# HG changeset patch # User Paul Boddie # Date 1461529394 -7200 # Node ID 642c8986466b8c6e0f1feb0c2de39315247966d9 # Parent 5d8263190f206545124e65eabfb980aabbbcd00f Introduced a special routine that is used to enter the task. diff -r 5d8263190f20 -r 642c8986466b stage2/entry.S --- a/stage2/entry.S Sun Apr 24 19:51:55 2016 +0200 +++ b/stage2/entry.S Sun Apr 24 22:23:14 2016 +0200 @@ -21,10 +21,12 @@ .extern interrupt_handler .extern current_registers .extern current_stack_pointer +.extern enter_task .globl _tlb_entry .globl _exc_entry .globl _irq_entry .globl _end_entries +.globl _enter_task .set noreorder #include "paging.h" @@ -72,7 +74,11 @@ tlbwr nop - eret + + lui $k0, %hi(_enter_task) + ori $k0, $k0, %lo(_enter_task) + lw $k1, 0($k0) + jr $k1 nop _tlb_entry_direct: diff -r 5d8263190f20 -r 642c8986466b stage2/handlers.S --- a/stage2/handlers.S Sun Apr 24 19:51:55 2016 +0200 +++ b/stage2/handlers.S Sun Apr 24 22:23:14 2016 +0200 @@ -24,6 +24,7 @@ .extern current_stack_pointer .extern current_task .globl interrupt_handler +.globl enter_task .set noreorder .set noat @@ -147,6 +148,13 @@ lw $k0, 124($k1) mthi $k0 + lui $k0, %hi(_enter_task) + ori $k0, $k0, %lo(_enter_task) + lw $k1, 0($k0) + jr $k1 + nop + +enter_task: eret nop diff -r 5d8263190f20 -r 642c8986466b stage2/head2.S --- a/stage2/head2.S Sun Apr 24 19:51:55 2016 +0200 +++ b/stage2/head2.S Sun Apr 24 22:23:14 2016 +0200 @@ -31,23 +31,25 @@ .extern _got_start .extern _got_end .extern _got_copy_start +.extern enter_task .globl _start +.globl _enter_task .set noreorder _start: - b real_start + b real_start nop /* Apparently reserved region which, if used, breaks the USB Boot process. */ - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 real_start: /* Initialise the stack. */ @@ -102,12 +104,23 @@ mtc0 $t0, $16 /* CP0_CONFIG */ nop + /* Set up the enter task reference for convenience. */ + + la $t0, enter_task + li $t1, 0x80000000 + /* subu $t0, $t0, $t1 */ + la $t1, _enter_task + sw $t0, 0($t1) + /* Start the program. */ la $t9, c_main /* load the address of the routine */ j c_main nop +_enter_task: + .word 0 + _copy: /* Copy via $t3 the region from $t0 to $t2 into $t1. */