# HG changeset patch # User Paul Boddie # Date 1448064652 -3600 # Node ID 4aa74d63b1d097edcb915b8ba2057cb60f26c2c0 # Parent ac3734da88fd65005231b3f9af00c6b94dc332e3 Added a separate "kernel" stack. diff -r ac3734da88fd -r 4aa74d63b1d0 boot_usb --- a/boot_usb Fri Jul 03 21:23:35 2015 +0200 +++ b/boot_usb Sat Nov 21 01:10:52 2015 +0100 @@ -7,4 +7,5 @@ xbboot flush_cache xbboot set_addr 0x80010000 xbboot bulk_write stage2/stage2.bin +xbboot flush_cache xbboot start2 0x80010000 diff -r ac3734da88fd -r 4aa74d63b1d0 stage2/handlers.S --- a/stage2/handlers.S Fri Jul 03 21:23:35 2015 +0200 +++ b/stage2/handlers.S Sat Nov 21 01:10:52 2015 +0100 @@ -21,20 +21,24 @@ .text .extern irq_handle .extern irq_counter +.globl _exc_stack .globl real_exception_handler .set noreorder .set noat -#define C0_STATUS $12 -#define C0_CAUSE $13 -#define C0_EPC $14 -#define C0_CONFIG $16 -#define C0_ERROREPC $30 -#define S_CauseExcCode 2 -#define M_CauseExcCode (0x1f << S_CauseExcCode) +#define C0_STATUS $12 +#define C0_CAUSE $13 +#define C0_EPC $14 +#define C0_CONFIG $16 +#define C0_ERROREPC $30 +#define S_CauseExcCode 2 +#define M_CauseExcCode (0x1f << S_CauseExcCode) + +_exc_stack: + .word 0 real_exception_handler: - addiu $sp, -0x88 /* multiple of 8 */ + addiu $sp, -0x88 /* multiple of 8 */ sw $ra, 0($sp) sw $fp, 4($sp) sw $gp, 8($sp) @@ -97,6 +101,14 @@ nop _int: + /* Initialise the kernel stack. */ + + la $k1, _exc_stack + lw $k0, 0($k1) + sw $sp, 0($k0) + addiu $k0, -4 + move $sp, $k0 + /* Initialise the globals pointer. */ lui $gp, %hi(_GLOBAL_OFFSET_TABLE_) @@ -113,6 +125,12 @@ jal irq_handle nop + + /* Restore the user stack. */ + + addiu $sp, 4 + lw $sp, 0($sp) + j _exception_return nop @@ -176,7 +194,7 @@ sll $zero, 1 sll $zero, 1 sll $zero, 1 - addiu $sp, 0x88 /* multiple of 8 */ + addiu $sp, 0x88 /* multiple of 8 */ eret nop diff -r ac3734da88fd -r 4aa74d63b1d0 stage2/head2.S --- a/stage2/head2.S Fri Jul 03 21:23:35 2015 +0200 +++ b/stage2/head2.S Sat Nov 21 01:10:52 2015 +0100 @@ -28,13 +28,17 @@ .extern _exc_entry .extern _irq_entry .extern _end_entries +.extern _exc_stack .globl _start .set noreorder _start: - /* Initialise the stack. */ + /* Initialise the stacks. */ la $sp, 0x80080000 + la $k0, 0x80090000 + la $k1, _exc_stack + sw $k0, 0($k1) /* Initialise the globals pointer. */