aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/context_switching
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/context_switching')
-rw-r--r--arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp7
-rw-r--r--arch/x86_64/src/context_switching/main.cpp3
2 files changed, 9 insertions, 1 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 80f01a8..c50ac1d 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
@@ -10,7 +10,7 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
{
/// @brief Amount of currently reserved interrupt indicies.
/// See https://wiki.osdev.org/Interrupt_Descriptor_Table#IDT_items for more information.
- constexpr uint8_t RESERVED_INTERRUPT_COUNT = 32U;
+ constexpr uint16_t RESERVED_INTERRUPT_COUNT = 256U;
auto create_interrupt_descriptor_table() -> interrupt_descriptor_table
{
@@ -26,6 +26,11 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
interrupt_descriptor_table.at(i) = {selector, ist, flags, offset};
}
+ 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},
+ uint64_t{reinterpret_cast<uint64_t>(interrupt_handling::syscall_interrupt_handler)}};
+
return interrupt_descriptor_table;
}
} // namespace
diff --git a/arch/x86_64/src/context_switching/main.cpp b/arch/x86_64/src/context_switching/main.cpp
index 952a3b2..fc8790f 100644
--- a/arch/x86_64/src/context_switching/main.cpp
+++ b/arch/x86_64/src/context_switching/main.cpp
@@ -49,6 +49,9 @@ namespace teachos::arch::context_switching
auto user_mode_main() -> void
{
kernel::cpu::validate_segment_registers(USER_DATA_SEGMENT_SELECTOR, USER_CODE_SEGMENT_SELECTOR);
+
+ asm volatile("INT $0x80");
+
video::vga::text::write("Successfully entered user mode!", video::vga::text::common_attributes::green_on_black);
}