4xx_locore.S revision 1.1.2.4 1 /* $NetBSD: 4xx_locore.S,v 1.1.2.4 2002/12/19 20:00:20 thorpej Exp $ */
2
3 /*
4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved.
6 *
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
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
23 * written permission.
24 *
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.
36 */
37
38 /*
39 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
40 * Copyright (C) 1995, 1996 TooLs GmbH.
41 * All rights reserved.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
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.
56 *
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.
67 */
68
69 /*
70 * This is not a standalone file. To use it, #inlcude it at
71 * the end of your port's locore.S
72 */
73
74 /*
75 * Pull in common PowerPC locore subroutines.
76 */
77 #include <powerpc/powerpc/locore_subr.S>
78
79 /*
80 * Pull in common trap vector code.
81 */
82 #include <powerpc/ibm4xx/trap_subr.S>
83 #include <powerpc/ibm4xx/4xx_trap_subr.S>
84
85 .globl _C_LABEL(ppc4xx_reset)
86 _C_LABEL(ppc4xx_reset):
87 mfspr 3,SPR_DBCR0
88 oris 3,r13,DBCR0_RST_SYSTEM@h
89 mtspr SPR_DBCR0,3
90 ba 0
91
92 #if 0
93 /*
94 * XXXX the following doesn't quite work right yet.
95 */
96 /*
97 * void bcopy(const void *src, void *dst, size_t len);
98 *
99 * swap r3 and r4 and fall through to memcopy.
100 */
101 .globl _C_LABEL(bcopy)
102 _C_LABEL(bcopy):
103 mr r0,r3
104 mr r3,r4
105 mr r4,r0
106 /* FALLTHROUGH */
107
108 /*
109 * void * memcpy(void *dst (r3), const void *src (r4), size_t len (r5));
110 *
111 * Copy memory (obviously)
112 *
113 * We will try to do data cache block aligned stores so we
114 * can use block allocate and not have to read from the
115 * destination.
116 *
117 * Register use:
118 *
119 * r1 stack (of course)
120 * r3 dst
121 * r4 src
122 * r5 len
123 * r6 tmp
124 * r7 holds 32
125 * r8 holds dst
126 * r24-r31 block move regs
127 *
128 */
129
130 ENTRY(memcpy)
131 stwu r1,-(10*4)(r1) /* Allocate some RAM to save 8 regs to. */
132 cmpwi r5, 32 /* Less than 32 bytes ? */
133 stmw r24,8(r1) /* Save ALL regs (could be optimized) */
134
135 mr r8,r3 /* save dst */
136 li r7,32
137
138 dcbt 0,r4 /* Start bringing in cache line. */
139 blt 1f /* Finish up */
140
141 neg r6,r3 /* Find how far unaligned we are... */
142 andi. r6,r6,31 /* Cache-align dest. */
143 mtxer r6
144 sub r5,r5,r6 /* subtract count */
145 lswx r24,0,r4 /* Load some. */
146 add r4,r4,r6
147 dcbt 0,r4 /* Fetch next line */
148 stswx r24,0,r3 /* Store some */
149 add r3,r3,r6
150 addic. r6,r5,-32 /* Pre-decrement next line */
151 ble 1f /* Less than 32-bytes? finishup */
152
153 /* Dest should not be cache line aligned. */
154 /* XXX need gas 2.11 to grok dcba insn */
155 #ifdef GAS_2_11
156 dcba 0,r3 /* Allocate a line */
157 #else
158 .long 0x7c001dec /* dcba 0,r3 */
159 #endif
160 0:
161 dcbt r7,r4 /* Bring in the next line, too */
162
163 lswi r24,r4,32
164 addi r4,r4,32 /* Inc src */
165 mr r5,r6
166
167 addic. r6,r5,-32
168 stswi r24,r3,32
169 addi r3,r3,32 /* Inc dst */
170 #ifdef GAS_2_11
171 dcba 0,r3 /* Allocate another line */
172 #else
173 .long 0x7c071dec /* dcba r7,r3 */
174 #endif
175 bgt 0b
176 1:
177 mtxer r5 /* Store byte count */
178 lswx r24,0,r4 /* Load up to 32 bytes */
179 stswx r24,0,r3 /* Store up to 32 bytes */
180
181 mr r3,r8 /* Return dst */
182
183 lmw r24,8(r1)
184 addi r1,r1,(10*4)
185 blr
186 #endif
187