diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2025-04-21 08:18:41 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2025-04-21 08:18:41 +0000 |
| commit | 0986058bb9ca5b4afd7c578c815dc3a4c08808a9 (patch) | |
| tree | 7820b35df1d58ca5a7367a77a5e16d5d914382d5 /arch/x86_64/src/context_switching | |
| parent | 5dc0e92a7211b44429c1a2e7efe19c146f5c4f9a (diff) | |
| download | teachos-0986058bb9ca5b4afd7c578c815dc3a4c08808a9.tar.xz teachos-0986058bb9ca5b4afd7c578c815dc3a4c08808a9.zip | |
WIP syscall
Diffstat (limited to 'arch/x86_64/src/context_switching')
| -rw-r--r-- | arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/src/context_switching/main.cpp | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp b/arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp index c50ac1d..c041198 100644 --- a/arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp +++ b/arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp @@ -27,8 +27,8 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table } interrupt_descriptor_table.at(0x80) = { - segment_selector{3U, segment_selector::REQUEST_LEVEL_USER}, ist_offset{0U}, - idt_flags{idt_flags::DESCRIPTOR_LEVEL_USER | idt_flags::INTERRUPT_GATE | idt_flags::PRESENT}, + segment_selector{1U, segment_selector::REQUEST_LEVEL_KERNEL}, ist_offset{0U}, + idt_flags{idt_flags::DESCRIPTOR_LEVEL_USER | idt_flags::TRAP_GATE | idt_flags::PRESENT}, uint64_t{reinterpret_cast<uint64_t>(interrupt_handling::syscall_interrupt_handler)}}; return interrupt_descriptor_table; diff --git a/arch/x86_64/src/context_switching/main.cpp b/arch/x86_64/src/context_switching/main.cpp index 7be286a..faaf831 100644 --- a/arch/x86_64/src/context_switching/main.cpp +++ b/arch/x86_64/src/context_switching/main.cpp @@ -52,7 +52,14 @@ namespace teachos::arch::context_switching { kernel::cpu::validate_segment_registers(USER_DATA_SEGMENT_SELECTOR, USER_CODE_SEGMENT_SELECTOR); - asm volatile("INT $0x80"); + // TODO/INFO: + // https://stackoverflow.com/questions/46022184/osdev-syscall-sysret-and-sysenter-sysexit-instructions-enabling + // https://stackoverflow.com/questions/12806584/what-is-better-int-0x80-or-syscall-in-32-bit-code-on-linux + // + // People claim that SYSENTER is for 32-Bit, while SYSCALL is for 64-Bit! + + // asm volatile("INT $0x80"); + asm volatile("SYSCALL"); video::vga::text::write("Successfully entered user mode!", video::vga::text::common_attributes::green_on_black); } |
