aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-18 17:18:37 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-03-18 17:18:37 +0100
commite7ccb96aecae7b231fb05818d7e45a767aebc31d (patch)
tree68f7a623018d025b3fb6d10ce49d022242cc14f2 /arch/x86_64/src
parent12c0586ee15cadfa178e6982dc0f76b047cb2df9 (diff)
downloadteachos-e7ccb96aecae7b231fb05818d7e45a767aebc31d.tar.xz
teachos-e7ccb96aecae7b231fb05818d7e45a767aebc31d.zip
kstd: introduce strong type for memory amounts
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/memory/kernel_mapper.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86_64/src/memory/kernel_mapper.cpp b/arch/x86_64/src/memory/kernel_mapper.cpp
index e5bb7f8..ced8a14 100644
--- a/arch/x86_64/src/memory/kernel_mapper.cpp
+++ b/arch/x86_64/src/memory/kernel_mapper.cpp
@@ -6,6 +6,7 @@
#include "arch/boot/ld.hpp"
#include <kstd/print>
+#include <kstd/units>
#include <elf/format.hpp>
#include <elf/section_header.hpp>
@@ -19,13 +20,14 @@
#include <string_view>
#include <utility>
+using namespace std::string_view_literals;
+using namespace kstd::units_literals;
+
namespace arch::memory
{
namespace
{
- using namespace std::string_view_literals;
-
constexpr auto static ignored_section_prefixes = std::array{
".boot_"sv,
};
@@ -71,7 +73,8 @@ namespace arch::memory
auto kernel_mapper::map_section(section_header_type const & section, std::string_view name,
kapi::memory::page_mapper & mapper) -> void
{
- auto number_of_pages = (section.size + (kapi::memory::page::size - 1)) / kapi::memory::page::size;
+ auto number_of_pages =
+ (kstd::units::bytes{section.size} + (kapi::memory::page::size - 1_B)) / kapi::memory::page::size;
auto linear_start_address = kapi::memory::linear_address{section.virtual_load_address};
auto physical_start_address = kapi::memory::physical_address{section.virtual_load_address & ~m_kernel_load_base};