|
<< Click to Display Table of Contents >> Navigation: ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 4 - Functional Execution Domains ("Boxes) > 4.9 PalBox - Privileged Architecture Library Box |
PalBox implements the privileged boundary. PAL code is effectively firmware running inside the CPU — it executes within the normal pipeline but with full architectural authority.
•CALL_PAL dispatch — executeCALL_PAL() extracts the PAL function code from the low 8 bits of the raw instruction, dispatches to PalService::execute() which implements the specific PAL function (e.g., SWPCTX, CHMK, CALLSYS, CSERVE)
•PAL mode entry and exit — enterPal(reason, vector, faultPC) sets PAL mode and redirects execution to the exception/interrupt handler. Only HW_REI may exit PAL mode.
•Privileged register access — HW_MFPR (Move From Processor Register, opcode 0x19) reads IPRs; HW_MTPR (Move To Processor Register, opcode 0x1D) writes IPRs. These are PAL-mode-only instructions.
•Hardware load/store — HW_LD (opcode 0x1B) and HW_ST (opcode 0x1F) provide PAL-mode physical memory access bypassing normal translation
•Exception vectoring — computes PAL entry vectors from PAL_BASE + offset for exception and interrupt delivery
•Mode transitions — manages the PAL mode flag via PalService::setPalMode(). Shadow register activation (m_shadowRegsActive) during PAL execution.
•Low-level OS services — implements privileged PAL calls: HALT, RESTART, REBOOT, DI (disable interrupts), EI (enable interrupts), IMB (instruction memory barrier), DRAINA, SWPCTX (context switch), CHMK/CHMS/CHME/CHMU (change mode), CALLSYS, BPT (breakpoint), BUGCHK, and many more
•BoxResult mapping — applyBoxResult() unpacks BoxResult flags (flush, enter PAL mode, fault info) into the PipelineSlot fields for pipeline consumption
•PAL instructions serialize the pipeline — CALL_PAL is a serialization boundary
•No speculative execution across the PAL boundary
•Only HW_REI may exit PAL mode
•LL/SC reservations are cleared on PAL entry
•PAL code executes within the normal pipeline — there is no special PAL execution path
PalBox delegates most implementation to PalService (owned via std::unique_ptr<PalService>). PalBox methods follow a uniform pattern: call m_palService->executeXXX(slot, slot.palResult), then commitPalResult(slot) to apply the result. PalBox also holds references to IRQPendingState and InterruptRouter for interrupt delivery coordination.
Implementation: PalBoxBase.h, 2,122 lines, 175 execute methods. PalBox supports the full Tru64 UNIX PAL call set as defined in the Alpha Architecture Reference Manual.
Invariant: PAL mode is an architectural firewall. No unprivileged code may execute HW_MFPR, HW_MTPR, HW_LD, HW_ST, or HW_REI.
See Also: Chapter 8 - PAL and Privileged Boundary; PalBoxLib/PalBoxBase.h; palLib_EV6/Pal_Service.h.