diff --git a/include/kernel/base.h b/include/kernel/base.h index 4927b10..bccb425 100644 --- a/include/kernel/base.h +++ b/include/kernel/base.h @@ -43,9 +43,10 @@ typedef struct ListNode_t ListNode_t; typedef struct Thread_t Thread_t; typedef struct Process_t Process_t; typedef struct BootInfo_t BootInfo_t; -typedef struct Processor_t Processor_t; +typedef struct CpuCore_t CpuCore_t; +typedef struct CpuInfo_t CpuInfo_t; typedef struct ISRFrame_t ISRFrame_t; -typedef enum ProcState_t ProcState_t; +typedef enum ProcState_t ProcState_t; typedef struct IdtDescriptor_t IdtDescriptor_t; typedef struct IdtEntry_t IdtEntry_t; @@ -63,7 +64,7 @@ typedef struct GdtPtr_t GdtPtr_t; // // Holds all CPU-local variables // -struct Processor_t +struct CpuCore_t { // CPU number, index in CPU list int index; @@ -71,17 +72,10 @@ struct Processor_t // CPU APIC id int apicId; - // CPU Vendor String (always 12 characters) - char vendorStr[12]; - - // CPU Model code (enum in cpu.h) - int modelCode; - - // CPU Features flag - uint featureFlag; + CpuInfo_t *infos; // Number of ticks since boot time - ulong ticks; + ulong ticks; // XXX I/O APIC // Current process & thread Process_t *process; @@ -100,6 +94,18 @@ struct Processor_t ListHead_t *timeCritProcs; }; +struct CpuInfo_t +{ + // CPU Vendor String (always 12 characters) + char vendorStr[12]; + + // CPU Model code (enum in cpu.h) + int modelCode; + + // CPU Features flag + uint featureFlag; +}; + struct ISRFrame_t { /* The register file */ ulong regs[15]; @@ -126,9 +132,9 @@ struct ISRFrame_t { // Current CPU number #define _KeCurCPU 0 -extern int KeCPUCount; -extern volatile Processor_t *KeCurCPU; -extern Processor_t _KeCPUTable[NCPUS]; +extern int KeCPUCount; +extern volatile CpuCore_t *KeCurCPU; +extern CpuCore_t _KeCPUTable[NCPUS]; //----------------------------------------------------------------------------// diff --git a/include/kernel/cpuid.h b/include/kernel/cpuid.h index 16eb9e0..4876a5c 100644 --- a/include/kernel/cpuid.h +++ b/include/kernel/cpuid.h @@ -93,6 +93,8 @@ enum { FEAT_EDX_PBE = 1 << 31 }; + + // -------------------------------------------------------------------------- // // Issue a single request to CPUID. Fits 'intel features', for instance diff --git a/kaleid/kernel/cpu/cpuid.c b/kaleid/kernel/cpu/cpuid.c index 43630b0..7aa56ea 100644 --- a/kaleid/kernel/cpu/cpuid.c +++ b/kaleid/kernel/cpu/cpuid.c @@ -24,9 +24,11 @@ #include -char* CpuGetVendorString(void) { - uint where[5] = { 0 }; - return (char *)&where[1]; + +void CpuGetInfos(void) +{ + CpuCpuidString(0, CpuVendorString); + return (char *)&CpuVendorString[1]; } diff --git a/kaleid/kernel/init/table.c b/kaleid/kernel/init/table.c index 88a3169..aec98a7 100644 --- a/kaleid/kernel/init/table.c +++ b/kaleid/kernel/init/table.c @@ -25,11 +25,11 @@ #include int KeCPUCount = 1; -Processor_t _KeCPUTable[NCPUS] = {0}; +CpuCore_t _KeCPUTable[NCPUS] = {0}; volatile BootInfo_t BtBootTab = {0}; volatile bool KeIsPanicking = 0; -volatile Processor_t *KeCurCPU = &_KeCPUTable[0]; +volatile CpuCore_t *KeCurCPU = &_KeCPUTable[0];