浏览代码

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).
Idan Horowitz 3 年之前
父节点
当前提交
e424e3b88c
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 6 6
      Kernel/Arch/x86/DescriptorTable.h
  2. 1 1
      Kernel/Arch/x86/common/Processor.cpp

+ 6 - 6
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

+ 1 - 1
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)