GDT finally works

This commit is contained in:
2025-08-10 21:29:16 +02:00
parent f8f00cc608
commit 8ee1ea1292
36 changed files with 868 additions and 206 deletions

31
kernel/spinlock.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef SPINLOCK_SPINLOCK_H_
#define SPINLOCK_SPINLOCK_H_
#include <stdatomic.h>
#include "hal/hal.h"
typedef atomic_bool SpinLock;
// Spin more efficiently - cpu dependant
#if defined(__x86_64__)
# define SPINLOCK_HINT() asm volatile("pause")
#else
# define SPINLOCK_HINT()
#endif
#define SPINLOCK_ACQUIRE(sl) \
do { \
bool __unlocked = false; \
while (!atomic_compare_exchange_weak((sl), &__unlocked, true)) { \
SPINLOCK_HINT(); \
} \
} while(0)
#define SPINLOCK_RELEASE(sl) \
do { \
atomic_store((sl), false); \
} while(0)
#define SPINLOCK_INIT() false
#endif // SPINLOCK_SPINLOCK_H_