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

Domain/strand context setup and user-mode first-entry trampolines. More...

import lib.cstring;
import arch.s390x.cpu.psw;
import arch.s390x.cpu.ctlreg;
import std;
import arch.s390x.cpu.processor;
import arch.s390x.cpu.lowcore;
import arch.s390x.sched.types;
import zxfoundation.sys.syschk.core;
import zxfoundation.dgp.isolation;
import zxfoundation.base.types;
import arch.s390x.cpu.aste;
import zxfoundation.dgp.isolation.types;
import zxfoundation.dgp.domain.types;
Include dependency graph for core.cxx:

Data Structures

struct  zxfoundation::sched::strandctx::domain
 The domain struct — the central entity of the DGP kernel. More...
struct  zxfoundation::sched::strandctx::strand
 Strand — the DGP kernel's unit of schedulable execution. More...
struct  zxfoundation::sched::strandctx::detail::user_regs
 User-mode register save area for strand entry/exit. More...
struct  zxfoundation::sched::strandctx::user_regs
 User-mode register save area for strand entry/exit. More...

Functions

auto zxfoundation::sched::strandctx::domain_enter_user (domain *d) noexcept -> void
 Overload taking domain* for backward compatibility.
auto zxfoundation::sched::strandctx::domain_enter_user (strand *s) noexcept -> void
 Enter user mode for a domain.
 from_global (nomangle)
auto zxfoundation::sched::strandctx::detail::normalize_user_psw (user_regs &uregs, const domain *owner) noexcept -> void
 Apply the canonical user-PSW normalization.
auto zxfoundation::sched::strandctx::setup_primary_strand_context (domain *d, strand_entry_fn entry, void *arg) noexcept -> void
 Convenience wrapper — kernel-thread first-switch for the primary strand of a domain.
auto zxfoundation::sched::strandctx::setup_primary_strand_context_user (domain *d) noexcept -> void
 Convenience wrapper — user-process first-switch for the primary strand of a domain.
auto zxfoundation::sched::strandctx::setup_strand_context_kernel_thread (strand *s, strand_entry_fn entry, void *arg) noexcept -> void
 Set up the initial kernel stack frame for a strand so that the.
auto zxfoundation::sched::strandctx::setup_strand_context_user (strand *s, const user_regs *uregs, const domain *owner) noexcept -> void
 Set up the initial kernel stack frame for a strand whose first context switch performs an LPSWE into user mode.
auto zxfoundation::sched::strandctx::detail::stage_user_ars_vrs_fpc (strand *s, const user_regs *uregs) noexcept -> void
 Stage the user_regs AR/FPC/VR state.

Variables

static constexpr u64 zxfoundation::sched::strandctx::detail::FRAME_ARS_OFF = 0
 AR bank within __switch_to_asm save area.
static constexpr u64 zxfoundation::sched::strandctx::detail::FRAME_FPC_OFF = 64
 FPC within save area.
static constexpr u64 zxfoundation::sched::strandctx::detail::FRAME_VRS_HI_SIZE = 256
 v16-v31.
static constexpr u64 zxfoundation::sched::strandctx::detail::FRAME_VRS_LO_SIZE = 256
 v0-v15 (16 * 16 bytes).
static constexpr u64 zxfoundation::sched::strandctx::detail::FRAME_VRS_OFF = 72
 VR bank within save area.
static constexpr u64 zxfoundation::sched::strandctx::detail::SF_GPRS = 48
 callee-saved GPR save region start (in __switch_to_asm post-pop frame).
static constexpr u64 zxfoundation::sched::strandctx::detail::SWITCH_FRAME_SIZE = 640
 __switch_to_asm save area.
static constexpr u64 zxfoundation::sched::strandctx::detail::TRAMPOLINE_FRAME_SIZE = 160
 domain_trampoline's own frame.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_ARS_OFF = UREGS_PSW_ADDR_OFF + 8U
 +0x90.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_ARS_SIZE = 16U * 4U
 64 bytes.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_FPC_OFF = UREGS_ARS_OFF + UREGS_ARS_SIZE
 +0xD0.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_GPRS_OFF = 0
 gprs[16] start.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_GPRS_SIZE = 16U * 8U
 128 bytes.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_PSW_ADDR_OFF = UREGS_PSW_MASK_OFF + 8U
 +0x88.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_PSW_MASK_OFF = UREGS_GPRS_OFF + UREGS_GPRS_SIZE
 +0x80.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_VRS_OFF = UREGS_FPC_OFF + 8U
 +0xD8.
static constexpr u64 zxfoundation::sched::strandctx::detail::UREGS_VRS_SIZE = 32U * 16U
 512 bytes.
static constexpr u64 zxfoundation::sched::strandctx::detail::USER_GPRS_OFF = 0x90
 user GPRs start within the user return frame.
static constexpr u64 zxfoundation::sched::strandctx::detail::USER_PSW_OFF = 0x110
 user PSW (mask+addr, 16B) within the user return frame.
static constexpr u64 zxfoundation::sched::strandctx::detail::USER_RETURN_FRAME_SIZE = 0x120

Detailed Description

Domain/strand context setup and user-mode first-entry trampolines.

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ domain_enter_user() [1/2]

auto zxfoundation::sched::strandctx::domain_enter_user ( domain * d) ->void
exportnoexcept

Overload taking domain* for backward compatibility.

Overload taking domain* for backward compatibility.

◆ domain_enter_user() [2/2]

auto zxfoundation::sched::strandctx::domain_enter_user ( strand * s) ->void
exportnoexcept

Enter user mode for a domain.

Enter user mode for a domain at runtime.

Parameters
sStrand with valid body->uregs; domain accessed via s->owner.

◆ from_global()

from_global ( nomangle )
noexcept

Assembly stub: load ARs/VRs/FPC from user_regs, then jump to ret_to_user.

Parameters
[in]%r2frame_base — kernel stack slot with 16 user GPRs + PSW.
[in]%r3user_regs* — AR/VR/FPC snapshot to restore before LPSWE.

Assembly kernel-thread first-entry trampoline.

Unified first-context-switch dispatcher (kernel-thread or user-process).

Low-level context switch: (strand* prev, strand* next) -> domain* (prev->owner).

◆ normalize_user_psw()

auto zxfoundation::sched::strandctx::detail::normalize_user_psw ( user_regs & uregs,
const domain * owner )->void
noexcept

Apply the canonical user-PSW normalization.

Parameters
[in,out]uregsMutable user_regs candidate PSW.
[in]ownerThe owning domain (may be nullptr in tests); its storage_key is blended into PSW bits 52..55.
Here is the caller graph for this function:

◆ setup_strand_context_kernel_thread()

auto zxfoundation::sched::strandctx::setup_strand_context_kernel_thread ( strand * s,
strand_entry_fn entry,
void * arg )->void
exportnoexcept

Set up the initial kernel stack frame for a strand so that the.

Parameters
sTarget strand with valid kstack_top
entryNon-null kernel entry function
argOpaque argument passed to entry in r2

◆ setup_strand_context_user()

auto zxfoundation::sched::strandctx::setup_strand_context_user ( strand * s,
const user_regs * uregs,
const domain * owner )->void
exportnoexcept

Set up the initial kernel stack frame for a strand whose first context switch performs an LPSWE into user mode.

Parameters
sTarget strand with valid kstack_top and body->uregs already populated
uregsPointer to the user_regs snapshot
ownerThe owning domain, used for ASC normalization and DGP isolation validation.
Here is the call graph for this function:

◆ stage_user_ars_vrs_fpc()

auto zxfoundation::sched::strandctx::detail::stage_user_ars_vrs_fpc ( strand * s,
const user_regs * uregs )->void
noexcept

Stage the user_regs AR/FPC/VR state.

Parameters
sStrand whose ksp IS already set to the bottom of the save area
uregsSource user_regs (must be non-null).
Here is the caller graph for this function: