root/include/asm-alpha/io.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __local_inb
  2. __local_outb
  3. __inb
  4. __outb
  5. __is_local
  6. inb
  7. outb
  8. inw
  9. outw
  10. outl
  11. readb
  12. readw
  13. readl
  14. writeb
  15. writew
  16. writel

   1 #ifndef __ALPHA_IO_H
   2 #define __ALPHA_IO_H
   3 
   4 /*
   5  * Defines for the AlphaPC EISA IO and memory address space.
   6  */
   7 
   8 #ifndef mb
   9 #define mb() __asm__ __volatile__("mb": : :"memory")
  10 #endif
  11 
  12 /*
  13  * NOTE! Currently it never uses the HAE register, so these work only
  14  * for the low 25 bits of EISA addressing.  That covers all of the IO
  15  * address space (16 bits), and most of the "normal" EISA memory space.
  16  * I'll fix it eventually, but I'll need to come up with a clean way
  17  * to handle races with interrupt services wanting to change HAE...
  18  */
  19 
  20 /*
  21  * NOTE 2! The memory operations do not set any memory barriers, as it's
  22  * not needed for cases like a frame buffer that is essentially memory-like.
  23  * You need to do them by hand if the operations depend on ordering.
  24  *
  25  * Similarly, the port IO operations do a "mb" only after a write operation:
  26  * if an mb is needed before (as in the case of doing memory mapped IO
  27  * first, and then a port IO operation to the same device), it needs to be
  28  * done by hand.
  29  *
  30  * After the above has bitten me 100 times, I'll give up and just do the
  31  * mb all the time, but right now I'm hoping this will work out.  Avoiding
  32  * mb's may potentially be a noticeable speed improvement, but I can't
  33  * honestly say I've tested it.
  34  *
  35  * Handling interrupts that need to do mb's to synchronize to non-interrupts
  36  * is another fun race area.  Don't do it (because if you do, I'll have to
  37  * do *everything* with interrupts disabled, ugh).
  38  */
  39 
  40 /*
  41  * Virtual -> physical identity mapping starts at this offset
  42  */
  43 #define IDENT_ADDR      (0xfffffc0000000000UL)
  44 
  45 /*
  46  * EISA Interrupt Acknowledge address
  47  */
  48 #define EISA_INTA               (IDENT_ADDR + 0x100000000UL)
  49 
  50 /*
  51  * FEPROM addresses
  52  */
  53 #define EISA_FEPROM0            (IDENT_ADDR + 0x180000000UL)
  54 #define EISA_FEPROM1            (IDENT_ADDR + 0x1A0000000UL)
  55 
  56 /*
  57  * VL82C106 base address
  58  */
  59 #define EISA_VL82C106           (IDENT_ADDR + 0x1C0000000UL)
  60 
  61 /*
  62  * EISA "Host Address Extension" address (bits 25-31 of the EISA address)
  63  */
  64 #define EISA_HAE                (IDENT_ADDR + 0x1D0000000UL)
  65 
  66 /*
  67  * "SYSCTL" register address
  68  */
  69 #define EISA_SYSCTL             (IDENT_ADDR + 0x1E0000000UL)
  70 
  71 /*
  72  * "spare" register address
  73  */
  74 #define EISA_SPARE              (IDENT_ADDR + 0x1F0000000UL)
  75 
  76 /*
  77  * EISA memory address offset
  78  */
  79 #define EISA_MEM                (IDENT_ADDR + 0x200000000UL)
  80 
  81 /*
  82  * EISA IO address offset
  83  */
  84 #define EISA_IO                 (IDENT_ADDR + 0x300000000UL)
  85 
  86 /*
  87  * IO functions
  88  *
  89  * The "local" functions are those that don't go out to the EISA bus,
  90  * but instead act on the VL82C106 chip directly.. This is mainly the
  91  * keyboard, RTC,  printer and first two serial lines..
  92  *
  93  * The local stuff makes for some complications, but it seems to be
  94  * gone in the PCI version. I hope I can get DEC suckered^H^H^H^H^H^H^H^H
  95  * convinced that I need one of the newer machines.
  96  */
  97 extern inline unsigned int __local_inb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99         long result = *(volatile int *) ((addr << 9) + EISA_VL82C106);
 100         return 0xffUL & result;
 101 }
 102 
 103 extern inline void __local_outb(unsigned char b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 104 {
 105         *(volatile unsigned int *) ((addr << 9) + EISA_VL82C106) = b;
 106         mb();
 107 }
 108 
 109 extern inline unsigned int __inb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 110 {
 111         long result = *(volatile int *) ((addr << 7) + EISA_IO + 0x00);
 112         result >>= (addr & 3) * 8;
 113         return 0xffUL & result;
 114 }
 115 
 116 extern inline void __outb(unsigned char b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 117 {
 118         *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x00) = b * 0x01010101;
 119         mb();
 120 }
 121 
 122 /*
 123  * This is a stupid one: I'll make it a bitmap soon, promise..
 124  *
 125  * On the other hand: this allows gcc to optimize. Hmm. I'll
 126  * have to use the __constant_p() stuff here.
 127  *
 128  * The PCI version just returns zero all the time, I do believe..
 129  */
 130 extern inline int __is_local(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 131 {
 132         /* keyboard */
 133         if (addr == 0x60 || addr == 0x64)
 134                 return 1;
 135 
 136         /* RTC */
 137         if (addr == 0x170 || addr == 0x171)
 138                 return 1;
 139 
 140         /* motherboard COM2 */
 141         if (addr >= 0x2f8 && addr <= 0x2ff)
 142                 return 1;
 143 
 144         /* motherboard LPT1 */
 145         if (addr >= 0x3bc && addr <= 0x3be)
 146                 return 1;
 147 
 148         /* motherboard COM2 */
 149         if (addr >= 0x3f8 && addr <= 0x3ff)
 150                 return 1;
 151 
 152         return 0;
 153 }
 154 
 155 extern inline unsigned int inb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 156 {
 157         if (__is_local(addr))
 158                 return __local_inb(addr);
 159         return __inb(addr);
 160 }
 161 
 162 extern inline void outb(unsigned char b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 163 {
 164         if (__is_local(addr))
 165                 __local_outb(b, addr);
 166         else
 167                 __outb(b, addr);
 168 }
 169 
 170 extern inline unsigned int inw(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 171 {
 172         long result = *(volatile int *) ((addr << 7) + EISA_IO + 0x20);
 173         result >>= (addr & 3) * 8;
 174         return 0xffffUL & result;
 175 }
 176 
 177 extern inline unsigned int inl(unsigned long addr)
 178 {
 179         return *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x60);
 180 }
 181 
 182 extern inline void outw(unsigned short b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 183 {
 184         *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x20) = b * 0x00010001;
 185         mb();
 186 }
 187 
 188 extern inline void outl(unsigned int b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 189 {
 190         *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x60) = b;
 191         mb();
 192 }
 193 
 194 /*
 195  * Memory functions
 196  */
 197 extern inline unsigned long readb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 198 {
 199         long result = *(volatile int *) ((addr << 7) + EISA_MEM + 0x00);
 200         result >>= (addr & 3) * 8;
 201         return 0xffUL & result;
 202 }
 203 
 204 extern inline unsigned long readw(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 205 {
 206         long result = *(volatile int *) ((addr << 7) + EISA_MEM + 0x20);
 207         result >>= (addr & 3) * 8;
 208         return 0xffffUL & result;
 209 }
 210 
 211 extern inline unsigned long readl(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 212 {
 213         return *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x60);
 214 }
 215 
 216 extern inline void writeb(unsigned short b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 217 {
 218         *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x00) = b * 0x01010101;
 219 }
 220 
 221 extern inline void writew(unsigned short b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 222 {
 223         *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x20) = b * 0x00010001;
 224 }
 225 
 226 extern inline void writel(unsigned int b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 227 {
 228         *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x60) = b;
 229 }
 230 
 231 #define inb_p inb
 232 #define outb_p outb
 233 
 234 #endif

/* [previous][next][first][last][top][bottom][index][help] */