summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit/AMD64/HalPlatformAMD64.cpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-25 18:19:19 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-25 18:19:41 +0100
commit91c88797f7fa9dbb6cce12c14928a6fbd97d51b6 (patch)
tree9dd58ee1e796684e6ec15902d39836e45a1cf054 /Private/HALKit/AMD64/HalPlatformAMD64.cpp
parent2bd2e28868d50a2f3ced8b1bfea68216ed35622a (diff)
Kernel: Did progress on interrupts, moved kernel main to HAL, as the
code here is very specific. Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit/AMD64/HalPlatformAMD64.cpp')
-rw-r--r--Private/HALKit/AMD64/HalPlatformAMD64.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/Private/HALKit/AMD64/HalPlatformAMD64.cpp b/Private/HALKit/AMD64/HalPlatformAMD64.cpp
index e9e7fb82..b2e98004 100644
--- a/Private/HALKit/AMD64/HalPlatformAMD64.cpp
+++ b/Private/HALKit/AMD64/HalPlatformAMD64.cpp
@@ -10,21 +10,13 @@
#include <ArchKit/ArchKit.hpp>
namespace HCore::HAL {
-namespace Detail {
-struct PACKED RegisterAMD64 final {
- UIntPtr base;
- UShort limit;
-};
-} // namespace Detail
-
void GDTLoader::Load(Register64 &gdt) {
- Detail::RegisterAMD64 *gdtReg = new Detail::RegisterAMD64();
- MUST_PASS(gdtReg);
+ Register64 gdtReg;
- gdtReg->base = gdt.Base;
- gdtReg->limit = gdt.Limit;
+ gdtReg.Base = gdt.Base;
+ gdtReg.Limit = gdt.Limit;
- rt_load_gdt((VoidPtr)gdtReg);
+ rt_load_gdt(gdtReg);
}
namespace Detail::AMD64 {
@@ -49,15 +41,16 @@ struct InterruptDescriptorAMD64 final {
extern "C" HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr &rsp);
-static ALIGN(
- 0x10) Detail::AMD64::InterruptDescriptorAMD64 kIdtRegs[kMaxSyscalls];
+static ALIGN(0x10)
+ Detail::AMD64::InterruptDescriptorAMD64 kIdtRegs[kKernelMaxSystemCalls];
static HAL::Register64 kRegIdt;
void IDTLoader::Load(Register64 &idt) {
for (auto i = 0; i < 32; i++) {
kIdtRegs[i].Selector = kGdtSelector;
kIdtRegs[i].Ist = 0x00;
- kIdtRegs[i].TypeAttributes = kInterruptGate | kRing0 | kIdtPresent;
+ kIdtRegs[i].TypeAttributes =
+ kInterruptGate | kTrapGate | kRing0 | kIdtPresent;
kIdtRegs[i].OffsetLow = (((UIntPtr *)idt.Base)[i]) & 0xFFFF;
kIdtRegs[i].OffsetMid = (((UIntPtr *)idt.Base)[i] >> 16) & 0xFFFF;
kIdtRegs[i].OffsetHigh = (((UIntPtr *)idt.Base)[i] >> 32) & 0xFFFF;
@@ -75,9 +68,13 @@ void IDTLoader::Load(Register64 &idt) {
kRegIdt.Base = (UIntPtr)kIdtRegs;
kRegIdt.Limit = sizeof(Detail::AMD64::InterruptDescriptorAMD64) * idt.Limit;
- rt_load_idt((VoidPtr)&kRegIdt);
+ kcout << "HCoreKrnl: Installing Interrupt vector...\n";
+
+ rt_load_idt(kRegIdt);
+
+ asm volatile("sti");
- kcout << "Krnl: IDT loaded\n";
+ kcout << "HCoreKrnl: Interrupt Vector installed.\n";
}
void GDTLoader::Load(Ref<Register64> &gdt) { GDTLoader::Load(gdt.Leak()); }