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

Gate subsystem dispatch table implementation. More...

import zxfoundation.sync.qspinlock.core;
import zxfoundation.dgp.gate.types;
import zxfoundation.base.typestate;
import lib.error;
import zxfoundation.dgp.sync_contract;
import std;
import zxfoundation.dgp.gate.core;
import zxfoundation.sys.printk.core;
import zxfoundation.dgp.cap.types;
import zxfoundation.base.types;
import zxfoundation.dgp.authorize;
import zxfoundation.dgp.cap.core;
import zxfoundation.dgp.domain.core;
import zxfoundation.dgp.domain.types;
import zxfoundation.dgp.isolation.types;
import zxfoundation.dgp.isolation;
import zxfoundation.sync.lockable;
Include dependency graph for dispatch.cxx:

Data Structures

struct  zxfoundation::dgp::gate::dispatch::detail::cap_token
 Opaque 64-bit capability token. More...
struct  zxfoundation::dgp::gate::dispatch::cap_token
 Opaque 64-bit capability token. More...
struct  zxfoundation::dgp::gate::dispatch::domain
 The domain struct — the central entity of the DGP kernel. More...
struct  zxfoundation::dgp::gate::dispatch::detail::entry
struct  zxfoundation::dgp::gate::dispatch::detail::gate_desc

Enumerations

enum class  zxfoundation::dgp::gate::dispatch::cap_rights
 Standard access rights usable with any capability type.
enum class  zxfoundation::dgp::gate::dispatch::detail::cap_rights
 Standard access rights usable with any capability type.
enum class  gate_auth
enum class  zxfoundation::dgp::gate::dispatch::detail::isolation_rights
 Authority bits interpreted by the DGP policy plane.
enum class  zxfoundation::dgp::gate::dispatch::isolation_rights
 Authority bits interpreted by the DGP policy plane.
enum class  zxfoundation::dgp::gate::dispatch::detail::lifecycle_state
 Unified lifecycle states for ALL typestate-tracked resources. More...
enum class  zxfoundation::dgp::gate::dispatch::detail::lock_context
 Execution context in which a DGP synchronization-sensitive operation occurs.
enum class  zxfoundation::dgp::gate::dispatch::lock_context
 Execution context in which a DGP synchronization-sensitive operation occurs.
enum class  zxfoundation::dgp::gate::dispatch::detail::teardown_phase
 Domain teardown phase used by lock-order documentation and checks.
enum class  zxfoundation::dgp::gate::dispatch::teardown_phase
 Domain teardown phase used by lock-order documentation and checks.

Functions

auto zxfoundation::dgp::gate::dispatch::detail::acquire_caller_domain () noexcept -> zxfoundation::dgp::domain::domain *
auto zxfoundation::dgp::gate::dispatch::detail::dgp_rights_for (gate_auth_level auth) noexcept -> dgp::isolation::isolation_rights
auto zxfoundation::dgp::gate::dispatch::dispatch (u32 packed_nr, u64 a0, u64 a1, u64 a2, u64 a3, u64 a4) noexcept -> u64
 Dispatch a nucleus call through the table.
constexpr auto zxfoundation::dgp::gate::dispatch::detail::has_all_rights (dgp::isolation::isolation_rights available, dgp::isolation::isolation_rights requested) noexcept -> bool
 Test that all requested rights are present.
auto zxfoundation::dgp::gate::dispatch::is_registered (u32 packed_nr) noexcept -> bool
 Return true if the given slot has a registered handler.
auto zxfoundation::dgp::gate::dispatch::detail::metadata_for_op (zxfoundation::dgp::operation_kind op_kind, u64 a0, u64 a1, u64 a2, u64 a3) noexcept -> zxfoundation::dgp::authorization_metadata
 Extract operation-specific authorization metadata (VA range, gate id, requested-rights hint) from the syscall arguments.
auto zxfoundation::dgp::gate::dispatch::register_handler (u32 packed_nr, dispatch_handler handler, const entry_meta &meta) noexcept -> std::expected< void, lib::kernel_error >
 Register a handler at a given packed call slot.
auto zxfoundation::dgp::gate::dispatch::register_namespace_handlers (call_namespace ns, const registration_op ops[], u32 count) noexcept -> std::expected< void, lib::kernel_error >
 Bulk-register all handlers for a namespace.
auto zxfoundation::dgp::gate::dispatch::detail::target_domain_for_op (zxfoundation::dgp::operation_kind op_kind, zxfoundation::dgp::domain::domain &caller, u64 a0, u64 a1) noexcept -> zxfoundation::dgp::domain::domain *
 Resolve the target domain for an op (the domain being acted upon, distinct from the caller).
auto zxfoundation::dgp::gate::dispatch::detail::validate_call (u32 packed_nr, u64 a0, u64 a1, u64 a2, u64 a3, const entry &ent, zxfoundation::dgp::domain::domain *caller) noexcept -> bool
 Validate DGP contract + capability before dispatch.
auto zxfoundation::dgp::gate::dispatch::detail::validate_gate_entry (u32 caller_domain_id, zxfoundation::dgp::gate::gate_desc *gate, dgp::isolation::isolation_rights requested) noexcept -> bool
 Full DGP gate validation — checks gate state, rights, and auth.

Variables

static sync::qspinlock::qspinlock zxfoundation::dgp::gate::dispatch::detail::s_lock {}
static entry zxfoundation::dgp::gate::dispatch::detail::s_table [DISPATCH_TABLE_SIZE] {}

Detailed Description

Gate subsystem dispatch table implementation.

SPDX-License-Identifier: Apache-2.0

Enumeration Type Documentation

◆ lifecycle_state

enum class zxfoundation::base::lifecycle_state : u8
strong

Unified lifecycle states for ALL typestate-tracked resources.

Every SCOMS-managed object, every folio, and every slab cache uses exactly these states. No subsystem may define its own.

Function Documentation

◆ dispatch()

auto zxfoundation::dgp::gate::dispatch::dispatch ( u32 packed_nr,
u64 a0,
u64 a1,
u64 a2,
u64 a3,
u64 a4 )->u64
nodiscardexportnoexcept

Dispatch a nucleus call through the table.

Parameters
packed_nrTable index.
a0-a4Arguments.
Returns
Handler return value, or ~0ULL on error.

◆ has_all_rights()

Test that all requested rights are present.

Parameters
[in]availableAvailable right mask.
[in]requestedRequired right mask.
Returns
true when every requested right is present.

◆ register_handler()

auto zxfoundation::dgp::gate::dispatch::register_handler ( u32 packed_nr,
dispatch_handler handler,
const entry_meta & meta )->std::expected< void, lib::kernel_error >
nodiscardexportnoexcept

Register a handler at a given packed call slot.

Parameters
packed_nrTable index: (namespace << 5) | operation.
handlerThe handler function.
metaAuthorization metadata.
Returns
Success, or kernel_error if slot occupied or out of range.

◆ register_namespace_handlers()

auto zxfoundation::dgp::gate::dispatch::register_namespace_handlers ( call_namespace ns,
const registration_op ops[],
u32 count )->std::expected< void, lib::kernel_error >
nodiscardexportnoexcept

Bulk-register all handlers for a namespace.

Parameters
nsThe namespace whose handlers to register.
opsArray of (operation_id, handler, meta) tuples.
countNumber of entries in ops.
Returns
Success, or the first registration error encountered.

◆ validate_call()

auto zxfoundation::dgp::gate::dispatch::detail::validate_call ( u32 packed_nr,
u64 a0,
u64 a1,
u64 a2,
u64 a3,
const entry & ent,
zxfoundation::dgp::domain::domain * caller )->bool
nodiscardnoexcept

Validate DGP contract + capability before dispatch.

Returns
true if the call is authorized.

◆ validate_gate_entry()

auto zxfoundation::dgp::gate::dispatch::detail::validate_gate_entry ( u32 caller_domain_id,
zxfoundation::dgp::gate::gate_desc * gate,
dgp::isolation::isolation_rights requested )->bool
nodiscardnoexcept

Full DGP gate validation — checks gate state, rights, and auth.

Parameters
gatePointer to the gate_desc (must be non-null).
Returns
true if authorized.