summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShell <[email protected]>2024-10-30 16:57:42 +0800
committerRbb666 <[email protected]>2024-11-03 10:08:45 +0800
commit40cd8cce995e24ea265664c5db127c662a747032 (patch)
tree278e962b3f5ad6a55f0b8157fec5c1d89db99d9e /src
parent3a696ebc671cb04b41f2ba19138fc3bd42c71f37 (diff)
feat: Added rt_interrupt_context* family for nested interrupt handling
These changes introduce the rt_interrupt_context family, providing a mechanism for managing nested interrupts. The context management ensures proper storage and retrieval of interrupt states, improving reliability in nested interrupt scenarios by enabling context tracking across different interrupt levels. This enhancement is essential for platforms where nested interrupt handling is crucial, such as in real- time or multi-threaded applications. Changes: - Defined rt_interrupt_context structure with context and node fields in `rtdef.h` to support nested interrupts. - Added rt_slist_pop function in `rtservice.h` for simplified node removal in singly linked lists. - Declared rt_interrupt_context_push, rt_interrupt_context_pop, and rt_interrupt_context_get functions in `rtthread.h` to manage the interrupt/exception stack. - Modified AArch64 CPU support in `cpuport.h` to include rt_hw_show_register for debugging registers. - Refactored `_rt_hw_trap_irq` in `trap.c` for context-aware IRQ handling, with stack push/pop logic to handle nested contexts. - Implemented interrupt context push, pop, and retrieval logic in `irq.c` to manage context at the CPU level. Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/irq.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/irq.c b/src/irq.c
index fb5a50275a..f6b33a7c7b 100644
--- a/src/irq.c
+++ b/src/irq.c
@@ -14,6 +14,7 @@
* 2022-07-04 Yunjie fix RT_DEBUG_LOG
* 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable
* 2024-01-05 Shell Fixup of data racing in rt_interrupt_get_nest
+ * 2024-01-03 Shell Support for interrupt context
*/
#include <rthw.h>
@@ -69,6 +70,25 @@ void rt_interrupt_leave_sethook(void (*hook)(void))
volatile rt_atomic_t rt_interrupt_nest = 0;
#endif /* RT_USING_SMP */
+#ifdef ARCH_USING_IRQ_CTX_LIST
+void rt_interrupt_context_push(rt_interrupt_context_t this_ctx)
+{
+ struct rt_cpu *this_cpu = rt_cpu_self();
+ rt_slist_insert(&this_cpu->irq_ctx_head, &this_ctx->node);
+}
+
+void rt_interrupt_context_pop(void)
+{
+ struct rt_cpu *this_cpu = rt_cpu_self();
+ rt_slist_pop(&this_cpu->irq_ctx_head);
+}
+
+void *rt_interrupt_context_get(void)
+{
+ struct rt_cpu *this_cpu = rt_cpu_self();
+ return rt_slist_first_entry(&this_cpu->irq_ctx_head, struct rt_interrupt_context, node)->context;
+}
+#endif /* ARCH_USING_IRQ_CTX_LIST */
/**
* @brief This function will be invoked by BSP, when enter interrupt service routine