Repository: raspberrypi/pico-sdk
File: src/rp2_common/hardware_exception/include/hardware/exception.h (C/C++)

Code before:
 *
 * \note That all exception APIs affect the executing core only (i.e. the core calling the function).
 */

// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION, Enable/disable assertions in the hardware_exception module, type=bool, default=0, group=hardware_exception
#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION
#ifdef PARAM_ASSERTIONS_ENABLED_EXCEPTION // backwards compatibility with SDK < 2.0.0
#define PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION PARAM_ASSERTIONS_ENABLED_EXCEPTION
#else
#define PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION 0
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif

/*! \brief  Exception number definitions
 *
 * On Arm these are vector table indices:
 *
 * Name                 | Value | Exception
 * ---------------------|-------|-----------------------
 * NMI_EXCEPTION        | 2     | Non Maskable Interrupt
 * HARDFAULT_EXCEPTION  | 3     | HardFault
 * \if rp2350_specific
 * MEMFAULT_EXCEPTION   | 4     | MemFault
 * BUSFAULT_EXCEPTION   | 5     | BusFault
 * USGFAULT_EXCEPTION   | 6     | UsageFault
 * \endif
 * SVCALL_EXCEPTION     | 11    | SV Call
 * PENDSV_EXCEPTION     | 14    | Pend SV
 * SYSTICK_EXCEPTION    | 15    | System Tick
 *
 * \if rp2350_specific
 * On RISC-V these are exception cause numbers:
 *
 * Name                    | Value | Exception
 * ------------------------|-------|-----------------------------
 * INSTR_ALIGN_EXCEPTION   | 0     | Instruction fetch misaligned
 * INSTR_FAULT_EXCEPTION   | 1     | Instruction fetch bus fault
 * INSTR_ILLEGAL_EXCEPTION | 2     | Invalid or illegal instruction
 * EBREAK_EXCEPTION        | 3     | ebreak was not caught by an ex
 * LOAD_ALIGN_EXCEPTION    | 4     | Load address not naturally ali
 * LOAD_FAULT_EXCEPTION    | 5     | Load bus fault
 * STORE_ALIGN_EXCEPTION   | 6     | Store or AMO address not natur
 * STORE_FAULT_EXCEPTION   | 7     | Store or AMO bus fault
 * ECALL_UMODE_EXCEPTION   | 8     | ecall was executed in U-mode
 * ECALL_SMODE_EXCEPTION   | 9     | ecall was executed in S-mode
 * ECALL_MMODE_EXCEPTION   | 11    | ecall was executed in M-mode
 * \endif
 *

Review comment (suggestion):
I think the actual exception names are:

MemManage, BusFault, UsageFault (and SecureFault (12) which we shoul add too)

![image](https://github.com/user-attachments/assets/c7bebac2-05fc-4247-bfaf-0a52f3cf6bf4)


Code after:
 *
 * \note That all exception APIs affect the executing core only (i.e. the core calling the function).
 */

// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION, Enable/disable assertions in the hardware_exception module, type=bool, default=0, group=hardware_exception
#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION
#ifdef PARAM_ASSERTIONS_ENABLED_EXCEPTION // backwards compatibility with SDK < 2.0.0
#define PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION PARAM_ASSERTIONS_ENABLED_EXCEPTION
#else
#define PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION 0
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif

/*! \brief  Exception number definitions
 *
 * On Arm these are vector table indices:
 *
 * Name                  | Value | Exception
 * ----------------------|-------|-----------------------
 * NMI_EXCEPTION         | 2     | Non Maskable Interrupt
 * HARDFAULT_EXCEPTION   | 3     | HardFault
 * \if rp2350_specific
 * MEMMANAGE_EXCEPTION   | 4     | MemManage
 * BUSFAULT_EXCEPTION    | 5     | BusFault
 * USAGEFAULT_EXCEPTION  | 6     | UsageFault
 * SECUREFAULT_EXCEPTION | 7     | SecureFault
 * \endif
 * SVCALL_EXCEPTION      | 11    | SV Call
 * PENDSV_EXCEPTION      | 14    | Pend SV
 * SYSTICK_EXCEPTION     | 15    | System Tick
 *
 * \if rp2350_specific
 * On RISC-V these are exception cause numbers:
 *
 * Name                    | Value | Exception
 * ------------------------|-------|-----------------------------
 * INSTR_ALIGN_EXCEPTION   | 0     | Instruction fetch misaligned
 * INSTR_FAULT_EXCEPTION   | 1     | Instruction fetch bus fault
 * INSTR_ILLEGAL_EXCEPTION | 2     | Invalid or illegal instruction
 * EBREAK_EXCEPTION        | 3     | ebreak was not caught by an ex
 * LOAD_ALIGN_EXCEPTION    | 4     | Load address not naturally ali
 * LOAD_FAULT_EXCEPTION    | 5     | Load bus fault
 * STORE_ALIGN_EXCEPTION   | 6     | Store or AMO address not natur
 * STORE_FAULT_EXCEPTION   | 7     | Store or AMO bus fault
 * ECALL_UMODE_EXCEPTION   | 8     | ecall was executed in U-mode
 * ECALL_SMODE_EXCEPTION   | 9     | ecall was executed in S-mode
 * ECALL_MMODE_EXCEPTION   | 11    | ecall was executed in M-mode
 * \endif