IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
igros::mem::phys Class Referencefinal

Physical page frame allocator. More...

#include <mem/phys.hpp>

Public Member Functions

 ~phys () noexcept=default
 D-tor.
 phys (const phys &other)=delete
 Copy c-tor.
auto operator= (const phys &other) -> phys &=delete
 Copy assignment.

Static Public Member Functions

static void init (const multiboot::info_t &info) noexcept
 Initialize from bootloader memory map (reserves kernel and boot data).
static auto alloc (const phys_t limit=MEMORY_LIMIT) noexcept -> phys_t
 Allocate physical page below limit (0 if no memory left).
static void free (const phys_t page) noexcept
 Free physical page.
static auto freePages () noexcept -> igros_usize_t
 Number of free pages.
static auto top () noexcept -> phys_t
 End of highest memory ever marked free (top of usable RAM, clamped to MEMORY_LIMIT).
static void markFree (const phys_t start, const phys_t end) noexcept
 Mark physical memory range [start, end) as free (only whole pages).
static void markUsed (const phys_t start, const phys_t end) noexcept
 Mark physical memory range [start, end) as used (every touched page).

Static Public Attributes

static constexpr auto MEMORY_LIMIT {0x100000000_u64}
 Physical memory tracked by allocator (bitmap of 128 KB).

Detailed Description

Physical page frame allocator.

(bitmap of physical pages: never touches the pages themselves, so free memory doesn't have to be mapped)

Definition at line 52 of file phys.hpp.

Member Function Documentation

◆ alloc()

auto igros::mem::phys::alloc ( const phys_t limit = MEMORY_LIMIT) ->phys_t
staticnodiscardnoexcept

Allocate physical page below limit (0 if no memory left).

Parameters
limitPage must be below this address
Returns
Page physical address, 0 if no memory

Definition at line 162 of file phys.cpp.

◆ free()

void igros::mem::phys::free ( const phys_t page)
staticnoexcept

Free physical page.

Parameters
pagePage physical address

Definition at line 185 of file phys.cpp.

◆ freePages()

auto igros::mem::phys::freePages ( ) ->igros_usize_t
staticnodiscardnoexcept

Number of free pages.

Returns
Number of free pages

Definition at line 202 of file phys.cpp.

◆ init()

void igros::mem::phys::init ( const multiboot::info_t & info)
staticnoexcept

Initialize from bootloader memory map (reserves kernel and boot data).

Parameters
infoMultiboot information (memory map, boot data to keep)

Definition at line 116 of file phys.cpp.

◆ markFree()

void igros::mem::phys::markFree ( const phys_t start,
const phys_t end )
staticnoexcept

Mark physical memory range [start, end) as free (only whole pages).

Parameters
startRange start
endRange end (whole pages inside are freed)

Definition at line 215 of file phys.cpp.

◆ markUsed()

void igros::mem::phys::markUsed ( const phys_t start,
const phys_t end )
staticnoexcept

Mark physical memory range [start, end) as used (every touched page).

Parameters
startRange start
endRange end (pages touched by range are used)

Definition at line 234 of file phys.cpp.

◆ top()

auto igros::mem::phys::top ( ) ->phys_t
staticnodiscardnoexcept

End of highest memory ever marked free (top of usable RAM, clamped to MEMORY_LIMIT).

Returns
End of highest available memory

Definition at line 209 of file phys.cpp.

Member Data Documentation

◆ MEMORY_LIMIT

auto igros::mem::phys::MEMORY_LIMIT {0x100000000_u64}
staticconstexpr

Physical memory tracked by allocator (bitmap of 128 KB).

Definition at line 65 of file phys.hpp.


The documentation for this class was generated from the following files: