diff options
Diffstat (limited to 'src/kernel/io/io.c')
-rw-r--r-- | src/kernel/io/io.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/kernel/io/io.c b/src/kernel/io/io.c new file mode 100644 index 0000000..7bddb13 --- /dev/null +++ b/src/kernel/io/io.c @@ -0,0 +1,21 @@ +#include <stdint.h> + +unsigned char receive(unsigned short port) { + unsigned char value; + __asm__ __volatile__ ("inb %1, %0" : "=a" (value) : "dN" (port)); + return value; +} + +void send(unsigned short port, unsigned char data) { + __asm__ __volatile__ ("outb %1, %0" : : "dN" (port), "a" (data)); +} + +void reboot() { + uint8_t good = 0x02; + while (good & 0x02) + good = receive(0x64); + send(0x64, 0xFE); + loop: + asm volatile ("hlt"); + goto loop; +}
\ No newline at end of file |