|
|
1.1 root 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: Function:
18: Input:
19: r3:
20: r4:
21: r5: prom entry
22: Output:
23:
24: Decription: Main entry point, called from OF
25:
26: */
27: .globl _entry
28: .section ".opd","aw"
29: .align 3
30: _entry:
31: .quad ._entry,.TOC.@tocbase,0
32: .previous
33: .size main,24
34: .globl ._entry
35: ._entry:
36: mr r3, r6 # parm 0 passed in r6
37: mr r4, r7 # parm 1 passed in r7
38: mr r6, r1 # save stack pointer
39: mflr r7 # save link register
40: bcl 20,31,over # branch after pointer table
41: base:
42: .align 3
43: .LCgot: .quad _got-base+0x8000
44: .LCstack: .quad _stack+STACKSIZE-0x80-base
45: over:
46: mflr r8 # gpr 8 is the base
47: ld r1,.LCstack-base(r8) # load new stack pointer
48: add r1, r1, r8 # add base
49: std r2, 64(r1) # save got
50: std r7, 56(r1) # save link register
51: # ld r2, .LCgot-base(r8) # load got pointer
52: # add r2, r2, r8 # add base
53: std r6, 0(r1) # save stack pointer
54:
55: ld r6, _prom_entry@got(r2)
56: std r5, 0(r6) # Save prom handle
57:
58: ld r10, _exit_sp@got(r2) # save stack pointer for exit call
59: std r1, 0(r10)
60:
61: bl ._start_kernel # call kernel init code
62:
63: the_end:
64: ld r4, 56(r1) # Restore link register
65: mtlr r4
66: ld r2, 64(r1) # restore got
67: ld r1, 0(r1)
68:
69: blr
70:
71: /*
72: * Function: _callback_entry
73: * Input: r6 start address of parameter string
74: * r7 length of parameter string.
75: *
76: * Description: If a client application wants to register a callback function,
77: * this function is registered w/ SLOF, not the application's function. SLOF
78: * passes the parameter string in Forth representation in R6 and R7. This
79: * function moves R6 to R3 and R7 to R4 and then calls callback_entry().
80: *
81: */
82: .globl _callback_entry
83: .section ".opd", "aw"
84: .align 3
85: _callback_entry:
86: .quad ._callback_entry,.TOC.@tocbase,0
87: .previous
88: .size callback,24
89: .type ._callback_entry, @function
90: .globl ._callback_entry
91: ._callback_entry:
92: # Save the LR
93: mflr r0
94: std r0, 16(r1)
95:
96: # Reserve stack space
97: stdu r1, -32(r1)
98:
99: # SLOF passes the parameters in Registers R6 and R7 but the target
100: # wants them in registers R3 and R4
101: mr r3, r6
102: mr r4, r7
103:
104: # Branch to the callback_entry function
105: bl .callback_entry
106:
107: # Destroy stack frame
108: ld r1, 0(r1)
109:
110: # Restore LR
111: ld r0, 16(r1)
112: mtlr r0
113:
114: # Return to caller
115: blr
116:
117:
118: .globl _exit_sp
119: _exit_sp: .quad 0
120: .globl _prom_entry
121: _prom_entry: .quad 0
122:
123: ENTRY(_exit)
124: ld r1, _exit_sp@got(r2)
125: ld r1, 0(r1)
126: b the_end
127:
128: .globl .undo_exception
129: .undo_exception:
130: .globl undo_exception
131: undo_exception:
132:
133: /*
134: unwind stack
135: */
136: ld r3,exception_stack_frame@got(r2)
137: ld r1,0(r3)
138:
139: ld r14,0x130(r1)
140: mtctr r14
141:
142: // restore regs same as in _exception_handler:
143:
144: .irp i, 2,3,4,5,6,7,8,9,10,12,13,14,15,16, \
145: 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
146: 27, 28, 29, 30, 31
147: ld r\i, 0x30+\i*8 (r1)
148: .endr
149: addi r1, r1, 0x130
150:
151: // restore regs as in default handler
152:
153: ld r0, 0x48(r1)
154: mtsrr0 r0
155: ld r0, 0x50(r1)
156: mtsrr1 r0
157: // 20
158: ld r0, 0x38(r1)
159: mtlr r0
160: ld r0, 0x30(r1)
161: ld r11, 0x40(r1)
162: // 30
163: addi r1, r1, 0x58
164:
165: rfid
166:
167: .lcomm _stack,STACKSIZE,16
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.