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

Domain subsystem implementation — domain, strand, and lifecycle management entry points. More...

import std;
import lib.error;
import lib.container_of;
import arch.s390x.cpu.lowcore;
import zxfoundation.sched.core;
import zxfoundation.sys.ipc.core;
import lib.cstring;
import zxfoundation.sync.lockable;
import zxfoundation.memory.vm;
import zxfoundation.memory.pmm.types;
import zxfoundation.memory.pmm;
import zxfoundation.sync.qspinlock.core;
import lib.format;
import zxfoundation.memory.hhdm;
import zxfoundation.base.transaction;
import zxfoundation.scoms.metadata.core;
import arch.s390x.cpu.aste;
import zxfoundation.sys.service.core;
import zxfoundation.scoms.kobject.ref;
import arch.s390x.cpu.ctlreg;
import zxfoundation.dgp.portal.core;
import zxfoundation.scoms.table;
import zxfoundation.scoms.kobject.types;
import zxfoundation.base.types;
import arch.s390x.mmu.core;
import zxfoundation.dgp.isolation.types;
import zxfoundation.scoms.kobject.base;
import zxfoundation.dgp.authorize;
import arch.s390x.mmu.types;
import zxfoundation.dgp.domain.types;
import zxfoundation.memory.kmalloc;
import zxfoundation.sys.printk.core;
import lib.list;
import zxfoundation.dgp.sync_contract;
import zxfoundation.sys.syschk.core;
import zxfoundation.base.typestate;
import zxfoundation.dgp.isolation;
import zxfoundation.memory.objects;
import arch.s390x.mmu.consts;
import zxfoundation.sched.policy;
import zxfoundation.dgp.cap.types;
import zxfoundation.dgp.cap.core;
import zxfoundation.dgp.signal;
import zxfoundation.dgp.gate.core;
import zxfoundation.dgp.policy.core;
Include dependency graph for core.cxx:

Data Structures

class  zxfoundation::dgp::domain::detail::domain_create_txn
 Transactional domain creation. More...
struct  zxfoundation::dgp::domain::detail::nucleus_domain_handle
 Nucleus domain. More...

Functions

auto zxfoundation::dgp::domain::detail::advance_domain_teardown_phase (domain &d, dgp::sync_contract::teardown_phase expected, dgp::sync_contract::teardown_phase requested) noexcept -> std::expected< void, lib::kernel_error >
auto zxfoundation::dgp::domain::detail::claim_domain_destroy (domain &d) noexcept -> std::expected< void, lib::kernel_error >
auto zxfoundation::dgp::domain::current_domain_or_nucleus () noexcept -> domain *
 Return the currently-running domain.
auto zxfoundation::dgp::domain::domain_activate (domain_id id) noexcept -> std::expected< void, lib::kernel_error >
 Activate a domain: transition from embryo → active.
auto zxfoundation::dgp::domain::domain_count () noexcept -> u32
 Return the current number of live domains.
auto zxfoundation::dgp::domain::domain_create (const char *name) noexcept -> std::expected< domain *, lib::kernel_error >
 Create a new domain.
auto zxfoundation::dgp::domain::domain_destroy (domain_id id) noexcept -> std::expected< void, lib::kernel_error >
 Destroy a domain and release all its resources.
auto zxfoundation::dgp::domain::domain_find (domain_id id) noexcept -> domain *
 Look up a domain by ID.
auto zxfoundation::dgp::domain::domain_init () noexcept -> void
 Initialize the domain subsystem.
auto zxfoundation::dgp::domain::domain_init_nucleus () noexcept -> std::expected< void, lib::kernel_error >
 Initialize the nucleus domain at slot 0.
auto zxfoundation::dgp::domain::domain_nucleus () noexcept -> domain *
 Get the nucleus domain — the kernel's own domain identity.
auto zxfoundation::dgp::domain::idle_strand_create (u16 cpu) noexcept -> std::expected< strand *, lib::kernel_error >
 Allocate a per-CPU idle strand from the SCOMS strand table.
auto zxfoundation::dgp::domain::detail::idle_strand_create_impl (u16 cpu) noexcept -> std::expected< strand *, lib::kernel_error >
 Allocate and initialize a per-CPU idle strand from the SCOMS strand table.
auto zxfoundation::dgp::domain::idle_strand_destroy (strand &s) noexcept -> std::expected< void, lib::kernel_error >
 Destroy a per-CPU idle strand and release its SCOMS slot.
auto zxfoundation::dgp::domain::detail::idle_strand_destroy_impl (strand &s) noexcept -> std::expected< void, lib::kernel_error >
 Destroy a per-CPU idle strand, releasing its stack and SCOMS slot.
auto zxfoundation::dgp::domain::detail::lifecycle_error () noexcept -> lib::kernel_error
auto zxfoundation::dgp::domain::register_domain_cap_lookup () noexcept -> void
auto zxfoundation::dgp::domain::detail::secondary_strand_count (const domain &owner) noexcept -> u32
auto zxfoundation::dgp::domain::strand_create (domain *owner, u16 cpu) noexcept -> std::expected< strand *, lib::kernel_error >
 Create a secondary strand within a domain.
auto zxfoundation::dgp::domain::detail::strand_create_impl (domain *owner, u16 cpu) noexcept -> std::expected< strand *, lib::kernel_error >
 Allocate and initialize a secondary strand for a domain.
auto zxfoundation::dgp::domain::strand_destroy (strand &s) noexcept -> std::expected< void, lib::kernel_error >
 Destroy a secondary strand that has already left all run queues.
auto zxfoundation::dgp::domain::detail::strand_destroy_impl (strand &s) noexcept -> std::expected< void, lib::kernel_error >
auto zxfoundation::dgp::domain::strand_init () noexcept -> void
 Initialize the strand SCOMS table.

Variables

no_export constexpr u32 zxfoundation::dgp::domain::detail::DOMAIN_KERNEL_STACK_ORDER = 2
 Buddy order for kernel stack allocation: 2^2 = 4 pages.
declscope(C) scoms no_export constexpr u32 zxfoundation::dgp::domain::detail::DOMAIN_KERNEL_STACK_SIZE = 4 * 4096
 The global domain table — SCOMS scoms_table.
no_export nucleus_domain_handle zxfoundation::dgp::domain::detail::g_nucleus {}
no_export scoms::scoms_table< strand, MAX_SECONDARY_STRAND_IDS > zxfoundation::dgp::domain::detail::g_strand_table {}
 Secondary strand SCOMS table.
no_export constexpr u32 zxfoundation::dgp::domain::detail::MAX_SECONDARY_STRAND_IDS = MAX_DOMAINS * MAX_STRANDS_PER_DOMAIN

Detailed Description

Domain subsystem implementation — domain, strand, and lifecycle management entry points.

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ domain_activate()

auto zxfoundation::dgp::domain::domain_activate ( domain_id id) ->std::expected< void, lib::kernel_error >
nodiscardnoexcept

Activate a domain: transition from embryo → active.

Parameters
[in]idDomain ID to activate.
Returns
Success, or kernel_error if the domain is not in embryo state.

◆ domain_create()

auto zxfoundation::dgp::domain::domain_create ( const char * name) ->std::expected< domain *, lib::kernel_error >
nodiscardnoexcept

Create a new domain.

Parameters
[in]nameHuman-readable name (pointer must remain valid for the domain's lifetime).
Returns
Pointer to the newly created and activated domain, or kernel_error.

◆ domain_destroy()

auto zxfoundation::dgp::domain::domain_destroy ( domain_id id) ->std::expected< void, lib::kernel_error >
nodiscardnoexcept

Destroy a domain and release all its resources.

Parameters
[in]idDomain ID to destroy.
Returns
Success or kernel_error on invalid ID or an already-claimed domain.

◆ domain_find()

auto zxfoundation::dgp::domain::domain_find ( domain_id id) ->domain *
nodiscardnoexcept

Look up a domain by ID.

Parameters
[in]idDomain ID.
Returns
Pointer to the domain, or nullptr if the slot is unused or the ID is out of range.

◆ domain_nucleus()

auto zxfoundation::dgp::domain::domain_nucleus ( ) ->domain *
nodiscardnoexcept

Get the nucleus domain — the kernel's own domain identity.

Returns
Pointer to the nucleus domain (slot 0). Always non-null after domain_init_nucleus has been called.

◆ idle_strand_create()

auto zxfoundation::dgp::domain::idle_strand_create ( u16 cpu) ->std::expected< strand *, lib::kernel_error >
nodiscardnoexcept

Allocate a per-CPU idle strand from the SCOMS strand table.

Parameters
cpuCPU this idle strand is pinned to.
Returns
Pointer to the idle strand, or kernel_error.
Note
Idle strands have owner == nullptr and strand_flags::idle set.

◆ idle_strand_create_impl()

auto zxfoundation::dgp::domain::detail::idle_strand_create_impl ( u16 cpu) ->std::expected< strand *, lib::kernel_error >
nodiscardnoexcept

Allocate and initialize a per-CPU idle strand from the SCOMS strand table.

Parameters
cpuCPU this idle strand is pinned to.
Returns
Pointer to the created idle strand, or kernel_error.
Note
Idle strands have owner == nullptr and strand_flags::idle set.

◆ idle_strand_destroy()

auto zxfoundation::dgp::domain::idle_strand_destroy ( strand & s) ->std::expected< void, lib::kernel_error >
nodiscardnoexcept

Destroy a per-CPU idle strand and release its SCOMS slot.

Parameters
sIdle strand to destroy.
Returns
Success or kernel_error.

◆ idle_strand_destroy_impl()

auto zxfoundation::dgp::domain::detail::idle_strand_destroy_impl ( strand & s) ->std::expected< void, lib::kernel_error >
nodiscardnoexcept

Destroy a per-CPU idle strand, releasing its stack and SCOMS slot.

Parameters
sIdle strand to destroy (must not be on_rq or running).
Returns
Success or kernel_error.

◆ strand_create()

auto zxfoundation::dgp::domain::strand_create ( domain * owner,
u16 cpu )->std::expected< strand *, lib::kernel_error >
nodiscardnoexcept

Create a secondary strand within a domain.

Parameters
ownerDomain that will own the strand.
cpuCPU affinity (0 for any, or specific CPU).
Returns
Pointer to the created strand, or kernel_error.

◆ strand_create_impl()

auto zxfoundation::dgp::domain::detail::strand_create_impl ( domain * owner,
u16 cpu )->std::expected< strand *, lib::kernel_error >
nodiscardnoexcept

Allocate and initialize a secondary strand for a domain.

Parameters
ownerThe domain that will own this strand.
cpuCPU affinity (0 for any).
Returns
Pointer to the created strand, or kernel_error.

◆ strand_destroy()

auto zxfoundation::dgp::domain::strand_destroy ( strand & s) ->std::expected< void, lib::kernel_error >
nodiscardnoexcept

Destroy a secondary strand that has already left all run queues.

Parameters
[in,out]sStrand whose stack and SCOMS identity should be released.
Returns
Success or kernel_error when the strand is still runnable or invalid.
Note
The primary embedded strand must be destroyed through domain_destroy().
Warning
Callers must dequeue or drain a runnable strand before invoking this function.

Variable Documentation

◆ DOMAIN_KERNEL_STACK_SIZE

declscope (C) scoms no_export constexpr u32 zxfoundation::dgp::domain::detail::DOMAIN_KERNEL_STACK_SIZE = 4 * 4096
constexpr

The global domain table — SCOMS scoms_table.

Kernel stack size per domain: 4 pages = 16 KiB.