chiark / gitweb /
volume_id: provide libvolume_id.a file
[elogind.git] / klibc / include / arch / i386 / sys / io.h
1 #ident "$Id: io.h,v 1.2 2004/01/25 07:49:39 hpa Exp $"
2 /* ----------------------------------------------------------------------- *
3  *   
4  *   Copyright 2004 H. Peter Anvin - All Rights Reserved
5  *
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
13  *   conditions:
14  *   
15  *   The above copyright notice and this permission notice shall
16  *   be included in all copies or substantial portions of the Software.
17  *   
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.
26  *
27  * ----------------------------------------------------------------------- */
28
29 /*
30  * sys/io.h for the i386 architecture
31  *
32  * Basic I/O macros
33  */
34
35 #ifndef _SYS_IO_H
36 #define _SYS_IO_H 1
37
38 /* I/O-related system calls */
39
40 int iopl(int);
41 int ioperm(unsigned long, unsigned long, int);
42
43 /* Basic I/O macros */
44
45 static __inline__ void
46 outb(unsigned char __v, unsigned short __p)
47 {
48   asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
49 }
50
51 static __inline__ void
52 outw(unsigned short __v, unsigned short __p)
53 {
54   asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
55 }
56
57 static __inline__ void
58 outl(unsigned int __v, unsigned short __p)
59 {
60   asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
61 }
62
63 static __inline__ unsigned char
64 inb(unsigned short __p)
65 {
66   unsigned char __v;
67   asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
68   return __v;
69 }
70
71 static __inline__ unsigned short
72 inw(unsigned short __p)
73 {
74   unsigned short __v;
75   asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
76   return __v;
77 }
78
79 static __inline__ unsigned int
80 inl(unsigned short __p)
81 {
82   unsigned int __v;
83   asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
84   return __v;
85 }
86
87 /* String I/O macros */
88
89 static __inline__ void
90 outsb (unsigned short __p, const void *__d, unsigned long __n)
91 {
92   asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
93 }
94
95 static __inline__ void
96 outsw (unsigned short __p, const void *__d, unsigned long __n)
97 {
98   asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
99 }
100
101 static __inline__ void
102 outsl (unsigned short __p, const void *__d, unsigned long __n)
103 {
104   asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
105 }
106
107
108 static __inline__ void
109 insb (unsigned short __p, void *__d, unsigned long __n)
110 {
111   asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
112 }
113
114 static __inline__ void
115 insw (unsigned short __p, void *__d, unsigned long __n)
116 {
117   asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
118 }
119
120 static __inline__ void
121 insl (unsigned short __p, void *__d, unsigned long __n)
122 {
123   asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
124 }
125
126 #endif /* _SYS_IO_H */