diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-03-31 13:18:56 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-03-31 13:18:56 +0000 |
| commit | e8fb1d771d9aa4d1cb5b18cd0483c7e5731aeecc (patch) | |
| tree | 2746d6ba794fd4ee40a8da55aaca962587524858 /arch/x86_64/include | |
| parent | abe7bd7480c8f4e1e30b9f0f3b98966222817f3e (diff) | |
| download | teachos-e8fb1d771d9aa4d1cb5b18cd0483c7e5731aeecc.tar.xz teachos-e8fb1d771d9aa4d1cb5b18cd0483c7e5731aeecc.zip | |
Improve create_segment readability
Diffstat (limited to 'arch/x86_64/include')
4 files changed, 46 insertions, 18 deletions
diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp index f153e36..2f8e61d 100644 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp +++ b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp @@ -48,13 +48,13 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table idt_flags(uint8_t flags); /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset. + * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. * * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng - * std::bitset. Any additional bits that are set are not relevant. + * data. Any additional bits that are set are not relevant. * - * @param other Flags that we want to compare against and check if the underlying std::bitset has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying std::bitset. + * @param other Flags that we want to compare against and check if the underlying data has the same bits set. + * @return Whether the given flags are a subset or equivalent with the underlying data. */ auto contains_flags(std::bitset<8U> other) const -> bool; @@ -66,6 +66,13 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table */ auto operator==(idt_flags const & other) const -> bool = default; + /** + * @brief Combines all bits that are set in the std::bitset flags with the bits already set in the underlying data. + * + * @param other Additional bits that should be set. + */ + auto operator|=(std::bitset<8U> other) -> void; + private: uint8_t _flags = {}; ///< Underlying bits used to read the flags from. }; 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 73cd176..2c90152 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 @@ -51,13 +51,13 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table segment_selector(uint16_t index, uint8_t flags); /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset. + * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. * * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng - * std::bitset. Any additional bits that are set are not relevant. + * data. Any additional bits that are set are not relevant. * - * @param other Flags that we want to compare against and check if the underlying std::bitset has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying std::bitset. + * @param other Flags that we want to compare against and check if the underlying data has the same bits set. + * @return Whether the given flags are a subset or equivalent with the underlying data. */ auto contains_flags(std::bitset<3U> other) const -> bool; @@ -66,6 +66,13 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table */ auto operator<=>(segment_selector const & other) const -> std::strong_ordering = default; + /** + * @brief Combines all bits that are set in the std::bitset flags with the bits already set in the underlying data. + * + * @param other Additional bits that should be set. + */ + auto operator|=(std::bitset<3U> other) -> void; + private: uint8_t _flags : 3 = {}; ///< Underlying bits used to read the flags from. uint16_t _index : 13 = diff --git a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/access_byte.hpp b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/access_byte.hpp index 3d7862c..621b570 100644 --- a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/access_byte.hpp +++ b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/access_byte.hpp @@ -71,24 +71,31 @@ namespace teachos::arch::context_switching::segment_descriptor_table access_byte(uint8_t flags); /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset. + * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. * * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng - * std::bitset. Any additional bits that are set are not relevant. + * data. Any additional bits that are set are not relevant. * - * @param other Flags that we want to compare against and check if the underlying std::bitset has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying std::bitset. + * @param other Flags that we want to compare against and check if the underlying data has the same bits set. + * @return Whether the given flags are a subset or equivalent with the underlying data. */ auto contains_flags(std::bitset<8U> other) const -> bool; /** - * @brief Allows to compare the underlying std::bitset of two instances. + * @brief Allows to compare the underlying data of two instances. * * @param other Other instance that we want to compare with. - * @return Whether the underlying std::bitset of both types is the same. + * @return Whether the underlying data of both types is the same. */ auto operator==(access_byte const & other) const -> bool = default; + /** + * @brief Combines all bits that are set in the std::bitset flags with the bits already set in the underlying data. + * + * @param other Additional bits that should be set. + */ + auto operator|=(std::bitset<8U> other) -> void; + private: uint8_t _flags = {}; ///< Underlying bits used to read the flags from. }; diff --git a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp index d8c3cd1..4b84035 100644 --- a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp +++ b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp @@ -50,13 +50,13 @@ namespace teachos::arch::context_switching::segment_descriptor_table gdt_flags(uint8_t flags, std::bitset<20U> limit); /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset. + * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. * * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng - * std::bitset. Any additional bits that are set are not relevant. + * data. Any additional bits that are set are not relevant. * - * @param other Flags that we want to compare against and check if the underlying std::bitset has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying std::bitset. + * @param other Flags that we want to compare against and check if the underlying data has the same bits set. + * @return Whether the given flags are a subset or equivalent with the underlying data. */ auto contains_flags(std::bitset<4U> other) const -> bool; @@ -77,6 +77,13 @@ namespace teachos::arch::context_switching::segment_descriptor_table */ auto operator==(gdt_flags const & other) const -> bool = default; + /** + * @brief Combines all bits that are set in the std::bitset flags with the bits already set in the underlying data. + * + * @param other Additional bits that should be set. + */ + auto operator|=(std::bitset<4U> other) -> void; + private: uint8_t _limit_2 : 4 = {}; ///< Second part of the limit field. uint8_t _flags : 4 = {}; ///< Underlying bits used to read the flags from. |
