# HG changeset patch # User Paul Boddie # Date 1435145381 -7200 # Node ID b6b226e2bd0c9157f714622c4f38ab67f661aad4 # Parent beb796ba8f2995ea79834f5ef936971b4cf39825 Added globals pointer initialisation, removed apparently superfluous no-pic flag from the Makefile. Added cache error handler definition. diff -r beb796ba8f29 -r b6b226e2bd0c stage2/Makefile --- a/stage2/Makefile Tue Jun 23 23:08:19 2015 +0200 +++ b/stage2/Makefile Wed Jun 24 13:29:41 2015 +0200 @@ -30,7 +30,7 @@ CFLAGS = -O2 -Wall \ -fno-unit-at-a-time -fno-zero-initialized-in-bss \ - -ffreestanding -fno-hosted -fno-builtin -fno-pic \ + -ffreestanding -fno-hosted -fno-builtin \ -march=mips32 \ -I../include LDFLAGS = -nostdlib -EL diff -r beb796ba8f29 -r b6b226e2bd0c stage2/entry.S --- a/stage2/entry.S Tue Jun 23 23:08:19 2015 +0200 +++ b/stage2/entry.S Wed Jun 24 13:29:41 2015 +0200 @@ -20,6 +20,7 @@ .text .extern real_exception_handler .globl _tlb_entry +.globl _cache_entry .globl _exc_entry .globl _irq_entry .globl _end_entries @@ -31,6 +32,12 @@ jr $k0 nop +_cache_entry: + lui $k0, %hi(real_exception_handler) + ori $k0, $k0, %lo(real_exception_handler) + jr $k0 + nop + _exc_entry: lui $k0, %hi(real_exception_handler) ori $k0, $k0, %lo(real_exception_handler) diff -r beb796ba8f29 -r b6b226e2bd0c stage2/handlers.S --- a/stage2/handlers.S Tue Jun 23 23:08:19 2015 +0200 +++ b/stage2/handlers.S Wed Jun 24 13:29:41 2015 +0200 @@ -94,6 +94,7 @@ jal irq_handle nop j _exception_return + nop _exception: move $a0, $sp diff -r beb796ba8f29 -r b6b226e2bd0c stage2/head2.S --- a/stage2/head2.S Tue Jun 23 23:08:19 2015 +0200 +++ b/stage2/head2.S Wed Jun 24 13:29:41 2015 +0200 @@ -34,13 +34,16 @@ la $sp, 0x80080000 + /* Initialise the globals pointer. */ + + lui $gp, %hi(_GLOBAL_OFFSET_TABLE_) + ori $gp, $gp, %lo(_GLOBAL_OFFSET_TABLE_) + /* Copy TLB handling instructions. */ - lui $t0, %hi(_tlb_entry) /* start */ - ori $t0, $t0, %lo(_tlb_entry) + la $t0, _tlb_entry /* start */ li $t1, 0x80000000 - lui $t2, %hi(_exc_entry) /* end */ - ori $t2, $t2, %lo(_exc_entry) + la $t2, _cache_entry /* end */ _tlb_copy: lw $t3, 0($t0) addiu $t0, $t0, 4 @@ -48,12 +51,23 @@ bne $t0, $t2, _tlb_copy addiu $t1, $t1, 4 /* executed in delay slot before branch */ + /* Copy cache handling instructions. */ + + move $t0, $t2 /* start */ + li $t1, 0x80000100 + la $t2, _exc_entry /* end */ +_cache_copy: + lw $t3, 0($t0) + addiu $t0, $t0, 4 + sw $t3, 0($t1) + bne $t0, $t2, _cache_copy + addiu $t1, $t1, 4 /* executed in delay slot before branch */ + /* Copy exception handling instructions. */ move $t0, $t2 /* start */ li $t1, 0x80000180 - lui $t2, %hi(_irq_entry) /* end */ - ori $t2, $t2, %lo(_irq_entry) + la $t2, _irq_entry /* end */ _exc_copy: lw $t3, 0($t0) addiu $t0, $t0, 4 @@ -65,8 +79,7 @@ move $t0, $t2 /* start */ li $t1, 0x80000200 - lui $t2, %hi(_end_entries) /* end */ - ori $t2, $t2, %lo(_end_entries) + la $t2, _end_entries /* end */ _irq_copy: lw $t3, 0($t0) addiu $t0, $t0, 4