diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-26 22:26:48 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-26 22:27:09 +0100 |
| commit | eba8b7ddd0a455d9e49f32dcae712c5612c0093c (patch) | |
| tree | 749a3d34546d055507a920bce4ab10e8a9945719 /Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp | |
| parent | dd192787a70a973f2474720aea49af3f6ddabb7a (diff) | |
Kernel: Major repository refactor.
Rework the repo into Private and Public modules.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp')
| -rw-r--r-- | Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp new file mode 100644 index 00000000..fd037c5f --- /dev/null +++ b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp @@ -0,0 +1,82 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <ArchKit/Arch.hpp> +#include <NewKit/String.hpp> +#include <KernelKit/ProcessManager.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->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(); +} |
