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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26#include <sys/asm_linkage.h>
27#include <sys/link.h>
28
29#if defined(lint)
30
31void
32_start(void)
33{
34}
35
36#else	/* lint */
37	.section	".text"
38	/*
39	 * Initial entry point for the brand emulation library.
40	 *
41	 * This platform specific assembly entry point exists just to invoke
42	 * the common brand library startup routine.  That routine expects to
43	 * be called with the following arguments:
44	 *	brand_init(int argc, char *argv[], char *envp[])
45	 *
46	 * There are no arguments explicitly passed to this entry point,
47	 * routine, but we do know how our initial stack has been setup by
48	 * the kernel.  The stack format is documented in:
49	 *	usr/src/cmd/sgs/rtld/sparc/boot.s
50	 *	usr/src/cmd/sgs/rtld/sparcv9/boot.s
51	 *
52	 * So this routine will troll through the stack to setup the argument
53	 * values for the common brand library startup routine and then invoke
54	 * it.
55	 */
56	ENTRY_NP(_start)
57#if defined (__sparcv9)
58	save	%sp, -SA(MINFRAME + EB_MAX_SIZE64), %sp
59#else /* !__sparcv9 */
60	save	%sp, -SA(MINFRAME + EB_MAX_SIZE32), %sp
61#endif /* !__sparcv9 */
62
63	/* get argc */
64	ldn	[%fp + WINDOWSIZE + STACK_BIAS], %o0
65
66	/* get argv */
67	add	%fp, + WINDOWSIZE + CPTRSIZE + STACK_BIAS, %o1
68
69	/* get envp */
70	add	%o0, 1, %l0		! add 1 to argc for last element of 0
71	sll	%l0, CPTRSHIFT, %l0	! multiply argc by pointer size
72	add	%o1, %l0, %o2		!  and add to argv to get first env ptr
73
74	call	brand_init
75	nop
76
77	/*NOTREACHED*/
78	SET_SIZE(_start)
79#endif	/* lint */
80