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@0
|
32 |
//SL: Can't figure out why this fails at times
|
sl@0
|
33 |
__NK_ASSERT_ALWAYS(!me.iDiverted);
|
sl@0
|
34 |
|
sl@0
|
35 |
/*
|
sl@0
|
36 |
if (me.iDiverted)
|
sl@0
|
37 |
{
|
sl@0
|
38 |
__KTRACE_OPT(KSCHED,DEBUGPRINT("WARNING: not diverted!"));
|
sl@0
|
39 |
}
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
|
sl@0
|
42 |
EnterKernel();
|
sl@0
|
43 |
|
sl@0
|
44 |
if (aFunction & 0x800000)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
aFunction &= 0x7fffff;
|
sl@0
|
47 |
// fast exec
|
sl@0
|
48 |
const SFastExecTable* table = me.iFastExecTable;
|
sl@0
|
49 |
if (aFunction == 0)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
// special case fast exec call
|
sl@0
|
52 |
NKern::WaitForAnyRequest();
|
sl@0
|
53 |
LeaveKernel();
|
sl@0
|
54 |
return 0;
|
sl@0
|
55 |
}
|
sl@0
|
56 |
if (TUint(aFunction)<TUint(table->iFastExecCount))
|
sl@0
|
57 |
{
|
sl@0
|
58 |
NKern::Lock();
|
sl@0
|
59 |
TInt r = Invoke(table->iFunction[aFunction-1],aArgs);
|
sl@0
|
60 |
NKern::Unlock();
|
sl@0
|
61 |
LeaveKernel();
|
sl@0
|
62 |
return r;
|
sl@0
|
63 |
}
|
sl@0
|
64 |
// invalid exec number passed, so ensure we invoke the invalid exec
|
sl@0
|
65 |
// handler by setting an illegal slow exec number
|
sl@0
|
66 |
aFunction = -1;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
// slow exec
|
sl@0
|
70 |
|
sl@0
|
71 |
|
sl@0
|
72 |
const SSlowExecTable* table = (const SSlowExecTable*)((const TUint8*)me.iSlowExecTable - _FOFF(SSlowExecTable,iEntries));
|
sl@0
|
73 |
if (TUint(aFunction) >= TUint(table->iSlowExecCount))
|
sl@0
|
74 |
return Invoke(table->iInvalidExecHandler,aArgs);
|
sl@0
|
75 |
|
sl@0
|
76 |
const SSlowExecEntry& e = table->iEntries[aFunction];
|
sl@0
|
77 |
if (e.iFlags & KExecFlagClaim)
|
sl@0
|
78 |
NKern::LockSystem();
|
sl@0
|
79 |
if (e.iFlags & KExecFlagPreprocess)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
// replace the first argument with the result of preprocessing
|
sl@0
|
82 |
TPreprocessHandler preprocesser = (TPreprocessHandler)table->iPreprocessHandler;
|
sl@0
|
83 |
preprocesser(aArgs, e.iFlags);
|
sl@0
|
84 |
}
|
sl@0
|
85 |
TInt r = Invoke(e.iFunction,aArgs);
|
sl@0
|
86 |
if (e.iFlags & KExecFlagRelease)
|
sl@0
|
87 |
NKern::UnlockSystem();
|
sl@0
|
88 |
LeaveKernel();
|
sl@0
|
89 |
return r;
|
sl@0
|
90 |
}
|