1 #ident "$Id: io.h,v 1.2 2004/01/25 07:49:39 hpa Exp $"
2 /* ----------------------------------------------------------------------- *
4 * Copyright 2004 H. Peter Anvin - All Rights Reserved
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following
15 * The above copyright notice and this permission notice shall
16 * be included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
27 * ----------------------------------------------------------------------- */
30 * sys/io.h for the i386 architecture
38 /* I/O-related system calls */
41 int ioperm(unsigned long, unsigned long, int);
43 /* Basic I/O macros */
45 static __inline__ void
46 outb(unsigned char __v, unsigned short __p)
48 asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
51 static __inline__ void
52 outw(unsigned short __v, unsigned short __p)
54 asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
57 static __inline__ void
58 outl(unsigned int __v, unsigned short __p)
60 asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
63 static __inline__ unsigned char
64 inb(unsigned short __p)
67 asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
71 static __inline__ unsigned short
72 inw(unsigned short __p)
75 asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
79 static __inline__ unsigned int
80 inl(unsigned short __p)
83 asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
87 /* String I/O macros */
89 static __inline__ void
90 outsb (unsigned short __p, const void *__d, unsigned long __n)
92 asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
95 static __inline__ void
96 outsw (unsigned short __p, const void *__d, unsigned long __n)
98 asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
101 static __inline__ void
102 outsl (unsigned short __p, const void *__d, unsigned long __n)
104 asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
108 static __inline__ void
109 insb (unsigned short __p, void *__d, unsigned long __n)
111 asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
114 static __inline__ void
115 insw (unsigned short __p, void *__d, unsigned long __n)
117 asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
120 static __inline__ void
121 insl (unsigned short __p, void *__d, unsigned long __n)
123 asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
126 #endif /* _SYS_IO_H */