From a8852f91967a7e55e62e30f5cc07d076092b8b78 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Sat, 5 Apr 2025 15:27:20 +0000 Subject: add wip context switch to user mode --- arch/x86_64/include/arch/boot/pointers.hpp | 5 ---- .../include/arch/kernel/cpu/segment_register.hpp | 23 ++++++++++++++++++ arch/x86_64/include/arch/kernel/cpu/ss.hpp | 27 ---------------------- 3 files changed, 23 insertions(+), 32 deletions(-) create mode 100644 arch/x86_64/include/arch/kernel/cpu/segment_register.hpp delete mode 100644 arch/x86_64/include/arch/kernel/cpu/ss.hpp (limited to 'arch/x86_64/include') diff --git a/arch/x86_64/include/arch/boot/pointers.hpp b/arch/x86_64/include/arch/boot/pointers.hpp index 9bf5cfd..fe9c657 100644 --- a/arch/x86_64/include/arch/boot/pointers.hpp +++ b/arch/x86_64/include/arch/boot/pointers.hpp @@ -10,11 +10,6 @@ namespace teachos::arch::boot */ extern "C" size_t const multiboot_information_pointer; - /** - * @brief Address pointing to the method that clears all segment registers. - */ - extern "C" void reload_segment_register(); - } // namespace teachos::arch::boot #endif // TEACHOS_ARCH_X86_64_BOOT_POINTERS_HPP diff --git a/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp b/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp new file mode 100644 index 0000000..bd244fd --- /dev/null +++ b/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp @@ -0,0 +1,23 @@ +#ifndef TEACHOS_ARCH_X86_64_KERNEL_CPU_SEGMENT_REGISTER_HPP +#define TEACHOS_ARCH_X86_64_KERNEL_CPU_SEGMENT_REGISTER_HPP + +#include "arch/context_switching/interrupt_descriptor_table/segment_selector.hpp" + +namespace teachos::arch::kernel::cpu +{ + /** + * @brief Clear all segment registers. + */ + [[gnu::naked]] + auto reload_segment_registers() -> void; + + /** + * @brief Set the value of all segment registers. + * + * @param segment_selector + */ + auto set_segment_registers(context_switching::interrupt_descriptor_table::segment_selector segment_selector) -> void; + +} // namespace teachos::arch::kernel::cpu + +#endif // TEACHOS_ARCH_X86_64_KERNEL_CPU_SEGMENT_REGISTER_HPP diff --git a/arch/x86_64/include/arch/kernel/cpu/ss.hpp b/arch/x86_64/include/arch/kernel/cpu/ss.hpp deleted file mode 100644 index b5fa5e3..0000000 --- a/arch/x86_64/include/arch/kernel/cpu/ss.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_KERNEL_CPU_SS_HPP -#define TEACHOS_ARCH_X86_64_KERNEL_CPU_SS_HPP - -#include "arch/context_switching/interrupt_descriptor_table/segment_selector.hpp" - -#include -#include - -namespace teachos::arch::kernel::cpu -{ - /** - * @brief Reads the current value of the stack segment (SS) register. - * - * @return The current SS register value. - */ - auto read_ss() -> context_switching::interrupt_descriptor_table::segment_selector; - - /** - * @brief Writes a new value to the stack segment (SS) register. - * - * @param selector The segment selector to be written to SS. - */ - auto write_ss(context_switching::interrupt_descriptor_table::segment_selector selector) -> void; - -} // namespace teachos::arch::kernel::cpu - -#endif // TEACHOS_ARCH_X86_64_KERNEL_CPU_SS_HPP -- cgit v1.2.3