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 |
Alexey Brodkin | 23d1b35 | 2015-02-24 17:08:44 +0300 | [diff] [blame] | 79 | /* Otherwise in ERET (exception return) reg */ |
| 80 | lr %r0, [%eret] |
Alexey Brodkin | 23d1b35 | 2015-02-24 17:08:44 +0300 | [diff] [blame] | 81 | .endm |
| 82 | |
| 83 | ENTRY(memory_error) |
| 84 | SAVE_ALL_SYS |
| 85 | SAVE_EXCEPTION_SOURCE |
| 86 | mov %r1, %sp |
| 87 | j do_memory_error |
| 88 | ENDPROC(memory_error) |
| 89 | |
| 90 | ENTRY(instruction_error) |
| 91 | SAVE_ALL_SYS |
| 92 | SAVE_EXCEPTION_SOURCE |
| 93 | mov %r1, %sp |
| 94 | j do_instruction_error |
| 95 | ENDPROC(instruction_error) |
| 96 | |
| 97 | ENTRY(interrupt_handler) |
| 98 | /* Todo - save and restore CPU context when interrupts will be in use */ |
| 99 | bl do_interrupt_handler |
| 100 | rtie |
| 101 | ENDPROC(interrupt_handler) |
| 102 | |
| 103 | ENTRY(EV_MachineCheck) |
| 104 | SAVE_ALL_SYS |
| 105 | SAVE_EXCEPTION_SOURCE |
| 106 | mov %r1, %sp |
| 107 | j do_machine_check_fault |
| 108 | ENDPROC(EV_MachineCheck) |
| 109 | |
| 110 | ENTRY(EV_TLBMissI) |
| 111 | SAVE_ALL_SYS |
| 112 | mov %r0, %sp |
| 113 | j do_itlb_miss |
| 114 | ENDPROC(EV_TLBMissI) |
| 115 | |
| 116 | ENTRY(EV_TLBMissD) |
| 117 | SAVE_ALL_SYS |
| 118 | mov %r0, %sp |
| 119 | j do_dtlb_miss |
| 120 | ENDPROC(EV_TLBMissD) |
| 121 | |
| 122 | ENTRY(EV_TLBProtV) |
| 123 | SAVE_ALL_SYS |
| 124 | SAVE_EXCEPTION_SOURCE |
| 125 | mov %r1, %sp |
| 126 | j do_tlb_prot_violation |
| 127 | ENDPROC(EV_TLBProtV) |
| 128 | |
| 129 | ENTRY(EV_PrivilegeV) |
| 130 | SAVE_ALL_SYS |
| 131 | mov %r0, %sp |
| 132 | j do_privilege_violation |
| 133 | ENDPROC(EV_PrivilegeV) |
| 134 | |
| 135 | ENTRY(EV_Trap) |
| 136 | SAVE_ALL_SYS |
| 137 | mov %r0, %sp |
| 138 | j do_trap |
| 139 | ENDPROC(EV_Trap) |
| 140 | |
| 141 | ENTRY(EV_Extension) |
| 142 | SAVE_ALL_SYS |
| 143 | mov %r0, %sp |
| 144 | j do_extension |
| 145 | ENDPROC(EV_Extension) |
Alexey Brodkin | e20c289 | 2016-08-04 09:21:50 +0300 | [diff] [blame] | 146 | |
| 147 | #ifdef CONFIG_ISA_ARCV2 |
| 148 | ENTRY(EV_SWI) |
| 149 | SAVE_ALL_SYS |
| 150 | mov %r0, %sp |
| 151 | j do_swi |
| 152 | ENDPROC(EV_SWI) |
| 153 | |
| 154 | ENTRY(EV_DivZero) |
| 155 | SAVE_ALL_SYS |
| 156 | SAVE_EXCEPTION_SOURCE |
| 157 | mov %r1, %sp |
| 158 | j do_divzero |
| 159 | ENDPROC(EV_DivZero) |
| 160 | |
| 161 | ENTRY(EV_DCError) |
| 162 | SAVE_ALL_SYS |
| 163 | mov %r0, %sp |
| 164 | j do_dcerror |
| 165 | ENDPROC(EV_DCError) |
| 166 | |
| 167 | ENTRY(EV_Maligned) |
| 168 | SAVE_ALL_SYS |
| 169 | SAVE_EXCEPTION_SOURCE |
| 170 | mov %r1, %sp |
| 171 | j do_maligned |
| 172 | ENDPROC(EV_Maligned) |
| 173 | #endif |