fix: read_reg and write_reg are better now, no more double fault
This commit is contained in:
parent
d6b35a2786
commit
83e513c32f
@ -31,13 +31,3 @@ static inline void io_wait(void)
|
||||
{
|
||||
outb(0x80, 0);
|
||||
}
|
||||
|
||||
static inline void write_reg(size_t addr, uint32_t val)
|
||||
{
|
||||
*(volatile uint32_t *)addr = val;
|
||||
}
|
||||
|
||||
static inline uint32_t read_reg(size_t addr)
|
||||
{
|
||||
return *(volatile uint32_t *)addr;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "apic.h"
|
||||
#include "cpuid.h"
|
||||
#include "sys/io.h"
|
||||
#include <cpuid.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -49,6 +48,16 @@ static uintptr_t cpu_get_apic_base(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t read_apic_register(uint32_t reg)
|
||||
{
|
||||
return *((volatile uint32_t *)(cpu_get_apic_base()) + reg);
|
||||
}
|
||||
|
||||
static void write_apic_register(uint32_t reg, uint32_t value)
|
||||
{
|
||||
*((volatile uint32_t *)(cpu_get_apic_base() + reg)) = value;
|
||||
}
|
||||
|
||||
void enable_apic(void)
|
||||
{
|
||||
/* Hardware enable the Local APIC if it wasn't enabled */
|
||||
@ -56,5 +65,5 @@ void enable_apic(void)
|
||||
|
||||
/* Set the Spurious Interrupt Vector Register bit 8 to start receiving
|
||||
* interrupts */
|
||||
write_reg(0xF0, read_reg(0xF0) | 0x100);
|
||||
write_apic_register(0xF0, read_apic_register(0xF0) | 0x100);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user