diff --git a/headers/sys/io.h b/headers/sys/io.h new file mode 100644 index 0000000..16724da --- /dev/null +++ b/headers/sys/io.h @@ -0,0 +1,4 @@ +#pragma once + +inline uint8_t inb(uint16_t port); +inline void outb(uint16_t port, uint8_t val); \ No newline at end of file diff --git a/src/sys/io/inb.c b/src/sys/io/inb.c new file mode 100644 index 0000000..efba1f0 --- /dev/null +++ b/src/sys/io/inb.c @@ -0,0 +1,10 @@ + +inline uint8_t inb(uint16_t port) +{ + uint8_t ret; + __asm__ volatile ( "inb %w1, %b0" + : "=a"(ret) + : "Nd"(port) + : "memory"); + return ret; +} \ No newline at end of file diff --git a/src/sys/io/outb.c b/src/sys/io/outb.c new file mode 100644 index 0000000..cb3d773 --- /dev/null +++ b/src/sys/io/outb.c @@ -0,0 +1,4 @@ +inline void outb(uint16_t port, uint8_t val) +{ + __asm__ volatile ( "outb %b0, %w1" : : "a"(val), "Nd"(port) : "memory"); +} \ No newline at end of file