diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-29 16:32:49 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-29 16:34:06 +0100 |
| commit | f3992c78790af42c53ed149cf04751261393d8e8 (patch) | |
| tree | 065fc8b2c6bb9305aefe5e4c2bf585b6cc20dafe /Private/HALKit/AMD64/HalDescriptorLoader.cpp | |
| parent | 1a22cb4fd330bf01f1c94bd12fcad9ab278b4f80 (diff) | |
Kernel: Pre-Release
- Kernel
- Bootloader
Working on AHCI support, AHCI is very important to bring fast I/O
support, ACPI and APIC is also in WiP for AMD64 HAL this time.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
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()); } |
