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

Capability management — acquire, release, derive, and validate capability tokens for the DGP kernel's authorization model. More...

import std;
import lib.format;
import lib.error;
import zxfoundation.sync.lockable;
import zxfoundation.sync.qspinlock.core;
import zxfoundation.base.typestate;
import zxfoundation.dgp.cap.types;
import zxfoundation.scoms.table;
import zxfoundation.scoms.kobject.base;
import zxfoundation.dgp.gate.types;
import zxfoundation.scoms.kobject.ref;
import zxfoundation.scoms.kobject.types;
import zxfoundation.dgp.domain.types;
import zxfoundation.dgp.portal.types;
import zxfoundation.memory.objects;
import zxfoundation.memory.vm.types;
import zxfoundation.memory.kmalloc;
import zxfoundation.base.types;
import zxfoundation.sys.zxio.types;
Include dependency graph for core.cxx:

Data Structures

struct  zxfoundation::dgp::cap::detail::capability_slot

Functions

auto zxfoundation::dgp::cap::cap_acquire (cap_token source, cap_rights rights, u32 owner_domain) noexcept -> std::expected< cap_token, lib::kernel_error >
 Acquire a private capability derived from an owned capability.
auto zxfoundation::dgp::cap::cap_duplicate (cap_token source, cap_rights rights, u32 owner_domain) noexcept -> std::expected< cap_token, lib::kernel_error >
 Duplicate a capability for a new owner from kernel policy code.
auto zxfoundation::dgp::cap::cap_duplicate_for (cap_token source, cap_rights rights, u32 source_domain, u32 owner_domain) noexcept -> std::expected< cap_token, lib::kernel_error >
 Duplicate a capability after checking its current owner.
auto zxfoundation::dgp::cap::cap_issue (cap_type type, u16 obj_id, cap_rights rights, u32 owner_domain) noexcept -> std::expected< cap_token, lib::kernel_error >
 Issue a capability from nucleus-owned object authority.
auto zxfoundation::dgp::cap::cap_release (cap_token token) noexcept -> std::expected< void, lib::kernel_error >
 Release a previously acquired capability.
auto zxfoundation::dgp::cap::cap_resolve (cap_token token, cap_rights needed) noexcept -> std::expected< scoms::kobject::bobject *, lib::kernel_error >
 Resolve a validated capability to its SCOMS object.
auto zxfoundation::dgp::cap::cap_revoke (cap_token token) noexcept -> std::expected< void, lib::kernel_error >
 Revoke a capability token administratively.
auto zxfoundation::dgp::cap::cap_revoke_for_domain (u32 domain_id) noexcept -> std::expected< u32, lib::kernel_error >
 Revoke every capability owned by or targeting a domain.
auto zxfoundation::dgp::cap::cap_revoke_target (scoms::kobject::bobject &target) noexcept -> std::expected< u32, lib::kernel_error >
 Revoke all slots referring to a SCOMS object.
template<>
auto zxfoundation::dgp::cap::cap_validate< zxfoundation::dgp::domain::domain > (cap_token token, cap_rights needed) noexcept -> std::expected< zxfoundation::dgp::domain::domain *, lib::kernel_error >
template<>
auto zxfoundation::dgp::cap::cap_validate< zxfoundation::dgp::gate::gate_desc > (cap_token token, cap_rights needed) noexcept -> std::expected< zxfoundation::dgp::gate::gate_desc *, lib::kernel_error >
template<>
auto zxfoundation::dgp::cap::cap_validate< zxfoundation::dgp::portal::portal_desc > (cap_token token, cap_rights needed) noexcept -> std::expected< zxfoundation::dgp::portal::portal_desc *, lib::kernel_error >
template<>
auto zxfoundation::dgp::cap::cap_validate< zxfoundation::memory::objects::memory_object > (cap_token token, cap_rights needed) noexcept -> std::expected< zxfoundation::memory::objects::memory_object *, lib::kernel_error >
auto zxfoundation::dgp::cap::cap_validate_generic (cap_token token, cap_rights needed) noexcept -> std::expected< void, lib::kernel_error >
 Validate a capability token without a concrete type parameter.
auto zxfoundation::dgp::cap::cap_validate_generic_for (cap_token token, cap_rights needed, u32 owner_domain) noexcept -> std::expected< void, lib::kernel_error >
 Validate a capability against its owning domain.
no_export auto zxfoundation::dgp::cap::detail::check_rights (cap_token token, cap_rights needed) noexcept -> std::expected< void, lib::kernel_error >
 Validate that the token's type has sufficient rights for an operation.
no_export auto zxfoundation::dgp::cap::detail::ensure_capabilities_locked () noexcept -> bool
no_export auto zxfoundation::dgp::cap::detail::issue_locked (cap_type type, u16 obj_id, cap_rights rights, u32 owner_domain) noexcept -> std::expected< cap_token, lib::kernel_error >
no_export auto zxfoundation::dgp::cap::detail::lookup_kobject (cap_type type, u16 obj_id) noexcept -> std::expected< std::pair< scoms::kobject::bobject *, u32 >, lib::kernel_error >
 Retrieve a kobject* and its generation via the callback table.
auto zxfoundation::dgp::cap::register_lookup (cap_type type, lookup_fn fn) noexcept -> std::expected< void, lib::kernel_error >
 Register a lookup callback for a resource type.
no_export auto zxfoundation::dgp::cap::detail::slot_for (cap_token token) noexcept -> capability_slot *
no_export auto zxfoundation::dgp::cap::detail::validate_slot (cap_token token, cap_rights needed, u32 owner_domain, bool check_owner, scoms::kobject::bobject *&target) noexcept -> std::expected< void, lib::kernel_error >

Variables

no_export constexpr u32 zxfoundation::dgp::cap::detail::LOOKUP_TABLE_SIZE = 16
 Maximum number of lookup table entries (must exceed largest cap_type).
no_export constexpr u32 zxfoundation::dgp::cap::detail::MAX_CAPABILITIES = 1024
no_export capability_slotzxfoundation::dgp::cap::detail::s_capabilities {nullptr}
no_export sync::qspinlock::qspinlock zxfoundation::dgp::cap::detail::s_capability_lock {}
no_export lookup_fn zxfoundation::dgp::cap::detail::s_lookup_table [LOOKUP_TABLE_SIZE] {}
 Callback table indexed by cap_type.

Detailed Description

Capability management — acquire, release, derive, and validate capability tokens for the DGP kernel's authorization model.

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ cap_acquire()

auto zxfoundation::dgp::cap::cap_acquire ( cap_token source,
cap_rights rights,
u32 owner_domain )->std::expected< cap_token, lib::kernel_error >
nodiscardexportnoexcept

Acquire a private capability derived from an owned capability.

Parameters
[in]sourceCapability owned by owner_domain.
[in]rightsRights to retain from source.
[in]owner_domainDomain receiving the new capability.
Returns
cap_token on success, kernel_error on failure.

◆ cap_duplicate()

auto zxfoundation::dgp::cap::cap_duplicate ( cap_token source,
cap_rights rights,
u32 owner_domain )->std::expected< cap_token, lib::kernel_error >
nodiscardexportnoexcept

Duplicate a capability for a new owner from kernel policy code.

Parameters
[in]sourceExisting capability.
[in]rightsRights to retain.
[in]owner_domainDomain receiving the capability.

◆ cap_issue()

auto zxfoundation::dgp::cap::cap_issue ( cap_type type,
u16 obj_id,
cap_rights rights,
u32 owner_domain )->std::expected< cap_token, lib::kernel_error >
nodiscardexportnoexcept

Issue a capability from nucleus-owned object authority.

Parameters
[in]typeResource type.
[in]obj_idSCOMS object ID.
[in]rightsRights granted to the recipient.
[in]owner_domainDomain receiving the capability.

◆ cap_release()

auto zxfoundation::dgp::cap::cap_release ( cap_token token) ->std::expected< void, lib::kernel_error >
nodiscardexportnoexcept

Release a previously acquired capability.

Parameters
[in]tokenThe capability token to release.
Returns
Success, or kernel_error if the token is invalid.
Note
Decrements the underlying object's reference count.

◆ cap_resolve()

auto zxfoundation::dgp::cap::cap_resolve ( cap_token token,
cap_rights needed )->std::expected< scoms::kobject::bobject *, lib::kernel_error >
nodiscardexportnoexcept

Resolve a validated capability to its SCOMS object.

Parameters
[in]tokenCapability supplied by a caller.
[in]neededRights required by the operation.
Returns
Referenced SCOMS object, or an authorization error.

◆ cap_revoke()

auto zxfoundation::dgp::cap::cap_revoke ( cap_token token) ->std::expected< void, lib::kernel_error >
nodiscardexportnoexcept

Revoke a capability token administratively.

Parameters
[in]tokenCapability token marking the object to revoke.
Returns
Success, or kernel_error if the token is null or the object vanished before we could bump its generation.

◆ cap_revoke_for_domain()

auto zxfoundation::dgp::cap::cap_revoke_for_domain ( u32 domain_id) ->std::expected< u32, lib::kernel_error >
nodiscardexportnoexcept

Revoke every capability owned by or targeting a domain.

Parameters
[in]domain_idDomain entering teardown.
Returns
Number of revoked capability slots, or an error.

◆ cap_revoke_target()

auto zxfoundation::dgp::cap::cap_revoke_target ( scoms::kobject::bobject & target) ->std::expected< u32, lib::kernel_error >
nodiscardexportnoexcept

Revoke all slots referring to a SCOMS object.

Parameters
[in]targetObject being destroyed.
Returns
Number of revoked slots, or an error.

◆ cap_validate_generic()

auto zxfoundation::dgp::cap::cap_validate_generic ( cap_token token,
cap_rights needed )->std::expected< void, lib::kernel_error >
nodiscardexportnoexcept

Validate a capability token without a concrete type parameter.

Note
Unlike cap_validate<T>, this does not return the object pointer — it only returns success/failure.

◆ cap_validate_generic_for()

auto zxfoundation::dgp::cap::cap_validate_generic_for ( cap_token token,
cap_rights needed,
u32 owner_domain )->std::expected< void, lib::kernel_error >
nodiscardexportnoexcept

Validate a capability against its owning domain.

Parameters
[in]tokenCapability supplied by the caller.
[in]neededRights required by the operation.
[in]owner_domainDomain making the call.

◆ lookup_kobject()

no_export auto zxfoundation::dgp::cap::detail::lookup_kobject ( cap_type type,
u16 obj_id )->std::expected< std::pair< scoms::kobject::bobject *, u32 >, lib::kernel_error >
nodiscardnoexcept

Retrieve a kobject* and its generation via the callback table.

Parameters
[in]typecap_type discriminator.
[in]obj_idObject ID.
Returns
Pair of (kobject*, generation) or error.

◆ register_lookup()

auto zxfoundation::dgp::cap::register_lookup ( cap_type type,
lookup_fn fn )->std::expected< void, lib::kernel_error >
nodiscardexportnoexcept

Register a lookup callback for a resource type.

Parameters
[in]typeThe resource type to associate with the callback.
[in]fnThe callback.
Returns
Success, or kernel_error if the type is out of range.