summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2004-01-28 23:51:16 +0000
committerpeter <peter@FreeBSD.org>2004-01-28 23:51:16 +0000
commitecb3754972524c7a24f7ebdb084216b0216c5825 (patch)
tree8fa6d7c9ce905ef57f0fd61b247f7d1544084cf3 /sys/amd64
parent3383d7b6d7edc6f41a0607b36a6dc1e3922503aa (diff)
downloadFreeBSD-src-ecb3754972524c7a24f7ebdb084216b0216c5825.zip
FreeBSD-src-ecb3754972524c7a24f7ebdb084216b0216c5825.tar.gz
MFi386: mp_topology().
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/local_apic.c4
-rw-r--r--sys/amd64/amd64/mp_machdep.c42
-rw-r--r--sys/amd64/include/smp.h1
3 files changed, 46 insertions, 1 deletions
diff --git a/sys/amd64/amd64/local_apic.c b/sys/amd64/amd64/local_apic.c
index 2afa52d..e4232bb 100644
--- a/sys/amd64/amd64/local_apic.c
+++ b/sys/amd64/amd64/local_apic.c
@@ -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)
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index 0d1a1bc..660f7e6 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -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.
*/
diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h
index c6e7fcf..785a67e 100644
--- a/sys/amd64/include/smp.h
+++ b/sys/amd64/include/smp.h
@@ -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);
OpenPOWER on IntegriCloud