]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/x86_64/sys/io.h
Fix a typo in x86_64 sys/io.h
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / x86_64 / sys / io.h
CommitLineData
471101a1 1/* Copyright (C) 1996-2012 Free Software Foundation, Inc.
40ff7949
AJ
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
40ff7949
AJ
17
18#ifndef _SYS_IO_H
19#define _SYS_IO_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* If TURN_ON is TRUE, request for permission to do direct i/o on the
26 port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
27 permission off for that range. This call requires root privileges.
28
29 Portability note: not all Linux platforms support this call. Most
30 platforms based on the PC I/O architecture probably will, however.
31 E.g., Linux/Alpha for Alpha PCs supports this. */
32extern int ioperm (unsigned long int __from, unsigned long int __num,
33 int __turn_on) __THROW;
34
35/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
36 access any I/O port is granted. This call requires root
37 privileges. */
38extern int iopl (int __level) __THROW;
39
40#if defined __GNUC__ && __GNUC__ >= 2
41
42static __inline unsigned char
d82a27f8 43inb (unsigned short int __port)
40ff7949
AJ
44{
45 unsigned char _v;
46
d82a27f8 47 __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
40ff7949
AJ
48 return _v;
49}
50
51static __inline unsigned char
d82a27f8 52inb_p (unsigned short int __port)
40ff7949
AJ
53{
54 unsigned char _v;
55
d82a27f8 56 __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
40ff7949
AJ
57 return _v;
58}
59
60static __inline unsigned short int
d82a27f8 61inw (unsigned short int __port)
40ff7949
AJ
62{
63 unsigned short _v;
64
d82a27f8 65 __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
40ff7949
AJ
66 return _v;
67}
68
69static __inline unsigned short int
d82a27f8 70inw_p (unsigned short int __port)
40ff7949
AJ
71{
72 unsigned short int _v;
73
d82a27f8 74 __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
40ff7949
AJ
75 return _v;
76}
77
78static __inline unsigned int
d82a27f8 79inl (unsigned short int __port)
40ff7949
AJ
80{
81 unsigned int _v;
82
d82a27f8 83 __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (__port));
40ff7949
AJ
84 return _v;
85}
86
87static __inline unsigned int
d82a27f8 88inl_p (unsigned short int __port)
40ff7949
AJ
89{
90 unsigned int _v;
d82a27f8 91 __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
40ff7949
AJ
92 return _v;
93}
94
95static __inline void
d82a27f8 96outb (unsigned char __value, unsigned short int __port)
40ff7949 97{
d82a27f8 98 __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
40ff7949
AJ
99}
100
101static __inline void
d82a27f8 102outb_p (unsigned char __value, unsigned short int __port)
40ff7949 103{
d82a27f8
JJ
104 __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
105 "Nd" (__port));
40ff7949
AJ
106}
107
108static __inline void
d82a27f8 109outw (unsigned short int __value, unsigned short int __port)
40ff7949 110{
d82a27f8 111 __asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));
40ff7949
AJ
112
113}
114
115static __inline void
d82a27f8 116outw_p (unsigned short int __value, unsigned short int __port)
40ff7949 117{
d82a27f8
JJ
118 __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (__value),
119 "Nd" (__port));
40ff7949
AJ
120}
121
122static __inline void
d82a27f8 123outl (unsigned int __value, unsigned short int __port)
40ff7949 124{
d82a27f8 125 __asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port));
40ff7949
AJ
126}
127
128static __inline void
d82a27f8 129outl_p (unsigned int __value, unsigned short int __port)
40ff7949 130{
d82a27f8
JJ
131 __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (__value),
132 "Nd" (__port));
40ff7949
AJ
133}
134
135static __inline void
471101a1 136insb (unsigned short int __port, void *__addr, unsigned long int __count)
40ff7949 137{
471101a1
L
138 __asm__ __volatile__ ("cld ; rep ; insb":"=D" (__addr), "=c" (__count)
139 :"d" (__port), "0" (__addr), "1" (__count));
40ff7949
AJ
140}
141
142static __inline void
471101a1 143insw (unsigned short int __port, void *__addr, unsigned long int __count)
40ff7949 144{
471101a1
L
145 __asm__ __volatile__ ("cld ; rep ; insw":"=D" (__addr), "=c" (__count)
146 :"d" (__port), "0" (__addr), "1" (__count));
40ff7949
AJ
147}
148
149static __inline void
471101a1 150insl (unsigned short int __port, void *__addr, unsigned long int __count)
40ff7949 151{
471101a1
L
152 __asm__ __volatile__ ("cld ; rep ; insl":"=D" (__addr), "=c" (__count)
153 :"d" (__port), "0" (__addr), "1" (__count));
40ff7949
AJ
154}
155
156static __inline void
471101a1
L
157outsb (unsigned short int __port, const void *__addr,
158 unsigned long int __count)
40ff7949 159{
471101a1
L
160 __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (__addr), "=c" (__count)
161 :"d" (__port), "0" (__addr), "1" (__count));
40ff7949
AJ
162}
163
164static __inline void
471101a1
L
165outsw (unsigned short int __port, const void *__addr,
166 unsigned long int __count)
40ff7949 167{
f34a1c6f 168 __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (__addr), "=c" (__count)
12e5e0f3 169 :"d" (__port), "0" (__addr), "1" (__count));
40ff7949
AJ
170}
171
172static __inline void
471101a1
L
173outsl (unsigned short int __port, const void *__addr,
174 unsigned long int __count)
40ff7949 175{
471101a1
L
176 __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (__addr), "=c" (__count)
177 :"d" (__port), "0" (__addr), "1" (__count));
40ff7949
AJ
178}
179
180#endif /* GNU C */
181
182__END_DECLS
183#endif /* _SYS_IO_H */