aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-10 09:34:21 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-10 09:34:21 +0000
commitedc11135d83ef1f8fcbc1575a290b31ccbdb7e07 (patch)
treeb4d151d94316a467a21a5aa0f344a59cbd2f59cb /arch/x86_64/include
parent4c030cbaee174a9f7f42d4f5ca7ddf6debbbe048 (diff)
downloadteachos-edc11135d83ef1f8fcbc1575a290b31ccbdb7e07.tar.xz
teachos-edc11135d83ef1f8fcbc1575a290b31ccbdb7e07.zip
Identity map memory map and vga text buffer,w hen setting up kernel
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp23
-rw-r--r--arch/x86_64/include/arch/memory/paging/page_entry.hpp2
-rw-r--r--arch/x86_64/include/arch/video/vga/text.hpp2
3 files changed, 23 insertions, 4 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 c91c5f0..d1b9325 100644
--- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
@@ -5,6 +5,7 @@
#include "arch/memory/paging/active_page_table.hpp"
#include "arch/memory/paging/inactive_page_table.hpp"
#include "arch/memory/paging/temporary_page.hpp"
+#include "arch/video/vga/text.hpp"
namespace teachos::arch::memory::paging
{
@@ -124,19 +125,35 @@ namespace teachos::arch::memory::paging
// End address is exclusive, so that it is not part of the section anymore (one past the last frame of this
// section). But end frame would now point to the actual last frame and not one past the last frame, therefore
// we increment by one to get one past the last frame of this section.
- auto end_frame =
+ auto const end_frame =
++(allocator::physical_frame::containing_address(section.physical_address + section.section_size - 1));
allocator::frame_container::iterator const begin{start_frame};
allocator::frame_container::iterator const end{end_frame};
- allocator::frame_container frames{begin, end};
- entry entry{section.flags};
+ allocator::frame_container const frames{begin, end};
+ entry const entry{section.flags};
for (auto const & frame : frames)
{
active_table.identity_map(allocator, frame, entry.get_flags());
}
}
+
+ auto const vga_buffer_frame =
+ allocator::physical_frame::containing_address(video::vga::text::DEFAULT_VGA_TEXT_BUFFER_ADDRESS);
+ active_table.identity_map(allocator, vga_buffer_frame, entry::WRITABLE);
+
+ auto const multiboot_start_frame = allocator::physical_frame::containing_address(mem_info.multiboot_start);
+ auto const multiboot_end_frame = ++allocator::physical_frame::containing_address(mem_info.multiboot_end - 1);
+
+ allocator::frame_container::iterator const multiboot_begin{multiboot_start_frame};
+ allocator::frame_container::iterator const multiboot_end{multiboot_end_frame};
+ allocator::frame_container const multiboot_frames{multiboot_begin, multiboot_end};
+
+ for (auto const & frame : multiboot_frames)
+ {
+ active_table.identity_map(allocator, frame, entry::PRESENT);
+ }
}
T & allocator;
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 ab9659d..a7ba262 100644
--- a/arch/x86_64/include/arch/memory/paging/page_entry.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_entry.hpp
@@ -104,7 +104,7 @@ namespace teachos::arch::memory::paging
*
* @return Extracted entry flags, without the physical address.
*/
- auto get_flags() -> std::bitset<64U>;
+ auto get_flags() const -> std::bitset<64U>;
private:
std::bitset<64U> flags; ///< Underlying bitset used to read the flags from. Bits 9 - 11 and 52 - 62 can be
diff --git a/arch/x86_64/include/arch/video/vga/text.hpp b/arch/x86_64/include/arch/video/vga/text.hpp
index f200da4..665dc1c 100644
--- a/arch/x86_64/include/arch/video/vga/text.hpp
+++ b/arch/x86_64/include/arch/video/vga/text.hpp
@@ -7,6 +7,8 @@
namespace teachos::arch::video::vga::text
{
+ auto constexpr DEFAULT_VGA_TEXT_BUFFER_ADDRESS = 0xB8000;
+
/**
* @brief The colors available in the standard VGA text mode.
*/