fix/kernel: Fixed LAPIC r/w
This commit is contained in:
parent
3892fc04c4
commit
03cc8ff8de
2 changed files with 21 additions and 3 deletions
|
@ -232,6 +232,9 @@ void paging_init(void)
|
|||
}
|
||||
memset(kernel_pagemap, 0, PAGE_SIZE);
|
||||
|
||||
if (_supports_large_pages())
|
||||
log_early("Support for 2MB pages is present");
|
||||
|
||||
/* Map kernel stack */
|
||||
uint64_t stack_top = ALIGN_UP(kstack_top, PAGE_SIZE);
|
||||
for (uint64_t addr = stack_top - (16 * 1024); addr < stack_top; addr += PAGE_SIZE)
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#include <stdatomic.h>
|
||||
#include <sys/kpanic.h>
|
||||
|
||||
#define LAPIC_REG_ALIGN 16
|
||||
#define LAPIC_REG_SIZE 4
|
||||
|
||||
atomic_uintptr_t lapic_msr = 0;
|
||||
atomic_uintptr_t lapic_base_atomic = 0;
|
||||
|
||||
|
@ -19,7 +22,13 @@ void lapic_write(uint32_t offset, uint32_t value)
|
|||
log_early("error: LAPIC not initialized!");
|
||||
kpanic(NULL, "LAPIC write attempted before initialization");
|
||||
}
|
||||
base[offset / 4] = value;
|
||||
if (offset % LAPIC_REG_ALIGN != 0)
|
||||
{
|
||||
log_early("error: Misaligned LAPIC offset 0x%x", offset);
|
||||
kpanic(NULL, "Invalid LAPIC register offset");
|
||||
}
|
||||
volatile uint32_t *reg = base + (offset / LAPIC_REG_SIZE);
|
||||
*reg = value;
|
||||
}
|
||||
|
||||
uint32_t lapic_read(uint32_t offset)
|
||||
|
@ -30,7 +39,13 @@ uint32_t lapic_read(uint32_t offset)
|
|||
log_early("error: LAPIC not initialized!");
|
||||
return 0;
|
||||
}
|
||||
return base[offset / 4];
|
||||
if (offset % LAPIC_REG_ALIGN != 0)
|
||||
{
|
||||
log_early("error: Misaligned LAPIC offset 0x%x", offset);
|
||||
kpanic(NULL, "Invalid LAPIC register offset");
|
||||
}
|
||||
volatile uint32_t *reg = base + (offset / LAPIC_REG_SIZE);
|
||||
return *reg;
|
||||
}
|
||||
|
||||
void lapic_init(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue