aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp10
1 files changed, 10 insertions, 0 deletions
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<segment_descriptor> global_descriptor_table{null_segment, kernel_code_segment, kernel_data_segment,
user_code_segment, user_data_segment};
return global_descriptor_table;