From fba2ee2527563001dbab46b4aa15570bf47c00bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 15 Apr 2010 13:54:15 +0000 Subject: [PATCH] * We should check for the I/O APIC before mapping it (since we panic if mapping it failed...). * Moved IRQ table reading much earlier (before starting to program the I/O APIC), though it currently fails, possibly because the device manager isn't up yet, and there is no embedded controller driver. * The kernel now enables I/O APICs by default, but the boot loader disables them - you can now enable them using the safe mode menu, but it currently won't have any (positive) effect. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36293 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/bios_ia32/smp.cpp | 7 ++-- src/system/kernel/arch/x86/arch_int.cpp | 39 ++++++++++++---------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/system/boot/platform/bios_ia32/smp.cpp b/src/system/boot/platform/bios_ia32/smp.cpp index 6b63742229..779680e130 100644 --- a/src/system/boot/platform/bios_ia32/smp.cpp +++ b/src/system/boot/platform/bios_ia32/smp.cpp @@ -577,16 +577,17 @@ void smp_add_safemode_menus(Menu *menu) { MenuItem *item; -#if 0 + if (gKernelArgs.arch_args.ioapic_phys != 0) { - // TODO: IOAPIC isn't yet used anywhere menu->AddItem(item = new(nothrow) MenuItem("Disable IO-APIC")); item->SetType(MENU_ITEM_MARKABLE); + item->SetMarked(true); + // TODO: disabled by default for now item->SetData(B_SAFEMODE_DISABLE_IOAPIC); item->SetHelpText("Disables using the IO APIC for interrupt handling, " "forcing instead the use of the PIC."); } -#endif + if (gKernelArgs.arch_args.apic_phys != 0) { menu->AddItem(item = new(nothrow) MenuItem("Disable LOCAL APIC")); item->SetType(MENU_ITEM_MARKABLE); diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp index 2cc09b5658..55bca5cd37 100644 --- a/src/system/kernel/arch/x86/arch_int.cpp +++ b/src/system/kernel/arch/x86/arch_int.cpp @@ -540,6 +540,16 @@ ioapic_configure_io_interrupt(int32 num, uint32 config) static void ioapic_map(kernel_args* args) { + if (args->arch_args.apic == NULL) { + dprintf("no local apic available\n"); + return; + } + + if (args->arch_args.ioapic == NULL) { + dprintf("no ioapic available, not using ioapics for interrupt routing\n"); + return; + } + // map in the ioapic sIOAPIC = (ioapic *)args->arch_args.ioapic; if (vm_map_physical_memory(B_SYSTEM_TEAM, "ioapic", (void**)&sIOAPIC, @@ -564,17 +574,10 @@ ioapic_init(kernel_args* args) &ioapic_end_of_interrupt }; - if (args->arch_args.apic == NULL) { - dprintf("no local apic available\n"); + if (sIOAPIC == NULL) return; - } - if (args->arch_args.ioapic == NULL) { - dprintf("no ioapic available, not using ioapics for interrupt routing\n"); - return; - } - - if (!get_safemode_boolean(B_SAFEMODE_DISABLE_IOAPIC, false)) { + if (!get_safemode_boolean(B_SAFEMODE_DISABLE_IOAPIC, true)) { dprintf("ioapic explicitly disabled, not using ioapics for interrupt " "routing\n"); return; @@ -607,6 +610,16 @@ ioapic_init(kernel_args* args) CObjectDeleter pciModulePutter(B_PCI_MODULE_NAME, put_module); + // TODO: here ACPI needs to be used to properly set up the PCI IRQ + // routing. + + IRQRoutingTable table; + status = read_irq_routing_table(pciModule, acpiModule, &table); + if (status != B_OK) { + dprintf("reading IRQ routing table failed, no ioapic.\n"); + return; + } + sLevelTriggeredInterrupts = 0; sIOAPICMaxRedirectionEntry = ((version >> IO_APIC_MAX_REDIRECTION_ENTRY_SHIFT) @@ -649,14 +662,6 @@ ioapic_init(kernel_args* args) for (uint32 i = 0; i < 256; i++) sIRQToIOAPICPin[i] = i; - // TODO: here ACPI needs to be used to properly set up the PCI IRQ - // routing. - - IRQRoutingTable table; - status = read_irq_routing_table(pciModule, acpiModule, &table); - if (status != B_OK) - return; - // configure apic interrupts assume 1:1 mapping for (int i = 0; i < table.Count(); i++) { irq_routing_entry& entry = table.ElementAt(i);