diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2025-04-10 12:11:55 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2025-04-10 12:11:55 +0000 |
| commit | dff78de795a89c181e9c94b26db2f16988e8f4d6 (patch) | |
| tree | ac19416b7b3ff76f58c4b3deeacbf64bb4cbad84 /arch/x86_64/include | |
| parent | 62d7fa83e831e84ea851d97b5c957146880ad69a (diff) | |
| download | teachos-dff78de795a89c181e9c94b26db2f16988e8f4d6.tar.xz teachos-dff78de795a89c181e9c94b26db2f16988e8f4d6.zip | |
move context_switch function and environment into different directory
Diffstat (limited to 'arch/x86_64/include')
3 files changed, 38 insertions, 2 deletions
diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp index b31f9e8..e8854f9 100644 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp +++ b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp @@ -52,7 +52,12 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table * @param flags Allows to set flags for the flags field using the unscoped enum contained in this class, used to * allow for direct integer conversion. */ - segment_selector(uint16_t index, uint8_t flags); + constexpr segment_selector(uint16_t index, uint8_t flags) + : _flags(flags) + , _index(index * 2U) + { + // Nothing to do. + } /** * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. diff --git a/arch/x86_64/include/arch/context_switching/main.hpp b/arch/x86_64/include/arch/context_switching/main.hpp index d2243ed..e296457 100644 --- a/arch/x86_64/include/arch/context_switching/main.hpp +++ b/arch/x86_64/include/arch/context_switching/main.hpp @@ -15,8 +15,32 @@ namespace teachos::arch::context_switching interrupt_descriptor_table::interrupt_descriptor_table & idt; ///< Reference to the interrupt descriptor table. }; + /** + * @brief Setup GDT and IDT TODO + * + * @return descriptor_tables + */ auto initialize_descriptor_tables() -> descriptor_tables; + /** + * @brief TODO + * + * @param data_segment + * @param code_segment + * @param return_function + */ + auto switch_to_user_mode() -> void; + + /** + * @brief TODO + * + * @param data_segment + * @param code_segment + * @param return_function + */ + auto switch_context(interrupt_descriptor_table::segment_selector data_segment, + interrupt_descriptor_table::segment_selector code_segment, void (*return_function)()) -> void; + } // namespace teachos::arch::context_switching #endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_MAIN_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 index bd244fd..fd5a972 100644 --- a/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp +++ b/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp @@ -12,12 +12,19 @@ namespace teachos::arch::kernel::cpu auto reload_segment_registers() -> void; /** - * @brief Set the value of all segment registers. + * @brief Set the value of all segment registers. TODO * * @param segment_selector */ auto set_segment_registers(context_switching::interrupt_descriptor_table::segment_selector segment_selector) -> void; + /** + * @brief Returns the segment_selector in the code segment (cs) register. TODO + * + * @return segment_selector in the cs register + */ + auto read_code_segment_register() -> context_switching::interrupt_descriptor_table::segment_selector; + } // namespace teachos::arch::kernel::cpu #endif // TEACHOS_ARCH_X86_64_KERNEL_CPU_SEGMENT_REGISTER_HPP |
