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