1.1 --- a/stage2/cpu.c Sun Apr 24 23:26:46 2016 +0200
1.2 +++ b/stage2/cpu.c Sun Apr 24 23:44:35 2016 +0200
1.3 @@ -131,12 +131,14 @@
1.4 base[29] = (u32) function - 0x80000000; /* store the function address as EPC (for the handler) */
1.5 }
1.6
1.7 -void invoke_task(u8 asid, u32 *base)
1.8 +void invoke_task(u8 asid, u32 *base, u32 *stack_pointer)
1.9 {
1.10 asm volatile(
1.11 "mtc0 %0, $10\n" /* CP0_ENTRYHI */
1.12 "nop\n"
1.13 - "move $t3, %1\n"
1.14 + "move $t4, %1\n" /* use arguments before they are overwritten */
1.15 + "lw $sp, 0($t4)\n" /* set the stack pointer */
1.16 + "move $t3, %2\n" /* load parameters from the stored registers */
1.17 "lw $a0, 16($t3)\n"
1.18 "lw $a1, 20($t3)\n"
1.19 "lw $a2, 24($t3)\n"
1.20 @@ -146,7 +148,7 @@
1.21 "jr $t9\n"
1.22 "nop"
1.23 :
1.24 - : "r" (asid), "r" (base)
1.25 + : "r" (asid), "r" (stack_pointer), "r" (base)
1.26 );
1.27 }
1.28
2.1 --- a/stage2/cpu.h Sun Apr 24 23:26:46 2016 +0200
2.2 +++ b/stage2/cpu.h Sun Apr 24 23:44:35 2016 +0200
2.3 @@ -7,7 +7,7 @@
2.4 void handle_error_level();
2.5 void enter_user_mode();
2.6 void init_registers(u32 *, u32, void (*)(), u32[], u8);
2.7 -void invoke_task(u8, u32 *);
2.8 +void invoke_task(u8, u32 *, u32 *);
2.9 void enable_interrupts();
2.10 void init_interrupts();
2.11 void init_tlb();
3.1 --- a/stage2/tasks.c Sun Apr 24 23:26:46 2016 +0200
3.2 +++ b/stage2/tasks.c Sun Apr 24 23:44:35 2016 +0200
3.3 @@ -85,7 +85,7 @@
3.4
3.5 void start_task_now()
3.6 {
3.7 - invoke_task(current_task, current_registers);
3.8 + invoke_task(current_task, current_registers, current_stack_pointer);
3.9 }
3.10
3.11 void switch_task()