# HG changeset patch # User Paul Boddie # Date 1456157230 -3600 # Node ID a34a56734b6e1184fd9b9c3a39434bec11037edf # Parent f1919a78c1686dc82b9a4797845ad27d0f286cb0 Mask interrupts while handling them, saving the status and EPC registers. diff -r f1919a78c168 -r a34a56734b6e stage2/handlers.S --- a/stage2/handlers.S Wed Jan 27 15:51:32 2016 +0100 +++ b/stage2/handlers.S Mon Feb 22 17:07:10 2016 +0100 @@ -2,7 +2,7 @@ * Handler routines. * * Copyright (C) 2015 Nicholas FitzRoy-Dale - * Copyright (C) 2015 Paul Boddie + * Copyright (C) 2015, 2016 Paul Boddie * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,15 @@ .set noat interrupt_handler: + + /* Save the status, mask interrupts. */ + + mfc0 $k0, $12 /* CP0_STATUS */ + li $k1, 0xffff03ff + and $k1, $k0, $k1 + mtc0 $k1, $12 + sw $k0, -120($sp) + sw $at, -4($sp) sw $v0, -8($sp) sw $v1, -12($sp) @@ -54,14 +63,18 @@ sw $fp, -108($sp) sw $ra, -112($sp) - addi $sp, $sp, -112 + mfc0 $k0, $14 /* CP0_EPC */ + nop + sw $k0, -116($sp) + + addi $sp, $sp, -120 /* Invoke the handler. */ jal irq_handle nop - addi $sp, $sp, 112 + addi $sp, $sp, 120 lw $at, -4($sp) lw $v0, -8($sp) @@ -92,6 +105,14 @@ lw $fp, -108($sp) lw $ra, -112($sp) + lw $k0, -116($sp) + mtc0 $k0, $14 /* CP0_EPC */ + nop + + lw $k0, -120($sp) + mtc0 $k0, $12 /* CP0_STATUS */ + nop + eret nop