aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/context_switching
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/context_switching')
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp7
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp12
2 files changed, 19 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 cbd230b..c5554a7 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
@@ -1,6 +1,7 @@
#include "arch/context_switching/descriptor_table/global_descriptor_table.hpp"
#include "arch/context_switching/descriptor_table/segment_descriptor.hpp"
+#include "arch/exception_handling/assert.hpp"
#include "arch/kernel/cpu/lgdt.hpp"
#include "arch/stl/vector.hpp"
@@ -47,6 +48,12 @@ namespace teachos::arch::context_switching::descriptor_table
decltype(auto) gdt = create_global_descriptor_table();
global_descriptor_table_pointer gdt_pointer{static_cast<uint16_t>(gdt.size() - 1), &gdt};
kernel::cpu::load_global_descriptor_table(gdt_pointer);
+
+ auto stored_gdt_pointer = kernel::cpu::store_global_descriptor_table();
+ arch::exception_handling::assert(
+ gdt_pointer == stored_gdt_pointer,
+ "[Global Descriptor Table] Loaded GDTR value is not the same as the stored value.");
+
return gdt;
}
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp
new file mode 100644
index 0000000..f552496
--- /dev/null
+++ b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp
@@ -0,0 +1,12 @@
+#include "arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp"
+
+namespace teachos::arch::context_switching::descriptor_table
+{
+ global_descriptor_table_pointer::global_descriptor_table_pointer(uint16_t table_length,
+ global_descriptor_table * address)
+ : table_length(table_length)
+ , address(address)
+ {
+ // Nothing to do.
+ }
+} // namespace teachos::arch::context_switching::descriptor_table