Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/x86/mptable.c
Show All 31 Lines | |||||
#include "opt_mptable_force_htt.h" | #include "opt_mptable_force_htt.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#ifdef NEW_PCIB | |||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#endif | |||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_param.h> | #include <vm/vm_param.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <dev/pci/pcivar.h> | #include <dev/pci/pcivar.h> | ||||
#ifdef NEW_PCIB | |||||
#include <dev/pci/pcib_private.h> | #include <dev/pci/pcib_private.h> | ||||
#endif | |||||
#include <x86/apicreg.h> | #include <x86/apicreg.h> | ||||
#include <x86/mptable.h> | #include <x86/mptable.h> | ||||
#include <machine/frame.h> | #include <machine/frame.h> | ||||
#include <machine/intr_machdep.h> | #include <machine/intr_machdep.h> | ||||
#include <x86/apicvar.h> | #include <x86/apicvar.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <machine/pc/bios.h> | #include <machine/pc/bios.h> | ||||
#ifdef NEW_PCIB | |||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#endif | |||||
#include <machine/specialreg.h> | #include <machine/specialreg.h> | ||||
/* string defined by the Intel MP Spec as identifying the MP table */ | /* string defined by the Intel MP Spec as identifying the MP table */ | ||||
#define MP_SIG 0x5f504d5f /* _MP_ */ | #define MP_SIG 0x5f504d5f /* _MP_ */ | ||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
#define MAX_LAPIC_ID 63 /* Max local APIC ID for HTT fixup */ | #define MAX_LAPIC_ID 63 /* Max local APIC ID for HTT fixup */ | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
static void mptable_pci_setup(void); | static void mptable_pci_setup(void); | ||||
static int mptable_probe(void); | static int mptable_probe(void); | ||||
static int mptable_probe_cpus(void); | static int mptable_probe_cpus(void); | ||||
static void mptable_probe_cpus_handler(u_char *entry, void *arg __unused); | static void mptable_probe_cpus_handler(u_char *entry, void *arg __unused); | ||||
static void mptable_setup_cpus_handler(u_char *entry, void *arg __unused); | static void mptable_setup_cpus_handler(u_char *entry, void *arg __unused); | ||||
static void mptable_register(void *dummy); | static void mptable_register(void *dummy); | ||||
static int mptable_setup_local(void); | static int mptable_setup_local(void); | ||||
static int mptable_setup_io(void); | static int mptable_setup_io(void); | ||||
#ifdef NEW_PCIB | |||||
static void mptable_walk_extended_table( | static void mptable_walk_extended_table( | ||||
mptable_extended_entry_handler *handler, void *arg); | mptable_extended_entry_handler *handler, void *arg); | ||||
#endif | |||||
static void mptable_walk_table(mptable_entry_handler *handler, void *arg); | static void mptable_walk_table(mptable_entry_handler *handler, void *arg); | ||||
static int search_for_sig(u_int32_t target, int count); | static int search_for_sig(u_int32_t target, int count); | ||||
static struct apic_enumerator mptable_enumerator = { | static struct apic_enumerator mptable_enumerator = { | ||||
.apic_name = "MPTable", | .apic_name = "MPTable", | ||||
.apic_probe = mptable_probe, | .apic_probe = mptable_probe, | ||||
.apic_probe_cpus = mptable_probe_cpus, | .apic_probe_cpus = mptable_probe_cpus, | ||||
.apic_setup_local = mptable_setup_local, | .apic_setup_local = mptable_setup_local, | ||||
▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | default: | ||||
panic("%s: Unknown MP Config Entry %d\n", __func__, | panic("%s: Unknown MP Config Entry %d\n", __func__, | ||||
(int)*entry); | (int)*entry); | ||||
} | } | ||||
handler(entry, arg); | handler(entry, arg); | ||||
entry += basetable_entry_types[*entry].length; | entry += basetable_entry_types[*entry].length; | ||||
} | } | ||||
} | } | ||||
#ifdef NEW_PCIB | |||||
/* | /* | ||||
* Call the handler routine for each entry in the MP config extended | * Call the handler routine for each entry in the MP config extended | ||||
* table. | * table. | ||||
*/ | */ | ||||
static void | static void | ||||
mptable_walk_extended_table(mptable_extended_entry_handler *handler, void *arg) | mptable_walk_extended_table(mptable_extended_entry_handler *handler, void *arg) | ||||
{ | { | ||||
ext_entry_ptr end, entry; | ext_entry_ptr end, entry; | ||||
if (mpet == NULL) | if (mpet == NULL) | ||||
return; | return; | ||||
entry = mpet; | entry = mpet; | ||||
end = (ext_entry_ptr)((char *)mpet + mpct->extended_table_length); | end = (ext_entry_ptr)((char *)mpet + mpct->extended_table_length); | ||||
while (entry < end) { | while (entry < end) { | ||||
handler(entry, arg); | handler(entry, arg); | ||||
entry = (ext_entry_ptr)((char *)entry + entry->length); | entry = (ext_entry_ptr)((char *)entry + entry->length); | ||||
} | } | ||||
} | } | ||||
#endif | |||||
static void | static void | ||||
mptable_probe_cpus_handler(u_char *entry, void *arg) | mptable_probe_cpus_handler(u_char *entry, void *arg) | ||||
{ | { | ||||
proc_entry_ptr proc; | proc_entry_ptr proc; | ||||
switch (*entry) { | switch (*entry) { | ||||
case MPCT_ENTRY_PROCESSOR: | case MPCT_ENTRY_PROCESSOR: | ||||
▲ Show 20 Lines • Show All 638 Lines • ▼ Show 20 Lines | if (args.vector < 0) { | ||||
return (PCI_INVALID_IRQ); | return (PCI_INVALID_IRQ); | ||||
} | } | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(pcib, "slot %d INT%c routed to irq %d\n", slot, | device_printf(pcib, "slot %d INT%c routed to irq %d\n", slot, | ||||
'A' + pin, args.vector); | 'A' + pin, args.vector); | ||||
return (args.vector); | return (args.vector); | ||||
} | } | ||||
#ifdef NEW_PCIB | |||||
struct host_res_args { | struct host_res_args { | ||||
struct mptable_hostb_softc *sc; | struct mptable_hostb_softc *sc; | ||||
device_t dev; | device_t dev; | ||||
u_char bus; | u_char bus; | ||||
}; | }; | ||||
/* | /* | ||||
* Initialize a Host-PCI bridge so it can restrict resource allocation | * Initialize a Host-PCI bridge so it can restrict resource allocation | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | mptable_pci_host_res_init(device_t pcib) | ||||
KASSERT(pci0 != -1, ("do not know how to map PCI bus IDs")); | KASSERT(pci0 != -1, ("do not know how to map PCI bus IDs")); | ||||
args.bus = pci_get_bus(pcib) + pci0; | args.bus = pci_get_bus(pcib) + pci0; | ||||
args.dev = pcib; | args.dev = pcib; | ||||
args.sc = device_get_softc(pcib); | args.sc = device_get_softc(pcib); | ||||
if (pcib_host_res_init(pcib, &args.sc->sc_host_res) != 0) | if (pcib_host_res_init(pcib, &args.sc->sc_host_res) != 0) | ||||
panic("failed to init hostb resources"); | panic("failed to init hostb resources"); | ||||
mptable_walk_extended_table(mptable_host_res_handler, &args); | mptable_walk_extended_table(mptable_host_res_handler, &args); | ||||
} | } | ||||
#endif |