1.1 --- a/stage2/handlers.S Fri Jul 03 21:23:35 2015 +0200
1.2 +++ b/stage2/handlers.S Sat Nov 21 01:10:52 2015 +0100
1.3 @@ -21,20 +21,24 @@
1.4 .text
1.5 .extern irq_handle
1.6 .extern irq_counter
1.7 +.globl _exc_stack
1.8 .globl real_exception_handler
1.9 .set noreorder
1.10 .set noat
1.11
1.12 -#define C0_STATUS $12
1.13 -#define C0_CAUSE $13
1.14 -#define C0_EPC $14
1.15 -#define C0_CONFIG $16
1.16 -#define C0_ERROREPC $30
1.17 -#define S_CauseExcCode 2
1.18 -#define M_CauseExcCode (0x1f << S_CauseExcCode)
1.19 +#define C0_STATUS $12
1.20 +#define C0_CAUSE $13
1.21 +#define C0_EPC $14
1.22 +#define C0_CONFIG $16
1.23 +#define C0_ERROREPC $30
1.24 +#define S_CauseExcCode 2
1.25 +#define M_CauseExcCode (0x1f << S_CauseExcCode)
1.26 +
1.27 +_exc_stack:
1.28 + .word 0
1.29
1.30 real_exception_handler:
1.31 - addiu $sp, -0x88 /* multiple of 8 */
1.32 + addiu $sp, -0x88 /* multiple of 8 */
1.33 sw $ra, 0($sp)
1.34 sw $fp, 4($sp)
1.35 sw $gp, 8($sp)
1.36 @@ -97,6 +101,14 @@
1.37 nop
1.38
1.39 _int:
1.40 + /* Initialise the kernel stack. */
1.41 +
1.42 + la $k1, _exc_stack
1.43 + lw $k0, 0($k1)
1.44 + sw $sp, 0($k0)
1.45 + addiu $k0, -4
1.46 + move $sp, $k0
1.47 +
1.48 /* Initialise the globals pointer. */
1.49
1.50 lui $gp, %hi(_GLOBAL_OFFSET_TABLE_)
1.51 @@ -113,6 +125,12 @@
1.52
1.53 jal irq_handle
1.54 nop
1.55 +
1.56 + /* Restore the user stack. */
1.57 +
1.58 + addiu $sp, 4
1.59 + lw $sp, 0($sp)
1.60 +
1.61 j _exception_return
1.62 nop
1.63
1.64 @@ -176,7 +194,7 @@
1.65 sll $zero, 1
1.66 sll $zero, 1
1.67 sll $zero, 1
1.68 - addiu $sp, 0x88 /* multiple of 8 */
1.69 + addiu $sp, 0x88 /* multiple of 8 */
1.70 eret
1.71 nop
1.72