|
0
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2006 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 "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 |
#ifdef __WINS__
|
|
|
20 |
#error - this driver cannot be built for emulation
|
|
|
21 |
#endif
|
|
|
22 |
|
|
|
23 |
#include <e32def.h>
|
|
|
24 |
#include <e32cmn.h>
|
|
|
25 |
#include <kernel.h>
|
|
|
26 |
#include <kern_priv.h>
|
|
|
27 |
#include <arm.h>
|
|
|
28 |
|
|
|
29 |
#include "TrkDccComm.h"
|
|
|
30 |
#include "TrkDccDriver.h"
|
|
|
31 |
|
|
|
32 |
//This macro turns on DCC3 mode, this is always turned on.
|
|
|
33 |
//To test DCC1 mode, comment this out and make sure to configure T32 to use DCC1 as well.
|
|
|
34 |
#define DCC3
|
|
|
35 |
|
|
|
36 |
//currenly both start and end bytes for the packet are the same
|
|
|
37 |
#define PKT_STRT_BYTE 0x7E
|
|
|
38 |
#define PKT_END_BYTE 0x7E
|
|
|
39 |
|
|
|
40 |
#define KTrkAppSecurUid 0x200170BB
|
|
|
41 |
#define KTrkExeSecurUid 0x200159E2
|
|
|
42 |
//
|
|
|
43 |
// Static function definitions
|
|
|
44 |
//
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
//
|
|
|
48 |
//
|
|
|
49 |
// DTrkDccDriverFactory implementation
|
|
|
50 |
//
|
|
|
51 |
//
|
|
|
52 |
|
|
|
53 |
//
|
|
|
54 |
// DTrkDccDriverFactory constructor
|
|
|
55 |
//
|
|
|
56 |
DTrkDccDriverFactory::DTrkDccDriverFactory()
|
|
|
57 |
{
|
|
|
58 |
iVersion = TVersion(KMajorDccVersionNumber, KMinorDccVersionNumber, KBuildDccVersionNumber);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
//
|
|
|
62 |
// DTrkDccDriverFactory::Create
|
|
|
63 |
//
|
|
|
64 |
TInt DTrkDccDriverFactory::Create(DLogicalChannelBase*& aChannel)
|
|
|
65 |
{
|
|
|
66 |
if (iOpenChannels != 0)
|
|
|
67 |
return KErrInUse; // a channel is already open
|
|
|
68 |
|
|
|
69 |
aChannel = new DTrkDccChannel(this);
|
|
|
70 |
|
|
|
71 |
return aChannel ? KErrNone : KErrNoMemory;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
//
|
|
|
75 |
// DTrkDccDriverFactory::Install
|
|
|
76 |
//
|
|
|
77 |
TInt DTrkDccDriverFactory::Install()
|
|
|
78 |
{
|
|
|
79 |
return(SetName(&KTrkDccDriverName));
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
//
|
|
|
83 |
// DTrkDccDriverFactory::Install
|
|
|
84 |
//
|
|
|
85 |
void DTrkDccDriverFactory::GetCaps(TDes8& aDes) const
|
|
|
86 |
{
|
|
|
87 |
TCapsTrkDccDriver b;
|
|
|
88 |
b.iVersion = TVersion(KMajorDccVersionNumber, KMinorDccVersionNumber, KBuildDccVersionNumber);
|
|
|
89 |
|
|
|
90 |
Kern::InfoCopy(aDes,(TUint8*)&b, sizeof(b));
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
//
|
|
|
95 |
//
|
|
|
96 |
// DTrkDccChannel implementation
|
|
|
97 |
//
|
|
|
98 |
//
|
|
|
99 |
|
|
|
100 |
//
|
|
|
101 |
// DTrkDccChannel constructor
|
|
|
102 |
//
|
|
|
103 |
DTrkDccChannel::DTrkDccChannel(DLogicalDevice* aLogicalDevice)
|
|
|
104 |
: iRxTimer(DTrkDccChannel::RxTimerCallBack, this),
|
|
|
105 |
iRxBufSize(MAXMESSAGESIZE*2),
|
|
|
106 |
iRxGetIndx(0),
|
|
|
107 |
iRxPutIndx(0),
|
|
|
108 |
iRxCompleteDfc(DTrkDccChannel::RxTimerDfc, this, 2),
|
|
|
109 |
iInterruptId(76),
|
|
|
110 |
iPacketStarted(EFalse),
|
|
|
111 |
iPacketEnded(EFalse)
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
{
|
|
|
115 |
LOG_MSG("DTrkDccChannel::DTrkDccChannel()");
|
|
|
116 |
|
|
|
117 |
iDevice = aLogicalDevice;
|
|
|
118 |
|
|
|
119 |
iClientThread = &Kern::CurrentThread();
|
|
|
120 |
TInt err = iClientThread->Open();
|
|
|
121 |
|
|
|
122 |
iRxTimeOut = NKern::TimerTicks(1);
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
//
|
|
|
126 |
// DTrkDccChannel destructor
|
|
|
127 |
//
|
|
|
128 |
DTrkDccChannel::~DTrkDccChannel()
|
|
|
129 |
{
|
|
|
130 |
LOG_MSG("DTrkDccChannel::~DTrkDccChannel()");
|
|
|
131 |
|
|
|
132 |
iRxTimer.Cancel();
|
|
|
133 |
|
|
|
134 |
if (iRxBuffer)
|
|
|
135 |
{
|
|
|
136 |
delete iRxBuffer;
|
|
|
137 |
iRxBuffer = NULL;
|
|
|
138 |
}
|
|
|
139 |
if (iLock)
|
|
|
140 |
iLock->Close(NULL);
|
|
|
141 |
|
|
|
142 |
Kern::SafeClose((DObject*&)iClientThread, NULL);
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
//
|
|
|
146 |
// DTrkDccChannel::DoCreate
|
|
|
147 |
//
|
|
|
148 |
TInt DTrkDccChannel::DoCreate(TInt /*aUnit*/, const TDesC* /*anInfo*/, const TVersion& aVer)
|
|
|
149 |
{
|
|
|
150 |
LOG_MSG("DTrkDccChannel::DoCreate()");
|
|
|
151 |
|
|
|
152 |
if (!Kern::QueryVersionSupported(TVersion(KMajorDccVersionNumber, KMinorDccVersionNumber, KBuildDccVersionNumber), aVer))
|
|
|
153 |
return KErrNotSupported;
|
|
|
154 |
|
|
|
155 |
//Setup the driver for receiving client messages
|
|
|
156 |
iDFCQue = NULL;
|
|
|
157 |
TBuf8<KMaxInfoName> dccDFC = _L8("DCC DFC");;
|
|
|
158 |
|
|
|
159 |
TInt err = Kern::DfcQCreate(iDFCQue, 27, &dccDFC);
|
|
|
160 |
if (err == KErrNone)
|
|
|
161 |
{
|
|
|
162 |
SetDfcQ(iDFCQue);
|
|
|
163 |
}
|
|
|
164 |
else
|
|
|
165 |
{
|
|
|
166 |
SetDfcQ(Kern::DfcQue0());
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
iMsgQ.Receive();
|
|
|
170 |
|
|
|
171 |
iRxCompleteDfc.SetDfcQ(Kern::TimerDfcQ());
|
|
|
172 |
|
|
|
173 |
iRxBuffer=(TUint8*)Kern::Alloc(iRxBufSize);
|
|
|
174 |
|
|
|
175 |
err = Kern::SemaphoreCreate(iLock, _L("TrkDccDriverWriteLock"), 1 /* Initial count */);
|
|
|
176 |
if (err != KErrNone)
|
|
|
177 |
return err;
|
|
|
178 |
|
|
|
179 |
return KErrNone;
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
//
|
|
|
183 |
// DTrkDccChannel::DoCancel
|
|
|
184 |
//
|
|
|
185 |
void DTrkDccChannel::DoCancel(TInt aReqNo)
|
|
|
186 |
{
|
|
|
187 |
LOG_MSG("DTrkDccChannel::DoCancel()");
|
|
|
188 |
|
|
|
189 |
switch(aReqNo)
|
|
|
190 |
{
|
|
|
191 |
case RTrkDccDriver::ERequestReadCancel:
|
|
|
192 |
{
|
|
|
193 |
Kern::RequestComplete(iClientThread, iRxRequestStatus, KErrCancel);
|
|
|
194 |
iRxClientBuffer = NULL;
|
|
|
195 |
iRxRequestStatus = NULL;
|
|
|
196 |
iRxClientBufferLength = 0;
|
|
|
197 |
|
|
|
198 |
iRxTimer.Cancel();
|
|
|
199 |
}
|
|
|
200 |
break;
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
//
|
|
|
206 |
// DTrkDccChannel::DoRequest
|
|
|
207 |
//
|
|
|
208 |
void DTrkDccChannel::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2)
|
|
|
209 |
{
|
|
|
210 |
LOG_MSG("DTrkDccChannel::DoRequest()");
|
|
|
211 |
|
|
|
212 |
switch(aReqNo)
|
|
|
213 |
{
|
|
|
214 |
case RTrkDccDriver::ERequestRead:
|
|
|
215 |
{
|
|
|
216 |
iRxRequestStatus = aStatus;
|
|
|
217 |
iRxClientBuffer = a1;
|
|
|
218 |
iRxClientBufferLength = (TUint32)a2;
|
|
|
219 |
//start the polling timer...
|
|
|
220 |
iRxTimer.OneShot(iRxTimeOut);
|
|
|
221 |
break;
|
|
|
222 |
}
|
|
|
223 |
default:
|
|
|
224 |
Kern::RequestComplete(iClientThread, aStatus, KErrNotSupported);
|
|
|
225 |
}
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
//
|
|
|
229 |
// DTrkDccChannel::DoControl
|
|
|
230 |
//
|
|
|
231 |
TInt DTrkDccChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
|
|
|
232 |
{
|
|
|
233 |
LOG_MSG("DTrkDccChannel::DoControl()");
|
|
|
234 |
|
|
|
235 |
TInt err = KErrNone;
|
|
|
236 |
|
|
|
237 |
switch(aFunction)
|
|
|
238 |
{
|
|
|
239 |
case RTrkDccDriver::EControlWrite:
|
|
|
240 |
{
|
|
|
241 |
//lock the Semaphore so that write doesn't happen when a write is already in progress.
|
|
|
242 |
Kern::SemaphoreWait(*iLock);
|
|
|
243 |
err = DoWrite((TUint32)a1, a2);
|
|
|
244 |
Kern::SemaphoreSignal(*iLock);
|
|
|
245 |
break;
|
|
|
246 |
}
|
|
|
247 |
default:
|
|
|
248 |
{
|
|
|
249 |
return KErrGeneral;
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
}
|
|
|
253 |
if (KErrNone != err)
|
|
|
254 |
{
|
|
|
255 |
LOG_MSG2("Error %d from control function", err);
|
|
|
256 |
}
|
|
|
257 |
return err;
|
|
|
258 |
}
|
|
|
259 |
|
|
|
260 |
//
|
|
|
261 |
// DTrkDccChannel::HandleMsg
|
|
|
262 |
//
|
|
|
263 |
void DTrkDccChannel::HandleMsg(TMessageBase* aMsg)
|
|
|
264 |
{
|
|
|
265 |
LOG_MSG("DTrkDccChannel::HandleMsg()");
|
|
|
266 |
|
|
|
267 |
TThreadMessage& m = *(TThreadMessage*)aMsg;
|
|
|
268 |
TInt id = m.iValue;
|
|
|
269 |
|
|
|
270 |
|
|
|
271 |
if (id == (TInt)ECloseMsg)
|
|
|
272 |
{
|
|
|
273 |
m.Complete(KErrNone, EFalse);
|
|
|
274 |
return;
|
|
|
275 |
}
|
|
|
276 |
|
|
|
277 |
if (id == KMaxTInt)
|
|
|
278 |
{
|
|
|
279 |
// DoCancel
|
|
|
280 |
DoCancel(m.Int0());
|
|
|
281 |
m.Complete(KErrNone, ETrue);
|
|
|
282 |
return;
|
|
|
283 |
}
|
|
|
284 |
|
|
|
285 |
if (id < 0)
|
|
|
286 |
{
|
|
|
287 |
// DoRequest
|
|
|
288 |
TRequestStatus* pStatus = (TRequestStatus*)m.Ptr0();
|
|
|
289 |
DoRequest(~id, pStatus, m.Ptr1(), m.Ptr2());
|
|
|
290 |
m.Complete(KErrNone, ETrue);
|
|
|
291 |
}
|
|
|
292 |
else
|
|
|
293 |
{
|
|
|
294 |
// DoControl
|
|
|
295 |
TInt err = DoControl(id, m.Ptr0(), m.Ptr1());
|
|
|
296 |
m.Complete(err, ETrue);
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
|
|
|
300 |
//
|
|
|
301 |
// DTrkDccChannel::DoWrite
|
|
|
302 |
//
|
|
|
303 |
TInt DTrkDccChannel::DoWrite(TUint32 aLength, TAny* a2)
|
|
|
304 |
{
|
|
|
305 |
LOG_MSG("DTrkDccChannel::DoWrite()");
|
|
|
306 |
|
|
|
307 |
TInt err = KErrNone;
|
|
|
308 |
|
|
|
309 |
err = Kern::ThreadDesRead(iClientThread, a2, iTxBuffer, 0, KChunkShiftBy0);
|
|
|
310 |
|
|
|
311 |
if (err == KErrNone)
|
|
|
312 |
{
|
|
|
313 |
err = WriteDccChannel(iTxBuffer);
|
|
|
314 |
}
|
|
|
315 |
return err;
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
//
|
|
|
319 |
// DTrkDccChannel::DoRead
|
|
|
320 |
//
|
|
|
321 |
TInt DTrkDccChannel::DoRead()
|
|
|
322 |
{
|
|
|
323 |
TInt err = KErrNone;
|
|
|
324 |
|
|
|
325 |
ReadDccChannel();
|
|
|
326 |
|
|
|
327 |
if (iRxPutIndx != iRxGetIndx)
|
|
|
328 |
{
|
|
|
329 |
if (iPacketEnded)
|
|
|
330 |
{
|
|
|
331 |
iPacketStarted = EFalse;
|
|
|
332 |
iPacketEnded = EFalse;
|
|
|
333 |
}
|
|
|
334 |
//there is some data, complete the read request if there is one pending
|
|
|
335 |
DoCompleteRx();
|
|
|
336 |
|
|
|
337 |
if (iRxPutIndx == iRxGetIndx)
|
|
|
338 |
{
|
|
|
339 |
iRxPutIndx = iRxGetIndx = 0;
|
|
|
340 |
}
|
|
|
341 |
}
|
|
|
342 |
else
|
|
|
343 |
{
|
|
|
344 |
err = -1;
|
|
|
345 |
//start the timer again since we didn't complete the request
|
|
|
346 |
iRxTimer.OneShot(iRxTimeOut);
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
return err;
|
|
|
350 |
}
|
|
|
351 |
|
|
|
352 |
//
|
|
|
353 |
// DTrkDccChannel::WriteDccChannel
|
|
|
354 |
//
|
|
|
355 |
// This function writes all the data in the descriptor word by word.
|
|
|
356 |
// DCC3 mode is used for transferring the data to the DCC channel.
|
|
|
357 |
// With DCC3, the number of bytes in the word is encoded in its MSB.
|
|
|
358 |
// DCC3 mode can be turned of by commenting the DCC3 macro at the
|
|
|
359 |
// beginning of this file.
|
|
|
360 |
//
|
|
|
361 |
TInt DTrkDccChannel::WriteDccChannel(const TDesC8& aDes)
|
|
|
362 |
{
|
|
|
363 |
TInt err = KErrNone;
|
|
|
364 |
|
|
|
365 |
const TText8* pStart = aDes.Ptr();
|
|
|
366 |
const TText8* pEnd = pStart + aDes.Length();
|
|
|
367 |
if (pStart != pEnd)
|
|
|
368 |
{
|
|
|
369 |
while (pStart < pEnd)
|
|
|
370 |
{
|
|
|
371 |
TUint retries = 10;
|
|
|
372 |
|
|
|
373 |
#ifdef DCC3
|
|
|
374 |
TUint32 data = 0;
|
|
|
375 |
//for DCC3 support
|
|
|
376 |
if ((pEnd-pStart) >= 3)
|
|
|
377 |
{
|
|
|
378 |
data = ((TUint32)(*pStart++)) | ((TUint32)(*pStart++))<<8 | ((TUint32)(*pStart++))<<16 | (0x02<<24);
|
|
|
379 |
}
|
|
|
380 |
else if ((pEnd-pStart) == 2)
|
|
|
381 |
{
|
|
|
382 |
data = ((TUint32)(*pStart++)) | ((TUint32)(*pStart++))<<8 | (0x01<<24);
|
|
|
383 |
}
|
|
|
384 |
else if ((pEnd-pStart) == 1)
|
|
|
385 |
{
|
|
|
386 |
data = (TUint32)(*pStart++);
|
|
|
387 |
}
|
|
|
388 |
#endif
|
|
|
389 |
|
|
|
390 |
while (retries--)
|
|
|
391 |
{
|
|
|
392 |
#ifdef DCC3
|
|
|
393 |
err = Arm::DebugOutJTAG(data);
|
|
|
394 |
#else
|
|
|
395 |
err = Arm::DebugOutJTAG(*pStart);
|
|
|
396 |
#endif
|
|
|
397 |
|
|
|
398 |
//if we get timeout error, try three times sending the same byte
|
|
|
399 |
if (err == KErrTimedOut)
|
|
|
400 |
{
|
|
|
401 |
LOG_MSG("Write timed out, trying again\n");
|
|
|
402 |
continue;
|
|
|
403 |
}
|
|
|
404 |
else
|
|
|
405 |
break;
|
|
|
406 |
}
|
|
|
407 |
if (err)
|
|
|
408 |
{
|
|
|
409 |
LOG_MSG2("WriteDccChannel() failed %d", err);
|
|
|
410 |
return err;
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
#ifndef DCC3
|
|
|
414 |
pStart++;
|
|
|
415 |
#endif
|
|
|
416 |
|
|
|
417 |
}
|
|
|
418 |
}
|
|
|
419 |
return err;
|
|
|
420 |
}
|
|
|
421 |
|
|
|
422 |
//
|
|
|
423 |
// DTrkDccChannel::ReadDccChannel
|
|
|
424 |
//
|
|
|
425 |
// Strictly reads packet by packets since TRK expects the host debugger
|
|
|
426 |
// to wait for the response for the cmd sent.
|
|
|
427 |
// This function will return if
|
|
|
428 |
// - the packet is completely read
|
|
|
429 |
// - if out of band data, i.e. data not conforming to TRK protocol packets
|
|
|
430 |
// - if an error other than KErrNotReady happens in while in the middle of
|
|
|
431 |
// reading a packet.
|
|
|
432 |
// Also the function uses DCC3 mode, where the no of bytes sent in the word
|
|
|
433 |
// is encoded in the MSB and the actual data bytes in the remaining bytes.
|
|
|
434 |
// Like for sending three bytes, the word will be 0x02CCBBAA.
|
|
|
435 |
// For sending three bytes, the MSB should be 2.
|
|
|
436 |
// For two bytes, the MSB should be 1.
|
|
|
437 |
// For one bytes, the MSB should be 0.
|
|
|
438 |
//
|
|
|
439 |
void DTrkDccChannel::ReadDccChannel()
|
|
|
440 |
{
|
|
|
441 |
TInt err = KErrNone;
|
|
|
442 |
TInt err1 = KErrNone;
|
|
|
443 |
|
|
|
444 |
TUint i = iRxPutIndx;
|
|
|
445 |
TUint32 data;
|
|
|
446 |
|
|
|
447 |
err = err1 = Arm::DebugInJTAG(data);
|
|
|
448 |
while (KErrNone == err)
|
|
|
449 |
{
|
|
|
450 |
if (KErrNone == err1)
|
|
|
451 |
{
|
|
|
452 |
TUint8 nBytes = 0;
|
|
|
453 |
nBytes = TUint8(data>>24);
|
|
|
454 |
|
|
|
455 |
for (int j=0; j<=nBytes; j++)
|
|
|
456 |
{
|
|
|
457 |
iRxBuffer[i] = (TUint8)(data>>(j*8));
|
|
|
458 |
if (iRxBuffer[i] == PKT_STRT_BYTE)
|
|
|
459 |
{
|
|
|
460 |
if (!iPacketStarted)
|
|
|
461 |
{
|
|
|
462 |
iPacketStarted = ETrue;
|
|
|
463 |
}
|
|
|
464 |
else
|
|
|
465 |
{
|
|
|
466 |
iPacketEnded = ETrue;
|
|
|
467 |
}
|
|
|
468 |
}
|
|
|
469 |
i++; //increment i here so that put index can be appriopriately set later
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
if (i == iRxBufSize)
|
|
|
473 |
{
|
|
|
474 |
i = 0;
|
|
|
475 |
break;
|
|
|
476 |
}
|
|
|
477 |
//if cmd packet ended, send the data to the engine.
|
|
|
478 |
if (iPacketEnded)
|
|
|
479 |
{
|
|
|
480 |
break;
|
|
|
481 |
}
|
|
|
482 |
}
|
|
|
483 |
|
|
|
484 |
//read again to see if there is data already available
|
|
|
485 |
err = err1 = Arm::DebugInJTAG(data);
|
|
|
486 |
|
|
|
487 |
//if the packet is started, try to read the whole packet
|
|
|
488 |
//so set the err value to KErrNone so that we can continue reading
|
|
|
489 |
if ((err == KErrNotReady) && iPacketStarted && !iPacketEnded)
|
|
|
490 |
err = KErrNone;
|
|
|
491 |
|
|
|
492 |
if (err != KErrNone && err != KErrNotReady)
|
|
|
493 |
LOG_MSG2("Read Error %d\n", err);
|
|
|
494 |
}
|
|
|
495 |
|
|
|
496 |
iRxPutIndx=i;
|
|
|
497 |
}
|
|
|
498 |
|
|
|
499 |
//
|
|
|
500 |
// DTrkDccChannel::RxTimerCallBack
|
|
|
501 |
//
|
|
|
502 |
void DTrkDccChannel::RxTimerCallBack(TAny* aPtr)
|
|
|
503 |
{
|
|
|
504 |
// called from ISR when timer completes
|
|
|
505 |
DTrkDccChannel *pChannel = (DTrkDccChannel*)aPtr;
|
|
|
506 |
pChannel->iRxCompleteDfc.Add();
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
//
|
|
|
510 |
// DTrkDccChannel::RxTimerDfc
|
|
|
511 |
//
|
|
|
512 |
void DTrkDccChannel::RxTimerDfc(TAny* aPtr)
|
|
|
513 |
{
|
|
|
514 |
DTrkDccChannel *pChannel = (DTrkDccChannel*)aPtr;
|
|
|
515 |
pChannel->DoRead();
|
|
|
516 |
}
|
|
|
517 |
|
|
|
518 |
//
|
|
|
519 |
// DTrkDccChannel::DoCompleteRx
|
|
|
520 |
//
|
|
|
521 |
void DTrkDccChannel::DoCompleteRx()
|
|
|
522 |
{
|
|
|
523 |
LOG_MSG("DTrkDccChannel::DoCompleteRx()");
|
|
|
524 |
|
|
|
525 |
if (iRxRequestStatus)
|
|
|
526 |
{
|
|
|
527 |
TInt avail = 0;
|
|
|
528 |
if (iRxPutIndx > iRxGetIndx)
|
|
|
529 |
avail = iRxPutIndx-iRxGetIndx;
|
|
|
530 |
else
|
|
|
531 |
avail = iRxBufSize-iRxGetIndx;
|
|
|
532 |
|
|
|
533 |
TInt len = Min(avail, iRxClientBufferLength);
|
|
|
534 |
|
|
|
535 |
TPtrC8 des(iRxBuffer+iRxGetIndx, len);
|
|
|
536 |
|
|
|
537 |
TInt err = Kern::ThreadDesWrite(iClientThread, iRxClientBuffer, des, 0, KChunkShiftBy0, iClientThread);
|
|
|
538 |
|
|
|
539 |
Kern::RequestComplete(iClientThread, iRxRequestStatus, err);
|
|
|
540 |
|
|
|
541 |
iRxRequestStatus = NULL;
|
|
|
542 |
iRxGetIndx += len;
|
|
|
543 |
}
|
|
|
544 |
|
|
|
545 |
if (iRxGetIndx >= iRxBufSize)
|
|
|
546 |
iRxGetIndx = 0;
|
|
|
547 |
}
|
|
|
548 |
|
|
|
549 |
|
|
|
550 |
DECLARE_STANDARD_LDD()
|
|
|
551 |
{
|
|
|
552 |
return new DTrkDccDriverFactory;
|
|
|
553 |
}
|