aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kapi/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/kapi/memory.cpp')
-rw-r--r--arch/x86_64/src/kapi/memory.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/x86_64/src/kapi/memory.cpp b/arch/x86_64/src/kapi/memory.cpp
index 3848fb8..99dcb5c 100644
--- a/arch/x86_64/src/kapi/memory.cpp
+++ b/arch/x86_64/src/kapi/memory.cpp
@@ -12,6 +12,7 @@
#include <multiboot2/information.hpp>
#include <atomic>
+#include <span>
namespace teachos::memory
{
@@ -25,11 +26,12 @@ namespace teachos::memory
auto create_memory_information() -> x86_64::region_allocator::memory_information
{
auto const & mbi = boot::bootstrap_information.mbi;
+ auto mbi_span = std::span{std::bit_cast<std::byte *>(mbi), mbi->size_bytes()};
+ auto image_span = std::span{&boot::x86_64::_start_physical, &boot::x86_64::_end_physical};
- return {.image_range = std::make_pair(physical_address{&boot::x86_64::_start_physical},
- physical_address{&boot::x86_64::_end_physical}),
- .mbi_range = std::make_pair(physical_address{std::bit_cast<std::byte *>(mbi)},
- physical_address{std::bit_cast<std::byte *>(mbi) + mbi->size_bytes()}),
+ return {.image_range =
+ std::make_pair(physical_address{&image_span.front()}, physical_address{&image_span.back()}),
+ .mbi_range = std::make_pair(physical_address{&mbi_span.front()}, physical_address{&mbi_span.back()}),
.memory_map = mbi->memory_map()};
};