kernel - v0.7 beta

+ acpi: add acpi support
+ lapic: add lapic support
+ ioapic: add ioapic support
+ arch/x86_64: add support for "syscall"/"sysret"
This commit is contained in:
RaphProductions 2025-05-15 18:49:09 +02:00
parent 4d52bac946
commit a8e919b033
53 changed files with 772 additions and 331 deletions

View file

@ -1,17 +1,31 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef struct spinlock {
volatile int locked;
volatile int locked;
} spinlock_t;
inline void spinlock_acquire(spinlock_t *lock) {
while (__sync_lock_test_and_set(&(lock)->locked, 1))
while ((lock)->locked)
__asm__ volatile("pause");
static inline void spinlock_acquire(spinlock_t *lock) {
//uint64_t timeout = 1000000; // Adjust this value based on your needs
for (;;) {
if (__atomic_exchange_n(&lock->locked, 1, __ATOMIC_ACQUIRE) == 0) {
return;
}
while (__atomic_load_n(&lock->locked, __ATOMIC_RELAXED)) {
/**if (--timeout == 0) {
// Force unlock after too many attempts
__atomic_store_n(&lock->locked, 0, __ATOMIC_RELEASE);
continue;
}**/
__asm__ volatile("pause" ::: "memory");
}
}
}
inline void spinlock_release(spinlock_t *lock) {
__sync_lock_release(&(lock)->locked);
static inline void spinlock_release(spinlock_t *lock) {
__atomic_store_n(&lock->locked, 0, __ATOMIC_RELEASE);
}