From 6409dfdf0bfaa45e9a56055e3e8f3a344c275a4f Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 7 Nov 2022 11:17:06 +0200 Subject: [PATCH] Kernel now boots on BIOS systems --- Core/Power.cpp | 8 ++++++-- Kernel.cpp | 1 + include/lock.hpp | 10 +++++----- include/power.hpp | 1 + include/vector.hpp | 13 ++++++++----- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Core/Power.cpp b/Core/Power.cpp index b17637e..60dba25 100644 --- a/Core/Power.cpp +++ b/Core/Power.cpp @@ -52,11 +52,15 @@ namespace Power CPU::Stop(); } + void Power::InitDSDT() + { + if (((ACPI::ACPI *)this->acpi)->FADT) + this->dsdt = new ACPI::DSDT((ACPI::ACPI *)acpi); + } + Power::Power() { this->acpi = new ACPI::ACPI(bInfo); - if (((ACPI::ACPI *)this->acpi)->FADT) - this->dsdt = new ACPI::DSDT((ACPI::ACPI *)acpi); this->madt = new ACPI::MADT(((ACPI::ACPI *)acpi)->MADT); trace("Power manager initialized"); } diff --git a/Kernel.cpp b/Kernel.cpp index 4839c65..1ea91bc 100644 --- a/Kernel.cpp +++ b/Kernel.cpp @@ -79,6 +79,7 @@ EXTERNC void Entry(BootInfo *Info) } KPrint("Enabling Interrupts on Bootstrap Processor"); Interrupts::Enable(0); + PowerManager->InitDSDT(); KPrint("Initializing Timers"); #if defined(__amd64__) TimeManager = new Time::time(PowerManager->GetACPI()); diff --git a/include/lock.hpp b/include/lock.hpp index be40381..9c21149 100644 --- a/include/lock.hpp +++ b/include/lock.hpp @@ -17,11 +17,11 @@ class LockClass { struct SpinLockData { - uint64_t LockData; - const char *CurrentHolder; - const char *AttemptingToGet; - uint64_t Count; - long Core; + uint64_t LockData = 0x0; + const char *CurrentHolder = "(nul)"; + const char *AttemptingToGet = "(nul)"; + uint64_t Count = 0; + long Core = 0; }; private: diff --git a/include/power.hpp b/include/power.hpp index d3b3e22..3ea1902 100644 --- a/include/power.hpp +++ b/include/power.hpp @@ -44,6 +44,7 @@ namespace Power */ void Shutdown(); + void InitDSDT(); Power(); ~Power(); }; diff --git a/include/vector.hpp b/include/vector.hpp index 3e2bca9..e9c37db 100644 --- a/include/vector.hpp +++ b/include/vector.hpp @@ -15,6 +15,9 @@ public: Vector() { +#ifdef DEBUG_MEM_ALLOCATION + debug("VECTOR INIT: Vector( )"); +#endif VectorCapacity = 0; VectorSize = 0; VectorBuffer = 0; @@ -25,7 +28,7 @@ public: VectorCapacity = Size; VectorSize = Size; #ifdef DEBUG_MEM_ALLOCATION - debug("VECTOR ALLOCATION: Vector( %lld )", Size); + debug("VECTOR INIT: Vector( %lld )", Size); #endif VectorBuffer = new T[Size]; } @@ -35,7 +38,7 @@ public: VectorSize = Size; VectorCapacity = Size; #ifdef DEBUG_MEM_ALLOCATION - debug("VECTOR ALLOCATION: Vector( %lld %llx )", Size, Initial); + debug("VECTOR INIT: Vector( %lld %llx )", Size, Initial); #endif VectorBuffer = new T[Size]; for (uint64_t i = 0; i < Size; i++) @@ -47,7 +50,7 @@ public: VectorSize = Vector.VectorSize; VectorCapacity = Vector.VectorCapacity; #ifdef DEBUG_MEM_ALLOCATION - debug("VECTOR ALLOCATION: Vector( )->Size: %lld", VectorSize); + debug("VECTOR INIT: Vector( )->Size: %lld", VectorSize); #endif VectorBuffer = new T[VectorSize]; for (uint64_t i = 0; i < VectorSize; i++) @@ -57,7 +60,7 @@ public: ~Vector() { #ifdef DEBUG_MEM_ALLOCATION - debug("VECTOR ALLOCATION: ~Vector( ~%lx )", VectorBuffer); + debug("VECTOR INIT: ~Vector( ~%lx )", VectorBuffer); #endif delete[] VectorBuffer; } @@ -144,7 +147,7 @@ public: delete[] VectorBuffer; VectorSize = Vector.VectorSize; VectorCapacity = Vector.VectorCapacity; - #ifdef DEBUG_MEM_ALLOCATION +#ifdef DEBUG_MEM_ALLOCATION debug("VECTOR ALLOCATION: operator=( )->Size:%lld", VectorSize); #endif VectorBuffer = new T[VectorSize];