aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-03 13:52:22 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-03 13:52:22 +0000
commitdb70018fc76800dd56b4421be797bffd00d7619d (patch)
tree290f13c811e382b4ebd7e74e336a98eec066ae43 /arch/x86_64/include
parent74c53bed107b87f064484b926d8ed02018eb3a3e (diff)
downloadteachos-db70018fc76800dd56b4421be797bffd00d7619d.tar.xz
teachos-db70018fc76800dd56b4421be797bffd00d7619d.zip
Convert elf section flags to entry flags
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp4
-rw-r--r--arch/x86_64/include/arch/memory/paging/page_entry.hpp20
2 files changed, 22 insertions, 2 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
index f30ca24..54ec682 100644
--- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
@@ -116,11 +116,11 @@ namespace teachos::arch::memory::paging
allocator::physical_frame_iterator const begin{start_frame};
allocator::physical_frame_iterator const end{end_frame};
frame_container frames{begin, end};
+ entry entry{section.flags};
for (auto const & frame : frames)
{
- // TODO: Use actual elf section flags, convert from one to the other flag type.
- active_table.identity_map(allocator, frame, entry::WRITABLE);
+ active_table.identity_map(allocator, frame, entry.get_flags());
}
}
}
diff --git a/arch/x86_64/include/arch/memory/paging/page_entry.hpp b/arch/x86_64/include/arch/memory/paging/page_entry.hpp
index 5959801..ab9659d 100644
--- a/arch/x86_64/include/arch/memory/paging/page_entry.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_entry.hpp
@@ -2,6 +2,7 @@
#define TEACHOS_ARCH_X86_64_MEMORY_PAGING_PAGE_ENTRY_HPP
#include "arch/memory/allocator/physical_frame.hpp"
+#include "arch/memory/multiboot/elf_symbols_section.hpp"
#include <bitset>
#include <optional>
@@ -48,6 +49,18 @@ namespace teachos::arch::memory::paging
explicit entry(uint64_t flags);
/**
+ * @brief Converts the given elf section flags into the corresponding correct entry flags.
+ *
+ * @note Enables us to set the correct flags on a entry depending on which elf section it is contained in. For
+ * example entries of .text sections should be executable and read only or entries of .data sections should be
+ * writable but not executable.
+ *
+ * @param elf_flags Elf section flags we want to convert into entry flags.
+ * @return Entry that has the corresponding bit flags set.
+ */
+ explicit entry(multiboot::elf_section_flags elf_flags);
+
+ /**
* @brief Whether the current page is unused, meaning the underlying std::bitset is 0.
*
* @return Current page is in memory.
@@ -86,6 +99,13 @@ namespace teachos::arch::memory::paging
*/
auto contains_flags(std::bitset<64U> other) const -> bool;
+ /**
+ * @brief Extracts only the flags from the underlying entry and ignores all bits that contain the physical address.
+ *
+ * @return Extracted entry flags, without the physical address.
+ */
+ auto get_flags() -> std::bitset<64U>;
+
private:
std::bitset<64U> flags; ///< Underlying bitset used to read the flags from. Bits 9 - 11 and 52 - 62 can be
///< freely used for additional flags by the operating system.