Implement userspace TLS, remove RW Locks

This commit is contained in:
2026-01-28 23:52:48 +01:00
parent a3b62ebd3d
commit 3d23187acf
17 changed files with 135 additions and 157 deletions

View File

@@ -4,7 +4,7 @@
#include <amd64/msr.h>
#include <libk/std.h>
#include <limine/requests.h>
#include <sync/rw_spin_lock.h>
#include <sync/spin_lock.h>
#include <sys/debug.h>
#include <sys/mm.h>
#include <sys/spin.h>
@@ -38,7 +38,7 @@
struct ioapic {
struct acpi_madt_ioapic table_data;
rw_spin_lock_t lock;
spin_lock_t lock;
uintptr_t mmio_base;
};
@@ -59,10 +59,10 @@ static spin_lock_t lapic_calibration_lock = SPIN_LOCK_INIT;
static uint32_t amd64_ioapic_read (struct ioapic* ioapic, uint32_t reg) {
spin_lock_ctx_t ctxioar;
rw_spin_read_lock (&ioapic->lock, &ctxioar);
spin_lock (&ioapic->lock, &ctxioar);
*(volatile uint32_t*)ioapic->mmio_base = reg;
uint32_t ret = *(volatile uint32_t*)(ioapic->mmio_base + 0x10);
rw_spin_read_unlock (&ioapic->lock, &ctxioar);
spin_unlock (&ioapic->lock, &ctxioar);
return ret;
}
@@ -70,10 +70,10 @@ static uint32_t amd64_ioapic_read (struct ioapic* ioapic, uint32_t reg) {
static void amd64_ioapic_write (struct ioapic* ioapic, uint32_t reg, uint32_t value) {
spin_lock_ctx_t ctxioaw;
rw_spin_write_lock (&ioapic->lock, &ctxioaw);
spin_lock (&ioapic->lock, &ctxioaw);
*(volatile uint32_t*)ioapic->mmio_base = reg;
*(volatile uint32_t*)(ioapic->mmio_base + 0x10) = value;
rw_spin_write_unlock (&ioapic->lock, &ctxioaw);
spin_unlock (&ioapic->lock, &ctxioaw);
}
/* Find an IOAPIC corresposting to provided IRQ */
@@ -162,7 +162,7 @@ void amd64_ioapic_init (void) {
(uintptr_t)hhdm->offset + (uintptr_t)ioapic_table_data->address,
MM_PG_PRESENT | MM_PG_RW);
ioapics[ioapic_entries++] = (struct ioapic){
.lock = RW_SPIN_LOCK_INIT,
.lock = SPIN_LOCK_INIT,
.table_data = *ioapic_table_data,
.mmio_base = ((uintptr_t)hhdm->offset + (uintptr_t)ioapic_table_data->address),
};