-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathports.c
37 lines (31 loc) · 813 Bytes
/
ports.c
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
#include "ports.h"
unsigned char inb(unsigned short port)
{
unsigned char result;
__asm__("in %%dx, %%al" : "=a" (result) : "d" (port));
return result;
}
unsigned short inw(unsigned short port)
{
unsigned short result;
__asm__("in %%dx, %%ax" : "=a" (result) : "d" (port));
return result;
}
unsigned int ind(unsigned short port)
{
unsigned int result;
__asm__("in %%dx, %%eax" : "=a" (result) : "d" (port));
return result;
}
void outb(unsigned short port, unsigned char value)
{
__asm__("out %%al, %%dx" : : "a" (value), "d" (port));
}
void outw(unsigned short port, unsigned short value)
{
__asm__("out %%ax, %%dx" : : "a" (value), "d" (port));
}
void outd(unsigned short port, unsigned int value)
{
__asm__("out %%eax, %%dx" : : "a" (value), "d" (port));
}