root/arch/alpha/lib/io.c

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

DEFINITIONS

This source file includes following definitions.
  1. _bus_inb
  2. _bus_outb
  3. _inb
  4. _inw
  5. _inl
  6. _outb
  7. _outw
  8. _outl
  9. _readb
  10. _readw
  11. _readl
  12. _writeb
  13. _writew
  14. _writel
  15. insb
  16. insw
  17. insl
  18. outsb
  19. outsw
  20. outsl
  21. _memcpy_fromio
  22. _memcpy_toio
  23. _memset_io

   1 /*
   2  * Alpha IO and memory functions.. Just expand the inlines in the header
   3  * files..
   4  */
   5 #include <linux/kernel.h>
   6 
   7 #include <asm/io.h>
   8 
   9 /* 
  10  * Jensen has a separate "local" and "bus" IO space for
  11  * byte-wide IO.
  12  */
  13 #ifdef __is_local
  14 
  15 unsigned int _bus_inb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  16 {
  17         return __bus_inb(addr);
  18 }
  19 
  20 void _bus_outb(unsigned char b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  21 {
  22         __bus_outb(b, addr);
  23 }
  24 #endif
  25 
  26 unsigned int _inb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  27 {
  28         return __inb(addr);
  29 }
  30 
  31 unsigned int _inw(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  32 {
  33         return __inw(addr);
  34 }
  35 
  36 unsigned int _inl(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  37 {
  38         return __inl(addr);
  39 }
  40 
  41 
  42 void _outb(unsigned char b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  43 {
  44         __outb(b, addr);
  45 }
  46 
  47 void _outw(unsigned short b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  48 {
  49         __outw(b, addr);
  50 }
  51 
  52 void _outl(unsigned int b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  53 {
  54         __outl(b, addr);
  55 }
  56 
  57 
  58 unsigned long _readb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  59 {
  60         return __readb(addr);
  61 }
  62 
  63 unsigned long _readw(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  64 {
  65         return __readw(addr);
  66 }
  67 
  68 unsigned long _readl(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  69 {
  70         return __readl(addr);
  71 }
  72 
  73 
  74 void _writeb(unsigned char b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  75 {
  76         __writeb(b, addr);
  77 }
  78 
  79 void _writew(unsigned short b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  80 {
  81         __writew(b, addr);
  82 }
  83 
  84 void _writel(unsigned int b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  85 {
  86         __writel(b, addr);
  87 }
  88 
  89 /*
  90  * Read COUNT 8-bit bytes from port PORT into memory starting at
  91  * SRC.
  92  */
  93 void insb (unsigned long port, void *dst, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
  94 {
  95         while (((unsigned long)dst) & 0x3) {
  96                 if (!count)
  97                         return;
  98                 count--;
  99                 *(unsigned char *) dst = inb(port);
 100                 ((unsigned char *) dst)++;
 101         }
 102 
 103         while (count >= 4) {
 104                 unsigned int w;
 105                 count -= 4;
 106                 w = inb(port);
 107                 w |= inb(port) << 8;
 108                 w |= inb(port) << 16;
 109                 w |= inb(port) << 24;
 110                 *(unsigned int *) dst = w;
 111                 ((unsigned int *) dst)++;
 112         }
 113 
 114         while (count) {
 115                 --count;
 116                 *(unsigned char *) dst = inb(port);
 117                 ((unsigned char *) dst)++;
 118         }
 119 }
 120 
 121 
 122 /*
 123  * Read COUNT 16-bit words from port PORT into memory starting at
 124  * SRC.  SRC must be at least short aligned.  This is used by the
 125  * IDE driver to read disk sectors.  Performance is important, but
 126  * the interfaces seems to be slow: just using the inlined version
 127  * of the inw() breaks things.
 128  */
 129 void insw (unsigned long port, void *dst, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
 130 {
 131         if (((unsigned long)dst) & 0x3) {
 132                 if (((unsigned long)dst) & 0x1) {
 133                         panic("insw: memory not short aligned");
 134                 }
 135                 if (!count)
 136                         return;
 137                 count--;
 138                 *(unsigned short* ) dst = inw(port);
 139                 ((unsigned short *) dst)++;
 140         }
 141 
 142         while (count >= 2) {
 143                 unsigned int w;
 144                 count -= 2;
 145                 w = inw(port);
 146                 w |= inw(port) << 16;
 147                 *(unsigned int *) dst = w;
 148                 ((unsigned int *) dst)++;
 149         }
 150 
 151         if (count) {
 152                 *(unsigned short*) dst = inw(port);
 153         }
 154 }
 155 
 156 
 157 /*
 158  * Read COUNT 32-bit words from port PORT into memory starting at
 159  * SRC.  SRC must be at least word aligned.  This is used by the
 160  * IDE driver to read disk sectors.  Performance is important, but
 161  * the interfaces seems to be slow: just using the inlined version
 162  * of the inw() breaks things.
 163  */
 164 void insl (unsigned long port, void *dst, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
 165 {
 166         if (((unsigned long)dst) & 0x3) {
 167                 panic("insl: memory not aligned");
 168         }
 169 
 170         while (count) {
 171                 --count;
 172                 *(unsigned int *) dst = inl(port);
 173                 ((unsigned int *) dst)++;
 174         }
 175 }
 176 
 177 /*
 178  * Like insb but in the opposite direction.
 179  * Don't worry as much about doing aligned memory transfers:
 180  * doing byte reads the "slow" way isn't nearly as slow as
 181  * doing byte writes the slow way (no r-m-w cycle).
 182  */
 183 void outsb(unsigned long port, const void * src, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
 184 {
 185         while (count) {
 186                 count--;
 187                 outb(*(char *)src, port);
 188                 ((char *) src)++;
 189         }
 190 }
 191 
 192 /*
 193  * Like insw but in the opposite direction.  This is used by the IDE
 194  * driver to write disk sectors.  Performance is important, but the
 195  * interfaces seems to be slow: just using the inlined version of the
 196  * outw() breaks things.
 197  */
 198 void outsw (unsigned long port, const void *src, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
 199 {
 200         if (((unsigned long)src) & 0x3) {
 201                 if (((unsigned long)src) & 0x1) {
 202                         panic("outsw: memory not short aligned");
 203                 }
 204                 outw(*(unsigned short*)src, port);
 205                 ((unsigned short *) src)++;
 206                 --count;
 207         }
 208 
 209         while (count >= 2) {
 210                 unsigned int w;
 211                 count -= 2;
 212                 w = *(unsigned int *) src;
 213                 ((unsigned int *) src)++;
 214                 outw(w >>  0, port);
 215                 outw(w >> 16, port);
 216         }
 217 
 218         if (count) {
 219                 outw(*(unsigned short *) src, port);
 220         }
 221 }
 222 
 223 
 224 /*
 225  * Like insl but in the opposite direction.  This is used by the IDE
 226  * driver to write disk sectors.  Performance is important, but the
 227  * interfaces seems to be slow: just using the inlined version of the
 228  * outw() breaks things.
 229  */
 230 void outsl (unsigned long port, const void *src, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
 231 {
 232         if (((unsigned long)src) & 0x3) {
 233                 panic("outsw: memory not aligned");
 234         }
 235 
 236         while (count) {
 237                 --count;
 238                 outl(*(unsigned int *) src, port);
 239                 ((unsigned int *) src)++;
 240         }
 241 }
 242 
 243 
 244 /*
 245  * Copy data from IO memory space to "real" memory space.
 246  * This needs to be optimized.
 247  */
 248 void _memcpy_fromio(void * to, unsigned long from, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
 249 {
 250         while (count) {
 251                 count--;
 252                 *(char *) to = readb(from);
 253                 ((char *) to)++;
 254                 from++;
 255         }
 256 }
 257 
 258 /*
 259  * Copy data from "real" memory space to IO memory space.
 260  * This needs to be optimized.
 261  */
 262 void _memcpy_toio(unsigned long to, void * from, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
 263 {
 264         while (count) {
 265                 count--;
 266                 writeb(*(char *) from, to);
 267                 ((char *) from)++;
 268                 to++;
 269         }
 270 }
 271 
 272 /*
 273  * "memset" on IO memory space.
 274  * This needs to be optimized.
 275  */
 276 void _memset_io(unsigned long dst, int c, unsigned long count)
     /* [previous][next][first][last][top][bottom][index][help] */
 277 {
 278         while (count) {
 279                 count--;
 280                 writeb(c, dst);
 281                 dst++;
 282         }
 283 }

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