os/kernelhwsrv/kerneltest/e32test/misc/int_svr_calls.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 // Do the exec stuff in a cpp file for WINS
    62 #define __GEN_USER_EXEC_CODE__
    63 #include <e32svr.h>
    64 #include <u32exec.h>
    65 
    66 #undef EXPORT_C
    67 #define EXPORT_C __declspec(dllexport)
    68 
    69 // ripped from e32\euser\epoc\x86\uc_exec.cpp
    70 
    71 __NAKED__ TInt Exec::SessionSend(TInt /*aHandle*/, TInt /*aFunction*/, TAny* /*aPtr*/, TRequestStatus* /*aStatus*/)
    72 //
    73 // Send a blind message to the server.
    74 //
    75 	{
    76 	SLOW_EXEC4(EExecSessionSend);
    77 	}
    78 
    79 __NAKED__ TInt Exec::SessionSendSync(TInt /*aHandle*/, TInt /*aFunction*/, TAny* /*aPtr*/, TRequestStatus* /*aStatus*/)
    80 //
    81 // Send a blind message to the server using thread's dedicated message slot.
    82 //
    83 	{
    84 	SLOW_EXEC4(EExecSessionSendSync);
    85 	}
    86 
    87 EXPORT_C TInt SessionCreate(const TDesC8& aName, TInt aMsgSlots, const TSecurityPolicy* aPolicy, TInt aType)
    88 	{
    89 	return Exec::SessionCreate(aName, aMsgSlots, aPolicy, aType);
    90 	}
    91 
    92 EXPORT_C TInt SessionSend(TInt aHandle, TInt aFunction, TAny* aArgs, TRequestStatus* aStatus)
    93 	{
    94 	return Exec::SessionSend(aHandle, aFunction, aArgs, aStatus);
    95 	}
    96 
    97 EXPORT_C TInt SessionSendSync(TInt aHandle, TInt aFunction, TAny* aArgs, TRequestStatus* aStatus)
    98 	{
    99 	return Exec::SessionSendSync(aHandle, aFunction, aArgs, aStatus);
   100 	}
   101 
   102 EXPORT_C void SetSessionPtr(TInt aHandle, const TAny* aPtr)
   103 	{
   104 	Exec::SetSessionPtr(aHandle, aPtr);
   105 	}
   106 #endif //__WINS__