|
|
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:
1.1.1.2 ! root 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:
1.1 root 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: */
1.1.1.2 ! root 39: C_ENTRY(_entry)
1.1 root 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
1.1.1.2 ! root 55: ld r2, .LCgot-base(r8) # load got pointer
! 56: add r2, r2, r8 # add base
1.1 root 57: std r6, 0(r1) # save stack pointer
58:
1.1.1.2 ! root 59: ld r6, .prom_entry_toc@toc(r2)
1.1 root 60: std r5, 0(r6) # Save prom handle
61:
1.1.1.2 ! root 62: ld r10, .exit_sp_toc@toc(r2) # save stack pointer for exit call
1.1 root 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: */
1.1.1.2 ! root 86: C_ENTRY(_callback_entry)
1.1 root 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:
1.1.1.2 ! root 112: .section ".bss"
1.1 root 113:
114: _exit_sp: .quad 0
1.1.1.2 ! root 115:
! 116: .global _prom_entry
1.1 root 117: _prom_entry: .quad 0
118:
1.1.1.2 ! root 119: .section ".text"
! 120:
! 121: C_ENTRY(_exit)
! 122: ld r1, .exit_sp_toc@toc(r2)
1.1 root 123: ld r1, 0(r1)
124: b the_end
125:
126:
1.1.1.2 ! root 127: C_ENTRY(undo_exception)
1.1 root 128: /*
129: unwind stack
130: */
1.1.1.2 ! root 131: ld r3,.exception_stack_frame_toc@toc(r2)
! 132: ld r1,0(r3)
1.1 root 133:
134: ld r14,0x130(r1)
135: mtctr r14
136:
137: // restore regs same as in _exception_handler:
138:
139: .irp i, 2,3,4,5,6,7,8,9,10,12,13,14,15,16, \
140: 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
141: 27, 28, 29, 30, 31
142: ld r\i, 0x30+\i*8 (r1)
143: .endr
1.1.1.2 ! root 144: addi r1, r1, 0x130
1.1 root 145:
146: // restore regs as in default handler
147:
148: ld r0, 0x48(r1)
149: mtsrr0 r0
150: ld r0, 0x50(r1)
151: mtsrr1 r0
152: // 20
153: ld r0, 0x38(r1)
154: mtlr r0
155: ld r0, 0x30(r1)
156: ld r11, 0x40(r1)
157: // 30
158: addi r1, r1, 0x58
159:
160: rfid
161:
162: .lcomm _stack,STACKSIZE,16
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.