aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Imhof <fabian.imhof@ost.ch>2025-05-04 10:51:12 +0000
committerFabian Imhof <fabian.imhof@ost.ch>2025-05-04 10:51:12 +0000
commit4d4e23116284f41329ea809e2bda86feea1b325c (patch)
treefb3577e8b00311e6e9c1ebcbca8b93c2122603a4
parent4b4ca98376cb4bdf97fd910b7e2ca78628b0a8ee (diff)
downloadteachos-4d4e23116284f41329ea809e2bda86feea1b325c.tar.xz
teachos-4d4e23116284f41329ea809e2bda86feea1b325c.zip
fix returning from syscall
-rw-r--r--arch/x86_64/src/context_switching/main.cpp3
-rw-r--r--arch/x86_64/src/context_switching/syscall/syscall_handler.cpp4
2 files changed, 5 insertions, 2 deletions
diff --git a/arch/x86_64/src/context_switching/main.cpp b/arch/x86_64/src/context_switching/main.cpp
index 7fe159e..6c6ec1a 100644
--- a/arch/x86_64/src/context_switching/main.cpp
+++ b/arch/x86_64/src/context_switching/main.cpp
@@ -27,6 +27,7 @@ namespace teachos::arch::context_switching
auto user_mode_main() -> void
{
+ // TODO: Remove or replace this wall of text
// RFLAGS is saved into R11, RIP of the next instruction into RCX
// Required for SYSRETURN to know where to return too.
// Additional state needs to be saved by calling convention:
@@ -38,7 +39,7 @@ namespace teachos::arch::context_switching
// Actual Source: https://man7.org/linux/man-pages/man2/syscall.2.html More cleare documentation:
// https://sys.readthedocs.io/en/latest/doc/05_calling_system_calls.html
- const char syscall_message[32] = "Successfully entered user mode!";
+ const char syscall_message[68] = "Successfully entered user mode and wrote to VGA buffer via syscall!";
auto error = syscall::syscall(syscall::WRITE, {reinterpret_cast<uint64_t>(&syscall_message)});
if (!error)
diff --git a/arch/x86_64/src/context_switching/syscall/syscall_handler.cpp b/arch/x86_64/src/context_switching/syscall/syscall_handler.cpp
index f6e1c9e..759a092 100644
--- a/arch/x86_64/src/context_switching/syscall/syscall_handler.cpp
+++ b/arch/x86_64/src/context_switching/syscall/syscall_handler.cpp
@@ -12,6 +12,7 @@ namespace teachos::arch::context_switching::syscall
{
video::vga::text::write(reinterpret_cast<const char *>(buffer),
video::vga::text::common_attributes::green_on_black);
+ video::vga::text::newline();
}
} // namespace
@@ -62,7 +63,8 @@ namespace teachos::arch::context_switching::syscall
: [input] "m"(rflags)
: "memory");
- asm volatile("sysretq");
+ asm volatile("leave\n"
+ "sysretq");
}
} // namespace teachos::arch::context_switching::syscall \ No newline at end of file