os/boardsupport/haitest/bspsvs/suite/bsp/mmc/src/T_MmcSDDriverData.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 "T_MmcSDDriverData.h"
    19 
    20 //MMCSD Commands index
    21 /*@{*/
    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,					"~");
    32 
    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");
    45 /*@}*/
    46 
    47 
    48 
    49 /**
    50  * Construction
    51  *
    52  * @return					N/A
    53  */
    54 CT_MmcSDDriverData::CT_MmcSDDriverData()
    55 :	CDataWrapperBase()
    56 ,	iMmcSDController(NULL)
    57 ,	iStackNum(0)
    58 ,	iAsyncErrorIndex(0)
    59 	{
    60 	}
    61 
    62 /**
    63  * Second phase construction
    64  *
    65  * @return					void
    66  *
    67  * @leave					System wide error
    68  */
    69 void CT_MmcSDDriverData::ConstructL()
    70 	{
    71 	User::LeaveIfError(iFs.Connect());
    72 	}
    73 
    74 /**
    75  * Public destructor
    76  *
    77  * @return					N/A
    78  */
    79 CT_MmcSDDriverData::~CT_MmcSDDriverData()
    80 	{
    81 	iFs.Close();
    82 
    83 	iActiveCallbacks.ResetAndDestroy();
    84 	}
    85 
    86 /**
    87  * Return a pointer to the object that the data wraps
    88  *
    89  * @return					pointer to the object that the data wraps
    90  */
    91 TAny* CT_MmcSDDriverData::GetObject()
    92 	{
    93 	return iMmcSDController;
    94 	}
    95 
    96 /**
    97  * Process a command read from the script file
    98  *
    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
   102  *
   103  * @return					ETrue if the command is processed
   104  *
   105  * @leave					System wide error
   106  */
   107 TBool CT_MmcSDDriverData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
   108 	{
   109 	TBool	ret=ETrue;
   110 
   111 	if ( aCommand==KCmdConstructor )
   112 		{
   113 		DoCmdConstructorL(aSection);
   114 		}
   115 	else if ( aCommand==KCmdDestructor )
   116 		{
   117 		DoCmdDestructor();
   118 		}
   119 	else if(aCommand == KCmdReadSector)
   120 		{
   121 		DoCmdReadSectorL(aSection, aAsyncErrorIndex);
   122 		}
   123 	else if(aCommand == KCmdWriteSector)
   124 		{
   125 		DoCmdWriteSectorL(aSection, aAsyncErrorIndex);
   126 		}
   127 	else if(aCommand == KCmdReadCSD)
   128 		{
   129 		DoCmdReadCSD();
   130 		}
   131 	else if(aCommand == KCmdReadExtCSD)
   132 		{
   133 		DoCmdReadExtCSD();
   134 		}
   135 	else if(aCommand == KCmdCardInfo)
   136 		{
   137 		DoCmdCardInfo(aSection);
   138 		}
   139 	else if(aCommand == KCmdCardIsPresent)
   140 		{
   141 		DoCmdCardIsPresent(aSection);
   142 		}
   143 	else if(aCommand == KCmdCardIsReady)
   144 		{
   145 		DoCmdCardIsReady(aSection);
   146 		}
   147 	else if(aCommand == KCmdCardIsLocked)
   148 		{
   149 		DoCmdCardIsLocked(aSection);
   150 		}
   151 	else
   152 		{
   153 		ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
   154 		}
   155 	return ret;
   156 	}
   157 
   158 /**
   159  * Creates the RBusLogicalChannel derived interface
   160  *
   161  * @param aSection			The section in the ini containing data for the command
   162  *
   163  * @return					void
   164  *
   165  * @leave					System wide error
   166  */
   167 void CT_MmcSDDriverData::DoCmdConstructorL(const TDesC& aSection)
   168 	{
   169 	TPtrC	wrapperName;
   170 	if( GetStringFromConfig(aSection, KSessionWrapperName(), wrapperName) )
   171 		{
   172 		iMmcSDController = static_cast<RMMCSDTestControllerInterface*>(GetDataObjectL(wrapperName));
   173 		INFO_PRINTF2(_L("iMmcSDController = %x"), iMmcSDController);
   174 
   175 		if( iMmcSDController == NULL )
   176 			{
   177 			ERR_PRINTF1(_L("iMmcSDController is NULL-Constructor"));
   178 			SetBlockResult(EFail);
   179 			}
   180 		}
   181 	else
   182 		{
   183 		ERR_PRINTF1(_L("Error in Session Wrapper Name from INI file-Constructor"));
   184 		SetBlockResult(EFail);
   185 		}
   186 	}
   187 
   188 /**
   189  * Destructor
   190  *
   191  * @return					void
   192  */
   193 void CT_MmcSDDriverData::DoCmdDestructor()
   194 	{
   195 	INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCmdDestructor()"));
   196 	}
   197 
   198 /**
   199  * Creates an active callback wrapper and adds to the list
   200  *
   201  * @param aFunctionId			The active callback function ID
   202  * @param aExpectedAsyncError	The active callback expected asynchronous error
   203  *
   204  * @return						The active callback wrapper created
   205  */
   206 CActiveCallbackWrap* CT_MmcSDDriverData::CreateActiveCallbackL(TInt aFunctionId, TInt aExpectedAsyncError)
   207 	{
   208 	CActiveCallbackWrap* activeCallbackWrap = CActiveCallbackWrap::NewL(*this, aFunctionId, aExpectedAsyncError);
   209 	iActiveCallbacks.Append(activeCallbackWrap);
   210 	return activeCallbackWrap;
   211 	}
   212 
   213 /**
   214  * Deletes an active callback from the list
   215  *
   216  * @param activeCallback	The active callback to delete
   217  *
   218  * @return					void
   219  */
   220 void CT_MmcSDDriverData::DeleteActiveCallback(CActiveCallback* activeCallback)
   221 	{
   222 	if(activeCallback)
   223 		{
   224 		// loop through all wraps until we find the appropriate item
   225 
   226 		CActiveCallbackWrap* activeCallbackWrap = NULL;
   227 
   228 		for(int i=0;i<iActiveCallbacks.Count();i++)
   229 			{
   230 			if( &(iActiveCallbacks[i]->ActiveCallback()) == activeCallback)
   231 				{
   232 				activeCallbackWrap = iActiveCallbacks[i];
   233 				iActiveCallbacks.Remove(i);
   234 				break;
   235 				}
   236 			}
   237 
   238 		delete activeCallbackWrap;
   239 		}
   240 	}
   241 
   242 /**
   243  * Reads a sector from the card
   244  *
   245  * @param aSection			The section in the ini containing data for the command
   246  * @param aAsyncErrorIndex	The asynchronous error index
   247  *
   248  * @return					void
   249  *
   250  * @leave					System wide error
   251  */
   252 void CT_MmcSDDriverData::DoCmdReadSectorL(const TDesC& aSection, TInt aAsyncErrorIndex)
   253 	{
   254 
   255 	INFO_PRINTF1(_L("DoCmdReadSectorL called()"));
   256 
   257 	TInt sectorNumber;
   258 
   259 	if(!GetIntFromConfig(aSection, KSectorNumber(), sectorNumber))
   260 		{
   261 		ERR_PRINTF1(_L("DoCmdReadSectorL FAILED TO READ sectorNumber"));
   262 		SetBlockResult(EFail);
   263 		}
   264 	else
   265 		{
   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);
   270 		
   271 		TPtrC 	expectedSectorText;
   272 		if(GetStringFromConfig(aSection, KSectorText(), expectedSectorText))
   273 			{
   274 			TInt	noOfRepeats = 1;
   275 			GetIntFromConfig(aSection, KRepeats(), noOfRepeats);
   276 
   277 			HBufC8* expectedData = HBufC8::NewLC(KSectorSizeInBytes);
   278 			activeCallbackWrap->SetExpectedDesData(expectedData);
   279 			
   280 			activeCallbackWrap->ExpectedDataPtr().Zero();
   281 			for(TInt i=0;i<noOfRepeats;i++)
   282 				{
   283 				activeCallbackWrap->ExpectedDataPtr().Append(expectedSectorText);
   284 				}
   285 
   286 		 	TBuf16<KSectorSizeInBytes> printBuf;
   287 		 	printBuf.Copy(activeCallbackWrap->ExpectedDataPtr());
   288 			INFO_PRINTF3(_L("DoCmdReadSectorL expectedSectorText (length=%d):\n%S"), printBuf.Length(), &printBuf);
   289 
   290 			CleanupStack::Pop(expectedData);
   291 			}
   292 
   293 		iMmcSDController->ReadSector(activeCallbackWrap->ActiveCallback().iStatus, sectorNumber, activeCallbackWrap->DataPtr());
   294 		activeCallbackWrap->ActiveCallback().Activate(aAsyncErrorIndex);
   295 		IncOutstanding();
   296 		CleanupStack::Pop(readData);
   297 		}
   298 	}
   299 
   300 /**
   301  * Writes a sector to the card
   302  *
   303  * @param aSection			The section in the ini containing data for the command
   304  * @param aAsyncErrorIndex	The asynchronous error index
   305  *
   306  * @return					void
   307  *
   308  * @leave					System wide error
   309  */
   310 void CT_MmcSDDriverData::DoCmdWriteSectorL(const TDesC& aSection, TInt aAsyncErrorIndex)
   311 	{
   312 	INFO_PRINTF1(_L("DoCmdWriteSectorL called()"));
   313 	TInt	sectorNumber;
   314 	TPtrC 	sectorText;
   315 
   316 	if(!GetIntFromConfig(aSection, KSectorNumber(), sectorNumber))
   317 		{
   318 		ERR_PRINTF1(_L("DoCmdWriteSectorL FAILED TO READ sectorNumber"));
   319 		SetBlockResult(EFail);
   320 		}
   321 	else if(!GetStringFromConfig(aSection, KSectorText(), sectorText))
   322 		{
   323 		ERR_PRINTF1(_L("DoCmdWriteSectorL FAILED TO READ sectorText"));
   324 		SetBlockResult(EFail);
   325 		}
   326 	else
   327 		{
   328 		TInt	noOfRepeats = 1;
   329 		GetIntFromConfig(aSection, KRepeats(), noOfRepeats);
   330 
   331 		HBufC8* writeData = HBufC8::NewLC(KSectorSizeInBytes);
   332 
   333 		CActiveCallbackWrap* activeCallbackWrap = CreateActiveCallbackL(RMMCSDTestControllerInterface::EWriteSector, GetExpectedAsyncError(aSection));
   334 		activeCallbackWrap->SetDesData(writeData);
   335 
   336 		activeCallbackWrap->DataPtr().Zero();
   337 		for(TInt i=0;i<noOfRepeats;i++)
   338 			{
   339 			activeCallbackWrap->DataPtr().Append(sectorText);
   340 			}
   341 
   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);
   345 
   346 		iMmcSDController->WriteSector(activeCallbackWrap->ActiveCallback().iStatus, sectorNumber, activeCallbackWrap->DataPtr());
   347 		activeCallbackWrap->ActiveCallback().Activate(aAsyncErrorIndex);
   348 		IncOutstanding();
   349 		CleanupStack::Pop(writeData);
   350 		}
   351 	}
   352 
   353 /**
   354  * Prints a CSD
   355  *
   356  * @param aCSDInfo			The CSD to print
   357  *
   358  * @return					void
   359  */
   360 void CT_MmcSDDriverData::PrintCSD(const TCSDInfo& aCSDInfo)
   361 	{
   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);
   408 	}
   409 
   410 /**
   411  * Prints an Extended CSD
   412  *
   413  * @param aExtendedCSDInfo	The Extended CSD to print
   414  *
   415  * @return					void
   416  */
   417 void CT_MmcSDDriverData::PrintExtendedCSD(const TExtendedCSDInfo& aExtendedCSDInfo)
   418 	{
   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);
   438 	}
   439 
   440 /**
   441  * Reads the CSD
   442  * This function is not contained within a TMMCard wrapper as this is not a class under test
   443  *
   444  * @param aSection			The section in the ini containing data for the command
   445  *
   446  * @return					void
   447  */
   448 void CT_MmcSDDriverData::DoCmdReadCSD()
   449 	{
   450 	INFO_PRINTF1(_L("DoCmdReadCSD called()"));
   451 	TCSDInfo csdInfo;
   452 	TInt err = iMmcSDController->ReadCSD(csdInfo);
   453 	PrintCSD(csdInfo);
   454 
   455 	if( err != KErrNone )
   456 		{
   457 		ERR_PRINTF2(_L("DoCmdReadCSD() ReadCSD() Error %d"), err);
   458 		SetError(err);
   459 		}
   460 	}
   461 
   462 /**
   463  * Reads the Extended CSD
   464  * This function is not contained within a TMMCard wrapper as this is not a class under test
   465  *
   466  * @param aSection			The section in the ini containing data for the command
   467  *
   468  * @return					void
   469  */
   470 void CT_MmcSDDriverData::DoCmdReadExtCSD()
   471 	{
   472 	INFO_PRINTF1(_L("DoCmdReadExtCSD called()"));
   473 	TExtendedCSDInfo extendedCSDInfo;
   474 	TInt err = iMmcSDController->ReadExtCSD(extendedCSDInfo);
   475 	if( err != KErrNone )
   476 		{
   477 		ERR_PRINTF2(_L("DoCmdReadExtCSD() Error %d"), err);
   478 		SetError(err);
   479 		}
   480 	else
   481 		{
   482 		PrintExtendedCSD(extendedCSDInfo);
   483 		}
   484 	}
   485 
   486 /**
   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
   489  *
   490  * @param aSection			The section in the ini containing data for the command
   491  *
   492  * @return					void
   493  */
   494 void CT_MmcSDDriverData::DoCmdCardInfo(const TDesC& aSection)
   495 	{
   496 	TMMCCardInfo ci;
   497 	INFO_PRINTF1(_L("DoCmdCardInfo()"));
   498 	TInt err = iMmcSDController->CardInfo(ci);
   499 	if (err != KErrNone)
   500 		{
   501 		ERR_PRINTF2(_L("DoCmdCardInfo Error %d"), err);
   502 		SetError(err);
   503 		}
   504 	else
   505 		{
   506 		INFO_PRINTF5(_L("iIsReady(%d) iIsLocked(%d) iRCA(%d) iMediaType(%d)"),
   507 				ci.iIsReady, ci.iIsLocked, ci.iRCA, ci.iMediaType );
   508 
   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 );
   511 
   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 );
   514 
   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 );
   517 
   518 		INFO_PRINTF3(_L("iHighCapacity(%d) iFlags(%d) "), ci.iHighCapacity, ci.iFlags);
   519 
   520 		// check against expected values
   521 
   522 		TInt maxreadBlockLen;
   523 		if(GetIntFromConfig(aSection, KMaxReadBlockLen(), maxreadBlockLen))
   524 			{
   525 			if(maxreadBlockLen != ci.iMaxReadBlLen)
   526 				{
   527 				ERR_PRINTF3(_L("max block lengths do not match actual(%d), expected(%d)"), ci.iMaxReadBlLen, maxreadBlockLen);
   528 				SetBlockResult(EFail);
   529 				}
   530 			}
   531 
   532 		TInt readCurrentInMilliAmps;
   533 		if(GetIntFromConfig(aSection, KReadCurrentInMilliAmps(), readCurrentInMilliAmps))
   534 			{
   535 			if(readCurrentInMilliAmps!= ci.iReadCurrentInMilliAmps)
   536 				{
   537 				ERR_PRINTF3(_L("ReadCurrentInMilliAmps do not match actual(%d), expected(%d)"),ci.iReadCurrentInMilliAmps, readCurrentInMilliAmps);
   538 				SetBlockResult(EFail);
   539 				}
   540 			}
   541 
   542 		TUint transferSpeed;
   543 		if(GetUintFromConfig(aSection, KTransferSpeed(), transferSpeed))
   544 			{
   545 			if(transferSpeed != ci.iTransferSpeed)
   546 				{
   547 				ERR_PRINTF3(_L("transferSpeed do not match actual(%d), expected(%d)"), ci.iTransferSpeed, transferSpeed);
   548 				SetBlockResult(EFail);
   549 				}
   550 			}
   551 
   552 		TBool highCapacity;
   553 		if(GetBoolFromConfig(aSection, KHighCapacity(), highCapacity))
   554 			{
   555 			if(highCapacity != ci.iHighCapacity)
   556 				{
   557 				ERR_PRINTF3(_L("highCapacity do not match actual(%d), expected(%d)"), ci.iHighCapacity, highCapacity);
   558 				SetBlockResult(EFail);
   559 				}
   560 			}
   561 		}
   562 	}
   563 
   564 /**
   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
   567  *
   568  * @param aSection			The section in the ini containing data for the command
   569  *
   570  * @return					void
   571  */
   572 void CT_MmcSDDriverData::DoCmdCardIsPresent(const TDesC& aSection)
   573 	{
   574 	TBool isPresent;
   575 	INFO_PRINTF1(_L("DoCmdCardIsPresent()"));
   576 	TInt err = iMmcSDController->CardIsPresent(isPresent);
   577 	if (err != KErrNone)
   578 		{
   579 		ERR_PRINTF2(_L("DoCmdCardIsPresent Error %d"), err);
   580 		SetError(err);
   581 		}
   582 	else
   583 		{
   584 		INFO_PRINTF2(_L("DoCmdCardIsPresent(): isPresent = %d"), isPresent);
   585 		
   586 		// check against expected value
   587 		TBool expectedIsPresent;
   588 		if(GetBoolFromConfig(aSection, KExpectedIsPresent(), expectedIsPresent))
   589 			{
   590 			if(expectedIsPresent != isPresent)
   591 				{
   592 				ERR_PRINTF3(_L("isPresent does not match actual(%d), expected(%d)"), isPresent, expectedIsPresent);
   593 				SetBlockResult(EFail);
   594 				}
   595 			}
   596 		else
   597 			{
   598 			ERR_PRINTF1(_L("DoCmdCardIsPresent(): No expected value given in INI file"));
   599 			SetBlockResult(EFail);			
   600 			}
   601 		}
   602 	}
   603 
   604 /**
   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
   607  *
   608  * @param aSection			The section in the ini containing data for the command
   609  *
   610  * @return					void
   611  */
   612 void CT_MmcSDDriverData::DoCmdCardIsReady(const TDesC& aSection)
   613 	{
   614 	TBool isReady;
   615 	INFO_PRINTF1(_L("DoCmdCardIsReady()"));
   616 	TInt err = iMmcSDController->CardIsReady(isReady);
   617 	if (err != KErrNone)
   618 		{
   619 		ERR_PRINTF2(_L("DoCmdCardIsReady Error %d"), err);
   620 		SetError(err);
   621 		}
   622 	else
   623 		{
   624 		INFO_PRINTF2(_L("DoCmdCardIsReady(): isReady = %d"), isReady);
   625 		
   626 		// check against expected value
   627 		TBool expectedIsReady;
   628 		if(GetBoolFromConfig(aSection, KExpectedIsReady(), expectedIsReady))
   629 			{
   630 			if(expectedIsReady != isReady)
   631 				{
   632 				ERR_PRINTF3(_L("isReady does not match actual(%d), expected(%d)"), isReady, expectedIsReady);
   633 				SetBlockResult(EFail);
   634 				}
   635 			}
   636 		else
   637 			{
   638 			ERR_PRINTF1(_L("DoCmdCardIsReady(): No expected value given in INI file"));
   639 			SetBlockResult(EFail);			
   640 			}
   641 		}
   642 	}
   643 
   644 /**
   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
   647  *
   648  * @param aSection			The section in the ini containing data for the command
   649  *
   650  * @return					void
   651  */
   652 void CT_MmcSDDriverData::DoCmdCardIsLocked(const TDesC& aSection)
   653 	{
   654 	TBool isLocked;
   655 	INFO_PRINTF1(_L("DoCmdCardIsLocked()"));
   656 	TInt err = iMmcSDController->CardIsLocked(isLocked);
   657 	if (err != KErrNone)
   658 		{
   659 		ERR_PRINTF2(_L("DoCmdCardIsLocked Error %d"), err);
   660 		SetError(err);
   661 		}
   662 	else
   663 		{
   664 		INFO_PRINTF2(_L("DoCmdCardIsLocked(): isLocked = %d"), isLocked);
   665 		
   666 		// check against expected value
   667 		TBool expectedIsLocked;
   668 		if(GetBoolFromConfig(aSection, KExpectedIsLocked(), expectedIsLocked))
   669 			{
   670 			if(expectedIsLocked != isLocked)
   671 				{
   672 				ERR_PRINTF3(_L("isLocked does not match actual(%d), expected(%d)"), isLocked, expectedIsLocked);
   673 				SetBlockResult(EFail);
   674 				}
   675 			}
   676 		else
   677 			{
   678 			ERR_PRINTF1(_L("DoCmdCardIsLocked(): No expected value given in INI file"));
   679 			SetBlockResult(EFail);			
   680 			}
   681 		}
   682 	}
   683 
   684 /**
   685  * Called on completion of an asynchronous command
   686  *
   687  * @param aActive			Active Object that RunL has been called on
   688  * @param aIndex			Index of the active object
   689  *
   690  * @return					void
   691  */
   692 void CT_MmcSDDriverData::RunL(CActive* aActive, TInt aIndex)
   693  	{
   694 	TInt	err = aActive->iStatus.Int();
   695  	INFO_PRINTF2(_L("CT_MmcSDDriverData::RunL() called. err (%d)"), err);
   696 
   697  	// retrieve the active callback wrap that wraps this item
   698  	CActiveCallbackWrap* activeCallbackWrap=NULL;
   699 
   700 	for(int i=0;i<iActiveCallbacks.Count();i++)
   701 		{
   702 		if( &(iActiveCallbacks[i]->ActiveCallback()) == aActive)
   703 			{
   704 			activeCallbackWrap = iActiveCallbacks[i];
   705 			break;
   706 			}
   707 		}
   708 
   709 	if(activeCallbackWrap)
   710 		{
   711 		switch(activeCallbackWrap->FunctionId())
   712 			{
   713 			case RMMCSDTestControllerInterface::EReadSector:
   714 				{
   715 				INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EReadSector:"));
   716 				if (err == KErrNone)
   717 					{
   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);
   723 
   724 					HBufC8* expectedData = (HBufC8*) activeCallbackWrap->ExpectedData();
   725 					if (expectedData)
   726 						{
   727 						if (*readData != *expectedData)
   728 							{
   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);
   734 							}
   735 						}
   736 					}
   737 				}
   738 				break;
   739 
   740 			case RMMCSDTestControllerInterface::EWriteSector:
   741 				INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EWriteSector:"));
   742 				break;
   743 				
   744 			case RMMCSDTestControllerInterface::ESocketPowerUp:
   745 				INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::ESocketPowerUp:"));
   746 				break;
   747 
   748 			default:
   749 				break;
   750 			}
   751 
   752 		if (err != activeCallbackWrap->ExpectedAsyncError())
   753 			{
   754 			ERR_PRINTF3(_L("Error (%d) != Expected error (%d)"), err, activeCallbackWrap->ExpectedAsyncError());
   755 			SetAsyncError(aIndex, err);
   756 			}
   757 
   758 		DecOutstanding();
   759 		DeleteActiveCallback((CActiveCallback*)aActive);
   760 		}
   761 	else
   762 		{
   763 		ERR_PRINTF1(_L("An unchecked active object completed"));
   764 		SetBlockResult(EFail);
   765 		}
   766  	}
   767 
   768 /**
   769  * Request to cancel the asynchronous command
   770  *
   771  * @param aActive			Active Object that DoCancel has been called on
   772  *
   773  * @return					void
   774  */
   775 void CT_MmcSDDriverData::DoCancel(CActive* aActive)
   776  	{
   777 	TInt	err = aActive->iStatus.Int();
   778  	INFO_PRINTF2(_L("CT_MmcSDDriverData::DoCancelL() called. err (%d)"), err);
   779 
   780  	// retrieve the active callback wrap that wraps this item
   781  	CActiveCallbackWrap* activeCallbackWrap=NULL;
   782 
   783 	for(int i=0;i<iActiveCallbacks.Count();i++)
   784 		{
   785 		if( &(iActiveCallbacks[i]->ActiveCallback()) == aActive)
   786 			{
   787 			activeCallbackWrap = iActiveCallbacks[i];
   788 			break;
   789 			}
   790 		}
   791 
   792 	if(activeCallbackWrap)
   793 		{
   794 		switch(activeCallbackWrap->FunctionId())
   795 		{
   796 			case RMMCSDTestControllerInterface::EReadSector:
   797 				INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EReadSector:"));
   798 				break;
   799 
   800 			case RMMCSDTestControllerInterface::EWriteSector:
   801 				INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EWriteSector:"));
   802 				break;
   803 				
   804 			case RMMCSDTestControllerInterface::ESocketPowerUp:
   805 				INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::ESocketPowerUp:"));
   806 				break;
   807 
   808 			default:
   809 				break;
   810 		}
   811 
   812 		if (err != activeCallbackWrap->ExpectedAsyncError())
   813 			{
   814 			ERR_PRINTF3(_L("Error (%d) != Expected error (%d)"), err, activeCallbackWrap->ExpectedAsyncError());
   815 			SetBlockResult(EFail);
   816 			}
   817 
   818 		DecOutstanding();
   819 		DeleteActiveCallback((CActiveCallback*)aActive);
   820 		}
   821 	else
   822 		{
   823 		ERR_PRINTF1(_L("An unchecked active object completed"));
   824 		SetBlockResult(EFail);
   825 		}
   826  	}
   827 
   828 /**
   829  * Gets the expected async error code
   830  *
   831  * @param aSection			The section in the ini containing data for the command
   832  *
   833  * @return					The expected async error code
   834  */
   835 TInt CT_MmcSDDriverData::GetExpectedAsyncError(const TDesC& aSection)
   836  	{
   837 	TInt expectedAsyncError = KErrNone;
   838 	GetIntFromConfig(aSection, KExpectedAsyncError(), expectedAsyncError);
   839 	return expectedAsyncError;
   840  	}
   841