summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit
diff options
context:
space:
mode:
Diffstat (limited to 'Private/HALKit')
-rw-r--r--Private/HALKit/AMD64/HalDescriptorLoader.cpp12
-rw-r--r--Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx29
-rw-r--r--Private/HALKit/AMD64/HalNewBoot.asm2
-rw-r--r--Private/HALKit/AMD64/Processor.hpp4
4 files changed, 26 insertions, 21 deletions
diff --git a/Private/HALKit/AMD64/HalDescriptorLoader.cpp b/Private/HALKit/AMD64/HalDescriptorLoader.cpp
index a68fb54a..1dbe8e9e 100644
--- a/Private/HALKit/AMD64/HalDescriptorLoader.cpp
+++ b/Private/HALKit/AMD64/HalDescriptorLoader.cpp
@@ -25,11 +25,12 @@ STATIC ::HCore::Detail::AMD64::InterruptDescriptorAMD64
void IDTLoader::Load(Register64 &idt) {
volatile ::HCore::UIntPtr **baseIdt = (volatile ::HCore::UIntPtr **)idt.Base;
+
MUST_PASS(baseIdt);
-
- MUST_PASS(baseIdt[0]);
-
+
for (UInt16 i = 0; i < kKernelIdtSize; i++) {
+ MUST_PASS(baseIdt[i]);
+
kInterruptVectorTable[i].Selector = kGdtCodeSelector;
kInterruptVectorTable[i].Ist = 0x0;
kInterruptVectorTable[i].TypeAttributes = kInterruptGate;
@@ -40,10 +41,9 @@ void IDTLoader::Load(Register64 &idt) {
kInterruptVectorTable[i].Zero = 0x0;
}
- kRegIdt.Base = (UIntPtr)kInterruptVectorTable;
+ kRegIdt.Base = reinterpret_cast<UIntPtr>(kInterruptVectorTable);
kRegIdt.Limit = sizeof(::HCore::Detail::AMD64::InterruptDescriptorAMD64) *
- kKernelIdtSize -
- 1;
+ (kKernelIdtSize - 1);
rt_load_idt(kRegIdt);
diff --git a/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx
index be0932bd..34cf049e 100644
--- a/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx
+++ b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx
@@ -9,21 +9,26 @@
#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)
+/// @brief Runtime interrupt handler
+/// @param sf The stack frame pushed by the isr.
+/// @return the stackframe pointer.
+EXTERN_C ATTRIBUTE(naked) HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr sf)
{
- HCore::HAL::StackFramePtr stackPtr = reinterpret_cast<HCore::HAL::StackFramePtr>(rsp);
-
- if (stackPtr->IntNum == kInterruptId ||
- stackPtr->IntNum == kInterruptIdAlt) {
- /// Do system call TODO
-
+ volatile HCore::HAL::StackFramePtr stackPtr = reinterpret_cast<volatile HCore::HAL::StackFramePtr>(sf);
+ MUST_PASS(stackPtr);
+
+ switch (stackPtr->IntNum)
+ {
+ case kInterruptId:
+ {
+ /* TODO: HcOpenDevice and such syscalls. */
+ break;
+ }
+ default:
+ break;
}
- return rsp;
+ return sf;
} \ No newline at end of file
diff --git a/Private/HALKit/AMD64/HalNewBoot.asm b/Private/HALKit/AMD64/HalNewBoot.asm
index a18b6814..881c1728 100644
--- a/Private/HALKit/AMD64/HalNewBoot.asm
+++ b/Private/HALKit/AMD64/HalNewBoot.asm
@@ -34,7 +34,7 @@ Main:
push rcx
call RuntimeMain
pop rcx
-L0:
+MainLoop:
cli
hlt
jmp $
diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp
index e5e35f20..c69e35d0 100644
--- a/Private/HALKit/AMD64/Processor.hpp
+++ b/Private/HALKit/AMD64/Processor.hpp
@@ -23,8 +23,8 @@
#define kCPUBackendName "AMD64"
-#define IsActiveLow(flag) (flag & 2)
-#define IsLevelTriggered(flag) (flag & 8)
+#define IsActiveLow(FLG) (FLG & 2)
+#define IsLevelTriggered(FLG) (FLG & 8)
#define kInterruptGate 0x8E
#define kTrapGate 0xEF