Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/acpica/madt.c
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
static void madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, | static void madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, | ||||
void *arg __unused); | void *arg __unused); | ||||
static void madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi); | static void madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi); | ||||
static void madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi); | static void madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi); | ||||
static int madt_probe(void); | static int madt_probe(void); | ||||
static int madt_probe_cpus(void); | static int madt_probe_cpus(void); | ||||
static void madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, | static void madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, | ||||
void *arg __unused); | void *arg __unused); | ||||
static void madt_setup_cpus_handler(ACPI_SUBTABLE_HEADER *entry, | |||||
void *arg __unused); | |||||
static void madt_register(void *dummy); | static void madt_register(void *dummy); | ||||
static int madt_setup_local(void); | static int madt_setup_local(void); | ||||
static int madt_setup_io(void); | static int madt_setup_io(void); | ||||
static void madt_walk_table(acpi_subtable_handler *handler, void *arg); | static void madt_walk_table(acpi_subtable_handler *handler, void *arg); | ||||
static struct apic_enumerator madt_enumerator = { | static struct apic_enumerator madt_enumerator = { | ||||
"MADT", | "MADT", | ||||
madt_probe, | madt_probe, | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | madt_setup_local(void) | ||||
vm_paddr_t dmartbl_physaddr; | vm_paddr_t dmartbl_physaddr; | ||||
const char *reason; | const char *reason; | ||||
char *hw_vendor; | char *hw_vendor; | ||||
u_int p[4]; | u_int p[4]; | ||||
int user_x2apic; | int user_x2apic; | ||||
bool bios_x2apic; | bool bios_x2apic; | ||||
madt = pmap_mapbios(madt_physaddr, madt_length); | madt = pmap_mapbios(madt_physaddr, madt_length); | ||||
madt_walk_table(madt_setup_cpus_handler, NULL); | |||||
if ((cpu_feature2 & CPUID2_X2APIC) != 0) { | if ((cpu_feature2 & CPUID2_X2APIC) != 0) { | ||||
reason = NULL; | reason = NULL; | ||||
/* | /* | ||||
* Automatically detect several configurations where | * Automatically detect several configurations where | ||||
* x2APIC mode is known to cause troubles. User can | * x2APIC mode is known to cause troubles. User can | ||||
* override the setting with hw.x2apic_enable tunable. | * override the setting with hw.x2apic_enable tunable. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
madt_walk_table(acpi_subtable_handler *handler, void *arg) | madt_walk_table(acpi_subtable_handler *handler, void *arg) | ||||
{ | { | ||||
acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, | acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, | ||||
handler, arg); | handler, arg); | ||||
} | } | ||||
static void | static void | ||||
madt_parse_cpu(unsigned int apic_id, unsigned int flags) | |||||
{ | |||||
if (!(flags & ACPI_MADT_ENABLED) || mp_ncpus == MAXCPU || | |||||
apic_id > MAX_APIC_ID) | |||||
return; | |||||
mp_ncpus++; | |||||
mp_maxid = mp_ncpus - 1; | |||||
max_apic_id = max(apic_id, max_apic_id); | |||||
} | |||||
static void | |||||
madt_add_cpu(u_int acpi_id, u_int apic_id, u_int flags) | madt_add_cpu(u_int acpi_id, u_int apic_id, u_int flags) | ||||
{ | { | ||||
struct lapic_info *la; | struct lapic_info *la; | ||||
/* | /* | ||||
* The MADT does not include a BSP flag, so we have to let the | * The MADT does not include a BSP flag, so we have to let the | ||||
* MP code figure out which CPU is the BSP on its own. | * MP code figure out which CPU is the BSP on its own. | ||||
*/ | */ | ||||
Show All 13 Lines | madt_add_cpu(u_int acpi_id, u_int apic_id, u_int flags) | ||||
KASSERT(la->la_enabled == 0, ("Duplicate local APIC ID %u", apic_id)); | KASSERT(la->la_enabled == 0, ("Duplicate local APIC ID %u", apic_id)); | ||||
la->la_enabled = 1; | la->la_enabled = 1; | ||||
la->la_acpi_id = acpi_id; | la->la_acpi_id = acpi_id; | ||||
lapic_create(apic_id, 0); | lapic_create(apic_id, 0); | ||||
} | } | ||||
static void | static void | ||||
madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, void *arg) | madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, void *arg) | ||||
{ | |||||
ACPI_MADT_LOCAL_APIC *proc; | |||||
ACPI_MADT_LOCAL_X2APIC *x2apic; | |||||
switch (entry->Type) { | |||||
case ACPI_MADT_TYPE_LOCAL_APIC: | |||||
proc = (ACPI_MADT_LOCAL_APIC *)entry; | |||||
madt_parse_cpu(proc->Id, proc->LapicFlags); | |||||
break; | |||||
case ACPI_MADT_TYPE_LOCAL_X2APIC: | |||||
x2apic = (ACPI_MADT_LOCAL_X2APIC *)entry; | |||||
madt_parse_cpu(x2apic->LocalApicId, x2apic->LapicFlags); | |||||
break; | |||||
} | |||||
} | |||||
static void | |||||
madt_setup_cpus_handler(ACPI_SUBTABLE_HEADER *entry, void *arg) | |||||
{ | { | ||||
ACPI_MADT_LOCAL_APIC *proc; | ACPI_MADT_LOCAL_APIC *proc; | ||||
ACPI_MADT_LOCAL_X2APIC *x2apic; | ACPI_MADT_LOCAL_X2APIC *x2apic; | ||||
switch (entry->Type) { | switch (entry->Type) { | ||||
case ACPI_MADT_TYPE_LOCAL_APIC: | case ACPI_MADT_TYPE_LOCAL_APIC: | ||||
proc = (ACPI_MADT_LOCAL_APIC *)entry; | proc = (ACPI_MADT_LOCAL_APIC *)entry; | ||||
madt_add_cpu(proc->ProcessorId, proc->Id, proc->LapicFlags); | madt_add_cpu(proc->ProcessorId, proc->Id, proc->LapicFlags); | ||||
▲ Show 20 Lines • Show All 364 Lines • Show Last 20 Lines |