From b7709d9dc8fc74ab1c60336b487a2c2f90ceeb99 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 29 Mar 2025 10:59:55 +0100 Subject: hal/amd64: unify GDT/IDT setup and rename I/O ops Normalize descriptor loading logic under Register64. Prefix low-level port and MSR functions with hal_ for consistency. Improve APIC init flow to reflect MADT-based IRQ routing. Signed-off-by: Amlal El Mahrouss --- dev/kernel/HALKit/AMD64/Processor.h | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'dev/kernel/HALKit/AMD64/Processor.h') diff --git a/dev/kernel/HALKit/AMD64/Processor.h b/dev/kernel/HALKit/AMD64/Processor.h index 57f50a48..38822be1 100644 --- a/dev/kernel/HALKit/AMD64/Processor.h +++ b/dev/kernel/HALKit/AMD64/Processor.h @@ -28,13 +28,10 @@ #define kPIC2Command (0xA0) #define kPIC2Data (0xA1) -EXTERN_C -{ -#include -} - #include +#define rtl_nop_op() asm volatile("nop") + /// @brief Maximum entries of the interrupt descriptor table. #define kKernelIdtSize (0x100) @@ -85,12 +82,6 @@ namespace Kernel::HAL UIntPtr Base; }; - struct PACKED RegisterGDT final - { - UShort Limit; - UIntPtr Base; - }; - using RawRegister = UInt64; using Reg = RawRegister; using InterruptId = UInt16; /* For each element in the IVT */ @@ -167,8 +158,8 @@ namespace Kernel::HAL class GDTLoader final { public: - static Void Load(RegisterGDT& gdt); - static Void Load(Ref& gdt); + static Void Load(Register64& gdt); + static Void Load(Ref& gdt); }; class IDTLoader final @@ -230,12 +221,7 @@ namespace Kernel::HAL /// @param msr MSR /// @param lo low byte /// @param hi high byte - inline Void hal_set_msr(UInt32 msr, UInt32 lo, UInt32 hi) noexcept - { - asm volatile("wrmsr" - : - : "a"(lo), "d"(hi), "c"(msr)); - } + Void hal_set_msr(UInt32 msr, UInt32 lo, UInt32 hi) noexcept; /// @brief Processor specific namespace. namespace Detail @@ -320,7 +306,7 @@ EXTERN_C Kernel::Void idt_handle_math(Kernel::UIntPtr rsp); EXTERN_C Kernel::Void idt_handle_pf(Kernel::UIntPtr rsp); EXTERN_C ATTRIBUTE(naked) Kernel::Void hal_load_idt(Kernel::HAL::Register64 ptr); -EXTERN_C ATTRIBUTE(naked) Kernel::Void hal_load_gdt(Kernel::HAL::RegisterGDT ptr); +EXTERN_C ATTRIBUTE(naked) Kernel::Void hal_load_gdt(Kernel::HAL::Register64 ptr); inline Kernel::VoidPtr kKernelBitMpStart = nullptr; inline Kernel::UIntPtr kKernelBitMpSize = 0UL; -- cgit v1.2.3