1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/mmc.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1532 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +// WARNING: This file contains some APIs which are internal and are subject
1.19 +// to change without noticed. Such APIs should therefore not be used
1.20 +// outside the Kernel and Hardware Services package.
1.21 +//
1.22 +
1.23 +/**
1.24 +
1.25 + A static function that takes the 4 bytes that are stored in a memory location
1.26 + in ascending address order, and returns them as a 32-bit unsigned integer
1.27 + in big-endian format.
1.28 +
1.29 + @param aPtr A pointer to the memory location containing the 4 bytes to be stored.
1.30 +
1.31 + @return A 32 bit unsigned integer containing the 4 bytes in big-endian format.
1.32 +*/
1.33 +inline TUint32 TMMC::BigEndian32(const TUint8* aPtr)
1.34 + {return( (aPtr[0]<<24) | (aPtr[1]<<16) | (aPtr[2]<<8) | (aPtr[3]) );}
1.35 +
1.36 +
1.37 +
1.38 +
1.39 +/**
1.40 +A static function that takes the specified 32-bit unsigned integer, assumed to
1.41 +be in big-endian format, and stores this into the specified memory location.
1.42 +
1.43 +@param aPtr A pointer to a 4 byte memory location which is to contain
1.44 + the unsigned integer.
1.45 +@param aVal A 32 bit unsigned integer in big-endian format.
1.46 +*/
1.47 +inline void TMMC::BigEndian4Bytes(TUint8* aPtr, TUint32 aVal)
1.48 + {
1.49 + aPtr[0] = (TUint8)(aVal >> 24);
1.50 + aPtr[1] = (TUint8)(aVal >> 16);
1.51 + aPtr[2] = (TUint8)(aVal >> 8);
1.52 + aPtr[3] = (TUint8)aVal;
1.53 + }
1.54 +
1.55 +
1.56 +
1.57 +
1.58 +// -------- class TCID --------
1.59 +
1.60 +inline TCID::TCID(const TUint8* aPtr)
1.61 + {memcpy(&iData[0], aPtr, KMMCCIDLength);}
1.62 +
1.63 +inline TCID& TCID::operator=(const TCID& aCID)
1.64 + {memcpy(&iData[0], &aCID.iData[0], KMMCCIDLength); return(*this);}
1.65 +
1.66 +inline TCID& TCID::operator=(const TUint8* aPtr)
1.67 + {memcpy(&iData[0], aPtr, KMMCCIDLength); return(*this);}
1.68 +
1.69 +inline TBool TCID::operator==(const TCID& aCID) const
1.70 + {return(memcompare(&iData[0],KMMCCIDLength,&aCID.iData[0],KMMCCIDLength)==0);}
1.71 +
1.72 +inline TBool TCID::operator==(const TUint8* aPtr) const
1.73 + {return(memcompare(&iData[0],KMMCCIDLength,aPtr,KMMCCIDLength)==0);}
1.74 +
1.75 +inline void TCID::Copy(TUint8* aPtr) const
1.76 + {memcpy(aPtr, &iData[0], KMMCCIDLength);}
1.77 +
1.78 +inline TUint8 TCID::At(TUint anIndex) const
1.79 + {return(iData[KMMCCIDLength-1-anIndex]);}
1.80 +
1.81 +// -------- class TCSD --------
1.82 +
1.83 +inline TCSD::TCSD(const TUint8* aPtr)
1.84 + {memcpy(&iData[0], aPtr, KMMCCSDLength);}
1.85 +
1.86 +inline TCSD& TCSD::operator=(const TCSD& aCSD)
1.87 + {memcpy(&iData[0], &aCSD.iData[0], KMMCCSDLength); return(*this);}
1.88 +
1.89 +inline TCSD& TCSD::operator=(const TUint8* aPtr)
1.90 + {memcpy(&iData[0], aPtr, KMMCCSDLength); return(*this);}
1.91 +
1.92 +inline void TCSD::Copy(TUint8* aPtr) const
1.93 + {memcpy(aPtr, &iData[0], KMMCCSDLength);}
1.94 +
1.95 +inline TUint8 TCSD::At(TUint anIndex) const // anIndex byte in little-endian format
1.96 + {return(iData[KMMCCSDLength-1-anIndex]);}
1.97 +
1.98 +// Raw field accessors. Encoded values such as memory capacity are calulated in
1.99 +// non-inline functions defined in ps_mmc.cpp.
1.100 +
1.101 +inline TUint TCSD::CSDStructure() const {return( CSDField(127,126) );}
1.102 +inline TUint TCSD::SpecVers() const {return( CSDField(125,122) );}
1.103 +inline TUint TCSD::Reserved120() const {return( CSDField(121,120) );}
1.104 +inline TUint TCSD::TAAC() const {return( CSDField(119,112) );}
1.105 +inline TUint TCSD::NSAC() const {return( CSDField(111,104) );}
1.106 +inline TUint TCSD::TranSpeed() const {return( CSDField(103,96) );}
1.107 +inline TUint TCSD::CCC() const {return( CSDField(95,84) );}
1.108 +inline TUint TCSD::ReadBlLen() const {return( CSDField(83,80) );}
1.109 +inline TBool TCSD::ReadBlPartial() const {return( CSDField(79,79) );}
1.110 +inline TBool TCSD::WriteBlkMisalign() const {return( CSDField(78,78) );}
1.111 +inline TBool TCSD::ReadBlkMisalign() const {return( CSDField(77,77) );}
1.112 +inline TBool TCSD::DSRImp() const {return( CSDField(76,76) );}
1.113 +inline TUint TCSD::Reserved74() const {return( CSDField(75,74) );}
1.114 +inline TUint TCSD::CSize() const {return( CSDField(73,62) );}
1.115 +inline TUint TCSD::VDDRCurrMin() const {return( CSDField(61,59) );}
1.116 +inline TUint TCSD::VDDRCurrMax() const {return( CSDField(58,56) );}
1.117 +inline TUint TCSD::VDDWCurrMin() const {return( CSDField(55,53) );}
1.118 +inline TUint TCSD::VDDWCurrMax() const {return( CSDField(52,50) );}
1.119 +inline TUint TCSD::CSizeMult() const {return( CSDField(49,47) );}
1.120 +
1.121 +inline TUint TCSD::EraseGrpSize() const {return( CSDField(46,42) );}
1.122 +inline TUint TCSD::EraseGrpMult() const {return( CSDField(41,37) );}
1.123 +inline TUint TCSD::WPGrpSize() const {return( CSDField(36,32) );}
1.124 +
1.125 +inline TBool TCSD::WPGrpEnable() const {return( CSDField(31,31) );}
1.126 +inline TUint TCSD::DefaultECC() const {return( CSDField(30,29) );}
1.127 +inline TUint TCSD::R2WFactor() const {return( CSDField(28,26) );}
1.128 +inline TUint TCSD::WriteBlLen() const {return( CSDField(25,22) );}
1.129 +inline TBool TCSD::WriteBlPartial() const {return( CSDField(21,21) );}
1.130 +inline TUint TCSD::Reserved16() const {return( CSDField(20,16) );}
1.131 +inline TBool TCSD::FileFormatGrp() const {return( CSDField(15,15) );}
1.132 +inline TBool TCSD::Copy() const {return( CSDField(14,14) );}
1.133 +inline TBool TCSD::PermWriteProtect() const {return( CSDField(13,13) );}
1.134 +inline TBool TCSD::TmpWriteProtect() const {return( CSDField(12,12) );}
1.135 +inline TUint TCSD::FileFormat() const {return( CSDField(11,10) );}
1.136 +inline TUint TCSD::ECC() const {return( CSDField(9,8) );}
1.137 +inline TUint TCSD::CRC() const {return( CSDField(7,1) );}
1.138 +
1.139 +// -------- class TExtendedCSD --------
1.140 +
1.141 +inline TExtendedCSD::TExtendedCSD() // Default constructor
1.142 + {}
1.143 +
1.144 +inline TExtendedCSD::TExtendedCSD(const TUint8* aPtr)
1.145 + {memcpy(&iData[0], aPtr, KMMCExtendedCSDLength);}
1.146 +
1.147 +inline TExtendedCSD& TExtendedCSD::operator=(const TExtendedCSD& aCSD)
1.148 + {memcpy(&iData[0], &aCSD.iData[0], KMMCExtendedCSDLength); return(*this);}
1.149 +
1.150 +inline TExtendedCSD& TExtendedCSD::operator=(const TUint8* aPtr)
1.151 + {memcpy(&iData[0], aPtr, KMMCExtendedCSDLength); return(*this);}
1.152 +
1.153 +inline TMMCArgument TExtendedCSD::GetWriteArg(TExtCSDAccessBits aAccess, TExtCSDModesFieldIndex aIndex, TUint aValue, TUint aCmdSet)
1.154 + {return TMMCArgument((aAccess << 24) | (aIndex << 16) | (aValue << 8) | (aCmdSet));}
1.155 +
1.156 +inline TUint8* TExtendedCSD::Ptr() {return &iData[0];}
1.157 +
1.158 +// Raw field accessors.
1.159 +// "Properties Segment" of Extended CSD - i.e. read-only fields
1.160 +inline TUint TExtendedCSD::SupportedCmdSet() const {return iData[504];}
1.161 +inline TUint TExtendedCSD::SectorCount() const {return(iData[212] | ((TUint)iData[213] << 8) | ((TUint)iData[214] << 16) | ((TUint)iData[215] << 24));}
1.162 +inline TUint TExtendedCSD::MinPerfWrite8Bit52Mhz() const {return iData[210];}
1.163 +inline TUint TExtendedCSD::MinPerfRead8Bit52Mhz() const {return iData[209];}
1.164 +inline TUint TExtendedCSD::MinPerfWrite8Bit26Mhz_4Bit52Mhz() const {return iData[208];}
1.165 +inline TUint TExtendedCSD::MinPerfRead8Bit26Mhz_4Bit52Mhz() const {return iData[207];}
1.166 +inline TUint TExtendedCSD::MinPerfWrite4Bit26Mhz() const {return iData[206];}
1.167 +inline TUint TExtendedCSD::MinPerfRead4Bit26Mhz() const {return iData[205];}
1.168 +inline TUint TExtendedCSD::PowerClass26Mhz360V() const {return iData[203];}
1.169 +inline TUint TExtendedCSD::PowerClass52Mhz360V() const {return iData[202];}
1.170 +inline TUint TExtendedCSD::PowerClass26Mhz195V() const {return iData[201];}
1.171 +inline TUint TExtendedCSD::PowerClass52Mhz195V() const {return iData[200];}
1.172 +inline TUint TExtendedCSD::CardType() const {return iData[196];}
1.173 +inline TUint TExtendedCSD::CSDStructureVer() const {return iData[194];}
1.174 +inline TUint TExtendedCSD::ExtendedCSDRev() const {return iData[EExtendedCSDRevIndex];}
1.175 +inline TUint TExtendedCSD::AccessSize() const {return iData[EAccessSizeIndex];}
1.176 +inline TUint TExtendedCSD::HighCapacityEraseGroupSize() const {return iData[EHighCapacityEraseGroupSizeIndex];}
1.177 +inline TUint TExtendedCSD::BootInfo() const {return iData[228];}
1.178 +inline TUint TExtendedCSD::BootSizeMultiple() const {return iData[226];}
1.179 +inline TUint TExtendedCSD::EraseTimeoutMultiple() const {return iData[223];}
1.180 +inline TUint TExtendedCSD::ReliableWriteSector() const {return iData[222];}
1.181 +inline TUint TExtendedCSD::HighCapacityWriteProtectGroupSize() const {return iData[221];}
1.182 +inline TUint TExtendedCSD::SleepCurrentVcc() const {return iData[220];}
1.183 +inline TUint TExtendedCSD::SleepCurrentVccQ() const {return iData[219];}
1.184 +inline TUint TExtendedCSD::SleepAwakeTimeout() const {return iData[217];}
1.185 +
1.186 +// "Modes Segment" of Extended CSD - i.e. modifiable fields
1.187 +inline TUint TExtendedCSD::CmdSet() const {return iData[ECmdSetIndex];}
1.188 +inline TUint TExtendedCSD::CmdSetRev() const {return iData[ECmdSetRevIndex];}
1.189 +inline TUint TExtendedCSD::PowerClass() const {return iData[EPowerClassIndex];}
1.190 +inline TUint TExtendedCSD::HighSpeedTiming() const {return iData[EHighSpeedInterfaceTimingIndex];}
1.191 +inline TUint TExtendedCSD::BusWidthMode() const {return iData[EBusWidthModeIndex];}
1.192 +inline TUint TExtendedCSD::BootConfig() const {return iData[EBootConfigIndex];}
1.193 +inline TUint TExtendedCSD::BootBusWidth() const {return iData[EBootBusWidthIndex];}
1.194 +inline TUint TExtendedCSD::EraseGroupDef() const {return iData[EEraseGroupDefIndex];}
1.195 +
1.196 +// -------- class TMMCStatus --------
1.197 + /**
1.198 + * Constructor for TMMCStatus.
1.199 + * @param aPtr A pointer to the memory location containing the 4 bytes to be stored.
1.200 + The 4 bytes corresponds to MMC card response. Refer to the MMC card specification for the possible values of response.
1.201 + */
1.202 +inline TMMCStatus::TMMCStatus(const TUint8* aPtr) : iData(TMMC::BigEndian32(aPtr)) {}
1.203 +
1.204 +/**
1.205 + * constructs the TMMCStatus object with value corresponding to MMC status register.
1.206 + * @param aData Value corresponding to MMC status register.
1.207 + */
1.208 +inline TMMCStatus::TMMCStatus(const TUint32& aData) : iData(aData) {}
1.209 +
1.210 +/**
1.211 + * Gets the bitfield(32 bits) representing the MMC status register.
1.212 + * @return Value corresponding to MMC status register.
1.213 + */
1.214 +inline TMMCStatus::operator TUint32() const {return(iData);}
1.215 +
1.216 +/**
1.217 + * Gets the error status.
1.218 + * For the possible values, refer to the MMC card R1 Response.
1.219 + * @see DMMCStack
1.220 + * @return MMC card error status.
1.221 + */
1.222 +inline TUint32 TMMCStatus::Error() const { return(iData & KMMCStatErrorMask); }
1.223 +
1.224 +/**
1.225 + * Gets the MMC card's current state machine.
1.226 + * For the possible values of the state machine, refer to the MMC card specification.
1.227 + * @return The current state of the state machine.
1.228 + */
1.229 +inline TMMCardStateEnum TMMCStatus::State() const
1.230 + { return((TMMCardStateEnum)(iData & KMMCStatCurrentStateMask)); }
1.231 +
1.232 +/**
1.233 + * Replace the MMC card's current state with supplied value
1.234 + * @param aState The new MMC card State
1.235 + */
1.236 +inline void TMMCStatus::UpdateState(TMMCardStateEnum aState)
1.237 + {
1.238 + iData &= ~KMMCStatCurrentStateMask;
1.239 + iData |= aState;
1.240 + }
1.241 +
1.242 +
1.243 +// -------- class TMMCArgument --------
1.244 +
1.245 +inline TMMCArgument::TMMCArgument()
1.246 +/**
1.247 + * Default constructor
1.248 + * Initialises the argument to zero.
1.249 + */
1.250 + {}
1.251 +
1.252 +inline TMMCArgument::TMMCArgument(const TUint32& aData)
1.253 + : iData(aData)
1.254 +/**
1.255 + * Constructs a TMMCArgument with a 32-bit parameter.
1.256 + * @param aData The 32-bit parameter.
1.257 + */
1.258 + {}
1.259 +
1.260 +inline TMMCArgument::TMMCArgument(TRCA anRCA) : iData(TUint(anRCA)<<16)
1.261 +/**
1.262 + * Constructs a TMMCArgument with a Relative Card Address (RCA).
1.263 + * @param anRCA The RCA.
1.264 + */
1.265 + {}
1.266 +inline TMMCArgument::TMMCArgument(TDSR aDSR) : iData(TUint(aDSR)<<16)
1.267 +/**
1.268 + * Constructs a TMMCArgument with a Driver Stage Register (DSR).
1.269 + * @param aDSR The DSR.
1.270 + */
1.271 + {}
1.272 +
1.273 +inline TMMCArgument::operator TUint32() const
1.274 +/**
1.275 + * Converts the TMMCArgument to it's raw 32-bit representation.
1.276 + * @return Raw 32-bit argument data
1.277 + */
1.278 + {return(iData);}
1.279 +
1.280 +inline void TMMCArgument::SetRCA(TRCA anRCA)
1.281 +/**
1.282 + * Sets the Relative Card Address
1.283 + * @param anRCA The RCA.
1.284 + */
1.285 + {iData=(iData&0xFFFF)|(TUint(anRCA)<<16);}
1.286 +
1.287 +// -------- class TRCA --------
1.288 +
1.289 +inline TRCA::TRCA(TUint16 aData) : iData(aData)
1.290 +/**
1.291 + * Constructs a TRCA with a 16-bit RCA.
1.292 + * @param aData The 16-bit RCA.
1.293 + */
1.294 + {}
1.295 +
1.296 +inline TRCA::TRCA(TInt aData) : iData(static_cast<TUint16>(aData))
1.297 +/**
1.298 + * Constructs a TRCA with a parameter of type TInt.
1.299 + * @param aData The TInt parameter.
1.300 + */
1.301 + {}
1.302 +
1.303 +inline TRCA::TRCA(TMMCArgument aData)
1.304 +/**
1.305 + * Constructs a TRCA with a TMMCArgument containing a RCA.
1.306 + * @param aData The argument containing the RCA.
1.307 + */
1.308 + {iData=(TUint16)((TUint32(aData)>>16)&0xFFFF);}
1.309 +
1.310 +inline TRCA::operator TUint16() const
1.311 +/**
1.312 + * Converts the TRCA to it's raw 16-bit representation.
1.313 + * @return Raw 16-bit RCA
1.314 + */
1.315 + {return(iData);}
1.316 +
1.317 +// -------- class TDSR --------
1.318 +
1.319 +inline TDSR::TDSR()
1.320 +/**
1.321 + * Default constructor.
1.322 + * Initialises the DRS to zero
1.323 + */
1.324 + {}
1.325 +
1.326 +inline TDSR::TDSR(TUint16 aData) : iData(aData)
1.327 +/**
1.328 + * Constructs a TDSR with a 16-bit DSR.
1.329 + * @param aData The 16-bit DSR.
1.330 + */
1.331 + {}
1.332 +
1.333 +inline TDSR::operator TUint16() const
1.334 +/**
1.335 + * Converts the TDSR to it's raw 16-bit representation.
1.336 + * @return Raw 16-bit DSR
1.337 + */
1.338 + {return(iData);}
1.339 +
1.340 +
1.341 +// -------- class TMMCard --------
1.342 +inline TBool TMMCard::IsHighCapacity() const { return (iFlags & KMMCardIsHighCapacity) != 0; }
1.343 +
1.344 +inline TBool TMMCard::IsPresent() const
1.345 +//
1.346 +// If the card is present, its index shows the card number + 1
1.347 +//
1.348 + {return( iIndex != 0 );}
1.349 +
1.350 +inline TInt TMMCard::Number() const {return( iIndex - 1 );}
1.351 +inline TMMCMediaTypeEnum TMMCard::MediaType() const {return(iCSD.MediaType());}
1.352 +inline const TCID& TMMCard::CID() const {return(iCID);}
1.353 +inline const TCSD& TMMCard::CSD() const {return(iCSD);}
1.354 +inline const TExtendedCSD& TMMCard::ExtendedCSD() const {return(iExtendedCSD);}
1.355 +inline TRCA TMMCard::RCA() const {return(iRCA);}
1.356 +inline TBool TMMCard::HasPassword() const {return(iFlags&KMMCardHasPassword);}
1.357 +inline TBool TMMCard::IsWriteProtected() const {return(iFlags&KMMCardIsWriteProtected);}
1.358 +
1.359 +inline TUint TMMCard::DeviceSize() const
1.360 + {
1.361 + TInt64 capacity = DeviceSize64();
1.362 + return(capacity > KMaxTInt ? KMaxTInt : I64LOW(capacity));
1.363 + }
1.364 +
1.365 +/**
1.366 +Gets the bus width setting for this card.
1.367 +Note returned value may differ from current host controller bus width setting.
1.368 +returns 1, 4 or 8
1.369 +*/
1.370 +inline TInt TMMCard::BusWidth() const
1.371 + {return iBusWidth;}
1.372 +
1.373 +/**
1.374 +Sets the bus width setting for this card.
1.375 +Note this buswidth will not be applied to the host controller and is only used for recording.
1.376 +
1.377 +@param aBusWidth the bus width to set - valid values are 1, 4 or 8
1.378 +*/
1.379 +inline void TMMCard::SetBusWidth(TInt aBusWidth)
1.380 + {iBusWidth=aBusWidth;}
1.381 +
1.382 +inline void TMMCard::SetHighSpeedClock(TUint32 aHighSpeedClock)
1.383 + {iHighSpeedClock = aHighSpeedClock;}
1.384 +inline TUint32 TMMCard::HighSpeedClock() const
1.385 + {return iHighSpeedClock;}
1.386 +
1.387 +// -------- class TMMCardArray --------
1.388 +
1.389 +inline TMMCardArray::TMMCardArray(DMMCStack* anOwningStack)
1.390 + {iOwningStack=anOwningStack;}
1.391 +inline TUint TMMCardArray::NewCardCount()
1.392 + {return(iNewCardsCount);}
1.393 +inline TInt TMMCardArray::CardsPresent()
1.394 + {return(iCardsPresent);}
1.395 +inline TMMCard* TMMCardArray::NewCardP(TUint aNewCardNumber)
1.396 + {return(iNewCards[aNewCardNumber]);}
1.397 +inline TMMCard* TMMCardArray::CardP(TUint aCardNumber)
1.398 + {return(iCards[aCardNumber]);}
1.399 +inline TMMCard& TMMCardArray::NewCard(TUint aCardNumber)
1.400 + {return *iNewCards[aCardNumber];}
1.401 +inline TMMCard& TMMCardArray::Card(TUint aCardNumber)
1.402 + {return *iCards[aCardNumber];}
1.403 +
1.404 +// -------- class TMMCCommandDesc --------
1.405 +
1.406 +inline TBool TMMCCommandDesc::IsBlockCmd() const
1.407 + { return ((iFlags & KMMCCmdFlagBlockAddress) != 0); }
1.408 +
1.409 +inline TUint32 TMMCCommandDesc::NumBlocks() const
1.410 + { return iTotalLength / BlockLength(); }
1.411 +
1.412 +inline TInt64 TMMCCommandDesc::Arg64() const
1.413 + { return IsBlockCmd()? ((TInt64)(TUint32)iArgument) << KMMCardHighCapBlockSizeLog2 : (TInt64)(TUint32)iArgument; }
1.414 +
1.415 +inline TBool TMMCCommandDesc::IsDoubleBuffered() const
1.416 + { return ((iFlags & KMMCCmdFlagDoubleBuffer) != 0); }
1.417 +
1.418 +inline TBool TMMCCommandDesc::IsPhysicalAddress() const
1.419 + { return ((iFlags & KMMCCmdFlagPhysAddr) != 0); }
1.420 +
1.421 +/**
1.422 +Returns the buffer length in bytes. If the current request is double-buffered,
1.423 +this returns the amount of data available in the currently active buffer.
1.424 +If the command is not double-buffered, the total amount of data to be transferred is returned.
1.425 +
1.426 +@return Buffer length in bytes
1.427 +*/
1.428 +inline TUint32 TMMCCommandDesc::BufferLength() const
1.429 + { return (IsDoubleBuffered() ? (iBlockLength >> 16) << KMMCardHighCapBlockSizeLog2 : iTotalLength); }
1.430 +
1.431 +inline TUint32 TMMCCommandDesc::BlockLength() const
1.432 + { return (IsDoubleBuffered() ? (iBlockLength & 0x0000FFFF) : iBlockLength); }
1.433 +
1.434 +// -------- class TMMCStackConfig --------
1.435 +
1.436 +inline TMMCStackConfig::TMMCStackConfig() : iUpdateMask(0), iClientMask(0)
1.437 +/**
1.438 + * Constructor for a TMMCStackConfig object.
1.439 + */
1.440 + {}
1.441 +
1.442 +inline void TMMCStackConfig::SetMode(TUint32 aMask)
1.443 +/**
1.444 + * Enable a single mode or a set of modes.
1.445 + * Enabled modes should be considered by the Controller as effective. However, client mode
1.446 + * settings may be overridden by master settings.
1.447 + * @param aMask The mode(s) to be set.
1.448 + */
1.449 + {iModes |= aMask; iUpdateMask |= aMask;}
1.450 +
1.451 +inline void TMMCStackConfig::RemoveMode(TUint32 aMask)
1.452 +/**
1.453 + * Disable a single mode or a set of modes.
1.454 + * Disabled modes should be considered by the Controller as not in effect. However, client mode
1.455 + * settings may be overridden by master settings.
1.456 + * @param aMask The mode(s) to be removed.
1.457 + */
1.458 + {iModes &= ~aMask; iUpdateMask |= aMask;}
1.459 +
1.460 +inline void TMMCStackConfig::UseDefault(TUint32 aMask)
1.461 +/**
1.462 + * Restore a single mode or a set of modes to the default setting setting for the platform.
1.463 + * @param aMask The mode(s) to be restored.
1.464 + */
1.465 + {iUpdateMask &= ~aMask; iClientMask &= ~aMask;}
1.466 +
1.467 +inline void TMMCStackConfig::SetPollAttempts(TUint aData)
1.468 +/**
1.469 + * Set the number of attempts the Controller is allowed to make to recover on busy timeout during writes to the card.
1.470 + * The default setting for this is KMMCMaxPollAttempts (i.e. 5).
1.471 + * @param aData The number of attempts to make to recover on busy timeout during write
1.472 + */
1.473 + {iPollAttempts=aData; iClientMask |= KMMCModeClientPollAttempts; }
1.474 +
1.475 +inline void TMMCStackConfig::SetOpCondBusyTimeout(TUint16 aData)
1.476 +/**
1.477 + * Set the number of attempts the Controller is allowed to make to recover on busy timeout
1.478 + * while waiting for a card which is slow to power up during stack initialisation. The default setting
1.479 + * for this is KMMCMaxOpCondBusyTimeout (i.e. 100).
1.480 + * @param aData The number of attempts to make to recover on busy timeout during power up
1.481 +*/
1.482 + {iOpCondBusyTimeout=aData; iClientMask |= KMMCModeClientiOpCondBusyTimeout; }
1.483 +
1.484 +inline TInt TMMCStackConfig::OpCondBusyTimeout()
1.485 +/**
1.486 + * Return the number of attempts the Controller is allowed to make to recover on busy timeout
1.487 + * while waiting for a card which is slow to power up during stack initialisation.
1.488 + * @return The number of attempts to make to recover on busy timeout
1.489 +*/
1.490 + {return((TInt)iOpCondBusyTimeout);}
1.491 +
1.492 +inline void TMMCStackConfig::SetTimeOutRetries(TUint aData)
1.493 +/**
1.494 + * Set the number of auto reties the Controller is allowed to make on command response time-out or data
1.495 + * block receive timeout situations. The default setting for this is KMMCMaxTimeOutRetries (i.e. 1).
1.496 + * @param aData The number of auto reties to make on command response time-out or data block receive timeout condition.
1.497 + */
1.498 + {iTimeOutRetries=aData; iClientMask |= KMMCModeClientTimeOutRetries; }
1.499 +
1.500 +inline void TMMCStackConfig::SetCRCRetries(TUint aData)
1.501 +/**
1.502 + * Set the number of auto reties the Controller is allowed to make on CRC error situations.
1.503 + * The default setting for this is KMMCMaxCRCRetries (i.e. 1).
1.504 + * @param aData The number of auto reties to make on a CRC error condition.
1.505 + */
1.506 + {iCRCRetries=aData; iClientMask |= KMMCModeClientCRCRetries; }
1.507 +
1.508 +inline void TMMCStackConfig::SetBusClockInKhz(TUint aData)
1.509 +/**
1.510 + * Set the bus clock speed in kilohertz.
1.511 + * The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults).
1.512 + * @param aData The bus clock speed in kilohertz
1.513 + */
1.514 + {iBusConfig.iBusClock=aData; iClientMask |= KMMCModeClientBusClock; }
1.515 +
1.516 +inline void TMMCStackConfig::SetTicksClockIn(TUint aData)
1.517 +/**
1.518 + * Set the number of clock ticks in the ClockIn phase to be used.
1.519 + * The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults).
1.520 + * @param aData The number of clock ticks in the ClockIn phase
1.521 + */
1.522 + {iBusConfig.iClockIn=aData; iClientMask |= KMMCModeClientClockIn; }
1.523 +
1.524 +inline void TMMCStackConfig::SetTicksClockOut(TUint aData)
1.525 +/**
1.526 + * Set the number of clock ticks in the ClockOut phase to be used.
1.527 + * The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults).
1.528 + * @param aData The number of clock ticks in the ClockOut phase
1.529 + */
1.530 + {iBusConfig.iClockOut=aData; iClientMask |= KMMCModeClientClockOut; }
1.531 +
1.532 +inline void TMMCStackConfig::SetResponseTimeOutInTicks(TUint aData)
1.533 +/**
1.534 + * Set the response timeout value to be used (in bus clock ticks).
1.535 + * If a command response is not received within this period then the Controller will either retry or return an error.
1.536 + * The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults).
1.537 + * @param aData The response timeout in bus clock ticks
1.538 + */
1.539 + {iBusConfig.iResponseTimeOut=aData; iClientMask |= KMMCModeClientResponseTimeOut; }
1.540 +
1.541 +inline void TMMCStackConfig::SetDataTimeOutInMcs(TUint aData)
1.542 +/**
1.543 + * Set the data timeout value to be used (in microseconds).
1.544 + * If an expected data block is not received from the card within this period then the Controller will
1.545 + * either retry or return an error.
1.546 + * The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults).
1.547 + * @param aData The data timeout in microseconds
1.548 + */
1.549 + {iBusConfig.iDataTimeOut=aData; iClientMask |= KMMCModeClientDataTimeOut; }
1.550 +
1.551 +inline void TMMCStackConfig::SetBusyTimeOutInMcs(TUint aData)
1.552 +/**
1.553 + * Set the busy timeout value to be used (in microseconds).
1.554 + * If a data block is not requested by the card within this period then the Controller will either retry
1.555 + * or return an error.
1.556 + * The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults).
1.557 + * @param aData The busy timeout in microseconds
1.558 + */
1.559 + {iBusConfig.iBusyTimeOut=aData; iClientMask |= KMMCModeClientBusyTimeOut; }
1.560 +
1.561 +
1.562 +// -------- class TMMCRCAPool --------
1.563 +
1.564 +inline TMMCRCAPool::TMMCRCAPool() : iLocked(0) {}
1.565 +inline void TMMCRCAPool::LockRCA(TRCA anRCA) {iLocked |= (1 << (((TUint(anRCA) / 257) - 1) & 31));}
1.566 +inline void TMMCRCAPool::UnlockRCA(TRCA anRCA) {iLocked &= ~(1 << (((TUint(anRCA) / 257) - 1) & 31));}
1.567 +inline void TMMCRCAPool::ReleaseUnlocked() {iPool = 0;}
1.568 +
1.569 +
1.570 +// -------- class TMMCSessRing --------
1.571 +
1.572 +inline TBool TMMCSessRing::IsEmpty() const {return(iSize==0);}
1.573 +inline void TMMCSessRing::SetMarker() {iPMark=iPrevP;}
1.574 +inline void TMMCSessRing::AdvanceMarker() {if(iPMark != NULL) iPMark=iPMark->iLinkP;}
1.575 +inline void TMMCSessRing::Point() {iPoint=((iPrevP=iPMark)==NULL)? NULL : iPMark->iLinkP;}
1.576 +inline TUint TMMCSessRing::Size() const {return(iSize);}
1.577 +inline TMMCSessRing::operator DMMCSession*() const {return(iPoint);}
1.578 +
1.579 +
1.580 +// -------- class TMMCStateMachine --------
1.581 +
1.582 +
1.583 +/**
1.584 +Gets the current MultiMediCard error code.
1.585 +
1.586 +@return The current MultiMediCard error code.
1.587 +*/
1.588 +inline TMMCErr TMMCStateMachine::ExitCode() { return(iExitCode); }
1.589 +
1.590 +
1.591 +
1.592 +
1.593 +/**
1.594 +Gets the current MultiMediCard error code, and sets a new error code.
1.595 +
1.596 +@param aCode The new error code value to be set.
1.597 +
1.598 +@return The current MultiMediCard error code.
1.599 +*/
1.600 +inline TMMCErr TMMCStateMachine::SetExitCode(TMMCErr aCode) { return __e32_atomic_swp_ord32(&iExitCode, aCode); }
1.601 +
1.602 +
1.603 +
1.604 +
1.605 +/**
1.606 +Gets the current state of the state machine.
1.607 +
1.608 +Note that this is the state of the current state entry within
1.609 +the state machine stack.
1.610 +
1.611 +@return The current state of the state machine.
1.612 +*/
1.613 +inline TUint TMMCStateMachine::State() { return(iStack[iSP].iState); }
1.614 +
1.615 +
1.616 +
1.617 +
1.618 +/**
1.619 +Sets the state of the state machine.
1.620 +
1.621 +Note that this sets the state of the current state entry within
1.622 +the state machine stack.
1.623 +
1.624 +@param aState The state to be set.
1.625 +
1.626 +@return KMMCErrNone
1.627 +*/
1.628 +inline TMMCErr TMMCStateMachine::SetState(TUint aState) { iStack[iSP].iState=aState; return(0); }
1.629 +
1.630 +
1.631 +
1.632 +
1.633 +/**
1.634 +Prevents the state machine from blocking.
1.635 +*/
1.636 +inline void TMMCStateMachine::SuppressSuspension() { iSuspend = EFalse; }
1.637 +
1.638 +
1.639 +
1.640 +
1.641 +/**
1.642 +Sets the trap mask for the current state machine entry.
1.643 +
1.644 +This defines the set of errors that the state machine function
1.645 +wants to trap.
1.646 +
1.647 +@param aMask The set of error values. This is a set of TMMCErr bits.
1.648 +
1.649 +@see TMMCErr
1.650 +*/
1.651 +inline void TMMCStateMachine::SetTraps(TMMCErr aMask) { iStack[iSP].iTrapMask=aMask; }
1.652 +
1.653 +
1.654 +
1.655 +
1.656 +/**
1.657 +Clears the trap mask.
1.658 +
1.659 +@see TMMCStateMachine::SetTraps()
1.660 +*/
1.661 +inline void TMMCStateMachine::ResetTraps() { iStack[iSP].iTrapMask=0; }
1.662 +
1.663 +
1.664 +
1.665 +
1.666 +/**
1.667 +Aborts the session.
1.668 +*/
1.669 +inline void TMMCStateMachine::Abort() { iAbort=ETrue; }
1.670 +
1.671 +
1.672 +
1.673 +
1.674 +/**
1.675 +Initialises the state machine.
1.676 +
1.677 +The function sets up the state machine function for the first state entry on
1.678 +the state machine stack.
1.679 +
1.680 +It also sets up the context. In practice, the context is a pointer to
1.681 +the DMMCStack stack object, i.e. the object representing the MultiMediaCard
1.682 +stack. The pointer is passed to the state machine functions when they
1.683 +are dispatched.
1.684 +
1.685 +@param anEntry The state machine function for the first state machine entry.
1.686 +@param aContextP A pointer to the context.
1.687 +*/
1.688 +inline void TMMCStateMachine::Setup(TMMCErr (*anEntry)(TAny*), TAny* aContextP)
1.689 + {iContextP = aContextP; iStack[0].iFunction = anEntry; Reset();}
1.690 +
1.691 +
1.692 +
1.693 +
1.694 +/**
1.695 +Pops the current state entry off the state machine stack.
1.696 +
1.697 +@param aSuspend Indicates whether the state machine is to block;
1.698 + specify ETrue to block, EFalse not to block.
1.699 +
1.700 +@return KMMCErrNone.
1.701 +*/
1.702 +inline TMMCErr TMMCStateMachine::Pop(TBool aSuspend)
1.703 + {iSP--; if(!aSuspend) iSuspend = EFalse; return( 0 );}
1.704 +
1.705 +
1.706 +
1.707 +
1.708 +/**
1.709 +Pushes the next state entry onto the stack, specifying the current state
1.710 +function as the child function that is to be run, and requests the state
1.711 +machine to block.
1.712 +
1.713 +@return A MultiMediaCard error code returned from a call to TMMCStateMachine::Push().
1.714 +*/
1.715 +inline TMMCErr TMMCStateMachine::PushMe() {return(Push(iStack[iSP].iFunction,ETrue));}
1.716 +
1.717 +
1.718 +// -------- class DMMCSession --------
1.719 +
1.720 +inline void DMMCSession::SetStack(DMMCStack* aStackP)
1.721 +/**
1.722 + * Assign a stack to the session.
1.723 + *
1.724 + * If an attempt is made to engage the session before a stack has been assigned to it
1.725 + * then the request will fail straight away. It is possible to change the stack controller
1.726 + * assigned to the session as long as this is not attempted while the session is engaged.
1.727 + *
1.728 + * @param aStackP A pointer to the stack to be assigned to the session
1.729 + */
1.730 + {iStackP = aStackP;}
1.731 +
1.732 +inline void DMMCSession::SetupCIMUpdateAcq()
1.733 +/**
1.734 + * Set up the session to perform the CIM_UPDATE_ACQ macro as outlined by the MMCA.
1.735 + *
1.736 + * Having set-up the session for this operation, the client must then engage the session
1.737 + * before the operation can commence. The CIM_UPDATE_ACQ macro starts an identification
1.738 + * cycle of a card stack. New cards are initialised but old cards keep their configuration.
1.739 + * The process ends with all compatible cards being moved to their stand-by state.
1.740 + */
1.741 + {iSessionID = ECIMUpdateAcq;}
1.742 +
1.743 +inline void DMMCSession::SetupCIMInitStack()
1.744 +/**
1.745 + * Set up the session to perform the CIM_INIT_STACK macro as outlined by the MMCA.
1.746 + *
1.747 + * Having set-up the session for this operation, the client must then engage the session
1.748 + * before the operation can commence. The CIM_UPDATE_ACQ macro sends all cards to the idle
1.749 + * state and then executes the update acquisition sequence.
1.750 + */
1.751 + {iSessionID = ECIMInitStack;}
1.752 +
1.753 +inline void DMMCSession::SetupCIMCheckStack()
1.754 +/**
1.755 + * Set up the session to perform the CIM_CHECK_STACK macro as outlined by the MMCA.
1.756 + *
1.757 + * Having set-up the session for this operation, the client must then engage the session
1.758 + * before the operation can commence. The CIM_CHECK_STACK macro attempts to read the CSD
1.759 + * of each active card in the stack, updating the data held by the stack controller for each card.
1.760 + */
1.761 + {iSessionID = ECIMCheckStack;}
1.762 +
1.763 +inline void DMMCSession::SetupCIMSetupCard()
1.764 +/**
1.765 + * Set up the session to perform the CIM_SETUP_CARD macro as outlined by the MMCA.
1.766 + *
1.767 + * Having set-up the session for this operation, the client must then engage the session
1.768 + * before the operation can commence. The CIM_SETUP_CARD macro selects a particular card
1.769 + * for data transfer and reads back its CSD.
1.770 + */
1.771 + {iSessionID = ECIMSetupCard;}
1.772 +
1.773 +inline void DMMCSession::SetupCIMLockStack()
1.774 +/**
1.775 + * Set up the session to lock the stack for this session only (so that only this session
1.776 + * can be engaged upon it). This prevents any other sessions from being engaged upon it.
1.777 + *
1.778 + * Having set-up the session for this operation, the client must then engage this session before
1.779 + * the stack becomes locked. In fact, no card bus activity results when this session is engaged.
1.780 + * However, because it may take some time for the Controller to be able to lock the stack for this
1.781 + * session, the mechanism for locking the stack still involves submitting a session.
1.782 + * When issuing a series of application specific commands, the client will want to lock the stack,
1.783 + * preventing any other client from generating bus activity during this period. This is accomplished
1.784 + * by issuing this function and then engaging that session. If successful, the stack will be locked
1.785 + * until the DMMCSession::UnlockStack() function is issued.
1.786 + */
1.787 + {iSessionID = ECIMLockStack;}
1.788 +
1.789 +inline void DMMCSession::UnlockStack()
1.790 +/**
1.791 + * Unlock this session as the locking session for the stack, the stack having previously been locked
1.792 + * to this session using the DMMCSession.
1.793 + */
1.794 + {if(iStackP != NULL) iStackP->UnlockStack(this);}
1.795 +
1.796 +inline void DMMCSession::SetupCIMInitStackAfterUnlock()
1.797 +/**
1.798 + * Set up the session to perform the second stage of initialisation after unlocking of the card
1.799 + *
1.800 + * This is provided to allow types of cards (particularly SD cards) to access the SD_STATUS and
1.801 + * associated registers during initialisation, which are only available once the card is unlocked.
1.802 + */
1.803 + {
1.804 + iCardP = NULL;
1.805 + iSessionID = ECIMInitStackAfterUnlock;
1.806 + }
1.807 +
1.808 +inline void DMMCSession::SetupCIMAutoUnlock()
1.809 +/**
1.810 + * Set up the session to perform auto-unlocking of the card
1.811 + */
1.812 + {iSessionID = ECIMAutoUnlock;}
1.813 +
1.814 +inline void DMMCSession::Stop()
1.815 +/**
1.816 + * Signal the session to complete immediately with KErrAbort
1.817 + * (i.e. the session end call-back function will be called).
1.818 + */
1.819 + {if(iStackP != NULL) iStackP->Stop(this);}
1.820 +
1.821 +inline void DMMCSession::Abort()
1.822 +/**
1.823 + * Signal the session to abort immediately with no completion
1.824 + * (i.e. the session end call-back function will not be called).
1.825 + */
1.826 + {if(iStackP != NULL) iStackP->Abort(this);}
1.827 +
1.828 +inline TMMCSessionTypeEnum DMMCSession::SessionID() const
1.829 +/**
1.830 + * Returns the current session type for this session.
1.831 + *
1.832 + * @return A TMMCSessionTypeEnum describing the sesion type
1.833 + */
1.834 + {return(iSessionID);}
1.835 +
1.836 +inline DMMCStack* DMMCSession::StackP() const
1.837 +/**
1.838 + * Returns the DMMCStack object serving this session.
1.839 + *
1.840 + * @return A pointer to the DMMCStack object serving this session.
1.841 + */
1.842 + {return(iStackP);}
1.843 +
1.844 +inline TMMCard* DMMCSession::CardP() const
1.845 +/**
1.846 + * Returns a pointer to the TMMCard object which this session is set to use.
1.847 + *
1.848 + * @return A pointer to the TMMCard object which this session is set to use.
1.849 + */
1.850 + {return(iCardP);}
1.851 +
1.852 +inline TBool DMMCSession::IsEngaged() const
1.853 +/**
1.854 + * Return ETrue if this session is currently queued on the DMMCStack object serving this session.
1.855 + *
1.856 + * @return ETrue if this session is currently queued, otherwise EFalse
1.857 + */
1.858 + {return((iState & KMMCSessStateEngaged) != 0);}
1.859 +
1.860 +inline TMMCErr DMMCSession::MMCExitCode() const
1.861 +/**
1.862 + * Returns the last MMC specific error code returned to this session.
1.863 + *
1.864 + * @return a TMMCErr describing the MMC specific error code
1.865 + */
1.866 + {return(iMMCExitCode);}
1.867 +
1.868 +inline TMMCStatus DMMCSession::LastStatus() const
1.869 +/**
1.870 + * Returns the last status information from the card (i.e. the last R1 response received from the card).
1.871 + *
1.872 + * @return a TMMCStatus describing the status information
1.873 + */
1.874 + {return(iLastStatus);}
1.875 +
1.876 +inline TUint32 DMMCSession::BytesTransferred() const
1.877 +/**
1.878 + * Returns the total number of bytes transferred in this session.
1.879 + *
1.880 + * @return the total number of bytes transferred in this session.
1.881 + */
1.882 + {return(iBytesTransferred);}
1.883 +
1.884 +inline TUint8* DMMCSession::ResponseP()
1.885 +/**
1.886 + * Returns a pointer to a buffer containing the last command response received in this session.
1.887 + *
1.888 + * @return a buffer with format TUint8[KMMCMaxResponseLength] (where KMMCMaxResponseLength = 16).
1.889 + */
1.890 + {return(&iCommand[iCmdSP].iResponse[0]);}
1.891 +
1.892 +inline TUint32 DMMCSession::EffectiveModes() const
1.893 +/**
1.894 + * Returns the modes which the DMMCStack object serving this session will consider as effective.
1.895 + *
1.896 + * @return the modes which the DMMCStack object serving this session will consider as effective
1.897 + */
1.898 + {if(iStackP != NULL) return(iStackP->EffectiveModes(iConfig)); return(0);}
1.899 +
1.900 +inline void DMMCSession::Block(TUint32 aFlag)
1.901 + {iStackP->Block(this, aFlag);}
1.902 +
1.903 +inline void DMMCSession::UnBlock(TUint32 aFlag, TMMCErr anExitCode)
1.904 + {iStackP->UnBlock(this, aFlag, anExitCode);}
1.905 +
1.906 +inline void DMMCSession::SwapMe()
1.907 + {iState |= KMMCSessStateDoReSchedule;}
1.908 +
1.909 +inline void DMMCSession::ResetCommandStack()
1.910 +/**
1.911 + * Resets the command stack, setting the stack pointer to zero.
1.912 + */
1.913 + {iCmdSP = 0;}
1.914 +
1.915 +/**
1.916 +Increments the command stack pointer.
1.917 +
1.918 +@panic PBUS-MMC 6 if the stack pointer lies outside the bounds of the stack.
1.919 +*/
1.920 +inline void DMMCSession::PushCommandStack()
1.921 + {
1.922 + __ASSERT_ALWAYS(TUint(++iCmdSP)<KMaxMMCCommandStackDepth,
1.923 + DMMCSocket::Panic(DMMCSocket::EMMCCommandStack));
1.924 + }
1.925 +
1.926 +/**
1.927 +Decrements the command stack pointer.
1.928 +
1.929 +@panic PBUS-MMC 6 if the stack pointer lies outside the bounds of the stack.
1.930 +*/
1.931 +inline void DMMCSession::PopCommandStack()
1.932 + {
1.933 + __ASSERT_ALWAYS(--iCmdSP>=0,
1.934 + DMMCSocket::Panic(DMMCSocket::EMMCCommandStack));
1.935 + }
1.936 +
1.937 +inline TMMCCommandDesc& DMMCSession::Command()
1.938 +/**
1.939 + * Returns the current command, as referred to by the stack pointer.
1.940 + * @return A TMMCCommandDesc reference, containing the current command.
1.941 + */
1.942 + {return(iCommand[iCmdSP]);}
1.943 +
1.944 +
1.945 +//
1.946 +// Data transfer macros setup (block mode)
1.947 +//
1.948 +
1.949 +inline void DMMCSession::SetupCIMReadBlock(TMMCArgument aBlockAddr, TUint8* aMemoryP, TUint32 aBlocks)
1.950 +/**
1.951 + * Sets the session up to perform the CIM_READ_BLOCK macro as outlined by the MMCA.
1.952 + * Having set-up the session for this operation, the client must then engage the session before the operation can commence.
1.953 + * The CIM_READ_BLOCK macro reads a single block from the card. It starts by setting the block length (CMD16) to 512 Bytes.
1.954 + * It then reads 'aBlocks' blocks of data from the card at offset 'aBlockAddr' on the card into system memory starting at
1.955 + * address 'aMemoryP'.
1.956 + *
1.957 + * @param aBlockAddr Contains offset (in blocks) to the block to be read from the card
1.958 + * @param aMemoryP host destination address
1.959 + * @param aBlocks The number of blocks to read from the card
1.960 + */
1.961 + {
1.962 + ResetCommandStack();
1.963 + FillCommandArgs(aBlockAddr, aBlocks << KMMCardHighCapBlockSizeLog2, aMemoryP, KMMCardHighCapBlockSize);
1.964 + Command().iFlags |= KMMCCmdFlagBlockAddress;
1.965 + iSessionID = (aBlocks > 1)? ECIMReadMBlock : ECIMReadBlock;
1.966 + }
1.967 +
1.968 +inline void DMMCSession::SetupCIMWriteBlock(TMMCArgument aBlockAddr, TUint8* aMemoryP, TUint32 aBlocks)
1.969 +/**
1.970 + * Set up the session to perform the CIM_WRITE_BLOCK macro as outlined by the MMCA.
1.971 + * Having set-up the session for this operation, the client must then engage the session before the operation can commence.
1.972 + * The CIM_WRITE_BLOCK macro writes a single block to the card. It starts by setting the block length (CMD16) to 512 Bytes.
1.973 + * It then writes 'aBlocks' block of data to the card at offset 'aBlockAddr' on the card reading from system memory starting
1.974 + * at address 'aMemoryP'.
1.975 + *
1.976 + * @param aBlockAddr Contains offset to the block (in blocks) to be written on the card
1.977 + * @param aMemoryP Host source address
1.978 + * @param aBlocks The number of blocks to write to the card
1.979 + */
1.980 + {
1.981 + ResetCommandStack();
1.982 + FillCommandArgs(aBlockAddr, aBlocks << KMMCardHighCapBlockSizeLog2, aMemoryP, KMMCardHighCapBlockSize);
1.983 + Command().iFlags |= KMMCCmdFlagBlockAddress;
1.984 + iSessionID = (aBlocks > 1)? ECIMWriteMBlock : ECIMWriteBlock;
1.985 + }
1.986 +
1.987 +inline void DMMCSession::SetupCIMEraseMSector(TMMCArgument aBlockAddr, TUint32 aBlocks)
1.988 +/**
1.989 + * Set up the session to perform the CIM_ERASE_SECTOR macro broadly as outlined by the MMCA.
1.990 + * However, the macro only performs a sector erase of a contiguous area and doesn't support the un-tagging of particular sectors
1.991 + * within the initial tagged area. Having set-up the session for this operation, the client must then engage the session before
1.992 + * the operation can commence.
1.993 + *
1.994 + * The CIM_ERASE_SECTOR macro erases a range of sectors on the card starting at offset (in blocks) 'aBlockAddr' on the card and ending at offset
1.995 + * 'aBlockAddr'+'aBlocks' (in blocks). The entire area specified must lie within a single erase group. (The erase group size can be read from the CSD).
1.996 + * The tag sector start command (CMD32) is first issued setting the address of the first sector to be erased.
1.997 + * This is followed by the tag sector end command (CMD33) setting the address of the last sector to be erased. Now that the erase
1.998 + * sectors are tagged, the erase command (CMD38) is sent followed by a send status command (CMD13) to read any additional status
1.999 + * information from the card.
1.1000 + *
1.1001 + * @param aBlockAddr Contains offset (in blocks) to the first block to be erased
1.1002 + * @param aBlocks Total number of blocks to erase
1.1003 + */
1.1004 + {
1.1005 + ResetCommandStack();
1.1006 + FillCommandArgs(aBlockAddr, aBlocks << KMMCardHighCapBlockSizeLog2, NULL, 0);
1.1007 + Command().iFlags |= KMMCCmdFlagBlockAddress;
1.1008 + iSessionID = ECIMEraseSector;
1.1009 + }
1.1010 +
1.1011 +inline void DMMCSession::SetupCIMEraseMGroup(TMMCArgument aBlockAddr, TUint32 aBlocks)
1.1012 +/**
1.1013 + * Set up the session to perform the CIM_ERASE_GROUP macro broadly as outlined by the MMCA.
1.1014 + * However, the macro only performs an erase group erase of a contiguous area and doesn't support the un-tagging of particular
1.1015 + * erase groups within the initial tagged area. Having set-up the session for this operation, the client must then engage the
1.1016 + * session before the operation can commence.
1.1017 + *
1.1018 + * The CIM_ERASE_GROUP macro erases a range of erase groups on the card starting at offset (in blocks) 'aDevAddr' on the card and ending at
1.1019 + * offset 'aBlockAddr'+'aBlocks' (in blocks). The tag ease group start command (CMD35) is first issued setting
1.1020 + * the address of the first erase group to be erased. This is followed by the tag erase group end command (CMD36) setting the
1.1021 + * address of the last erase group to be erased. Now that the erase groups are tagged, the erase command (CMD38) is sent followed
1.1022 + * by a send status command (CMD13) to read any additional status information from the card.
1.1023 + *
1.1024 + * @param aBlockAddr Contains offset (in blocks) to the first block to be erased
1.1025 + * @param aBlocks Total number of blocks to erase
1.1026 + */
1.1027 + {
1.1028 + ResetCommandStack();
1.1029 + FillCommandArgs(aBlockAddr, aBlocks << KMMCardHighCapBlockSizeLog2, NULL, 0);
1.1030 + Command().iFlags |= KMMCCmdFlagBlockAddress;
1.1031 + iSessionID = ECIMEraseGroup;
1.1032 + }
1.1033 +
1.1034 +inline void DMMCSession::EnableDoubleBuffering(TUint32 aNumBlocks)
1.1035 +/**
1.1036 + * When called before a data transfer operation is engaged, specifies that the data
1.1037 + * transfer operation is to be double-buffered.
1.1038 + *
1.1039 + * @param aNumBlocks The number of blocks to transfer per double-buffer transfer.
1.1040 + *
1.1041 + * @internalTechnology
1.1042 + */
1.1043 + {
1.1044 + __KTRACE_OPT(KPBUS1, Kern::Printf("++ DMMCSession::EnableDoubleBuffering(%d Blocks)", aNumBlocks))
1.1045 +
1.1046 + //__ASSERT_ALWAYS(iSessionID == ECIMWriteMBlock || iSessionID == ECIMReadMBlock, DMMCSocket::Panic(DMMCSocket::EMMCInvalidDBCommand));
1.1047 +
1.1048 + Command().iBlockLength &= 0x0000FFFF;
1.1049 + Command().iBlockLength |= aNumBlocks << 16;
1.1050 + Command().iFlags |= KMMCCmdFlagDoubleBuffer;
1.1051 + }
1.1052 +
1.1053 +inline void DMMCSession::SetDataTransferCallback(TMMCCallBack& aCallback)
1.1054 +/**
1.1055 + * Registers the data transfer callback function to be called when more data is required by the PSL,
1.1056 + * typically while the hardware is busy performing a DMA transfer.
1.1057 + *
1.1058 + * @param aCallback The callback function.
1.1059 + *
1.1060 + * @internalTechnology
1.1061 + */
1.1062 + {
1.1063 + __KTRACE_OPT(KPBUS1, Kern::Printf("++ DMMCSession::SetDataTransferCallback"));
1.1064 +
1.1065 + iDataTransferCallback = aCallback;
1.1066 + }
1.1067 +
1.1068 +inline void DMMCSession::MoreDataAvailable(TUint32 aNumBlocks, TUint8* aMemoryP, TInt aError)
1.1069 +/**
1.1070 + * Called by the MMC Media Driver after copying data from the client thread to indicate to the
1.1071 + * PSL that data is available in the next data buffer. Should be called at the end of the
1.1072 + * data transfer callback function, at which point the stack will be unblocked enabling the
1.1073 + * next data transfer to take place.
1.1074 + *
1.1075 + * @param aNumBlocks The number of blocks available in the buffer.
1.1076 + * @param aMemoryP A pointer to the host memory containing the next blocks of data.
1.1077 + * @param aError The result of the data callback.
1.1078 + *
1.1079 + * @internalTechnology
1.1080 + */
1.1081 + {
1.1082 + __KTRACE_OPT(KPBUS1, Kern::Printf("++ DMMCSession::MoreDataAvailable(%d blocks, %08x, %d)", aNumBlocks, aMemoryP, aError));
1.1083 +
1.1084 + Command().iDataMemoryP = aMemoryP;
1.1085 + EnableDoubleBuffering(aNumBlocks);
1.1086 +
1.1087 + iStackP->UnBlock(this, KMMCBlockOnMoreData, aError == KErrNone ? KMMCErrNone : KMMCErrGeneral);
1.1088 + }
1.1089 +
1.1090 +inline TBool DMMCSession::RequestMoreData()
1.1091 +/**
1.1092 + * Called by the PSL to request the next blocks of data to be transferred from the media driver
1.1093 + * to the PSL. This would typically be called while the hardware is busy transferring the current
1.1094 + * block of data, allowing the media driver to copy data from the client in parallel.
1.1095 + *
1.1096 + * This method will set the state machine to block on KMMCBlockOnMoreData, so the PSL must block
1.1097 + * the state machine using an SMF_WAITS (or equivalent). When the Media Driver has populated the
1.1098 + * next buffer, the current command descriptor will be updated and the state machine unblocked.
1.1099 + *
1.1100 + * @return ETrue if all conditions are met to perform double-buffering (ie - command is enabled
1.1101 + * for double-buffering and the last transfer has not already been satisfied). If
1.1102 + * successful, upon exit the state machine will be blocked with the KMMCBlockOnMOreData
1.1103 + * condition and the Media Driver's data transfer callback invoked.
1.1104 + *
1.1105 + *
1.1106 + */
1.1107 + {
1.1108 + __KTRACE_OPT(KPBUS1, Kern::Printf("++ DMMCSession::RequestMoreData()"));
1.1109 +
1.1110 + if(Command().IsDoubleBuffered() && (Command().iBytesDone + Command().BufferLength() < Command().iTotalLength))
1.1111 + {
1.1112 + iStackP->Block(this, KMMCBlockOnMoreData);
1.1113 + iDataTransferCallback.CallBack();
1.1114 + return(ETrue);
1.1115 + }
1.1116 +
1.1117 + return(EFalse);
1.1118 + }
1.1119 +
1.1120 +
1.1121 +// -------- class DMMCSocket --------
1.1122 +
1.1123 +inline TBool DMMCSocket::SupportsDoubleBuffering()
1.1124 +/**
1.1125 + * @return ETrue If the PSL supports double buffering, as specified by the
1.1126 + * PSL by setting the ESupportsDoubleBuffering flag in ::MachineInfo.
1.1127 + *
1.1128 + * @internalTechnology
1.1129 + */
1.1130 + {
1.1131 + return ((iMachineInfo.iFlags & TMMCMachineInfo::ESupportsDoubleBuffering) ? (TBool)ETrue : (TBool)EFalse);
1.1132 + }
1.1133 +
1.1134 +inline TUint32 DMMCSocket::MaxDataTransferLength()
1.1135 +/**
1.1136 + * @return The maximum length that the PSL supports in a single data transfer.
1.1137 + * Returns Zero if the PSL has no limitation on the maximum length of data transfer.
1.1138 + *
1.1139 + * @internalTechnology
1.1140 + */
1.1141 + {
1.1142 + TUint32 r = (iMachineInfo.iFlags & TMMCMachineInfo::EMaxTransferLength_16M) >> 8;
1.1143 + if (r)
1.1144 + r = 0x20000 << r;
1.1145 +
1.1146 + return r;
1.1147 + }
1.1148 +
1.1149 +inline TUint32 DMMCSocket::DmaAlignment()
1.1150 +/**
1.1151 + * @return Byte alignment required by the DMA Controller.
1.1152 + * e.g. 16 Bit addressing scheme equates to 2 byte alignment.
1.1153 + *
1.1154 + * @internalTechnology
1.1155 + */
1.1156 + {
1.1157 + const TUint32 DmaAddrMsk = TMMCMachineInfo::EDma8BitAddressing |
1.1158 + TMMCMachineInfo::EDma16BitAddressing |
1.1159 + TMMCMachineInfo::EDma32BitAddressing |
1.1160 + TMMCMachineInfo::EDma64BitAddressing;
1.1161 + return ((iMachineInfo.iFlags & DmaAddrMsk) >> 3);
1.1162 + }
1.1163 +
1.1164 +// -------- class DMMCStack --------
1.1165 +
1.1166 +inline void DMMCStack::ReportPowerUp()
1.1167 +/**
1.1168 + * Called by the variant layer to indicate that a
1.1169 + * power up operation has successfully completed.
1.1170 + */
1.1171 + {iPoweredUp = ETrue;}
1.1172 +
1.1173 +inline void DMMCStack::ReportPowerDown()
1.1174 +/**
1.1175 + * Indicates that that power down operation has successfully completed.
1.1176 + * Following power down, the stack enters a state pending the next power up operation.
1.1177 + */
1.1178 + {iPoweredUp = EFalse; iStackState |= KMMCStackStateInitPending;}
1.1179 +
1.1180 +inline void DMMCStack::Reset()
1.1181 +/**
1.1182 + * Resets the stack by aborting all current requests.
1.1183 + */
1.1184 + {iAbortAll = ETrue; Scheduler(iAbortReq);}
1.1185 +
1.1186 +inline void DMMCStack::CompleteAll(TMMCErr aCode)
1.1187 +/**
1.1188 + * Stops and dequeues all sessions queued on this stack (including those queued by other clients).
1.1189 + * Each of the sessions affected will complete immediately with error code 'aCode' (i.e. the session
1.1190 + * end call-back function will be called).
1.1191 + * @param aCode The MMC error code to be returned.
1.1192 + */
1.1193 + {iCompleteAllExitCode = aCode; Scheduler(iCompReq);}
1.1194 +
1.1195 +inline TUint DMMCStack::MaxCardsInStack() const
1.1196 +/**
1.1197 + * Returns the maximum number of MultiMediaCards which could ever be present in this stack.
1.1198 + * i.e. the total number of physical card slots associated with this stack on this platform.
1.1199 + * (This is initialised from the DMMCSocket::TotalSupportedCards)
1.1200 + * @return The number of supported cards.
1.1201 + */
1.1202 + {return( iMaxCardsInStack );}
1.1203 +
1.1204 +inline TMMCard* DMMCStack::CardP(TUint aCardNumber)
1.1205 +/**
1.1206 + * Returns a pointer to the specified card.
1.1207 + * @param aCardNumber The card number.
1.1208 + * @return A pointer to the specified card.
1.1209 + */
1.1210 + {return( (aCardNumber<iMaxCardsInStack) ? (iCardArray->CardP(aCardNumber)) : NULL );}
1.1211 +
1.1212 +inline DMMCSocket* DMMCStack::MMCSocket() const
1.1213 +/**
1.1214 + * Returns a pointer to associated socket object.
1.1215 + * @return A pointer to the associated socket.
1.1216 + */
1.1217 + {return( iSocket );}
1.1218 +
1.1219 +inline TMMCPasswordStore* DMMCStack::PasswordStore() const
1.1220 +/**
1.1221 + * Returns a pointer to the associated password store.
1.1222 + * @return A pointer to the associated password store.
1.1223 + */
1.1224 + {return( iSocket->iPasswordStore );}
1.1225 +
1.1226 +inline TBool DMMCStack::InitStackInProgress() const
1.1227 +/**
1.1228 + * Reports the initialisation state of the stack (i.e is the CIM_INIT_STACK macro in progress).
1.1229 + * @return ETrue if the stack is being initialised, EFalse otherwise.
1.1230 + */
1.1231 + {return( (iStackState & KMMCStackStateInitInProgress) != 0 );}
1.1232 +
1.1233 +inline TBool DMMCStack::HasSessionsQueued() const
1.1234 +/**
1.1235 + * Reports if any of the session queues have submitted session engaged.
1.1236 + * @return ETrue if there are any sessions engaged on this stack, EFalse otherwise.
1.1237 + */
1.1238 + {return((iWorkSet.Size()!=0) || (iReadyQueue.Size()!=0) || (iEntryQueue.Size()!=0));}
1.1239 +
1.1240 +inline TBool DMMCStack::HasCardsPresent()
1.1241 +/**
1.1242 + * Reports if any cards are present on the stack
1.1243 + * @return ETrue if there are any sessions engaged on this stack, EFalse otherwise.
1.1244 + */
1.1245 + {
1.1246 + for (TUint i=0 ; i<iMaxCardsInStack ; i++)
1.1247 + if (CardDetect(i)) return(ETrue);
1.1248 + return(EFalse);
1.1249 + }
1.1250 +
1.1251 +inline TBool DMMCStack::StackRunning() const
1.1252 +/**
1.1253 + * Reports whether the stack is currently running (i.e. running in another context from the caller)
1.1254 + * @return ETrue if the stack is currently running
1.1255 + */
1.1256 + {return( (iStackState & KMMCStackStateRunning) != 0 );}
1.1257 +
1.1258 +inline void DMMCStack::BufferInfo(TUint8*& aBuf, TInt& aBufLen, TInt& aMinorBufLen)
1.1259 +/**
1.1260 + * Calls the variant-layer function GetBufferInfo() to retrieve the DMA-capable buffer start and length
1.1261 + * and then calculates the minor buffer length (which is situated at the start) -
1.1262 + * this is the maximum of a sector size (512 bytes) and the biggest block size of
1.1263 + * any card in the stack.
1.1264 +
1.1265 + * @param aBuf A pointer to the allocated buffer
1.1266 + * @param aBufLen The length of the allocated buffer
1.1267 + * @param aMinorBufLen The length of the minor buffer
1.1268 + */
1.1269 + {
1.1270 + aBuf = iPSLBuf;
1.1271 + aBufLen = iPSLBufLen;
1.1272 + aMinorBufLen = iMinorBufLen;
1.1273 + }
1.1274 +
1.1275 +
1.1276 +inline TInt DMMCStack::DemandPagingInfo(TDemandPagingInfo& aInfo)
1.1277 + {
1.1278 + MDemandPagingInfo* demandPagingInterface = NULL;
1.1279 + GetInterface(KInterfaceDemandPagingInfo, (MInterface*&) demandPagingInterface);
1.1280 + if (demandPagingInterface)
1.1281 + return demandPagingInterface->DemandPagingInfo(aInfo);
1.1282 + else
1.1283 + return KErrNotSupported;
1.1284 + }
1.1285 +
1.1286 +
1.1287 +inline void DMMCStack::CancelSession(DMMCSession* aSession)
1.1288 + {
1.1289 + GetInterface(KInterfaceCancelSession, (MInterface*&) aSession);
1.1290 + }
1.1291 +
1.1292 +inline TRCA DMMCStack::SelectedCard() const
1.1293 +/**
1.1294 + * Returns the Relative Card Address (RCA) of the currently selected card
1.1295 + * @return A TRCA object containing the Relative Card Address.
1.1296 + */
1.1297 + {
1.1298 + return iSelectedCard;
1.1299 + }
1.1300 +
1.1301 +inline TMMCStateMachine& DMMCStack::Machine()
1.1302 +/**
1.1303 + * Returns the current sessions MMC State Machine object.
1.1304 + * @return A TMMCStateMachine reference to the current sessions State Machine object.
1.1305 + */
1.1306 + {return( iSessionP->iMachine );}
1.1307 +
1.1308 +inline TMMCBusConfig& DMMCStack::BusConfig()
1.1309 +/**
1.1310 + * Returns the current bus configuration.
1.1311 + * @return A TMMCBusConfig reference describing current sessions bus configuration.
1.1312 + */
1.1313 + {return( iConfig.iBusConfig );}
1.1314 +
1.1315 +inline TMMCBusConfig& DMMCStack::MasterBusConfig()
1.1316 +/**
1.1317 + * Returns the master bus configuration.
1.1318 + * @return A TMMCBusConfig reference describing the master bus configuration.
1.1319 + */
1.1320 + {return( iMasterConfig.iBusConfig );}
1.1321 +
1.1322 +inline TMMCCommandDesc& DMMCStack::Command()
1.1323 +/**
1.1324 + * Returns the current sessions command description.
1.1325 + * @return A TMMCCommandDesc reference describing current sessions command.
1.1326 + */
1.1327 + {return( iSessionP->Command() );}
1.1328 +
1.1329 +inline DMMCSession& DMMCStack::Session()
1.1330 +/**
1.1331 + * Returns the current session object.
1.1332 + * @return A reference to the current DMMCSession object.
1.1333 + */
1.1334 + {return(*iSessionP);}
1.1335 +
1.1336 +inline void DMMCStack::BlockCurrentSession(TUint32 aFlag)
1.1337 +/**
1.1338 + * Indicates that the current session is to be blocked (ie - waiting on an asynchronous response such as interrupt).
1.1339 + * The state machine will only unblock when an unblock request with the matching argument is called.
1.1340 + * In the PSL level of the Controller you should always use KMMCBlockOnASSPFunction as the argument.
1.1341 + * @param aFlag Bitmask describing the reason for blocking.
1.1342 + */
1.1343 + {Block(iSessionP,aFlag);}
1.1344 +
1.1345 +inline void DMMCStack::UnBlockCurrentSession(TUint32 aFlag, TMMCErr anExitCode)
1.1346 +/**
1.1347 + * Indicates that the current session is to be unblocked (ie - an a asynchronous operation has completed).
1.1348 + * The state machine will only unblock when an unblock request with the matching argument is called.
1.1349 + * @param aFlag Bitmask describing the reason for unblocking.
1.1350 + * @param anExitCode KMMCErrNone if successful, otherwise a standard TMMCErr code.
1.1351 + */
1.1352 + {UnBlock(iSessionP,aFlag,anExitCode);}
1.1353 +
1.1354 +inline void DMMCStack::ReportInconsistentBusState()
1.1355 +/**
1.1356 + * Indicates that something has gone wrong, so the stack needs re-initialising.
1.1357 + */
1.1358 + {iStackState |= KMMCStackStateBusInconsistent;}
1.1359 +
1.1360 +inline void DMMCStack::ReportASSPEngaged()
1.1361 +/**
1.1362 + * Called by the PSL to indicate that a session has been engaged.
1.1363 + */
1.1364 + {iSessionP->iState |= KMMCSessStateASSPEngaged;}
1.1365 +
1.1366 +inline void DMMCStack::ReportASSPDisengaged()
1.1367 +/**
1.1368 + * Called by the PSL to indicate that a session has completed or has been aborted.
1.1369 + */
1.1370 + {iSessionP->iState &= ~KMMCSessStateASSPEngaged;}
1.1371 +
1.1372 +inline TRCA DMMCStack::CurrentSessCardRCA()
1.1373 +/**
1.1374 + * Returns the Relative Card Address (RCA) in use by the current session.
1.1375 + * @return A TRCA object containing the Relative Card Address.
1.1376 + */
1.1377 + {return(iSessionP->CardRCA());}
1.1378 +
1.1379 +
1.1380 +inline TMMCErr DMMCStack::BaseModifyCardCapabilitySMST( TAny* aStackP )
1.1381 + { return( static_cast<DMMCStack *>(aStackP)->DMMCStack::ModifyCardCapabilitySM() ); }
1.1382 +
1.1383 +inline TMMCErr DMMCStack::InitCurrentCardAfterUnlockSMST( TAny* aStackP )
1.1384 + { return( static_cast<DMMCStack *>(aStackP)->DMMCStack::InitStackAfterUnlockSM() ); }
1.1385 +
1.1386 +/**
1.1387 +Increments the current session's command stack pointer.
1.1388 +
1.1389 +@see DMMCSession::PushCommandStack()
1.1390 +*/
1.1391 +inline void DMMCStack::CurrentSessPushCmdStack()
1.1392 + {iSessionP->PushCommandStack();}
1.1393 +
1.1394 +
1.1395 +
1.1396 +/**
1.1397 +Decrements the current session's command stack pointer.
1.1398 +
1.1399 +@see DMMCSession::PopCommandStack()
1.1400 +*/
1.1401 +inline void DMMCStack::CurrentSessPopCmdStack()
1.1402 + {iSessionP->PopCommandStack();}
1.1403 +
1.1404 +/**
1.1405 +Allows the stack to yield to another command temporarily, for one loop of the scheduler only.
1.1406 +
1.1407 +@param aCommandType The command type to yield to.
1.1408 +*/
1.1409 +inline void DMMCStack::YieldStack(TMMCCommandTypeEnum aCommandType)
1.1410 + {
1.1411 + BlockCurrentSession(KMMCBlockOnYielding);
1.1412 + iYieldCommandType = aCommandType;
1.1413 + iStackState |= KMMCStackStateYielding;
1.1414 + }
1.1415 +
1.1416 +
1.1417 +inline void DMMCStack::CurrentSessFillCmdDesc(TMMCCommandEnum aCommand)
1.1418 +/**
1.1419 + * Initialises the current sessions command according to whether it is a normal
1.1420 + * or an application command.
1.1421 + * @param aCommand Contains the command.
1.1422 + */
1.1423 + {iSessionP->FillCommandDesc(aCommand);}
1.1424 +
1.1425 +inline void DMMCStack::CurrentSessFillCmdDesc(TMMCCommandEnum aCommand,TMMCArgument anArgument)
1.1426 +/**
1.1427 + * Initialises the current sessions command with an argument according to whether
1.1428 + * it is a normal or an application command.
1.1429 + * @param aCommand Contains the command.
1.1430 + * @param anArgument Specifies the argument.
1.1431 + */
1.1432 + {iSessionP->FillCommandDesc(aCommand,anArgument);}
1.1433 +
1.1434 +inline void DMMCStack::CurrentSessFillCmdArgs(TMMCArgument anArgument,TUint32 aLength,TUint8* aMemoryP,TUint32 aBlkLen)
1.1435 +/**
1.1436 + * Initialises the current sessions command arguments with the specified parameters
1.1437 + * It is necessary to have set the command arguments with this command prior
1.1438 + * to engaging a read/write macro or command.
1.1439 + * @param anArgument Command specific argument.
1.1440 + * @param aLength aLength Total number of bytes to read/write.
1.1441 + * @param aMemoryP Host source/destination address
1.1442 + * @param aBlkLen Block length
1.1443 + */
1.1444 + {iSessionP->FillCommandArgs(anArgument,aLength,aMemoryP,aBlkLen);}
1.1445 +
1.1446 +inline void DMMCStack::DeselectsToIssue(TUint aNumber)
1.1447 +/**
1.1448 + * Specifies how many deselects to issue during deselection.
1.1449 + * @param aNumber The number of deselects to issue.
1.1450 + */
1.1451 + {iDeselectsToIssue = aNumber; iStackState |= KMMCStackStateDoDeselect;}
1.1452 +
1.1453 +// -------- class DMMCController --------
1.1454 +
1.1455 +inline DMMCStack* DMMCSocket::Stack(TInt aBus)
1.1456 +/**
1.1457 + * Returns a pointer to the DMMCStack object corresponding to the specified MMC card.
1.1458 + * @param aBus The MMC card number.
1.1459 + * @return A pointer to the DMMCStack object corresponding to the specified card.
1.1460 + */
1.1461 + {return( ((TInt)aBus < iMachineInfo.iTotalSockets) ? iStack : NULL );}
1.1462 +
1.1463 +inline void DMMCSocket::ResetInactivity(TInt /*aBus*/)
1.1464 +/**
1.1465 + * Resets the sockets PSU inactivity timer.
1.1466 + * Commonly used to prevent reset due to inactivity
1.1467 + * while waiting for a response from the card.
1.1468 + * @param aBus Unused
1.1469 + */
1.1470 + {
1.1471 + iVcc->ResetInactivityTimer();
1.1472 + if (iVccCore)
1.1473 + iVccCore->ResetInactivityTimer();
1.1474 + }
1.1475 +
1.1476 +inline const TMMCMachineInfo& DMMCSocket::MachineInfo() const
1.1477 +/**
1.1478 + * Returns a reference to the MachineInfo retrieved from the PSL
1.1479 + * @return a reference to the MachineInfo
1.1480 + */
1.1481 + {return iMachineInfo;}
1.1482 +
1.1483 +// -------- class TMMCPsu --------
1.1484 +
1.1485 +inline void DMMCPsu::SetVoltage(TUint32 aVoltage)
1.1486 +/**
1.1487 + * Specifies the voltage setting to be used when the stack is next powered up.
1.1488 + * @param aVoltage The required voltage setting, in OCR register format.
1.1489 + */
1.1490 + {iVoltageSetting=aVoltage;}
1.1491 +
1.1492 +// -------- Class TMMCCallBack --------
1.1493 +/**
1.1494 + * Default constructor. Initializes the pointer to the callback function to NULL.
1.1495 + * @see iFunction
1.1496 + */
1.1497 +inline TMMCCallBack::TMMCCallBack()
1.1498 + {iFunction=NULL;}
1.1499 +
1.1500 +/**
1.1501 + * Constructs the TMMCCallBack object with the specified callback function.
1.1502 + * @param aFunction Callback notification function.
1.1503 + */
1.1504 +inline TMMCCallBack::TMMCCallBack(void (*aFunction)(TAny *aPtr))
1.1505 + : iFunction(aFunction),iPtr(NULL)
1.1506 + {}
1.1507 +/**
1.1508 + * Constructs the TMMCCallBack object with the specified callback function and a pointer to any object.
1.1509 + * @param aFunction Callback notification function.
1.1510 + * @param aPtr Pointer to any data.
1.1511 + */
1.1512 +inline TMMCCallBack::TMMCCallBack(void (*aFunction)(TAny *aPtr),TAny *aPtr)
1.1513 + : iFunction(aFunction),iPtr(aPtr)
1.1514 + {}
1.1515 +/**
1.1516 + * Calls the registered callback function.
1.1517 + */
1.1518 +inline void TMMCCallBack::CallBack() const
1.1519 + { if(iFunction) (*iFunction)(iPtr); }
1.1520 +
1.1521 +// -------- class TMMCEraseInfo --------
1.1522 +
1.1523 +inline TBool TMMCEraseInfo::EraseClassCmdsSupported() const
1.1524 +/**
1.1525 + * Returns ETrue if Erase Class commands are supported.
1.1526 + * @return ETrue if Erase Class commands are supported.
1.1527 + */
1.1528 + {return(iEraseFlags&KMMCEraseClassCmdsSupported);}
1.1529 +
1.1530 +inline TBool TMMCEraseInfo::EraseGroupCmdsSupported() const
1.1531 +/**
1.1532 + * Returns ETrue if Erase Group commands are supported.
1.1533 + * @return ETrue if Erase Group commands are supported.
1.1534 + */
1.1535 + {return(iEraseFlags&KMMCEraseGroupCmdsSupported);}