From 52fffdf2c76def4a875e0328eb45d74c6e97e805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Mon, 10 Mar 2025 16:05:31 +0000 Subject: Adjust segment descriptor to use defined helpers --- .../descriptor_table/segment_descriptor.hpp | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'arch/x86_64/include') 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 b7665d9..59f99f6 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 @@ -1,44 +1,44 @@ #ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_SEGMENT_DESCRIPTOR_HPP #define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_SEGMENT_DESCRIPTOR_HPP +#include "arch/context_switching/descriptor_table/access_byte.hpp" #include "arch/context_switching/descriptor_table/gdt_flags.hpp" - -#include +#include "arch/context_switching/descriptor_table/segment_descriptor_type.hpp" +#include "arch/context_switching/descriptor_table/type_field.hpp" namespace teachos::arch::context_switching::descriptor_table { + __extension__ typedef __int128 int128_t; + __extension__ typedef unsigned __int128 uint128_t; - /* - TODO: Lookup segment_descriptor in intel manual chapter 3.4.5 - */ - + /** + * @brief Defines helper function for all states and the actual data the segment descriptor can have. + */ struct segment_descriptor { /** - * @brief Possible set bits in our underlying std::bitset and the meaning when they are set. + * @brief Constructor. + * + * @note Created segment descriptor copies the given bytes into theese components ending with a 32 bit reserved + * field that has to be used, because the 64-bit segment descriptor needs to be big enough for two 32-bit segment + * descriptor. + * - 8 bit Access Type + * - 4 bit Flags + * - 64 bit Base Address + * - 20 bit Limit + * + * @param flags Copies the bits set from the given data into the individual components of a segment + * descriptor. */ - enum bitset : uint64_t - { - BASE = 1U << 0U, - FLAGS = 1U << 8U, - LIMIT = 1U << 12U, - ACCESS_BYTE = 1U << 16U, - BASE = 1U << 32U, - BASE = 1U << 40U, - LIMIT = 1U << 56U - }; - - explicit segment_descriptor(uint64_t flags) - : flags(flags) - { - // Nothing to do - } + explicit segment_descriptor(uint128_t flags); private: - std::uint8_t base1; - gdt_flags flags; - std::bitset<64U> flags; ///< Underlying bitset used to read the flags from + uint32_t _reserved; + access_byte _access; + gdt_flags _flag; + uint64_t _base; + std::bitset<20U> _limit; }; } // namespace teachos::arch::context_switching::descriptor_table -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_SEGMENT_DESCRIPTOR_HPP \ No newline at end of file +#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_SEGMENT_DESCRIPTOR_HPP -- cgit v1.2.3