summaryrefslogtreecommitdiff
path: root/Kernel/IO.cpp
blob: baeaa1bfec850c6c01f7976fbf4da977f411e798 (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
#include "IO.h"

namespace IO {

BYTE in8(WORD port)
{
    BYTE value;
    asm("inb %%dx, %%al":"=a"(value):"d"(port));
    return value;
}

WORD in16(WORD port)
{
    WORD value;
    asm("inw %%dx, %%ax":"=a"(value):"d"(port));
    return value;
}

DWORD in32(DWORD port)
{
    DWORD value;
    asm("inl %%dx, %%eax":"=a"(value):"d"(port));
    return value;
}

void out8(WORD port, BYTE value)
{
    asm("outb %%al, %%dx"::"d"(port), "a"(value));
}

void out16(WORD port, WORD value)
{
    asm("outw %%ax, %%dx"::"d"(port), "a"(value));
}

void out32(WORD port, WORD value)
{
    asm("outl %%eax, %%dx"::"d"(port), "a"(value));
}

}