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 externunsignedint_inb (unsignedlongport);
65 externunsignedint_inw (unsignedlongport);
66 externunsignedint_inl (unsignedlongport);
67 externvoid_outb (unsignedcharb,unsignedlongport);
68 externvoid_outw (unsignedshortw,unsignedlongport);
69 externvoid_outl (unsignedintl,unsignedlongport);
70
71 #ifndefinb 72 # defineinb(p) _inb((p))
73 # defineinw(p) _inw((p))
74 # defineinl(p) _inl((p))
75 # defineoutb(b,p) _outb((b),(p))
76 # defineoutw(w,p) _outw((w),(p))
77 # defineoutl(l,p) _outl((l),(p))
78 #endif 79
80 #endif/* !__KERNEL__ */ 81
82 /* 83 * There are different version of the alpha motherboards: the 84 * "interesting" (read: slightly braindead) Jensen type hardware 85 * and the PCI version 86 */ 87 #ifdefined(CONFIG_ALPHA_LCA)
88 # include <asm/lca.h> /* get chip-specific definitions */ 89 #elifdefined(CONFIG_ALPHA_APECS)
90 # include <asm/apecs.h> /* get chip-specific definitions */ 91 #else 92 # include <asm/jensen.h>
93 #endif 94
95 #ifdef__KERNEL__ 96
97 /* 98 * String version of IO memory access ops: 99 */ 100 externvoidmemcpy_fromio(void *, unsignedlong, unsignedlong);
101 externvoidmemcpy_toio(unsignedlong, void *, unsignedlong);
102 externvoidmemset_io(unsignedlong, int, unsignedlong);
103
104 /* 105 * String versions of in/out ops: 106 */ 107 externvoidinsb (unsignedlongport, void *src, unsignedlongcount);
108 externvoidinsw (unsignedlongport, void *src, unsignedlongcount);
109 externvoidinsl (unsignedlongport, void *src, unsignedlongcount);
110 externvoidoutsb (unsignedlongport, void *dst, unsignedlongcount);
111 externvoidoutsw (unsignedlongport, void *dst, unsignedlongcount);
112 externvoidoutsl (unsignedlongport, void *dst, unsignedlongcount);
113
114 /* 115 * The "address" in IO memory space is not clearly either a integer or a 116 * pointer. We will accept both, thus the casts. 117 */ 118 #definereadb(addr) ((unsignedchar) (readb)((unsignedlong)(addr)))
119 #definereadw(addr) ((unsignedshort) (readw)((unsignedlong)(addr)))
120 #definereadl(addr) ((unsignedint) (readl)((unsignedlong)(addr)))
121
122 #definewriteb(b,addr) (writeb)((b),(unsignedlong)(addr))
123 #definewritew(w,addr) (writew)((w),(unsignedlong)(addr))
124 #definewritel(l,addr) (writel)((l),(unsignedlong)(addr))
125
126 #definememset_io(addr,c,len) (memset_io)((unsignedlong)(addr),(c),(len))
127 #definememcpy_fromio(to,from,len) (memcpy_fromio)((to),(unsignedlong)(from),(len))
128 #definememcpy_toio(to,from,len) (memcpy_toio)((unsignedlong)(to),(from),(len))
129
130 /* 131 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 132 * just copy it. The net code will then do the checksum later. Presently 133 * only used by some shared memory 8390 ethernet cards anyway. 134 */ 135
136 #defineeth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
137
138 #endif/* __KERNEL__ */ 139
140 #endif