4xx_locore.S revision 1.3 1 /* $NetBSD: 4xx_locore.S,v 1.3 2003/07/25 10:12:42 scw 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 /*
86 * Include PIO routines
87 */
88 #include <powerpc/powerpc/pio_subr.S>
89
90 .globl _C_LABEL(ppc4xx_reset)
91 _C_LABEL(ppc4xx_reset):
92 mfspr 3,SPR_DBCR0
93 oris 3,r13,DBCR0_RST_SYSTEM@h
94 mtspr SPR_DBCR0,3
95 ba 0
96
97 #if 0
98 /*
99 * XXXX the following doesn't quite work right yet.
100 */
101 /*
102 * void bcopy(const void *src, void *dst, size_t len);
103 *
104 * swap r3 and r4 and fall through to memcopy.
105 */
106 .globl _C_LABEL(bcopy)
107 _C_LABEL(bcopy):
108 mr r0,r3
109 mr r3,r4
110 mr r4,r0
111 /* FALLTHROUGH */
112
113 /*
114 * void * memcpy(void *dst (r3), const void *src (r4), size_t len (r5));
115 *
116 * Copy memory (obviously)
117 *
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
120 * destination.
121 *
122 * Register use:
123 *
124 * r1 stack (of course)
125 * r3 dst
126 * r4 src
127 * r5 len
128 * r6 tmp
129 * r7 holds 32
130 * r8 holds dst
131 * r24-r31 block move regs
132 *
133 */
134
135 ENTRY(memcpy)
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) */
139
140 mr r8,r3 /* save dst */
141 li r7,32
142
143 dcbt 0,r4 /* Start bringing in cache line. */
144 blt 1f /* Finish up */
145
146 neg r6,r3 /* Find how far unaligned we are... */
147 andi. r6,r6,31 /* Cache-align dest. */
148 mtxer r6
149 sub r5,r5,r6 /* subtract count */
150 lswx r24,0,r4 /* Load some. */
151 add r4,r4,r6
152 dcbt 0,r4 /* Fetch next line */
153 stswx r24,0,r3 /* Store some */
154 add r3,r3,r6
155 addic. r6,r5,-32 /* Pre-decrement next line */
156 ble 1f /* Less than 32-bytes? finishup */
157
158 /* Dest should not be cache line aligned. */
159 /* XXX need gas 2.11 to grok dcba insn */
160 #ifdef GAS_2_11
161 dcba 0,r3 /* Allocate a line */
162 #else
163 .long 0x7c001dec /* dcba 0,r3 */
164 #endif
165 0:
166 dcbt r7,r4 /* Bring in the next line, too */
167
168 lswi r24,r4,32
169 addi r4,r4,32 /* Inc src */
170 mr r5,r6
171
172 addic. r6,r5,-32
173 stswi r24,r3,32
174 addi r3,r3,32 /* Inc dst */
175 #ifdef GAS_2_11
176 dcba 0,r3 /* Allocate another line */
177 #else
178 .long 0x7c071dec /* dcba r7,r3 */
179 #endif
180 bgt 0b
181 1:
182 mtxer r5 /* Store byte count */
183 lswx r24,0,r4 /* Load up to 32 bytes */
184 stswx r24,0,r3 /* Store up to 32 bytes */
185
186 mr r3,r8 /* Return dst */
187
188 lmw r24,8(r1)
189 addi r1,r1,(10*4)
190 blr
191 #endif
192