diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-25 08:06:38 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-25 08:06:38 +0100 |
| commit | 9be51d883414584db0926ab854d6026e1785048b (patch) | |
| tree | 6afb5cec25c48ac76a8e26b2cc0b09dd1dc2c1ea /Private/HALKit | |
| parent | 27e0af3ecfe0be226f88837634111299121e5ddb (diff) | |
Kernel: Morning bump.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit')
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreInterruptHandler.cpp | 25 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 17 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp | 5 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalHardwareInit.cpp | 16 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalInterruptRouting.asm | 5 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalPlatformAMD64.cpp | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalRoutines.s | 1 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/Processor.hpp | 3 |
8 files changed, 40 insertions, 34 deletions
diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp new file mode 100644 index 00000000..a668a0e4 --- /dev/null +++ b/Private/HALKit/AMD64/HalCoreInterruptHandler.cpp @@ -0,0 +1,25 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <ArchKit/ArchKit.hpp> +#include <KernelKit/ProcessManager.hpp> +#include <NewKit/String.hpp> + +extern "C" HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr &rsp) { + HCore::HAL::rt_cli(); + + HCore::HAL::StackFramePtr sf = (HCore::HAL::StackFramePtr)rsp; + + rt_syscall_handle(sf); + + HCore::kcout << "Krnl\\rt_handle_interrupts: Done\r\n"; + + HCore::HAL::rt_sti(); + return rsp; +} diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp index caf891d1..98d36f86 100644 --- a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -25,7 +25,7 @@ extern "C" void idt_handle_gpf(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout - << "General Protection Fault, Caused by " + << "General Protection Fault, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -50,7 +50,7 @@ extern "C" void idt_handle_pf(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Segmentation Fault, Caused by " + << "Segmentation Fault, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -62,7 +62,7 @@ extern "C" void idt_handle_math(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Math error, Caused by " + << "Math error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); @@ -74,17 +74,8 @@ extern "C" void idt_handle_generic(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); HCore::kcout - << "Processor error, Caused by " + << "Execution error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); } - -extern "C" HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr &rsp) { - HCore::HAL::rt_cli(); - - HCore::HAL::StackFramePtr sf = (HCore::HAL::StackFramePtr)rsp; - - HCore::HAL::rt_sti(); - return rsp; -} diff --git a/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp index 4f1ed4da..2e75b6cb 100644 --- a/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp @@ -14,10 +14,9 @@ HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), kMaxSyscalls> kSyscalls; -// IDT System Call Handler. -// NOTE: don't trust the user. +/// @brief Interrupt system call handler. extern "C" void rt_syscall_handle(HCore::HAL::StackFrame *stack) { for (HCore::SizeT index = 0UL; index < kMaxSyscalls; ++index) { - (kSyscalls[index].Leak().Leak())(stack->R15, stack); + if (kSyscalls[index]) (kSyscalls[index].Leak().Leak())(stack->R15, stack); } } diff --git a/Private/HALKit/AMD64/HalHardwareInit.cpp b/Private/HALKit/AMD64/HalHardwareInit.cpp index 1c857ff7..43b15169 100644 --- a/Private/HALKit/AMD64/HalHardwareInit.cpp +++ b/Private/HALKit/AMD64/HalHardwareInit.cpp @@ -11,18 +11,10 @@ // bugs = 0 -extern "C" HCore::VoidPtr __EXEC_IVT; +extern "C" HCore::UIntPtr* __EXEC_IVT; -namespace HCore { -bool ke_init_hal() { - HCore::HAL::Register64 kIdtRegister; - - kIdtRegister.Base = (UIntPtr)__EXEC_IVT; - kIdtRegister.Limit = sizeof(HAL::Register64) * 255; +extern void rt_wait_for_io(void); - HAL::IDTLoader idt; - idt.Load(kIdtRegister); - - return true; -} +namespace HCore { +bool ke_init_hal() { return true; } } // namespace HCore diff --git a/Private/HALKit/AMD64/HalInterruptRouting.asm b/Private/HALKit/AMD64/HalInterruptRouting.asm index 9bc13f15..da0a8d5a 100644 --- a/Private/HALKit/AMD64/HalInterruptRouting.asm +++ b/Private/HALKit/AMD64/HalInterruptRouting.asm @@ -19,6 +19,7 @@ HCoreInterrupt%1: push %1 jmp ke_handle_irq + iretq %endmacro %macro IntNormal 1 @@ -26,6 +27,7 @@ HCoreInterrupt%1: push 0 push %1 jmp ke_handle_irq + iretq %endmacro ; This file handles the core interrupt table @@ -38,8 +40,6 @@ global __EXEC_IVT section .text ke_handle_irq: - cld - push rax push rbx push rcx @@ -76,6 +76,7 @@ ke_handle_irq: pop rbx pop rax + ret section .data diff --git a/Private/HALKit/AMD64/HalPlatformAMD64.cpp b/Private/HALKit/AMD64/HalPlatformAMD64.cpp index 71b7542e..b2e343b6 100644 --- a/Private/HALKit/AMD64/HalPlatformAMD64.cpp +++ b/Private/HALKit/AMD64/HalPlatformAMD64.cpp @@ -35,9 +35,7 @@ void IDTLoader::Load(Register64 &idt) { reg->base = idt.Base; reg->limit = idt.Limit; - rt_cli(); rt_load_idt(reg); - rt_sti(); } void GDTLoader::Load(Ref<Register64> &gdt) { GDTLoader::Load(gdt.Leak()); } diff --git a/Private/HALKit/AMD64/HalRoutines.s b/Private/HALKit/AMD64/HalRoutines.s index 3e70a507..28833c47 100644 --- a/Private/HALKit/AMD64/HalRoutines.s +++ b/Private/HALKit/AMD64/HalRoutines.s @@ -10,7 +10,6 @@ rt_load_gdt: rt_load_idt: lidt (%rcx) - sti ret .section .text diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp index bacfb393..5c79e042 100644 --- a/Private/HALKit/AMD64/Processor.hpp +++ b/Private/HALKit/AMD64/Processor.hpp @@ -56,7 +56,8 @@ using interruptTrap = UIntPtr(UIntPtr sp); typedef UIntPtr Reg; -struct __attribute__((packed)) StackFrame { +struct PACKED StackFrame { + Reg IntNum; Reg Rax; Reg Rbx; Reg Rcx; |
