summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-10-12 15:33:22 -0400
committerIan Moffett <ian@osmora.org>2025-10-12 15:46:13 -0400
commit5ad6058bf94f953462aab91ede6c15d4d5784d82 (patch)
treee0374f073db9651c13ecb121140c706d7505d785 /src
parent23b28e59e8a4922252415f0a44497d7471fce942 (diff)
kern/amd64: cpu: Get processor family ID
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src')
-rw-r--r--src/sys/arch/amd64/cpu/cpu_conf.c30
-rw-r--r--src/sys/include/arch/amd64/mdcpu.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/src/sys/arch/amd64/cpu/cpu_conf.c b/src/sys/arch/amd64/cpu/cpu_conf.c
index 16bd57d..f844cf7 100644
--- a/src/sys/arch/amd64/cpu/cpu_conf.c
+++ b/src/sys/arch/amd64/cpu/cpu_conf.c
@@ -132,6 +132,35 @@ cpu_vendor(struct mdcore *mdcore)
}
/*
+ * Acquire the CPU family ID - used by cpu_identify()
+ */
+static void
+cpu_family(struct mdcore *mdcore)
+{
+ uint32_t eax, dmmy;
+ uint32_t family, ext_family;
+
+ if (mdcore == NULL) {
+ return;
+ }
+
+ CPUID(0x01, eax, dmmy, dmmy, dmmy);
+
+ /*
+ * If the family ID is 15 then the actual result
+ * is the sum of the family ID and extended family
+ * ID.
+ */
+ family = (eax >> 8) & 0xF;
+ if (family == 15) {
+ ext_family = (eax >> 20) & 0xFF;
+ family += ext_family;
+ }
+
+ mdcore->family = family;
+}
+
+/*
* Identify the CPU via a CPUID
*/
static void
@@ -142,6 +171,7 @@ cpu_identify(struct mdcore *mdcore)
}
cpu_vendor(mdcore);
+ cpu_family(mdcore);
}
void
diff --git a/src/sys/include/arch/amd64/mdcpu.h b/src/sys/include/arch/amd64/mdcpu.h
index 8701a61..a7336bd 100644
--- a/src/sys/include/arch/amd64/mdcpu.h
+++ b/src/sys/include/arch/amd64/mdcpu.h
@@ -53,6 +53,7 @@
* @apic_id: Local APIC ID
* @cr3: CR3 register value (PML<n> phys)
* @vendor: Processor vendor (CPU_VENDOR_*)
+ * @family: Processor family ID
* @lapic_base: LAPIC register interface base
* @x2apic: Has the x2APIC? Is 1 if true
* @tss: Task state segment for this core
@@ -64,6 +65,7 @@ struct mdcore {
uint32_t apic_id;
uint64_t cr3;
uint8_t vendor;
+ uint32_t family;
void *lapic_base;
uint8_t x2apic : 1;
struct tss_entry tss;