aarch64-cpu 11.2.0

Low level access to processors using the AArch64 execution state
Documentation
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2018-2025 by the author(s)
//
// Author(s):
//   - Andre Richter <andre.o.richter@gmail.com>
//   - Berkus Decker <berkus+github@metta.systems>
//   - Bradley Landherr <landhb@users.noreply.github.com>
//   - Yan Tan <tanyan@kylinos.cn>

//! Exception Syndrome Register - EL2
//!
//! Holds syndrome information for an exception taken to EL2.

use tock_registers::{
    interfaces::{Readable, Writeable},
    register_bitfields,
};

register_bitfields! {u64,
    pub ESR_EL2 [

        /// Reserved
        RES0 OFFSET(37) NUMBITS(27) [],

        /// Instruction Specific Syndrome 2. If a memory access generated by an ST64BV or ST64BV0
        /// instruction generates a Data Abort for a Translation fault, Access flag fault, or
        /// Permission fault, then this field holds register specifier, Xs.
        ///
        /// For any other Data Abort, this field is RES0.
        ISS2 OFFSET(32) NUMBITS(5) [],

        /// Exception Class. Indicates the reason for the exception that this register holds
        /// information about.
        ///
        /// For each EC value, the table references a subsection that gives information about:
        ///   - The cause of the exception, for example the configuration required to enable the
        ///     trap.
        ///   - The encoding of the associated ISS.
        EC  OFFSET(26) NUMBITS(6) [
            /// Unknown reason
            Unknown = 0b00_0000,
            /// Trapped WF* instruction execution
            TrappedWFIorWFE = 0b00_0001,
            /// Trapped MCR or MRC access with (coproc==0b1111) (FEAT_AA32)
            TrappedMCRorMRC = 0b00_0011,
            /// Trapped MCRR or MRRC access with (coproc==0b1111) (FEAT_AA32)
            TrappedMCRRorMRRC = 0b00_0100,
            /// Trapped MCR or MRC access with (coproc==0b1110) (FEAT_AA32)
            TrappedMCRorMRC2 = 0b00_0101,
            /// Trapped LDC or STC access (FEAT_AA32)
            TrappedLDCorSTC = 0b00_0110,
            /// Access to SME, SVE, Advanced SIMD or floating-point functionality trapped
            TrappedFP = 0b00_0111,
            /// Trapped VMRS access, from ID group trap (FEAT_AA32)
            TrappedVMRS = 0b00_1000,
            /// Trapped use of a Pointer authentication instruction (FEAT_PAuth)
            TrappedPointerAuth = 0b00_1001,
            /// Trapped execution of any instruction not covered by other EC values (FEAT_LS64/FEAT_SPEv1p5/FEAT_TRBEv1p1)
            TrappedNotCovered = 0b00_1010,
            /// Trapped MRRC access with (coproc==0b1110) (FEAT_AA32)
            TrappedMRRC = 0b00_1100,
            /// Branch Target Exception (FEAT_BTI)
            BranchTarget = 0b00_1101,
            /// Illegal Execution state
            IllegalExecutionState = 0b00_1110,
            /// SVC instruction execution in AArch32 state (FEAT_AA32)
            SVC32 = 0b01_0001,
            /// HVC instruction execution in AArch32 state (FEAT_AA32)
            HVC32 = 0b01_0010,
            /// SMC instruction execution in AArch32 state (FEAT_AA32)
            SMC32 = 0b01_0011,
            /// Trapped MSRR, MRRS or System instruction execution in AArch64 state (FEAT_SYSREG128/FEAT_SYSINSTR128)
            TrappedMSRR_MRRS = 0b01_0100,
            /// SVC instruction execution in AArch64 state (FEAT_AA64)
            SVC64 = 0b01_0101,
            /// HVC instruction execution in AArch64 state (FEAT_AA64)
            HVC64 = 0b01_0110,
            /// SMC instruction execution in AArch64 state (FEAT_AA64)
            SMC64 = 0b01_0111,
            /// Trapped MSR, MRS or System instruction execution in AArch64 state (FEAT_AA64)
            TrappedMsrMrs = 0b01_1000,
            /// Access to SVE functionality trapped (FEAT_SVE)
            TrappedSve = 0b01_1001,
            /// Trapped ERET, ERETAA, or ERETAB instruction execution (FEAT_FGT/FEAT_NV)
            TrappedERET = 0b01_1010,
            /// Exception from TSTART instruction (FEAT_TME)
            TrappedTSTART = 0b01_1011,
            /// Exception from a PAC Fail (FEAT_FPAC)
            PointerAuth = 0b01_1100,
            /// Access to SME functionality trapped (FEAT_SME)
            TrappedSME = 0b01_1101,
            /// Instruction Abort from a lower Exception level
            InstrAbortLowerEL = 0b10_0000,
            /// Instruction Abort taken without a change in Exception level
            InstrAbortCurrentEL = 0b10_0001,
            /// PC alignment fault exception
            PCAlignmentFault = 0b10_0010,
            /// Data Abort exception from a lower Exception level
            DataAbortLowerEL = 0b10_0100,
            /// Data Abort exception without a change in Exception level
            DataAbortCurrentEL = 0b10_0101,
            /// SP alignment fault exception
            SPAlignmentFault = 0b10_0110,
            /// Memory Operation Exception (FEAT_MOPS)
            MemoryOperationException = 0b10_0111,
            /// Trapped floating-point exception taken from AArch32 state (FEAT_AA32)
            TrappedFP32 = 0b10_1000,
            /// Trapped floating-point exception taken from AArch64 state (FEAT_AA64)
            TrappedFP64 = 0b10_1100,
            /// GCS exception (FEAT_GCS)
            GCSException = 0b10_1101,
            /// SError exception
            SError = 0b10_1111,
            /// Breakpoint exception from a lower Exception level
            BreakpointLowerEL = 0b11_0000,
            /// Breakpoint exception taken without a change in Exception level
            BreakpointCurrentEL = 0b11_0001,
            /// Software Step exception from a lower Exception level
            SoftwareStepLowerEL = 0b11_0010,
            /// Software Step exception taken without a change in Exception level
            SoftwareStepCurrentEL = 0b11_0011,
            /// Watchpoint exception from a lower Exception level
            WatchpointLowerEL = 0b11_0100,
            /// Watchpoint exception taken without a change in Exception level
            WatchpointCurrentEL = 0b11_0101,
            /// BKPT instruction execution in AArch32 state (FEAT_AA32)
            Bkpt32 = 0b11_1000,
            /// Vector Catch exception from AArch32 state (FEAT_AA32)
            VectorCatch32 = 0b11_1010,
            /// BRK instruction execution in AArch64 state (FEAT_AA64)
            Brk64 = 0b11_1100,
            /// Profiling exception (FEAT_EBEP/FEAT_SPE_EXC/FEAT_TRBE_EXC)
            ProfilingException = 0b11_1101
        ],

        /// Instruction Length for synchronous exceptions.
        IL  OFFSET(25) NUMBITS(1) [],

        /// Instruction Specific Syndrome. Architecturally, this field can be defined independently
        /// for each defined Exception class. However, in practice, some ISS encodings are used for
        /// more than one Exception class.
        ISS OFFSET(0)  NUMBITS(25) []
    ]
}

pub struct Reg;

impl Readable for Reg {
    type T = u64;
    type R = ESR_EL2::Register;

    sys_coproc_read_raw!(u64, "ESR_EL2", "x");
}

impl Writeable for Reg {
    type T = u64;
    type R = ();

    sys_coproc_write_raw!(u64, "ESR_EL2", "x");
}

pub const ESR_EL2: Reg = Reg {};