x86_64: more local and i/o apic configuration

This commit is contained in:
2023-03-20 20:21:44 +00:00
parent 8e9127cd6a
commit a4d850cc03
6 changed files with 71 additions and 11 deletions

View File

@@ -89,21 +89,43 @@ kern_status_t local_apic_enable(void)
static void configure_legacy_pic(void)
{
printk("acpi: APIC unavailable, using 8259 PIC");
pit_init(1000);
pit_start(1000);
}
static void ioapic_init(void)
{
}
static void init_all_ioapic(void)
{
ioapic_init();
}
kern_status_t apic_init(void)
{
if (check_apic() == 0) {
static int bsp_id = -1;
/* the bootstrap processor will be the first one ro call apic_init().
it is responsible for initialising the I/O APICs */
if (bsp_id == -1) {
bsp_id = this_cpu();
}
struct acpi_madt *madt = (struct acpi_madt *)acpi_find_sdt(ACPI_SIG_MADT);
if (check_apic() == 0 || !madt) {
configure_legacy_pic();
return KERN_UNSUPPORTED;
}
if (local_apic_enable() != KERN_OK) {
configure_legacy_pic();
return KERN_UNSUPPORTED;
if (this_cpu() == bsp_id) {
init_all_ioapic();
}
disable_8259();
local_apic_enable();
disable_8259();
pit_start(10);
return KERN_OK;
}