diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-03 20:39:06 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-03 20:39:06 +0100 |
| commit | f99e383775fa43c5c1354067962b1590ff2abdae (patch) | |
| tree | f83a9b232c0424963fc9989b517e53f903ee036f /Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | |
| parent | 0ca5d0d92ee326f3deda797403c27090bd0784ab (diff) | |
NewBoot: Will work on AHCI instead, ATA is not getting any further in
the future.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp')
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp new file mode 100644 index 00000000..caf891d1 --- /dev/null +++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -0,0 +1,90 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <ArchKit/ArchKit.hpp> +#include <KernelKit/ProcessManager.hpp> +#include <NewKit/String.hpp> + +extern "C" void idt_handle_system_call(HCore::UIntPtr rsp) { + HCore::HAL::StackFrame *sf = reinterpret_cast<HCore::HAL::StackFrame *>(rsp); + rt_syscall_handle(sf); + + HCore::kcout << "System Call with ID: " + << HCore::StringBuilder::FromInt("syscall{%}", sf->R15); +} + +extern "C" void idt_handle_gpf(HCore::UIntPtr rsp) { + MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); + + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); + + HCore::kcout + << "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) { + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); + + HCore::kcout + << "Will be scheduled back later " + << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); + + /// schedule another process. + if (!HCore::ProcessHelper::StartScheduling()) { + HCore::kcout << "Let's continue schedule this process...\r\n"; + } +} + +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 " + << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); + + HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); +} + +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 " + << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); + + HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); +} + +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 + << "Processor 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; +} |
