From 5ad6058bf94f953462aab91ede6c15d4d5784d82 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 12 Oct 2025 15:33:22 -0400 Subject: kern/amd64: cpu: Get processor family ID Signed-off-by: Ian Moffett --- src/sys/arch/amd64/cpu/cpu_conf.c | 30 ++++++++++++++++++++++++++++++ src/sys/include/arch/amd64/mdcpu.h | 2 ++ 2 files changed, 32 insertions(+) (limited to 'src') 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 @@ -131,6 +131,35 @@ cpu_vendor(struct mdcore *mdcore) mdcore->vendor = CPU_VENDOR_OTHER; } +/* + * 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 */ @@ -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 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; -- cgit v1.2.3