aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/interrupt_handling
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/interrupt_handling')
-rw-r--r--arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp b/arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp
index 6075770..7afd87d 100644
--- a/arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp
+++ b/arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp
@@ -15,7 +15,27 @@ namespace teachos::arch::interrupt_handling
[[gnu::interrupt]] [[gnu::section(".interrupt_text")]]
auto syscall_interrupt_handler(interrupt_frame * frame) -> void
{
+ // RDI, RSI, RDX, RCX, R8, R9
+ // RDI -> SYSCALL number
+ // Others are arguments
+
+ // TODO: The registers are not available here. We need to set them up on the stack
+ // and access them via argument.
+
+ uint64_t syscall_number{};
+ asm volatile("mov %%rdi, %0" : "=r"(syscall_number));
+
+ // Handle system call based on the number
+ switch (syscall_number)
+ {
+ case 1:
+ video::vga::text::write("SYSCALL 1.", video::vga::text::common_attributes::green_on_black);
+ break;
+ default:
+ // Handle unknown syscall
+ break;
+ }
+
(void)frame;
- video::vga::text::write("A SYSCALL interrupt occurred.", video::vga::text::common_attributes::green_on_black);
}
} // namespace teachos::arch::interrupt_handling