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 <pn_const.h> // For PN_NO_ROUTING
|
|
21 |
|
|
22 |
#include <nk_priv.h> // For __ASSERT_SYSTEM_LOCK etc..
|
|
23 |
|
|
24 |
#include "isakernelchannel.h"
|
|
25 |
#include "queue.h" // For DQueue
|
|
26 |
#include "iadtrace.h" // For ASSERT_...
|
|
27 |
#include "isaaccessextension.h" // For DIsaAccessExtension
|
|
28 |
#include "iadnokiadefinitions.h" // For checking allowed kernel channels.
|
|
29 |
|
|
30 |
// Extracting and adding the pipeheader.
|
|
31 |
#include <phonetisi.h> // For ISI_HEADER_SIZE
|
|
32 |
#include <pipeisi.h> // For PNS_PIPE_DATA_OFFSET_DATA
|
|
33 |
#include "OstTraceDefinitions.h"
|
|
34 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
35 |
#include "isakernelchannelTraces.h"
|
|
36 |
#endif
|
|
37 |
const TInt KPipeDataHeader( ISI_HEADER_SIZE + PNS_PIPE_DATA_OFFSET_DATA );
|
|
38 |
|
|
39 |
// CONST
|
|
40 |
const TInt KFirstParam( 0 );
|
|
41 |
const TInt KSecondParam( 1 );
|
|
42 |
const TInt KThirdParam( 2 );
|
|
43 |
const TInt KFourthParam( 3 );
|
|
44 |
|
|
45 |
const TInt KDestroyChannelMsg( 0xff );
|
|
46 |
|
|
47 |
// TODO: change this to use UniqueID instead and to extension..
|
|
48 |
void DISAKernelChannel::CheckDfc()
|
|
49 |
{
|
|
50 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_CHECKDFC_ENTRY, ">DISAKernelChannel::CheckDfc" );
|
|
51 |
|
|
52 |
C_TRACE( ( _T( "DISAKernelChannel::CheckDfc>" ) ) );
|
|
53 |
DObject* tempObj = reinterpret_cast<DObject*>( &Kern::CurrentThread() );
|
|
54 |
TUint8* buffer = ( TUint8* )Kern::Alloc( 100 );
|
|
55 |
TPtr8* bufferPtr = new ( TPtr8 )( buffer, 100 );
|
|
56 |
tempObj->Name( *bufferPtr );
|
|
57 |
if ( bufferPtr->Compare( KIADExtensionDfc ) != KErrNone )
|
|
58 |
{
|
|
59 |
for( TInt i( 0 );i < bufferPtr->Length(); ++i )
|
|
60 |
{
|
|
61 |
C_TRACE( ( _T( "bufferPtr[ %d ] %c" ), i, bufferPtr->Ptr()[ i ] ) );
|
|
62 |
}
|
|
63 |
ASSERT_RESET_ALWAYS( 0, EIADWrongDFCQueueUsed | EIADFaultIdentifier1 << KFaultIdentifierShift );
|
|
64 |
}
|
|
65 |
Kern::Free( buffer );
|
|
66 |
delete bufferPtr;
|
|
67 |
bufferPtr = NULL;
|
|
68 |
C_TRACE( ( _T( "DISAKernelChannel::CheckDfc<" ) ) );
|
|
69 |
|
|
70 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_CHECKDFC_EXIT, "<DISAKernelChannel::CheckDfc" );
|
|
71 |
}
|
|
72 |
|
|
73 |
#ifdef _DEBUG
|
|
74 |
#define ASSERT_DFCTHREAD_INEXT() CheckDfc()
|
|
75 |
#else
|
|
76 |
#define ASSERT_DFCTHREAD_INEXT()
|
|
77 |
#endif
|
|
78 |
|
|
79 |
DISAKernelChannel::DISAKernelChannel(
|
|
80 |
// None
|
|
81 |
) :
|
|
82 |
iKernelChMsgQue( MsgQDfc,this, DIsaAccessExtension::GetDFCThread( EIADExtensionDfcQueue ), KIADKernelChMsgQueDfcPriori )
|
|
83 |
{
|
|
84 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DISAKERNELCHANNEL_ENTRY, ">DISAKernelChannel::DISAKernelChannel" );
|
|
85 |
|
|
86 |
C_TRACE( ( _T( "DISAKernelChannel::DISAKernelChannel ->" ) ) );
|
|
87 |
|
|
88 |
iChannelNumber = KNotInitializedChannel;
|
|
89 |
|
|
90 |
//owned
|
|
91 |
iPtrPtrToRxBuf = NULL;
|
|
92 |
iPtrPtrToDataRxBuf = NULL;
|
|
93 |
|
|
94 |
iRx = new DQueue( KIADKernelRxQueuSize );
|
|
95 |
iDataRx = new DQueue( KIADKernelDataRxQueuSize );
|
|
96 |
// NOTE! This now in extension DFC, kernel client must ensure not to write to user add space in this threads context.
|
|
97 |
iEmptyRxDfc = new TDfc( EmptyRxDfc, this, DIsaAccessExtension::GetDFCThread( EIADExtensionDfcQueue ), KIADKernelEmptyRxQueuePriori );
|
|
98 |
iEmptyDataRxDfc = new TDfc( EmptyDataRxDfc, this, DIsaAccessExtension::GetDFCThread( EIADExtensionDfcQueue ), KIADKernelEmptyRxQueuePriori );
|
|
99 |
|
|
100 |
ASSERT_RESET_ALWAYS( iRx && iDataRx && iEmptyRxDfc && iEmptyDataRxDfc, EIADMemoryAllocationFailure | EIADFaultIdentifier7 << KFaultIdentifierShift );
|
|
101 |
|
|
102 |
for( TInt i( KErrNone ); i < EIADAsyncLast; ++i )
|
|
103 |
{
|
|
104 |
iRequests[ i ].iDfcFunction = NULL;
|
|
105 |
iRequests[ i ].iRequestStatus = NULL;//*KRequestPending;
|
|
106 |
}
|
|
107 |
iExtensionApi = DIsaAccessExtension::GetChannel2IADApi();
|
|
108 |
ASSERT_RESET_ALWAYS( iExtensionApi, EIADMemoryAllocationFailure | EIADFaultIdentifier8 << KFaultIdentifierShift );
|
|
109 |
iPep = NULL;
|
|
110 |
C_TRACE( ( _T( "DISAKernelChannel::DISAKernelChannel calling Receive..." ) ) );
|
|
111 |
iKernelChMsgQue.Receive();
|
|
112 |
C_TRACE( ( _T( "DISAKernelChannel::DISAKernelChannel <-" ) ) );
|
|
113 |
|
|
114 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DISAKERNELCHANNEL_EXIT, "<DISAKernelChannel::DISAKernelChannel" );
|
|
115 |
}
|
|
116 |
|
|
117 |
DISAKernelChannel::~DISAKernelChannel(
|
|
118 |
// None
|
|
119 |
)
|
|
120 |
{
|
|
121 |
OstTrace0( TRACE_NORMAL, DUP1_DISAKERNELCHANNEL_DISAKERNELCHANNEL_ENTRY, ">DISAKernelChannel::~DISAKernelChannel" );
|
|
122 |
|
|
123 |
// Send channel destroyed message to complete with EFalse.
|
|
124 |
TThreadMessage& m=Kern::Message();
|
|
125 |
m.iValue = KDestroyChannelMsg;
|
|
126 |
m.SendReceive( &iKernelChMsgQue );
|
|
127 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel 0x%x ->" ), iChannelNumber ) );
|
|
128 |
if( iRx )
|
|
129 |
{
|
|
130 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel iRx" ) ) );
|
|
131 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DISAKERNELCHANNEL_RX, "DISAKernelChannel::~DISAKernelChannel iRx" );
|
|
132 |
|
|
133 |
delete iRx;
|
|
134 |
iRx =NULL;
|
|
135 |
}
|
|
136 |
if( iDataRx )
|
|
137 |
{
|
|
138 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel iDataRx" ) ) );
|
|
139 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DISAKERNELCHANNEL_DATARX, "DISAKernelChannel::~DISAKernelChannel iDataRx" );
|
|
140 |
delete iDataRx;
|
|
141 |
iDataRx =NULL;
|
|
142 |
}
|
|
143 |
if( iPtrPtrToRxBuf )
|
|
144 |
{
|
|
145 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel iPtrPtrToRxBuf" ) ) );
|
|
146 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DISAKERNELCHANNEL_PTRPTRTORXBUF, "DISAKernelChannel::~DISAKernelChannel iPtrPtrToRxBuf" );
|
|
147 |
iPtrPtrToRxBuf =NULL;
|
|
148 |
}
|
|
149 |
if( iPtrPtrToDataRxBuf )
|
|
150 |
{
|
|
151 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel iPtrPtrToDataRxBuf" ) ) );
|
|
152 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DISAKERNELCHANNEL_PTRPTRTODATARXBUF, "DISAKernelChannel::~DISAKernelChannel iPtrPtrToDataRxBuf" );
|
|
153 |
iPtrPtrToDataRxBuf =NULL;
|
|
154 |
}
|
|
155 |
if( iEmptyRxDfc )
|
|
156 |
{
|
|
157 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel iEmptyRxDfc" ) ) );
|
|
158 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DISAKERNELCHANNEL_EMTPYRXDFC, "DISAKernelChannel::~DISAKernelChannel iEmptyRxDfc" );
|
|
159 |
iEmptyRxDfc->Cancel();
|
|
160 |
delete iEmptyRxDfc;
|
|
161 |
iEmptyRxDfc = NULL;
|
|
162 |
}
|
|
163 |
if( iEmptyDataRxDfc )
|
|
164 |
{
|
|
165 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel iEmptyDataRxDfc" ) ) );
|
|
166 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DISAKERNELCHANNEL_EMTPYDATARXDFC, "DISAKernelChannel::~DISAKernelChannel iEmptyDataRxDfc" );
|
|
167 |
iEmptyDataRxDfc->Cancel();
|
|
168 |
delete iEmptyDataRxDfc;
|
|
169 |
iEmptyDataRxDfc = NULL;
|
|
170 |
}
|
|
171 |
|
|
172 |
// not owned, just using
|
|
173 |
iPep = NULL;
|
|
174 |
iExtensionApi = NULL;
|
|
175 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel table TBR" ) ) );
|
|
176 |
for( TInt i( KErrNone ); i < EIADAsyncLast; ++i )
|
|
177 |
{
|
|
178 |
iRequests[ i ].iDfcFunction = NULL;
|
|
179 |
iRequests[ i ].iRequestStatus = NULL;
|
|
180 |
}
|
|
181 |
iChannelNumber = KNotInitializedChannel;
|
|
182 |
C_TRACE( ( _T( "DISAKernelChannel::~DISAKernelChannel 0x%x <-" ), iChannelNumber ) );
|
|
183 |
|
|
184 |
OstTrace0( TRACE_NORMAL, DUP1_DISAKERNELCHANNEL_DISAKERNELCHANNEL_EXIT, "<DISAKernelChannel::~DISAKernelChannel" );
|
|
185 |
}
|
|
186 |
|
|
187 |
// Handling of the request from kernel api
|
|
188 |
TInt DISAKernelChannel::HandleRequest(
|
|
189 |
TThreadMessage& aMsg
|
|
190 |
)
|
|
191 |
{
|
|
192 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_HANDLEREQUEST_ENTRY, ">DISAKernelChannel::HandleRequest;aMsg=%x", ( TUint )&( aMsg ) );
|
|
193 |
C_TRACE( ( _T( "DISAKernelChannel::HandleRequest 0x%x 0x%x 0x%x ->" ), this, iChannelNumber, aMsg.iValue ) );
|
|
194 |
// NOTE! Major change previously went as client thread's context for allocating etc... now going as
|
|
195 |
// context of the extension dfc thread.
|
|
196 |
|
|
197 |
// __NK_ASSERT_UNLOCKED;
|
|
198 |
__ASSERT_NO_FAST_MUTEX; // nk_priv.h published partner.
|
|
199 |
ASSERT_CONTEXT_ALWAYS( NKern::EThread, iChannelNumber );
|
|
200 |
// TODO
|
|
201 |
//@pre Kernel must be unlocked
|
|
202 |
//@pre interrupts enabled
|
|
203 |
|
|
204 |
C_TRACE( ( _T( "DISAKernelChannel::HandleRequest 0x%x == 0x%x " ), iChannelNumber, KNotInitializedChannel ) );
|
|
205 |
TInt valueToReturn( KErrNotSupported );
|
|
206 |
if( KNotInitializedChannel == iChannelNumber )
|
|
207 |
{
|
|
208 |
// In case of a open request.
|
|
209 |
if( EIADAsyncOpen == aMsg.iValue )
|
|
210 |
{
|
|
211 |
C_TRACE( ( _T( "DISAKernelChannel::HandleRequest open.. 0x%x" ), this ) );
|
|
212 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_HANDLEREQUEST, "DISAKernelChannel::HandleRequest;this=%x", this );
|
|
213 |
|
|
214 |
valueToReturn = aMsg.SendReceive( &iKernelChMsgQue );
|
|
215 |
}
|
|
216 |
// In case of a already closed channel close request.
|
|
217 |
else
|
|
218 |
{
|
|
219 |
// Do nothing
|
|
220 |
C_TRACE( ( _T( "DISAKernelChannel::HandleRequest already closed channel.. 0x%x" ), this ) );
|
|
221 |
OstTrace1( TRACE_NORMAL, DUP1_DISAKERNELCHANNEL_HANDLEREQUEST, "DISAKernelChannel::HandleRequest already closed channel;this=%x", this );
|
|
222 |
|
|
223 |
valueToReturn = KErrNone;
|
|
224 |
ASSERT_RESET_ALWAYS( ( EIADClose == aMsg.iValue ), EIADWrongParameter | EIADFaultIdentifier6 << KFaultIdentifierShift );
|
|
225 |
}
|
|
226 |
}
|
|
227 |
else
|
|
228 |
{
|
|
229 |
// Do nothing
|
|
230 |
valueToReturn = KErrInUse;
|
|
231 |
if( EIADAsyncOpen != aMsg.iValue )
|
|
232 |
{
|
|
233 |
valueToReturn = aMsg.SendReceive( &iKernelChMsgQue );
|
|
234 |
}
|
|
235 |
}
|
|
236 |
C_TRACE( ( _T( "DISAKernelChannel::HandleRequest 0x%x %d <-" ), this, valueToReturn ) );
|
|
237 |
|
|
238 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_HANDLEREQUEST_EXIT, "<DISAKernelChannel::HandleRequest;valueToReturn=%d", valueToReturn );
|
|
239 |
return valueToReturn;
|
|
240 |
}
|
|
241 |
|
|
242 |
void DISAKernelChannel::NotifyConnectionStatus(
|
|
243 |
TIADConnectionStatus aStatus
|
|
244 |
)
|
|
245 |
{
|
|
246 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_NOTIFYCONNECTIONSTATUS_ENTRY, ">DISAKernelChannel::NotifyConnectionStatus;aStatus=%x", ( TUint )&( aStatus ) );
|
|
247 |
|
|
248 |
C_TRACE( ( _T( "DISAKernelChannel::NotifyConnectionStatus -> %d 0x%x" ), aStatus, this ) );
|
|
249 |
// If we have DFC active.
|
|
250 |
CompleteChannelRequest( EIADAsyncNotifyConnectionStatus, aStatus );
|
|
251 |
C_TRACE( ( _T( "DISAKernelChannel::NotifyConnectionStatus <- %d 0x%x" ), aStatus, this ) );
|
|
252 |
|
|
253 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_NOTIFYCONNECTIONSTATUS_EXIT, "<DISAKernelChannel::NotifyConnectionStatus" );
|
|
254 |
}
|
|
255 |
|
|
256 |
void DISAKernelChannel::ReceiveMsg(
|
|
257 |
const TDesC8& aMessage
|
|
258 |
)
|
|
259 |
{
|
|
260 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_RECEIVEMSG_ENTRY, ">DISAKernelChannel::ReceiveMsg;aMessage=%x", ( TUint )&( aMessage ) );
|
|
261 |
|
|
262 |
C_TRACE( ( _T( "DISAKernelChannel::ReceiveMsg 0x%x 0x%x ->" ), iChannelNumber, &aMessage ) );
|
|
263 |
// Can only be called from thread context.
|
|
264 |
ASSERT_CONTEXT_ALWAYS( NKern::EThread, 0 );// 0 is iad?
|
|
265 |
iRx->Add( aMessage );
|
|
266 |
// TRACE_ASSERT( !iEmptyRxDfc->Queued() );
|
|
267 |
iEmptyRxDfc->Enque();
|
|
268 |
C_TRACE( ( _T( "DISAKernelChannel::ReceiveMsg 0x%x 0x%x <-" ), iChannelNumber, &aMessage ) );
|
|
269 |
|
|
270 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_RECEIVEMSG_EXIT, "<DISAKernelChannel::ReceiveMsg" );
|
|
271 |
}
|
|
272 |
|
|
273 |
// Register pep associated to this channel to listen data message
|
|
274 |
// deliveries.
|
|
275 |
void DISAKernelChannel::RegisterPep(
|
|
276 |
MDataMessageStatus& aPep
|
|
277 |
)
|
|
278 |
{
|
|
279 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_REGISTERPEP_ENTRY, ">DISAKernelChannel::RegisterPep;aPep=%x", ( TUint )&( aPep ) );
|
|
280 |
|
|
281 |
C_TRACE( ( _T( "DISAKernelChannel::RegisterPep 0x%x 0x%x ->" ), iPep, iChannelNumber ) );
|
|
282 |
iPep = &aPep;
|
|
283 |
C_TRACE( ( _T( "DISAKernelChannel::RegisterPep 0x%x 0x%x <-" ), iPep, iChannelNumber ) );
|
|
284 |
|
|
285 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_REGISTERPEP_EXIT, "<DISAKernelChannel::RegisterPep" );
|
|
286 |
}
|
|
287 |
|
|
288 |
// When data message is written to user thread call
|
|
289 |
// MDataMesssageStatus::DataMessageDelivered. It's responsibility is to
|
|
290 |
// tell PEP that one data message e.g.a credit is used. PEP's should also
|
|
291 |
// keep count of data messages added to channel to be abel to control the
|
|
292 |
// legacy flowcontrol
|
|
293 |
void DISAKernelChannel::ReceiveDataMsg(
|
|
294 |
const TDesC8& aDataMessage
|
|
295 |
)
|
|
296 |
{
|
|
297 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_RECEIVEDATAMSG_ENTRY, ">DISAKernelChannel::ReceiveDataMsg;aDataMessage=%x", ( TUint )&( aDataMessage ) );
|
|
298 |
|
|
299 |
C_TRACE( ( _T( "DISAKernelChannel::ReceiveDataMsg 0x%x 0x%x ->" ), iChannelNumber, &aDataMessage ) );
|
|
300 |
// Can only be called from thread context.
|
|
301 |
ASSERT_CONTEXT_ALWAYS( NKern::EThread, 0 );// 0 is iad?
|
|
302 |
iDataRx->Add( aDataMessage );
|
|
303 |
iEmptyDataRxDfc->Enque();
|
|
304 |
C_TRACE( ( _T( "DISAKernelChannel::ReceiveDataMsg 0x%x 0x%x <-" ), iChannelNumber, &aDataMessage ) );
|
|
305 |
|
|
306 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_RECEIVEDATAMSG_EXIT, "<DISAKernelChannel::ReceiveDataMsg" );
|
|
307 |
}
|
|
308 |
|
|
309 |
void DISAKernelChannel::NotifyFlowCtrl(
|
|
310 |
TIADFlowControlStatus aStatus
|
|
311 |
)
|
|
312 |
{
|
|
313 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_NOTIFYFLOWCTRL_ENTRY, ">DISAKernelChannel::NotifyFlowCtrl;aStatus=%x", ( TUint )&( aStatus ) );
|
|
314 |
|
|
315 |
C_TRACE( ( _T( "DISAKernelChannel::NotifyFlowCtrl -> %d 0x%x" ), aStatus, this ) );
|
|
316 |
// If we have DFC active.
|
|
317 |
CompleteChannelRequest( EIADAsyncNotifyFlowControlStatus, aStatus );
|
|
318 |
C_TRACE( ( _T( "DISAKernelChannel::NotifyFlowCtrl <- %d 0x%x" ), aStatus, this ) );
|
|
319 |
|
|
320 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_NOTIFYFLOWCTRL_EXIT, "<DISAKernelChannel::NotifyFlowCtrl" );
|
|
321 |
}
|
|
322 |
|
|
323 |
|
|
324 |
void DISAKernelChannel::CompleteChannelRequest(
|
|
325 |
TInt aRequest,
|
|
326 |
TInt aStatusToComplete
|
|
327 |
)
|
|
328 |
{
|
|
329 |
OstTraceExt2( TRACE_NORMAL, DISAKERNELCHANNEL_COMPLETECHANNELREQUEST_ENTRY, ">DISAKernelChannel::CompleteChannelRequest;aRequest=%d;aStatusToComplete=%d", aRequest, aStatusToComplete );
|
|
330 |
|
|
331 |
C_TRACE( ( _T( "DISAKernelChannel::CompleteChannelRequest %d %d 0x%x ->" ), aRequest, aStatusToComplete, iChannelNumber ) );
|
|
332 |
ASSERT_DFCTHREAD_INEXT();
|
|
333 |
// Acceptable asynchronous requests in kernel channel.
|
|
334 |
ASSERT_RESET_ALWAYS( ( aRequest == EIADAsyncOpen ||
|
|
335 |
aRequest == EIADAsyncReceive ||
|
|
336 |
aRequest == EIADAsyncDataReceive ||
|
|
337 |
aRequest == EIADAsyncNotifyFlowControlStatus ||
|
|
338 |
aRequest == EIADAsyncNotifyConnectionStatus ), EIADWrongParameter | EIADFaultIdentifier7 << KFaultIdentifierShift );
|
|
339 |
ASSERT_CONTEXT_ALWAYS( NKern::EThread, 0 );
|
|
340 |
ASSERT_RESET_ALWAYS( EIADAsyncLast > ( aRequest ), EIADOverTheLimits | EIADFaultIdentifier35 << KFaultIdentifierShift );
|
|
341 |
if( iRequests[ aRequest ].iDfcFunction )
|
|
342 |
{
|
|
343 |
// Clien't DFC function. The writing to user addr. space and DP issues are in resp of the client.
|
|
344 |
TDfc* completeDfc = iRequests[ aRequest ].iDfcFunction;
|
|
345 |
C_TRACE( ( _T( "DISAKernelChannel::CompleteChannelRequest %d %d 0x%x 0x%x" ), aRequest, aStatusToComplete, completeDfc, iChannelNumber ) );
|
|
346 |
OstTraceExt4( TRACE_NORMAL, DISAKERNELCHANNEL_COMPLETECHANNELREQUEST, "DISAKernelChannel::CompleteChannelRequest;aRequest=%d;aStatusToComplete=%d;iChannelNumber=%hx;completeDfc=%x", aRequest, aStatusToComplete, iChannelNumber, (TUint)(completeDfc) );
|
|
347 |
|
|
348 |
*iRequests[ aRequest ].iRequestStatus = aStatusToComplete;
|
|
349 |
C_TRACE( ( _T( "DISAKernelChannel::CompleteChannelRequest %d %d 0x%x 0x%x TBR" ), aRequest, aStatusToComplete, completeDfc, iChannelNumber ) );
|
|
350 |
iChannelNumber = ( aRequest == EIADAsyncOpen ? ( KErrNone == aStatusToComplete || KErrInUse == aStatusToComplete ? ~iChannelNumber : KNotInitializedChannel ) : iChannelNumber );
|
|
351 |
ASSERT_RESET_ALWAYS( !completeDfc->Queued(), EIADDFCAlreadyQueued | EIADFaultIdentifier1 << KFaultIdentifierShift );
|
|
352 |
completeDfc->Enque();
|
|
353 |
C_TRACE( ( _T( "DISAKernelChannel::CompleteChannelRequest %d %d 0x%x 0x%x TBR" ), aRequest, aStatusToComplete, completeDfc, iChannelNumber ) );
|
|
354 |
iRequests[ aRequest ].iDfcFunction = NULL;
|
|
355 |
}
|
|
356 |
C_TRACE( ( _T( "DISAKernelChannel::CompleteChannelRequest %d %d 0x%x <-" ), aRequest, aStatusToComplete, iChannelNumber ) );
|
|
357 |
|
|
358 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_COMPLETECHANNELREQUEST_EXIT, "<DISAKernelChannel::CompleteChannelRequest" );
|
|
359 |
}
|
|
360 |
|
|
361 |
void DISAKernelChannel::MsgQDfc(
|
|
362 |
TAny* aPtr
|
|
363 |
)
|
|
364 |
{
|
|
365 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_MSGQDFC_ENTRY, ">DISAKernelChannel::MsgQDfc;aPtr=%x", ( TUint )( aPtr ) );
|
|
366 |
|
|
367 |
C_TRACE( ( _T( "DISAKernelChannel::MsgQDfc ->" ) ) );
|
|
368 |
DISAKernelChannel* tmp = reinterpret_cast<DISAKernelChannel*>( aPtr );
|
|
369 |
tmp->HandleThreadMsg( static_cast<TThreadMessage&>(*tmp->iKernelChMsgQue.iMessage ) );
|
|
370 |
C_TRACE( ( _T( "DISAKernelChannel::MsgQDfc <-" ) ) );
|
|
371 |
|
|
372 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_MSGQDFC_EXIT, "<DISAKernelChannel::MsgQDfc" );
|
|
373 |
}
|
|
374 |
|
|
375 |
void DISAKernelChannel::HandleThreadMsg(
|
|
376 |
TThreadMessage& aMsg
|
|
377 |
)
|
|
378 |
{
|
|
379 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_HANDLETHREADMSG_ENTRY, ">DISAKernelChannel::HandleThreadMsg;aMsg=%x", ( TUint )&( aMsg ) );
|
|
380 |
|
|
381 |
C_TRACE( ( _T( "DISAKernelChannel::HandleThreadMsg 0x%x ->" ), &aMsg ) );
|
|
382 |
TThreadMessage& m = ( aMsg );
|
|
383 |
/* TODO CLOSING See LDD Framework DLogicalChannel */
|
|
384 |
TInt completeValue( KErrNone );
|
|
385 |
TBool complete( ETrue );
|
|
386 |
switch( m.iValue )
|
|
387 |
{
|
|
388 |
// All asynchronous requests. Return result after DFC function is run.
|
|
389 |
case EIADAsyncOpen:
|
|
390 |
case EIADAsyncNotifyConnectionStatus:
|
|
391 |
case EIADAsyncNotifyFlowControlStatus:
|
|
392 |
case EIADAsyncReceive:
|
|
393 |
case EIADAsyncDataReceive:
|
|
394 |
{
|
|
395 |
// No need to check return value in async functions, completed to client from DFC.
|
|
396 |
HandleDfcRequest( m );
|
|
397 |
break;
|
|
398 |
}
|
|
399 |
case EIADAllocateBlock:
|
|
400 |
case EIADAllocateDataBlock:
|
|
401 |
case EIADDeAllocateBlock:
|
|
402 |
case EIADDeAllocateDataBlock:
|
|
403 |
case EIADSend:
|
|
404 |
case EIADDataSend:
|
|
405 |
case EIADSendIndication:
|
|
406 |
case EIADSubscribeIndications:
|
|
407 |
case EIADSubscribeIndications32Bit:
|
|
408 |
{
|
|
409 |
completeValue = HandleSyncRequest( m );
|
|
410 |
break;
|
|
411 |
}
|
|
412 |
// From synchronized request return the result immediately
|
|
413 |
case EIADClose:
|
|
414 |
{
|
|
415 |
completeValue = HandleSyncRequest( m );
|
|
416 |
break;
|
|
417 |
}
|
|
418 |
case KDestroyChannelMsg:
|
|
419 |
{
|
|
420 |
completeValue = KErrNone;
|
|
421 |
complete = EFalse;
|
|
422 |
break;
|
|
423 |
}
|
|
424 |
case KMaxTInt:
|
|
425 |
{
|
|
426 |
completeValue = KErrNone;
|
|
427 |
DoCancel( KMaxTInt, m.Int0() );
|
|
428 |
break;
|
|
429 |
}
|
|
430 |
default:
|
|
431 |
{
|
|
432 |
ASSERT_RESET_ALWAYS( 0, EIADWrongRequest | EIADFaultIdentifier1 << KFaultIdentifierShift );
|
|
433 |
break;
|
|
434 |
}
|
|
435 |
}
|
|
436 |
m.Complete( completeValue, complete );
|
|
437 |
C_TRACE( ( _T( "DISAKernelChannel::HandleThreadMsg <-" ) ) );
|
|
438 |
|
|
439 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_HANDLETHREADMSG_EXIT, "<DISAKernelChannel::HandleThreadMsg" );
|
|
440 |
}
|
|
441 |
|
|
442 |
void DISAKernelChannel::HandleDfcRequest(
|
|
443 |
TThreadMessage& aMsg
|
|
444 |
)
|
|
445 |
{
|
|
446 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_HANDLEDFCREQUEST_ENTRY, ">DISAKernelChannel::HandleDfcRequest;aMsg=%x", ( TUint )&( aMsg ) );
|
|
447 |
|
|
448 |
C_TRACE( ( _T( "DISAKernelChannel::HandleDfcRequest 0x%x ->" ), &aMsg ) );
|
|
449 |
TThreadMessage& m = ( aMsg );
|
|
450 |
TInt request( m.iValue );
|
|
451 |
ASSERT_RESET_ALWAYS( m.iArg, EIADNullParameter | EIADFaultIdentifier1 << KFaultIdentifierShift );
|
|
452 |
// If request already active.
|
|
453 |
ASSERT_RESET_ALWAYS( EIADAsyncLast > ( request ), EIADOverTheLimits | EIADFaultIdentifier36 << KFaultIdentifierShift );
|
|
454 |
if( iRequests[ request ].iDfcFunction )
|
|
455 |
{
|
|
456 |
C_TRACE( ( _T( "DISAKernelChannel::HandleDfcRequest existing 0x%x request 0x%x" ), this, request ) );
|
|
457 |
TRACE_ASSERT_INFO(0, (TUint8)iChannelNumber<<KChannelNumberShift | (TUint8)request<<KExtraInfoShift );
|
|
458 |
// Active object should not give same request object twice before completing the first one.
|
|
459 |
ASSERT_RESET_ALWAYS( !iRequests[ request ].iDfcFunction, ( EIADSameRequestTwice | static_cast<TUint8>( iChannelNumber ) << KChannelNumberShift | static_cast<TUint8>( request ) << KExtraInfoShift ) );
|
|
460 |
//CompleteChannelRequest( request, KErrAlreadyExists );
|
|
461 |
}
|
|
462 |
else
|
|
463 |
{
|
|
464 |
C_TRACE( ( _T( "HandleDfcRequest handling %d 0x%x" ), request, this ) );
|
|
465 |
//NOTE! This are tight to isakernelapi parameter passing!!
|
|
466 |
C_TRACE( ( _T( "TBR *** TBR m.iArg[ 0 ]=0x%x m.iArg[ 1 ]=0x%x m.iArg[ 2 ]=0x%x m.iArg[ 3 ]=0x%x "), m.iArg[ 0 ], m.iArg[ 1 ], m.iArg[ 2 ], m.iArg[ 3 ] ) );
|
|
467 |
TUint32* tablePtr = reinterpret_cast<TUint32*>( m.Ptr0() );
|
|
468 |
TInt* dfcStatus = reinterpret_cast<TInt*>( tablePtr[ 0 ] );
|
|
469 |
TDfc* dfc = reinterpret_cast<TDfc*>( tablePtr[ 1 ] );
|
|
470 |
ASSERT_RESET_ALWAYS( dfcStatus, EIADNullParameter | EIADFaultIdentifier2 << KFaultIdentifierShift );
|
|
471 |
ASSERT_RESET_ALWAYS( dfc, EIADNullParameter | EIADFaultIdentifier3 << KFaultIdentifierShift );
|
|
472 |
iRequests[ request ].iDfcFunction = dfc;
|
|
473 |
iRequests[ request ].iRequestStatus = dfcStatus;
|
|
474 |
// Set the request to pending.
|
|
475 |
*iRequests[ request ].iRequestStatus = KRequestPending;
|
|
476 |
C_TRACE( ( _T( "HandleDfcRequest dfc 0x%x dfcStatus 0x%x dfcStatus %d " ), iRequests[ request ].iDfcFunction, iRequests[ request ].iRequestStatus, *iRequests[ request ].iRequestStatus ) );
|
|
477 |
switch( request )
|
|
478 |
{
|
|
479 |
case EIADAsyncOpen:
|
|
480 |
{
|
|
481 |
C_TRACE( ( _T( "HandleDfcRequest EIADNokiaKernelOpen 0x%x" ), this ) );
|
|
482 |
iChannelNumber = tablePtr[ KThirdParam ];
|
|
483 |
iChannelNumber = ~iChannelNumber;
|
|
484 |
C_TRACE( ( _T( "HandleDfcRequest EIADNokiaKernelOpen 0x%x 0x%x TBR" ), iChannelNumber, ~iChannelNumber ) );
|
|
485 |
const TDesC8& resource = *reinterpret_cast<const TDesC8*>( tablePtr[ KFourthParam ] );
|
|
486 |
ASSERT_RESET_ALWAYS( resource.Length() > ( 3 ), EIADOverTheLimits | EIADFaultIdentifier37 << KFaultIdentifierShift );
|
|
487 |
C_TRACE( ( _T( "0x%x 0x%x 0x%x 0x%x TBR" ), resource[ 0 ], resource[ 1 ], resource[ 2 ], resource[ 3 ] ) );
|
|
488 |
if( PN_NO_ROUTING == resource[ KFourthParam ] )
|
|
489 |
{
|
|
490 |
C_TRACE( ( _T( "HandleDfcRequest EIADNokiaKernelOpen normal 0x%x" ), this ) );
|
|
491 |
iExtensionApi->Open( ~iChannelNumber, request, this );
|
|
492 |
}
|
|
493 |
else
|
|
494 |
{
|
|
495 |
// TODO : trace works only for 8-bit values.
|
|
496 |
C_TRACE( ( _T( "HandleDfcRequest EIADNokiaKernelOpen resource 0x%x 0x%x" ), resource[ KFourthParam ], this ) );
|
|
497 |
iExtensionApi->Open( ~iChannelNumber, request, resource, this );
|
|
498 |
}
|
|
499 |
break;
|
|
500 |
}
|
|
501 |
case EIADAsyncNotifyConnectionStatus:
|
|
502 |
{
|
|
503 |
C_TRACE( ( _T( "HandleDfcRequest EIADAsyncNotifyConnectionStatus 0x%x" ), this ) );
|
|
504 |
// Nothing to do, the dfc and status are marked as active.
|
|
505 |
break;
|
|
506 |
}
|
|
507 |
case EIADAsyncNotifyFlowControlStatus:
|
|
508 |
{
|
|
509 |
C_TRACE( ( _T( "HandleDfcRequest EIADAsyncNotifyFlowControlStatus 0x%x" ), this ) );
|
|
510 |
// Nothing to do, the dfc and status are marked as active.
|
|
511 |
break;
|
|
512 |
}
|
|
513 |
case EIADAsyncReceive:
|
|
514 |
{
|
|
515 |
C_TRACE( ( _T( "HandleDfcRequest EIADAsyncReceive 0x%x" ), this ) );
|
|
516 |
ASSERT_RESET_ALWAYS( !iPtrPtrToRxBuf, EIADBufferNotReleased | ( iChannelNumber << KChannelNumberShift ) );
|
|
517 |
iPtrPtrToRxBuf = reinterpret_cast<TDes8**>( tablePtr[ KThirdParam ] );
|
|
518 |
C_TRACE( ( _T( "PTR iPtrPtrToRxBuf PTR 0x%x REF 0x%x" ), iPtrPtrToRxBuf, &iPtrPtrToRxBuf ) );
|
|
519 |
C_TRACE( ( _T( "HandleDfcRequest EIADAsyncReceive 0x%x 0x%x" ), this, iPtrPtrToRxBuf ) );
|
|
520 |
iEmptyRxDfc->Enque();
|
|
521 |
break;
|
|
522 |
}
|
|
523 |
case EIADAsyncDataReceive:
|
|
524 |
{
|
|
525 |
C_TRACE( ( _T( "HandleDfcRequest EIADAsyncDataReceive 0x%x" ), this ) );
|
|
526 |
ASSERT_RESET_ALWAYS( !iPtrPtrToDataRxBuf, EIADBufferNotReleased | ( iChannelNumber << KChannelNumberShift ) );
|
|
527 |
iPtrPtrToDataRxBuf = reinterpret_cast<TDes8**>( tablePtr[ KThirdParam ] );
|
|
528 |
C_TRACE( ( _T( "PTR iPtrPtrToDataRxBuf PTR 0x%x REF 0x%x" ), iPtrPtrToDataRxBuf, &iPtrPtrToDataRxBuf ) );
|
|
529 |
C_TRACE( ( _T( "HandleDfcRequest EIADAsyncDataReceive 0x%x 0x%x" ), this, iPtrPtrToDataRxBuf ) );
|
|
530 |
iEmptyDataRxDfc->Enque();
|
|
531 |
break;
|
|
532 |
}
|
|
533 |
default:
|
|
534 |
{
|
|
535 |
ASSERT_RESET_ALWAYS( 0, EIADWrongRequest | EIADFaultIdentifier2 << KFaultIdentifierShift );
|
|
536 |
break;
|
|
537 |
}
|
|
538 |
}
|
|
539 |
}
|
|
540 |
C_TRACE( ( _T( "DISAKernelChannel::HandleDfcRequest 0x%x <-" ), &aMsg ) );
|
|
541 |
|
|
542 |
}
|
|
543 |
|
|
544 |
|
|
545 |
TInt DISAKernelChannel::HandleSyncRequest(
|
|
546 |
TThreadMessage& aMsg
|
|
547 |
)
|
|
548 |
{
|
|
549 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_HANDLESYNCREQUEST_ENTRY, ">DISAKernelChannel::HandleSyncRequest;aMsg=%x", ( TUint )&( aMsg ) );
|
|
550 |
|
|
551 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest 0x%x ->" ), &aMsg ) );
|
|
552 |
TThreadMessage& m = ( aMsg );
|
|
553 |
TInt request( m.iValue );
|
|
554 |
ASSERT_RESET_ALWAYS( m.iArg, EIADNullParameter | EIADFaultIdentifier4 << KFaultIdentifierShift );
|
|
555 |
TInt returnValue( KErrNone );
|
|
556 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest handling %d 0x%x" ), request, this ) );
|
|
557 |
//NOTE! These are tight to isakernelapi parameter passing!!
|
|
558 |
TUint32* tablePtr = reinterpret_cast<TUint32*>( m.Ptr0() );
|
|
559 |
switch( request )
|
|
560 |
{
|
|
561 |
case EIADClose:
|
|
562 |
{
|
|
563 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADClose 0x%x" ), this ) );
|
|
564 |
ResetQueues();
|
|
565 |
for( TInt i( KErrNone ); i < EIADAsyncLast; ++i )
|
|
566 |
{
|
|
567 |
C_TRACE( ( _T( "DISAKernelChannel::CancelRequests req to cancel %d" ), i ) );
|
|
568 |
DoCancel( KMaxTInt, i );
|
|
569 |
}
|
|
570 |
Close( iChannelNumber );
|
|
571 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADClose 0x%x 0x%x == 0x%x " ), this, iChannelNumber, KNotInitializedChannel ) );
|
|
572 |
break;
|
|
573 |
}
|
|
574 |
case EIADAllocateBlock:
|
|
575 |
{
|
|
576 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADAllocateBlock 0x%x" ), this ) );
|
|
577 |
const TInt size = *reinterpret_cast<TInt*>( tablePtr[ KFirstParam ] );
|
|
578 |
TDes8*& block = *(reinterpret_cast<TDes8**>( tablePtr[ KSecondParam ] ));
|
|
579 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADAllocateBlock 0x%x 0x%x TBR" ), this, block ) );
|
|
580 |
block = ( &iExtensionApi->AllocateBlock( size ) );
|
|
581 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADAllocateBlock 0x%x 0x%x TBR2" ), this, block ) );
|
|
582 |
break;
|
|
583 |
}
|
|
584 |
case EIADAllocateDataBlock:
|
|
585 |
{
|
|
586 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADAllocateDataBlock 0x%x" ), this ) );
|
|
587 |
const TInt size = *reinterpret_cast<TInt*>( tablePtr[ KFirstParam ] );
|
|
588 |
TDes8*& block = *(reinterpret_cast<TDes8**>( tablePtr[ KSecondParam ] ));
|
|
589 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADAllocateDataBlock 0x%x 0x%x TBR" ), this, block ) );
|
|
590 |
block = ( &iExtensionApi->AllocateDataBlock( size ) );
|
|
591 |
C_TRACE( ( _T( "GET block 0x%x length %d maxLength %d" ), &block, block->Length(), block->MaxLength() ) );
|
|
592 |
TInt tmpLength( block->MaxLength() - KPipeDataHeader );
|
|
593 |
TUint8* tmpPtr( const_cast<TUint8*>( ( block->Ptr() + KPipeDataHeader ) ) );
|
|
594 |
TPtr* test = static_cast<TPtr8*>( block );
|
|
595 |
test->Set( tmpPtr, 0, tmpLength );
|
|
596 |
C_TRACE( ( _T( "MOD block 0x%x length %d maxLength %d tmpPtr = 0x%x tmpPtr-KPipeDataHeader=0x%x" ), &block, block->Length(), block->MaxLength(), tmpPtr, ( tmpPtr - KPipeDataHeader ) ) );
|
|
597 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADAllocateDataBlock 0x%x 0x%x TBR2" ), this, block ) );
|
|
598 |
break;
|
|
599 |
}
|
|
600 |
case EIADDeAllocateBlock:
|
|
601 |
{
|
|
602 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADDeAllocateBlock 0x%x" ), this ) );
|
|
603 |
TDes8& block = *reinterpret_cast<TDes8*>( tablePtr[ KFirstParam ] );
|
|
604 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADDeAllocateBlock 0x%x 0x%x TBR2" ), this, &block ) );
|
|
605 |
// Needed to ensure that right channel is deleting the right block. (Could it be done otherways too?)
|
|
606 |
if( iPtrPtrToRxBuf )
|
|
607 |
{
|
|
608 |
if ( &block == *iPtrPtrToRxBuf )
|
|
609 |
{
|
|
610 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest release iPtrPtrToRxBuf") ) );
|
|
611 |
iPtrPtrToRxBuf = NULL;
|
|
612 |
}
|
|
613 |
}
|
|
614 |
iExtensionApi->DeAllocateBlock( block );
|
|
615 |
break;
|
|
616 |
}
|
|
617 |
case EIADDeAllocateDataBlock:
|
|
618 |
{
|
|
619 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADDeAllocateDataBlock 0x%x" ), this ) );
|
|
620 |
// Needed to ensure that right channel is deleting the right block. (Could it be done otherways too?)
|
|
621 |
TPtr8& block = *reinterpret_cast<TPtr8*>( tablePtr[ KFirstParam ] );
|
|
622 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADDeAllocateDataBlock 0x%x 0x%x TBR2" ), this, &block ) );
|
|
623 |
if( iPtrPtrToDataRxBuf )
|
|
624 |
{
|
|
625 |
if ( &block == *iPtrPtrToDataRxBuf ) // TODO: do less branches
|
|
626 |
{
|
|
627 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest release iPtrPtrToDataRxBuf") ) );
|
|
628 |
iPtrPtrToDataRxBuf = NULL;
|
|
629 |
}
|
|
630 |
}
|
|
631 |
TDes8* block2 = █
|
|
632 |
TDes8*& tmpPtrPtr = *( &block2 );
|
|
633 |
TInt tmpLength( ( block2->Length() + KPipeDataHeader ) );
|
|
634 |
TInt tmpMaxLength( ( block2->MaxLength() + KPipeDataHeader ) );
|
|
635 |
TUint8* tmpPtr( const_cast<TUint8*>( ( tmpPtrPtr->Ptr() - KPipeDataHeader ) ) );
|
|
636 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADDeAllocateDataBlock TBR tmpPtr=0x%x tmpPtr+KPipeDataHeader=0x%x TBR2" ), tmpPtr, (tmpPtr+KPipeDataHeader) ) );
|
|
637 |
block.Set( tmpPtr, tmpLength, tmpMaxLength );
|
|
638 |
iExtensionApi->DeAllocateBlock( block );
|
|
639 |
ASSERT_RESET_ALWAYS( iPep, EIADNullParameter | EIADFaultIdentifier28 << KFaultIdentifierShift );
|
|
640 |
iPep->DataMessageDelivered();
|
|
641 |
|
|
642 |
|
|
643 |
break;
|
|
644 |
}
|
|
645 |
case EIADSend:
|
|
646 |
{
|
|
647 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADSend 0x%x" ), this ) );
|
|
648 |
TDes8& block = *reinterpret_cast<TDes8*>( tablePtr[ KFirstParam ] );
|
|
649 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADSend 0x%x 0x%x TBR2" ), this, &block ) );
|
|
650 |
returnValue = iExtensionApi->SendMessage( block, iChannelNumber );
|
|
651 |
break;
|
|
652 |
}
|
|
653 |
case EIADDataSend:
|
|
654 |
{
|
|
655 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADDataSend 0x%x" ), this ) );
|
|
656 |
TPtr8& block = *reinterpret_cast<TPtr8*>( tablePtr[ KFirstParam ] );
|
|
657 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADDataSend 0x%x 0x%x TBR2" ), this, &block ) );
|
|
658 |
TDes8* block2 = █
|
|
659 |
TDes8*& tmpPtrPtr = *( &block2 );
|
|
660 |
TInt tmpLength( ( block2->Length() + KPipeDataHeader ) );
|
|
661 |
TInt tmpMaxLength( ( block2->MaxLength() + KPipeDataHeader ) );
|
|
662 |
TUint8* tmpPtr( const_cast<TUint8*>( ( tmpPtrPtr->Ptr() - KPipeDataHeader ) ) );
|
|
663 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADDeAllocateDataBlock TBR tmpPtr=0x%x tmpPtr+KPipeDataHeader=0x%x TBR2" ), tmpPtr, (tmpPtr+KPipeDataHeader) ) );
|
|
664 |
block.Set( tmpPtr, tmpLength, tmpMaxLength );
|
|
665 |
returnValue = iExtensionApi->SendMessage( block, iChannelNumber );
|
|
666 |
break;
|
|
667 |
}
|
|
668 |
case EIADSendIndication:
|
|
669 |
{
|
|
670 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADSendIndication 0x%x" ), this ) );
|
|
671 |
TDes8& block = *reinterpret_cast<TDes8*>( tablePtr[ KFirstParam ] );
|
|
672 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADSendIndication 0x%x 0x%x TBR2" ), this, &block ) );
|
|
673 |
returnValue = iExtensionApi->SendIndication( block, iChannelNumber );
|
|
674 |
break;
|
|
675 |
}
|
|
676 |
case EIADSubscribeIndications:
|
|
677 |
case EIADSubscribeIndications32Bit:
|
|
678 |
{
|
|
679 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EIADSubscribeIndications | EIADSubscribeIndications32Bit:0x%x" ), this ) );
|
|
680 |
TDes8& subscription = *reinterpret_cast<TDes8*>( tablePtr[ KFirstParam ] );
|
|
681 |
TBool thirtyTwoBit( EIADSubscribeIndications32Bit == request ? ETrue : EFalse );
|
|
682 |
returnValue = iExtensionApi->OrderIndication( subscription, iChannelNumber, thirtyTwoBit );
|
|
683 |
break;
|
|
684 |
}
|
|
685 |
default:
|
|
686 |
{
|
|
687 |
ASSERT_RESET_ALWAYS( 0, EIADWrongRequest | EIADFaultIdentifier3 << KFaultIdentifierShift );
|
|
688 |
break;
|
|
689 |
}
|
|
690 |
}
|
|
691 |
C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest 0x%x %d <-" ), &aMsg, returnValue ) );
|
|
692 |
return returnValue;
|
|
693 |
|
|
694 |
}
|
|
695 |
|
|
696 |
void DISAKernelChannel::EmptyRxDfc(
|
|
697 |
TAny* aPtr // self
|
|
698 |
)
|
|
699 |
{
|
|
700 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_EMPTYRXDFC_ENTRY, ">DISAKernelChannel::EmptyRxDfc;aPtr=%x", ( TUint )( aPtr ) );
|
|
701 |
|
|
702 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyRxDfc ->" ) ) );
|
|
703 |
DISAKernelChannel& chTmp = *reinterpret_cast<DISAKernelChannel*>( aPtr );
|
|
704 |
if( ( chTmp.iRequests[ EIADAsyncReceive ].iDfcFunction ) && ( chTmp.iRx->Count() > 0 ) )
|
|
705 |
{
|
|
706 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyRxDfc 0x%x writing to kernel client" ), chTmp.iChannelNumber ) );
|
|
707 |
TDes8*& tmpWrite = *chTmp.iPtrPtrToRxBuf;
|
|
708 |
tmpWrite = &chTmp.iRx->Get();
|
|
709 |
C_TRACE( ( _T( "PTR2 iPtrPtrToRxBuf PTR 0x%x REF 0x%x" ), chTmp.iPtrPtrToRxBuf, &chTmp.iPtrPtrToRxBuf ) );
|
|
710 |
OstTraceExt2( TRACE_NORMAL, DISAKERNELCHANNEL_EMPTYRXDFC, "DISAKernelChannel::EmptyRxDfc;iPtrPtrToRxBuf=%x;iPtrPtrToRxBuf_ref=%x", (TUint)(chTmp.iPtrPtrToRxBuf), (TUint)&(chTmp.iPtrPtrToRxBuf) );
|
|
711 |
|
|
712 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyRxDfc client 0x%x " ), *chTmp.iPtrPtrToRxBuf ) );
|
|
713 |
chTmp.CompleteChannelRequest( EIADAsyncReceive, KErrNone );
|
|
714 |
}
|
|
715 |
else
|
|
716 |
{
|
|
717 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyRxDfc 0x%x no receive active or no message" ), chTmp.iChannelNumber ) );
|
|
718 |
OstTraceExt1( TRACE_NORMAL, DUP1_DISAKERNELCHANNEL_EMPTYRXDFC, "DISAKernelChannel::EmptyRxDfc;iChannelNumber=%hx", chTmp.iChannelNumber );
|
|
719 |
|
|
720 |
}
|
|
721 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyRxDfc <-" ) ) );
|
|
722 |
|
|
723 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_EMPTYRXDFC_EXIT, "<DISAKernelChannel::EmptyRxDfc" );
|
|
724 |
}
|
|
725 |
|
|
726 |
void DISAKernelChannel::EmptyDataRxDfc(
|
|
727 |
TAny* aPtr // self
|
|
728 |
)
|
|
729 |
{
|
|
730 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_EMPTYDATARXDFC_ENTRY, ">DISAKernelChannel::EmptyDataRxDfc;aPtr=%x", ( TUint )( aPtr ) );
|
|
731 |
|
|
732 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyDataRxDfc ->" ) ) );
|
|
733 |
DISAKernelChannel& chTmp = *reinterpret_cast<DISAKernelChannel*>( aPtr );
|
|
734 |
if( ( chTmp.iRequests[ EIADAsyncDataReceive ].iDfcFunction ) && ( chTmp.iDataRx->Count() > 0 ) )
|
|
735 |
{
|
|
736 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyDataRxDfc 0x%x writing to kernel client" ), chTmp.iChannelNumber ) );
|
|
737 |
TDes8*& tmpWrite = ( *chTmp.iPtrPtrToDataRxBuf );
|
|
738 |
tmpWrite = ( &chTmp.iDataRx->Get() );
|
|
739 |
C_TRACE( ( _T( "GET tmpWrite 0x%x length %d maxLength %d" ), &tmpWrite, tmpWrite->Length(), tmpWrite->MaxLength() ) );
|
|
740 |
// Adjust the start not to contain pipe header!
|
|
741 |
TInt tmpLength( tmpWrite->Length() - KPipeDataHeader );
|
|
742 |
TInt tmpMaxLength( tmpWrite->MaxLength() - KPipeDataHeader );
|
|
743 |
TUint8* tmpPtr( const_cast<TUint8*>( ( tmpWrite->Ptr() + KPipeDataHeader ) ) );
|
|
744 |
TPtr* test = static_cast<TPtr8*>(tmpWrite);
|
|
745 |
test->Set( tmpPtr, tmpLength, tmpMaxLength );
|
|
746 |
C_TRACE( ( _T( "MOD tmpWrite 0x%x length %d maxLength %d" ), &tmpWrite, tmpWrite->Length(), tmpWrite->MaxLength() ) );
|
|
747 |
C_TRACE( ( _T( "PTR2 iPtrPtrToDataRxBuf PTR 0x%x REF 0x%x" ), chTmp.iPtrPtrToDataRxBuf, &chTmp.iPtrPtrToDataRxBuf ) );
|
|
748 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyDataRxDfc client 0x%x " ), *chTmp.iPtrPtrToDataRxBuf ) );
|
|
749 |
OstTraceExt3( TRACE_NORMAL, DISAKERNELCHANNEL_EMPTYDATARXDFC, "DISAKernelChannel::EmptyDataRxDfc;tmpWrite=%x;iPtrPtrToDataRxBuf=%x;iPtrPtrToDataRxBuf_ref=%x", (TUint)&(tmpWrite), (TUint)(chTmp.iPtrPtrToDataRxBuf), (TUint)&(chTmp.iPtrPtrToDataRxBuf) );
|
|
750 |
|
|
751 |
chTmp.CompleteChannelRequest( EIADAsyncDataReceive, KErrNone );
|
|
752 |
}
|
|
753 |
else
|
|
754 |
{
|
|
755 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyDataRxDfc 0x%x no datareceive active or no datamessage" ), chTmp.iChannelNumber ) );
|
|
756 |
OstTraceExt1( TRACE_NORMAL, DUP1_DISAKERNELCHANNEL_EMPTYDATARXDFC, "DISAKernelChannel::EmptyDataRxDfc;iChannelNumber=%hx", chTmp.iChannelNumber );
|
|
757 |
|
|
758 |
}
|
|
759 |
C_TRACE( ( _T( "DISAKernelChannel::EmptyDataRxDfc <-" ) ) );
|
|
760 |
|
|
761 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_EMPTYDATARXDFC_EXIT, "<DISAKernelChannel::EmptyDataRxDfc" );
|
|
762 |
}
|
|
763 |
|
|
764 |
void DISAKernelChannel::DoCancel(
|
|
765 |
TInt aRequest,
|
|
766 |
TInt aMask )
|
|
767 |
{
|
|
768 |
OstTraceExt2( TRACE_NORMAL, DISAKERNELCHANNEL_DOCANCEL_ENTRY, ">DISAKernelChannel::DoCancel;aRequest=%d;aMask=%d", aRequest, aMask );
|
|
769 |
|
|
770 |
C_TRACE( ( _T( "DISAKernelChannel::DoCancel ->" ) ) );
|
|
771 |
ASSERT_RESET_ALWAYS( EIADAsyncLast > ( aMask&aRequest ), EIADOverTheLimits | EIADFaultIdentifier38 << KFaultIdentifierShift );
|
|
772 |
if( iRequests[ aMask&aRequest ].iDfcFunction )
|
|
773 |
{
|
|
774 |
switch( aMask&aRequest )
|
|
775 |
{
|
|
776 |
case EIADAsyncNotifyFlowControlStatus:
|
|
777 |
{
|
|
778 |
// Nothing to do. Just cancel with KErrCancel.
|
|
779 |
C_TRACE( ( _T( "DISAKernelChannel::DoCancel EIADAsyncNotifyFlowControlStatus nothing" ) ) );
|
|
780 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DOCANCEL_FLOW, "DISAKernelChannel::DoCancel EIADAsyncNotifyFlowControlStatus nothing" );
|
|
781 |
|
|
782 |
break;
|
|
783 |
}
|
|
784 |
case EIADAsyncNotifyConnectionStatus:
|
|
785 |
{
|
|
786 |
// Nothing to do. Just cancel with KErrCancel.
|
|
787 |
C_TRACE( ( _T( "DISAKernelChannel::DoCancel EIADAsyncNotifyConnectionStatus nothing" ) ) );
|
|
788 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DOCANCEL_CONNSTATUS, "DISAKernelChannel::DoCancel EIADAsyncNotifyConnectionStatus nothing" );
|
|
789 |
|
|
790 |
break;
|
|
791 |
}
|
|
792 |
case EIADAsyncReceive:
|
|
793 |
{
|
|
794 |
C_TRACE( ( _T( "DISAKernelChannel::DoCancel EIADAsyncReceive iPtrPtrToRxBuf 0x%x -> NULL" ), iPtrPtrToRxBuf ) );
|
|
795 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_DOCANCEL_RECEIVE, "DISAKernelChannel::DoCancel EIADAsyncDataReceive;iPtrPtrToRxBuf=%x", iPtrPtrToRxBuf );
|
|
796 |
|
|
797 |
iPtrPtrToRxBuf = NULL;
|
|
798 |
break;
|
|
799 |
}
|
|
800 |
case EIADAsyncDataReceive:
|
|
801 |
{
|
|
802 |
C_TRACE( ( _T( "DISAKernelChannel::DoCancel EIADAsyncDataReceive iPtrPtrToDataRxBuf 0x%x -> NULL" ), iPtrPtrToDataRxBuf ) );
|
|
803 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_DOCANCEL_DATARECEIVE, "DISAKernelChannel::DoCancel EIADAsyncDataReceive;iPtrPtrToDataRxBuf=%x", iPtrPtrToDataRxBuf );
|
|
804 |
iPtrPtrToDataRxBuf = NULL;
|
|
805 |
break;
|
|
806 |
}
|
|
807 |
case EIADAsyncOpen:
|
|
808 |
{
|
|
809 |
C_TRACE( ( _T( "DISAKernelChannel::DoCancel EIADAsyncOpen nothing" ) ) );
|
|
810 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DOCANCEL_OPEN, "DISAKernelChannel::DoCancel EIADAsyncOpen" );
|
|
811 |
|
|
812 |
ResetQueues();
|
|
813 |
Close( ~iChannelNumber );
|
|
814 |
break;
|
|
815 |
}
|
|
816 |
default:
|
|
817 |
{
|
|
818 |
ASSERT_RESET_ALWAYS( 0, EIADWrongRequest | EIADFaultIdentifier4 << KFaultIdentifierShift );
|
|
819 |
break;
|
|
820 |
}
|
|
821 |
}
|
|
822 |
CompleteChannelRequest( aMask&aRequest, KErrCancel );
|
|
823 |
}
|
|
824 |
else
|
|
825 |
{
|
|
826 |
C_TRACE( ( _T( "DISAKernelChannel::DoCancel nothing to cancel" ) ) );
|
|
827 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DOCANCEL_IGNORE, "DISAKernelChannel::DoCancel nothing to cancel" );
|
|
828 |
|
|
829 |
}
|
|
830 |
C_TRACE( ( _T( "DISAKernelChannel::DoCancel <-" ) ) );
|
|
831 |
|
|
832 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_DOCANCEL_EXIT, "<DISAKernelChannel::DoCancel" );
|
|
833 |
}
|
|
834 |
|
|
835 |
void DISAKernelChannel::ResetQueues(
|
|
836 |
// None
|
|
837 |
)
|
|
838 |
{
|
|
839 |
OstTraceExt1( TRACE_NORMAL, DISAKERNELCHANNEL_RESETQUEUES_ENTRY, ">DISAKernelChannel::ResetQueues;iChannelNumber=%hx", iChannelNumber );
|
|
840 |
|
|
841 |
// TODO: SSI cancel pending sending
|
|
842 |
C_TRACE( ( _T( "DISAKernelChannel::ResetQueues 0x%x ->" ), iChannelNumber ) );
|
|
843 |
if( iRx )
|
|
844 |
{
|
|
845 |
C_TRACE( ( _T( "DISAKernelChannel::ResetQueues 0x%x iRx 0x%x" ), iChannelNumber, iRx ) );
|
|
846 |
OstTraceExt2( TRACE_NORMAL, DISAKERNELCHANNEL_RESETQUEUES, "DISAKernelChannel::ResetQueues Rx;iChannelNumber=%hx;iRx=%x", iChannelNumber, (TUint)(iRx) );
|
|
847 |
|
|
848 |
while( iRx->Count() )
|
|
849 |
{
|
|
850 |
iExtensionApi->DeAllocateBlock( iRx->Get() );
|
|
851 |
}
|
|
852 |
}
|
|
853 |
if( iDataRx )
|
|
854 |
{
|
|
855 |
C_TRACE( ( _T( "DISAKernelChannel::ResetQueues 0x%x iDataRx 0x%x" ), iChannelNumber, iDataRx ) );
|
|
856 |
OstTrace1( TRACE_NORMAL, DISAKERNELCHANNEL_RESETQUEUES_DATA, "DISAKernelChannel::ResetQueues;iDataRx=%x", iDataRx );
|
|
857 |
|
|
858 |
while( iDataRx->Count() )
|
|
859 |
{
|
|
860 |
iExtensionApi->DeAllocateBlock( iDataRx->Get() );
|
|
861 |
}
|
|
862 |
}
|
|
863 |
C_TRACE( ( _T( "DISAKernelChannel::ResetQueues 0x%x <-" ), iChannelNumber ) );
|
|
864 |
|
|
865 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_RESETQUEUES_EXIT, "<DISAKernelChannel::ResetQueues" );
|
|
866 |
}
|
|
867 |
|
|
868 |
void DISAKernelChannel::Close(
|
|
869 |
const TUint16 aChannelId
|
|
870 |
)
|
|
871 |
{
|
|
872 |
OstTraceExt1( TRACE_NORMAL, DISAKERNELCHANNEL_CLOSE_ENTRY, ">DISAKernelChannel::Close;aChannelId=%hx", aChannelId );
|
|
873 |
|
|
874 |
C_TRACE( ( _T( "DISAKernelChannel::Close 0x%x 0x%x ->" ), iChannelNumber, aChannelId ) );
|
|
875 |
iExtensionApi->Close( aChannelId );
|
|
876 |
iChannelNumber = KNotInitializedChannel;
|
|
877 |
C_TRACE( ( _T( "DISAKernelChannel::Close 0x%x 0x%x <-" ), iChannelNumber, aChannelId ) );
|
|
878 |
|
|
879 |
OstTrace0( TRACE_NORMAL, DISAKERNELCHANNEL_CLOSE_EXIT, "<DISAKernelChannel::Close" );
|
|
880 |
}
|
|
881 |
|
|
882 |
// End of file.
|
|
883 |
|