First public contribution.
1 // Copyright (c) 1996-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\system\t_exc.cpp
22 #include <exec_enum.h>
24 #if defined(__CPU_ARM)
25 __NAKED__ void UndefinedInstruction()
27 asm("mcr p15, 0, r0, c3, c0 ");
30 __NAKED__ TInt ContextThread0(TAny *)
32 asm("cmp r0, #0x80000000 ");
34 asm("mov r0, #0xa0000000 ");
35 asm("msr cpsr_flg, r0 ");
46 asm("mov r10, #0xaa");
47 asm("mov r11, #0xbb");
48 asm("mov r12, #0xcc");
49 asm("mov r13, #0xdd");
50 asm("mov r14, #0xee");
52 asm("context_thread0_loop: ");
53 asm("b context_thread0_loop ");
55 asm("adr r0, context_thread0_loop ");
59 __NAKED__ TInt ContextThread1(TAny *)
61 asm("cmp r0, #0x80000000 ");
63 asm("mov r0, #0xa0000000 ");
64 asm("msr cpsr_flg, r0 ");
75 asm("mov r10, #0xaa");
76 asm("mov r11, #0xbb");
77 asm("mov r12, #0xcc");
78 asm("mov r13, #0xdd");
79 asm("mov r14, #0xee");
81 asm("swi 0x800000"); // WaitForAnyRequest");
83 asm("context_thread1_pc: ");
84 asm("b context_thread1_pc ");
86 asm("adr r0, context_thread1_pc ");
90 __NAKED__ TInt ContextThread2(TAny *)
92 asm("cmp r0, #0x80000000 ");
94 asm("ldr r0, __current_thread_handle ");
95 asm("mov r1, #0xa0000000 ");
96 asm("msr cpsr_flg, r1 ");
100 asm("mov r4, #0x44");
101 asm("mov r5, #0x55");
102 asm("mov r6, #0x66");
103 asm("mov r7, #0x77");
104 asm("mov r8, #0x88");
105 asm("mov r9, #0x99");
106 asm("mov r10, #0xaa");
107 asm("mov r11, #0xbb");
108 asm("mov r12, #0xcc");
109 asm("mov r13, #0xdd");
110 asm("mov r14, #0xee");
112 asm("swi %a0" : : "i" (EExecThreadSuspend)); // RThread::Suspend");
114 asm("context_thread2_pc: ");
115 asm("b context_thread2_pc ");
117 asm("adr r0, context_thread2_pc ");
120 asm("__current_thread_handle: ");
121 asm(".word 0xffff8001 ");
125 #if defined(__CPU_X86)
126 __NAKED__ TInt ContextThread0(TAny *)
128 asm("mov eax, [esp+4] ");
129 asm("cmp eax, 0x80000000 ");
130 asm("jz short c0_get_eip_addr ");
131 asm("mov eax, 0xaaaaaaaa ");
132 asm("mov ebx, 0xbbbbbbbb ");
133 asm("mov ecx, 0xcccccccc ");
134 asm("mov edx, 0xdddddddd ");
135 asm("mov ebp, 0xeb0eb0eb ");
136 asm("mov esi, 0xe51e51e5 ");
137 asm("mov edi, 0xed1ed1ed ");
139 asm("or dword ptr [esp], 0xcd5 "); // set OF DF SF ZF AF PF CF
141 asm("mov esp, 0xe50e50e5 ");
143 asm("jmp short c0_loop ");
144 asm("c0_get_eip_addr: ");
145 asm("lea eax, c0_loop ");
149 __NAKED__ TInt ContextThread1(TAny *)
151 asm("mov eax, [esp+4] ");
152 asm("cmp eax, 0x80000000 ");
153 asm("jz short c1_get_eip_addr ");
154 asm("mov eax, 0xaaaaaaaa ");
155 asm("mov ebx, 0xbbbbbbbb ");
156 asm("mov ecx, 0xcccccccc ");
157 asm("mov edx, 0xdddddddd ");
158 asm("mov ebp, 0xeb0eb0eb ");
159 asm("mov esi, 0xe51e51e5 ");
160 asm("mov edi, 0xed1ed1ed ");
162 asm("or dword ptr [esp], 0xcd5 "); // set OF DF SF ZF AF PF CF
164 asm("mov esp, 0xe50e50e5 ");
165 asm("mov eax, %0" : : "i" (EFastExecWaitForAnyRequest));
168 asm("c1_get_eip_addr: ");
169 asm("lea eax, c1_eip ");
173 __NAKED__ TInt ContextThread2(TAny *)
175 asm("mov eax, [esp+4] ");
176 asm("cmp eax, 0x80000000 ");
177 asm("jz short c2_get_eip_addr ");
178 asm("mov eax, 0xaaaaaaaa ");
179 asm("mov ebx, 0xbbbbbbbb ");
180 asm("mov ecx, 0xcccccccc ");
181 asm("mov edx, 0xdddddddd ");
182 asm("mov ebp, 0xeb0eb0eb ");
183 asm("mov esi, 0xe51e51e5 ");
184 asm("mov edi, 0xed1ed1ed ");
186 asm("or dword ptr [esp], 0xcd5 "); // set OF DF SF ZF AF PF CF
188 asm("mov esp, 0xe50e50e5 ");
189 asm("mov eax, %0" : : "i" (EExecThreadSuspend));
190 asm("mov ecx, 0xffff8001 ");
193 asm("c2_get_eip_addr: ");
194 asm("lea eax, c2_eip ");