Merge from vendor branch GCC:
[dragonfly.git] / sys / boot / powerpc / loader / start.c
1 /*
2  * $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $
3  * $FreeBSD: src/sys/boot/powerpc/loader/start.c,v 1.3 2003/08/05 11:30:18 grehan Exp $
4  * $DragonFly: src/sys/boot/powerpc/loader/start.c,v 1.1 2003/11/10 06:08:40 dillon Exp $
5  */
6
7 /*
8  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
9  * Copyright (C) 1995, 1996 TooLs GmbH.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. All advertising materials mentioning features or use of this software
21  *    must display the following acknowledgement:
22  *      This product includes software developed by TooLs GmbH.
23  * 4. The name of TooLs GmbH may not be used to endorse or promote products
24  *    derived from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
27  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37
38 #include <stand.h>
39 #include "libofw.h"
40
41 void startup(void *, int, int (*)(void *), char *, int);
42
43 #ifdef XCOFF_GLUE
44 asm("                           \n\
45         .text                   \n\
46         .globl  _entry          \n\
47 _entry:                         \n\
48         .long   _start,0,0      \n\
49 ");
50 #endif
51
52 __asm("                         \n\
53         .data                   \n\
54 stack:                          \n\
55         .space  16388           \n\
56                                 \n\
57         .text                   \n\
58         .globl  _start          \n\
59 _start:                         \n\
60         li      %r8,0           \n\
61         li      %r9,0x100       \n\
62         mtctr   %r9             \n\
63 1:                              \n\
64         dcbf    %r0,%r8         \n\
65         icbi    %r0,%r8         \n\
66         addi    %r8,%r8,0x20    \n\
67         bdnz    1b              \n\
68         sync                    \n\
69         isync                   \n\
70                                 \n\
71         lis     %r1,stack@ha    \n\
72         addi    %r1,%r1,stack@l \n\
73         addi    %r1,%r1,8192    \n\
74                                 \n\
75         mfmsr   %r8             \n\
76         li      %r0,0           \n\
77         mtmsr   %r0             \n\
78         isync                   \n\
79                                 \n\
80         mtibatu 0,%r0           \n\
81         mtibatu 1,%r0           \n\
82         mtibatu 2,%r0           \n\
83         mtibatu 3,%r0           \n\
84         mtdbatu 0,%r0           \n\
85         mtdbatu 1,%r0           \n\
86         mtdbatu 2,%r0           \n\
87         mtdbatu 3,%r0           \n\
88                                 \n\
89         li      %r9,0x12     /* BATL(0, BAT_M, BAT_PP_RW) */ \n\
90         mtibatl 0,%r9           \n\
91         mtdbatl 0,%r9           \n\
92         li      %r9,0x1ffe   /* BATU(0, BAT_BL_256M, BAT_Vs) */ \n\
93         mtibatu 0,%r9           \n\
94         mtdbatu 0,%r9           \n\
95         isync                   \n\
96                                 \n\
97         mtmsr   %r8             \n\
98         isync                   \n\
99                                 \n\
100         b       startup         \n\
101 ");
102
103 void
104 startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl)
105 {
106         main(openfirm);
107 }