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

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