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