diff --git a/usr/src/sp1/amd64/cpu/cpu_init.c b/usr/src/sp1/amd64/cpu/cpu_init.c index c6e260a..99267f2 100644 --- a/usr/src/sp1/amd64/cpu/cpu_init.c +++ b/usr/src/sp1/amd64/cpu/cpu_init.c @@ -11,6 +11,7 @@ #include #include +#include #include #define pr_trace(fmt, ...) \ @@ -24,18 +25,50 @@ extern void md_cpu_init(void); * processor on early startup */ static void -cpu_print_info(void) +cpu_print_info(struct cpu_info *ci) { static bool once = false; + struct mcb *mcb; - if (once) { + if (once || ci == NULL) { return; } - pr_trace("pg.nx : yes\n"); + mcb = &ci->mcb; + pr_trace("pg.nx : yes\n"); + pr_trace("cpu.model : %x\n", mcb->model_id); + pr_trace("cpu.family : %x\n", mcb->family_id); once = true; } +static void +cpu_get_info(struct cpu_info *ci) +{ + struct mcb *mcb; + uint32_t eax, unused; + uint8_t model_low, model_high; + uint8_t family_low, family_high; + + if (ci == NULL) { + return; + } + + mcb = &ci->mcb; + + /* Get processor info and feature bits */ + __cpuid(0x01, eax, unused, unused, unused); + + /* Obtain the model ID */ + model_low = (eax >> 4) & 0xF; + model_high = (eax >> 16) & 0xF; + mcb->model_id = (model_high << 4) | model_low; + + /* Obtain the family ID */ + family_low = (eax >> 8) & 0xF; + family_high = (eax >> 20) & 0xFF; + mcb->family_id = (family_high << 4) | family_low; +} + void mu_cpu_preinit(struct cpu_info *ci) { @@ -49,6 +82,9 @@ mu_cpu_preinit(struct cpu_info *ci) /* Initialize control registers and such */ md_cpu_init(); + /* Obtain some processor information */ + cpu_get_info(ci); + /* Log out some information */ - cpu_print_info(); + cpu_print_info(ci); } diff --git a/usr/src/sp1/head/amd64/mcb.h b/usr/src/sp1/head/amd64/mcb.h new file mode 100644 index 0000000..4e74f3e --- /dev/null +++ b/usr/src/sp1/head/amd64/mcb.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * All rights reserved. + * + * The following sources are CONFIDENTIAL and PROPRIETARY + * property of Mirocom Laboratories. Unauthorized copying, + * use, distribution or modification of this file, in whole + * and in part, is strictly prohibited without the prior written + * consent from Mirocom Laboratories. + */ + +#ifndef _MACHINE_MCB_H_ +#define _MACHINE_MCB_H_ 1 + +#include + +/* + * The machine core block contains MD processor + * specific information + * + * @model_id: Processor model ID + * @family_id: Processor family ID + */ +struct mcb { + uint8_t model_id; + uint16_t family_id : 12; +}; + +#endif /* !_MACHINE_MCB_H_ */ diff --git a/usr/src/sp1/head/mu/cpu.h b/usr/src/sp1/head/mu/cpu.h index 4c51c69..dc9a0f7 100644 --- a/usr/src/sp1/head/mu/cpu.h +++ b/usr/src/sp1/head/mu/cpu.h @@ -13,14 +13,17 @@ #define _MU_CPU_H_ 1 #include +#include /* shared */ /* * MI processor specific information * * @id: Processor ID + * @mcb: Machine core block */ struct cpu_info { uint8_t id; + struct mcb mcb; }; /*