Use RW spin locks
All checks were successful
Build documentation / build-and-deploy (push) Successful in 39s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 39s
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include <amd64/msr.h>
|
||||
#include <libk/std.h>
|
||||
#include <limine/requests.h>
|
||||
#include <sync/spin_lock.h>
|
||||
#include <sync/rw_spin_lock.h>
|
||||
#include <sys/debug.h>
|
||||
#include <sys/mm.h>
|
||||
#include <sys/spin.h>
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
struct ioapic {
|
||||
struct acpi_madt_ioapic table_data;
|
||||
spin_lock_t lock;
|
||||
rw_spin_lock_t lock;
|
||||
uintptr_t mmio_base;
|
||||
};
|
||||
|
||||
@@ -55,19 +55,19 @@ static uint64_t lapic_ticks;
|
||||
|
||||
/* Read IOAPIC */
|
||||
static uint32_t amd64_ioapic_read (struct ioapic* ioapic, uint32_t reg) {
|
||||
spin_lock (&ioapic->lock);
|
||||
rw_spin_read_lock (&ioapic->lock);
|
||||
*(volatile uint32_t*)ioapic->mmio_base = reg;
|
||||
uint32_t ret = *(volatile uint32_t*)(ioapic->mmio_base + 0x10);
|
||||
spin_unlock (&ioapic->lock);
|
||||
rw_spin_read_unlock (&ioapic->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Write IOAPIC */
|
||||
static void amd64_ioapic_write (struct ioapic* ioapic, uint32_t reg, uint32_t value) {
|
||||
spin_lock (&ioapic->lock);
|
||||
rw_spin_write_lock (&ioapic->lock);
|
||||
*(volatile uint32_t*)ioapic->mmio_base = reg;
|
||||
*(volatile uint32_t*)(ioapic->mmio_base + 0x10) = value;
|
||||
spin_unlock (&ioapic->lock);
|
||||
rw_spin_write_unlock (&ioapic->lock);
|
||||
}
|
||||
|
||||
/* Find an IOAPIC corresposting to provided IRQ */
|
||||
@@ -160,7 +160,7 @@ void amd64_ioapic_init (void) {
|
||||
(uintptr_t)hhdm->offset + (uintptr_t)ioapic_table_data->address,
|
||||
MM_PG_PRESENT | MM_PG_RW | MM_PD_RELOAD);
|
||||
ioapics[ioapic_entries++] = (struct ioapic){
|
||||
.lock = SPIN_LOCK_INIT,
|
||||
.lock = RW_SPIN_LOCK_INIT,
|
||||
.table_data = *ioapic_table_data,
|
||||
.mmio_base = ((uintptr_t)hhdm->offset + (uintptr_t)ioapic_table_data->address),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user