diff options
| -rw-r--r-- | Private/HALKit/AMD64/HalACPIManager.cpp | 5 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 16 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx | 30 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/Processor.hpp | 2 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/EPM.hxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/BootMain.cxx | 26 | ||||
| -rw-r--r-- | Private/NewKit/Macros.hpp | 1 | ||||
| -rw-r--r-- | ReadMe.md | 2 |
9 files changed, 57 insertions, 29 deletions
diff --git a/Private/HALKit/AMD64/HalACPIManager.cpp b/Private/HALKit/AMD64/HalACPIManager.cpp index 20cbd327..945ae6d8 100644 --- a/Private/HALKit/AMD64/HalACPIManager.cpp +++ b/Private/HALKit/AMD64/HalACPIManager.cpp @@ -10,7 +10,7 @@ namespace HCore { ACPIManager::ACPIManager(voidPtr rsdPtr) : m_Rsdp(rsdPtr), m_Entries(0) { - RSDP *_rsdPtr = reinterpret_cast<RSDP *>(this->m_Rsdp); + volatile RSDP *_rsdPtr = reinterpret_cast<volatile RSDP *>(this->m_Rsdp); MUST_PASS(_rsdPtr); MUST_PASS(_rsdPtr->Revision >= 2); @@ -19,6 +19,7 @@ ACPIManager::ACPIManager(voidPtr rsdPtr) : m_Rsdp(rsdPtr), m_Entries(0) { void ACPIManager::Shutdown() {} void ACPIManager::Reset() {} +/// @brief Finds a descriptor table inside ACPI XSDT. ErrorOr<voidPtr> ACPIManager::Find(const char *signature) { MUST_PASS(m_Rsdp); @@ -61,6 +62,8 @@ bool ACPIManager::Checksum(const char *checksum, SSizeT len) { return chr == 0; } +/// Custom to the virtual machine, you'll need to parse the MADT instead. + void rt_shutdown_acpi_qemu_20(void) { HAL::Out16(0xb004, 0x2000); } void rt_shutdown_acpi_qemu_30_plus(void) { HAL::Out16(0x604, 0x2000); } diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp index 90c29ea3..5fe39225 100644 --- a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -14,13 +14,13 @@ EXTERN_C void idt_handle_gpf(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout - << "General Protection Fault, caused by " + << "HCoreKrnl: General Protection Fault, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); } -extern "C" void idt_handle_scheduler(HCore::UIntPtr rsp) { +EXTERN_C void idt_handle_scheduler(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout @@ -34,37 +34,37 @@ extern "C" void idt_handle_scheduler(HCore::UIntPtr rsp) { } } -extern "C" void idt_handle_pf(HCore::UIntPtr rsp) { +EXTERN_C void idt_handle_pf(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Segmentation Fault, caused by " + << "HCoreKrnl: Segmentation Fault, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); } -extern "C" void idt_handle_math(HCore::UIntPtr rsp) { +EXTERN_C void idt_handle_math(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Math error, caused by " + << "HCoreKrnl: Math error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); } -extern "C" void idt_handle_generic(HCore::UIntPtr rsp) { +EXTERN_C void idt_handle_generic(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("sp{%}", rsp); MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Execution error, caused by " + << "HCoreKrnl: Execution error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); diff --git a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index bf122415..fa68ef4a 100644 --- a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -11,6 +11,8 @@ //! NOTE: fGSI stands 'Field Global System Interrupt' +/////////////////////////////////////////////////////////////////////////////////////// + namespace HCore::HAL { constexpr Int32 kThreadAPIC = 0; constexpr Int32 kThreadLAPIC = 1; diff --git a/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx new file mode 100644 index 00000000..0f89d208 --- /dev/null +++ b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx @@ -0,0 +1,30 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +//! @file InterruptHandler.cxx +//! @brief x64 interrupt handler. + +#include <ArchKit/ArchKit.hpp> + +/// @brief Interrupt handler 21h, 10h +/// @param rsp stack pointer. + +#define kInterruptIdAlt 0x10 +#define kInterruptId 0x21 + +EXTERN_C ATTRIBUTE(naked) HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr rsp) +{ + HCore::HAL::StackFramePtr stackPtr = reinterpret_cast<HCore::HAL::StackFramePtr>(rsp); + HCORE_UNUSED(stackPtr); + + if (stackPtr->IntNum == kInterruptId || + stackPtr->IntNum == kInterruptIdAlt) { + /// Do system call TODO + + } + + return rsp; +}
\ No newline at end of file diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp index 93a9775a..e5e35f20 100644 --- a/Private/HALKit/AMD64/Processor.hpp +++ b/Private/HALKit/AMD64/Processor.hpp @@ -79,7 +79,7 @@ using interruptTrap = UIntPtr(UIntPtr sp); typedef UIntPtr Reg; -struct PACKED StackFrame { +struct PACKED StackFrame final { Reg IntNum, ErrCode; Reg Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; Reg R8, R9, R10, R11, R12, R13, R14, R15; diff --git a/Private/NewBoot/BootKit/EPM.hxx b/Private/NewBoot/BootKit/EPM.hxx index 328906f2..2d20237d 100644 --- a/Private/NewBoot/BootKit/EPM.hxx +++ b/Private/NewBoot/BootKit/EPM.hxx @@ -9,4 +9,4 @@ #pragma once -#include <EFIKit/EPM.hxx> +#include <FirmwareKit/EPM.hxx> diff --git a/Private/NewBoot/Source/BootMain.cxx b/Private/NewBoot/Source/BootMain.cxx index 53a217b6..67c6929a 100644 --- a/Private/NewBoot/Source/BootMain.cxx +++ b/Private/NewBoot/Source/BootMain.cxx @@ -7,8 +7,6 @@ * ======================================================== */ -#define __BOOTLOADER__ 1 - #include <BootKit/BootKit.hxx> #include <KernelKit/MSDOS.hpp> #include <KernelKit/PE.hpp> @@ -21,7 +19,7 @@ #endif // ifdef __x86_64__ #ifndef kBootKrnlSections -#error Please provide the amount of sections the kernel has. +#error [NewBoot/HCoreLdr] Please provide the amount of sections the kernel has. #endif // !kBootKrnlSections #define kBootReadSize \ @@ -33,11 +31,13 @@ typedef void (*bt_main_type)(HEL::HandoverInformationHeader* HIH); EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, EfiSystemTable* SystemTable) { - InitEFI(SystemTable); - InitQT(); + InitEFI(SystemTable); // Init the efi library. + InitQT(); // Quick Toolkit for UI BTextWriter writer; + /// Splash screen stuff + writer.Write(L"MahroussLogic (R) HCoreLdr: "); writer.Write(BVersionString::Shared()).Write(L"\r\n"); @@ -52,6 +52,8 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, .Write(SystemTable->FirmwareVendor) .Write(L"\r\n"); + /// Read Kernel blob. + BFileReader kernelImg(L"HCOREKRNL.EXE", ImageHandle); kernelImg.Size(kBootReadSize); @@ -70,6 +72,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, ExecOptionalHeaderPtr optHdr = reinterpret_cast<ExecOptionalHeaderPtr>( (UIntPtr)&ptrHdr->mCharacteristics + 1); + // first check for kernel.cfg inside ESP/EPM. BFileReader systemIni(L"KERNEL.CFG", ImageHandle); systemIni.Size(1); @@ -83,18 +86,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, UInt64 posSeek = 0; - /**** - * - * LOAD KERNEL CODE - * - * - * - * - * - * - * - * LOAD KERNEL CODE - */ + // load sections here kernelImg.File()->SetPosition(kernelImg.File(), &posSeek); kernelImg.Size(kBootReadSize + diff --git a/Private/NewKit/Macros.hpp b/Private/NewKit/Macros.hpp index 5b8fd0ce..141ccc53 100644 --- a/Private/NewKit/Macros.hpp +++ b/Private/NewKit/Macros.hpp @@ -89,3 +89,4 @@ #endif #define STRINGIFY(X) #X +#define HCORE_UNUSED(X) ((void)X)
\ No newline at end of file @@ -20,6 +20,6 @@ And execute: make h-core-<cpu>-<hardware> ``` -You'd also need The SDK and MinGW, to build and link the components. For Tools look at `Public/Tools` +You'd also need The SDK and MinGW, to build and link the components. For Tools look at `Private/Tools` ##### Copyright, Mahrouss Logic, all rights reserved. |
