Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/x86/mptable.c
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
#include <dev/pci/pcib_private.h> | #include <dev/pci/pcib_private.h> | ||||
#endif | #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> | |||||
#ifdef NEW_PCIB | #ifdef NEW_PCIB | ||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#endif | #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_ */ | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static int | static int | ||||
search_for_sig(u_int32_t target, int count) | search_for_sig(u_int32_t target, int count) | ||||
{ | { | ||||
int x; | int x; | ||||
u_int32_t *addr; | u_int32_t *addr; | ||||
#ifdef __amd64__ | addr = (u_int32_t *)BIOS_PADDRTOVADDR(target); | ||||
addr = (u_int32_t *) (KERNBASE + target); | |||||
#else /* __i386__ */ | |||||
addr = (u_int32_t *) (PMAP_MAP_LOW + target); | |||||
#endif | |||||
for (x = 0; x < count; x += 4) | for (x = 0; x < count; x += 4) | ||||
if (addr[x] == MP_SIG) | if (addr[x] == MP_SIG) | ||||
/* make array index a byte index */ | /* make array index a byte index */ | ||||
return (target + (x * sizeof(u_int32_t))); | return (target + (x * sizeof(u_int32_t))); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
static int | static int | ||||
Show All 14 Lines | |||||
static int | static int | ||||
mptable_probe(void) | mptable_probe(void) | ||||
{ | { | ||||
int x; | int x; | ||||
u_long segment; | u_long segment; | ||||
u_int32_t target; | u_int32_t target; | ||||
/* see if EBDA exists */ | /* see if EBDA exists */ | ||||
if ((segment = (u_long) * (u_short *) ( | if ((segment = *(u_short *)BIOS_PADDRTOVADDR(0x40e)) != 0) { | ||||
#ifdef __amd64__ | |||||
KERNBASE | |||||
#else /* __i386__ */ | |||||
PMAP_MAP_LOW | |||||
#endif | |||||
+ 0x40e)) != 0) { | |||||
/* search first 1K of EBDA */ | /* search first 1K of EBDA */ | ||||
target = (u_int32_t) (segment << 4); | target = (u_int32_t) (segment << 4); | ||||
if ((x = search_for_sig(target, 1024 / 4)) >= 0) | if ((x = search_for_sig(target, 1024 / 4)) >= 0) | ||||
goto found; | goto found; | ||||
} else { | } else { | ||||
/* last 1K of base memory, effective 'top of base' passed in */ | /* last 1K of base memory, effective 'top of base' passed in */ | ||||
target = (u_int32_t) ((basemem * 1024) - 0x400); | target = (u_int32_t) ((basemem * 1024) - 0x400); | ||||
if ((x = search_for_sig(target, 1024 / 4)) >= 0) | if ((x = search_for_sig(target, 1024 / 4)) >= 0) | ||||
goto found; | goto found; | ||||
} | } | ||||
/* search the BIOS */ | /* search the BIOS */ | ||||
target = (u_int32_t) BIOS_BASE; | target = (u_int32_t) BIOS_BASE; | ||||
if ((x = search_for_sig(target, BIOS_COUNT)) >= 0) | if ((x = search_for_sig(target, BIOS_COUNT)) >= 0) | ||||
goto found; | goto found; | ||||
/* nothing found */ | /* nothing found */ | ||||
return (ENXIO); | return (ENXIO); | ||||
found: | found: | ||||
mpfps = (mpfps_t)(KERNBASE + x); | mpfps = (mpfps_t)BIOS_PADDRTOVADDR(x); | ||||
/* Map in the configuration table if it exists. */ | /* Map in the configuration table if it exists. */ | ||||
if (mpfps->config_type != 0) { | if (mpfps->config_type != 0) { | ||||
if (bootverbose) | if (bootverbose) | ||||
printf( | printf( | ||||
"MP Table version 1.%d found using Default Configuration %d\n", | "MP Table version 1.%d found using Default Configuration %d\n", | ||||
mpfps->spec_rev, mpfps->config_type); | mpfps->spec_rev, mpfps->config_type); | ||||
if (mpfps->config_type != 5 && mpfps->config_type != 6) { | if (mpfps->config_type != 5 && mpfps->config_type != 6) { | ||||
printf( | printf( | ||||
"MP Table Default Configuration %d is unsupported\n", | "MP Table Default Configuration %d is unsupported\n", | ||||
mpfps->config_type); | mpfps->config_type); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
mpct = NULL; | mpct = NULL; | ||||
} else { | } else { | ||||
if ((uintptr_t)mpfps->pap >= 1024 * 1024) { | if ((uintptr_t)mpfps->pap >= 1024 * 1024) { | ||||
printf("%s: Unable to map MP Configuration Table\n", | printf("%s: Unable to map MP Configuration Table\n", | ||||
__func__); | __func__); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
mpct = (mpcth_t)(KERNBASE + (uintptr_t)mpfps->pap); | mpct = (mpcth_t)BIOS_PADDRTOVADDR((uintptr_t)mpfps->pap); | ||||
if (mpct->base_table_length + (uintptr_t)mpfps->pap >= | if (mpct->base_table_length + (uintptr_t)mpfps->pap >= | ||||
1024 * 1024) { | 1024 * 1024) { | ||||
printf("%s: Unable to map end of MP Config Table\n", | printf("%s: Unable to map end of MP Config Table\n", | ||||
__func__); | __func__); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
if (mpct->extended_table_length != 0 && | if (mpct->extended_table_length != 0 && | ||||
mpct->extended_table_length + mpct->base_table_length + | mpct->extended_table_length + mpct->base_table_length + | ||||
▲ Show 20 Lines • Show All 954 Lines • Show Last 20 Lines |