kerneltest/e32test/system/t_exc.cia
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\system\t_exc.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 #include <e32test.h>
       
    20 #include <e32svr.h>
       
    21 #include <u32std.h>
       
    22 #include <exec_enum.h>
       
    23 
       
    24 #if defined(__CPU_ARM)
       
    25 __NAKED__ void UndefinedInstruction()
       
    26 	{
       
    27 	asm("mcr p15, 0, r0, c3, c0 ");
       
    28 	}
       
    29 
       
    30 __NAKED__ TInt ContextThread0(TAny *)
       
    31 	{
       
    32 	asm("cmp r0, #0x80000000 ");
       
    33 	asm("beq 1f ");
       
    34 	asm("mov r0, #0xa0000000 ");
       
    35 	asm("msr cpsr_flg, r0 ");
       
    36 	asm("mov r0, #0x00");
       
    37 	asm("mov r1, #0x11");
       
    38 	asm("mov r2, #0x22");
       
    39 	asm("mov r3, #0x33");
       
    40 	asm("mov r4, #0x44");
       
    41 	asm("mov r5, #0x55");
       
    42 	asm("mov r6, #0x66");
       
    43 	asm("mov r7, #0x77");
       
    44 	asm("mov r8, #0x88");
       
    45 	asm("mov r9, #0x99");
       
    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");
       
    51 
       
    52 	asm("context_thread0_loop: ");
       
    53 	asm("b context_thread0_loop ");
       
    54 	asm("1: ");
       
    55 	asm("adr r0, context_thread0_loop ");
       
    56 	__JUMP(,lr);
       
    57 	}
       
    58 
       
    59 __NAKED__ TInt ContextThread1(TAny *)
       
    60 	{
       
    61 	asm("cmp r0, #0x80000000 ");
       
    62 	asm("beq 1f ");
       
    63 	asm("mov r0, #0xa0000000 ");
       
    64 	asm("msr cpsr_flg, r0 ");
       
    65 	asm("mov r0, #0x00");
       
    66 	asm("mov r1, #0x11");
       
    67 	asm("mov r2, #0x22");
       
    68 	asm("mov r3, #0x33");
       
    69 	asm("mov r4, #0x44");
       
    70 	asm("mov r5, #0x55");
       
    71 	asm("mov r6, #0x66");
       
    72 	asm("mov r7, #0x77");
       
    73 	asm("mov r8, #0x88");
       
    74 	asm("mov r9, #0x99");
       
    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");
       
    80 
       
    81 	asm("swi 0x800000"); //	WaitForAnyRequest");
       
    82 
       
    83 	asm("context_thread1_pc: ");
       
    84 	asm("b context_thread1_pc ");
       
    85 	asm("1: ");
       
    86 	asm("adr r0, context_thread1_pc ");
       
    87 	__JUMP(,lr);
       
    88 	}
       
    89 
       
    90 __NAKED__ TInt ContextThread2(TAny *)
       
    91 	{
       
    92 	asm("cmp r0, #0x80000000 ");
       
    93 	asm("beq 1f ");
       
    94 	asm("ldr r0, __current_thread_handle ");
       
    95 	asm("mov r1, #0xa0000000 ");
       
    96 	asm("msr cpsr_flg, r1 ");
       
    97 	asm("mov r1, #0x11");
       
    98 	asm("mov r2, #0x22");
       
    99 	asm("mov r3, #0x33");
       
   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");
       
   111 
       
   112 	asm("swi %a0" : : "i" (EExecThreadSuspend)); //	RThread::Suspend");
       
   113 
       
   114 	asm("context_thread2_pc: ");
       
   115 	asm("b context_thread2_pc ");
       
   116 	asm("1: ");
       
   117 	asm("adr r0, context_thread2_pc ");
       
   118 	__JUMP(,lr);
       
   119 
       
   120 	asm("__current_thread_handle: ");
       
   121 	asm(".word 0xffff8001 ");
       
   122 	}
       
   123 #endif
       
   124 
       
   125 #if defined(__CPU_X86)
       
   126 __NAKED__ TInt ContextThread0(TAny *)
       
   127 	{
       
   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 ");
       
   138 	asm("pushfd ");
       
   139 	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
       
   140 	asm("popfd ");
       
   141 	asm("mov esp, 0xe50e50e5 ");
       
   142 	asm("c0_loop: ");
       
   143 	asm("jmp short c0_loop ");
       
   144 	asm("c0_get_eip_addr: ");
       
   145 	asm("lea eax, c0_loop ");
       
   146 	asm("ret ");
       
   147 	}
       
   148 
       
   149 __NAKED__ TInt ContextThread1(TAny *)
       
   150 	{
       
   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 ");
       
   161 	asm("pushfd ");
       
   162 	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
       
   163 	asm("popfd ");
       
   164 	asm("mov esp, 0xe50e50e5 ");
       
   165 	asm("mov eax, %0" : : "i" (EFastExecWaitForAnyRequest));
       
   166 	asm("int 0x20 ");
       
   167 	asm("c1_eip: ");
       
   168 	asm("c1_get_eip_addr: ");
       
   169 	asm("lea eax, c1_eip ");
       
   170 	asm("ret ");
       
   171 	}
       
   172 
       
   173 __NAKED__ TInt ContextThread2(TAny *)
       
   174 	{
       
   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 ");
       
   185 	asm("pushfd ");
       
   186 	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
       
   187 	asm("popfd ");
       
   188 	asm("mov esp, 0xe50e50e5 ");
       
   189 	asm("mov eax, %0" : : "i" (EExecThreadSuspend));
       
   190 	asm("mov ecx, 0xffff8001 ");
       
   191 	asm("int 0x21 ");
       
   192 	asm("c2_eip: ");
       
   193 	asm("c2_get_eip_addr: ");
       
   194 	asm("lea eax, c2_eip ");
       
   195 	asm("ret ");
       
   196 	}
       
   197 
       
   198 #endif
       
   199