ZXFoundation™ 26h2
Loading...
Searching...
No Matches
core.cxxm File Reference

Virtual Memory Engine — core interface. More...

import std;
import lib.error;
import zxfoundation.memory.vm.types;
import zxfoundation.memory.objects;
import zxfoundation.base.types;
Include dependency graph for core.cxxm:

Functions

auto zxfoundation::memory::vm::vm_destroy_space (vm_space &space) noexcept -> void
 Destroy all regions in a VME space, freeing region descriptors.
auto zxfoundation::memory::vm::vm_drain_phys_range (u64 phys_start, u64 phys_end) noexcept -> u32
 Drain resident mappings whose phys lies in [phys_start,phys_end].
auto zxfoundation::memory::vm::vm_find (const vm_space &space, u64 va) noexcept -> vm_region *
 RCU-protected lookup: find the vm_region containing VA.
auto zxfoundation::memory::vm::vm_find_gap (const vm_space &space, u64 size, u64 align) noexcept -> std::expected< u64, lib::kernel_error >
 Top-down scan from mmap_base for a gap of at least size bytes.
auto zxfoundation::memory::vm::vm_find_grant_mapping (vm_space &space, objects::memory_object_ref grant) noexcept -> vm_region *
 Find one live mapping view that consumes grant.
auto zxfoundation::memory::vm::vm_for_each_region (region_visitor callback) noexcept -> void
auto zxfoundation::memory::vm::vm_init () noexcept -> void
 Initialize the VME subsystem (create SCOMS table for vm_region).
auto zxfoundation::memory::vm::vm_map (vm_space &space, u64 size, vm_prot prot, vm_flags flags) noexcept -> std::expected< u64, lib::kernel_error >
 Map a region of size bytes with given protection and flags.
auto zxfoundation::memory::vm::vm_map_extent (vm_space &space, u64 root_phys, u64 va, u64 length, vm_prot prot, objects::memory_object_ref extent_ref, u64 extent_offset) noexcept -> std::expected< void, lib::kernel_error >
 Map a checked subrange of a capability-bound physical extent. The caller supplies an offset, never an arbitrary physical address.
auto zxfoundation::memory::vm::vm_map_fixed (vm_space &space, u64 va, u64 size, vm_prot prot, vm_flags flags, vm_backing backing, u64 phys_base, objects::memory_object_ref mapped_extent) noexcept -> std::expected< void, lib::kernel_error >
 Map at an exact VA with specified backing.
auto zxfoundation::memory::vm::vm_map_shared_region (vm_space &target, u64 target_root_phys, u64 target_va, u64 length, vm_region &source, vm_prot prot) noexcept -> std::expected< void, lib::kernel_error >
auto zxfoundation::memory::vm::vm_protect (vm_space &space, u64 root_phys, u64 va, u64 size, vm_prot new_prot) noexcept -> std::expected< void, lib::kernel_error >
 Change protection bits for [va, va+size).
auto zxfoundation::memory::vm::vm_region_find_by_id (u32 id) noexcept -> vm_region *
 Look up a vm_region by SCOMS ID.
auto zxfoundation::memory::vm::vm_region_maps_phys (const vm_region &rgn, u64 phys) noexcept -> bool
 Test if phys is mapped-resident in rgn.
auto zxfoundation::memory::vm::vm_rekey_region (vm_space &space, vm_region &rgn, u64 new_start) noexcept -> bool
auto zxfoundation::memory::vm::vm_space_drain_phys_range (vm_space &space, u64 phys_start, u64 phys_end) noexcept -> u32
 Drop all resident page mappings in space whose backing physical address lies in [phys_start, phys_end).
auto zxfoundation::memory::vm::vm_space_init (vm_space &space) noexcept -> void
 Initialize a per-domain VME address space.
auto zxfoundation::memory::vm::vm_space_set_commit_limit (vm_space &space, u64 limit_pages) noexcept -> std::expected< void, lib::kernel_error >
 Set a domain VM-space committed-page budget.
auto zxfoundation::memory::vm::vm_space_try_charge_commit (vm_space &space, u64 pages) noexcept -> bool
 Atomically reserve committed pages for a caller that cannot retain space.lock through its fallible page-install work.
auto zxfoundation::memory::vm::vm_space_uncharge_commit (vm_space &space, u64 pages) noexcept -> void
 Return a page charge obtained from vm_space_try_charge_commit.
auto zxfoundation::memory::vm::vm_split (vm_space &space, vm_region *rgn, u64 split_va) noexcept -> std::expected< vm_region *, lib::kernel_error >
 Split rgn at split_va into [rgn->va_start, split_va) and [split_va, old_end).
auto zxfoundation::memory::vm::vm_try_merge (vm_space &space, vm_region *rgn) noexcept -> void
 Try to merge rgn with its predecessor and/or successor.
auto zxfoundation::memory::vm::vm_unmap (vm_space &space, u64 root_phys, u64 va, u64 size) noexcept -> std::expected< void, lib::kernel_error >
 Unmap pages in [va, va+size), splitting partially-overlapping regions, removing fully-covered regions, and freeing physical pages.

Detailed Description

Virtual Memory Engine — core interface.

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ vm_drain_phys_range()

auto zxfoundation::memory::vm::vm_drain_phys_range ( u64 phys_start,
u64 phys_end )->u32
nodiscardexportnoexcept

Drain resident mappings whose phys lies in [phys_start,phys_end].

Parameters
[in]phys_startInclusive start of physical range.
[in]phys_endExclusive end of physical range.
Returns
Number of physical frames freed.
Here is the call graph for this function:

◆ vm_find()

auto zxfoundation::memory::vm::vm_find ( const vm_space & space,
u64 va )->vm_region *
nodiscardexportnoexcept

RCU-protected lookup: find the vm_region containing VA.

Returns
Pointer to the region, or nullptr if no region contains va.

◆ vm_find_gap()

auto zxfoundation::memory::vm::vm_find_gap ( const vm_space & space,
u64 size,
u64 align )->std::expected< u64, lib::kernel_error >
nodiscardexportnoexcept

Top-down scan from mmap_base for a gap of at least size bytes.

Parameters
[in]spaceThe address space to scan.
[in]sizeRequired gap size (must be page-aligned).
[in]alignAlignment requirement (must be power of 2).
Returns
The base VA of the gap on success.

◆ vm_map()

auto zxfoundation::memory::vm::vm_map ( vm_space & space,
u64 size,
vm_prot prot,
vm_flags flags )->std::expected< u64, lib::kernel_error >
nodiscardexportnoexcept

Map a region of size bytes with given protection and flags.

Returns
The virtual address of the mapped region on success.

◆ vm_region_find_by_id()

auto zxfoundation::memory::vm::vm_region_find_by_id ( u32 id) ->vm_region *
nodiscardexportnoexcept

Look up a vm_region by SCOMS ID.

Returns
Raw pointer, or nullptr if not found.

◆ vm_rekey_region()

auto zxfoundation::memory::vm::vm_rekey_region ( vm_space & space,
vm_region & rgn,
u64 new_start )->bool
nodiscardexportnoexcept
Parameters
[in,out]spaceAddress space whose tree is locked by the caller.
[in,out]rgnRegion whose start key changes.
[in]new_startNew page-aligned inclusive start address.
Returns
Success when the new interval can be reinserted.
Here is the call graph for this function:

◆ vm_space_drain_phys_range()

auto zxfoundation::memory::vm::vm_space_drain_phys_range ( vm_space & space,
u64 phys_start,
u64 phys_end )->u32
nodiscardexportnoexcept

Drop all resident page mappings in space whose backing physical address lies in [phys_start, phys_end).

Parameters
[in,out]spaceAddress space to sweep (locked internally).
[in]phys_startInclusive start of physical range.
[in]phys_endExclusive end of physical range.
Returns
Number of physical frames freed (not slots dropped).
Here is the call graph for this function:

◆ vm_space_set_commit_limit()

auto zxfoundation::memory::vm::vm_space_set_commit_limit ( vm_space & space,
u64 limit_pages )->std::expected< void, lib::kernel_error >
nodiscardexportnoexcept

Set a domain VM-space committed-page budget.

Note
A live budget may not be reduced below pages already committed.

◆ vm_split()

auto zxfoundation::memory::vm::vm_split ( vm_space & space,
vm_region * rgn,
u64 split_va )->std::expected< vm_region *, lib::kernel_error >
nodiscardexportnoexcept

Split rgn at split_va into [rgn->va_start, split_va) and [split_va, old_end).

Returns
Pointer to the new region [split_va, old_end) on success.