summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scheduler.c10
-rw-r--r--src/thread.c6
2 files changed, 15 insertions, 1 deletions
diff --git a/src/scheduler.c b/src/scheduler.c
index 95b5d487df..0b8b54ae92 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_uint32_t)thread->sp > ((rt_uint32_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_uint32_t)thread->sp <= ((rt_uint32_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/thread.c b/src/thread.c
index 6d79ece54b..687852e92e 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 - 4),
(void *)rt_thread_exit);
+#endif
/* priority init */
RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX);