From 9b8698769535846d029c44247956eed9a21f1185 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 4 Jul 2021 21:31:28 +0200 Subject: Initial commit --- src/loader/cpu.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/loader/cpu.c (limited to 'src/loader/cpu.c') diff --git a/src/loader/cpu.c b/src/loader/cpu.c new file mode 100644 index 0000000..a12d2fa --- /dev/null +++ b/src/loader/cpu.c @@ -0,0 +1,26 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#include + +/** + * CPU IO + */ + +u8 inb(u16 port) +{ + u8 value; + __asm__ volatile("inb %1, %0" : "=a"(value) : "Nd"(port)); + return value; +} + +u16 inw(u16 port) +{ + u16 value; + __asm__ volatile("inw %1, %0" : "=a"(value) : "Nd"(port)); + return value; +} + +void outb(u16 port, u8 data) +{ + __asm__ volatile("outb %0, %1" ::"a"(data), "Nd"(port)); +} -- cgit v1.2.3