Deleted Added
full compact
locore64.S (209975) locore64.S (218824)
1/* $FreeBSD: head/sys/powerpc/aim/locore64.S 209975 2010-07-13 05:32:19Z nwhitehorn $ */
1/* $FreeBSD: head/sys/powerpc/aim/locore64.S 218824 2011-02-18 21:44:53Z nwhitehorn $ */
2/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */
3
4/*-
5 * Copyright (C) 2001 Benno Rice
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28/*-
29 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
30 * Copyright (C) 1995, 1996 TooLs GmbH.
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 * 3. All advertising materials mentioning features or use of this software
42 * must display the following acknowledgement:
43 * This product includes software developed by TooLs GmbH.
44 * 4. The name of TooLs GmbH may not be used to endorse or promote products
45 * derived from this software without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
52 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
53 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
54 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
55 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
56 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 */
58
59#include "assym.s"
60
61#include <sys/syscall.h>
62
63#include <machine/trap.h>
64#include <machine/param.h>
65#include <machine/spr.h>
66#include <machine/asm.h>
67
68/* Locate the per-CPU data structure */
69#define GET_CPUINFO(r) \
70 mfsprg0 r
71
72/*
73 * Compiled KERNBASE location and the kernel load address
74 */
75 .globl kernbase
76 .set kernbase, KERNBASE
77
78#define TMPSTKSZ 8192 /* 8K temporary stack */
79#define OFWSTKSZ 4096 /* 4K Open Firmware stack */
80
81/*
82 * Globals
83 */
84 .data
85 .align 4
86GLOBAL(tmpstk)
87 .space TMPSTKSZ
88GLOBAL(ofwstk)
89 .space OFWSTKSZ
90GLOBAL(esym)
91 .llong 0 /* end of symbol table */
92
93GLOBAL(ofmsr)
94 .llong 0, 0, 0, 0, 0 /* msr/sprg0-3 used in Open Firmware */
95
96#define INTRCNT_COUNT 256 /* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */
97GLOBAL(intrnames)
98 .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
99GLOBAL(eintrnames)
100 .align 4
101GLOBAL(intrcnt)
102 .space INTRCNT_COUNT * 4 * 2
103GLOBAL(eintrcnt)
104
105/*
106 * File-scope for locore.S
107 */
108idle_u:
109 .llong 0 /* fake uarea during idle after exit */
110openfirmware_entry:
111 .llong 0 /* Open Firmware entry point */
112srsave:
113 .llong 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
114
115 .text
116 .globl btext
117btext:
118
119/*
120 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
121 * mark the start of kernel text.
122 */
123 .globl kernel_text
124kernel_text:
125
126/*
127 * Startup entry. Note, this must be the first thing in the text
128 * segment!
129 */
130 .text
131ASENTRY(__start)
132 li 8,0
133 li 9,0x100
134 mtctr 9
1351:
136 dcbf 0,8
137 icbi 0,8
138 addi 8,8,0x20
139 bdnz 1b
140 sync
141 isync
142
143 /* Save the argument pointer and length */
144 mr 20,6
145 mr 21,7
146
147 lis 8,openfirmware_entry@ha
148 std 5,openfirmware_entry@l(8) /* save client interface handler */
149
150 /* Set up the stack pointer */
151 lis 1,(tmpstk+TMPSTKSZ-48)@ha
152 addi 1,1,(tmpstk+TMPSTKSZ-48)@l
153
154 /* Set up the TOC pointer */
155 lis 2,tocbase@ha
156 ld 2,tocbase@l(2)
157
158 mfmsr 0
159 lis 9,ofmsr@ha
160 stdu 0,ofmsr@l(9)
161
162 mfsprg0 0 /* save SPRG0-3 */
163 std 0,8(9) /* ofmsr[1] = sprg0 */
164 mfsprg1 0
165 std 0,16(9) /* ofmsr[2] = sprg1 */
166 mfsprg2 0
167 std 0,24(9) /* ofmsr[3] = sprg2 */
168 mfsprg3 0
169 std 0,32(9) /* ofmsr[4] = sprg3 */
170
171 /* Switch to 64-bit mode */
172 mfmsr 9
173 li 8,1
174 insrdi 9,8,1,0
175 mtmsrd 9
176
2/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */
3
4/*-
5 * Copyright (C) 2001 Benno Rice
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28/*-
29 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
30 * Copyright (C) 1995, 1996 TooLs GmbH.
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 * 3. All advertising materials mentioning features or use of this software
42 * must display the following acknowledgement:
43 * This product includes software developed by TooLs GmbH.
44 * 4. The name of TooLs GmbH may not be used to endorse or promote products
45 * derived from this software without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
52 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
53 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
54 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
55 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
56 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 */
58
59#include "assym.s"
60
61#include <sys/syscall.h>
62
63#include <machine/trap.h>
64#include <machine/param.h>
65#include <machine/spr.h>
66#include <machine/asm.h>
67
68/* Locate the per-CPU data structure */
69#define GET_CPUINFO(r) \
70 mfsprg0 r
71
72/*
73 * Compiled KERNBASE location and the kernel load address
74 */
75 .globl kernbase
76 .set kernbase, KERNBASE
77
78#define TMPSTKSZ 8192 /* 8K temporary stack */
79#define OFWSTKSZ 4096 /* 4K Open Firmware stack */
80
81/*
82 * Globals
83 */
84 .data
85 .align 4
86GLOBAL(tmpstk)
87 .space TMPSTKSZ
88GLOBAL(ofwstk)
89 .space OFWSTKSZ
90GLOBAL(esym)
91 .llong 0 /* end of symbol table */
92
93GLOBAL(ofmsr)
94 .llong 0, 0, 0, 0, 0 /* msr/sprg0-3 used in Open Firmware */
95
96#define INTRCNT_COUNT 256 /* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */
97GLOBAL(intrnames)
98 .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
99GLOBAL(eintrnames)
100 .align 4
101GLOBAL(intrcnt)
102 .space INTRCNT_COUNT * 4 * 2
103GLOBAL(eintrcnt)
104
105/*
106 * File-scope for locore.S
107 */
108idle_u:
109 .llong 0 /* fake uarea during idle after exit */
110openfirmware_entry:
111 .llong 0 /* Open Firmware entry point */
112srsave:
113 .llong 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
114
115 .text
116 .globl btext
117btext:
118
119/*
120 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
121 * mark the start of kernel text.
122 */
123 .globl kernel_text
124kernel_text:
125
126/*
127 * Startup entry. Note, this must be the first thing in the text
128 * segment!
129 */
130 .text
131ASENTRY(__start)
132 li 8,0
133 li 9,0x100
134 mtctr 9
1351:
136 dcbf 0,8
137 icbi 0,8
138 addi 8,8,0x20
139 bdnz 1b
140 sync
141 isync
142
143 /* Save the argument pointer and length */
144 mr 20,6
145 mr 21,7
146
147 lis 8,openfirmware_entry@ha
148 std 5,openfirmware_entry@l(8) /* save client interface handler */
149
150 /* Set up the stack pointer */
151 lis 1,(tmpstk+TMPSTKSZ-48)@ha
152 addi 1,1,(tmpstk+TMPSTKSZ-48)@l
153
154 /* Set up the TOC pointer */
155 lis 2,tocbase@ha
156 ld 2,tocbase@l(2)
157
158 mfmsr 0
159 lis 9,ofmsr@ha
160 stdu 0,ofmsr@l(9)
161
162 mfsprg0 0 /* save SPRG0-3 */
163 std 0,8(9) /* ofmsr[1] = sprg0 */
164 mfsprg1 0
165 std 0,16(9) /* ofmsr[2] = sprg1 */
166 mfsprg2 0
167 std 0,24(9) /* ofmsr[3] = sprg2 */
168 mfsprg3 0
169 std 0,32(9) /* ofmsr[4] = sprg3 */
170
171 /* Switch to 64-bit mode */
172 mfmsr 9
173 li 8,1
174 insrdi 9,8,1,0
175 mtmsrd 9
176
177 bl .OF_initial_setup
177 bl OF_initial_setup
178 nop
179
180 lis 4,end@ha
181 addi 4,4,end@l
182 mr 5,4
183
184 lis 3,kernbase@ha
185 addi 3,3,kernbase@l
186
187 /* Restore the argument pointer and length */
188 mr 6,20
189 mr 7,21
190
178 nop
179
180 lis 4,end@ha
181 addi 4,4,end@l
182 mr 5,4
183
184 lis 3,kernbase@ha
185 addi 3,3,kernbase@l
186
187 /* Restore the argument pointer and length */
188 mr 6,20
189 mr 7,21
190
191 bl .powerpc_init
191 bl powerpc_init
192 nop
193 mr %r1, %r3
194 li %r3, 0
195 std %r3, 0(%r1)
192 nop
193 mr %r1, %r3
194 li %r3, 0
195 std %r3, 0(%r1)
196 bl .mi_startup
196 bl mi_startup
197 nop
197 nop
198 b .OF_exit
198 b OF_exit
199 nop
200
201/*
202 * PPC64 ABI TOC base
203 */
204
205 .align 3
206 .globl tocbase
207tocbase:
208 .llong .TOC.@tocbase
209
210/*
211 * Open Firmware Real-mode Entry Point. This is a huge pain.
212 */
213
214ASENTRY(ofw_32bit_mode_entry)
215 mflr %r0
216 std %r0,16(%r1)
217 stdu %r1,-208(%r1)
218
219 /*
220 * We need to save the following, because OF's register save/
221 * restore code assumes that the contents of registers are
222 * at most 32 bits wide: lr, cr, r2, r13-r31, the old MSR. These
223 * get placed in that order in the stack.
224 */
225
226 mfcr %r4
227 std %r4,48(%r1)
228 std %r13,56(%r1)
229 std %r14,64(%r1)
230 std %r15,72(%r1)
231 std %r16,80(%r1)
232 std %r17,88(%r1)
233 std %r18,96(%r1)
234 std %r19,104(%r1)
235 std %r20,112(%r1)
236 std %r21,120(%r1)
237 std %r22,128(%r1)
238 std %r23,136(%r1)
239 std %r24,144(%r1)
240 std %r25,152(%r1)
241 std %r26,160(%r1)
242 std %r27,168(%r1)
243 std %r28,176(%r1)
244 std %r29,184(%r1)
245 std %r30,192(%r1)
246 std %r31,200(%r1)
247
248 /* Record the old MSR */
249 mfmsr %r6
250
251 /* read client interface handler */
252 lis %r4,openfirmware_entry@ha
253 ld %r4,openfirmware_entry@l(%r4)
254
255 /*
256 * Set the MSR to the OF value. This has the side effect of disabling
257 * exceptions, which is important for the next few steps.
258 */
259
260 lis %r5,ofmsr@ha
261 ld %r5,ofmsr@l(%r5)
262 mtmsrd %r5
263 isync
264
265 /*
266 * Set up OF stack. This needs to be accessible in real mode and
267 * use the 32-bit ABI stack frame format. The pointer to the current
268 * kernel stack is placed at the very top of the stack along with
269 * the old MSR so we can get them back later.
270 */
271 mr %r5,%r1
272 lis %r1,(ofwstk+OFWSTKSZ-32)@ha
273 addi %r1,%r1,(ofwstk+OFWSTKSZ-32)@l
274 std %r5,8(%r1) /* Save real stack pointer */
275 std %r2,16(%r1) /* Save old TOC */
276 std %r6,24(%r1) /* Save old MSR */
277 li %r5,0
278 stw %r5,4(%r1)
279 stw %r5,0(%r1)
280
281 /* Finally, branch to OF */
282 mtctr %r4
283 bctrl
284
285 /* Reload stack pointer and MSR from the OFW stack */
286 ld %r6,24(%r1)
287 ld %r2,16(%r1)
288 ld %r1,8(%r1)
289
290 /* Now set the real MSR */
291 mtmsrd %r6
292 isync
293
294 /* Sign-extend the return value from OF */
295 extsw %r3,%r3
296
297 /* Restore all the non-volatile registers */
298 ld %r5,48(%r1)
299 mtcr %r5
300 ld %r13,56(%r1)
301 ld %r14,64(%r1)
302 ld %r15,72(%r1)
303 ld %r16,80(%r1)
304 ld %r17,88(%r1)
305 ld %r18,96(%r1)
306 ld %r19,104(%r1)
307 ld %r20,112(%r1)
308 ld %r21,120(%r1)
309 ld %r22,128(%r1)
310 ld %r23,136(%r1)
311 ld %r24,144(%r1)
312 ld %r25,152(%r1)
313 ld %r26,160(%r1)
314 ld %r27,168(%r1)
315 ld %r28,176(%r1)
316 ld %r29,184(%r1)
317 ld %r30,192(%r1)
318 ld %r31,200(%r1)
319
320 /* Restore the stack and link register */
321 ld %r1,0(%r1)
322 ld %r0,16(%r1)
323 mtlr %r0
324 blr
325
326/*
327 * int setfault()
328 *
329 * Similar to setjmp to setup for handling faults on accesses to user memory.
330 * Any routine using this may only call bcopy, either the form below,
331 * or the (currently used) C code optimized, so it doesn't use any non-volatile
332 * registers.
333 */
334ASENTRY(setfault)
335 mflr 0
336 mfcr 12
337 mfsprg 4,0
338 ld 4,PC_CURTHREAD(4)
339 ld 4,TD_PCB(4)
340 std 3,PCB_ONFAULT(4)
341 std 0,0(3)
342 std 1,8(3)
343 std 2,16(3)
344
345 std %r12,24(%r3) /* Save the non-volatile GP regs. */
346 std %r13,24+1*8(%r3)
347 std %r14,24+2*8(%r3)
348 std %r15,24+3*8(%r3)
349 std %r16,24+4*8(%r3)
350 std %r17,24+5*8(%r3)
351 std %r18,24+6*8(%r3)
352 std %r19,24+7*8(%r3)
353 std %r20,24+8*8(%r3)
354 std %r21,24+9*8(%r3)
355 std %r22,24+10*8(%r3)
356 std %r23,24+11*8(%r3)
357 std %r24,24+12*8(%r3)
358 std %r25,24+13*8(%r3)
359 std %r26,24+14*8(%r3)
360 std %r27,24+15*8(%r3)
361 std %r28,24+16*8(%r3)
362 std %r29,24+17*8(%r3)
363 std %r30,24+18*8(%r3)
364 std %r31,24+19*8(%r3)
365
366 xor 3,3,3
367 blr
368
369#include <powerpc/aim/trap_subr64.S>
199 nop
200
201/*
202 * PPC64 ABI TOC base
203 */
204
205 .align 3
206 .globl tocbase
207tocbase:
208 .llong .TOC.@tocbase
209
210/*
211 * Open Firmware Real-mode Entry Point. This is a huge pain.
212 */
213
214ASENTRY(ofw_32bit_mode_entry)
215 mflr %r0
216 std %r0,16(%r1)
217 stdu %r1,-208(%r1)
218
219 /*
220 * We need to save the following, because OF's register save/
221 * restore code assumes that the contents of registers are
222 * at most 32 bits wide: lr, cr, r2, r13-r31, the old MSR. These
223 * get placed in that order in the stack.
224 */
225
226 mfcr %r4
227 std %r4,48(%r1)
228 std %r13,56(%r1)
229 std %r14,64(%r1)
230 std %r15,72(%r1)
231 std %r16,80(%r1)
232 std %r17,88(%r1)
233 std %r18,96(%r1)
234 std %r19,104(%r1)
235 std %r20,112(%r1)
236 std %r21,120(%r1)
237 std %r22,128(%r1)
238 std %r23,136(%r1)
239 std %r24,144(%r1)
240 std %r25,152(%r1)
241 std %r26,160(%r1)
242 std %r27,168(%r1)
243 std %r28,176(%r1)
244 std %r29,184(%r1)
245 std %r30,192(%r1)
246 std %r31,200(%r1)
247
248 /* Record the old MSR */
249 mfmsr %r6
250
251 /* read client interface handler */
252 lis %r4,openfirmware_entry@ha
253 ld %r4,openfirmware_entry@l(%r4)
254
255 /*
256 * Set the MSR to the OF value. This has the side effect of disabling
257 * exceptions, which is important for the next few steps.
258 */
259
260 lis %r5,ofmsr@ha
261 ld %r5,ofmsr@l(%r5)
262 mtmsrd %r5
263 isync
264
265 /*
266 * Set up OF stack. This needs to be accessible in real mode and
267 * use the 32-bit ABI stack frame format. The pointer to the current
268 * kernel stack is placed at the very top of the stack along with
269 * the old MSR so we can get them back later.
270 */
271 mr %r5,%r1
272 lis %r1,(ofwstk+OFWSTKSZ-32)@ha
273 addi %r1,%r1,(ofwstk+OFWSTKSZ-32)@l
274 std %r5,8(%r1) /* Save real stack pointer */
275 std %r2,16(%r1) /* Save old TOC */
276 std %r6,24(%r1) /* Save old MSR */
277 li %r5,0
278 stw %r5,4(%r1)
279 stw %r5,0(%r1)
280
281 /* Finally, branch to OF */
282 mtctr %r4
283 bctrl
284
285 /* Reload stack pointer and MSR from the OFW stack */
286 ld %r6,24(%r1)
287 ld %r2,16(%r1)
288 ld %r1,8(%r1)
289
290 /* Now set the real MSR */
291 mtmsrd %r6
292 isync
293
294 /* Sign-extend the return value from OF */
295 extsw %r3,%r3
296
297 /* Restore all the non-volatile registers */
298 ld %r5,48(%r1)
299 mtcr %r5
300 ld %r13,56(%r1)
301 ld %r14,64(%r1)
302 ld %r15,72(%r1)
303 ld %r16,80(%r1)
304 ld %r17,88(%r1)
305 ld %r18,96(%r1)
306 ld %r19,104(%r1)
307 ld %r20,112(%r1)
308 ld %r21,120(%r1)
309 ld %r22,128(%r1)
310 ld %r23,136(%r1)
311 ld %r24,144(%r1)
312 ld %r25,152(%r1)
313 ld %r26,160(%r1)
314 ld %r27,168(%r1)
315 ld %r28,176(%r1)
316 ld %r29,184(%r1)
317 ld %r30,192(%r1)
318 ld %r31,200(%r1)
319
320 /* Restore the stack and link register */
321 ld %r1,0(%r1)
322 ld %r0,16(%r1)
323 mtlr %r0
324 blr
325
326/*
327 * int setfault()
328 *
329 * Similar to setjmp to setup for handling faults on accesses to user memory.
330 * Any routine using this may only call bcopy, either the form below,
331 * or the (currently used) C code optimized, so it doesn't use any non-volatile
332 * registers.
333 */
334ASENTRY(setfault)
335 mflr 0
336 mfcr 12
337 mfsprg 4,0
338 ld 4,PC_CURTHREAD(4)
339 ld 4,TD_PCB(4)
340 std 3,PCB_ONFAULT(4)
341 std 0,0(3)
342 std 1,8(3)
343 std 2,16(3)
344
345 std %r12,24(%r3) /* Save the non-volatile GP regs. */
346 std %r13,24+1*8(%r3)
347 std %r14,24+2*8(%r3)
348 std %r15,24+3*8(%r3)
349 std %r16,24+4*8(%r3)
350 std %r17,24+5*8(%r3)
351 std %r18,24+6*8(%r3)
352 std %r19,24+7*8(%r3)
353 std %r20,24+8*8(%r3)
354 std %r21,24+9*8(%r3)
355 std %r22,24+10*8(%r3)
356 std %r23,24+11*8(%r3)
357 std %r24,24+12*8(%r3)
358 std %r25,24+13*8(%r3)
359 std %r26,24+14*8(%r3)
360 std %r27,24+15*8(%r3)
361 std %r28,24+16*8(%r3)
362 std %r29,24+17*8(%r3)
363 std %r30,24+18*8(%r3)
364 std %r31,24+19*8(%r3)
365
366 xor 3,3,3
367 blr
368
369#include <powerpc/aim/trap_subr64.S>