1 /* $NetBSD: 4xx_locore.S,v 1.6 2006/10/07 14:44:22 tsutsui Exp $ */
4 * Copyright 2001 Wasabi Systems, Inc.
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
39 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
40 * Copyright (C) 1995, 1996 TooLs GmbH.
41 * All rights reserved.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by TooLs GmbH.
54 * 4. The name of TooLs GmbH may not be used to endorse or promote products
55 * derived from this software without specific prior written permission.
57 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
62 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
63 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
64 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
65 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
66 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70 * This is not a standalone file. To use it, #inlcude it at
71 * the end of your port's locore.S
75 * Pull in common PowerPC locore subroutines.
77 #include <powerpc/powerpc/locore_subr.S>
80 * Pull in common trap vector code.
82 #include <powerpc/ibm4xx/trap_subr.S>
83 #include <powerpc/ibm4xx/4xx_trap_subr.S>
86 * Include PIO routines
88 #include <powerpc/powerpc/pio_subr.S>
90 .globl _C_LABEL(ppc4xx_reset)
91 _C_LABEL(ppc4xx_reset):
93 oris %r3,%r3,DBCR0_RST_SYSTEM@h
99 * XXXX the following doesn't quite work right yet.
102 * void bcopy(const void *src, void *dst, size_t len);
104 * swap %r3 and %r4 and fall through to memcopy.
106 .globl _C_LABEL(bcopy)
114 * void *memcpy(void *dst (%r3), const void *src (%r4), size_t len (%r5));
116 * Copy memory (obviously)
118 * We will try to do data cache block aligned stores so we
119 * can use block allocate and not have to read from the
124 * %r1 stack (of course)
131 * %r24-%r31 block move regs
136 stwu %r1,-(10*4)(%r1) /* Allocate some RAM to save 8 regs to. */
137 cmpwi %r5, 32 /* Less than 32 bytes ? */
138 stmw %r24,8(%r1) /* Save ALL regs (could be optimized) */
140 mr %r8,%r3 /* save dst */
143 dcbt %r0,%r4 /* Start bringing in cache line. */
144 blt 1f /* Finish up */
146 neg %r6,%r3 /* Find how far unaligned we are... */
147 andi. %r6,%r6,31 /* Cache-align dest. */
149 sub %r5,%r5,%r6 /* subtract count */
150 lswx %r24,%r0,%r4 /* Load some. */
152 dcbt %r0,%r4 /* Fetch next line */
153 stswx %r24,%r0,%r3 /* Store some */
155 addic. %r6,%r5,-32 /* Pre-decrement next line */
156 ble 1f /* Less than 32-bytes? finishup */
158 /* Dest should not be cache line aligned. */
159 /* XXX need gas 2.11 to grok dcba insn */
161 dcba %r0,%r3 /* Allocate a line */
163 .long 0x7c001dec /* dcba 0,r3 */
166 dcbt %r7,%r4 /* Bring in the next line, too */
169 addi %r4,%r4,32 /* Inc src */
174 addi %r3,%r3,32 /* Inc dst */
176 dcba 0,%r3 /* Allocate another line */
178 .long 0x7c071dec /* dcba %r7,%r3 */
182 mtxer %r5 /* Store byte count */
183 lswx %r24,%r0,%r4 /* Load up to 32 bytes */
184 stswx %r24,%r0,%r3 /* Store up to 32 bytes */
186 mr %r3,%r8 /* Return dst */