MADT MP probe: Rework cpuid mapping, and cpuid to apicid mapping
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 14 Jun 2009 11:39:44 +0000 (19:39 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 14 Jun 2009 11:39:44 +0000 (19:39 +0800)
commit223bf214b579c486a04c63795cdf9808b2e87b14
treecdb8cd33a7f76f2ee866d43dd261ab1ff22433ee
parentc408a8b3d9268245f7f2af65399dd3f6d464d2a6
MADT MP probe: Rework cpuid mapping, and cpuid to apicid mapping

- Don't use the ACPI ProcessorID as our cpuid, some BIOSes count ProcessorID
  from 1, and ACPI standards actually allow that.  Instead, except for BSP,
  we set the processor's cpuid in the order that we found the MADT LAPIC
  entry.
- Since MADT does not provide a way to identify the BSP, we will have to do
  it ourselves:

  Split the madt_parse() into three parts:
  o  madt_check(), preliminary length and revision check.
  o  madt_pass1(), locate the LAPIC address.
  o  madt_pass2(), set mp_naps and map cpuid to apicid.

  After madt_pass1(), the lapic is mapped, so we could get the current CPU's
  apic id.  Since the current CPU is BSP, we have the BSP's apic id.
  In madt_pass2(), we match the MADT LAPIC entry's apic_id field against the
  the value read from the current CPU's lapic id field.  Any matching means
  that entry contains information concerning BSP.

Reported-by: tuxillo on EFnet #dragonflybsd
sys/platform/pc32/i386/mp_machdep.c
sys/platform/pc32/i386/mp_madt.c
sys/platform/pc32/include/smp.h