summaryrefslogtreecommitdiff
path: root/libcpu/arm
diff options
context:
space:
mode:
authorfenghuijie <[email protected]>2021-07-05 18:33:22 +0800
committerfenghuijie <[email protected]>2021-07-05 18:33:22 +0800
commit0015af02e4f08ab47f2d2fefcb7c1aca1682bfda (patch)
treefded7632c1ea03699173ce94ba627544669786f1 /libcpu/arm
parente933c1f6105caf4e68bd57bc5521767b32063a5f (diff)
调整代码,以支持cpu usage
Diffstat (limited to 'libcpu/arm')
-rw-r--r--libcpu/arm/cortex-a/interrupt.c14
-rw-r--r--libcpu/arm/cortex-a/start_gcc.S2
2 files changed, 16 insertions, 0 deletions
diff --git a/libcpu/arm/cortex-a/interrupt.c b/libcpu/arm/cortex-a/interrupt.c
index 474a23fee1..f90f1c0094 100644
--- a/libcpu/arm/cortex-a/interrupt.c
+++ b/libcpu/arm/cortex-a/interrupt.c
@@ -27,6 +27,20 @@ struct rt_irq_desc isr_table[MAX_HANDLERS];
rt_uint32_t rt_interrupt_from_thread = 0;
rt_uint32_t rt_interrupt_to_thread = 0;
rt_uint32_t rt_thread_switch_interrupt_flag = 0;
+
+#ifdef RT_USING_HOOK
+static void (*rt_interrupt_switch_hook)(void);
+
+void rt_interrupt_switch_sethook(void (*hook)(void))
+{
+ rt_interrupt_switch_hook = hook;
+}
+#endif
+
+void rt_interrupt_hook(void)
+{
+ RT_OBJECT_HOOK_CALL(rt_interrupt_switch_hook, ());
+}
#endif
const unsigned int VECTOR_BASE = 0x00;
diff --git a/libcpu/arm/cortex-a/start_gcc.S b/libcpu/arm/cortex-a/start_gcc.S
index 6c5dd81785..908468476e 100644
--- a/libcpu/arm/cortex-a/start_gcc.S
+++ b/libcpu/arm/cortex-a/start_gcc.S
@@ -341,6 +341,8 @@ rt_hw_context_switch_interrupt_do:
ldr r6, [r6]
ldr sp, [r6] @ get new task's stack pointer
+ bl rt_interrupt_hook
+
#ifdef RT_USING_FPU
/* fpu context */
ldmfd sp!, {r6}