forked from xt-sys/exectos
Implement APIC presence check and panic if unsupported
This commit is contained in:
@@ -9,6 +9,41 @@
|
|||||||
#include <xtos.hh>
|
#include <xtos.hh>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the APIC is supported by the processor.
|
||||||
|
*
|
||||||
|
* @return This routine returns TRUE if APIC is supported, or FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
BOOLEAN
|
||||||
|
HL::Pic::CheckApicSupport(VOID)
|
||||||
|
{
|
||||||
|
CPUID_REGISTERS CpuRegisters;
|
||||||
|
|
||||||
|
/* Prepare CPUID registers */
|
||||||
|
CpuRegisters.Leaf = CPUID_GET_STANDARD1_FEATURES;
|
||||||
|
CpuRegisters.SubLeaf = 0;
|
||||||
|
CpuRegisters.Eax = 0;
|
||||||
|
CpuRegisters.Ebx = 0;
|
||||||
|
CpuRegisters.Ecx = 0;
|
||||||
|
CpuRegisters.Edx = 0;
|
||||||
|
|
||||||
|
/* Get CPUID */
|
||||||
|
AR::CpuFunc::CpuId(&CpuRegisters);
|
||||||
|
|
||||||
|
/* Check APIC status from the CPUID results */
|
||||||
|
if(!(CpuRegisters.Edx & CPUID_FEATURES_EDX_APIC))
|
||||||
|
{
|
||||||
|
/* APIC is not supported */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* APIC is supported */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the x2APIC extension is supported by the processor.
|
* Checks whether the x2APIC extension is supported by the processor.
|
||||||
*
|
*
|
||||||
@@ -124,6 +159,14 @@ HL::Pic::InitializeApic(VOID)
|
|||||||
APIC_LVT_REGISTER LvtRegister;
|
APIC_LVT_REGISTER LvtRegister;
|
||||||
ULONG CpuNumber;
|
ULONG CpuNumber;
|
||||||
|
|
||||||
|
/* Check APIC support */
|
||||||
|
if(!CheckApicSupport())
|
||||||
|
{
|
||||||
|
/* APIC is not supported, raise kernel panic */
|
||||||
|
DebugPrint(L"FATAL ERROR: Local APIC not present.\n");
|
||||||
|
KE::Crash::Panic(0x5D, CPUID_GET_STANDARD1_FEATURES, 0x0, 0x0, CPUID_FEATURES_EDX_APIC);
|
||||||
|
}
|
||||||
|
|
||||||
/* Determine APIC mode (xAPIC compatibility or x2APIC) */
|
/* Determine APIC mode (xAPIC compatibility or x2APIC) */
|
||||||
if(CheckX2ApicSupport())
|
if(CheckX2ApicSupport())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace HL
|
|||||||
IN ULONGLONG Value);
|
IN ULONGLONG Value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
STATIC XTAPI BOOLEAN CheckApicSupport(VOID);
|
||||||
STATIC XTAPI BOOLEAN CheckX2ApicSupport(VOID);
|
STATIC XTAPI BOOLEAN CheckX2ApicSupport(VOID);
|
||||||
STATIC XTCDECL VOID HandleApicSpuriousService(VOID);
|
STATIC XTCDECL VOID HandleApicSpuriousService(VOID);
|
||||||
STATIC XTCDECL VOID HandlePicSpuriousService(VOID);
|
STATIC XTCDECL VOID HandlePicSpuriousService(VOID);
|
||||||
|
|||||||
Reference in New Issue
Block a user