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 externvoid_writeb(unsignedcharb, unsignedlongaddr);
98 externvoid_writew(unsignedshortb, unsignedlongaddr);
99
100 /* 101 * The platform header files may define some of these macros to use 102 * the inlined versions where appropriate. These macros may also be 103 * redefined by userlevel programs. 104 */ 105 #ifndefinb 106 # defineinb(p) _inb((p))
107 #endif 108 #ifndefinw 109 # defineinw(p) _inw((p))
110 #endif 111 #ifndefinl 112 # defineinl(p) _inl((p))
113 #endif 114 #ifndefoutb 115 # defineoutb(b,p) _outb((b),(p))
116 #endif 117 #ifndefoutw 118 # defineoutw(w,p) _outw((w),(p))
119 #endif 120 #ifndefoutl 121 # defineoutl(l,p) _outl((l),(p))
122 #endif 123
124 #ifndefinb_p 125 # defineinb_pinb 126 #endif 127 #ifndefoutb_p 128 # defineoutb_poutb 129 #endif 130
131 #ifndefinw_p 132 # defineinw_pinw 133 #endif 134 #ifndefoutw_p 135 # defineoutw_poutw 136 #endif 137
138 #ifndefinl_p 139 # defineinl_pinl 140 #endif 141 #ifndefoutl_p 142 # defineoutl_poutl 143 #endif 144
145 /* 146 * The "address" in IO memory space is not clearly either a integer or a 147 * pointer. We will accept both, thus the casts. 148 */ 149 #ifndefreadb 150 # definereadb(a) _readb((unsignedlong)(a))
151 #endif 152 #ifndefreadw 153 # definereadw(a) _readw((unsignedlong)(a))
154 #endif 155 #ifndefreadl 156 # definereadl(a) _readl((unsignedlong)(a))
157 #endif 158 #ifndefwriteb 159 # definewriteb(v,a) _writeb((v),(unsignedlong)(a))
160 #endif 161 #ifndefwritew 162 # definewritew(v,a) _writew((v),(unsignedlong)(a))
163 #endif 164 #ifndefwritel 165 # definewritel(v,a) _writel((v),(unsignedlong)(a))
166 #endif 167
168 #ifdef__KERNEL__ 169
170 /* 171 * String version of IO memory access ops: 172 */ 173 externvoid_memcpy_fromio(void *, unsignedlong, unsignedlong);
174 externvoid_memcpy_toio(unsignedlong, void *, unsignedlong);
175 externvoid_memset_io(unsignedlong, int, unsignedlong);
176
177 #definememcpy_fromio(to,from,len) _memcpy_fromio((to),(unsignedlong)(from),(len))
178 #definememcpy_toio(to,from,len) _memcpy_toio((unsignedlong)(to),(from),(len))
179 #definememset_io(addr,c,len) _memset_io((unsignedlong)(addr),(c),(len))
180
181 /* 182 * String versions of in/out ops: 183 */ 184 externvoidinsb (unsignedlongport, void *dst, unsignedlongcount);
185 externvoidinsw (unsignedlongport, void *dst, unsignedlongcount);
186 externvoidinsl (unsignedlongport, void *dst, unsignedlongcount);
187 externvoidoutsb (unsignedlongport, constvoid *src, unsignedlongcount);
188 externvoidoutsw (unsignedlongport, constvoid *src, unsignedlongcount);
189 externvoidoutsl (unsignedlongport, constvoid *src, unsignedlongcount);
190
191 /* 192 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 193 * just copy it. The net code will then do the checksum later. Presently 194 * only used by some shared memory 8390 ethernet cards anyway. 195 */ 196
197 #defineeth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
198
199 #endif/* __KERNEL__ */ 200
201 #endif