summaryrefslogtreecommitdiffhomepage
path: root/src/loader/cpu.c
diff options
context:
space:
mode:
authorMarvin Borner2021-07-04 21:31:28 +0200
committerMarvin Borner2021-07-04 21:34:15 +0200
commit9b8698769535846d029c44247956eed9a21f1185 (patch)
tree294a17af4102805ab9863274339e8e030897804e /src/loader/cpu.c
Initial commit
Diffstat (limited to 'src/loader/cpu.c')
-rw-r--r--src/loader/cpu.c26
1 files changed, 26 insertions, 0 deletions
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.h>
+
+/**
+ * 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));
+}