1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/bsp/mmc/src/T_MmcSDDriverData.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,841 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +#include "T_MmcSDDriverData.h"
1.22 +
1.23 +//MMCSD Commands index
1.24 +/*@{*/
1.25 +_LIT(KCmdConstructor, "NewL");
1.26 +_LIT(KCmdReadSector, "ReadSector");
1.27 +_LIT(KCmdWriteSector, "WriteSector");
1.28 +_LIT(KCmdReadCSD, "ReadCSD");
1.29 +_LIT(KCmdReadExtCSD, "ReadExtCSD");
1.30 +_LIT(KCmdCardInfo, "CardInfo");
1.31 +_LIT(KCmdCardIsPresent, "CardIsPresent");
1.32 +_LIT(KCmdCardIsReady, "CardIsReady");
1.33 +_LIT(KCmdCardIsLocked, "CardIsLocked");
1.34 +_LIT(KCmdDestructor, "~");
1.35 +
1.36 +_LIT(KExpectedAsyncError, "expectedasyncerror");
1.37 +_LIT(KSectorNumber, "sectornumber");
1.38 +_LIT(KSectorText, "sectortext");
1.39 +_LIT(KRepeats, "repeats");
1.40 +_LIT(KHighCapacity, "highcapacity");
1.41 +_LIT(KMaxReadBlockLen, "maxreadblocklen");
1.42 +_LIT(KReadCurrentInMilliAmps, "readcurrentinmilliamps");
1.43 +_LIT(KTransferSpeed, "transferspeed");
1.44 +_LIT(KSessionWrapperName, "sessionwrappername");
1.45 +_LIT(KExpectedIsPresent, "expectedispresent");
1.46 +_LIT(KExpectedIsReady, "expectedisready");
1.47 +_LIT(KExpectedIsLocked, "expectedislocked");
1.48 +/*@}*/
1.49 +
1.50 +
1.51 +
1.52 +/**
1.53 + * Construction
1.54 + *
1.55 + * @return N/A
1.56 + */
1.57 +CT_MmcSDDriverData::CT_MmcSDDriverData()
1.58 +: CDataWrapperBase()
1.59 +, iMmcSDController(NULL)
1.60 +, iStackNum(0)
1.61 +, iAsyncErrorIndex(0)
1.62 + {
1.63 + }
1.64 +
1.65 +/**
1.66 + * Second phase construction
1.67 + *
1.68 + * @return void
1.69 + *
1.70 + * @leave System wide error
1.71 + */
1.72 +void CT_MmcSDDriverData::ConstructL()
1.73 + {
1.74 + User::LeaveIfError(iFs.Connect());
1.75 + }
1.76 +
1.77 +/**
1.78 + * Public destructor
1.79 + *
1.80 + * @return N/A
1.81 + */
1.82 +CT_MmcSDDriverData::~CT_MmcSDDriverData()
1.83 + {
1.84 + iFs.Close();
1.85 +
1.86 + iActiveCallbacks.ResetAndDestroy();
1.87 + }
1.88 +
1.89 +/**
1.90 + * Return a pointer to the object that the data wraps
1.91 + *
1.92 + * @return pointer to the object that the data wraps
1.93 + */
1.94 +TAny* CT_MmcSDDriverData::GetObject()
1.95 + {
1.96 + return iMmcSDController;
1.97 + }
1.98 +
1.99 +/**
1.100 + * Process a command read from the script file
1.101 + *
1.102 + * @param aCommand The command to process
1.103 + * @param aSection The section in the ini containing data for the command
1.104 + * @param aAsyncErrorIndex Command index for async calls to return errors to
1.105 + *
1.106 + * @return ETrue if the command is processed
1.107 + *
1.108 + * @leave System wide error
1.109 + */
1.110 +TBool CT_MmcSDDriverData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.111 + {
1.112 + TBool ret=ETrue;
1.113 +
1.114 + if ( aCommand==KCmdConstructor )
1.115 + {
1.116 + DoCmdConstructorL(aSection);
1.117 + }
1.118 + else if ( aCommand==KCmdDestructor )
1.119 + {
1.120 + DoCmdDestructor();
1.121 + }
1.122 + else if(aCommand == KCmdReadSector)
1.123 + {
1.124 + DoCmdReadSectorL(aSection, aAsyncErrorIndex);
1.125 + }
1.126 + else if(aCommand == KCmdWriteSector)
1.127 + {
1.128 + DoCmdWriteSectorL(aSection, aAsyncErrorIndex);
1.129 + }
1.130 + else if(aCommand == KCmdReadCSD)
1.131 + {
1.132 + DoCmdReadCSD();
1.133 + }
1.134 + else if(aCommand == KCmdReadExtCSD)
1.135 + {
1.136 + DoCmdReadExtCSD();
1.137 + }
1.138 + else if(aCommand == KCmdCardInfo)
1.139 + {
1.140 + DoCmdCardInfo(aSection);
1.141 + }
1.142 + else if(aCommand == KCmdCardIsPresent)
1.143 + {
1.144 + DoCmdCardIsPresent(aSection);
1.145 + }
1.146 + else if(aCommand == KCmdCardIsReady)
1.147 + {
1.148 + DoCmdCardIsReady(aSection);
1.149 + }
1.150 + else if(aCommand == KCmdCardIsLocked)
1.151 + {
1.152 + DoCmdCardIsLocked(aSection);
1.153 + }
1.154 + else
1.155 + {
1.156 + ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
1.157 + }
1.158 + return ret;
1.159 + }
1.160 +
1.161 +/**
1.162 + * Creates the RBusLogicalChannel derived interface
1.163 + *
1.164 + * @param aSection The section in the ini containing data for the command
1.165 + *
1.166 + * @return void
1.167 + *
1.168 + * @leave System wide error
1.169 + */
1.170 +void CT_MmcSDDriverData::DoCmdConstructorL(const TDesC& aSection)
1.171 + {
1.172 + TPtrC wrapperName;
1.173 + if( GetStringFromConfig(aSection, KSessionWrapperName(), wrapperName) )
1.174 + {
1.175 + iMmcSDController = static_cast<RMMCSDTestControllerInterface*>(GetDataObjectL(wrapperName));
1.176 + INFO_PRINTF2(_L("iMmcSDController = %x"), iMmcSDController);
1.177 +
1.178 + if( iMmcSDController == NULL )
1.179 + {
1.180 + ERR_PRINTF1(_L("iMmcSDController is NULL-Constructor"));
1.181 + SetBlockResult(EFail);
1.182 + }
1.183 + }
1.184 + else
1.185 + {
1.186 + ERR_PRINTF1(_L("Error in Session Wrapper Name from INI file-Constructor"));
1.187 + SetBlockResult(EFail);
1.188 + }
1.189 + }
1.190 +
1.191 +/**
1.192 + * Destructor
1.193 + *
1.194 + * @return void
1.195 + */
1.196 +void CT_MmcSDDriverData::DoCmdDestructor()
1.197 + {
1.198 + INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCmdDestructor()"));
1.199 + }
1.200 +
1.201 +/**
1.202 + * Creates an active callback wrapper and adds to the list
1.203 + *
1.204 + * @param aFunctionId The active callback function ID
1.205 + * @param aExpectedAsyncError The active callback expected asynchronous error
1.206 + *
1.207 + * @return The active callback wrapper created
1.208 + */
1.209 +CActiveCallbackWrap* CT_MmcSDDriverData::CreateActiveCallbackL(TInt aFunctionId, TInt aExpectedAsyncError)
1.210 + {
1.211 + CActiveCallbackWrap* activeCallbackWrap = CActiveCallbackWrap::NewL(*this, aFunctionId, aExpectedAsyncError);
1.212 + iActiveCallbacks.Append(activeCallbackWrap);
1.213 + return activeCallbackWrap;
1.214 + }
1.215 +
1.216 +/**
1.217 + * Deletes an active callback from the list
1.218 + *
1.219 + * @param activeCallback The active callback to delete
1.220 + *
1.221 + * @return void
1.222 + */
1.223 +void CT_MmcSDDriverData::DeleteActiveCallback(CActiveCallback* activeCallback)
1.224 + {
1.225 + if(activeCallback)
1.226 + {
1.227 + // loop through all wraps until we find the appropriate item
1.228 +
1.229 + CActiveCallbackWrap* activeCallbackWrap = NULL;
1.230 +
1.231 + for(int i=0;i<iActiveCallbacks.Count();i++)
1.232 + {
1.233 + if( &(iActiveCallbacks[i]->ActiveCallback()) == activeCallback)
1.234 + {
1.235 + activeCallbackWrap = iActiveCallbacks[i];
1.236 + iActiveCallbacks.Remove(i);
1.237 + break;
1.238 + }
1.239 + }
1.240 +
1.241 + delete activeCallbackWrap;
1.242 + }
1.243 + }
1.244 +
1.245 +/**
1.246 + * Reads a sector from the card
1.247 + *
1.248 + * @param aSection The section in the ini containing data for the command
1.249 + * @param aAsyncErrorIndex The asynchronous error index
1.250 + *
1.251 + * @return void
1.252 + *
1.253 + * @leave System wide error
1.254 + */
1.255 +void CT_MmcSDDriverData::DoCmdReadSectorL(const TDesC& aSection, TInt aAsyncErrorIndex)
1.256 + {
1.257 +
1.258 + INFO_PRINTF1(_L("DoCmdReadSectorL called()"));
1.259 +
1.260 + TInt sectorNumber;
1.261 +
1.262 + if(!GetIntFromConfig(aSection, KSectorNumber(), sectorNumber))
1.263 + {
1.264 + ERR_PRINTF1(_L("DoCmdReadSectorL FAILED TO READ sectorNumber"));
1.265 + SetBlockResult(EFail);
1.266 + }
1.267 + else
1.268 + {
1.269 + INFO_PRINTF2(_L("DoCmdReadSectorL sectorNumber(%d)"), sectorNumber);
1.270 + HBufC8* readData = HBufC8::NewLC(KSectorSizeInBytes);
1.271 + CActiveCallbackWrap* activeCallbackWrap = CreateActiveCallbackL(RMMCSDTestControllerInterface::EReadSector, GetExpectedAsyncError(aSection));
1.272 + activeCallbackWrap->SetDesData(readData);
1.273 +
1.274 + TPtrC expectedSectorText;
1.275 + if(GetStringFromConfig(aSection, KSectorText(), expectedSectorText))
1.276 + {
1.277 + TInt noOfRepeats = 1;
1.278 + GetIntFromConfig(aSection, KRepeats(), noOfRepeats);
1.279 +
1.280 + HBufC8* expectedData = HBufC8::NewLC(KSectorSizeInBytes);
1.281 + activeCallbackWrap->SetExpectedDesData(expectedData);
1.282 +
1.283 + activeCallbackWrap->ExpectedDataPtr().Zero();
1.284 + for(TInt i=0;i<noOfRepeats;i++)
1.285 + {
1.286 + activeCallbackWrap->ExpectedDataPtr().Append(expectedSectorText);
1.287 + }
1.288 +
1.289 + TBuf16<KSectorSizeInBytes> printBuf;
1.290 + printBuf.Copy(activeCallbackWrap->ExpectedDataPtr());
1.291 + INFO_PRINTF3(_L("DoCmdReadSectorL expectedSectorText (length=%d):\n%S"), printBuf.Length(), &printBuf);
1.292 +
1.293 + CleanupStack::Pop(expectedData);
1.294 + }
1.295 +
1.296 + iMmcSDController->ReadSector(activeCallbackWrap->ActiveCallback().iStatus, sectorNumber, activeCallbackWrap->DataPtr());
1.297 + activeCallbackWrap->ActiveCallback().Activate(aAsyncErrorIndex);
1.298 + IncOutstanding();
1.299 + CleanupStack::Pop(readData);
1.300 + }
1.301 + }
1.302 +
1.303 +/**
1.304 + * Writes a sector to the card
1.305 + *
1.306 + * @param aSection The section in the ini containing data for the command
1.307 + * @param aAsyncErrorIndex The asynchronous error index
1.308 + *
1.309 + * @return void
1.310 + *
1.311 + * @leave System wide error
1.312 + */
1.313 +void CT_MmcSDDriverData::DoCmdWriteSectorL(const TDesC& aSection, TInt aAsyncErrorIndex)
1.314 + {
1.315 + INFO_PRINTF1(_L("DoCmdWriteSectorL called()"));
1.316 + TInt sectorNumber;
1.317 + TPtrC sectorText;
1.318 +
1.319 + if(!GetIntFromConfig(aSection, KSectorNumber(), sectorNumber))
1.320 + {
1.321 + ERR_PRINTF1(_L("DoCmdWriteSectorL FAILED TO READ sectorNumber"));
1.322 + SetBlockResult(EFail);
1.323 + }
1.324 + else if(!GetStringFromConfig(aSection, KSectorText(), sectorText))
1.325 + {
1.326 + ERR_PRINTF1(_L("DoCmdWriteSectorL FAILED TO READ sectorText"));
1.327 + SetBlockResult(EFail);
1.328 + }
1.329 + else
1.330 + {
1.331 + TInt noOfRepeats = 1;
1.332 + GetIntFromConfig(aSection, KRepeats(), noOfRepeats);
1.333 +
1.334 + HBufC8* writeData = HBufC8::NewLC(KSectorSizeInBytes);
1.335 +
1.336 + CActiveCallbackWrap* activeCallbackWrap = CreateActiveCallbackL(RMMCSDTestControllerInterface::EWriteSector, GetExpectedAsyncError(aSection));
1.337 + activeCallbackWrap->SetDesData(writeData);
1.338 +
1.339 + activeCallbackWrap->DataPtr().Zero();
1.340 + for(TInt i=0;i<noOfRepeats;i++)
1.341 + {
1.342 + activeCallbackWrap->DataPtr().Append(sectorText);
1.343 + }
1.344 +
1.345 + TBuf16<KSectorSizeInBytes> printBuf;
1.346 + printBuf.Copy(activeCallbackWrap->DataPtr());
1.347 + INFO_PRINTF4(_L("DoCmdWriteSectorL sectorNumber(%d) sectorText (length=%d):\n%S"), sectorNumber, printBuf.Length(), &printBuf);
1.348 +
1.349 + iMmcSDController->WriteSector(activeCallbackWrap->ActiveCallback().iStatus, sectorNumber, activeCallbackWrap->DataPtr());
1.350 + activeCallbackWrap->ActiveCallback().Activate(aAsyncErrorIndex);
1.351 + IncOutstanding();
1.352 + CleanupStack::Pop(writeData);
1.353 + }
1.354 + }
1.355 +
1.356 +/**
1.357 + * Prints a CSD
1.358 + *
1.359 + * @param aCSDInfo The CSD to print
1.360 + *
1.361 + * @return void
1.362 + */
1.363 +void CT_MmcSDDriverData::PrintCSD(const TCSDInfo& aCSDInfo)
1.364 + {
1.365 + INFO_PRINTF2(_L("CSDInfo->CSDStructure() = %u"), aCSDInfo.iCSDStructure);
1.366 + INFO_PRINTF2(_L("CSDInfo->SpecVers() = %u"), aCSDInfo.iSpecVers);
1.367 + INFO_PRINTF2(_L("CSDInfo->Reserved120() = %u"), aCSDInfo.iReserved120);
1.368 + INFO_PRINTF2(_L("CSDInfo->TAAC() = %u"), aCSDInfo.iTAAC);
1.369 + INFO_PRINTF2(_L("CSDInfo->NSAC() = %u"), aCSDInfo.iNSAC);
1.370 + INFO_PRINTF2(_L("CSDInfo->TranSpeed() = %u"), aCSDInfo.iTranSpeed);
1.371 + INFO_PRINTF2(_L("CSDInfo->CCC() = %u"), aCSDInfo.iCCC);
1.372 + INFO_PRINTF2(_L("CSDInfo->ReadBlLen() = %u"), aCSDInfo.iReadBlLen);
1.373 + INFO_PRINTF2(_L("CSDInfo->Reserved74() = %u"), aCSDInfo.iReserved74);
1.374 + INFO_PRINTF2(_L("CSDInfo->CSize() = %u"), aCSDInfo.iCSize);
1.375 + INFO_PRINTF2(_L("CSDInfo->VDDRCurrMin() = %u"), aCSDInfo.iVDDRCurrMin);
1.376 + INFO_PRINTF2(_L("CSDInfo->VDDRCurrMax() = %u"), aCSDInfo.iVDDRCurrMax);
1.377 + INFO_PRINTF2(_L("CSDInfo->VDDWCurrMin() = %u"), aCSDInfo.iVDDWCurrMin);
1.378 + INFO_PRINTF2(_L("CSDInfo->VDDWCurrMax() = %u"), aCSDInfo.iVDDWCurrMax);
1.379 + INFO_PRINTF2(_L("CSDInfo->CSizeMult() = %u"), aCSDInfo.iCSizeMult);
1.380 + INFO_PRINTF2(_L("CSDInfo->EraseGrpSize() = %u"), aCSDInfo.iEraseGrpSize);
1.381 + INFO_PRINTF2(_L("CSDInfo->EraseGrpMult() = %u"), aCSDInfo.iEraseGrpMult);
1.382 + INFO_PRINTF2(_L("CSDInfo->WPGrpSize() = %u"), aCSDInfo.iWPGrpSize);
1.383 + INFO_PRINTF2(_L("CSDInfo->DefaultECC() = %u"), aCSDInfo.iDefaultECC);
1.384 + INFO_PRINTF2(_L("CSDInfo->R2WFactor() = %u"), aCSDInfo.iR2WFactor);
1.385 + INFO_PRINTF2(_L("CSDInfo->WriteBlLen() = %u"), aCSDInfo.iWriteBlLen);
1.386 + INFO_PRINTF2(_L("CSDInfo->Reserved16() = %u"), aCSDInfo.iReserved16);
1.387 + INFO_PRINTF2(_L("CSDInfo->FileFormat() = %u"), aCSDInfo.iFileFormat);
1.388 + INFO_PRINTF2(_L("CSDInfo->ECC() = %u"), aCSDInfo.iECC);
1.389 + INFO_PRINTF2(_L("CSDInfo->CRC() = %u"), aCSDInfo.iCRC);
1.390 + INFO_PRINTF2(_L("CSDInfo->DeviceSize() = %u"), aCSDInfo.iDeviceSize);
1.391 + INFO_PRINTF2(_L("CSDInfo->ReadBlockLength() = %u"), aCSDInfo.iReadBlockLength);
1.392 + INFO_PRINTF2(_L("CSDInfo->WriteBlockLength() = %u"), aCSDInfo.iWriteBlockLength);
1.393 + INFO_PRINTF2(_L("CSDInfo->EraseSectorSize() = %u"), aCSDInfo.iEraseSectorSize);
1.394 + INFO_PRINTF2(_L("CSDInfo->EraseGroupSize() = %u"), aCSDInfo.iEraseGroupSize);
1.395 + INFO_PRINTF2(_L("CSDInfo->MinReadCurrentInMilliamps() = %u"), aCSDInfo.iMinReadCurrentInMilliamps);
1.396 + INFO_PRINTF2(_L("CSDInfo->MinWriteCurrentInMilliamps() = %u"), aCSDInfo.iMinWriteCurrentInMilliamps);
1.397 + INFO_PRINTF2(_L("CSDInfo->MaxReadCurrentInMilliamps() = %u"), aCSDInfo.iMaxReadCurrentInMilliamps);
1.398 + INFO_PRINTF2(_L("CSDInfo->MaxWriteCurrentInMilliamps() = %u"), aCSDInfo.iMaxWriteCurrentInMilliamps);
1.399 + INFO_PRINTF2(_L("CSDInfo->MaxTranSpeedInKilohertz() = %u"), aCSDInfo.iMaxTranSpeedInKilohertz);
1.400 + INFO_PRINTF2(_L("CSDInfo->ReadBlPartial() = %d"), aCSDInfo.iReadBlPartial);
1.401 + INFO_PRINTF2(_L("CSDInfo->WriteBlkMisalign() = %d"), aCSDInfo.iWriteBlkMisalign);
1.402 + INFO_PRINTF2(_L("CSDInfo->ReadBlkMisalign() = %d"), aCSDInfo.iReadBlkMisalign);
1.403 + INFO_PRINTF2(_L("CSDInfo->DSRImp() = %d"), aCSDInfo.iDSRImp);
1.404 + INFO_PRINTF2(_L("CSDInfo->WPGrpEnable() = %d"), aCSDInfo.iWPGrpEnable);
1.405 + INFO_PRINTF2(_L("CSDInfo->WriteBlPartial() = %d"), aCSDInfo.iWriteBlPartial);
1.406 + INFO_PRINTF2(_L("CSDInfo->FileFormatGrp() = %d"), aCSDInfo.iFileFormatGrp);
1.407 + INFO_PRINTF2(_L("CSDInfo->Copy() = %d"), aCSDInfo.iCopy);
1.408 + INFO_PRINTF2(_L("CSDInfo->PermWriteProtect() = %d"), aCSDInfo.iPermWriteProtect);
1.409 + INFO_PRINTF2(_L("CSDInfo->TmpWriteProtect() = %d"), aCSDInfo.iTmpWriteProtect);
1.410 + INFO_PRINTF2(_L("CSDInfo->MediaType() = %d"), aCSDInfo.iMediaType);
1.411 + }
1.412 +
1.413 +/**
1.414 + * Prints an Extended CSD
1.415 + *
1.416 + * @param aExtendedCSDInfo The Extended CSD to print
1.417 + *
1.418 + * @return void
1.419 + */
1.420 +void CT_MmcSDDriverData::PrintExtendedCSD(const TExtendedCSDInfo& aExtendedCSDInfo)
1.421 + {
1.422 + INFO_PRINTF2(_L("ExtendedCSDInfo->SupportedCmdSet() = %u"), aExtendedCSDInfo.iSupportedCmdSet);
1.423 + INFO_PRINTF2(_L("ExtendedCSDInfo->SectorCount() = %u"), aExtendedCSDInfo.iSectorCount);
1.424 + INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfWrite8Bit52Mhz() = %u"), aExtendedCSDInfo.iMinPerfWrite8Bit52Mhz);
1.425 + INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfRead8Bit52Mhz() = %u"), aExtendedCSDInfo.iMinPerfRead8Bit52Mhz);
1.426 + INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfWrite8Bit26Mhz_4Bit52Mhz() = %u"), aExtendedCSDInfo.iMinPerfWrite8Bit26Mhz_4Bit52Mhz);
1.427 + INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfRead8Bit26Mhz_4Bit52Mhz() = %u"), aExtendedCSDInfo.iMinPerfRead8Bit26Mhz_4Bit52Mhz);
1.428 + INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfWrite4Bit26Mhz() = %u"), aExtendedCSDInfo.iMinPerfWrite4Bit26Mhz);
1.429 + INFO_PRINTF2(_L("ExtendedCSDInfo->MinPerfRead4Bit26Mhz() = %u"), aExtendedCSDInfo.iMinPerfRead4Bit26Mhz);
1.430 + INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass26Mhz360V() = %u"), aExtendedCSDInfo.iPowerClass26Mhz360V);
1.431 + INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass52Mhz360V() = %u"), aExtendedCSDInfo.iPowerClass52Mhz360V);
1.432 + INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass26Mhz195V() = %u"), aExtendedCSDInfo.iPowerClass26Mhz195V);
1.433 + INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass52Mhz195V() = %u"), aExtendedCSDInfo.iPowerClass52Mhz195V);
1.434 + INFO_PRINTF2(_L("ExtendedCSDInfo->CardType() = %u"), aExtendedCSDInfo.iCardType);
1.435 + INFO_PRINTF2(_L("ExtendedCSDInfo->CSDStructureVer() = %u"), aExtendedCSDInfo.iCSDStructureVer);
1.436 + INFO_PRINTF2(_L("ExtendedCSDInfo->ExtendedCSDRev() = %u"), aExtendedCSDInfo.iExtendedCSDRev);
1.437 + INFO_PRINTF2(_L("ExtendedCSDInfo->CmdSet() = %u"), aExtendedCSDInfo.iCmdSet);
1.438 + INFO_PRINTF2(_L("ExtendedCSDInfo->CmdSetRev() = %u"), aExtendedCSDInfo.iCmdSetRev);
1.439 + INFO_PRINTF2(_L("ExtendedCSDInfo->PowerClass() = %u"), aExtendedCSDInfo.iPowerClass);
1.440 + INFO_PRINTF2(_L("ExtendedCSDInfo->HighSpeedTiming() = %u"), aExtendedCSDInfo.iHighSpeedTiming);
1.441 + }
1.442 +
1.443 +/**
1.444 + * Reads the CSD
1.445 + * This function is not contained within a TMMCard wrapper as this is not a class under test
1.446 + *
1.447 + * @param aSection The section in the ini containing data for the command
1.448 + *
1.449 + * @return void
1.450 + */
1.451 +void CT_MmcSDDriverData::DoCmdReadCSD()
1.452 + {
1.453 + INFO_PRINTF1(_L("DoCmdReadCSD called()"));
1.454 + TCSDInfo csdInfo;
1.455 + TInt err = iMmcSDController->ReadCSD(csdInfo);
1.456 + PrintCSD(csdInfo);
1.457 +
1.458 + if( err != KErrNone )
1.459 + {
1.460 + ERR_PRINTF2(_L("DoCmdReadCSD() ReadCSD() Error %d"), err);
1.461 + SetError(err);
1.462 + }
1.463 + }
1.464 +
1.465 +/**
1.466 + * Reads the Extended CSD
1.467 + * This function is not contained within a TMMCard wrapper as this is not a class under test
1.468 + *
1.469 + * @param aSection The section in the ini containing data for the command
1.470 + *
1.471 + * @return void
1.472 + */
1.473 +void CT_MmcSDDriverData::DoCmdReadExtCSD()
1.474 + {
1.475 + INFO_PRINTF1(_L("DoCmdReadExtCSD called()"));
1.476 + TExtendedCSDInfo extendedCSDInfo;
1.477 + TInt err = iMmcSDController->ReadExtCSD(extendedCSDInfo);
1.478 + if( err != KErrNone )
1.479 + {
1.480 + ERR_PRINTF2(_L("DoCmdReadExtCSD() Error %d"), err);
1.481 + SetError(err);
1.482 + }
1.483 + else
1.484 + {
1.485 + PrintExtendedCSD(extendedCSDInfo);
1.486 + }
1.487 + }
1.488 +
1.489 +/**
1.490 + * Process command that will obtain card info from kernel side
1.491 + * This function is not contained within a TMMCard wrapper as this is not a class under test
1.492 + *
1.493 + * @param aSection The section in the ini containing data for the command
1.494 + *
1.495 + * @return void
1.496 + */
1.497 +void CT_MmcSDDriverData::DoCmdCardInfo(const TDesC& aSection)
1.498 + {
1.499 + TMMCCardInfo ci;
1.500 + INFO_PRINTF1(_L("DoCmdCardInfo()"));
1.501 + TInt err = iMmcSDController->CardInfo(ci);
1.502 + if (err != KErrNone)
1.503 + {
1.504 + ERR_PRINTF2(_L("DoCmdCardInfo Error %d"), err);
1.505 + SetError(err);
1.506 + }
1.507 + else
1.508 + {
1.509 + INFO_PRINTF5(_L("iIsReady(%d) iIsLocked(%d) iRCA(%d) iMediaType(%d)"),
1.510 + ci.iIsReady, ci.iIsLocked, ci.iRCA, ci.iMediaType );
1.511 +
1.512 + INFO_PRINTF6(_L("iCardSizeInBytes low(%x) high(%x) iMaxReadBlLen(%d) iReadBlLen(%d) iReadBlPartial(%d)"),
1.513 + I64LOW(ci.iCardSizeInBytes), I64HIGH(ci.iCardSizeInBytes), ci.iMaxReadBlLen, ci.iReadBlLen, ci.iReadBlPartial );
1.514 +
1.515 + INFO_PRINTF6(_L("iWriteBlPartial(%d) iReadBlkMisalign(%d) iWriteBlkMisalign(%d) iReadCurrentInMilliAmps(%d) iWriteCurrentInMilliAmps(%d)"),
1.516 + ci.iWriteBlPartial, ci.iReadBlkMisalign, ci.iWriteBlkMisalign, ci.iReadCurrentInMilliAmps, ci.iWriteCurrentInMilliAmps );
1.517 +
1.518 + INFO_PRINTF6(_L("iSpecVers(%d) iTAAC(%d) iNSAC(%d) iTransferSpeed(%d) iCommandRegister(%d)"),
1.519 + ci.iSpecVers, ci.iTAAC, ci.iNSAC, ci.iTransferSpeed, ci.iCommandRegister );
1.520 +
1.521 + INFO_PRINTF3(_L("iHighCapacity(%d) iFlags(%d) "), ci.iHighCapacity, ci.iFlags);
1.522 +
1.523 + // check against expected values
1.524 +
1.525 + TInt maxreadBlockLen;
1.526 + if(GetIntFromConfig(aSection, KMaxReadBlockLen(), maxreadBlockLen))
1.527 + {
1.528 + if(maxreadBlockLen != ci.iMaxReadBlLen)
1.529 + {
1.530 + ERR_PRINTF3(_L("max block lengths do not match actual(%d), expected(%d)"), ci.iMaxReadBlLen, maxreadBlockLen);
1.531 + SetBlockResult(EFail);
1.532 + }
1.533 + }
1.534 +
1.535 + TInt readCurrentInMilliAmps;
1.536 + if(GetIntFromConfig(aSection, KReadCurrentInMilliAmps(), readCurrentInMilliAmps))
1.537 + {
1.538 + if(readCurrentInMilliAmps!= ci.iReadCurrentInMilliAmps)
1.539 + {
1.540 + ERR_PRINTF3(_L("ReadCurrentInMilliAmps do not match actual(%d), expected(%d)"),ci.iReadCurrentInMilliAmps, readCurrentInMilliAmps);
1.541 + SetBlockResult(EFail);
1.542 + }
1.543 + }
1.544 +
1.545 + TUint transferSpeed;
1.546 + if(GetUintFromConfig(aSection, KTransferSpeed(), transferSpeed))
1.547 + {
1.548 + if(transferSpeed != ci.iTransferSpeed)
1.549 + {
1.550 + ERR_PRINTF3(_L("transferSpeed do not match actual(%d), expected(%d)"), ci.iTransferSpeed, transferSpeed);
1.551 + SetBlockResult(EFail);
1.552 + }
1.553 + }
1.554 +
1.555 + TBool highCapacity;
1.556 + if(GetBoolFromConfig(aSection, KHighCapacity(), highCapacity))
1.557 + {
1.558 + if(highCapacity != ci.iHighCapacity)
1.559 + {
1.560 + ERR_PRINTF3(_L("highCapacity do not match actual(%d), expected(%d)"), ci.iHighCapacity, highCapacity);
1.561 + SetBlockResult(EFail);
1.562 + }
1.563 + }
1.564 + }
1.565 + }
1.566 +
1.567 +/**
1.568 + * Process command that will obtain card is present status from kernel side
1.569 + * This function is not contained within a TMMCard wrapper as this is not a class under test
1.570 + *
1.571 + * @param aSection The section in the ini containing data for the command
1.572 + *
1.573 + * @return void
1.574 + */
1.575 +void CT_MmcSDDriverData::DoCmdCardIsPresent(const TDesC& aSection)
1.576 + {
1.577 + TBool isPresent;
1.578 + INFO_PRINTF1(_L("DoCmdCardIsPresent()"));
1.579 + TInt err = iMmcSDController->CardIsPresent(isPresent);
1.580 + if (err != KErrNone)
1.581 + {
1.582 + ERR_PRINTF2(_L("DoCmdCardIsPresent Error %d"), err);
1.583 + SetError(err);
1.584 + }
1.585 + else
1.586 + {
1.587 + INFO_PRINTF2(_L("DoCmdCardIsPresent(): isPresent = %d"), isPresent);
1.588 +
1.589 + // check against expected value
1.590 + TBool expectedIsPresent;
1.591 + if(GetBoolFromConfig(aSection, KExpectedIsPresent(), expectedIsPresent))
1.592 + {
1.593 + if(expectedIsPresent != isPresent)
1.594 + {
1.595 + ERR_PRINTF3(_L("isPresent does not match actual(%d), expected(%d)"), isPresent, expectedIsPresent);
1.596 + SetBlockResult(EFail);
1.597 + }
1.598 + }
1.599 + else
1.600 + {
1.601 + ERR_PRINTF1(_L("DoCmdCardIsPresent(): No expected value given in INI file"));
1.602 + SetBlockResult(EFail);
1.603 + }
1.604 + }
1.605 + }
1.606 +
1.607 +/**
1.608 + * Process command that will obtain card is ready status from kernel side
1.609 + * This function is not contained within a TMMCard wrapper as this is not a class under test
1.610 + *
1.611 + * @param aSection The section in the ini containing data for the command
1.612 + *
1.613 + * @return void
1.614 + */
1.615 +void CT_MmcSDDriverData::DoCmdCardIsReady(const TDesC& aSection)
1.616 + {
1.617 + TBool isReady;
1.618 + INFO_PRINTF1(_L("DoCmdCardIsReady()"));
1.619 + TInt err = iMmcSDController->CardIsReady(isReady);
1.620 + if (err != KErrNone)
1.621 + {
1.622 + ERR_PRINTF2(_L("DoCmdCardIsReady Error %d"), err);
1.623 + SetError(err);
1.624 + }
1.625 + else
1.626 + {
1.627 + INFO_PRINTF2(_L("DoCmdCardIsReady(): isReady = %d"), isReady);
1.628 +
1.629 + // check against expected value
1.630 + TBool expectedIsReady;
1.631 + if(GetBoolFromConfig(aSection, KExpectedIsReady(), expectedIsReady))
1.632 + {
1.633 + if(expectedIsReady != isReady)
1.634 + {
1.635 + ERR_PRINTF3(_L("isReady does not match actual(%d), expected(%d)"), isReady, expectedIsReady);
1.636 + SetBlockResult(EFail);
1.637 + }
1.638 + }
1.639 + else
1.640 + {
1.641 + ERR_PRINTF1(_L("DoCmdCardIsReady(): No expected value given in INI file"));
1.642 + SetBlockResult(EFail);
1.643 + }
1.644 + }
1.645 + }
1.646 +
1.647 +/**
1.648 + * Process command that will obtain card is locked status from kernel side
1.649 + * This function is not contained within a TMMCard wrapper as this is not a class under test
1.650 + *
1.651 + * @param aSection The section in the ini containing data for the command
1.652 + *
1.653 + * @return void
1.654 + */
1.655 +void CT_MmcSDDriverData::DoCmdCardIsLocked(const TDesC& aSection)
1.656 + {
1.657 + TBool isLocked;
1.658 + INFO_PRINTF1(_L("DoCmdCardIsLocked()"));
1.659 + TInt err = iMmcSDController->CardIsLocked(isLocked);
1.660 + if (err != KErrNone)
1.661 + {
1.662 + ERR_PRINTF2(_L("DoCmdCardIsLocked Error %d"), err);
1.663 + SetError(err);
1.664 + }
1.665 + else
1.666 + {
1.667 + INFO_PRINTF2(_L("DoCmdCardIsLocked(): isLocked = %d"), isLocked);
1.668 +
1.669 + // check against expected value
1.670 + TBool expectedIsLocked;
1.671 + if(GetBoolFromConfig(aSection, KExpectedIsLocked(), expectedIsLocked))
1.672 + {
1.673 + if(expectedIsLocked != isLocked)
1.674 + {
1.675 + ERR_PRINTF3(_L("isLocked does not match actual(%d), expected(%d)"), isLocked, expectedIsLocked);
1.676 + SetBlockResult(EFail);
1.677 + }
1.678 + }
1.679 + else
1.680 + {
1.681 + ERR_PRINTF1(_L("DoCmdCardIsLocked(): No expected value given in INI file"));
1.682 + SetBlockResult(EFail);
1.683 + }
1.684 + }
1.685 + }
1.686 +
1.687 +/**
1.688 + * Called on completion of an asynchronous command
1.689 + *
1.690 + * @param aActive Active Object that RunL has been called on
1.691 + * @param aIndex Index of the active object
1.692 + *
1.693 + * @return void
1.694 + */
1.695 +void CT_MmcSDDriverData::RunL(CActive* aActive, TInt aIndex)
1.696 + {
1.697 + TInt err = aActive->iStatus.Int();
1.698 + INFO_PRINTF2(_L("CT_MmcSDDriverData::RunL() called. err (%d)"), err);
1.699 +
1.700 + // retrieve the active callback wrap that wraps this item
1.701 + CActiveCallbackWrap* activeCallbackWrap=NULL;
1.702 +
1.703 + for(int i=0;i<iActiveCallbacks.Count();i++)
1.704 + {
1.705 + if( &(iActiveCallbacks[i]->ActiveCallback()) == aActive)
1.706 + {
1.707 + activeCallbackWrap = iActiveCallbacks[i];
1.708 + break;
1.709 + }
1.710 + }
1.711 +
1.712 + if(activeCallbackWrap)
1.713 + {
1.714 + switch(activeCallbackWrap->FunctionId())
1.715 + {
1.716 + case RMMCSDTestControllerInterface::EReadSector:
1.717 + {
1.718 + INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EReadSector:"));
1.719 + if (err == KErrNone)
1.720 + {
1.721 + HBufC8* readData = (HBufC8*) activeCallbackWrap->Data();
1.722 + // dump the read buffer here
1.723 + TBuf16<KSectorSizeInBytes> printBuf;
1.724 + printBuf.Copy(activeCallbackWrap->DataPtr());
1.725 + INFO_PRINTF3(_L("ReadSector data (length=%d):\n%S"), printBuf.Length(), &printBuf);
1.726 +
1.727 + HBufC8* expectedData = (HBufC8*) activeCallbackWrap->ExpectedData();
1.728 + if (expectedData)
1.729 + {
1.730 + if (*readData != *expectedData)
1.731 + {
1.732 + TPtr8 expectedDataPtr(expectedData->Des());
1.733 + TBuf16<KSectorSizeInBytes> printExpectedBuf;
1.734 + printExpectedBuf.Copy(expectedDataPtr);
1.735 + ERR_PRINTF3(_L("ReadSector data not as expected (length=%d):\n%S"), printExpectedBuf.Length(), &printExpectedBuf);
1.736 + SetBlockResult(EFail);
1.737 + }
1.738 + }
1.739 + }
1.740 + }
1.741 + break;
1.742 +
1.743 + case RMMCSDTestControllerInterface::EWriteSector:
1.744 + INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EWriteSector:"));
1.745 + break;
1.746 +
1.747 + case RMMCSDTestControllerInterface::ESocketPowerUp:
1.748 + INFO_PRINTF1(_L("CT_MmcSDDriverData::RunL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::ESocketPowerUp:"));
1.749 + break;
1.750 +
1.751 + default:
1.752 + break;
1.753 + }
1.754 +
1.755 + if (err != activeCallbackWrap->ExpectedAsyncError())
1.756 + {
1.757 + ERR_PRINTF3(_L("Error (%d) != Expected error (%d)"), err, activeCallbackWrap->ExpectedAsyncError());
1.758 + SetAsyncError(aIndex, err);
1.759 + }
1.760 +
1.761 + DecOutstanding();
1.762 + DeleteActiveCallback((CActiveCallback*)aActive);
1.763 + }
1.764 + else
1.765 + {
1.766 + ERR_PRINTF1(_L("An unchecked active object completed"));
1.767 + SetBlockResult(EFail);
1.768 + }
1.769 + }
1.770 +
1.771 +/**
1.772 + * Request to cancel the asynchronous command
1.773 + *
1.774 + * @param aActive Active Object that DoCancel has been called on
1.775 + *
1.776 + * @return void
1.777 + */
1.778 +void CT_MmcSDDriverData::DoCancel(CActive* aActive)
1.779 + {
1.780 + TInt err = aActive->iStatus.Int();
1.781 + INFO_PRINTF2(_L("CT_MmcSDDriverData::DoCancelL() called. err (%d)"), err);
1.782 +
1.783 + // retrieve the active callback wrap that wraps this item
1.784 + CActiveCallbackWrap* activeCallbackWrap=NULL;
1.785 +
1.786 + for(int i=0;i<iActiveCallbacks.Count();i++)
1.787 + {
1.788 + if( &(iActiveCallbacks[i]->ActiveCallback()) == aActive)
1.789 + {
1.790 + activeCallbackWrap = iActiveCallbacks[i];
1.791 + break;
1.792 + }
1.793 + }
1.794 +
1.795 + if(activeCallbackWrap)
1.796 + {
1.797 + switch(activeCallbackWrap->FunctionId())
1.798 + {
1.799 + case RMMCSDTestControllerInterface::EReadSector:
1.800 + INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EReadSector:"));
1.801 + break;
1.802 +
1.803 + case RMMCSDTestControllerInterface::EWriteSector:
1.804 + INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::EWriteSector:"));
1.805 + break;
1.806 +
1.807 + case RMMCSDTestControllerInterface::ESocketPowerUp:
1.808 + INFO_PRINTF1(_L("CT_MmcSDDriverData::DoCancelL() Post processing CActiveCallbackWrap RMMCSDTestControllerInterface::ESocketPowerUp:"));
1.809 + break;
1.810 +
1.811 + default:
1.812 + break;
1.813 + }
1.814 +
1.815 + if (err != activeCallbackWrap->ExpectedAsyncError())
1.816 + {
1.817 + ERR_PRINTF3(_L("Error (%d) != Expected error (%d)"), err, activeCallbackWrap->ExpectedAsyncError());
1.818 + SetBlockResult(EFail);
1.819 + }
1.820 +
1.821 + DecOutstanding();
1.822 + DeleteActiveCallback((CActiveCallback*)aActive);
1.823 + }
1.824 + else
1.825 + {
1.826 + ERR_PRINTF1(_L("An unchecked active object completed"));
1.827 + SetBlockResult(EFail);
1.828 + }
1.829 + }
1.830 +
1.831 +/**
1.832 + * Gets the expected async error code
1.833 + *
1.834 + * @param aSection The section in the ini containing data for the command
1.835 + *
1.836 + * @return The expected async error code
1.837 + */
1.838 +TInt CT_MmcSDDriverData::GetExpectedAsyncError(const TDesC& aSection)
1.839 + {
1.840 + TInt expectedAsyncError = KErrNone;
1.841 + GetIntFromConfig(aSection, KExpectedAsyncError(), expectedAsyncError);
1.842 + return expectedAsyncError;
1.843 + }
1.844 +