Use the common LinuxBIOS license header (trivial). Refs #5.
[coreboot.git] / src / arch / ppc / lib / c_start.S
1 /*
2  * This file is part of the LinuxBIOS project.
3  *
4  * Copyright (C) 2000 AG Electronics Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 /*
21  * The assumption is that we're located in ROM and we have a fake stack
22  * located in cache. Our task is to turn on memory proper, the finish
23  * configuring the machine.
24  */
25
26 #define ASM
27 #include "ppcreg.h"
28 #include <ppc_asm.tmpl>
29
30 .section ".text"
31 .globl _start
32
33 _start:
34         /* 
35          * init stack pointer to real ram now that memory is on
36          * Note: We use the last 8 bytes on the stack to hold struct cpu_info,
37          *       Which are initialized to zero as we clear the stack.
38          */
39         li      r0, 0
40         lis     r1, _estack@ha
41         addi    r1, r1, _estack@l
42         stwu    r0,-64(r1) 
43         stwu    r1,-24(r1) 
44
45         /*
46          * Clear stack
47          */
48         lis     r4, _stack@ha
49         addi    r4, r4, _stack@l
50         lis     r7, _estack@ha
51         addi    r7, r7, _estack@l
52         lis     r5, 0
53 1:      stwx    r5, 0, r4
54         addi    r4, r4, 4
55         cmp     0, 0, r4, r7
56         ble     1b
57         sync
58
59         /*
60          * Clear bss
61          */
62         lis     r4, _bss@ha
63         addi    r4, r4, _bss@l
64         lis     r7, _ebss@ha
65         addi    r7, r7, _ebss@l
66         lis     r5, 0
67 1:      stwx    r5, 0, r4
68         addi    r4, r4, 4
69         cmp     0, 0, r4, r7
70         ble     1b
71         sync
72
73         /*
74          * Set up the EABI pointers, before we enter any C code
75          */
76         lis     r13, _SDA_BASE_@ha
77         addi    r13, r13, _SDA_BASE_@l
78         lis     r2, _SDA2_BASE_@ha
79         addi    r2, r2, _SDA2_BASE_@l
80
81         /*
82          * load start address into SRR0 for rfi
83          */
84         lis     r3, hardwaremain@ha
85         addi    r3, r3, hardwaremain@l
86         mtspr   SRR0, r3
87
88         /*
89          * load the current MSR into SRR1 so that it will be copied 
90          * back into MSR on rfi
91          */
92         mfmsr   r4
93         mtspr   SRR1, r4        // load SRR1 with r4
94
95         /*
96          * If something returns after rfi then die
97          */
98         lis     r3, dead@ha
99         addi    r3, r3, dead@l
100         mtlr    r3
101
102         /*
103          * Complete rest of initialization in C (hardwaremain)
104          */
105         rfi
106
107         /*
108          * Stop here if something goes wrong
109          */
110 dead:
111         b       dead
112         /*NOTREACHED*/
113
114 /* Remove need for ecrti.o and ectrn.o */
115 .globl __init
116 __init:
117 .globl __fini
118 __fini:
119 .globl __CTOR_LIST__
120 __CTOR_LIST__:
121 .globl __CTOR_END__
122 __CTOR_END__:
123 .globl __DTOR_LIST__
124 __DTOR_LIST__:
125 .globl __DTOR_END__
126 __DTOR_END__:
127         blr