1/* $NetBSD: bus_space_asm_generic.S,v 1.3 2003/03/27 19:46:14 mycroft Exp $ */ 2 3/*- 4 * Copyright (c) 1997 Causality Limited. 5 * Copyright (c) 1997 Mark Brinicombe. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Mark Brinicombe 19 * for the NetBSD Project. 20 * 4. The name of the company nor the name of the author may be used to 21 * endorse or promote products derived from this software without specific 22 * prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 */ 37 38#include <machine/asm.h> 39/* 40 * Generic bus_space functions. 41 */ 42 43/* 44 * read single 45 */ 46 47ENTRY(generic_bs_r_1) 48 ldrb r0, [r1, r2] 49 RET 50END(generic_bs_r_1) 51 52ENTRY(generic_bs_r_2) 53 ldrh r0, [r1, r2] 54 RET 55END(generic_bs_r_2) 56 57ENTRY(generic_bs_r_4) 58 ldr r0, [r1, r2] 59 RET 60END(generic_bs_r_4) 61 62/* 63 * write single 64 */ 65 66ENTRY(generic_bs_w_1) 67 strb r3, [r1, r2] 68 RET 69END(generic_bs_w_1) 70 71ENTRY(generic_bs_w_2) 72 strh r3, [r1, r2] 73 RET 74END(generic_bs_w_2) 75 76ENTRY(generic_bs_w_4) 77 str r3, [r1, r2] 78 RET 79END(generic_bs_w_4) 80 81/* 82 * read multiple 83 */ 84 85ENTRY(generic_bs_rm_1) 86 add r0, r1, r2 87 mov r1, r3 88 ldr r2, [sp, #0] 89 teq r2, #0 90 RETeq 91 921: ldrb r3, [r0] 93 strb r3, [r1], #1 94 subs r2, r2, #1 95 bne 1b 96 97 RET 98END(generic_bs_rm_1) 99 100ENTRY(generic_bs_rm_2) 101 add r0, r1, r2 102 mov r1, r3 103 ldr r2, [sp, #0] 104 teq r2, #0 105 RETeq 106 1071: ldrh r3, [r0] 108 strh r3, [r1], #2 109 subs r2, r2, #1 110 bne 1b 111 112 RET 113END(generic_bs_rm_2) 114 115ENTRY(generic_bs_rm_4) 116 add r0, r1, r2 117 mov r1, r3 118 ldr r2, [sp, #0] 119 teq r2, #0 120 RETeq 121 1221: ldr r3, [r0] 123 str r3, [r1], #4 124 subs r2, r2, #1 125 bne 1b 126 127 RET 128END(generic_bs_rm_4) 129 130/* 131 * write multiple 132 */ 133 134ENTRY(generic_bs_wm_1) 135 add r0, r1, r2 136 mov r1, r3 137 ldr r2, [sp, #0] 138 teq r2, #0 139 RETeq 140 1411: ldrb r3, [r1], #1 142 strb r3, [r0] 143 subs r2, r2, #1 144 bne 1b 145 146 RET 147END(generic_bs_wm_1) 148 149ENTRY(generic_bs_wm_2) 150 add r0, r1, r2 151 mov r1, r3 152 ldr r2, [sp, #0] 153 teq r2, #0 154 RETeq 155 1561: ldrh r3, [r1], #2 157 strh r3, [r0] 158 subs r2, r2, #1 159 bne 1b 160 161 RET 162END(generic_bs_wm_2) 163 164ENTRY(generic_bs_wm_4) 165 add r0, r1, r2 166 mov r1, r3 167 ldr r2, [sp, #0] 168 teq r2, #0 169 RETeq 170 1711: ldr r3, [r1], #4 172 str r3, [r0] 173 subs r2, r2, #1 174 bne 1b 175 176 RET 177END(generic_bs_wm_4) 178 179/* 180 * read region 181 */ 182 183ENTRY(generic_bs_rr_1) 184 add r0, r1, r2 185 mov r1, r3 186 ldr r2, [sp, #0] 187 teq r2, #0 188 RETeq 189 1901: ldrb r3, [r0], #1 191 strb r3, [r1], #1 192 subs r2, r2, #1 193 bne 1b 194 195 RET 196END(generic_bs_rr_1) 197 198ENTRY(generic_bs_rr_2) 199 add r0, r1, r2 200 mov r1, r3 201 ldr r2, [sp, #0] 202 teq r2, #0 203 RETeq 204 2051: ldrh r3, [r0], #2 206 strh r3, [r1], #2 207 subs r2, r2, #1 208 bne 1b 209 210 RET 211END(generic_bs_rr_2) 212 213ENTRY(generic_bs_rr_4) 214 add r0, r1, r2 215 mov r1, r3 216 ldr r2, [sp, #0] 217 teq r2, #0 218 RETeq 219 2201: ldr r3, [r0], #4 221 str r3, [r1], #4 222 subs r2, r2, #1 223 bne 1b 224 225 RET 226END(generic_bs_rr_4) 227 228/* 229 * write region. 230 */ 231 232ENTRY(generic_bs_wr_1) 233 add r0, r1, r2 234 mov r1, r3 235 ldr r2, [sp, #0] 236 teq r2, #0 237 RETeq 238 2391: ldrb r3, [r1], #1 240 strb r3, [r0], #1 241 subs r2, r2, #1 242 bne 1b 243 244 RET 245END(generic_bs_wr_1) 246 247ENTRY(generic_bs_wr_2) 248 add r0, r1, r2 249 mov r1, r3 250 ldr r2, [sp, #0] 251 teq r2, #0 252 RETeq 253 2541: ldrh r3, [r1], #2 255 strh r3, [r0], #2 256 subs r2, r2, #1 257 bne 1b 258 259 RET 260END(generic_bs_wr_2) 261 262ENTRY(generic_bs_wr_4) 263 add r0, r1, r2 264 mov r1, r3 265 ldr r2, [sp, #0] 266 teq r2, #0 267 RETeq 268 2691: ldr r3, [r1], #4 270 str r3, [r0], #4 271 subs r2, r2, #1 272 bne 1b 273 274 RET 275END(generic_bs_wr_4) 276 277/* 278 * set region 279 */ 280 281ENTRY(generic_bs_sr_1) 282 add r0, r1, r2 283 mov r1, r3 284 ldr r2, [sp, #0] 285 teq r2, #0 286 RETeq 287 2881: strb r1, [r0], #1 289 subs r2, r2, #1 290 bne 1b 291 292 RET 293END(generic_bs_sr_1) 294 295ENTRY(generic_bs_sr_2) 296 add r0, r1, r2 297 mov r1, r3 298 ldr r2, [sp, #0] 299 teq r2, #0 300 RETeq 301 3021: strh r1, [r0], #2 303 subs r2, r2, #1 304 bne 1b 305 306 RET 307END(generic_bs_sr_2) 308 309ENTRY(generic_bs_sr_4) 310 add r0, r1, r2 311 mov r1, r3 312 ldr r2, [sp, #0] 313 teq r2, #0 314 RETeq 315 3161: str r1, [r0], #4 317 subs r2, r2, #1 318 bne 1b 319 320 RET 321END(generic_bs_sr_4) 322 323/* 324 * copy region 325 */ 326 327ENTRY(generic_bs_c_2) 328 add r0, r1, r2 329 ldr r2, [sp, #0] 330 add r1, r2, r3 331 ldr r2, [sp, #4] 332 teq r2, #0 333 RETeq 334 335 cmp r0, r1 336 blt 2f 337 3381: ldrh r3, [r0], #2 339 strh r3, [r1], #2 340 subs r2, r2, #1 341 bne 1b 342 343 RET 344 3452: add r0, r0, r2, lsl #1 346 add r1, r1, r2, lsl #1 347 sub r0, r0, #2 348 sub r1, r1, #2 349 3503: ldrh r3, [r0], #-2 351 strh r3, [r1], #-2 352 subs r2, r2, #1 353 bne 3b 354 355 RET 356END(generic_bs_c_2) 357 358