OSDN Git Service

7d09a97fb9916188859fb13ad6f25ad55759dae4
[openbsd-octeon/openbsd-octeon.git] / src / sys / arch / octeon / octeon / locore.S
1 /*      $OpenBSD: locore.S,v 1.2 2010/02/14 22:39:33 miod Exp $ */
2
3 /*
4  * Copyright (c) 2001-2004 Opsycon AB  (www.opsycon.se / www.opsycon.com)
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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.
14  *
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
25  * SUCH DAMAGE.
26  *
27  */
28 #include <sys/errno.h>
29 #include <sys/syscall.h>
30
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>
36
37 #include "assym.h"
38
39         .set    noreorder               # Noreorder is default style!
40         .set    mips64r2
41         .globl  start
42         .globl  kernel_text
43 kernel_text = start
44 start:
45 /* initialize ebase */
46         dla     t0, 0xffffffff80000000
47         mtc0    t0, COP_0_EBASE
48
49 /* initialize cvmctl */
50         dli     t0, 0x900043F0
51         dmtc0   t0, COP_0_CVMCTL
52
53 /* initialize cvmmemctl */
54         dli     t0, 0x46104
55         dmtc0   t0, COP_0_CVMMEMCTL
56
57 /* initialize pagegrain */
58         dli     t0, 0x20000000
59         dmtc0   t0, COP_0_TLB_PG_GRAIN
60
61         mfc0    v0, COP_0_STATUS_REG
62         li      v1, ~(SR_INT_ENAB | SR_ERL | SR_EXL)
63         and     v0, v1
64         mtc0    v0, COP_0_STATUS_REG    # disable all interrupts
65
66         mtc0    zero, COP_0_CAUSE_REG   # Clear soft interrupts
67
68         /*
69          * Initialize stack and call machine startup.
70          */
71         LA      t0, start - FRAMESZ(CF_SZ)
72         LA      gp, _gp
73         PTR_S   ra, CF_RA_OFFS(t0)              # save pmon return address
74         PTR_S   sp, 0(t0)                       # and stack
75         move    sp, t0
76         jal     mips_init                       # mips_init(argc, argv, envp,
77         nop                                     #    callvec, esym)
78
79         beqz    v0, 1f                          # upon failure, return to pmon
80         nop
81
82         PTR_S   zero, CF_RA_OFFS(sp)            # Zero out old ra for debugger
83         move    sp, v0                          # switch to new stack
84         jal     main                            # main(regs)
85         move    a0, zero
86         PANIC("Startup failed!")
87
88 1:      PTR_L   ra, CF_RA_OFFS(sp)
89         PTR_L   sp, 0(sp)
90         jr      ra
91         nop
92
93 LEAF(get_cvmctl, 0)
94         .set push
95         .set mips64r2
96         dmfc0   v0, $9, 7
97         jr      ra
98         nop
99 END(get_cvmctl)
100
101 LEAF(get_cvmmemctl, 0)
102         .set push
103         .set mips64r2
104         dmfc0   v0, $11, 7
105         jr      ra
106         nop
107 END(get_cvmmemctl)
108
109
110 #if defined(MULTIPROCESSOR)
111 LEAF(hw_cpu_spinup_trampoline, 0)
112         mfc0    v0, COP_0_STATUS_REG
113         li      v1, ~SR_INT_ENAB
114         and     v0, v1
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
118         LA      gp, _gp
119         jal     hw_cpu_hatch
120         nop
121 END(hw_cpu_spinup_trampoline)
122
123 LEAF(hw_getcurcpu, 0)
124         GET_CPU_INFO(v0, v1)
125         jr      ra
126         nop
127 END(hw_getcurcpu)
128
129 LEAF(hw_setcurcpu, 0)
130         dmtc0   a0, COP_0_ERROR_PC
131         j       ra
132         nop
133 END(hw_setcurcpu)
134 #endif /* MULTIPROCESSOR */