IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
phys.cpp File Reference

Physical memory allocator. More...

#include <algorithm>
#include <array>
#include <bit>
#include <initializer_list>
#include <limits>
#include <span>
#include <klib/kAlign.hpp>
#include <klib/kString.hpp>
#include <mem/direct.hpp>
#include <mem/phys.hpp>
#include <multiboot/multiboot.hpp>
#include <platform/platform.hpp>
Include dependency graph for phys.cpp:

Go to the source code of this file.

Namespaces

namespace  igros
 IgrOS kernel: common types and literals.
namespace  igros::mem
 Memory management: physical page allocator, direct map, virtual addresses.
namespace  igros::mem::anonymous_namespace{phys.cpp}
 Allocator state.

Typedefs

using igros::mem::anonymous_namespace{phys.cpp}::word_t = igros_dword_t
 Bitmap word.

Functions

auto igros::mem::anonymous_namespace{phys.cpp}::isFree (const igros_usize_t page) noexcept -> bool
 Check if page is free.
void igros::mem::anonymous_namespace{phys.cpp}::setFree (const igros_usize_t page) noexcept
 Mark page as free.
void igros::mem::anonymous_namespace{phys.cpp}::setUsed (const igros_usize_t page) noexcept
 Mark page as used.
void igros::mem::anonymous_namespace{phys.cpp}::markUsedString (const phys_t address) noexcept
 Mark boot string as used (only first byte if string is not directly mapped).
void igros::mem::anonymous_namespace{phys.cpp}::markUsedModules (const multiboot::info_t &info) noexcept
 Mark modules list, modules and their names as used.

Variables

constexpr auto igros::mem::anonymous_namespace{phys.cpp}::WORD_BITS {static_cast<igros_usize_t>(std::numeric_limits<word_t>::digits)}
 Pages per bitmap word.
constexpr auto igros::mem::anonymous_namespace{phys.cpp}::PAGES {static_cast<igros_usize_t>(phys::MEMORY_LIMIT >> PAGE_SHIFT)}
 Number of tracked pages.
constinit std::array< word_t, PAGES/WORD_BITS > igros::mem::anonymous_namespace{phys.cpp}::freeMap {}
 Free pages bitmap (bit set - page is free).
constinit igros_usize_t igros::mem::anonymous_namespace{phys.cpp}::freeCount {0_usize}
 Number of free pages.
constinit igros_usize_t igros::mem::anonymous_namespace{phys.cpp}::searchHint {0_usize}
 No free pages in words below this one.
constinit phys_t igros::mem::anonymous_namespace{phys.cpp}::memoryTop {0_u64}
 End of highest memory marked free.

Detailed Description

Physical memory allocator.

Date
03 Nov 2026
Author
Igor Baklykov

Definition in file phys.cpp.