From 028d7057402051f809bbafa27aa278769732c56b Mon Sep 17 00:00:00 2001 From: amlal Date: Sat, 9 Mar 2024 19:12:48 +0000 Subject: Microkernel: See below. - Moved most of GDT code to AMD64's Processor.hpp - add hal_ category of functions. Signed-off-by: amlal --- Private/Drivers/AHCI/API.hxx | 2 ++ .../HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 2 +- Private/HALKit/AMD64/HalKernelMain.cxx | 35 +++------------------- Private/HALKit/AMD64/HalSMPCore.cxx | 1 - Private/HALKit/AMD64/Processor.hpp | 29 +++++++++++++++++- Private/NewBoot/BootKit/Arch/AHCI.hxx | 4 +-- 6 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Private/Drivers/AHCI/API.hxx b/Private/Drivers/AHCI/API.hxx index 2a02b434..5ef58d84 100644 --- a/Private/Drivers/AHCI/API.hxx +++ b/Private/Drivers/AHCI/API.hxx @@ -6,3 +6,5 @@ #pragma once +#include + diff --git a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index fa68ef4a..0727aff0 100644 --- a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -104,7 +104,7 @@ Madt* system_find_core(Madt* madt) { /////////////////////////////////////////////////////////////////////////////////////// -void system_get_cores(voidPtr rsdPtr) { +void hal_system_get_cores(voidPtr rsdPtr) { auto acpi = ACPIManager(rsdPtr); kApicMadt = acpi.Find(kApicSignature).Leak().Leak(); diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx index 6e752e99..535a4fc9 100644 --- a/Private/HALKit/AMD64/HalKernelMain.cxx +++ b/Private/HALKit/AMD64/HalKernelMain.cxx @@ -22,33 +22,6 @@ EXTERN_C HCore::VoidPtr kInterruptVectorTable[]; -namespace Detail { -using namespace HCore; - -EXTERN_C void _ke_power_on_self_test(void); - -/** - @brief Global descriptor table entry, either null, code or data. -*/ -struct PACKED HC_GDT_ENTRY final { - UInt16 Limit0; - UInt16 Base0; - UInt8 Base1; - UInt8 AccessByte; - UInt8 Limit1_Flags; - UInt8 Base2; -}; - -struct PACKED ALIGN(0x1000) HC_GDT final { - HC_GDT_ENTRY Null; - HC_GDT_ENTRY KernCode; - HC_GDT_ENTRY KernData; - HC_GDT_ENTRY UserNull; - HC_GDT_ENTRY UserCode; - HC_GDT_ENTRY UserData; -}; -} // namespace Detail - EXTERN_C void RuntimeMain( HCore::HEL::HandoverInformationHeader* HandoverHeader) { kHandoverHeader = HandoverHeader; @@ -60,7 +33,7 @@ EXTERN_C void RuntimeMain( kKernelPhysicalSize = HandoverHeader->f_PhysicalSize; kKernelPhysicalStart = HandoverHeader->f_PhysicalStart; - static Detail::HC_GDT GDT = { + STATIC HCore::HAL::Detail::HCoreGDT GDT = { {0, 0, 0, 0x00, 0x00, 0}, // null entry {0, 0, 0, 0x9a, 0xaf, 0}, // kernel code {0, 0, 0, 0x92, 0xaf, 0}, // kernel data @@ -71,8 +44,8 @@ EXTERN_C void RuntimeMain( HCore::HAL::RegisterGDT gdtBase; - gdtBase.Base = (HCore::UIntPtr)&GDT; - gdtBase.Limit = sizeof(Detail::HC_GDT) - 1; + gdtBase.Base = reinterpret_cast(&GDT); + gdtBase.Limit = sizeof(HCore::HAL::Detail::HCoreGDT) - 1; /// Load GDT. @@ -98,7 +71,7 @@ EXTERN_C void RuntimeMain( /// START POST - Detail::_ke_power_on_self_test(); + HCore::HAL::Detail::_ke_power_on_self_test(); /// END POST diff --git a/Private/HALKit/AMD64/HalSMPCore.cxx b/Private/HALKit/AMD64/HalSMPCore.cxx index 9e98fb3c..a72d6bfe 100644 --- a/Private/HALKit/AMD64/HalSMPCore.cxx +++ b/Private/HALKit/AMD64/HalSMPCore.cxx @@ -7,7 +7,6 @@ #include using namespace HCore; - Void Process::AssignStart(UIntPtr &imageStart) noexcept { if (imageStart == 0) this->Crash(); diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp index c69e35d0..e94d055f 100644 --- a/Private/HALKit/AMD64/Processor.hpp +++ b/Private/HALKit/AMD64/Processor.hpp @@ -140,7 +140,34 @@ class IDTLoader final { static void Load(Ref &idt); }; -void system_get_cores(voidPtr rsdPtr); +Void hal_system_get_cores(VoidPtr rsdPtr); + +/// @brief Processor specific structures. +namespace Detail { +EXTERN_C void _ke_power_on_self_test(void); + +/** + @brief Global descriptor table entry, either null, code or data. +*/ + +struct PACKED HCoreGDTRecord final { + UInt16 Limit0; + UInt16 Base0; + UInt8 Base1; + UInt8 AccessByte; + UInt8 Limit1_Flags; + UInt8 Base2; +}; + +struct PACKED ALIGN(0x1000) HCoreGDT final { + HCoreGDTRecord Null; + HCoreGDTRecord KernCode; + HCoreGDTRecord KernData; + HCoreGDTRecord UserNull; + HCoreGDTRecord UserCode; + HCoreGDTRecord UserData; +}; +} // namespace Detail } // namespace HCore::HAL EXTERN_C void idt_handle_system_call(HCore::UIntPtr rsp); diff --git a/Private/NewBoot/BootKit/Arch/AHCI.hxx b/Private/NewBoot/BootKit/Arch/AHCI.hxx index 32fe033c..f4e635c7 100644 --- a/Private/NewBoot/BootKit/Arch/AHCI.hxx +++ b/Private/NewBoot/BootKit/Arch/AHCI.hxx @@ -24,10 +24,10 @@ class BDeviceAHCI final { HCore::Boolean mErr{false}; HCore::Boolean mDetected{false}; - operator bool() { return !mErr; } + operator bool() { return !this->mErr; } }; - operator bool() { return Leak().mDetected; } + operator bool() { return this->Leak().mDetected; } BDeviceAHCI& Read(HCore::WideChar* Buf, const HCore::SizeT& SecCount); BDeviceAHCI& Write(HCore::WideChar* Buf, const HCore::SizeT& SecCount); -- cgit v1.2.3