Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\debug\context.cia
18 #ifndef __KERNEL_MODE__
22 __NAKED__ void SetRegs()
25 asm("str r1, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR0));
26 asm("add r1, r1, #1 ");
27 asm("str r1, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR1));
28 asm("add r2, r1, #1 ");
29 asm("str r2, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR2));
30 asm("add r3, r2, #1 ");
31 asm("str r3, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR3));
32 asm("add r4, r3, #1 ");
33 asm("str r4, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR4));
34 asm("add r5, r4, #1 ");
35 asm("str r5, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR5));
36 asm("add r6, r5, #1 ");
37 asm("str r6, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR6));
38 asm("add r7, r6, #1 ");
39 asm("str r7, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR7));
40 asm("add r8, r7, #1 ");
41 asm("str r8, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR8));
42 asm("add r9, r8, #1 ");
43 asm("str r9, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR9));
44 asm("add r10, r9, #1 ");
45 asm("str r10, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR10));
46 asm("add r11, r10, #1 ");
47 asm("str r11, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR11));
48 asm("add r12, r11, #1 ");
49 asm("str r12, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR12));
50 asm("str r13, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR13));
51 asm("str r14, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR14));
52 asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,iR0));
56 #define CHECK_REGA(reg,val) \
57 asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,reg)); \
58 asm("ldr r3, ="#val); \
60 asm("movne r0, #0"); \
63 #define CHECK_REG(reg) \
64 asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(TArmRegSet,reg)); \
65 asm("ldr r3, [r1, #%a0]" : : "i" _FOFF(TArmRegSet,reg)); \
67 asm("movne r0, #0"); \
72 __NAKED__ TInt ThreadContextHwExc(TAny*)
74 asm("stmdb sp!, {r4-r11,lr} ");
75 asm("mov r1, #0x80000000");
77 asm("ldr r0,[r13, #1]"); // Cause alignment fault
78 asm("ThreadContextHwExc_pc:");
80 asm("ldmia sp!, {r4-r11,pc} ");
83 __NAKED__ TInt CheckContextHwExc(TArmRegSet* aContext,TArmRegSet* aSavedData)
100 CHECK_REGA(iR15,ThreadContextHwExc_pc)
107 __NAKED__ TInt ThreadContextUserInt(TAny*)
109 asm("mov r1, #0x70000000");
111 asm("ThreadContextUserInt_pc:");
112 asm("b ThreadContextUserInt_pc");
115 __NAKED__ TInt CheckContextUserInt(TArmRegSet*,TArmRegSet*)
132 CHECK_REGA(iR15,ThreadContextUserInt_pc)
137 __NAKED__ TInt CheckContextUserIntDied(TArmRegSet*,TArmRegSet*)
146 CHECK_REGA(iR15,ThreadContextUserInt_pc)
152 __NAKED__ TInt ThreadContextWFAR(TAny*)
154 asm("stmdb sp!, {r4-r11,lr} ");
155 asm("mov r1, #0x60000000");
157 asm("adr lr, ThreadContextWFAR_return");
158 FAST_EXEC0(EFastExecWaitForAnyRequest);
159 asm("ThreadContextWFAR_return:");
161 asm("ldmia sp!, {r4-r11,pc} ");
164 __NAKED__ TInt CheckContextWFAR(TArmRegSet*,TArmRegSet*)
175 CHECK_REGA(iR14,ThreadContextWFAR_return)
176 CHECK_REGA(iR15,ThreadContextWFAR_return - 4)
181 __NAKED__ TInt CheckContextWFARDied(TArmRegSet*,TArmRegSet*)
184 CHECK_REGA(iR14,ThreadContextWFAR_return)
185 CHECK_REGA(iR15,ThreadContextWFAR_return - 4)
192 __NAKED__ TInt ThreadContextExecCall(TAny*)
194 asm("stmdb sp!, {r4-r11,lr} ");
195 asm("mov r1, #0x50000000");
197 asm("adr lr, ThreadContextExecCall_return");
198 asm("ldr r0, current_thread_handle ");
199 SLOW_EXEC1(EExecThreadSuspend);
200 asm("ThreadContextExecCall_return:");
202 asm("ldmia sp!, {r4-r11,pc} ");
203 asm("current_thread_handle: ");
204 asm(".word 0xffff8001 ");
207 __NAKED__ TInt CheckContextExecCall(TArmRegSet*,TArmRegSet*)
218 CHECK_REGA(iR14,ThreadContextExecCall_return)
219 CHECK_REGA(iR15,ThreadContextExecCall_return - 4)
225 // Simulate a software exception by invoking first the exec call which
226 // triggers kernel-side handlers and on return panicking the current
230 __NAKED__ TInt ThreadContextSwExc(TAny*)
232 asm("stmdb sp!, {r4-r11,lr} ");
233 asm("mov r1, #0x50000000");
235 asm("adr lr, ThreadContextSwExc_return");
236 asm("ldr r0, current_thread_handle ");
238 SLOW_EXEC3(EExecIsExceptionHandled);
239 asm("ThreadContextSwExc_return:");
240 asm("ldr r0, current_thread_handle ");
241 asm("ldr r3, null_descriptor");
242 asm("mov r1, #%a0 " : : "i" ((TInt)EExitPanic));
244 SLOW_EXEC4(EExecThreadKill);
245 asm("ldmia sp!, {r4-r11,pc} ");
246 asm("null_descriptor:");
247 asm(".word 0x00000000");
248 asm(".word 0x00000000");
251 __NAKED__ TInt CheckContextSwExc(TArmRegSet*,TArmRegSet*)
262 CHECK_REGA(iR14,ThreadContextSwExc_return)
263 CHECK_REGA(iR15,ThreadContextSwExc_return - 4)
268 __NAKED__ TInt CheckContextKernel(TArmRegSet*,TArmRegSet*)
278 // can't test r13 because we don't know how much the irq vector pushes onto the stack
280 // can't really test r15 because pc is somewhere in the irq
281 // vector and we don't export that address
291 __NAKED__ TUint32 SpinInKernel(TBool)
298 // asm("sub r0, sp, #32 "); // IRQ mode pushes 8 extra registers <--- NOT TRUE
301 asm("mov r0, #0xa0000000 ");
302 asm("add r1, r0, #1 ");
303 asm("add r2, r1, #1 ");
304 asm("add r3, r2, #1 ");
305 asm("add r4, r3, #1 ");
306 asm("add r5, r4, #1 ");
307 asm("add r6, r5, #1 ");
308 asm("add r7, r6, #1 ");
309 asm("add r8, r7, #1 ");
310 asm("add r9, r8, #1 ");
311 asm("add r10, r9, #1 ");
312 asm("add r11, r10, #1 ");
313 asm("add r12, r11, #1 ");
314 asm("add r14, r12, #2 ");
315 asm("loopforever: ");
316 asm("b loopforever ");