Virtual memory & paging
[lunaix-os.git] / lunaix-os / includes / hal / io.h
1 #ifndef __LUNAIX_IO_H
2 #define __LUNAIX_IO_H
3
4 #include <stdint.h>
5
6 void io_port_wb(uint8_t port, uint8_t value) {
7     asm volatile (
8         "movb %0, %%al\n"
9         "movb %1, %%dx\n"
10         "out %%al, %%dx\n"
11         :: "r"(value) "r"(port)
12     );
13 }
14
15 void io_port_wl(uint8_t port, uint32_t value) {
16     asm volatile (
17         "movl %0, %%eax\n"
18         "movb %1, %%dx\n"
19         "out %%eax, %%dx\n"
20         :: "r"(value) "r"(port)
21     );
22 }
23
24 uint8_t io_port_rb(uint8_t port) {
25     asm volatile (
26         "movb $0, %%eax\n"
27         "movb %0, %%dx\n"
28         "in %%dx, %%al\n"
29         :: "r"(port)
30     );
31 }
32
33 uint32_t io_port_rl(uint8_t port) {
34     asm volatile (
35         "movb %0, %%dx\n"
36         "in %%dx, %%eax\n"
37         :: "r"(port)
38     );
39 }
40
41 #endif /* __LUNAIX_IO_H */