aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp8
-rw-r--r--arch/x86_64/src/context_switching/interrupt_descriptor_table/segment_selector.cpp2
-rw-r--r--arch/x86_64/src/context_switching/main.cpp2
3 files changed, 8 insertions, 4 deletions
diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp
index 2c90152..b31f9e8 100644
--- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp
+++ b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp
@@ -43,8 +43,12 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
/**
* @brief Constructor.
*
- * @param index Index into the local or global descriptor table. Processor multiplies the index value by 16 (number
- * of bytes in segment descriptor) and adds the result to the base address.
+ * @param index Index into the local or global descriptor table. Processor multiplies the index value by 8 (number
+ * of bytes in 32-bit segment descriptor) and adds the result to the base GDT or LDT address. Because it only
+ * multiplies by 8, but we are using long mode the constructor additionally multiplies the given value by two. This
+ * is done because 64-bit segment descriptor are twice as big in size. If we wouldn't multiply by two, index 1 would
+ * result in the middle between the second part of the null entry and the first part of the code kernel segment and
+ * therefore be invalid.
* @param flags Allows to set flags for the flags field using the unscoped enum contained in this class, used to
* allow for direct integer conversion.
*/
diff --git a/arch/x86_64/src/context_switching/interrupt_descriptor_table/segment_selector.cpp b/arch/x86_64/src/context_switching/interrupt_descriptor_table/segment_selector.cpp
index 62aed9b..b1b316d 100644
--- a/arch/x86_64/src/context_switching/interrupt_descriptor_table/segment_selector.cpp
+++ b/arch/x86_64/src/context_switching/interrupt_descriptor_table/segment_selector.cpp
@@ -4,7 +4,7 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
{
segment_selector::segment_selector(uint16_t index, uint8_t flags)
: _flags(flags)
- , _index(index)
+ , _index(index * 2U)
{
// Nothing to do.
}
diff --git a/arch/x86_64/src/context_switching/main.cpp b/arch/x86_64/src/context_switching/main.cpp
index ac53735..6614065 100644
--- a/arch/x86_64/src/context_switching/main.cpp
+++ b/arch/x86_64/src/context_switching/main.cpp
@@ -16,7 +16,7 @@ namespace teachos::arch::context_switching
interrupt_descriptor_table::update_interrupt_descriptor_table_register();
interrupt_descriptor_table::segment_selector segment_selector{
- 2U, interrupt_descriptor_table::segment_selector::REQUEST_LEVEL_KERNEL};
+ 1U, interrupt_descriptor_table::segment_selector::REQUEST_LEVEL_KERNEL};
kernel::cpu::far_pointer pointer{&boot::reload_segment_register, segment_selector};
kernel::cpu::jmp(pointer);