Skip to content

add new M33 processor exception handlers #2482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/rp2_common/cmsis/include/cmsis/rename_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@
#if PICO_RP2350
#define isr_nmi NMI_Handler
#define isr_hardfault HardFault_Handler
#define isr_memmanage MemManage_Handler
#define isr_busfault BusFault_Handler
#define isr_usagefault UsageFault_Handler
#define isr_securefault SecureFault_Handler
#define isr_svcall SVC_Handler
#define isr_debugmonitor DebugMon_Handler
#define isr_pendsv PendSV_Handler
#define isr_systick SysTick_Handler
#define isr_irq0 TIMER0_IRQ_0_Handler
Expand Down
27 changes: 25 additions & 2 deletions src/rp2_common/pico_crt0/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,26 @@ __vectors:
#else
.word isr_nmi
.word isr_hardfault
#if PICO_RP2040
.word isr_invalid // Reserved, should never fire
.word isr_invalid // Reserved, should never fire
.word isr_invalid // Reserved, should never fire
.word isr_invalid // Reserved, should never fire
#else
.word isr_memmanage
.word isr_busfault
.word isr_usagefault
.word isr_securefault
#endif
Comment on lines +55 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick, but it kinda feels like isr_memmanage is a "specific" action, and isr_invalid is a "default" action, so I wonder if it might make more sense to write this as:

#if PICO_RP2350
.word isr_memmanage
.word isr_busfault
.word isr_usagefault
.word isr_securefault
#else
.word isr_invalid // Reserved, should never fire
.word isr_invalid // Reserved, should never fire
.word isr_invalid // Reserved, should never fire
.word isr_invalid // Reserved, should never fire
#endif

? 🤷

.word isr_invalid // Reserved, should never fire
.word isr_invalid // Reserved, should never fire
.word isr_invalid // Reserved, should never fire
.word isr_svcall
#if PICO_RP2040
.word isr_invalid // Reserved, should never fire
#else
.word isr_debugmonitor
#endif
.word isr_invalid // Reserved, should never fire
.word isr_pendsv
.word isr_systick
Expand Down Expand Up @@ -287,8 +298,20 @@ if_irq_decl 79 isr_irq79
#if PICO_NUM_VTABLE_IRQS > 80
#error more IRQ entries required
#endif
#if !PICO_RP2040
// since these are disabled by default, map them all to __unhandled_user_irq (will have
// a negative number
decl_isr isr_memmanage
decl_isr isr_busfault
decl_isr isr_usagefault
decl_isr isr_securefault
decl_isr isr_debugmonitor
#endif

// All unhandled USER IRQs fall through to here
// All unhandled USER IRQs fall through to here.
// Additionally, if the Armv9-M MemManage/BusFault/UsageFault/SescureFault/DebugMonitor exceptions
// are enabled, but the handlers are not defined, then unhandled_user_irq_num_in_r0 will
// also be reached, but with a negative exception number (e.g. MemManage == -12)
.global __unhandled_user_irq
.thumb_func
__unhandled_user_irq:
Expand All @@ -305,7 +328,7 @@ unhandled_user_irq_num_in_r0:

decl_isr_bkpt isr_invalid
#if !PICO_MINIMAL_STORED_VECTOR_TABLE
// these are separated out for clarity
// these are separated out into individual BKPT instructions with label for clarity
decl_isr_bkpt isr_nmi
decl_isr_bkpt isr_hardfault
decl_isr_bkpt isr_svcall
Expand Down
Loading