diff --git a/src/rp2_common/pico_platform/include/pico/platform.h b/src/rp2_common/pico_platform/include/pico/platform.h index 1d9e1bc..d930e56 100644 --- a/src/rp2_common/pico_platform/include/pico/platform.h +++ b/src/rp2_common/pico_platform/include/pico/platform.h @@ -396,7 +396,11 @@ __force_inline static int32_t __mul_instruction(int32_t a, int32_t b) { * * \return the exception number if the CPU is handling an exception, or 0 otherwise */ -uint __get_current_exception(void); +inline uint __get_current_exception(void) { + uint exception; + asm ("mrs %0, ipsr" : "=l" (exception)); + return exception; +} #define WRAPPER_FUNC(x) __wrap_ ## x #define REAL_FUNC(x) __real_ ## x diff --git a/src/rp2_common/pico_standard_link/crt0.S b/src/rp2_common/pico_standard_link/crt0.S index b2992f6..37a2d26 100644 --- a/src/rp2_common/pico_standard_link/crt0.S +++ b/src/rp2_common/pico_standard_link/crt0.S @@ -8,6 +8,7 @@ #include "hardware/regs/m0plus.h" #include "hardware/regs/addressmap.h" #include "hardware/regs/sio.h" +#include "pico/asm_helper.S" #include "pico/binary_info/defs.h" #ifdef NDEBUG @@ -147,7 +148,7 @@ decl_isr isr_irq31 .global __unhandled_user_irq .thumb_func __unhandled_user_irq: - bl __get_current_exception + mrs r0, ipsr subs r0, #16 .global unhandled_user_irq_num_in_r0 unhandled_user_irq_num_in_r0: @@ -325,13 +326,6 @@ hold_non_core0_in_bootrom: bl rom_func_lookup bx r0 -.global __get_current_exception -.thumb_func -__get_current_exception: - mrs r0, ipsr - uxtb r0, r0 - bx lr - // ---------------------------------------------------------------------------- // Stack/heap dummies to set size