From b7f59b28b380d55f9e7abd8e450f1f9c7f050221 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 1 Aug 2020 20:55:53 +0200 Subject: Added syscalls --- src/inc/cpu.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/inc/cpu.h') diff --git a/src/inc/cpu.h b/src/inc/cpu.h index b8897de..092fd3f 100644 --- a/src/inc/cpu.h +++ b/src/inc/cpu.h @@ -14,4 +14,12 @@ void outb(u16 port, u8 data); void outw(u16 port, u16 data); void outl(u16 port, u32 data); +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