[Writeup] Shared pseudocode: part 23 of 36 ========================================== Section: Silicon & Architectures Started: 2026-11-28 17:47 UTC by admin Replies: 0, last post 2026-11-28 17:47 UTC Page: 1 of 1 Web: https://romdump.net/t/115 ------------------------------------------------------------------------------ #135 admin, 2026-11-28 17:47 UTC [OP] Source: https://romdump.net/raw/135
Shared pseudocode from the offline Arm documentation snapshot. Part 23 of 36.
walkparams.emec = (if IsFeatureImplemented(FEAT_MEC) &&
IsSCTLR2EL2Enabled
then SCTLR2_EL2().EMEC else '0');
if IsFeatureImplemented(FEAT_MEC) && ss == SS_Realm &&
IsTCR2EL2Enabled() then
walkparams.amec = if varange == VARange_LOWER then TCR2_EL2().AMEC0 else TCR2_EL2().AMEC1;
else
walkparams.amec = '0';
end;
return walkparams;
end;
## Library pseudocode for
aarch64/translation/vmsa\_walkparams/AArch64\_S1TTWParamsEL3
// AArch64_S1TTWParamsEL3 // ======================== // Gather stage 1 translation table walk parameters for EL3 regime
readonly func AArch64_S1TTWParamsEL3() => S1TTWParams begin var walkparams : S1TTWParams;
walkparams.tgx = AArch64_S1DecodeTG0(TCR_EL3().TG0);
walkparams.txsz = TCR_EL3().T0SZ;
walkparams.ps = TCR_EL3().PS;
walkparams.irgn = TCR_EL3().IRGN0;
walkparams.orgn = TCR_EL3().ORGN0;
walkparams.sh = TCR_EL3().SH0;
walkparams.tbi = TCR_EL3().TBI;
walkparams.mair = MAIR_EL3() as MAIRType;
walkparams.d128 = if IsFeatureImplemented(FEAT_D128) then TCR_EL3().D128 else
'0';
walkparams.skl = if walkparams.d128 == '1' then TTBR0_EL3().SKL else '00';
walkparams.disch = if walkparams.d128 == '1' then TCR_EL3().DisCH0 else '0';
if walkparams.d128 == '1' then
walkparams.pie = '1';
else
walkparams.pie = if IsFeatureImplemented(FEAT_S1PIE) then TCR_EL3().PIE else '0';
end;
if IsFeatureImplemented(FEAT_S1PIE) then
walkparams.pir = PIR_EL3() as S1PIRType;
end;
if IsFeatureImplemented(FEAT_AIE) then
walkparams.mair2 = MAIR2_EL3() as MAIRType;
end;
walkparams.aie = if IsFeatureImplemented(FEAT_AIE) then TCR_EL3().AIE else
'0';
walkparams.wxn = SCTLR_EL3().WXN;
walkparams.ee = SCTLR_EL3().EE;
walkparams.sif = (if !IsFeatureImplemented(FEAT_RME) ||
IsFeatureImplemented(FEAT_SEL2)
then SCR_EL3().SIF else '0');
walkparams.tbid = if IsFeatureImplemented(FEAT_PAuth) then TCR_EL3().TBID else
'0';
walkparams.hpd = if IsFeatureImplemented(FEAT_HPDS) then TCR_EL3().HPD else
'0';
if walkparams.hpd == '0' then
if walkparams.aie == '1' then walkparams.hpd = '1'; end;
if walkparams.pie == '1' then walkparams.hpd = '1'; end;
if AArch64_S1POEnabled(Regime_EL3) then walkparams.hpd = '1'; end;
end;
walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then TCR_EL3().HA else '0';
if IsFeatureImplemented(FEAT_HAFDBS) && walkparams.ha == '1' then
walkparams.hd = TCR_EL3().HD;
else
walkparams.hd = '0';
end;
if (walkparams.tgx IN {TGx_4KB, TGx_16KB} &&
IsFeatureImplemented(FEAT_LPA2) &&
walkparams.d128 == '0') then
walkparams.ds = TCR_EL3().DS;
else
walkparams.ds = '0';
end;
if (IsFeatureImplemented(FEAT_MTE_NO_ADDRESS_TAGS) ||
IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS)) then
walkparams.mtx = TCR_EL3().MTX;
else
walkparams.mtx = '0';
end;
if IsFeatureImplemented(FEAT_THE) && walkparams.d128 == '0' then
walkparams.pnch = TCR_EL3().PnCH;
else
walkparams.pnch = '0';
end;
if IsFeatureImplemented(FEAT_HAFT) && walkparams.ha == '1' then
walkparams.haft = TCR_EL3().HAFT;
else
walkparams.haft = '0';
end;
walkparams.emec = if IsFeatureImplemented(FEAT_MEC) then SCTLR2_EL3().EMEC
else '0';
return walkparams;
end;
## Library pseudocode for
aarch64/translation/vmsa\_walkparams/AArch64\_S2DecodeTG0
// AArch64_S2DecodeTG0 // ===================== // Decode stage 2 granule size configuration bits TG0
func AArch64_S2DecodeTG0(tg0_in : bits(2)) => TGx begin var tg0 : bits(2) = tg0_in; var tgx : TGx;
if tg0 == '11' then
tg0 = ImpDefBits{2}("TG0 encoded granule size");
end;
case tg0 of
when '00' => tgx = TGx_4KB;
when '01' => tgx = TGx_64KB;
when '10' => tgx = TGx_16KB;
end;
if (tgx) then
case ImpDefBits{2}("TG0 encoded granule size") of
when '00' => tgx = TGx_4KB;
when '01' => tgx = TGx_64KB;
when '10' => tgx = TGx_16KB;
end;
end;
return tgx;
end;
## Library pseudocode for
aarch64/translation/vmsa\_walkparams/AArch64\_S2MinTxSZ
// AArch64_S2MinTxSZ // =================== // Retrieve the minimum value of TxSZ indicating maximum input address size for stage 2
func AArch64_S2MinTxSZ(walkparams : S2TTWParams, s1aarch64 : boolean) => integer begin var ips : integer;
if AArch64_PAMax() == 56 then
if walkparams.d128 == '1' then
ips = 56;
elsif walkparams.tgx == TGx_64KB || walkparams.ds == '1' then
ips = 52;
else
ips = 48;
end;
elsif AArch64_PAMax() == 52 then
if walkparams.tgx == TGx_64KB || walkparams.ds == '1' then
ips = 52;
else
ips = 48;
end;
else
ips = AArch64_PAMax();
end;
var min_txsz : integer = 64 - ips;
if !s1aarch64 then
// EL1 is AArch32
min_txsz = Min(min_txsz, 24);
end;
return min_txsz;
end;
## Library pseudocode for
aarch64/translation/vmsa\_walkparams/AArch64\_SS2TTWParams
// AArch64_SS2TTWParams // ====================== // Gather walk parameters specific for secure stage 2 translation
func AArch64_SS2TTWParams(ipaspace : PASpace, s1aarch64 : boolean) => S2TTWParams begin var walkparams : S2TTWParams;
walkparams.d128 = if IsFeatureImplemented(FEAT_D128) then
VTCR_EL2().D128 else '0';
if ipaspace == PAS_Secure then
walkparams.tgx = AArch64_S2DecodeTG0(VSTCR_EL2().TG0);
walkparams.txsz = VSTCR_EL2().T0SZ;
if walkparams.d128 == '1' then
walkparams.skl = VSTTBR_EL2().SKL;
else
walkparams.sl0 = VSTCR_EL2().SL0;
end;
if walkparams.tgx == TGx_4KB && IsFeatureImplemented(FEAT_LPA2) then
walkparams.sl2 = VSTCR_EL2().SL2 AND VTCR_EL2().DS;
else
walkparams.sl2 = '0';
end;
elsif ipaspace == PAS_NonSecure then
walkparams.tgx = AArch64_S2DecodeTG0(VTCR_EL2().TG0);
walkparams.txsz = VTCR_EL2().T0SZ;
if walkparams.d128 == '1' then
walkparams.skl = VTTBR_EL2().SKL;
else
walkparams.sl0 = VTCR_EL2().SL0;
end;
if walkparams.tgx == TGx_4KB && IsFeatureImplemented(FEAT_LPA2) then
walkparams.sl2 = VTCR_EL2().SL2 AND VTCR_EL2().DS;
else
walkparams.sl2 = '0';
end;
else
unreachable;
end;
walkparams.sw = VSTCR_EL2().SW;
walkparams.nsw = VTCR_EL2().NSW;
walkparams.sa = VSTCR_EL2().SA;
walkparams.nsa = VTCR_EL2().NSA;
if IsFeatureImplemented(FEAT_HCRMAC) then
walkparams.vm = HCR_EL2().VM OR HCR_EL2().DC;
else
walkparams.vm = HCR_EL2().VM;
end;
walkparams.ps = VTCR_EL2().PS;
walkparams.irgn = VTCR_EL2().IRGN0;
walkparams.orgn = VTCR_EL2().ORGN0;
walkparams.sh = VTCR_EL2().SH0;
walkparams.ee = SCTLR_EL2().EE;
if HCR_EL2().TGE == '0' then
walkparams.ptw = if IsFeatureImplemented(FEAT_HCRMAC) then HCR_EL2().PTW else '1';
else
walkparams.ptw = '0';
end;
if IsFeatureImplemented(FEAT_S2FWB) then
walkparams.fwb = if IsFeatureImplemented(FEAT_HCRMAC) then HCR_EL2().FWB else '1';
else
walkparams.fwb = '0';
end;
walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then VTCR_EL2().HA else '0';
if IsFeatureImplemented(FEAT_HAFDBS) && walkparams.ha == '1' then
walkparams.hd = VTCR_EL2().HD;
else
walkparams.hd = '0';
end;
if walkparams.tgx IN {TGx_4KB, TGx_16KB} &&
IsFeatureImplemented(FEAT_LPA2) then
walkparams.ds = VTCR_EL2().DS;
else
walkparams.ds = '0';
end;
walkparams.cmow = (if IsFeatureImplemented(FEAT_CMOW) &&
IsHCRXEL2Enabled() then HCRX_EL2().CMOW
else '0');
if walkparams.d128 == '1' then
walkparams.s2pie = '1';
else
walkparams.s2pie = if IsFeatureImplemented(FEAT_S2PIE) then VTCR_EL2().S2PIE else '0';
end;
if IsFeatureImplemented(FEAT_S2PIE) then
if !(HaveEL(EL3) && SCR_EL3().PIEn == '0' &&
ImpDefBool("SCR_EL3.PIEn forces PIR_ELx or POR_ELx to zero")) then
walkparams.s2pir = S2PIR_EL2() as S2PIRType;
else
walkparams.s2pir = Zeros{64} as S2PIRType;
end;
end;
if IsFeatureImplemented(FEAT_THE) && walkparams.d128 != '1' then
walkparams.assuredonly = VTCR_EL2().AssuredOnly;
else
walkparams.assuredonly = '0';
end;
walkparams.tl0 = if IsFeatureImplemented(FEAT_THE) then VTCR_EL2().TL0 else
'0';
walkparams.tl1 = if IsFeatureImplemented(FEAT_THE) then VTCR_EL2().TL1 else
'0';
if IsFeatureImplemented(FEAT_HAFT) && walkparams.ha == '1' then
walkparams.haft = VTCR_EL2().HAFT;
else
walkparams.haft = '0';
end;
walkparams.emec = '0';
if (IsFeatureImplemented(FEAT_HDBSS) && walkparams.hd == '1'
&&
((EL3) || SCR_EL3().HDBSSEn == '1')) then
walkparams.hdbss = VTCR_EL2().HDBSS;
else
walkparams.hdbss = '0';
end;
return walkparams;
end;
## Library pseudocode for aarch64/translation/vmsa\_walkparams/S2DCacheEnabled
// S2DCacheEnabled // ================= // Returns TRUE if Stage 2 Data access cacheability is enabled
readonly func S2DCacheEnabled() => boolean begin return !IsFeatureImplemented(FEAT_HCRMAC) || HCR_EL2().CD == '0'; end;
## Library pseudocode for aarch64/translation/vmsa\_walkparams/S2ICacheEnabled
// S2ICacheEnabled // ================= // Returns TRUE if Stage 2 Instruction access cacheability is enabled
readonly func S2ICacheEnabled() => boolean begin return !IsFeatureImplemented(FEAT_HCRMAC) || HCR_EL2().ID == '0'; end;
## Library pseudocode for shared/debug/ClearStickyErrors/ClearStickyErrors
// ClearStickyErrors // ===================
func ClearStickyErrors begin EDSCR().TXU = '0'; // Clear TX underrun flag EDSCR().RXO = '0'; // Clear RX overrun flag
if Halted() then // in Debug state
EDSCR().ITO = '0'; // Clear ITR overrun flag
end;
// If halted and the ITR is not empty then it is UNPREDICTABLE whether the
EDSCR.ERR is cleared.
// The UNPREDICTABLE behavior also affects the instructions in flight, but
this is not described
// in the pseudocode.
if (Halted() && EDSCR().ITE == '0' &&
ConstrainUnpredictableBool(Unpredictable_CLEARERRITEZERO)) then
return;
end;
EDSCR().ERR = '0'; // Clear cumulative error flag
return;
end;
## Library pseudocode for shared/debug/DebugTarget/DebugTarget
// DebugTarget // ============= // Returns the debug exception target Exception level
func DebugTarget() => bits(2) begin let ss : SecurityState = CurrentSecurityState(); return DebugTargetFrom(ss); end;
## Library pseudocode for shared/debug/DebugTarget/DebugTargetFrom
// DebugTargetFrom // =================
func DebugTargetFrom(from_state : SecurityState) => bits(2) begin var route_to_el2 : boolean; if HaveEL(EL2) && (from_state != SS_Secure || (IsFeatureImplemented(FEAT_SEL2) && ((EL3) || SCR_EL3().EEL2 == '1'))) then if ELUsingAArch32(EL2) then route_to_el2 = (HDCR().TDE == '1' || HCR().TGE == '1'); else route_to_el2 = (MDCR_EL2().TDE == '1' || HCR_EL2().TGE == '1'); end; else route_to_el2 = FALSE; end;
var target : bits(2);
if route_to_el2 then
target = EL2;
elsif HaveEL(EL3) && () && from_state == SS_Secure then
target = EL3;
else
target = EL1;
end;
return target;
end;
## Library pseudocode for shared/debug/DoubleLockStatus/DoubleLockStatus
// DoubleLockStatus // ================== // Returns the state of the OS Double Lock. // FALSE if OSDLR_EL1.DLK == 0 or DBGPRCR_EL1.CORENPDRQ == 1 or the PE is in Debug state. // TRUE if OSDLR_EL1.DLK == 1 and DBGPRCR_EL1.CORENPDRQ == 0 and the PE is in Non-debug state.
func DoubleLockStatus() => boolean begin if !IsFeatureImplemented(FEAT_DoubleLock) then return FALSE; end; if ELUsingAArch32(EL1) then return DBGOSDLR().DLK == '1' && DBGPRCR().CORENPDRQ == '0' && (); else return OSDLR_EL1().DLK == '1' && DBGPRCR_EL1().CORENPDRQ == '0' && (); end; end;
## Library pseudocode for shared/debug/OSLockStatus/OSLockStatus
// OSLockStatus // ============== // Returns the state of the OS Lock.
readonly func OSLockStatus() => boolean begin return (if ELUsingAArch32(EL1) then DBGOSLSR().OSLK else OSLSR_EL1().OSLK) == '1'; end;
## Library pseudocode for shared/debug/SoftwareLockStatus/Component
// Component // ========= // Component Types.
type Component of enumeration { Component_AMU, Component_ETE, Component_TRBE, Component_RAS, Component_GIC, Component_PMU, Component_Debug, Component_CTI };
## Library pseudocode for shared/debug/SoftwareLockStatus/GetAccessComponent
// GetAccessComponent // ==================== // Determines the component by decoding the physical address in the address descriptor.
impdef func GetAccessComponent(addrdesc : AddressDescriptor) => Component begin return Component_Debug; end;
## Library pseudocode for shared/debug/SoftwareLockStatus/HaveSoftwareLock
// HaveSoftwareLock // ================== // Returns TRUE if Software Lock is implemented.
func HaveSoftwareLock(component : Component) => boolean begin if IsFeatureImplemented(FEAT_Debugv8p4) then return FALSE; end; if IsFeatureImplemented(FEAT_DoPD) && component != Component_CTI then return FALSE; end; case component of when Component_ETE => return ImpDefBool("ETE has Software Lock"); when Component_Debug => return ImpDefBool("Debug has Software Lock"); when Component_PMU => return ImpDefBool("PMU has Software Lock"); when Component_CTI => return ImpDefBool("CTI has Software Lock"); otherwise => unreachable; end; end;
## Library pseudocode for shared/debug/SoftwareLockStatus/SoftwareLockStatus
// SoftwareLockStatus // ==================== // Returns the state of the Software Lock.
func SoftwareLockStatus(addrdesc : AddressDescriptor) => boolean begin let component : Component = GetAccessComponent(addrdesc); if (component) then return FALSE; end; case component of when Component_ETE => return TRCLSR().SLK == '1'; when Component_Debug => return EDLSR().SLK == '1'; when Component_PMU => return PMLSR().SLK == '1'; when Component_CTI => return CTILSR().SLK == '1'; otherwise => return FALSE; end; end;
## Library pseudocode for shared/debug/amu/G1ActivityMonitorImplementedMask
// G1ActivityMonitorImplementedMask // ================================== // Return the implementation-defined G1 activity monitor mask.
func G1ActivityMonitorImplementedMask() => bits(16) begin assert NUM_AMU_CG1_MONITORS <= 16; var mask : bits(16) = Zeros{16};
for i = 0 to (NUM_AMU_CG1_MONITORS-1) do
mask* = if IsG1ActivityMonitorImplemented(i) then '1' else '0';
end;
return mask;
end;
## Library pseudocode for shared/debug/amu/IsG1ActivityMonitorImplemented
// IsG1ActivityMonitorImplemented // ================================ // Returns TRUE if a G1 activity monitor is implemented for the counter // and FALSE otherwise.
impdef func IsG1ActivityMonitorImplemented(i : integer) => boolean begin case i of when 0 => return (ImpDefBool( "G1 activity monitor is implemented for counter 0")); when 1 => return (ImpDefBool( "G1 activity monitor is implemented for counter 1")); when 2 => return (ImpDefBool( "G1 activity monitor is implemented for counter 2")); when 3 => return (ImpDefBool( "G1 activity monitor is implemented for counter 3")); when 4 => return (ImpDefBool( "G1 activity monitor is implemented for counter 4")); when 5 => return (ImpDefBool( "G1 activity monitor is implemented for counter 5")); when 6 => return (ImpDefBool( "G1 activity monitor is implemented for counter 6")); when 7 => return (ImpDefBool( "G1 activity monitor is implemented for counter 7")); when 8 => return (ImpDefBool( "G1 activity monitor is implemented for counter 8")); when 9 => return (ImpDefBool( "G1 activity monitor is implemented for counter 9")); when 10 => return (ImpDefBool( "G1 activity monitor is implemented for counter 10")); when 11 => return (ImpDefBool( "G1 activity monitor is implemented for counter 11")); when 12 => return (ImpDefBool( "G1 activity monitor is implemented for counter 12")); when 13 => return (ImpDefBool( "G1 activity monitor is implemented for counter 13")); when 14 => return (ImpDefBool( "G1 activity monitor is implemented for counter 14")); when 15 => return (ImpDefBool( "G1 activity monitor is implemented for counter 15")); otherwise => return FALSE; end; end;
## Library pseudocode for
shared/debug/amu/IsG1ActivityMonitorOffsetImplemented
// IsG1ActivityMonitorOffsetImplemented // ====================================== // Returns TRUE if a G1 activity monitor offset is implemented for the counter, // and FALSE otherwise.
impdef func IsG1ActivityMonitorOffsetImplemented(i : integer) => boolean begin case i of when 0 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 0")); when 1 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 1")); when 2 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 2")); when 3 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 3")); when 4 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 4")); when 5 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 5")); when 6 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 6")); when 7 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 7")); when 8 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 8")); when 9 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 9")); when 10 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 10")); when 11 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 11")); when 12 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 12")); when 13 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 13")); when 14 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 14")); when 15 => return (ImpDefBool( "G1 activity monitor offset is implemented for counter 15")); otherwise => return FALSE; end; end;
## Library pseudocode for shared/debug/amu/Write\_AMCNTENCLR0
// Write_AMCNTENCLR0 // =================== // System register write to AMCNTENCLR0.
func Write_AMCNTENCLR0(value_in : bits(32)) begin AMCNTENCLR0().P = AMCNTENCLR0().P AND NOT value_in[0 +: NUM_AMU_CG0_MONITORS]; end;
## Library pseudocode for shared/debug/amu/Write\_AMCNTENCLR0\_EL0
// Write_AMCNTENCLR0_EL0 // ======================= // System register write to AMCNTENCLR0_EL0.
func Write_AMCNTENCLR0_EL0(value_in : bits(64)) begin AMCNTENCLR0_EL0().P = AMCNTENCLR0_EL0().P AND NOT value_in[0 +: NUM_AMU_CG0_MONITORS]; end;
## Library pseudocode for shared/debug/amu/Write\_AMCNTENCLR1
// Write_AMCNTENCLR1 // =================== // System register write to AMCNTENCLR1.
func Write_AMCNTENCLR1(value_in : bits(32)) begin assert NUM_AMU_CG1_MONITORS <= 16; let implemented : bits(16) = G1ActivityMonitorImplementedMask();
AMCNTENCLR1().P = (AMCNTENCLR1().P AND NOT
(ZeroExtend{16}(value_in[0 +: NUM_AMU_CG1_MONITORS]) AND implemented));
end;
## Library pseudocode for shared/debug/amu/Write\_AMCNTENCLR1\_EL0
// Write_AMCNTENCLR1_EL0 // ======================= // System register write to AMCNTENCLR1_EL0.
func Write_AMCNTENCLR1_EL0(value_in : bits(64)) begin assert NUM_AMU_CG1_MONITORS <= 16; let implemented : bits(16) = G1ActivityMonitorImplementedMask();
AMCNTENCLR1_EL0().P = (AMCNTENCLR1_EL0().P AND NOT
(ZeroExtend{16}(value_in[0 +: NUM_AMU_CG1_MONITORS]) AND implemented));
end;
## Library pseudocode for shared/debug/amu/Write\_AMCNTENSET0
// Write_AMCNTENSET0 // =================== // System register write to AMCNTENSET0.
func Write_AMCNTENSET0(value_in : bits(32)) begin AMCNTENSET0().P = AMCNTENSET0().P OR value_in[0 +: NUM_AMU_CG0_MONITORS]; end;
## Library pseudocode for shared/debug/amu/Write\_AMCNTENSET0\_EL0
// Write_AMCNTENSET0_EL0 // ======================= // System register write to AMCNTENSET0_EL0.
func Write_AMCNTENSET0_EL0(value_in : bits(64)) begin AMCNTENSET0_EL0().P = AMCNTENSET0_EL0().P OR value_in[0 +: NUM_AMU_CG0_MONITORS]; end;
## Library pseudocode for shared/debug/amu/Write\_AMCNTENSET1
// Write_AMCNTENSET1 // =================== // System register write to AMCNTENSET1.
func Write_AMCNTENSET1(value_in : bits(32)) begin assert NUM_AMU_CG1_MONITORS <= 16; let implemented : bits(16) = G1ActivityMonitorImplementedMask();
AMCNTENSET1().P = (AMCNTENSET1().P OR
(ZeroExtend{16}(value_in[0 +: NUM_AMU_CG1_MONITORS]) AND implemented));
end;
## Library pseudocode for shared/debug/amu/Write\_AMCNTENSET1\_EL0
// Write_AMCNTENSET1_EL0 // ======================= // System register write to AMCNTENSET1_EL0.
func Write_AMCNTENSET1_EL0(value_in : bits(64)) begin assert NUM_AMU_CG1_MONITORS <= 16; let implemented : bits(16) = G1ActivityMonitorImplementedMask();
AMCNTENSET1_EL0().P = (AMCNTENSET1_EL0().P OR
(ZeroExtend{16}(value_in[0 +: NUM_AMU_CG1_MONITORS]) AND implemented));
end;
## Library pseudocode for shared/debug/authentication/AllowExternalDebugAccess
// AllowExternalDebugAccess // ========================== // Returns TRUE if an external debug interface access to the External DBGBVR_EL1, // DBGBCR_EL1, DBGWVR_EL1, DBGWCR_EL1 registers, and, from Armv8.2, the // OSLAR_EL1 register is allowed for the access. Returns FALSE otherwise.
func AllowExternalDebugAccess(addrdesc : AddressDescriptor) => boolean begin // The access may also be subject to OS Lock, power-down, etc. if IsFeatureImplemented(FEAT_RME) then case MDCR_EL3().[EDADE,EDAD] of when '00' => return TRUE; when '01' => return addrdesc.paddress.paspace IN {PAS_Root, PAS_Secure}; when '10' => return addrdesc.paddress.paspace IN {PAS_Root, PAS_Realm}; when '11' => return addrdesc.paddress.paspace == PAS_Root; end; end;
if IsFeatureImplemented(FEAT_Debugv8p4) then
if addrdesc.paddress.paspace == PAS_Secure then return TRUE; end;
else
if () then return FALSE; end;
if ExternalSecureInvasiveDebugEnabled() then return TRUE; end;
end;
if HaveEL(EL3) then
let EDAD_bit : bit = if ELUsingAArch32(EL3) then SDCR().EDAD else MDCR_EL3().EDAD;
return EDAD_bit == '0';
else
return NonSecureOnlyImplementation();
end;
end;
## Library pseudocode for shared/debug/authentication/AllowExternalPMSSAccess
// AllowExternalPMSSAccess // ========================= // Returns TRUE if an external debug interface access to the PMU Snapshot // registers is allowed for the given Security state, FALSE otherwise.
func AllowExternalPMSSAccess(addrdesc : AddressDescriptor) => boolean begin assert IsFeatureImplemented(FEAT_PMUv3_SS) && HaveAArch64(); // FEAT_Debugv8p4 is always implemented when FEAT_PMUv3_SS is implemented. assert IsFeatureImplemented(FEAT_Debugv8p4);
// The access may also be subject to the OS Double Lock,
power-down, etc.
var epmssad : bits(2) = if HaveEL(EL3) then MDCR_EL3().EPMSSAD else '11';
// Check for reserved values
if !IsFeatureImplemented(FEAT_RME) && epmssad IN {'01','10'} then
(-, epmssad) = ConstrainUnpredictableBits{2}(Unpredictable_RESEPMSSAD);
// The value returned by ConstrainUnpredictableBits() must be a
// non-reserved value
assert epmssad IN {'00','11'};
end;
case epmssad of
when '00' =>
if IsFeatureImplemented(FEAT_RME) then
return addrdesc.paddress.paspace == PAS_Root;
else
return addrdesc.paddress.paspace == PAS_Secure;
end;
when '01' =>
assert IsFeatureImplemented(FEAT_RME);
return addrdesc.paddress.paspace IN {PAS_Root, PAS_Realm};
when '10' =>
assert IsFeatureImplemented(FEAT_RME);
return addrdesc.paddress.paspace IN {PAS_Root, PAS_Secure};
when '11' =>
return TRUE;
end;
end;
## Library pseudocode for shared/debug/authentication/AllowExternalPMUAccess
// AllowExternalPMUAccess // ======================== // Returns TRUE if an external debug interface access to the PMU registers is // allowed for the given Security state, FALSE otherwise.
func AllowExternalPMUAccess(addrdesc : AddressDescriptor) => boolean begin // The access may also be subject to OS Lock, power-down, etc. if IsFeatureImplemented(FEAT_RME) then case MDCR_EL3().[EPMADE,EPMAD] of when '00' => return TRUE; when '01' => return addrdesc.paddress.paspace IN {PAS_Root, PAS_Secure}; when '10' => return addrdesc.paddress.paspace IN {PAS_Root, PAS_Realm}; when '11' => return addrdesc.paddress.paspace == PAS_Root; end; end;
if IsFeatureImplemented(FEAT_Debugv8p4) then
if addrdesc.paddress.paspace == PAS_Secure then return TRUE; end;
else
if () then return FALSE; end;
if ExternalSecureInvasiveDebugEnabled() then return TRUE; end;
end;
if HaveEL(EL3) then
let EPMAD_bit : bit = if ELUsingAArch32(EL3) then SDCR().EPMAD else MDCR_EL3().EPMAD;
return EPMAD_bit == '0';
else
return NonSecureOnlyImplementation();
end;
end;
## Library pseudocode for shared/debug/authentication/AllowExternalTraceAccess
// AllowExternalTraceAccess // ========================== // Returns TRUE if an external Trace access to the Trace registers is allowed for the // given PAS, FALSE otherwise.
func AllowExternalTraceAccess(addrdesc : AddressDescriptor) => boolean begin // The access may also be subject to OS lock, power-down, etc. if !IsFeatureImplemented(FEAT_TRBE) then return TRUE; end; assert IsFeatureImplemented(FEAT_Debugv8p4); if IsFeatureImplemented(FEAT_RME) then case MDCR_EL3().[ETADE,ETAD] of when '00' => return TRUE; when '01' => return addrdesc.paddress.paspace IN {PAS_Root, PAS_Secure}; when '10' => return addrdesc.paddress.paspace IN {PAS_Root, PAS_Realm}; when '11' => return addrdesc.paddress.paspace == PAS_Root; end; end;
if addrdesc.paddress.paspace == PAS_Secure then return TRUE; end;
if HaveEL(EL3) then
// External Trace access is not supported for EL3 using AArch32
assert (EL3);
return MDCR_EL3().ETAD == '0';
else
return NonSecureOnlyImplementation();
end;
end;
## Library pseudocode for
shared/debug/authentication/AllowRASMemoryMappedAccess
// AllowRASMemoryMappedAccess // ============================ // Returns TRUE if read and/or write access to RAS memory-mapped registers is // permitted for the given access.
func AllowRASMemoryMappedAccess(addrdesc : AddressDescriptor, iswrite : boolean) => boolean begin // An access from the most secure implemented PAS is always permitted. if IsMostSecureAccess(addrdesc) then return TRUE; end;
if IsFeatureImplemented(FEAT_RASSA_ACR) &&
IsFeatureImplemented(FEAT_RASSAv2) then
var ra : bits(2);
let implements_rl_and_s : boolean = (IsFeatureImplemented(FEAT_RME) &&
ImpDefBool(
"the error record group allows configuration of Secure and Realm register accesses"));
if IsAccessRealm(addrdesc) then
ra = if implements_rl_and_s then ERRACR().RLRA else ERRACR().NSRA;
elsif IsAccessSecure(addrdesc) then
ra = if implements_rl_and_s then ERRACR().SRA else ERRACR().NSRA;
elsif IsAccessNonSecure(addrdesc) then
ra = ERRACR().NSRA;
else
unreachable;
end;
// '10' is reserved
if ra == '10' then (-, ra) = ConstrainUnpredictableBits{2}(Unpredictable_RES_RA); end;
// Interpret configured permissions to a boolean for the requested access
case ra of
when '00' => return FALSE; // RAZ/WI => no read or write
when '01' => return !iswrite; // RO => reads allowed, writes not
when '11' => return TRUE; // RW => both allowed
otherwise => unreachable;
end;
end;
return ImpDefBool("error records are accessible to all PAS");
end;
## Library pseudocode for shared/debug/authentication/Debug
// Debug authentication signals // ============================
var DBGEN : Signal; var NIDEN : Signal; var SPIDEN : Signal; var SPNIDEN : Signal; var RLPIDEN : Signal; var RTPIDEN : Signal;
## Library pseudocode for
shared/debug/authentication/ExternalInvasiveDebugEnabled
// ExternalInvasiveDebugEnabled // ============================== // The definition of this function is IMPLEMENTATION DEFINED. // In the recommended interface, this function returns the state of the DBGEN signal.
readonly func ExternalInvasiveDebugEnabled() => boolean begin return DBGEN == HIGH; end;
## Library pseudocode for
shared/debug/authentication/ExternalNoninvasiveDebugAllowed
// ExternalNoninvasiveDebugAllowed // ================================= // Returns TRUE if Trace and PC Sample-based Profiling are allowed
func ExternalNoninvasiveDebugAllowed() => boolean begin return ExternalNoninvasiveDebugAllowed(PSTATE.EL); end;
// ExternalNoninvasiveDebugAllowed // =================================
func ExternalNoninvasiveDebugAllowed(el : bits(2)) => boolean begin if () then return FALSE; end; let ss : SecurityState = SecurityStateAtEL(el);
if ((ELUsingAArch32(EL3) || ELUsingAArch32(EL1)) && el ==
EL0 &&
ss == SS_Secure && SDER().SUNIDEN == '1') then
return TRUE;
end;
case ss of
when SS_NonSecure => return TRUE;
when SS_Secure => return ExternalSecureNoninvasiveDebugEnabled();
when SS_Realm => return ExternalRealmNoninvasiveDebugEnabled();
when SS_Root => return ExternalRootNoninvasiveDebugEnabled();
end;
end;
## Library pseudocode for
shared/debug/authentication/ExternalNoninvasiveDebugEnabled
// ExternalNoninvasiveDebugEnabled // ================================= // This function returns TRUE if the FEAT_Debugv8p4 is implemented. // Otherwise, this function is IMPLEMENTATION DEFINED, and, in the // recommended interface, ExternalNoninvasiveDebugEnabled returns // the state of the (DBGEN OR NIDEN) signal.
readonly func ExternalNoninvasiveDebugEnabled() => boolean begin return (IsFeatureImplemented(FEAT_Debugv8p4) || ExternalInvasiveDebugEnabled() || NIDEN == HIGH); end;
## Library pseudocode for
shared/debug/authentication/ExternalRealmInvasiveDebugEnabled
// ExternalRealmInvasiveDebugEnabled // =================================== // The definition of this function is IMPLEMENTATION DEFINED. // In the recommended interface, this function returns the state of the // (DBGEN AND RLPIDEN) signal.
readonly func ExternalRealmInvasiveDebugEnabled() => boolean begin if !IsFeatureImplemented(FEAT_RME) then return FALSE; end; return ExternalInvasiveDebugEnabled() && RLPIDEN == HIGH; end;
## Library pseudocode for
shared/debug/authentication/ExternalRealmNoninvasiveDebugEnabled
// ExternalRealmNoninvasiveDebugEnabled // ====================================== // The definition of this function is IMPLEMENTATION DEFINED. // In the recommended interface, this function returns the state of the // (DBGEN AND RLPIDEN) signal.
readonly func ExternalRealmNoninvasiveDebugEnabled() => boolean begin if !IsFeatureImplemented(FEAT_RME) then return FALSE; end; return ExternalRealmInvasiveDebugEnabled(); end;
## Library pseudocode for
shared/debug/authentication/ExternalRootInvasiveDebugEnabled
// ExternalRootInvasiveDebugEnabled // ================================== // The definition of this function is IMPLEMENTATION DEFINED. // In the recommended interface, this function returns the state of the // (DBGEN AND RLPIDEN AND RTPIDEN AND SPIDEN) signal when FEAT_SEL2 is implemented // and the (DBGEN AND RLPIDEN AND RTPIDEN) signal when FEAT_SEL2 is not implemented.
readonly func ExternalRootInvasiveDebugEnabled() => boolean begin if !IsFeatureImplemented(FEAT_RME) then return FALSE; end; return (ExternalInvasiveDebugEnabled() && (!IsFeatureImplemented(FEAT_SEL2) || ExternalSecureInvasiveDebugEnabled()) && ExternalRealmInvasiveDebugEnabled() && RTPIDEN == HIGH); end;
## Library pseudocode for
shared/debug/authentication/ExternalRootNoninvasiveDebugEnabled
// ExternalRootNoninvasiveDebugEnabled // ===================================== // The definition of this function is IMPLEMENTATION DEFINED. // In the recommended interface, this function returns the state of the // (DBGEN AND RLPIDEN AND SPIDEN AND RTPIDEN) signal.
func ExternalRootNoninvasiveDebugEnabled() => boolean begin if !IsFeatureImplemented(FEAT_RME) then return FALSE; end; return ExternalRootInvasiveDebugEnabled(); end;
## Library pseudocode for
shared/debug/authentication/ExternalSecureInvasiveDebugEnabled
// ExternalSecureInvasiveDebugEnabled // ==================================== // The definition of this function is IMPLEMENTATION DEFINED. // In the recommended interface, this function returns the state of the (DBGEN AND SPIDEN) signal. // CoreSight allows asserting SPIDEN without also asserting DBGEN, but this is not recommended.
readonly func ExternalSecureInvasiveDebugEnabled() => boolean begin if () then return IsFeatureImplemented(FEAT_RME) && RTPIDEN == HIGH; end; return ExternalInvasiveDebugEnabled() && SPIDEN == HIGH; end;
## Library pseudocode for
shared/debug/authentication/ExternalSecureNoninvasiveDebugEnabled
// ExternalSecureNoninvasiveDebugEnabled // ======================================= // This function returns the value of ExternalSecureInvasiveDebugEnabled() when FEAT_Debugv8p4 // is implemented. Otherwise, the definition of this function is IMPLEMENTATION DEFINED. // In the recommended interface, this function returns the state of the (DBGEN OR NIDEN) AND // (SPIDEN OR SPNIDEN) signal.
readonly func ExternalSecureNoninvasiveDebugEnabled() => boolean begin if () then return FALSE; end; if !IsFeatureImplemented(FEAT_Debugv8p4) then return (ExternalNoninvasiveDebugEnabled() && (SPIDEN == HIGH || SPNIDEN == HIGH)); else return ExternalSecureInvasiveDebugEnabled(); end; end;
## Library pseudocode for
shared/debug/authentication/InvasiveDebugPermittedPAS
// InvasiveDebugPermittedPAS // =========================== // Returns TRUE if the invasive debug of the configured PASpace is permitted by // the authentication interface, and FALSE otherwise.
readonly func InvasiveDebugPermittedPAS(pas : PASpace) => boolean begin case pas of when PAS_Secure => return ExternalSecureInvasiveDebugEnabled(); when PAS_NonSecure => return ExternalInvasiveDebugEnabled(); when PAS_Root => return ExternalRootInvasiveDebugEnabled(); when PAS_Realm => return ExternalRealmInvasiveDebugEnabled(); otherwise => return FALSE; end; end;
## Library pseudocode for shared/debug/authentication/IsAccessNonSecure
// IsAccessNonSecure // =================== // Returns TRUE when an access is Non-Secure
func IsAccessNonSecure(addrdesc : AddressDescriptor) => boolean begin return addrdesc.paddress.paspace == PAS_NonSecure; end;
## Library pseudocode for shared/debug/authentication/IsAccessRealm
// IsAccessRealm // =============== // Returns TRUE when an access is Realm
func IsAccessRealm(addrdesc : AddressDescriptor) => boolean begin return addrdesc.paddress.paspace == PAS_Realm; end;
## Library pseudocode for shared/debug/authentication/IsAccessRoot
// IsAccessRoot // ============== // Returns TRUE when an access is Root
func IsAccessRoot(addrdesc : AddressDescriptor) => boolean begin return addrdesc.paddress.paspace == PAS_Root; end;
## Library pseudocode for shared/debug/authentication/IsAccessSecure
// IsAccessSecure // ================ // Returns TRUE when an access is Secure
func IsAccessSecure(addrdesc : AddressDescriptor) => boolean begin return addrdesc.paddress.paspace == PAS_Secure; end;
## Library pseudocode for shared/debug/authentication/IsCorePowered
// IsCorePowered // =============== // Returns TRUE if the Core power domain is powered on, FALSE otherwise.
impdef func IsCorePowered() => boolean begin return TRUE; end;
## Library pseudocode for shared/debug/authentication/IsMostSecureAccess
// IsMostSecureAccess // ==================== // Returns TRUE if the security state of an access is the most secure PAS.
func IsMostSecureAccess(addrdesc : AddressDescriptor) => boolean begin if IsFeatureImplemented(FEAT_RME) then return addrdesc.paddress.paspace == PAS_Root; elsif HaveEL(EL3) || SecureOnlyImplementation() then return addrdesc.paddress.paspace == PAS_Secure; else assert addrdesc.paddress.paspace == PAS_NonSecure; return TRUE; end; end;
## Library pseudocode for shared/debug/authentication/IsPASValid
// IsPASValid // ============ // Returns TRUE if the given value of 'pas' is not reserved, and FALSE otherwise.
func IsPASValid(pas : bits(2)) => boolean begin case pas of when '00' => return IsFeatureImplemented(FEAT_Secure); when '01' => return TRUE; when '10' => return IsFeatureImplemented(FEAT_RME); when '11' => return IsFeatureImplemented(FEAT_RME); end; end;
## Library pseudocode for shared/debug/breakpoint/BreakpointInfo
// BreakpointInfo // ============== // Breakpoint related fields.
type BreakpointInfo of record { bptype : BreakpointType, // Type of breakpoint matched match : boolean, // breakpoint match mismatch : boolean // breakpoint mismatch };
## Library pseudocode for shared/debug/breakpoint/BreakpointType
// BreakpointType // ==============
type BreakpointType of enumeration { BreakpointType_Inactive, // Breakpoint inactive or disabled BreakpointType_AddrMatch, // Address Match breakpoint BreakpointType_AddrMismatch, // Address Mismatch breakpoint BreakpointType_CtxtMatch }; // Context matching breakpoint
## Library pseudocode for shared/debug/breakpoint/CheckValidStateMatch
// CheckValidStateMatch // ====================== // Checks for an invalid state match that will generate Constrained // Unpredictable behavior, otherwise returns Constraint_NONE.
func CheckValidStateMatch(ssc : bits(2), ssce : bit, hmc : bit, pxc : bits(2), isbreakpnt : boolean) => (Constraint, bits(2), bit, bit, bits(2)) begin if !IsFeatureImplemented(FEAT_RME) then assert ssce == '0'; end; var reserved : boolean = FALSE;
// Values that are not allocated in any architecture version
case hmc::ssce::ssc::pxc of
when '0 0 11 10' => reserved = TRUE;
when '0 1 01 00' => reserved = TRUE;
when '1 0 00 x0' => reserved = TRUE;
when '1 0 01 10' => reserved = TRUE;
when '1 0 1x 10' => reserved = TRUE;
when '1 1 01 10' => reserved = TRUE;
when 'x 1 x0 xx' => reserved = TRUE;
when 'x 1 11 xx' => reserved = TRUE;
otherwise => reserved = FALSE;
end;
// Reserved when any combination has HMC = 0, SSCE = 0, and SSC = 0b10.
if !IsFeatureImplemented(FEAT_Secure) && hmc::ssce::ssc == '0 0 10'
then
reserved = TRUE;
end;
// Reserved when any combination has HMC = 0 and SSC = 0b01,
// and when HMC = 1, SSC = 0b10, and PxC = 0b00.
if (!IsFeatureImplemented(FEAT_RME) &&
!IsFeatureImplemented(FEAT_Secure) &&
(hmc::ssc == '0 01' || hmc::ssc::pxc == '1 10 00')) then
reserved = TRUE;
end;
// Reserved when SSC is either 0b01 or 0b10, when EL3 is not implemented and
// EL2 is implemented.
if (EL3) && HaveEL(EL2) && ssc IN {'01','10'} then
reserved = TRUE;
end;
// Reserved when either HMC = 1 or SSC is not 0b00, when both EL3 and
// EL2 are not implemented.
if (EL3) && (EL2) && (hmc == '1' || ssc != '00') then
reserved = TRUE;
end;
// Reserved when HMC = 1, SSC = 0b11, and PxC = 0b00, when EL2 is not
implemented.
if (EL2) && hmc::ssc::pxc == '1 11 00' then
reserved = TRUE;
end;
// Reserved when SSC = 0b11, except when HMC = 1, SSCE = 0, SSC = 0b11, and
PxC = 0b00, when
// Secure EL2 is not implemented.
if (!IsFeatureImplemented(FEAT_SEL2) && ssc == '11' &&
hmc::ssce::ssc::pxc != '1 0 11 00') then
reserved = TRUE;
end;
// Reserved when HMC = 1, SSCE = 0, SSC = 0b01 and PxC = 0b00, when EL3 is not
implemented OR
// Secure EL2 is not implemented.
if (((EL3) || !IsFeatureImplemented(FEAT_SEL2)) &&
hmc::ssce::ssc::pxc == '1 0 01 00') then
reserved = TRUE;
end;
// Reserved when HMC = 1, SSC = 0b10, and PxC = 0b00, when AArch64 is not
implemented.
if () && hmc::ssc::pxc == '1 10 00' then
reserved = TRUE;
end;
// 'Usr/Sys/Svc' encoding is valid only for AArch32 EL1 breakpoints.
// Otherwise reserved.
if ((EL1) || !isbreakpnt) && hmc::pxc == '000' && ssc != '11'
then
reserved = TRUE;
end;
if reserved then
// If parameters are set to a reserved type, behaves as either disabled or a defined type
var c : Constraint;
var unpred_state_bits : bits(6);
var unpred_hmc : bit;
var unpred_ssc : bits(2);
var unpred_ssce : bit;
var unpred_pxc : bits(2);
(c, unpred_state_bits) = ConstrainUnpredictableBits{6}(Unpredictable_RESBPWPCTRL);
assert c IN {Constraint_DISABLED, Constraint_UNKNOWN};
if c == Constraint_DISABLED then
unpred_hmc = ARBITRARY : bit;
unpred_ssc = ARBITRARY : bits(2);
unpred_ssce = ARBITRARY : bit;
unpred_pxc = ARBITRARY : bits(2);
return (c, unpred_ssc, unpred_ssce, unpred_hmc, unpred_pxc);
else
unpred_hmc = unpred_state_bits[5];
unpred_ssc = unpred_state_bits[4:3];
unpred_ssce = unpred_state_bits[2];
unpred_pxc = unpred_state_bits[1:0];
return (Constraint_NONE, unpred_ssc, unpred_ssce, unpred_hmc, unpred_pxc);
end;
end;
return (Constraint_NONE, ssc, ssce, hmc, pxc);
end;
## Library pseudocode for shared/debug/breakpoint/ContextAwareBreakpointRange
// ContextAwareBreakpointRange // ============================= // Returns two numbers indicating the index of the first and last context-aware breakpoint.
func ContextAwareBreakpointRange() => (integer, integer) begin let b : integer = NumBreakpointsImplemented(); let c : integer = NumContextAwareBreakpointsImplemented();
if b <= 16 then
return (b - c, b - 1);
elsif c <= 16 then
return (16 - c, 15);
else
return (0, c - 1);
end;
end;
## Library pseudocode for shared/debug/breakpoint/IsContextAwareBreakpoint
// IsContextAwareBreakpoint // ========================== // Returns TRUE if DBGBCR_EL1[n] is a context-aware breakpoint.
func IsContextAwareBreakpoint(n : integer) => boolean begin let (lower, upper) : (integer, integer) = ContextAwareBreakpointRange(); return n >= lower && n <= upper; end;
## Library pseudocode for shared/debug/breakpoint/NumBreakpointsImplemented
// NumBreakpointsImplemented // =========================== // Returns the number of breakpoints implemented.
readonly func NumBreakpointsImplemented() => integer begin return ImpDefInt("Number of breakpoints"); end;
## Library pseudocode for
shared/debug/breakpoint/NumContextAwareBreakpointsImplemented
// NumContextAwareBreakpointsImplemented // ======================================= // Returns the number of context-aware breakpoints implemented.
readonly func NumContextAwareBreakpointsImplemented() => integer begin return ImpDefInt("Number of context-aware breakpoints"); end;
## Library pseudocode for shared/debug/breakpoint/NumWatchpointsImplemented
// NumWatchpointsImplemented // =========================== // Returns the number of watchpoints implemented.
readonly func NumWatchpointsImplemented() => integer begin return ImpDefInt("Number of watchpoints"); end;
## Library pseudocode for shared/debug/claim
var DBGClaimTags : bits(8);
## Library pseudocode for shared/debug/claim/Write\_DBGCLAIMCLR
// Write_DBGCLAIMCLR // =================== // System register write to DBGCLAIMCLR.
func Write_DBGCLAIMCLR(value_in : bits(32)) begin DBGClaimTags = DBGClaimTags AND NOT value_in[7:0]; end;
## Library pseudocode for shared/debug/claim/Write\_DBGCLAIMCLR\_EL1
// Write_DBGCLAIMCLR_EL1 // ======================= // System register write to DBGCLAIMCLR_EL1.
func Write_DBGCLAIMCLR_EL1(value_in : bits(64)) begin DBGClaimTags = DBGClaimTags AND NOT value_in[7:0]; end;
## Library pseudocode for shared/debug/claim/Write\_DBGCLAIMSET
// Write_DBGCLAIMSET // =================== // System register write to DBGCLAIMSET.
func Write_DBGCLAIMSET(value_in : bits(32)) begin DBGClaimTags = DBGClaimTags OR value_in[7:0]; end;
## Library pseudocode for shared/debug/claim/Write\_DBGCLAIMSET\_EL1
// Write_DBGCLAIMSET_EL1 // ======================= // System register write to DBGCLAIMSET_EL1.
func Write_DBGCLAIMSET_EL1(value_in : bits(64)) begin DBGClaimTags = DBGClaimTags OR value_in[7:0]; end;
## Library pseudocode for shared/debug/cti/CTI\_ProcessEvent
// CTI_ProcessEvent // ================== // Process a discrete event on a Cross Trigger output event trigger.
impdef func CTI_ProcessEvent(id : CrossTriggerOut) begin return; end;
## Library pseudocode for shared/debug/cti/CTI\_SetEventLevel
// CTI_SetEventLevel // =================== // Set a Cross Trigger multi-cycle input event trigger to the specified level.
impdef func CTI_SetEventLevel(id : CrossTriggerIn, level : Signal) begin return; end;
## Library pseudocode for shared/debug/cti/CTI\_SignalEvent
// CTI_SignalEvent // ================= // Signal a discrete event on a Cross Trigger input event trigger.
impdef func CTI_SignalEvent(id : CrossTriggerIn) begin return; end;
## Library pseudocode for shared/debug/cti/CrossTrigger
// CrossTrigger // ============
type CrossTriggerOut of enumeration {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ, CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0, CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2, CrossTriggerOut_TraceExtIn3};
type CrossTriggerIn of enumeration {CrossTriggerIn_CrossHalt, CrossTriggerIn_PMUOverflow, CrossTriggerIn_SPESample, CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0, CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2, CrossTriggerIn_TraceExtOut3, CrossTriggerIn_TRBEStop, CrossTriggerIn_TRBEMgmt, CrossTriggerIn_TRBEWrap};
var CTIClaimTags : bits(32);
## Library pseudocode for shared/debug/dccanditr/CheckForDCCInterrupts
// CheckForDCCInterrupts // =======================
func CheckForDCCInterrupts begin let commrx : boolean = (EDSCR().RXfull == '1'); let commtx : boolean = (EDSCR().TXfull == '0');
// COMMRX and COMMTX support is optional and not recommended for
new designs.
// SetInterruptRequestLevel(InterruptID_COMMRX, if commrx then HIGH else LOW);
// SetInterruptRequestLevel(InterruptID_COMMTX, if commtx then HIGH else LOW);
// The value to be driven onto the common COMMIRQ signal.
var commirq : boolean;
if ELUsingAArch32(EL1) then
commirq = ((commrx && DBGDCCINT().RX == '1') ||
(commtx && DBGDCCINT().TX == '1'));
else
commirq = ((commrx && MDCCINT_EL1().RX == '1') ||
(commtx && MDCCINT_EL1().TX == '1'));
end;
SetInterruptRequestLevel(InterruptID_COMMIRQ, if commirq then HIGH else LOW);
return;
end;
## Library pseudocode for shared/debug/dccanditr/DTR
// DTR // ===
var DTRRX : bits(32); var DTRTX : bits(32);
## Library pseudocode for shared/debug/dccanditr/Read\_DBGDTRRX\_EL0
// Read_DBGDTRRX_EL0 // =================== // Called on reads of debug register 0x080.
func Read_DBGDTRRX_EL0(memory_mapped : boolean) => bits(32) begin return DTRRX; end;
## Library pseudocode for shared/debug/dccanditr/Read\_DBGDTRTX\_EL0
// Read_DBGDTRTX_EL0 // =================== // Called on reads of debug register 0x08C.
func Read_DBGDTRTX_EL0(memory_mapped : boolean) => bits(32) begin let underrun : boolean = (EDSCR().TXfull == '0' || (Halted() && EDSCR().MA == '1' && EDSCR().ITE == '0')); let value : bits(32) = if underrun then ARBITRARY : bits(32) else DTRTX;
if EDSCR().ERR == '1' then return value; end; // Error flag set: no
side-effects
if underrun then
EDSCR().TXU = '1'; EDSCR().ERR = '1'; // Underrun condition: block side-effects
return value; // Return UNKNOWN
end;
EDSCR().TXfull = '0';
if Halted() && EDSCR().MA == '1' then
EDSCR().ITE = '0'; // See comments in Write_EDITR
if () then
ExecuteA64(0xB8404401[31:0]); // A64 "LDR W1,[X0],#4"
else
ExecuteT32(0xF850[15:0] /*hw1*/, 0x1B04[15:0] /*hw2*/); // T32 "LDR R1,[R0],#4"
end;
// If the load aborts, the Data Abort exception is taken and EDSCR.ERR is set to 1
if EDSCR().ERR == '1' then
EDSCR().TXfull = ARBITRARY : bit;
DBGDTRTX_EL0() = ARBITRARY : bits(64);
else
if () then
ExecuteA64(0xD5130501[31:0]); // A64 "MSR DBGDTRTX_EL0,X1"
else
ExecuteT32(0xEE00[15:0] /*hw1*/, 0x1E15[15:0] /*hw2*/); // T32 "MSR DBGDTRTXint,R1"
end;
// "MSR DBGDTRTX_EL0,X1" calls Write_DBGDTR_EL0() which sets TXfull.
assert EDSCR().TXfull == '1';
end;
if () then
X{64}(1) = ARBITRARY : bits(64);
else
R(1) = ARBITRARY : bits(32);
end;
EDSCR().ITE = '1'; // See comments in Write_EDITR
end;
return value;
end;
## Library pseudocode for shared/debug/dccanditr/Read\_DBGDTR\_EL0
// Read_DBGDTR_EL0 // ================= // System register reads of DBGDTR_EL0, DBGDTRRX_EL0 (AArch64) and DBGDTRRXint (AArch32)
func Read_DBGDTR_EL0{N}() => bits(N) begin // For MRS ,DBGDTRTX_EL0 N=32, X[t]=Zeros(32):result // For MRS ,DBGDTR_EL0 N=64, X[t]=result assert N IN {32,64}; var result : bits(N); if EDSCR().RXfull == '0' then result = ARBITRARY : bits(N); else // On a 64-bit read, implement a half-duplex channel // NOTE: the word order is reversed on reads with regards to writes if N == 64 then result[63:32] = DTRTX; end; result[31:0] = DTRRX; end; EDSCR().RXfull = '0'; return result; end;
## Library pseudocode for shared/debug/dccanditr/Write\_DBGDTRRX\_EL0
// Write_DBGDTRRX_EL0 // ==================== // Called on writes to debug register 0x080.
func Write_DBGDTRRX_EL0(memory_mapped : boolean, value : bits(32))
------------------------------------------------------------------------------ Page 1 of 1. End of thread.