|
<< Click to Display Table of Contents >> Navigation: ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 8 - PAL and Privileged Boundary > 8.4 CALL_PAL - Entering the Privileged Boundary |
CALL_PAL is the only architecturally valid entry point into PAL mode (aside from exception/interrupt vectors). It encodes a PAL function selector in bits [25:0], does not behave like a normal subroutine call, and implies full serialization.
CALL_PAL behaves as the strongest serialization point (MemoryBarrierKind::PAL = 0xFFFF). Before PAL code begins execution:
1.All prior instructions must complete
2.Write buffers must be drained
3.LL/SC reservations must be cleared
4.Speculative instructions must be discarded
5.Interrupts must be masked (IPL raised to 7)
6.Pipeline must be flushed
Failure to serialize creates privilege leaks.
PalBoxBase::enterPal() executes the following sequence:
BoxResult enterPal(PalEntryReason reason, quint64 vectorOrSelector, quint64 faultPC) {
// 1. Record metadata
m_entryReason = reason;
m_entryVector = vectorOrSelector;
m_faultPC = faultPC;
// 2. Save complete context (UNIFIED - same for all entry types)
m_iprGlobalMaster->saveContext();
// 3. Compute entry PC
if (reason == PalEntryReason::CALL_PAL_INSTRUCTION)
entryPC = computeCallPalEntry(vectorOrSelector);
else
entryPC = vectorOrSelector; // Direct vector for faults
// 4. Set EXC_ADDR to faulting/return PC
m_iprGlobalMaster->h->exc_addr = faultPC;
// 5. Enter PAL mode: PC = vector | 0x1, IPL = 7, CM = KERNEL
m_iprGlobalMaster->h->pc = entryPC | 0x1ULL;
m_iprGlobalMaster->h->setIPL_Unsynced(7);
m_iprGlobalMaster->h->setCM(CM_KERNEL);
// 6. Activate shadow registers
m_shadowRegsActive = true;
// 7. Return flush request
return BoxResult().flushPipeline();
}
Key details: the low bit of PC (| 0x1) is the PAL mode indicator used by the execution engine. saveContext() captures the full register-context snapshot for later restoration by HW_REI. Shadow registers are activated for CALL_PAL entries, providing a separate register workspace for PAL code.
The PalEntryReason enum classifies why PAL mode was entered, which determines how the entry vector is computed:
enum class PalEntryReason {
CALL_PAL_INSTRUCTION, // Explicit PAL call → computed dispatch offset
FAULT_DTBM, // DTB miss → direct vector
FAULT_ITB, // ITB miss → direct vector
FAULT_ARITH, // Arithmetic exception → direct vector
FAULT_UNALIGNED, // Alignment fault → direct vector
INTERRUPT, // Hardware/software interrupt → direct vector
AST, // Asynchronous System Trap → direct vector
FAULT_ACV, // Access violation → direct vector
MACHINE_CHECK, // Machine check → direct vector
TRAP // Software trap → direct vector
};
See Also: PalBoxLib/PalBoxBase.h (enterPal); palLib_EV6/PAL_core.h (PalEntryReason).