1 /* $OpenBSD: locore.S,v 1.18 1998/09/15 10:58:53 pefo Exp $ */
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
6 * This code is derived from software contributed to Berkeley by
7 * Digital Equipment Corporation and Ralph Campbell.
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 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * Copyright (C) 1989 Digital Equipment Corporation.
34 * Permission to use, copy, modify, and distribute this software and
35 * its documentation for any purpose and without fee is hereby granted,
36 * provided that the above copyright notice appears in all copies.
37 * Digital Equipment Corporation makes no representations about the
38 * suitability of this software for any purpose. It is provided "as is"
39 * without express or implied warranty.
41 * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/loMem.s,
42 * v 1.1 89/07/11 17:55:04 nelson Exp SPRITE (DECWRL)
43 * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsm.s,
44 * v 9.2 90/01/29 18:00:39 shirriff Exp SPRITE (DECWRL)
45 * from: Header: /sprite/src/kernel/vm/ds3100.md/vmPmaxAsm.s,
46 * v 1.1 89/07/10 14:27:41 nelson Exp SPRITE (DECWRL)
48 * from: @(#)locore.s 8.5 (Berkeley) 1/4/94
49 * JNPR: swtch.S,v 1.6.2.1 2007/09/10 10:36:50 girish
54 * Contains code that is the first executed at boot time plus
55 * assembly language support routines.
58 #include "opt_compat.h"
59 #include <sys/syscall.h>
60 #include <machine/asm.h>
61 #include <machine/cpu.h>
62 #include <machine/cpuregs.h>
63 #include <machine/regnum.h>
64 #include <machine/pte.h>
68 .set noreorder # Noreorder is default style!
70 #define SAVE_U_PCB_REG(reg, offs, base) \
71 REG_S reg, U_PCB_REGS + (SZREG * offs) (base)
73 #define RESTORE_U_PCB_REG(reg, offs, base) \
74 REG_L reg, U_PCB_REGS + (SZREG * offs) (base)
76 #define SAVE_U_PCB_FPREG(reg, offs, base) \
77 FP_S reg, U_PCB_FPREGS + (SZFPREG * offs) (base)
79 #define RESTORE_U_PCB_FPREG(reg, offs, base) \
80 FP_L reg, U_PCB_FPREGS + (SZFPREG * offs) (base)
82 #define SAVE_U_PCB_FPSR(reg, offs, base) \
83 REG_S reg, U_PCB_FPREGS + (SZFPREG * offs) (base)
85 #define RESTORE_U_PCB_FPSR(reg, offs, base) \
86 REG_L reg, U_PCB_FPREGS + (SZFPREG * offs) (base)
88 #define SAVE_U_PCB_CONTEXT(reg, offs, base) \
89 REG_S reg, U_PCB_CONTEXT + (SZREG * offs) (base)
91 #define RESTORE_U_PCB_CONTEXT(reg, offs, base) \
92 REG_L reg, U_PCB_CONTEXT + (SZREG * offs) (base)
96 * Setup for and return to user.
101 jal _C_LABEL(fork_exit)
106 mfc0 v0, MIPS_COP_0_STATUS
107 and v0, ~(MIPS_SR_INT_IE)
108 mtc0 v0, MIPS_COP_0_STATUS # disable interrupts
111 * The use of k1 for storing the PCB pointer must be done only
112 * after interrupts are disabled. Otherwise it will get overwritten
113 * by the interrupt code.
117 PTR_L k1, PC_CURPCB(k1)
119 RESTORE_U_PCB_REG(t0, MULLO, k1)
120 RESTORE_U_PCB_REG(t1, MULHI, k1)
123 RESTORE_U_PCB_REG(a0, PC, k1)
124 RESTORE_U_PCB_REG(AT, AST, k1)
125 RESTORE_U_PCB_REG(v0, V0, k1)
126 MTC0 a0, MIPS_COP_0_EXC_PC # set return address
128 RESTORE_U_PCB_REG(v1, V1, k1)
129 RESTORE_U_PCB_REG(a0, A0, k1)
130 RESTORE_U_PCB_REG(a1, A1, k1)
131 RESTORE_U_PCB_REG(a2, A2, k1)
132 RESTORE_U_PCB_REG(a3, A3, k1)
133 RESTORE_U_PCB_REG(t0, T0, k1)
134 RESTORE_U_PCB_REG(t1, T1, k1)
135 RESTORE_U_PCB_REG(t2, T2, k1)
136 RESTORE_U_PCB_REG(t3, T3, k1)
137 RESTORE_U_PCB_REG(ta0, TA0, k1)
138 RESTORE_U_PCB_REG(ta1, TA1, k1)
139 RESTORE_U_PCB_REG(ta2, TA2, k1)
140 RESTORE_U_PCB_REG(ta3, TA3, k1)
141 RESTORE_U_PCB_REG(s0, S0, k1)
142 RESTORE_U_PCB_REG(s1, S1, k1)
143 RESTORE_U_PCB_REG(s2, S2, k1)
144 RESTORE_U_PCB_REG(s3, S3, k1)
145 RESTORE_U_PCB_REG(s4, S4, k1)
146 RESTORE_U_PCB_REG(s5, S5, k1)
147 RESTORE_U_PCB_REG(s6, S6, k1)
148 RESTORE_U_PCB_REG(s7, S7, k1)
149 RESTORE_U_PCB_REG(t8, T8, k1)
150 RESTORE_U_PCB_REG(t9, T9, k1)
151 RESTORE_U_PCB_REG(k0, SR, k1)
152 RESTORE_U_PCB_REG(gp, GP, k1)
153 RESTORE_U_PCB_REG(s8, S8, k1)
154 RESTORE_U_PCB_REG(ra, RA, k1)
155 RESTORE_U_PCB_REG(sp, SP, k1)
156 li k1, ~MIPS_SR_INT_MASK
158 mfc0 k1, MIPS_COP_0_STATUS
159 and k1, k1, MIPS_SR_INT_MASK
161 mtc0 k0, MIPS_COP_0_STATUS # switch to user mode (when eret...)
169 * Update pcb, saving current processor state.
170 * Note: this only works if pcbp != curproc's pcb since
171 * cpu_switch() will copy over pcb_context.
173 * savectx(struct pcb *pcbp);
176 SAVE_U_PCB_CONTEXT(s0, PREG_S0, a0)
177 SAVE_U_PCB_CONTEXT(s1, PREG_S1, a0)
178 SAVE_U_PCB_CONTEXT(s2, PREG_S2, a0)
179 SAVE_U_PCB_CONTEXT(s3, PREG_S3, a0)
180 mfc0 v0, MIPS_COP_0_STATUS
181 SAVE_U_PCB_CONTEXT(s4, PREG_S4, a0)
182 SAVE_U_PCB_CONTEXT(s5, PREG_S5, a0)
183 SAVE_U_PCB_CONTEXT(s6, PREG_S6, a0)
184 SAVE_U_PCB_CONTEXT(s7, PREG_S7, a0)
185 SAVE_U_PCB_CONTEXT(sp, PREG_SP, a0)
186 SAVE_U_PCB_CONTEXT(s8, PREG_S8, a0)
187 SAVE_U_PCB_CONTEXT(ra, PREG_RA, a0)
188 SAVE_U_PCB_CONTEXT(v0, PREG_SR, a0)
189 SAVE_U_PCB_CONTEXT(gp, PREG_GP, a0)
191 move v0, ra /* save 'ra' before we trash it */
195 SAVE_U_PCB_CONTEXT(ra, PREG_PC, a0)
196 move ra, v0 /* restore 'ra' before returning */
202 NON_LEAF(cpu_throw, CALLFRAME_SIZ, ra)
203 mfc0 t0, MIPS_COP_0_STATUS # t0 = saved status register
206 and a3, t0, ~(MIPS_SR_INT_IE)
207 mtc0 a3, MIPS_COP_0_STATUS # Disable all interrupts
209 j mips_sw1 # We're not interested in old
210 # thread's context, so jump
216 * cpu_switch(struct thread *old, struct thread *new, struct mutex *mtx);
220 * Find the highest priority process and resume it.
222 NON_LEAF(cpu_switch, CALLFRAME_SIZ, ra)
223 mfc0 t0, MIPS_COP_0_STATUS # t0 = saved status register
226 and a3, t0, ~(MIPS_SR_INT_IE)
227 mtc0 a3, MIPS_COP_0_STATUS # Disable all interrupts
231 PTR_L a0, TD_PCB(a0) # load PCB addr of curproc
232 SAVE_U_PCB_CONTEXT(sp, PREG_SP, a0) # save old sp
233 PTR_SUBU sp, sp, CALLFRAME_SIZ
234 REG_S ra, CALLFRAME_RA(sp)
235 .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
236 SAVE_U_PCB_CONTEXT(s0, PREG_S0, a0) # do a 'savectx()'
237 SAVE_U_PCB_CONTEXT(s1, PREG_S1, a0)
238 SAVE_U_PCB_CONTEXT(s2, PREG_S2, a0)
239 SAVE_U_PCB_CONTEXT(s3, PREG_S3, a0)
240 SAVE_U_PCB_CONTEXT(s4, PREG_S4, a0)
241 SAVE_U_PCB_CONTEXT(s5, PREG_S5, a0)
242 SAVE_U_PCB_CONTEXT(s6, PREG_S6, a0)
243 SAVE_U_PCB_CONTEXT(s7, PREG_S7, a0)
244 SAVE_U_PCB_CONTEXT(s8, PREG_S8, a0)
245 SAVE_U_PCB_CONTEXT(ra, PREG_RA, a0) # save return address
246 SAVE_U_PCB_CONTEXT(t0, PREG_SR, a0) # save status register
247 SAVE_U_PCB_CONTEXT(gp, PREG_GP, a0)
251 SAVE_U_PCB_CONTEXT(ra, PREG_PC, a0) # save return address
255 lw t2, TD_MDFLAGS(a3) # get md_flags
256 and t1, t2, MDTD_COP2USED
257 beqz t1, cop2_untouched
260 /* Clear cop2used flag */
261 and t2, t2, ~MDTD_COP2USED
262 sw t2, TD_MDFLAGS(a3)
264 and t2, t0, ~MIPS_SR_COP_2_BIT # clear COP_2 enable bit
265 SAVE_U_PCB_CONTEXT(t2, PREG_SR, a0) # save status register
267 RESTORE_U_PCB_REG(t0, PS, a0) # get CPU status register
268 and t2, t0, ~MIPS_SR_COP_2_BIT # clear COP_2 enable bit
269 SAVE_U_PCB_REG(t2, PS, a0) # save stratus register
271 /* preserve a0..a3 */
277 /* does kernel own COP2 context? */
278 lw t1, TD_COP2OWNER(a3) # get md_cop2owner
279 beqz t1, userland_cop2 # 0 - it's userland context
282 PTR_L a0, TD_COP2(a3)
283 beqz a0, no_cop2_context
291 PTR_L a0, TD_UCOP2(a3)
292 beqz a0, no_cop2_context
308 PTR_S a2, TD_LOCK(a3) # Switchout td_lock
311 #if defined(SMP) && defined(SCHED_ULE)
312 PTR_LA t0, _C_LABEL(blocked_lock)
314 PTR_L t1, TD_LOCK(a1)
315 beq t0, t1, blocked_loop
318 move s7, a1 # Store newthread
320 * Switch to new context.
323 PTR_S a1, PC_CURTHREAD(a3)
325 PTR_S a2, PC_CURPCB(a3)
326 PTR_L v0, TD_KSTACK(a1)
327 #if defined(__mips_n64)
328 PTR_LI s0, MIPS_XKSEG_START
330 PTR_LI s0, MIPS_KSEG2_START # If Uarea addr is below kseg2,
332 bltu v0, s0, sw2 # no need to insert in TLB.
333 PTE_L a1, TD_UPTE + 0(s7) # a1 = u. pte #0
334 PTE_L a2, TD_UPTE + PTESIZE(s7) # a2 = u. pte #1
336 * Wiredown the USPACE of newproc in TLB entry#0. Check whether target
337 * USPACE is already in another place of TLB before that, and if so
338 * invalidate that TLB entry.
339 * NOTE: This is hard coded to UPAGES == 2.
340 * Also, there should be no TLB faults at this point.
342 MTC0 v0, MIPS_COP_0_TLB_HI # VPN = va
346 mfc0 s0, MIPS_COP_0_TLB_INDEX
349 PTR_LI t1, MIPS_KSEG0_START # invalidate tlb entry
352 sll s0, PAGE_SHIFT + 1
354 MTC0 t1, MIPS_COP_0_TLB_HI
355 PTE_MTC0 zero, MIPS_COP_0_TLB_LO0
356 PTE_MTC0 zero, MIPS_COP_0_TLB_LO1
360 MTC0 v0, MIPS_COP_0_TLB_HI # set VPN again
363 /* SMP!! - Works only for unshared TLB case - i.e. no v-cpus */
364 mtc0 zero, MIPS_COP_0_TLB_INDEX # TLB entry #0
366 PTE_MTC0 a1, MIPS_COP_0_TLB_LO0 # upte[0]
368 PTE_MTC0 a2, MIPS_COP_0_TLB_LO1 # upte[1]
370 tlbwi # set TLB entry #0
373 * Now running on new u struct.
377 RESTORE_U_PCB_CONTEXT(sp, PREG_SP, s0)
378 PTR_LA t1, _C_LABEL(pmap_activate) # s7 = new proc pointer
379 jalr t1 # s7 = new proc pointer
382 * Restore registers and return.
385 RESTORE_U_PCB_CONTEXT(gp, PREG_GP, a0)
386 RESTORE_U_PCB_CONTEXT(v0, PREG_SR, a0) # restore kernel context
387 RESTORE_U_PCB_CONTEXT(ra, PREG_RA, a0)
388 RESTORE_U_PCB_CONTEXT(s0, PREG_S0, a0)
389 RESTORE_U_PCB_CONTEXT(s1, PREG_S1, a0)
390 RESTORE_U_PCB_CONTEXT(s2, PREG_S2, a0)
391 RESTORE_U_PCB_CONTEXT(s3, PREG_S3, a0)
392 RESTORE_U_PCB_CONTEXT(s4, PREG_S4, a0)
393 RESTORE_U_PCB_CONTEXT(s5, PREG_S5, a0)
394 RESTORE_U_PCB_CONTEXT(s6, PREG_S6, a0)
395 RESTORE_U_PCB_CONTEXT(s7, PREG_S7, a0)
396 RESTORE_U_PCB_CONTEXT(s8, PREG_S8, a0)
398 mfc0 t0, MIPS_COP_0_STATUS
399 and t0, t0, MIPS_SR_INT_MASK
400 and v0, v0, ~MIPS_SR_INT_MASK
402 mtc0 v0, MIPS_COP_0_STATUS
409 /*----------------------------------------------------------------------------
411 * MipsSwitchFPState --
413 * Save the current state into 'from' and restore it from 'to'.
415 * MipsSwitchFPState(from, to)
416 * struct thread *from;
417 * struct trapframe *to;
425 *----------------------------------------------------------------------------
427 LEAF(MipsSwitchFPState)
428 mfc0 t1, MIPS_COP_0_STATUS # Save old SR
429 li t0, MIPS_SR_COP_1_BIT # enable the coprocessor
430 mtc0 t0, MIPS_COP_0_STATUS
433 beq a0, zero, 1f # skip save if NULL pointer
436 * First read out the status register to make sure that all FP operations
439 PTR_L a0, TD_PCB(a0) # get pointer to pcb for proc
440 cfc1 t0, MIPS_FPU_CSR # stall til FP done
441 cfc1 t0, MIPS_FPU_CSR # now get status
442 li t3, ~MIPS_SR_COP_1_BIT
443 RESTORE_U_PCB_REG(t2, PS, a0) # get CPU status register
444 SAVE_U_PCB_FPSR(t0, FSR_NUM, a0) # save FP status
445 and t2, t2, t3 # clear COP_1 enable bit
446 SAVE_U_PCB_REG(t2, PS, a0) # save new status register
448 * Save the floating point registers.
450 SAVE_U_PCB_FPREG($f0, F0_NUM, a0)
451 SAVE_U_PCB_FPREG($f1, F1_NUM, a0)
452 SAVE_U_PCB_FPREG($f2, F2_NUM, a0)
453 SAVE_U_PCB_FPREG($f3, F3_NUM, a0)
454 SAVE_U_PCB_FPREG($f4, F4_NUM, a0)
455 SAVE_U_PCB_FPREG($f5, F5_NUM, a0)
456 SAVE_U_PCB_FPREG($f6, F6_NUM, a0)
457 SAVE_U_PCB_FPREG($f7, F7_NUM, a0)
458 SAVE_U_PCB_FPREG($f8, F8_NUM, a0)
459 SAVE_U_PCB_FPREG($f9, F9_NUM, a0)
460 SAVE_U_PCB_FPREG($f10, F10_NUM, a0)
461 SAVE_U_PCB_FPREG($f11, F11_NUM, a0)
462 SAVE_U_PCB_FPREG($f12, F12_NUM, a0)
463 SAVE_U_PCB_FPREG($f13, F13_NUM, a0)
464 SAVE_U_PCB_FPREG($f14, F14_NUM, a0)
465 SAVE_U_PCB_FPREG($f15, F15_NUM, a0)
466 SAVE_U_PCB_FPREG($f16, F16_NUM, a0)
467 SAVE_U_PCB_FPREG($f17, F17_NUM, a0)
468 SAVE_U_PCB_FPREG($f18, F18_NUM, a0)
469 SAVE_U_PCB_FPREG($f19, F19_NUM, a0)
470 SAVE_U_PCB_FPREG($f20, F20_NUM, a0)
471 SAVE_U_PCB_FPREG($f21, F21_NUM, a0)
472 SAVE_U_PCB_FPREG($f22, F22_NUM, a0)
473 SAVE_U_PCB_FPREG($f23, F23_NUM, a0)
474 SAVE_U_PCB_FPREG($f24, F24_NUM, a0)
475 SAVE_U_PCB_FPREG($f25, F25_NUM, a0)
476 SAVE_U_PCB_FPREG($f26, F26_NUM, a0)
477 SAVE_U_PCB_FPREG($f27, F27_NUM, a0)
478 SAVE_U_PCB_FPREG($f28, F28_NUM, a0)
479 SAVE_U_PCB_FPREG($f29, F29_NUM, a0)
480 SAVE_U_PCB_FPREG($f30, F30_NUM, a0)
481 SAVE_U_PCB_FPREG($f31, F31_NUM, a0)
485 * Restore the floating point registers.
487 RESTORE_U_PCB_FPSR(t0, FSR_NUM, a1) # get status register
488 RESTORE_U_PCB_FPREG($f0, F0_NUM, a1)
489 RESTORE_U_PCB_FPREG($f1, F1_NUM, a1)
490 RESTORE_U_PCB_FPREG($f2, F2_NUM, a1)
491 RESTORE_U_PCB_FPREG($f3, F3_NUM, a1)
492 RESTORE_U_PCB_FPREG($f4, F4_NUM, a1)
493 RESTORE_U_PCB_FPREG($f5, F5_NUM, a1)
494 RESTORE_U_PCB_FPREG($f6, F6_NUM, a1)
495 RESTORE_U_PCB_FPREG($f7, F7_NUM, a1)
496 RESTORE_U_PCB_FPREG($f8, F8_NUM, a1)
497 RESTORE_U_PCB_FPREG($f9, F9_NUM, a1)
498 RESTORE_U_PCB_FPREG($f10, F10_NUM, a1)
499 RESTORE_U_PCB_FPREG($f11, F11_NUM, a1)
500 RESTORE_U_PCB_FPREG($f12, F12_NUM, a1)
501 RESTORE_U_PCB_FPREG($f13, F13_NUM, a1)
502 RESTORE_U_PCB_FPREG($f14, F14_NUM, a1)
503 RESTORE_U_PCB_FPREG($f15, F15_NUM, a1)
504 RESTORE_U_PCB_FPREG($f16, F16_NUM, a1)
505 RESTORE_U_PCB_FPREG($f17, F17_NUM, a1)
506 RESTORE_U_PCB_FPREG($f18, F18_NUM, a1)
507 RESTORE_U_PCB_FPREG($f19, F19_NUM, a1)
508 RESTORE_U_PCB_FPREG($f20, F20_NUM, a1)
509 RESTORE_U_PCB_FPREG($f21, F21_NUM, a1)
510 RESTORE_U_PCB_FPREG($f22, F22_NUM, a1)
511 RESTORE_U_PCB_FPREG($f23, F23_NUM, a1)
512 RESTORE_U_PCB_FPREG($f24, F24_NUM, a1)
513 RESTORE_U_PCB_FPREG($f25, F25_NUM, a1)
514 RESTORE_U_PCB_FPREG($f26, F26_NUM, a1)
515 RESTORE_U_PCB_FPREG($f27, F27_NUM, a1)
516 RESTORE_U_PCB_FPREG($f28, F28_NUM, a1)
517 RESTORE_U_PCB_FPREG($f29, F29_NUM, a1)
518 RESTORE_U_PCB_FPREG($f30, F30_NUM, a1)
519 RESTORE_U_PCB_FPREG($f31, F31_NUM, a1)
521 and t0, t0, ~MIPS_FPU_EXCEPTION_BITS
522 ctc1 t0, MIPS_FPU_CSR
525 mtc0 t1, MIPS_COP_0_STATUS # Restore the status register.
529 END(MipsSwitchFPState)
531 /*----------------------------------------------------------------------------
533 * MipsSaveCurFPState --
535 * Save the current floating point coprocessor state.
537 * MipsSaveCurFPState(td)
544 * machFPCurProcPtr is cleared.
546 *----------------------------------------------------------------------------
548 LEAF(MipsSaveCurFPState)
549 PTR_L a0, TD_PCB(a0) # get pointer to pcb for thread
550 mfc0 t1, MIPS_COP_0_STATUS # Disable interrupts and
551 li t0, MIPS_SR_COP_1_BIT # enable the coprocessor
552 mtc0 t0, MIPS_COP_0_STATUS
555 PTR_S zero, PC_FPCURTHREAD(a1) # indicate state has been saved
557 * First read out the status register to make sure that all FP operations
560 RESTORE_U_PCB_REG(t2, PS, a0) # get CPU status register
561 li t3, ~MIPS_SR_COP_1_BIT
562 and t2, t2, t3 # clear COP_1 enable bit
563 cfc1 t0, MIPS_FPU_CSR # stall til FP done
564 cfc1 t0, MIPS_FPU_CSR # now get status
565 SAVE_U_PCB_REG(t2, PS, a0) # save new status register
566 SAVE_U_PCB_FPSR(t0, FSR_NUM, a0) # save FP status
568 * Save the floating point registers.
570 SAVE_U_PCB_FPREG($f0, F0_NUM, a0)
571 SAVE_U_PCB_FPREG($f1, F1_NUM, a0)
572 SAVE_U_PCB_FPREG($f2, F2_NUM, a0)
573 SAVE_U_PCB_FPREG($f3, F3_NUM, a0)
574 SAVE_U_PCB_FPREG($f4, F4_NUM, a0)
575 SAVE_U_PCB_FPREG($f5, F5_NUM, a0)
576 SAVE_U_PCB_FPREG($f6, F6_NUM, a0)
577 SAVE_U_PCB_FPREG($f7, F7_NUM, a0)
578 SAVE_U_PCB_FPREG($f8, F8_NUM, a0)
579 SAVE_U_PCB_FPREG($f9, F9_NUM, a0)
580 SAVE_U_PCB_FPREG($f10, F10_NUM, a0)
581 SAVE_U_PCB_FPREG($f11, F11_NUM, a0)
582 SAVE_U_PCB_FPREG($f12, F12_NUM, a0)
583 SAVE_U_PCB_FPREG($f13, F13_NUM, a0)
584 SAVE_U_PCB_FPREG($f14, F14_NUM, a0)
585 SAVE_U_PCB_FPREG($f15, F15_NUM, a0)
586 SAVE_U_PCB_FPREG($f16, F16_NUM, a0)
587 SAVE_U_PCB_FPREG($f17, F17_NUM, a0)
588 SAVE_U_PCB_FPREG($f18, F18_NUM, a0)
589 SAVE_U_PCB_FPREG($f19, F19_NUM, a0)
590 SAVE_U_PCB_FPREG($f20, F20_NUM, a0)
591 SAVE_U_PCB_FPREG($f21, F21_NUM, a0)
592 SAVE_U_PCB_FPREG($f22, F22_NUM, a0)
593 SAVE_U_PCB_FPREG($f23, F23_NUM, a0)
594 SAVE_U_PCB_FPREG($f24, F24_NUM, a0)
595 SAVE_U_PCB_FPREG($f25, F25_NUM, a0)
596 SAVE_U_PCB_FPREG($f26, F26_NUM, a0)
597 SAVE_U_PCB_FPREG($f27, F27_NUM, a0)
598 SAVE_U_PCB_FPREG($f28, F28_NUM, a0)
599 SAVE_U_PCB_FPREG($f29, F29_NUM, a0)
600 SAVE_U_PCB_FPREG($f30, F30_NUM, a0)
601 SAVE_U_PCB_FPREG($f31, F31_NUM, a0)
603 mtc0 t1, MIPS_COP_0_STATUS # Restore the status register.
607 END(MipsSaveCurFPState)
610 * This code is copied the user's stack for returning from signal handlers
611 * (see sendsig() and sigreturn()). We have to compute the address
612 * of the sigcontext struct for the sigreturn call.
614 .globl _C_LABEL(sigcode)
616 PTR_ADDU a0, sp, SIGF_UC # address of ucontext
620 break 0 # just in case sigreturn fails
621 .globl _C_LABEL(esigcode)
627 .long esigcode-sigcode
630 #if (defined(__mips_n32) || defined(__mips_n64)) && defined(COMPAT_FREEBSD32)
631 .globl _C_LABEL(sigcode32)
633 addu a0, sp, SIGF32_UC # address of ucontext
637 break 0 # just in case sigreturn fails
638 .globl _C_LABEL(esigcode32)
639 _C_LABEL(esigcode32):
644 .long esigcode32-sigcode32