aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel/cpu
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-07-24 16:33:10 +0000
committerFelix Morgner <felix.morgner@ost.ch>2025-07-24 16:33:10 +0000
commit1b65136a11453fe7e89320dfe6170a0cd75e60dd (patch)
treeb031192e5af29866e75a2c842d01e22f16877bcc /arch/x86_64/src/kernel/cpu
parent3b9bbbb4be529f2365b8bc2e43c1c8e9a65b1a07 (diff)
downloadteachos-1b65136a11453fe7e89320dfe6170a0cd75e60dd.tar.xz
teachos-1b65136a11453fe7e89320dfe6170a0cd75e60dd.zip
x86_64: clean up hw details
Diffstat (limited to 'arch/x86_64/src/kernel/cpu')
-rw-r--r--arch/x86_64/src/kernel/cpu/control_register.cpp66
-rw-r--r--arch/x86_64/src/kernel/cpu/tlb.cpp16
2 files changed, 0 insertions, 82 deletions
diff --git a/arch/x86_64/src/kernel/cpu/control_register.cpp b/arch/x86_64/src/kernel/cpu/control_register.cpp
deleted file mode 100644
index 41b8cd7..0000000
--- a/arch/x86_64/src/kernel/cpu/control_register.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "arch/kernel/cpu/control_register.hpp"
-
-#include "arch/exception_handling/panic.hpp"
-
-#include <type_traits>
-
-namespace teachos::arch::kernel::cpu
-{
- auto read_control_register(control_register cr) -> uint64_t
- {
- uint64_t current_value;
- switch (cr)
- {
- case control_register::CR0:
- asm volatile("mov %%cr0, %[output]" : [output] "=r"(current_value));
- break;
- case control_register::CR2:
- asm volatile("mov %%cr2, %[output]" : [output] "=r"(current_value));
- break;
- case control_register::CR3:
- asm volatile("mov %%cr3, %[output]" : [output] "=r"(current_value));
- break;
- case control_register::CR4:
- asm volatile("mov %%cr4, %[output]" : [output] "=r"(current_value));
- break;
- }
- return current_value;
- }
-
- auto write_control_register(control_register cr, uint64_t new_value) -> void
- {
- switch (cr)
- {
- case control_register::CR0:
- asm volatile("mov %[input], %%cr0"
- : /* no output from call */
- : [input] "r"(new_value)
- : "memory");
- break;
- case control_register::CR2:
- asm volatile("mov %[input], %%cr2"
- : /* no output from call */
- : [input] "r"(new_value)
- : "memory");
- break;
- case control_register::CR3:
- asm volatile("mov %[input], %%cr3"
- : /* no output from call */
- : [input] "r"(new_value)
- : "memory");
- break;
- case control_register::CR4:
- asm volatile("mov %[input], %%cr4"
- : /* no output from call */
- : [input] "r"(new_value)
- : "memory");
- break;
- }
- }
-
- auto set_cr0_bit(cr0_flags flag) -> void
- {
- auto const cr0 = read_control_register(control_register::CR0);
- write_control_register(control_register::CR0, static_cast<std::underlying_type<cr0_flags>::type>(flag) | cr0);
- }
-} // namespace teachos::arch::kernel::cpu
diff --git a/arch/x86_64/src/kernel/cpu/tlb.cpp b/arch/x86_64/src/kernel/cpu/tlb.cpp
deleted file mode 100644
index a09001c..0000000
--- a/arch/x86_64/src/kernel/cpu/tlb.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "arch/kernel/cpu/tlb.hpp"
-
-#include "arch/kernel/cpu/control_register.hpp"
-
-namespace teachos::arch::kernel::cpu
-{
- auto tlb_flush(memory::paging::virtual_address address) -> void
- {
- asm volatile("invlpg (%[input])" : /* no output from call */ : [input] "r"(address) : "memory");
- }
-
- auto tlb_flush_all() -> void
- {
- write_control_register(cpu::control_register::CR3, read_control_register(cpu::control_register::CR3));
- }
-} // namespace teachos::arch::kernel::cpu