Contents of /trunk/mkinitrd-magellan/klibc/usr/include/arch/x86_64/sys/io.h
Parent Directory | Revision Log
Revision 842 -
(show annotations)
(download)
Mon May 4 17:21:24 2009 UTC (15 years ago) by niro
File MIME type: text/plain
File size: 3474 byte(s)
Mon May 4 17:21:24 2009 UTC (15 years ago) by niro
File MIME type: text/plain
File size: 3474 byte(s)
-applied klibc-1.5.14-x86_64-fix-io.h.patch to fix errors in io.h
1 | /* ----------------------------------------------------------------------- * |
2 | * |
3 | * Copyright 2004 H. Peter Anvin - All Rights Reserved |
4 | * |
5 | * Permission is hereby granted, free of charge, to any person |
6 | * obtaining a copy of this software and associated documentation |
7 | * files (the "Software"), to deal in the Software without |
8 | * restriction, including without limitation the rights to use, |
9 | * copy, modify, merge, publish, distribute, sublicense, and/or |
10 | * sell copies of the Software, and to permit persons to whom |
11 | * the Software is furnished to do so, subject to the following |
12 | * conditions: |
13 | * |
14 | * The above copyright notice and this permission notice shall |
15 | * be included in all copies or substantial portions of the Software. |
16 | * |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
24 | * OTHER DEALINGS IN THE SOFTWARE. |
25 | * |
26 | * ----------------------------------------------------------------------- */ |
27 | |
28 | /* |
29 | * sys/io.h for the i386 architecture |
30 | * |
31 | * Basic I/O macros |
32 | */ |
33 | |
34 | #ifndef _SYS_IO_H |
35 | #define _SYS_IO_H 1 |
36 | |
37 | /* I/O-related system calls */ |
38 | |
39 | int iopl(int); |
40 | int ioperm(unsigned long, unsigned long, int); |
41 | |
42 | /* Basic I/O macros */ |
43 | |
44 | static __inline__ void outb(unsigned char __v, unsigned short __p) |
45 | { |
46 | asm volatile ("outb %0,%1" : : "a" (__v), "dN"(__p)); |
47 | } |
48 | |
49 | static __inline__ void outw(unsigned short __v, unsigned short __p) |
50 | { |
51 | asm volatile ("outw %0,%1" : : "a" (__v), "dN"(__p)); |
52 | } |
53 | |
54 | static __inline__ void outl(unsigned int __v, unsigned short __p) |
55 | { |
56 | asm volatile ("outl %0,%1" : : "a" (__v), "dN"(__p)); |
57 | } |
58 | |
59 | static __inline__ unsigned char inb(unsigned short __p) |
60 | { |
61 | unsigned char __v; |
62 | asm volatile ("inb %1,%0" : "=a" (__v) : "dN"(__p)); |
63 | return __v; |
64 | } |
65 | |
66 | static __inline__ unsigned short inw(unsigned short __p) |
67 | { |
68 | unsigned short __v; |
69 | asm volatile ("inw %1,%0" : "=a" (__v) : "dN"(__p)); |
70 | return __v; |
71 | } |
72 | |
73 | static __inline__ unsigned int inl(unsigned short __p) |
74 | { |
75 | unsigned int __v; |
76 | asm volatile ("inl %1,%0" : "=a" (__v) : "dN"(__p)); |
77 | return __v; |
78 | } |
79 | |
80 | /* String I/O macros */ |
81 | |
82 | static __inline__ void |
83 | outsb(unsigned short __p, const void *__d, unsigned long __n) |
84 | { |
85 | asm volatile ("cld; rep; outsb" |
86 | : "+S" (__d), "+c"(__n) |
87 | : "d"(__p)); |
88 | } |
89 | |
90 | static __inline__ void |
91 | outsw(unsigned short __p, const void *__d, unsigned long __n) |
92 | { |
93 | asm volatile ("cld; rep; outsw" |
94 | : "+S" (__d), "+c"(__n) |
95 | : "d"(__p)); |
96 | } |
97 | |
98 | static __inline__ void |
99 | outsl(unsigned short __p, const void *__d, unsigned long __n) |
100 | { |
101 | asm volatile ("cld; rep; outsl" |
102 | : "+S" (__d), "+c"(__n) |
103 | : "d"(__p)); |
104 | } |
105 | |
106 | static __inline__ void insb(unsigned short __p, void *__d, unsigned long __n) |
107 | { |
108 | asm volatile ("cld; rep; insb" |
109 | : "+D" (__d), "+c"(__n) |
110 | : "d"(__p)); |
111 | } |
112 | |
113 | static __inline__ void insw(unsigned short __p, void *__d, unsigned long __n) |
114 | { |
115 | asm volatile ("cld; rep; insw" |
116 | : "+D" (__d), "+c"(__n) |
117 | : "d"(__p)); |
118 | } |
119 | |
120 | static __inline__ void insl(unsigned short __p, void *__d, unsigned long __n) |
121 | { |
122 | asm volatile ("cld; rep; insl" |
123 | : "+D" (__d), "+c"(__n) |
124 | : "d"(__p)); |
125 | } |
126 | |
127 | #endif /* _SYS_IO_H */ |