diff options
Diffstat (limited to 'Private/HALKit/AMD64/HalDescriptorLoader.cpp')
| -rw-r--r-- | Private/HALKit/AMD64/HalDescriptorLoader.cpp | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/Private/HALKit/AMD64/HalDescriptorLoader.cpp b/Private/HALKit/AMD64/HalDescriptorLoader.cpp index fb41f654..8552b958 100644 --- a/Private/HALKit/AMD64/HalDescriptorLoader.cpp +++ b/Private/HALKit/AMD64/HalDescriptorLoader.cpp @@ -1,11 +1,8 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ #include <ArchKit/ArchKit.hpp> @@ -25,6 +22,28 @@ STATIC ::HCore::Detail::AMD64::InterruptDescriptorAMD64 kInterruptVectorTable[kKernelIdtSize]; void IDTLoader::Load(Register64 &idt) { + volatile ::HCore::UIntPtr **baseIdt = (volatile ::HCore::UIntPtr **)idt.Base; + + MUST_PASS(baseIdt[0]); + + for (UInt16 i = 0; i < kKernelIdtSize; i++) { + kInterruptVectorTable[i].Selector = kGdtCodeSelector; + kInterruptVectorTable[i].Ist = 0x0; + kInterruptVectorTable[i].TypeAttributes = kInterruptGate; + kInterruptVectorTable[i].OffsetLow = ((UIntPtr)baseIdt[i] & 0xFFFF); + kInterruptVectorTable[i].OffsetMid = (((UIntPtr)baseIdt[i] >> 16) & 0xFFFF); + kInterruptVectorTable[i].OffsetHigh = + (((UIntPtr)baseIdt[i] >> 32) & 0xFFFFFFFF); + kInterruptVectorTable[i].Zero = 0x0; + } + + kRegIdt.Base = (UIntPtr)kInterruptVectorTable; + kRegIdt.Limit = sizeof(::HCore::Detail::AMD64::InterruptDescriptorAMD64) * + kKernelIdtSize - + 1; + + rt_load_idt(kRegIdt); + UInt8 a1, a2; a1 = HAL::In8(0x21); // save masks @@ -50,28 +69,6 @@ void IDTLoader::Load(Register64 &idt) { HAL::Out8(0x21, a1); HAL::rt_wait_400ns(); HAL::Out8(0xA1, a2); - - volatile ::HCore::UIntPtr **baseIdt = (volatile ::HCore::UIntPtr **)idt.Base; - - MUST_PASS(baseIdt[0]); - - for (UInt16 i = 0; i < kKernelIdtSize; i++) { - kInterruptVectorTable[i].Selector = kGdtCodeSelector; - kInterruptVectorTable[i].Ist = 0x0; - kInterruptVectorTable[i].TypeAttributes = kInterruptGate; - kInterruptVectorTable[i].OffsetLow = ((UIntPtr)baseIdt[i] & 0xFFFF); - kInterruptVectorTable[i].OffsetMid = (((UIntPtr)baseIdt[i] >> 16) & 0xFFFF); - kInterruptVectorTable[i].OffsetHigh = - (((UIntPtr)baseIdt[i] >> 32) & 0xFFFFFFFF); - kInterruptVectorTable[i].Zero = 0x0; - } - - kRegIdt.Base = (UIntPtr)kInterruptVectorTable; - kRegIdt.Limit = sizeof(::HCore::Detail::AMD64::InterruptDescriptorAMD64) * - kKernelIdtSize - - 1; - - rt_load_idt(kRegIdt); } void GDTLoader::Load(Ref<RegisterGDT> &gdt) { GDTLoader::Load(gdt.Leak()); } |
