os/kernelhwsrv/kerneltest/e32test/system/t_exc.cia
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/system/t_exc.cia	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,199 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\system\t_exc.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +
    1.22 +#include <e32test.h>
    1.23 +#include <e32svr.h>
    1.24 +#include <u32std.h>
    1.25 +#include <exec_enum.h>
    1.26 +
    1.27 +#if defined(__CPU_ARM)
    1.28 +__NAKED__ void UndefinedInstruction()
    1.29 +	{
    1.30 +	asm("mcr p15, 0, r0, c3, c0 ");
    1.31 +	}
    1.32 +
    1.33 +__NAKED__ TInt ContextThread0(TAny *)
    1.34 +	{
    1.35 +	asm("cmp r0, #0x80000000 ");
    1.36 +	asm("beq 1f ");
    1.37 +	asm("mov r0, #0xa0000000 ");
    1.38 +	asm("msr cpsr_flg, r0 ");
    1.39 +	asm("mov r0, #0x00");
    1.40 +	asm("mov r1, #0x11");
    1.41 +	asm("mov r2, #0x22");
    1.42 +	asm("mov r3, #0x33");
    1.43 +	asm("mov r4, #0x44");
    1.44 +	asm("mov r5, #0x55");
    1.45 +	asm("mov r6, #0x66");
    1.46 +	asm("mov r7, #0x77");
    1.47 +	asm("mov r8, #0x88");
    1.48 +	asm("mov r9, #0x99");
    1.49 +	asm("mov r10, #0xaa");
    1.50 +	asm("mov r11, #0xbb");
    1.51 +	asm("mov r12, #0xcc");
    1.52 +	asm("mov r13, #0xdd");
    1.53 +	asm("mov r14, #0xee");
    1.54 +
    1.55 +	asm("context_thread0_loop: ");
    1.56 +	asm("b context_thread0_loop ");
    1.57 +	asm("1: ");
    1.58 +	asm("adr r0, context_thread0_loop ");
    1.59 +	__JUMP(,lr);
    1.60 +	}
    1.61 +
    1.62 +__NAKED__ TInt ContextThread1(TAny *)
    1.63 +	{
    1.64 +	asm("cmp r0, #0x80000000 ");
    1.65 +	asm("beq 1f ");
    1.66 +	asm("mov r0, #0xa0000000 ");
    1.67 +	asm("msr cpsr_flg, r0 ");
    1.68 +	asm("mov r0, #0x00");
    1.69 +	asm("mov r1, #0x11");
    1.70 +	asm("mov r2, #0x22");
    1.71 +	asm("mov r3, #0x33");
    1.72 +	asm("mov r4, #0x44");
    1.73 +	asm("mov r5, #0x55");
    1.74 +	asm("mov r6, #0x66");
    1.75 +	asm("mov r7, #0x77");
    1.76 +	asm("mov r8, #0x88");
    1.77 +	asm("mov r9, #0x99");
    1.78 +	asm("mov r10, #0xaa");
    1.79 +	asm("mov r11, #0xbb");
    1.80 +	asm("mov r12, #0xcc");
    1.81 +	asm("mov r13, #0xdd");
    1.82 +	asm("mov r14, #0xee");
    1.83 +
    1.84 +	asm("swi 0x800000"); //	WaitForAnyRequest");
    1.85 +
    1.86 +	asm("context_thread1_pc: ");
    1.87 +	asm("b context_thread1_pc ");
    1.88 +	asm("1: ");
    1.89 +	asm("adr r0, context_thread1_pc ");
    1.90 +	__JUMP(,lr);
    1.91 +	}
    1.92 +
    1.93 +__NAKED__ TInt ContextThread2(TAny *)
    1.94 +	{
    1.95 +	asm("cmp r0, #0x80000000 ");
    1.96 +	asm("beq 1f ");
    1.97 +	asm("ldr r0, __current_thread_handle ");
    1.98 +	asm("mov r1, #0xa0000000 ");
    1.99 +	asm("msr cpsr_flg, r1 ");
   1.100 +	asm("mov r1, #0x11");
   1.101 +	asm("mov r2, #0x22");
   1.102 +	asm("mov r3, #0x33");
   1.103 +	asm("mov r4, #0x44");
   1.104 +	asm("mov r5, #0x55");
   1.105 +	asm("mov r6, #0x66");
   1.106 +	asm("mov r7, #0x77");
   1.107 +	asm("mov r8, #0x88");
   1.108 +	asm("mov r9, #0x99");
   1.109 +	asm("mov r10, #0xaa");
   1.110 +	asm("mov r11, #0xbb");
   1.111 +	asm("mov r12, #0xcc");
   1.112 +	asm("mov r13, #0xdd");
   1.113 +	asm("mov r14, #0xee");
   1.114 +
   1.115 +	asm("swi %a0" : : "i" (EExecThreadSuspend)); //	RThread::Suspend");
   1.116 +
   1.117 +	asm("context_thread2_pc: ");
   1.118 +	asm("b context_thread2_pc ");
   1.119 +	asm("1: ");
   1.120 +	asm("adr r0, context_thread2_pc ");
   1.121 +	__JUMP(,lr);
   1.122 +
   1.123 +	asm("__current_thread_handle: ");
   1.124 +	asm(".word 0xffff8001 ");
   1.125 +	}
   1.126 +#endif
   1.127 +
   1.128 +#if defined(__CPU_X86)
   1.129 +__NAKED__ TInt ContextThread0(TAny *)
   1.130 +	{
   1.131 +	asm("mov eax, [esp+4] ");
   1.132 +	asm("cmp eax, 0x80000000 ");
   1.133 +	asm("jz short c0_get_eip_addr ");
   1.134 +	asm("mov eax, 0xaaaaaaaa ");
   1.135 +	asm("mov ebx, 0xbbbbbbbb ");
   1.136 +	asm("mov ecx, 0xcccccccc ");
   1.137 +	asm("mov edx, 0xdddddddd ");
   1.138 +	asm("mov ebp, 0xeb0eb0eb ");
   1.139 +	asm("mov esi, 0xe51e51e5 ");
   1.140 +	asm("mov edi, 0xed1ed1ed ");
   1.141 +	asm("pushfd ");
   1.142 +	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
   1.143 +	asm("popfd ");
   1.144 +	asm("mov esp, 0xe50e50e5 ");
   1.145 +	asm("c0_loop: ");
   1.146 +	asm("jmp short c0_loop ");
   1.147 +	asm("c0_get_eip_addr: ");
   1.148 +	asm("lea eax, c0_loop ");
   1.149 +	asm("ret ");
   1.150 +	}
   1.151 +
   1.152 +__NAKED__ TInt ContextThread1(TAny *)
   1.153 +	{
   1.154 +	asm("mov eax, [esp+4] ");
   1.155 +	asm("cmp eax, 0x80000000 ");
   1.156 +	asm("jz short c1_get_eip_addr ");
   1.157 +	asm("mov eax, 0xaaaaaaaa ");
   1.158 +	asm("mov ebx, 0xbbbbbbbb ");
   1.159 +	asm("mov ecx, 0xcccccccc ");
   1.160 +	asm("mov edx, 0xdddddddd ");
   1.161 +	asm("mov ebp, 0xeb0eb0eb ");
   1.162 +	asm("mov esi, 0xe51e51e5 ");
   1.163 +	asm("mov edi, 0xed1ed1ed ");
   1.164 +	asm("pushfd ");
   1.165 +	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
   1.166 +	asm("popfd ");
   1.167 +	asm("mov esp, 0xe50e50e5 ");
   1.168 +	asm("mov eax, %0" : : "i" (EFastExecWaitForAnyRequest));
   1.169 +	asm("int 0x20 ");
   1.170 +	asm("c1_eip: ");
   1.171 +	asm("c1_get_eip_addr: ");
   1.172 +	asm("lea eax, c1_eip ");
   1.173 +	asm("ret ");
   1.174 +	}
   1.175 +
   1.176 +__NAKED__ TInt ContextThread2(TAny *)
   1.177 +	{
   1.178 +	asm("mov eax, [esp+4] ");
   1.179 +	asm("cmp eax, 0x80000000 ");
   1.180 +	asm("jz short c2_get_eip_addr ");
   1.181 +	asm("mov eax, 0xaaaaaaaa ");
   1.182 +	asm("mov ebx, 0xbbbbbbbb ");
   1.183 +	asm("mov ecx, 0xcccccccc ");
   1.184 +	asm("mov edx, 0xdddddddd ");
   1.185 +	asm("mov ebp, 0xeb0eb0eb ");
   1.186 +	asm("mov esi, 0xe51e51e5 ");
   1.187 +	asm("mov edi, 0xed1ed1ed ");
   1.188 +	asm("pushfd ");
   1.189 +	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
   1.190 +	asm("popfd ");
   1.191 +	asm("mov esp, 0xe50e50e5 ");
   1.192 +	asm("mov eax, %0" : : "i" (EExecThreadSuspend));
   1.193 +	asm("mov ecx, 0xffff8001 ");
   1.194 +	asm("int 0x21 ");
   1.195 +	asm("c2_eip: ");
   1.196 +	asm("c2_get_eip_addr: ");
   1.197 +	asm("lea eax, c2_eip ");
   1.198 +	asm("ret ");
   1.199 +	}
   1.200 +
   1.201 +#endif
   1.202 +