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