Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / clients / net-snk / kernel / entry.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 #define STACKSIZE 0x100000
14 #include <macros.h>
15
16
17         .section        ".toc","aw"     # TOC entries are needed for relocation
18 .exception_stack_frame_toc:
19         .tc             exception_stack_frame[TC],exception_stack_frame
20 .exit_sp_toc:
21         .tc             _exit_sp[TC],_exit_sp
22 .prom_entry_toc:
23         .tc             _prom_entry[TC],_prom_entry
24
25         .previous
26
27
28 /*
29 Function:       
30         Input:
31                 r3:   
32                 r4:   
33                 r5:   prom entry         
34         Output:         
35
36 Decription: Main entry point, called from OF
37         
38 */
39 C_ENTRY(_entry)
40         mr      r3, r6  # parm 0 passed in r6
41         mr      r4, r7  # parm 1 passed in r7   
42         mr      r6, r1  # save stack pointer    
43         mflr    r7      # save link register
44         bcl     20,31,over      # branch after pointer table
45 base:   
46         .align  3
47 .LCgot:         .quad   _got-base+0x8000
48 .LCstack:       .quad   _stack+STACKSIZE-0x80-base
49 over:   
50         mflr    r8              # gpr 8 is the base
51         ld      r1,.LCstack-base(r8)    # load new stack pointer
52         add     r1, r1, r8              # add base
53         std     r2, 64(r1)              # save got
54         std     r7, 56(r1)              # save link register
55         ld      r2, .LCgot-base(r8)     # load got pointer
56         add     r2, r2, r8              # add base
57         std     r6, 0(r1)               # save stack pointer
58
59         ld      r6, .prom_entry_toc@toc(r2)
60         std     r5, 0(r6)               # Save prom handle
61
62         ld      r10, .exit_sp_toc@toc(r2)  # save stack pointer for exit call
63         std     r1, 0(r10)
64
65         bl      ._start_kernel          # call kernel init code
66
67 the_end:
68         ld      r4, 56(r1)              # Restore link register
69         mtlr    r4
70         ld      r2, 64(r1)              # restore got
71         ld      r1, 0(r1)
72
73         blr
74
75 /*
76  * Function: _callback_entry
77  * Input:   r6  start address of parameter string
78  *          r7  length of parameter string.
79  *
80  * Description: If a client application wants to register a callback function,
81  *  this function is registered w/ SLOF, not the application's function. SLOF
82  *  passes the parameter string in Forth representation in R6 and R7. This
83  *  function moves R6 to R3 and R7 to R4 and then calls callback_entry().
84  *
85  */
86 C_ENTRY(_callback_entry)
87         # Save the LR
88         mflr    r0
89         std     r0, 16(r1)
90
91         # Reserve stack space
92         stdu    r1,     -32(r1)
93
94         # SLOF passes the parameters in Registers R6 and R7 but the target
95         # wants them in registers R3 and R4
96         mr      r3, r6
97         mr      r4, r7
98
99         # Branch to the callback_entry function
100         bl      .callback_entry
101
102         # Destroy stack frame
103         ld      r1,     0(r1)
104
105         # Restore LR
106         ld      r0, 16(r1)
107         mtlr    r0
108
109         # Return to caller
110         blr
111
112         .section        ".bss"
113
114 _exit_sp:       .quad 0
115
116 .global         _prom_entry
117 _prom_entry:    .quad 0
118
119         .section        ".text"
120
121 C_ENTRY(_exit)
122         ld      r1, .exit_sp_toc@toc(r2)
123         ld      r1, 0(r1)
124         b       the_end
125
126
127        .lcomm  _stack,STACKSIZE,16