This forum was built by humans, for humans. AI was used exclusively for security auditing. The forum officially launched on November 24, 2026. Read more

romdump.net
romdump.net › Forum › Silicon & Architectures › Shared pseudocode: part 32 of 36

Writeup Shared pseudocode: part 32 of 36

started by admin

admin admin admingod mode Posts 116
Rep 505
Joined Nov 2026
2d ago OP #144

Shared pseudocode from the offline Arm documentation snapshot. Part 32 of 36.

Library pseudocode for shared/functions/registers/BranchType

// BranchType
// ==========
// Information associated with a change in control flow.

type BranchType of enumeration { BranchType_DIRCALL, // Direct Branch with link BranchType_INDCALL, // Indirect Branch with link BranchType_ERET, // Exception return (indirect) BranchType_DBGEXIT, // Exit from Debug state BranchType_RET, // Indirect branch with function return hint BranchType_DIR, // Direct branch BranchType_INDIR, // Indirect branch BranchType_EXCEPTION, // Exception entry BranchType_RESET, // Reset BranchType_UNKNOWN}; // Other

Library pseudocode for shared/functions/registers/Branchtypetaken

// Branchtypetaken// ===============var Branchtypetaken : BranchType;

Library pseudocode for shared/functions/registers/ESize

// ESize
// =====

type ESize of integer{8, 16, 32, 64, 128};

Library pseudocode for shared/functions/registers/EffectiveFPCR

// EffectiveFPCR
// ===============
// Returns the effective FPCR value

func EffectiveFPCR() => FPCR_Type begin if UsingAArch32() then var fpcr : FPCR_Type = ZeroExtend{64}(FPSCR()); fpcr[7:0] = '00000000'; fpcr[31:27] = '00000'; return fpcr; end; return FPCR(); end;

Library pseudocode for shared/functions/registers/Hint_Branch

// Hint_Branch
// =============
// Report the hint passed to BranchTo() and BranchToAddr(), for consideration when processing
// the next instruction.

impdef func Hint_Branch(hint : BranchType) begin Branchtypetaken = hint; return; end;

Library pseudocode for shared/functions/registers/NextInstrAddr

// NextInstrAddr
// ===============
// Return address of the sequentially next instruction.

impdef func NextInstrAddr{N}() => bits(N) begin return Zeros{N}; end;

Library pseudocode for shared/functions/registers/ResetExternalDebugRegisters

// ResetExternalDebugRegisters
// =============================
// Reset the External Debug registers in the Core power domain.

impdef func ResetExternalDebugRegisters(cold_reset : boolean) begin return; end;

Library pseudocode for shared/functions/registers/ThisInstrAddr

// ThisInstrAddr
// ===============
// Return address of the current instruction.

func ThisInstrAddr{N}() => bits(N) begin assert N == 64 || (N == 32 && UsingAArch32()); return _PC[N-1:0]; end;

Library pseudocode for shared/functions/registers/UnimplementedIDRegister

// UnimplementedIDRegister
// =========================
// Trap access to unimplemented encodings in the feature ID register space.

func UnimplementedIDRegister begin if IsFeatureImplemented(FEAT_IDST) then if EffectivelyAtEL0InHost() || EffectivelyAtEL0NotInHost() then AArch64_SystemAccessTraptoEL1orEL2(0x18); else AArch64_SystemAccessTrap(PSTATE.EL, 0x18); end; end; Undefined(); end;

Library pseudocode for shared/functions/registers/V

// V - accessor
// ============

accessor V{width : ESize}(n : integer) <=> value : bits(width) begin // Read from SIMD&FP register with implicit slice of 8, 16 // 32, 64 or 128 bits. getter assert n >= 0 && n <= 31; return _Z[[n]][width-1:0]; end;

// Write to SIMD&amp;FP register with implicit extension from// 8, 16, 32, 64 or 128 bits.setter    assert n &gt;= 0 &amp;&amp; n &lt;= 31;    if ConstrainUnpredictableBool(Unpredictable_SVEZEROUPPER) then        _Z[[n]] = ZeroExtend{MAX_VL}(value);    else        let vlen : VecLen = if IsSVEEnabled(PSTATE.EL) then CurrentVL() else 128;        _Z[[n]][vlen-1:0] = ZeroExtend{vlen}(value);    end;end;

end;

Library pseudocode for shared/functions/registers/Vpart

// Vpart - accessor
// ================

accessor Vpart{width : ESize}(n : integer, part : integer) <=> value : bits(width) begin // Reads a 128-bit SIMD&FP register in up to two parts: // part 0 returns the bottom 8, 16, 32 or 64 bits of a value held in the register; // part 1 returns the top half of the bottom 64 bits or the top half of the 128-bit // value held in the register. getter assert n >= 0 && n <= 31; assert part IN {0, 1}; if part == 0 then assert width < 128; return V{width}(n); else assert width IN {32,64}; let vreg : bits(128) = V{}(n); return vreg[(width * 2)-1:width]; end; end;

setter// Writes a 128-bit SIMD&amp;FP register in up to two parts://  part 0 zero extends a 8, 16, 32, or 64-bit value to fill the whole register;//  part 1 inserts a 64-bit value into the top half of the register.    assert n &gt;= 0 &amp;&amp; n &lt;= 31;    assert part IN {0, 1};    if part == 0 then        assert width &lt; 128;        V{width}(n) = value;    else        assert width == 64;        let vreg : bits(64) = V{}(n);        V{128}(n) = value[63:0] :: vreg;    end;end;

end;

Library pseudocode for shared/functions/registers/_PC

// _PC - the program counter
// =========================

var _PC : bits(64);

Library pseudocode for shared/functions/registers/_R

// _R - the general-purpose register file array
// ============================================

var _R : array [[31]] of bits(64);

Library pseudocode for shared/functions/sysregisters/SPSR_ELx

// SPSR_ELx - accessor
// ===================

accessor SPSR_ELx() <=> value : bits(64) begin getter var result : bits(64); case PSTATE.EL of when EL1 => result = SPSR_EL1()[63:0]; when EL2 => result = SPSR_EL2()[63:0]; when EL3 => result = SPSR_EL3()[63:0]; otherwise => unreachable; end; return result; end;

setter    case PSTATE.EL of        when EL1   =&gt; SPSR_EL1()[63:0] = value[63:0];        when EL2   =&gt; SPSR_EL2()[63:0] = value[63:0];        when EL3   =&gt; SPSR_EL3()[63:0] = value[63:0];        otherwise  =&gt; unreachable;    end;end;

end;

Library pseudocode for shared/functions/sysregisters/SPSR_curr

// SPSR_curr - accessor
// ====================

accessor SPSR_curr() <=> value : bits(32) begin getter var result : bits(32); case PSTATE.M of when M32_FIQ => result = SPSR_fiq()[31:0]; when M32_IRQ => result = SPSR_irq()[31:0]; when M32_Svc => result = SPSR_svc()[31:0]; when M32_Monitor => result = SPSR_mon()[31:0]; when M32_Abort => result = SPSR_abt()[31:0]; when M32_Hyp => result = SPSR_hyp()[31:0]; when M32_Undef => result = SPSR_und()[31:0]; otherwise => unreachable; end; return result; end;

setter    case PSTATE.M of        when M32_FIQ     =&gt; SPSR_fiq()[31:0] = value[31:0];        when M32_IRQ     =&gt; SPSR_irq()[31:0] = value[31:0];        when M32_Svc     =&gt; SPSR_svc()[31:0] = value[31:0];        when M32_Monitor =&gt; SPSR_mon()[31:0] = value[31:0];        when M32_Abort   =&gt; SPSR_abt()[31:0] = value[31:0];        when M32_Hyp     =&gt; SPSR_hyp()[31:0] = value[31:0];        when M32_Undef   =&gt; SPSR_und()[31:0] = value[31:0];        otherwise        =&gt; unreachable;    end;end;

end;

Library pseudocode for shared/functions/system/AArch64_ChkFeat

// AArch64_ChkFeat
// =================
// Indicates the status of some features

func AArch64_ChkFeat(feat_select : bits(64)) => bits(64) begin var feat_en : bits(64) = Zeros{}; feat_en[0] = if IsFeatureImplemented(FEAT_GCS) && GCSEnabled(PSTATE.EL) then '1' else '0'; return feat_select AND NOT(feat_en); end;

Library pseudocode for shared/functions/system/AddressAdd

// AddressAdd
// ============
// Add an address with an offset and return the result.
// If FEAT_CPA2 is implemented, the pointer arithmetic is checked.

func AddressAdd(base : bits(64), offset : integer, accdesc : AccessDescriptor) => bits(64) begin return AddressAdd(base, offset[63:0], accdesc); end;

func AddressAdd(base : bits(64), offset : bits(64), accdesc : AccessDescriptor) => bits(64) begin var result : bits(64) = base + offset; result = PointerAddCheckAtEL(accdesc.el, result, base); return result; end;

Library pseudocode for shared/functions/system/AddressInNaturallyAlignedBlock

// AddressInNaturallyAlignedBlock
// ================================
// Returns TRUE if the given addresses are in the same naturally aligned block, and FALSE otherwise.
// An address is in a naturally aligned block if it meets any of the below conditions:
// * is a power-of-two size.
// * Is no larger than the DC ZVA block size if ESR_ELx.FnP is being set to 0b0, or EDHSR is not
//   implemented or EDHSR.FnP is being set to 0b0 (as appropriate).
// * Is no larger than the smallest implemented translation granule if ESR_ELx.FnP, or EDHSR.FnP
//   (as appropriate) is being set to 0b1.
// * Contains a watchpointed address accessed by the memory access or set of contiguous memory
//   accesses that triggered the watchpoint.

impdef func AddressInNaturallyAlignedBlock(address1 : bits(64), address2 : bits(64)) => boolean begin // Returns TRUE if address in within a naturally aligned block of memory as the watchpointed // location, else FALSE. return FALSE; end;

Library pseudocode for shared/functions/system/AddressIncrement

// AddressIncrement
// ==================
// Increment an address and return the result.
// If FEAT_CPA2 is implemented, the pointer arithmetic may be checked.

func AddressIncrement(base : bits(64), increment : integer, accdesc : AccessDescriptor) => bits(64) begin return AddressIncrement(base, increment[63:0], accdesc); end;

func AddressIncrement(base : bits(64), increment : bits(64), accdesc : AccessDescriptor) => bits(64) begin var result : bits(64) = base + increment; // Checking the Pointer Arithmetic on an increment is equivalent to checking the // bytes in a sequential access crossing the 0xXXFF_FFFF_FFFF_FFFF boundary. if ConstrainUnpredictableBool(Unpredictable_CPACHECK) then result = PointerAddCheckAtEL(accdesc.el, result, base); end; return result; end;

Library pseudocode for shared/functions/system/BranchTargetCheck

// BranchTargetCheck
// ===================
// This function is executed checks if the current instruction is a valid target for a branch
// taken into, or inside, a guarded page. It is executed on every cycle once the current
// instruction has been decoded and the values of InGuardedPage and BTypeCompatible have been
// determined for the current instruction.

func BranchTargetCheck begin assert IsFeatureImplemented(FEAT_BTI) && ();

// The branch target check considers the following state variables:// * InGuardedPage, which is evaluated during instruction fetch.// * BTypeCompatible, which is evaluated during instruction decode.if Halted() then    return;elsif IsZero(PSTATE.BTYPE) then    return;elsif InGuardedPage &amp;&amp;  then    let pc : bits(64) = ThisInstrAddr{}();    AArch64_BranchTargetException(pc[51:0]);end;

end;

Library pseudocode for shared/functions/system/ClearEventRegister

// ClearEventRegister
// ====================
// Clear the Event Register of this PE.

func ClearEventRegister begin EventRegister = '0'; return; end;

Library pseudocode for shared/functions/system/ConditionHolds

// ConditionHolds
// ================
// Return TRUE iff COND currently holds

func ConditionHolds(cond : bits(4)) => boolean begin // Evaluate base condition. var result : boolean; case cond[3:1] of when '000' => result = (PSTATE.Z == '1'); // EQ or NE when '001' => result = (PSTATE.C == '1'); // CS or CC when '010' => result = (PSTATE.N == '1'); // MI or PL when '011' => result = (PSTATE.V == '1'); // VS or VC when '100' => result = (PSTATE.C == '1' && PSTATE.Z == '0'); // HI or LS when '101' => result = (PSTATE.N == PSTATE.V); // GE or LT when '110' => result = (PSTATE.N == PSTATE.V && PSTATE.Z == '0'); // GT or LE when '111' => result = TRUE; // AL end;

// Condition flag values in the set '111x' indicate always true// Otherwise, invert condition if necessary.if cond[0] == '1' &amp;&amp; cond != '1111' then    result = !result;end;return result;

end;

Library pseudocode for shared/functions/system/ConsumptionOfSpeculativeDataBarrier

// ConsumptionOfSpeculativeDataBarrier
// =====================================

impdef func ConsumptionOfSpeculativeDataBarrier begin return; end;

Library pseudocode for shared/functions/system/CurrentInstrSet

// CurrentInstrSet
// =================

readonly func CurrentInstrSet() => InstrSet begin var result : InstrSet; if UsingAArch32() then result = if PSTATE.T == '0' then InstrSet_A32 else InstrSet_T32; // PSTATE.J is RES0. Implementation of T32EE or Jazelle state not permitted. else result = InstrSet_A64; end; return result; end;

Library pseudocode for shared/functions/system/CurrentSecurityState

// CurrentSecurityState
// ======================
// Returns the effective security state at the exception level based off current settings.

readonly func CurrentSecurityState() => SecurityState begin return SecurityStateAtEL(PSTATE.EL); end;

Library pseudocode for shared/functions/system/DSBAlias

// DSBAlias
// ========
// Aliases of DSB.

type DSBAlias of enumeration {DSBAlias_SSBB, DSBAlias_PSSBB, DSBAlias_DSB};

Library pseudocode for shared/functions/system/EL0

// EL0-3
// =====
// PSTATE.EL Exception level bits.

constant EL3 : bits(2) = '11'; constant EL2 : bits(2) = '10'; constant EL1 : bits(2) = '01'; constant EL0 : bits(2) = '00';

Library pseudocode for shared/functions/system/EL2Enabled

// EL2Enabled
// ============
// Returns TRUE if EL2 is present and executing
// - with the PE in Non-secure state when Non-secure EL2 is implemented, or
// - with the PE in Realm state when Realm EL2 is implemented, or
// - with the PE in Secure state when Secure EL2 is implemented and enabled, or
// - when EL3 is not implemented.

readonly func EL2Enabled() => boolean begin var scr_ns : bit; if HaveEL(EL3) then if ELUsingAArch32(EL3) then scr_ns = SCR().NS; else scr_ns = SCR_EL3().NS; end; end; return HaveEL(EL2) && ((EL3) || scr_ns == '1' || IsSecureEL2Enabled()); end;

Library pseudocode for shared/functions/system/EL3SDDUndef

// EL3SDDUndef
// =============
// Returns TRUE if in Debug state and EDSCR.SDD is set.

func EL3SDDUndef() => boolean begin if Halted() && EDSCR().SDD == '1' then assert (PSTATE.EL != EL3 && (IsFeatureImplemented(FEAT_RME) || CurrentSecurityState() != SS_Secure)); return TRUE; else return FALSE; end; end;

Library pseudocode for shared/functions/system/EL3SDDUndefPriority

// EL3SDDUndefPriority
// =====================
// Returns TRUE if in Debug state, EDSCR.SDD is set, and an EL3 trap by an
// EL3 control register has priority over other traps.
// The IMPLEMENTATION DEFINED priority may be different for each case.

func EL3SDDUndefPriority() => boolean begin return EL3SDDUndef() && ImpDefBool("EL3 trap priority when SDD == '1'"); end;

Library pseudocode for shared/functions/system/ELFromM32

// ELFromM32
// ===========

readonly func ELFromM32(mode : bits(5)) => (boolean,bits(2)) begin // Convert an AArch32 mode encoding to an Exception level. // Returns (valid,EL): // 'valid' is TRUE if 'mode[4:0]' encodes a mode that is both valid for this implementation // and the current value of SCR.NS/SCR_EL3.NS. // 'EL' is the Exception level decoded from 'mode'. var el : bits(2); // Check for modes that are not valid for this implementation var valid : boolean = (mode); let effective_nse_ns : bits(2) = EffectiveSCR_EL3_NSE() :: EffectiveSCR_EL3_NS();

case mode of    when M32_Monitor =&gt;        el = EL3;    when M32_Hyp =&gt;        el = EL2;    when M32_FIQ, M32_IRQ, M32_Svc, M32_Abort, M32_Undef, M32_System =&gt;        // If EL3 is implemented and using AArch32, then these modes are EL3 modes in Secure        // state, and EL1 modes in Non-secure state. If EL3 is not implemented or is using        // AArch64, then these modes are EL1 modes.        el = (if HaveEL(EL3) &amp;&amp; () &amp;&amp; SCR().NS == '0' then EL3 else EL1);    when M32_User =&gt;        el = EL0;    otherwise =&gt;        valid = FALSE;           // Passed an illegal mode valueend;if valid &amp;&amp; el == EL2 &amp;&amp; HaveEL(EL3) then    if ELUsingAArch32(EL3) &amp;&amp; SCR().NS == '0' then        valid = FALSE; // EL2 only valid in Non-secure state in AArch32    elsif (EL3) &amp;&amp; SCR_EL3().NS == '0' then        valid = FALSE; // EL2 only valid in Non-secure state in AArch32    end;elsif valid &amp;&amp; IsFeatureImplemented(FEAT_RME) &amp;&amp; effective_nse_ns == '10' then    valid = FALSE;               // Illegal Exception Return from EL3 if SCR_EL3.[NSE,NS]                                 // selects a reserved encodingend;if !valid then el = ARBITRARY : bits(2); end;return (valid, el);

end;

Library pseudocode for shared/functions/system/ELFromSPSR

// ELFromSPSR
// ============

// Convert an SPSR value encoding to an Exception level. // Returns (valid,EL): // 'valid' is TRUE if 'spsr[4:0]' encodes a valid mode for the current state. // 'EL' is the Exception level decoded from 'spsr'.

readonly func ELFromSPSR{N}(spsr : bits(N)) => (boolean,bits(2)) begin var el : bits(2); var valid : boolean; if spsr[4] == '0' then // AArch64 state el = spsr[3:2]; if (() && IsFeatureImplemented(FEAT_NV3) && spsr[3:2] == '10' && PSTATE.EL == EL1 && EffectiveHCRX_EL2_NVTGE() == '1') then el = EL1; end;

    let effective_nse_ns : bits(2) = EffectiveSCR_EL3_NSE() :: EffectiveSCR_EL3_NS();    if () then        valid = FALSE;      // No AArch64 support    elsif (el) then        valid = FALSE;      // Exception level not implemented    elsif spsr[1] == '1' then        valid = FALSE;      // M[1] must be 0    elsif el == EL0 &amp;&amp; spsr[0] == '1' then        valid = FALSE;      // for EL0, M[0] must be 0    elsif IsFeatureImplemented(FEAT_RME) &amp;&amp; el != EL3 &amp;&amp; effective_nse_ns == '10' then        valid = FALSE;      // Only EL3 valid in Root state    elsif el == EL2 &amp;&amp; HaveEL(EL3) &amp;&amp; () &amp;&amp; EffectiveSCR_EL3_NS() == '0' then        valid = FALSE;      // Unless Secure EL2 is enabled, EL2 valid only in Non-secure state    else        valid = TRUE;    end;elsif HaveAArch32() then    // AArch32 state    (valid, el) = ELFromM32(spsr[4:0]);else    valid = FALSE;end;if !valid then el = ARBITRARY : bits(2); end;return (valid,el);

end;

Library pseudocode for shared/functions/system/ELIsInHost

// ELIsInHost
// ============

readonly func ELIsInHost(el : bits(2)) => boolean begin if !IsFeatureImplemented(FEAT_VHE) || ELUsingAArch32(EL2) then return FALSE; end; case el of when EL3 => return FALSE; when EL2 => return EL2Enabled() && EffectiveHCR_EL2_E2H() == '1'; when EL1 => return FALSE; when EL0 => return EL2Enabled() && EffectiveHCR_EL2_E2H()::HCR_EL2().TGE == '11'; otherwise => unreachable; end; end;

Library pseudocode for shared/functions/system/ELStateUsingAArch32

// ELStateUsingAArch32
// =====================

readonly func ELStateUsingAArch32(el : bits(2), secure : boolean) => boolean begin // See ELStateUsingAArch32K() for description. Must only be called in circumstances where // result is valid (typically, that means 'el IN {EL1,EL2,EL3}'). let (known, aarch32) : (boolean, boolean) = ELStateUsingAArch32K(el, secure); assert known; return aarch32; end;

Library pseudocode for shared/functions/system/ELStateUsingAArch32K

// ELStateUsingAArch32K
// ======================
// Returns (known, aarch32):
//   'known'   is FALSE for EL0 if the current Exception level is not EL0 and EL1 is
//             using AArch64, since it cannot determine the state of EL0; TRUE otherwise.
//   'aarch32' is TRUE if the specified Exception level is using AArch32; FALSE otherwise.

readonly func ELStateUsingAArch32K(el : bits(2), secure : boolean) => (boolean, boolean) begin assert HaveEL(el);

if (el) then    return (TRUE, FALSE);   // Exception level is using AArch64elsif secure &amp;&amp; el == EL2 then    return (TRUE, FALSE);   // Secure EL2 is using AArch64elsif () then    return (TRUE, TRUE);    // Highest Exception level, therefore all levels are using AArch32end;// Remainder of function deals with the interprocessing cases when highest// Exception level is using AArch64.if el == EL3 then    return (TRUE, FALSE);end;if (HaveEL(EL3) &amp;&amp; EffectiveSCR_EL3_RW() == '0' &amp;&amp;      (!secure || !IsFeatureImplemented(FEAT_SEL2) || SCR_EL3().EEL2 == '0')) then    // AArch32 below EL3.    return (TRUE, TRUE);end;if el == EL2 then    return (TRUE, FALSE);end;if (HaveEL(EL2) &amp;&amp; (EL0) &amp;&amp; HCR_EL2().RW == '0' &amp;&amp;      (!secure || (IsFeatureImplemented(FEAT_SEL2) &amp;&amp; SCR_EL3().EEL2 == '1'))) then    // AArch32 below EL2.    return (TRUE, TRUE);end;if el == EL1 then    return (TRUE, FALSE);end;// The execution state of EL0 is only known from PSTATE.nRW when executing at EL0.if PSTATE.EL == EL0 then    return (TRUE, PSTATE.nRW == '1');else    return (FALSE, ARBITRARY : boolean);end;

end;

Library pseudocode for shared/functions/system/ELUsingAArch32

// ELUsingAArch32
// ================

readonly func ELUsingAArch32(el : bits(2)) => boolean recurselimit 1 begin return ELStateUsingAArch32(el, IsSecureBelowEL3()); end;

Library pseudocode for shared/functions/system/ELUsingAArch32K

// ELUsingAArch32K
// =================

readonly func ELUsingAArch32K(el : bits(2)) => (boolean,boolean) begin return ELStateUsingAArch32K(el, IsSecureBelowEL3()); end;

Library pseudocode for shared/functions/system/EffectiveEA

// EffectiveEA
// =============
// Returns the Effective value of SCR_EL3().EA

readonly func EffectiveEA() => bit begin if (EL3) || Halted() then return '0'; else return if HaveAArch64() then SCR_EL3().EA else SCR().EA; end; end;

Library pseudocode for shared/functions/system/EffectiveHCR_EL2_E2H

// EffectiveHCR_EL2_E2H
// ======================
// Returns the Effective value of HCR_EL2().E2H.

readonly func EffectiveHCR_EL2_E2H() => bit begin if !IsFeatureImplemented(FEAT_VHE) then return '0'; end;

if !IsFeatureImplemented(FEAT_E2H0) then    return '1';end;return HCR_EL2().E2H;

end;

Library pseudocode for shared/functions/system/EffectiveHCR_EL2_NVx

// EffectiveHCR_EL2_NVx
// ======================
// Returns the Effective value of HCR_EL2().[NV2,NV1,NV].

readonly func EffectiveHCR_EL2_NVx() => bits(3) begin if () || !IsFeatureImplemented(FEAT_NV) then return '000'; end;

var nv1 : bit = HCR_EL2().NV1;if (!IsFeatureImplemented(FEAT_E2H0) &amp;&amp;      ImpDefBool("HCR_EL2.NV1 is implemented as RAZ")) then    nv1 = '0';end;if HCR_EL2().NV == '0' then    if nv1 == '1' then        case ConstrainUnpredictable(Unpredictable_NVNV1) of            when Constraint_NVNV1_00 =&gt; return '000';            when Constraint_NVNV1_01 =&gt; return '010';            when Constraint_NVNV1_11 =&gt; return '011';        end;    else        return '000';    end;end;if !IsFeatureImplemented(FEAT_NV2) then    return '0' :: nv1 :: '1';end;var nv2 : bit = HCR_EL2().NV2;if (nv2 == '0' &amp;&amp; ImpDefBool(      "Programming HCR_EL2.&lt;NV,NV2&gt; to '10' behaves as '11'")) then    nv2 = '1';end;return nv2 :: nv1 :: '1';

end;

Library pseudocode for shared/functions/system/EffectiveHCR_EL2_TERR

// EffectiveHCR_EL2_TERR
// =======================
// Returns the Effective value of HCR_EL2().TERR.

readonly func EffectiveHCR_EL2_TERR() => bit begin assert IsFeatureImplemented(FEAT_RAS); if () then return '0'; end;

assert (EL2);if (NUM_ERROR_RECORDS == 0 &amp;&amp;       ImpDefBool("HCR_EL2.TERR,SCR_EL3.TERR/TWERR=0 when ERRIDR_EL1.NUM==0")) then    return '0';end;return HCR_EL2().TERR;

end;

Library pseudocode for shared/functions/system/EffectiveIESB

// EffectiveIESB
// ===============
// Returns the Effective value of SCTLR_ELx().IESB.

func EffectiveIESB(target_el : bits(2)) => bit begin if EffectiveNMEA(target_el) == '1' then return '1'; end;

return SCTLR_EL(target_el).IESB;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_ADEn

// EffectiveSCR_EL3_ADEn
// =======================
// Returns the Effective value of SCR_EL3().ADEn.

readonly func EffectiveSCR_EL3_ADEn() => bit begin assert IsFeatureImplemented(FEAT_LS64_ACCDATA); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().ADEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_AIEn

// EffectiveSCR_EL3_AIEn
// =======================
// Returns the Effective value of SCR_EL3().AIEn.

readonly func EffectiveSCR_EL3_AIEn() => bit begin assert IsFeatureImplemented(FEAT_AIE); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().AIEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_AMVOFFEN

// EffectiveSCR_EL3_AMVOFFEN
// ===========================
// Returns the Effective value of SCR_EL3().AMVOFFEN.
readonly func EffectiveSCR_EL3_AMVOFFEN() => bit
begin
    assert IsFeatureImplemented(FEAT_AMUv1p1);
    if (EL3) then return '1'; end;
assert (EL3);return SCR_EL3().AMVOFFEN;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_API

// EffectiveSCR_EL3_API
// ======================
// Returns the Effective value of SCR_EL3().API.

readonly func EffectiveSCR_EL3_API() => bit begin assert IsFeatureImplemented(FEAT_PAuth); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().API;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_APK

// EffectiveSCR_EL3_APK
// ======================
// Returns the Effective value of SCR_EL3().APK.

readonly func EffectiveSCR_EL3_APK() => bit begin assert IsFeatureImplemented(FEAT_PAuth); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().APK;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_ATA

// EffectiveSCR_EL3_ATA
// ======================
// Returns the Effective value of SCR_EL3().ATA.

readonly func EffectiveSCR_EL3_ATA() => bit begin assert IsFeatureImplemented(FEAT_MTE2); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().ATA;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_D128En

// EffectiveSCR_EL3_D128En
// =========================
// Returns the Effective value of SCR_EL3().D128En.

readonly func EffectiveSCR_EL3_D128En() => bit begin assert IsFeatureImplemented(FEAT_D128); if (EL3) then return '1'; end;

return SCR_EL3().D128En;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_DSE

// EffectiveSCR_EL3_DSE
// ======================
// Returns the Effective value of SCR_EL3().DSE.

readonly func EffectiveSCR_EL3_DSE() => bit begin assert IsFeatureImplemented(FEAT_E3DSE); if (EL3) then return '0'; end;

assert (EL3);if EffectiveSCR_EL3_EnDSE() == '0' then return '0'; end;return SCR_EL3().DSE;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EA

// EffectiveSCR_EL3_EA
// =====================
// Returns the Effective value of SCR_EL3().EA.

readonly func EffectiveSCR_EL3_EA() => bit begin if (EL3) then return '0'; end;

assert (EL3);return SCR_EL3().EA;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EASE

// EffectiveSCR_EL3_EASE
// =======================
// Returns the Effective value of SCR_EL3().EASE.

readonly func EffectiveSCR_EL3_EASE() => bit begin assert IsFeatureImplemented(FEAT_DoubleFault); assert HaveEL(EL3); assert (EL3);

return SCR_EL3().EASE;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_ECVEn

// EffectiveSCR_EL3_ECVEn
// ========================
// Returns the Effective value of SCR_EL3().ECVEn.

readonly func EffectiveSCR_EL3_ECVEn() => bit begin assert IsFeatureImplemented(FEAT_ECV_POFF); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().ECVEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EEL2

// EffectiveSCR_EL3_EEL2
// =======================
// Returns the Effective value of SCR_EL3().EEL2.

readonly func EffectiveSCR_EL3_EEL2() => bit begin assert IsFeatureImplemented(FEAT_SEL2); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().EEL2;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnAS0

// EffectiveSCR_EL3_EnAS0
// ========================
// Returns the Effective value of SCR_EL3().EnAS0.

readonly func EffectiveSCR_EL3_EnAS0() => bit begin assert IsFeatureImplemented(FEAT_LS64_ACCDATA); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().EnAS0;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnDSE

// EffectiveSCR_EL3_EnDSE
// ========================
// Returns the Effective value of SCR_EL3().EnDSE.

readonly func EffectiveSCR_EL3_EnDSE() => bit begin assert IsFeatureImplemented(FEAT_E3DSE); assert (EL3);

if SCR_EL3().EA == '0' &amp;&amp; EffectiveSCR_EL3_TMEA() == '0' then return '0'; end;return SCR_EL3().EnDSE;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnFPM

// EffectiveSCR_EL3_EnFPM
// ========================
// Returns the Effective value of SCR_EL3().EnFPM.

readonly func EffectiveSCR_EL3_EnFPM() => bit begin assert IsFeatureImplemented(FEAT_FPMR); if (EL3) then return '1'; end;

return SCR_EL3().EnFPM;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnIDCP128

// EffectiveSCR_EL3_EnIDCP128
// ============================
// Returns the Effective value of SCR_EL3().EnIDCP128.

readonly func EffectiveSCR_EL3_EnIDCP128() => bit begin assert IsFeatureImplemented(FEAT_SYSREG128); if (EL3) then return '1'; end;

return SCR_EL3().EnIDCP128;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnSCXT

// EffectiveSCR_EL3_EnSCXT
// =========================
// Returns the Effective value of SCR_EL3().EnSCXT.

readonly func EffectiveSCR_EL3_EnSCXT() => bit begin assert (IsFeatureImplemented(FEAT_CSV2_2) || IsFeatureImplemented(FEAT_CSV2_1p2)); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().EnSCXT;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnTP2

// EffectiveSCR_EL3_EnTP2
// ========================
// Returns the Effective value of SCR_EL3().EnTP2.

readonly func EffectiveSCR_EL3_EnTP2() => bit begin assert IsFeatureImplemented(FEAT_SME); if (EL3) then return '1'; end;

return SCR_EL3().EnTP2;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_FGTEn

// EffectiveSCR_EL3_FGTEn
// ========================
// Returns the Effective value of SCR_EL3().FGTEn.

readonly func EffectiveSCR_EL3_FGTEn() => bit begin assert IsFeatureImplemented(FEAT_FGT); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().FGTEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_FGTEn2

// EffectiveSCR_EL3_FGTEn2
// =========================
// Returns the Effective value of SCR_EL3().FGTEn2.

readonly func EffectiveSCR_EL3_FGTEn2() => bit begin assert IsFeatureImplemented(FEAT_FGT2); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().FGTEn2;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_FIEN

// EffectiveSCR_EL3_FIEN
// =======================
// Returns the Effective value of SCR_EL3().FIEN.

readonly func EffectiveSCR_EL3_FIEN() => bit begin assert IsFeatureImplemented(FEAT_RASv1p1); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().FIEN;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_FIQ

// EffectiveSCR_EL3_FIQ
// ======================
// Returns the Effective value of SCR_EL3().FIQ.

readonly func EffectiveSCR_EL3_FIQ() => bit begin if (EL3) || ELUsingAArch32(EL3) then return '0'; end; if IsFeatureImplemented(FEAT_GCIE) && IsFeatureImplemented(FEAT_EL3) then return '1'; end; return SCR_EL3().FIQ; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_GCSEn

// EffectiveSCR_EL3_GCSEn
// ========================
// Returns the Effective value of SCR_EL3().GCSEn.

readonly func EffectiveSCR_EL3_GCSEn() => bit begin assert IsFeatureImplemented(FEAT_GCS); if (EL3) then return '1'; end;

return SCR_EL3().GCSEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_GPF

// EffectiveSCR_EL3_GPF
// ======================
// Returns the Effective value of SCR_EL3().GPF.

readonly func EffectiveSCR_EL3_GPF() => bit begin assert IsFeatureImplemented(FEAT_RME); if (EL3) then return '0'; end;

return SCR_EL3().GPF;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_HACDBSEn

// EffectiveSCR_EL3_HACDBSEn
// ===========================
// Returns the Effective value of SCR_EL3().HACDBSEn.

readonly func EffectiveSCR_EL3_HACDBSEn() => bit begin assert IsFeatureImplemented(FEAT_HACDBS); if (EL3) then return '1'; end;

return SCR_EL3().HACDBSEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_HCE

// EffectiveSCR_EL3_HCE
// ======================
// Returns the Effective value of SCR_EL3().HCE.

readonly func EffectiveSCR_EL3_HCE() => bit begin if (EL2) then return '0'; end; if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().HCE;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_HDBSSEn

// EffectiveSCR_EL3_HDBSSEn
// ==========================
// Returns the Effective value of SCR_EL3().HDBSSEn.

readonly func EffectiveSCR_EL3_HDBSSEn() => bit begin assert IsFeatureImplemented(FEAT_HDBSS); if (EL3) then return '1'; end;

return SCR_EL3().HDBSSEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_HXEn

// EffectiveSCR_EL3_HXEn
// =======================
// Returns the Effective value of SCR_EL3().HXEn.

readonly func EffectiveSCR_EL3_HXEn() => bit begin assert IsFeatureImplemented(FEAT_HCX); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().HXEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_IRQ

// EffectiveSCR_EL3_IRQ
// ======================
// Returns the Effective value of SCR_EL3().IRQ.

readonly func EffectiveSCR_EL3_IRQ() => bit begin if (EL3) || ELUsingAArch32(EL3) then return '0'; end; if IsFeatureImplemented(FEAT_GCIE) then return '0'; end; return SCR_EL3().IRQ; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_MECEn

// EffectiveSCR_EL3_MECEn
// ========================
// Returns the Effective value of SCR_EL3().MECEn.

readonly func EffectiveSCR_EL3_MECEn() => bit begin assert IsFeatureImplemented(FEAT_MEC); if (EL3) then return '1'; end;

return SCR_EL3().MECEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_NMEA

// EffectiveSCR_EL3_NMEA
// =======================
// Returns the Effective value of SCR_EL3().NMEA.

readonly func EffectiveSCR_EL3_NMEA() => bit begin assert IsFeatureImplemented(FEAT_DoubleFault); if (EL3) then return '0'; end;

assert (EL3);if !IsFeatureImplemented(FEAT_DoubleFault2) &amp;&amp; EffectiveSCR_EL3_EA() == '0' then    return '0';end;return SCR_EL3().NMEA;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_NS

// EffectiveSCR_EL3_NS
// =====================
// Returns the Effective value of SCR_EL3().NS.

readonly func EffectiveSCR_EL3_NS() => bit begin if () then return '1'; elsif (EL3) then return '0'; elsif ELUsingAArch32(EL3) then return SCR().NS; else return SCR_EL3().NS; end; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_NSE

// EffectiveSCR_EL3_NSE
// ======================
// Returns the Effective value of SCR_EL3().NSE.

readonly func EffectiveSCR_EL3_NSE() => bit begin return if !IsFeatureImplemented(FEAT_RME) then '0' else SCR_EL3().NSE; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_PFAREn

// EffectiveSCR_EL3_PFAREn
// =========================
// Returns the Effective value of SCR_EL3().PFAREn.

readonly func EffectiveSCR_EL3_PFAREn() => bit begin assert IsFeatureImplemented(FEAT_PFAR); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().PFAREn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_PIEn

// EffectiveSCR_EL3_PIEn
// =======================
// Returns the Effective value of SCR_EL3().PIEn.

readonly func EffectiveSCR_EL3_PIEn() => bit begin assert (IsFeatureImplemented(FEAT_S1PIE) || IsFeatureImplemented(FEAT_S2PIE) || IsFeatureImplemented(FEAT_S1POE) || IsFeatureImplemented(FEAT_S2POE)); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().PIEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_RCWMASKEn

// EffectiveSCR_EL3_RCWMASKEn
// ============================
// Returns the Effective value of SCR_EL3().RCWMASKEn.

readonly func EffectiveSCR_EL3_RCWMASKEn() => bit begin assert IsFeatureImplemented(FEAT_THE); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().RCWMASKEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_RW

// EffectiveSCR_EL3_RW
// =====================
// Returns the Effective value of SCR_EL3().RW.

readonly func EffectiveSCR_EL3_RW() => bit begin if () then return '0'; end; if (EL2) && (EL1) then return '1'; end; if HaveAArch32EL(EL1) then if (EL2) && EffectiveSCR_EL3_NS() == '1' then return '1'; end; if (IsFeatureImplemented(FEAT_SEL2) && SCR_EL3().EEL2 == '1' && EffectiveSCR_EL3_NS() == '0') then return '1'; end; end; return SCR_EL3().RW; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_SCTLR2En

// EffectiveSCR_EL3_SCTLR2En
// ===========================
// Returns the Effective value of SCR_EL3().SCTLR2En.

readonly func EffectiveSCR_EL3_SCTLR2En() => bit begin assert IsFeatureImplemented(FEAT_SCTLR2); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().SCTLR2En;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_SIF

// EffectiveSCR_EL3_SIF
// ======================
// Returns the Effective value of SCR_EL3().SIF.

readonly func EffectiveSCR_EL3_SIF() => bit begin if (EL3) then return '0'; end;

assert (EL3);if IsFeatureImplemented(FEAT_RME) &amp;&amp; !IsFeatureImplemented(FEAT_SEL2) then    return '0';end;return SCR_EL3().SIF;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_SMD

// EffectiveSCR_EL3_SMD
// ======================
// Returns the Effective value of SCR_EL3().SMD.

readonly func EffectiveSCR_EL3_SMD() => bit begin if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().SMD;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_SRMASKEn

// EffectiveSCR_EL3_SRMASKEn
// ===========================
// Returns the Effective value of SCR_EL3().SRMASKEn.

readonly func EffectiveSCR_EL3_SRMASKEn() => bit begin assert IsFeatureImplemented(FEAT_SRMASK); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().SRMASKEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_ST

// EffectiveSCR_EL3_ST
// =====================
// Returns the Effective value of SCR_EL3().ST.

readonly func EffectiveSCR_EL3_ST() => bit begin if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().ST;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TCR2En

// EffectiveSCR_EL3_TCR2En
// =========================
// Returns the Effective value of SCR_EL3().TCR2En.

readonly func EffectiveSCR_EL3_TCR2En() => bit begin assert IsFeatureImplemented(FEAT_TCR2); if (EL3) then return '1'; end;

assert (EL3);return SCR_EL3().TCR2En;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TERR

// EffectiveSCR_EL3_TERR
// =======================
// Returns the Effective value of SCR_EL3().TERR.

readonly func EffectiveSCR_EL3_TERR() => bit begin assert IsFeatureImplemented(FEAT_RAS); if (EL3) then return '0'; end;

assert (EL3);if (NUM_ERROR_RECORDS == 0 &amp;&amp;       ImpDefBool("HCR_EL2.TERR,SCR_EL3.TERR/TWERR=0 when ERRIDR_EL1.NUM==0")) then    return '0';end;return SCR_EL3().TERR;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TID3

// EffectiveSCR_EL3_TID3
// =======================
// Returns the Effective value of SCR_EL3().TID3.

readonly func EffectiveSCR_EL3_TID3() => bit begin assert IsFeatureImplemented(FEAT_IDTE3); if (EL3) then return '0'; end;

assert (EL3);return SCR_EL3().TID3;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TID5

// EffectiveSCR_EL3_TID5
// =======================
// Returns the Effective value of SCR_EL3().TID5.

readonly func EffectiveSCR_EL3_TID5() => bit begin assert IsFeatureImplemented(FEAT_IDTE3); assert IsFeatureImplemented(FEAT_MTE2); if (EL3) then return '0'; end;

assert (EL3);return SCR_EL3().TID5;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TLOR

// EffectiveSCR_EL3_TLOR
// =======================
// Returns the Effective value of SCR_EL3().TLOR.

readonly func EffectiveSCR_EL3_TLOR() => bit begin assert IsFeatureImplemented(FEAT_LOR); if (EL3) then return '0'; end;

assert (EL3);return SCR_EL3().TLOR;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TMEA

// EffectiveSCR_EL3_TMEA
// =======================
// Returns the Effective value of SCR_EL3().TMEA

readonly func EffectiveSCR_EL3_TMEA() => bit begin if (IsFeatureImplemented(FEAT_DoubleFault2) && HaveEL(EL3) && (EL3)) then return SCR_EL3().TMEA; else return '0'; end; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TRNDR

// EffectiveSCR_EL3_TRNDR
// ========================
// Returns the Effective value of SCR_EL3().TRNDR.

readonly func EffectiveSCR_EL3_TRNDR() => bit begin assert IsFeatureImplemented(FEAT_RNG_TRAP); if (EL3) then return '0'; end;

assert (EL3);return SCR_EL3().TRNDR;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWE

// EffectiveSCR_EL3_TWE
// ======================
// Returns the Effective value of SCR_EL3().TWE.

readonly func EffectiveSCR_EL3_TWE() => bit begin if (EL3) then return '0'; end;

assert (EL3);return SCR_EL3().TWE;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWEDEL

// EffectiveSCR_EL3_TWEDEL
// =========================
// Returns the Effective value of SCR_EL3().TWEDEL.

readonly func EffectiveSCR_EL3_TWEDEL() => bits(4) begin assert IsFeatureImplemented(FEAT_TWED); if (EL3) then return '0000'; end;

assert (EL3);return SCR_EL3().TWEDEL;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWEDEn

// EffectiveSCR_EL3_TWEDEn
// =========================
// Returns the Effective value of SCR_EL3().TWEDEn.

readonly func EffectiveSCR_EL3_TWEDEn() => bit begin assert IsFeatureImplemented(FEAT_TWED); if (EL3) then return '0'; end;

assert (EL3);return SCR_EL3().TWEDEn;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWERR

// EffectiveSCR_EL3_TWERR
// ========================
// Returns the Effective value of SCR_EL3().TWERR.

readonly func EffectiveSCR_EL3_TWERR() => bit begin assert IsFeatureImplemented(FEAT_RASv2); if (EL3) then return '0'; end;

assert (EL3);if (NUM_ERROR_RECORDS == 0 &amp;&amp;       ImpDefBool("HCR_EL2.TERR,SCR_EL3.TERR/TWERR=0 when ERRIDR_EL1.NUM==0")) then    return '0';end;return SCR_EL3().TWERR;

end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWI

// EffectiveSCR_EL3_TWI
// ======================
// Returns the Effective value of SCR_EL3().TWI.

readonly func EffectiveSCR_EL3_TWI() => bit begin if (EL3) then return '0'; end;

assert (EL3);return SCR_EL3().TWI;

end;

Library pseudocode for shared/functions/system/EffectiveTGE

// EffectiveTGE
// ==============
// Returns the Effective value of TGE.

readonly func EffectiveTGE() => bit begin if EL2Enabled() then return if ELUsingAArch32(EL2) then HCR().TGE else HCR_EL2().TGE; else return '0'; // Effective value of TGE is zero end; end;

Library pseudocode for shared/functions/system/EffectiveTGEforEL0Traps

// EffectiveTGEforEL0Traps
// =========================
// Returns the Effective value of HCR_EL2().TGE for direct accesses to system or special-purpose
// registers, and execution of system instructions, that may trap when either
// EffectivelyAtEL0NotInHost() or EffectivelyAtEL0InHost() is TRUE.

func EffectiveTGEforEL0Traps() => bit begin if () then return '0'; end;

return HCR_EL2().TGE;

end;

Library pseudocode for shared/functions/system/EffectivelyAtEL0InHost

// EffectivelyAtEL0InHost
// ========================
// Accesses from EL0 when the Effective value of HCR_EL2().[E2H, TGE] is {1, 1} will be trapped
// or Undefined.

func EffectivelyAtEL0InHost() => boolean begin return (PSTATE.EL == EL0 && ELIsInHost(EL0)); end;

Library pseudocode for shared/functions/system/EffectivelyAtEL0NotInHost

// EffectivelyAtEL0NotInHost
// ===========================
// Accesses from EL0 when the Effective value of HCR_EL2().[E2H, TGE] is not {1, 1} will be
// trapped or Undefined.

func EffectivelyAtEL0NotInHost() => boolean begin return (PSTATE.EL == EL0 && (EL0)); end;

Library pseudocode for shared/functions/system/EndOfInstruction

// EndOfInstruction
// ==================
// Terminate processing of the current instruction.

noreturn impdef func EndOfInstruction(EndReason : EndOfInstructionReason) begin throw EndOfInstructionException{reason=EndReason}; end;

Library pseudocode for shared/functions/system/EndOfInstructionException

// EndOfInstructionException
// =========================
// End of Instruction exception type.

type EndOfInstructionException of exception { reason : EndOfInstructionReason };

Library pseudocode for shared/functions/system/EndOfInstructionReason

// EndOfInstructionReason
// ======================

type EndOfInstructionReason of enumeration { EndOfInstructionReason_Retired, EndOfInstructionReason_Exception };

Library pseudocode for shared/functions/system/EnterLowPowerState

// EnterLowPowerState
// ====================
// PE enters a low-power state.

impdef func EnterLowPowerState begin return; end;

Library pseudocode for shared/functions/system/EventRegister

// EventRegister
// =============
// Event Register for this PE.

var EventRegister : bits(1);

Library pseudocode for shared/functions/system/ExceptionalOccurrenceTargetState

// ExceptionalOccurrenceTargetState
// ================================
// Enumeration to represent the target state of an Exceptional Occurrence.
// The Exceptional Occurrence can be either Exception or Debug State entry.

type ExceptionalOccurrenceTargetState of enumeration { AArch32_NonDebugState, AArch64_NonDebugState, DebugState };

Library pseudocode for shared/functions/system/ExecuteAsNOP

// ExecuteAsNOP
// ==============

func ExecuteAsNOP begin EndOfInstruction(EndOfInstructionReason_Retired); end;

Library pseudocode for shared/functions/system/FIQPending

// FIQPending
// ============
// Returns a tuple indicating if there is any pending physical FIQ
// and if the pending FIQ has superpriority.

readonly impdef func FIQPending() => (boolean, boolean) begin return (FALSE, FALSE); end;

Library pseudocode for shared/functions/system/GetAccumulatedFPExceptions

// GetAccumulatedFPExceptions
// ============================
// Returns FP exceptions accumulated by the PE.

impdef func GetAccumulatedFPExceptions() => bits(8) begin return ARBITRARY : bits(8); end;

Library pseudocode for shared/functions/system/GetLoadStoreType

// GetLoadStoreType
// ==================
// Returns the Load/Store Type. Used when a Translation fault,
// Access flag fault, or Permission fault generates a Data Abort.

impdef func GetLoadStoreType() => bits(2) begin return ARBITRARY : bits(2); end;

Library pseudocode for shared/functions/system/GetPSRFromPSTATE

// GetPSRFromPSTATE
// ==================
// Return a PSR value which represents the current PSTATE

func GetPSRFromPSTATE{N}(targetELState : ExceptionalOccurrenceTargetState) => bits(N) begin if UsingAArch32() && targetELState == AArch32_NonDebugState then assert N == 32; else assert N == 64; end;

var spsr : bits(N) = Zeros{};if IsFeatureImplemented(FEAT_UINJ) &amp;&amp; targetELState == DebugState then    spsr[36] = PSTATE.UINJ;end;spsr[31:28] = PSTATE.[N,Z,C,V];if IsFeatureImplemented(FEAT_PAN) then spsr[22] = PSTATE.PAN; end;spsr[20]     = PSTATE.IL;if PSTATE.nRW == '1' then                           // AArch32 state    spsr[27]     = PSTATE.Q;    spsr[26:25]  = PSTATE.IT[1:0];    if IsFeatureImplemented(FEAT_SSBS) then spsr[23] = PSTATE.SSBS; end;    if IsFeatureImplemented(FEAT_DIT) then        if targetELState == AArch32_NonDebugState then            spsr[21] = PSTATE.DIT;        else                                        // AArch64_NonDebugState or DebugState            spsr[24] = PSTATE.DIT;        end;    end;    if targetELState IN {AArch64_NonDebugState, DebugState} then        spsr[21] = PSTATE.SS;    end;    spsr[19:16]  = PSTATE.GE;    spsr[15:10]  = PSTATE.IT[7:2];    spsr[9]      = PSTATE.E;    spsr[8:6]    = PSTATE.[A,I,F];                  // No PSTATE.D in AArch32 state    spsr[5]      = PSTATE.T;    assert PSTATE.M[4] == PSTATE.nRW;               // bit [4] is the discriminator    spsr[4:0]    = PSTATE.M;else                                                // AArch64 state    if IsFeatureImplemented(FEAT_PAuth_LR) then spsr[35] = PSTATE.PACM; end;    if IsFeatureImplemented(FEAT_GCS) then spsr[34] = PSTATE.EXLOCK; end;    if (IsFeatureImplemented(FEAT_EBEP) || IsFeatureImplemented(FEAT_SPE_EXC) ||          IsFeatureImplemented(FEAT_TRBE_EXC)) then        spsr[32] = PSTATE.PM;    end;    if IsFeatureImplemented(FEAT_MTE) then spsr[25] = PSTATE.TCO; end;    if IsFeatureImplemented(FEAT_DIT) then spsr[24] = PSTATE.DIT; end;    if IsFeatureImplemented(FEAT_UAO) then spsr[23] = PSTATE.UAO; end;    spsr[21]    = PSTATE.SS;    if IsFeatureImplemented(FEAT_NMI) then spsr[13] = PSTATE.ALLINT; end;    if IsFeatureImplemented(FEAT_SSBS) then spsr[12] = PSTATE.SSBS; end;    if IsFeatureImplemented(FEAT_BTI) then spsr[11:10] = PSTATE.BTYPE; end;    spsr[9:6]    = PSTATE.[D,A,I,F];    spsr[4]      = PSTATE.nRW;    spsr[3:2]    = PSTATE.EL;    spsr[0]      = PSTATE.SP;end;return spsr;

end;

Library pseudocode for shared/functions/system/HaveAArch32

// HaveAArch32
// =============
// Return TRUE if AArch32 state is supported from at least EL0.

readonly func HaveAArch32() => boolean begin return IsFeatureImplemented(FEAT_AA32EL0); end;

Library pseudocode for shared/functions/system/HaveAArch32EL

// HaveAArch32EL
// ===============
// Return TRUE if Exception level 'el' supports AArch32 in this implementation

readonly func HaveAArch32EL(el : bits(2)) => boolean begin case el of when EL0 => return IsFeatureImplemented(FEAT_AA32EL0);

Log in to reply.