os/kernelhwsrv/kernel/eka/nkern/win32/vectors.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
parent 0 bde4ae8d615e
permissions -rw-r--r--
Update contrib.
     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 	//SL: If you panic here its probably because you forgot to Emulator::Lock() when doing system calls.
    33 	//@see: http://www.developer.nokia.com/Community/Wiki/Symbian_OS_Internals/03._Threads,_Processes_and_Libraries#Forced_exit_-_diverting_threads
    34 	__NK_ASSERT_ALWAYS(!me.iDiverted);
    35 
    36 	EnterKernel();
    37 
    38 	if (aFunction & 0x800000)
    39 		{
    40 		aFunction &= 0x7fffff;
    41 		// fast exec
    42 		const SFastExecTable* table = me.iFastExecTable;
    43 		if (aFunction == 0)
    44 			{
    45 			// special case fast exec call
    46 			NKern::WaitForAnyRequest();
    47 			LeaveKernel();
    48 			return 0;
    49 			}
    50 		if (TUint(aFunction)<TUint(table->iFastExecCount))
    51 			{
    52 			NKern::Lock();
    53 			TInt r = Invoke(table->iFunction[aFunction-1],aArgs);
    54 			NKern::Unlock();
    55 			LeaveKernel();
    56 			return r;
    57 			}
    58 		// invalid exec number passed, so ensure we invoke the invalid exec
    59 		// handler by setting an illegal slow exec number
    60 		aFunction = -1;
    61 		}
    62 
    63 	// slow exec
    64 
    65 	
    66 	const SSlowExecTable* table = (const SSlowExecTable*)((const TUint8*)me.iSlowExecTable - _FOFF(SSlowExecTable,iEntries));
    67 	if (TUint(aFunction) >= TUint(table->iSlowExecCount))
    68 		return Invoke(table->iInvalidExecHandler,aArgs);
    69 
    70 	const SSlowExecEntry& e = table->iEntries[aFunction];
    71 	if (e.iFlags & KExecFlagClaim)
    72 		NKern::LockSystem();
    73 	if (e.iFlags & KExecFlagPreprocess)
    74 		{
    75 		// replace the first argument with the result of preprocessing
    76 		TPreprocessHandler preprocesser = (TPreprocessHandler)table->iPreprocessHandler;
    77 		preprocesser(aArgs, e.iFlags);
    78 		}
    79 	TInt r = Invoke(e.iFunction,aArgs);
    80 	if (e.iFlags & KExecFlagRelease)
    81 		NKern::UnlockSystem();
    82 	LeaveKernel();
    83 	return r;
    84 	}