add port io functions to sys/io.h
[musl] / arch / x86_64 / bits / io.h
1 int iopl(int);
2 int ioperm(unsigned long, unsigned long, int);
3
4 static __inline void outb(unsigned char __val, unsigned short __port)
5 {
6         __asm__ volatile ("outb %0,%1" : : "a" (__val), "dN" (__port));
7 }
8
9 static __inline void outw(unsigned short __val, unsigned short __port)
10 {
11         __asm__ volatile ("outw %0,%1" : : "a" (__val), "dN" (__port));
12 }
13
14 static __inline void outl(unsigned int __val, unsigned short __port)
15 {
16         __asm__ volatile ("outl %0,%1" : : "a" (__val), "dN" (__port));
17 }
18
19 static __inline unsigned char inb(unsigned short __port)
20 {
21         unsigned char __val;
22         __asm__ volatile ("inb %1,%0" : "=a" (__val) : "dN" (__port));
23         return __val;
24 }
25
26 static __inline unsigned short inw(unsigned short __port)
27 {
28         unsigned short __val;
29         __asm__ volatile ("inw %1,%0" : "=a" (__val) : "dN" (__port));
30         return __val;
31 }
32
33 static __inline unsigned int inl(unsigned short __port)
34 {
35         unsigned int __val;
36         __asm__ volatile ("inl %1,%0" : "=a" (__val) : "dN" (__port));
37         return __val;
38 }
39
40 static __inline void outsb(unsigned short __port, const void *__buf, unsigned long __n)
41 {
42         __asm__ volatile ("cld; rep; outsb"
43                       : "+S" (__buf), "+c" (__n)
44                       : "d" (__port));
45 }
46
47 static __inline void outsw(unsigned short __port, const void *__buf, unsigned long __n)
48 {
49         __asm__ volatile ("cld; rep; outsw"
50                       : "+S" (__buf), "+c" (__n)
51                       : "d" (__port));
52 }
53
54 static __inline void outsl(unsigned short __port, const void *__buf, unsigned long __n)
55 {
56         __asm__ volatile ("cld; rep; outsl"
57                       : "+S" (__buf), "+c"(__n)
58                       : "d" (__port));
59 }
60
61 static __inline void insb(unsigned short __port, void *__buf, unsigned long __n)
62 {
63         __asm__ volatile ("cld; rep; insb"
64                       : "+D" (__buf), "+c" (__n)
65                       : "d" (__port));
66 }
67
68 static __inline void insw(unsigned short __port, void *__buf, unsigned long __n)
69 {
70         __asm__ volatile ("cld; rep; insw"
71                       : "+D" (__buf), "+c" (__n)
72                       : "d" (__port));
73 }
74
75 static __inline void insl(unsigned short __port, void *__buf, unsigned long __n)
76 {
77         __asm__ volatile ("cld; rep; insl"
78                       : "+D" (__buf), "+c" (__n)
79                       : "d" (__port));
80 }