1 /* 2 * Handler routines. 3 * 4 * Copyright (C) 2015 Nicholas FitzRoy-Dale <wzdd.code@lardcave.net> 5 * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 .text 22 .extern tlb_handle 23 .extern irq_handle 24 .globl tlb_handler 25 .globl interrupt_handler 26 .set noreorder 27 .set noat 28 29 tlb_handler: 30 /* gp should have been set in the entrypoint. */ 31 32 jal save_state 33 nop 34 35 /* Invoke the handler. */ 36 37 jal tlb_handle 38 nop 39 40 j load_and_return 41 nop 42 43 interrupt_handler: 44 /* gp should have been set in the entrypoint. */ 45 46 jal save_state 47 nop 48 49 /* Invoke the handler. */ 50 51 jal irq_handle 52 nop 53 54 j load_and_return 55 nop 56 57 save_state: 58 sw $at, -4($sp) 59 sw $v0, -8($sp) 60 sw $v1, -12($sp) 61 sw $a0, -16($sp) 62 sw $a1, -20($sp) 63 sw $a2, -24($sp) 64 sw $a3, -28($sp) 65 sw $t0, -32($sp) 66 sw $t1, -36($sp) 67 sw $t2, -40($sp) 68 sw $t3, -44($sp) 69 sw $t4, -48($sp) 70 sw $t5, -52($sp) 71 sw $t6, -56($sp) 72 sw $t7, -60($sp) 73 sw $s0, -64($sp) 74 sw $s1, -68($sp) 75 sw $s2, -72($sp) 76 sw $s3, -76($sp) 77 sw $s4, -80($sp) 78 sw $s5, -84($sp) 79 sw $s6, -88($sp) 80 sw $s7, -92($sp) 81 sw $t8, -96($sp) 82 /* sw $t9, -100($sp) */ 83 /* sw $gp, -104($sp) */ 84 sw $fp, -108($sp) 85 /* sw $ra, -112($sp) */ 86 87 mfc0 $k0, $14 /* CP0_EPC */ 88 nop 89 sw $k0, -116($sp) 90 91 addi $sp, $sp, -120 92 j $ra 93 nop 94 95 load_and_return: 96 97 addi $sp, $sp, 120 98 99 lw $at, -4($sp) 100 lw $v0, -8($sp) 101 lw $v1, -12($sp) 102 lw $a0, -16($sp) 103 lw $a1, -20($sp) 104 lw $a2, -24($sp) 105 lw $a3, -28($sp) 106 lw $t0, -32($sp) 107 lw $t1, -36($sp) 108 lw $t2, -40($sp) 109 lw $t3, -44($sp) 110 lw $t4, -48($sp) 111 lw $t5, -52($sp) 112 lw $t6, -56($sp) 113 lw $t7, -60($sp) 114 lw $s0, -64($sp) 115 lw $s1, -68($sp) 116 lw $s2, -72($sp) 117 lw $s3, -76($sp) 118 lw $s4, -80($sp) 119 lw $s5, -84($sp) 120 lw $s6, -88($sp) 121 lw $s7, -92($sp) 122 lw $t8, -96($sp) 123 lw $t9, -100($sp) 124 lw $gp, -104($sp) 125 lw $fp, -108($sp) 126 lw $ra, -112($sp) 127 128 lw $k0, -116($sp) 129 mtc0 $k0, $14 /* CP0_EPC */ 130 nop 131 132 lw $k0, -120($sp) 133 mtc0 $k0, $12 /* CP0_STATUS */ 134 nop 135 136 eret 137 nop 138 139 .set reorder 140 .set at