aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/glibc/include/sys/io.h
blob: 311b25f85190ab500bf3c6cb6f7b096118a3e668 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef _SYS_IO_H
#define _SYS_IO_H

#include <bits/inline-definition.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef __MLIBC_ABI_ONLY

int ioperm(unsigned long int from, unsigned long int num, int turn_on);

__attribute__((deprecated)) int iopl(int level);

#endif /* !__MLIBC_ABI_ONLY */

#ifdef __x86_64__
__MLIBC_INLINE_DEFINITION unsigned char inb(unsigned short int port) {
	unsigned char _v;
	__asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port));
	return _v;
}

__MLIBC_INLINE_DEFINITION unsigned char inb_p(unsigned short int port) {
	unsigned char _v;
	__asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
	return _v;
}

__MLIBC_INLINE_DEFINITION unsigned short int inw(unsigned short int port) {
	unsigned short _v;
	__asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port));
	return _v;
}

__MLIBC_INLINE_DEFINITION unsigned short int inw_p(unsigned short int port) {
	unsigned short int _v;
	__asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
	return _v;
}

__MLIBC_INLINE_DEFINITION unsigned int inl(unsigned short int port) {
	unsigned int _v;
	__asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port));
	return _v;
}

__MLIBC_INLINE_DEFINITION unsigned int inl_p(unsigned short int port) {
	unsigned int _v;
	__asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
	return _v;
}

__MLIBC_INLINE_DEFINITION void outb(unsigned char value, unsigned short int port) {
	__asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port));
}

__MLIBC_INLINE_DEFINITION void outb_p(unsigned char value, unsigned short int port) {
	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (value), "Nd" (port));
}

__MLIBC_INLINE_DEFINITION void outw(unsigned short int value, unsigned short int port) {
	__asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port));
}

__MLIBC_INLINE_DEFINITION void outw_p(unsigned short int value, unsigned short int port) {
	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (value), "Nd" (port));
}

__MLIBC_INLINE_DEFINITION void outl(unsigned int value, unsigned short int port) {
	__asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port));
}

__MLIBC_INLINE_DEFINITION void outl_p(unsigned int value, unsigned short int port) {
	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (value), "Nd" (port));
}

__MLIBC_INLINE_DEFINITION void insb(unsigned short int port, void *addr, unsigned long int count) {
	__asm__ __volatile__ ("cld ; rep ; insb":"=D" (addr), "=c" (count) :"d" (port), "0" (addr), "1" (count));
}

__MLIBC_INLINE_DEFINITION void insw(unsigned short int port, void *addr, unsigned long int count) {
	__asm__ __volatile__ ("cld ; rep ; insw":"=D" (addr), "=c" (count) :"d" (port), "0" (addr), "1" (count));
}

__MLIBC_INLINE_DEFINITION void insl(unsigned short int port, void *addr, unsigned long int count) {
	__asm__ __volatile__ ("cld ; rep ; insl":"=D" (addr), "=c" (count) :"d" (port), "0" (addr), "1" (count));
}

__MLIBC_INLINE_DEFINITION void outsb(unsigned short int port, const void *addr, unsigned long int count) {
	__asm__ __volatile__ ("cld ; rep ; outsb":"=S" (addr), "=c" (count) :"d" (port), "0" (addr), "1" (count));
}

__MLIBC_INLINE_DEFINITION void outsw(unsigned short int port, const void *addr, unsigned long int count) {
	__asm__ __volatile__ ("cld ; rep ; outsw":"=S" (addr), "=c" (count) :"d" (port), "0" (addr), "1" (count));
}

__MLIBC_INLINE_DEFINITION void outsl(unsigned short int port, const void *addr, unsigned long int count) {
	__asm__ __volatile__ ("cld ; rep ; outsl":"=S" (addr), "=c" (count) :"d" (port), "0" (addr), "1" (count));
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* _SYS_IO_H */