]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/lapic_native.c
xnu-3247.1.106.tar.gz
[apple/xnu.git] / osfmk / i386 / lapic_native.c
index 347b9e969597f862f2069c69aba1fa14b817ca67..1a1bc5845f24dfa5c96c4a21887d9d07cb6fc430 100644 (file)
 #include <i386/machine_check.h>
 #endif
 
-#if CONFIG_COUNTERS
-#include <pmc/pmc.h>
-#endif
-
 #include <sys/kdebug.h>
 
 #if    MP_DEBUG
@@ -121,7 +117,7 @@ legacy_init(void)
                result = vm_map_find_space(kernel_map,
                                           &lapic_vbase64,
                                           round_page(LAPIC_SIZE), 0,
-                                          VM_MAKE_TAG(VM_MEMORY_IOKIT), &entry);
+                                          VM_MAKE_TAG(VM_KERN_MEMORY_IOKIT), &entry);
                /* Convert 64-bit vm_map_offset_t to "pointer sized" vm_offset_t
                 */
                lapic_vbase = (vm_offset_t) lapic_vbase64;
@@ -284,6 +280,7 @@ lapic_init(void)
        /* Set up the lapic_id <-> cpu_number map and add this boot processor */
        lapic_cpu_map_init();
        lapic_cpu_map((LAPIC_READ(ID)>>LAPIC_ID_SHIFT)&LAPIC_ID_MASK, 0);
+       current_cpu_datap()->cpu_phys_number = cpu_to_lapic[0];
        kprintf("Boot cpu local APIC id 0x%x\n", cpu_to_lapic[0]);
 }
 
@@ -443,6 +440,10 @@ lapic_probe(void)
                 * Re-initialize cpu features info and re-check.
                 */
                cpuid_set_info();
+               /* We expect this codepath will never be traversed
+                * due to EFI enabling the APIC. Reducing the APIC
+                * interrupt base dynamically is not supported.
+                */
                if (cpuid_features() & CPUID_FEATURE_APIC) {
                        printf("Local APIC discovered and enabled\n");
                        lapic_os_enabled = TRUE;
@@ -795,17 +796,12 @@ lapic_interrupt(int interrupt_num, x86_saved_state_t *state)
                break;
        case LAPIC_PMC_SW_INTERRUPT: 
                {
-#if CONFIG_COUNTERS
-                       thread_t old, new;
-                       ml_get_csw_threads(&old, &new);
-
-                       if (pmc_context_switch(old, new) == TRUE) {
-                               retval = 1;
-                               /* No EOI required for SWI */
-                       }
-#endif /* CONFIG_COUNTERS */
                }
                break;
+       case LAPIC_KICK_INTERRUPT:
+               _lapic_end_of_interrupt();
+               retval = 1;
+               break;
        }
 
        return retval;
@@ -949,3 +945,26 @@ lapic_disable_timer(void)
        }
 }
 
+/* SPI returning the CMCI vector */
+uint8_t
+lapic_get_cmci_vector(void)
+{
+       uint8_t cmci_vector = 0;
+#if CONFIG_MCA
+       /* CMCI, if available */
+       if (mca_is_cmci_present())
+               cmci_vector = LAPIC_VECTOR(CMCI);
+#endif
+       return cmci_vector;
+}
+
+#if DEBUG
+extern void lapic_trigger_MC(void);
+void
+lapic_trigger_MC(void)
+{
+       /* A 64-bit access to any register will do it. */
+       volatile uint64_t dummy = *(volatile uint64_t *) (volatile void *) LAPIC_MMIO(ID);
+       dummy++;
+}
+#endif