First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / os-support / misc / SlowBcopy.c
blob5cd7168235c58054a4a669d15e00bc2c43d0869e
1 /*******************************************************************************
2 for Alpha Linux
3 *******************************************************************************/
5 /*
6 * Create a dependency that should be immune from the effect of register
7 * renaming as is commonly seen in superscalar processors. This should
8 * insert a minimum of 100-ns delays between reads/writes at clock rates
9 * up to 100 MHz---GGL
11 * Slowbcopy(char *src, char *dst, int count)
13 */
15 #ifdef HAVE_XORG_CONFIG_H
16 #include <xorg-config.h>
17 #endif
19 #include <X11/X.h>
20 #include "xf86.h"
21 #include "xf86Priv.h"
22 #include "xf86_OSlib.h"
23 #include "compiler.h"
25 static int really_slow_bcopy;
27 _X_EXPORT void
28 xf86SetReallySlowBcopy(void)
30 really_slow_bcopy = 1;
33 #if defined(__i386__) || defined(__x86_64__)
34 static void xf86_really_slow_bcopy(unsigned char *src, unsigned char *dst, int len)
36 while(len--)
38 *dst++ = *src++;
39 outb(0x80, 0x00);
42 #endif
44 /* The outb() isn't needed on my machine, but who knows ... -- ost */
45 _X_EXPORT void
46 xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len)
48 #if defined(__i386__) || defined(__x86_64__)
49 if (really_slow_bcopy) {
50 xf86_really_slow_bcopy(src, dst, len);
51 return;
53 #endif
54 while(len--)
55 *dst++ = *src++;
58 #ifdef __alpha__
60 * The Jensen lacks dense memory, thus we have to address the bus via
61 * the sparse addressing scheme. Time critical code uses routines from
62 * BUSmemcpy.c
64 * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
67 #ifdef linux
69 unsigned long _bus_base(void);
71 #ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */
72 #define SPARSE (5)
73 #else
74 #define SPARSE (7)
75 #endif
77 #define isJensen() (!_bus_base())
79 #else
81 #define isJensen() 0
82 #define SPARSE 0
84 #endif
86 _X_EXPORT void
87 xf86SlowBCopyFromBus(unsigned char *src, unsigned char *dst, int count)
89 if (isJensen())
91 unsigned long addr;
92 long result;
94 addr = (unsigned long) src;
95 while( count ){
96 result = *(volatile int *) addr;
97 result >>= ((addr>>SPARSE) & 3) * 8;
98 *dst++ = (unsigned char) (0xffUL & result);
99 addr += 1<<SPARSE;
100 count--;
101 outb(0x80, 0x00);
104 else
105 xf86SlowBcopy(src,dst,count);
108 _X_EXPORT void
109 xf86SlowBCopyToBus(unsigned char *src, unsigned char *dst, int count)
111 if (isJensen())
113 unsigned long addr;
115 addr = (unsigned long) dst;
116 while(count) {
117 *(volatile unsigned int *) addr = (unsigned short)(*src) * 0x01010101;
118 src++;
119 addr += 1<<SPARSE;
120 count--;
121 outb(0x80, 0x00);
124 else
125 xf86SlowBcopy(src,dst,count);
127 #endif