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.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\nkern\win32\vectors.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "nk_priv.h"
sl@0
    19
sl@0
    20
inline TInt Invoke(TLinAddr aHandler,const TInt* aArgs)
sl@0
    21
	{return (TExecHandler(aHandler))(aArgs[0],aArgs[1],aArgs[2],aArgs[3]);}
sl@0
    22
sl@0
    23
/**	Executive dispatcher.
sl@0
    24
	This is hooked by EUSER to handle executive dispatch into the kernel.
sl@0
    25
	aArgs can be treated as an array of 1 to 4 arguments (depending on the exec call).
sl@0
    26
sl@0
    27
	@internalTechnology
sl@0
    28
 */
sl@0
    29
EXPORT_C TInt __fastcall Dispatch(TInt aFunction, TInt* aArgs)
sl@0
    30
	{
sl@0
    31
	NThread& me = *static_cast<NThread*>(TheScheduler.iCurrentThread);
sl@1
    32
	//SL: If you panic here its probably because you forgot to Emulator::Lock() when doing system calls.
sl@1
    33
	//@see: http://www.developer.nokia.com/Community/Wiki/Symbian_OS_Internals/03._Threads,_Processes_and_Libraries#Forced_exit_-_diverting_threads
sl@0
    34
	__NK_ASSERT_ALWAYS(!me.iDiverted);
sl@0
    35
sl@0
    36
	EnterKernel();
sl@0
    37
sl@0
    38
	if (aFunction & 0x800000)
sl@0
    39
		{
sl@0
    40
		aFunction &= 0x7fffff;
sl@0
    41
		// fast exec
sl@0
    42
		const SFastExecTable* table = me.iFastExecTable;
sl@0
    43
		if (aFunction == 0)
sl@0
    44
			{
sl@0
    45
			// special case fast exec call
sl@0
    46
			NKern::WaitForAnyRequest();
sl@0
    47
			LeaveKernel();
sl@0
    48
			return 0;
sl@0
    49
			}
sl@0
    50
		if (TUint(aFunction)<TUint(table->iFastExecCount))
sl@0
    51
			{
sl@0
    52
			NKern::Lock();
sl@0
    53
			TInt r = Invoke(table->iFunction[aFunction-1],aArgs);
sl@0
    54
			NKern::Unlock();
sl@0
    55
			LeaveKernel();
sl@0
    56
			return r;
sl@0
    57
			}
sl@0
    58
		// invalid exec number passed, so ensure we invoke the invalid exec
sl@0
    59
		// handler by setting an illegal slow exec number
sl@0
    60
		aFunction = -1;
sl@0
    61
		}
sl@0
    62
sl@0
    63
	// slow exec
sl@0
    64
sl@0
    65
	
sl@0
    66
	const SSlowExecTable* table = (const SSlowExecTable*)((const TUint8*)me.iSlowExecTable - _FOFF(SSlowExecTable,iEntries));
sl@0
    67
	if (TUint(aFunction) >= TUint(table->iSlowExecCount))
sl@0
    68
		return Invoke(table->iInvalidExecHandler,aArgs);
sl@0
    69
sl@0
    70
	const SSlowExecEntry& e = table->iEntries[aFunction];
sl@0
    71
	if (e.iFlags & KExecFlagClaim)
sl@0
    72
		NKern::LockSystem();
sl@0
    73
	if (e.iFlags & KExecFlagPreprocess)
sl@0
    74
		{
sl@0
    75
		// replace the first argument with the result of preprocessing
sl@0
    76
		TPreprocessHandler preprocesser = (TPreprocessHandler)table->iPreprocessHandler;
sl@0
    77
		preprocesser(aArgs, e.iFlags);
sl@0
    78
		}
sl@0
    79
	TInt r = Invoke(e.iFunction,aArgs);
sl@0
    80
	if (e.iFlags & KExecFlagRelease)
sl@0
    81
		NKern::UnlockSystem();
sl@0
    82
	LeaveKernel();
sl@0
    83
	return r;
sl@0
    84
	}