aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/context_switching
diff options
context:
space:
mode:
authorFabian Imhof <fabian.imhof@ost.ch>2025-04-10 12:29:19 +0000
committerFabian Imhof <fabian.imhof@ost.ch>2025-04-10 12:29:19 +0000
commit87091e2246d2c4c794d9d6a0c5398ca80d92335a (patch)
tree4f9ff755da53182d864b604f28e10c0dd8ba82bd /arch/x86_64/src/context_switching
parentdff78de795a89c181e9c94b26db2f16988e8f4d6 (diff)
downloadteachos-87091e2246d2c4c794d9d6a0c5398ca80d92335a.tar.xz
teachos-87091e2246d2c4c794d9d6a0c5398ca80d92335a.zip
add register validation and asserts
Diffstat (limited to 'arch/x86_64/src/context_switching')
-rw-r--r--arch/x86_64/src/context_switching/main.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86_64/src/context_switching/main.cpp b/arch/x86_64/src/context_switching/main.cpp
index 3efba45..0f2ec93 100644
--- a/arch/x86_64/src/context_switching/main.cpp
+++ b/arch/x86_64/src/context_switching/main.cpp
@@ -2,6 +2,7 @@
#include "arch/exception_handling/assert.hpp"
#include "arch/kernel/cpu/call.hpp"
+#include "arch/kernel/cpu/control_register.hpp"
#include "arch/kernel/cpu/if.hpp"
#include "arch/kernel/cpu/segment_register.hpp"
#include "arch/kernel/cpu/tr.hpp"
@@ -82,10 +83,12 @@ namespace teachos::arch::context_switching
auto user_mode_main() -> void
{
auto current_segment = kernel::cpu::read_code_segment_register();
- arch::exception_handling::assert(USER_CODE_SEGMENT_SELECTOR == current_segment,
- "[Context Switching] Context switch into user mode not successful");
+ exception_handling::assert(USER_CODE_SEGMENT_SELECTOR == current_segment,
+ "[Context Switching] Context switch into user mode not successful");
+ exception_handling::assert(USER_DATA_SEGMENT_SELECTOR == kernel::cpu::validate_data_segment_registers(),
+ "[Context Switching] Context switch into user mode not successful");
- video::vga::text::write("User Mode!!!", video::vga::text::common_attributes::green_on_black);
+ video::vga::text::write("Successfully entered user mode!", video::vga::text::common_attributes::green_on_black);
}
auto switch_to_user_mode() -> void