1
/******************************************************************************
2
* Copyright (c) 2004, 2008 IBM Corporation
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
10
* IBM Corporation - initial implementation
11
*****************************************************************************/
15
#define STACKSIZE 0x2000
18
# The generic exception code.
20
# Enter with GPR0 = vector, SPRG0 = saved GPR0
23
.section ".entry_text"
29
/* the_exception_frame is a C variable which is usually
30
* defined in $(TARG).c
31
* the_exception_frame can be accessed from paflof through
33
* in the case an excpetion is handled paflof will read
34
* from eregs the values of all registers and print them
35
* out in the exception handler */
36
.quad the_exception_frame
39
mtsprg 1,1 # SPRG1 = saved GPR1
42
ld 1,eregs-$+4(1) # GPR1 = address of register save area
44
.irp i, 2,3,4,5,6,7,8,9,10,11,12,13,14,15, \
45
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
47
.endr # save GPR2..GPR31
49
li r3, 3 // GPR3 = mode (param_1, param_2)
50
mr 4,0 // GPR4 = vector
53
std 0,0(1) # save GPR0
55
std 0,8(1) # save GPR1
57
cmpwi r4, 0x900 # Decrementer interrupt
59
mfdec r5 # Save old value of decrementer as reason
60
lis r0,0x7fff # Set decrementer to highest value
78
std 0,0x138(1) # save special regs
84
.quad the_system_stack+STACKSIZE-base
86
mflr r2 /* gpr 2 is the base */
87
ld r1, .the_system_stack-base(r2) /* load stack pointer */
88
add r1, r1, r2 /* add base */
94
ld 0,engine@l(2) # set up entry
97
ld 2,8+engine@l(2) # set up TOC pointer
100
# b .engine # ...and run!
105
# Swap non-volatile client interface regs, plus GPR3..GPR7.
111
/* let's find out where our client stack is */
112
bcl 20, 31, client_over
116
.quad the_client_frame-client_base
118
mflr r8 /* gpr 2 is the client_base */
119
mtlr r0 /* restore the original lr */
120
ld r0, .the_client_frame-client_base(r8)
121
add r8, r0, r8 /* add the client_base */
122
/* r8 now contains the address of the_client_frame */
124
.irp i, 1,2,3,4,5,6,7, \
125
13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
129
.endr # swap GPR1..7, GPR13..31
134
std 9,0x100(8) # swap CR
141
std 9,0x128(8) # swap MSR
146
# Entry point for the OF client interface.
149
.globl client_entry_point
153
.quad .client_entry_point,.TOC.@tocbase,0
155
.type .client_entry_point,@function
156
.globl .client_entry_point
159
bl swap_ci_regs # swap regs
161
li 3, 0 # client call
172
.quad .call_client,.TOC.@tocbase,0
174
.type .call_client,@function
177
.call_client: # called with r3 = address, returns r3
184
li 3, -1 # client app return
187
.lcomm the_system_stack, STACKSIZE, 16