Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/x86/mp_x86.c
Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | |||||
static int core_id_shift; | static int core_id_shift; | ||||
static int disabled_cpus; | static int disabled_cpus; | ||||
struct cache_info { | struct cache_info { | ||||
int id_shift; | int id_shift; | ||||
int present; | int present; | ||||
} static caches[MAX_CACHE_LEVELS]; | } static caches[MAX_CACHE_LEVELS]; | ||||
unsigned int boot_address; | |||||
static bool stop_mwait = false; | static bool stop_mwait = false; | ||||
SYSCTL_BOOL(_machdep, OID_AUTO, stop_mwait, CTLFLAG_RWTUN, &stop_mwait, 0, | SYSCTL_BOOL(_machdep, OID_AUTO, stop_mwait, CTLFLAG_RWTUN, &stop_mwait, 0, | ||||
"Use MONITOR/MWAIT when stopping CPU, if available"); | "Use MONITOR/MWAIT when stopping CPU, if available"); | ||||
#define MiB(v) (v ## ULL << 20) | |||||
void | void | ||||
mem_range_AP_init(void) | mem_range_AP_init(void) | ||||
{ | { | ||||
if (mem_range_softc.mr_op && mem_range_softc.mr_op->initAP) | if (mem_range_softc.mr_op && mem_range_softc.mr_op->initAP) | ||||
mem_range_softc.mr_op->initAP(&mem_range_softc); | mem_range_softc.mr_op->initAP(&mem_range_softc); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 745 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
/* | /* | ||||
* Always record BSP in CPU map so that the mbuf init code works | * Always record BSP in CPU map so that the mbuf init code works | ||||
* correctly. | * correctly. | ||||
*/ | */ | ||||
CPU_SETOF(0, &all_cpus); | CPU_SETOF(0, &all_cpus); | ||||
return (mp_ncpus > 1); | return (mp_ncpus > 1); | ||||
} | |||||
/* Allocate memory for the AP trampoline. */ | |||||
void | |||||
alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int *physmap_idx) | |||||
{ | |||||
unsigned int i; | |||||
bool allocated; | |||||
allocated = false; | |||||
for (i = *physmap_idx; i <= *physmap_idx; i -= 2) { | |||||
/* | |||||
* Find a memory region big enough and below the 1MB boundary | |||||
* for the trampoline code. | |||||
* NB: needs to be page aligned. | |||||
*/ | |||||
if (physmap[i] >= MiB(1) || | |||||
(trunc_page(physmap[i + 1]) - round_page(physmap[i])) < | |||||
round_page(bootMP_size)) | |||||
continue; | |||||
allocated = true; | |||||
/* | |||||
* Try to steal from the end of the region to mimic previous | |||||
* behaviour, else fallback to steal from the start. | |||||
*/ | |||||
if (physmap[i + 1] < MiB(1)) { | |||||
boot_address = trunc_page(physmap[i + 1]); | |||||
if ((physmap[i + 1] - boot_address) < bootMP_size) | |||||
boot_address -= round_page(bootMP_size); | |||||
physmap[i + 1] = boot_address; | |||||
} else { | |||||
boot_address = round_page(physmap[i]); | |||||
physmap[i] = boot_address + round_page(bootMP_size); | |||||
} | |||||
if (physmap[i] == physmap[i + 1] && *physmap_idx != 0) { | |||||
memmove(&physmap[i], &physmap[i + 2], | |||||
sizeof(*physmap) * (*physmap_idx - i + 2)); | |||||
*physmap_idx -= 2; | |||||
} | |||||
break; | |||||
} | |||||
if (!allocated) { | |||||
boot_address = basemem * 1024 - bootMP_size; | |||||
if (bootverbose) | |||||
printf( | |||||
"Cannot find enough space for the boot trampoline, placing it at %#x", | |||||
boot_address); | |||||
} | |||||
} | } | ||||
/* | /* | ||||
* AP CPU's call this to initialize themselves. | * AP CPU's call this to initialize themselves. | ||||
*/ | */ | ||||
void | void | ||||
init_secondary_tail(void) | init_secondary_tail(void) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 687 Lines • Show Last 20 Lines |