1/* $NetBSD: external_io_asm.S,v 1.2 2013/06/22 13:32:54 kiyohara Exp $ */ 2 3/* 4 * Copyright (c) 1997 Mark Brinicombe. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Mark Brinicombe. 18 * 4. The name of the company nor the name of the author may be used to 19 * endorse or promote products derived from this software without specific 20 * prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 35#include <machine/asm.h> 36 37/* 38 * bus_space I/O functions for external bus 39 */ 40 41/* 42 * read single 43 */ 44 45ENTRY(external_bs_r_1) 46 mov r2, r2, lsl r0 47 ldrb r0, [r1, r2] 48 mov pc, lr 49 50ENTRY(external_bs_r_4) 51 mov r2, r2, lsl r0 52 ldr r0, [r1, r2] 53 mov pc, lr 54 55/* 56 * write single 57 */ 58 59ENTRY(external_bs_w_1) 60 mov r2, r2, lsl r0 61 strb r3, [r1, r2] 62 mov pc, lr 63 64ENTRY(external_bs_w_4) 65 mov r2, r2, lsl r0 66 str r3, [r1, r2] 67 mov pc, lr 68 69/* 70 * read multiple 71 */ 72 73ENTRY(external_bs_rm_1) 74 add r0, r1, r2, lsl r0 75 ldr r2, [sp, #0] 76 77 /* Make sure that we have a positive length */ 78 cmp r2, #0x00000000 79 movle pc, lr 80 81external_rm_1_loop: 82 ldrb r1, [r0] 83 strb r1, [r3], #0x0001 84 subs r2, r2, #0x00000001 85 bgt external_rm_1_loop 86 87 mov pc, lr 88 89ENTRY(external_bs_rm_2) 90 add r0, r1, r2, lsl r0 91 mov r1, r3 92 ldr r2, [sp, #0] 93 b _C_LABEL(insw) 94 95ENTRY(external_bs_rm_4) 96 add r0, r1, r2, lsl r0 97 mov r1, r3 98 ldr r2, [sp, #0] 99 teq r2, #0 100 moveq pc, lr 101 1021: ldr r3, [r0] 103 str r3, [r1], #4 104 subs r2, r2, #1 105 bne 1b 106 107 mov pc, lr 108 109/* 110 * write multiple 111 */ 112 113ENTRY(external_bs_wm_1) 114 add r0, r1, r2, lsl r0 115 ldr r2, [sp, #0] 116 117 /* Make sure that we have a positive length */ 118 cmp r2, #0x00000000 119 movle pc, lr 120 121external_wm_1_loop: 122 ldrb r1, [r3], #0x0001 123 strb r1, [r0] 124 subs r2, r2, #0x00000001 125 bgt external_wm_1_loop 126 127 mov pc, lr 128 129ENTRY(external_bs_wm_2) 130 add r0, r1, r2, lsl r0 131 mov r1, r3 132 ldr r2, [sp, #0] 133 b _C_LABEL(outsw) 134 135ENTRY(external_bs_wm_4) 136 add r0, r1, r2, lsl r0 137 mov r1, r3 138 ldr r2, [sp, #0] 139 teq r2, #0 140 moveq pc, lr 141 1421: ldr r3, [r1], #4 143 str r3, [r0] 144 subs r2, r2, #1 145 bne 1b 146 147 mov pc, lr 148