You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cortex-R5/GNU: Add GIC support with deferred EOI for level-triggered IRQs
Add optional GIC (Generic Interrupt Controller) support for the
Cortex-R5 port, targeting GICv2 platforms such as the Xilinx Zynq
UltraScale+ RPU.
tx_thread_context_restore.S:
Add TX_GIC_DEFERRED_EOI support. When enabled, GICC_EOIR is written
AFTER CPSID in context_restore rather than in the IRQ handler. This
closes the race window where a level-triggered interrupt re-triggers
between EOIR and CPSID. After EOI, _tx_gic_iar is invalidated (set
to 1023/spurious) to prevent duplicate EOIs on voluntary context
switches (tx_thread_sleep, mutex wait, etc.).
Constraints: single-core only (global _tx_gic_iar), incompatible
with TX_ENABLE_IRQ_NESTING, GICv2 only.
example_build/tx_initialize_low_level.S:
Add reference GIC initialization (_tx_gic_initialize), IRQ dispatch
with handler table support, deferred EOI storage, and runtime handler
registration API. Guarded by TX_ENABLE_GIC_SUPPORT. Base addresses
configurable via TX_GIC_DISTRIBUTOR_BASE / TX_GIC_CPU_INTERFACE_BASE.
README.md:
Document GIC support including base address discovery, initialization
sequence, API reference, deferred EOI pattern, and platform-specific
configuration for ZynqMP RPU.
Copy file name to clipboardExpand all lines: ports/cortex_r5/gnu/README.md
+298Lines changed: 298 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1864,3 +1864,301 @@ If reconfiguring hardware from lockstep → SMP:
1864
1864
ThreadX requires a periodic interrupt source to manage all time-slicing, thread sleeps, timeouts, and application timers. Without such a timer interrupt source, these services are not functional but the remainder of ThreadX will still run.
1865
1865
1866
1866
To add the timer interrupt processing, simply make a call to `_tx_timer_interrupt` in the IRQ processing. An example of this can be found in the file `tx_initialize_low_level.S` for the demonstration system.
1867
+
1868
+
## 11. GIC (Generic Interrupt Controller) Support
1869
+
1870
+
The Cortex-R5 port includes optional GIC (Generic Interrupt Controller) initialization and IRQ dispatch support. This is essential for systems using ARM GIC v1/v2 interrupt controllers, such as the Xilinx Zynq UltraScale+ RPU.
Handler table size is `TX_GIC_MAX_INTERRUPTS * 4` bytes (default: 768 bytes for 192 interrupts).
2004
+
2005
+
### 11.6 IRQ Handler Flow
2006
+
2007
+
```
2008
+
IRQ Exception
2009
+
│
2010
+
├─► _tx_thread_context_save (save thread context)
2011
+
│
2012
+
├─► Read GICC_IAR (acknowledge interrupt, get ID)
2013
+
│ │
2014
+
│ ├─► ID >= 1020? ──► Yes ──► Spurious, exit
2015
+
│ │
2016
+
│ └─► ID < 1020? ──► Dispatch to handler
2017
+
│ │
2018
+
│ └─► Write GICC_EOIR (signal completion)
2019
+
│
2020
+
└─► _tx_thread_context_restore (restore context, may switch threads)
2021
+
```
2022
+
2023
+
**CRITICAL: IAR/EOIR Pairing**
2024
+
2025
+
The value written to GICC_EOIR **must** be the exact value read from GICC_IAR, including the CPU ID bits (bits 12:10) for SGIs. Failure to do so causes interrupt handling errors.
2026
+
2027
+
### 11.7 Timer Interrupt Configuration
2028
+
2029
+
The default timer interrupt ID is PPI #29 (Private Timer). Override for your platform:
2030
+
2031
+
```bash
2032
+
-DTX_GIC_TIMER_IRQ=27 # Example: Use IRQ 27 for timer
3. Configure interrupt groups: Write GICD_IGROUPR to assign interrupts to Group 0 (FIQ) or Group 1 (IRQ)
2103
+
2104
+
**Typical ZynqMP RPU Usage:**
2105
+
Most applications use all interrupts through IRQ. The default configuration is appropriate for:
2106
+
- Timer interrupts (PPI #29 or TTC)
2107
+
- UART, SPI, I2C peripherals
2108
+
- DMA completion interrupts
2109
+
- Inter-processor interrupts (IPI)
2110
+
2111
+
If dedicated low-latency FIQ is needed for a specific source not requiring GIC features, use `TX_ENABLE_FIQ_SUPPORT` with direct FIQ pin routing, bypassing GIC entirely
For platforms with level-triggered interrupts, there is a race window between the EOIR write in the IRQ handler and the CPSID in `_tx_thread_context_restore`. If the peripheral still asserts the interrupt signal, the interrupt can re-trigger before interrupts are masked.
0 commit comments