sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\system\t_exc.cpp sl@0: // sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #if defined(__CPU_ARM) sl@0: __NAKED__ void UndefinedInstruction() sl@0: { sl@0: asm("mcr p15, 0, r0, c3, c0 "); sl@0: } sl@0: sl@0: __NAKED__ TInt ContextThread0(TAny *) sl@0: { sl@0: asm("cmp r0, #0x80000000 "); sl@0: asm("beq 1f "); sl@0: asm("mov r0, #0xa0000000 "); sl@0: asm("msr cpsr_flg, r0 "); sl@0: asm("mov r0, #0x00"); sl@0: asm("mov r1, #0x11"); sl@0: asm("mov r2, #0x22"); sl@0: asm("mov r3, #0x33"); sl@0: asm("mov r4, #0x44"); sl@0: asm("mov r5, #0x55"); sl@0: asm("mov r6, #0x66"); sl@0: asm("mov r7, #0x77"); sl@0: asm("mov r8, #0x88"); sl@0: asm("mov r9, #0x99"); sl@0: asm("mov r10, #0xaa"); sl@0: asm("mov r11, #0xbb"); sl@0: asm("mov r12, #0xcc"); sl@0: asm("mov r13, #0xdd"); sl@0: asm("mov r14, #0xee"); sl@0: sl@0: asm("context_thread0_loop: "); sl@0: asm("b context_thread0_loop "); sl@0: asm("1: "); sl@0: asm("adr r0, context_thread0_loop "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ TInt ContextThread1(TAny *) sl@0: { sl@0: asm("cmp r0, #0x80000000 "); sl@0: asm("beq 1f "); sl@0: asm("mov r0, #0xa0000000 "); sl@0: asm("msr cpsr_flg, r0 "); sl@0: asm("mov r0, #0x00"); sl@0: asm("mov r1, #0x11"); sl@0: asm("mov r2, #0x22"); sl@0: asm("mov r3, #0x33"); sl@0: asm("mov r4, #0x44"); sl@0: asm("mov r5, #0x55"); sl@0: asm("mov r6, #0x66"); sl@0: asm("mov r7, #0x77"); sl@0: asm("mov r8, #0x88"); sl@0: asm("mov r9, #0x99"); sl@0: asm("mov r10, #0xaa"); sl@0: asm("mov r11, #0xbb"); sl@0: asm("mov r12, #0xcc"); sl@0: asm("mov r13, #0xdd"); sl@0: asm("mov r14, #0xee"); sl@0: sl@0: asm("swi 0x800000"); // WaitForAnyRequest"); sl@0: sl@0: asm("context_thread1_pc: "); sl@0: asm("b context_thread1_pc "); sl@0: asm("1: "); sl@0: asm("adr r0, context_thread1_pc "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ TInt ContextThread2(TAny *) sl@0: { sl@0: asm("cmp r0, #0x80000000 "); sl@0: asm("beq 1f "); sl@0: asm("ldr r0, __current_thread_handle "); sl@0: asm("mov r1, #0xa0000000 "); sl@0: asm("msr cpsr_flg, r1 "); sl@0: asm("mov r1, #0x11"); sl@0: asm("mov r2, #0x22"); sl@0: asm("mov r3, #0x33"); sl@0: asm("mov r4, #0x44"); sl@0: asm("mov r5, #0x55"); sl@0: asm("mov r6, #0x66"); sl@0: asm("mov r7, #0x77"); sl@0: asm("mov r8, #0x88"); sl@0: asm("mov r9, #0x99"); sl@0: asm("mov r10, #0xaa"); sl@0: asm("mov r11, #0xbb"); sl@0: asm("mov r12, #0xcc"); sl@0: asm("mov r13, #0xdd"); sl@0: asm("mov r14, #0xee"); sl@0: sl@0: asm("swi %a0" : : "i" (EExecThreadSuspend)); // RThread::Suspend"); sl@0: sl@0: asm("context_thread2_pc: "); sl@0: asm("b context_thread2_pc "); sl@0: asm("1: "); sl@0: asm("adr r0, context_thread2_pc "); sl@0: __JUMP(,lr); sl@0: sl@0: asm("__current_thread_handle: "); sl@0: asm(".word 0xffff8001 "); sl@0: } sl@0: #endif sl@0: sl@0: #if defined(__CPU_X86) sl@0: __NAKED__ TInt ContextThread0(TAny *) sl@0: { sl@0: asm("mov eax, [esp+4] "); sl@0: asm("cmp eax, 0x80000000 "); sl@0: asm("jz short c0_get_eip_addr "); sl@0: asm("mov eax, 0xaaaaaaaa "); sl@0: asm("mov ebx, 0xbbbbbbbb "); sl@0: asm("mov ecx, 0xcccccccc "); sl@0: asm("mov edx, 0xdddddddd "); sl@0: asm("mov ebp, 0xeb0eb0eb "); sl@0: asm("mov esi, 0xe51e51e5 "); sl@0: asm("mov edi, 0xed1ed1ed "); sl@0: asm("pushfd "); sl@0: asm("or dword ptr [esp], 0xcd5 "); // set OF DF SF ZF AF PF CF sl@0: asm("popfd "); sl@0: asm("mov esp, 0xe50e50e5 "); sl@0: asm("c0_loop: "); sl@0: asm("jmp short c0_loop "); sl@0: asm("c0_get_eip_addr: "); sl@0: asm("lea eax, c0_loop "); sl@0: asm("ret "); sl@0: } sl@0: sl@0: __NAKED__ TInt ContextThread1(TAny *) sl@0: { sl@0: asm("mov eax, [esp+4] "); sl@0: asm("cmp eax, 0x80000000 "); sl@0: asm("jz short c1_get_eip_addr "); sl@0: asm("mov eax, 0xaaaaaaaa "); sl@0: asm("mov ebx, 0xbbbbbbbb "); sl@0: asm("mov ecx, 0xcccccccc "); sl@0: asm("mov edx, 0xdddddddd "); sl@0: asm("mov ebp, 0xeb0eb0eb "); sl@0: asm("mov esi, 0xe51e51e5 "); sl@0: asm("mov edi, 0xed1ed1ed "); sl@0: asm("pushfd "); sl@0: asm("or dword ptr [esp], 0xcd5 "); // set OF DF SF ZF AF PF CF sl@0: asm("popfd "); sl@0: asm("mov esp, 0xe50e50e5 "); sl@0: asm("mov eax, %0" : : "i" (EFastExecWaitForAnyRequest)); sl@0: asm("int 0x20 "); sl@0: asm("c1_eip: "); sl@0: asm("c1_get_eip_addr: "); sl@0: asm("lea eax, c1_eip "); sl@0: asm("ret "); sl@0: } sl@0: sl@0: __NAKED__ TInt ContextThread2(TAny *) sl@0: { sl@0: asm("mov eax, [esp+4] "); sl@0: asm("cmp eax, 0x80000000 "); sl@0: asm("jz short c2_get_eip_addr "); sl@0: asm("mov eax, 0xaaaaaaaa "); sl@0: asm("mov ebx, 0xbbbbbbbb "); sl@0: asm("mov ecx, 0xcccccccc "); sl@0: asm("mov edx, 0xdddddddd "); sl@0: asm("mov ebp, 0xeb0eb0eb "); sl@0: asm("mov esi, 0xe51e51e5 "); sl@0: asm("mov edi, 0xed1ed1ed "); sl@0: asm("pushfd "); sl@0: asm("or dword ptr [esp], 0xcd5 "); // set OF DF SF ZF AF PF CF sl@0: asm("popfd "); sl@0: asm("mov esp, 0xe50e50e5 "); sl@0: asm("mov eax, %0" : : "i" (EExecThreadSuspend)); sl@0: asm("mov ecx, 0xffff8001 "); sl@0: asm("int 0x21 "); sl@0: asm("c2_eip: "); sl@0: asm("c2_get_eip_addr: "); sl@0: asm("lea eax, c2_eip "); sl@0: asm("ret "); sl@0: } sl@0: sl@0: #endif sl@0: