-
Notifications
You must be signed in to change notification settings - Fork 1
/
io.h
66 lines (51 loc) · 1.38 KB
/
io.h
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
#ifndef __IO_H__
#define __IO_H__
// stolen from LINUX
// output
static __inline void
outb (unsigned char value, unsigned short int port) {
__asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port));
}
static __inline void
outb_p (unsigned char value, unsigned short int port) {
__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (value),
"Nd" (port));
}
static __inline void
outw (unsigned short int value, unsigned short int port)
{
__asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port));
}
static __inline void
outw_p (unsigned short int value, unsigned short int port) {
__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (value),
"Nd" (port));
}
static __inline void
outl (unsigned long int value, unsigned short int port)
{
__asm__ __volatile__ ("outl %0,%1": :"a" (value), "Nd" (port));
}
// input
static __inline unsigned char
inb (unsigned short int port)
{
unsigned char _v;
__asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port));
return _v;
}
static __inline unsigned short int
inw (unsigned short int port)
{
unsigned short int _v;
__asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port));
return _v;
}
static __inline unsigned long int
inl (unsigned short int port)
{
unsigned long int _v;
__asm__ __volatile__ ("inl %1,%0":"=a" (_v):"Nd" (port));
return _v;
}
#endif