Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 1998, 1999, 2000 by Ralf Baechle |
| 7 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 8 | * Copyright (C) 2007 by Maciej W. Rozycki |
| 9 | * Copyright (C) 2011, 2012 MIPS Technologies, Inc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | */ |
| 11 | #include <asm/asm.h> |
Sam Ravnborg | 048eb58 | 2005-09-09 22:32:31 +0200 | [diff] [blame] | 12 | #include <asm/asm-offsets.h> |
Paul Burton | 576a2f0 | 2016-11-07 11:14:15 +0000 | [diff] [blame] | 13 | #include <asm/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/regdef.h> |
| 15 | |
Atsushi Nemoto | a583158 | 2006-12-18 00:07:40 +0900 | [diff] [blame] | 16 | #if LONGSIZE == 4 |
| 17 | #define LONG_S_L swl |
| 18 | #define LONG_S_R swr |
| 19 | #else |
| 20 | #define LONG_S_L sdl |
| 21 | #define LONG_S_R sdr |
| 22 | #endif |
| 23 | |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 24 | #ifdef CONFIG_CPU_MICROMIPS |
| 25 | #define STORSIZE (LONGSIZE * 2) |
| 26 | #define STORMASK (STORSIZE - 1) |
| 27 | #define FILL64RG t8 |
| 28 | #define FILLPTRG t7 |
| 29 | #undef LONG_S |
| 30 | #define LONG_S LONG_SP |
| 31 | #else |
| 32 | #define STORSIZE LONGSIZE |
| 33 | #define STORMASK LONGMASK |
| 34 | #define FILL64RG a1 |
| 35 | #define FILLPTRG t0 |
| 36 | #endif |
| 37 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 38 | #define LEGACY_MODE 1 |
| 39 | #define EVA_MODE 2 |
| 40 | |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 41 | /* |
| 42 | * No need to protect it with EVA #ifdefery. The generated block of code |
| 43 | * will never be assembled if EVA is not enabled. |
| 44 | */ |
| 45 | #define __EVAFY(insn, reg, addr) __BUILD_EVA_INSN(insn##e, reg, addr) |
| 46 | #define ___BUILD_EVA_INSN(insn, reg, addr) __EVAFY(insn, reg, addr) |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define EX(insn,reg,addr,handler) \ |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 49 | .if \mode == LEGACY_MODE; \ |
| 50 | 9: insn reg, addr; \ |
| 51 | .else; \ |
| 52 | 9: ___BUILD_EVA_INSN(insn, reg, addr); \ |
| 53 | .endif; \ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 54 | .section __ex_table,"a"; \ |
| 55 | PTR 9b, handler; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | .previous |
| 57 | |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 58 | .macro f_fill64 dst, offset, val, fixup, mode |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 59 | EX(LONG_S, \val, (\offset + 0 * STORSIZE)(\dst), \fixup) |
| 60 | EX(LONG_S, \val, (\offset + 1 * STORSIZE)(\dst), \fixup) |
| 61 | EX(LONG_S, \val, (\offset + 2 * STORSIZE)(\dst), \fixup) |
| 62 | EX(LONG_S, \val, (\offset + 3 * STORSIZE)(\dst), \fixup) |
| 63 | #if ((defined(CONFIG_CPU_MICROMIPS) && (LONGSIZE == 4)) || !defined(CONFIG_CPU_MICROMIPS)) |
| 64 | EX(LONG_S, \val, (\offset + 4 * STORSIZE)(\dst), \fixup) |
| 65 | EX(LONG_S, \val, (\offset + 5 * STORSIZE)(\dst), \fixup) |
| 66 | EX(LONG_S, \val, (\offset + 6 * STORSIZE)(\dst), \fixup) |
| 67 | EX(LONG_S, \val, (\offset + 7 * STORSIZE)(\dst), \fixup) |
| 68 | #endif |
| 69 | #if (!defined(CONFIG_CPU_MICROMIPS) && (LONGSIZE == 4)) |
| 70 | EX(LONG_S, \val, (\offset + 8 * STORSIZE)(\dst), \fixup) |
| 71 | EX(LONG_S, \val, (\offset + 9 * STORSIZE)(\dst), \fixup) |
| 72 | EX(LONG_S, \val, (\offset + 10 * STORSIZE)(\dst), \fixup) |
| 73 | EX(LONG_S, \val, (\offset + 11 * STORSIZE)(\dst), \fixup) |
| 74 | EX(LONG_S, \val, (\offset + 12 * STORSIZE)(\dst), \fixup) |
| 75 | EX(LONG_S, \val, (\offset + 13 * STORSIZE)(\dst), \fixup) |
| 76 | EX(LONG_S, \val, (\offset + 14 * STORSIZE)(\dst), \fixup) |
| 77 | EX(LONG_S, \val, (\offset + 15 * STORSIZE)(\dst), \fixup) |
Atsushi Nemoto | a583158 | 2006-12-18 00:07:40 +0900 | [diff] [blame] | 78 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | .endm |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | .align 5 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 83 | /* |
| 84 | * Macro to generate the __bzero{,_user} symbol |
| 85 | * Arguments: |
| 86 | * mode: LEGACY_MODE or EVA_MODE |
| 87 | */ |
| 88 | .macro __BUILD_BZERO mode |
| 89 | /* Initialize __memset if this is the first time we call this macro */ |
| 90 | .ifnotdef __memset |
| 91 | .set __memset, 1 |
| 92 | .hidden __memset /* Make sure it does not leak */ |
| 93 | .endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 95 | sltiu t0, a2, STORSIZE /* very small region? */ |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 96 | .set noreorder |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 97 | bnez t0, .Lsmall_memset\@ |
Matt Redfearn | 2132563 | 2018-04-17 16:40:02 +0100 | [diff] [blame] | 98 | andi t0, a0, STORMASK /* aligned? */ |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 99 | .set reorder |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 101 | #ifdef CONFIG_CPU_MICROMIPS |
| 102 | move t8, a1 /* used by 'swp' instruction */ |
| 103 | move t9, a1 |
| 104 | #endif |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 105 | .set noreorder |
Maciej W. Rozycki | 619b6e1 | 2007-10-23 12:43:25 +0100 | [diff] [blame] | 106 | #ifndef CONFIG_CPU_DADDI_WORKAROUNDS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | beqz t0, 1f |
Matt Redfearn | 2132563 | 2018-04-17 16:40:02 +0100 | [diff] [blame] | 108 | PTR_SUBU t0, STORSIZE /* alignment in bytes */ |
Maciej W. Rozycki | 619b6e1 | 2007-10-23 12:43:25 +0100 | [diff] [blame] | 109 | #else |
| 110 | .set noat |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 111 | li AT, STORSIZE |
Maciej W. Rozycki | 619b6e1 | 2007-10-23 12:43:25 +0100 | [diff] [blame] | 112 | beqz t0, 1f |
Matt Redfearn | 2132563 | 2018-04-17 16:40:02 +0100 | [diff] [blame] | 113 | PTR_SUBU t0, AT /* alignment in bytes */ |
Maciej W. Rozycki | 619b6e1 | 2007-10-23 12:43:25 +0100 | [diff] [blame] | 114 | .set at |
| 115 | #endif |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 116 | .set reorder |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Alexander Lobakin | 18d84e2e | 2020-01-22 13:58:50 +0300 | [diff] [blame^] | 118 | #ifndef CONFIG_CPU_NO_LOAD_STORE_LR |
Thomas Bogendoerfer | 930bff8 | 2007-11-25 11:47:56 +0100 | [diff] [blame] | 119 | R10KCBARRIER(0(ra)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | #ifdef __MIPSEB__ |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 121 | EX(LONG_S_L, a1, (a0), .Lfirst_fixup\@) /* make word/dword aligned */ |
Markos Chandras | dd2adea | 2014-11-19 08:58:10 +0000 | [diff] [blame] | 122 | #else |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 123 | EX(LONG_S_R, a1, (a0), .Lfirst_fixup\@) /* make word/dword aligned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | #endif |
| 125 | PTR_SUBU a0, t0 /* long align ptr */ |
| 126 | PTR_ADDU a2, t0 /* correct size */ |
| 127 | |
Alexander Lobakin | 18d84e2e | 2020-01-22 13:58:50 +0300 | [diff] [blame^] | 128 | #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ |
Leonid Yegoshin | 8c56208 | 2014-11-18 09:04:34 +0000 | [diff] [blame] | 129 | #define STORE_BYTE(N) \ |
| 130 | EX(sb, a1, N(a0), .Lbyte_fixup\@); \ |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 131 | .set noreorder; \ |
Leonid Yegoshin | 8c56208 | 2014-11-18 09:04:34 +0000 | [diff] [blame] | 132 | beqz t0, 0f; \ |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 133 | PTR_ADDU t0, 1; \ |
| 134 | .set reorder; |
Leonid Yegoshin | 8c56208 | 2014-11-18 09:04:34 +0000 | [diff] [blame] | 135 | |
| 136 | PTR_ADDU a2, t0 /* correct size */ |
| 137 | PTR_ADDU t0, 1 |
| 138 | STORE_BYTE(0) |
| 139 | STORE_BYTE(1) |
| 140 | #if LONGSIZE == 4 |
| 141 | EX(sb, a1, 2(a0), .Lbyte_fixup\@) |
| 142 | #else |
| 143 | STORE_BYTE(2) |
| 144 | STORE_BYTE(3) |
| 145 | STORE_BYTE(4) |
| 146 | STORE_BYTE(5) |
| 147 | EX(sb, a1, 6(a0), .Lbyte_fixup\@) |
| 148 | #endif |
| 149 | 0: |
| 150 | ori a0, STORMASK |
| 151 | xori a0, STORMASK |
| 152 | PTR_ADDIU a0, STORSIZE |
Alexander Lobakin | 18d84e2e | 2020-01-22 13:58:50 +0300 | [diff] [blame^] | 153 | #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | 1: ori t1, a2, 0x3f /* # of full blocks */ |
| 155 | xori t1, 0x3f |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 156 | andi t0, a2, 0x40-STORSIZE |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 157 | beqz t1, .Lmemset_partial\@ /* no block to fill */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | PTR_ADDU t1, a0 /* end address */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | 1: PTR_ADDIU a0, 64 |
Thomas Bogendoerfer | 930bff8 | 2007-11-25 11:47:56 +0100 | [diff] [blame] | 161 | R10KCBARRIER(0(ra)) |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 162 | f_fill64 a0, -64, FILL64RG, .Lfwd_fixup\@, \mode |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | bne t1, a0, 1b |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 165 | .Lmemset_partial\@: |
Thomas Bogendoerfer | 930bff8 | 2007-11-25 11:47:56 +0100 | [diff] [blame] | 166 | R10KCBARRIER(0(ra)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | PTR_LA t1, 2f /* where to start */ |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 168 | #ifdef CONFIG_CPU_MICROMIPS |
| 169 | LONG_SRL t7, t0, 1 |
| 170 | #endif |
Atsushi Nemoto | a583158 | 2006-12-18 00:07:40 +0900 | [diff] [blame] | 171 | #if LONGSIZE == 4 |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 172 | PTR_SUBU t1, FILLPTRG |
Atsushi Nemoto | a583158 | 2006-12-18 00:07:40 +0900 | [diff] [blame] | 173 | #else |
| 174 | .set noat |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 175 | LONG_SRL AT, FILLPTRG, 1 |
Atsushi Nemoto | a583158 | 2006-12-18 00:07:40 +0900 | [diff] [blame] | 176 | PTR_SUBU t1, AT |
Maciej W. Rozycki | 619b6e1 | 2007-10-23 12:43:25 +0100 | [diff] [blame] | 177 | .set at |
Atsushi Nemoto | a583158 | 2006-12-18 00:07:40 +0900 | [diff] [blame] | 178 | #endif |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 179 | PTR_ADDU a0, t0 /* dest ptr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | jr t1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 182 | /* ... but first do longs ... */ |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 183 | f_fill64 a0, -64, FILL64RG, .Lpartial_fixup\@, \mode |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 184 | 2: andi a2, STORMASK /* At most one long to go */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 186 | .set noreorder |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | beqz a2, 1f |
Alexander Lobakin | 18d84e2e | 2020-01-22 13:58:50 +0300 | [diff] [blame^] | 188 | #ifndef CONFIG_CPU_NO_LOAD_STORE_LR |
Matt Redfearn | 2132563 | 2018-04-17 16:40:02 +0100 | [diff] [blame] | 189 | PTR_ADDU a0, a2 /* What's left */ |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 190 | .set reorder |
Thomas Bogendoerfer | 930bff8 | 2007-11-25 11:47:56 +0100 | [diff] [blame] | 191 | R10KCBARRIER(0(ra)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | #ifdef __MIPSEB__ |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 193 | EX(LONG_S_R, a1, -1(a0), .Llast_fixup\@) |
Markos Chandras | dd2adea | 2014-11-19 08:58:10 +0000 | [diff] [blame] | 194 | #else |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 195 | EX(LONG_S_L, a1, -1(a0), .Llast_fixup\@) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | #endif |
Alexander Lobakin | 18d84e2e | 2020-01-22 13:58:50 +0300 | [diff] [blame^] | 197 | #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ |
Matt Redfearn | 2132563 | 2018-04-17 16:40:02 +0100 | [diff] [blame] | 198 | PTR_SUBU t0, $0, a2 |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 199 | .set reorder |
Matt Redfearn | b1c03f1 | 2018-05-23 14:39:58 +0100 | [diff] [blame] | 200 | move a2, zero /* No remaining longs */ |
Leonid Yegoshin | 8c56208 | 2014-11-18 09:04:34 +0000 | [diff] [blame] | 201 | PTR_ADDIU t0, 1 |
| 202 | STORE_BYTE(0) |
| 203 | STORE_BYTE(1) |
| 204 | #if LONGSIZE == 4 |
| 205 | EX(sb, a1, 2(a0), .Lbyte_fixup\@) |
| 206 | #else |
| 207 | STORE_BYTE(2) |
| 208 | STORE_BYTE(3) |
| 209 | STORE_BYTE(4) |
| 210 | STORE_BYTE(5) |
| 211 | EX(sb, a1, 6(a0), .Lbyte_fixup\@) |
| 212 | #endif |
| 213 | 0: |
Alexander Lobakin | 18d84e2e | 2020-01-22 13:58:50 +0300 | [diff] [blame^] | 214 | #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 215 | 1: move a2, zero |
| 216 | jr ra |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 218 | .Lsmall_memset\@: |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 219 | PTR_ADDU t1, a0, a2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | beqz a2, 2f |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
| 222 | 1: PTR_ADDIU a0, 1 /* fill bytewise */ |
Thomas Bogendoerfer | 930bff8 | 2007-11-25 11:47:56 +0100 | [diff] [blame] | 223 | R10KCBARRIER(0(ra)) |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 224 | .set noreorder |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | bne t1, a0, 1b |
Matt Redfearn | 8a8158c | 2018-03-29 10:28:23 +0100 | [diff] [blame] | 226 | EX(sb, a1, -1(a0), .Lsmall_fixup\@) |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 227 | .set reorder |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 229 | 2: move a2, zero |
| 230 | jr ra /* done */ |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 231 | .if __memset == 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | END(memset) |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 233 | .set __memset, 0 |
| 234 | .hidden __memset |
| 235 | .endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
Alexander Lobakin | 18d84e2e | 2020-01-22 13:58:50 +0300 | [diff] [blame^] | 237 | #ifdef CONFIG_CPU_NO_LOAD_STORE_LR |
Leonid Yegoshin | 8c56208 | 2014-11-18 09:04:34 +0000 | [diff] [blame] | 238 | .Lbyte_fixup\@: |
Matt Redfearn | 6312455 | 2018-05-23 14:39:59 +0100 | [diff] [blame] | 239 | /* |
| 240 | * unset_bytes = (#bytes - (#unaligned bytes)) - (-#unaligned bytes remaining + 1) + 1 |
| 241 | * a2 = a2 - t0 + 1 |
| 242 | */ |
Matt Redfearn | b1c03f1 | 2018-05-23 14:39:58 +0100 | [diff] [blame] | 243 | PTR_SUBU a2, t0 |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 244 | PTR_ADDIU a2, 1 |
Leonid Yegoshin | 8c56208 | 2014-11-18 09:04:34 +0000 | [diff] [blame] | 245 | jr ra |
Alexander Lobakin | 18d84e2e | 2020-01-22 13:58:50 +0300 | [diff] [blame^] | 246 | #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ |
Leonid Yegoshin | 8c56208 | 2014-11-18 09:04:34 +0000 | [diff] [blame] | 247 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 248 | .Lfirst_fixup\@: |
Matt Redfearn | 6312455 | 2018-05-23 14:39:59 +0100 | [diff] [blame] | 249 | /* unset_bytes already in a2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | jr ra |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 252 | .Lfwd_fixup\@: |
Matt Redfearn | 6312455 | 2018-05-23 14:39:59 +0100 | [diff] [blame] | 253 | /* |
| 254 | * unset_bytes = partial_start_addr + #bytes - fault_addr |
| 255 | * a2 = t1 + (a2 & 3f) - $28->task->BUADDR |
| 256 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | PTR_L t0, TI_TASK($28) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | andi a2, 0x3f |
Tony Wu | e5674ad | 2010-11-10 21:48:15 +0800 | [diff] [blame] | 259 | LONG_L t0, THREAD_BUADDR(t0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | LONG_ADDU a2, t1 |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 261 | LONG_SUBU a2, t0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | jr ra |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 264 | .Lpartial_fixup\@: |
Matt Redfearn | 6312455 | 2018-05-23 14:39:59 +0100 | [diff] [blame] | 265 | /* |
| 266 | * unset_bytes = partial_end_addr + #bytes - fault_addr |
| 267 | * a2 = a0 + (a2 & STORMASK) - $28->task->BUADDR |
| 268 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | PTR_L t0, TI_TASK($28) |
Steven J. Hill | 26c5e07 | 2013-03-25 13:40:49 -0500 | [diff] [blame] | 270 | andi a2, STORMASK |
Tony Wu | e5674ad | 2010-11-10 21:48:15 +0800 | [diff] [blame] | 271 | LONG_L t0, THREAD_BUADDR(t0) |
Matt Redfearn | daf70d8 | 2018-04-17 15:52:21 +0100 | [diff] [blame] | 272 | LONG_ADDU a2, a0 |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 273 | LONG_SUBU a2, t0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | jr ra |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 276 | .Llast_fixup\@: |
Matt Redfearn | 6312455 | 2018-05-23 14:39:59 +0100 | [diff] [blame] | 277 | /* unset_bytes already in a2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | jr ra |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 279 | |
Matt Redfearn | 8a8158c | 2018-03-29 10:28:23 +0100 | [diff] [blame] | 280 | .Lsmall_fixup\@: |
Matt Redfearn | 6312455 | 2018-05-23 14:39:59 +0100 | [diff] [blame] | 281 | /* |
| 282 | * unset_bytes = end_addr - current_addr + 1 |
| 283 | * a2 = t1 - a0 + 1 |
| 284 | */ |
Matt Redfearn | 8a8158c | 2018-03-29 10:28:23 +0100 | [diff] [blame] | 285 | PTR_SUBU a2, t1, a0 |
Maciej W. Rozycki | 2f7619a | 2018-10-02 12:50:11 +0100 | [diff] [blame] | 286 | PTR_ADDIU a2, 1 |
Matt Redfearn | 8a8158c | 2018-03-29 10:28:23 +0100 | [diff] [blame] | 287 | jr ra |
Matt Redfearn | 8a8158c | 2018-03-29 10:28:23 +0100 | [diff] [blame] | 288 | |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 289 | .endm |
| 290 | |
| 291 | /* |
| 292 | * memset(void *s, int c, size_t n) |
| 293 | * |
| 294 | * a0: start of area to clear |
| 295 | * a1: char to fill with |
| 296 | * a2: size of area to clear |
| 297 | */ |
| 298 | |
| 299 | LEAF(memset) |
Paul Burton | 576a2f0 | 2016-11-07 11:14:15 +0000 | [diff] [blame] | 300 | EXPORT_SYMBOL(memset) |
Maciej W. Rozycki | 68dec26 | 2018-10-02 12:50:16 +0100 | [diff] [blame] | 301 | move v0, a0 /* result */ |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 302 | beqz a1, 1f |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 303 | |
| 304 | andi a1, 0xff /* spread fillword */ |
| 305 | LONG_SLL t1, a1, 8 |
| 306 | or a1, t1 |
| 307 | LONG_SLL t1, a1, 16 |
| 308 | #if LONGSIZE == 8 |
| 309 | or a1, t1 |
| 310 | LONG_SLL t1, a1, 32 |
| 311 | #endif |
| 312 | or a1, t1 |
| 313 | 1: |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 314 | #ifndef CONFIG_EVA |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 315 | FEXPORT(__bzero) |
Paul Burton | 576a2f0 | 2016-11-07 11:14:15 +0000 | [diff] [blame] | 316 | EXPORT_SYMBOL(__bzero) |
James Hogan | d6a428f | 2015-08-05 16:41:39 +0100 | [diff] [blame] | 317 | #else |
| 318 | FEXPORT(__bzero_kernel) |
Paul Burton | 576a2f0 | 2016-11-07 11:14:15 +0000 | [diff] [blame] | 319 | EXPORT_SYMBOL(__bzero_kernel) |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 320 | #endif |
Markos Chandras | 6d5155c | 2014-01-03 09:23:16 +0000 | [diff] [blame] | 321 | __BUILD_BZERO LEGACY_MODE |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 322 | |
| 323 | #ifdef CONFIG_EVA |
| 324 | LEAF(__bzero) |
Paul Burton | 576a2f0 | 2016-11-07 11:14:15 +0000 | [diff] [blame] | 325 | EXPORT_SYMBOL(__bzero) |
Markos Chandras | fd9720e | 2014-01-03 10:11:45 +0000 | [diff] [blame] | 326 | __BUILD_BZERO EVA_MODE |
| 327 | END(__bzero) |
| 328 | #endif |