os/kernelhwsrv/kerneltest/e32test/system/t_exc.cia
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\system\t_exc.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
sl@0
    19
#include <e32test.h>
sl@0
    20
#include <e32svr.h>
sl@0
    21
#include <u32std.h>
sl@0
    22
#include <exec_enum.h>
sl@0
    23
sl@0
    24
#if defined(__CPU_ARM)
sl@0
    25
__NAKED__ void UndefinedInstruction()
sl@0
    26
	{
sl@0
    27
	asm("mcr p15, 0, r0, c3, c0 ");
sl@0
    28
	}
sl@0
    29
sl@0
    30
__NAKED__ TInt ContextThread0(TAny *)
sl@0
    31
	{
sl@0
    32
	asm("cmp r0, #0x80000000 ");
sl@0
    33
	asm("beq 1f ");
sl@0
    34
	asm("mov r0, #0xa0000000 ");
sl@0
    35
	asm("msr cpsr_flg, r0 ");
sl@0
    36
	asm("mov r0, #0x00");
sl@0
    37
	asm("mov r1, #0x11");
sl@0
    38
	asm("mov r2, #0x22");
sl@0
    39
	asm("mov r3, #0x33");
sl@0
    40
	asm("mov r4, #0x44");
sl@0
    41
	asm("mov r5, #0x55");
sl@0
    42
	asm("mov r6, #0x66");
sl@0
    43
	asm("mov r7, #0x77");
sl@0
    44
	asm("mov r8, #0x88");
sl@0
    45
	asm("mov r9, #0x99");
sl@0
    46
	asm("mov r10, #0xaa");
sl@0
    47
	asm("mov r11, #0xbb");
sl@0
    48
	asm("mov r12, #0xcc");
sl@0
    49
	asm("mov r13, #0xdd");
sl@0
    50
	asm("mov r14, #0xee");
sl@0
    51
sl@0
    52
	asm("context_thread0_loop: ");
sl@0
    53
	asm("b context_thread0_loop ");
sl@0
    54
	asm("1: ");
sl@0
    55
	asm("adr r0, context_thread0_loop ");
sl@0
    56
	__JUMP(,lr);
sl@0
    57
	}
sl@0
    58
sl@0
    59
__NAKED__ TInt ContextThread1(TAny *)
sl@0
    60
	{
sl@0
    61
	asm("cmp r0, #0x80000000 ");
sl@0
    62
	asm("beq 1f ");
sl@0
    63
	asm("mov r0, #0xa0000000 ");
sl@0
    64
	asm("msr cpsr_flg, r0 ");
sl@0
    65
	asm("mov r0, #0x00");
sl@0
    66
	asm("mov r1, #0x11");
sl@0
    67
	asm("mov r2, #0x22");
sl@0
    68
	asm("mov r3, #0x33");
sl@0
    69
	asm("mov r4, #0x44");
sl@0
    70
	asm("mov r5, #0x55");
sl@0
    71
	asm("mov r6, #0x66");
sl@0
    72
	asm("mov r7, #0x77");
sl@0
    73
	asm("mov r8, #0x88");
sl@0
    74
	asm("mov r9, #0x99");
sl@0
    75
	asm("mov r10, #0xaa");
sl@0
    76
	asm("mov r11, #0xbb");
sl@0
    77
	asm("mov r12, #0xcc");
sl@0
    78
	asm("mov r13, #0xdd");
sl@0
    79
	asm("mov r14, #0xee");
sl@0
    80
sl@0
    81
	asm("swi 0x800000"); //	WaitForAnyRequest");
sl@0
    82
sl@0
    83
	asm("context_thread1_pc: ");
sl@0
    84
	asm("b context_thread1_pc ");
sl@0
    85
	asm("1: ");
sl@0
    86
	asm("adr r0, context_thread1_pc ");
sl@0
    87
	__JUMP(,lr);
sl@0
    88
	}
sl@0
    89
sl@0
    90
__NAKED__ TInt ContextThread2(TAny *)
sl@0
    91
	{
sl@0
    92
	asm("cmp r0, #0x80000000 ");
sl@0
    93
	asm("beq 1f ");
sl@0
    94
	asm("ldr r0, __current_thread_handle ");
sl@0
    95
	asm("mov r1, #0xa0000000 ");
sl@0
    96
	asm("msr cpsr_flg, r1 ");
sl@0
    97
	asm("mov r1, #0x11");
sl@0
    98
	asm("mov r2, #0x22");
sl@0
    99
	asm("mov r3, #0x33");
sl@0
   100
	asm("mov r4, #0x44");
sl@0
   101
	asm("mov r5, #0x55");
sl@0
   102
	asm("mov r6, #0x66");
sl@0
   103
	asm("mov r7, #0x77");
sl@0
   104
	asm("mov r8, #0x88");
sl@0
   105
	asm("mov r9, #0x99");
sl@0
   106
	asm("mov r10, #0xaa");
sl@0
   107
	asm("mov r11, #0xbb");
sl@0
   108
	asm("mov r12, #0xcc");
sl@0
   109
	asm("mov r13, #0xdd");
sl@0
   110
	asm("mov r14, #0xee");
sl@0
   111
sl@0
   112
	asm("swi %a0" : : "i" (EExecThreadSuspend)); //	RThread::Suspend");
sl@0
   113
sl@0
   114
	asm("context_thread2_pc: ");
sl@0
   115
	asm("b context_thread2_pc ");
sl@0
   116
	asm("1: ");
sl@0
   117
	asm("adr r0, context_thread2_pc ");
sl@0
   118
	__JUMP(,lr);
sl@0
   119
sl@0
   120
	asm("__current_thread_handle: ");
sl@0
   121
	asm(".word 0xffff8001 ");
sl@0
   122
	}
sl@0
   123
#endif
sl@0
   124
sl@0
   125
#if defined(__CPU_X86)
sl@0
   126
__NAKED__ TInt ContextThread0(TAny *)
sl@0
   127
	{
sl@0
   128
	asm("mov eax, [esp+4] ");
sl@0
   129
	asm("cmp eax, 0x80000000 ");
sl@0
   130
	asm("jz short c0_get_eip_addr ");
sl@0
   131
	asm("mov eax, 0xaaaaaaaa ");
sl@0
   132
	asm("mov ebx, 0xbbbbbbbb ");
sl@0
   133
	asm("mov ecx, 0xcccccccc ");
sl@0
   134
	asm("mov edx, 0xdddddddd ");
sl@0
   135
	asm("mov ebp, 0xeb0eb0eb ");
sl@0
   136
	asm("mov esi, 0xe51e51e5 ");
sl@0
   137
	asm("mov edi, 0xed1ed1ed ");
sl@0
   138
	asm("pushfd ");
sl@0
   139
	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
sl@0
   140
	asm("popfd ");
sl@0
   141
	asm("mov esp, 0xe50e50e5 ");
sl@0
   142
	asm("c0_loop: ");
sl@0
   143
	asm("jmp short c0_loop ");
sl@0
   144
	asm("c0_get_eip_addr: ");
sl@0
   145
	asm("lea eax, c0_loop ");
sl@0
   146
	asm("ret ");
sl@0
   147
	}
sl@0
   148
sl@0
   149
__NAKED__ TInt ContextThread1(TAny *)
sl@0
   150
	{
sl@0
   151
	asm("mov eax, [esp+4] ");
sl@0
   152
	asm("cmp eax, 0x80000000 ");
sl@0
   153
	asm("jz short c1_get_eip_addr ");
sl@0
   154
	asm("mov eax, 0xaaaaaaaa ");
sl@0
   155
	asm("mov ebx, 0xbbbbbbbb ");
sl@0
   156
	asm("mov ecx, 0xcccccccc ");
sl@0
   157
	asm("mov edx, 0xdddddddd ");
sl@0
   158
	asm("mov ebp, 0xeb0eb0eb ");
sl@0
   159
	asm("mov esi, 0xe51e51e5 ");
sl@0
   160
	asm("mov edi, 0xed1ed1ed ");
sl@0
   161
	asm("pushfd ");
sl@0
   162
	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
sl@0
   163
	asm("popfd ");
sl@0
   164
	asm("mov esp, 0xe50e50e5 ");
sl@0
   165
	asm("mov eax, %0" : : "i" (EFastExecWaitForAnyRequest));
sl@0
   166
	asm("int 0x20 ");
sl@0
   167
	asm("c1_eip: ");
sl@0
   168
	asm("c1_get_eip_addr: ");
sl@0
   169
	asm("lea eax, c1_eip ");
sl@0
   170
	asm("ret ");
sl@0
   171
	}
sl@0
   172
sl@0
   173
__NAKED__ TInt ContextThread2(TAny *)
sl@0
   174
	{
sl@0
   175
	asm("mov eax, [esp+4] ");
sl@0
   176
	asm("cmp eax, 0x80000000 ");
sl@0
   177
	asm("jz short c2_get_eip_addr ");
sl@0
   178
	asm("mov eax, 0xaaaaaaaa ");
sl@0
   179
	asm("mov ebx, 0xbbbbbbbb ");
sl@0
   180
	asm("mov ecx, 0xcccccccc ");
sl@0
   181
	asm("mov edx, 0xdddddddd ");
sl@0
   182
	asm("mov ebp, 0xeb0eb0eb ");
sl@0
   183
	asm("mov esi, 0xe51e51e5 ");
sl@0
   184
	asm("mov edi, 0xed1ed1ed ");
sl@0
   185
	asm("pushfd ");
sl@0
   186
	asm("or dword ptr [esp], 0xcd5 ");	// set OF DF SF ZF AF PF CF
sl@0
   187
	asm("popfd ");
sl@0
   188
	asm("mov esp, 0xe50e50e5 ");
sl@0
   189
	asm("mov eax, %0" : : "i" (EExecThreadSuspend));
sl@0
   190
	asm("mov ecx, 0xffff8001 ");
sl@0
   191
	asm("int 0x21 ");
sl@0
   192
	asm("c2_eip: ");
sl@0
   193
	asm("c2_get_eip_addr: ");
sl@0
   194
	asm("lea eax, c2_eip ");
sl@0
   195
	asm("ret ");
sl@0
   196
	}
sl@0
   197
sl@0
   198
#endif
sl@0
   199