author | hgs |
Fri, 23 Apr 2010 22:20:31 +0100 | |
changeset 123 | fc55edbf3919 |
parent 33 | 0173bcd7697c |
child 110 | c734af59ce98 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// |
|
15 |
// WARNING: This file contains some APIs which are internal and are subject |
|
16 |
// to change without noticed. Such APIs should therefore not be used |
|
17 |
// outside the Kernel and Hardware Services package. |
|
18 |
// |
|
19 |
||
20 |
/** |
|
21 |
||
22 |
A static function that takes the 4 bytes that are stored in a memory location |
|
23 |
in ascending address order, and returns them as a 32-bit unsigned integer |
|
24 |
in big-endian format. |
|
25 |
||
26 |
@param aPtr A pointer to the memory location containing the 4 bytes to be stored. |
|
27 |
||
28 |
@return A 32 bit unsigned integer containing the 4 bytes in big-endian format. |
|
29 |
*/ |
|
30 |
inline TUint32 TMMC::BigEndian32(const TUint8* aPtr) |
|
31 |
{return( (aPtr[0]<<24) | (aPtr[1]<<16) | (aPtr[2]<<8) | (aPtr[3]) );} |
|
32 |
||
33 |
||
34 |
||
35 |
||
36 |
/** |
|
37 |
A static function that takes the specified 32-bit unsigned integer, assumed to |
|
38 |
be in big-endian format, and stores this into the specified memory location. |
|
39 |
||
40 |
@param aPtr A pointer to a 4 byte memory location which is to contain |
|
41 |
the unsigned integer. |
|
42 |
@param aVal A 32 bit unsigned integer in big-endian format. |
|
43 |
*/ |
|
44 |
inline void TMMC::BigEndian4Bytes(TUint8* aPtr, TUint32 aVal) |
|
45 |
{ |
|
46 |
aPtr[0] = (TUint8)(aVal >> 24); |
|
47 |
aPtr[1] = (TUint8)(aVal >> 16); |
|
48 |
aPtr[2] = (TUint8)(aVal >> 8); |
|
49 |
aPtr[3] = (TUint8)aVal; |
|
50 |
} |
|
51 |
||
52 |
||
53 |
||
54 |
||
55 |
// -------- class TCID -------- |
|
56 |
||
57 |
inline TCID::TCID(const TUint8* aPtr) |
|
58 |
{memcpy(&iData[0], aPtr, KMMCCIDLength);} |
|
59 |
||
60 |
inline TCID& TCID::operator=(const TCID& aCID) |
|
61 |
{memcpy(&iData[0], &aCID.iData[0], KMMCCIDLength); return(*this);} |
|
62 |
||
63 |
inline TCID& TCID::operator=(const TUint8* aPtr) |
|
64 |
{memcpy(&iData[0], aPtr, KMMCCIDLength); return(*this);} |
|
65 |
||
66 |
inline TBool TCID::operator==(const TCID& aCID) const |
|
67 |
{return(memcompare(&iData[0],KMMCCIDLength,&aCID.iData[0],KMMCCIDLength)==0);} |
|
68 |
||
69 |
inline TBool TCID::operator==(const TUint8* aPtr) const |
|
70 |
{return(memcompare(&iData[0],KMMCCIDLength,aPtr,KMMCCIDLength)==0);} |
|
71 |
||
72 |
inline void TCID::Copy(TUint8* aPtr) const |
|
73 |
{memcpy(aPtr, &iData[0], KMMCCIDLength);} |
|
74 |
||
75 |
inline TUint8 TCID::At(TUint anIndex) const |
|
76 |
{return(iData[KMMCCIDLength-1-anIndex]);} |
|
77 |
||
78 |
// -------- class TCSD -------- |
|
79 |
||
80 |
inline TCSD::TCSD(const TUint8* aPtr) |
|
81 |
{memcpy(&iData[0], aPtr, KMMCCSDLength);} |
|
82 |
||
83 |
inline TCSD& TCSD::operator=(const TCSD& aCSD) |
|
84 |
{memcpy(&iData[0], &aCSD.iData[0], KMMCCSDLength); return(*this);} |
|
85 |
||
86 |
inline TCSD& TCSD::operator=(const TUint8* aPtr) |
|
87 |
{memcpy(&iData[0], aPtr, KMMCCSDLength); return(*this);} |
|
88 |
||
89 |
inline void TCSD::Copy(TUint8* aPtr) const |
|
90 |
{memcpy(aPtr, &iData[0], KMMCCSDLength);} |
|
91 |
||
92 |
inline TUint8 TCSD::At(TUint anIndex) const // anIndex byte in little-endian format |
|
93 |
{return(iData[KMMCCSDLength-1-anIndex]);} |
|
94 |
||
95 |
// Raw field accessors. Encoded values such as memory capacity are calulated in |
|
96 |
// non-inline functions defined in ps_mmc.cpp. |
|
97 |
||
98 |
inline TUint TCSD::CSDStructure() const {return( CSDField(127,126) );} |
|
99 |
inline TUint TCSD::SpecVers() const {return( CSDField(125,122) );} |
|
100 |
inline TUint TCSD::Reserved120() const {return( CSDField(121,120) );} |
|
101 |
inline TUint TCSD::TAAC() const {return( CSDField(119,112) );} |
|
102 |
inline TUint TCSD::NSAC() const {return( CSDField(111,104) );} |
|
103 |
inline TUint TCSD::TranSpeed() const {return( CSDField(103,96) );} |
|
104 |
inline TUint TCSD::CCC() const {return( CSDField(95,84) );} |
|
105 |
inline TUint TCSD::ReadBlLen() const {return( CSDField(83,80) );} |
|
106 |
inline TBool TCSD::ReadBlPartial() const {return( CSDField(79,79) );} |
|
107 |
inline TBool TCSD::WriteBlkMisalign() const {return( CSDField(78,78) );} |
|
108 |
inline TBool TCSD::ReadBlkMisalign() const {return( CSDField(77,77) );} |
|
109 |
inline TBool TCSD::DSRImp() const {return( CSDField(76,76) );} |
|
110 |
inline TUint TCSD::Reserved74() const {return( CSDField(75,74) );} |
|
111 |
inline TUint TCSD::CSize() const {return( CSDField(73,62) );} |
|
112 |
inline TUint TCSD::VDDRCurrMin() const {return( CSDField(61,59) );} |
|
113 |
inline TUint TCSD::VDDRCurrMax() const {return( CSDField(58,56) );} |
|
114 |
inline TUint TCSD::VDDWCurrMin() const {return( CSDField(55,53) );} |
|
115 |
inline TUint TCSD::VDDWCurrMax() const {return( CSDField(52,50) );} |
|
116 |
inline TUint TCSD::CSizeMult() const {return( CSDField(49,47) );} |
|
117 |
||
118 |
inline TUint TCSD::EraseGrpSize() const {return( CSDField(46,42) );} |
|
119 |
inline TUint TCSD::EraseGrpMult() const {return( CSDField(41,37) );} |
|
120 |
inline TUint TCSD::WPGrpSize() const {return( CSDField(36,32) );} |
|
121 |
||
122 |
inline TBool TCSD::WPGrpEnable() const {return( CSDField(31,31) );} |
|
123 |
inline TUint TCSD::DefaultECC() const {return( CSDField(30,29) );} |
|
124 |
inline TUint TCSD::R2WFactor() const {return( CSDField(28,26) );} |
|
125 |
inline TUint TCSD::WriteBlLen() const {return( CSDField(25,22) );} |
|
126 |
inline TBool TCSD::WriteBlPartial() const {return( CSDField(21,21) );} |
|
127 |
inline TUint TCSD::Reserved16() const {return( CSDField(20,16) );} |
|
128 |
inline TBool TCSD::FileFormatGrp() const {return( CSDField(15,15) );} |
|
129 |
inline TBool TCSD::Copy() const {return( CSDField(14,14) );} |
|
130 |
inline TBool TCSD::PermWriteProtect() const {return( CSDField(13,13) );} |
|
131 |
inline TBool TCSD::TmpWriteProtect() const {return( CSDField(12,12) );} |
|
132 |
inline TUint TCSD::FileFormat() const {return( CSDField(11,10) );} |
|
133 |
inline TUint TCSD::ECC() const {return( CSDField(9,8) );} |
|
134 |
inline TUint TCSD::CRC() const {return( CSDField(7,1) );} |
|
135 |
||
136 |
// -------- class TExtendedCSD -------- |
|
137 |
||
138 |
inline TExtendedCSD::TExtendedCSD() // Default constructor |
|
139 |
{} |
|
140 |
||
141 |
inline TExtendedCSD::TExtendedCSD(const TUint8* aPtr) |
|
142 |
{memcpy(&iData[0], aPtr, KMMCExtendedCSDLength);} |
|
143 |
||
144 |
inline TExtendedCSD& TExtendedCSD::operator=(const TExtendedCSD& aCSD) |
|
145 |
{memcpy(&iData[0], &aCSD.iData[0], KMMCExtendedCSDLength); return(*this);} |
|
146 |
||
147 |
inline TExtendedCSD& TExtendedCSD::operator=(const TUint8* aPtr) |
|
148 |
{memcpy(&iData[0], aPtr, KMMCExtendedCSDLength); return(*this);} |
|
149 |
||
150 |
inline TMMCArgument TExtendedCSD::GetWriteArg(TExtCSDAccessBits aAccess, TExtCSDModesFieldIndex aIndex, TUint aValue, TUint aCmdSet) |
|
151 |
{return TMMCArgument((aAccess << 24) | (aIndex << 16) | (aValue << 8) | (aCmdSet));} |
|
152 |
||
153 |
inline TUint8* TExtendedCSD::Ptr() {return &iData[0];} |
|
154 |
||
155 |
// Raw field accessors. |
|
156 |
// "Properties Segment" of Extended CSD - i.e. read-only fields |
|
157 |
inline TUint TExtendedCSD::SupportedCmdSet() const {return iData[504];} |
|
158 |
inline TUint TExtendedCSD::SectorCount() const {return(iData[212] | ((TUint)iData[213] << 8) | ((TUint)iData[214] << 16) | ((TUint)iData[215] << 24));} |
|
159 |
inline TUint TExtendedCSD::MinPerfWrite8Bit52Mhz() const {return iData[210];} |
|
160 |
inline TUint TExtendedCSD::MinPerfRead8Bit52Mhz() const {return iData[209];} |
|
161 |
inline TUint TExtendedCSD::MinPerfWrite8Bit26Mhz_4Bit52Mhz() const {return iData[208];} |
|
162 |
inline TUint TExtendedCSD::MinPerfRead8Bit26Mhz_4Bit52Mhz() const {return iData[207];} |
|
163 |
inline TUint TExtendedCSD::MinPerfWrite4Bit26Mhz() const {return iData[206];} |
|
164 |
inline TUint TExtendedCSD::MinPerfRead4Bit26Mhz() const {return iData[205];} |
|
165 |
inline TUint TExtendedCSD::PowerClass26Mhz360V() const {return iData[203];} |
|
166 |
inline TUint TExtendedCSD::PowerClass52Mhz360V() const {return iData[202];} |
|
167 |
inline TUint TExtendedCSD::PowerClass26Mhz195V() const {return iData[201];} |
|
168 |
inline TUint TExtendedCSD::PowerClass52Mhz195V() const {return iData[200];} |
|
169 |
inline TUint TExtendedCSD::CardType() const {return iData[196];} |
|
170 |
inline TUint TExtendedCSD::CSDStructureVer() const {return iData[194];} |
|
171 |
inline TUint TExtendedCSD::ExtendedCSDRev() const {return iData[EExtendedCSDRevIndex];} |
|
172 |
inline TUint TExtendedCSD::AccessSize() const {return iData[EAccessSizeIndex];} |
|
173 |
inline TUint TExtendedCSD::HighCapacityEraseGroupSize() const {return iData[EHighCapacityEraseGroupSizeIndex];} |
|
174 |
inline TUint TExtendedCSD::BootInfo() const {return iData[228];} |
|
175 |
inline TUint TExtendedCSD::BootSizeMultiple() const {return iData[226];} |
|
176 |
inline TUint TExtendedCSD::EraseTimeoutMultiple() const {return iData[223];} |
|
177 |
inline TUint TExtendedCSD::ReliableWriteSector() const {return iData[222];} |
|
178 |
inline TUint TExtendedCSD::HighCapacityWriteProtectGroupSize() const {return iData[221];} |
|
179 |
inline TUint TExtendedCSD::SleepCurrentVcc() const {return iData[220];} |
|
180 |
inline TUint TExtendedCSD::SleepCurrentVccQ() const {return iData[219];} |
|
181 |
inline TUint TExtendedCSD::SleepAwakeTimeout() const {return iData[217];} |
|
182 |
||
183 |
// "Modes Segment" of Extended CSD - i.e. modifiable fields |
|
184 |
inline TUint TExtendedCSD::CmdSet() const {return iData[ECmdSetIndex];} |
|
185 |
inline TUint TExtendedCSD::CmdSetRev() const {return iData[ECmdSetRevIndex];} |
|
186 |
inline TUint TExtendedCSD::PowerClass() const {return iData[EPowerClassIndex];} |
|
187 |
inline TUint TExtendedCSD::HighSpeedTiming() const {return iData[EHighSpeedInterfaceTimingIndex];} |
|
188 |
inline TUint TExtendedCSD::BusWidthMode() const {return iData[EBusWidthModeIndex];} |
|
189 |
inline TUint TExtendedCSD::BootConfig() const {return iData[EBootConfigIndex];} |
|
190 |
inline TUint TExtendedCSD::BootBusWidth() const {return iData[EBootBusWidthIndex];} |
|
191 |
inline TUint TExtendedCSD::EraseGroupDef() const {return iData[EEraseGroupDefIndex];} |
|
192 |
||
193 |
// -------- class TMMCStatus -------- |
|
194 |
/** |
|
195 |
* Constructor for TMMCStatus. |
|
196 |
* @param aPtr A pointer to the memory location containing the 4 bytes to be stored. |
|
197 |
The 4 bytes corresponds to MMC card response. Refer to the MMC card specification for the possible values of response. |
|
198 |
*/ |
|
199 |
inline TMMCStatus::TMMCStatus(const TUint8* aPtr) : iData(TMMC::BigEndian32(aPtr)) {} |
|
200 |
||
201 |
/** |
|
202 |
* constructs the TMMCStatus object with value corresponding to MMC status register. |
|
203 |
* @param aData Value corresponding to MMC status register. |
|
204 |
*/ |
|
205 |
inline TMMCStatus::TMMCStatus(const TUint32& aData) : iData(aData) {} |
|
206 |
||
207 |
/** |
|
208 |
* Gets the bitfield(32 bits) representing the MMC status register. |
|
209 |
* @return Value corresponding to MMC status register. |
|
210 |
*/ |
|
211 |
inline TMMCStatus::operator TUint32() const {return(iData);} |
|
212 |
||
213 |
/** |
|
214 |
* Gets the error status. |
|
215 |
* For the possible values, refer to the MMC card R1 Response. |
|
216 |
* @see DMMCStack |
|
217 |
* @return MMC card error status. |
|
218 |
*/ |
|
219 |
inline TUint32 TMMCStatus::Error() const { return(iData & KMMCStatErrorMask); } |
|
220 |
||
221 |
/** |
|
222 |
* Gets the MMC card's current state machine. |
|
223 |
* For the possible values of the state machine, refer to the MMC card specification. |
|
224 |
* @return The current state of the state machine. |
|
225 |
*/ |
|
226 |
inline TMMCardStateEnum TMMCStatus::State() const |
|
227 |
{ return((TMMCardStateEnum)(iData & KMMCStatCurrentStateMask)); } |
|
228 |
||
229 |
/** |
|
230 |
* Replace the MMC card's current state with supplied value |
|
231 |
* @param aState The new MMC card State |
|
232 |
*/ |
|
233 |
inline void TMMCStatus::UpdateState(TMMCardStateEnum aState) |
|
234 |
{ |
|
235 |
iData &= ~KMMCStatCurrentStateMask; |
|
236 |
iData |= aState; |
|
237 |
} |
|
238 |
||
239 |
||
240 |
// -------- class TMMCArgument -------- |
|
241 |
||
242 |
inline TMMCArgument::TMMCArgument() |
|
243 |
/** |
|
244 |
* Default constructor |
|
245 |
* Initialises the argument to zero. |
|
246 |
*/ |
|
247 |
{} |
|
248 |
||
249 |
inline TMMCArgument::TMMCArgument(const TUint32& aData) |
|
250 |
: iData(aData) |
|
251 |
/** |
|
252 |
* Constructs a TMMCArgument with a 32-bit parameter. |
|
253 |
* @param aData The 32-bit parameter. |
|
254 |
*/ |
|
255 |
{} |
|
256 |
||
257 |
inline TMMCArgument::TMMCArgument(TRCA anRCA) : iData(TUint(anRCA)<<16) |
|
258 |
/** |
|
259 |
* Constructs a TMMCArgument with a Relative Card Address (RCA). |
|
260 |
* @param anRCA The RCA. |
|
261 |
*/ |
|
262 |
{} |
|
263 |
inline TMMCArgument::TMMCArgument(TDSR aDSR) : iData(TUint(aDSR)<<16) |
|
264 |
/** |
|
265 |
* Constructs a TMMCArgument with a Driver Stage Register (DSR). |
|
266 |
* @param aDSR The DSR. |
|
267 |
*/ |
|
268 |
{} |
|
269 |
||
270 |
inline TMMCArgument::operator TUint32() const |
|
271 |
/** |
|
272 |
* Converts the TMMCArgument to it's raw 32-bit representation. |
|
273 |
* @return Raw 32-bit argument data |
|
274 |
*/ |
|
275 |
{return(iData);} |
|
276 |
||
277 |
inline void TMMCArgument::SetRCA(TRCA anRCA) |
|
278 |
/** |
|
279 |
* Sets the Relative Card Address |
|
280 |
* @param anRCA The RCA. |
|
281 |
*/ |
|
282 |
{iData=(iData&0xFFFF)|(TUint(anRCA)<<16);} |
|
283 |
||
284 |
// -------- class TRCA -------- |
|
285 |
||
286 |
inline TRCA::TRCA(TUint16 aData) : iData(aData) |
|
287 |
/** |
|
288 |
* Constructs a TRCA with a 16-bit RCA. |
|
289 |
* @param aData The 16-bit RCA. |
|
290 |
*/ |
|
291 |
{} |
|
292 |
||
293 |
inline TRCA::TRCA(TInt aData) : iData(static_cast<TUint16>(aData)) |
|
294 |
/** |
|
295 |
* Constructs a TRCA with a parameter of type TInt. |
|
296 |
* @param aData The TInt parameter. |
|
297 |
*/ |
|
298 |
{} |
|
299 |
||
300 |
inline TRCA::TRCA(TMMCArgument aData) |
|
301 |
/** |
|
302 |
* Constructs a TRCA with a TMMCArgument containing a RCA. |
|
303 |
* @param aData The argument containing the RCA. |
|
304 |
*/ |
|
305 |
{iData=(TUint16)((TUint32(aData)>>16)&0xFFFF);} |
|
306 |
||
307 |
inline TRCA::operator TUint16() const |
|
308 |
/** |
|
309 |
* Converts the TRCA to it's raw 16-bit representation. |
|
310 |
* @return Raw 16-bit RCA |
|
311 |
*/ |
|
312 |
{return(iData);} |
|
313 |
||
314 |
// -------- class TDSR -------- |
|
315 |
||
316 |
inline TDSR::TDSR() |
|
317 |
/** |
|
318 |
* Default constructor. |
|
319 |
* Initialises the DRS to zero |
|
320 |
*/ |
|
321 |
{} |
|
322 |
||
323 |
inline TDSR::TDSR(TUint16 aData) : iData(aData) |
|
324 |
/** |
|
325 |
* Constructs a TDSR with a 16-bit DSR. |
|
326 |
* @param aData The 16-bit DSR. |
|
327 |
*/ |
|
328 |
{} |
|
329 |
||
330 |
inline TDSR::operator TUint16() const |
|
331 |
/** |
|
332 |
* Converts the TDSR to it's raw 16-bit representation. |
|
333 |
* @return Raw 16-bit DSR |
|
334 |
*/ |
|
335 |
{return(iData);} |
|
336 |
||
337 |
||
338 |
// -------- class TMMCard -------- |
|
339 |
inline TBool TMMCard::IsHighCapacity() const { return (iFlags & KMMCardIsHighCapacity) != 0; } |
|
340 |
||
341 |
inline TBool TMMCard::IsPresent() const |
|
342 |
// |
|
343 |
// If the card is present, its index shows the card number + 1 |
|
344 |
// |
|
345 |
{return( iIndex != 0 );} |
|
346 |
||
347 |
inline TInt TMMCard::Number() const {return( iIndex - 1 );} |
|
348 |
inline TMMCMediaTypeEnum TMMCard::MediaType() const {return(iCSD.MediaType());} |
|
349 |
inline const TCID& TMMCard::CID() const {return(iCID);} |
|
350 |
inline const TCSD& TMMCard::CSD() const {return(iCSD);} |
|
351 |
inline const TExtendedCSD& TMMCard::ExtendedCSD() const {return(iExtendedCSD);} |
|
352 |
inline TRCA TMMCard::RCA() const {return(iRCA);} |
|
353 |
inline TBool TMMCard::HasPassword() const {return(iFlags&KMMCardHasPassword);} |
|
354 |
inline TBool TMMCard::IsWriteProtected() const {return(iFlags&KMMCardIsWriteProtected);} |
|
355 |
||
356 |
inline TUint TMMCard::DeviceSize() const |
|
357 |
{ |
|
358 |
TInt64 capacity = DeviceSize64(); |
|
359 |
return(capacity > KMaxTInt ? KMaxTInt : I64LOW(capacity)); |
|
360 |
} |
|
361 |
||
362 |
/** |
|
363 |
Gets the bus width setting for this card. |
|
364 |
Note returned value may differ from current host controller bus width setting. |
|
365 |
returns 1, 4 or 8 |
|
366 |
*/ |
|
367 |
inline TInt TMMCard::BusWidth() const |
|
368 |
{return iBusWidth;} |
|
369 |
||
370 |
/** |
|
371 |
Sets the bus width setting for this card. |
|
372 |
Note this buswidth will not be applied to the host controller and is only used for recording. |
|
373 |
||
374 |
@param aBusWidth the bus width to set - valid values are 1, 4 or 8 |
|
375 |
*/ |
|
376 |
inline void TMMCard::SetBusWidth(TInt aBusWidth) |
|
377 |
{iBusWidth=aBusWidth;} |
|
378 |
||
379 |
inline void TMMCard::SetHighSpeedClock(TUint32 aHighSpeedClock) |
|
380 |
{iHighSpeedClock = aHighSpeedClock;} |
|
381 |
inline TUint32 TMMCard::HighSpeedClock() const |
|
382 |
{return iHighSpeedClock;} |
|
383 |
||
384 |
// -------- class TMMCardArray -------- |
|
385 |
||
386 |
inline TMMCardArray::TMMCardArray(DMMCStack* anOwningStack) |
|
387 |
{iOwningStack=anOwningStack;} |
|
388 |
inline TUint TMMCardArray::NewCardCount() |
|
389 |
{return(iNewCardsCount);} |
|
390 |
inline TInt TMMCardArray::CardsPresent() |
|
391 |
{return(iCardsPresent);} |
|
392 |
inline TMMCard* TMMCardArray::NewCardP(TUint aNewCardNumber) |
|
393 |
{return(iNewCards[aNewCardNumber]);} |
|
394 |
inline TMMCard* TMMCardArray::CardP(TUint aCardNumber) |
|
395 |
{return(iCards[aCardNumber]);} |
|
396 |
inline TMMCard& TMMCardArray::NewCard(TUint aCardNumber) |
|
397 |
{return *iNewCards[aCardNumber];} |
|
398 |
inline TMMCard& TMMCardArray::Card(TUint aCardNumber) |
|
399 |
{return *iCards[aCardNumber];} |
|
400 |
||
401 |
// -------- class TMMCCommandDesc -------- |
|
402 |
||
403 |
inline TBool TMMCCommandDesc::IsBlockCmd() const |
|
404 |
{ return ((iFlags & KMMCCmdFlagBlockAddress) != 0); } |
|
405 |
||
406 |
inline TUint32 TMMCCommandDesc::NumBlocks() const |
|
407 |
{ return iTotalLength / BlockLength(); } |
|
408 |
||
409 |
inline TInt64 TMMCCommandDesc::Arg64() const |
|
410 |
{ return IsBlockCmd()? ((TInt64)(TUint32)iArgument) << KMMCardHighCapBlockSizeLog2 : (TInt64)(TUint32)iArgument; } |
|
411 |
||
412 |
inline TBool TMMCCommandDesc::IsDoubleBuffered() const |
|
413 |
{ return ((iFlags & KMMCCmdFlagDoubleBuffer) != 0); } |
|
414 |
||
415 |
inline TBool TMMCCommandDesc::IsPhysicalAddress() const |
|
416 |
{ return ((iFlags & KMMCCmdFlagPhysAddr) != 0); } |
|
417 |
||
418 |
/** |
|
419 |
Returns the buffer length in bytes. If the current request is double-buffered, |
|
420 |
this returns the amount of data available in the currently active buffer. |
|
421 |
If the command is not double-buffered, the total amount of data to be transferred is returned. |
|
422 |
||
423 |
@return Buffer length in bytes |
|
424 |
*/ |
|
425 |
inline TUint32 TMMCCommandDesc::BufferLength() const |
|
426 |
{ return (IsDoubleBuffered() ? (iBlockLength >> 16) << KMMCardHighCapBlockSizeLog2 : iTotalLength); } |
|
427 |
||
428 |
inline TUint32 TMMCCommandDesc::BlockLength() const |
|
429 |
{ return (IsDoubleBuffered() ? (iBlockLength & 0x0000FFFF) : iBlockLength); } |
|
430 |
||
431 |
// -------- class TMMCStackConfig -------- |
|
432 |
||
433 |
inline TMMCStackConfig::TMMCStackConfig() : iUpdateMask(0), iClientMask(0) |
|
434 |
/** |
|
435 |
* Constructor for a TMMCStackConfig object. |
|
436 |
*/ |
|
437 |
{} |
|
438 |
||
439 |
inline void TMMCStackConfig::SetMode(TUint32 aMask) |
|
440 |
/** |
|
441 |
* Enable a single mode or a set of modes. |
|
442 |
* Enabled modes should be considered by the Controller as effective. However, client mode |
|
443 |
* settings may be overridden by master settings. |
|
444 |
* @param aMask The mode(s) to be set. |
|
445 |
*/ |
|
446 |
{iModes |= aMask; iUpdateMask |= aMask;} |
|
447 |
||
448 |
inline void TMMCStackConfig::RemoveMode(TUint32 aMask) |
|
449 |
/** |
|
450 |
* Disable a single mode or a set of modes. |
|
451 |
* Disabled modes should be considered by the Controller as not in effect. However, client mode |
|
452 |
* settings may be overridden by master settings. |
|
453 |
* @param aMask The mode(s) to be removed. |
|
454 |
*/ |
|
455 |
{iModes &= ~aMask; iUpdateMask |= aMask;} |
|
456 |
||
457 |
inline void TMMCStackConfig::UseDefault(TUint32 aMask) |
|
458 |
/** |
|
459 |
* Restore a single mode or a set of modes to the default setting setting for the platform. |
|
460 |
* @param aMask The mode(s) to be restored. |
|
461 |
*/ |
|
462 |
{iUpdateMask &= ~aMask; iClientMask &= ~aMask;} |
|
463 |
||
464 |
inline void TMMCStackConfig::SetPollAttempts(TUint aData) |
|
465 |
/** |
|
466 |
* Set the number of attempts the Controller is allowed to make to recover on busy timeout during writes to the card. |
|
467 |
* The default setting for this is KMMCMaxPollAttempts (i.e. 5). |
|
468 |
* @param aData The number of attempts to make to recover on busy timeout during write |
|
469 |
*/ |
|
470 |
{iPollAttempts=aData; iClientMask |= KMMCModeClientPollAttempts; } |
|
471 |
||
472 |
inline void TMMCStackConfig::SetOpCondBusyTimeout(TUint16 aData) |
|
473 |
/** |
|
474 |
* Set the number of attempts the Controller is allowed to make to recover on busy timeout |
|
475 |
* while waiting for a card which is slow to power up during stack initialisation. The default setting |
|
476 |
* for this is KMMCMaxOpCondBusyTimeout (i.e. 100). |
|
477 |
* @param aData The number of attempts to make to recover on busy timeout during power up |
|
478 |
*/ |
|
479 |
{iOpCondBusyTimeout=aData; iClientMask |= KMMCModeClientiOpCondBusyTimeout; } |
|
480 |
||
481 |
inline TInt TMMCStackConfig::OpCondBusyTimeout() |
|
482 |
/** |
|
483 |
* Return the number of attempts the Controller is allowed to make to recover on busy timeout |
|
484 |
* while waiting for a card which is slow to power up during stack initialisation. |
|
485 |
* @return The number of attempts to make to recover on busy timeout |
|
486 |
*/ |
|
487 |
{return((TInt)iOpCondBusyTimeout);} |
|
488 |
||
489 |
inline void TMMCStackConfig::SetTimeOutRetries(TUint aData) |
|
490 |
/** |
|
491 |
* Set the number of auto reties the Controller is allowed to make on command response time-out or data |
|
492 |
* block receive timeout situations. The default setting for this is KMMCMaxTimeOutRetries (i.e. 1). |
|
493 |
* @param aData The number of auto reties to make on command response time-out or data block receive timeout condition. |
|
494 |
*/ |
|
495 |
{iTimeOutRetries=aData; iClientMask |= KMMCModeClientTimeOutRetries; } |
|
496 |
||
497 |
inline void TMMCStackConfig::SetCRCRetries(TUint aData) |
|
498 |
/** |
|
499 |
* Set the number of auto reties the Controller is allowed to make on CRC error situations. |
|
500 |
* The default setting for this is KMMCMaxCRCRetries (i.e. 1). |
|
501 |
* @param aData The number of auto reties to make on a CRC error condition. |
|
502 |
*/ |
|
503 |
{iCRCRetries=aData; iClientMask |= KMMCModeClientCRCRetries; } |
|
504 |
||
505 |
inline void TMMCStackConfig::SetBusClockInKhz(TUint aData) |
|
506 |
/** |
|
507 |
* Set the bus clock speed in kilohertz. |
|
508 |
* The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults). |
|
509 |
* @param aData The bus clock speed in kilohertz |
|
510 |
*/ |
|
511 |
{iBusConfig.iBusClock=aData; iClientMask |= KMMCModeClientBusClock; } |
|
512 |
||
513 |
inline void TMMCStackConfig::SetTicksClockIn(TUint aData) |
|
514 |
/** |
|
515 |
* Set the number of clock ticks in the ClockIn phase to be used. |
|
516 |
* The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults). |
|
517 |
* @param aData The number of clock ticks in the ClockIn phase |
|
518 |
*/ |
|
519 |
{iBusConfig.iClockIn=aData; iClientMask |= KMMCModeClientClockIn; } |
|
520 |
||
521 |
inline void TMMCStackConfig::SetTicksClockOut(TUint aData) |
|
522 |
/** |
|
523 |
* Set the number of clock ticks in the ClockOut phase to be used. |
|
524 |
* The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults). |
|
525 |
* @param aData The number of clock ticks in the ClockOut phase |
|
526 |
*/ |
|
527 |
{iBusConfig.iClockOut=aData; iClientMask |= KMMCModeClientClockOut; } |
|
528 |
||
529 |
inline void TMMCStackConfig::SetResponseTimeOutInTicks(TUint aData) |
|
530 |
/** |
|
531 |
* Set the response timeout value to be used (in bus clock ticks). |
|
532 |
* If a command response is not received within this period then the Controller will either retry or return an error. |
|
533 |
* The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults). |
|
534 |
* @param aData The response timeout in bus clock ticks |
|
535 |
*/ |
|
536 |
{iBusConfig.iResponseTimeOut=aData; iClientMask |= KMMCModeClientResponseTimeOut; } |
|
537 |
||
538 |
inline void TMMCStackConfig::SetDataTimeOutInMcs(TUint aData) |
|
539 |
/** |
|
540 |
* Set the data timeout value to be used (in microseconds). |
|
541 |
* If an expected data block is not received from the card within this period then the Controller will |
|
542 |
* either retry or return an error. |
|
543 |
* The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults). |
|
544 |
* @param aData The data timeout in microseconds |
|
545 |
*/ |
|
546 |
{iBusConfig.iDataTimeOut=aData; iClientMask |= KMMCModeClientDataTimeOut; } |
|
547 |
||
548 |
inline void TMMCStackConfig::SetBusyTimeOutInMcs(TUint aData) |
|
549 |
/** |
|
550 |
* Set the busy timeout value to be used (in microseconds). |
|
551 |
* If a data block is not requested by the card within this period then the Controller will either retry |
|
552 |
* or return an error. |
|
553 |
* The default master setting for this depends on the platform (set in DMMCStack::SetBusConfigDefaults). |
|
554 |
* @param aData The busy timeout in microseconds |
|
555 |
*/ |
|
556 |
{iBusConfig.iBusyTimeOut=aData; iClientMask |= KMMCModeClientBusyTimeOut; } |
|
557 |
||
558 |
||
559 |
// -------- class TMMCRCAPool -------- |
|
560 |
||
561 |
inline TMMCRCAPool::TMMCRCAPool() : iLocked(0) {} |
|
562 |
inline void TMMCRCAPool::LockRCA(TRCA anRCA) {iLocked |= (1 << (((TUint(anRCA) / 257) - 1) & 31));} |
|
563 |
inline void TMMCRCAPool::UnlockRCA(TRCA anRCA) {iLocked &= ~(1 << (((TUint(anRCA) / 257) - 1) & 31));} |
|
564 |
inline void TMMCRCAPool::ReleaseUnlocked() {iPool = 0;} |
|
565 |
||
566 |
||
567 |
// -------- class TMMCSessRing -------- |
|
568 |
||
569 |
inline TBool TMMCSessRing::IsEmpty() const {return(iSize==0);} |
|
570 |
inline void TMMCSessRing::SetMarker() {iPMark=iPrevP;} |
|
571 |
inline void TMMCSessRing::AdvanceMarker() {if(iPMark != NULL) iPMark=iPMark->iLinkP;} |
|
572 |
inline void TMMCSessRing::Point() {iPoint=((iPrevP=iPMark)==NULL)? NULL : iPMark->iLinkP;} |
|
573 |
inline TUint TMMCSessRing::Size() const {return(iSize);} |
|
574 |
inline TMMCSessRing::operator DMMCSession*() const {return(iPoint);} |
|
575 |
||
576 |
||
577 |
// -------- class TMMCStateMachine -------- |
|
578 |
||
579 |
||
580 |
/** |
|
581 |
Gets the current MultiMediCard error code. |
|
582 |
||
583 |
@return The current MultiMediCard error code. |
|
584 |
*/ |
|
585 |
inline TMMCErr TMMCStateMachine::ExitCode() { return(iExitCode); } |
|
586 |
||
587 |
||
588 |
||
589 |
||
590 |
/** |
|
591 |
Gets the current MultiMediCard error code, and sets a new error code. |
|
592 |
||
593 |
@param aCode The new error code value to be set. |
|
594 |
||
595 |
@return The current MultiMediCard error code. |
|
596 |
*/ |
|
597 |
inline TMMCErr TMMCStateMachine::SetExitCode(TMMCErr aCode) { return __e32_atomic_swp_ord32(&iExitCode, aCode); } |
|
598 |
||
599 |
||
600 |
||
601 |
||
602 |
/** |
|
603 |
Gets the current state of the state machine. |
|
604 |
||
605 |
Note that this is the state of the current state entry within |
|
606 |
the state machine stack. |
|
607 |
||
608 |
@return The current state of the state machine. |
|
609 |
*/ |
|
610 |
inline TUint TMMCStateMachine::State() { return(iStack[iSP].iState); } |
|
611 |
||
612 |
||
613 |
||
614 |
||
615 |
/** |
|
616 |
Sets the state of the state machine. |
|
617 |
||
618 |
Note that this sets the state of the current state entry within |
|
619 |
the state machine stack. |
|
620 |
||
621 |
@param aState The state to be set. |
|
622 |
||
623 |
@return KMMCErrNone |
|
624 |
*/ |
|
625 |
inline TMMCErr TMMCStateMachine::SetState(TUint aState) { iStack[iSP].iState=aState; return(0); } |
|
626 |
||
627 |
||
628 |
||
629 |
||
630 |
/** |
|
631 |
Prevents the state machine from blocking. |
|
632 |
*/ |
|
633 |
inline void TMMCStateMachine::SuppressSuspension() { iSuspend = EFalse; } |
|
634 |
||
635 |
||
636 |
||
637 |
||
638 |
/** |
|
639 |
Sets the trap mask for the current state machine entry. |
|
640 |
||
641 |
This defines the set of errors that the state machine function |
|
642 |
wants to trap. |
|
643 |
||
644 |
@param aMask The set of error values. This is a set of TMMCErr bits. |
|
645 |
||
646 |
@see TMMCErr |
|
647 |
*/ |
|
648 |
inline void TMMCStateMachine::SetTraps(TMMCErr aMask) { iStack[iSP].iTrapMask=aMask; } |
|
649 |
||
650 |
||
651 |
||
652 |
||
653 |
/** |
|
654 |
Clears the trap mask. |
|
655 |
||
656 |
@see TMMCStateMachine::SetTraps() |
|
657 |
*/ |
|
658 |
inline void TMMCStateMachine::ResetTraps() { iStack[iSP].iTrapMask=0; } |
|
659 |
||
660 |
||
661 |
||
662 |
||
663 |
/** |
|
664 |
Aborts the session. |
|
665 |
*/ |
|
666 |
inline void TMMCStateMachine::Abort() { iAbort=ETrue; } |
|
667 |
||
668 |
||
669 |
||
670 |
||
671 |
/** |
|
672 |
Initialises the state machine. |
|
673 |
||
674 |
The function sets up the state machine function for the first state entry on |
|
675 |
the state machine stack. |
|
676 |
||
677 |
It also sets up the context. In practice, the context is a pointer to |
|
678 |
the DMMCStack stack object, i.e. the object representing the MultiMediaCard |
|
679 |
stack. The pointer is passed to the state machine functions when they |
|
680 |
are dispatched. |
|
681 |
||
682 |
@param anEntry The state machine function for the first state machine entry. |
|
683 |
@param aContextP A pointer to the context. |
|
684 |
*/ |
|
685 |
inline void TMMCStateMachine::Setup(TMMCErr (*anEntry)(TAny*), TAny* aContextP) |
|
686 |
{iContextP = aContextP; iStack[0].iFunction = anEntry; Reset();} |
|
687 |
||
688 |
||
689 |
||
690 |
||
691 |
/** |
|
692 |
Pops the current state entry off the state machine stack. |
|
693 |
||
694 |
@param aSuspend Indicates whether the state machine is to block; |
|
695 |
specify ETrue to block, EFalse not to block. |
|
696 |
||
697 |
@return KMMCErrNone. |
|
698 |
*/ |
|
699 |
inline TMMCErr TMMCStateMachine::Pop(TBool aSuspend) |
|
700 |
{iSP--; if(!aSuspend) iSuspend = EFalse; return( 0 );} |
|
701 |
||
702 |
||
703 |
||
704 |
||
705 |
/** |
|
706 |
Pushes the next state entry onto the stack, specifying the current state |
|
707 |
function as the child function that is to be run, and requests the state |
|
708 |
machine to block. |
|
709 |
||
710 |
@return A MultiMediaCard error code returned from a call to TMMCStateMachine::Push(). |
|
711 |
*/ |
|
712 |
inline TMMCErr TMMCStateMachine::PushMe() {return(Push(iStack[iSP].iFunction,ETrue));} |
|
713 |
||
714 |
||
715 |
// -------- class DMMCSession -------- |
|
716 |
||
717 |
inline void DMMCSession::SetStack(DMMCStack* aStackP) |
|
718 |
/** |
|
719 |
* Assign a stack to the session. |
|
720 |
* |
|
721 |
* If an attempt is made to engage the session before a stack has been assigned to it |
|
722 |
* then the request will fail straight away. It is possible to change the stack controller |
|
723 |
* assigned to the session as long as this is not attempted while the session is engaged. |
|
724 |
* |
|
725 |
* @param aStackP A pointer to the stack to be assigned to the session |
|
726 |
*/ |
|
727 |
{iStackP = aStackP;} |
|
728 |
||
729 |
inline void DMMCSession::SetupCIMUpdateAcq() |
|
730 |
/** |
|
731 |
* Set up the session to perform the CIM_UPDATE_ACQ macro as outlined by the MMCA. |
|
732 |
* |
|
733 |
* Having set-up the session for this operation, the client must then engage the session |
|
734 |
* before the operation can commence. The CIM_UPDATE_ACQ macro starts an identification |
|
735 |
* cycle of a card stack. New cards are initialised but old cards keep their configuration. |
|
736 |
* The process ends with all compatible cards being moved to their stand-by state. |
|
737 |
*/ |
|
738 |
{iSessionID = ECIMUpdateAcq;} |
|
739 |
||
740 |
inline void DMMCSession::SetupCIMInitStack() |
|
741 |
/** |
|
742 |
* Set up the session to perform the CIM_INIT_STACK macro as outlined by the MMCA. |
|
743 |
* |
|
744 |
* Having set-up the session for this operation, the client must then engage the session |
|
745 |
* before the operation can commence. The CIM_UPDATE_ACQ macro sends all cards to the idle |
|
746 |
* state and then executes the update acquisition sequence. |
|
747 |
*/ |
|
748 |
{iSessionID = ECIMInitStack;} |
|
749 |
||
750 |
inline void DMMCSession::SetupCIMCheckStack() |
|
751 |
/** |
|
752 |
* Set up the session to perform the CIM_CHECK_STACK macro as outlined by the MMCA. |
|
753 |
* |
|
754 |
* Having set-up the session for this operation, the client must then engage the session |
|
755 |
* before the operation can commence. The CIM_CHECK_STACK macro attempts to read the CSD |
|
756 |
* of each active card in the stack, updating the data held by the stack controller for each card. |
|
757 |
*/ |
|
758 |
{iSessionID = ECIMCheckStack;} |
|
759 |
||
760 |
inline void DMMCSession::SetupCIMSetupCard() |
|
761 |
/** |
|
762 |
* Set up the session to perform the CIM_SETUP_CARD macro as outlined by the MMCA. |
|
763 |
* |
|
764 |
* Having set-up the session for this operation, the client must then engage the session |
|
765 |
* before the operation can commence. The CIM_SETUP_CARD macro selects a particular card |
|
766 |
* for data transfer and reads back its CSD. |
|
767 |
*/ |
|
768 |
{iSessionID = ECIMSetupCard;} |
|
769 |
||
770 |
inline void DMMCSession::SetupCIMLockStack() |
|
771 |
/** |
|
772 |
* Set up the session to lock the stack for this session only (so that only this session |
|
773 |
* can be engaged upon it). This prevents any other sessions from being engaged upon it. |
|
774 |
* |
|
775 |
* Having set-up the session for this operation, the client must then engage this session before |
|
776 |
* the stack becomes locked. In fact, no card bus activity results when this session is engaged. |
|
777 |
* However, because it may take some time for the Controller to be able to lock the stack for this |
|
778 |
* session, the mechanism for locking the stack still involves submitting a session. |
|
779 |
* When issuing a series of application specific commands, the client will want to lock the stack, |
|
780 |
* preventing any other client from generating bus activity during this period. This is accomplished |
|
781 |
* by issuing this function and then engaging that session. If successful, the stack will be locked |
|
782 |
* until the DMMCSession::UnlockStack() function is issued. |
|
783 |
*/ |
|
784 |
{iSessionID = ECIMLockStack;} |
|
785 |
||
786 |
inline void DMMCSession::UnlockStack() |
|
787 |
/** |
|
788 |
* Unlock this session as the locking session for the stack, the stack having previously been locked |
|
789 |
* to this session using the DMMCSession. |
|
790 |
*/ |
|
791 |
{if(iStackP != NULL) iStackP->UnlockStack(this);} |
|
792 |
||
793 |
inline void DMMCSession::SetupCIMInitStackAfterUnlock() |
|
794 |
/** |
|
795 |
* Set up the session to perform the second stage of initialisation after unlocking of the card |
|
796 |
* |
|
797 |
* This is provided to allow types of cards (particularly SD cards) to access the SD_STATUS and |
|
798 |
* associated registers during initialisation, which are only available once the card is unlocked. |
|
799 |
*/ |
|
800 |
{ |
|
801 |
iCardP = NULL; |
|
802 |
iSessionID = ECIMInitStackAfterUnlock; |
|
803 |
} |
|
804 |
||
805 |
inline void DMMCSession::SetupCIMAutoUnlock() |
|
806 |
/** |
|
807 |
* Set up the session to perform auto-unlocking of the card |
|
808 |
*/ |
|
809 |
{iSessionID = ECIMAutoUnlock;} |
|
810 |
||
811 |
inline void DMMCSession::Stop() |
|
812 |
/** |
|
813 |
* Signal the session to complete immediately with KErrAbort |
|
814 |
* (i.e. the session end call-back function will be called). |
|
815 |
*/ |
|
816 |
{if(iStackP != NULL) iStackP->Stop(this);} |
|
817 |
||
818 |
inline void DMMCSession::Abort() |
|
819 |
/** |
|
820 |
* Signal the session to abort immediately with no completion |
|
821 |
* (i.e. the session end call-back function will not be called). |
|
822 |
*/ |
|
823 |
{if(iStackP != NULL) iStackP->Abort(this);} |
|
824 |
||
825 |
inline TMMCSessionTypeEnum DMMCSession::SessionID() const |
|
826 |
/** |
|
827 |
* Returns the current session type for this session. |
|
828 |
* |
|
829 |
* @return A TMMCSessionTypeEnum describing the sesion type |
|
830 |
*/ |
|
831 |
{return(iSessionID);} |
|
832 |
||
833 |
inline DMMCStack* DMMCSession::StackP() const |
|
834 |
/** |
|
835 |
* Returns the DMMCStack object serving this session. |
|
836 |
* |
|
837 |
* @return A pointer to the DMMCStack object serving this session. |
|
838 |
*/ |
|
839 |
{return(iStackP);} |
|
840 |
||
841 |
inline TMMCard* DMMCSession::CardP() const |
|
842 |
/** |
|
843 |
* Returns a pointer to the TMMCard object which this session is set to use. |
|
844 |
* |
|
845 |
* @return A pointer to the TMMCard object which this session is set to use. |
|
846 |
*/ |
|
847 |
{return(iCardP);} |
|
848 |
||
849 |
inline TBool DMMCSession::IsEngaged() const |
|
850 |
/** |
|
851 |
* Return ETrue if this session is currently queued on the DMMCStack object serving this session. |
|
852 |
* |
|
853 |
* @return ETrue if this session is currently queued, otherwise EFalse |
|
854 |
*/ |
|
855 |
{return((iState & KMMCSessStateEngaged) != 0);} |
|
856 |
||
857 |
inline TMMCErr DMMCSession::MMCExitCode() const |
|
858 |
/** |
|
859 |
* Returns the last MMC specific error code returned to this session. |
|
860 |
* |
|
861 |
* @return a TMMCErr describing the MMC specific error code |
|
862 |
*/ |
|
863 |
{return(iMMCExitCode);} |
|
864 |
||
865 |
inline TMMCStatus DMMCSession::LastStatus() const |
|
866 |
/** |
|
867 |
* Returns the last status information from the card (i.e. the last R1 response received from the card). |
|
868 |
* |
|
869 |
* @return a TMMCStatus describing the status information |
|
870 |
*/ |
|
871 |
{return(iLastStatus);} |
|
872 |
||
873 |
inline TUint32 DMMCSession::BytesTransferred() const |
|
874 |
/** |
|
875 |
* Returns the total number of bytes transferred in this session. |
|
876 |
* |
|
877 |
* @return the total number of bytes transferred in this session. |
|
878 |
*/ |
|
879 |
{return(iBytesTransferred);} |
|
880 |
||
881 |
inline TUint8* DMMCSession::ResponseP() |
|
882 |
/** |
|
883 |
* Returns a pointer to a buffer containing the last command response received in this session. |
|
884 |
* |
|
885 |
* @return a buffer with format TUint8[KMMCMaxResponseLength] (where KMMCMaxResponseLength = 16). |
|
886 |
*/ |
|
887 |
{return(&iCommand[iCmdSP].iResponse[0]);} |
|
888 |
||
889 |
inline TUint32 DMMCSession::EffectiveModes() const |
|
890 |
/** |
|
891 |
* Returns the modes which the DMMCStack object serving this session will consider as effective. |
|
892 |
* |
|
893 |
* @return the modes which the DMMCStack object serving this session will consider as effective |
|
894 |
*/ |
|
895 |
{if(iStackP != NULL) return(iStackP->EffectiveModes(iConfig)); return(0);} |
|
896 |
||
897 |
inline void DMMCSession::Block(TUint32 aFlag) |
|
898 |
{iStackP->Block(this, aFlag);} |
|
899 |
||
900 |
inline void DMMCSession::UnBlock(TUint32 aFlag, TMMCErr anExitCode) |
|
901 |
{iStackP->UnBlock(this, aFlag, anExitCode);} |
|
902 |
||
903 |
inline void DMMCSession::SwapMe() |
|
904 |
{iState |= KMMCSessStateDoReSchedule;} |
|
905 |
||
906 |
inline void DMMCSession::ResetCommandStack() |
|
907 |
/** |
|
908 |
* Resets the command stack, setting the stack pointer to zero. |
|
909 |
*/ |
|
910 |
{iCmdSP = 0;} |
|
911 |
||
912 |
/** |
|
913 |
Increments the command stack pointer. |
|
914 |
||
915 |
@panic PBUS-MMC 6 if the stack pointer lies outside the bounds of the stack. |
|
916 |
*/ |
|
917 |
inline void DMMCSession::PushCommandStack() |
|
918 |
{ |
|
919 |
__ASSERT_ALWAYS(TUint(++iCmdSP)<KMaxMMCCommandStackDepth, |
|
920 |
DMMCSocket::Panic(DMMCSocket::EMMCCommandStack)); |
|
921 |
} |
|
922 |
||
923 |
/** |
|
924 |
Decrements the command stack pointer. |
|
925 |
||
926 |
@panic PBUS-MMC 6 if the stack pointer lies outside the bounds of the stack. |
|
927 |
*/ |
|
928 |
inline void DMMCSession::PopCommandStack() |
|
929 |
{ |
|
930 |
__ASSERT_ALWAYS(--iCmdSP>=0, |
|
931 |
DMMCSocket::Panic(DMMCSocket::EMMCCommandStack)); |
|
932 |
} |
|
933 |
||
934 |
inline TMMCCommandDesc& DMMCSession::Command() |
|
935 |
/** |
|
936 |
* Returns the current command, as referred to by the stack pointer. |
|
937 |
* @return A TMMCCommandDesc reference, containing the current command. |
|
938 |
*/ |
|
939 |
{return(iCommand[iCmdSP]);} |
|
940 |
||
941 |
||
942 |
// |
|
943 |
// Data transfer macros setup (block mode) |
|
944 |
// |
|
945 |
||
946 |
inline void DMMCSession::SetupCIMReadBlock(TMMCArgument aBlockAddr, TUint8* aMemoryP, TUint32 aBlocks) |
|
947 |
/** |
|
948 |
* Sets the session up to perform the CIM_READ_BLOCK macro as outlined by the MMCA. |
|
949 |
* Having set-up the session for this operation, the client must then engage the session before the operation can commence. |
|
950 |
* The CIM_READ_BLOCK macro reads a single block from the card. It starts by setting the block length (CMD16) to 512 Bytes. |
|
951 |
* It then reads 'aBlocks' blocks of data from the card at offset 'aBlockAddr' on the card into system memory starting at |
|
952 |
* address 'aMemoryP'. |
|
953 |
* |
|
954 |
* @param aBlockAddr Contains offset (in blocks) to the block to be read from the card |
|
955 |
* @param aMemoryP host destination address |
|
956 |
* @param aBlocks The number of blocks to read from the card |
|
957 |
*/ |
|
958 |
{ |
|
959 |
ResetCommandStack(); |
|
960 |
FillCommandArgs(aBlockAddr, aBlocks << KMMCardHighCapBlockSizeLog2, aMemoryP, KMMCardHighCapBlockSize); |
|
961 |
Command().iFlags |= KMMCCmdFlagBlockAddress; |
|
962 |
iSessionID = (aBlocks > 1)? ECIMReadMBlock : ECIMReadBlock; |
|
963 |
} |
|
964 |
||
965 |
inline void DMMCSession::SetupCIMWriteBlock(TMMCArgument aBlockAddr, TUint8* aMemoryP, TUint32 aBlocks) |
|
966 |
/** |
|
967 |
* Set up the session to perform the CIM_WRITE_BLOCK macro as outlined by the MMCA. |
|
968 |
* Having set-up the session for this operation, the client must then engage the session before the operation can commence. |
|
969 |
* The CIM_WRITE_BLOCK macro writes a single block to the card. It starts by setting the block length (CMD16) to 512 Bytes. |
|
970 |
* It then writes 'aBlocks' block of data to the card at offset 'aBlockAddr' on the card reading from system memory starting |
|
971 |
* at address 'aMemoryP'. |
|
972 |
* |
|
973 |
* @param aBlockAddr Contains offset to the block (in blocks) to be written on the card |
|
974 |
* @param aMemoryP Host source address |
|
975 |
* @param aBlocks The number of blocks to write to the card |
|
976 |
*/ |
|
977 |
{ |
|
978 |
ResetCommandStack(); |
|
979 |
FillCommandArgs(aBlockAddr, aBlocks << KMMCardHighCapBlockSizeLog2, aMemoryP, KMMCardHighCapBlockSize); |
|
980 |
Command().iFlags |= KMMCCmdFlagBlockAddress; |
|
981 |
iSessionID = (aBlocks > 1)? ECIMWriteMBlock : ECIMWriteBlock; |
|
982 |
} |
|
983 |
||
984 |
inline void DMMCSession::SetupCIMEraseMSector(TMMCArgument aBlockAddr, TUint32 aBlocks) |
|
985 |
/** |
|
986 |
* Set up the session to perform the CIM_ERASE_SECTOR macro broadly as outlined by the MMCA. |
|
987 |
* However, the macro only performs a sector erase of a contiguous area and doesn't support the un-tagging of particular sectors |
|
988 |
* within the initial tagged area. Having set-up the session for this operation, the client must then engage the session before |
|
989 |
* the operation can commence. |
|
990 |
* |
|
991 |
* 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 |
|
992 |
* '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). |
|
993 |
* The tag sector start command (CMD32) is first issued setting the address of the first sector to be erased. |
|
994 |
* This is followed by the tag sector end command (CMD33) setting the address of the last sector to be erased. Now that the erase |
|
995 |
* sectors are tagged, the erase command (CMD38) is sent followed by a send status command (CMD13) to read any additional status |
|
996 |
* information from the card. |
|
997 |
* |
|
998 |
* @param aBlockAddr Contains offset (in blocks) to the first block to be erased |
|
999 |
* @param aBlocks Total number of blocks to erase |
|
1000 |
*/ |
|
1001 |
{ |
|
1002 |
ResetCommandStack(); |
|
1003 |
FillCommandArgs(aBlockAddr, aBlocks << KMMCardHighCapBlockSizeLog2, NULL, 0); |
|
1004 |
Command().iFlags |= KMMCCmdFlagBlockAddress; |
|
1005 |
iSessionID = ECIMEraseSector; |
|
1006 |
} |
|
1007 |
||
1008 |
inline void DMMCSession::SetupCIMEraseMGroup(TMMCArgument aBlockAddr, TUint32 aBlocks) |
|
1009 |
/** |
|
1010 |
* Set up the session to perform the CIM_ERASE_GROUP macro broadly as outlined by the MMCA. |
|
1011 |
* However, the macro only performs an erase group erase of a contiguous area and doesn't support the un-tagging of particular |
|
1012 |
* erase groups within the initial tagged area. Having set-up the session for this operation, the client must then engage the |
|
1013 |
* session before the operation can commence. |
|
1014 |
* |
|
1015 |
* 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 |
|
1016 |
* offset 'aBlockAddr'+'aBlocks' (in blocks). The tag ease group start command (CMD35) is first issued setting |
|
1017 |
* the address of the first erase group to be erased. This is followed by the tag erase group end command (CMD36) setting the |
|
1018 |
* address of the last erase group to be erased. Now that the erase groups are tagged, the erase command (CMD38) is sent followed |
|
1019 |
* by a send status command (CMD13) to read any additional status information from the card. |
|
1020 |
* |
|
1021 |
* @param aBlockAddr Contains offset (in blocks) to the first block to be erased |
|
1022 |
* @param aBlocks Total number of blocks to erase |
|
1023 |
*/ |
|
1024 |
{ |
|
1025 |
ResetCommandStack(); |
|
1026 |
FillCommandArgs(aBlockAddr, aBlocks << KMMCardHighCapBlockSizeLog2, NULL, 0); |
|
1027 |
Command().iFlags |= KMMCCmdFlagBlockAddress; |
|
1028 |
iSessionID = ECIMEraseGroup; |
|
1029 |
} |
|
1030 |
||
1031 |
inline void DMMCSession::EnableDoubleBuffering(TUint32 aNumBlocks) |
|
1032 |
/** |
|
1033 |
* When called before a data transfer operation is engaged, specifies that the data |
|
1034 |
* transfer operation is to be double-buffered. |
|
1035 |
* |
|
1036 |
* @param aNumBlocks The number of blocks to transfer per double-buffer transfer. |
|
1037 |
* |
|
1038 |
* @internalTechnology |
|
1039 |
*/ |
|
1040 |
{ |
|
1041 |
__KTRACE_OPT(KPBUS1, Kern::Printf("++ DMMCSession::EnableDoubleBuffering(%d Blocks)", aNumBlocks)) |
|
1042 |
||
1043 |
//__ASSERT_ALWAYS(iSessionID == ECIMWriteMBlock || iSessionID == ECIMReadMBlock, DMMCSocket::Panic(DMMCSocket::EMMCInvalidDBCommand)); |
|
1044 |
||
1045 |
Command().iBlockLength &= 0x0000FFFF; |
|
1046 |
Command().iBlockLength |= aNumBlocks << 16; |
|
1047 |
Command().iFlags |= KMMCCmdFlagDoubleBuffer; |
|
1048 |
} |
|
1049 |
||
1050 |
inline void DMMCSession::SetDataTransferCallback(TMMCCallBack& aCallback) |
|
1051 |
/** |
|
1052 |
* Registers the data transfer callback function to be called when more data is required by the PSL, |
|
1053 |
* typically while the hardware is busy performing a DMA transfer. |
|
1054 |
* |
|
1055 |
* @param aCallback The callback function. |
|
1056 |
* |
|
1057 |
* @internalTechnology |
|
1058 |
*/ |
|
1059 |
{ |
|
1060 |
__KTRACE_OPT(KPBUS1, Kern::Printf("++ DMMCSession::SetDataTransferCallback")); |
|
1061 |
||
1062 |
iDataTransferCallback = aCallback; |
|
1063 |
} |
|
1064 |
||
1065 |
inline void DMMCSession::MoreDataAvailable(TUint32 aNumBlocks, TUint8* aMemoryP, TInt aError) |
|
1066 |
/** |
|
1067 |
* Called by the MMC Media Driver after copying data from the client thread to indicate to the |
|
1068 |
* PSL that data is available in the next data buffer. Should be called at the end of the |
|
1069 |
* data transfer callback function, at which point the stack will be unblocked enabling the |
|
1070 |
* next data transfer to take place. |
|
1071 |
* |
|
1072 |
* @param aNumBlocks The number of blocks available in the buffer. |
|
1073 |
* @param aMemoryP A pointer to the host memory containing the next blocks of data. |
|
1074 |
* @param aError The result of the data callback. |
|
1075 |
* |
|
1076 |
* @internalTechnology |
|
1077 |
*/ |
|
1078 |
{ |
|
1079 |
__KTRACE_OPT(KPBUS1, Kern::Printf("++ DMMCSession::MoreDataAvailable(%d blocks, %08x, %d)", aNumBlocks, aMemoryP, aError)); |
|
1080 |
||
1081 |
Command().iDataMemoryP = aMemoryP; |
|
1082 |
EnableDoubleBuffering(aNumBlocks); |
|
1083 |
||
1084 |
iStackP->UnBlock(this, KMMCBlockOnMoreData, aError == KErrNone ? KMMCErrNone : KMMCErrGeneral); |
|
1085 |
} |
|
1086 |
||
1087 |
inline TBool DMMCSession::RequestMoreData() |
|
1088 |
/** |
|
1089 |
* Called by the PSL to request the next blocks of data to be transferred from the media driver |
|
1090 |
* to the PSL. This would typically be called while the hardware is busy transferring the current |
|
1091 |
* block of data, allowing the media driver to copy data from the client in parallel. |
|
1092 |
* |
|
1093 |
* This method will set the state machine to block on KMMCBlockOnMoreData, so the PSL must block |
|
1094 |
* the state machine using an SMF_WAITS (or equivalent). When the Media Driver has populated the |
|
1095 |
* next buffer, the current command descriptor will be updated and the state machine unblocked. |
|
1096 |
* |
|
1097 |
* @return ETrue if all conditions are met to perform double-buffering (ie - command is enabled |
|
1098 |
* for double-buffering and the last transfer has not already been satisfied). If |
|
1099 |
* successful, upon exit the state machine will be blocked with the KMMCBlockOnMOreData |
|
1100 |
* condition and the Media Driver's data transfer callback invoked. |
|
1101 |
* |
|
1102 |
* |
|
1103 |
*/ |
|
1104 |
{ |
|
1105 |
__KTRACE_OPT(KPBUS1, Kern::Printf("++ DMMCSession::RequestMoreData()")); |
|
1106 |
||
1107 |
if(Command().IsDoubleBuffered() && (Command().iBytesDone + Command().BufferLength() < Command().iTotalLength)) |
|
1108 |
{ |
|
1109 |
iStackP->Block(this, KMMCBlockOnMoreData); |
|
1110 |
iDataTransferCallback.CallBack(); |
|
1111 |
return(ETrue); |
|
1112 |
} |
|
1113 |
||
1114 |
return(EFalse); |
|
1115 |
} |
|
1116 |
||
1117 |
||
1118 |
// -------- class DMMCSocket -------- |
|
1119 |
||
1120 |
inline TBool DMMCSocket::SupportsDoubleBuffering() |
|
1121 |
/** |
|
1122 |
* @return ETrue If the PSL supports double buffering, as specified by the |
|
1123 |
* PSL by setting the ESupportsDoubleBuffering flag in ::MachineInfo. |
|
1124 |
* |
|
1125 |
* @internalTechnology |
|
1126 |
*/ |
|
1127 |
{ |
|
1128 |
return ((iMachineInfo.iFlags & TMMCMachineInfo::ESupportsDoubleBuffering) ? (TBool)ETrue : (TBool)EFalse); |
|
1129 |
} |
|
1130 |
||
1131 |
inline TUint32 DMMCSocket::MaxDataTransferLength() |
|
1132 |
/** |
|
1133 |
* @return The maximum length that the PSL supports in a single data transfer. |
|
1134 |
* Returns Zero if the PSL has no limitation on the maximum length of data transfer. |
|
1135 |
* |
|
1136 |
* @internalTechnology |
|
1137 |
*/ |
|
1138 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1139 |
TUint32 r = (iMachineInfo.iFlags & TMMCMachineInfo::EMaxTransferLength_16M) >> 8; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1140 |
if (r) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1141 |
r = 0x20000 << r; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1142 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1143 |
return r; |
0 | 1144 |
} |
1145 |
||
1146 |
inline TUint32 DMMCSocket::DmaAlignment() |
|
1147 |
/** |
|
1148 |
* @return Byte alignment required by the DMA Controller. |
|
1149 |
* e.g. 16 Bit addressing scheme equates to 2 byte alignment. |
|
1150 |
* |
|
1151 |
* @internalTechnology |
|
1152 |
*/ |
|
1153 |
{ |
|
1154 |
const TUint32 DmaAddrMsk = TMMCMachineInfo::EDma8BitAddressing | |
|
1155 |
TMMCMachineInfo::EDma16BitAddressing | |
|
1156 |
TMMCMachineInfo::EDma32BitAddressing | |
|
1157 |
TMMCMachineInfo::EDma64BitAddressing; |
|
1158 |
return ((iMachineInfo.iFlags & DmaAddrMsk) >> 3); |
|
1159 |
} |
|
1160 |
||
1161 |
// -------- class DMMCStack -------- |
|
1162 |
||
1163 |
inline void DMMCStack::ReportPowerUp() |
|
1164 |
/** |
|
1165 |
* Called by the variant layer to indicate that a |
|
1166 |
* power up operation has successfully completed. |
|
1167 |
*/ |
|
1168 |
{iPoweredUp = ETrue;} |
|
1169 |
||
1170 |
inline void DMMCStack::ReportPowerDown() |
|
1171 |
/** |
|
1172 |
* Indicates that that power down operation has successfully completed. |
|
1173 |
* Following power down, the stack enters a state pending the next power up operation. |
|
1174 |
*/ |
|
1175 |
{iPoweredUp = EFalse; iStackState |= KMMCStackStateInitPending;} |
|
1176 |
||
1177 |
inline void DMMCStack::Reset() |
|
1178 |
/** |
|
1179 |
* Resets the stack by aborting all current requests. |
|
1180 |
*/ |
|
1181 |
{iAbortAll = ETrue; Scheduler(iAbortReq);} |
|
1182 |
||
1183 |
inline void DMMCStack::CompleteAll(TMMCErr aCode) |
|
1184 |
/** |
|
1185 |
* Stops and dequeues all sessions queued on this stack (including those queued by other clients). |
|
1186 |
* Each of the sessions affected will complete immediately with error code 'aCode' (i.e. the session |
|
1187 |
* end call-back function will be called). |
|
1188 |
* @param aCode The MMC error code to be returned. |
|
1189 |
*/ |
|
1190 |
{iCompleteAllExitCode = aCode; Scheduler(iCompReq);} |
|
1191 |
||
1192 |
inline TUint DMMCStack::MaxCardsInStack() const |
|
1193 |
/** |
|
1194 |
* Returns the maximum number of MultiMediaCards which could ever be present in this stack. |
|
1195 |
* i.e. the total number of physical card slots associated with this stack on this platform. |
|
1196 |
* (This is initialised from the DMMCSocket::TotalSupportedCards) |
|
1197 |
* @return The number of supported cards. |
|
1198 |
*/ |
|
1199 |
{return( iMaxCardsInStack );} |
|
1200 |
||
1201 |
inline TMMCard* DMMCStack::CardP(TUint aCardNumber) |
|
1202 |
/** |
|
1203 |
* Returns a pointer to the specified card. |
|
1204 |
* @param aCardNumber The card number. |
|
1205 |
* @return A pointer to the specified card. |
|
1206 |
*/ |
|
1207 |
{return( (aCardNumber<iMaxCardsInStack) ? (iCardArray->CardP(aCardNumber)) : NULL );} |
|
1208 |
||
1209 |
inline DMMCSocket* DMMCStack::MMCSocket() const |
|
1210 |
/** |
|
1211 |
* Returns a pointer to associated socket object. |
|
1212 |
* @return A pointer to the associated socket. |
|
1213 |
*/ |
|
1214 |
{return( iSocket );} |
|
1215 |
||
1216 |
inline TMMCPasswordStore* DMMCStack::PasswordStore() const |
|
1217 |
/** |
|
1218 |
* Returns a pointer to the associated password store. |
|
1219 |
* @return A pointer to the associated password store. |
|
1220 |
*/ |
|
1221 |
{return( iSocket->iPasswordStore );} |
|
1222 |
||
1223 |
inline TBool DMMCStack::InitStackInProgress() const |
|
1224 |
/** |
|
1225 |
* Reports the initialisation state of the stack (i.e is the CIM_INIT_STACK macro in progress). |
|
1226 |
* @return ETrue if the stack is being initialised, EFalse otherwise. |
|
1227 |
*/ |
|
1228 |
{return( (iStackState & KMMCStackStateInitInProgress) != 0 );} |
|
1229 |
||
1230 |
inline TBool DMMCStack::HasSessionsQueued() const |
|
1231 |
/** |
|
1232 |
* Reports if any of the session queues have submitted session engaged. |
|
1233 |
* @return ETrue if there are any sessions engaged on this stack, EFalse otherwise. |
|
1234 |
*/ |
|
1235 |
{return((iWorkSet.Size()!=0) || (iReadyQueue.Size()!=0) || (iEntryQueue.Size()!=0));} |
|
1236 |
||
1237 |
inline TBool DMMCStack::HasCardsPresent() |
|
1238 |
/** |
|
1239 |
* Reports if any cards are present on the stack |
|
1240 |
* @return ETrue if there are any sessions engaged on this stack, EFalse otherwise. |
|
1241 |
*/ |
|
1242 |
{ |
|
1243 |
for (TUint i=0 ; i<iMaxCardsInStack ; i++) |
|
1244 |
if (CardDetect(i)) return(ETrue); |
|
1245 |
return(EFalse); |
|
1246 |
} |
|
1247 |
||
1248 |
inline TBool DMMCStack::StackRunning() const |
|
1249 |
/** |
|
1250 |
* Reports whether the stack is currently running (i.e. running in another context from the caller) |
|
1251 |
* @return ETrue if the stack is currently running |
|
1252 |
*/ |
|
1253 |
{return( (iStackState & KMMCStackStateRunning) != 0 );} |
|
1254 |
||
1255 |
inline void DMMCStack::BufferInfo(TUint8*& aBuf, TInt& aBufLen, TInt& aMinorBufLen) |
|
1256 |
/** |
|
1257 |
* Calls the variant-layer function GetBufferInfo() to retrieve the DMA-capable buffer start and length |
|
1258 |
* and then calculates the minor buffer length (which is situated at the start) - |
|
1259 |
* this is the maximum of a sector size (512 bytes) and the biggest block size of |
|
1260 |
* any card in the stack. |
|
1261 |
||
1262 |
* @param aBuf A pointer to the allocated buffer |
|
1263 |
* @param aBufLen The length of the allocated buffer |
|
1264 |
* @param aMinorBufLen The length of the minor buffer |
|
1265 |
*/ |
|
1266 |
{ |
|
1267 |
aBuf = iPSLBuf; |
|
1268 |
aBufLen = iPSLBufLen; |
|
1269 |
aMinorBufLen = iMinorBufLen; |
|
1270 |
} |
|
1271 |
||
1272 |
||
1273 |
inline TInt DMMCStack::DemandPagingInfo(TDemandPagingInfo& aInfo) |
|
1274 |
{ |
|
1275 |
MDemandPagingInfo* demandPagingInterface = NULL; |
|
1276 |
GetInterface(KInterfaceDemandPagingInfo, (MInterface*&) demandPagingInterface); |
|
1277 |
if (demandPagingInterface) |
|
1278 |
return demandPagingInterface->DemandPagingInfo(aInfo); |
|
1279 |
else |
|
1280 |
return KErrNotSupported; |
|
1281 |
} |
|
1282 |
||
1283 |
||
1284 |
inline void DMMCStack::CancelSession(DMMCSession* aSession) |
|
1285 |
{ |
|
1286 |
GetInterface(KInterfaceCancelSession, (MInterface*&) aSession); |
|
1287 |
} |
|
1288 |
||
1289 |
inline TRCA DMMCStack::SelectedCard() const |
|
1290 |
/** |
|
1291 |
* Returns the Relative Card Address (RCA) of the currently selected card |
|
1292 |
* @return A TRCA object containing the Relative Card Address. |
|
1293 |
*/ |
|
1294 |
{ |
|
1295 |
return iSelectedCard; |
|
1296 |
} |
|
1297 |
||
1298 |
inline TMMCStateMachine& DMMCStack::Machine() |
|
1299 |
/** |
|
1300 |
* Returns the current sessions MMC State Machine object. |
|
1301 |
* @return A TMMCStateMachine reference to the current sessions State Machine object. |
|
1302 |
*/ |
|
1303 |
{return( iSessionP->iMachine );} |
|
1304 |
||
1305 |
inline TMMCBusConfig& DMMCStack::BusConfig() |
|
1306 |
/** |
|
1307 |
* Returns the current bus configuration. |
|
1308 |
* @return A TMMCBusConfig reference describing current sessions bus configuration. |
|
1309 |
*/ |
|
1310 |
{return( iConfig.iBusConfig );} |
|
1311 |
||
1312 |
inline TMMCBusConfig& DMMCStack::MasterBusConfig() |
|
1313 |
/** |
|
1314 |
* Returns the master bus configuration. |
|
1315 |
* @return A TMMCBusConfig reference describing the master bus configuration. |
|
1316 |
*/ |
|
1317 |
{return( iMasterConfig.iBusConfig );} |
|
1318 |
||
1319 |
inline TMMCCommandDesc& DMMCStack::Command() |
|
1320 |
/** |
|
1321 |
* Returns the current sessions command description. |
|
1322 |
* @return A TMMCCommandDesc reference describing current sessions command. |
|
1323 |
*/ |
|
1324 |
{return( iSessionP->Command() );} |
|
1325 |
||
1326 |
inline DMMCSession& DMMCStack::Session() |
|
1327 |
/** |
|
1328 |
* Returns the current session object. |
|
1329 |
* @return A reference to the current DMMCSession object. |
|
1330 |
*/ |
|
1331 |
{return(*iSessionP);} |
|
1332 |
||
1333 |
inline void DMMCStack::BlockCurrentSession(TUint32 aFlag) |
|
1334 |
/** |
|
1335 |
* Indicates that the current session is to be blocked (ie - waiting on an asynchronous response such as interrupt). |
|
1336 |
* The state machine will only unblock when an unblock request with the matching argument is called. |
|
1337 |
* In the PSL level of the Controller you should always use KMMCBlockOnASSPFunction as the argument. |
|
1338 |
* @param aFlag Bitmask describing the reason for blocking. |
|
1339 |
*/ |
|
1340 |
{Block(iSessionP,aFlag);} |
|
1341 |
||
1342 |
inline void DMMCStack::UnBlockCurrentSession(TUint32 aFlag, TMMCErr anExitCode) |
|
1343 |
/** |
|
1344 |
* Indicates that the current session is to be unblocked (ie - an a asynchronous operation has completed). |
|
1345 |
* The state machine will only unblock when an unblock request with the matching argument is called. |
|
1346 |
* @param aFlag Bitmask describing the reason for unblocking. |
|
1347 |
* @param anExitCode KMMCErrNone if successful, otherwise a standard TMMCErr code. |
|
1348 |
*/ |
|
1349 |
{UnBlock(iSessionP,aFlag,anExitCode);} |
|
1350 |
||
1351 |
inline void DMMCStack::ReportInconsistentBusState() |
|
1352 |
/** |
|
1353 |
* Indicates that something has gone wrong, so the stack needs re-initialising. |
|
1354 |
*/ |
|
1355 |
{iStackState |= KMMCStackStateBusInconsistent;} |
|
1356 |
||
1357 |
inline void DMMCStack::ReportASSPEngaged() |
|
1358 |
/** |
|
1359 |
* Called by the PSL to indicate that a session has been engaged. |
|
1360 |
*/ |
|
1361 |
{iSessionP->iState |= KMMCSessStateASSPEngaged;} |
|
1362 |
||
1363 |
inline void DMMCStack::ReportASSPDisengaged() |
|
1364 |
/** |
|
1365 |
* Called by the PSL to indicate that a session has completed or has been aborted. |
|
1366 |
*/ |
|
1367 |
{iSessionP->iState &= ~KMMCSessStateASSPEngaged;} |
|
1368 |
||
1369 |
inline TRCA DMMCStack::CurrentSessCardRCA() |
|
1370 |
/** |
|
1371 |
* Returns the Relative Card Address (RCA) in use by the current session. |
|
1372 |
* @return A TRCA object containing the Relative Card Address. |
|
1373 |
*/ |
|
1374 |
{return(iSessionP->CardRCA());} |
|
1375 |
||
1376 |
||
1377 |
inline TMMCErr DMMCStack::BaseModifyCardCapabilitySMST( TAny* aStackP ) |
|
1378 |
{ return( static_cast<DMMCStack *>(aStackP)->DMMCStack::ModifyCardCapabilitySM() ); } |
|
1379 |
||
1380 |
inline TMMCErr DMMCStack::InitCurrentCardAfterUnlockSMST( TAny* aStackP ) |
|
1381 |
{ return( static_cast<DMMCStack *>(aStackP)->DMMCStack::InitStackAfterUnlockSM() ); } |
|
1382 |
||
1383 |
/** |
|
1384 |
Increments the current session's command stack pointer. |
|
1385 |
||
1386 |
@see DMMCSession::PushCommandStack() |
|
1387 |
*/ |
|
1388 |
inline void DMMCStack::CurrentSessPushCmdStack() |
|
1389 |
{iSessionP->PushCommandStack();} |
|
1390 |
||
1391 |
||
1392 |
||
1393 |
/** |
|
1394 |
Decrements the current session's command stack pointer. |
|
1395 |
||
1396 |
@see DMMCSession::PopCommandStack() |
|
1397 |
*/ |
|
1398 |
inline void DMMCStack::CurrentSessPopCmdStack() |
|
1399 |
{iSessionP->PopCommandStack();} |
|
1400 |
||
1401 |
/** |
|
1402 |
Allows the stack to yield to another command temporarily, for one loop of the scheduler only. |
|
1403 |
||
1404 |
@param aCommandType The command type to yield to. |
|
1405 |
*/ |
|
1406 |
inline void DMMCStack::YieldStack(TMMCCommandTypeEnum aCommandType) |
|
1407 |
{ |
|
1408 |
BlockCurrentSession(KMMCBlockOnYielding); |
|
1409 |
iYieldCommandType = aCommandType; |
|
1410 |
iStackState |= KMMCStackStateYielding; |
|
1411 |
} |
|
1412 |
||
1413 |
||
1414 |
inline void DMMCStack::CurrentSessFillCmdDesc(TMMCCommandEnum aCommand) |
|
1415 |
/** |
|
1416 |
* Initialises the current sessions command according to whether it is a normal |
|
1417 |
* or an application command. |
|
1418 |
* @param aCommand Contains the command. |
|
1419 |
*/ |
|
1420 |
{iSessionP->FillCommandDesc(aCommand);} |
|
1421 |
||
1422 |
inline void DMMCStack::CurrentSessFillCmdDesc(TMMCCommandEnum aCommand,TMMCArgument anArgument) |
|
1423 |
/** |
|
1424 |
* Initialises the current sessions command with an argument according to whether |
|
1425 |
* it is a normal or an application command. |
|
1426 |
* @param aCommand Contains the command. |
|
1427 |
* @param anArgument Specifies the argument. |
|
1428 |
*/ |
|
1429 |
{iSessionP->FillCommandDesc(aCommand,anArgument);} |
|
1430 |
||
1431 |
inline void DMMCStack::CurrentSessFillCmdArgs(TMMCArgument anArgument,TUint32 aLength,TUint8* aMemoryP,TUint32 aBlkLen) |
|
1432 |
/** |
|
1433 |
* Initialises the current sessions command arguments with the specified parameters |
|
1434 |
* It is necessary to have set the command arguments with this command prior |
|
1435 |
* to engaging a read/write macro or command. |
|
1436 |
* @param anArgument Command specific argument. |
|
1437 |
* @param aLength aLength Total number of bytes to read/write. |
|
1438 |
* @param aMemoryP Host source/destination address |
|
1439 |
* @param aBlkLen Block length |
|
1440 |
*/ |
|
1441 |
{iSessionP->FillCommandArgs(anArgument,aLength,aMemoryP,aBlkLen);} |
|
1442 |
||
1443 |
inline void DMMCStack::DeselectsToIssue(TUint aNumber) |
|
1444 |
/** |
|
1445 |
* Specifies how many deselects to issue during deselection. |
|
1446 |
* @param aNumber The number of deselects to issue. |
|
1447 |
*/ |
|
1448 |
{iDeselectsToIssue = aNumber; iStackState |= KMMCStackStateDoDeselect;} |
|
1449 |
||
1450 |
// -------- class DMMCController -------- |
|
1451 |
||
1452 |
inline DMMCStack* DMMCSocket::Stack(TInt aBus) |
|
1453 |
/** |
|
1454 |
* Returns a pointer to the DMMCStack object corresponding to the specified MMC card. |
|
1455 |
* @param aBus The MMC card number. |
|
1456 |
* @return A pointer to the DMMCStack object corresponding to the specified card. |
|
1457 |
*/ |
|
1458 |
{return( ((TInt)aBus < iMachineInfo.iTotalSockets) ? iStack : NULL );} |
|
1459 |
||
1460 |
inline void DMMCSocket::ResetInactivity(TInt /*aBus*/) |
|
1461 |
/** |
|
1462 |
* Resets the sockets PSU inactivity timer. |
|
1463 |
* Commonly used to prevent reset due to inactivity |
|
1464 |
* while waiting for a response from the card. |
|
1465 |
* @param aBus Unused |
|
1466 |
*/ |
|
1467 |
{ |
|
1468 |
iVcc->ResetInactivityTimer(); |
|
1469 |
if (iVccCore) |
|
1470 |
iVccCore->ResetInactivityTimer(); |
|
1471 |
} |
|
1472 |
||
1473 |
inline const TMMCMachineInfo& DMMCSocket::MachineInfo() const |
|
1474 |
/** |
|
1475 |
* Returns a reference to the MachineInfo retrieved from the PSL |
|
1476 |
* @return a reference to the MachineInfo |
|
1477 |
*/ |
|
1478 |
{return iMachineInfo;} |
|
1479 |
||
1480 |
// -------- class TMMCPsu -------- |
|
1481 |
||
1482 |
inline void DMMCPsu::SetVoltage(TUint32 aVoltage) |
|
1483 |
/** |
|
1484 |
* Specifies the voltage setting to be used when the stack is next powered up. |
|
1485 |
* @param aVoltage The required voltage setting, in OCR register format. |
|
1486 |
*/ |
|
1487 |
{iVoltageSetting=aVoltage;} |
|
1488 |
||
1489 |
// -------- Class TMMCCallBack -------- |
|
1490 |
/** |
|
1491 |
* Default constructor. Initializes the pointer to the callback function to NULL. |
|
1492 |
* @see iFunction |
|
1493 |
*/ |
|
1494 |
inline TMMCCallBack::TMMCCallBack() |
|
1495 |
{iFunction=NULL;} |
|
1496 |
||
1497 |
/** |
|
1498 |
* Constructs the TMMCCallBack object with the specified callback function. |
|
1499 |
* @param aFunction Callback notification function. |
|
1500 |
*/ |
|
1501 |
inline TMMCCallBack::TMMCCallBack(void (*aFunction)(TAny *aPtr)) |
|
1502 |
: iFunction(aFunction),iPtr(NULL) |
|
1503 |
{} |
|
1504 |
/** |
|
1505 |
* Constructs the TMMCCallBack object with the specified callback function and a pointer to any object. |
|
1506 |
* @param aFunction Callback notification function. |
|
1507 |
* @param aPtr Pointer to any data. |
|
1508 |
*/ |
|
1509 |
inline TMMCCallBack::TMMCCallBack(void (*aFunction)(TAny *aPtr),TAny *aPtr) |
|
1510 |
: iFunction(aFunction),iPtr(aPtr) |
|
1511 |
{} |
|
1512 |
/** |
|
1513 |
* Calls the registered callback function. |
|
1514 |
*/ |
|
1515 |
inline void TMMCCallBack::CallBack() const |
|
1516 |
{ if(iFunction) (*iFunction)(iPtr); } |
|
1517 |
||
1518 |
// -------- class TMMCEraseInfo -------- |
|
1519 |
||
1520 |
inline TBool TMMCEraseInfo::EraseClassCmdsSupported() const |
|
1521 |
/** |
|
1522 |
* Returns ETrue if Erase Class commands are supported. |
|
1523 |
* @return ETrue if Erase Class commands are supported. |
|
1524 |
*/ |
|
1525 |
{return(iEraseFlags&KMMCEraseClassCmdsSupported);} |
|
1526 |
||
1527 |
inline TBool TMMCEraseInfo::EraseGroupCmdsSupported() const |
|
1528 |
/** |
|
1529 |
* Returns ETrue if Erase Group commands are supported. |
|
1530 |
* @return ETrue if Erase Group commands are supported. |
|
1531 |
*/ |
|
1532 |
{return(iEraseFlags&KMMCEraseGroupCmdsSupported);} |