This commit is contained in:
Adrien Bourmault 2019-05-09 21:57:54 +02:00
parent 6c504cff34
commit 90761c4a10
4 changed files with 30 additions and 20 deletions

View File

@ -43,9 +43,10 @@ typedef struct ListNode_t ListNode_t;
typedef struct Thread_t Thread_t; typedef struct Thread_t Thread_t;
typedef struct Process_t Process_t; typedef struct Process_t Process_t;
typedef struct BootInfo_t BootInfo_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 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 IdtDescriptor_t IdtDescriptor_t;
typedef struct IdtEntry_t IdtEntry_t; typedef struct IdtEntry_t IdtEntry_t;
@ -63,7 +64,7 @@ typedef struct GdtPtr_t GdtPtr_t;
// //
// Holds all CPU-local variables // Holds all CPU-local variables
// //
struct Processor_t struct CpuCore_t
{ {
// CPU number, index in CPU list // CPU number, index in CPU list
int index; int index;
@ -71,17 +72,10 @@ struct Processor_t
// CPU APIC id // CPU APIC id
int apicId; int apicId;
// CPU Vendor String (always 12 characters) CpuInfo_t *infos;
char vendorStr[12];
// CPU Model code (enum in cpu.h)
int modelCode;
// CPU Features flag
uint featureFlag;
// Number of ticks since boot time // Number of ticks since boot time
ulong ticks; ulong ticks; // XXX I/O APIC
// Current process & thread // Current process & thread
Process_t *process; Process_t *process;
@ -100,6 +94,18 @@ struct Processor_t
ListHead_t *timeCritProcs; 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 { struct ISRFrame_t {
/* The register file */ /* The register file */
ulong regs[15]; ulong regs[15];
@ -126,9 +132,9 @@ struct ISRFrame_t {
// Current CPU number // Current CPU number
#define _KeCurCPU 0 #define _KeCurCPU 0
extern int KeCPUCount; extern int KeCPUCount;
extern volatile Processor_t *KeCurCPU; extern volatile CpuCore_t *KeCurCPU;
extern Processor_t _KeCPUTable[NCPUS]; extern CpuCore_t _KeCPUTable[NCPUS];
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//

View File

@ -93,6 +93,8 @@ enum {
FEAT_EDX_PBE = 1 << 31 FEAT_EDX_PBE = 1 << 31
}; };
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
// Issue a single request to CPUID. Fits 'intel features', for instance // Issue a single request to CPUID. Fits 'intel features', for instance

View File

@ -24,9 +24,11 @@
#include <kernel/cpuid.h> #include <kernel/cpuid.h>
char* CpuGetVendorString(void) {
uint where[5] = { 0 }; void CpuGetInfos(void)
return (char *)&where[1]; {
CpuCpuidString(0, CpuVendorString);
return (char *)&CpuVendorString[1];
} }

View File

@ -25,11 +25,11 @@
#include <kernel/boot.h> #include <kernel/boot.h>
int KeCPUCount = 1; int KeCPUCount = 1;
Processor_t _KeCPUTable[NCPUS] = {0}; CpuCore_t _KeCPUTable[NCPUS] = {0};
volatile BootInfo_t BtBootTab = {0}; volatile BootInfo_t BtBootTab = {0};
volatile bool KeIsPanicking = 0; volatile bool KeIsPanicking = 0;
volatile Processor_t *KeCurCPU = &_KeCPUTable[0]; volatile CpuCore_t *KeCurCPU = &_KeCPUTable[0];