# HG changeset patch # User Paul Boddie # Date 1456594490 -3600 # Node ID 4502cd6c72549075041124c1e0f1053dca9e3058 # Parent 9e9d063cdfd163ed9bd887d3695877eab08283aa Tidied up stack location calculations. diff -r 9e9d063cdfd1 -r 4502cd6c7254 stage2/irq.c --- a/stage2/irq.c Sat Feb 27 17:56:51 2016 +0100 +++ b/stage2/irq.c Sat Feb 27 18:34:50 2016 +0100 @@ -116,10 +116,10 @@ physical memory, but at the same address in virtual memory. */ - virtual = stack_start - pagesize * 2; - physical = stack_start + stack_size * task - pagesize * 2; + virtual = stack_start; + physical = stack_start + stack_size * task; - init_page_table(page_table_start, virtual, physical, pagesize, 0x1e, task); + init_page_table(page_table_start, virtual - pagesize * 2, physical - pagesize * 2, pagesize, 0x1e, task); /* Map the page for initialisation. */ @@ -130,11 +130,11 @@ return address. */ - init_stack(stack_start + stack_size * task, _got_copy_start, (void (*)()) plot_pattern, args, 3); + init_stack(physical, _got_copy_start, (void (*)()) plot_pattern, args, 3); /* Advance the stack pointer so that the adopted frame will be found. */ - stack_pointers[task] = stack_start - framesize; + stack_pointers[task] = virtual - framesize; } void switch_task() @@ -198,7 +198,7 @@ "lw $fp, -108($sp)\n" "lw $ra, -112($sp)\n" "lw $k0, -116($sp)\n" - "mtc0 $k0, $14\n" /* CP0_EPC */ + "mtc0 $k0, $14\n" /* CP0_EPC */ "nop\n" "jr $ra\n" "nop"