- Remove all of the annoying $Id strings
[coreboot.git] / src / arch / ppc / lib / c_start.S
1 /* Copyright 2000  AG Electronics Ltd. */
2 /* This code is distributed without warranty under the GPL v2 (see COPYING) */
3
4 /*
5  * The assumption is that we're located in ROM and we have a fake stack
6  * located in cache. Our task is to turn on memory proper, the finish
7  * configuring the machine.
8  */
9
10 #define ASM
11 #include "ppcreg.h"
12 #include <ppc_asm.tmpl>
13
14 .section ".text"
15 .globl _start
16
17 _start:
18         /* 
19          * init stack pointer to real ram now that memory is on
20          */
21         lis     r1, _estack@ha
22         addi    r1, r1, _estack@l
23         stwu    r0,-64(r1) 
24         stwu    r1,-24(r1) 
25
26         /*
27          * Clear stack
28          */
29         lis     r4, _stack@ha
30         addi    r4, r4, _stack@l
31         lis     r7, _estack@ha
32         addi    r7, r7, _estack@l
33         lis     r5, 0
34 1:      stwx    r5, 0, r4
35         addi    r4, r4, 4
36         cmp     0, 0, r4, r7
37         ble     1b
38         sync
39
40         /*
41          * Clear bss
42          */
43         lis     r4, _bss@ha
44         addi    r4, r4, _bss@l
45         lis     r7, _ebss@ha
46         addi    r7, r7, _ebss@l
47         lis     r5, 0
48 1:      stwx    r5, 0, r4
49         addi    r4, r4, 4
50         cmp     0, 0, r4, r7
51         ble     1b
52         sync
53
54         /*
55          * Set up the EABI pointers, before we enter any C code
56          */
57         lis     r13, _SDA_BASE_@ha
58         addi    r13, r13, _SDA_BASE_@l
59         lis     r2, _SDA2_BASE_@ha
60         addi    r2, r2, _SDA2_BASE_@l
61
62         /*
63          * load start address into SRR0 for rfi
64          */
65         lis     r3, hardwaremain@ha
66         addi    r3, r3, hardwaremain@l
67         mtspr   SRR0, r3
68
69         /*
70          * load the current MSR into SRR1 so that it will be copied 
71          * back into MSR on rfi
72          */
73         mfmsr   r4
74         mtspr   SRR1, r4        // load SRR1 with r4
75
76         /*
77          * If something returns after rfi then die
78          */
79         lis     r3, dead@ha
80         addi    r3, r3, dead@l
81         mtlr    r3
82
83         /*
84          * Complete rest of initialization in C (hardwaremain)
85          */
86         rfi
87
88         /*
89          * Stop here if something goes wrong
90          */
91 dead:
92         b       dead
93         /*NOTREACHED*/
94
95 /* Remove need for ecrti.o and ectrn.o */
96 .globl __init
97 __init:
98 .globl __fini
99 __fini:
100 .globl __CTOR_LIST__
101 __CTOR_LIST__:
102 .globl __CTOR_END__
103 __CTOR_END__:
104 .globl __DTOR_LIST__
105 __DTOR_LIST__:
106 .globl __DTOR_END__
107 __DTOR_END__:
108         blr