|
1 /* |
|
2 * Copyright (c) 2005-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 "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 #include <kernel.h> |
|
19 #include <mmc.h> |
|
20 #include <locmedia.h> |
|
21 |
|
22 #include "mmcldd.h" |
|
23 #include "d_mmcsdif.h" |
|
24 |
|
25 |
|
26 |
|
27 const TInt KMajorVersionNumber=1; |
|
28 const TInt KMinorVersionNumber=0; |
|
29 const TInt KBuildVersionNumber=0; |
|
30 |
|
31 // global Dfc Que |
|
32 TDynamicDfcQue* gDfcQ; |
|
33 |
|
34 |
|
35 |
|
36 DECLARE_STANDARD_LDD() |
|
37 { |
|
38 return new DLddFactoryMmcCntrlInterface; |
|
39 } |
|
40 |
|
41 /** |
|
42 * DLddFactoryMmcCntrlInterface constructor |
|
43 * |
|
44 * @return N/A |
|
45 * |
|
46 * @leave N/A |
|
47 */ |
|
48 DLddFactoryMmcCntrlInterface::DLddFactoryMmcCntrlInterface() |
|
49 { |
|
50 iParseMask=KDeviceAllowUnit; // Pass stack number as unit |
|
51 iUnitsMask=0xffffffff; |
|
52 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
53 } |
|
54 |
|
55 /** |
|
56 * Create logical channel |
|
57 * |
|
58 * @param DLogicalChannelBase*& aChannel - logical channel |
|
59 * |
|
60 * @return TInt the error code |
|
61 * |
|
62 * @leave N/A |
|
63 */ |
|
64 TInt DLddFactoryMmcCntrlInterface::Create(DLogicalChannelBase*& aChannel) |
|
65 { |
|
66 aChannel = new DLddMmcCntrlInterface; |
|
67 return aChannel ? KErrNone : KErrNoMemory; |
|
68 } |
|
69 |
|
70 const TInt KDMmcThreadPriority = 27; |
|
71 _LIT(KDMmcThread,"DMMCSDThread"); |
|
72 |
|
73 |
|
74 /** |
|
75 * Install driver |
|
76 * |
|
77 * @return TInt the error code |
|
78 * |
|
79 * @leave N/A |
|
80 */ |
|
81 TInt DLddFactoryMmcCntrlInterface::Install() |
|
82 { |
|
83 // Allocate a kernel thread to run the DFC |
|
84 TInt r = Kern::DynamicDfcQCreate(gDfcQ, KDMmcThreadPriority, KDMmcThread); |
|
85 |
|
86 if (r != KErrNone) |
|
87 return r; |
|
88 __KTRACE_OPT(KHARDWARE,MMCSDLOG("installing driver name from factory")); |
|
89 return SetName(&KLddName); |
|
90 } |
|
91 |
|
92 /** |
|
93 * Get the Pc Card Contoller Interface ldd's version info |
|
94 * |
|
95 * @param TDes8 &aDes - Buffer to contain version info |
|
96 * |
|
97 * @return N/A |
|
98 * |
|
99 * @leave N/A |
|
100 */ |
|
101 void DLddFactoryMmcCntrlInterface::GetCaps(TDes8 &aDes) const |
|
102 { |
|
103 TCapsMmcIfV01 b; |
|
104 b.version=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
105 aDes.FillZ(aDes.MaxLength()); |
|
106 aDes.Copy((TUint8 *)&b,Min(aDes.MaxLength(),sizeof(b))); |
|
107 } |
|
108 |
|
109 /** |
|
110 * Destructor |
|
111 * |
|
112 * @return N/A |
|
113 * |
|
114 * @leave N/A |
|
115 */ |
|
116 DLddFactoryMmcCntrlInterface::~DLddFactoryMmcCntrlInterface() |
|
117 { |
|
118 if (gDfcQ) |
|
119 gDfcQ->Destroy(); |
|
120 } |
|
121 |
|
122 /** |
|
123 * DLddMmcCntrlInterface constructor |
|
124 * |
|
125 * @return N/A |
|
126 * |
|
127 * @leave N/A |
|
128 */ |
|
129 DLddMmcCntrlInterface::DLddMmcCntrlInterface() |
|
130 { |
|
131 iClient = &Kern::CurrentThread(); |
|
132 ((DObject*)iClient)->Open(); // can't fail since thread is running |
|
133 } |
|
134 |
|
135 /** |
|
136 * Destructor |
|
137 * |
|
138 * @return N/A |
|
139 * |
|
140 * @leave N/A |
|
141 */ |
|
142 DLddMmcCntrlInterface::~DLddMmcCntrlInterface() |
|
143 { |
|
144 Kern::SafeClose((DObject*&)iClient,NULL); |
|
145 iAsyncList.ResetAndDestroy(); |
|
146 } |
|
147 |
|
148 /** |
|
149 * Create driver ojects |
|
150 * |
|
151 * @param TInt aUnit - Socket ID |
|
152 * @param const TDesC8* aInfo - Buffer for logging |
|
153 * @param const TVersion& aVer - Current version |
|
154 * |
|
155 * @return TInt the error code |
|
156 * |
|
157 * @leave N/A |
|
158 */ |
|
159 TInt DLddMmcCntrlInterface::DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer) |
|
160 { |
|
161 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) |
|
162 return(KErrNotSupported); |
|
163 |
|
164 MMCSDLOG2("DLddMmcCntrlInterface::DoCreate called aInfo(%S)", aInfo); |
|
165 |
|
166 // create the socket - there is only a DMMCSocket |
|
167 iSocket = static_cast<DMMCSocket*>(DPBusSocket::SocketFromId(aUnit)); |
|
168 if(!iSocket) |
|
169 return(KErrNoMemory); |
|
170 |
|
171 //Obtain the appropriate card from the stack |
|
172 iStack = static_cast<DMMCStack*>(iSocket->Stack(KStackNo)); |
|
173 if(iStack == NULL) |
|
174 return(KErrNoMemory); |
|
175 |
|
176 //Obtain the appropriate card power supply |
|
177 iPsu=static_cast<DMMCPsu*>(iSocket->iVcc); |
|
178 if (iPsu==NULL) |
|
179 return(KErrNoMemory); |
|
180 |
|
181 //Obtain the appropriate card Media change |
|
182 iMediaChange=static_cast<DMMCMediaChange*>(iSocket->iMediaChange); |
|
183 if (iMediaChange==NULL) |
|
184 return(KErrNoMemory); |
|
185 |
|
186 SetDfcQ(gDfcQ); |
|
187 iMsgQ.Receive(); |
|
188 |
|
189 iUnit = aUnit; // save the unit - needed for regitering callbacks for subsequent bus events |
|
190 |
|
191 return(KErrNone); |
|
192 } |
|
193 |
|
194 /** |
|
195 * Request cancelled callback |
|
196 * |
|
197 * @param TInt sReqNo - Request Number |
|
198 * |
|
199 * @return N/A |
|
200 * |
|
201 * @leave N/A |
|
202 */ |
|
203 void DLddMmcCntrlInterface::DoCancel(TInt /*aReqNo*/) |
|
204 { |
|
205 } |
|
206 |
|
207 /** |
|
208 * Handle kernel side message |
|
209 * |
|
210 * @param TMessageBase* aMsg - The kernel side message |
|
211 * |
|
212 * @return N/A |
|
213 * |
|
214 * @leave N/A |
|
215 */ |
|
216 void DLddMmcCntrlInterface::HandleMsg(TMessageBase* aMsg) |
|
217 { |
|
218 TThreadMessage& m=*(TThreadMessage*)aMsg; |
|
219 TInt id=m.iValue; |
|
220 |
|
221 if (id==(TInt)ECloseMsg) |
|
222 { |
|
223 m.Complete(KErrNone, EFalse); |
|
224 return; |
|
225 } |
|
226 else if (id==KMaxTInt) |
|
227 { |
|
228 // DoCancel |
|
229 m.Complete(KErrNone,ETrue); |
|
230 return; |
|
231 } |
|
232 |
|
233 if (id<0) |
|
234 { |
|
235 // DoRequest |
|
236 TRequestStatus* pS=(TRequestStatus*)m.Ptr0(); |
|
237 TInt r=DoRequest(~id, pS, m.Ptr1(), m.Ptr2()); |
|
238 if (r!=KErrNone) |
|
239 Kern::RequestComplete(iClient, pS, r); |
|
240 m.Complete(KErrNone,ETrue); |
|
241 } |
|
242 else |
|
243 { |
|
244 // DoControl |
|
245 TInt r=DoControl(id,m.Ptr0(),m.Ptr1()); |
|
246 if(r != KErrCompletion) |
|
247 { |
|
248 m.Complete(r,ETrue); |
|
249 } |
|
250 } |
|
251 } |
|
252 |
|
253 /** |
|
254 * Do a kernel side request |
|
255 * |
|
256 * @param TInt aFunction - Request Function ID |
|
257 * @param TRequestStatus* aStatus - Request Status |
|
258 * @param TAny* a1 - Given parameter |
|
259 * @param TAny* a2 - Given parameter |
|
260 * |
|
261 * @return TInt the error code |
|
262 * |
|
263 * @leave N/A |
|
264 */ |
|
265 TInt DLddMmcCntrlInterface::DoRequest(TInt aFunction, TRequestStatus* aStatus, TAny* a1, TAny *a2) |
|
266 { |
|
267 |
|
268 TTCFunctionId fid = TTCFunctionId(aFunction); |
|
269 switch(fid.TestType()) |
|
270 { |
|
271 case EMmcTestSocket: |
|
272 return SocketDoRequest(aStatus, a1, a2, aFunction); |
|
273 |
|
274 case EMmcTestStack: |
|
275 case EMmcTestPsu: |
|
276 case EMmcTestMediaChange: |
|
277 case EMmcGeneralTest: |
|
278 default: |
|
279 break; |
|
280 }; |
|
281 |
|
282 switch(fid.FunctionId()) |
|
283 { |
|
284 case RMMCSDTestControllerInterface::EReadSector: |
|
285 { |
|
286 // read sector a1 is block number, a2 is client descriptor |
|
287 // data will be written back to upon completion |
|
288 MMCSDLOG3("RMMCSDTestControllerInterface::EReadSector a1(%d) a2(%x)", (TUint32)a1, a2); |
|
289 if(!iCard) |
|
290 { |
|
291 MMCSDLOG("RMMCSDTestControllerInterface::EReadSector NULL card\n"); |
|
292 return KErrNotReady; |
|
293 } |
|
294 |
|
295 DMmcSessionAsyncRequest* request = CreateAsyncSessionRequest(EMmcSesReadBlk, aStatus); |
|
296 |
|
297 TUint32 srcAddr=((TUint32)a1)<<KSectorSizeShift; |
|
298 TUint readBlLen = 1 << iCard->MaxReadBlLen(); |
|
299 TUint readBlMask=(readBlLen-1); |
|
300 request->iBlkOffet=srcAddr-(srcAddr&(~readBlMask)); |
|
301 request->iClientDesPtr = a2; |
|
302 srcAddr &= (~readBlMask); |
|
303 |
|
304 MMCSDLOG("RMMCSDTestControllerInterface::EReadSector #2"); |
|
305 TMMCArgument da(srcAddr); |
|
306 |
|
307 request->Session().SetupCIMReadBlock(da,readBlLen,&(request->iBuf[0])); |
|
308 request->Session().Engage(); |
|
309 |
|
310 MMCSDLOG("RMMCSDTestControllerInterface::EReadSector #3"); |
|
311 break; |
|
312 } |
|
313 case RMMCSDTestControllerInterface::EWriteSector: |
|
314 { |
|
315 MMCSDLOG3("RMMCSDTestControllerInterface::EWriteSector a1(%d) a2(%x) #1", (TUint32)a1, a2); |
|
316 if(!iCard) |
|
317 { |
|
318 MMCSDLOG("RMMCSDTestControllerInterface::EWriteSector NULL card\n"); |
|
319 return KErrNotReady; |
|
320 } |
|
321 |
|
322 TUint32 destAddr=((TUint32)a1)<<KSectorSizeShift; |
|
323 TUint writeBlLen=1 << iCard->MaxWriteBlLen(); |
|
324 |
|
325 DMmcSessionAsyncRequest* request = CreateAsyncSessionRequest(EMmcSesWriteBlk, aStatus); |
|
326 |
|
327 TUint writeBlMask=(writeBlLen-1); |
|
328 request->iBlkOffet=destAddr-(destAddr&(~writeBlMask)); |
|
329 TPtr8* srcDes = (TPtr8*)a2; |
|
330 TPtr8 ptr(&(request->iBuf[request->iBlkOffet]),KSectorSizeInBytes,KSectorSizeInBytes); |
|
331 TInt r = Kern::ThreadDesRead(iClient, srcDes, ptr, 0, KChunkShiftBy0); |
|
332 if(r != KErrNone) |
|
333 { |
|
334 return(r); |
|
335 } |
|
336 |
|
337 destAddr&=(~writeBlMask); |
|
338 request->Session().SetupCIMWriteBlock(TMMCArgument(destAddr),writeBlLen,&(request->iBuf[0])); |
|
339 request->Session().Engage(); |
|
340 |
|
341 MMCSDLOG("RMMCSDTestControllerInterface::EWriteSector #4"); |
|
342 break; |
|
343 } |
|
344 } |
|
345 return(KErrNone); |
|
346 } |
|
347 |
|
348 /** |
|
349 * Do a kernel side control |
|
350 * |
|
351 * @param TInt aFunction - Request Function ID |
|
352 * @param TAny* a1 - Given parameter |
|
353 * @param TAny* a2 - Given parameter |
|
354 * |
|
355 * @return TInt the error code |
|
356 * |
|
357 * @leave N/A |
|
358 */ |
|
359 TInt DLddMmcCntrlInterface::DoControl(TInt aFunction,TAny* a1,TAny* a2) |
|
360 { |
|
361 TInt r = KErrNotSupported; |
|
362 TTCFunctionId fid = TTCFunctionId(aFunction); |
|
363 MMCSDLOG4("DLddMmcCntrlInterface::DoControl aFunction(%d) \ |
|
364 fid.FunctionId()(%d) fid.TestType(%d)" |
|
365 , aFunction, fid.FunctionId(), fid.TestType()); |
|
366 |
|
367 switch(fid.TestType()) |
|
368 { |
|
369 case EMmcTestStack: |
|
370 return StackDoControl(aFunction, a1, a2); |
|
371 case EMmcTestSocket: |
|
372 return SocketDoControl(aFunction, a1, a2); |
|
373 case EMmcTestPsu: |
|
374 return PsuDoControl(aFunction, a1, a2); |
|
375 case EMmcTestMediaChange: |
|
376 return MediaChangeDoControl(aFunction, a1, a2); |
|
377 case EMmcGeneralTest: |
|
378 default: |
|
379 break; |
|
380 }; |
|
381 |
|
382 switch (fid.FunctionId()) |
|
383 { |
|
384 case RMMCSDTestControllerInterface::EReadCSD: |
|
385 { |
|
386 iCSD = iCard->CSD(); |
|
387 { |
|
388 TCSDInfo csdInfo(iCSD); |
|
389 r = Kern::ThreadRawWrite(iClient, a1, &csdInfo, sizeof(csdInfo)); |
|
390 } |
|
391 } |
|
392 break; |
|
393 |
|
394 case RMMCSDTestControllerInterface::EReadExtCSD: |
|
395 { |
|
396 iExtendedCSD = iCard->ExtendedCSD(); |
|
397 TExtendedCSDInfo extendedCSDInfo(iExtendedCSD); |
|
398 r = Kern::ThreadRawWrite(iClient, a1, &extendedCSDInfo, sizeof(extendedCSDInfo)); |
|
399 } |
|
400 break; |
|
401 |
|
402 case RMMCSDTestControllerInterface::ECardInfo: |
|
403 { |
|
404 TMMCCardInfo cardInfo; |
|
405 cardInfo.SetCardInfo(*iCard); |
|
406 r = Kern::ThreadRawWrite(iClient, a1, &cardInfo, sizeof(cardInfo)); |
|
407 } |
|
408 break; |
|
409 |
|
410 case RMMCSDTestControllerInterface::ECard: |
|
411 { |
|
412 r = Kern::ThreadRawWrite(iClient, a1, &iCard, sizeof(iCard)); |
|
413 } |
|
414 break; |
|
415 |
|
416 case RMMCSDTestControllerInterface::ECardIsPresent: |
|
417 { |
|
418 TBool isPresent = iCard->IsPresent(); |
|
419 r = Kern::ThreadRawWrite(iClient, a1, &isPresent, sizeof(isPresent)); |
|
420 } |
|
421 break; |
|
422 |
|
423 case RMMCSDTestControllerInterface::ECardIsReady: |
|
424 { |
|
425 TBool isReady = iCard->IsReady(); |
|
426 r = Kern::ThreadRawWrite(iClient, a1, &isReady, sizeof(isReady)); |
|
427 } |
|
428 break; |
|
429 |
|
430 case RMMCSDTestControllerInterface::ECardIsLocked: |
|
431 { |
|
432 TBool isLocked = iCard->IsLocked(); |
|
433 r = Kern::ThreadRawWrite(iClient, a1, &isLocked, sizeof(isLocked)); |
|
434 } |
|
435 break; |
|
436 |
|
437 default: |
|
438 { |
|
439 MMCSDLOG2("DLddMmcCntrlInterface::DoControl - Invalid FunctionId()(%d)", fid.FunctionId()); |
|
440 } |
|
441 break; |
|
442 } |
|
443 |
|
444 |
|
445 return (r); |
|
446 } |
|
447 |
|
448 /** |
|
449 * Check if a request status exists |
|
450 * |
|
451 * @param TRequestStatus* aStatus - Request Status |
|
452 * |
|
453 * @return TBool A request status exists |
|
454 * |
|
455 * @leave N/A |
|
456 */ |
|
457 TBool DLddMmcCntrlInterface::RequestStatusExists(TRequestStatus* aStatus) |
|
458 { |
|
459 |
|
460 // check whether this request status already exists in the async request list |
|
461 for(int i=0;i<iAsyncList.Count();i++) |
|
462 { |
|
463 MMCSDLOG3("Checking index(%d) iAsyncList[i]->Status(%x)", i, iAsyncList[i]->Status()); |
|
464 |
|
465 if(iAsyncList[i]->Status() == aStatus) |
|
466 { |
|
467 MMCSDLOG3("WaRNING - adding duplicate TRequestStatus index[%d] aStatus(%x)", i, aStatus); |
|
468 return ETrue; |
|
469 } |
|
470 } |
|
471 |
|
472 return EFalse; |
|
473 } |
|
474 |
|
475 /** |
|
476 * Create Asynchronous Session Request |
|
477 * |
|
478 * @param TMmcAsyncCmd aFunctionId - Request Function ID |
|
479 * @param TRequestStatus* aStatus - Request Status |
|
480 * |
|
481 * @return DMmcSessionAsyncRequest* Poniter to the created session request object |
|
482 * |
|
483 * @leave N/A |
|
484 */ |
|
485 DMmcSessionAsyncRequest* DLddMmcCntrlInterface::CreateAsyncSessionRequest(TMmcAsyncCmd aFunctionId, TRequestStatus* aStatus) |
|
486 { |
|
487 |
|
488 MMCSDLOG3("DLddMmcCntrlInterface::CreateAsyncRequest aStatus(%x) num requests in list (%d)", |
|
489 aStatus, iAsyncList.Count()); |
|
490 |
|
491 // create an async request & append to async request list |
|
492 DMmcSessionAsyncRequest* request = new DMmcSessionAsyncRequest(aFunctionId, aStatus, *this, gDfcQ, *iStack, *iCard); |
|
493 iAsyncList.Append(request); |
|
494 MMCSDLOG4("DLddMmcCntrlInterface::CreateAsyncSessionRequest created OK Status(%x) functionID(%d) aFunctionId(%d)", |
|
495 request->Status(), request->FunctionId(), aFunctionId); |
|
496 return request; |
|
497 } |
|
498 |
|
499 /** |
|
500 * Create Asynchronous Bus Event Request |
|
501 * |
|
502 * @param TMmcAsyncCmd aFunctionId - Request Function ID |
|
503 * @param TRequestStatus* aStatus - Request Status |
|
504 * @param TInt aUnit - Socket ID |
|
505 * |
|
506 * @return DBusEventRequest* Poniter to the created bus event request object |
|
507 * |
|
508 * @leave N/A |
|
509 */ |
|
510 DBusEventRequest* DLddMmcCntrlInterface::CreateAsyncBusEventRequest(TMmcAsyncCmd aFunctionId, TRequestStatus* aStatus, TInt aUnit) |
|
511 { |
|
512 MMCSDLOG3("DLddMmcCntrlInterface::CreateAsyncBusEventRequest aStatus(%x) num requests in list (%d)", |
|
513 aStatus, iAsyncList.Count()); |
|
514 |
|
515 MMCSDLOG4("gDfcQ(%x), iStack(%x), iCard(%x)", gDfcQ, iStack, iCard); |
|
516 |
|
517 // create an async request & append toS async request list |
|
518 DBusEventRequest* request = new DBusEventRequest(aFunctionId, aStatus, *this, aUnit, gDfcQ, *iStack, *iCard); |
|
519 iAsyncList.Append(request); |
|
520 MMCSDLOG4("DLddMmcCntrlInterface::CreateAsyncBusEventRequest created OK Status(%x) functionID(%d) aFunctionId(%d)", |
|
521 request->Status(), request->FunctionId(), aFunctionId); |
|
522 return request; |
|
523 |
|
524 } |
|
525 |
|
526 /** |
|
527 * Clears an asynchronous Request from list |
|
528 * |
|
529 * @param DLddAsyncRequest* aRequest - Pointer to the request |
|
530 * |
|
531 * @return N/A |
|
532 * |
|
533 * @leave N/A |
|
534 */ |
|
535 void DLddMmcCntrlInterface::ClearRequest(DLddAsyncRequest* aRequest) |
|
536 { |
|
537 if(!aRequest) |
|
538 { |
|
539 MMCSDLOG("ERROR IN DLddMmcCntrlInterface::ClearRequest NULL request"); |
|
540 return; |
|
541 } |
|
542 |
|
543 TInt i = iAsyncList.Find(aRequest); |
|
544 if(i >= 0) |
|
545 { |
|
546 iAsyncList.Remove(i); |
|
547 } |
|
548 else |
|
549 { |
|
550 MMCSDLOG2("ERROR IN DLddMmcCntrlInterface::ClearRequest err(%d)", i); |
|
551 } |
|
552 |
|
553 delete aRequest; |
|
554 |
|
555 } |
|
556 |
|
557 /** |
|
558 * Callback when request has completed |
|
559 * |
|
560 * @param DLddAsyncRequest& aRequest - The completed request |
|
561 * |
|
562 * @return N/A |
|
563 * |
|
564 * @leave N/A |
|
565 */ |
|
566 void DLddMmcCntrlInterface::Notify(DLddAsyncRequest& aRequest) // callback from DLddAsyncRequest |
|
567 { |
|
568 MMCSDLOG("DLddMmcCntrlInterface::Notify called"); |
|
569 TRequestStatus* status = aRequest.Status(); |
|
570 switch (aRequest.FunctionId()) |
|
571 { |
|
572 case DLddMmcCntrlInterface::EMmcSesReadBlk: |
|
573 { |
|
574 DMmcSessionAsyncRequest& request = (DMmcSessionAsyncRequest&) aRequest; |
|
575 MMCSDLOG("DLddMmcCntrlInterface::ReadBlockComplete"); |
|
576 TInt r = KErrNone; |
|
577 if (request.iClientDesPtr) // have we supplied descriptor to hold returned data |
|
578 { |
|
579 TPtr8 ptr(&(request.iBuf[request.iBlkOffet]), KSectorSizeInBytes, KSectorSizeInBytes); |
|
580 TPtrC8* srcDes = (TPtrC8*)request.iClientDesPtr; |
|
581 r = Kern::ThreadDesWrite(iClient, srcDes, ptr, 0, iClient); |
|
582 if(r != KErrNone) |
|
583 { |
|
584 MMCSDLOG2("ERROR DLddMmcCntrlInterface::ReadBlockComplete Kern::ThreadDesWrite returned r(%d)", r); |
|
585 } |
|
586 } |
|
587 else |
|
588 { |
|
589 MMCSDLOG("ERROR DLddMmcCntrlInterface::ReadExtCSDComplete - No pointer provided to hold returned data"); |
|
590 Kern::PanicCurrentThread(_L("PBUS-MMC"), 0); |
|
591 } |
|
592 Kern::RequestComplete(iClient, status, (r == KErrNone) ? aRequest.Error() : r); |
|
593 } |
|
594 break; |
|
595 |
|
596 case DLddMmcCntrlInterface::EMmcSesWriteBlk: |
|
597 { |
|
598 MMCSDLOG("DLddMmcCntrlInterface::WriteBlockComplete)"); |
|
599 TRequestStatus* status = aRequest.Status(); |
|
600 Kern::RequestComplete(iClient, status, aRequest.Error()); |
|
601 } |
|
602 break; |
|
603 |
|
604 case DLddMmcCntrlInterface::EMmcSesReadCSD: |
|
605 { |
|
606 DMmcSessionAsyncRequest& request = (DMmcSessionAsyncRequest&) aRequest; |
|
607 MMCSDLOG("DLddMmcCntrlInterface::ReadCSDComplete"); |
|
608 TInt r = KErrNone; |
|
609 if (request.iClientDesPtr) // have we supplied pointer to hold returned data |
|
610 { |
|
611 { |
|
612 TCSDInfo csdInfo(iCSD); |
|
613 r = Kern::ThreadRawWrite(iClient, request.iClientDesPtr, &csdInfo, sizeof(csdInfo)); |
|
614 } |
|
615 if(r != KErrNone) |
|
616 { |
|
617 MMCSDLOG2("ERROR DLddMmcCntrlInterface::ReadCSDComplete Kern::ThreadRawWrite returned r(%d)", r); |
|
618 } |
|
619 } |
|
620 else |
|
621 { |
|
622 MMCSDLOG("ERROR DLddMmcCntrlInterface::ReadExtCSDComplete - No pointer provided to hold returned data"); |
|
623 Kern::PanicCurrentThread(_L("PBUS-MMC"), 0); |
|
624 } |
|
625 Kern::RequestComplete(iClient, status, (r == KErrNone) ? aRequest.Error() : r); |
|
626 } |
|
627 break; |
|
628 |
|
629 case DLddMmcCntrlInterface::EMmcSesReadExtCSD: |
|
630 { |
|
631 DMmcSessionAsyncRequest& request = (DMmcSessionAsyncRequest&) aRequest; |
|
632 MMCSDLOG("DLddMmcCntrlInterface::ReadExtCSDComplete"); |
|
633 TInt r = KErrNone; |
|
634 if (request.iClientDesPtr) // have we supplied pointer to hold returned data |
|
635 { |
|
636 TExtendedCSDInfo extendedCSDInfo(iExtendedCSD); |
|
637 r = Kern::ThreadRawWrite(iClient, request.iClientDesPtr, &extendedCSDInfo, sizeof(extendedCSDInfo)); |
|
638 if(r != KErrNone) |
|
639 { |
|
640 MMCSDLOG2("ERROR DLddMmcCntrlInterface::ReadExtCSDComplete Kern::ThreadRawWrite returned r(%d)", r); |
|
641 } |
|
642 } |
|
643 else |
|
644 { |
|
645 MMCSDLOG("ERROR DLddMmcCntrlInterface::ReadExtCSDComplete - No pointer provided to hold returned data"); |
|
646 Kern::PanicCurrentThread(_L("PBUS-MMC"), 0); |
|
647 } |
|
648 Kern::RequestComplete(iClient, status, (r == KErrNone) ? aRequest.Error() : r); |
|
649 } |
|
650 break; |
|
651 |
|
652 case DLddMmcCntrlInterface::EMMcSocketPowerUp: |
|
653 { |
|
654 DBusEventRequest& request = (DBusEventRequest&) aRequest; |
|
655 TInt retCode = KErrNone; |
|
656 |
|
657 MMCSDLOG2("DLddMmcCntrlInterface::EMMcSocketPowerUp ret code = %d", aRequest.Error()); |
|
658 MMCSDLOG2("DLddMmcCntrlInterface::EMMcSocketPowerUp request.BusState() = %d", request.BusState()); |
|
659 MMCSDLOG2("DLddMmcCntrlInterface::EMMcSocketPowerUp request.BusError() = %d", request.BusError()); |
|
660 |
|
661 switch(aRequest.Error()) |
|
662 { |
|
663 case TPBusCallBack::EPBusStateChange: |
|
664 { |
|
665 TPBusState newState = request.BusState(); |
|
666 retCode = request.BusError(); |
|
667 |
|
668 if (retCode == KErrNone) |
|
669 { |
|
670 switch(newState) |
|
671 { |
|
672 case EPBusCardAbsent: retCode = KErrNotFound; break; |
|
673 case EPBusPsuFault: retCode = KErrBadPower; break; |
|
674 case EPBusOff: |
|
675 case EPBusOn: |
|
676 case EPBusPowerUpPending: |
|
677 case EPBusPoweringUp: |
|
678 default: |
|
679 break; |
|
680 } |
|
681 } |
|
682 |
|
683 break; |
|
684 } |
|
685 } |
|
686 |
|
687 Kern::RequestComplete(iClient, status, retCode); |
|
688 } |
|
689 break; |
|
690 |
|
691 default: |
|
692 MMCSDLOG("#######################################################################"); |
|
693 MMCSDLOG("## UNHANDLED END DFC DLddAsyncRequest DLddMmcCntrlInterface::Notify ##"); |
|
694 MMCSDLOG2("## aRequest.FunctionId(%d) ##", aRequest.FunctionId()); |
|
695 MMCSDLOG("#######################################################################"); |
|
696 Kern::PanicCurrentThread(_L("PBUS-MMC"), 0); |
|
697 break; |
|
698 }; |
|
699 |
|
700 ClearRequest(&aRequest); |
|
701 |
|
702 } |
|
703 |