xref: /illumos-gate/usr/src/lib/crt/sparc/mach-crt1.S (revision 5de85994e399d09203c0a0ac1c559f968f1a21a7)
1/*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source.  A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12/*
13 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
14 * Use is subject to license terms.
15 */
16
17/* Copyright 2016, Richard Lowe. */
18
19#include <sys/asm_linkage.h>
20#include <sys/stack.h>
21
22	.file	"mach-crt1.s"
23	.ident	""
24
25	.global	_start_crt
26
27#if defined(__sparcv9)
28#define	EB_MAX_SIZE	128
29#else
30#define	EB_MAX_SIZE	64
31#endif
32
33ENTRY_NP(_start)
34	/*
35	 * On entry, the stack is:
36	 *
37	 * .-----------------------.   <--- %sp
38	 * |			   |
39	 * |	    Window	   |
40	 * |			   |
41	 * |-----------------------|
42	 * |	    argc	   |
43	 * |-----------------------|
44	 * |	    argv[0]	   |
45	 * |	    argv[1]	   |
46	 * |	    argv[2]	   |
47	 * |	    argv[3]	   |
48	 * |	    ...		   |
49	 * |	 argv[argc - 1]	   |
50	 * |-----------------------|
51	 * |	      NULL	   |
52	 * |-----------------------|
53	 * |	    envp[0]	   |
54	 * |	    envp[1]	   |
55	 * |	    envp[2]	   |
56	 * |	    envp[3]	   |
57	 * |	     ...	   |
58	 * |	    envp[N]	   |
59	 * |-----------------------|
60	 * |	      NULL	   |
61	 * .-----------------------.
62	 *
63	 * and an exit handler from the linker is in %g1
64	 */
65	clr	%fp		! don't trace the stack past this point
66
67	add	%sp, WINDOWSIZE + STACK_BIAS, %l0	! address of argc
68
69	! allocate a minimally sized frame, and align ourselves
70	add	%sp, -SA(MINFRAME - EB_MAX_SIZE), %sp
71
72	ldn	[%l0], %o0			! argc
73	add	%l0, CPTRSIZE, %o1	! argv
74	call	_start_crt
75	    mov %g1, %o2			! exit_handler in delay slot
76SET_SIZE(_start)
77