1 #ifndef__ALPHA_IO_H 2 #define__ALPHA_IO_H 3
4 #include <linux/config.h>
5
6 #include <asm/system.h>
7
8 /* We don't use IO slowdowns on the alpha, but.. */ 9 #define__SLOW_DOWN_IOdo{}while (0)
10 #defineSLOW_DOWN_IOdo{}while (0)
11
12 /* 13 * The hae (hardware address extension) register is used to 14 * access high IO addresses. To avoid doing an external cycle 15 * every time we need to set the hae, we have a hae cache in 16 * memory. The kernel entry code makes sure that the hae is 17 * preserved across interrupts, so it is safe to set the hae 18 * once and then depend on it staying the same in kernel code. 19 */ 20 externstructhae{ 21 unsignedlongcache;
22 unsignedlong *reg;
23 }hae;
24
25 /* 26 * Virtual -> physical identity mapping starts at this offset 27 */ 28 #defineIDENT_ADDR (0xfffffc0000000000UL)
29
30 #ifdef__KERNEL__ 31
32 /* 33 * We try to avoid hae updates (thus the cache), but when we 34 * do need to update the hae, we need to do it atomically, so 35 * that any interrupts wouldn't get confused with the hae 36 * register not being up-to-date with respect to the hardware 37 * value. 38 */ 39 externinlinevoidset_hae(unsignedlongnew_hae)
/* */ 40 { 41 unsignedlongipl = swpipl(7);
42 hae.cache = new_hae;
43 *hae.reg = new_hae;
44 mb();
45 setipl(ipl);
46 } 47
48 /* 49 * Change virtual addresses to physical addresses and vv. 50 */ 51 externinlineunsignedlongvirt_to_phys(volatilevoid * address)
/* */ 52 { 53 return 0xffffffffUL & (unsignedlong) address;
54 } 55
56 externinlinevoid * phys_to_virt(unsignedlongaddress)
/* */ 57 { 58 return (void *) (address + IDENT_ADDR);
59 } 60
61 #else/* !__KERNEL__ */ 62
63 /* 64 * Define actual functions in private name-space so it's easier to 65 * accommodate things like XFree or svgalib that like to define their 66 * own versions of inb etc. 67 */ 68 externvoid __sethae (unsignedlongaddr); /* syscall */ 69 externvoid _sethae (unsignedlongaddr); /* cached version */ 70
71 #endif/* !__KERNEL__ */ 72
73 /* 74 * There are different version of the Alpha PC motherboards: 75 */ 76 #ifdefined(CONFIG_ALPHA_LCA)
77 # include <asm/lca.h> /* get chip-specific definitions */ 78 #elifdefined(CONFIG_ALPHA_APECS)
79 # include <asm/apecs.h> /* get chip-specific definitions */ 80 #elifdefined(CONFIG_ALPHA_ALCOR)
81 # include <asm/alcor.h> /* get chip-specific definitions */ 82 #else 83 # include <asm/jensen.h>
84 #endif 85
86 /* 87 * The convention used for inb/outb etc. is that names starting with 88 * two underscores are the inline versions, names starting with a 89 * single underscore are proper functions, and names starting with a 90 * letter are macros that map in some way to inline or proper function 91 * versions. Not all that pretty, but before you change it, be sure 92 * to convince yourself that it won't break anything (in particular 93 * module support). 94 */ 95 externunsignedint_inb (unsignedlongport);
96 externunsignedint_inw (unsignedlongport);
97 externunsignedint_inl (unsignedlongport);
98 externvoid_outb (unsignedcharb,unsignedlongport);
99 externvoid_outw (unsignedshortw,unsignedlongport);
100 externvoid_outl (unsignedintl,unsignedlongport);
101 externunsignedlong_readb(unsignedlongaddr);
102 externunsignedlong_readw(unsignedlongaddr);
103 externunsignedlong_readl(unsignedlongaddr);
104 externvoid_writeb(unsignedcharb, unsignedlongaddr);
105 externvoid_writew(unsignedshortb, unsignedlongaddr);
106 externvoid_writel(unsignedintb, unsignedlongaddr);
107
108 /* 109 * The platform header files may define some of these macros to use 110 * the inlined versions where appropriate. These macros may also be 111 * redefined by userlevel programs. 112 */ 113 #ifndefinb 114 # defineinb(p) _inb((p))
115 #endif 116 #ifndefinw 117 # defineinw(p) _inw((p))
118 #endif 119 #ifndefinl 120 # defineinl(p) _inl((p))
121 #endif 122 #ifndefoutb 123 # defineoutb(b,p) _outb((b),(p))
124 #endif 125 #ifndefoutw 126 # defineoutw(w,p) _outw((w),(p))
127 #endif 128 #ifndefoutl 129 # defineoutl(l,p) _outl((l),(p))
130 #endif 131
132 #ifndefinb_p 133 # defineinb_pinb 134 #endif 135 #ifndefinw_p 136 # defineinw_pinw 137 #endif 138 #ifndefinl_p 139 # defineinl_pinl 140 #endif 141
142 #ifndefoutb_p 143 # defineoutb_poutb 144 #endif 145 #ifndefoutw_p 146 # defineoutw_poutw 147 #endif 148 #ifndefoutl_p 149 # defineoutl_poutl 150 #endif 151
152 /* 153 * The "address" in IO memory space is not clearly either a integer or a 154 * pointer. We will accept both, thus the casts. 155 */ 156 #ifndefreadb 157 # definereadb(a) _readb((unsignedlong)(a))
158 #endif 159 #ifndefreadw 160 # definereadw(a) _readw((unsignedlong)(a))
161 #endif 162 #ifndefreadl 163 # definereadl(a) _readl((unsignedlong)(a))
164 #endif 165 #ifndefwriteb 166 # definewriteb(v,a) _writeb((v),(unsignedlong)(a))
167 #endif 168 #ifndefwritew 169 # definewritew(v,a) _writew((v),(unsignedlong)(a))
170 #endif 171 #ifndefwritel 172 # definewritel(v,a) _writel((v),(unsignedlong)(a))
173 #endif 174
175 #ifdef__KERNEL__ 176
177 /* 178 * String version of IO memory access ops: 179 */ 180 externvoid_memcpy_fromio(void *, unsignedlong, unsignedlong);
181 externvoid_memcpy_toio(unsignedlong, void *, unsignedlong);
182 externvoid_memset_io(unsignedlong, int, unsignedlong);
183
184 #definememcpy_fromio(to,from,len) _memcpy_fromio((to),(unsignedlong)(from),(len))
185 #definememcpy_toio(to,from,len) _memcpy_toio((unsignedlong)(to),(from),(len))
186 #definememset_io(addr,c,len) _memset_io((unsignedlong)(addr),(c),(len))
187
188 /* 189 * String versions of in/out ops: 190 */ 191 externvoidinsb (unsignedlongport, void *dst, unsignedlongcount);
192 externvoidinsw (unsignedlongport, void *dst, unsignedlongcount);
193 externvoidinsl (unsignedlongport, void *dst, unsignedlongcount);
194 externvoidoutsb (unsignedlongport, constvoid *src, unsignedlongcount);
195 externvoidoutsw (unsignedlongport, constvoid *src, unsignedlongcount);
196 externvoidoutsl (unsignedlongport, constvoid *src, unsignedlongcount);
197
198 /* 199 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 200 * just copy it. The net code will then do the checksum later. Presently 201 * only used by some shared memory 8390 ethernet cards anyway. 202 */ 203
204 #defineeth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
205
206 #endif/* __KERNEL__ */ 207
208 #endif