- Reorder the APIC enumerator SYSINIT's to register enumeators at

SI_SUB_CPU - 1 and probe enumerators, probe CPUs, and setup the local
  APIC programming all at SI_SUB_CPU / SI_ORDER_FIRST.  This is needed to
  help get the ACPI module working again as it moves the APIC enumeration
  code after SI_SUB_KLD.
- In the MADT parser, use mp_maxid rather than MAXCPU to terminate a loop
  when assigning per-cpu ACPI IDs to avoid a dependency on 'options SMP'.
- Allow the apic device to be disabled via 'hint.apic.0.disabled' from the
  loader.  Note that since this is done in the local APIC code, it works
  for both the ACPI and non-ACPI cases.

Approved by:	re (scott / blanket)
This commit is contained in:
John Baldwin 2003-12-03 20:33:18 +00:00
parent 447a5fa113
commit 6afad3b055
3 changed files with 20 additions and 29 deletions

View File

@ -351,8 +351,7 @@ madt_register(void *dummy __unused)
apic_register_enumerator(&madt_enumerator);
}
SYSINIT(madt_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST,
madt_register, NULL)
SYSINIT(madt_register, SI_SUB_CPU - 1, SI_ORDER_FIRST, madt_register, NULL)
/*
* Call the handler routine for each entry in the MADT table.
@ -644,7 +643,7 @@ madt_set_ids(void *dummy)
if (madt == NULL)
return;
for (i = 0; i < MAXCPU; i++) {
for (i = 0; i <= mp_maxid; i++) {
if (CPU_ABSENT(i))
continue;
pc = pcpu_find(i);

View File

@ -537,20 +537,24 @@ apic_register_enumerator(struct apic_enumerator *enumerator)
}
/*
* We have to look for CPU's very, very early because certain subsystems
* want to know how many CPU's we have extremely early on in the boot
* process.
* Probe the APIC enumerators, enumerate CPUs, and initialize the
* local APIC.
*/
static void
apic_init(void *dummy __unused)
{
struct apic_enumerator *enumerator;
uint64_t apic_base;
int retval, best;
/* We only support built in local APICs. */
if (!(cpu_feature & CPUID_APIC))
return;
/* Don't probe if APIC mode is disabled. */
if (resource_disabled("apic", 0))
return;
/* First, probe all the enumerators to find the best match. */
best_enum = NULL;
best = 0;
@ -573,26 +577,6 @@ apic_init(void *dummy __unused)
printf("APIC: Using the %s enumerator.\n",
best_enum->apic_name);
/* Second, probe the CPU's in the system. */
retval = best_enum->apic_probe_cpus();
if (retval != 0)
printf("%s: Failed to probe CPUs: returned %d\n",
best_enum->apic_name, retval);
}
SYSINIT(apic_init, SI_SUB_TUNABLES - 1, SI_ORDER_SECOND, apic_init, NULL)
/*
* Setup the local APIC. We have to do this prior to starting up the APs
* in the SMP case.
*/
static void
apic_setup_local(void *dummy __unused)
{
int retval;
uint64_t apic_base;
if (best_enum == NULL)
return;
/*
* To work around an errata, we disable the local APIC on some
* CPUs during early startup. We need to turn the local APIC back
@ -604,12 +588,20 @@ apic_setup_local(void *dummy __unused)
apic_base |= APICBASE_ENABLED;
wrmsr(MSR_APICBASE, apic_base);
}
/* Second, probe the CPU's in the system. */
retval = best_enum->apic_probe_cpus();
if (retval != 0)
printf("%s: Failed to probe CPUs: returned %d\n",
best_enum->apic_name, retval);
/* Third, initialize the local APIC. */
retval = best_enum->apic_setup_local();
if (retval != 0)
printf("%s: Failed to setup the local APIC: returned %d\n",
best_enum->apic_name, retval);
}
SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_FIRST, apic_setup_local, NULL)
SYSINIT(apic_init, SI_SUB_CPU, SI_ORDER_FIRST, apic_init, NULL)
/*
* Setup the I/O APICs.

View File

@ -375,8 +375,8 @@ mptable_register(void *dummy __unused)
apic_register_enumerator(&mptable_enumerator);
}
SYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST,
mptable_register, NULL)
SYSINIT(mptable_register, SI_SUB_CPU - 1, SI_ORDER_FIRST, mptable_register,
NULL)
/*
* Call the handler routine for each entry in the MP config table.