Skip to content

Conversation

@mazunki
Copy link
Contributor

@mazunki mazunki commented Oct 28, 2025

The old kernel/memory.hpp had several responsibilities, and albeit not being super long it felt hard to read. It comprised at least two fairly different parts:

  • Setting up a mapping from virtual memory to physical pages (now mem/vmap.hpp)
  • Setting up the allocator for the heap (now mem/alloc.hpp)

Furthermore, I've also created mem/flags.hpp since it doesn't quite fit either of them entirely, and it facilitates plans going forward.

Currently, we're assuming architecture-specific/hardware protection flags match IncludeOS-allocation flags. While this is currently the case, I do intend to change this in the future for the sake of type safety. src/arch/x86_64/paging.cpp uses os::mem::Access referring to hardware flags, while src/kernel/multiboot.cpp or src/kernel/elf.cpp refers to IncludeOS semantics. I intend to create a per-architecture translation mapping for this (constexpr, so it won't affect any performance, of course).

The responsibility separation between mem/vmap and mem/alloc seems to be represented in the usages across the code too (most of the results are non-overlapping):

$ rg mem/vmap.hpp | wc -l
18
$ rg mem/alloc.hpp | wc -l
14

This PR essentially makes #2329 obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant