+ cpu_interrupt(PROCESSOR_DATA(processor, slot_num));
+}
+
+kern_return_t
+ml_processor_register(
+ cpu_id_t cpu_id,
+ uint32_t lapic_id,
+ processor_t *processor_out,
+ ipi_handler_t *ipi_handler,
+ boolean_t boot_cpu)
+{
+ int target_cpu;
+ cpu_data_t *this_cpu_datap;
+
+ this_cpu_datap = cpu_data_alloc(boot_cpu);
+ if (this_cpu_datap == NULL) {
+ return KERN_FAILURE;
+ }
+ target_cpu = this_cpu_datap->cpu_number;
+ assert((boot_cpu && (target_cpu == 0)) ||
+ (!boot_cpu && (target_cpu != 0)));
+
+ lapic_cpu_map(lapic_id, target_cpu);
+
+ this_cpu_datap->cpu_id = cpu_id;
+ this_cpu_datap->cpu_phys_number = lapic_id;
+
+ this_cpu_datap->cpu_console_buf = console_cpu_alloc(boot_cpu);
+ if (this_cpu_datap->cpu_console_buf == NULL)
+ goto failed;
+
+ if (!boot_cpu) {
+ this_cpu_datap->cpu_pmap = pmap_cpu_alloc(boot_cpu);
+ if (this_cpu_datap->cpu_pmap == NULL)
+ goto failed;
+
+ this_cpu_datap->cpu_processor = cpu_processor_alloc(boot_cpu);
+ if (this_cpu_datap->cpu_processor == NULL)
+ goto failed;
+ processor_init(this_cpu_datap->cpu_processor, target_cpu);
+ }
+
+ *processor_out = this_cpu_datap->cpu_processor;
+ *ipi_handler = NULL;
+
+ return KERN_SUCCESS;
+
+failed:
+ cpu_processor_free(this_cpu_datap->cpu_processor);
+ pmap_cpu_free(this_cpu_datap->cpu_pmap);
+ console_cpu_free(this_cpu_datap->cpu_console_buf);
+ return KERN_FAILURE;
+}
+
+void
+ml_cpu_get_info(ml_cpu_info_t *cpu_infop)
+{
+ boolean_t os_supports_sse;
+ i386_cpu_info_t *cpuid_infop;
+
+ if (cpu_infop == NULL)
+ return;
+
+ /*
+ * Are we supporting XMM/SSE/SSE2?
+ * As distinct from whether the cpu has these capabilities.
+ */
+ os_supports_sse = get_cr4() & CR4_XMM;
+ if ((cpuid_features() & CPUID_FEATURE_SSE2) && os_supports_sse)
+ cpu_infop->vector_unit = 4;
+ else if ((cpuid_features() & CPUID_FEATURE_SSE) && os_supports_sse)
+ cpu_infop->vector_unit = 3;
+ else if (cpuid_features() & CPUID_FEATURE_MMX)
+ cpu_infop->vector_unit = 2;
+ else
+ cpu_infop->vector_unit = 0;
+
+ cpuid_infop = cpuid_info();
+
+ cpu_infop->cache_line_size = cpuid_infop->cache_linesize;
+
+ cpu_infop->l1_icache_size = cpuid_infop->cache_size[L1I];
+ cpu_infop->l1_dcache_size = cpuid_infop->cache_size[L1D];
+
+ if (cpuid_infop->cache_size[L2U] > 0) {
+ cpu_infop->l2_settings = 1;
+ cpu_infop->l2_cache_size = cpuid_infop->cache_size[L2U];
+ } else {
+ cpu_infop->l2_settings = 0;
+ cpu_infop->l2_cache_size = 0xFFFFFFFF;
+ }
+
+ if (cpuid_infop->cache_size[L3U] > 0) {
+ cpu_infop->l2_settings = 1;
+ cpu_infop->l2_cache_size = cpuid_infop->cache_size[L3U];
+ } else {
+ cpu_infop->l3_settings = 0;
+ cpu_infop->l3_cache_size = 0xFFFFFFFF;
+ }
+}
+
+void
+ml_init_max_cpus(unsigned long max_cpus)
+{
+ boolean_t current_state;
+
+ current_state = ml_set_interrupts_enabled(FALSE);
+ if (max_cpus_initialized != MAX_CPUS_SET) {
+ if (max_cpus > 0 && max_cpus <= MAX_CPUS) {
+ /*
+ * Note: max_cpus is the number of enable processors
+ * that ACPI found; max_ncpus is the maximum number
+ * that the kernel supports or that the "cpus="
+ * boot-arg has set. Here we take int minimum.
+ */
+ machine_info.max_cpus = MIN(max_cpus, max_ncpus);
+ }
+ if (max_cpus_initialized == MAX_CPUS_WAIT)
+ wakeup((event_t)&max_cpus_initialized);
+ max_cpus_initialized = MAX_CPUS_SET;
+ }
+ (void) ml_set_interrupts_enabled(current_state);
+}
+
+int
+ml_get_max_cpus(void)
+{
+ boolean_t current_state;
+
+ current_state = ml_set_interrupts_enabled(FALSE);
+ if (max_cpus_initialized != MAX_CPUS_SET) {
+ max_cpus_initialized = MAX_CPUS_WAIT;
+ assert_wait((event_t)&max_cpus_initialized, THREAD_UNINT);
+ (void)thread_block(THREAD_CONTINUE_NULL);
+ }
+ (void) ml_set_interrupts_enabled(current_state);
+ return(machine_info.max_cpus);
+}
+
+/*
+ * This is called from the machine-independent routine cpu_up()
+ * to perform machine-dependent info updates. Defer to cpu_thread_init().
+ */
+void
+ml_cpu_up(void)
+{
+ return;
+}
+
+/*
+ * This is called from the machine-independent routine cpu_down()
+ * to perform machine-dependent info updates.
+ */
+void
+ml_cpu_down(void)
+{
+ return;