Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46254178
rt-thread
提交
189e9b96
R
rt-thread
项目概览
weixin_46254178
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
189e9b96
编写于
8月 09, 2016
作者:
A
ArdaFu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Kernel] add new hooks for support trace componment.
上级
a0d264ba
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
5 deletion
+88
-5
include/rtthread.h
include/rtthread.h
+12
-0
src/idle.c
src/idle.c
+13
-5
src/irq.c
src/irq.c
+30
-0
src/thread.c
src/thread.c
+33
-0
未找到文件。
include/rtthread.h
浏览文件 @
189e9b96
...
...
@@ -26,6 +26,7 @@
* 2007-03-03 Bernard clean up the definitions to rtdef.h
* 2010-04-11 yi.qiu add module feature
* 2013-06-24 Bernard add rt_kprintf re-define when not use RT_USING_CONSOLE.
* 2016-08-09 ArdaFu add new thread and interrupt hook.
*/
#ifndef __RT_THREAD_H__
...
...
@@ -153,6 +154,11 @@ rt_err_t rt_thread_suspend(rt_thread_t thread);
rt_err_t
rt_thread_resume
(
rt_thread_t
thread
);
void
rt_thread_timeout
(
void
*
parameter
);
#ifdef RT_USING_HOOK
void
rt_thread_suspend_sethook
(
void
(
*
hook
)(
rt_thread_t
thread
));
void
rt_thread_resume_sethook
(
void
(
*
hook
)(
rt_thread_t
thread
));
#endif
/*
* idle thread interface
*/
...
...
@@ -161,6 +167,7 @@ void rt_thread_idle_init(void);
void
rt_thread_idle_sethook
(
void
(
*
hook
)(
void
));
#endif
void
rt_thread_idle_excute
(
void
);
rt_thread_t
rt_thread_idle_gethandler
(
void
);
/*
* schedule service
...
...
@@ -460,6 +467,11 @@ void rt_interrupt_leave(void);
*/
rt_uint8_t
rt_interrupt_get_nest
(
void
);
#ifdef RT_USING_HOOK
void
rt_interrupt_enter_sethook
(
void
(
*
hook
)(
void
));
void
rt_interrupt_leave_sethook
(
void
(
*
hook
)(
void
));
#endif
#ifdef RT_USING_COMPONENTS_INIT
void
rt_components_init
(
void
);
void
rt_components_board_init
(
void
);
...
...
src/idle.c
浏览文件 @
189e9b96
...
...
@@ -24,6 +24,7 @@
* 2012-12-29 Bernard fix compiling warning.
* 2013-12-21 Grissiom let rt_thread_idle_excute loop until there is no
* dead thread.
* 2016-08-09 ArdaFu add method to get the handler of the idle thread.
*/
#include <rthw.h>
...
...
@@ -178,11 +179,7 @@ static void rt_thread_idle_entry(void *parameter)
{
while
(
1
)
{
#ifdef RT_USING_HOOK
if
(
rt_thread_idle_hook
!=
RT_NULL
)
rt_thread_idle_hook
();
#endif
RT_OBJECT_HOOK_CALL
(
rt_thread_idle_hook
,());
rt_thread_idle_excute
();
}
}
...
...
@@ -209,3 +206,14 @@ void rt_thread_idle_init(void)
/* startup */
rt_thread_startup
(
&
idle
);
}
/**
* @ingroup Thread
*
* This function will get the handler of the idle thread.
*
*/
rt_thread_t
rt_thread_idle_gethandler
(
void
)
{
return
(
rt_thread_t
)(
&
idle
);
}
src/irq.c
浏览文件 @
189e9b96
...
...
@@ -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
);
...
...
src/thread.c
浏览文件 @
189e9b96
...
...
@@ -35,6 +35,7 @@
* thread preempted, which reported by Jiaxing Lee.
* 2011-09-08 Bernard fixed the scheduling issue in rt_thread_startup.
* 2012-12-29 Bernard fixed compiling warning.
* 2016-08-09 ArdaFu add thread suspend and resume hook.
*/
#include <rtthread.h>
...
...
@@ -44,6 +45,36 @@ extern rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
extern
struct
rt_thread
*
rt_current_thread
;
extern
rt_list_t
rt_thread_defunct
;
#ifdef RT_USING_HOOK
static
void
(
*
rt_thread_suspend_hook
)(
rt_thread_t
thread
);
static
void
(
*
rt_thread_resume_hook
)(
rt_thread_t
thread
);
/**
* @ingroup Hook
* This function sets a hook function when the system suspend a thread.
*
* @param hook the specified hook function
*
* @note the hook function must be simple and never be blocked or suspend.
*/
void
rt_thread_suspend_sethook
(
void
(
*
hook
)(
rt_thread_t
thread
))
{
rt_thread_suspend_hook
=
hook
;
}
/**
* @ingroup Hook
* This function sets a hook function when the system resume a thread.
*
* @param hook the specified hook function
*
* @note the hook function must be simple and never be blocked or suspend.
*/
void
rt_thread_resume_sethook
(
void
(
*
hook
)(
rt_thread_t
thread
))
{
rt_thread_resume_hook
=
hook
;
}
#endif
void
rt_thread_exit
(
void
)
{
struct
rt_thread
*
thread
;
...
...
@@ -581,6 +612,7 @@ rt_err_t rt_thread_suspend(rt_thread_t thread)
/* enable interrupt */
rt_hw_interrupt_enable
(
temp
);
RT_OBJECT_HOOK_CALL
(
rt_thread_suspend_hook
,(
thread
));
return
RT_EOK
;
}
RTM_EXPORT
(
rt_thread_suspend
);
...
...
@@ -623,6 +655,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
/* insert to schedule ready list */
rt_schedule_insert_thread
(
thread
);
RT_OBJECT_HOOK_CALL
(
rt_thread_resume_hook
,(
thread
));
return
RT_EOK
;
}
RTM_EXPORT
(
rt_thread_resume
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录