Skip to content

Commit 7d450bf

Browse files
authored
add a bunch of verbosity around shared vtables (#2230)
1 parent b51fa1b commit 7d450bf

File tree

1 file changed

+54
-0
lines changed
  • src/rp2_common/hardware_irq/include/hardware

1 file changed

+54
-0
lines changed

src/rp2_common/hardware_irq/include/hardware/irq.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,33 @@ void irq_set_mask_n_enabled(uint n, uint32_t mask, bool enabled);
286286
* This method will assert if there is already any sort of interrupt handler installed
287287
* for the specified irq number.
288288
*
289+
* NOTE: By default, the SDK uses a single shared vector table per core, and the current installed
290+
* IRQ handlers are effectively a linked list starting a vector table entry for a particular IRQ number.
291+
* Therefore, this method (when using the same vector table for both cores) sets the same interrupt handler
292+
* for both cores.
293+
*
294+
* On RP2040 this was never really a cause of any confusion, because it rarely made sense to enable
295+
* the same interrupt number in the NVIC on both cores (see \ref irq_set_enabled()), because the interrupt
296+
* would then fire on both cores, and the interrupt handlers would race.
297+
*
298+
* The problem *does* exist however when dealing with interrupts which are independent on the two cores.
299+
*
300+
* This includes:
301+
*
302+
* * the core local "spare" IRQs
303+
* * on RP2350 the SIO FIFO IRQ which is now the same irq number for both cores (vs RP2040 where it was two)
304+
*
305+
* In the cases where you want to enable the same IRQ on both cores, and both cores are sharing the same vector
306+
* table, you should install the IRQ handler once - it will be used on both cores - and check the core
307+
* number (via \ref get_core_num()) on each core.
308+
*
309+
* NOTE: It is not thread safe to add/remove/handle IRQs for the same irq number in the same vector table
310+
* from both cores concurrently.
311+
*
312+
* NOTE: The SDK defines a PICO_VTABLE_PER_CORE variable indicating whether the two vector tables are separate,
313+
* however as of version 2.1.1 the user cannot set this value, and expect the vector table duplication to be handled
314+
* for them. This functionality will be added in a future SDK version
315+
*
289316
* \param num Interrupt number \ref interrupt_nums
290317
* \param handler The handler to set. See \ref irq_handler_t
291318
* \see irq_add_shared_handler()
@@ -316,6 +343,33 @@ irq_handler_t irq_get_exclusive_handler(uint num);
316343
* the (total across all IRQs on both cores) maximum (configurable via PICO_MAX_SHARED_IRQ_HANDLERS) number of shared handlers
317344
* would be exceeded.
318345
*
346+
* NOTE: By default, the SDK uses a single shared vector table per core, and the current installed
347+
* IRQ handlers are effectively a linked list starting a vector table entry for a particular IRQ number.
348+
* Therefore, this method (when using the same vector table for both cores) add the same interrupt handler
349+
* for both cores.
350+
*
351+
* On RP2040 this was never really a cause of any confusion, because it rarely made sense to enable
352+
* the same interrupt number in the NVIC on both cores (see \ref irq_set_enabled()), because the interrupt
353+
* would then fire on both cores, and the interrupt handlers would race.
354+
*
355+
* The problem *does* exist however when dealing with interrupts which are independent on the two cores.
356+
*
357+
* This includes:
358+
*
359+
* * the core local "spare" IRQs
360+
* * on RP2350 the SIO FIFO IRQ which is now the same irq number for both cores (vs RP2040 where it was two)
361+
*
362+
* In the cases where you want to enable the same IRQ on both cores, and both cores are sharing the same vector
363+
* table, you should install the IRQ handler once - it will be used on both cores - and check the core
364+
* number (via \ref get_core_num()) on each core.
365+
*
366+
* NOTE: It is not thread safe to add/remove/handle IRQs for the same irq number in the same vector table
367+
* from both cores concurrently.
368+
*
369+
* NOTE: The SDK defines a PICO_VTABLE_PER_CORE variable indicating whether the two vector tables are separate,
370+
* however as of version 2.1.1 the user cannot set this value, and expect the vector table duplication to be handled
371+
* for them. This functionality will be added in a future SDK version
372+
*
319373
* \param num Interrupt number \ref interrupt_nums
320374
* \param handler The handler to set. See \ref irq_handler_t
321375
* \param order_priority The order priority controls the order that handlers for the same IRQ number on the core are called.

0 commit comments

Comments
 (0)