]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/mach/hurd/i386/sys/io.h
1 /* Access to hardware i/o ports. GNU/x86 version.
2 Copyright (C) 2002-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
26 /* If TURN_ON is TRUE, request for permission to do direct i/o on the
27 port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
28 permission off for that range. This call requires root privileges. */
29 extern int ioperm (unsigned long int __from
, unsigned long int __num
,
30 int __turn_on
) __THROW
;
32 /* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
33 access any I/O port is granted. This call requires root
35 extern int iopl (int __level
) __THROW
;
37 #if defined __GNUC__ && __GNUC__ >= 2
39 static __inline
unsigned char
40 inb (unsigned short int port
)
44 __asm__
__volatile__ ("inb %w1,%0":"=a" (_v
):"Nd" (port
));
48 static __inline
unsigned char
49 inb_p (unsigned short int port
)
53 __asm__
__volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v
):"Nd" (port
));
57 static __inline
unsigned short int
58 inw (unsigned short int port
)
62 __asm__
__volatile__ ("inw %w1,%0":"=a" (_v
):"Nd" (port
));
66 static __inline
unsigned short int
67 inw_p (unsigned short int port
)
69 unsigned short int _v
;
71 __asm__
__volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v
):"Nd" (port
));
75 static __inline
unsigned int
76 inl (unsigned short int port
)
80 __asm__
__volatile__ ("inl %w1,%0":"=a" (_v
):"Nd" (port
));
84 static __inline
unsigned int
85 inl_p (unsigned short int port
)
88 __asm__
__volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v
):"Nd" (port
));
93 outb (unsigned char value
, unsigned short int port
)
95 __asm__
__volatile__ ("outb %b0,%w1": :"a" (value
), "Nd" (port
));
99 outb_p (unsigned char value
, unsigned short int port
)
101 __asm__
__volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (value
),
106 outw (unsigned short int value
, unsigned short int port
)
108 __asm__
__volatile__ ("outw %w0,%w1": :"a" (value
), "Nd" (port
));
113 outw_p (unsigned short int value
, unsigned short int port
)
115 __asm__
__volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (value
),
120 outl (unsigned int value
, unsigned short int port
)
122 __asm__
__volatile__ ("outl %0,%w1": :"a" (value
), "Nd" (port
));
126 outl_p (unsigned int value
, unsigned short int port
)
128 __asm__
__volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (value
),
133 insb (unsigned short int port
, void *addr
, unsigned long int count
)
135 __asm__
__volatile__ ("cld ; rep ; insb":"=D" (addr
),
136 "=c" (count
):"d" (port
), "0" (addr
), "1" (count
));
140 insw (unsigned short int port
, void *addr
, unsigned long int count
)
142 __asm__
__volatile__ ("cld ; rep ; insw":"=D" (addr
),
143 "=c" (count
):"d" (port
), "0" (addr
), "1" (count
));
147 insl (unsigned short int port
, void *addr
, unsigned long int count
)
149 __asm__
__volatile__ ("cld ; rep ; insl":"=D" (addr
),
150 "=c" (count
):"d" (port
), "0" (addr
), "1" (count
));
154 outsb (unsigned short int port
, const void *addr
, unsigned long int count
)
156 __asm__
__volatile__ ("cld ; rep ; outsb":"=S" (addr
),
157 "=c" (count
):"d" (port
), "0" (addr
), "1" (count
));
161 outsw (unsigned short int port
, const void *addr
, unsigned long int count
)
163 __asm__
__volatile__ ("cld ; rep ; outsw":"=S" (addr
),
164 "=c" (count
):"d" (port
), "0" (addr
), "1" (count
));
168 outsl (unsigned short int port
, const void *addr
, unsigned long int count
)
170 __asm__
__volatile__ ("cld ; rep ; outsl":"=S" (addr
),
171 "=c" (count
):"d" (port
), "0" (addr
), "1" (count
));
177 #endif /* _SYS_IO_H */