aboutsummaryrefslogtreecommitdiff
path: root/libc/inc/cpu.h
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inc/cpu.h')
-rw-r--r--libc/inc/cpu.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/libc/inc/cpu.h b/libc/inc/cpu.h
new file mode 100644
index 0000000..2d367cb
--- /dev/null
+++ b/libc/inc/cpu.h
@@ -0,0 +1,30 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#ifndef CPU_H
+#define CPU_H
+
+#include <def.h>
+
+u8 inb(u16 port);
+u16 inw(u16 port);
+u32 inl(u16 port);
+void insl(u16 port, void *addr, int n);
+
+void outb(u16 port, u8 data);
+void outw(u16 port, u16 data);
+void outl(u16 port, u32 data);
+void cli();
+void sti();
+void hlt();
+void idle();
+void loop();
+
+static inline void spinlock(int *ptr)
+{
+ int prev;
+ do
+ __asm__ volatile("lock xchgl %0,%1" : "=a"(prev) : "m"(*ptr), "a"(1));
+ while (prev);
+}
+
+#endif