aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel/cpu/idtr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/kernel/cpu/idtr.cpp')
-rw-r--r--arch/x86_64/src/kernel/cpu/idtr.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/x86_64/src/kernel/cpu/idtr.cpp b/arch/x86_64/src/kernel/cpu/idtr.cpp
new file mode 100644
index 0000000..7aa20c1
--- /dev/null
+++ b/arch/x86_64/src/kernel/cpu/idtr.cpp
@@ -0,0 +1,18 @@
+#include "arch/kernel/cpu/idtr.hpp"
+
+namespace teachos::arch::kernel::cpu
+{
+ auto store_interrupt_descriptor_table()
+ -> context_switching::interrupt_descriptor_table::interrupt_descriptor_table_pointer
+ {
+ context_switching::interrupt_descriptor_table::interrupt_descriptor_table_pointer current_value{};
+ asm("sidt %[output]" : [output] "=m"(current_value));
+ return current_value;
+ }
+
+ auto load_interrupt_descriptor_table(
+ context_switching::interrupt_descriptor_table::interrupt_descriptor_table_pointer const & idt_pointer) -> void
+ {
+ asm volatile("lidt %[input]" : /* no output from call */ : [input] "m"(idt_pointer));
+ }
+} // namespace teachos::arch::kernel::cpu