summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-11-20 23:13:45 +0800
committerGitHub <[email protected]>2018-11-20 23:13:45 +0800
commit46dae3f35f5cc44664a26ebd87803156033a166a (patch)
tree47f132d0a7472768deabd2add67d990c0c6e64e7 /src
parentb31888de49408b212d2aeab4b40b2a672b958313 (diff)
parent6b6d122e3673ca64d2171d3daf1ae940edfa699a (diff)
Merge branch 'master' into dev-4.0.x
Diffstat (limited to 'src')
-rw-r--r--src/Kconfig7
-rw-r--r--src/components.c6
-rw-r--r--src/scheduler.c10
-rw-r--r--src/signal.c18
-rw-r--r--src/thread.c6
-rw-r--r--src/timer.c28
6 files changed, 54 insertions, 21 deletions
diff --git a/src/Kconfig b/src/Kconfig
index d3889f4211..78a3bf6d67 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -51,11 +51,16 @@ config RT_USING_OVERFLOW_CHECK
config RT_USING_HOOK
bool "Enable system hook"
default y
+ select RT_USING_IDLE_HOOK
help
Enable the hook function when system running, such as idle thread hook,
thread context switch etc.
- if RT_USING_HOOK
+config RT_USING_IDLE_HOOK
+ bool "Enable IDLE Task hook"
+ default y if RT_USING_HOOK
+
+ if RT_USING_IDLE_HOOK
config RT_IDEL_HOOK_LIST_SIZE
int "The max size of idel hook list"
default 4
diff --git a/src/components.c b/src/components.c
index 679a88ef11..68e5799f59 100644
--- a/src/components.c
+++ b/src/components.c
@@ -44,7 +44,7 @@
*
* rti_end --> 6.end
*
- * These automatically initializaiton, the driver or component initial function must
+ * These automatically initialization, the driver or component initial function must
* be defined with:
* INIT_BOARD_EXPORT(fn);
* INIT_DEVICE_EXPORT(fn);
@@ -109,7 +109,7 @@ void rt_components_init(void)
int result;
const struct rt_init_desc *desc;
- rt_kprintf("do components intialization.\n");
+ rt_kprintf("do components initialization.\n");
for (desc = &__rt_init_desc_rti_board_end; desc < &__rt_init_desc_rti_end; desc ++)
{
rt_kprintf("initialize %s", desc->fn_name);
@@ -215,7 +215,7 @@ int rtthread_startup(void)
{
rt_hw_interrupt_disable();
- /* board level initalization
+ /* board level initialization
* NOTE: please initialize heap inside board initialization.
*/
rt_hw_board_init();
diff --git a/src/scheduler.c b/src/scheduler.c
index 446b153e1b..fd068a6671 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -91,11 +91,19 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread)
level = rt_hw_interrupt_disable();
while (level);
}
+#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
+ else if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size))
+ {
+ rt_kprintf("warning: %s stack is close to the top of stack address.\n",
+ thread->name);
+ }
+#else
else if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32))
{
- rt_kprintf("warning: %s stack is close to end of stack address.\n",
+ rt_kprintf("warning: %s stack is close to the bottom of stack address.\n",
thread->name);
}
+#endif
}
#endif
diff --git a/src/signal.c b/src/signal.c
index c783420514..890f16f497 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -41,7 +41,7 @@ void rt_thread_handle_sig(rt_bool_t clean_state);
static void _signal_default_handler(int signo)
{
- dbg_log(DBG_INFO, "handled signo[%d] with default action.\n", signo);
+ LOG_I("handled signo[%d] with default action.", signo);
return ;
}
@@ -60,7 +60,7 @@ static void _signal_entry(void *parameter)
tid->sp = tid->sig_ret;
tid->sig_ret = RT_NULL;
- dbg_log(DBG_LOG, "switch back to: 0x%08x\n", tid->sp);
+ LOG_D("switch back to: 0x%08x", tid->sp);
tid->stat &= ~RT_THREAD_STAT_SIGNAL;
rt_hw_context_switch_to((rt_uint32_t) & (tid->sp));
@@ -119,7 +119,7 @@ static void _signal_deliver(rt_thread_t tid)
(void *)((char *)tid->sig_ret - 32), RT_NULL);
rt_hw_interrupt_enable(level);
- dbg_log(DBG_LOG, "signal stack pointer @ 0x%08x\n", tid->sp);
+ LOG_D("signal stack pointer @ 0x%08x", tid->sp);
/* re-schedule */
rt_schedule();
@@ -268,7 +268,7 @@ __done:
{
*si = si_node->si;
- dbg_log(DBG_LOG, "sigwait: %d sig raised!\n", signo);
+ LOG_D("sigwait: %d sig raised!", signo);
if (si_prev) si_prev->list.next = si_node->list.next;
else tid->si_list = si_node->list.next;
@@ -320,7 +320,7 @@ void rt_thread_handle_sig(rt_bool_t clean_state)
handler = tid->sig_vectors[signo];
rt_hw_interrupt_enable(level);
- dbg_log(DBG_LOG, "handle signal: %d, handler 0x%08x\n", signo, handler);
+ LOG_D("handle signal: %d, handler 0x%08x", signo, handler);
if (handler) handler(signo);
level = rt_hw_interrupt_disable();
@@ -378,7 +378,7 @@ void rt_thread_free_sig(rt_thread_t tid)
struct rt_slist_node *node;
struct siginfo_node *si_node;
- dbg_log(DBG_LOG, "free signal info list\n");
+ LOG_D("free signal info list");
node = &(si_list->list);
do
{
@@ -404,7 +404,7 @@ int rt_thread_kill(rt_thread_t tid, int sig)
RT_ASSERT(tid != RT_NULL);
if (!sig_valid(sig)) return -RT_EINVAL;
- dbg_log(DBG_INFO, "send signal: %d\n", sig);
+ LOG_I("send signal: %d", sig);
si.si_signo = sig;
si.si_code = SI_USER;
si.si_value.sival_ptr = RT_NULL;
@@ -462,7 +462,7 @@ int rt_thread_kill(rt_thread_t tid, int sig)
}
else
{
- dbg_log(DBG_ERROR, "The allocation of signal info node failed.\n");
+ LOG_E("The allocation of signal info node failed.");
}
/* deliver signal to this thread */
@@ -476,7 +476,7 @@ int rt_system_signal_init(void)
_rt_siginfo_pool = rt_mp_create("signal", RT_SIG_INFO_MAX, sizeof(struct siginfo_node));
if (_rt_siginfo_pool == RT_NULL)
{
- dbg_log(DBG_ERROR, "create memory pool for signal info failed.\n");
+ LOG_E("create memory pool for signal info failed.");
RT_ASSERT(0);
}
diff --git a/src/thread.c b/src/thread.c
index 82eb18942c..07c7619c6f 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -136,9 +136,15 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread,
/* init thread stack */
rt_memset(thread->stack_addr, '#', thread->stack_size);
+#ifdef ARCH_CPU_STACK_GROWS_UPWARD
+ thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter,
+ (void *)((char *)thread->stack_addr),
+ (void *)rt_thread_exit);
+#else
thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter,
(void *)((char *)thread->stack_addr + thread->stack_size - sizeof(rt_ubase_t)),
(void *)rt_thread_exit);
+#endif
/* priority init */
RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX);
diff --git a/src/timer.c b/src/timer.c
index dc489a2d0d..fd938065db 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -43,7 +43,8 @@ static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
#ifdef RT_USING_HOOK
extern void (*rt_object_take_hook)(struct rt_object *object);
extern void (*rt_object_put_hook)(struct rt_object *object);
-static void (*rt_timer_timeout_hook)(struct rt_timer *timer);
+static void (*rt_timer_enter_hook)(struct rt_timer *timer);
+static void (*rt_timer_exit_hook)(struct rt_timer *timer);
/**
* @addtogroup Hook
@@ -52,14 +53,25 @@ static void (*rt_timer_timeout_hook)(struct rt_timer *timer);
/**@{*/
/**
- * This function will set a hook function, which will be invoked when timer
- * is timeout.
+ * This function will set a hook function, which will be invoked when enter
+ * timer timeout callback function.
*
* @param hook the hook function
*/
-void rt_timer_timeout_sethook(void (*hook)(struct rt_timer *timer))
+void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer))
{
- rt_timer_timeout_hook = hook;
+ rt_timer_enter_hook = hook;
+}
+
+/**
+ * This function will set a hook function, which will be invoked when exit
+ * timer timeout callback function.
+ *
+ * @param hook the hook function
+ */
+void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
+{
+ rt_timer_exit_hook = hook;
}
/**@}*/
@@ -503,7 +515,7 @@ void rt_timer_check(void)
*/
if ((current_tick - t->timeout_tick) < RT_TICK_MAX / 2)
{
- RT_OBJECT_HOOK_CALL(rt_timer_timeout_hook, (t));
+ RT_OBJECT_HOOK_CALL(rt_timer_enter_hook, (t));
/* remove timer from timer list firstly */
_rt_timer_remove(t);
@@ -514,6 +526,7 @@ void rt_timer_check(void)
/* re-get tick */
current_tick = rt_tick_get();
+ RT_OBJECT_HOOK_CALL(rt_timer_exit_hook, (t));
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
if ((t->parent.flag & RT_TIMER_FLAG_PERIODIC) &&
@@ -578,7 +591,7 @@ void rt_soft_timer_check(void)
*/
if ((current_tick - t->timeout_tick) < RT_TICK_MAX / 2)
{
- RT_OBJECT_HOOK_CALL(rt_timer_timeout_hook, (t));
+ RT_OBJECT_HOOK_CALL(rt_timer_enter_hook, (t));
/* move node to the next */
n = n->next;
@@ -594,6 +607,7 @@ void rt_soft_timer_check(void)
/* re-get tick */
current_tick = rt_tick_get();
+ RT_OBJECT_HOOK_CALL(rt_timer_exit_hook, (t));
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
/* lock scheduler */