1/*
2 * libc/sysdeps/linux/microblaze/crt1.S -- Initial program entry point for linux/microblaze
3 *
4 *  Copyright (C) 2009       Meyer Sound Laboratories
5 *  Copyright (C) 2003       John Williams <jwilliams@itee.uq.edu.au>
6 *  Copyright (C) 2001,2002  NEC Corporation
7 *  Copyright (C) 2001,2002  Miles Bader <miles@gnu.org>
8 *
9 * This file is subject to the terms and conditions of the GNU Lesser
10 * General Public License.  See the file COPYING.LIB in the main
11 * directory of this archive for more details.
12 *
13 * Written by Miles Bader <miles@gnu.org>
14 */
15
16#include <libc-symbols.h>
17
18/* Upon entry, the stack contains the following data:
19	argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
20*/
21
22	.text
23	.globl C_SYMBOL_NAME(_start)
24	.align 4
25C_SYMBOL_NAME(_start):
26
27	/*
28	Preparing arguments for uClibc's startup routine.
29	The routine has 6 arguments, so 5 of them are placed
30	into registers, one on the stack
31	*/
32
33	la      r5, r0, C_SYMBOL_NAME(main) /* Arg 1: main() */
34	lw	r6, r0, r1		    /* Arg 2: argc   */
35	addi	r7, r1, 4		    /* Arg 3: argv   */
36	la	r8, r0, _init               /* Arg 4: init   */
37	la	r9, r0, _fini               /* Arg 5: fini   */
38	addk	r10,r0,r0                   /* Arg 6: rtld_fini = NULL */
39
40
41	/* Reserve space for __uClibc_main to save parameters
42	   (Microblaze ABI stack calling convention)
43	   and for stack_end argument to __uClibc_main  */
44	add 	r3, r1, r0
45	addi    r1, r1, -32
46
47	/* tail-call uClibc's startup routine */
48	brid	C_SYMBOL_NAME(__uClibc_main)
49	swi 	r3, r1, 28	/* Arg 7: stack end [DELAY SLOT] */
50
51/* Define a symbol for the first piece of initialized data.  */
52	.data
53	.globl __data_start
54__data_start:
55	.long 0
56	.weak data_start
57	data_start = __data_start
58