xref: /freebsd/stand/powerpc/ofw/start.c (revision 3e15b01d6914c927e37d1699645783acf286655c)
1ca987d46SWarner Losh /* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */
2ca987d46SWarner Losh /*-
3ca987d46SWarner Losh  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
4ca987d46SWarner Losh  * Copyright (C) 1995, 1996 TooLs GmbH.
5ca987d46SWarner Losh  * All rights reserved.
6ca987d46SWarner Losh  *
7ca987d46SWarner Losh  * Redistribution and use in source and binary forms, with or without
8ca987d46SWarner Losh  * modification, are permitted provided that the following conditions
9ca987d46SWarner Losh  * are met:
10ca987d46SWarner Losh  * 1. Redistributions of source code must retain the above copyright
11ca987d46SWarner Losh  *    notice, this list of conditions and the following disclaimer.
12ca987d46SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
13ca987d46SWarner Losh  *    notice, this list of conditions and the following disclaimer in the
14ca987d46SWarner Losh  *    documentation and/or other materials provided with the distribution.
15ca987d46SWarner Losh  * 3. All advertising materials mentioning features or use of this software
16ca987d46SWarner Losh  *    must display the following acknowledgement:
17ca987d46SWarner Losh  *	This product includes software developed by TooLs GmbH.
18ca987d46SWarner Losh  * 4. The name of TooLs GmbH may not be used to endorse or promote products
19ca987d46SWarner Losh  *    derived from this software without specific prior written permission.
20ca987d46SWarner Losh  *
21ca987d46SWarner Losh  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
22ca987d46SWarner Losh  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23ca987d46SWarner Losh  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24ca987d46SWarner Losh  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25ca987d46SWarner Losh  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26ca987d46SWarner Losh  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27ca987d46SWarner Losh  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28ca987d46SWarner Losh  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29ca987d46SWarner Losh  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30ca987d46SWarner Losh  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31ca987d46SWarner Losh  */
32ca987d46SWarner Losh 
33ca987d46SWarner Losh #include <stand.h>
34ca987d46SWarner Losh #include "libofw.h"
35ca987d46SWarner Losh 
36ca987d46SWarner Losh void startup(void *, int, int (*)(void *), char *, int);
37ca987d46SWarner Losh 
38ca987d46SWarner Losh __asm("				\n\
39ca987d46SWarner Losh 	.data			\n\
40ca987d46SWarner Losh 	.align 4		\n\
41ca987d46SWarner Losh stack:				\n\
42ca987d46SWarner Losh 	.space	16388		\n\
43ca987d46SWarner Losh 				\n\
44ca987d46SWarner Losh 	.text			\n\
45ca987d46SWarner Losh 	.globl	_start		\n\
46ca987d46SWarner Losh _start:				\n\
47ca987d46SWarner Losh 	lis	%r1,stack@ha	\n\
48ca987d46SWarner Losh 	addi	%r1,%r1,stack@l	\n\
49ca987d46SWarner Losh 	addi	%r1,%r1,8192	\n\
50ca987d46SWarner Losh 				\n\
51ca987d46SWarner Losh 	/* Clear the .bss!!! */	\n\
52ca987d46SWarner Losh 	li      %r0,0		\n\
53ca987d46SWarner Losh 	lis     %r8,_edata@ha	\n\
54ca987d46SWarner Losh 	addi    %r8,%r8,_edata@l\n\
55ca987d46SWarner Losh 	lis     %r9,_end@ha	\n\
56ca987d46SWarner Losh 	addi    %r9,%r9,_end@l	\n\
57ca987d46SWarner Losh 				\n\
58ca987d46SWarner Losh 1:	cmpw    0,%r8,%r9	\n\
59ca987d46SWarner Losh 	bge     2f		\n\
60ca987d46SWarner Losh 	stw     %r0,0(%r8)	\n\
61ca987d46SWarner Losh 	addi    %r8,%r8,4	\n\
62ca987d46SWarner Losh 	b       1b		\n\
63ca987d46SWarner Losh 				\n\
64ca987d46SWarner Losh 2:	b	startup		\n\
65ca987d46SWarner Losh ");
66ca987d46SWarner Losh 
67*afb769e9SWarner Losh void main(int (*openfirm)(void *));
68*afb769e9SWarner Losh 
69ca987d46SWarner Losh void
startup(void * vpd,int res,int (* openfirm)(void *),char * arg,int argl)70ca987d46SWarner Losh startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl)
71ca987d46SWarner Losh {
72ca987d46SWarner Losh 	main(openfirm);
73ca987d46SWarner Losh }
74