-/* $OpenBSD: acpimadt.c,v 1.19 2008/06/11 04:42:09 marco Exp $ */
+/* $OpenBSD: acpimadt.c,v 1.20 2008/08/10 09:59:55 kettenis Exp $ */
/*
* Copyright (c) 2006 Mark Kettenis <kettenis@openbsd.org>
*
struct aml_value arg;
struct mp_intr_map *map;
struct ioapic_softc *apic;
- int cpu_role = CPU_ROLE_BP;
int nlapic_nmis = 0;
int pin;
/* 1st pass, get CPUs and IOAPICs */
while (addr < (caddr_t)madt + madt->hdr.length) {
union acpi_madt_entry *entry = (union acpi_madt_entry *)addr;
+ struct cpu_attach_args caa;
+ struct apic_attach_args aaa;
switch (entry->madt_lapic.apic_type) {
case ACPI_MADT_LAPIC:
acpi_lapic_flags[entry->madt_lapic.acpi_proc_id] =
entry->madt_lapic.flags;
- {
- struct cpu_attach_args caa;
-
- if ((entry->madt_lapic.flags & ACPI_PROC_ENABLE) == 0)
- break;
+ if ((entry->madt_lapic.flags & ACPI_PROC_ENABLE) == 0)
+ break;
- memset(&caa, 0, sizeof(struct cpu_attach_args));
- caa.cpu_role = cpu_role;
- caa.caa_name = "cpu";
- caa.cpu_number = entry->madt_lapic.apic_id;
- caa.cpu_func = &mp_cpu_funcs;
+ memset(&caa, 0, sizeof(struct cpu_attach_args));
+ if (lapic_cpu_number() == entry->madt_lapic.apic_id)
+ caa.cpu_role = CPU_ROLE_BP;
+ else
+ caa.cpu_role = CPU_ROLE_AP;
+ caa.caa_name = "cpu";
+ caa.cpu_number = entry->madt_lapic.apic_id;
+ caa.cpu_func = &mp_cpu_funcs;
#ifdef __i386__
- /*
- * XXX utterly wrong. These are the
- * cpu_feature/cpu_id from the BSP cpu,
- * now being given to another cpu.
- * This is bullshit.
- */
- extern int cpu_id, cpu_feature;
- caa.cpu_signature = cpu_id;
- caa.feature_flags = cpu_feature;
+ /*
+ * XXX utterly wrong. These are the
+ * cpu_feature/cpu_id from the BSP cpu, now
+ * being given to another cpu. This is
+ * bullshit.
+ */
+ extern int cpu_id, cpu_feature;
+ caa.cpu_signature = cpu_id;
+ caa.feature_flags = cpu_feature;
#endif
- config_found(mainbus, &caa, acpimadt_print);
-
- cpu_role = CPU_ROLE_AP;
- }
+ config_found(mainbus, &caa, acpimadt_print);
break;
case ACPI_MADT_IOAPIC:
dprintf("%s: IOAPIC: acpi_ioapic_id %x, address 0x%x, global_int_base 0x%x\n",
entry->madt_ioapic.address,
entry->madt_ioapic.global_int_base);
- {
- struct apic_attach_args aaa;
-
- memset(&aaa, 0, sizeof(struct apic_attach_args));
- aaa.aaa_name = "ioapic";
- aaa.apic_id = entry->madt_ioapic.acpi_ioapic_id;
- aaa.apic_address = entry->madt_ioapic.address;
- aaa.apic_vecbase = entry->madt_ioapic.global_int_base;
+ memset(&aaa, 0, sizeof(struct apic_attach_args));
+ aaa.aaa_name = "ioapic";
+ aaa.apic_id = entry->madt_ioapic.acpi_ioapic_id;
+ aaa.apic_address = entry->madt_ioapic.address;
+ aaa.apic_vecbase = entry->madt_ioapic.global_int_base;
- config_found(mainbus, &aaa, acpimadt_print);
- }
+ config_found(mainbus, &aaa, acpimadt_print);
break;
case ACPI_MADT_LAPIC_NMI:
nlapic_nmis++;