From 5339d016c07bf717ee388f4feb73544087324af0 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 6 Jan 2024 09:14:11 +0100 Subject: git: port from mercurial repo. Signed-off-by: Amlal El Mahrouss --- HALKit/AMD64/CoreInterruptHandlerAMD64.cpp | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 HALKit/AMD64/CoreInterruptHandlerAMD64.cpp (limited to 'HALKit/AMD64/CoreInterruptHandlerAMD64.cpp') diff --git a/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp b/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp new file mode 100644 index 00000000..4e93d990 --- /dev/null +++ b/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp @@ -0,0 +1,82 @@ +/* + * ======================================================== + * + * 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->SID); +} + +extern "C" void idt_handle_gpf(hCore::UIntPtr rsp) +{ + MUST_PASS(hCore::ProcessManager::Shared().Leak().GetCurrent()); + + hCore::kcout << hCore::StringBuilder::FromInt("sp{%}", 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("sp{%}", 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("sp{%}", 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("sp{%}", 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(); +} -- cgit v1.2.3