Skip to content
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

add a bunch of verbosity around shared vtables #2230

Merged
merged 2 commits into from
Feb 4, 2025
Merged
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
54 changes: 54 additions & 0 deletions src/rp2_common/hardware_irq/include/hardware/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,33 @@ void irq_set_mask_n_enabled(uint n, uint32_t mask, bool enabled);
* This method will assert if there is already any sort of interrupt handler installed
* for the specified irq number.
*
* NOTE: By default, the SDK uses a single shared vector table per core, and the current installed
* IRQ handlers are effectively a linked list starting a vector table entry for a particular IRQ numbers.
kilograham marked this conversation as resolved.
Show resolved Hide resolved
* Therefore, this method (when using the same vector table for both cores) sets the same interrupt handler
* for both cores.
*
* On RP2040 this was never really a cause of any confusion, because it rarely made sense to enable
* the same interrupt number in the NVIC on both cores (see \ref irq_set_enabled()), because the interrupt
* would then fire on both cores, and the interrupt handlers would race.
*
* The problem *does* exist however when dealing with interrupts which are independent on the two cores.
*
* This includes:
*
* * the core local "spare" IRQs
* * on RP2350 the SIO FIFO IRQ which is now the same irq number for both cores (vs RP2040 where it was two)
*
* In the cases where you want to enable the same IRQ on both cores, and both cores are sharing the same vector
* table, you should install the IRQ handler once - it will be used on both cores - and check the core
* number (via \ref get_core_num()) on each core.
*
* NOTE: It is not thread safe to add/remove/handle IRQs for the same irq number in the same vector table
* from both cores concurrently.
*
* NOTE: The SDK defines a PICO_VTABLE_PER_CORE variable indicating whether the two vector tables are separate,
* however as of version 2.1.1 the user cannot set this value, and expect the vector table duplication to be handled
* for them. This functionality will be added in a future SDK version
*
* \param num Interrupt number \ref interrupt_nums
* \param handler The handler to set. See \ref irq_handler_t
* \see irq_add_shared_handler()
Expand Down Expand Up @@ -316,6 +343,33 @@ irq_handler_t irq_get_exclusive_handler(uint num);
* the (total across all IRQs on both cores) maximum (configurable via PICO_MAX_SHARED_IRQ_HANDLERS) number of shared handlers
* would be exceeded.
*
* NOTE: By default, the SDK uses a single shared vector table per core, and the current installed
* IRQ handlers are effectively a linked list starting a vector table entry for a particular IRQ numbers.
kilograham marked this conversation as resolved.
Show resolved Hide resolved
* Therefore, this method (when using the same vector table for both cores) add the same interrupt handler
* for both cores.
*
* On RP2040 this was never really a cause of any confusion, because it rarely made sense to enable
* the same interrupt number in the NVIC on both cores (see \ref irq_set_enabled()), because the interrupt
* would then fire on both cores, and the interrupt handlers would race.
*
* The problem *does* exist however when dealing with interrupts which are independent on the two cores.
*
* This includes:
*
* * the core local "spare" IRQs
* * on RP2350 the SIO FIFO IRQ which is now the same irq number for both cores (vs RP2040 where it was two)
*
* In the cases where you want to enable the same IRQ on both cores, and both cores are sharing the same vector
* table, you should install the IRQ handler once - it will be used on both cores - and check the core
* number (via \ref get_core_num()) on each core.
*
* NOTE: It is not thread safe to add/remove/handle IRQs for the same irq number in the same vector table
* from both cores concurrently.
*
* NOTE: The SDK defines a PICO_VTABLE_PER_CORE variable indicating whether the two vector tables are separate,
* however as of version 2.1.1 the user cannot set this value, and expect the vector table duplication to be handled
* for them. This functionality will be added in a future SDK version
*
* \param num Interrupt number \ref interrupt_nums
* \param handler The handler to set. See \ref irq_handler_t
* \param order_priority The order priority controls the order that handlers for the same IRQ number on the core are called.
Expand Down
Loading