root/include/asm/io.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __outb
  2. __outbc
  3. __inb
  4. __inbc
  5. __outb_p
  6. __outbc_p
  7. __inb_p
  8. __inbc_p

   1 #ifndef _ASM_IO_H
   2 #define _ASM_IO_H
   3 
   4 /*
   5  * Thanks to James van Artsdalen for a better timing-fix than
   6  * the two short jumps: using outb's to a nonexistent port seems
   7  * to guarantee better timings even on fast machines.
   8  *
   9  * On the other hand, I'd like to be sure of a non-existent port:
  10  * I feel a bit unsafe about using 0x80.
  11  *
  12  *              Linus
  13  */
  14 
  15 #ifdef SLOW_IO_BY_JUMPING
  16 #define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
  17 #else
  18 #define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
  19 #endif
  20 
  21 #ifdef REALLY_SLOW_IO
  22 #define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
  23 #else
  24 #define SLOW_DOWN_IO __SLOW_DOWN_IO
  25 #endif
  26 
  27 /* This is the more general version of outb.. */
  28 extern inline void __outb(unsigned char value, unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  29 {
  30 __asm__ __volatile__ ("outb %b0,%w1"
  31                 : /* no outputs */
  32                 :"a" (value),"d" (port));
  33 }
  34 
  35 /* this is used for constant port numbers < 256.. */
  36 extern inline void __outbc(unsigned char value, unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  37 {
  38 __asm__ __volatile__ ("outb %b0,%1"
  39                 : /* no outputs */
  40                 :"a" (value),"i" (port));
  41 }
  42 
  43 /* general version of inb */
  44 extern inline unsigned int __inb(unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  45 {
  46         unsigned int _v;
  47 __asm__ __volatile__ ("inb %w1,%b0"
  48                 :"=a" (_v):"d" (port),"0" (0));
  49         return _v;
  50 }
  51 
  52 /* inb with constant port nr 0-255 */
  53 extern inline unsigned int __inbc(unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55         unsigned int _v;
  56 __asm__ __volatile__ ("inb %1,%b0"
  57                 :"=a" (_v):"i" (port),"0" (0));
  58         return _v;
  59 }
  60 
  61 extern inline void __outb_p(unsigned char value, unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  62 {
  63 __asm__ __volatile__ ("outb %b0,%w1"
  64                 : /* no outputs */
  65                 :"a" (value),"d" (port));
  66         SLOW_DOWN_IO;
  67 }
  68 
  69 extern inline void __outbc_p(unsigned char value, unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  70 {
  71 __asm__ __volatile__ ("outb %b0,%1"
  72                 : /* no outputs */
  73                 :"a" (value),"i" (port));
  74         SLOW_DOWN_IO;
  75 }
  76 
  77 extern inline unsigned int __inb_p(unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  78 {
  79         unsigned int _v;
  80 __asm__ __volatile__ ("inb %w1,%b0"
  81                 :"=a" (_v):"d" (port),"0" (0));
  82         SLOW_DOWN_IO;
  83         return _v;
  84 }
  85 
  86 extern inline unsigned int __inbc_p(unsigned short port)
     /* [previous][next][first][last][top][bottom][index][help] */
  87 {
  88         unsigned int _v;
  89 __asm__ __volatile__ ("inb %1,%b0"
  90                 :"=a" (_v):"i" (port),"0" (0));
  91         SLOW_DOWN_IO;
  92         return _v;
  93 }
  94 
  95 /*
  96  * Note that due to the way __builtin_constant_p() works, you
  97  *  - can't use it inside a inline function (it will never be true)
  98  *  - you don't have to worry about side effects within the __builtin..
  99  */
 100 #define outb(val,port) \
 101 ((__builtin_constant_p((port)) && (port) < 256) ? \
 102         __outbc((val),(port)) : \
 103         __outb((val),(port)))
 104 
 105 #define inb(port) \
 106 ((__builtin_constant_p((port)) && (port) < 256) ? \
 107         __inbc(port) : \
 108         __inb(port))
 109 
 110 #define outb_p(val,port) \
 111 ((__builtin_constant_p((port)) && (port) < 256) ? \
 112         __outbc_p((val),(port)) : \
 113         __outb_p((val),(port)))
 114 
 115 #define inb_p(port) \
 116 ((__builtin_constant_p((port)) && (port) < 256) ? \
 117         __inbc_p(port) : \
 118         __inb_p(port))
 119 
 120 #endif

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