fix bug introduced by 7cef6c4655

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.
dev/timer
Benjamin Valentin 10 years ago
parent 0a50f17006
commit 15d6070ad6

@ -36,7 +36,7 @@ void thread_yield() {
char * thread_stack_init(void * task_func, void * stack_start, int stack_size)
{
unsigned int * stk;
stk = (unsigned int *) stack_start + stack_size;
stk = (unsigned int *) (stack_start + stack_size);
stk--;
*stk = 0x77777777;
@ -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--;
*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
stk--;

@ -100,7 +100,7 @@ void cpu_switch_context_exit(void){
char *thread_stack_init(void *task_func, void *stack_start, int stack_size)
{
unsigned short * stk;
stk = (unsigned short *) stack_start + stack_size;
stk = (unsigned short *) (stack_start + stack_size);
*stk = (unsigned short) sched_task_exit;
--stk;

Loading…
Cancel
Save