diff options
-rw-r--r-- | src/kernel/io/io.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/kernel/io/io.c b/src/kernel/io/io.c index 2d9d009..dfd9efa 100644 --- a/src/kernel/io/io.c +++ b/src/kernel/io/io.c @@ -66,6 +66,14 @@ void outl(u16 port, u32 data) asm volatile("outl %0, %1" ::"a"(data), "Nd"(port)); } +void spinlock(int *ptr) +{ + int prev; + do + asm volatile("lock xchgl %0,%1" : "=a"(prev) : "m"(*ptr), "a"(1)); + while (prev); +} + void init_serial() { outb(0x3f8 + 1, 0x00); |