From e424e3b88ce7b597cfc5857f20da571f502908b1 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 2 Jan 2022 17:51:17 +0200 Subject: [PATCH] Kernel: Use enum instead of magic numbers for GDT descriptor types Some of the enum members were also renamed to reflect the fact that the segment sizes are not necessarily 32bit (64bit on x86_64). --- Kernel/Arch/x86/DescriptorTable.h | 12 ++++++------ Kernel/Arch/x86/common/Processor.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Kernel/Arch/x86/DescriptorTable.h b/Kernel/Arch/x86/DescriptorTable.h index 475318af6d..974d3b4970 100644 --- a/Kernel/Arch/x86/DescriptorTable.h +++ b/Kernel/Arch/x86/DescriptorTable.h @@ -66,7 +66,7 @@ union [[gnu::packed]] Descriptor { u32 high; }; - enum Type { + enum SystemType { Invalid = 0, AvailableTSS_16bit = 0x1, LDT = 0x2, @@ -75,11 +75,11 @@ union [[gnu::packed]] Descriptor { TaskGate = 0x5, InterruptGate_16bit = 0x6, TrapGate_16bit = 0x7, - AvailableTSS_32bit = 0x9, - BusyTSS_32bit = 0xb, - CallGate_32bit = 0xc, - InterruptGate_32bit = 0xe, - TrapGate_32bit = 0xf, + AvailableTSS = 0x9, + BusyTSS = 0xb, + CallGate = 0xc, + InterruptGate = 0xe, + TrapGate = 0xf, }; VirtualAddress base() const diff --git a/Kernel/Arch/x86/common/Processor.cpp b/Kernel/Arch/x86/common/Processor.cpp index 42b851d154..5dd342b3d1 100644 --- a/Kernel/Arch/x86/common/Processor.cpp +++ b/Kernel/Arch/x86/common/Processor.cpp @@ -1222,7 +1222,7 @@ UNMAP_AFTER_INIT void Processor::gdt_init() tss_descriptor.operation_size64 = 0; tss_descriptor.operation_size32 = 1; tss_descriptor.descriptor_type = 0; - tss_descriptor.type = 9; + tss_descriptor.type = Descriptor::SystemType::AvailableTSS; write_gdt_entry(GDT_SELECTOR_TSS, tss_descriptor); // tss #if ARCH(X86_64)