Purpose and scope
This unit implements PTO v0 validation and restoration of a saved trap context. Recovery is a checked, one-use state transition: an invalid envelope returns false without restoring execution state.
PTO-ARCH-PROFILE-TRAP-CONTEXT-RECOVERYThe complete ASL owner is shown directly below.
// PTO-UNIT: {"id":"PTO-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY","surface":"arch","classification":["profile","trap-context-recovery"],"depends_on":["PTO-ARCH-PROFILE-REFERENCE-PROFILE"]}implementation func TrapContextRecoverable(target: AccessControlRing) => booleanbegin let control = PTOv0ReadContextRegister(target, 0x0f40); let ecstate = PTOv0ReadContextRegister(target, 0x0f00); let recovered_bpc = PTOv0ReadContextRegister(target, 0x0f41); let recovered_tpc = PTOv0ReadContextRegister(target, 0x0f43); return _TrapContexts[[target]].valid && control[4] == '1' && PTOv0EBARGControlLegal(control) && control[3:0] == ecstate[3:0] && recovered_bpc[0] == '0' && recovered_tpc[0] == '0';end;
implementation func RecoverTrapContext(target: AccessControlRing) => booleanbegin if !TrapContextRecoverable(target) then return FALSE; end; var control = PTOv0ReadContextRegister(target, 0x0f40); let ecstate = PTOv0ReadContextRegister(target, 0x0f00); let recovered_bpc = PTOv0ReadContextRegister(target, 0x0f41); let recovered_tpc = PTOv0ReadContextRegister(target, 0x0f43); WriteTPC(recovered_tpc); WriteBPC(recovered_bpc); _SystemRegisters.core_state = ecstate; _BundleArgument = _TrapContexts[[target]].bundle_argument; _CommitArgument = _TrapContexts[[target]].commit_argument; _BundleActive = control[5] == '1'; _BundleBodyActive = control[6] == '1'; _BundleCommitTargetSet = _TrapContexts[[target]].bundle_commit_target_set; _BundleConditionSet = _TrapContexts[[target]].bundle_condition_set; _SystemBlockTerminalPending = _TrapContexts[[target]].system_block_terminal_pending; _BARG.block_type = PTOv0BundleKindOf(control[10:7]); _BARG.transfer_type = PTOv0BundleTransferOf(control[13:11]); _BARG.taken = control[14] == '1'; _BARG.bpcn = PTOv0ReadContextRegister(target, 0x0f42); _FrameStackReturnTarget = _TrapContexts[[target]].frame_stack_return_target; _ReturnAddress = PTOv0ReadContextRegister(target, 0x0f44); _BundleArgumentKind = _TrapContexts[[target]].bundle_argument_kind; _BundleSequentialPC = _TrapContexts[[target]].bundle_sequential_pc; _BundleOperation = _TrapContexts[[target]].bundle_operation; _BundleDimensions = _TrapContexts[[target]].bundle_dimensions; _BundleDimensionPresent = _TrapContexts[[target]].bundle_dimension_present; _BundleScalarBindings = _TrapContexts[[target]].bundle_scalar_bindings; _BundleTileBindings = _TrapContexts[[target]].bundle_tile_bindings; _BundleSharedBindings = _TrapContexts[[target]].bundle_shared_bindings; _BundleRangeGroup = _TrapContexts[[target]].bundle_range_group; _BundleZeroParticipationSeen = _TrapContexts[[target]].bundle_zero_participation_seen; _BundleControlAttributes = _TrapContexts[[target]].bundle_control_attributes; _BundleDataAttributes = _TrapContexts[[target]].bundle_data_attributes; _BundleDataAttributesPresent = _TrapContexts[[target]].bundle_data_attributes_present; _BundleHint = _TrapContexts[[target]].bundle_hint; _BundleFixedPointAttributes = _TrapContexts[[target]].bundle_fixed_point_attributes; _LocalGenerations = _TrapContexts[[target]].local_generations; _SharedGenerations = _TrapContexts[[target]].shared_generations; _BundleExecutionDomainToken = _TrapContexts[[target]].bundle_execution_domain_token; _MemoryCopyTemplate = _TrapContexts[[target]].memory_copy_template; _FrameTemplate = _TrapContexts[[target]].frame_template; for index = 0 to PTO_TEMPORARY_QUEUE_DEPTH - 1 do _TQueue[[index]] = PTOv0ReadContextRegister(target, 0x0f45 + index); _UQueue[[index]] = PTOv0ReadContextRegister(target, 0x0f49 + index); end; _TQueueValid = _TrapContexts[[target]].t_queue_valid; _UQueueValid = _TrapContexts[[target]].u_queue_valid; _PredicateRegisters = _TrapContexts[[target]].predicates; _CurrentACR = UInt(ecstate[3:0]) as AccessControlRing; control[4] = '0'; PTOv0WriteContextRegister(target, 0x0f40, control); _TrapContexts[[target]].valid = FALSE; return TRUE;end;
This unit implements PTO v0 validation and restoration of a saved trap context. Recovery is a checked, one-use state transition: an invalid envelope returns false without restoring execution state.
TrapContextRecoverable requires a valid saved context, control bit 4 set, legal EBARG control, matching low 4 ACR bits in control and ECSTATE, and even recovered BPC and TPC values. It reads context registers 0x0f40, 0x0f00, 0x0f41, and 0x0f43.
RecoverTrapContext first repeats the recoverability check. On success it restores TPC, BPC, core state, bundle arguments and activity, bundle descriptors and bindings, generation state, templates, queues, predicates, return address, and the current ACR from the saved context and context registers.
Failed validation returns false before restoration. Successful recovery clears control bit 4, writes the updated control register, invalidates the saved context, and returns true. A second recovery attempt therefore requires a newly saved valid context.
Use this example block only as a reading aid: apply the rules above, then confirm the result in the normative ASL owner. It does not add an architectural contract.
Bodies come from owning ASL. Dragging or buttons change only this page-session view order.
No NDF clause is attached to this unit.
8 matching entries
PTO-AVS-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY-STATIC-001tests/asl/arch/profile/trap-context-recovery/arch-static-trap-context-recovery-contract-001.asl11dd4c20522e3d9795355802c04340394d768c55cb872bdfc12dbad8956550bePTO-EVIDENCE-RELEASE-TRACEABILITYPTO-EVIDENCE-RELEASE-TRACEABILITYspec/evidence/release-traceability-readiness.jsonc7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3ePTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREspec/evidence/instruction-contract-closure.json3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106aPTO-EVIDENCE-ARCHITECTURE-READINESSPTO-EVIDENCE-ARCHITECTURE-READINESSspec/evidence/architecture-readiness.json4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004PTO-EVIDENCE-RELEASE-GATE-READINESSPTO-EVIDENCE-RELEASE-GATE-READINESSspec/evidence/release-gate-readiness.jsona0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0PTO-EVIDENCE-RELEASE-MANIFESTPTO-EVIDENCE-RELEASE-MANIFESTspec/release-manifest.json1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8Loading ADR-0005…
ADR-0005docs/status/decisions/0005-pto-v0-concrete-reference-profile.mda83528c2fc744cc120c2a0a32c82410059638ea88936fa65ac0eb36a0274d87cLoading ADR-0098…
ADR-0098docs/status/decisions/0098-b-range-modifiers.mde194ccc6b6922fd4b65066b533f5e4b0eba094e099970059bca8e25b4e466fba{
"classification": [
"profile",
"trap-context-recovery"
],
"documentation": "docs/arch/profile/trap-context-recovery.md",
"id": "PTO-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY",
"mnemonic": null,
"readiness_subjects": [
"ADR-0005",
"ADR-0098"
],
"semantic_tests": [],
"source": "asl/arch/profile/trap-context-recovery.asl",
"surface": "arch",
"tests": [
"PTO-AVS-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY-STATIC-001"
]
}0.58.5 · Release candidate7dc8b7e5b121d2b2499a2273bebff29e2cd868126c87ee4d53ed316f6ad72768ac84f67bcdf19c3af52dd96f3eb97eddc07c13578ba8fe4b76085c3c6ca002c57bab6f964c524e936f0b73e755fa3bf0acc33af7asl/arch/profile/trap-context-recovery.asl