1 1.4 martin /* $NetBSD: isa_io_asm.S,v 1.4 2008/04/28 20:23:35 martin Exp $ */ 2 1.1 thorpej 3 1.1 thorpej /*- 4 1.1 thorpej * Copyright (c) 1997 The NetBSD Foundation, Inc. 5 1.1 thorpej * All rights reserved. 6 1.1 thorpej * 7 1.1 thorpej * This code is derived from software contributed to The NetBSD Foundation 8 1.1 thorpej * by Mark Brinicombe. 9 1.1 thorpej * 10 1.1 thorpej * Redistribution and use in source and binary forms, with or without 11 1.1 thorpej * modification, are permitted provided that the following conditions 12 1.1 thorpej * are met: 13 1.1 thorpej * 1. Redistributions of source code must retain the above copyright 14 1.1 thorpej * notice, this list of conditions and the following disclaimer. 15 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 thorpej * notice, this list of conditions and the following disclaimer in the 17 1.1 thorpej * documentation and/or other materials provided with the distribution. 18 1.1 thorpej * 19 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE. 30 1.1 thorpej */ 31 1.1 thorpej 32 1.1 thorpej /* 33 1.1 thorpej * Copyright 1997 34 1.1 thorpej * Digital Equipment Corporation. All rights reserved. 35 1.1 thorpej * 36 1.1 thorpej * This software is furnished under license and may be used and 37 1.1 thorpej * copied only in accordance with the following terms and conditions. 38 1.1 thorpej * Subject to these conditions, you may download, copy, install, 39 1.1 thorpej * use, modify and distribute this software in source and/or binary 40 1.1 thorpej * form. No title or ownership is transferred hereby. 41 1.1 thorpej * 42 1.1 thorpej * 1) Any source code used, modified or distributed must reproduce 43 1.1 thorpej * and retain this copyright notice and list of conditions as 44 1.1 thorpej * they appear in the source file. 45 1.1 thorpej * 46 1.1 thorpej * 2) No right is granted to use any trade name, trademark, or logo of 47 1.1 thorpej * Digital Equipment Corporation. Neither the "Digital Equipment 48 1.1 thorpej * Corporation" name nor any trademark or logo of Digital Equipment 49 1.1 thorpej * Corporation may be used to endorse or promote products derived 50 1.1 thorpej * from this software without the prior written permission of 51 1.1 thorpej * Digital Equipment Corporation. 52 1.1 thorpej * 53 1.1 thorpej * 3) This software is provided "AS-IS" and any express or implied 54 1.1 thorpej * warranties, including but not limited to, any implied warranties 55 1.1 thorpej * of merchantability, fitness for a particular purpose, or 56 1.1 thorpej * non-infringement are disclaimed. In no event shall DIGITAL be 57 1.1 thorpej * liable for any damages whatsoever, and in particular, DIGITAL 58 1.1 thorpej * shall not be liable for special, indirect, consequential, or 59 1.1 thorpej * incidental damages or damages for lost profits, loss of 60 1.1 thorpej * revenue or loss of use, whether such damages arise in contract, 61 1.1 thorpej * negligence, tort, under statute, in equity, at law or otherwise, 62 1.1 thorpej * even if advised of the possibility of such damage. 63 1.1 thorpej */ 64 1.1 thorpej 65 1.1 thorpej /* 66 1.1 thorpej * bus_space I/O functions for isa 67 1.1 thorpej */ 68 1.1 thorpej 69 1.1 thorpej #include <machine/asm.h> 70 1.1 thorpej 71 1.1 thorpej #ifdef GPROF 72 1.1 thorpej #define PAUSE nop ; nop ; nop ; nop ; nop 73 1.1 thorpej #else 74 1.1 thorpej #define PAUSE 75 1.1 thorpej #endif 76 1.1 thorpej 77 1.1 thorpej /* 78 1.1 thorpej * Note these functions use ARM Architecture V4 instructions as 79 1.1 thorpej * all current systems with ISA will be using processors that support 80 1.1 thorpej * V4 or later architectures (SHARK & CATS) 81 1.1 thorpej */ 82 1.1 thorpej 83 1.1 thorpej /* 84 1.1 thorpej * read single 85 1.1 thorpej */ 86 1.1 thorpej 87 1.1 thorpej ENTRY(isa_bs_r_1) 88 1.1 thorpej ldrb r0, [r1, r2] 89 1.1 thorpej PAUSE 90 1.1 thorpej mov pc, lr 91 1.1 thorpej 92 1.1 thorpej ENTRY(isa_bs_r_2) 93 1.1 thorpej ldrh r0, [r1, r2] /*.word 0xe19100b2*/ 94 1.1 thorpej PAUSE 95 1.1 thorpej mov pc, lr 96 1.1 thorpej 97 1.1 thorpej ENTRY(isa_bs_r_4) 98 1.1 thorpej ldr r0, [r1, r2] 99 1.1 thorpej PAUSE 100 1.1 thorpej mov pc, lr 101 1.1 thorpej 102 1.1 thorpej /* 103 1.1 thorpej * read multiple. 104 1.1 thorpej */ 105 1.1 thorpej 106 1.1 thorpej ENTRY(isa_bs_rm_1) 107 1.1 thorpej add r0, r1, r2 108 1.1 thorpej mov r1, r3 109 1.1 thorpej ldr r2, [sp, #0] 110 1.1 thorpej teq r2, #0 111 1.1 thorpej moveq pc, lr 112 1.1 thorpej 113 1.1 thorpej Lisa_rm_1_loop: 114 1.1 thorpej ldrb r3, [r0] 115 1.1 thorpej strb r3, [r1], #1 116 1.1 thorpej subs r2, r2, #1 117 1.1 thorpej bne Lisa_rm_1_loop 118 1.1 thorpej 119 1.1 thorpej mov pc, lr 120 1.1 thorpej 121 1.1 thorpej ENTRY(isa_bs_rm_2) 122 1.1 thorpej add r0, r1, r2 123 1.1 thorpej mov r1, r3 124 1.1 thorpej ldr r2, [sp, #0] 125 1.1 thorpej teq r2, #0 126 1.1 thorpej moveq pc, lr 127 1.1 thorpej 128 1.1 thorpej Lisa_rm_2_loop: 129 1.1 thorpej ldrh r3, [r0] /*.word 0xe1d030b0*/ 130 1.1 thorpej strh r3, [r1], #2 /*.word 0xe0c130b2*/ 131 1.1 thorpej subs r2, r2, #1 132 1.1 thorpej bne Lisa_rm_2_loop 133 1.1 thorpej 134 1.1 thorpej mov pc, lr 135 1.1 thorpej 136 1.1 thorpej ENTRY(isa_bs_rm_4) 137 1.1 thorpej add r0, r1, r2 138 1.1 thorpej mov r1, r3 139 1.1 thorpej ldr r2, [sp, #0] 140 1.1 thorpej teq r2, #0 141 1.1 thorpej moveq pc, lr 142 1.1 thorpej 143 1.1 thorpej Lisa_rm_4_loop: 144 1.1 thorpej ldr r3, [r0] 145 1.1 thorpej str r3, [r1], #4 146 1.1 thorpej subs r2, r2, #1 147 1.1 thorpej bne Lisa_rm_4_loop 148 1.1 thorpej 149 1.1 thorpej mov pc, lr 150 1.1 thorpej 151 1.1 thorpej /* 152 1.1 thorpej * read region. 153 1.1 thorpej */ 154 1.1 thorpej 155 1.1 thorpej ENTRY(isa_bs_rr_1) 156 1.1 thorpej add r0, r1, r2 157 1.1 thorpej mov r1, r3 158 1.1 thorpej ldr r2, [sp, #0] 159 1.1 thorpej teq r2, #0 160 1.1 thorpej moveq pc, lr 161 1.1 thorpej 162 1.1 thorpej Lisa_rr_1_loop: 163 1.1 thorpej ldrb r3, [r0], #1 164 1.1 thorpej strb r3, [r1], #1 165 1.1 thorpej subs r2, r2, #1 166 1.1 thorpej bne Lisa_rr_1_loop 167 1.1 thorpej 168 1.1 thorpej mov pc, lr 169 1.1 thorpej 170 1.1 thorpej ENTRY(isa_bs_rr_2) 171 1.1 thorpej add r0, r1, r2 172 1.1 thorpej mov r1, r3 173 1.1 thorpej ldr r2, [sp, #0] 174 1.1 thorpej teq r2, #0 175 1.1 thorpej moveq pc, lr 176 1.1 thorpej 177 1.1 thorpej Lisa_rr_2_loop: 178 1.1 thorpej ldrh r3, [r0], #2 179 1.1 thorpej strh r3, [r1], #2 /*.word 0xe0c130b2*/ 180 1.1 thorpej subs r2, r2, #1 181 1.1 thorpej bne Lisa_rr_2_loop 182 1.1 thorpej 183 1.1 thorpej mov pc, lr 184 1.1 thorpej 185 1.1 thorpej ENTRY(isa_bs_rr_4) 186 1.1 thorpej add r0, r1, r2 187 1.1 thorpej mov r1, r3 188 1.1 thorpej ldr r2, [sp, #0] 189 1.1 thorpej teq r2, #0 190 1.1 thorpej moveq pc, lr 191 1.1 thorpej 192 1.1 thorpej Lisa_rr_4_loop: 193 1.1 thorpej ldr r3, [r0], #4 194 1.1 thorpej str r3, [r1], #4 195 1.1 thorpej subs r2, r2, #1 196 1.1 thorpej bne Lisa_rr_4_loop 197 1.1 thorpej 198 1.1 thorpej mov pc, lr 199 1.1 thorpej 200 1.1 thorpej /* 201 1.1 thorpej * write single 202 1.1 thorpej */ 203 1.1 thorpej 204 1.1 thorpej ENTRY(isa_bs_w_1) 205 1.1 thorpej strb r3, [r1, r2] 206 1.1 thorpej PAUSE 207 1.1 thorpej mov pc, lr 208 1.1 thorpej 209 1.1 thorpej ENTRY(isa_bs_w_2) 210 1.1 thorpej strh r3, [r1, r2] /*.word 0xe18130b2*/ 211 1.1 thorpej PAUSE 212 1.1 thorpej mov pc, lr 213 1.1 thorpej 214 1.1 thorpej ENTRY(isa_bs_w_4) 215 1.1 thorpej str r3, [r1, r2] 216 1.1 thorpej PAUSE 217 1.1 thorpej mov pc, lr 218 1.1 thorpej 219 1.1 thorpej /* 220 1.1 thorpej * write multiple 221 1.1 thorpej */ 222 1.1 thorpej 223 1.1 thorpej ENTRY(isa_bs_wm_1) 224 1.1 thorpej add r0, r1, r2 225 1.1 thorpej mov r1, r3 226 1.1 thorpej ldr r2, [sp, #0] 227 1.1 thorpej teq r2, #0 228 1.1 thorpej moveq pc, lr 229 1.1 thorpej 230 1.1 thorpej Lisa_wm_1_loop: 231 1.1 thorpej ldrb r3, [r1], #1 232 1.1 thorpej strb r3, [r0] 233 1.1 thorpej subs r2, r2, #1 234 1.1 thorpej bne Lisa_wm_1_loop 235 1.1 thorpej 236 1.1 thorpej mov pc, lr 237 1.1 thorpej 238 1.1 thorpej ENTRY(isa_bs_wm_2) 239 1.1 thorpej add r0, r1, r2 240 1.1 thorpej mov r1, r3 241 1.1 thorpej ldr r2, [sp, #0] 242 1.1 thorpej teq r2, #0 243 1.1 thorpej moveq pc, lr 244 1.1 thorpej 245 1.1 thorpej Lisa_wm_2_loop: 246 1.1 thorpej ldrh r3, [r1], #2 /*.word 0xe0d130b2*/ 247 1.1 thorpej strh r3, [r0] /*.word 0xe1c030b0*/ 248 1.1 thorpej subs r2, r2, #1 249 1.1 thorpej bne Lisa_wm_2_loop 250 1.1 thorpej 251 1.1 thorpej mov pc, lr 252 1.1 thorpej 253 1.1 thorpej ENTRY(isa_bs_wm_4) 254 1.1 thorpej add r0, r1, r2 255 1.1 thorpej mov r1, r3 256 1.1 thorpej ldr r2, [sp, #0] 257 1.1 thorpej teq r2, #0 258 1.1 thorpej moveq pc, lr 259 1.1 thorpej 260 1.1 thorpej Lisa_wm_4_loop: 261 1.1 thorpej ldr r3, [r1], #4 262 1.1 thorpej str r3, [r0] 263 1.1 thorpej subs r2, r2, #1 264 1.1 thorpej bne Lisa_wm_4_loop 265 1.1 thorpej 266 1.1 thorpej mov pc, lr 267 1.1 thorpej 268 1.1 thorpej 269 1.1 thorpej /* 270 1.1 thorpej * write region. 271 1.1 thorpej */ 272 1.1 thorpej 273 1.1 thorpej ENTRY(isa_bs_wr_1) 274 1.1 thorpej add r0, r1, r2 275 1.1 thorpej mov r1, r3 276 1.1 thorpej ldr r2, [sp, #0] 277 1.1 thorpej teq r2, #0 278 1.1 thorpej moveq pc, lr 279 1.1 thorpej 280 1.1 thorpej Lisa_wr_1_loop: 281 1.1 thorpej ldrb r3, [r1], #1 282 1.1 thorpej strb r3, [r0], #1 283 1.1 thorpej subs r2, r2, #1 284 1.1 thorpej bne Lisa_wr_1_loop 285 1.1 thorpej 286 1.1 thorpej mov pc, lr 287 1.1 thorpej 288 1.1 thorpej ENTRY(isa_bs_wr_2) 289 1.1 thorpej add r0, r1, r2 290 1.1 thorpej mov r1, r3 291 1.1 thorpej ldr r2, [sp, #0] 292 1.1 thorpej teq r2, #0 293 1.1 thorpej moveq pc, lr 294 1.1 thorpej 295 1.1 thorpej Lisa_wr_2_loop: 296 1.1 thorpej ldrh r3, [r1], #2 /*.word 0xe0d130b2*/ 297 1.1 thorpej strh r3, [r0], #2 298 1.1 thorpej subs r2, r2, #1 299 1.1 thorpej bne Lisa_wr_2_loop 300 1.1 thorpej 301 1.1 thorpej mov pc, lr 302 1.1 thorpej 303 1.1 thorpej ENTRY(isa_bs_wr_4) 304 1.1 thorpej add r0, r1, r2 305 1.1 thorpej mov r1, r3 306 1.1 thorpej ldr r2, [sp, #0] 307 1.1 thorpej teq r2, #0 308 1.1 thorpej moveq pc, lr 309 1.1 thorpej 310 1.1 thorpej Lisa_wr_4_loop: 311 1.1 thorpej ldr r3, [r1], #4 312 1.1 thorpej str r3, [r0], #4 313 1.1 thorpej subs r2, r2, #1 314 1.1 thorpej bne Lisa_wr_4_loop 315 1.1 thorpej 316 1.1 thorpej mov pc, lr 317 1.1 thorpej 318 1.1 thorpej /* 319 1.1 thorpej * Set region 320 1.1 thorpej */ 321 1.1 thorpej 322 1.1 thorpej ENTRY(isa_bs_sr_2) 323 1.1 thorpej add r0, r1, r2 324 1.1 thorpej mov r1, r3 325 1.1 thorpej ldr r2, [sp, #0] 326 1.1 thorpej teq r2, #0 327 1.1 thorpej moveq pc, lr 328 1.1 thorpej 329 1.1 thorpej Lisa_bs_sr_2_loop: 330 1.1 thorpej strh r1, [r0], #2 /*.word e0c010b2*/ 331 1.1 thorpej subs r2, r2, #1 332 1.1 thorpej bne Lisa_bs_sr_2_loop 333 1.1 thorpej 334 1.1 thorpej mov pc, lr 335 1.2 tsutsui 336 1.2 tsutsui /* 337 1.2 tsutsui * Copy region 338 1.2 tsutsui */ 339 1.2 tsutsui 340 1.2 tsutsui ENTRY(isa_bs_c_2) 341 1.2 tsutsui add r0, r1, r2 342 1.2 tsutsui ldr r2, [sp, #0] 343 1.2 tsutsui add r1, r2, r3 344 1.2 tsutsui ldr r2, [sp, #4] 345 1.2 tsutsui teq r2, #0 346 1.2 tsutsui moveq pc, lr 347 1.2 tsutsui 348 1.2 tsutsui cmp r0, r1 349 1.2 tsutsui blt 2f 350 1.2 tsutsui 351 1.2 tsutsui 1: ldrh r3, [r0], #2 352 1.2 tsutsui strh r3, [r1], #2 353 1.2 tsutsui subs r2, r2, #1 354 1.2 tsutsui bne 1b 355 1.2 tsutsui 356 1.2 tsutsui mov pc, lr 357 1.2 tsutsui 358 1.2 tsutsui 2: add r0, r0, r2, lsl #1 359 1.2 tsutsui add r1, r1, r2, lsl #1 360 1.2 tsutsui sub r0, r0, #2 361 1.2 tsutsui sub r1, r1, #2 362 1.2 tsutsui 363 1.2 tsutsui 3: ldrh r3, [r0], #-2 364 1.2 tsutsui strh r3, [r1], #-2 365 1.2 tsutsui subs r2, r2, #1 366 1.2 tsutsui bne 3b 367 1.2 tsutsui 368 1.2 tsutsui mov pc, lr 369