Skip to content
Snippets Groups Projects
Commit 15d6070a authored by Benjamin Valentin's avatar Benjamin Valentin
Browse files

fix bug introduced by 7cef6c46

stack_start used to be stack_start + stack_size, so re-setting stk to stack_start would set the pointer to the *end* of the stack instead of the beginning.
parent 0a50f170
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ void thread_yield() { ...@@ -36,7 +36,7 @@ void thread_yield() {
char * thread_stack_init(void * task_func, void * stack_start, int stack_size) char * thread_stack_init(void * task_func, void * stack_start, int stack_size)
{ {
unsigned int * stk; unsigned int * stk;
stk = (unsigned int *) stack_start + stack_size; stk = (unsigned int *) (stack_start + stack_size);
stk--; stk--;
*stk = 0x77777777; *stk = 0x77777777;
...@@ -45,7 +45,7 @@ char * thread_stack_init(void * task_func, void * stack_start, int stack_size) ...@@ -45,7 +45,7 @@ char * thread_stack_init(void * task_func, void * stack_start, int stack_size)
*stk = (unsigned int)sched_task_exit; // LR *stk = (unsigned int)sched_task_exit; // LR
stk--; stk--;
*stk = (unsigned int) stack_start - 4; // SP *stk = (unsigned int) (stack_start + stack_size) - 4; // SP
for (int i = 12; i>= 0 ; i--) { // build base stack for (int i = 12; i>= 0 ; i--) { // build base stack
stk--; stk--;
......
...@@ -100,7 +100,7 @@ void cpu_switch_context_exit(void){ ...@@ -100,7 +100,7 @@ void cpu_switch_context_exit(void){
char *thread_stack_init(void *task_func, void *stack_start, int stack_size) char *thread_stack_init(void *task_func, void *stack_start, int stack_size)
{ {
unsigned short * stk; unsigned short * stk;
stk = (unsigned short *) stack_start + stack_size; stk = (unsigned short *) (stack_start + stack_size);
*stk = (unsigned short) sched_task_exit; *stk = (unsigned short) sched_task_exit;
--stk; --stk;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment