aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi
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 /kernel/kapi
parent12c0586ee15cadfa178e6982dc0f76b047cb2df9 (diff)
downloadteachos-e7ccb96aecae7b231fb05818d7e45a767aebc31d.tar.xz
teachos-e7ccb96aecae7b231fb05818d7e45a767aebc31d.zip
kstd: introduce strong type for memory amounts
Diffstat (limited to 'kernel/kapi')
-rw-r--r--kernel/kapi/memory.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/kapi/memory.cpp b/kernel/kapi/memory.cpp
index d8065d4..2803d76 100644
--- a/kernel/kapi/memory.cpp
+++ b/kernel/kapi/memory.cpp
@@ -5,6 +5,7 @@
#include "kernel/memory/bitmap_allocator.hpp"
#include <kstd/print>
+#include <kstd/units>
#include <algorithm>
#include <cstddef>
@@ -112,8 +113,10 @@ namespace kapi::memory
auto init_pmm(std::size_t frame_count, void (&handoff_handler)(frame_allocator &)) -> void
{
- auto const bitmap_bytes = (frame_count + 7uz) / 8uz;
- auto const bitmap_pages = (bitmap_bytes + page::size - 1uz) / page::size;
+ using namespace kstd::units_literals;
+
+ auto const bitmap_bytes = kstd::units::bytes{(frame_count + 7uz) / 8uz};
+ auto const bitmap_pages = (bitmap_bytes + page::size - 1_B) / page::size;
auto const bitmap_frames = allocate_many_frames(bitmap_pages);
if (!bitmap_frames)
@@ -130,7 +133,8 @@ namespace kapi::memory
});
auto bitmap_ptr = static_cast<std::uint64_t *>(pmm_metadata_base);
- auto bitmap = std::span{bitmap_ptr, (bitmap_bytes + sizeof(std::uint64_t) - 1uz) / sizeof(std::uint64_t)};
+ auto bitmap =
+ std::span{bitmap_ptr, (bitmap_bytes + kstd::type_size<std::uint64_t> - 1_B) / kstd::type_size<std::uint64_t>};
allocator.emplace(bitmap, frame_count);