root/drivers/net/iow.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __outw
  2. __outwc
  3. __inw
  4. __inwc
  5. __outw_p
  6. __outwc_p
  7. __inw_p
  8. __inwc_p

   1 #ifndef _ASM_IOW_H
   2 #define _ASM_IOW_H
   3 /* I added a few.  Please add to the distributed files. -djb. */
   4 /* This file is copied 1:1 from /linux/include/asm/io.h, and changed all
   5    al to ax, all inb to inw and all outb to outw (to get word in/out)
   6    the four inlines here should be added to the original, and
   7    then this one rm'd (and the #include "iow.h" in depca.c removed)... 
   8    Gruss PB 
   9 */
  10 /*
  11  * Thanks to James van Artsdalen for a better timing-fix than
  12  * the two short jumps: using outb's to a nonexistent port seems
  13  * to guarantee better timings even on fast machines.
  14  *
  15  * On the other hand, I'd like to be sure of a non-existent port:
  16  * I feel a bit unsafe abou using 0x80.
  17  *
  18  *              Linus
  19  */
  20 
  21 /* This is the more general version of outw.. */
  22 extern inline void __outw(unsigned short value, unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24 __asm__ __volatile__ ("outw %w0,%w1"
  25                 : /* no outputs */
  26                 :"a" (value),"d" (port));
  27 }
  28 
  29 /* this is used for constant port numbers < 256.. */
  30 extern inline void __outwc(unsigned short value, unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  31 {
  32 __asm__ __volatile__ ("outw %w0,%1"
  33                 : /* no outputs */
  34                 :"a" (value),"i" (port));
  35 }
  36 
  37 /* general version of inw */
  38 extern inline unsigned int __inw(unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  39 {
  40         unsigned int _v;
  41 __asm__ __volatile__ ("inw %w1,%w0"
  42                 :"=a" (_v):"d" (port),"0" (0));
  43         return _v;
  44 }
  45 
  46 /* inw with constant port nr 0-255 */
  47 extern inline unsigned int __inwc(unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  48 {
  49         unsigned int _v;
  50 __asm__ __volatile__ ("inw %1,%w0"
  51                 :"=a" (_v):"i" (port),"0" (0));
  52         return _v;
  53 }
  54 
  55 extern inline void __outw_p(unsigned short value, unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  56 {
  57 __asm__ __volatile__ ("outw %w0,%w1"
  58                 : /* no outputs */
  59                 :"a" (value),"d" (port));
  60         SLOW_DOWN_IO;
  61 }
  62 
  63 extern inline void __outwc_p(unsigned short value, unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  64 {
  65 __asm__ __volatile__ ("outw %w0,%1"
  66                 : /* no outputs */
  67                 :"a" (value),"i" (port));
  68         SLOW_DOWN_IO;
  69 }
  70 
  71 extern inline unsigned int __inw_p(unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  72 {
  73         unsigned int _v;
  74 __asm__ __volatile__ ("inw %w1,%w0"
  75                 :"=a" (_v):"d" (port),"0" (0));
  76         SLOW_DOWN_IO;
  77         return _v;
  78 }
  79 
  80 extern inline unsigned int __inwc_p(unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  81 {
  82         unsigned int _v;
  83 __asm__ __volatile__ ("inw %1,%w0"
  84                 :"=a" (_v):"i" (port),"0" (0));
  85         SLOW_DOWN_IO;
  86         return _v;
  87 }
  88 
  89 /*
  90  * Note that due to the way __builtin_constant_p() works, you
  91  *  - can't use it inside a inlien function (it will never be true)
  92  *  - you don't have to worry about side effects within the __builtin..
  93  */
  94 #define outw(val,port) \
  95 ((__builtin_constant_p((port)) && (port) < 256) ? \
  96         __outwc((val),(port)) : \
  97         __outw((val),(port)))
  98 
  99 #define inw(port) \
 100 ((__builtin_constant_p((port)) && (port) < 256) ? \
 101         __inwc(port) : \
 102         __inw(port))
 103 
 104 #define outw_p(val,port) \
 105 ((__builtin_constant_p((port)) && (port) < 256) ? \
 106         __outwc_p((val),(port)) : \
 107         __outw_p((val),(port)))
 108 
 109 #define inw_p(port) \
 110 ((__builtin_constant_p((port)) && (port) < 256) ? \
 111         __inwc_p(port) : \
 112         __inw_p(port))
 113 
 114 #endif
 115 
 116 /* The word-wide I/O operations are more general, but require a halved
 117    count.  */
 118 #define port_read(port,buf,nr) \
 119 __asm__("cld;rep;insw": :"d" (port),"D" (buf),"c" (nr):"cx","di")
 120 #define port_write(port,buf,nr) \
 121 __asm__("cld;rep;outsw": :"d" (port),"S" (buf),"c" (nr):"cx","si")
 122 
 123 #define port_read_b(port,buf,nr) \
 124 __asm__("cld;rep;insb": :"d" (port),"D" (buf),"c" (nr):"cx","di")
 125 #define port_write_b(port,buf,nr) \
 126 __asm__("cld;rep;outsb": :"d" (port),"S" (buf),"c" (nr):"cx","si")

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