diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-03-14 14:20:24 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-03-14 14:20:24 +0000 |
| commit | f2b9ac8f0f22354241e9b78e47aa7cb94e5ef511 (patch) | |
| tree | 637d8b3432c2c2f9c7086af73cdf8408d487ac6e | |
| parent | 11db9338dac611ea32e202add5ce5055b54ebb58 (diff) | |
| download | teachos-f2b9ac8f0f22354241e9b78e47aa7cb94e5ef511.tar.xz teachos-f2b9ac8f0f22354241e9b78e47aa7cb94e5ef511.zip | |
Fix header recursion problem
5 files changed, 23 insertions, 24 deletions
diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table.hpp index 45f2d31..c4d0e30 100644 --- a/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table.hpp +++ b/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table.hpp @@ -2,13 +2,9 @@ #define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_GLOBAL_DESCRIPTOR_TABLE_HPP #include "arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp" -#include "arch/context_switching/descriptor_table/segment_descriptor.hpp" -#include "arch/stl/vector.hpp" namespace teachos::arch::context_switching::descriptor_table { - typedef stl::vector<segment_descriptor> global_descriptor_table; - auto create_global_descriptor_table() -> global_descriptor_table; auto initialize_global_descriptor_table() -> global_descriptor_table; diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp index 0305bff..d4febe1 100644 --- a/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp +++ b/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp @@ -1,10 +1,15 @@ #ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_GLOBAL_DESCRIPTOR_TABLE_POINTER_HPP #define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_GLOBAL_DESCRIPTOR_TABLE_POINTER_HPP +#include "arch/context_switching/descriptor_table/segment_descriptor.hpp" +#include "arch/stl/vector.hpp" + #include <cstdint> namespace teachos::arch::context_switching::descriptor_table { + typedef stl::vector<segment_descriptor> global_descriptor_table; + /** * @brief Represents a pointer to the Global Descriptor Table (GDT). * @@ -13,10 +18,8 @@ namespace teachos::arch::context_switching::descriptor_table */ struct global_descriptor_table_pointer { - std::size_t table_length; ///< The size of the GDT in bytes. - - // TODO: Would rather use global_descriptor_table *, but circular dependency - uint64_t address; ///< Pointer to the GDT base address. + std::size_t table_length; ///< The size of the GDT in bytes. + global_descriptor_table * address; ///< Pointer to the GDT base address. }; } // namespace teachos::arch::context_switching::descriptor_table diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp index 06e2e8a..86b6c75 100644 --- a/arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp +++ b/arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp @@ -52,13 +52,13 @@ namespace teachos::arch::context_switching::descriptor_table private: // The order in private variables starts for the first variable being the rightmost bit. - std::bitset<16U> _limit_1 = {}; ///< First part of the limit field (0 - 15) - std::bitset<24U> _base_1 = {}; ///< First part of the base field (16 - 39) - access_byte _access = {}; ///< Access byte field (40 - 47) - std::bitset<4U> _limit_2 = {}; ///< Second part of the limit field (48 - 51) - gdt_flags _flag = {}; ///< Flags field (52 - 55) - std::bitset<40U> _base_2 = {}; ///< Second part of the base field (56 - 95) - uint32_t _reserved = {}; ///< Reserved field used to ensure this struct is 128 bits big (96 - 127) + uint16_t _limit_1 = {}; ///< First part of the limit field (0 - 15) + std::bitset<24U> _base_1 = {}; ///< First part of the base field (16 - 39) + access_byte _access = {}; ///< Access byte field (40 - 47) + std::bitset<4U> _limit_2 = {}; ///< Second part of the limit field (48 - 51) + gdt_flags _flag = {}; ///< Flags field (52 - 55) + std::bitset<40U> _base_2 = {}; ///< Second part of the base field (56 - 95) + uint32_t _reserved = {}; ///< Reserved field used to ensure this struct is 128 bits big (96 - 127) }; } // namespace teachos::arch::context_switching::descriptor_table diff --git a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp index ca3d7ff..f4ea61b 100644 --- a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp +++ b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp @@ -45,12 +45,9 @@ namespace teachos::arch::context_switching::descriptor_table auto initialize_global_descriptor_table() -> global_descriptor_table { - global_descriptor_table gdt{create_global_descriptor_table()}; - - // TODO: Second argument does not work yet (because pointer hpp) + decltype(auto) gdt = create_global_descriptor_table(); global_descriptor_table_pointer gdt_pointer{gdt.size() - 1, &gdt}; kernel::cpu::load_global_descriptor_table(gdt_pointer); - return gdt; } -} // namespace teachos::arch::context_switching::descriptor_table
\ No newline at end of file +} // namespace teachos::arch::context_switching::descriptor_table diff --git a/arch/x86_64/src/kernel/cpu/lgdt.cpp b/arch/x86_64/src/kernel/cpu/lgdt.cpp index cb13aa8..70a48dd 100644 --- a/arch/x86_64/src/kernel/cpu/lgdt.cpp +++ b/arch/x86_64/src/kernel/cpu/lgdt.cpp @@ -4,11 +4,14 @@ namespace teachos::arch::kernel::cpu { - auto load_global_descriptor_table(context_switching::descriptor_table::global_descriptor_table_pointer gdt_pointer) + auto + load_global_descriptor_table(context_switching::descriptor_table::global_descriptor_table_pointer const & gdt_pointer) -> void { // TODO: build lgdt argument from global_descriptor_table_pointer (don't know how yet) - asm volatile("lgdt (%0)" : : "r"(gdt_pointer)); + // asm volatile("lgdt (%0)" : : "r"(gdt_pointer)); + if (gdt_pointer.table_length) + { + } } - -} // namespace teachos::arch::kernel::cpu
\ No newline at end of file +} // namespace teachos::arch::kernel::cpu |
