diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-03-04 15:38:28 +0000 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-03-04 15:38:28 +0000 |
| commit | 357e7a82bc85acee0ed05c6dc0fd870990859df9 (patch) | |
| tree | 896663a5f2ec9498513b99659c5d73a8718ece7e /Private/HALKit | |
| parent | 332fab8d57aac52b9664785cbda989260962a41c (diff) | |
| parent | 64c8674bc09985fcf7119cfb2b88cad3081b1603 (diff) | |
Merge branch 'unstable' into 'trunk'
HCoreKrnl:HAL: Work on interrupts for AMD64
See merge request mahrouss-logic/micro-kernel!8
Diffstat (limited to 'Private/HALKit')
| -rw-r--r-- | Private/HALKit/AMD64/HalACPIManager.cpp | 5 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 16 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx | 30 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/Processor.hpp | 2 |
5 files changed, 45 insertions, 10 deletions
diff --git a/Private/HALKit/AMD64/HalACPIManager.cpp b/Private/HALKit/AMD64/HalACPIManager.cpp index 20cbd327..945ae6d8 100644 --- a/Private/HALKit/AMD64/HalACPIManager.cpp +++ b/Private/HALKit/AMD64/HalACPIManager.cpp @@ -10,7 +10,7 @@ namespace HCore { ACPIManager::ACPIManager(voidPtr rsdPtr) : m_Rsdp(rsdPtr), m_Entries(0) { - RSDP *_rsdPtr = reinterpret_cast<RSDP *>(this->m_Rsdp); + volatile RSDP *_rsdPtr = reinterpret_cast<volatile RSDP *>(this->m_Rsdp); MUST_PASS(_rsdPtr); MUST_PASS(_rsdPtr->Revision >= 2); @@ -19,6 +19,7 @@ ACPIManager::ACPIManager(voidPtr rsdPtr) : m_Rsdp(rsdPtr), m_Entries(0) { void ACPIManager::Shutdown() {} void ACPIManager::Reset() {} +/// @brief Finds a descriptor table inside ACPI XSDT. ErrorOr<voidPtr> ACPIManager::Find(const char *signature) { MUST_PASS(m_Rsdp); @@ -61,6 +62,8 @@ bool ACPIManager::Checksum(const char *checksum, SSizeT len) { return chr == 0; } +/// Custom to the virtual machine, you'll need to parse the MADT instead. + void rt_shutdown_acpi_qemu_20(void) { HAL::Out16(0xb004, 0x2000); } void rt_shutdown_acpi_qemu_30_plus(void) { HAL::Out16(0x604, 0x2000); } diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp index 90c29ea3..5fe39225 100644 --- a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -14,13 +14,13 @@ EXTERN_C void idt_handle_gpf(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout - << "General Protection Fault, caused by " + << "HCoreKrnl: 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) { +EXTERN_C void idt_handle_scheduler(HCore::UIntPtr rsp) { HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout @@ -34,37 +34,37 @@ extern "C" void idt_handle_scheduler(HCore::UIntPtr rsp) { } } -extern "C" void idt_handle_pf(HCore::UIntPtr rsp) { +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 " + << "HCoreKrnl: 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) { +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 " + << "HCoreKrnl: 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) { +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 - << "Execution error, caused by " + << "HCoreKrnl: Execution error, caused by " << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); diff --git a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index bf122415..fa68ef4a 100644 --- a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -11,6 +11,8 @@ //! NOTE: fGSI stands 'Field Global System Interrupt' +/////////////////////////////////////////////////////////////////////////////////////// + namespace HCore::HAL { constexpr Int32 kThreadAPIC = 0; constexpr Int32 kThreadLAPIC = 1; diff --git a/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx new file mode 100644 index 00000000..0f89d208 --- /dev/null +++ b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx @@ -0,0 +1,30 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +//! @file InterruptHandler.cxx +//! @brief x64 interrupt handler. + +#include <ArchKit/ArchKit.hpp> + +/// @brief Interrupt handler 21h, 10h +/// @param rsp stack pointer. + +#define kInterruptIdAlt 0x10 +#define kInterruptId 0x21 + +EXTERN_C ATTRIBUTE(naked) HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr rsp) +{ + HCore::HAL::StackFramePtr stackPtr = reinterpret_cast<HCore::HAL::StackFramePtr>(rsp); + HCORE_UNUSED(stackPtr); + + if (stackPtr->IntNum == kInterruptId || + stackPtr->IntNum == kInterruptIdAlt) { + /// Do system call TODO + + } + + return rsp; +}
\ No newline at end of file diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp index 93a9775a..e5e35f20 100644 --- a/Private/HALKit/AMD64/Processor.hpp +++ b/Private/HALKit/AMD64/Processor.hpp @@ -79,7 +79,7 @@ using interruptTrap = UIntPtr(UIntPtr sp); typedef UIntPtr Reg; -struct PACKED StackFrame { +struct PACKED StackFrame final { Reg IntNum, ErrCode; Reg Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; Reg R8, R9, R10, R11, R12, R13, R14, R15; |
