stos/amd64: Impl phase 1 processor init
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026, Chloe M.
|
||||||
|
* Provided under the BSD-3 clause.
|
||||||
|
*
|
||||||
|
* Description: Kernel processor control region
|
||||||
|
* Author: Chloe M.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <hal/kpcr.h>
|
||||||
|
#include <ex/trace.h>
|
||||||
|
#include <machine/cpuid.h>
|
||||||
|
#include <stdef.h>
|
||||||
|
|
||||||
|
#define DTRACE(Fmt, ...) \
|
||||||
|
TRACE("[ CPU ]: " Fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
ProcessorIdentify(MCB *Mcb)
|
||||||
|
{
|
||||||
|
ULONG Eax, Unused;
|
||||||
|
UCHAR ModelLow, ModelHigh;
|
||||||
|
UCHAR FamilyLow, FamilyHigh;
|
||||||
|
|
||||||
|
if (Mcb == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPUID(1, Eax, Unused, Unused, Unused);
|
||||||
|
|
||||||
|
/* Extarct the model ID */
|
||||||
|
ModelLow = (Eax >> 4) & 0xF;
|
||||||
|
ModelHigh = (Eax >> 16) & 0xF;
|
||||||
|
Mcb->ModelId = (ModelHigh << 4) | ModelLow;
|
||||||
|
|
||||||
|
/* Extract the family ID */
|
||||||
|
FamilyLow = (Eax >> 8) & 0xF;
|
||||||
|
FamilyHigh = (Eax >> 20) & 0xFF;
|
||||||
|
Mcb->FamilyId = (FamilyHigh << 4) | FamilyLow;
|
||||||
|
|
||||||
|
/* Informational logging */
|
||||||
|
DTRACE("model : %X\n", Mcb->ModelId);
|
||||||
|
DTRACE("family : %X\n", Mcb->FamilyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
HalKpcrP1Init(KPCR *Kpcr)
|
||||||
|
{
|
||||||
|
MCB *Mcb;
|
||||||
|
|
||||||
|
if (Kpcr == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mcb = &Kpcr->Mcb;
|
||||||
|
ProcessorIdentify(Mcb);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026, Chloe M.
|
||||||
|
* Provided under the BSD-3 clause.
|
||||||
|
*
|
||||||
|
* Description: Machine core block
|
||||||
|
* Author: Chloe M.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MACHINE_MCB_H_
|
||||||
|
#define _MACHINE_MCB_H_ 1
|
||||||
|
|
||||||
|
#include <stdef.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The machine-core block contains machine specific
|
||||||
|
* processor information
|
||||||
|
*
|
||||||
|
* @ModelId: Processor model ID
|
||||||
|
* @FamilyId: Processor family ID
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
UCHAR ModelId;
|
||||||
|
USHORT FamilyId : 12;
|
||||||
|
} MCB;
|
||||||
|
|
||||||
|
#endif /* !_MACHINE_MCB_H_ */
|
||||||
@@ -10,15 +10,25 @@
|
|||||||
#define _HAL_KPCR_H_ 1
|
#define _HAL_KPCR_H_ 1
|
||||||
|
|
||||||
#include <stdef.h>
|
#include <stdef.h>
|
||||||
|
#include <machine/mcb.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The kernel processor control region contains MI
|
* The kernel processor control region contains MI
|
||||||
* information about the processor.
|
* information about the processor.
|
||||||
*
|
*
|
||||||
* @CoreId: Processor core ID assigned by us
|
* @CoreId: Processor core ID assigned by us
|
||||||
|
* @Mcb: Machine-core block
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
USHORT CoreId;
|
USHORT CoreId;
|
||||||
|
MCB Mcb;
|
||||||
} KPCR;
|
} KPCR;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Phase 1 initialization of processor
|
||||||
|
*
|
||||||
|
* @Kpcr: KPCR to initialize
|
||||||
|
*/
|
||||||
|
VOID HalKpcrP1Init(KPCR *Kpcr);
|
||||||
|
|
||||||
#endif /* !_HAL_KPCR_H_ */
|
#endif /* !_HAL_KPCR_H_ */
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <ke/stos.h>
|
#include <ke/stos.h>
|
||||||
#include <ke/bpal.h>
|
#include <ke/bpal.h>
|
||||||
#include <hal/serial.h>
|
#include <hal/serial.h>
|
||||||
|
#include <hal/kpcr.h>
|
||||||
#include <drivers/bootvid/fbio.h>
|
#include <drivers/bootvid/fbio.h>
|
||||||
#include <mm/pmm.h>
|
#include <mm/pmm.h>
|
||||||
#include <stdef.h>
|
#include <stdef.h>
|
||||||
@@ -17,6 +18,9 @@
|
|||||||
#define DTRACE(Fmt, ...) \
|
#define DTRACE(Fmt, ...) \
|
||||||
TRACE("[ INIT ]: " Fmt, ##__VA_ARGS__)
|
TRACE("[ INIT ]: " Fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
/* Globals */
|
||||||
|
static KPCR BootstrapCore;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Display a boot banner
|
* Display a boot banner
|
||||||
*/
|
*/
|
||||||
@@ -47,4 +51,7 @@ KiKernelEntry(VOID)
|
|||||||
|
|
||||||
/* Initialize physical memory */
|
/* Initialize physical memory */
|
||||||
MmInitPmm();
|
MmInitPmm();
|
||||||
|
|
||||||
|
/* Phase 1 initialization the bootstrap core */
|
||||||
|
HalKpcrP1Init(&BootstrapCore);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user