apic: enable LAPIC on application processors

This commit is contained in:
Michael Shaw 2023-11-01 19:18:31 -04:00
commit eaf5254b3b
3 changed files with 11 additions and 2 deletions

View file

@ -80,6 +80,12 @@ void lapic_eoi()
lapic_write(lapic_addr, LAPIC_EOI, 0);
}
void lapic_enable()
{
/* Set spurious interrupt vector to 0xFF and enable the LAPIC */
lapic_write(lapic_addr, 0xF0, 0x1FF);
}
void apic_init()
{
if (__madt == NULL) {
@ -107,8 +113,7 @@ void apic_init()
lapic_id = lapic_read(lapic_addr, 0x20);
ioapic_redirect_insert(4, 0x24, 0, 0);
/* Set spurious interrupt vector to 0xFF and enable the LAPIC */
lapic_write(lapic_addr, 0xF0, 0x1FF);
lapic_enable();
uint64_t msr = rdmsr(MSR_IA32_APIC_BASE);
msr |= 1 << 11;

View file

@ -130,6 +130,7 @@ struct apic_redirect {
void apic_init();
void lapic_eoi();
int madt_parse_next_entry(int offset);
void lapic_enable();
#endif /* __ASM__ */
#endif /* _APIC_H_ */

View file

@ -193,6 +193,9 @@ void ap_kmain(struct limine_smp_info *info)
idt_load();
cr3_write(kcr3);
/* enable the APIC */
lapic_enable();
void *kstack = buddy_alloc(KSTACK_SIZE);
uintptr_t ptr = (uintptr_t)kstack + KSTACK_SIZE - 8;