From ecb67842d3578dfc8c7d685b0cd168efd24505e6 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Sat, 15 Mar 2025 14:56:12 +0000 Subject: create TSS descriptor --- .../descriptor_table/global_descriptor_table.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp index c5554a7..6474739 100644 --- a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp +++ b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp @@ -12,6 +12,7 @@ namespace teachos::arch::context_switching::descriptor_table segment_descriptor null_segment{0}; std::bitset<20U> limit{0xFFFFF}; + // Kernel space code segment access_byte kernel_code_access_byte{access_byte::PRESENT | access_byte::ACCESS_LEVEL_KERNEL | access_byte::CODE_OR_DATA_SEGMENT | access_byte::CODE_SEGMENT | @@ -38,6 +39,15 @@ namespace teachos::arch::context_switching::descriptor_table gdt_flags user_data_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::UPPER_BOUND, limit}; segment_descriptor user_data_segment{user_data_access_byte, user_data_gdt_flags, 0, limit}; + // Task state segment + // TODO: Create TSS + access_byte tss_access_byte{access_byte::PRESENT | access_byte::ACCESS_LEVEL_KERNEL | + access_byte::TASK_STATE_SEGMENT_AVAILABLE}; + gdt_flags tss_gdt_flags{0U, limit}; + uint64_t tss_address = 0; // &TSS + uint64_t tss_limit = 0U; // sizeof(TSS) - 1 + segment_descriptor task_state_segment{tss_access_byte, tss_gdt_flags, tss_address, tss_limit}; + stl::vector global_descriptor_table{null_segment, kernel_code_segment, kernel_data_segment, user_code_segment, user_data_segment}; return global_descriptor_table; -- cgit v1.2.3