io.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019: #ifndef _SYS_IO_H
020: #define _SYS_IO_H 1
021:
022: #include <features.h>
023:
024: __BEGIN_DECLS
025:
026:
027:
028:
029:
030:
031:
032:
033: extern int ioperm (unsigned long int __from, unsigned long int __num,
034: int __turn_on) __THROW;
035:
036:
037:
038:
039: extern int iopl (int __level) __THROW;
040:
041: #if defined __GNUC__ && __GNUC__ >= 2
042:
043: static __inline unsigned char
044: inb (unsigned short int __port)
045: {
046: unsigned char _v;
047:
048: __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
049: return _v;
050: }
051:
052: static __inline unsigned char
053: inb_p (unsigned short int __port)
054: {
055: unsigned char _v;
056:
057: __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
058: return _v;
059: }
060:
061: static __inline unsigned short int
062: inw (unsigned short int __port)
063: {
064: unsigned short _v;
065:
066: __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
067: return _v;
068: }
069:
070: static __inline unsigned short int
071: inw_p (unsigned short int __port)
072: {
073: unsigned short int _v;
074:
075: __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
076: return _v;
077: }
078:
079: static __inline unsigned int
080: inl (unsigned short int __port)
081: {
082: unsigned int _v;
083:
084: __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (__port));
085: return _v;
086: }
087:
088: static __inline unsigned int
089: inl_p (unsigned short int __port)
090: {
091: unsigned int _v;
092: __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
093: return _v;
094: }
095:
096: static __inline void
097: outb (unsigned char __value, unsigned short int __port)
098: {
099: __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
100: }
101:
102: static __inline void
103: outb_p (unsigned char __value, unsigned short int __port)
104: {
105: __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
106: "Nd" (__port));
107: }
108:
109: static __inline void
110: outw (unsigned short int __value, unsigned short int __port)
111: {
112: __asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));
113:
114: }
115:
116: static __inline void
117: outw_p (unsigned short int __value, unsigned short int __port)
118: {
119: __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (__value),
120: "Nd" (__port));
121: }
122:
123: static __inline void
124: outl (unsigned int __value, unsigned short int __port)
125: {
126: __asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port));
127: }
128:
129: static __inline void
130: outl_p (unsigned int __value, unsigned short int __port)
131: {
132: __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (__value),
133: "Nd" (__port));
134: }
135:
136: static __inline void
137: insb (unsigned short int __port, void *addr, unsigned long int __count)
138: {
139: __asm__ __volatile__ ("cld ; rep ; insb":"=D" (addr), "=c" (__count)
140: :"d" (__port), "0" (addr), "1" (__count));
141: }
142:
143: static __inline void
144: insw (unsigned short int __port, void *addr, unsigned long int __count)
145: {
146: __asm__ __volatile__ ("cld ; rep ; insw":"=D" (addr), "=c" (__count)
147: :"d" (__port), "0" (addr), "1" (__count));
148: }
149:
150: static __inline void
151: insl (unsigned short int __port, void *addr, unsigned long int __count)
152: {
153: __asm__ __volatile__ ("cld ; rep ; insl":"=D" (addr), "=c" (__count)
154: :"d" (__port), "0" (addr), "1" (__count));
155: }
156:
157: static __inline void
158: outsb (unsigned short int __port, const void *addr, unsigned long int __count)
159: {
160: __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (addr), "=c" (__count)
161: :"d" (__port), "0" (addr), "1" (__count));
162: }
163:
164: static __inline void
165: outsw (unsigned short int __port, const void *addr, unsigned long int __count)
166: {
167: __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (addr), "=c" (__count)
168: :"d" (__port), "0" (addr), "1" (__count));
169: }
170:
171: static __inline void
172: outsl (unsigned short int __port, const void *addr, unsigned long int __count)
173: {
174: __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (addr), "=c" (__count)
175: :"d" (__port), "0" (addr), "1" (__count));
176: }
177:
178: #endif
179:
180: __END_DECLS
181: #endif
182:
© Andrew Scott 2006 -
2024,
All Rights Reserved