kerneltest/e32test/misc/int_svr_calls.cpp
changeset 0 a41df078684a
child 15 4122176ea935
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2005-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\misc\int_svr_calls.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32def.h>
       
    19 #include <e32def_private.h>
       
    20 #include <e32cmn.h>
       
    21 #include <e32cmn_private.h>
       
    22 #undef EXPORT_C
       
    23 #define EXPORT_C
       
    24 #undef IMPORT_C
       
    25 #define IMPORT_C
       
    26 #include <e32std.h>
       
    27 #include <e32std_private.h>
       
    28 
       
    29 #ifdef __WINS__
       
    30 // NB: The following is a straight rip from the win32 uc_exec.cpp
       
    31 #include <emulator.h>
       
    32 
       
    33 typedef TInt (__fastcall *TDispatcher)(TInt, TInt*);
       
    34 TInt __fastcall LazyDispatch(TInt aFunction, TInt* aArgs);
       
    35 
       
    36 #pragma data_seg(".data2")
       
    37 #ifdef __VC32__
       
    38 #pragma bss_seg(".data2")
       
    39 #endif
       
    40 static TDispatcher TheDispatcher = &LazyDispatch;
       
    41 #pragma data_seg()
       
    42 #ifdef __VC32__
       
    43 #pragma bss_seg()
       
    44 #endif
       
    45 
       
    46 TInt __fastcall LazyDispatch(TInt aFunction, TInt* aArgs)
       
    47 	{
       
    48 	HINSTANCE kernel = GetModuleHandleA("ekern.exe");
       
    49 	if (kernel)
       
    50 		{
       
    51 		TDispatcher dispatcher = (TDispatcher)Emulator::GetProcAddress(kernel, (LPCSTR)1);
       
    52 		if (dispatcher)
       
    53 			{
       
    54 			TheDispatcher = dispatcher;
       
    55 			return dispatcher(aFunction, aArgs);
       
    56 			}
       
    57 		}
       
    58 	return 0;
       
    59 	}
       
    60 
       
    61 #endif //__WINS__
       
    62 
       
    63 #ifndef __MARM__
       
    64 // Do the exec stuff in a cpp file for WINS/X86
       
    65 #define __GEN_USER_EXEC_CODE__
       
    66 #include <e32svr.h>
       
    67 #include <u32exec.h>
       
    68 
       
    69 #undef EXPORT_C
       
    70 #define EXPORT_C __declspec(dllexport)
       
    71 
       
    72 // ripped from e32\euser\epoc\x86\uc_exec.cpp
       
    73 
       
    74 __NAKED__ TInt Exec::SessionSend(TInt /*aHandle*/, TInt /*aFunction*/, TAny* /*aPtr*/, TRequestStatus* /*aStatus*/)
       
    75 //
       
    76 // Send a blind message to the server.
       
    77 //
       
    78 	{
       
    79 	SLOW_EXEC4(EExecSessionSend);
       
    80 	}
       
    81 
       
    82 __NAKED__ TInt Exec::SessionSendSync(TInt /*aHandle*/, TInt /*aFunction*/, TAny* /*aPtr*/, TRequestStatus* /*aStatus*/)
       
    83 //
       
    84 // Send a blind message to the server using thread's dedicated message slot.
       
    85 //
       
    86 	{
       
    87 	SLOW_EXEC4(EExecSessionSendSync);
       
    88 	}
       
    89 
       
    90 EXPORT_C TInt SessionCreate(const TDesC8& aName, TInt aMsgSlots, const TSecurityPolicy* aPolicy, TInt aType)
       
    91 	{
       
    92 	return Exec::SessionCreate(aName, aMsgSlots, aPolicy, aType);
       
    93 	}
       
    94 
       
    95 EXPORT_C TInt SessionSend(TInt aHandle, TInt aFunction, TAny* aArgs, TRequestStatus* aStatus)
       
    96 	{
       
    97 	return Exec::SessionSend(aHandle, aFunction, aArgs, aStatus);
       
    98 	}
       
    99 
       
   100 EXPORT_C TInt SessionSendSync(TInt aHandle, TInt aFunction, TAny* aArgs, TRequestStatus* aStatus)
       
   101 	{
       
   102 	return Exec::SessionSendSync(aHandle, aFunction, aArgs, aStatus);
       
   103 	}
       
   104 
       
   105 EXPORT_C void SetSessionPtr(TInt aHandle, const TAny* aPtr)
       
   106 	{
       
   107 	Exec::SetSessionPtr(aHandle, aPtr);
       
   108 	}
       
   109 #endif //!__MARM__