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 #ifdefCONFIG_PCI 88 #include <asm/lca.h> /* get chip-specific definitions */ 89 #else 90 #include <asm/jensen.h>
91 #endif 92
93 /* 94 * String version of IO memory access ops: 95 */ 96 externvoidmemcpy_fromio(void *, unsignedlong, unsignedlong);
97 externvoidmemcpy_toio(unsignedlong, void *, unsignedlong);
98 externvoidmemset_io(unsignedlong, int, unsignedlong);
99
100 /* 101 * String versions of in/out ops: 102 */ 103 externvoidinsb (unsignedlongport, void *src, unsignedlongcount);
104 externvoidinsw (unsignedlongport, void *src, unsignedlongcount);
105 externvoidinsl (unsignedlongport, void *src, unsignedlongcount);
106 externvoidoutsb (unsignedlongport, void *dst, unsignedlongcount);
107 externvoidoutsw (unsignedlongport, void *dst, unsignedlongcount);
108 externvoidoutsl (unsignedlongport, void *dst, unsignedlongcount);
109
110 /* 111 * The "address" in IO memory space is not clearly either a integer or a 112 * pointer. We will accept both, thus the casts. 113 */ 114 #definereadb(addr) ((unsignedchar) (readb)((unsignedlong)(addr)))
115 #definereadw(addr) ((unsignedshort) (readw)((unsignedlong)(addr)))
116 #definereadl(addr) ((unsignedint) (readl)((unsignedlong)(addr)))
117
118 #definewriteb(b,addr) (writeb)((b),(unsignedlong)(addr))
119 #definewritew(w,addr) (writew)((w),(unsignedlong)(addr))
120 #definewritel(l,addr) (writel)((l),(unsignedlong)(addr))
121
122 #definememset_io(addr,c,len) (memset_io)((unsignedlong)(addr),(c),(len))
123 #definememcpy_fromio(to,from,len) (memcpy_fromio)((to),(unsignedlong)(from),(len))
124 #definememcpy_toio(to,from,len) (memcpy_toio)((unsignedlong)(to),(from),(len))
125
126 #endif