aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-15 08:45:29 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-15 08:45:29 +0000
commit11f9c91e602bd0231e6bc402418dedf445e47402 (patch)
treeb86125270e9d18bc63b1cdb7c711c82d1b714e6f /arch/x86_64/src
parent03d3dec4807d6adcfc5e21bd13992014900b4eac (diff)
downloadteachos-11f9c91e602bd0231e6bc402418dedf445e47402.tar.xz
teachos-11f9c91e602bd0231e6bc402418dedf445e47402.zip
Adding enum flags
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/kernel/main.cpp34
-rw-r--r--arch/x86_64/src/memory/multiboot.cpp36
-rw-r--r--arch/x86_64/src/memory/paging.cpp7
3 files changed, 27 insertions, 50 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index c8981a8..12498d0 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -48,21 +48,27 @@ namespace teachos::arch::kernel
for (auto section = begin; section != end; ++section)
{
- bool const writable = section->flags.writable();
- bool const occupies_memory = section->flags.occupies_memory();
- bool const is_executable = section->flags.is_executable();
- bool const contains_duplicate_data = section->flags.contains_duplicate_data();
- bool const contains_strings = section->flags.contains_strings();
- bool const section_header_info_is_section_header_table_index =
- section->flags.section_header_info_is_section_header_table_index();
- bool const preserve_ordering_after_combination = section->flags.preserve_ordering_after_combination();
- bool const requires_special_os_processing = section->flags.requires_special_os_processing();
- bool const is_section_group_member = section->flags.is_section_group_member();
- bool const holds_thread_local_data = section->flags.holds_thread_local_data();
- bool const is_compressed = section->flags.is_compressed();
- bool const has_special_ordering_requirements = section->flags.has_special_ordering_requirements();
+ bool const writable = section->flags.contains_flags(arch::memory::elf_section_flags::WRITABLE);
+ bool const occupies_memory = section->flags.contains_flags(arch::memory::elf_section_flags::OCCUPIES_MEMORY);
+ bool const is_executable = section->flags.contains_flags(arch::memory::elf_section_flags::EXECUTABLE_CODE);
+ bool const contains_duplicate_data =
+ section->flags.contains_flags(arch::memory::elf_section_flags::DUPLICATE_DATA);
+ bool const contains_strings = section->flags.contains_flags(arch::memory::elf_section_flags::CONTAINS_STRING);
+ bool const section_header_info_is_section_header_table_index = section->flags.contains_flags(
+ arch::memory::elf_section_flags::SECTION_HEADER_INFO_IS_SECTION_HEADER_TABLE_INDEX);
+ bool const preserve_ordering_after_combination =
+ section->flags.contains_flags(arch::memory::elf_section_flags::PRESERVE_ORDERING_AFTER_COMBINATION);
+ bool const requires_special_os_processing =
+ section->flags.contains_flags(arch::memory::elf_section_flags::REQUIRES_SPECIAL_OS_PROCESSING);
+ bool const is_section_group_member =
+ section->flags.contains_flags(arch::memory::elf_section_flags::SECTION_GROUP_MEMBER);
+ bool const holds_thread_local_data =
+ section->flags.contains_flags(arch::memory::elf_section_flags::HOLDS_THREAD_LOCAL_DATA);
+ bool const is_compressed = section->flags.contains_flags(arch::memory::elf_section_flags::COMPRESSED);
+ bool const has_special_ordering_requirements =
+ section->flags.contains_flags(arch::memory::elf_section_flags::SPECIAL_ORDERING_REQUIREMENTS);
bool const is_excluded_unless_referenced_or_allocated =
- section->flags.is_excluded_unless_referenced_or_allocated();
+ section->flags.contains_flags(arch::memory::elf_section_flags::EXCLUDED_UNLESS_REFERENCED_OR_ALLOCATED);
if (writable && occupies_memory && is_executable && contains_duplicate_data && contains_strings &&
section_header_info_is_section_header_table_index && preserve_ordering_after_combination &&
diff --git a/arch/x86_64/src/memory/multiboot.cpp b/arch/x86_64/src/memory/multiboot.cpp
index bd3b00b..b0432a9 100644
--- a/arch/x86_64/src/memory/multiboot.cpp
+++ b/arch/x86_64/src/memory/multiboot.cpp
@@ -2,40 +2,12 @@
namespace teachos::arch::memory
{
- auto elf_section_flags::writable() const -> bool { return is_bit_set(0U); }
-
- auto elf_section_flags::occupies_memory() const -> bool { return is_bit_set(1U); }
-
- auto elf_section_flags::is_executable() const -> bool { return is_bit_set(2U); }
-
- auto elf_section_flags::contains_duplicate_data() const -> bool { return is_bit_set(4U); }
-
- auto elf_section_flags::contains_strings() const -> bool { return is_bit_set(5U); }
-
- auto elf_section_flags::section_header_info_is_section_header_table_index() const -> bool { return is_bit_set(6U); }
-
- auto elf_section_flags::preserve_ordering_after_combination() const -> bool { return is_bit_set(7U); }
-
- auto elf_section_flags::requires_special_os_processing() const -> bool { return is_bit_set(8U); }
-
- auto elf_section_flags::is_section_group_member() const -> bool { return is_bit_set(9U); }
-
- auto elf_section_flags::holds_thread_local_data() const -> bool { return is_bit_set(10U); }
-
- auto elf_section_flags::is_compressed() const -> bool { return is_bit_set(11U); }
-
- auto elf_section_flags::has_special_ordering_requirements() const -> bool { return is_bit_set(30U); }
-
- auto elf_section_flags::is_excluded_unless_referenced_or_allocated() const -> bool { return is_bit_set(31U); }
-
- auto elf_section_flags::operator==(elf_section_flags const & other) const -> bool { return flags == other.flags; }
-
- auto elf_section_flags::is_bit_set(uint8_t index) const -> bool { return flags[index] == 1U; }
+ auto elf_section_flags::contains_flags(std::bitset<64U> b) const -> bool { return (flags & b) == b; }
auto elf_section_header::is_null() const -> bool
{
- return name_table_index == 0U && type == elf_section_type::INACTIVE &&
- flags == teachos::arch::memory::elf_section_flags{0U} && virtual_address == 0U && file_offset == 0U &&
- additional_information == 0U && address_alignment == 0U && fixed_table_entry_size == 0U;
+ return name_table_index == 0U && type == elf_section_type::INACTIVE && flags == elf_section_flags(0U) &&
+ virtual_address == 0U && file_offset == 0U && additional_information == 0U && address_alignment == 0U &&
+ fixed_table_entry_size == 0U;
}
} // namespace teachos::arch::memory
diff --git a/arch/x86_64/src/memory/paging.cpp b/arch/x86_64/src/memory/paging.cpp
index 58a2b99..6fef339 100644
--- a/arch/x86_64/src/memory/paging.cpp
+++ b/arch/x86_64/src/memory/paging.cpp
@@ -31,15 +31,15 @@ namespace teachos::arch::memory
return value;
}
- auto entry::set(physical_frame frame) -> void
+ auto entry::contains_flags(std::bitset<64U> b) const -> bool { return (flags & b) == b; }
+
+ auto entry::set_address(physical_frame frame) -> void
{
arch::exception_handling::assert((frame.start_address() & ~0x000fffff'fffff000) == 0,
"Start address is not aligned with Page");
flags = std::bitset<64U>(frame.start_address()) | flags;
}
- auto entry::contains_flags(std::bitset<64U> b) const -> bool { return (flags & b) == b; }
-
auto page_table::zero_entries() -> void
{
auto begin = &entries[0];
@@ -50,5 +50,4 @@ namespace teachos::arch::memory
entry->set_unused();
}
}
-
} // namespace teachos::arch::memory