[haiku-commits] r33951 - in haiku/trunk: headers/private/kernel/arch/x86 src/system/kernel/arch/x86

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 8 Nov 2009 18:31:39 +0100 (CET)

Author: axeld
Date: 2009-11-08 18:31:39 +0100 (Sun, 08 Nov 2009)
New Revision: 33951
Changeset: http://dev.haiku-os.org/changeset/33951/haiku

Modified:
   haiku/trunk/headers/private/kernel/arch/x86/arch_int.h
   haiku/trunk/src/system/kernel/arch/x86/arch_int.cpp
Log:
* Cleanup, no functional change.


Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_int.h
===================================================================
--- haiku/trunk/headers/private/kernel/arch/x86/arch_int.h      2009-11-08 
15:48:05 UTC (rev 33950)
+++ haiku/trunk/headers/private/kernel/arch/x86/arch_int.h      2009-11-08 
17:31:39 UTC (rev 33951)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved.
+ * Copyright 2005-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 #ifndef _KERNEL_ARCH_x86_INT_H
@@ -25,14 +25,14 @@
        asm volatile("pushfl;\n"
                "popl %0;\n"
                "cli" : "=g" (flags));
-       return flags & 0x200 ? 1 : 0;
+       return (flags & 0x200) != 0;
 }
 
 
 static inline void
-arch_int_restore_interrupts_inline(int oldstate)
+arch_int_restore_interrupts_inline(int oldState)
 {
-       int flags = oldstate ? 0x200 : 0;
+       int flags = oldState ? 0x200 : 0;
 
        asm volatile("pushfl;\n"
                "popl   %0;\n"
@@ -51,7 +51,7 @@
 
        asm volatile("pushfl;\n"
                "popl %0;\n" : "=g" (flags));
-       return flags & 0x200 ? 1 : 0;
+       return (flags & 0x200) != 0;
 }
 
 

Modified: haiku/trunk/src/system/kernel/arch/x86/arch_int.cpp
===================================================================
--- haiku/trunk/src/system/kernel/arch/x86/arch_int.cpp 2009-11-08 15:48:05 UTC 
(rev 33950)
+++ haiku/trunk/src/system/kernel/arch/x86/arch_int.cpp 2009-11-08 17:31:39 UTC 
(rev 33951)
@@ -1,12 +1,13 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxxx
- * Copyright 2002-2008, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * Copyright 2002-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  *
  * Copyright 2001, Travis Geiselbrecht. All rights reserved.
  * Distributed under the terms of the NewOS License.
  */
 
+
 #include <cpu.h>
 #include <int.h>
 #include <kscheduler.h>
@@ -42,6 +43,7 @@
 #      define TRACE(x) ;
 #endif
 
+
 // Definitions for the PIC 8259 controller
 // (this is not a complete list, only what we're actually using)
 
@@ -143,9 +145,8 @@
        void    (*end_of_interrupt)(int32 num);
 } interrupt_controller;
 
-static interrupt_controller *sCurrentPIC = NULL;
+static const interrupt_controller *sCurrentPIC = NULL;
 
-
 static const char *kInterruptNames[] = {
        /*  0 */ "Divide Error Exception",
        /*  1 */ "Debug Exception",
@@ -250,11 +251,13 @@
 }
 
 
-/**    Tests if the interrupt in-service register of the responsible
- *     PIC is set for interrupts 7 and 15, and if that's not the case,
- *     it must assume it's a spurious interrupt.
- */
+// #pragma mark - PIC
 
+
+/*!    Tests if the interrupt in-service register of the responsible
+       PIC is set for interrupts 7 and 15, and if that's not the case,
+       it must assume it's a spurious interrupt.
+*/
 static bool
 pic_is_spurious_interrupt(int32 num)
 {
@@ -275,11 +278,10 @@
 }
 
 
-/**    Sends a non-specified EOI (end of interrupt) notice to the PIC in
- *     question (or both of them).
- *     This clears the PIC interrupt in-service bit.
- */
-
+/*!    Sends a non-specified EOI (end of interrupt) notice to the PIC in
+       question (or both of them).
+       This clears the PIC interrupt in-service bit.
+*/
 static void
 pic_end_of_interrupt(int32 num)
 {
@@ -415,6 +417,9 @@
 }
 
 
+// #pragma mark - I/O APIC
+
+
 static inline uint32
 ioapic_read_32(uint8 registerSelect)
 {
@@ -540,13 +545,7 @@
 static void
 ioapic_init(kernel_args *args)
 {
-       uint32 i;
-       uint32 version;
-       uint64 targetAPIC;
-       void *settings;
-       acpi_module_info *acpi;
-
-       static interrupt_controller ioapicController = {
+       static const interrupt_controller ioapicController = {
                "82093AA IOAPIC",
                &ioapic_enable_io_interrupt,
                &ioapic_disable_io_interrupt,
@@ -560,18 +559,12 @@
                return;
        }
 
-       bool disableAPIC = false;       
-       void *handle = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS);
-       if (handle != NULL) {
-               disableAPIC = get_driver_boolean_parameter(handle, 
B_SAFEMODE_DISABLE_APIC,
-                       disableAPIC, disableAPIC);
-               unload_driver_settings(handle);
-       }
-       
+       bool disableAPIC = get_safemode_boolean(B_SAFEMODE_DISABLE_APIC, false);
        if (disableAPIC) {
                args->arch_args.apic = NULL;
                return;
        }
+
        // always map the local apic as it can be used for timers even if we
        // don't end up using the io apic
        sLocalAPIC = args->arch_args.apic;
@@ -581,23 +574,22 @@
                panic("mapping the local apic failed");
                return;
        }
-       
+
        if (args->arch_args.ioapic == NULL) {
                dprintf("no ioapic available, not using ioapics for interrupt 
routing\n");
                return;
        }
 
-       settings = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS);
-       if (settings != NULL && get_driver_boolean_parameter(settings,
-               B_SAFEMODE_DISABLE_IOAPIC, false, false)) {
-               dprintf("ioapic explicitly disabled, not using ioapics for 
interrupt routing\n");
-               unload_driver_settings(settings);
+       if (!get_safemode_boolean(B_SAFEMODE_DISABLE_IOAPIC, false)) {
+               dprintf("ioapic explicitly disabled, not using ioapics for 
interrupt "
+                       "routing\n");
                return;
-       } else if (settings != NULL)
-               unload_driver_settings(settings);
+       }
 
        // TODO: remove when the PCI IRQ routing through ACPI is available below
        return;
+
+       acpi_module_info *acpi;
        if (get_module(B_ACPI_MODULE_NAME, (module_info **)&acpi) != B_OK) {
                dprintf("acpi module not available, not configuring ioapic\n");
                return;
@@ -606,13 +598,13 @@
        // map in the ioapic
        sIOAPIC = (ioapic *)args->arch_args.ioapic;
        if (map_physical_memory("ioapic", (void *)args->arch_args.ioapic_phys,
-               B_PAGE_SIZE, B_EXACT_ADDRESS, B_KERNEL_READ_AREA | 
B_KERNEL_WRITE_AREA,
-               (void **)&sIOAPIC) < B_OK) {
+                       B_PAGE_SIZE, B_EXACT_ADDRESS,
+                       B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void 
**)&sIOAPIC) < 0) {
                panic("mapping the ioapic failed");
                return;
        }
 
-       version = ioapic_read_32(IO_APIC_VERSION);
+       uint32 version = ioapic_read_32(IO_APIC_VERSION);
        if (version == 0xffffffff) {
                dprintf("ioapic seems inaccessible, not using it\n");
                return;
@@ -621,13 +613,13 @@
        sLevelTriggeredInterrupts = 0;
        sIOAPICMaxRedirectionEntry
                = ((version >> IO_APIC_MAX_REDIRECTION_ENTRY_SHIFT)
-               & IO_APIC_MAX_REDIRECTION_ENTRY_MASK);
+                       & IO_APIC_MAX_REDIRECTION_ENTRY_MASK);
 
        // use the boot CPU as the target for all interrupts
-       targetAPIC = args->arch_args.cpu_apic_id[0];
+       uint64 targetAPIC = args->arch_args.cpu_apic_id[0];
 
        // program the interrupt vectors of the ioapic
-       for (i = 0; i <= sIOAPICMaxRedirectionEntry; i++) {
+       for (uint32 i = 0; i <= sIOAPICMaxRedirectionEntry; i++) {
                // initialize everything to deliver to the boot CPU in physical 
mode
                // and masked until explicitly enabled through 
enable_io_interrupt()
                uint64 entry = (targetAPIC << IO_APIC_DESTINATION_FIELD_SHIFT)
@@ -657,7 +649,7 @@
        }
 
        // setup default 1:1 mapping
-       for (i = 0; i < 256; i++)
+       for (uint32 i = 0; i < 256; i++)
                sIRQToIOAPICPin[i] = i;
 
        // TODO: here ACPI needs to be used to properly set up the PCI IRQ
@@ -671,6 +663,9 @@
 }
 
 
+// #pragma mark -
+
+
 void
 arch_int_enable_io_interrupt(int irq)
 {
@@ -713,9 +708,9 @@
 
 
 void
-arch_int_restore_interrupts(int oldstate)
+arch_int_restore_interrupts(int oldState)
 {
-       arch_int_restore_interrupts_inline(oldstate);
+       arch_int_restore_interrupts_inline(oldState);
 }
 
 


Other related posts:

  • » [haiku-commits] r33951 - in haiku/trunk: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 - axeld