sl@0: // Copyright (c) 1998-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_xprot.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "execinfo.h" sl@0: #include sl@0: sl@0: const TInt KSupervisorAddress=0x80000000; sl@0: const TInt KGarbageAddress=0xeeddbbcc; sl@0: sl@0: TInt Handles[MAX_HANDLE]; sl@0: TInt DataArea[1024]; sl@0: TBuf8<1024> Buf8; sl@0: TBuf<1024> Buf; sl@0: TPtrC8 PtrC8(Buf8.Ptr(),10); sl@0: TPtrC8 PtrC(Buf.Ptr(),10); sl@0: TPtrC8 Ptr8(Buf8.Ptr(),10,1024); sl@0: TPtrC8 Ptr(Buf.Ptr(),10,1024); sl@0: TPtrC8 Ptr8N(NULL,10,1024); sl@0: TPtrC8 PtrN(NULL,10,1024); sl@0: TPtrC8 Ptr8I((TUint8*)KGarbageAddress,10,1024); sl@0: TPtrC8 PtrI((TText*)KGarbageAddress,10,1024); sl@0: TPtrC8 Ptr8S((TUint8*)KSupervisorAddress,10,1024); sl@0: TPtrC8 PtrS((TText*)KSupervisorAddress,10,1024); sl@0: TInt MessageHandle; sl@0: sl@0: TInt Args[4]; sl@0: sl@0: TInt GetHandle(TInt& aState, TInt aHandleType) sl@0: { sl@0: TInt r; sl@0: TInt t=aHandleType?aHandleType-1:ELibrary; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=0xdeaddead; break; sl@0: case 2: r=Handles[EThread]; break; sl@0: case 3: r=Handles[t]; break; sl@0: case 4: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetAnyInt(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=1; break; sl@0: case 2: r=2; break; sl@0: case 3: r=-1; break; sl@0: case 4: r=299792458; break; sl@0: case 5: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetAnyPtr(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=KSupervisorAddress; break; sl@0: case 3: r=(TInt)DataArea; break; sl@0: case 4: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetIntPtr(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=((TInt)DataArea)+1; break; sl@0: case 3: r=KSupervisorAddress; break; sl@0: case 4: r=(TInt)DataArea; break; sl@0: case 5: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetDes8(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=KSupervisorAddress; break; sl@0: case 3: r=(TInt)&Ptr8N; break; sl@0: case 4: r=(TInt)&Ptr8I; break; sl@0: case 5: r=(TInt)&Ptr8S; break; sl@0: case 6: r=(TInt)&Ptr8; break; sl@0: case 7: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetWDes8(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=KSupervisorAddress; break; sl@0: case 3: r=(TInt)&Ptr8N; break; sl@0: case 4: r=(TInt)&Ptr8I; break; sl@0: case 5: r=(TInt)&Ptr8S; break; sl@0: case 6: r=(TInt)&PtrC8; break; sl@0: case 7: r=(TInt)&Ptr8; break; sl@0: case 8: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetDes(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=KSupervisorAddress; break; sl@0: case 3: r=(TInt)&PtrN; break; sl@0: case 4: r=(TInt)&PtrI; break; sl@0: case 5: r=(TInt)&PtrS; break; sl@0: case 6: r=(TInt)&Ptr; break; sl@0: case 7: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetWDes(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=KSupervisorAddress; break; sl@0: case 3: r=(TInt)&PtrN; break; sl@0: case 4: r=(TInt)&PtrI; break; sl@0: case 5: r=(TInt)&PtrS; break; sl@0: case 6: r=(TInt)&PtrC; break; sl@0: case 7: r=(TInt)&Ptr; break; sl@0: case 8: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetBool(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=1; break; sl@0: case 2: r=299792458; break; sl@0: case 3: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetObjectType(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=EThread; break; sl@0: case 1: r=ELibrary; break; sl@0: case 2: r=ENumObjectType; break; sl@0: case 3: r=20000; break; sl@0: case 4: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetDevUnit(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=1; break; sl@0: case 2: r=20000; break; sl@0: case 3: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetMsgHandle(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=(TInt)DataArea; break; sl@0: case 3: r=KSupervisorAddress; break; sl@0: case 4: r=MessageHandle; break; sl@0: case 5: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetModuleHandle(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=ModuleHandle; break; sl@0: case 3: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetSessionHandlePtr(TInt& aState) sl@0: { sl@0: TInt r; sl@0: switch(aState) sl@0: { sl@0: case 0: r=0; break; sl@0: case 1: r=KGarbageAddress; break; sl@0: case 2: r=KSupervisorAddress; break; sl@0: case 3: r=(TInt)&Handles[ESession]; break; sl@0: case 4: aState=0; return 0; sl@0: } sl@0: ++aState; sl@0: return r; sl@0: } sl@0: sl@0: TInt GetArgument(TInt& aState, TInt aArgType) sl@0: { sl@0: if (aArgType==NO_PAR) sl@0: return 0; sl@0: if (aArgType