summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-03-03 20:04:14 +0000
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-03-03 20:04:14 +0000
commit1be90ecf5c097c143ec90f463dbd73e7fa1ad3f9 (patch)
tree658c8d5e27903155d582fb0e14b08dbe1094a4d4
parente93e0a0c548a407b7eadc8148687f626f2e26c42 (diff)
HCoreKrnl:HAL: Improve interrupt handling, found a solution to interrupt problem in C++; don't modify the stack on the C++ side.
-rw-r--r--Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx19
-rw-r--r--Private/HALKit/AMD64/Processor.hpp2
-rw-r--r--Private/NewBoot/Source/BootMain.cxx26
-rw-r--r--Private/NewKit/Macros.hpp1
4 files changed, 30 insertions, 18 deletions
diff --git a/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx
new file mode 100644
index 00000000..b43ad8c0
--- /dev/null
+++ b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx
@@ -0,0 +1,19 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+//! @file InterruptHandler.cxx
+//! @brief x64 interrupt handler.
+
+#include <ArchKit/ArchKit.hpp>
+
+/// @brief AMD64 Interrupt handler redirects interrupts to their handlers.
+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);
+
+ 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/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