Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Alexey Brodkin | 23d1b35 | 2015-02-24 17:08:44 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. |
Alexey Brodkin | 23d1b35 | 2015-02-24 17:08:44 +0300 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <linux/linkage.h> |
| 7 | |
| 8 | /* |
| 9 | * Note on the LD/ST addressing modes with address register write-back |
| 10 | * |
| 11 | * LD.a same as LD.aw |
| 12 | * |
| 13 | * LD.a reg1, [reg2, x] => Pre Incr |
| 14 | * Eff Addr for load = [reg2 + x] |
| 15 | * |
| 16 | * LD.ab reg1, [reg2, x] => Post Incr |
| 17 | * Eff Addr for load = [reg2] |
| 18 | */ |
| 19 | |
| 20 | .macro PUSH reg |
| 21 | st.a \reg, [%sp, -4] |
| 22 | .endm |
| 23 | |
| 24 | .macro PUSHAX aux |
| 25 | lr %r9, [\aux] |
| 26 | PUSH %r9 |
| 27 | .endm |
| 28 | |
| 29 | .macro SAVE_R1_TO_R24 |
| 30 | PUSH %r1 |
| 31 | PUSH %r2 |
| 32 | PUSH %r3 |
| 33 | PUSH %r4 |
| 34 | PUSH %r5 |
| 35 | PUSH %r6 |
| 36 | PUSH %r7 |
| 37 | PUSH %r8 |
| 38 | PUSH %r9 |
| 39 | PUSH %r10 |
| 40 | PUSH %r11 |
| 41 | PUSH %r12 |
| 42 | PUSH %r13 |
| 43 | PUSH %r14 |
| 44 | PUSH %r15 |
| 45 | PUSH %r16 |
| 46 | PUSH %r17 |
| 47 | PUSH %r18 |
| 48 | PUSH %r19 |
| 49 | PUSH %r20 |
| 50 | PUSH %r21 |
| 51 | PUSH %r22 |
| 52 | PUSH %r23 |
| 53 | PUSH %r24 |
| 54 | .endm |
| 55 | |
| 56 | .macro SAVE_ALL_SYS |
| 57 | /* saving %r0 to reg->r0 in advance since we read %ecr into it */ |
| 58 | st %r0, [%sp, -8] |
| 59 | lr %r0, [%ecr] /* all stack addressing is manual so far */ |
| 60 | st %r0, [%sp] |
| 61 | st %sp, [%sp, -4] |
| 62 | /* now move %sp to reg->r0 position so we can do "push" automatically */ |
| 63 | sub %sp, %sp, 8 |
| 64 | |
| 65 | SAVE_R1_TO_R24 |
| 66 | PUSH %r25 |
| 67 | PUSH %gp |
| 68 | PUSH %fp |
| 69 | PUSH %blink |
| 70 | PUSHAX %eret |
| 71 | PUSHAX %erstatus |
| 72 | PUSH %lp_count |
| 73 | PUSHAX %lp_end |
| 74 | PUSHAX %lp_start |
| 75 | PUSHAX %erbta |
| 76 | .endm |
| 77 | |
| 78 | .macro SAVE_EXCEPTION_SOURCE |
| 79 | #ifdef CONFIG_MMU |
| 80 | /* If MMU exists exception faulting address is loaded in EFA reg */ |
| 81 | lr %r0, [%efa] |
| 82 | #else |
| 83 | /* Otherwise in ERET (exception return) reg */ |
| 84 | lr %r0, [%eret] |
| 85 | #endif |
| 86 | .endm |
| 87 | |
| 88 | ENTRY(memory_error) |
| 89 | SAVE_ALL_SYS |
| 90 | SAVE_EXCEPTION_SOURCE |
| 91 | mov %r1, %sp |
| 92 | j do_memory_error |
| 93 | ENDPROC(memory_error) |
| 94 | |
| 95 | ENTRY(instruction_error) |
| 96 | SAVE_ALL_SYS |
| 97 | SAVE_EXCEPTION_SOURCE |
| 98 | mov %r1, %sp |
| 99 | j do_instruction_error |
| 100 | ENDPROC(instruction_error) |
| 101 | |
| 102 | ENTRY(interrupt_handler) |
| 103 | /* Todo - save and restore CPU context when interrupts will be in use */ |
| 104 | bl do_interrupt_handler |
| 105 | rtie |
| 106 | ENDPROC(interrupt_handler) |
| 107 | |
| 108 | ENTRY(EV_MachineCheck) |
| 109 | SAVE_ALL_SYS |
| 110 | SAVE_EXCEPTION_SOURCE |
| 111 | mov %r1, %sp |
| 112 | j do_machine_check_fault |
| 113 | ENDPROC(EV_MachineCheck) |
| 114 | |
| 115 | ENTRY(EV_TLBMissI) |
| 116 | SAVE_ALL_SYS |
| 117 | mov %r0, %sp |
| 118 | j do_itlb_miss |
| 119 | ENDPROC(EV_TLBMissI) |
| 120 | |
| 121 | ENTRY(EV_TLBMissD) |
| 122 | SAVE_ALL_SYS |
| 123 | mov %r0, %sp |
| 124 | j do_dtlb_miss |
| 125 | ENDPROC(EV_TLBMissD) |
| 126 | |
| 127 | ENTRY(EV_TLBProtV) |
| 128 | SAVE_ALL_SYS |
| 129 | SAVE_EXCEPTION_SOURCE |
| 130 | mov %r1, %sp |
| 131 | j do_tlb_prot_violation |
| 132 | ENDPROC(EV_TLBProtV) |
| 133 | |
| 134 | ENTRY(EV_PrivilegeV) |
| 135 | SAVE_ALL_SYS |
| 136 | mov %r0, %sp |
| 137 | j do_privilege_violation |
| 138 | ENDPROC(EV_PrivilegeV) |
| 139 | |
| 140 | ENTRY(EV_Trap) |
| 141 | SAVE_ALL_SYS |
| 142 | mov %r0, %sp |
| 143 | j do_trap |
| 144 | ENDPROC(EV_Trap) |
| 145 | |
| 146 | ENTRY(EV_Extension) |
| 147 | SAVE_ALL_SYS |
| 148 | mov %r0, %sp |
| 149 | j do_extension |
| 150 | ENDPROC(EV_Extension) |
Alexey Brodkin | e20c289 | 2016-08-04 09:21:50 +0300 | [diff] [blame] | 151 | |
| 152 | #ifdef CONFIG_ISA_ARCV2 |
| 153 | ENTRY(EV_SWI) |
| 154 | SAVE_ALL_SYS |
| 155 | mov %r0, %sp |
| 156 | j do_swi |
| 157 | ENDPROC(EV_SWI) |
| 158 | |
| 159 | ENTRY(EV_DivZero) |
| 160 | SAVE_ALL_SYS |
| 161 | SAVE_EXCEPTION_SOURCE |
| 162 | mov %r1, %sp |
| 163 | j do_divzero |
| 164 | ENDPROC(EV_DivZero) |
| 165 | |
| 166 | ENTRY(EV_DCError) |
| 167 | SAVE_ALL_SYS |
| 168 | mov %r0, %sp |
| 169 | j do_dcerror |
| 170 | ENDPROC(EV_DCError) |
| 171 | |
| 172 | ENTRY(EV_Maligned) |
| 173 | SAVE_ALL_SYS |
| 174 | SAVE_EXCEPTION_SOURCE |
| 175 | mov %r1, %sp |
| 176 | j do_maligned |
| 177 | ENDPROC(EV_Maligned) |
| 178 | #endif |