kernel/eka/nkern/win32/vectors.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1998-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 // e32\nkern\win32\vectors.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "nk_priv.h"
       
    19 
       
    20 inline TInt Invoke(TLinAddr aHandler,const TInt* aArgs)
       
    21 	{return (TExecHandler(aHandler))(aArgs[0],aArgs[1],aArgs[2],aArgs[3]);}
       
    22 
       
    23 /**	Executive dispatcher.
       
    24 	This is hooked by EUSER to handle executive dispatch into the kernel.
       
    25 	aArgs can be treated as an array of 1 to 4 arguments (depending on the exec call).
       
    26 
       
    27 	@internalTechnology
       
    28  */
       
    29 EXPORT_C TInt __fastcall Dispatch(TInt aFunction, TInt* aArgs)
       
    30 	{
       
    31 	NThread& me = *static_cast<NThread*>(TheScheduler.iCurrentThread);
       
    32 	__NK_ASSERT_ALWAYS(!me.iDiverted);
       
    33 	
       
    34 	EnterKernel();
       
    35 
       
    36 	if (aFunction & 0x800000)
       
    37 		{
       
    38 		aFunction &= 0x7fffff;
       
    39 		// fast exec
       
    40 		const SFastExecTable* table = me.iFastExecTable;
       
    41 		if (aFunction == 0)
       
    42 			{
       
    43 			// special case fast exec call
       
    44 			NKern::WaitForAnyRequest();
       
    45 			LeaveKernel();
       
    46 			return 0;
       
    47 			}
       
    48 		if (TUint(aFunction)<TUint(table->iFastExecCount))
       
    49 			{
       
    50 			NKern::Lock();
       
    51 			TInt r = Invoke(table->iFunction[aFunction-1],aArgs);
       
    52 			NKern::Unlock();
       
    53 			LeaveKernel();
       
    54 			return r;
       
    55 			}
       
    56 		// invalid exec number passed, so ensure we invoke the invalid exec
       
    57 		// handler by setting an illegal slow exec number
       
    58 		aFunction = -1;
       
    59 		}
       
    60 
       
    61 	// slow exec
       
    62 
       
    63 	
       
    64 	const SSlowExecTable* table = (const SSlowExecTable*)((const TUint8*)me.iSlowExecTable - _FOFF(SSlowExecTable,iEntries));
       
    65 	if (TUint(aFunction) >= TUint(table->iSlowExecCount))
       
    66 		return Invoke(table->iInvalidExecHandler,aArgs);
       
    67 
       
    68 	const SSlowExecEntry& e = table->iEntries[aFunction];
       
    69 	if (e.iFlags & KExecFlagClaim)
       
    70 		NKern::LockSystem();
       
    71 	if (e.iFlags & KExecFlagPreprocess)
       
    72 		{
       
    73 		// replace the first argument with the result of preprocessing
       
    74 		TPreprocessHandler preprocesser = (TPreprocessHandler)table->iPreprocessHandler;
       
    75 		preprocesser(aArgs, e.iFlags);
       
    76 		}
       
    77 	TInt r = Invoke(e.iFunction,aArgs);
       
    78 	if (e.iFlags & KExecFlagRelease)
       
    79 		NKern::UnlockSystem();
       
    80 	LeaveKernel();
       
    81 	return r;
       
    82 	}