diff options
author | Marvin Borner | 2020-05-10 13:35:43 +0200 |
---|---|---|
committer | Marvin Borner | 2020-05-10 13:35:43 +0200 |
commit | 6abd515c051b6dcb545e1033ff129aaaf7293917 (patch) | |
tree | 6c50e6a16e3519a0a451b3a7895fabb198544f1c | |
parent | c5b0305b3a6e7e6ec6742b99ceb6a1a0b3c6e286 (diff) |
Added basic spinlock
-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); |