xref: /illumos-gate/usr/src/psm/stand/boot/sparc/common/sun4u_srt0.S (revision 5d9d9091f564c198a760790b0bfa72c44e17912b)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright (c) 1986-1997, Sun Microsystems, Inc.
24 * All rights reserved.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29/*
30 * standalone startup code for sun4u LP64 secondary booters.
31 */
32
33#include <sys/asm_linkage.h>
34#include <sys/privregs.h>
35#include <sys/stack.h>
36
37#if defined(lint)
38
39/*ARGSUSED*/
40void
41_start(void *a, ...)
42{}
43
44#else
45	.seg	".text"
46	.align	8
47	.global	end
48	.global	edata
49	.global	main
50
51	.seg	".bss"
52	.align	8
53
54_local_p1275cif:
55	.skip	8
56
57!
58! Create a stack just below _start.
59!
60#define	STACK_SIZE	0x14000
61
62	.skip	STACK_SIZE
63.ebootstack:			! end --top-- of boot stack
64
65!
66! Enter here for all disk/secondary booters loaded by a bootblk program or
67! inetboot loaded by OBP.
68! Careful: don't touch %o4 until the save, since it contains the
69! address of the IEEE 1275 SPARC v9 CIF handler; the linkage to the prom.
70!
71	.seg	".text"
72	.global	prom_exit_to_mon
73	.type	prom_exit_to_mon, #function
74
75	ENTRY(_start)
76
77	!
78	! The stacks in bss now; use the stack we came in on (prom is supposed
79	! to call us with a minimum of an 8k stack, bzero bss (and thus our
80	! new stack), then switch to the new stack. Do all this without losing
81	! track of the p1275cif address cached in %o4.
82	!
83
84	save	%sp, -SA(MINFRAME), %sp
85
86	!
87	! Zero the bss [edata to end]
88	!
89	setn	edata, %g1, %o0
90	setn	end, %g1, %i2
91	call	bzero
92	sub	%i2, %o0, %o1			! size
93
94	restore %g0, %g0, %g0	! Trivial restore
95
96	!
97	! Switch to our new stack.
98	!
99	setn    (.ebootstack - STACK_BIAS), %g1, %o1
100	save	%o1, -SA(MINFRAME), %sp
101
102	!
103	! Set supervisor mode, interrupt level >= 13, traps enabled
104	! We don't set PSTATE_AM even though all our addresses are under 4G.
105	!
106	wrpr	%g0, PSTATE_PEF+PSTATE_PRIV+PSTATE_IE, %pstate
107
108	sethi	%hi(_local_p1275cif), %o1
109	stx	%i4, [%o1 + %lo(_local_p1275cif)]
110	call	main			! main(prom-cookie)
111	mov	%i4, %o0		! SPARCV9/CIF
112
113	! print stupid error message here!
114
115	call	prom_enter_mon		! can't happen .. :-)
116	nop
117	SET_SIZE(_start)
118
119#endif	/* lint */
120
121#if defined(lint)
122
123/* ARGSUSED */
124void
125exitto(int (*entrypoint)(void *romvec, void *dvec, void *bootops,
126    void *bootvec))
127{}
128
129/* ARGSUSED */
130void
131exitto64(int (*entrypoint)(void *romvec, void *dvec, void *bootops,
132    void *bootvec), void *bootvec)
133{}
134
135#else	/* lint */
136
137	ENTRY(exitto)
138	!
139	! Setup args for client.
140	!
141	! 32 bit frame, 64 bit sized
142	sub	%g0, SA(MINFRAME) - STACK_BIAS, %g1
143	save	%sp, %g1, %sp
144	sethi	%hi(_local_p1275cif), %o0 ! 1275 CIF handler for callee.
145	ldx	[%o0 + %lo(_local_p1275cif)], %o0
146	clr	%o1			! boot passes no dvec
147	setn	bootops, %g1, %o2
148	sethi	%hi(elfbootvec), %o3	! pass elf bootstrap vector
149	ldx	[%o3 + %lo(elfbootvec)], %o3
150	rdpr	%pstate, %l1		! Get the present pstate value
151	wrpr    %l1, PSTATE_AM, %pstate ! Set PSTATE_AM = 1
152	jmpl	%i0, %o7		! call thru register to the standalone
153	mov	%o0, %o4		! 1210378: Pass cif in both %o0 & %o4
154
155	! eek - we returned -- switch back to a 64-bit frame
156	! then panic in a slightly informative way.
157
158	restore	%g0, %g0, %g0
159	save	%sp, -SA(MINFRAME), %sp
160	sethi	%hi(.msg), %o0
161	call	prom_panic
162	or	%o0, %lo(.msg), %o0
163.msg:	.asciz	"exitto returned from client program"
164	SET_SIZE(exitto)
165
166	ENTRY(exitto64)
167	!
168	! Setup args for client.
169	!
170	save	%sp, -SA(MINFRAME), %sp
171	sethi	%hi(_local_p1275cif), %o0 ! 1275 CIF handler for callee.
172	ldx	[%o0 + %lo(_local_p1275cif)], %o0
173	mov	%i1, %o3		! bootvec
174	clr	%o1			! boot passes no dvec
175	setn	bootops, %g1, %o2
176	jmpl	%i0, %o7		! call thru register to the standalone
177	mov	%o0, %o4		! 1210378: Pass cif in both %o0 & %o4
178
179	! eek - we returned -- panic in a slightly informative way.
180
181	sethi	%hi(.msg64), %o0
182	call	prom_panic
183	or	%o0, %lo(.msg64), %o0
184.msg64:	.asciz	"exitto64 returned from client program"
185	SET_SIZE(exitto64)
186
187#endif	/* lint */
188
189#if defined(lint)
190
191/*
192 * The interface for our 64-bit client program
193 * calling the 64-bit romvec OBP.
194 */
195
196#include <sys/promif.h>
197#include <sys/prom_isa.h>
198
199/* ARGSUSED */
200int
201client_handler(void *cif_handler, void *arg_array)
202{ return (0); }
203
204#else	/* lint */
205
206	ENTRY(client_handler)
207	mov	%o7, %g1
208	mov	%o0, %g5
209	mov	%o1, %o0
210	jmp	%g5
211	mov	%g1, %o7
212	SET_SIZE(client_handler)
213
214#endif	/* lint */
215