Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / board-js2x / llfw / stage2_head.S
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 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 __stack_end
25         .globl __bss_start
26         .globl __bss_size
27         .globl __start
28
29 ASM_ENTRY(__startC)
30         /* clear out bss section                */
31         LOAD64(r3, (__bss_start - 8))
32         LOAD64(r4, __bss_size)
33
34         /* divide __bss_size by 8 to get number */
35         /* of dwords to clear                   */
36         srwi.   r4, r4, 3
37         beq     bsscdone
38         li      r5, 0
39         mtctr   r4
40 bssc:   stdu    r5, 8(r3)
41         bdnz    bssc
42 bsscdone:
43         /* setup stack                          */
44         LOAD64(r1, __stack_end + STACK_SIZE)
45
46         /* save return address beside stack     */
47         addi    r3, r1, 128
48         mflr    r0
49         std     r0, 0(r3)
50         
51         /* setup toc                            */
52         bl      toc_init
53
54         /* ------------------------------------ */
55         /* jump to c-code                       */
56         /* r10 = cpu_init_slave address - r3    */
57         /* r11 = slave_setup address    - r4    */
58         /* ------------------------------------ */
59         mr      r3, r10
60         mr      r4, r11
61         bl      .early_c_entry
62
63         /* return to caller...                  */
64         LOAD64(r1, __stack_end + STACK_SIZE)
65         addi    r1, r1, 128
66         ld      r3, 0(r1)
67         mtlr    r3
68         blr
69
70         /* #################################### */
71         /* Basic Additional Functions           */
72         /* for extended lib functions see       */
73         /* external library                     */
74         /* #################################### */
75         .align  2
76
77         /* ------------------------------------ */
78         /* updates toc in r2                    */
79         /* ------------------------------------ */
80 ASM_ENTRY(toc_init)     
81         LOAD64(r2, __toc_start)
82         addi    r2,r2,0x4000
83         addi    r2,r2,0x4000
84         blr
85
86         /* ------------------------------------ */
87         /* stores arg#1 in r27 and stops        */
88         /* ------------------------------------ */
89 ENTRY(do_panic)
90 ENTRY(halt_sys)
91         BOOT_ABORT_R3HINT(ABORT_CANIO, ALTBOOT, msg_e_ierror);