From 162d024a53e1e31e00ff0b6f47dd4590edebc551 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 9 Aug 2020 16:51:01 +0200 Subject: Heavy restructuring of libc, kernel and apps --- kernel/inc/cpu.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 kernel/inc/cpu.h (limited to 'kernel/inc/cpu.h') diff --git a/kernel/inc/cpu.h b/kernel/inc/cpu.h new file mode 100644 index 0000000..eb09291 --- /dev/null +++ b/kernel/inc/cpu.h @@ -0,0 +1,29 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#ifndef CPU_H +#define CPU_H + +#include + +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(); + +static inline void spinlock(int *ptr) +{ + int prev; + do + __asm__ volatile("lock xchgl %0,%1" : "=a"(prev) : "m"(*ptr), "a"(1)); + while (prev); +} + +#endif -- cgit v1.2.3