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 #else 77 # include <asm/jensen.h>
78 #endif 79
80 /* 81 * The convention used for inb/outb etc. is that names starting with 82 * two underscores are the inline versions, names starting with a 83 * single underscore are proper functions, and names starting with a 84 * letter are macros that map in some way to inline or proper function 85 * versions. Not all that pretty, but before you change it, be sure 86 * to convince yourself that it won't break anything (in particular 87 * module support). 88 */ 89 externunsignedint_inb (unsignedlongport);
90 externunsignedint_inw (unsignedlongport);
91 externunsignedint_inl (unsignedlongport);
92 externvoid_outb (unsignedcharb,unsignedlongport);
93 externvoid_outw (unsignedshortw,unsignedlongport);
94 externvoid_outl (unsignedintl,unsignedlongport);
95 externunsignedlong_readb(unsignedlongaddr);
96 externunsignedlong_readw(unsignedlongaddr);
97 externunsignedlong_readl(unsignedlongaddr);
98 externvoid_writeb(unsignedcharb, unsignedlongaddr);
99 externvoid_writew(unsignedshortb, unsignedlongaddr);
100 externvoid_writel(unsignedintb, unsignedlongaddr);
101
102 /* 103 * The platform header files may define some of these macros to use 104 * the inlined versions where appropriate. These macros may also be 105 * redefined by userlevel programs. 106 */ 107 #ifndefinb 108 # defineinb(p) _inb((p))
109 #endif 110 #ifndefinw 111 # defineinw(p) _inw((p))
112 #endif 113 #ifndefinl 114 # defineinl(p) _inl((p))
115 #endif 116 #ifndefoutb 117 # defineoutb(b,p) _outb((b),(p))
118 #endif 119 #ifndefoutw 120 # defineoutw(w,p) _outw((w),(p))
121 #endif 122 #ifndefoutl 123 # defineoutl(l,p) _outl((l),(p))
124 #endif 125
126 #ifndefinb_p 127 # defineinb_pinb 128 #endif 129 #ifndefinw_p 130 # defineinw_pinw 131 #endif 132 #ifndefinl_p 133 # defineinl_pinl 134 #endif 135 #ifndefoutb_p 136 # defineoutb_poutb 137 #endif 138 #ifndefoutw_p 139 # defineoutw_poutw 140 #endif 141 #ifndefoutl_p 142 # defineoutl_poutl 143 #endif 144
145 #ifndefinw_p 146 # defineinw_pinw 147 #endif 148 #ifndefoutw_p 149 # defineoutw_poutw 150 #endif 151
152 #ifndefinl_p 153 # defineinl_pinl 154 #endif 155 #ifndefoutl_p 156 # defineoutl_poutl 157 #endif 158
159 /* 160 * The "address" in IO memory space is not clearly either a integer or a 161 * pointer. We will accept both, thus the casts. 162 */ 163 #ifndefreadb 164 # definereadb(a) _readb((unsignedlong)(a))
165 #endif 166 #ifndefreadw 167 # definereadw(a) _readw((unsignedlong)(a))
168 #endif 169 #ifndefreadl 170 # definereadl(a) _readl((unsignedlong)(a))
171 #endif 172 #ifndefwriteb 173 # definewriteb(v,a) _writeb((v),(unsignedlong)(a))
174 #endif 175 #ifndefwritew 176 # definewritew(v,a) _writew((v),(unsignedlong)(a))
177 #endif 178 #ifndefwritel 179 # definewritel(v,a) _writel((v),(unsignedlong)(a))
180 #endif 181
182 #ifdef__KERNEL__ 183
184 /* 185 * String version of IO memory access ops: 186 */ 187 externvoid_memcpy_fromio(void *, unsignedlong, unsignedlong);
188 externvoid_memcpy_toio(unsignedlong, void *, unsignedlong);
189 externvoid_memset_io(unsignedlong, int, unsignedlong);
190
191 #definememcpy_fromio(to,from,len) _memcpy_fromio((to),(unsignedlong)(from),(len))
192 #definememcpy_toio(to,from,len) _memcpy_toio((unsignedlong)(to),(from),(len))
193 #definememset_io(addr,c,len) _memset_io((unsignedlong)(addr),(c),(len))
194
195 /* 196 * String versions of in/out ops: 197 */ 198 externvoidinsb (unsignedlongport, void *dst, unsignedlongcount);
199 externvoidinsw (unsignedlongport, void *dst, unsignedlongcount);
200 externvoidinsl (unsignedlongport, void *dst, unsignedlongcount);
201 externvoidoutsb (unsignedlongport, constvoid *src, unsignedlongcount);
202 externvoidoutsw (unsignedlongport, constvoid *src, unsignedlongcount);
203 externvoidoutsl (unsignedlongport, constvoid *src, unsignedlongcount);
204
205 /* 206 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 207 * just copy it. The net code will then do the checksum later. Presently 208 * only used by some shared memory 8390 ethernet cards anyway. 209 */ 210
211 #defineeth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
212
213 #endif/* __KERNEL__ */ 214
215 #endif