1 /* $OpenBSD: locore.S,v 1.2 2010/02/14 22:39:33 miod Exp $ */
4 * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/errno.h>
29 #include <sys/syscall.h>
31 #include <machine/param.h>
32 #include <machine/asm.h>
33 #include <machine/cpu.h>
34 #include <machine/regnum.h>
35 #include <machine/cpustate.h>
39 .set noreorder # Noreorder is default style!
45 /* initialize ebase */
46 dla t0, 0xffffffff80000000
49 /* initialize cvmctl */
51 dmtc0 t0, COP_0_CVMCTL
53 /* initialize cvmmemctl */
55 dmtc0 t0, COP_0_CVMMEMCTL
57 /* initialize pagegrain */
59 dmtc0 t0, COP_0_TLB_PG_GRAIN
61 mfc0 v0, COP_0_STATUS_REG
62 li v1, ~(SR_INT_ENAB | SR_ERL | SR_EXL)
64 mtc0 v0, COP_0_STATUS_REG # disable all interrupts
66 mtc0 zero, COP_0_CAUSE_REG # Clear soft interrupts
69 * Initialize stack and call machine startup.
71 LA t0, start - FRAMESZ(CF_SZ)
73 PTR_S ra, CF_RA_OFFS(t0) # save pmon return address
74 PTR_S sp, 0(t0) # and stack
76 jal mips_init # mips_init(argc, argv, envp,
79 beqz v0, 1f # upon failure, return to pmon
82 PTR_S zero, CF_RA_OFFS(sp) # Zero out old ra for debugger
83 move sp, v0 # switch to new stack
86 PANIC("Startup failed!")
88 1: PTR_L ra, CF_RA_OFFS(sp)
101 LEAF(get_cvmmemctl, 0)
110 #if defined(MULTIPROCESSOR)
111 LEAF(hw_cpu_spinup_trampoline, 0)
112 mfc0 v0, COP_0_STATUS_REG
115 ori v0, SR_KX | SR_UX
116 mtc0 v0, COP_0_STATUS_REG # disable all interrupts
117 mtc0 zero, COP_0_CAUSE_REG # Clear soft interrupts
121 END(hw_cpu_spinup_trampoline)
123 LEAF(hw_getcurcpu, 0)
129 LEAF(hw_setcurcpu, 0)
130 dmtc0 a0, COP_0_ERROR_PC
134 #endif /* MULTIPROCESSOR */