MFi386: mp_topology().

This commit is contained in:
peter 2004-01-28 23:51:16 +00:00
parent c98bdf5b6a
commit 61ce0b1d90
3 changed files with 46 additions and 1 deletions

View File

@ -600,6 +600,10 @@ apic_setup_local(void *dummy __unused)
if (retval != 0)
printf("%s: Failed to setup the local APIC: returned %d\n",
best_enum->apic_name, retval);
#ifdef SMP
/* Last, setup the cpu topology now that we have probed CPUs */
mp_topology();
#endif
}
SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_FIRST, apic_setup_local, NULL)

View File

@ -78,7 +78,7 @@ int boot_cpu_id = -1; /* designated BSP */
extern int nkpt;
/*
* CPU topology map datastructures for HTT. (XXX)
* CPU topology map datastructures for HTT.
*/
struct cpu_group mp_groups[MAXCPU];
struct cpu_top mp_top;
@ -141,6 +141,46 @@ static int hlt_logical_cpus;
static struct sysctl_ctx_list logical_cpu_clist;
static u_int bootMP_size;
void
mp_topology(void)
{
struct cpu_group *group;
int logical_cpus;
int apic_id;
int groups;
int cpu;
/* Build the smp_topology map. */
/* Nothing to do if there is no HTT support. */
if ((cpu_feature & CPUID_HTT) == 0)
return;
logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16;
if (logical_cpus <= 1)
return;
group = &mp_groups[0];
groups = 1;
for (cpu = 0, apic_id = 0; apic_id < MAXCPU; apic_id++) {
if (!cpu_info[apic_id].cpu_present)
continue;
/*
* If the current group has members and we're not a logical
* cpu, create a new group.
*/
if (group->cg_count != 0 && (apic_id % logical_cpus) == 0) {
group++;
groups++;
}
group->cg_count++;
group->cg_mask |= 1 << cpu;
cpu++;
}
mp_top.ct_count = groups;
mp_top.ct_group = mp_groups;
smp_topology = &mp_top;
}
/*
* Calculate usable address in base memory for AP trampoline code.
*/

View File

@ -60,6 +60,7 @@ void forward_hardclock(void);
void forwarded_hardclock(struct clockframe frame);
u_int mp_bootaddress(u_int);
int mp_grab_cpu_hlt(void);
void mp_topology(void);
void smp_invlpg(vm_offset_t addr);
void smp_masked_invlpg(u_int mask, vm_offset_t addr);
void smp_invlpg_range(vm_offset_t startva, vm_offset_t endva);