1233545Sjchandra/*-
2233545Sjchandra * Copyright (c) 2003-2012 Broadcom Corporation
3233545Sjchandra * All Rights Reserved
4233545Sjchandra *
5233545Sjchandra * Redistribution and use in source and binary forms, with or without
6233545Sjchandra * modification, are permitted provided that the following conditions
7233545Sjchandra * are met:
8233545Sjchandra *
9233545Sjchandra * 1. Redistributions of source code must retain the above copyright
10233545Sjchandra *    notice, this list of conditions and the following disclaimer.
11233545Sjchandra * 2. Redistributions in binary form must reproduce the above copyright
12233545Sjchandra *    notice, this list of conditions and the following disclaimer in
13233545Sjchandra *    the documentation and/or other materials provided with the
14233545Sjchandra *    distribution.
15279388Sjchandra *
16233545Sjchandra * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
17233545Sjchandra * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18233545Sjchandra * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19233545Sjchandra * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
20233545Sjchandra * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21233545Sjchandra * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22233545Sjchandra * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23233545Sjchandra * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24233545Sjchandra * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25233545Sjchandra * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26233545Sjchandra * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27233545Sjchandra *
28233545Sjchandra * $FreeBSD$
29233545Sjchandra */
30233545Sjchandra
31233545Sjchandra#include <machine/asm.h>
32233545Sjchandra
33233545Sjchandra	.text
34233545Sjchandra	.align	2
35233545Sjchandra	.globl	_start
36233545Sjchandra	.ent	_start
37233545Sjchandra_start:
38233545Sjchandra	.set	noreorder
39233545Sjchandra	la	gp, _gp
40279388Sjchandra	.end	_start
41233545Sjchandra
42233545Sjchandra	.globl	__stack
43233545Sjchandra
44233545Sjchandra	.ent	zerobss
45233545Sjchandrazerobss:
46233545Sjchandra	la	v0, _fbss
47233545Sjchandra	la	v1, _end
48233545Sjchandra3:
49233545Sjchandra	sw	zero, 0(v0)
50233545Sjchandra	bltu	v0,v1,3b
51233545Sjchandra	addiu	v0,v0,4			# executed in delay slot
52233545Sjchandra	la	sp, __stack		# set stack pointer
53233545Sjchandra	.end	zerobss
54233545Sjchandra
55233545Sjchandra	.ent	init
56233545Sjchandrainit:
57233545Sjchandra	addiu	a1,sp,32		# argv = sp + 32
58233545Sjchandra	addiu	a2,sp,40		# envp = sp + 40
59233545Sjchandra	sw	zero,(a1)		# argv[argc] = 0
60233545Sjchandra	sw	zero,(a2)		# envp[0] = 0
61233545Sjchandra	jal	main			# call the program start function
62233545Sjchandra	move	a0,zero			# set argc to 0
63233545Sjchandra1:	b	1b
64233545Sjchandra	nop
65233545Sjchandra	.end	init
66233545Sjchandra
67