Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #include "T_MmcSDDriverData.h"
20 //MMCSD Commands index
22 _LIT(KCmdConstructor, "NewL");
23 _LIT(KCmdReadSector, "ReadSector");
24 _LIT(KCmdWriteSector, "WriteSector");
25 _LIT(KCmdReadCSD, "ReadCSD");
26 _LIT(KCmdReadExtCSD, "ReadExtCSD");
27 _LIT(KCmdCardInfo, "CardInfo");
28 _LIT(KCmdCardIsPresent, "CardIsPresent");
29 _LIT(KCmdCardIsReady, "CardIsReady");
30 _LIT(KCmdCardIsLocked, "CardIsLocked");
31 _LIT(KCmdDestructor, "~");
33 _LIT(KExpectedAsyncError, "expectedasyncerror");
34 _LIT(KSectorNumber, "sectornumber");
35 _LIT(KSectorText, "sectortext");
36 _LIT(KRepeats, "repeats");
37 _LIT(KHighCapacity, "highcapacity");
38 _LIT(KMaxReadBlockLen, "maxreadblocklen");
39 _LIT(KReadCurrentInMilliAmps, "readcurrentinmilliamps");
40 _LIT(KTransferSpeed, "transferspeed");
41 _LIT(KSessionWrapperName, "sessionwrappername");
42 _LIT(KExpectedIsPresent, "expectedispresent");
43 _LIT(KExpectedIsReady, "expectedisready");
44 _LIT(KExpectedIsLocked, "expectedislocked");
54 CT_MmcSDDriverData::CT_MmcSDDriverData()
56 , iMmcSDController(NULL)
63 * Second phase construction
67 * @leave System wide error
69 void CT_MmcSDDriverData::ConstructL()
71 User::LeaveIfError(iFs.Connect());
79 CT_MmcSDDriverData::~CT_MmcSDDriverData()
83 iActiveCallbacks.ResetAndDestroy();
87 * Return a pointer to the object that the data wraps
89 * @return pointer to the object that the data wraps
91 TAny* CT_MmcSDDriverData::GetObject()
93 return iMmcSDController;
97 * Process a command read from the script file
99 * @param aCommand The command to process
100 * @param aSection The section in the ini containing data for the command
101 * @param aAsyncErrorIndex Command index for async calls to return errors to
103 * @return ETrue if the command is processed
105 * @leave System wide error
107 TBool CT_MmcSDDriverData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
111 if ( aCommand==KCmdConstructor )
113 DoCmdConstructorL(aSection);
115 else if ( aCommand==KCmdDestructor )
119 else if(aCommand == KCmdReadSector)
121 DoCmdReadSectorL(aSection, aAsyncErrorIndex);
123 else if(aCommand == KCmdWriteSector)
125 DoCmdWriteSectorL(aSection, aAsyncErrorIndex);
127 else if(aCommand == KCmdReadCSD)
131 else if(aCommand == KCmdReadExtCSD)
135 else if(aCommand == KCmdCardInfo)
137 DoCmdCardInfo(aSection);
139 else if(aCommand == KCmdCardIsPresent)
141 DoCmdCardIsPresent(aSection);
143 else if(aCommand == KCmdCardIsReady)
145 DoCmdCardIsReady(aSection);
147 else if(aCommand == KCmdCardIsLocked)
149 DoCmdCardIsLocked(aSection);
153 ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
159 * Creates the RBusLogicalChannel derived interface
161 * @param aSection The section in the ini containing data for the command
165 * @leave System wide error
167 void CT_MmcSDDriverData::DoCmdConstructorL(const TDesC& aSection)
170 if( GetStringFromConfig(aSection, KSessionWrapperName(), wrapperName) )
172 iMmcSDController = static_cast<RMMCSDTestControllerInterface*>(GetDataObjectL(wrapperName));
173 INFO_PRINTF2(_L("iMmcSDController = %x"), iMmcSDController);
175 if( iMmcSDController == NULL )
177 ERR_PRINTF1(_L("iMmcSDController is NULL-Constructor"));
178 SetBlockResult(EFail);
183 ERR_PRINTF1(_L("Error in Session Wrapper Name from INI file-Constructor"));
184 SetBlockResult(EFail);
193 void CT_MmcSDDriverData::DoCmdDestructor()
195 INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCmdDestructor()"));
199 * Creates an active callback wrapper and adds to the list
201 * @param aFunctionId The active callback function ID
202 * @param aExpectedAsyncError The active callback expected asynchronous error
204 * @return The active callback wrapper created
206 CActiveCallbackWrap* CT_MmcSDDriverData::CreateActiveCallbackL(TInt aFunctionId, TInt aExpectedAsyncError)
208 CActiveCallbackWrap* activeCallbackWrap = CActiveCallbackWrap::NewL(*this, aFunctionId, aExpectedAsyncError);
209 iActiveCallbacks.Append(activeCallbackWrap);
210 return activeCallbackWrap;
214 * Deletes an active callback from the list
216 * @param activeCallback The active callback to delete
220 void CT_MmcSDDriverData::DeleteActiveCallback(CActiveCallback* activeCallback)
224 // loop through all wraps until we find the appropriate item
226 CActiveCallbackWrap* activeCallbackWrap = NULL;
228 for(int i=0;i<iActiveCallbacks.Count();i++)
230 if( &(iActiveCallbacks[i]->ActiveCallback()) == activeCallback)
232 activeCallbackWrap = iActiveCallbacks[i];
233 iActiveCallbacks.Remove(i);
238 delete activeCallbackWrap;
243 * Reads a sector from the card
245 * @param aSection The section in the ini containing data for the command
246 * @param aAsyncErrorIndex The asynchronous error index
250 * @leave System wide error
252 void CT_MmcSDDriverData::DoCmdReadSectorL(const TDesC& aSection, TInt aAsyncErrorIndex)
255 INFO_PRINTF1(_L("DoCmdReadSectorL called()"));
259 if(!GetIntFromConfig(aSection, KSectorNumber(), sectorNumber))
261 ERR_PRINTF1(_L("DoCmdReadSectorL FAILED TO READ sectorNumber"));
262 SetBlockResult(EFail);
266 INFO_PRINTF2(_L("DoCmdReadSectorL sectorNumber(%d)"), sectorNumber);
267 HBufC8* readData = HBufC8::NewLC(KSectorSizeInBytes);
268 CActiveCallbackWrap* activeCallbackWrap = CreateActiveCallbackL(RMMCSDTestControllerInterface::EReadSector, GetExpectedAsyncError(aSection));
269 activeCallbackWrap->SetDesData(readData);
271 TPtrC expectedSectorText;
272 if(GetStringFromConfig(aSection, KSectorText(), expectedSectorText))
274 TInt noOfRepeats = 1;
275 GetIntFromConfig(aSection, KRepeats(), noOfRepeats);
277 HBufC8* expectedData = HBufC8::NewLC(KSectorSizeInBytes);
278 activeCallbackWrap->SetExpectedDesData(expectedData);
280 activeCallbackWrap->ExpectedDataPtr().Zero();
281 for(TInt i=0;i<noOfRepeats;i++)
283 activeCallbackWrap->ExpectedDataPtr().Append(expectedSectorText);
286 TBuf16<KSectorSizeInBytes> printBuf;
287 printBuf.Copy(activeCallbackWrap->ExpectedDataPtr());
288 INFO_PRINTF3(_L("DoCmdReadSectorL expectedSectorText (length=%d):\n%S"), printBuf.Length(), &printBuf);
290 CleanupStack::Pop(expectedData);
293 iMmcSDController->ReadSector(activeCallbackWrap->ActiveCallback().iStatus, sectorNumber, activeCallbackWrap->DataPtr());
294 activeCallbackWrap->ActiveCallback().Activate(aAsyncErrorIndex);
296 CleanupStack::Pop(readData);
301 * Writes a sector to the card
303 * @param aSection The section in the ini containing data for the command
304 * @param aAsyncErrorIndex The asynchronous error index
308 * @leave System wide error
310 void CT_MmcSDDriverData::DoCmdWriteSectorL(const TDesC& aSection, TInt aAsyncErrorIndex)
312 INFO_PRINTF1(_L("DoCmdWriteSectorL called()"));
316 if(!GetIntFromConfig(aSection, KSectorNumber(), sectorNumber))
318 ERR_PRINTF1(_L("DoCmdWriteSectorL FAILED TO READ sectorNumber"));
319 SetBlockResult(EFail);
321 else if(!GetStringFromConfig(aSection, KSectorText(), sectorText))
323 ERR_PRINTF1(_L("DoCmdWriteSectorL FAILED TO READ sectorText"));
324 SetBlockResult(EFail);
328 TInt noOfRepeats = 1;
329 GetIntFromConfig(aSection, KRepeats(), noOfRepeats);
331 HBufC8* writeData = HBufC8::NewLC(KSectorSizeInBytes);
333 CActiveCallbackWrap* activeCallbackWrap = CreateActiveCallbackL(RMMCSDTestControllerInterface::EWriteSector, GetExpectedAsyncError(aSection));
334 activeCallbackWrap->SetDesData(writeData);
336 activeCallbackWrap->DataPtr().Zero();
337 for(TInt i=0;i<noOfRepeats;i++)
339 activeCallbackWrap->DataPtr().Append(sectorText);
342 TBuf16<KSectorSizeInBytes> printBuf;
343 printBuf.Copy(activeCallbackWrap->DataPtr());
344 INFO_PRINTF4(_L("DoCmdWriteSectorL sectorNumber(%d) sectorText (length=%d):\n%S"), sectorNumber, printBuf.Length(), &printBuf);
346 iMmcSDController->WriteSector(activeCallbackWrap->ActiveCallback().iStatus, sectorNumber, activeCallbackWrap->DataPtr());
347 activeCallbackWrap->ActiveCallback().Activate(aAsyncErrorIndex);
349 CleanupStack::Pop(writeData);
356 * @param aCSDInfo The CSD to print
360 void CT_MmcSDDriverData::PrintCSD(const TCSDInfo& aCSDInfo)
362 INFO_PRINTF2(_L("CSDInfo->CSDStructure() = %u"), aCSDInfo.iCSDStructure);
363 INFO_PRINTF2(_L("CSDInfo->SpecVers() = %u"), aCSDInfo.iSpecVers);
364 INFO_PRINTF2(_L("CSDInfo->Reserved120() = %u"), aCSDInfo.iReserved120);
365 INFO_PRINTF2(_L("CSDInfo->TAAC() = %u"), aCSDInfo.iTAAC);
366 INFO_PRINTF2(_L("CSDInfo->NSAC() = %u"), aCSDInfo.iNSAC);
367 INFO_PRINTF2(_L("CSDInfo->TranSpeed() = %u"), aCSDInfo.iTranSpeed);
368 INFO_PRINTF2(_L("CSDInfo->CCC() = %u"), aCSDInfo.iCCC);
369 INFO_PRINTF2(_L("CSDInfo->ReadBlLen() = %u"), aCSDInfo.iReadBlLen);
370 INFO_PRINTF2(_L("CSDInfo->Reserved74() = %u"), aCSDInfo.iReserved74);
371 INFO_PRINTF2(_L("CSDInfo->CSize() = %u"), aCSDInfo.iCSize);
372 INFO_PRINTF2(_L("CSDInfo->VDDRCurrMin() = %u"), aCSDInfo.iVDDRCurrMin);
373 INFO_PRINTF2(_L("CSDInfo->VDDRCurrMax() = %u"), aCSDInfo.iVDDRCurrMax);
374 INFO_PRINTF2(_L("CSDInfo->VDDWCurrMin() = %u"), aCSDInfo.iVDDWCurrMin);
375 INFO_PRINTF2(_L("CSDInfo->VDDWCurrMax() = %u"), aCSDInfo.iVDDWCurrMax);
376 INFO_PRINTF2(_L("CSDInfo->CSizeMult() = %u"), aCSDInfo.iCSizeMult);
377 INFO_PRINTF2(_L("CSDInfo->EraseGrpSize() = %u"), aCSDInfo.iEraseGrpSize);
378 INFO_PRINTF2(_L("CSDInfo->EraseGrpMult() = %u"), aCSDInfo.iEraseGrpMult);
379 INFO_PRINTF2(_L("CSDInfo->WPGrpSize() = %u"), aCSDInfo.iWPGrpSize);
380 INFO_PRINTF2(_L("CSDInfo->DefaultECC() = %u"), aCSDInfo.iDefaultECC);
381 INFO_PRINTF2(_L("CSDInfo->R2WFactor() = %u"), aCSDInfo.iR2WFactor);
382 INFO_PRINTF2(_L("CSDInfo->WriteBlLen() = %u"), aCSDInfo.iWriteBlLen);
383 INFO_PRINTF2(_L("CSDInfo->Reserved16() = %u"), aCSDInfo.iReserved16);
384 INFO_PRINTF2(_L("CSDInfo->FileFormat() = %u"), aCSDInfo.iFileFormat);
385 INFO_PRINTF2(_L("CSDInfo->ECC() = %u"), aCSDInfo.iECC);
386 INFO_PRINTF2(_L("CSDInfo->CRC() = %u"), aCSDInfo.iCRC);
387 INFO_PRINTF2(_L("CSDInfo->DeviceSize() = %u"), aCSDInfo.iDeviceSize);
388 INFO_PRINTF2(_L("CSDInfo->ReadBlockLength() = %u"), aCSDInfo.iReadBlockLength);
389 INFO_PRINTF2(_L("CSDInfo->WriteBlockLength() = %u"), aCSDInfo.iWriteBlockLength);
390 INFO_PRINTF2(_L("CSDInfo->EraseSectorSize() = %u"), aCSDInfo.iEraseSectorSize);
391 INFO_PRINTF2(_L("CSDInfo->EraseGroupSize() = %u"), aCSDInfo.iEraseGroupSize);
392 INFO_PRINTF2(_L("CSDInfo->MinReadCurrentInMilliamps() = %u"), aCSDInfo.iMinReadCurrentInMilliamps);
393 INFO_PRINTF2(_L("CSDInfo->MinWriteCurrentInMilliamps() = %u"), aCSDInfo.iMinWriteCurrentInMilliamps);
394 INFO_PRINTF2(_L("CSDInfo->MaxReadCurrentInMilliamps() = %u"), aCSDInfo.iMaxReadCurrentInMilliamps);
395 INFO_PRINTF2(_L("CSDInfo->MaxWriteCurrentInMilliamps() = %u"), aCSDInfo.iMaxWriteCurrentInMilliamps);
396 INFO_PRINTF2(_L("CSDInfo->MaxTranSpeedInKilohertz() = %u"), aCSDInfo.iMaxTranSpeedInKilohertz);
397 INFO_PRINTF2(_L("CSDInfo->ReadBlPartial() = %d"), aCSDInfo.iReadBlPartial);
398 INFO_PRINTF2(_L("CSDInfo->WriteBlkMisalign() = %d"), aCSDInfo.iWriteBlkMisalign);
399 INFO_PRINTF2(_L("CSDInfo->ReadBlkMisalign() = %d"), aCSDInfo.iReadBlkMisalign);
400 INFO_PRINTF2(_L("CSDInfo->DSRImp() = %d"), aCSDInfo.iDSRImp);
401 INFO_PRINTF2(_L("CSDInfo->WPGrpEnable() = %d"), aCSDInfo.iWPGrpEnable);
402 INFO_PRINTF2(_L("CSDInfo->WriteBlPartial() = %d"), aCSDInfo.iWriteBlPartial);
403 INFO_PRINTF2(_L("CSDInfo->FileFormatGrp() = %d"), aCSDInfo.iFileFormatGrp);
404 INFO_PRINTF2(_L("CSDInfo->Copy() = %d"), aCSDInfo.iCopy);
405 INFO_PRINTF2(_L("CSDInfo->PermWriteProtect() = %d"), aCSDInfo.iPermWriteProtect);
406 INFO_PRINTF2(_L("CSDInfo->TmpWriteProtect() = %d"), aCSDInfo.iTmpWriteProtect);
407 INFO_PRINTF2(_L("CSDInfo->MediaType() = %d"), aCSDInfo.iMediaType);
411 * Prints an Extended CSD
413 * @param aExtendedCSDInfo The Extended CSD to print
417 void CT_MmcSDDriverData::PrintExtendedCSD(const TExtendedCSDInfo& aExtendedCSDInfo)
419 INFO_PRINTF2(_L("ExtendedCSDInfo->SupportedCmdSet() = %u"), aExtendedCSDInfo.iSupportedCmdSet);
420 INFO_PRINTF2(_L("ExtendedCSDInfo->SectorCount() = %u"), aExtendedCSDInfo.iSectorCount);
421 INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfWrite8Bit52Mhz() = %u"), aExtendedCSDInfo.iMinPerfWrite8Bit52Mhz);
422 INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfRead8Bit52Mhz() = %u"), aExtendedCSDInfo.iMinPerfRead8Bit52Mhz);
423 INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfWrite8Bit26Mhz_4Bit52Mhz() = %u"), aExtendedCSDInfo.iMinPerfWrite8Bit26Mhz_4Bit52Mhz);
424 INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfRead8Bit26Mhz_4Bit52Mhz() = %u"), aExtendedCSDInfo.iMinPerfRead8Bit26Mhz_4Bit52Mhz);
425 INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfWrite4Bit26Mhz() = %u"), aExtendedCSDInfo.iMinPerfWrite4Bit26Mhz);
426 INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfRead4Bit26Mhz() = %u"), aExtendedCSDInfo.iMinPerfRead4Bit26Mhz);
427 INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass26Mhz360V() = %u"), aExtendedCSDInfo.iPowerClass26Mhz360V);
428 INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass52Mhz360V() = %u"), aExtendedCSDInfo.iPowerClass52Mhz360V);
429 INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass26Mhz195V() = %u"), aExtendedCSDInfo.iPowerClass26Mhz195V);
430 INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass52Mhz195V() = %u"), aExtendedCSDInfo.iPowerClass52Mhz195V);
431 INFO_PRINTF2(_L("ExtendedCSDInfo->CardType() = %u"), aExtendedCSDInfo.iCardType);
432 INFO_PRINTF2(_L("ExtendedCSDInfo->CSDStructureVer() = %u"), aExtendedCSDInfo.iCSDStructureVer);
433 INFO_PRINTF2(_L("ExtendedCSDInfo->ExtendedCSDRev() = %u"), aExtendedCSDInfo.iExtendedCSDRev);
434 INFO_PRINTF2(_L("ExtendedCSDInfo->CmdSet() = %u"), aExtendedCSDInfo.iCmdSet);
435 INFO_PRINTF2(_L("ExtendedCSDInfo->CmdSetRev() = %u"), aExtendedCSDInfo.iCmdSetRev);
436 INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass() = %u"), aExtendedCSDInfo.iPowerClass);
437 INFO_PRINTF2(_L("ExtendedCSDInfo->HighSpeedTiming() = %u"), aExtendedCSDInfo.iHighSpeedTiming);
442 * This function is not contained within a TMMCard wrapper as this is not a class under test
444 * @param aSection The section in the ini containing data for the command
448 void CT_MmcSDDriverData::DoCmdReadCSD()
450 INFO_PRINTF1(_L("DoCmdReadCSD called()"));
452 TInt err = iMmcSDController->ReadCSD(csdInfo);
455 if( err != KErrNone )
457 ERR_PRINTF2(_L("DoCmdReadCSD() ReadCSD() Error %d"), err);
463 * Reads the Extended CSD
464 * This function is not contained within a TMMCard wrapper as this is not a class under test
466 * @param aSection The section in the ini containing data for the command
470 void CT_MmcSDDriverData::DoCmdReadExtCSD()
472 INFO_PRINTF1(_L("DoCmdReadExtCSD called()"));
473 TExtendedCSDInfo extendedCSDInfo;
474 TInt err = iMmcSDController->ReadExtCSD(extendedCSDInfo);
475 if( err != KErrNone )
477 ERR_PRINTF2(_L("DoCmdReadExtCSD() Error %d"), err);
482 PrintExtendedCSD(extendedCSDInfo);
487 * Process command that will obtain card info from kernel side
488 * This function is not contained within a TMMCard wrapper as this is not a class under test
490 * @param aSection The section in the ini containing data for the command
494 void CT_MmcSDDriverData::DoCmdCardInfo(const TDesC& aSection)
497 INFO_PRINTF1(_L("DoCmdCardInfo()"));
498 TInt err = iMmcSDController->CardInfo(ci);
501 ERR_PRINTF2(_L("DoCmdCardInfo Error %d"), err);
506 INFO_PRINTF5(_L("iIsReady(%d) iIsLocked(%d) iRCA(%d) iMediaType(%d)"),
507 ci.iIsReady, ci.iIsLocked, ci.iRCA, ci.iMediaType );
509 INFO_PRINTF6(_L("iCardSizeInBytes low(%x) high(%x) iMaxReadBlLen(%d) iReadBlLen(%d) iReadBlPartial(%d)"),
510 I64LOW(ci.iCardSizeInBytes), I64HIGH(ci.iCardSizeInBytes), ci.iMaxReadBlLen, ci.iReadBlLen, ci.iReadBlPartial );
512 INFO_PRINTF6(_L("iWriteBlPartial(%d) iReadBlkMisalign(%d) iWriteBlkMisalign(%d) iReadCurrentInMilliAmps(%d) iWriteCurrentInMilliAmps(%d)"),
513 ci.iWriteBlPartial, ci.iReadBlkMisalign, ci.iWriteBlkMisalign, ci.iReadCurrentInMilliAmps, ci.iWriteCurrentInMilliAmps );
515 INFO_PRINTF6(_L("iSpecVers(%d) iTAAC(%d) iNSAC(%d) iTransferSpeed(%d) iCommandRegister(%d)"),
516 ci.iSpecVers, ci.iTAAC, ci.iNSAC, ci.iTransferSpeed, ci.iCommandRegister );
518 INFO_PRINTF3(_L("iHighCapacity(%d) iFlags(%d) "), ci.iHighCapacity, ci.iFlags);
520 // check against expected values
522 TInt maxreadBlockLen;
523 if(GetIntFromConfig(aSection, KMaxReadBlockLen(), maxreadBlockLen))
525 if(maxreadBlockLen != ci.iMaxReadBlLen)
527 ERR_PRINTF3(_L("max block lengths do not match actual(%d), expected(%d)"), ci.iMaxReadBlLen, maxreadBlockLen);
528 SetBlockResult(EFail);
532 TInt readCurrentInMilliAmps;
533 if(GetIntFromConfig(aSection, KReadCurrentInMilliAmps(), readCurrentInMilliAmps))
535 if(readCurrentInMilliAmps!= ci.iReadCurrentInMilliAmps)
537 ERR_PRINTF3(_L("ReadCurrentInMilliAmps do not match actual(%d), expected(%d)"),ci.iReadCurrentInMilliAmps, readCurrentInMilliAmps);
538 SetBlockResult(EFail);
543 if(GetUintFromConfig(aSection, KTransferSpeed(), transferSpeed))
545 if(transferSpeed != ci.iTransferSpeed)
547 ERR_PRINTF3(_L("transferSpeed do not match actual(%d), expected(%d)"), ci.iTransferSpeed, transferSpeed);
548 SetBlockResult(EFail);
553 if(GetBoolFromConfig(aSection, KHighCapacity(), highCapacity))
555 if(highCapacity != ci.iHighCapacity)
557 ERR_PRINTF3(_L("highCapacity do not match actual(%d), expected(%d)"), ci.iHighCapacity, highCapacity);
558 SetBlockResult(EFail);
565 * Process command that will obtain card is present status from kernel side
566 * This function is not contained within a TMMCard wrapper as this is not a class under test
568 * @param aSection The section in the ini containing data for the command
572 void CT_MmcSDDriverData::DoCmdCardIsPresent(const TDesC& aSection)
575 INFO_PRINTF1(_L("DoCmdCardIsPresent()"));
576 TInt err = iMmcSDController->CardIsPresent(isPresent);
579 ERR_PRINTF2(_L("DoCmdCardIsPresent Error %d"), err);
584 INFO_PRINTF2(_L("DoCmdCardIsPresent(): isPresent = %d"), isPresent);
586 // check against expected value
587 TBool expectedIsPresent;
588 if(GetBoolFromConfig(aSection, KExpectedIsPresent(), expectedIsPresent))
590 if(expectedIsPresent != isPresent)
592 ERR_PRINTF3(_L("isPresent does not match actual(%d), expected(%d)"), isPresent, expectedIsPresent);
593 SetBlockResult(EFail);
598 ERR_PRINTF1(_L("DoCmdCardIsPresent(): No expected value given in INI file"));
599 SetBlockResult(EFail);
605 * Process command that will obtain card is ready status from kernel side
606 * This function is not contained within a TMMCard wrapper as this is not a class under test
608 * @param aSection The section in the ini containing data for the command
612 void CT_MmcSDDriverData::DoCmdCardIsReady(const TDesC& aSection)
615 INFO_PRINTF1(_L("DoCmdCardIsReady()"));
616 TInt err = iMmcSDController->CardIsReady(isReady);
619 ERR_PRINTF2(_L("DoCmdCardIsReady Error %d"), err);
624 INFO_PRINTF2(_L("DoCmdCardIsReady(): isReady = %d"), isReady);
626 // check against expected value
627 TBool expectedIsReady;
628 if(GetBoolFromConfig(aSection, KExpectedIsReady(), expectedIsReady))
630 if(expectedIsReady != isReady)
632 ERR_PRINTF3(_L("isReady does not match actual(%d), expected(%d)"), isReady, expectedIsReady);
633 SetBlockResult(EFail);
638 ERR_PRINTF1(_L("DoCmdCardIsReady(): No expected value given in INI file"));
639 SetBlockResult(EFail);
645 * Process command that will obtain card is locked status from kernel side
646 * This function is not contained within a TMMCard wrapper as this is not a class under test
648 * @param aSection The section in the ini containing data for the command
652 void CT_MmcSDDriverData::DoCmdCardIsLocked(const TDesC& aSection)
655 INFO_PRINTF1(_L("DoCmdCardIsLocked()"));
656 TInt err = iMmcSDController->CardIsLocked(isLocked);
659 ERR_PRINTF2(_L("DoCmdCardIsLocked Error %d"), err);
664 INFO_PRINTF2(_L("DoCmdCardIsLocked(): isLocked = %d"), isLocked);
666 // check against expected value
667 TBool expectedIsLocked;
668 if(GetBoolFromConfig(aSection, KExpectedIsLocked(), expectedIsLocked))
670 if(expectedIsLocked != isLocked)
672 ERR_PRINTF3(_L("isLocked does not match actual(%d), expected(%d)"), isLocked, expectedIsLocked);
673 SetBlockResult(EFail);
678 ERR_PRINTF1(_L("DoCmdCardIsLocked(): No expected value given in INI file"));
679 SetBlockResult(EFail);
685 * Called on completion of an asynchronous command
687 * @param aActive Active Object that RunL has been called on
688 * @param aIndex Index of the active object
692 void CT_MmcSDDriverData::RunL(CActive* aActive, TInt aIndex)
694 TInt err = aActive->iStatus.Int();
695 INFO_PRINTF2(_L("CT_MmcSDDriverData::RunL() called. err (%d)"), err);
697 // retrieve the active callback wrap that wraps this item
698 CActiveCallbackWrap* activeCallbackWrap=NULL;
700 for(int i=0;i<iActiveCallbacks.Count();i++)
702 if( &(iActiveCallbacks[i]->ActiveCallback()) == aActive)
704 activeCallbackWrap = iActiveCallbacks[i];
709 if(activeCallbackWrap)
711 switch(activeCallbackWrap->FunctionId())
713 case RMMCSDTestControllerInterface::EReadSector:
715 INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EReadSector:"));
718 HBufC8* readData = (HBufC8*) activeCallbackWrap->Data();
719 // dump the read buffer here
720 TBuf16<KSectorSizeInBytes> printBuf;
721 printBuf.Copy(activeCallbackWrap->DataPtr());
722 INFO_PRINTF3(_L("ReadSector data (length=%d):\n%S"), printBuf.Length(), &printBuf);
724 HBufC8* expectedData = (HBufC8*) activeCallbackWrap->ExpectedData();
727 if (*readData != *expectedData)
729 TPtr8 expectedDataPtr(expectedData->Des());
730 TBuf16<KSectorSizeInBytes> printExpectedBuf;
731 printExpectedBuf.Copy(expectedDataPtr);
732 ERR_PRINTF3(_L("ReadSector data not as expected (length=%d):\n%S"), printExpectedBuf.Length(), &printExpectedBuf);
733 SetBlockResult(EFail);
740 case RMMCSDTestControllerInterface::EWriteSector:
741 INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EWriteSector:"));
744 case RMMCSDTestControllerInterface::ESocketPowerUp:
745 INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::ESocketPowerUp:"));
752 if (err != activeCallbackWrap->ExpectedAsyncError())
754 ERR_PRINTF3(_L("Error (%d) != Expected error (%d)"), err, activeCallbackWrap->ExpectedAsyncError());
755 SetAsyncError(aIndex, err);
759 DeleteActiveCallback((CActiveCallback*)aActive);
763 ERR_PRINTF1(_L("An unchecked active object completed"));
764 SetBlockResult(EFail);
769 * Request to cancel the asynchronous command
771 * @param aActive Active Object that DoCancel has been called on
775 void CT_MmcSDDriverData::DoCancel(CActive* aActive)
777 TInt err = aActive->iStatus.Int();
778 INFO_PRINTF2(_L("CT_MmcSDDriverData::DoCancelL() called. err (%d)"), err);
780 // retrieve the active callback wrap that wraps this item
781 CActiveCallbackWrap* activeCallbackWrap=NULL;
783 for(int i=0;i<iActiveCallbacks.Count();i++)
785 if( &(iActiveCallbacks[i]->ActiveCallback()) == aActive)
787 activeCallbackWrap = iActiveCallbacks[i];
792 if(activeCallbackWrap)
794 switch(activeCallbackWrap->FunctionId())
796 case RMMCSDTestControllerInterface::EReadSector:
797 INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EReadSector:"));
800 case RMMCSDTestControllerInterface::EWriteSector:
801 INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EWriteSector:"));
804 case RMMCSDTestControllerInterface::ESocketPowerUp:
805 INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::ESocketPowerUp:"));
812 if (err != activeCallbackWrap->ExpectedAsyncError())
814 ERR_PRINTF3(_L("Error (%d) != Expected error (%d)"), err, activeCallbackWrap->ExpectedAsyncError());
815 SetBlockResult(EFail);
819 DeleteActiveCallback((CActiveCallback*)aActive);
823 ERR_PRINTF1(_L("An unchecked active object completed"));
824 SetBlockResult(EFail);
829 * Gets the expected async error code
831 * @param aSection The section in the ini containing data for the command
833 * @return The expected async error code
835 TInt CT_MmcSDDriverData::GetExpectedAsyncError(const TDesC& aSection)
837 TInt expectedAsyncError = KErrNone;
838 GetIntFromConfig(aSection, KExpectedAsyncError(), expectedAsyncError);
839 return expectedAsyncError;