summaryrefslogtreecommitdiff
path: root/firmware/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/thread.c')
-rw-r--r--firmware/thread.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/firmware/thread.c b/firmware/thread.c
index c00fc36e3f..b3d8ec3970 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -123,8 +123,13 @@ static struct core_entry cores[NUM_CORES] IBSS_ATTR;
123struct thread_entry threads[MAXTHREADS] IBSS_ATTR; 123struct thread_entry threads[MAXTHREADS] IBSS_ATTR;
124 124
125static const char main_thread_name[] = "main"; 125static const char main_thread_name[] = "main";
126#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
126extern uintptr_t stackbegin[]; 127extern uintptr_t stackbegin[];
127extern uintptr_t stackend[]; 128extern uintptr_t stackend[];
129#else
130extern uintptr_t *stackbegin;
131extern uintptr_t *stackend;
132#endif
128 133
129static inline void core_sleep(IF_COP_VOID(unsigned int core)) 134static inline void core_sleep(IF_COP_VOID(unsigned int core))
130 __attribute__((always_inline)); 135 __attribute__((always_inline));
@@ -170,7 +175,9 @@ void switch_thread(void)
170/**************************************************************************** 175/****************************************************************************
171 * Processor-specific section - include necessary core support 176 * Processor-specific section - include necessary core support
172 */ 177 */
173#if defined(CPU_ARM) 178#if defined(ANDROID)
179#include "thread-android-arm.c"
180#elif defined(CPU_ARM)
174#include "thread-arm.c" 181#include "thread-arm.c"
175#if defined (CPU_PP) 182#if defined (CPU_PP)
176#include "thread-pp.c" 183#include "thread-pp.c"
@@ -1150,7 +1157,7 @@ void switch_thread(void)
1150 store_context(&thread->context); 1157 store_context(&thread->context);
1151 1158
1152 /* Check if the current thread stack is overflown */ 1159 /* Check if the current thread stack is overflown */
1153 if (UNLIKELY(thread->stack[0] != DEADBEEF)) 1160 if (UNLIKELY(thread->stack[0] != DEADBEEF) && thread->stack_size > 0)
1154 thread_stkov(thread); 1161 thread_stkov(thread);
1155 1162
1156#if NUM_CORES > 1 1163#if NUM_CORES > 1
@@ -2319,7 +2326,9 @@ static int stack_usage(uintptr_t *stackptr, size_t stack_size)
2319 */ 2326 */
2320int thread_stack_usage(const struct thread_entry *thread) 2327int thread_stack_usage(const struct thread_entry *thread)
2321{ 2328{
2322 return stack_usage(thread->stack, thread->stack_size); 2329 if (LIKELY(thread->stack_size > 0))
2330 return stack_usage(thread->stack, thread->stack_size);
2331 return 0;
2323} 2332}
2324 2333
2325#if NUM_CORES > 1 2334#if NUM_CORES > 1