start.c revision 124139
168548Sbenno/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */
268548Sbenno/*
368548Sbenno * Copyright (C) 1995, 1996 Wolfgang Solfrank.
468548Sbenno * Copyright (C) 1995, 1996 TooLs GmbH.
568548Sbenno * All rights reserved.
668548Sbenno *
768548Sbenno * Redistribution and use in source and binary forms, with or without
868548Sbenno * modification, are permitted provided that the following conditions
968548Sbenno * are met:
1068548Sbenno * 1. Redistributions of source code must retain the above copyright
1168548Sbenno *    notice, this list of conditions and the following disclaimer.
1268548Sbenno * 2. Redistributions in binary form must reproduce the above copyright
1368548Sbenno *    notice, this list of conditions and the following disclaimer in the
1468548Sbenno *    documentation and/or other materials provided with the distribution.
1568548Sbenno * 3. All advertising materials mentioning features or use of this software
1668548Sbenno *    must display the following acknowledgement:
1768548Sbenno *	This product includes software developed by TooLs GmbH.
1868548Sbenno * 4. The name of TooLs GmbH may not be used to endorse or promote products
1968548Sbenno *    derived from this software without specific prior written permission.
2068548Sbenno *
2168548Sbenno * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
2268548Sbenno * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2368548Sbenno * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2468548Sbenno * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2568548Sbenno * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2668548Sbenno * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2768548Sbenno * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2868548Sbenno * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2968548Sbenno * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
3068548Sbenno * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3168548Sbenno */
3268548Sbenno
33124139Sobrien#include <sys/cdefs.h>
34124139Sobrien__FBSDID("$FreeBSD: head/sys/boot/powerpc/ofw/start.c 124139 2004-01-04 23:21:18Z obrien $");
35124139Sobrien
3668548Sbenno#include <stand.h>
3768548Sbenno#include "libofw.h"
3868548Sbenno
3968548Sbennovoid startup(void *, int, int (*)(void *), char *, int);
4068548Sbenno
4168548Sbenno#ifdef XCOFF_GLUE
42118485Sgrehanasm("				\n\
43118485Sgrehan	.text			\n\
44118485Sgrehan	.globl	_entry		\n\
45118485Sgrehan_entry:				\n\
46118485Sgrehan	.long	_start,0,0	\n\
4768548Sbenno");
4868548Sbenno#endif
4968548Sbenno
50118485Sgrehan__asm("				\n\
51118485Sgrehan	.data			\n\
52118485Sgrehanstack:				\n\
53118485Sgrehan	.space	16388		\n\
54118485Sgrehan				\n\
55118485Sgrehan	.text			\n\
56118485Sgrehan	.globl	_start		\n\
57118485Sgrehan_start:				\n\
58118485Sgrehan	li	%r8,0		\n\
59118485Sgrehan	li	%r9,0x100	\n\
60118485Sgrehan	mtctr	%r9		\n\
61118485Sgrehan1:				\n\
62118485Sgrehan	dcbf	%r0,%r8		\n\
63118485Sgrehan	icbi	%r0,%r8		\n\
64118485Sgrehan	addi	%r8,%r8,0x20	\n\
65118485Sgrehan	bdnz	1b		\n\
66118485Sgrehan	sync			\n\
67118485Sgrehan	isync			\n\
68118485Sgrehan				\n\
69118485Sgrehan	lis	%r1,stack@ha	\n\
70118485Sgrehan	addi	%r1,%r1,stack@l	\n\
71118485Sgrehan	addi	%r1,%r1,8192	\n\
72118485Sgrehan				\n\
73118485Sgrehan	mfmsr	%r8		\n\
74118485Sgrehan	li	%r0,0		\n\
75118485Sgrehan	mtmsr	%r0		\n\
76118485Sgrehan	isync			\n\
77118485Sgrehan				\n\
78118485Sgrehan	mtibatu	0,%r0		\n\
79118485Sgrehan	mtibatu	1,%r0		\n\
80118485Sgrehan	mtibatu	2,%r0		\n\
81118485Sgrehan	mtibatu	3,%r0		\n\
82118485Sgrehan	mtdbatu	0,%r0		\n\
83118485Sgrehan	mtdbatu	1,%r0		\n\
84118485Sgrehan	mtdbatu	2,%r0		\n\
85118485Sgrehan	mtdbatu	3,%r0		\n\
86118485Sgrehan				\n\
87118485Sgrehan	li	%r9,0x12     /* BATL(0, BAT_M, BAT_PP_RW) */ \n\
88118485Sgrehan	mtibatl	0,%r9		\n\
89118485Sgrehan	mtdbatl	0,%r9		\n\
90118485Sgrehan	li	%r9,0x1ffe   /* BATU(0, BAT_BL_256M, BAT_Vs) */ \n\
91118485Sgrehan	mtibatu	0,%r9		\n\
92118485Sgrehan	mtdbatu	0,%r9		\n\
93118485Sgrehan	isync			\n\
94118485Sgrehan				\n\
95118485Sgrehan	mtmsr	%r8		\n\
96118485Sgrehan	isync			\n\
97118485Sgrehan				\n\
98118485Sgrehan	b	startup		\n\
9968548Sbenno");
10068548Sbenno
10168548Sbennovoid
10268548Sbennostartup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl)
10368548Sbenno{
10468548Sbenno	main(openfirm);
10568548Sbenno}
106