summaryrefslogtreecommitdiff
path: root/Kernel/IO.h
blob: 5761383375d14008e3faaebf8bad830f042f4482 (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
#pragma once

#include "types.h"

namespace IO {

inline byte in8(word port)
{
    byte value;
    asm volatile("inb %1, %0":"=a"(value):"Nd"(port));
    return value;
}

inline word in16(word port)
{
    word value;
    asm volatile("inw %1, %0":"=a"(value):"Nd"(port));
    return value;
}

inline dword in32(word port)
{
    dword value;
    asm volatile("inl %1, %0":"=a"(value):"Nd"(port));
    return value;
}

inline void out8(word port, byte value)
{
    asm volatile("outb %0, %1"::"a"(value), "Nd"(port));
}

inline void out16(word port, word value)
{
    asm volatile("outw %0, %1"::"a"(value), "Nd"(port));
}

inline void out32(word port, dword value)
{
    asm volatile("outl %0, %1"::"a"(value), "Nd"(port));
}
}