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 |
|
|
20 |
#include <nk_priv.h> // For __ASSERT_NO_FAST_MUTEX
|
|
21 |
#include <kern_priv.h> // For __ASSERT_CRITICAL
|
|
22 |
#include <dfcs.h> // For TDfc
|
|
23 |
#include "isikernelchannel.h" // For DISIKernelChannel
|
|
24 |
#include "isiroutertrace.h" // For C_TRACE, ASSERT_RESET.. and fault codes
|
|
25 |
#include "misichannelrouterif.h" // For MISIChannelRouterIf
|
|
26 |
#include "memapi.h" // For MemApi
|
|
27 |
#include "isimsgqueue.h" // For DISIMsgQueue
|
|
28 |
|
|
29 |
// CONST
|
|
30 |
const TInt KFirstParam( 0 );
|
|
31 |
const TInt KSecondParam( 1 );
|
|
32 |
const TInt KThirdParam( 2 );
|
|
33 |
|
|
34 |
const TInt KISIKernelChannelMsgQueDfcPrio( 2 ); // LDD FW has one
|
|
35 |
const TInt KISIKernelEmptyRxQueuePrio( 1 );
|
|
36 |
const TInt KDestroyChannelMsg( 0xff );
|
|
37 |
|
|
38 |
enum TISIKernelChannelFaults
|
|
39 |
{
|
|
40 |
EISIKernelChannelMemAllocFailure = 0x01,
|
|
41 |
EISIKernelChannelMemAllocFailure1,
|
|
42 |
EISIKernelChannelNotThreadContext,
|
|
43 |
EISIKernelChannelNotThreadContext1,
|
|
44 |
EISIKernelChannelNotThreadContext2,
|
|
45 |
EISIKernelChannelNullParam,
|
|
46 |
EISIKernelChannelNullParam2,
|
|
47 |
EISIKernelChannelNullParam3,
|
|
48 |
EISIKernelChannelNullParam4,
|
|
49 |
EISIKernelChannelNullParam5,
|
|
50 |
EISIKernelChannelNullParam6,
|
|
51 |
EISIKernelChannelWrongParam,
|
|
52 |
EISIKernelChannelWrongRequest,
|
|
53 |
EISIKernelChannelWrongRequest1,
|
|
54 |
EISIKernelChannelWrongRequest2,
|
|
55 |
EISIKernelChannelWrongRequest3,
|
|
56 |
EISIKernelChannelOverTheLimits,
|
|
57 |
EISIKernelChannelOverTheLimits2,
|
|
58 |
EISIKernelChannelOverTheLimits3,
|
|
59 |
EISIKernelChannelOverTheLimits4,
|
|
60 |
EISIKernelChannelSameRequestTwice,
|
|
61 |
EISIKernelChannelDfcAlreadyQueued,
|
|
62 |
EISIKernelChannelRxBufferNotReleased,
|
|
63 |
EISIKernelChannelAlreadyCreated,
|
|
64 |
};
|
|
65 |
|
|
66 |
|
|
67 |
DISIKernelChannel::DISIKernelChannel(
|
|
68 |
const TUint16& aObjId
|
|
69 |
) : iKernelChMsgQue( MsgQDfc, this, NULL, KISIKernelChannelMsgQueDfcPrio )
|
|
70 |
{
|
|
71 |
C_TRACE( ( _T( "DISIKernelChannel::DISIKernelChannel 0x%x>" ), this ) );
|
|
72 |
iRouterIf = MISIChannelRouterIf::GetIf();
|
|
73 |
ASSERT_RESET_ALWAYS( iRouterIf, ( EISIKernelChannelMemAllocFailure | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
74 |
iRequests = new DISIKernelAsyncRequests( EISILastAsyncRequest );
|
|
75 |
iRx = new DISIMsgQueue( KISILddRxQueueSize );
|
|
76 |
iCompletionThread = iRouterIf->GetDfcThread( MISIChannelRouterIf::EISIUserRequestCompletionThread );
|
|
77 |
iEmptyRxDfc = new TDfc( EmptyRxDfc, this, iCompletionThread, KISIKernelEmptyRxQueuePrio );
|
|
78 |
ASSERT_RESET_ALWAYS( ( iEmptyRxDfc && iRequests && iRx ), ( EISIKernelChannelMemAllocFailure1 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
79 |
iMainThread = iRouterIf->GetDfcThread( MISIChannelRouterIf::EISIKernelMainThread );
|
|
80 |
iKernelChMsgQue.SetDfcQ( iMainThread );
|
|
81 |
iKernelChMsgQue.Receive();
|
|
82 |
C_TRACE( ( _T( "DISIKernelChannel::DISIKernelChannel 0x%x<" ), this ) );
|
|
83 |
}
|
|
84 |
|
|
85 |
DISIKernelChannel::~DISIKernelChannel(
|
|
86 |
// None
|
|
87 |
)
|
|
88 |
{
|
|
89 |
C_TRACE( ( _T( "DISIKernelChannel::~DISIKernelChannel 0x%x 0x%x>" ), this ) );
|
|
90 |
// Send channel destroyed message to complete with EFalse.
|
|
91 |
TThreadMessage& m=Kern::Message();
|
|
92 |
m.iValue = KDestroyChannelMsg;
|
|
93 |
m.SendReceive( &iKernelChMsgQue );
|
|
94 |
C_TRACE( ( _T( "DISIKernelChannel::~DISIKernelChannel iRx 0x%x" ), iRx ) );
|
|
95 |
// Only modified in constructor, if not created already reseted.
|
|
96 |
delete iRx;
|
|
97 |
iRx = NULL;
|
|
98 |
C_TRACE( ( _T( "DISIKernelChannel::~DISIKernelChannel iEmptyRxDfc 0x%x" ), iEmptyRxDfc ) );
|
|
99 |
// Only modified in constructor, if not created already reseted.
|
|
100 |
iEmptyRxDfc->Cancel();
|
|
101 |
delete iEmptyRxDfc;
|
|
102 |
iEmptyRxDfc = NULL;
|
|
103 |
C_TRACE( ( _T( "DISIKernelChannel::~DISIKernelChannel iRequests 0x%x" ), iEmptyRxDfc ) );
|
|
104 |
iPtrPtrToRxBuf = NULL;
|
|
105 |
iRouterIf = NULL;
|
|
106 |
// Only modified in constructor, if not created already reseted.
|
|
107 |
delete iRequests;
|
|
108 |
iRequests = NULL;
|
|
109 |
C_TRACE( ( _T( "DISIKernelChannel::~DISIKernelChannel 0x%x 0x%x<" ), this ) );
|
|
110 |
}
|
|
111 |
|
|
112 |
void DISIKernelChannel::MsgQDfc(
|
|
113 |
TAny* aPtr
|
|
114 |
)
|
|
115 |
{
|
|
116 |
C_TRACE( ( _T( "DISIKernelChannel::MsgQDfc>" ) ) );
|
|
117 |
DISIKernelChannel* tmp = reinterpret_cast<DISIKernelChannel*>( aPtr );
|
|
118 |
tmp->HandleThreadMsg( static_cast<TThreadMessage&>(*tmp->iKernelChMsgQue.iMessage ) );
|
|
119 |
C_TRACE( ( _T( "DISIKernelChannel::MsgQDfc<" ) ) );
|
|
120 |
}
|
|
121 |
|
|
122 |
TInt DISIKernelChannel::HandleRequest(
|
|
123 |
TThreadMessage& aMsg
|
|
124 |
)
|
|
125 |
{
|
|
126 |
C_TRACE( ( _T( "DISIKernelChannel::HandleRequest 0x%x 0x%x 0x%x>" ), this, aMsg.iValue, iObjId ) );
|
|
127 |
__ASSERT_CRITICAL;
|
|
128 |
__ASSERT_NO_FAST_MUTEX;
|
|
129 |
ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIKernelChannelNotThreadContext | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
130 |
TInt valueToReturn( KErrAlreadyExists );
|
|
131 |
// Channel is not open.
|
|
132 |
if( iObjId == KNotInitializedId )
|
|
133 |
{
|
|
134 |
switch( aMsg.iValue )
|
|
135 |
{
|
|
136 |
// Only connect is legal
|
|
137 |
case EISIConnect:
|
|
138 |
{
|
|
139 |
C_TRACE( ( _T( "DISIKernelChannel::HandleRequest connect 0x%x" ), this ) );
|
|
140 |
valueToReturn = aMsg.SendReceive( &iKernelChMsgQue );
|
|
141 |
break;
|
|
142 |
}
|
|
143 |
default:
|
|
144 |
{
|
|
145 |
ASSERT_RESET_ALWAYS( 0, ( EISIKernelChannelWrongParam | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
146 |
break;
|
|
147 |
}
|
|
148 |
}
|
|
149 |
}
|
|
150 |
// Channel is open.
|
|
151 |
else
|
|
152 |
{
|
|
153 |
// Accept all calls except new.
|
|
154 |
if( EISIConnect != aMsg.iValue )
|
|
155 |
{
|
|
156 |
valueToReturn = aMsg.SendReceive( &iKernelChMsgQue );
|
|
157 |
}
|
|
158 |
else
|
|
159 |
{
|
|
160 |
ASSERT_RESET_ALWAYS( ( 0 ), ( EISIKernelChannelAlreadyCreated | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
161 |
}
|
|
162 |
}
|
|
163 |
C_TRACE( ( _T( "DISIKernelChannel::HandleRequest 0x%x %d 0x%x<" ), this, valueToReturn, iObjId ) );
|
|
164 |
return valueToReturn;
|
|
165 |
}
|
|
166 |
|
|
167 |
// Called only in router extension thread context.
|
|
168 |
void DISIKernelChannel::EnqueChannelRequestCompleteDfc(
|
|
169 |
TInt aRequest,
|
|
170 |
TInt aStatusToComplete
|
|
171 |
)
|
|
172 |
{
|
|
173 |
C_TRACE( ( _T( "DISIKernelChannel::EnqueChannelRequestCompleteDfc 0x%x %d %d 0x%x 0x%x>" ), this, aRequest, aStatusToComplete, iObjId ) );
|
|
174 |
ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIKernelChannelNotThreadContext2 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
175 |
iRequests->Complete( aRequest, aStatusToComplete );
|
|
176 |
C_TRACE( ( _T( "DISIKernelChannel::EnqueChannelRequestCompleteDfc 0x%x %d %d 0x%x 0x%x<" ), this, aRequest, aStatusToComplete, iObjId ) );
|
|
177 |
}
|
|
178 |
|
|
179 |
void DISIKernelChannel::HandleThreadMsg(
|
|
180 |
TThreadMessage& aMsg
|
|
181 |
)
|
|
182 |
{
|
|
183 |
C_TRACE( ( _T( "DISIKernelChannel::HandleThreadMsg 0x%x 0x%x 0x%x>" ), this, &aMsg, iObjId ) );
|
|
184 |
TThreadMessage& m = ( aMsg );
|
|
185 |
TInt completeValue( KErrNone );
|
|
186 |
TBool complete( ETrue );
|
|
187 |
switch( m.iValue )
|
|
188 |
{
|
|
189 |
// All asynchronous requests. Return result after DFC function is run.
|
|
190 |
case EISIAsyncReceive:
|
|
191 |
{
|
|
192 |
// No need to check return value in async functions, completed to client from DFC.
|
|
193 |
HandleDfcRequest( m );
|
|
194 |
break;
|
|
195 |
}
|
|
196 |
// From synchronized request return the result immediately
|
|
197 |
case EISIConnect:
|
|
198 |
case EISIDisconnect:
|
|
199 |
case EISIAllocateBlock:
|
|
200 |
case EISIDeallocateBlock:
|
|
201 |
case EISISend:
|
|
202 |
{
|
|
203 |
completeValue = HandleSyncRequest( m );
|
|
204 |
break;
|
|
205 |
}
|
|
206 |
case KDestroyChannelMsg:
|
|
207 |
{
|
|
208 |
completeValue = KErrNone;
|
|
209 |
// Don't receive anymore messages.
|
|
210 |
complete = EFalse;
|
|
211 |
break;
|
|
212 |
}
|
|
213 |
case KMaxTInt:
|
|
214 |
{
|
|
215 |
completeValue = KErrNone;
|
|
216 |
DoCancel( KMaxTInt, m.Int0() );
|
|
217 |
break;
|
|
218 |
}
|
|
219 |
default:
|
|
220 |
{
|
|
221 |
ASSERT_RESET_ALWAYS( 0, ( EISIKernelChannelWrongRequest | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
222 |
break;
|
|
223 |
}
|
|
224 |
}
|
|
225 |
m.Complete( completeValue, complete );
|
|
226 |
C_TRACE( ( _T( "DISIKernelChannel::HandleThreadMsg 0x%x< 0x%x" ), this, iObjId ) );
|
|
227 |
}
|
|
228 |
|
|
229 |
void DISIKernelChannel::HandleDfcRequest(
|
|
230 |
TThreadMessage& aMsg
|
|
231 |
)
|
|
232 |
{
|
|
233 |
C_TRACE( ( _T( "DISIKernelChannel::HandleDfcRequest 0x%x 0x%x 0x%x>" ), this, &aMsg, iObjId ) );
|
|
234 |
TThreadMessage& m = ( aMsg );
|
|
235 |
TInt request( m.iValue );
|
|
236 |
ASSERT_RESET_ALWAYS( m.iArg, ( EISIKernelChannelNullParam | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
237 |
ASSERT_RESET_ALWAYS( EISILastAsyncRequest > ( request ), ( EISIKernelChannelWrongRequest1 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
238 |
if( iRequests->IsPending( request) )
|
|
239 |
{
|
|
240 |
C_TRACE( ( _T( "DISIKernelChannel::HandleDfcRequest existing 0x%x request 0x%x" ), this, request ) );
|
|
241 |
// Should not give same request object twice before completing the first one.
|
|
242 |
ASSERT_RESET_ALWAYS( 0, ( EISIKernelChannelSameRequestTwice | iObjId << KObjIdShift | static_cast<TUint8>( request ) << KExtraInfoShift ) );
|
|
243 |
}
|
|
244 |
else
|
|
245 |
{
|
|
246 |
C_TRACE( ( _T( "DISIKernelChannel::HandleDfcRequest 0x%x handling %d" ), this, request ) );
|
|
247 |
TUint32* tablePtr = reinterpret_cast<TUint32*>( m.Ptr0() );
|
|
248 |
TRequestStatus* dfcStatus = reinterpret_cast<TRequestStatus*>( tablePtr[ KFirstParam ] );
|
|
249 |
TDfc* dfc = reinterpret_cast<TDfc*>( tablePtr[ KThirdParam ] );
|
|
250 |
ASSERT_RESET_ALWAYS( dfcStatus, ( EISIKernelChannelNullParam2 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
251 |
ASSERT_RESET_ALWAYS( dfc, ( EISIKernelChannelNullParam3 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
252 |
iRequests->SetPending( request, dfc, dfcStatus );
|
|
253 |
switch( request )
|
|
254 |
{
|
|
255 |
case EISIAsyncReceive:
|
|
256 |
{
|
|
257 |
ASSERT_RESET_ALWAYS( !iPtrPtrToRxBuf, ( EISIKernelChannelRxBufferNotReleased | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
258 |
iPtrPtrToRxBuf = reinterpret_cast<TDes8**>( tablePtr[ KSecondParam ] );
|
|
259 |
C_TRACE( ( _T( "DISIKernelChannel::HandleDfcRequest EIADAsyncReceive 0x%x 0x%x 0x%x" ), this, iPtrPtrToRxBuf, &iPtrPtrToRxBuf ) );
|
|
260 |
iEmptyRxDfc->Enque();
|
|
261 |
break;
|
|
262 |
}
|
|
263 |
default:
|
|
264 |
{
|
|
265 |
ASSERT_RESET_ALWAYS( 0, ( EISIKernelChannelWrongRequest2 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
266 |
break;
|
|
267 |
}
|
|
268 |
}
|
|
269 |
}
|
|
270 |
C_TRACE( ( _T( "DISIKernelChannel::HandleDfcRequest 0x%x 0x%x 0x%x<" ), this, &aMsg, iObjId ) );
|
|
271 |
}
|
|
272 |
|
|
273 |
// Called in 1...N transceivers thread context
|
|
274 |
void DISIKernelChannel::ReceiveMsg(
|
|
275 |
const TDesC8& aMessage
|
|
276 |
)
|
|
277 |
{
|
|
278 |
C_TRACE( ( _T( "DISIKernelChannel::ReceiveMsg 0x%x 0x%x 0x%x>" ), this, &aMessage, iObjId ) );
|
|
279 |
ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIKernelChannelNotThreadContext1 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
280 |
iRx->Add( aMessage );
|
|
281 |
iEmptyRxDfc->Enque();
|
|
282 |
C_TRACE( ( _T( "DISIKernelChannel::ReceiveMsg 0x%x 0x%x 0x%x<" ), this, &aMessage, iObjId ) );
|
|
283 |
}
|
|
284 |
|
|
285 |
// From MISIRouterChannelIf end
|
|
286 |
|
|
287 |
DISIKernelChannel::DISIKernelAsyncRequests::DISIKernelAsyncRequests(
|
|
288 |
const TInt aSize
|
|
289 |
)
|
|
290 |
{
|
|
291 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::DISIKernelAsyncRequests size %d>" ), aSize ) );
|
|
292 |
iRequestLock = new NFastMutex();
|
|
293 |
iDfcFunctionList = new TDfc*[ aSize ];
|
|
294 |
iRequestStatusList = new TRequestStatus*[ aSize ];
|
|
295 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::DISIKernelAsyncRequests<" ) ) );
|
|
296 |
}
|
|
297 |
|
|
298 |
DISIKernelChannel::DISIKernelAsyncRequests::~DISIKernelAsyncRequests()
|
|
299 |
{
|
|
300 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::~DISIKernelAsyncRequests>" ) ) );
|
|
301 |
// Delete space reserved for the array not the contents of the array, so mem behind pointers that are not owned are not deleted.
|
|
302 |
delete iDfcFunctionList;
|
|
303 |
delete iRequestStatusList;
|
|
304 |
// Deletes lock
|
|
305 |
delete iRequestLock;
|
|
306 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::~DISIKernelAsyncRequests<" ) ) );
|
|
307 |
}
|
|
308 |
|
|
309 |
void DISIKernelChannel::DISIKernelAsyncRequests::SetPending(
|
|
310 |
const TUint aRequest,
|
|
311 |
TDfc* aDfc,
|
|
312 |
TRequestStatus* aStatus
|
|
313 |
)
|
|
314 |
{
|
|
315 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::SetPending %d 0x%x 0x%x>" ), aRequest, aDfc, aStatus ) );
|
|
316 |
ASSERT_RESET_ALWAYS( aDfc, ( EISIKernelChannelNullParam5 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
317 |
ASSERT_RESET_ALWAYS( aStatus, ( EISIKernelChannelNullParam6 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
318 |
ASSERT_RESET_ALWAYS( ( EISILastAsyncRequest > aRequest && EISIAsyncReceive <= aRequest ), ( EISIKernelChannelOverTheLimits2 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
319 |
// Note asserts must be done before holding the lock.
|
|
320 |
NKern::FMWait( iRequestLock );
|
|
321 |
iDfcFunctionList[ aRequest ] = aDfc;
|
|
322 |
iRequestStatusList[ aRequest ] = aStatus;
|
|
323 |
*iRequestStatusList[ aRequest ] = KRequestPending;
|
|
324 |
NKern::FMSignal( iRequestLock );
|
|
325 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::SetPending %d 0x%x 0x%x<" ), aRequest, aDfc, aStatus ) );
|
|
326 |
}
|
|
327 |
|
|
328 |
TBool DISIKernelChannel::DISIKernelAsyncRequests::IsPending(
|
|
329 |
const TUint aRequest
|
|
330 |
)
|
|
331 |
{
|
|
332 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::IsPending %d>" ), aRequest ) );
|
|
333 |
ASSERT_RESET_ALWAYS( ( EISILastAsyncRequest > aRequest && EISIAsyncReceive <= aRequest ), ( EISIKernelChannelOverTheLimits3 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
334 |
TBool ret( EFalse );
|
|
335 |
NKern::FMWait( iRequestLock );
|
|
336 |
ret = ( iDfcFunctionList[ aRequest ] && iRequestStatusList[ aRequest ] ) ? ETrue : EFalse;
|
|
337 |
NKern::FMSignal( iRequestLock );
|
|
338 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::IsPending %d %d<" ), aRequest, ret ) );
|
|
339 |
return ret;
|
|
340 |
}
|
|
341 |
|
|
342 |
void DISIKernelChannel::DISIKernelAsyncRequests::Complete(
|
|
343 |
const TUint aRequest,
|
|
344 |
const TInt aStatusToComplete
|
|
345 |
)
|
|
346 |
{
|
|
347 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::Complete %d>" ), aRequest ) );
|
|
348 |
// Check that request is legal.
|
|
349 |
ASSERT_RESET_ALWAYS( ( EISILastAsyncRequest > aRequest && EISIAsyncReceive <= aRequest ), ( EISIKernelChannelOverTheLimits4 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
350 |
NKern::FMWait( iRequestLock );
|
|
351 |
TDfc* completeDfc = iDfcFunctionList[ aRequest ];
|
|
352 |
if( ( completeDfc && iRequestStatusList[ aRequest ] ) )
|
|
353 |
{
|
|
354 |
// Writing straight to clients pointer. There is a risk that malfunctioning client can mess up it's own pointer, if used out side of rx dfc, but what can you do..
|
|
355 |
*iRequestStatusList[ aRequest ] = aStatusToComplete;
|
|
356 |
ASSERT_RESET_ALWAYS( !completeDfc->Queued(), ( EISIKernelChannelDfcAlreadyQueued | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
357 |
completeDfc->Enque();
|
|
358 |
iDfcFunctionList[ aRequest ] = NULL;
|
|
359 |
}
|
|
360 |
NKern::FMSignal( iRequestLock );
|
|
361 |
C_TRACE( ( _T( "DISIKernelAsyncRequests::Complete %d<" ), aRequest ) );
|
|
362 |
}
|
|
363 |
|
|
364 |
void DISIKernelChannel::EmptyRxDfc(
|
|
365 |
TAny* aPtr // self
|
|
366 |
)
|
|
367 |
{
|
|
368 |
C_TRACE( ( _T( "DISIKernelChannel::EmptyRxDfc>" ) ) );
|
|
369 |
DISIKernelChannel& chTmp = *reinterpret_cast<DISIKernelChannel*>( aPtr );
|
|
370 |
C_TRACE( ( _T( "DISIKernelChannel::EmptyRxDfc 0x%x 0x%x>" ), &chTmp, chTmp.iObjId ) );
|
|
371 |
if( chTmp.iRequests->IsPending( EISIAsyncReceive ) && chTmp.iRx->Count() > 0 )
|
|
372 |
{
|
|
373 |
C_TRACE( ( _T( "DISIKernelChannel::EmptyRxDfc 0x%x writing to kernel client" ), &chTmp ) );
|
|
374 |
TDes8*& tmpWrite = *chTmp.iPtrPtrToRxBuf;
|
|
375 |
tmpWrite = &chTmp.iRx->Get();
|
|
376 |
C_TRACE( ( _T( "DISIKernelChannel::EmptyRxDfc 0x%x 0x%x 0x%x clientRx 0x%x " ), &chTmp, chTmp.iPtrPtrToRxBuf, &chTmp.iPtrPtrToRxBuf, *chTmp.iPtrPtrToRxBuf ) );
|
|
377 |
chTmp.EnqueChannelRequestCompleteDfc( EISIAsyncReceive, KErrNone );
|
|
378 |
}
|
|
379 |
else
|
|
380 |
{
|
|
381 |
C_TRACE( ( _T( "DISIKernelChannel::EmptyRxDfc 0x%x no receive active or no message" ), &chTmp ) );
|
|
382 |
}
|
|
383 |
C_TRACE( ( _T( "DISIKernelChannel::EmptyRxDfc 0x%x 0x%x<" ), &chTmp, chTmp.iObjId ) );
|
|
384 |
}
|
|
385 |
|
|
386 |
void DISIKernelChannel::DoCancel(
|
|
387 |
TInt aRequest,
|
|
388 |
TInt aMask )
|
|
389 |
{
|
|
390 |
C_TRACE( ( _T( "DISIKernelChannel::DoCancel 0x%x 0x%x>" ), this, iObjId ) );
|
|
391 |
ASSERT_RESET_ALWAYS( EISILastAsyncRequest > ( aMask&aRequest ), EISIKernelChannelOverTheLimits | EDISIKernelChannelId << KClassIdentifierShift );
|
|
392 |
if( iRequests->IsPending( aMask&aRequest ) )
|
|
393 |
{
|
|
394 |
switch( aMask&aRequest )
|
|
395 |
{
|
|
396 |
case EISIAsyncReceive:
|
|
397 |
{
|
|
398 |
C_TRACE( ( _T( "DISIKernelChannel::DoCancel EIADAsyncReceive 0x%x ptrs 0x%x 0x%x" ), this, iPtrPtrToRxBuf, &iPtrPtrToRxBuf ) );
|
|
399 |
iPtrPtrToRxBuf = NULL;
|
|
400 |
break;
|
|
401 |
}
|
|
402 |
default:
|
|
403 |
{
|
|
404 |
ASSERT_RESET_ALWAYS( 0, EISIKernelChannelWrongRequest | EDISIKernelChannelId << KClassIdentifierShift );
|
|
405 |
break;
|
|
406 |
}
|
|
407 |
}
|
|
408 |
EnqueChannelRequestCompleteDfc( aMask&aRequest, KErrCancel );
|
|
409 |
}
|
|
410 |
else
|
|
411 |
{
|
|
412 |
C_TRACE( ( _T( "DISIKernelChannel::DoCancel nothing to cancel 0x%x" ), this ) );
|
|
413 |
}
|
|
414 |
C_TRACE( ( _T( "DISIKernelChannel::DoCancel 0x%x 0x%x<" ), this, iObjId ) );
|
|
415 |
}
|
|
416 |
|
|
417 |
TInt DISIKernelChannel::HandleSyncRequest(
|
|
418 |
TThreadMessage& aMsg
|
|
419 |
)
|
|
420 |
{
|
|
421 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest 0x%x 0x%x 0x%x>" ), this, &aMsg, iObjId ) );
|
|
422 |
TThreadMessage& m = ( aMsg );
|
|
423 |
TInt request( m.iValue );
|
|
424 |
ASSERT_RESET_ALWAYS( m.iArg, ( EISIKernelChannelNullParam4 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
425 |
TInt returnValue( KErrNone );
|
|
426 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest 0x%x handling %d" ), this, request ) );
|
|
427 |
TUint32* tablePtr = reinterpret_cast<TUint32*>( m.Ptr0() );
|
|
428 |
|
|
429 |
switch( request )
|
|
430 |
{
|
|
431 |
case EISIConnect:
|
|
432 |
{
|
|
433 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIConnect 0x%x" ), this ) );
|
|
434 |
iUID = tablePtr[ KFirstParam ];
|
|
435 |
TUint8* objIdPtr = reinterpret_cast<TUint8*>( tablePtr[ KSecondParam ] ); //TODO vasta tempobjid
|
|
436 |
C_TRACE( ( _T( "DISIKernelChannel::HandleDfcRequest EISINokiaKernelOpen 0x%x" ), this ) );
|
|
437 |
iRouterIf->Connect( iUID, iObjId, this );
|
|
438 |
*objIdPtr = iObjId;
|
|
439 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIConnect 0x%x" ), this ) );
|
|
440 |
break;
|
|
441 |
}
|
|
442 |
case EISIDisconnect:
|
|
443 |
{
|
|
444 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIDisconnect 0x%x" ), this ) );
|
|
445 |
Disconnect();
|
|
446 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIDisconnect 0x%x" ), this ) );
|
|
447 |
returnValue = KErrNone;
|
|
448 |
break;
|
|
449 |
}
|
|
450 |
case EISIAllocateBlock:
|
|
451 |
{
|
|
452 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIAllocateBlock 0x%x" ), this ) );
|
|
453 |
const TInt size = *reinterpret_cast<TInt*>( tablePtr[ KFirstParam ] );
|
|
454 |
TDes8*& block = *(reinterpret_cast<TDes8**>( tablePtr[ KSecondParam ] ));
|
|
455 |
C_TRACE( ( _T( "DISIKernelChannel:: EISIAllocateBlock 0x%x block 0x%x %d" ), this, block, size ) );
|
|
456 |
block = ( &MemApi::AllocBlock( size ) );
|
|
457 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIAllocateBlock 0x%x" ), this ) );
|
|
458 |
break;
|
|
459 |
}
|
|
460 |
case EISIDeallocateBlock:
|
|
461 |
{
|
|
462 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIDeallocateBlock 0x%x" ), this ) );
|
|
463 |
TDes8& block = *reinterpret_cast<TDes8*>( tablePtr[ KFirstParam ] );
|
|
464 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIAllocateBlock 0x%x block 0x%x" ), this, &block ) );
|
|
465 |
// Needed to ensure that right channel is deleting the right block. (Could it be done otherways too?)
|
|
466 |
if( iPtrPtrToRxBuf )
|
|
467 |
{
|
|
468 |
if ( &block == *iPtrPtrToRxBuf )
|
|
469 |
{
|
|
470 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest release 0x%x 0x%x clientRx 0x%x"), iPtrPtrToRxBuf, &iPtrPtrToRxBuf, *iPtrPtrToRxBuf ) );
|
|
471 |
iPtrPtrToRxBuf = NULL;
|
|
472 |
}
|
|
473 |
}
|
|
474 |
MemApi::DeallocBlock( block );
|
|
475 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISIDeallocateBlock 0x%x" ), this ) );
|
|
476 |
break;
|
|
477 |
}
|
|
478 |
case EISISend:
|
|
479 |
{
|
|
480 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISISend 0x%x" ), this ) );
|
|
481 |
TDes8& block = *reinterpret_cast<TDes8*>( tablePtr[ KFirstParam ] );
|
|
482 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISISend 0x%x block 0x%x" ), this, &block ) );
|
|
483 |
returnValue = iRouterIf->Send( block, iObjId );
|
|
484 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest EISISend 0x%x" ), this ) );
|
|
485 |
break;
|
|
486 |
}
|
|
487 |
default:
|
|
488 |
{
|
|
489 |
ASSERT_RESET_ALWAYS( 0, ( EISIKernelChannelWrongRequest3 | EDISIKernelChannelId << KClassIdentifierShift ) );
|
|
490 |
break;
|
|
491 |
}
|
|
492 |
}
|
|
493 |
C_TRACE( ( _T( "DISIKernelChannel::HandleSyncRequest 0x%x 0x%x %d 0x%x<" ), this, &aMsg, returnValue, iObjId ) );
|
|
494 |
return returnValue;
|
|
495 |
}
|
|
496 |
|
|
497 |
void DISIKernelChannel::Disconnect(
|
|
498 |
// None
|
|
499 |
)
|
|
500 |
{
|
|
501 |
C_TRACE( ( _T( "DISIKernelChannel::Disconnect 0x%x 0x%x>" ), this, iObjId ) );
|
|
502 |
ResetQueues();
|
|
503 |
for( TInt i( EISILastSyncRequest ); i < EISILastAsyncRequest; ++i )
|
|
504 |
{
|
|
505 |
C_TRACE( ( _T( "DISIKernelChannel::CancelRequests req to cancel %d" ), i ) );
|
|
506 |
DoCancel( KMaxTInt, i );
|
|
507 |
}
|
|
508 |
iRouterIf->Disconnect( iObjId );
|
|
509 |
iRouterIf->FreeDfcThread( iMainThread );
|
|
510 |
iRouterIf->FreeDfcThread( iCompletionThread );
|
|
511 |
C_TRACE( ( _T( "DISIKernelChannel::Disconnect 0x%x 0x%x<" ), this, iObjId ) );
|
|
512 |
}
|
|
513 |
|
|
514 |
void DISIKernelChannel::ResetQueues(
|
|
515 |
// None
|
|
516 |
)
|
|
517 |
{
|
|
518 |
C_TRACE( ( _T( "DISIKernelChannel::ResetQueues 0x%x 0x%x>" ), this, iObjId ) );
|
|
519 |
// TODO: assert router ext thread context
|
|
520 |
if( iRx )
|
|
521 |
{
|
|
522 |
C_TRACE( ( _T( "DISIKernelChannel::ResetQueues 0x%x iRx 0x%x" ), this, iRx ) );
|
|
523 |
while( iRx->Count() )
|
|
524 |
{
|
|
525 |
MemApi::DeallocBlock( iRx->Get() );
|
|
526 |
}
|
|
527 |
}
|
|
528 |
C_TRACE( ( _T( "DISIKernelChannel::ResetQueues 0x%x 0x%x<" ), this, iObjId ) );
|
|
529 |
}
|
|
530 |
|
|
531 |
// End of file.
|
|
532 |
|