aboutsummaryrefslogtreecommitdiff
path: root/src/inc/cpu.h
diff options
context:
space:
mode:
authorMarvin Borner2020-08-01 20:55:53 +0200
committerMarvin Borner2020-08-01 20:55:53 +0200
commitb7f59b28b380d55f9e7abd8e450f1f9c7f050221 (patch)
treec6b89fa0ff2bebd5ed06a4384d766990bcb42c0a /src/inc/cpu.h
parent1686173757af4e453e7a32d152ec4bd20d789652 (diff)
Added syscalls
Diffstat (limited to 'src/inc/cpu.h')
-rw-r--r--src/inc/cpu.h8
1 files changed, 8 insertions, 0 deletions
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