From f99e383775fa43c5c1354067962b1590ff2abdae Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 3 Feb 2024 20:39:06 +0100 Subject: NewBoot: Will work on AHCI instead, ATA is not getting any further in the future. Signed-off-by: Amlal El Mahrouss --- .../HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp (limited to 'Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp') 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 +#include +#include + +extern "C" void idt_handle_system_call(HCore::UIntPtr rsp) { + HCore::HAL::StackFrame *sf = reinterpret_cast(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; +} -- cgit v1.2.3