Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / board-qemu / llfw / stage2_head.S
1 /******************************************************************************
2  * Copyright (c) 2004, 2011 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13 #include "macros.h"
14 #include "../../llfw/boot_abort.h"
15
16 /*#################### defines #####################*/
17 #define STACK_SIZE   0x4000
18
19 /*#################### code ########################*/
20         .text
21         .globl .gluon_c_entry
22         .globl __toc_start
23         .globl __toc_end
24         .globl __bss_start
25         .globl __bss_size
26         .globl __start
27
28 ASM_ENTRY(__startC)
29         /* clear out bss section                */
30         LOAD64(r3, (__bss_start - 8))
31         LOAD64(r4, __bss_size)
32
33         /* divide __bss_size by 8 to get number */
34         /* of dwords to clear                   */
35         srwi.   r4, r4, 3
36         beq     bsscdone
37         li      r5, 0
38         mtctr   r4
39 bssc:   stdu    r5, 8(r3)
40         bdnz    bssc
41 bsscdone:
42         /* setup stack                          */
43         LOAD64(r1, __stack_end + STACK_SIZE)
44
45         /* save return address beside stack     */
46         addi    r3, r1, 128
47         mflr    r0
48         std     r0, 0(r3)
49
50         /* setup toc                            */
51         bl      toc_init
52
53         /* ------------------------------------ */
54         /* jump to c-code                       */
55         /* r31 = fdt                    - r5    */
56         /* ------------------------------------ */
57         li      r3, r0
58         mr      r4, r31
59         bl      .early_c_entry
60
61         /* return to caller...                  */
62         LOAD64(r1, __stack_end + STACK_SIZE)
63         addi    r1, r1, 128
64         ld      r3, 0(r1)
65         mtlr    r3
66         blr
67
68         /* #################################### */
69         /* Basic Additional Functions           */
70         /* for extended lib functions see       */
71         /* external library                     */
72         /* #################################### */
73         .align  2
74
75         /* ------------------------------------ */
76         /* updates toc in r2                    */
77         /* ------------------------------------ */
78 ASM_ENTRY(toc_init)
79         LOAD64(r2, __toc_start)
80         addi    r2,r2,0x4000
81         addi    r2,r2,0x4000
82         blr
83
84         /* ------------------------------------ */
85         /* stores arg#1 in r27 and stops        */
86         /* ------------------------------------ */
87 ENTRY(do_panic)
88 ENTRY(halt_sys)
89         BOOT_ABORT_R3HINT(ABORT_CANIO, ALTBOOT, msg_e_ierror);
90
91         .section ".bss"
92         .balign STACK_SIZE
93 __stack_end:
94         .space STACK_SIZE
95         .text