Skip to content
Closed
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions src/rp2_common/pico_crt0/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ __vectors:
// we don't include any IRQ vectors; we will initialize them during runtime_init in the RAM vector table
#else

#ifndef PICO_VECTOR_TABLE_NUM_IRQS
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs a PICO_CONFIG comment

Copy link
Contributor

Choose a reason for hiding this comment

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

Note i was going to suggest we say you cannot use the IRQ at all, which is because there will be garbage in the table which will confuse set_exclusive_irq_handler or do the wrong thing for add_shared_irq_handler

That said perhaps instead we should (as part of this fix) change runtime_init_install_ram_vector_table() to copy the provided amount of IRQs and clear the rest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pushed a change which solves this in a different way, by setting the PICO_RAM_VECTOR_TABLE_SIZE correctly based on PICO_VECTOR_TABLE_NUM_IRQS, and then checking against PICO_VECTOR_TABLE_NUM_IRQS in check_irq_param - I think this should prevent use of any IRQs which don't have vectors in the vector table?

Copy link
Contributor

Choose a reason for hiding this comment

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

check_irq_param uses invalid_params_if which I think means that it'll become a no-op in release builds? (but I dunno if that's a problem or not)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, yeah, I think upon further thought what I actually want is a way to disable all IRQ vectors, to create a minimal vector table. I'll submit a new PR with that

#define PICO_VECTOR_TABLE_NUM_IRQS NUM_IRQS
#endif

.macro if_irq_word num func
.if \num < NUM_IRQS
.if \num < PICO_VECTOR_TABLE_NUM_IRQS
.word \func
.endif
.endm
Expand Down Expand Up @@ -142,7 +146,7 @@ if_irq_word 76 isr_irq76
if_irq_word 77 isr_irq77
if_irq_word 78 isr_irq78
if_irq_word 79 isr_irq79
#if NUM_IRQS > 80
#if PICO_VECTOR_TABLE_NUM_IRQS > 80
#error more IRQ entries required
#endif
#endif
Expand Down
Loading