This source file includes following definitions.
- __outb
- __outbc
- __inb
- __inbc
- __outb_p
- __outbc_p
- __inb_p
- __inbc_p
1 #ifndef _ASM_IO_H
2 #define _ASM_IO_H
3
4
5
6
7
8
9
10
11
12
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
28 extern inline void __outb(unsigned char value, unsigned short port)
29 {
30 __asm__ __volatile__ ("outb %b0,%w1"
31 :
32 :"a" (value),"d" (port));
33 }
34
35
36 extern inline void __outbc(unsigned char value, unsigned short port)
37 {
38 __asm__ __volatile__ ("outb %b0,%1"
39 :
40 :"a" (value),"i" (port));
41 }
42
43
44 extern inline unsigned int __inb(unsigned short port)
45 {
46 unsigned int _v;
47 __asm__ __volatile__ ("inb %w1,%b0"
48 :"=a" (_v):"d" (port),"0" (0));
49 return _v;
50 }
51
52
53 extern inline unsigned int __inbc(unsigned short port)
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)
62 {
63 __asm__ __volatile__ ("outb %b0,%w1"
64 :
65 :"a" (value),"d" (port));
66 SLOW_DOWN_IO;
67 }
68
69 extern inline void __outbc_p(unsigned char value, unsigned short port)
70 {
71 __asm__ __volatile__ ("outb %b0,%1"
72 :
73 :"a" (value),"i" (port));
74 SLOW_DOWN_IO;
75 }
76
77 extern inline unsigned int __inb_p(unsigned short port)
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)
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
97
98
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