From e176990138fac81ed6a0200d65d2e0d5bb4e003a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 22 May 2019 19:41:00 +0200 Subject: [PATCH] Working on CPUID --- include/ke/cpuid.h | 2 ++ kaleid/kernel/init/init.c | 1 + kaleid/kernel/init/init.h | 1 + kaleid/kernel/init/ssp.c | 2 +- kaleid/kernel/init/table.c | 1 + kaleid/kernel/ke/cpuid.c | 16 +++++++++++----- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/ke/cpuid.h b/include/ke/cpuid.h index e1c9c6f..50dcd84 100644 --- a/include/ke/cpuid.h +++ b/include/ke/cpuid.h @@ -113,6 +113,8 @@ static inline int CpuCpuidString(int code, uint where[4]) return (int)where[0]; } +void CpuGetInfos(void); + // -------------------------------------------------------------------------- // #endif diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 27f6ca4..2e4ca66 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -61,6 +61,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) // Interrupts launching KeSetupIDT(); KeEnableIRQs(); + CpuGetInfos(); MmInitGdt(); // Start drivers diff --git a/kaleid/kernel/init/init.h b/kaleid/kernel/init/init.h index 5480722..82df973 100644 --- a/kaleid/kernel/init/init.h +++ b/kaleid/kernel/init/init.h @@ -33,6 +33,7 @@ #include #include #include +#include // info.c extern void BtDoSanityChecks(uint mbMagic); diff --git a/kaleid/kernel/init/ssp.c b/kaleid/kernel/init/ssp.c index 510d42e..958f1b2 100644 --- a/kaleid/kernel/init/ssp.c +++ b/kaleid/kernel/init/ssp.c @@ -28,6 +28,6 @@ ulong __stack_chk_guard = 0x447c0ffe4dbf9e55; noreturn void __stack_chk_fail(void) { - KeStartPanic("Stack has been smashed!\n"); + KeStartPanic("Stack has been smashed!"); } diff --git a/kaleid/kernel/init/table.c b/kaleid/kernel/init/table.c index 795ebb7..912a62a 100644 --- a/kaleid/kernel/init/table.c +++ b/kaleid/kernel/init/table.c @@ -31,5 +31,6 @@ volatile BootInfo_t BtBootTab = {0}; volatile bool KeIsPanicking = 0; volatile CpuCore_t *KeCurCPU = &_KeCPUTable[0]; +volatile CpuInfo_t CpuInfo = { 0 }; diff --git a/kaleid/kernel/ke/cpuid.c b/kaleid/kernel/ke/cpuid.c index 1bb3af0..3b38f99 100644 --- a/kaleid/kernel/ke/cpuid.c +++ b/kaleid/kernel/ke/cpuid.c @@ -23,13 +23,19 @@ //----------------------------------------------------------------------------// #include +#include +void CpuGetInfos(void) +{ + uint CpuVendorString[5] = {0}; + extern CpuInfo_t CpuInfo; -/* void CpuGetInfos(void) */ -/* { */ -/* CpuCpuidString(0, CpuVendorString); */ -/* return (char *)&CpuVendorString[1]; */ -/* } */ + CpuCpuidString(0, CpuVendorString); + + memmove(CpuInfo.vendorStr, (char *)&CpuVendorString[1], 12*sizeof(char)); + + KernLog("\tCPU %s detected\n", CpuInfo.vendorStr); +}