1.1 --- a/boot_usb Fri Jul 03 21:23:35 2015 +0200
1.2 +++ b/boot_usb Sat Nov 21 01:10:52 2015 +0100
1.3 @@ -7,4 +7,5 @@
1.4 xbboot flush_cache
1.5 xbboot set_addr 0x80010000
1.6 xbboot bulk_write stage2/stage2.bin
1.7 +xbboot flush_cache
1.8 xbboot start2 0x80010000
2.1 --- a/stage2/handlers.S Fri Jul 03 21:23:35 2015 +0200
2.2 +++ b/stage2/handlers.S Sat Nov 21 01:10:52 2015 +0100
2.3 @@ -21,20 +21,24 @@
2.4 .text
2.5 .extern irq_handle
2.6 .extern irq_counter
2.7 +.globl _exc_stack
2.8 .globl real_exception_handler
2.9 .set noreorder
2.10 .set noat
2.11
2.12 -#define C0_STATUS $12
2.13 -#define C0_CAUSE $13
2.14 -#define C0_EPC $14
2.15 -#define C0_CONFIG $16
2.16 -#define C0_ERROREPC $30
2.17 -#define S_CauseExcCode 2
2.18 -#define M_CauseExcCode (0x1f << S_CauseExcCode)
2.19 +#define C0_STATUS $12
2.20 +#define C0_CAUSE $13
2.21 +#define C0_EPC $14
2.22 +#define C0_CONFIG $16
2.23 +#define C0_ERROREPC $30
2.24 +#define S_CauseExcCode 2
2.25 +#define M_CauseExcCode (0x1f << S_CauseExcCode)
2.26 +
2.27 +_exc_stack:
2.28 + .word 0
2.29
2.30 real_exception_handler:
2.31 - addiu $sp, -0x88 /* multiple of 8 */
2.32 + addiu $sp, -0x88 /* multiple of 8 */
2.33 sw $ra, 0($sp)
2.34 sw $fp, 4($sp)
2.35 sw $gp, 8($sp)
2.36 @@ -97,6 +101,14 @@
2.37 nop
2.38
2.39 _int:
2.40 + /* Initialise the kernel stack. */
2.41 +
2.42 + la $k1, _exc_stack
2.43 + lw $k0, 0($k1)
2.44 + sw $sp, 0($k0)
2.45 + addiu $k0, -4
2.46 + move $sp, $k0
2.47 +
2.48 /* Initialise the globals pointer. */
2.49
2.50 lui $gp, %hi(_GLOBAL_OFFSET_TABLE_)
2.51 @@ -113,6 +125,12 @@
2.52
2.53 jal irq_handle
2.54 nop
2.55 +
2.56 + /* Restore the user stack. */
2.57 +
2.58 + addiu $sp, 4
2.59 + lw $sp, 0($sp)
2.60 +
2.61 j _exception_return
2.62 nop
2.63
2.64 @@ -176,7 +194,7 @@
2.65 sll $zero, 1
2.66 sll $zero, 1
2.67 sll $zero, 1
2.68 - addiu $sp, 0x88 /* multiple of 8 */
2.69 + addiu $sp, 0x88 /* multiple of 8 */
2.70 eret
2.71 nop
2.72
3.1 --- a/stage2/head2.S Fri Jul 03 21:23:35 2015 +0200
3.2 +++ b/stage2/head2.S Sat Nov 21 01:10:52 2015 +0100
3.3 @@ -28,13 +28,17 @@
3.4 .extern _exc_entry
3.5 .extern _irq_entry
3.6 .extern _end_entries
3.7 +.extern _exc_stack
3.8 .globl _start
3.9 .set noreorder
3.10
3.11 _start:
3.12 - /* Initialise the stack. */
3.13 + /* Initialise the stacks. */
3.14
3.15 la $sp, 0x80080000
3.16 + la $k0, 0x80090000
3.17 + la $k1, _exc_stack
3.18 + sw $k0, 0($k1)
3.19
3.20 /* Initialise the globals pointer. */
3.21