diff options
| author | ArdaFu <[email protected]> | 2016-08-09 11:29:11 +0800 |
|---|---|---|
| committer | ArdaFu <[email protected]> | 2016-08-09 11:29:11 +0800 |
| commit | 189e9b9632abca70c3a78403a9ad737dfd471da8 (patch) | |
| tree | ba0b9c77564ff7a7f4adb3712a925461fe1a7048 /src/irq.c | |
| parent | a0d264ba7245fb9ddbd2bf45652286655499066c (diff) | |
[Kernel] add new hooks for support trace componment.
Diffstat (limited to 'src/irq.c')
| -rw-r--r-- | src/irq.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -21,11 +21,39 @@ * Date Author Notes * 2006-02-24 Bernard first version * 2006-05-03 Bernard add IRQ_DEBUG + * 2016-08-09 ArdaFu add interrupt enter and leave hook. */ #include <rthw.h> #include <rtthread.h> +#ifdef RT_USING_HOOK + +static void (*rt_interrupt_enter_hook)(void); +static void (*rt_interrupt_leave_hook)(void); + +/** + * @ingroup Hook + * This function set a hook function when the system enter a interrupt + * + * @note the hook function must be simple and never be blocked or suspend. + */ +void rt_interrupt_enter_sethook(void (*hook)(void)) +{ + rt_interrupt_enter_hook = hook; +} +/** + * @ingroup Hook + * This function set a hook function when the system exit a interrupt. + * + * @note the hook function must be simple and never be blocked or suspend. + */ +void rt_interrupt_leave_sethook(void (*hook)(void)) +{ + rt_interrupt_leave_hook = hook; +} +#endif + /* #define IRQ_DEBUG */ /** @@ -52,6 +80,7 @@ void rt_interrupt_enter(void) level = rt_hw_interrupt_disable(); rt_interrupt_nest ++; + RT_OBJECT_HOOK_CALL(rt_interrupt_enter_hook,()); rt_hw_interrupt_enable(level); } RTM_EXPORT(rt_interrupt_enter); @@ -72,6 +101,7 @@ void rt_interrupt_leave(void) level = rt_hw_interrupt_disable(); rt_interrupt_nest --; + RT_OBJECT_HOOK_CALL(rt_interrupt_leave_hook,()); rt_hw_interrupt_enable(level); } RTM_EXPORT(rt_interrupt_leave); |
