1define(_rcsid,``$OpenBSD: bcopy.m4,v 1.17 2007/11/24 19:42:00 deraadt Exp $'')dnl 2dnl 3dnl 4dnl This is the source file for bcopy.S, spcopy.S 5dnl 6dnl 7define(`versionmacro',substr(_rcsid,1,eval(len(_rcsid)-2)))dnl 8dnl 9/* This is a generated file. DO NOT EDIT. */ 10/* 11 * Generated from: 12 * 13 * versionmacro 14 */ 15/* 16 * Copyright (c) 1999 Michael Shalayeff 17 * All rights reserved. 18 * 19 * Redistribution and use in source and binary forms, with or without 20 * modification, are permitted provided that the following conditions 21 * are met: 22 * 1. Redistributions of source code must retain the above copyright 23 * notice, this list of conditions and the following disclaimer. 24 * 2. Redistributions in binary form must reproduce the above copyright 25 * notice, this list of conditions and the following disclaimer in the 26 * documentation and/or other materials provided with the distribution. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 31 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 33 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 37 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 * 39 */ 40 41dnl 42dnl macro: L(`arg1',`arg2') 43dnl synopsis: creates an assembly label based on args resulting in $arg1.arg2 44dnl 45define(`L', `$$1.$2')dnl 46dnl 47dnl 48dnl 49define(`STWS',`ifelse($5, `u',dnl 50`ifelse($1, `1', `vshd $4, t`$1', r31 51 stbys,B,m r31, F`'4($2, $3)', 52`0', `0', `vshd t`'decr($1), t`$1', r31 53 stws,M r31, F`'4($2, $3)')',dnl 54`0', `0', 55`ifelse($1, `1', 56`stbys,B`'ifelse(B, `b', `,m ', `0', `0', ` ')`'t`$1', F`'4($2, $3)', 57`0', `0', `stws,M t`$1', F`'4($2, $3)')')')dnl 58define(`STWSS', `ifelse(`$3', `1', `dnl', 59`0', `0', `STWSS($1, $2, eval($3 - 1), $4, $5)') 60 STWS($3, $1, $2, $4, $5)dnl 61')dnl 62define(`LDWSS', `ifelse(`$3', `1', `dnl', 63`0', `0', `LDWSS($1, $2, eval($3 - 1))') 64 ldws,M F`'4($1, $2), t`'$3`'dnl 65')dnl 66dnl 67dnl copy data in 4-words blocks 68dnl 69define(`hppa_blcopy',` 70 addi -16, $6, $6 71L($1, `loop16'`$7') 72dnl cache hint may not work on some hardware 73dnl ldw F 32($2, $3), r0 74ifelse(F, `-', `dnl 75 addi F`'4, $5, $5', `0', `0', `dnl') 76LDWSS($2, $3, 4) 77STWSS($4, $5, 3, `ret1', $7) 78ifelse($7, `u', `dnl 79 STWS(4, $4, $5, `ret1', $7)', $7, `a', `dnl') 80 addib,>= -16, $6, L($1, `loop16'`$7') 81ifelse($7, `a', `dnl 82 STWS(4, $4, $5, `ret1', $7)dnl 83', $7, `u', `dnl 84 copy t4, ret1')')dnl 85dnl 86dnl copy in words 87dnl 88define(`STWL', `addib,<,n 12, $6, L($1, cleanup) 89ifelse($7, `u', ` copy ret1, t1', $7, `a', `dnl') 90L($1, word) 91 ldws,M F`'4($2, $3), t1 92 addib,>= -4, $6, L($1, word) 93 stws,M t1, F`'4($4, $5) 94 95L($1, cleanup) 96 addib,=,n 4, $6, L($1, done) 97 ldws 0($2, $3), t1 98 add $5, $6, $5 99 b L($1, done) 100 stbys,E t1, 0($4, $5) 101') 102dnl 103dnl 104dnl parameters: 105dnl $1 name 106dnl $2 source space 107dnl $3 source address 108dnl $4 destination space 109dnl $5 destination address 110dnl $6 length 111dnl $7 direction 112dnl 113define(hppa_copy, 114`dnl 115dnl 116dnl if direction is `-' (backwards copy), adjust src, dst 117dnl 118ifelse($7,`-', `add $3, $6, $3 119 add $5, $6, $5 120define(`F', `-')dnl 121define(`R', `')dnl 122define(`M', `mb')dnl 123define(`B', `e')dnl 124define(`E', `b')dnl 125',dnl ifelse 126`0',`0', 127`define(`F', `')dnl 128define(`R', `-')dnl 129define(`M', `ma')dnl 130define(`B', `b')dnl 131define(`E', `e')dnl 132')dnl ifelse 133 134ifelse($7,`-', `', `0',`0', 135` comib,>=,n 15, $6, L($1, byte) 136 137 extru $3, 31, 2, t3 138 extru $5, 31, 2, t4 139 add $6, t4, $6 140 comb,<> t3, t4, L($1, unaligned) 141 dep r0, 31, 2, $3 142 hppa_blcopy($1, $2, $3, $4, $5, $6, `a') 143 144 STWL($1, $2, $3, $4, $5, $6, `a')dnl 145 146L($1, unaligned) 147 sub,>= t4, t3, t2 148 ldwm F`'4($2, $3), ret1 149 zdep t2, 28, 29, t1 150 mtsar t1 151 hppa_blcopy($1, $2, $3, $4, $5, $6, `u') 152 153dnl STWL($1, $2, $3, $4, $5, $6, `u') 154 addib,<,n 12, $6, L($1, cleanup_un) 155L($1, word_un) 156 ldws,M F`'4($2, $3), t1 157 vshd ret1, t1, t2 158 addib,< -4, $6, L($1, cleanup1_un) 159 stws,M t2, F`'4($4, $5) 160 ldws,M F`'4($2, $3), ret1 161 vshd t1, ret1, t2 162 addib,>= -4, $6, L($1, word_un) 163 stws,M t2, F`'4($4, $5) 164 165L($1, cleanup_un) 166 addib,<=,n 4, $6, L($1, done) 167 mfctl sar, t4 168 add $5, $6, $5 169 extru t4, 28, 2, t4 170 sub,<= $6, t4, r0 171 ldws,M F`'4($2, $3), t1 172 vshd ret1, t1, t2 173 b L($1, done) 174 stbys,E t2, 0($4, $5) 175 176L($1, cleanup1_un) 177 b L($1, cleanup_un) 178 copy t1, ret1 179')dnl ifelse 180 181L($1, byte) 182 comb,>=,n r0, $6, L($1, done) 183L($1, byte_loop) 184 ldbs,M F`'1($2, $3), t1 185 addib,<> -1, $6, L($1, byte_loop) 186 stbs,M t1, F`'1($4, $5) 187L($1, done) 188')dnl 189` 190#undef _LOCORE 191#define _LOCORE 192#include <machine/asm.h> 193#include <machine/frame.h> 194' 195ifelse(NAME, `bcopy', 196` 197LEAF_ENTRY(memcpy) 198ALTENTRY(memmove) 199 copy arg0, t1 200 copy arg1, arg0 201 copy t1, arg1 202 copy arg0, ret0 203ALTENTRY(ovbcopy) 204ALTENTRY(bcopy) 205 comb,>,n arg1, arg0, L(bcopy, reverse) 206 hppa_copy(bcopy_f, sr0, arg0, sr0, arg1, arg2, `+') 207 bv 0(rp) 208 nop 209L(bcopy, reverse) 210 hppa_copy(bcopy_r, sr0, arg0, sr0, arg1, arg2, `-') 211 bv 0(rp) 212 nop 213EXIT(memcpy) 214')dnl 215dnl 216ifelse(NAME, `spcopy', 217` 218#ifdef _KERNEL 219#include <assym.h> 220 221/* 222 * int spcopy (pa_space_t ssp, const void *src, pa_space_t dsp, void *dst, 223 * size_t size) 224 * do a space to space bcopy. 225 * 226 * assumes that spaces do not clash, otherwise we lose 227 */ 228 .import curproc, data 229 .import cpu_info_primary, data 230 .import copy_on_fault, code 231 232#define curproc (cpu_info_primary + CI_CURPROC) 233 234LEAF_ENTRY(spcopy) 235 ldw HPPA_FRAME_ARG(4)(sp), ret0 236 sub,<> r0, ret0, r0 237 bv r0(rp) 238 nop 239` 240 ldo 64(sp), sp 241 stw rp, HPPA_FRAME_CRP(sp) 242 /* setup fault handler */ 243 ldil L%curproc, t1 244 ldw R%curproc(t1), t3 245 ldil L%copy_on_fault, t2 246 ldw P_ADDR(t3), r2 247 ldo R%copy_on_fault(t2), t2 248 ldw PCB_ONFAULT+U_PCB(r2), r1 249 stw t2, PCB_ONFAULT+U_PCB(r2) 250' 251 mtsp arg0, sr1 252 mtsp arg2, sr2 253 254 hppa_copy(spcopy, sr1, arg1, sr2, arg3, ret0, `+') 255 256 mtsp r0, sr1 257 mtsp r0, sr2 258 /* reset fault handler */ 259 stw r1, PCB_ONFAULT+U_PCB(r2) 260 ldw HPPA_FRAME_CRP(sp), rp 261 ldo -64(sp), sp 262 bv 0(rp) 263 copy r0, ret0 264EXIT(spcopy) 265#endif 266')dnl 267 268 .end 269