0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "isiif.h" // For DISIIf
|
|
20 |
#include "isiroutertrace.h" // For C_TRACE, ASSERT_RESET.. and fault codes
|
|
21 |
#include "isikernelchannel.h" // For DISIKernelChannel
|
|
22 |
#include <dfcs.h> // For TDfc
|
|
23 |
#include <kern_priv.h> // For __ASSERT_CRITICAL
|
|
24 |
|
|
25 |
|
|
26 |
// Constants
|
|
27 |
const TInt KFirstParam( 0 );
|
|
28 |
const TInt KSecondParam( 1 );
|
|
29 |
const TInt KThirdParam( 2 );
|
|
30 |
const TInt KOneParam( 2 );
|
|
31 |
const TInt KTwoParams( 2 );
|
|
32 |
const TInt KThreeParams( 3 );
|
|
33 |
|
|
34 |
|
|
35 |
// Faults
|
|
36 |
enum TISIIfFaults
|
|
37 |
{
|
|
38 |
EISIIfMemAllocFailure = 0x01,
|
|
39 |
EISIIfMemAllocFailure2,
|
|
40 |
EISIIfNotThreadContext,
|
|
41 |
EISIIfNotThreadContext2,
|
|
42 |
EISIIfNotNullPtr,
|
|
43 |
EISIIfWrongResponseToRequest,
|
|
44 |
EISIIfWrongResponseToRequest2,
|
|
45 |
EISIIfWrongResponseToRequest3,
|
|
46 |
EISIIfWrongResponseToRequest4,
|
|
47 |
EISIIfWrongResponseToRequest5,
|
|
48 |
EISIIfWrongResponseToRequest6,
|
|
49 |
};
|
|
50 |
|
|
51 |
|
|
52 |
EXPORT_C MISIIf* MISIIf::NewISIIf( const TInt32 aUID, TUint8& aObjId )
|
|
53 |
{
|
|
54 |
return DISIIf::NewF( aUID, aObjId );
|
|
55 |
}
|
|
56 |
|
|
57 |
DISIIf* DISIIf::NewF( const TInt32 aUID, TUint8& aObjId )
|
|
58 |
{
|
|
59 |
C_TRACE((_T("DISIIf::NewF>") ));
|
|
60 |
DISIIf* tmp = new DISIIf( aUID, aObjId );
|
|
61 |
ASSERT_RESET_ALWAYS( tmp, ( EISIIfMemAllocFailure | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
62 |
C_TRACE((_T("DISIIf::NewF 0x%x<"), tmp ));
|
|
63 |
return tmp;
|
|
64 |
}
|
|
65 |
|
|
66 |
DISIIf::DISIIf( const TInt32 aUID, TUint8& aObjId )
|
|
67 |
{
|
|
68 |
C_TRACE( ( _T( "DISIIf::DISIIf 0x%x>" ), this ) );
|
|
69 |
__ASSERT_CRITICAL;// From kern_priv.h published partner
|
|
70 |
ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIIfNotThreadContext | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
71 |
iKernelChannel = new DISIKernelChannel( aObjId );
|
|
72 |
ASSERT_RESET_ALWAYS( iKernelChannel, ( EISIIfMemAllocFailure2 | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
73 |
TAny* params[ KTwoParams ]; //TODO should probably take process identifier into this to identify binary
|
|
74 |
params[ KFirstParam ] = reinterpret_cast<TAny*>( aUID );
|
|
75 |
params[ KSecondParam ] = reinterpret_cast<TAny*>( &aObjId );
|
|
76 |
// Get's the current thread's thread message.
|
|
77 |
TThreadMessage& m = Kern::Message();
|
|
78 |
m.iValue = EISIConnect;
|
|
79 |
m.iArg[ KFirstParam ] = params;
|
|
80 |
// Other asserts in kernel channel.
|
|
81 |
ASSERT_RESET_ALWAYS( ( KErrNone == iKernelChannel->HandleRequest( m ) ), ( EISIIfWrongResponseToRequest2 | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
82 |
C_TRACE( ( _T( "DISIIf::DISIIf 0x%x<" ), this ) );
|
|
83 |
}
|
|
84 |
|
|
85 |
DISIIf::~DISIIf()
|
|
86 |
{
|
|
87 |
C_TRACE( ( _T( "DISIIf::~DISIIf 0x%x>" ), this ) );
|
|
88 |
// Get's the current thread's thread message.
|
|
89 |
TThreadMessage& m = Kern::Message();
|
|
90 |
m.iValue = EISIDisconnect;
|
|
91 |
m.iArg[ KFirstParam ] = NULL;
|
|
92 |
// Other asserts in kernel channel.
|
|
93 |
ASSERT_RESET_ALWAYS( ( KErrNone == iKernelChannel->HandleRequest( m ) ), ( EISIIfWrongResponseToRequest | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
94 |
if( iKernelChannel )
|
|
95 |
{
|
|
96 |
delete iKernelChannel;
|
|
97 |
iKernelChannel = NULL;
|
|
98 |
}
|
|
99 |
C_TRACE( ( _T( "DISIIf::~DISIIf 0x%x<" ), this ) );
|
|
100 |
}
|
|
101 |
|
|
102 |
TDes8& DISIIf::AllocateMsgBlock( const TUint16 aSize )
|
|
103 |
{
|
|
104 |
C_TRACE( ( _T( "DISIIf::AllocateMsgBlock 0x%x %d>" ), this, aSize ) );
|
|
105 |
TDes8* temp = NULL;
|
|
106 |
TInt size( aSize );
|
|
107 |
TAny* params[ KTwoParams ];
|
|
108 |
params[ KFirstParam ] = reinterpret_cast<TAny*>( &size );
|
|
109 |
params[ KSecondParam ] = reinterpret_cast<TAny*>( &temp );
|
|
110 |
// Get's the current thread's thread message.
|
|
111 |
TThreadMessage& m = Kern::Message();
|
|
112 |
m.iValue = EISIAllocateBlock;
|
|
113 |
m.iArg[ KFirstParam ] = params;
|
|
114 |
// Other asserts in kernel channel.
|
|
115 |
ASSERT_RESET_ALWAYS( ( KErrNone == iKernelChannel->HandleRequest( m ) ), ( EISIIfWrongResponseToRequest3 | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
116 |
C_TRACE( ( _T( "DISIIf::AllocateMsgBlock 0x%x %d<" ), this, aSize ) );
|
|
117 |
return *temp;
|
|
118 |
}
|
|
119 |
|
|
120 |
void DISIIf::DeallocateMsgBlock( TDes8& aMsgBlock )
|
|
121 |
{
|
|
122 |
C_TRACE( ( _T( "DISIIf::DeallocateMsgBlock 0x%x s %d>" ), this, &aMsgBlock ) );
|
|
123 |
TAny* params[ KOneParam ];
|
|
124 |
params[ KFirstParam ] = reinterpret_cast<TAny*>( &aMsgBlock );
|
|
125 |
// Get's the current thread's thread message.
|
|
126 |
TThreadMessage& m = Kern::Message();
|
|
127 |
m.iValue = EISIDeallocateBlock;
|
|
128 |
m.iArg[ KFirstParam ] = params;
|
|
129 |
ASSERT_RESET_ALWAYS( ( KErrNone == iKernelChannel->HandleRequest( m ) ), ( EISIIfWrongResponseToRequest4 | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
130 |
C_TRACE( ( _T( "DISIIf::DeallocateMsgBlock 0x%x s %d<" ), this, &aMsgBlock ) );
|
|
131 |
}
|
|
132 |
|
|
133 |
void DISIIf::Receive( TRequestStatus& aRxStatus, TDes8*& aRxMsg, const TDfc& aRxCompletedDfc )
|
|
134 |
{
|
|
135 |
C_TRACE( ( _T( "DISIIf::Receive 0x%x s %d b 0x%x d 0x%x>" ), this, &aRxStatus, &aRxMsg, &aRxCompletedDfc ) );
|
|
136 |
ASSERT_RESET_ALWAYS( !aRxMsg, ( EISIIfNotNullPtr | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
137 |
aRxStatus = KRequestPending;
|
|
138 |
TAny* params[ KThreeParams ];
|
|
139 |
params[ KFirstParam ] = reinterpret_cast<TAny*>( &aRxStatus );
|
|
140 |
params[ KSecondParam ] = reinterpret_cast<TAny*>( &aRxMsg );
|
|
141 |
params[ KThirdParam ] = reinterpret_cast<TAny*>( &const_cast<TDfc&>( aRxCompletedDfc ) );
|
|
142 |
// Get's the current thread's thread message.
|
|
143 |
TThreadMessage& m = Kern::Message();
|
|
144 |
m.iValue = EISIAsyncReceive;
|
|
145 |
m.iArg[ KFirstParam ] = params;
|
|
146 |
ASSERT_RESET_ALWAYS( ( KErrNone == iKernelChannel->HandleRequest( m ) ), ( EISIIfWrongResponseToRequest5 | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
147 |
C_TRACE( ( _T( "DISIIf::Receive 0x%x s %d b 0x%x d 0x%x<" ), this, &aRxStatus, &aRxMsg, &aRxCompletedDfc ) );
|
|
148 |
}
|
|
149 |
void DISIIf::ReceiveCancel()
|
|
150 |
{
|
|
151 |
C_TRACE( ( _T( "DISIIf::ReceiveCancel 0x%x>" ), this ) );
|
|
152 |
TThreadMessage& m = Kern::Message();
|
|
153 |
m.iValue = KMaxTInt;
|
|
154 |
m.iArg[ KFirstParam ] = reinterpret_cast<TAny*>( EISIAsyncReceive );
|
|
155 |
ASSERT_RESET_ALWAYS( ( KErrNone == iKernelChannel->HandleRequest( m ) ), ( EISIIfWrongResponseToRequest6 | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
156 |
C_TRACE( ( _T( "DISIIf::ReceiveCancel 0x%x<" ), this ) );
|
|
157 |
}
|
|
158 |
|
|
159 |
void DISIIf::Release()
|
|
160 |
{
|
|
161 |
C_TRACE( ( _T( "DISIIf::Release 0x%x>" ), this ) );
|
|
162 |
__ASSERT_CRITICAL;
|
|
163 |
ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIIfNotThreadContext2 | EDISIIfTraceId << KClassIdentifierShift ) );
|
|
164 |
delete this;
|
|
165 |
C_TRACE( ( _T( "DISIIf::Release 0x%x<" ), this ) );
|
|
166 |
}
|
|
167 |
TInt DISIIf::Send( const TDesC8& aTxMsg )
|
|
168 |
{
|
|
169 |
C_TRACE( ( _T( "DISIIf::Send 0x%x m 0x%x>" ), this, &aTxMsg ) );
|
|
170 |
TAny* params[ KOneParam ];
|
|
171 |
params[ KFirstParam ] = reinterpret_cast<TAny*>( const_cast<TDesC8*>( &aTxMsg )); //TODO need const?
|
|
172 |
// Get's the current thread's thread message.
|
|
173 |
TThreadMessage& m = Kern::Message();
|
|
174 |
m.iValue = EISISend;
|
|
175 |
m.iArg[ KFirstParam ] = params;
|
|
176 |
TInt retValue( iKernelChannel->HandleRequest( m ) );
|
|
177 |
C_TRACE( ( _T( "DISIIf::Send 0x%x m 0x%x %d<" ), this, &aTxMsg, retValue ) );
|
|
178 |
return retValue;
|
|
179 |
}
|
|
180 |
|
|
181 |
// End of file
|