author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 11 May 2010 17:28:22 +0300 | |
branch | RCL_3 |
changeset 110 | c734af59ce98 |
parent 0 | a41df078684a |
child 244 | a77889bee936 |
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 |
// Generic MMC controller types and standard classes for MMC manipulation |
|
15 |
// This controller follows MMC spec V2.1 |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
/** |
|
20 |
@file |
|
21 |
@internalComponent |
|
22 |
*/ |
|
23 |
||
24 |
#if !defined(__MMC_H__) |
|
25 |
#define __MMC_H__ |
|
26 |
||
27 |
#include <drivers/pbus.h> |
|
28 |
#include <d32locd.h> |
|
29 |
||
30 |
// MMC Card maximum system settings |
|
31 |
||
32 |
const TInt KMaxMmcSockets = KMaxPBusSockets; |
|
33 |
||
34 |
// Forward type declarations |
|
35 |
||
36 |
class TMMC; |
|
37 |
class TCID; |
|
38 |
class TCSD; |
|
39 |
class TExtendedCSD; |
|
40 |
class TRCA; |
|
41 |
class TDSR; |
|
42 |
class TMMCStatus; |
|
43 |
class TMMCArgument; |
|
44 |
class TMMCard; |
|
45 |
class TMMCCommandDesc; |
|
46 |
class TMMCBusConfig; |
|
47 |
class TMMCStackConfig; |
|
48 |
class TMMCRCAPool; |
|
49 |
class TMMCSessRing; |
|
50 |
class TMMCStateMachine; |
|
51 |
class DMMCSocket; |
|
52 |
class DMMCSession; |
|
53 |
class DMMCStack; |
|
54 |
class TMMCMachineInfo; |
|
55 |
class TMapping; |
|
56 |
class TMMCPasswordStore; |
|
57 |
class TMMCEraseInfo; |
|
58 |
class TMMCMachineInfoV4; |
|
59 |
typedef TPckg<TMMCMachineInfoV4> TMMCMachineInfoV4Pckg; |
|
60 |
||
61 |
enum TMMCAppCommand {EMMCNormalCmd,EMMCApplicationCmd}; |
|
62 |
||
63 |
// Typedefs |
|
64 |
||
65 |
/** |
|
66 |
@publishedPartner |
|
67 |
@released |
|
68 |
||
69 |
Represents the MultiMediaCard error code bit set. |
|
70 |
||
71 |
MultiMediaCard error codes are defined as bit masks, mainly for use with |
|
72 |
the state machine where the error trap mask may be used. |
|
73 |
The function DMMCSession::EpocErrorCode() converts these error bit values |
|
74 |
into standard Symbian OS error values. |
|
75 |
||
76 |
@see KMMCErrNone |
|
77 |
@see KMMCErrResponseTimeOut |
|
78 |
@see KMMCErrDataTimeOut |
|
79 |
@see KMMCErrBusyTimeOut |
|
80 |
@see KMMCErrBusTimeOut |
|
81 |
@see KMMCErrTooManyCards |
|
82 |
@see KMMCErrResponseCRC |
|
83 |
@see KMMCErrDataCRC |
|
84 |
@see KMMCErrCommandCRC |
|
85 |
@see KMMCErrStatus |
|
86 |
@see KMMCErrNoCard |
|
87 |
@see KMMCErrBrokenLock |
|
88 |
@see KMMCErrPowerDown |
|
89 |
@see KMMCErrAbort |
|
90 |
@see KMMCErrStackNotReady |
|
91 |
@see KMMCErrNotSupported |
|
92 |
@see KMMCErrHardware |
|
93 |
@see KMMCErrBusInconsistent |
|
94 |
@see KMMCErrBypass |
|
95 |
@see KMMCErrInitContext |
|
96 |
@see KMMCErrArgument |
|
97 |
@see KMMCErrSingleBlock |
|
98 |
@see KMMCErrLocked |
|
99 |
@see KMMCErrNotFound |
|
100 |
@see KMMCErrAlreadyExists |
|
101 |
@see KMMCErrGeneral |
|
102 |
@see KMMCErrAll |
|
103 |
@see KMMCErrBasic |
|
104 |
*/ |
|
105 |
typedef TUint32 TMMCErr; |
|
106 |
||
107 |
// MMC Enums and inline functions |
|
108 |
||
109 |
||
110 |
||
111 |
||
112 |
/** |
|
113 |
@publishedPartner |
|
114 |
@released |
|
115 |
||
116 |
Defines a set of symbols corresponding to the MultiMediaCard bus commands. |
|
117 |
||
118 |
A command is one of the parameter values inserted into a TMMCCommandDesc object. |
|
119 |
The commands themselves are defined by the MultiMediaCard specification. |
|
120 |
||
121 |
@see TMMCCommandDesc |
|
122 |
*/ |
|
123 |
enum TMMCCommandEnum |
|
124 |
{ |
|
125 |
/** |
|
126 |
CMD0; reset all cards to idle state. |
|
127 |
*/ |
|
128 |
ECmdGoIdleState =0, |
|
129 |
||
130 |
||
131 |
/** |
|
132 |
CMD1; all cards in the idle state send their operating conditions. |
|
133 |
*/ |
|
134 |
ECmdSendOpCond =1, |
|
135 |
||
136 |
||
137 |
/** |
|
138 |
CMD2; all cards send their CID number. |
|
139 |
*/ |
|
140 |
ECmdAllSendCID =2, |
|
141 |
||
142 |
||
143 |
/** |
|
144 |
CMD3; assign relative address to a card. |
|
145 |
*/ |
|
146 |
ECmdSetRelativeAddr =3, |
|
147 |
||
148 |
||
149 |
/** |
|
150 |
CMD4; program the DSR register of all cards. |
|
151 |
*/ |
|
152 |
ECmdSetDSR =4, |
|
153 |
||
154 |
||
155 |
/** |
|
156 |
CMD5; toggle device between Sleep and Awake states. |
|
157 |
*/ |
|
158 |
ECmd5 =5, |
|
159 |
ECmdSleepAwake =5, |
|
160 |
||
161 |
||
162 |
/** |
|
163 |
CMD6; Switch |
|
164 |
*/ |
|
165 |
ECmd6 =6, |
|
166 |
ECmdSwitch =6, |
|
167 |
||
168 |
||
169 |
/** |
|
170 |
CMD7; toggle a card between standby and transfer state, or between |
|
171 |
programming and disconnected state. |
|
172 |
||
173 |
The card is selected by its RCA and deselected by any other address. |
|
174 |
*/ |
|
175 |
ECmdSelectCard =7, |
|
176 |
||
177 |
||
178 |
/** |
|
179 |
CMD8; addressed card sends its extended CSD. |
|
180 |
*/ |
|
181 |
ECmd8 =8, |
|
182 |
ECmdSendExtendedCSD =8, |
|
183 |
||
184 |
||
185 |
/** |
|
186 |
CMD9; addressed card sends its CSD. |
|
187 |
*/ |
|
188 |
ECmdSendCSD =9, |
|
189 |
||
190 |
||
191 |
/** |
|
192 |
CMD10; addressed card sends its CID. |
|
193 |
*/ |
|
194 |
ECmdSendCID =10, |
|
195 |
||
196 |
||
197 |
/** |
|
198 |
CMD11; read data stream from the card starting at the given address until |
|
199 |
an ECmdStopTransmission follows. |
|
200 |
||
201 |
@see ECmdStopTransmission |
|
202 |
*/ |
|
203 |
ECmdReadDatUntilStop =11, |
|
204 |
||
205 |
||
206 |
/** |
|
207 |
CMD12; force the card to stop transmission. |
|
208 |
*/ |
|
209 |
ECmdStopTransmission =12, |
|
210 |
||
211 |
||
212 |
/** |
|
213 |
CMD13; addressed card sends its status register. |
|
214 |
*/ |
|
215 |
ECmdSendStatus =13, |
|
216 |
||
217 |
||
218 |
/** |
|
219 |
CMD14; BUSTEST_R - Reads the reversed bus testing data pattern from the card. |
|
220 |
||
221 |
@see ECmdBustest_W |
|
222 |
*/ |
|
223 |
ECmd14 =14, |
|
224 |
ECmdBustest_R =14, |
|
225 |
||
226 |
||
227 |
/** |
|
228 |
CMD15; set the card to the inactive state. |
|
229 |
*/ |
|
230 |
ECmdGoInactiveState =15, |
|
231 |
||
232 |
||
233 |
/** |
|
234 |
CMD16; set the block length for all following block commands. |
|
235 |
*/ |
|
236 |
ECmdSetBlockLen =16, |
|
237 |
||
238 |
||
239 |
/** |
|
240 |
CMD17; read a single data block from the card. |
|
241 |
*/ |
|
242 |
ECmdReadSingleBlock =17, |
|
243 |
||
244 |
||
245 |
/** |
|
246 |
CMD18; continuously transfer data blocks from the card until interrupted |
|
247 |
by ECmdStopTransmission. |
|
248 |
||
249 |
@see ECmdStopTransmission |
|
250 |
*/ |
|
251 |
ECmdReadMultipleBlock =18, |
|
252 |
||
253 |
||
254 |
/** |
|
255 |
CMD19; BUSTEST_W - Sends a test data pattern to the card to determine the bus characteristics |
|
256 |
||
257 |
@see ECmdBustest_R |
|
258 |
*/ |
|
259 |
ECmd19 =19, |
|
260 |
ECmdBustest_W =19, |
|
261 |
||
262 |
||
263 |
/** |
|
264 |
CMD20; write data stream from the host starting at the given address |
|
265 |
until interrupted by ECmdStopTransmission. |
|
266 |
||
267 |
@see ECmdStopTransmission |
|
268 |
*/ |
|
269 |
ECmdWriteDatUntilStop =20, |
|
270 |
||
271 |
||
272 |
/** |
|
273 |
CMD21; reserved for future use. |
|
274 |
*/ |
|
275 |
ECmd21 =21, |
|
276 |
||
277 |
||
278 |
/** |
|
279 |
CMD22; reserved for future use. |
|
280 |
*/ |
|
281 |
ECmd22 =22, |
|
282 |
||
283 |
||
284 |
/** |
|
285 |
CMD23; define the number of blocks to be transferred in the following |
|
286 |
multiple block read or write command. |
|
287 |
*/ |
|
288 |
ECmdSetBlockCount =23, |
|
289 |
||
290 |
||
291 |
/** |
|
292 |
CMD24; write a single block to the card. |
|
293 |
*/ |
|
294 |
ECmdWriteBlock =24, |
|
295 |
||
296 |
||
297 |
/** |
|
298 |
CMD25; continuously transfer data blocks to the card until interrupted |
|
299 |
by ECmdStopTransmission. |
|
300 |
||
301 |
@see ECmdStopTransmission |
|
302 |
*/ |
|
303 |
ECmdWriteMultipleBlock =25, |
|
304 |
||
305 |
||
306 |
/** |
|
307 |
CMD26; programming of the CID. |
|
308 |
||
309 |
This is issued once per card, and is normally reserved for |
|
310 |
the manufacturer. |
|
311 |
*/ |
|
312 |
ECmdProgramCID =26, |
|
313 |
||
314 |
||
315 |
/** |
|
316 |
CMD27; programming of the programmable bits of the CSD. |
|
317 |
*/ |
|
318 |
ECmdProgramCSD =27, |
|
319 |
||
320 |
||
321 |
/** |
|
322 |
CMD28; set the write protect bit of the addressed group, if the card has |
|
323 |
write protection features. |
|
324 |
*/ |
|
325 |
ECmdSetWriteProt =28, |
|
326 |
||
327 |
||
328 |
/** |
|
329 |
CMD29; clear the write protect bit of the addressed group, if the card has |
|
330 |
write protection features. |
|
331 |
*/ |
|
332 |
ECmdClearWriteProt =29, |
|
333 |
||
334 |
||
335 |
/** |
|
336 |
CMD30; ask the card to send the status of the write protect bit, if |
|
337 |
the card has write protection features. |
|
338 |
*/ |
|
339 |
ECmdSendWriteProt =30, |
|
340 |
||
341 |
||
342 |
/** |
|
343 |
CMD31; reserved for future use. |
|
344 |
*/ |
|
345 |
ECmd31 =31, |
|
346 |
||
347 |
||
348 |
/** |
|
349 |
CMD32; set the address of the first sector of the erase group. |
|
350 |
*/ |
|
351 |
ECmdTagSectorStart =32, |
|
352 |
||
353 |
||
354 |
/** |
|
355 |
CMD33; set the address of the last sector in a continuous range within |
|
356 |
the selected erase group, or the address of a single sector to be |
|
357 |
selected for erase. |
|
358 |
*/ |
|
359 |
ECmdTagSectorEnd =33, |
|
360 |
||
361 |
||
362 |
/** |
|
363 |
CMD34; remove one previously selected sector from the erase selection. |
|
364 |
*/ |
|
365 |
ECmdUntagSector =34, |
|
366 |
||
367 |
||
368 |
/** |
|
369 |
CMD35; set the the address of the first erase group within a continuous |
|
370 |
range to be selected for erase. |
|
371 |
*/ |
|
372 |
ECmdTagEraseGroupStart =35, |
|
373 |
||
374 |
||
375 |
/** |
|
376 |
CMD36; set the address of the last erase group within a continuous range |
|
377 |
to be selected for erase. |
|
378 |
*/ |
|
379 |
ECmdTagEraseGroupEnd =36, |
|
380 |
||
381 |
||
382 |
/** |
|
383 |
CMD37; removes one previously selected erase group from the erase selection. |
|
384 |
*/ |
|
385 |
ECmdUntagEraseGroup =37, |
|
386 |
||
387 |
||
388 |
/** |
|
389 |
CMD38; erase all previously selected sectors. |
|
390 |
*/ |
|
391 |
ECmdErase =38, |
|
392 |
||
393 |
||
394 |
/** |
|
395 |
CMD39; read and write 8 bit (register) data fields. |
|
396 |
*/ |
|
397 |
ECmdFastIO =39, |
|
398 |
||
399 |
||
400 |
/** |
|
401 |
CMD40; set the system into interrupt mode. |
|
402 |
*/ |
|
403 |
ECmdGoIRQState =40, |
|
404 |
||
405 |
||
406 |
/** |
|
407 |
CMD41; reserved for future use. |
|
408 |
*/ |
|
409 |
ECmd41 =41, |
|
410 |
||
411 |
||
412 |
/** |
|
413 |
CMD42; set/reset the password or lock/unlock the card. |
|
414 |
*/ |
|
415 |
ECmdLockUnlock =42, |
|
416 |
||
417 |
||
418 |
/** |
|
419 |
CMD43; reserved for future use. |
|
420 |
*/ |
|
421 |
ECmd43 =43, |
|
422 |
||
423 |
||
424 |
/** |
|
425 |
CMD44; reserved for future use. |
|
426 |
*/ |
|
427 |
ECmd44 =44, |
|
428 |
||
429 |
||
430 |
/** |
|
431 |
CMD45; reserved for future use. |
|
432 |
*/ |
|
433 |
ECmd45 =45, |
|
434 |
||
435 |
||
436 |
/** |
|
437 |
CMD46; reserved for future use. |
|
438 |
*/ |
|
439 |
ECmd46 =46, |
|
440 |
||
441 |
||
442 |
/** |
|
443 |
CMD47; reserved for future use. |
|
444 |
*/ |
|
445 |
ECmd47 =47, |
|
446 |
||
447 |
||
448 |
/** |
|
449 |
CMD48; reserved for future use. |
|
450 |
*/ |
|
451 |
ECmd48 =48, |
|
452 |
||
453 |
||
454 |
/** |
|
455 |
CMD49; reserved for future use. |
|
456 |
*/ |
|
457 |
ECmd49 =49, |
|
458 |
||
459 |
||
460 |
/** |
|
461 |
CMD50; reserved for future use. |
|
462 |
*/ |
|
463 |
ECmd50 =50, |
|
464 |
||
465 |
||
466 |
/** |
|
467 |
CMD51; reserved for future use. |
|
468 |
*/ |
|
469 |
ECmd51 =51, |
|
470 |
||
471 |
||
472 |
/** |
|
473 |
CMD52; reserved for future use. |
|
474 |
*/ |
|
475 |
ECmd52 =52, |
|
476 |
||
477 |
||
478 |
/** |
|
479 |
CMD53; reserved for future use. |
|
480 |
*/ |
|
481 |
ECmd53 =53, |
|
482 |
||
483 |
||
484 |
/** |
|
485 |
CMD54; reserved for future use. |
|
486 |
*/ |
|
487 |
ECmd54 =54, |
|
488 |
||
489 |
||
490 |
/** |
|
491 |
CMD55; indicate to the card that the next command is an application |
|
492 |
specific command rather than a standard command. |
|
493 |
*/ |
|
494 |
ECmdAppCmd =55, |
|
495 |
||
496 |
||
497 |
/** |
|
498 |
CMD56; transfer a data block to the card, or get a data block from the card, |
|
499 |
for general purpose/application specific commands. |
|
500 |
*/ |
|
501 |
ECmdGenCmd =56, |
|
502 |
||
503 |
||
504 |
/** |
|
505 |
CMD57; reserved for future use. |
|
506 |
*/ |
|
507 |
ECmd57 =57, |
|
508 |
||
509 |
||
510 |
/** |
|
511 |
CMD58; reserved for future use. |
|
512 |
*/ |
|
513 |
ECmd58 =58, |
|
514 |
||
515 |
||
516 |
/** |
|
517 |
CMD59; reserved for future use. |
|
518 |
*/ |
|
519 |
ECmd59 =59, |
|
520 |
||
521 |
||
522 |
/** |
|
523 |
CMD60; reserved for future use. |
|
524 |
*/ |
|
525 |
ECmd60 =60, |
|
526 |
||
527 |
||
528 |
/** |
|
529 |
CMD61; reserved for future use. |
|
530 |
*/ |
|
531 |
ECmd61 =61, |
|
532 |
||
533 |
||
534 |
/** |
|
535 |
CMD62; reserved for future use. |
|
536 |
*/ |
|
537 |
ECmd62 =62, |
|
538 |
||
539 |
||
540 |
/** |
|
541 |
CMD63; reserved for future use. |
|
542 |
*/ |
|
543 |
ECmd63 =63 |
|
544 |
}; |
|
545 |
||
546 |
enum TMMCCommandTypeEnum |
|
547 |
{ |
|
548 |
ECmdTypeUK, // UnKnown command type |
|
549 |
ECmdTypeBC, // Broadcast Command |
|
550 |
ECmdTypeBCR, // Broadcast Command with Response |
|
551 |
ECmdTypeAC, // Addressed Command |
|
552 |
ECmdTypeACS, // Addressed Command to a Selected card |
|
553 |
ECmdTypeADTCS, // Addressed Data Transfer Command to a Selected card |
|
554 |
ECmdTypeADC // Addressed Direct Command to a Selected card |
|
555 |
}; |
|
556 |
||
557 |
enum TMMCResponseTypeEnum |
|
558 |
{ |
|
559 |
ERespTypeNone, |
|
560 |
ERespTypeUnknown, |
|
561 |
ERespTypeR1, // 32 bits Status |
|
562 |
ERespTypeR1B, // 32 bits Status with possible busy signal |
|
563 |
ERespTypeR2, // 128 bits CID or CSD register |
|
564 |
ERespTypeR3, // 32 bits OCR register |
|
565 |
ERespTypeR4, // 32 bits Fast I/O |
|
566 |
ERespTypeR5, // 32 bits IRQ |
|
567 |
ERespTypeR6, |
|
568 |
ERespTypeR7 // not currently defined for MMC |
|
569 |
}; |
|
570 |
||
571 |
||
572 |
/** |
|
573 |
@publishedPartner |
|
574 |
@released |
|
575 |
||
576 |
Defines the set of media types for a MultiMediaCard. |
|
577 |
*/ |
|
578 |
enum TMMCMediaTypeEnum |
|
579 |
{ |
|
580 |
/** |
|
581 |
A read only card. |
|
582 |
*/ |
|
583 |
EMultiMediaROM, |
|
584 |
||
585 |
||
586 |
/** |
|
587 |
A writable card. |
|
588 |
*/ |
|
589 |
EMultiMediaFlash, |
|
590 |
||
591 |
||
592 |
/** |
|
593 |
An I/O card. |
|
594 |
*/ |
|
595 |
EMultiMediaIO, |
|
596 |
||
597 |
||
598 |
/** |
|
599 |
A card type that is neither read only, writable nor I/O. |
|
600 |
*/ |
|
601 |
EMultiMediaOther, |
|
602 |
||
603 |
||
604 |
/** |
|
605 |
A card type that is not supported. |
|
606 |
*/ |
|
607 |
EMultiMediaNotSupported |
|
608 |
}; |
|
609 |
||
610 |
enum TMMCSessionTypeEnum |
|
611 |
{ |
|
612 |
ECIMNakedSession =0, |
|
613 |
ECIMUpdateAcq =1, |
|
614 |
ECIMInitStack =2, |
|
615 |
ECIMCheckStack =3, |
|
616 |
ECIMSetupCard =4, |
|
617 |
ECIMReadBlock =5, |
|
618 |
ECIMWriteBlock =6, |
|
619 |
ECIMReadMBlock =7, |
|
620 |
ECIMWriteMBlock =8, |
|
621 |
ECIMEraseSector =9, |
|
622 |
ECIMEraseGroup =10, |
|
623 |
ECIMReadIO =11, |
|
624 |
ECIMWriteIO =12, |
|
625 |
ECIMLockUnlock =13, |
|
626 |
ECIMLockStack =14, |
|
627 |
ECIMInitStackAfterUnlock =15, |
|
628 |
ECIMAutoUnlock =16, |
|
629 |
ECIMSleep =17 |
|
630 |
}; |
|
631 |
||
632 |
const TUint KMMCMaxSessionTypeNumber = 18; |
|
633 |
const TUint KMMCMinCustomSession = 1024; |
|
634 |
||
635 |
const TUint KMMCCmdDirDirBitPosition= KBit0; //fixed - dont change it |
|
636 |
const TUint KMMCCmdDirIndBitPosition= (KBit5-KBit0); //fixed - dont change it |
|
637 |
const TUint KMMCCmdDirWBitArgument= KBit5; |
|
638 |
const TUint KMMCCmdDirNegate= KBit6; |
|
639 |
const TUint KMMCCmdDirWBitDirect= KBit7; |
|
640 |
||
641 |
const TUint KMMCCmdReliableWrite = KBit31; |
|
642 |
||
643 |
||
644 |
/** |
|
645 |
@publishedPartner |
|
646 |
@released |
|
647 |
||
648 |
An enum whose values specify the data transfer direction. |
|
649 |
||
650 |
@see TMMCCommandSpec |
|
651 |
*/ |
|
652 |
enum TMMCCmdDirEnum |
|
653 |
{ |
|
654 |
EDirNone = 0, |
|
655 |
EDirRead = KMMCCmdDirWBitDirect, |
|
656 |
EDirWrite = KMMCCmdDirWBitDirect|KMMCCmdDirDirBitPosition, |
|
657 |
EDirWBit0 = KMMCCmdDirWBitArgument + 0, |
|
658 |
EDirRBit0 = (KMMCCmdDirWBitArgument|KMMCCmdDirNegate) + 0 |
|
659 |
}; |
|
660 |
||
661 |
||
662 |
||
663 |
||
664 |
/** |
|
665 |
@publishedPartner |
|
666 |
@released |
|
667 |
||
668 |
An enum whose values specify the width of the data bus |
|
669 |
||
670 |
This enum is used by the DMMCStack::SetBusWidth() and TMMCMachineInfo.iMaxBusWidth. |
|
671 |
*/ |
|
672 |
enum TBusWidth |
|
673 |
{ |
|
674 |
EBusWidth1 = 0x00, |
|
675 |
EBusWidth4 = 0x02, |
|
676 |
EBusWidth8 = 0x03, |
|
677 |
EBusWidthInvalid = KMaxTUint32 |
|
678 |
}; |
|
679 |
||
680 |
/** |
|
681 |
@publishedPartner |
|
682 |
@released |
|
683 |
*/ |
|
684 |
const TUint8 KMMCLockUnlockErase = KBit3; // In first byte of CMD42 data block |
|
685 |
||
686 |
/** |
|
687 |
@publishedPartner |
|
688 |
@released |
|
689 |
*/ |
|
690 |
const TUint8 KMMCLockUnlockLockUnlock = KBit2; |
|
691 |
||
692 |
/** |
|
693 |
@publishedPartner |
|
694 |
@released |
|
695 |
*/ |
|
696 |
const TUint8 KMMCLockUnlockClrPwd = KBit1; |
|
697 |
||
698 |
/** |
|
699 |
@publishedPartner |
|
700 |
@released |
|
701 |
*/ |
|
702 |
const TUint8 KMMCLockUnlockSetPwd = KBit0; |
|
703 |
||
704 |
||
705 |
||
706 |
||
707 |
/** |
|
708 |
@publishedPartner |
|
709 |
@released |
|
710 |
||
711 |
A utility class that contains convenience functions to handle conversion |
|
712 |
to and from big-endian format. |
|
713 |
*/ |
|
714 |
class TMMC |
|
715 |
{ |
|
716 |
public: |
|
717 |
static inline TUint32 BigEndian32(const TUint8*); |
|
718 |
static inline void BigEndian4Bytes(TUint8* aPtr, TUint32 aVal); |
|
719 |
}; |
|
720 |
||
721 |
||
722 |
// Generic MMC layer constants |
|
723 |
||
724 |
const TInt KMaxMMCStacks=1; // Number of separate MMC buses |
|
725 |
const TUint KMaxMMCardsPerStack=4; // Limits the number of cards in each stack |
|
726 |
||
727 |
const TUint KBroadcastToAllCards=0xFFFFFFFF; |
|
728 |
||
729 |
// MMC Spec related constants |
|
730 |
||
731 |
const TUint KMMCMaxResponseLength=16; // in bytes |
|
732 |
const TUint KMMCCIDLength=16; |
|
733 |
const TUint KMMCCSDLength=16; |
|
734 |
const TUint KMMCExtendedCSDLength=512; |
|
735 |
const TUint KMMCBusClockFOD=400; // Identification clock in kiloherz |
|
736 |
const TUint KMMCCommandMask = 63; // Size of TMMCCommandEnum enumerator |
|
737 |
||
738 |
// Command Classes Bit Set |
|
739 |
||
740 |
/** |
|
741 |
@publishedPartner |
|
742 |
@released |
|
743 |
*/ |
|
744 |
const TUint32 KMMCCmdClassNone= 0; |
|
745 |
||
746 |
/** |
|
747 |
@publishedPartner |
|
748 |
@released |
|
749 |
*/ |
|
750 |
const TUint32 KMMCCmdClassBasic= KBit0; |
|
751 |
||
752 |
/** |
|
753 |
@publishedPartner |
|
754 |
@released |
|
755 |
*/ |
|
756 |
const TUint32 KMMCCmdClassStreamRead= KBit1; |
|
757 |
||
758 |
/** |
|
759 |
@publishedPartner |
|
760 |
@released |
|
761 |
*/ |
|
762 |
const TUint32 KMMCCmdClassBlockRead= KBit2; |
|
763 |
||
764 |
/** |
|
765 |
@publishedPartner |
|
766 |
@released |
|
767 |
*/ |
|
768 |
const TUint32 KMMCCmdClassStreamWrite= KBit3; |
|
769 |
||
770 |
/** |
|
771 |
@publishedPartner |
|
772 |
@released |
|
773 |
*/ |
|
774 |
const TUint32 KMMCCmdClassBlockWrite= KBit4; |
|
775 |
||
776 |
/** |
|
777 |
@publishedPartner |
|
778 |
@released |
|
779 |
*/ |
|
780 |
const TUint32 KMMCCmdClassErase= KBit5; |
|
781 |
||
782 |
/** |
|
783 |
@publishedPartner |
|
784 |
@released |
|
785 |
*/ |
|
786 |
const TUint32 KMMCCmdClassWriteProtection=KBit6; |
|
787 |
||
788 |
/** |
|
789 |
@publishedPartner |
|
790 |
@released |
|
791 |
*/ |
|
792 |
const TUint32 KMMCCmdClassLockCard= KBit7; |
|
793 |
||
794 |
/** |
|
795 |
@publishedPartner |
|
796 |
@released |
|
797 |
*/ |
|
798 |
const TUint32 KMMCCmdClassApplication= KBit8; |
|
799 |
||
800 |
/** |
|
801 |
@publishedPartner |
|
802 |
@released |
|
803 |
*/ |
|
804 |
const TUint32 KMMCCmdClassIOMode= KBit9; |
|
805 |
||
806 |
/** |
|
807 |
@publishedPartner |
|
808 |
@released |
|
809 |
*/ |
|
810 |
const TUint32 KMMCCmdClassReserved10= KBit10; |
|
811 |
const TUint32 KMMCCmdClassSwitch= KBit10; |
|
812 |
||
813 |
/** |
|
814 |
@publishedPartner |
|
815 |
@released |
|
816 |
*/ |
|
817 |
const TUint32 KMMCCmdClassReserved11= KBit11; |
|
818 |
||
819 |
// Specific MMC implementation constants |
|
820 |
||
821 |
const TUint KMaxMMCMachineStackDepth=20; // TMMCStateMachine stack depth |
|
822 |
const TUint KMaxMMCCommandStackDepth=9; // Session TMMCCommandDesc stack depth |
|
823 |
const TUint KMMCIdleCommandsAtRestart=2; // Number of CMD0s to be issued at initialisation |
|
824 |
const TUint KMMCMaxJobsInStackWorkSet=8; // Number of sessions simultaneously served |
|
825 |
const TUint KMMCPollGapInMilliseconds=40; |
|
826 |
const TUint KMMCMaxPollAttempts=5; // 40*5 = 200ms |
|
827 |
const TUint KMMCRetryGapInMilliseconds=10; |
|
828 |
const TUint KMMCMaxTimeOutRetries=1; |
|
829 |
const TUint KMMCMaxCRCRetries=1; |
|
830 |
const TUint16 KMMCMaxUnlockRetries=4; |
|
831 |
const TUint16 KMMCMaxAutoUnlockRetries=25; |
|
832 |
const TUint KMMCMaxGlobalRetries=1; |
|
833 |
const TUint16 KMMCSpecOpCondBusyTimeout=100 ; //MMC/SD Standard OCR timeout 1 second |
|
834 |
const TUint16 KMMCMaxOpCondBusyTimeout=150; // 10*150 = 1500ms |
|
835 |
const TUint KMMCLowVoltagePowerUpTimeoutInMilliseconds=2; // 1ms + 74 400KHz clock cycles |
|
836 |
const TUint KMMCUnlockRetryGapInMilliseconds = 200; // Unlock retry gap |
|
837 |
||
838 |
// DMMCStack Modes Bit Set |
|
839 |
const TUint32 KMMCModeEnableClientConfig = KBit0; // Merge with session iConfig |
|
840 |
const TUint32 KMMCModeEnableTimeOutRetry = KBit1; // Auto retry on response time-outs |
|
841 |
const TUint32 KMMCModeTimeOutRetryGap = KBit2; // Force timer delay between retries |
|
842 |
const TUint32 KMMCModeEnableCRCRetry = KBit3; // Command or response CRC errors |
|
843 |
const TUint32 KMMCModeCRCRetryGap = KBit4; |
|
844 |
const TUint32 KMMCModeDataCRCRetry = KBit5; // Repeat data transaction from the last valid position |
|
845 |
const TUint32 KMMCModeEnableUnlockRetry = KBit6; // Resend CMD42 for unreliable cards |
|
846 |
const TUint32 KMMCModeEnablePreemption = KBit7; // Allow sessions to share the MMC bus |
|
847 |
const TUint32 KMMCModePreemptOnBusy = KBit8; // Release bus control if busy |
|
848 |
const TUint32 KMMCModePreemptOnRetry = KBit9; // Release bus control before timeout/crc retries |
|
849 |
const TUint32 KMMCModePreemptInGaps = KBit10; // Preempt whenever gap timer is invoked |
|
850 |
const TUint32 KMMCModeEnqueIfLocked = KBit11; // Enque session if DMMCStack is locked |
|
851 |
const TUint32 KMMCModeCardControlled = KBit12; // Use Session CardP to get RCAs etc. |
|
852 |
const TUint32 KMMCModeCompleteInStackDFC = KBit13; // Run DMMCStack in DFC when completing |
|
853 |
const TUint32 KMMCModeEnableBusyPoll = KBit14; // Enables mechanism recovering from busy timeouts |
|
854 |
const TUint32 KMMCModeBusyPollGap = KBit15; |
|
855 |
const TUint32 KMMCModeEnableRetries = KBit16; // This mode removed disables all retries/polls |
|
856 |
const TUint32 KMMCModeMask = KBit17 - KBit0; |
|
857 |
||
858 |
// The following modes are effective for MasterConfig only |
|
859 |
const TUint32 KMMCModeClientPollAttempts = KBit20; |
|
860 |
const TUint32 KMMCModeClientTimeOutRetries = KBit21; |
|
861 |
const TUint32 KMMCModeClientCRCRetries = KBit22; |
|
862 |
const TUint32 KMMCModeClientUnlockRetries = KBit23; |
|
863 |
const TUint32 KMMCModeClientBusClock = KBit24; |
|
864 |
const TUint32 KMMCModeClientClockIn = KBit25; |
|
865 |
const TUint32 KMMCModeClientClockOut = KBit26; |
|
866 |
const TUint32 KMMCModeClientResponseTimeOut = KBit27; |
|
867 |
const TUint32 KMMCModeClientDataTimeOut = KBit28; |
|
868 |
const TUint32 KMMCModeClientBusyTimeOut = KBit29; |
|
869 |
const TUint32 KMMCModeClientiOpCondBusyTimeout = KBit30; |
|
870 |
const TUint32 KMMCModeClientMask = KBit31 - KBit20; |
|
871 |
||
872 |
// The following modes cannot be enabled by a client if disabled in MasterConfig |
|
873 |
const TUint32 KMMCModeMasterOverrides= |
|
874 |
KMMCModeEnableClientConfig | |
|
875 |
KMMCModeEnablePreemption | |
|
876 |
KMMCModeEnqueIfLocked | |
|
877 |
KMMCModeClientMask; |
|
878 |
||
879 |
// The following modes are always effective, even if the ClientConfig is disabled |
|
880 |
const TUint32 KMMCModeClientOverrides= |
|
881 |
KMMCModeEnableClientConfig | |
|
882 |
KMMCModeCardControlled; |
|
883 |
||
884 |
||
885 |
// The default MasterConfig modes |
|
886 |
const TUint32 KMMCModeDefault= KMMCModeEnableClientConfig | |
|
887 |
KMMCModeEnableRetries | |
|
888 |
KMMCModeEnableTimeOutRetry | |
|
889 |
KMMCModeTimeOutRetryGap | |
|
890 |
KMMCModeEnableCRCRetry | |
|
891 |
KMMCModeCRCRetryGap | |
|
892 |
KMMCModeDataCRCRetry | |
|
893 |
KMMCModeEnableUnlockRetry | |
|
894 |
KMMCModeEnablePreemption | |
|
895 |
KMMCModePreemptInGaps | |
|
896 |
KMMCModeEnqueIfLocked | |
|
897 |
KMMCModeCardControlled | |
|
898 |
KMMCModeClientMask; |
|
899 |
||
900 |
||
901 |
// MMC Error Code Bit Set |
|
902 |
||
903 |
/** |
|
904 |
@publishedPartner |
|
905 |
@released |
|
906 |
||
907 |
A MultiMediaCard error code. |
|
908 |
||
909 |
Indicates no error. |
|
910 |
||
911 |
@see TMMCErr |
|
912 |
*/ |
|
913 |
const TUint32 KMMCErrNone=0; |
|
914 |
||
915 |
||
916 |
/** |
|
917 |
@publishedPartner |
|
918 |
@released |
|
919 |
||
920 |
A MultiMediaCard error code. |
|
921 |
||
922 |
Timed out waiting for a response from the card after issuing a command. |
|
923 |
||
924 |
@see TMMCErr |
|
925 |
*/ |
|
926 |
const TUint32 KMMCErrResponseTimeOut=KBit0; |
|
927 |
||
928 |
||
929 |
/** |
|
930 |
@publishedPartner |
|
931 |
@released |
|
932 |
||
933 |
A MultiMediaCard error code. |
|
934 |
||
935 |
Timed out waiting for a data block to be received during a data read command. |
|
936 |
||
937 |
@see TMMCErr |
|
938 |
*/ |
|
939 |
const TUint32 KMMCErrDataTimeOut= KBit1; |
|
940 |
||
941 |
||
942 |
/** |
|
943 |
@publishedPartner |
|
944 |
@released |
|
945 |
||
946 |
A MultiMediaCard error code. |
|
947 |
||
948 |
Timed out waiting for a data block to be requested during a data write command. |
|
949 |
||
950 |
@see TMMCErr |
|
951 |
*/ |
|
952 |
const TUint32 KMMCErrBusyTimeOut= KBit2; |
|
953 |
||
954 |
||
955 |
/** |
|
956 |
@publishedPartner |
|
957 |
@released |
|
958 |
||
959 |
A MultiMediaCard error code. |
|
960 |
||
961 |
Timed out during the CIM_UPDATE_ACQ macro waiting for a card to power up. |
|
962 |
Cards that are still powering up return busy in response to a SEND_OP_COND command. |
|
963 |
||
964 |
@see TMMCErr |
|
965 |
*/ |
|
966 |
const TUint32 KMMCErrBusTimeOut= KBit3; |
|
967 |
||
968 |
||
969 |
/** |
|
970 |
@publishedPartner |
|
971 |
@released |
|
972 |
||
973 |
A MultiMediaCard error code. |
|
974 |
||
975 |
The host has detected more cards in a stack that it can handle, or it has |
|
976 |
detected more cards than it was expecting, for example, more cards than physical slots. |
|
977 |
||
978 |
@see TMMCErr |
|
979 |
*/ |
|
980 |
const TUint32 KMMCErrTooManyCards= KBit4; |
|
981 |
||
982 |
||
983 |
/** |
|
984 |
@publishedPartner |
|
985 |
@released |
|
986 |
||
987 |
A MultiMediaCard error code. |
|
988 |
||
989 |
The host has detected a CRC error in a response received from a card. |
|
990 |
||
991 |
@see TMMCErr |
|
992 |
*/ |
|
993 |
const TUint32 KMMCErrResponseCRC= KBit5; |
|
994 |
||
995 |
||
996 |
/** |
|
997 |
@publishedPartner |
|
998 |
@released |
|
999 |
||
1000 |
A MultiMediaCard error code. |
|
1001 |
||
1002 |
The host has detected a CRC error in a data block received from a card. |
|
1003 |
||
1004 |
@see TMMCErr |
|
1005 |
*/ |
|
1006 |
const TUint32 KMMCErrDataCRC= KBit6; |
|
1007 |
||
1008 |
||
1009 |
/** |
|
1010 |
@publishedPartner |
|
1011 |
@released |
|
1012 |
||
1013 |
A MultiMediaCard error code. |
|
1014 |
||
1015 |
The card has detected a CRC error in a command received from the host. |
|
1016 |
||
1017 |
@see TMMCErr |
|
1018 |
*/ |
|
1019 |
const TUint32 KMMCErrCommandCRC= KBit7; |
|
1020 |
||
1021 |
||
1022 |
/** |
|
1023 |
@publishedPartner |
|
1024 |
@released |
|
1025 |
||
1026 |
A MultiMediaCard error code. |
|
1027 |
||
1028 |
An R1 response was received from the card with one or more of the error flags |
|
1029 |
set in the card status field. |
|
1030 |
||
1031 |
@see TMMCErr |
|
1032 |
*/ |
|
1033 |
const TUint32 KMMCErrStatus= KBit8; |
|
1034 |
||
1035 |
||
1036 |
/** |
|
1037 |
@publishedPartner |
|
1038 |
@released |
|
1039 |
||
1040 |
A MultiMediaCard error code. |
|
1041 |
||
1042 |
A session was submitted without first being set-up with a card object, |
|
1043 |
or was set-up with a card object that is no longer present. |
|
1044 |
||
1045 |
@see TMMCErr |
|
1046 |
*/ |
|
1047 |
const TUint32 KMMCErrNoCard= KBit9; |
|
1048 |
||
1049 |
||
1050 |
/** |
|
1051 |
@publishedPartner |
|
1052 |
@released |
|
1053 |
||
1054 |
A MultiMediaCard error code. |
|
1055 |
||
1056 |
The session had the stack locked but the MultiMediaCard controller had |
|
1057 |
to override the lock to perform some other bus activity. |
|
1058 |
||
1059 |
@see TMMCErr |
|
1060 |
*/ |
|
1061 |
const TUint32 KMMCErrBrokenLock= KBit10; |
|
1062 |
||
1063 |
||
1064 |
/** |
|
1065 |
@publishedPartner |
|
1066 |
@released |
|
1067 |
||
1068 |
A MultiMediaCard error code. |
|
1069 |
||
1070 |
The card was powered down. |
|
1071 |
||
1072 |
@see TMMCErr |
|
1073 |
*/ |
|
1074 |
const TUint32 KMMCErrPowerDown= KBit11; |
|
1075 |
||
1076 |
||
1077 |
/** |
|
1078 |
@publishedPartner |
|
1079 |
@released |
|
1080 |
||
1081 |
A MultiMediaCard error code. |
|
1082 |
||
1083 |
The session was stopped. |
|
1084 |
||
1085 |
@see TMMCErr |
|
1086 |
*/ |
|
1087 |
const TUint32 KMMCErrAbort= KBit12; |
|
1088 |
||
1089 |
||
1090 |
/** |
|
1091 |
@publishedPartner |
|
1092 |
@released |
|
1093 |
||
1094 |
A MultiMediaCard error code. |
|
1095 |
||
1096 |
The stack has not yet been initialised. |
|
1097 |
||
1098 |
@see TMMCErr |
|
1099 |
*/ |
|
1100 |
const TUint32 KMMCErrStackNotReady= KBit13; |
|
1101 |
||
1102 |
||
1103 |
/** |
|
1104 |
@publishedPartner |
|
1105 |
@released |
|
1106 |
||
1107 |
A MultiMediaCard error code. |
|
1108 |
||
1109 |
The session requested a service or feature that is not supported. |
|
1110 |
||
1111 |
@see TMMCErr |
|
1112 |
*/ |
|
1113 |
const TUint32 KMMCErrNotSupported= KBit14; |
|
1114 |
||
1115 |
||
1116 |
/** |
|
1117 |
@publishedPartner |
|
1118 |
@released |
|
1119 |
||
1120 |
A MultiMediaCard error code. |
|
1121 |
||
1122 |
Indicates a general hardware related error. |
|
1123 |
||
1124 |
@see TMMCErr |
|
1125 |
*/ |
|
1126 |
const TUint32 KMMCErrHardware= KBit15; |
|
1127 |
||
1128 |
||
1129 |
/** |
|
1130 |
@publishedPartner |
|
1131 |
@released |
|
1132 |
||
1133 |
A MultiMediaCard error code. |
|
1134 |
||
1135 |
An unexpected or inconsistent bus state has been detected. |
|
1136 |
||
1137 |
@see TMMCErr |
|
1138 |
*/ |
|
1139 |
const TUint32 KMMCErrBusInconsistent=KBit16; |
|
1140 |
||
1141 |
||
1142 |
||
1143 |
||
1144 |
// SM control error codes |
|
1145 |
||
1146 |
/** |
|
1147 |
@publishedPartner |
|
1148 |
@released |
|
1149 |
||
1150 |
A MultiMediaCard error code. |
|
1151 |
||
1152 |
This is used interally by the MultiMediaCard controller. |
|
1153 |
||
1154 |
@see TMMCErr |
|
1155 |
*/ |
|
1156 |
const TUint32 KMMCErrBypass= KBit17; |
|
1157 |
||
1158 |
||
1159 |
/** |
|
1160 |
@publishedPartner |
|
1161 |
@released |
|
1162 |
||
1163 |
A MultiMediaCard error code. |
|
1164 |
||
1165 |
This is used internally by the MultiMediaCard controller in the process |
|
1166 |
of re-initialising a card to recover from an inconsistent bus state. |
|
1167 |
||
1168 |
@see TMMCErr |
|
1169 |
*/ |
|
1170 |
const TUint32 KMMCErrInitContext= KBit18; |
|
1171 |
||
1172 |
||
1173 |
/** |
|
1174 |
@publishedPartner |
|
1175 |
@released |
|
1176 |
||
1177 |
A MultiMediaCard error code. |
|
1178 |
||
1179 |
Indicates a bad argument. |
|
1180 |
||
1181 |
@see TMMCErr |
|
1182 |
*/ |
|
1183 |
const TUint32 KMMCErrArgument= KBit19; |
|
1184 |
||
1185 |
||
1186 |
/** |
|
1187 |
@publishedPartner |
|
1188 |
@released |
|
1189 |
||
1190 |
A MultiMediaCard error code. |
|
1191 |
||
1192 |
A multiple block operation was requested, but the length specified was |
|
1193 |
less than that of a block. |
|
1194 |
||
1195 |
@see TMMCErr |
|
1196 |
*/ |
|
1197 |
const TUint32 KMMCErrSingleBlock= KBit20; |
|
1198 |
||
1199 |
||
1200 |
||
1201 |
/** |
|
1202 |
@internalComponent |
|
1203 |
*/ |
|
1204 |
const TUint32 KMMCErrUpdPswd= KBit21; |
|
1205 |
||
1206 |
||
1207 |
||
1208 |
||
1209 |
// General error codes |
|
1210 |
||
1211 |
/** |
|
1212 |
@publishedPartner |
|
1213 |
@released |
|
1214 |
||
1215 |
A MultiMediaCard error code. |
|
1216 |
||
1217 |
The card is locked. |
|
1218 |
||
1219 |
@see TMMCErr |
|
1220 |
*/ |
|
1221 |
const TUint32 KMMCErrLocked= KBit22; |
|
1222 |
||
1223 |
||
1224 |
/** |
|
1225 |
@publishedPartner |
|
1226 |
@released |
|
1227 |
||
1228 |
A MultiMediaCard error code. |
|
1229 |
||
1230 |
Indicates a general 'not found' type error. |
|
1231 |
||
1232 |
@see TMMCErr |
|
1233 |
*/ |
|
1234 |
const TUint32 KMMCErrNotFound= KBit23; |
|
1235 |
||
1236 |
||
1237 |
/** |
|
1238 |
@publishedPartner |
|
1239 |
@released |
|
1240 |
||
1241 |
An MultiMediaCard error code: |
|
1242 |
||
1243 |
Indicates a general already 'exists type' error. |
|
1244 |
||
1245 |
@see TMMCErr |
|
1246 |
*/ |
|
1247 |
const TUint32 KMMCErrAlreadyExists= KBit24; |
|
1248 |
||
1249 |
||
1250 |
/** |
|
1251 |
@publishedPartner |
|
1252 |
@released |
|
1253 |
||
1254 |
An MultiMediaCard error code: |
|
1255 |
||
1256 |
Indicates an unspecified error. |
|
1257 |
||
1258 |
@see TMMCErr |
|
1259 |
*/ |
|
1260 |
const TUint32 KMMCErrGeneral= KBit25; |
|
1261 |
||
1262 |
||
1263 |
/** |
|
1264 |
@publishedPartner |
|
1265 |
@released |
|
1266 |
||
1267 |
A bitmask of all MultiMediaCard error codes. |
|
1268 |
*/ |
|
1269 |
const TUint32 KMMCErrAll = (KBit26 - KBit0); |
|
1270 |
||
1271 |
/** |
|
1272 |
@publishedPartner |
|
1273 |
@released |
|
1274 |
||
1275 |
A subset of MultiMediaCard error codes. |
|
1276 |
*/ |
|
1277 |
const TUint32 KMMCErrBasic = (KMMCErrAll & ~( |
|
1278 |
KMMCErrBypass | |
|
1279 |
KMMCErrUpdPswd | |
|
1280 |
KMMCErrInitContext | |
|
1281 |
KMMCErrArgument | |
|
1282 |
KMMCErrSingleBlock | |
|
1283 |
KMMCErrLocked | |
|
1284 |
KMMCErrNotFound | |
|
1285 |
KMMCErrAlreadyExists| |
|
1286 |
KMMCErrGeneral)); |
|
1287 |
||
1288 |
// DMMC Stack and Session control bits |
|
1289 |
||
1290 |
// Stack State bits |
|
1291 |
const TUint32 KMMCStackStateRunning= KBit0; // Stack scheduler active |
|
1292 |
const TUint32 KMMCStackStateWaitingToLock= KBit1; // |
|
1293 |
const TUint32 KMMCStackStateLocked= KBit2; // |
|
1294 |
const TUint32 KMMCStackStateWaitingDFC= KBit3; |
|
1295 |
const TUint32 KMMCStackStateInitInProgress= KBit4; |
|
1296 |
const TUint32 KMMCStackStateReScheduled= KBit5; |
|
1297 |
const TUint32 KMMCStackStateJobChooser= KBit6; |
|
1298 |
const TUint32 KMMCStackStateDoDeselect= KBit7; |
|
1299 |
const TUint32 KMMCStackStateBusInconsistent=KBit8; |
|
1300 |
const TUint32 KMMCStackStateInitPending= KBit9; |
|
1301 |
const TUint32 KMMCStackStateCardRemoved= KBit10; |
|
1302 |
const TUint32 KMMCStackStateSleepinProgress=KBit11; |
|
1303 |
const TUint32 KMMCStackStateSleep= KBit12; |
|
1304 |
const TUint32 KMMCStackStateYielding= KBit13; |
|
1305 |
||
1306 |
// Session Blocking bits definition |
|
1307 |
||
1308 |
/** |
|
1309 |
@publishedPartner |
|
1310 |
@released |
|
1311 |
||
1312 |
A bit, which when set in a call to DMMCStack::BlockCurrentSession(), indicates |
|
1313 |
that the current session is to be blocked, awaiting an event that is to |
|
1314 |
be handled at the platform specific level. |
|
1315 |
||
1316 |
For example, the session may be waiting for: |
|
1317 |
||
1318 |
- a response following a command |
|
1319 |
- an interrupt indicating that data transfer is required |
|
1320 |
- a platform specific layer specific timer. |
|
1321 |
||
1322 |
@see DMMCStack::BlockCurrentSession() |
|
1323 |
*/ |
|
1324 |
const TUint32 KMMCBlockOnASSPFunction= KBit0; |
|
1325 |
||
1326 |
const TUint32 KMMCBlockOnPollTimer = KBit1; |
|
1327 |
const TUint32 KMMCBlockOnRetryTimer = KBit2; |
|
1328 |
const TUint32 KMMCBlockOnNoRun = KBit3; |
|
1329 |
const TUint32 KMMCBlockOnDoor = KBit4; |
|
1330 |
const TUint32 KMMCBlockOnWaitToLock = KBit5; |
|
1331 |
const TUint32 KMMCBlockOnCardInUse = KBit6; |
|
1332 |
const TUint32 KMMCBlockOnPgmTimer = KBit7; |
|
1333 |
const TUint32 KMMCBlockOnInterrupt = KBit8; |
|
1334 |
const TUint32 KMMCBlockOnDataTransfer = KBit9; |
|
1335 |
const TUint32 KMMCBlockOnMoreData = KBit10; |
|
1336 |
const TUint32 KMMCBlockOnYielding = KBit11; // Yielding to other commands |
|
1337 |
||
1338 |
const TUint32 KMMCBlockOnAsynchMask = KMMCBlockOnASSPFunction | |
|
1339 |
KMMCBlockOnPollTimer | |
|
1340 |
KMMCBlockOnRetryTimer | |
|
1341 |
KMMCBlockOnPgmTimer | |
|
1342 |
KMMCBlockOnInterrupt | |
|
1343 |
KMMCBlockOnDataTransfer | |
|
1344 |
KMMCBlockOnMoreData; |
|
1345 |
||
1346 |
const TUint32 KMMCBlockOnGapTimersMask = KMMCBlockOnPollTimer | |
|
1347 |
KMMCBlockOnRetryTimer | |
|
1348 |
KMMCBlockOnPgmTimer; |
|
1349 |
||
1350 |
// Session State bits definition |
|
1351 |
const TUint32 KMMCSessStateEngaged = KBit0; // Processed by DMMCStack |
|
1352 |
const TUint32 KMMCSessStateInProgress = KBit1; // No longer safe to restart |
|
1353 |
const TUint32 KMMCSessStateCritical = KBit2; // Re-initialise the stack if aborted |
|
1354 |
const TUint32 KMMCSessStateSafeInGaps = KBit3; |
|
1355 |
const TUint32 KMMCSessStateDoReSchedule= KBit4; |
|
1356 |
||
1357 |
/** |
|
1358 |
@publishedPartner |
|
1359 |
@released |
|
1360 |
||
1361 |
A bit that when set into DMMCSession::iState before calling |
|
1362 |
DMMCStack::UnBlockCurrentSession(), causes a DFC to be queued in order |
|
1363 |
to resume the state machine at some later stage. |
|
1364 |
*/ |
|
1365 |
const TUint32 KMMCSessStateDoDFC = KBit5; |
|
1366 |
const TUint32 KMMCSessStateBlockOnDoor = KBit6; |
|
1367 |
const TUint32 KMMCSessStateCardIsGone = KBit7; |
|
1368 |
const TUint32 KMMCSessStateASSPEngaged = KBit8; |
|
1369 |
const TUint32 KMMCSessStateAllowDirectCommands = KBit9; // Allow Direct Commands (Using CMD) during Data Transfer |
|
1370 |
||
1371 |
class TCID |
|
1372 |
/** |
|
1373 |
CID class |
|
1374 |
||
1375 |
@publishedPartner |
|
1376 |
@released |
|
1377 |
*/ |
|
1378 |
{ |
|
1379 |
public: |
|
1380 |
inline TCID() {} // Default constructor |
|
1381 |
inline TCID(const TUint8*); |
|
1382 |
inline TCID& operator=(const TCID&); |
|
1383 |
inline TCID& operator=(const TUint8*); |
|
1384 |
inline TBool operator==(const TCID&) const; |
|
1385 |
inline TBool operator==(const TUint8*) const; |
|
1386 |
inline void Copy(TUint8*) const; // Copies big endian 16 bytes CID |
|
1387 |
inline TUint8 At(TUint anIndex) const; // Byte from CID at anIndex |
|
1388 |
private: |
|
1389 |
TUint8 iData[KMMCCIDLength]; // Big endian 128 bit bitfield representing CID |
|
1390 |
}; |
|
1391 |
||
1392 |
||
1393 |
class TCSD |
|
1394 |
/** |
|
1395 |
CSD class |
|
1396 |
||
1397 |
@publishedPartner |
|
1398 |
@released |
|
1399 |
*/ |
|
1400 |
{ |
|
1401 |
public: |
|
1402 |
inline TCSD() {memclr(this, sizeof(*this));} // Default constructor |
|
1403 |
inline TCSD(const TUint8*); |
|
1404 |
inline TCSD& operator=(const TCSD&); |
|
1405 |
inline TCSD& operator=(const TUint8*); |
|
1406 |
inline void Copy(TUint8*) const; // Copies big endian 16 bytes CSD |
|
1407 |
inline TUint8 At(TUint anIndex) const; // Byte from CSD at anIndex |
|
1408 |
public: |
|
1409 |
inline TUint CSDStructure() const; |
|
1410 |
inline TUint SpecVers() const; |
|
1411 |
inline TUint Reserved120() const; |
|
1412 |
inline TUint TAAC() const; |
|
1413 |
inline TUint NSAC() const; |
|
1414 |
inline TUint TranSpeed() const; |
|
1415 |
inline TUint CCC() const; |
|
1416 |
inline TUint ReadBlLen() const; |
|
1417 |
inline TBool ReadBlPartial() const; |
|
1418 |
inline TBool WriteBlkMisalign() const; |
|
1419 |
inline TBool ReadBlkMisalign() const; |
|
1420 |
inline TBool DSRImp() const; |
|
1421 |
inline TUint Reserved74() const; |
|
1422 |
inline TUint CSize() const; |
|
1423 |
inline TUint VDDRCurrMin() const; |
|
1424 |
inline TUint VDDRCurrMax() const; |
|
1425 |
inline TUint VDDWCurrMin() const; |
|
1426 |
inline TUint VDDWCurrMax() const; |
|
1427 |
inline TUint CSizeMult() const; |
|
1428 |
inline TUint EraseGrpSize() const; |
|
1429 |
inline TUint EraseGrpMult() const; |
|
1430 |
inline TUint WPGrpSize() const; |
|
1431 |
inline TBool WPGrpEnable() const; |
|
1432 |
inline TUint DefaultECC() const; |
|
1433 |
inline TUint R2WFactor() const; |
|
1434 |
inline TUint WriteBlLen() const; |
|
1435 |
inline TBool WriteBlPartial() const; |
|
1436 |
inline TUint Reserved16() const; |
|
1437 |
inline TBool FileFormatGrp() const; |
|
1438 |
inline TBool Copy() const; |
|
1439 |
inline TBool PermWriteProtect() const; |
|
1440 |
inline TBool TmpWriteProtect() const; |
|
1441 |
inline TUint FileFormat() const; |
|
1442 |
inline TUint ECC() const; |
|
1443 |
inline TUint CRC() const; |
|
1444 |
public: |
|
1445 |
IMPORT_C TUint DeviceSize() const; // Uses functions above to calculate device capacity |
|
1446 |
IMPORT_C TMMCMediaTypeEnum MediaType() const; |
|
1447 |
IMPORT_C TUint ReadBlockLength() const; // Read Block Length in bytes |
|
1448 |
IMPORT_C TUint WriteBlockLength() const;// Write Block Length in bytes |
|
1449 |
IMPORT_C TUint EraseSectorSize() const; // Erase sector size (default 512 bytes) |
|
1450 |
IMPORT_C TUint EraseGroupSize() const; // Erase group size (default 16*<sector size> bytes) |
|
1451 |
IMPORT_C TUint MinReadCurrentInMilliamps() const; |
|
1452 |
IMPORT_C TUint MinWriteCurrentInMilliamps() const; |
|
1453 |
IMPORT_C TUint MaxReadCurrentInMilliamps() const; |
|
1454 |
IMPORT_C TUint MaxWriteCurrentInMilliamps() const; |
|
1455 |
IMPORT_C TUint MaxTranSpeedInKilohertz() const; |
|
1456 |
public: |
|
1457 |
IMPORT_C TUint CSDField(const TUint& aTopBit, const TUint& aBottomBit) const; /**< @internalComponent */ |
|
1458 |
TUint8 iData[KMMCCSDLength]; /**< @internalComponent */ // Big endian 128 bit bitfield representing CSD |
|
1459 |
}; |
|
1460 |
||
1461 |
||
1462 |
class TExtendedCSD |
|
1463 |
/** |
|
1464 |
Extended CSD register class. |
|
1465 |
For more information about this register, see the MultimediaCard System |
|
1466 |
Specification, Version 4.1+ |
|
1467 |
||
1468 |
@publishedPartner |
|
1469 |
@released |
|
1470 |
*/ |
|
1471 |
{ |
|
1472 |
public: |
|
1473 |
/** |
|
1474 |
An enum used by TExtendedCSD::GetWriteArg() to construct a TMMCArgument object. |
|
1475 |
The value chosen defines how the register or command set is to be modified. |
|
1476 |
*/ |
|
1477 |
enum TExtCSDAccessBits |
|
1478 |
{ |
|
1479 |
/** Change the card's command set */ |
|
1480 |
ECmdSet, |
|
1481 |
/** Set the specified bits */ |
|
1482 |
ESetBits, |
|
1483 |
/** Clear the specified bits */ |
|
1484 |
EClearBits, |
|
1485 |
/** Write the specified byte */ |
|
1486 |
EWriteByte |
|
1487 |
}; |
|
1488 |
/** |
|
1489 |
This enum defines various field offsets into the Modes Segment (i.e. |
|
1490 |
the writable part) of the Extended CSD register. |
|
1491 |
*/ |
|
1492 |
enum TExtCSDModesFieldIndex |
|
1493 |
{ |
|
1494 |
/** Offset of the CMD_SET field */ |
|
1495 |
ECmdSetIndex = 191, |
|
1496 |
/** Offset of the CMD_SET_REV field */ |
|
1497 |
ECmdSetRevIndex = 189, |
|
1498 |
/** Offset of the POWER_CLASS field */ |
|
1499 |
EPowerClassIndex = 187, |
|
1500 |
/** Offset of the HS_TIMING field */ |
|
1501 |
EHighSpeedInterfaceTimingIndex = 185, |
|
1502 |
/** Offset of the BUS_WIDTH field */ |
|
1503 |
EBusWidthModeIndex = 183, |
|
1504 |
/** Offset of the BOOT_CONFIG field */ |
|
1505 |
EBootConfigIndex = 179, |
|
1506 |
/** Offset of the BOOT_BUS_WIDTH field */ |
|
1507 |
EBootBusWidthIndex = 177, |
|
1508 |
/** Offset of the ERASE_GROUP_DEF field */ |
|
1509 |
EEraseGroupDefIndex = 175 |
|
1510 |
}; |
|
1511 |
||
1512 |
/** |
|
1513 |
This enum defines various field offsets into the Properties Segment (i.e. |
|
1514 |
the read-only part) of the Extended CSD register. |
|
1515 |
*/ |
|
1516 |
enum TExtCSDPropertiesFieldIndex |
|
1517 |
{ |
|
1518 |
/** Offset of the EXT_CSD_REV field */ |
|
1519 |
EExtendedCSDRevIndex = 192, |
|
1520 |
/** Offset of the CARD_TYPE field */ |
|
1521 |
ECardTypeIndex = 196, |
|
1522 |
/** Offset of the ACC_SIZE field */ |
|
1523 |
EAccessSizeIndex = 225, |
|
1524 |
/** Offset of the HC_ERASE_GRP_SIZE field */ |
|
1525 |
EHighCapacityEraseGroupSizeIndex = 224 |
|
1526 |
}; |
|
1527 |
||
1528 |
/** This enum defines the bus width encoding used by the BUS_WIDTH field */ |
|
1529 |
enum TExtCSDBusWidths |
|
1530 |
{ |
|
1531 |
EExtCsdBusWidth1 = 0x00, |
|
1532 |
EExtCsdBusWidth4 = 0x01, |
|
1533 |
EExtCsdBusWidth8 = 0x02 |
|
1534 |
}; |
|
1535 |
||
1536 |
/** |
|
1537 |
This enum defines the different MMCV4.x card types available as defined |
|
1538 |
in the CARD_TYPE field |
|
1539 |
*/ |
|
1540 |
enum TCardTypes |
|
1541 |
{ |
|
1542 |
EHighSpeedCard26Mhz = 0x01, |
|
110
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1543 |
EHighSpeedCard52Mhz = 0x02, |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1544 |
ECardTypeMsk = 0x03 |
0 | 1545 |
}; |
1546 |
||
1547 |
/** |
|
1548 |
This enum defines the boot config encoding used by the BOOT_CONFIG field |
|
1549 |
*/ |
|
1550 |
enum TExtCSDBootConfig |
|
1551 |
{ |
|
1552 |
ESelectUserArea = 0x00, |
|
1553 |
ESelectBootPartition1 = 0x01, |
|
1554 |
ESelectBootPartition2 = 0x02, |
|
1555 |
EEnableBootPartition1forBoot = 0x08, |
|
1556 |
EEnableBootPartition2forBoot = 0x10, |
|
1557 |
EEnableUserAreaforBoot = 0x38, |
|
1558 |
EEnableBootAck = 0x40 |
|
1559 |
}; |
|
1560 |
||
1561 |
/** |
|
1562 |
This enum defines the Boot Bus Width encoding used by the BOOT_BUS_WIDTH field |
|
1563 |
*/ |
|
1564 |
enum TExtCSDBootBusWidth |
|
1565 |
{ |
|
1566 |
EBootBusWidth1Bit = 0x00, |
|
1567 |
EBootBusWidth4Bit = 0x01, |
|
1568 |
EBootBusWidth8Bit = 0x02, |
|
1569 |
EResetBusWidthafterBoot = 0x08 |
|
1570 |
}; |
|
1571 |
||
1572 |
/** |
|
1573 |
This enum defines the Erase Group Definition encoding |
|
1574 |
used by the ERASE_GROUP_DEF field |
|
1575 |
*/ |
|
1576 |
enum TExtCSDEraseGroupDef |
|
1577 |
{ |
|
1578 |
||
1579 |
EEraseGrpDefEnableOldSizes = 0x00, |
|
1580 |
EEraseGrpDefEnableHighCapSizes = 0x01 |
|
1581 |
}; |
|
1582 |
||
1583 |
public: |
|
1584 |
/** Default constructor */ |
|
1585 |
inline TExtendedCSD(); |
|
1586 |
/** |
|
1587 |
Constructor |
|
1588 |
@param aPtr a byte buffer containing the contents of the register |
|
1589 |
*/ |
|
1590 |
inline TExtendedCSD(const TUint8* aPtr); |
|
1591 |
/** |
|
1592 |
Copy constructor |
|
1593 |
@param aCSD a reference to another instance of the same class |
|
1594 |
*/ |
|
1595 |
inline TExtendedCSD& operator=(const TExtendedCSD& aCSD); |
|
1596 |
/** |
|
1597 |
Copy constructor |
|
1598 |
@param aPtr a byte buffer containing the contents of the register |
|
1599 |
*/ |
|
1600 |
inline TExtendedCSD& operator=(const TUint8* aPtr); |
|
1601 |
||
1602 |
/** Returns the byte at a particular offset into the register |
|
1603 |
@param anIndex the offset into the register |
|
1604 |
*/ |
|
1605 |
inline TUint8 At(TUint anIndex) const; |
|
1606 |
||
1607 |
/** returns a pointer to the raw data */ |
|
1608 |
inline TUint8* Ptr(); |
|
1609 |
||
1610 |
/** |
|
1611 |
Constructs and then returns a TMMCArgument which can be used to |
|
1612 |
write to the register using the SWITCH command (CMD6) |
|
1613 |
@param aAccess specifies how the register or command set is to be modified. |
|
1614 |
@param aIndex the offset into the register |
|
1615 |
@param aValue the value to write to the field in the register |
|
1616 |
@param aCmdSet The command set to write. Valid if aAccess = ECmdSet |
|
1617 |
*/ |
|
1618 |
inline static TMMCArgument GetWriteArg(TExtCSDAccessBits aAccess, TExtCSDModesFieldIndex aIndex, TUint aValue, TUint aCmdSet); |
|
1619 |
||
1620 |
/** returns the contents of the CMD_SET field */ |
|
1621 |
inline TUint SupportedCmdSet() const; |
|
1622 |
||
1623 |
/** returns the contents of the SEC_COUNT field */ |
|
1624 |
inline TUint SectorCount() const; |
|
1625 |
||
1626 |
/** returns the contents of the MIN_PERF_W_8_52 field */ |
|
1627 |
inline TUint MinPerfWrite8Bit52Mhz() const; |
|
1628 |
||
1629 |
/** returns the contents of the MIN_PERF_R_8_52 field */ |
|
1630 |
inline TUint MinPerfRead8Bit52Mhz() const; |
|
1631 |
||
1632 |
/** returns the contents of the MIN_PERF_W_8_26_4_52 field */ |
|
1633 |
inline TUint MinPerfWrite8Bit26Mhz_4Bit52Mhz() const; |
|
1634 |
||
1635 |
/** returns the contents of the MIN_PERF_R_8_26_4_52 field */ |
|
1636 |
inline TUint MinPerfRead8Bit26Mhz_4Bit52Mhz() const; |
|
1637 |
||
1638 |
/** returns the contents of the MIN_PERF_W_4_26 field */ |
|
1639 |
inline TUint MinPerfWrite4Bit26Mhz() const; |
|
1640 |
||
1641 |
/** returns the contents of the MIN_PERF_R_4_26 field */ |
|
1642 |
inline TUint MinPerfRead4Bit26Mhz() const; |
|
1643 |
||
1644 |
/** returns the contents of the PWR_CL_26_360 field */ |
|
1645 |
inline TUint PowerClass26Mhz360V() const; |
|
1646 |
||
1647 |
/** returns the contents of the PWR_CL_52_360 field */ |
|
1648 |
inline TUint PowerClass52Mhz360V() const; |
|
1649 |
||
1650 |
/** returns the contents of the PWR_CL_26_195 field */ |
|
1651 |
inline TUint PowerClass26Mhz195V() const; |
|
1652 |
||
1653 |
/** returns the contents of the PWR_CL_52_195 field */ |
|
1654 |
inline TUint PowerClass52Mhz195V() const; |
|
1655 |
||
1656 |
/** returns the contents of the CARD_TYPE field */ |
|
1657 |
inline TUint CardType() const; |
|
1658 |
||
1659 |
/** returns the contents of the CSD_STRUCTURE field */ |
|
1660 |
inline TUint CSDStructureVer() const; |
|
1661 |
||
1662 |
/** returns the contents of the EXT_CSD_REV field */ |
|
1663 |
inline TUint ExtendedCSDRev() const; |
|
1664 |
||
1665 |
/** returns the contents of the CMD_SET field */ |
|
1666 |
inline TUint CmdSet() const; |
|
1667 |
||
1668 |
/** returns the contents of the CMD_SET_REV field */ |
|
1669 |
inline TUint CmdSetRev() const; |
|
1670 |
||
1671 |
/** returns the contents of the POWER_CLASS field */ |
|
1672 |
inline TUint PowerClass() const; |
|
1673 |
||
1674 |
/** returns the contents of the HS_TIMING field */ |
|
1675 |
inline TUint HighSpeedTiming() const; |
|
1676 |
||
1677 |
/** returns the contents of the BUS_WIDTH field */ |
|
1678 |
inline TUint BusWidthMode() const; |
|
1679 |
||
1680 |
/** returns the contents of the BOOT_CONFIG field */ |
|
1681 |
inline TUint BootConfig() const; |
|
1682 |
||
1683 |
/** returns the contents of the BOOT_BUS_WIDTH field */ |
|
1684 |
inline TUint BootBusWidth() const; |
|
1685 |
||
1686 |
/** returns the contents of the ERASE_GROUP_DEF field */ |
|
1687 |
inline TUint EraseGroupDef() const; |
|
1688 |
||
1689 |
/** returns the contents of the ACC_SIZE field */ |
|
1690 |
inline TUint AccessSize() const; |
|
1691 |
||
1692 |
/** returns the contents of the HC_ERASE_GRP_SIZE field */ |
|
1693 |
inline TUint HighCapacityEraseGroupSize() const; |
|
1694 |
||
1695 |
/** returns the contents of the BOOT_INFO field */ |
|
1696 |
inline TUint BootInfo() const; |
|
1697 |
||
1698 |
/** returns the contents of the BOOT_SIZE_MUTLI field */ |
|
1699 |
inline TUint BootSizeMultiple() const; |
|
1700 |
||
1701 |
/** returns the contents of the ERASE_TIMEOUT_MULT field */ |
|
1702 |
inline TUint EraseTimeoutMultiple() const; |
|
1703 |
||
1704 |
/** returns the contents of the REL_WR_SEC_C field */ |
|
1705 |
inline TUint ReliableWriteSector() const; |
|
1706 |
||
1707 |
/** returns the contents of the HC_WP_GRP_SIZE field */ |
|
1708 |
inline TUint HighCapacityWriteProtectGroupSize() const; |
|
1709 |
||
1710 |
/** returns the contents of the S_C_VCC field */ |
|
1711 |
inline TUint SleepCurrentVcc() const; |
|
1712 |
||
1713 |
/** returns the contents of the S_C_VCCQ field */ |
|
1714 |
inline TUint SleepCurrentVccQ() const; |
|
1715 |
||
1716 |
/** returns the contents of the S_A_TIMEOUT field */ |
|
1717 |
inline TUint SleepAwakeTimeout() const; |
|
110
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1718 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1719 |
/** returns True if the CARD_TYPE field conatains a valid value **/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1720 |
inline TBool IsSupportedCardType() const; |
0 | 1721 |
|
1722 |
private: |
|
1723 |
/** |
|
1724 |
@internalComponent little endian 512 byte field representing extended CSD |
|
1725 |
*/ |
|
1726 |
TUint8 iData[KMMCExtendedCSDLength]; |
|
1727 |
}; |
|
1728 |
||
1729 |
||
1730 |
// 32 bit MMC card status field (response R1) |
|
1731 |
||
1732 |
const TUint32 KMMCStatAppCmd= KBit5; |
|
1733 |
const TUint32 KMMCStatSwitchError= KBit7; |
|
1734 |
const TUint32 KMMCStatReadyForData= KBit8; |
|
1735 |
const TUint32 KMMCStatCurrentStateMask= (KBit13-KBit9); |
|
1736 |
const TUint32 KMMCStatEraseReset= KBit13; |
|
1737 |
const TUint32 KMMCStatCardECCDisabled= KBit14; |
|
1738 |
const TUint32 KMMCStatWPEraseSkip= KBit15; |
|
1739 |
const TUint32 KMMCStatErrCSDOverwrite= KBit16; |
|
1740 |
const TUint32 KMMCStatErrOverrun= KBit17; |
|
1741 |
const TUint32 KMMCStatErrUnderrun= KBit18; |
|
1742 |
const TUint32 KMMCStatErrUnknown= KBit19; |
|
1743 |
const TUint32 KMMCStatErrCCError= KBit20; |
|
1744 |
const TUint32 KMMCStatErrCardECCFailed= KBit21; |
|
1745 |
const TUint32 KMMCStatErrIllegalCommand=KBit22; |
|
1746 |
const TUint32 KMMCStatErrComCRCError= KBit23; |
|
1747 |
const TUint32 KMMCStatErrLockUnlock= KBit24; |
|
1748 |
const TUint32 KMMCStatCardIsLocked= KBit25; |
|
1749 |
const TUint32 KMMCStatErrWPViolation= KBit26; |
|
1750 |
const TUint32 KMMCStatErrEraseParam= KBit27; |
|
1751 |
const TUint32 KMMCStatErrEraseSeqError= KBit28; |
|
1752 |
const TUint32 KMMCStatErrBlockLenError= KBit29; |
|
1753 |
const TUint32 KMMCStatErrAddressError= KBit30; |
|
1754 |
const TUint32 KMMCStatErrOutOfRange= KBit31; |
|
1755 |
||
1756 |
const TUint32 KMMCStatErrorMask= KMMCStatErrOutOfRange | |
|
1757 |
KMMCStatErrAddressError | |
|
1758 |
KMMCStatErrBlockLenError| |
|
1759 |
KMMCStatErrEraseSeqError| |
|
1760 |
KMMCStatErrEraseParam | |
|
1761 |
KMMCStatErrWPViolation | |
|
1762 |
KMMCStatErrLockUnlock | |
|
1763 |
KMMCStatErrCardECCFailed| |
|
1764 |
KMMCStatErrCCError | |
|
1765 |
KMMCStatErrUnknown | |
|
1766 |
KMMCStatErrUnderrun | |
|
1767 |
KMMCStatErrOverrun | |
|
1768 |
KMMCStatErrCSDOverwrite; |
|
1769 |
||
1770 |
||
1771 |
const TUint32 KMMCStatClearByReadMask= KMMCStatErrOutOfRange | |
|
1772 |
KMMCStatErrAddressError | |
|
1773 |
KMMCStatErrBlockLenError| |
|
1774 |
KMMCStatErrEraseSeqError| |
|
1775 |
KMMCStatErrEraseParam | |
|
1776 |
KMMCStatErrWPViolation | |
|
1777 |
KMMCStatErrLockUnlock | |
|
1778 |
KMMCStatErrCardECCFailed| |
|
1779 |
KMMCStatErrCCError | |
|
1780 |
KMMCStatErrUnknown | |
|
1781 |
KMMCStatErrUnderrun | |
|
1782 |
KMMCStatErrOverrun | |
|
1783 |
KMMCStatErrCSDOverwrite | |
|
1784 |
KMMCStatWPEraseSkip | |
|
1785 |
KMMCStatEraseReset | |
|
1786 |
KMMCStatAppCmd; |
|
1787 |
||
1788 |
enum TMMCardStateEnum |
|
1789 |
{ |
|
1790 |
ECardStateIdle = 0, |
|
1791 |
ECardStateReady = (1 << 9), |
|
1792 |
ECardStateIdent = (2 << 9), |
|
1793 |
ECardStateStby = (3 << 9), |
|
1794 |
ECardStateTran = (4 << 9), |
|
1795 |
ECardStateData = (5 << 9), |
|
1796 |
ECardStateRcv = (6 << 9), |
|
1797 |
ECardStatePrg = (7 << 9), |
|
1798 |
ECardStateDis = (8 << 9), |
|
1799 |
ECardStateBtst = (9 << 9), |
|
1800 |
ECardStateSlp = (10 << 9) |
|
1801 |
}; |
|
1802 |
||
1803 |
class TMMCStatus |
|
1804 |
/** |
|
1805 |
MMC Status class. |
|
1806 |
This class can be used to get the MMC card state machine and response status. |
|
1807 |
For the details of MMC card state machine and command response refer to MMC card specification. |
|
1808 |
||
1809 |
@see DMMCStack |
|
1810 |
@publishedPartner |
|
1811 |
@released |
|
1812 |
*/ |
|
1813 |
{ |
|
1814 |
public: |
|
1815 |
/** |
|
1816 |
* Default constructor. |
|
1817 |
*/ |
|
1818 |
inline TMMCStatus() {} |
|
1819 |
inline TMMCStatus(const TUint8*); |
|
1820 |
inline TMMCStatus(const TUint32&); |
|
1821 |
inline operator TUint32() const; |
|
1822 |
inline TUint32 Error() const; |
|
1823 |
inline TMMCardStateEnum State() const; |
|
1824 |
inline void UpdateState(TMMCardStateEnum aState); |
|
1825 |
private: |
|
1826 |
TUint32 iData; // 32 bit bitfield representing status register |
|
1827 |
}; |
|
1828 |
||
1829 |
||
1830 |
||
1831 |
const TUint32 KMMCOCRBusy = KBit31; // OCR Busy Bit (Response R3) |
|
1832 |
const TUint32 KMMCOCRAccessModeHCS = KBit30; // OCR Access Mode + SD HCS Bit (Response R3) |
|
1833 |
const TUint32 KMMCOCRLowVoltage = KBit7; // 1.65 - 1.95 volt support |
|
1834 |
const TUint32 KMMCOCRAccessModeMask = KBit30 | KBit29; // OCR Access Mode : [00 : Byte], [10 : Block] |
|
1835 |
||
1836 |
||
1837 |
||
1838 |
/** |
|
1839 |
Defines the bit value that can be used in TPBusPsuInfo::iVoltageSupported |
|
1840 |
to indicate that the MultiMediaCard PSU supports voltage adjustment. |
|
1841 |
||
1842 |
@publishedPartner |
|
1843 |
@released |
|
1844 |
*/ |
|
1845 |
#define KMMCAdjustableOpVoltage KMMCOCRBusy // Use same bit to flag ASSP PSU supports voltage adjustment. |
|
1846 |
||
1847 |
||
1848 |
class TMMCArgument |
|
1849 |
/** |
|
1850 |
MMC Argument class |
|
1851 |
||
1852 |
@publishedPartner |
|
1853 |
@released |
|
1854 |
*/ |
|
1855 |
{ |
|
1856 |
public: |
|
1857 |
inline TMMCArgument(); |
|
1858 |
inline TMMCArgument(const TUint32&); |
|
1859 |
inline TMMCArgument(TRCA); |
|
1860 |
inline TMMCArgument(TDSR); |
|
1861 |
inline operator TUint32() const; |
|
1862 |
inline void SetRCA(TRCA); |
|
1863 |
private: |
|
1864 |
TUint32 iData; // 32 bit bitfield representing the argument |
|
1865 |
}; |
|
1866 |
||
1867 |
||
1868 |
class TRCA |
|
1869 |
/** |
|
1870 |
MMC RCA (Relative Card Address) class |
|
1871 |
*/ |
|
1872 |
{ |
|
1873 |
public: |
|
1874 |
inline TRCA() {} |
|
1875 |
inline TRCA(TUint16); |
|
1876 |
inline TRCA(TInt); |
|
1877 |
inline TRCA(TMMCArgument); |
|
1878 |
inline operator TUint16() const; |
|
1879 |
private: |
|
1880 |
TUint16 iData; // 16 bit bitfield representing MultiMedia Card's RCA |
|
1881 |
}; |
|
1882 |
||
1883 |
||
1884 |
class TDSR |
|
1885 |
/** |
|
1886 |
MMC DSR (Driver Stage Register) class |
|
1887 |
*/ |
|
1888 |
{ |
|
1889 |
public: |
|
1890 |
inline TDSR(); |
|
1891 |
inline TDSR(TUint16); |
|
1892 |
inline operator TUint16() const; |
|
1893 |
private: |
|
1894 |
TUint16 iData; // 16 bit bitfield representing MultiMedia Card's DSR |
|
1895 |
}; |
|
1896 |
||
1897 |
||
1898 |
// Card specific information and context |
|
1899 |
||
1900 |
/** |
|
1901 |
@publishedPartner |
|
1902 |
@released |
|
1903 |
*/ |
|
1904 |
const TUint32 KMMCardHasPassword= KBit0; |
|
1905 |
||
1906 |
/** |
|
1907 |
@publishedPartner |
|
1908 |
@released |
|
1909 |
*/ |
|
1910 |
const TUint32 KMMCardIsWriteProtected= KBit1; |
|
1911 |
||
1912 |
/** |
|
1913 |
@publishedPartner |
|
1914 |
@released |
|
1915 |
*/ |
|
1916 |
const TUint32 KMMCardIsLockable= KBit2; |
|
1917 |
const TUint32 KMMCardIsHighCapacity= KBit3; |
|
1918 |
const TUint32 KMMCardIsHighSpeed= KBit4; |
|
1919 |
||
1920 |
const TUint32 KMMCardMMCFlagMask= 0x0000ffff; |
|
1921 |
||
1922 |
const TUint32 KMMCardFirstCustomFlag= KBit16; |
|
1923 |
const TUint32 KMMCardCustomFlagMask= 0xffff0000; |
|
1924 |
||
1925 |
const TUint32 KMMCardHighCapBlockSize= 512; |
|
1926 |
const TUint32 KMMCardHighCapBlockSizeLog2= 9; |
|
1927 |
||
1928 |
NONSHARABLE_CLASS(TMMCard) |
|
1929 |
/** |
|
1930 |
MMC card class |
|
1931 |
*/ |
|
1932 |
{ |
|
1933 |
public: |
|
1934 |
inline TBool IsHighCapacity() const; |
|
1935 |
||
1936 |
/** @publishedPartner |
|
1937 |
@released */ |
|
1938 |
TMMCard(); |
|
1939 |
||
1940 |
/** @publishedPartner |
|
1941 |
@released */ |
|
1942 |
inline TBool IsPresent() const; |
|
1943 |
||
1944 |
/** @publishedPartner |
|
1945 |
@released */ |
|
1946 |
IMPORT_C TBool IsReady() const; |
|
1947 |
||
1948 |
/** @publishedPartner |
|
1949 |
@released */ |
|
1950 |
IMPORT_C TBool IsLocked() const; |
|
1951 |
||
1952 |
/** @publishedPartner |
|
1953 |
@released */ |
|
1954 |
inline TMMCMediaTypeEnum MediaType() const; |
|
1955 |
||
1956 |
/** @publishedPartner |
|
1957 |
@released */ |
|
1958 |
inline TUint DeviceSize() const; |
|
1959 |
||
1960 |
/** @publishedPartner |
|
1961 |
@released */ |
|
1962 |
inline const TCID& CID() const; |
|
1963 |
||
1964 |
/** @publishedPartner |
|
1965 |
@released */ |
|
1966 |
inline const TCSD& CSD() const; |
|
1967 |
||
1968 |
/** @publishedPartner |
|
1969 |
@released */ |
|
1970 |
inline const TExtendedCSD& ExtendedCSD() const; |
|
1971 |
||
1972 |
/** @publishedPartner |
|
1973 |
@released */ |
|
1974 |
inline TRCA RCA() const; |
|
1975 |
||
1976 |
/** @publishedPartner |
|
1977 |
@released */ |
|
1978 |
inline TBool HasPassword() const; |
|
1979 |
||
1980 |
/** @publishedPartner |
|
1981 |
@released */ |
|
1982 |
inline TBool IsWriteProtected() const; // Always EFalse in MMC build |
|
1983 |
||
1984 |
/** @publishedPartner |
|
1985 |
@released */ |
|
1986 |
inline TInt BusWidth() const; |
|
1987 |
||
1988 |
/** @publishedPartner |
|
1989 |
@released */ |
|
1990 |
inline void SetBusWidth(TInt aBusWidth); |
|
1991 |
||
1992 |
/** @internalTechnology */ |
|
1993 |
inline void SetHighSpeedClock(TUint32 aHighSpeedClock); |
|
1994 |
||
1995 |
/** @internalTechnology */ |
|
1996 |
inline TUint32 HighSpeedClock() const; |
|
1997 |
||
1998 |
/** @publishedPartner |
|
1999 |
@released */ |
|
2000 |
virtual TUint32 PreferredWriteGroupLength() const; |
|
2001 |
||
2002 |
/** @publishedPartner |
|
2003 |
@released */ |
|
2004 |
virtual TInt GetFormatInfo(TLDFormatInfo& aFormatInfo) const; |
|
2005 |
||
2006 |
/** @publishedPartner |
|
2007 |
@released */ |
|
2008 |
virtual TUint32 MinEraseSectorSize() const; |
|
2009 |
||
2010 |
/** @publishedPartner |
|
2011 |
@released */ |
|
2012 |
virtual TUint32 EraseSectorSize() const; |
|
2013 |
||
2014 |
virtual TUint MaxTranSpeedInKilohertz() const; |
|
2015 |
||
2016 |
virtual TInt GetEraseInfo(TMMCEraseInfo& anEraseInfo) const; |
|
2017 |
||
2018 |
/** @publishedPartner |
|
2019 |
@released |
|
2020 |
||
2021 |
Returns the maximum block length supported by the card encoded as a logarithm. |
|
2022 |
This may be less than the READ_BL_LEN field in the CSD |
|
2023 |
register depending on the type of card and it's capacity. |
|
2024 |
*/ |
|
2025 |
virtual TInt MaxReadBlLen() const; |
|
2026 |
||
2027 |
/** @publishedPartner |
|
2028 |
@released |
|
2029 |
||
2030 |
Returns the maximum write block length supported by the card encoded as a logarithm. |
|
2031 |
This may be less than the WRITE_BL_LEN field in the CSD |
|
2032 |
register depending on the type of card and it's capacity. |
|
2033 |
*/ |
|
2034 |
virtual TInt MaxWriteBlLen() const; |
|
2035 |
||
2036 |
/** @publishedPartner |
|
2037 |
@released */ |
|
2038 |
virtual TInt64 DeviceSize64() const; |
|
2039 |
||
2040 |
private: |
|
2041 |
inline TInt Number() const; |
|
2042 |
public: |
|
2043 |
TInt iIndex; |
|
2044 |
TMMCStatus iStatus; // last card's status |
|
2045 |
TUint32 iSetBlockLen; // current block length set for the card |
|
2046 |
TMMCCommandEnum iLastCommand; // Last Command code issued for the card |
|
2047 |
TCID iCID; |
|
2048 |
TCSD iCSD; |
|
2049 |
TRCA iRCA; |
|
2050 |
DMMCSession* iUsingSessionP; // session which has this card attached |
|
2051 |
TUint32 iFlags; |
|
2052 |
TExtendedCSD iExtendedCSD; |
|
2053 |
private: |
|
2054 |
TUint32 iHighSpeedClock; |
|
2055 |
TInt iSpare[4]; |
|
2056 |
TInt iBusWidth; |
|
2057 |
friend class DMMCStack; |
|
2058 |
friend class TMMCardArray; |
|
2059 |
}; |
|
2060 |
||
2061 |
class TMMCardArray |
|
2062 |
/** |
|
2063 |
MMC card array class |
|
2064 |
*/ |
|
2065 |
{ |
|
2066 |
public: |
|
2067 |
inline TMMCardArray(DMMCStack* anOwningStack); |
|
2068 |
||
2069 |
/** @publishedPartner |
|
2070 |
@released */ |
|
2071 |
IMPORT_C virtual TInt AllocCards(); |
|
2072 |
||
2073 |
void InitNewCardScan(); |
|
2074 |
||
2075 |
/** @publishedPartner |
|
2076 |
@released */ |
|
2077 |
IMPORT_C void AddNewCard(const TUint8* aCID,TRCA* aNewRCA); |
|
2078 |
||
2079 |
inline TUint NewCardCount(); |
|
2080 |
inline TInt CardsPresent(); |
|
2081 |
inline TMMCard* NewCardP(TUint aNewCardNumber); |
|
2082 |
inline TMMCard* CardP(TUint aCardNumber); |
|
2083 |
inline TMMCard& Card(TUint aCardNumber); |
|
2084 |
inline TMMCard& NewCard(TUint aCardNumber); |
|
2085 |
TInt MergeCards(TBool aFirstPass); |
|
2086 |
void UpdateAcquisitions(TUint* aMaxClock); |
|
2087 |
||
2088 |
/** @internalTechnology */ |
|
2089 |
TInt CardIndex(const TMMCard* aCard); |
|
2090 |
||
2091 |
/** @publishedPartner |
|
2092 |
@released */ |
|
2093 |
IMPORT_C virtual void DeclareCardAsGone(TUint aCardNumber); |
|
2094 |
||
2095 |
protected: // initialized by AllocCards() |
|
2096 |
void MoveCardAndLockRCA(TMMCard& aSrc,TMMCard& aDest,TInt aDestIndex); |
|
2097 |
DMMCStack* iOwningStack; |
|
2098 |
TInt iCardsPresent; |
|
2099 |
TUint iNewCardsCount; |
|
2100 |
TMMCard* iCards[KMaxMMCardsPerStack]; |
|
2101 |
TMMCard* iNewCards[KMaxMMCardsPerStack]; |
|
2102 |
}; |
|
2103 |
||
2104 |
// MMC Command descriptor |
|
2105 |
||
2106 |
const TUint32 KMMCCmdFlagBytesValid= KBit0; // iBytesDone has a valid data |
|
2107 |
const TUint32 KMMCCmdFlagTransStopped= KBit1; // CMD12 has been successfully issued |
|
2108 |
const TUint32 KMMCCmdFlagStatusReceived=KBit2; // Raised by ASSP layer, cleared by ExecCommandSM() |
|
2109 |
const TUint32 KMMCCmdFlagExecTopBusy= KBit3; // ExecCommandSM() flag |
|
2110 |
const TUint32 KMMCCmdFlagExecSelBusy= KBit4; // ExecCommandSM() flag |
|
2111 |
const TUint32 KMMCCmdFlagBlockAddress= KBit5; // Block addressing mode |
|
2112 |
const TUint32 KMMCCmdFlagDMARamValid= KBit6; // Memory is DMA'able flag |
|
2113 |
const TUint32 KMMCCmdFlagDoubleBuffer= KBit7; // The current DT command is double-buffered |
|
2114 |
const TUint32 KMMCCmdFlagPhysAddr= KBit8; // Address is a physical address |
|
2115 |
const TUint32 KMMCCmdFlagReliableWrite= KBit9; // Current command is Reliable Write |
|
2116 |
||
2117 |
const TUint32 KMMCCmdFlagASSPFlags= KMMCCmdFlagBytesValid | |
|
2118 |
KMMCCmdFlagTransStopped | |
|
2119 |
KMMCCmdFlagStatusReceived; |
|
2120 |
||
2121 |
||
2122 |
||
2123 |
||
2124 |
/** |
|
2125 |
The MultiMediaCard command specification. |
|
2126 |
||
2127 |
@publishedPartner |
|
2128 |
@released |
|
2129 |
*/ |
|
2130 |
class TMMCCommandSpec |
|
2131 |
{ |
|
2132 |
public: |
|
2133 |
/** |
|
2134 |
The command class as defined by the MultiMediaCard System Specification. |
|
2135 |
*/ |
|
2136 |
TUint32 iCommandClass; |
|
2137 |
||
2138 |
/** |
|
2139 |
The command type as defined by the MultiMediaCard System Specification. |
|
2140 |
*/ |
|
2141 |
TMMCCommandTypeEnum iCommandType; |
|
2142 |
||
2143 |
/** |
|
2144 |
The data transfer direction. |
|
2145 |
*/ |
|
2146 |
TMMCCmdDirEnum iDirection; |
|
2147 |
||
2148 |
/** |
|
2149 |
ETrue indicates more than one data block is to be tranferred. |
|
2150 |
*/ |
|
2151 |
TBool iMultipleBlocks; |
|
2152 |
||
2153 |
/** |
|
2154 |
ETrue indicates use standard stop transmission mode. |
|
2155 |
*/ |
|
2156 |
TBool iUseStopTransmission; // CMD12 has to be used in the end |
|
2157 |
||
2158 |
/** |
|
2159 |
The expected response type. |
|
2160 |
||
2161 |
Note: |
|
2162 |
||
2163 |
- if this is EResponseTypeNone, then no response is expected. |
|
2164 |
- if this is ERespTypeR2, then a long (128-bit) response is expected. |
|
2165 |
- for all other types, a standard (32-bit) response is expected. |
|
2166 |
*/ |
|
2167 |
TMMCResponseTypeEnum iResponseType; |
|
2168 |
||
2169 |
/** |
|
2170 |
Expected response length (currently 4 or 16 bytes). |
|
2171 |
*/ |
|
2172 |
TUint iResponseLength; |
|
2173 |
}; |
|
2174 |
||
2175 |
class TMMCIdxCommandSpec |
|
2176 |
/** |
|
2177 |
MMC Index command spec class |
|
2178 |
*/ |
|
2179 |
{ |
|
2180 |
public: |
|
2181 |
TInt iIdx; |
|
2182 |
TMMCCommandSpec iSpec; |
|
2183 |
}; |
|
2184 |
||
2185 |
||
2186 |
||
2187 |
||
2188 |
/** |
|
2189 |
MMC command description. |
|
2190 |
||
2191 |
When issuing an individual command over the bus, the MultiMediaCard |
|
2192 |
controller uses an object of this type to specify the parameters |
|
2193 |
for the command, and to receive back any response. |
|
2194 |
||
2195 |
Commands are issued by passing an object of this type to |
|
2196 |
the DMMCStack::IssueMMCCommandSM() function, which is implemented by |
|
2197 |
the platform specific layer. |
|
2198 |
||
2199 |
@publishedPartner |
|
2200 |
@released |
|
2201 |
*/ |
|
2202 |
class TMMCCommandDesc |
|
2203 |
{ |
|
2204 |
public: |
|
2205 |
IMPORT_C TInt Direction() const; // returns -1/0/+1 for read/none/write |
|
2206 |
||
2207 |
inline TBool IsBlockCmd() const; |
|
2208 |
inline TUint32 NumBlocks() const; |
|
2209 |
inline TInt64 Arg64() const; |
|
2210 |
inline TBool IsDoubleBuffered() const; |
|
2211 |
inline TUint32 BufferLength() const; |
|
2212 |
inline TUint32 BlockLength() const; |
|
2213 |
inline TBool IsPhysicalAddress() const; |
|
2214 |
TBool AdjustForBlockOrByteAccess(const DMMCSession& aSession); |
|
2215 |
||
2216 |
void Dump(TUint8* aResponseP, TMMCErr aErr); |
|
2217 |
||
2218 |
public: |
|
2219 |
/** |
|
2220 |
@internalComponent |
|
2221 |
*/ |
|
2222 |
TUint32 iFlags; |
|
2223 |
||
2224 |
/** |
|
2225 |
The command code. |
|
2226 |
||
2227 |
This can be written directly to the MMC controller hardware. |
|
2228 |
*/ |
|
2229 |
TMMCCommandEnum iCommand; |
|
2230 |
||
2231 |
/** |
|
2232 |
The argument to be supplied with the command. |
|
2233 |
||
2234 |
This can be written directly to the MMC controller hardware. |
|
2235 |
*/ |
|
2236 |
TMMCArgument iArgument; |
|
2237 |
||
2238 |
/** |
|
2239 |
The total length of the data to be tranferred. |
|
2240 |
*/ |
|
2241 |
TUint32 iTotalLength; |
|
2242 |
||
2243 |
/** |
|
2244 |
A pointer to the location from where the data is to be read, or written. |
|
2245 |
*/ |
|
2246 |
TUint8* iDataMemoryP; |
|
2247 |
||
2248 |
/** |
|
2249 |
The block length to be used in a data transaction. |
|
2250 |
*/ |
|
2251 |
TUint32 iBlockLength; |
|
2252 |
||
2253 |
/** |
|
2254 |
The MultiMediaCard command specification. |
|
2255 |
*/ |
|
2256 |
TMMCCommandSpec iSpec; |
|
2257 |
||
2258 |
/** |
|
2259 |
The number of bytes transferred since the last time the card was selected. |
|
2260 |
*/ |
|
2261 |
TUint32 iBytesDone; |
|
2262 |
||
2263 |
/** |
|
2264 |
@internalComponent |
|
2265 |
*/ |
|
2266 |
TUint iPollAttempts; // Retry counters |
|
2267 |
||
2268 |
/** |
|
2269 |
@internalComponent |
|
2270 |
*/ |
|
2271 |
TUint iTimeOutRetries; |
|
2272 |
||
2273 |
/** |
|
2274 |
@internalComponent |
|
2275 |
*/ |
|
2276 |
TUint iCRCRetries; |
|
2277 |
||
2278 |
/** |
|
2279 |
@internalComponent |
|
2280 |
*/ |
|
2281 |
TUint16 iUnlockRetries; |
|
2282 |
||
2283 |
/** |
|
2284 |
@internalComponent |
|
2285 |
*/ |
|
2286 |
TUint16 iOpCondBusyTimeout; // Units of 10mS |
|
2287 |
||
2288 |
/** |
|
2289 |
@internalComponent |
|
2290 |
*/ |
|
2291 |
TUint iCustomRetries; |
|
2292 |
||
2293 |
/** |
|
2294 |
@internalComponent |
|
2295 |
*/ |
|
2296 |
TUint32 iExecNotHandle; // error codes to not handle in ExecCommandSM() |
|
2297 |
||
2298 |
/** |
|
2299 |
The area into which the command response is put. |
|
2300 |
||
2301 |
This is in big-endian format. |
|
2302 |
*/ |
|
2303 |
TUint8 iResponse[KMMCMaxResponseLength]; |
|
2304 |
}; |
|
2305 |
||
2306 |
||
2307 |
||
2308 |
||
2309 |
/** |
|
2310 |
MMC bus configuration. |
|
2311 |
||
2312 |
An object of this type is passed to the Variant implementation |
|
2313 |
of DMMCStack::SetBusConfigDefaults(), which should fill the public data |
|
2314 |
members with appropriate information and values. |
|
2315 |
||
2316 |
@publishedPartner |
|
2317 |
@released |
|
2318 |
*/ |
|
2319 |
class TMMCBusConfig |
|
2320 |
{ |
|
2321 |
public: |
|
2322 |
/** |
|
2323 |
The hardware interface clock, in KHz. |
|
2324 |
*/ |
|
2325 |
TUint iBusClock; |
|
2326 |
||
2327 |
||
2328 |
/** |
|
2329 |
The bus clock when clocking in data, in KHz. |
|
2330 |
*/ |
|
2331 |
TUint iClockIn; |
|
2332 |
||
2333 |
||
2334 |
/** |
|
2335 |
The bus clock when clocking out data, in KHz. |
|
2336 |
*/ |
|
2337 |
TUint iClockOut; |
|
2338 |
||
2339 |
||
2340 |
/** |
|
2341 |
The response timeout value, in uS. |
|
2342 |
*/ |
|
2343 |
TUint iResponseTimeOut; |
|
2344 |
||
2345 |
||
2346 |
/** |
|
2347 |
The data timeout value, in uS. |
|
2348 |
*/ |
|
2349 |
TUint iDataTimeOut; |
|
2350 |
||
2351 |
||
2352 |
/** |
|
2353 |
The busy timeout value, in uS. |
|
2354 |
*/ |
|
2355 |
TUint iBusyTimeOut; |
|
2356 |
}; |
|
2357 |
||
2358 |
||
2359 |
class TMMCStackConfig |
|
2360 |
/** |
|
2361 |
@publishedPartner |
|
2362 |
@released |
|
2363 |
||
2364 |
Holds the stack configuration settings on behalf of a session. |
|
2365 |
||
2366 |
Each DMMCSession object contains the public member DMMCSession::iConfig - an instance of the TMMCStackConfig class. |
|
2367 |
By changing these settings, the client can override the master (i.e. default) stack configuration settings. |
|
2368 |
||
2369 |
However, these changes only remain in effect for the period that the session remains the current session. |
|
2370 |
In this way, the client is able to change the settings employed by the Controller (e.g. bus clock, enable retries, |
|
2371 |
change time-out values, restore defaults etc) while it performs that client's request. |
|
2372 |
||
2373 |
The client would generally set-up the stack configuration it requires prior to submitting the session. |
|
2374 |
*/ |
|
2375 |
{ |
|
2376 |
public: |
|
2377 |
inline TMMCStackConfig(); |
|
2378 |
inline void SetMode(TUint32 aMask); |
|
2379 |
inline void RemoveMode(TUint32 aMask); |
|
2380 |
inline void UseDefault(TUint32 aMask); |
|
2381 |
inline void SetPollAttempts(TUint aData); |
|
2382 |
inline void SetTimeOutRetries(TUint aData); |
|
2383 |
inline void SetCRCRetries(TUint aData); |
|
2384 |
inline void SetBusClockInKhz(TUint aParam); // In kilohertz |
|
2385 |
inline void SetTicksClockIn(TUint aParam); // Number of clock ticks in ClockIn phase |
|
2386 |
inline void SetTicksClockOut(TUint aParam); // Number of clock ticks in ClockOut phase |
|
2387 |
inline void SetResponseTimeOutInTicks(TUint aParam); // Timeout in bus clock ticks |
|
2388 |
inline void SetDataTimeOutInMcs(TUint aParam); // in microseconds |
|
2389 |
inline void SetBusyTimeOutInMcs(TUint aParam); // in microseconds |
|
2390 |
inline void SetOpCondBusyTimeout(TUint16 aData); // Units of 10mS |
|
2391 |
inline TInt OpCondBusyTimeout(); |
|
2392 |
TUint iPollAttempts; |
|
2393 |
private: |
|
2394 |
TUint32 iModes; |
|
2395 |
TUint32 iUpdateMask; |
|
2396 |
TUint32 iClientMask; |
|
2397 |
TUint iTimeOutRetries; |
|
2398 |
TUint iCRCRetries; |
|
2399 |
TUint16 iUnlockRetries; |
|
2400 |
TUint16 iOpCondBusyTimeout; // Units of 10mS |
|
2401 |
TMMCBusConfig iBusConfig; |
|
2402 |
friend class DMMCStack; |
|
2403 |
}; |
|
2404 |
||
2405 |
||
2406 |
class TMMCRCAPool |
|
2407 |
/** |
|
2408 |
MMC RCA Pool |
|
2409 |
*/ |
|
2410 |
{ |
|
2411 |
public: |
|
2412 |
inline TMMCRCAPool(); |
|
2413 |
TRCA GetFreeRCA(); |
|
2414 |
inline void LockRCA(TRCA); |
|
2415 |
inline void UnlockRCA(TRCA); |
|
2416 |
inline void ReleaseUnlocked(); |
|
2417 |
private: |
|
2418 |
TUint32 iPool; |
|
2419 |
TUint32 iLocked; |
|
2420 |
}; |
|
2421 |
||
2422 |
||
2423 |
class TMMCSessRing |
|
2424 |
/** |
|
2425 |
MMC session ring |
|
2426 |
*/ |
|
2427 |
{ |
|
2428 |
public: |
|
2429 |
TMMCSessRing(); |
|
2430 |
inline TBool IsEmpty() const; |
|
2431 |
void Erase(); |
|
2432 |
inline void SetMarker(); // Sets Marker into Point position |
|
2433 |
inline void AdvanceMarker(); // Moves Marker one position forward |
|
2434 |
inline void Point(); // Sets Point into Marker position |
|
2435 |
TBool Point(DMMCSession* aSessP); // Finds aSessP and sets Point to it |
|
2436 |
void Add(DMMCSession* aSessP); // Inserts aSessP before the Marker; Point moves to Marker |
|
2437 |
void Add(TMMCSessRing& aRing); |
|
2438 |
DMMCSession* Remove(); // Removes at Point; Point moves forward |
|
2439 |
void Remove(DMMCSession* aSessP); // Points aSessP first, then remove() |
|
2440 |
inline TUint Size() const; |
|
2441 |
inline operator DMMCSession*() const; |
|
2442 |
DMMCSession* operator++(TInt); // returns Point and moves it forward; stops at Marker |
|
2443 |
private: |
|
2444 |
DMMCSession* iPMark; |
|
2445 |
DMMCSession* iPoint; |
|
2446 |
DMMCSession* iPrevP; |
|
2447 |
TUint iSize; |
|
2448 |
}; |
|
2449 |
||
2450 |
||
2451 |
// |
|
2452 |
// DMMCStack State Machine Functions are supported by TMMCStateMachine class |
|
2453 |
// |
|
2454 |
// The structure of state machine functions is assumed to be as follows |
|
2455 |
// |
|
2456 |
// TMMCErr DMMCStack::FunctionNameSMST( TAny* aPtr ) |
|
2457 |
// { return( STATIC_CAST(DMMCStack*,aPtr)->FunctionNameSM() ); } |
|
2458 |
// |
|
2459 |
// TMMCErr DMMCStack::FunctionNameSM() |
|
2460 |
// { |
|
2461 |
// enum states {EStBegin=0, ..., EStEnd }; |
|
2462 |
// DMMCSession& s = Session(); |
|
2463 |
// TMMCStateMachine& m = Machine(); |
|
2464 |
// const TMMCErr err = m.SetExitCode( 0 ); |
|
2465 |
// |
|
2466 |
// for(;;) |
|
2467 |
// { |
|
2468 |
// switch(m.State()) |
|
2469 |
// { |
|
2470 |
// case EStBegin: |
|
2471 |
// { |
|
2472 |
// .... |
|
2473 |
// } |
|
2474 |
// case EStNext: |
|
2475 |
// { |
|
2476 |
// ..... |
|
2477 |
// } |
|
2478 |
// case EStEnd: break; |
|
2479 |
// default: Panic(...); |
|
2480 |
// } |
|
2481 |
// break; |
|
2482 |
// } |
|
2483 |
// return(m.Pop()); |
|
2484 |
// } |
|
2485 |
// |
|
2486 |
// State Machine remembers the next state number and function name and goes there as soon |
|
2487 |
// as the control is returned to the session. To release the control and wait for the next |
|
2488 |
// re-entrance (which will happen immediately if the session is not blocked or, as soon as |
|
2489 |
// an asynchronous event removes the blocking condition), a state machine function has to |
|
2490 |
// return( 0 ); Returning non-zero exit code will result in the session being completed with |
|
2491 |
// that error code unless a caller state machine function has explicitly intercepted such |
|
2492 |
// an error with m.SetTraps( TMMCErr aMask ). |
|
2493 |
// |
|
2494 |
// To make a state machine function code more readable, the following macros are provided: |
|
2495 |
// |
|
2496 |
// SMF_NEXTS(nexts) - set the next state to "nexts" |
|
2497 |
// SMF_CALL(func) - invoke SM function "func", then go to the next state |
|
2498 |
// SMF_CALLWAIT(func) - the same as above, but sleep at the entry point |
|
2499 |
// SMF_CALLMYS(nexts,retst) - invoke current SM function at "nexts" entry point |
|
2500 |
// SMF_CALLMEWR(retst) - invoke me right here with return state retst |
|
2501 |
// SMF_INVOKES(func,nexts) - invoke SM function "func", then go to the state "nexts" |
|
2502 |
// SMF_INVOKEWAITS(func,nexts) - the same as above, but sleep at the entry point |
|
2503 |
// SMF_WAIT - sleep at the next state |
|
2504 |
// SMF_WAITS(nexts) - set next state to "nexts", then sleep |
|
2505 |
// SMF_RETURN(value) - return an error to the caller SM function |
|
2506 |
// SMF_EXIT - return to the caller SM function |
|
2507 |
// SMF_EXITWAIT - the same as above, but sleep at the exit point |
|
2508 |
// SMF_JUMP(func) - transfer the control to SM function "func" |
|
2509 |
// SMF_JUMPWAIT(func) - the same as above, but sleep at the entry point |
|
2510 |
// SMF_GOTONEXTS - goto the next state |
|
2511 |
// SMF_GOTOS(nexts) - set the next state to "nexts", then go to it |
|
2512 |
// SMF_STATE(sname) - declare the state name "sname" |
|
2513 |
// SMF_BPOINT(sname) - declare the state "sname" and sleep here if blocked statically |
|
2514 |
// |
|
2515 |
||
2516 |
/** |
|
2517 |
@publishedPartner |
|
2518 |
@released |
|
2519 |
||
2520 |
Declares the start of a state machine case switch statement. |
|
2521 |
||
2522 |
The macro assumes that the first state defined by the state machine |
|
2523 |
function is EStBegin. |
|
2524 |
||
2525 |
NOTES: |
|
2526 |
||
2527 |
- the code generates an opening curly brace that must be matched by |
|
2528 |
a closing curly brace. Typically, this is provided by the SMF_STATE or |
|
2529 |
the SMF_END macros. |
|
2530 |
||
2531 |
@see SMF_STATE |
|
2532 |
@see SMF_END |
|
2533 |
*/ |
|
2534 |
#define SMF_BEGIN TMMCStateMachine& m=Machine();const TMMCErr err=m.SetExitCode(0);\ |
|
2535 |
for(;;){switch(m.State()){case EStBegin:{if(err) (void)0; |
|
2536 |
||
2537 |
/** |
|
2538 |
@publishedPartner |
|
2539 |
@released |
|
2540 |
||
2541 |
Declares the end of a state machine case switch statement. |
|
2542 |
||
2543 |
The macro assumes that the last state defined by the state machine |
|
2544 |
function is EStEnd. |
|
2545 |
||
2546 |
NOTES: |
|
2547 |
||
2548 |
- the code generated assumes that there are earlier calls to SMF_BEGIN, |
|
2549 |
and zero or more calls to SMF_STATE. |
|
2550 |
||
2551 |
@see SMF_BEGIN |
|
2552 |
@see SMF_STATE |
|
2553 |
*/ |
|
2554 |
#define SMF_END }case EStEnd:break;default:DMMCSocket::Panic(DMMCSocket::EMMCMachineState);}break;}\ |
|
2555 |
return(m.Pop()); |
|
2556 |
||
2557 |
||
2558 |
/** |
|
2559 |
@publishedPartner |
|
2560 |
@released |
|
2561 |
||
2562 |
Sets the next state when the current state machine |
|
2563 |
function is re-entered. |
|
2564 |
||
2565 |
@param nexts The next state to be entered in the current state machine. |
|
2566 |
*/ |
|
2567 |
#define SMF_NEXTS(nexts) m.SetState(nexts); |
|
2568 |
||
2569 |
||
2570 |
/** |
|
2571 |
@publishedPartner |
|
2572 |
@released |
|
2573 |
||
2574 |
Pushes a state machine entry onto the stack, specifying the child state machine |
|
2575 |
function to be invoked. |
|
2576 |
||
2577 |
The child function will be entered at state 0 (EStBegin), when the state machine |
|
2578 |
is next dispatched. |
|
2579 |
||
2580 |
Control returns from this state machine function after completion of |
|
2581 |
all functions coded by this macro. |
|
2582 |
||
2583 |
@param func The child state machine function to be invoked. |
|
2584 |
*/ |
|
2585 |
#define SMF_CALL(func) return(m.Push(func)); |
|
2586 |
||
2587 |
||
2588 |
/** |
|
2589 |
@publishedPartner |
|
2590 |
@released |
|
2591 |
||
2592 |
Pushes a state machine entry onto the stack, specifying the child state machine |
|
2593 |
function to be invoked. |
|
2594 |
||
2595 |
The state machine is blocked before entry to the child function, but when |
|
2596 |
it becomes unblocked, the child function will be entered at state 0 (EStBegin) |
|
2597 |
when the state machine is next dispatched. |
|
2598 |
||
2599 |
Control returns from this state machine function after completion of |
|
2600 |
all functions coded by this macro. |
|
2601 |
||
2602 |
@param func The child state machine function to be invoked. |
|
2603 |
*/ |
|
2604 |
#define SMF_CALLWAIT(func) return(m.Push(func,ETrue)); |
|
2605 |
||
2606 |
||
2607 |
/** |
|
2608 |
@publishedPartner |
|
2609 |
@released |
|
2610 |
||
2611 |
Sets the next state for the current state machine function - control will |
|
2612 |
flow to this state on completion of all functions coded by this macro. |
|
2613 |
||
2614 |
The macro also pushes a state machine entry onto the stack, specifying |
|
2615 |
the CURRENT state machine function as the child state machine function to be |
|
2616 |
invoked, and sets the state in which this child state machine function will |
|
2617 |
be entered, when it gains control. |
|
2618 |
||
2619 |
NOTES: |
|
2620 |
||
2621 |
- the child function is the same as the parent function. |
|
2622 |
- the state machine is blocked on return from the current state machine function. |
|
2623 |
||
2624 |
@param nexts The state in which the child state machine function will |
|
2625 |
gain control. |
|
2626 |
@param retst The next state for the current state machine function. |
|
2627 |
*/ |
|
2628 |
#define SMF_CALLMYS(nexts,retst) {m.SetState(retst);m.PushMe();m.SetState(nexts);continue;} |
|
2629 |
||
2630 |
||
2631 |
/** |
|
2632 |
@publishedPartner |
|
2633 |
@released |
|
2634 |
||
2635 |
Sets the next state for the current state machine function - control flows to |
|
2636 |
the next instruction on completion of all functions coded by this macro. |
|
2637 |
||
2638 |
The macro also pushes a state machine entry onto the stack, specifying |
|
2639 |
the CURRENT state machine function as the child state machine function to be |
|
2640 |
invoked. The child function will be entered at state 0 (EStBegin), when the state machine |
|
2641 |
is next dispatched. |
|
2642 |
||
2643 |
NOTES: |
|
2644 |
||
2645 |
- the child function is the same as the parent function. |
|
2646 |
- the state machine is blocked on return from the current state machine function. |
|
2647 |
||
2648 |
@param retst The next state for the current state machine function. |
|
2649 |
*/ |
|
2650 |
#define SMF_CALLMEWR(retst) {m.SetState(retst);m.PushMe();} |
|
2651 |
||
2652 |
||
2653 |
/** |
|
2654 |
@publishedPartner |
|
2655 |
@released |
|
2656 |
||
2657 |
Sets the next state for the current state machine function. |
|
2658 |
||
2659 |
The macro also pushes a state machine entry onto the stack, specifying |
|
2660 |
the child state machine function to be |
|
2661 |
invoked. The child function will be entered at state 0 (EStBegin), when the state machine |
|
2662 |
is next dispatched. |
|
2663 |
||
2664 |
Control returns from the current state machine function after completion of |
|
2665 |
all functions coded by this macro. |
|
2666 |
||
2667 |
@param func The child state machine function to be invoked. |
|
2668 |
@param nexts The next state for the current state machine function. |
|
2669 |
*/ |
|
2670 |
#define SMF_INVOKES(func,nexts) {m.SetState(nexts);return(m.Push(func));} |
|
2671 |
||
2672 |
||
2673 |
/** |
|
2674 |
@publishedPartner |
|
2675 |
@released |
|
2676 |
||
2677 |
Sets the next state for the current state machine function. |
|
2678 |
||
2679 |
The macro also pushes a state machine entry onto the stack, specifying |
|
2680 |
the child state machine function to be |
|
2681 |
invoked. The child function will be entered at state 0 (EStBegin), when the state machine |
|
2682 |
is next dispatched. |
|
2683 |
||
2684 |
Control returns from the current state machine function after completion of |
|
2685 |
all functions coded by this macro. |
|
2686 |
||
2687 |
NOTES: |
|
2688 |
||
2689 |
- the state machine is blocked on return from the current state machine function. |
|
2690 |
||
2691 |
@param func The child state machine function to be invoked. |
|
2692 |
@param nexts The next state for the current state machine function. |
|
2693 |
*/ |
|
2694 |
#define SMF_INVOKEWAITS(func,nexts) {m.SetState(nexts);return(m.Push(func,ETrue));} |
|
2695 |
||
2696 |
||
2697 |
/** |
|
2698 |
@publishedPartner |
|
2699 |
@released |
|
2700 |
||
2701 |
Returns from the current state machine function, and the state machine then blocks (waits). |
|
2702 |
*/ |
|
2703 |
#define SMF_WAIT return(0); |
|
2704 |
||
2705 |
||
2706 |
/** |
|
2707 |
@publishedPartner |
|
2708 |
@released |
|
2709 |
||
2710 |
Sets the next state for the current state machine function; control then returns |
|
2711 |
from the current state machine function, and the state machine blocks (waits). |
|
2712 |
||
2713 |
@param nexts The next state for the current state machine function. |
|
2714 |
*/ |
|
2715 |
#define SMF_WAITS(nexts) return(m.SetState(nexts)); |
|
2716 |
||
2717 |
||
2718 |
/** |
|
2719 |
@publishedPartner |
|
2720 |
@released |
|
2721 |
||
2722 |
Returns the specified error value to the calling (parent) state machine function. |
|
2723 |
||
2724 |
@param value The error value to be returned. |
|
2725 |
*/ |
|
2726 |
#define SMF_RETURN(value) {m.Pop();return(value);} |
|
2727 |
||
2728 |
||
2729 |
/** |
|
2730 |
@publishedPartner |
|
2731 |
@released |
|
2732 |
||
2733 |
Returns to the calling state machine function. |
|
2734 |
*/ |
|
2735 |
#define SMF_EXIT break; |
|
2736 |
||
2737 |
||
2738 |
/** |
|
2739 |
@publishedPartner |
|
2740 |
@released |
|
2741 |
||
2742 |
Returns to the calling state machine function, and the state machine blocks (waits). |
|
2743 |
*/ |
|
2744 |
#define SMF_EXITWAIT return(m.Pop(ETrue)); |
|
2745 |
||
2746 |
||
2747 |
/** |
|
2748 |
@publishedPartner |
|
2749 |
@released |
|
2750 |
||
2751 |
Transfers control to the specified state machine function. |
|
2752 |
||
2753 |
NOTES: |
|
2754 |
||
2755 |
- this function is executed at the same stack entry level as the current state machine function. |
|
2756 |
||
2757 |
@param func The state machine function to which control is to be transferred. |
|
2758 |
*/ |
|
2759 |
#define SMF_JUMP(func) return(m.Jump(func)); |
|
2760 |
||
2761 |
||
2762 |
/** |
|
2763 |
@publishedPartner |
|
2764 |
@released |
|
2765 |
||
2766 |
Transfers control to the specified state machine function, and waits |
|
2767 |
at its entry point. |
|
2768 |
||
2769 |
@param func The state machine function to which control is to be transferred. |
|
2770 |
*/ |
|
2771 |
#define SMF_JUMPWAIT(func) return(m.Jump(func,ETrue)); |
|
2772 |
||
2773 |
||
2774 |
/** |
|
2775 |
@publishedPartner |
|
2776 |
@released |
|
2777 |
||
2778 |
Goes to the next state. |
|
2779 |
*/ |
|
2780 |
#define SMF_GOTONEXTS continue; |
|
2781 |
||
2782 |
||
2783 |
/** |
|
2784 |
@publishedPartner |
|
2785 |
@released |
|
2786 |
||
2787 |
Sets the next state and then goes to that state. |
|
2788 |
||
2789 |
@param nexts The next state. |
|
2790 |
*/ |
|
2791 |
#define SMF_GOTOS(nexts) {m.SetState(nexts);continue;} |
|
2792 |
||
2793 |
||
2794 |
/** |
|
2795 |
@publishedPartner |
|
2796 |
@released |
|
2797 |
||
2798 |
Declares the name of a state. |
|
2799 |
||
2800 |
This is used to generate a case statement based on the state name. |
|
2801 |
||
2802 |
@param sname The state name. |
|
2803 |
*/ |
|
2804 |
#define SMF_STATE(sname) }case sname:{ |
|
2805 |
||
2806 |
||
2807 |
/** |
|
2808 |
@publishedPartner |
|
2809 |
@released |
|
2810 |
||
2811 |
Declares the name of a state, and sleeps here |
|
2812 |
if blocked statically. |
|
2813 |
||
2814 |
@param sname The state name. |
|
2815 |
*/ |
|
2816 |
#define SMF_BPOINT(sname) }case sname: if(StaticBlocks()) return(m.SetState(sname));{ |
|
2817 |
||
2818 |
||
2819 |
||
2820 |
||
2821 |
class TMMCStateMachine |
|
2822 |
/** |
|
2823 |
The MultiMediaCard state machine. |
|
2824 |
||
2825 |
@publishedPartner |
|
2826 |
@released |
|
2827 |
*/ |
|
2828 |
{ |
|
2829 |
public: |
|
2830 |
inline void Setup(TMMCErr (*anEntry)(TAny*), TAny* aContextP); |
|
2831 |
IMPORT_C void Reset(); |
|
2832 |
IMPORT_C TMMCErr Dispatch(); |
|
2833 |
inline TMMCErr ExitCode(); |
|
2834 |
inline TMMCErr SetExitCode(TMMCErr aCode); |
|
2835 |
inline TUint State(); |
|
2836 |
inline TMMCErr SetState(TUint aState); |
|
2837 |
inline void SuppressSuspension(); |
|
2838 |
inline void SetTraps(TMMCErr aMask); |
|
2839 |
inline void ResetTraps(); |
|
2840 |
inline void Abort(); |
|
2841 |
inline TMMCErr Pop(TBool aSuspend=EFalse); |
|
2842 |
inline TMMCErr PushMe(); |
|
2843 |
IMPORT_C TMMCErr Push(TMMCErr (*anEntry)(TAny*), TBool aSuspend=EFalse); |
|
2844 |
IMPORT_C TMMCErr Jump(TMMCErr (*anEntry)(TAny*), TBool aSuspend=EFalse); |
|
2845 |
private: |
|
2846 |
class TMMCMachineStackEntry |
|
2847 |
{ |
|
2848 |
public: |
|
2849 |
TMMCErr (*iFunction)(TAny*); |
|
2850 |
TUint iState; |
|
2851 |
TMMCErr iTrapMask; |
|
2852 |
}; |
|
2853 |
TBool iAbort; |
|
2854 |
TBool iSuspend; |
|
2855 |
TAny* iContextP; |
|
2856 |
TMMCErr iExitCode; |
|
2857 |
TInt iSP; |
|
2858 |
TMMCMachineStackEntry iStack[KMaxMMCMachineStackDepth]; |
|
2859 |
}; |
|
2860 |
||
2861 |
class TMMCCallBack |
|
2862 |
/** |
|
2863 |
This class is used to notify the request completion as a callback function for the clients of DMMCSession. |
|
2864 |
The callback function will be called on session completion. |
|
2865 |
Callback function is used to indicate Asynchronous Completion. |
|
2866 |
||
2867 |
@see DMMCSession |
|
2868 |
@publishedPartner |
|
2869 |
@released |
|
2870 |
*/ |
|
2871 |
{ |
|
2872 |
public: |
|
2873 |
inline TMMCCallBack(); |
|
2874 |
inline TMMCCallBack(void (*aFunction)(TAny* aPtr)); |
|
2875 |
inline TMMCCallBack(void (*aFunction)(TAny* aPtr), TAny* aPtr); |
|
2876 |
inline void CallBack() const; |
|
2877 |
public: |
|
2878 |
/** |
|
2879 |
A pointer to the callback function. |
|
2880 |
*/ |
|
2881 |
void (*iFunction)(TAny* aPtr); |
|
2882 |
||
2883 |
/** |
|
2884 |
A pointer that is passed to the callback function when |
|
2885 |
the callback function is called. |
|
2886 |
*/ |
|
2887 |
TAny* iPtr; |
|
2888 |
}; |
|
2889 |
||
2890 |
// DMMCStack serves an incoming queue of session requests. |
|
2891 |
// Each queue element is represented by an instance of the following class |
|
2892 |
||
2893 |
typedef TMMCErr (*TMMCSMSTFunc)(TAny*); |
|
2894 |
||
2895 |
class DMMCSession : public DBase |
|
2896 |
/** |
|
2897 |
Provides the main interface between the client and the MMC Socket, allowing commands and responses |
|
2898 |
to be processed asynchronously on the stack. |
|
2899 |
||
2900 |
Each client creates it own instance of this class. It is then able to make MultiMediaCard requests |
|
2901 |
on the selected stack by configuring the DMMCSession object with relevant information for the request |
|
2902 |
and then submitting (or engaging) this session object. |
|
2903 |
||
2904 |
The session is used to pass commands either to the entire stack (a broadcast command), or to individual |
|
2905 |
cards in the stack. The class contains functions for initiating macro functions as laid down by the |
|
2906 |
MultiMediaCard Association (MMCA) as well as lower level functions allowing a client to control the |
|
2907 |
stack in a more explicit manner. |
|
2908 |
||
2909 |
All requests on the MultiMediaCard stack which involve bus activity are inherently asynchronous. When |
|
2910 |
creating a DMMCSession object, a client supplies a call-back function as part of the constructor. |
|
2911 |
Once a client has engaged a session on the stack, it is informed of the completion of the request by |
|
2912 |
the Controller calling this call-back function. |
|
2913 |
||
2914 |
@publishedPartner |
|
2915 |
@released |
|
2916 |
*/ |
|
2917 |
{ |
|
2918 |
public: |
|
2919 |
IMPORT_C virtual ~DMMCSession(); |
|
2920 |
IMPORT_C DMMCSession(const TMMCCallBack& aCallBack); |
|
2921 |
||
2922 |
// Object initialisation |
|
2923 |
inline void SetStack(DMMCStack* aStackP); |
|
2924 |
IMPORT_C void SetCard(TMMCard* aCardP); |
|
2925 |
||
2926 |
// Control macros setup |
|
2927 |
inline void SetupCIMUpdateAcq(); |
|
2928 |
inline void SetupCIMInitStack(); |
|
2929 |
inline void SetupCIMCheckStack(); |
|
2930 |
inline void SetupCIMSetupCard(); |
|
2931 |
inline void SetupCIMLockStack(); |
|
2932 |
inline void SetupCIMInitStackAfterUnlock(); |
|
2933 |
inline void SetupCIMAutoUnlock(); |
|
2934 |
||
2935 |
// Data transfer macros setup |
|
2936 |
IMPORT_C void SetupCIMReadBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP); |
|
2937 |
IMPORT_C void SetupCIMWriteBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP); |
|
2938 |
IMPORT_C void SetupCIMReadMBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen); |
|
2939 |
IMPORT_C void SetupCIMWriteMBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen); |
|
2940 |
IMPORT_C void SetupCIMEraseSector(TMMCArgument aDevAddr, TUint32 aLength); |
|
2941 |
IMPORT_C void SetupCIMEraseGroup(TMMCArgument aDevAddr, TUint32 aLength); |
|
2942 |
IMPORT_C void SetupCIMReadIO(TUint8 aRegAddr, TUint32 aLength, TUint8* aMemoryP); |
|
2943 |
IMPORT_C void SetupCIMWriteIO(TUint8 aRegAddr, TUint32 aLength, TUint8* aMemoryP); |
|
2944 |
IMPORT_C void SetupCIMLockUnlock(TUint32 aLength, TUint8* aMemoryP); |
|
2945 |
||
2946 |
// Data transfer macros setup (block mode) |
|
2947 |
inline void SetupCIMReadBlock(TMMCArgument aBlockAddr, TUint8* aMemoryP, TUint32 aBlocks = 1); |
|
2948 |
inline void SetupCIMWriteBlock(TMMCArgument aBlockAddr, TUint8* aMemoryP, TUint32 aBlocks = 1); |
|
2949 |
inline void SetupCIMEraseMSector(TMMCArgument aBlockAddr, TUint32 aBlocks = 1); |
|
2950 |
inline void SetupCIMEraseMGroup(TMMCArgument aBlockAddr, TUint32 aBlocks = 1); |
|
2951 |
||
2952 |
// Raw commands (must be used in the locked bus state only) |
|
2953 |
// Known commands with or without (with a default) argument |
|
2954 |
IMPORT_C void SetupCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument=0); |
|
2955 |
||
2956 |
// Generic unknown command with unknown response type |
|
2957 |
IMPORT_C void SetupRSCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument, |
|
2958 |
TUint32 aResponseLength, TMMCCommandTypeEnum aCommandType=ECmdTypeUK, |
|
2959 |
TMMCResponseTypeEnum aResponseType=ERespTypeUnknown, |
|
2960 |
TUint32 aCommandClass=KMMCCmdClassNone); |
|
2961 |
||
2962 |
// Generic data transfer command |
|
2963 |
IMPORT_C void SetupDTCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument, |
|
2964 |
TUint32 aTotalLength, TUint8* aMemoryAddress, TUint32 aBlockLength=0, |
|
2965 |
TBool aStopTransmission=EFalse, TMMCCmdDirEnum aDir=EDirNone, |
|
2966 |
TUint32 aCommandClass=KMMCCmdClassNone); |
|
2967 |
// Actions |
|
2968 |
IMPORT_C TInt Engage(); // Enque session for execution |
|
2969 |
inline void UnlockStack(); // Unlock the bus |
|
2970 |
inline void Stop(); // Signal session to complete (stop and complete) |
|
2971 |
inline void Abort(); // Abort only (no completion) |
|
2972 |
||
2973 |
// Info retrieval |
|
2974 |
IMPORT_C TInt EpocErrorCode() const; // Derived from MMCExitCode and LastStatus |
|
2975 |
inline TMMCSessionTypeEnum SessionID() const; |
|
2976 |
inline DMMCStack* StackP() const; // DMMCStack serving this session |
|
2977 |
inline TMMCard* CardP() const; // The current card pointer |
|
2978 |
inline TBool IsEngaged() const; // Session is being served by DMMCStack |
|
2979 |
inline TMMCErr MMCExitCode() const; // MMC specific error code returned by DMMCStack |
|
2980 |
inline TMMCStatus LastStatus() const; // Last R1 response received from the card |
|
2981 |
inline TUint32 BytesTransferred() const;// The actual amount of data transferred in this session |
|
2982 |
inline TUint8* ResponseP(); // Current command response (&iCommand[iCmdSP].iResponse) |
|
2983 |
inline TUint32 EffectiveModes() const; // Modes which DMMCStack will consider as effective |
|
2984 |
// |
|
2985 |
inline void ResetCommandStack(); |
|
2986 |
private: |
|
2987 |
void SetupCIMControl(TInt aSessNum); |
|
2988 |
protected: |
|
2989 |
IMPORT_C virtual TMMCSMSTFunc GetMacro(TInt aSessNum) const; |
|
2990 |
inline void Block(TUint32 aFlag); |
|
2991 |
inline void UnBlock(TUint32 aFlag, TMMCErr anExitCode); |
|
2992 |
private: |
|
2993 |
#ifdef __EPOC32__ |
|
2994 |
static void PollTimerCallBack(TAny* aSessP); |
|
2995 |
static void RetryTimerCallBack(TAny* aSessP); |
|
2996 |
static void ProgramTimerCallBack(TAny* aSessP); |
|
2997 |
#endif |
|
2998 |
inline void SwapMe(); |
|
2999 |
void SynchBlock(TUint32 aFlag); |
|
3000 |
void SynchUnBlock(TUint32 aFlag); |
|
3001 |
public: |
|
3002 |
static const TMMCCommandSpec& FindCommandSpec(const TMMCIdxCommandSpec aSpecs[], TInt aIdx); |
|
3003 |
IMPORT_C void FillCommandDesc(); |
|
3004 |
IMPORT_C void FillCommandDesc(TMMCCommandEnum aCommand); |
|
3005 |
IMPORT_C void FillCommandDesc(TMMCCommandEnum aCommand, TMMCArgument anArgument); |
|
3006 |
IMPORT_C void FillCommandArgs(TMMCArgument anArgument, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen); |
|
3007 |
inline TMMCCommandDesc& Command(); // The current command descriptor |
|
3008 |
||
3009 |
inline void PushCommandStack(); |
|
3010 |
inline void PopCommandStack(); |
|
3011 |
||
3012 |
// Methods for double-buffered data transfer: |
|
3013 |
inline TBool RequestMoreData(); |
|
3014 |
inline void EnableDoubleBuffering(TUint32 aNumBlocks); /**< @internalTechnology */ |
|
3015 |
inline void SetDataTransferCallback(TMMCCallBack& aCallback); /**< @internalTechnology */ |
|
3016 |
inline void MoreDataAvailable(TUint32 aNumBlocks, TUint8* aMemoryP, TInt aError); /**< @internalTechnology */ |
|
3017 |
public: |
|
3018 |
/** |
|
3019 |
The last R1 response. |
|
3020 |
*/ |
|
3021 |
TMMCStatus iLastStatus; |
|
3022 |
||
3023 |
/** |
|
3024 |
A pointer to the card object. |
|
3025 |
*/ |
|
3026 |
TMMCard* iCardP; // Pointer to Card Info object |
|
3027 |
IMPORT_C TRCA CardRCA(); // Checks that card is still ready - otherwise returns 0 |
|
3028 |
TMMCSessionTypeEnum iSessionID; |
|
3029 |
private: |
|
3030 |
DMMCSession* iLinkP; // |
|
3031 |
protected: |
|
3032 |
TMMCCallBack iCallBack; // Where to report the completion |
|
3033 |
private: |
|
3034 |
DMMCStack* iStackP; // Pointer to Stack Controller |
|
3035 |
TCID iCID; // Card ID to ensure we are still talking to the same card |
|
3036 |
TUint32 iBytesTransferred; // The actual amount of data transferred in this session |
|
3037 |
TMMCErr iMMCExitCode; // State Machine exit code (MMC specific) |
|
3038 |
public: |
|
3039 |
/** |
|
3040 |
Session state flags (synchronous). |
|
3041 |
*/ |
|
3042 |
TUint32 iState; |
|
3043 |
private: |
|
3044 |
TUint iInitContext; // Stack Initialiser pass number |
|
3045 |
TUint iGlobalRetries; // Global retry counter |
|
3046 |
||
3047 |
// Asynchronous flags analysed by scheduler |
|
3048 |
TBool volatile iDoAbort; // Marks the session for abort |
|
3049 |
TBool volatile iDoStop; // Stop the session as soon as it's safe |
|
3050 |
TBool volatile iDoComplete; // Completion callback is now to be invoked |
|
3051 |
TBool iBrokenLock; // Stack lock is broken by force major |
|
3052 |
// |
|
3053 |
TUint32 iBlockOn; // blocking reasons |
|
3054 |
TInt iCmdSP; // Current Command stack index |
|
3055 |
||
3056 |
TMMCCommandDesc iCommand[KMaxMMCCommandStackDepth]; // Command stack |
|
3057 |
||
3058 |
TMMCCallBack iDataTransferCallback; // A callback function, used to request more data when performing double-buffering |
|
3059 |
||
3060 |
TUint32 iSpare[22]; // Spare data (stolen from iCommand) |
|
3061 |
||
3062 |
TMMCStateMachine iMachine; // State Machine context |
|
3063 |
#ifdef __EPOC32__ |
|
3064 |
NTimer iPollTimer; |
|
3065 |
NTimer iRetryTimer; |
|
3066 |
NTimer iProgramTimer; |
|
3067 |
#endif |
|
3068 |
public: |
|
3069 |
TMMCStackConfig iConfig; // Client configuration parameters |
|
3070 |
friend class DMMCStack; |
|
3071 |
friend class TMMCSessRing; |
|
3072 |
friend class TMMCardArray; |
|
3073 |
}; |
|
3074 |
||
3075 |
||
3076 |
class DMMCStack : public DBase |
|
3077 |
/** |
|
3078 |
This object controls access to the MultiMediaCard stack. |
|
3079 |
The DMMCSocket owns an instance of this class for the MultiMediaCard stack that it manages. |
|
3080 |
||
3081 |
@publishedPartner |
|
3082 |
@released |
|
3083 |
*/ |
|
3084 |
{ |
|
3085 |
public: |
|
3086 |
/** extension interfaces Ids */ |
|
3087 |
enum TInterfaceId |
|
3088 |
{ |
|
3089 |
KInterfaceMachineInfo, |
|
3090 |
KInterfaceSwitchToLowVoltageSM, |
|
3091 |
KInterfaceSetBusWidth, |
|
3092 |
KInterfaceDemandPagingInfo, |
|
3093 |
KInterfaceCancelSession, |
|
3094 |
KInterfaceDoWakeUpSM |
|
3095 |
}; |
|
3096 |
||
3097 |
/** generic interface */ |
|
3098 |
class MInterface |
|
3099 |
{ |
|
3100 |
public: |
|
3101 |
virtual TInt Function() = 0; |
|
3102 |
}; |
|
3103 |
||
3104 |
/** |
|
3105 |
Demand paging support |
|
3106 |
@see KInterfaceDemandPagingInfo |
|
3107 |
*/ |
|
3108 |
class TDemandPagingInfo |
|
3109 |
{ |
|
3110 |
public: |
|
3111 |
const TInt* iPagingDriveList; |
|
3112 |
TInt iDriveCount; |
|
3113 |
TUint iPagingType; |
|
3114 |
TInt iReadShift; |
|
3115 |
TUint iNumPages; |
|
3116 |
TBool iWriteProtected; |
|
3117 |
TInt iSlotNumber; |
|
3118 |
TUint iSpare[2]; |
|
3119 |
} ; |
|
3120 |
/** |
|
3121 |
* An optional interface implemented by the PSL for returning demand-paging information. |
|
3122 |
* @see KInterfaceDemandPagingInfo |
|
3123 |
*/ |
|
3124 |
class MDemandPagingInfo |
|
3125 |
{ |
|
3126 |
public: |
|
3127 |
virtual TInt DemandPagingInfo(TDemandPagingInfo& aInfo) = 0; |
|
3128 |
}; |
|
3129 |
||
3130 |
/** |
|
3131 |
* An optional interface State machine implemented by the PSL for handling asynchronous VccCore powerup |
|
3132 |
* @see KInterfaceDoWakeUpSM |
|
3133 |
*/ |
|
3134 |
class MDoWakeUp |
|
3135 |
{ |
|
3136 |
public: |
|
3137 |
virtual TMMCErr DoWakeUpSM()=0; |
|
3138 |
}; |
|
3139 |
||
3140 |
||
3141 |
public: |
|
3142 |
IMPORT_C DMMCStack(TInt aBus, DMMCSocket* aSocket); |
|
3143 |
IMPORT_C virtual TInt Init(); |
|
3144 |
// |
|
3145 |
// Actions |
|
3146 |
inline void ReportPowerUp(); |
|
3147 |
inline void ReportPowerDown(); |
|
3148 |
inline void Reset(); // Discard all requests and clear up |
|
3149 |
inline void CompleteAll(TMMCErr aCode); // Complete all operations with an error |
|
3150 |
inline void CancelSession(DMMCSession* aSession); |
|
3151 |
||
3152 |
IMPORT_C void PowerUpStack(); |
|
3153 |
IMPORT_C void PowerDownStack(); |
|
3154 |
void QSleepStack(); |
|
3155 |
IMPORT_C TInt Stop(TMMCard* aCardP); |
|
3156 |
// |
|
3157 |
// Inquiries |
|
3158 |
inline TUint MaxCardsInStack() const; |
|
3159 |
inline TMMCard* CardP(TUint aCardNumber); |
|
3160 |
inline DMMCSocket* MMCSocket() const; |
|
3161 |
inline TMMCPasswordStore* PasswordStore() const; |
|
3162 |
inline TBool InitStackInProgress() const; |
|
3163 |
inline TBool HasSessionsQueued() const; |
|
3164 |
inline TBool HasCardsPresent(); |
|
3165 |
inline void BufferInfo(TUint8*& aBuf, TInt& aBufLen, TInt& aMinorBufLen); |
|
3166 |
inline TInt DemandPagingInfo(TDemandPagingInfo& aInfo); |
|
3167 |
inline TBool StackRunning() const; |
|
3168 |
||
3169 |
||
3170 |
#ifdef __EPOC32__ |
|
3171 |
||
3172 |
/** |
|
3173 |
Defines the period for the poll timer. |
|
3174 |
||
3175 |
The poll timer is used by the generic layer for platforms |
|
3176 |
that do not provide an interrupt to indicate |
|
3177 |
when programming mode is finished. |
|
3178 |
||
3179 |
@return The poll timer period, in milliseconds. |
|
3180 |
*/ |
|
3181 |
virtual TInt ProgramPeriodInMilliSeconds() const =0; |
|
3182 |
#endif |
|
3183 |
||
3184 |
/** |
|
3185 |
* Calculates the minimum range that must be read off a card, an optimisation that takes advantage |
|
3186 |
* of the partial read feature found on some cards. It takes the logical range that the media driver |
|
3187 |
* wants to read from the card, and increases it to take into account factors such as FIFO width and |
|
3188 |
* minimum DMA transfer size. |
|
3189 |
* @param aCard A pointer to the MMC Card |
|
3190 |
* @param aStart The required start position |
|
3191 |
* @param aEnd The required end position |
|
3192 |
* @param aPhysStart The adjusted start position |
|
3193 |
* @param aPhysEnd The adjusted end position |
|
3194 |
*/ |
|
3195 |
virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const =0; |
|
3196 |
||
3197 |
/** |
|
3198 |
* Returns the details of the buffer allocated by the socket for data transfer operations. The buffer |
|
3199 |
* is allocated and configured at the variant layer to allow , for example, contiguous pages to be |
|
3200 |
* allocated for DMA transfers. |
|
3201 |
* @param aMDBuf A pointer to the allocated buffer |
|
3202 |
* @param aMDBufLen The length of the allocated buffer |
|
3203 |
*/ |
|
3204 |
virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen) =0; |
|
3205 |
||
3206 |
/** |
|
3207 |
* Gets the platform specific configuration information. |
|
3208 |
* @see TMMCMachineInfo |
|
3209 |
*/ |
|
3210 |
virtual void MachineInfo(TMMCMachineInfo& aMachineInfo) =0; |
|
3211 |
||
3212 |
/** |
|
3213 |
* Creates the session object |
|
3214 |
*/ |
|
3215 |
IMPORT_C virtual DMMCSession* AllocSession(const TMMCCallBack& aCallBack) const; |
|
3216 |
||
3217 |
protected: |
|
3218 |
// Platform layer service |
|
3219 |
inline TMMCBusConfig& BusConfig(); |
|
3220 |
inline TMMCBusConfig& MasterBusConfig(); |
|
3221 |
inline DMMCSession& Session(); // Current session |
|
3222 |
inline TMMCCommandDesc& Command(); // Current command descriptor of current session |
|
3223 |
inline TMMCStateMachine& Machine(); // State machine of current session |
|
3224 |
inline void BlockCurrentSession(TUint32 aFlag); |
|
3225 |
inline void UnBlockCurrentSession(TUint32 aFlag, TMMCErr anExitCode); |
|
3226 |
inline void ReportInconsistentBusState(); |
|
3227 |
inline void ReportASSPEngaged(); |
|
3228 |
inline void ReportASSPDisengaged(); |
|
3229 |
inline TRCA CurrentSessCardRCA(); // Checks that card is still ready - otherwise returns 0 |
|
3230 |
inline void CurrentSessPushCmdStack(); |
|
3231 |
inline void CurrentSessPopCmdStack(); |
|
3232 |
inline void CurrentSessFillCmdDesc(TMMCCommandEnum aCommand); |
|
3233 |
inline void CurrentSessFillCmdDesc(TMMCCommandEnum aCommand,TMMCArgument anArgument); |
|
3234 |
inline void CurrentSessFillCmdArgs(TMMCArgument anArgument,TUint32 aLength,TUint8* aMemoryP,TUint32 aBlkLen); |
|
3235 |
inline TRCA SelectedCard() const; |
|
3236 |
inline void YieldStack(TMMCCommandTypeEnum aCommand); |
|
3237 |
||
3238 |
void DoSetClock(TUint32 aClock); |
|
3239 |
void DoSetBusWidth(TUint32 aBusWidth); |
|
3240 |
TBusWidth BusWidthEncoding(TInt aBusWidth) const; |
|
3241 |
TUint MaxTranSpeedInKilohertz(const TMMCard& aCard) const; |
|
3242 |
||
3243 |
// Stack service provided by platform/variant layer. |
|
3244 |
||
3245 |
/** |
|
3246 |
* Returns the default master settings for the platform. |
|
3247 |
* @param aConfig A TMMCBusConfig reference to be filled in with the default settings. |
|
3248 |
* @param aClock The requested clock frequency (may be ignored if the hardware cannot support it). |
|
3249 |
*/ |
|
3250 |
virtual void SetBusConfigDefaults(TMMCBusConfig& aConfig, TUint aClock)=0; |
|
3251 |
||
3252 |
/** |
|
3253 |
* Switches from identification mode of operation to data transfer mode operation. |
|
3254 |
* |
|
3255 |
* Note that at this point the clock information in iBusConfig will not have been updated |
|
3256 |
* to the new data transfer rate. This function should generally just switch from open drain |
|
3257 |
* to push-pull bus mode - with the clock rate being changed at the start of IssueMMCCommandSM, |
|
3258 |
* where iBusConfig will be valid. |
|
3259 |
*/ |
|
3260 |
virtual void InitClockOff()=0; |
|
3261 |
||
3262 |
/** |
|
3263 |
* Stop all activities on the host stack. |
|
3264 |
* |
|
3265 |
* This will generally perform the same operations as for ASSPDisengage() but this will additionally |
|
3266 |
* turn off the clock to the hardware interface and release any requested power requirements made on |
|
3267 |
* the power model. (That is release any power requirements made as part of the InitClockOnSM() function). |
|
3268 |
* |
|
3269 |
* Called from the platform independent layer when it is required to immediately cancel any PSL asynchronous |
|
3270 |
* activity because the current session has been aborted. |
|
3271 |
* |
|
3272 |
* This function should normally include a call to ReportAsspDisengaged() at the end, to report to the PIL |
|
3273 |
* that the PSL level resources have been disengaged. |
|
3274 |
*/ |
|
3275 |
virtual void ASSPReset()=0; |
|
3276 |
||
3277 |
/** |
|
3278 |
* Called each time a session which has engaged PSL resources has completed or has been aborted. |
|
3279 |
* |
|
3280 |
* This should disable any activities which were required to perform the session just completed/aborted. |
|
3281 |
* It shouldn't however turn off the clock to the hardware interface (which will be turned off instead |
|
3282 |
* by the inactivity timer). This typically disables DMA and interface interrupts and forces the hardware |
|
3283 |
* interface into idle. |
|
3284 |
* |
|
3285 |
* This function should normally include a call to ReportAsspDisengaged() at the end, to report to the PIL |
|
3286 |
* that the PSL level resources have been disengaged. |
|
3287 |
*/ |
|
3288 |
virtual void ASSPDisengage()=0; |
|
3289 |
||
3290 |
/** |
|
3291 |
* Called as part of the bus power down sequence. It stops all activities on the host stack, turns off the clock |
|
3292 |
* to the hardware interface and releases any requested power requirements made on the power model |
|
3293 |
* (i.e. very often a straight call of ASSPReset()). |
|
3294 |
* |
|
3295 |
* This shouldn't turn off the MMC PSU as this will be performed immediately afterwards by the PSU class. |
|
3296 |
*/ |
|
3297 |
virtual void DoPowerDown()=0; |
|
3298 |
||
3299 |
IMPORT_C virtual TBool CardDetect(TUint aCardNumber); |
|
3300 |
IMPORT_C virtual TBool WriteProtected(TUint aCardNumber); |
|
3301 |
// |
|
3302 |
// State Machine functions implemented in platform layer. |
|
3303 |
||
3304 |
/** |
|
3305 |
* Called as a child function at the start of the CIM_UPDATE_ACQ macro state machine. |
|
3306 |
* |
|
3307 |
* It should perform the necessary PSL level actions associated with powering up the bus. This includes |
|
3308 |
* turning on the MMC PSU. However, the hardware interface clock should not be turned on as part of this function. |
|
3309 |
* |
|
3310 |
* If the Controller has to request power resources from the power model (e.g a fast system clock required all the |
|
3311 |
* time the bus is powered) then this state machine function can be used to asynchronously wait for this resource |
|
3312 |
* to become available. |
|
3313 |
* |
|
3314 |
* Upon completion, DMMCStack::ReportPowerUp() should be called. |
|
3315 |
* |
|
3316 |
* @return KMMCErrNone if completed successfully or standard TMMCErr code otherwise |
|
3317 |
*/ |
|
3318 |
virtual TMMCErr DoPowerUpSM()=0; |
|
3319 |
||
3320 |
/** |
|
3321 |
* Turns on the clock to the hardware interface. |
|
3322 |
* |
|
3323 |
* This state machine function is called as a child function as part of the CIM_UPDATE_ACQ macro state machine. |
|
3324 |
* |
|
3325 |
* It is implemented as a state machine function since it may be necessary to include a short delay after the |
|
3326 |
* clock has been turned on to allow it to stabilise, or in some cases it may be necessary to wait for a power |
|
3327 |
* resource to become available. |
|
3328 |
* |
|
3329 |
* This function should normally include a call to ReportAsspEngaged() at the start, to report to the PIL that the PSL |
|
3330 |
* level resources have been engaged. |
|
3331 |
* |
|
3332 |
* @return KMMCErrNone if completed successfully or standard TMMCErr code otherwise |
|
3333 |
*/ |
|
3334 |
virtual TMMCErr InitClockOnSM()=0; |
|
3335 |
||
3336 |
/** |
|
3337 |
* Executes a single command over the bus. |
|
3338 |
* |
|
3339 |
* The input parameters are passed via the current command descriptor on the session's command stack |
|
3340 |
* (TMMCCommandDesc class), which specifies the type of command, response type, arguments etc.. |
|
3341 |
* |
|
3342 |
* @return KMMCErrNone if completed successfully or standard TMMCErr code otherwise |
|
3343 |
*/ |
|
3344 |
IMPORT_C virtual TMMCErr IssueMMCCommandSM()=0; |
|
3345 |
||
3346 |
TBool StaticBlocks(); |
|
3347 |
||
3348 |
/** |
|
3349 |
* Indicates that the PSL should change the bus width. |
|
3350 |
* Must be implemented by the Platform Specific Layer if MMCV4 4/8-bit bus mode is required |
|
3351 |
*/ |
|
3352 |
IMPORT_C virtual void SetBusWidth(TUint32 aBusWidth); |
|
3353 |
||
3354 |
/** |
|
3355 |
* Retrieves a TMMCMachineInfoV4 from the PSL |
|
3356 |
* Must be implemented by the Platform Specific Layer if MMCV4 support is required |
|
3357 |
*/ |
|
3358 |
public: |
|
3359 |
IMPORT_C virtual void MachineInfo(TDes8& aMachineInfo); |
|
3360 |
||
3361 |
protected: |
|
3362 |
/** |
|
3363 |
* Switches the MMC bus to low voltage mode |
|
3364 |
*/ |
|
3365 |
TMMCErr SwitchToLowVoltageSM(); |
|
3366 |
||
3367 |
||
3368 |
private: |
|
3369 |
// |
|
3370 |
// Session service |
|
3371 |
void Add(DMMCSession* aSessP); |
|
3372 |
void Abort(DMMCSession* aSessP); |
|
3373 |
void Stop(DMMCSession* aSessP); |
|
3374 |
void UnlockStack(DMMCSession* aSessP); |
|
3375 |
void MarkComplete(DMMCSession* aSessP, TMMCErr anExitCode); |
|
3376 |
// |
|
3377 |
// Stack control and operations support |
|
3378 |
// Scheduler and its supplementary functions |
|
3379 |
enum TMMCStackSchedStateEnum |
|
3380 |
{ |
|
3381 |
ESchedContinue=0, |
|
3382 |
ESchedLoop=1, |
|
3383 |
ESchedExit, |
|
3384 |
ESchedChooseJob |
|
3385 |
}; |
|
3386 |
void Scheduler(volatile TBool& aFlag); |
|
3387 |
void DoSchedule(); |
|
3388 |
TMMCStackSchedStateEnum SchedGetOnDFC(); |
|
3389 |
void SchedSetContext(DMMCSession* aSessP); |
|
3390 |
void SchedDoAbort(DMMCSession* aSessP); |
|
3391 |
TMMCStackSchedStateEnum SchedResolveStatBlocks(DMMCSession* aSessP); |
|
3392 |
TMMCStackSchedStateEnum SchedGroundDown(DMMCSession* aSessP, TMMCErr aReason); |
|
3393 |
TMMCStackSchedStateEnum SchedEnqueStackSession(TMMCSessionTypeEnum aSessID); |
|
3394 |
void SchedGrabEntries(); |
|
3395 |
void SchedDisengage(); |
|
3396 |
TBool SchedAllowDirectCommands(DMMCSession* aSessP); |
|
3397 |
TBool SchedYielding(DMMCSession* aSessP); |
|
3398 |
inline TMMCStackSchedStateEnum SchedAbortPass(); |
|
3399 |
inline TMMCStackSchedStateEnum SchedCompletionPass(); |
|
3400 |
inline TMMCStackSchedStateEnum SchedInitStack(); |
|
3401 |
inline TMMCStackSchedStateEnum SchedSleepStack(); |
|
3402 |
inline TBool SchedPreemptable(); |
|
3403 |
inline TMMCStackSchedStateEnum SchedSession(); |
|
3404 |
inline TMMCStackSchedStateEnum SchedChooseJob(); |
|
3405 |
// |
|
3406 |
// Miscellaneous SM function service |
|
3407 |
protected: |
|
3408 |
void MergeConfig(DMMCSession* aSessP); |
|
3409 |
private: |
|
3410 |
inline void DeselectsToIssue(TUint aNumber); |
|
3411 |
||
3412 |
// Static Completion routines. |
|
3413 |
static void StackDFC(TAny* aStackP); |
|
3414 |
static void StackSessionCBST(TAny* aStackP); |
|
3415 |
TInt StackSessionCB(); |
|
3416 |
static void AutoUnlockCBST(TAny *aStackP); |
|
3417 |
TInt AutoUnlockCB(); |
|
3418 |
||
3419 |
protected: |
|
3420 |
IMPORT_C void Block(DMMCSession* aSessP, TUint32 aFlag); |
|
3421 |
IMPORT_C void UnBlock(DMMCSession* aSessP, TUint32 aFlag, TMMCErr anExitCode); |
|
3422 |
||
3423 |
protected: |
|
3424 |
// State machines. The adapter functions just call the non-static versions. |
|
3425 |
// Top-level state machines. |
|
3426 |
static TMMCErr NakedSessionSMST(TAny* aStackP); // ECIMNakedSession |
|
3427 |
inline TMMCErr NakedSessionSM(); |
|
3428 |
static TMMCErr CIMUpdateAcqSMST(TAny* aStackP); // ECIMUpdateAcq |
|
3429 |
TMMCErr CIMUpdateAcqSM(); |
|
3430 |
static TMMCErr CIMInitStackSMST(TAny* aStackP); // ECIMInitStack |
|
3431 |
inline TMMCErr CIMInitStackSM(); |
|
3432 |
static TMMCErr CIMCheckStackSMST(TAny* aStackP); // ECIMCheckStack |
|
3433 |
inline TMMCErr CIMCheckStackSM(); |
|
3434 |
static TMMCErr CIMSetupCardSMST(TAny* aStackP); // ECIMSetupCard |
|
3435 |
inline TMMCErr CIMSetupCardSM(); |
|
3436 |
IMPORT_C static TMMCErr CIMReadWriteBlocksSMST(TAny* aStackP); // ECIMReadBlock, ECIMWriteBlock, ECIMReadMBlock, ECIMWriteMBlock |
|
3437 |
IMPORT_C virtual TMMCErr CIMReadWriteBlocksSM(); |
|
3438 |
static TMMCErr CIMEraseSMST(TAny* aStackP); // ECIMEraseSector, ECIMEraseGroup |
|
3439 |
inline TMMCErr CIMEraseSM(); |
|
3440 |
static TMMCErr CIMReadWriteIOSMST(TAny* aStackP); // ECIMReadIO, ECIMWriteIO |
|
3441 |
inline TMMCErr CIMReadWriteIOSM(); |
|
3442 |
static TMMCErr CIMLockUnlockSMST(TAny *aStackP); // ECIMLockUnlock |
|
3443 |
inline TMMCErr CIMLockUnlockSM(); |
|
3444 |
static TMMCErr NoSessionSMST(TAny* aStackP); // ECIMLockStack |
|
3445 |
inline TMMCErr NoSessionSM(); |
|
3446 |
static TMMCErr AcquireStackSMST(TAny* aStackP); |
|
3447 |
IMPORT_C virtual TMMCErr AcquireStackSM(); |
|
3448 |
static TMMCErr CheckStackSMST(TAny* aStackP); // ECIMCheckStack |
|
3449 |
inline TMMCErr CheckStackSM(); |
|
3450 |
static TMMCErr CheckLockStatusSMST(TAny* aStackP); |
|
3451 |
inline TMMCErr CheckLockStatusSM(); |
|
3452 |
static TMMCErr ModifyCardCapabilitySMST(TAny* aStackP); |
|
3453 |
IMPORT_C virtual TMMCErr ModifyCardCapabilitySM(); |
|
3454 |
static TMMCErr BaseModifyCardCapabilitySMST(TAny* aStackP); |
|
3455 |
static TMMCErr DoPowerUpSMST(TAny* aStackP); |
|
3456 |
static TMMCErr InitClockOnSMST(TAny* aStackP); |
|
3457 |
IMPORT_C static TMMCErr IssueMMCCommandSMST(TAny* aStackP); |
|
3458 |
||
3459 |
static TMMCErr CIMAutoUnlockSMST(TAny* aStackP); |
|
3460 |
inline TMMCErr CIMAutoUnlockSM(); |
|
3461 |
||
3462 |
static TMMCErr InitStackAfterUnlockSMST(TAny* aStackP); // ECIMInitStackAfterUnlock |
|
3463 |
IMPORT_C virtual TMMCErr InitStackAfterUnlockSM(); |
|
3464 |
||
3465 |
static TMMCErr InitCurrentCardAfterUnlockSMST(TAny* aStackP); |
|
3466 |
||
3467 |
static TMMCErr AttachCardSMST(TAny* aStackP); |
|
3468 |
inline TMMCErr AttachCardSM(); |
|
3469 |
static TMMCErr ExecCommandSMST(TAny* aStackP); |
|
3470 |
inline TMMCErr ExecCommandSM(); |
|
3471 |
static TMMCErr IssueCommandCheckResponseSMST(TAny* aStackP); |
|
3472 |
inline TMMCErr IssueCommandCheckResponseSM(); |
|
3473 |
static TMMCErr PollGapTimerSMST(TAny* aStackP); |
|
3474 |
inline TMMCErr PollGapTimerSM(); |
|
3475 |
static TMMCErr RetryGapTimerSMST(TAny* aStackP); |
|
3476 |
inline TMMCErr RetryGapTimerSM(); |
|
3477 |
static TMMCErr ProgramTimerSMST(TAny *aStackP); |
|
3478 |
inline TMMCErr ProgramTimerSM(); |
|
3479 |
static TMMCErr GoIdleSMST(TAny* aStackP); |
|
3480 |
inline TMMCErr GoIdleSM(); |
|
3481 |
||
3482 |
static TMMCErr SwitchToLowVoltageSMST(TAny* aStackP); |
|
3483 |
||
3484 |
static TMMCErr DoWakeUpSMST(TAny* aStackP); |
|
3485 |
||
3486 |
||
3487 |
private: |
|
3488 |
static TMMCErr ConfigureHighSpeedSMST(TAny* aStackP); |
|
3489 |
inline TMMCErr ConfigureHighSpeedSM(); |
|
3490 |
||
3491 |
static TMMCErr DetermineBusWidthAndClockSMST(TAny* aStackP); |
|
3492 |
inline TMMCErr DetermineBusWidthAndClockSM(); |
|
3493 |
||
3494 |
static TMMCErr ExecSwitchCommandST(TAny* aStackP); |
|
3495 |
inline TMMCErr ExecSwitchCommand(); |
|
3496 |
||
3497 |
static TMMCErr ExecSleepCommandSMST(TAny* aStackP); |
|
3498 |
inline TMMCErr ExecSleepCommandSM(); |
|
3499 |
||
3500 |
static TMMCErr ExecAwakeCommandSMST(TAny* aStackP); |
|
3501 |
inline TMMCErr ExecAwakeCommandSM(); |
|
3502 |
||
3503 |
static TMMCErr LowVoltagePowerupTimerSMST(TAny *aStackP); |
|
3504 |
TMMCErr LowVoltagePowerupTimerSM(); |
|
3505 |
||
3506 |
static TMMCErr ExecBusTestSMST(TAny* aStackP); |
|
3507 |
inline TMMCErr ExecBusTestSM(); |
|
3508 |
||
3509 |
enum TBusWidthAndClock |
|
3510 |
{ |
|
3511 |
E1Bit20Mhz = 0x0000, |
|
3512 |
||
3513 |
E4Bits26Mhz = 0x0001, |
|
3514 |
E4Bits52Mhz = 0x0002, |
|
3515 |
||
3516 |
E8Bits26Mhz = 0x0004, |
|
3517 |
E8Bits52Mhz = 0x0008, |
|
3518 |
}; |
|
3519 |
enum TBusWidthAndClockMasks |
|
3520 |
{ |
|
3521 |
E4BitMask = E4Bits26Mhz | E4Bits52Mhz, |
|
3522 |
E8BitMask = E8Bits26Mhz | E8Bits52Mhz, |
|
3523 |
E26MhzMask = E4Bits26Mhz | E8Bits26Mhz, |
|
3524 |
E52MhzMask = E4Bits52Mhz | E8Bits52Mhz |
|
3525 |
}; |
|
3526 |
||
3527 |
void DetermineBusWidthAndClock(const TMMCard& aCard, TBool aLowVoltage, TUint& aPowerClass, TBusWidthAndClock& aBusWidthAndClock); |
|
3528 |
TUint GetPowerClass(const TMMCard& aCard, TBusWidthAndClock aWidthAndClock, TBool aLowVoltage); |
|
3529 |
||
3530 |
||
3531 |
// ----------- Data Members ------------- |
|
3532 |
private: |
|
3533 |
// |
|
3534 |
// Synchronous status, data structures and control info. |
|
3535 |
TUint32 iStackState; |
|
3536 |
TUint iInitContext; // Stack Initialiser pass number |
|
3537 |
DMMCSession* iLockingSessionP; |
|
3538 |
TMMCSessRing iWorkSet; |
|
3539 |
TMMCSessRing iReadyQueue; |
|
3540 |
TMMCSessRing iEntryQueue; |
|
3541 |
TDfc iStackDFC; |
|
3542 |
TRCA iSelectedCard; |
|
3543 |
DMMCSocket* iSocket; |
|
3544 |
DMMCSession* iStackSession; |
|
3545 |
DMMCSession iAutoUnlockSession; |
|
3546 |
TInt iAutoUnlockIndex; // index into iCards |
|
3547 |
protected: |
|
3548 |
TUint8* iPSLBuf; |
|
3549 |
private: |
|
3550 |
TInt iPSLBufLen; |
|
3551 |
TInt iMinorBufLen; |
|
3552 |
TUint8 iSpare[2]; |
|
3553 |
TBool volatile iSleep; |
|
3554 |
DThread* iNotifierThread; |
|
3555 |
TRequestStatus* iNotifierReqStat; |
|
3556 |
enum TInitState {EISPending, EISDone}; |
|
3557 |
TInitState iInitState; |
|
3558 |
// |
|
3559 |
// Stack and Scheduler control |
|
3560 |
// Asynchronous sheduler attention flags |
|
3561 |
TBool volatile iAttention; // There are ready sessions |
|
3562 |
TBool volatile iAbortReq; // There are sessions marked for abort |
|
3563 |
TBool volatile iCompReq; // There are sessions to complete |
|
3564 |
TBool volatile iInitialise; // Enforce InitStack (after enforced PowerDown) |
|
3565 |
TBool volatile iUpdate; // Enque InitStack into iWorkSet |
|
3566 |
// Other asynchronous flags |
|
3567 |
TBool volatile iPoweredUp; |
|
3568 |
TBool volatile iDFCRunning; |
|
3569 |
TBool volatile iAbortAll; |
|
3570 |
TMMCErr volatile iCompleteAllExitCode; |
|
3571 |
// |
|
3572 |
// Session context |
|
3573 |
protected: |
|
3574 |
DMMCSession* iSessionP; |
|
3575 |
private: |
|
3576 |
// |
|
3577 |
// Bus control |
|
3578 |
TDSR iCurrentDSR; |
|
3579 |
// |
|
3580 |
// Stack data structures and Session/StateMachine miscellaneous |
|
3581 |
TUint iDeselectsToIssue; |
|
3582 |
TInt iCxDeselectCount; |
|
3583 |
TUint8 iCMD42CmdByte; |
|
3584 |
TMediaPassword iMPTgt; |
|
3585 |
public: |
|
3586 |
IMPORT_C TUint32 EffectiveModes(const TMMCStackConfig& aClientConfig); |
|
3587 |
TUint32 iCurrentOpRange; |
|
3588 |
TInt iCxCardCount; |
|
3589 |
TInt iCxPollRetryCount; |
|
3590 |
TMMCStackConfig iConfig; |
|
3591 |
TUint iMaxCardsInStack; |
|
3592 |
TMMCRCAPool iRCAPool; |
|
3593 |
TMMCardArray* iCardArray; |
|
3594 |
TMMCStackConfig iMasterConfig; |
|
3595 |
friend class DMMCSocket; |
|
3596 |
friend class DMMCSession; |
|
3597 |
friend class TMMCardArray; |
|
3598 |
||
3599 |
private: |
|
3600 |
// |
|
3601 |
// Dummy functions to maintain binary compatibility |
|
3602 |
IMPORT_C virtual void Dummy1(); |
|
3603 |
||
3604 |
protected: |
|
3605 |
/** |
|
3606 |
Gets an interface from a derived class |
|
3607 |
replaces reserved virtual Dummy4() |
|
3608 |
*/ |
|
3609 |
IMPORT_C virtual void GetInterface(TInterfaceId aInterfaceId, MInterface*& aInterfacePtr); |
|
3610 |
||
3611 |
private: |
|
3612 |
TBusWidthAndClock iBusWidthAndClock; |
|
3613 |
TInt iSelectedCardIndex; |
|
3614 |
// |
|
3615 |
// Reserved members to maintain binary compatibility |
|
3616 |
protected: |
|
3617 |
TBool iMultiplexedBus; // ETrue if cards are individually selectable. EFalse if stacked on a common bus. |
|
3618 |
private: |
|
3619 |
TMMCCommandTypeEnum iYieldCommandType; |
|
3620 |
TInt iReserved; |
|
3621 |
||
3622 |
protected: |
|
3623 |
// Pointer to protected utility class which allows class to grow while maintining BC |
|
3624 |
// replaces fourth element of iReserved[] |
|
3625 |
class DBody; |
|
3626 |
friend class DBody; |
|
3627 |
DBody* iBody; |
|
3628 |
}; |
|
3629 |
||
3630 |
||
3631 |
||
3632 |
||
3633 |
class TMMCMachineInfo |
|
3634 |
/** |
|
3635 |
Platform-specific configuration information for the |
|
3636 |
MultiMediaCard stack. |
|
3637 |
||
3638 |
An object of this type is passed to the Variant implementation |
|
3639 |
of DMMCStack::MachineInfo(), which should fill the public data |
|
3640 |
members with appropriate information and values. |
|
3641 |
||
3642 |
@publishedPartner |
|
3643 |
@released |
|
3644 |
*/ |
|
3645 |
{ |
|
3646 |
||
3647 |
public: |
|
3648 |
enum THardwareConfig |
|
3649 |
{ |
|
3650 |
/** |
|
3651 |
Set this bit in iFlags if hardware supports SPI mode (not currently supported - set this bit to zero) |
|
3652 |
*/ |
|
3653 |
ESupportsSPIMode = 0x01, |
|
3654 |
||
3655 |
/** |
|
3656 |
Set this bit in iFlags if the PSL is enabled for double-buffered data transfers |
|
3657 |
*/ |
|
3658 |
ESupportsDoubleBuffering = 0x02, |
|
3659 |
||
3660 |
/** |
|
3661 |
Set this bit in iFlags if the PSL supports response type R7 |
|
3662 |
*/ |
|
3663 |
ESupportsR7 = 0x04, |
|
3664 |
||
3665 |
/** |
|
3666 |
Set this bit in iFlags if the hardware DMA controller utilises 8-Bit Addressing |
|
3667 |
*/ |
|
3668 |
EDma8BitAddressing = 0x08, |
|
3669 |
||
3670 |
/** |
|
3671 |
Set this bit in iFlags if the hardware DMA controller utilises 16-Bit Addressing |
|
3672 |
*/ |
|
3673 |
EDma16BitAddressing = 0x10, |
|
3674 |
||
3675 |
/** |
|
3676 |
Set this bit in iFlags if the hardware DMA controller utilises 32-Bit Addressing |
|
3677 |
*/ |
|
3678 |
EDma32BitAddressing = 0x20, |
|
3679 |
||
3680 |
/** |
|
3681 |
Set this bit in iFlags if the hardware DMA controller utilises 64-Bit Addressing |
|
3682 |
*/ |
|
3683 |
EDma64BitAddressing = 0x40, |
|
3684 |
||
3685 |
/** |
|
3686 |
Set this in iFlags if the hardware supports DMA and can cope with being given a physical address. |
|
3687 |
This also sets the ESupportsDoubleBuffering flag, physical addressing is dependent on |
|
3688 |
doublebuffering functionality. |
|
3689 |
@see ESupportsDoubleBuffering |
|
3690 |
@see KMMCCmdFlagPhysAddr flag |
|
3691 |
*/ |
|
3692 |
ESupportsDMA = 0x082, |
|
3693 |
||
3694 |
/** |
|
3695 |
Set this in iFlags if the hardware is unable to perform data transfers of more than 256K |
|
3696 |
- Transfers greater than 256K will be split into multiple transactions. |
|
3697 |
*/ |
|
3698 |
EMaxTransferLength_256K = 0x100, |
|
3699 |
||
3700 |
/** |
|
3701 |
Set this in iFlags if the hardware is unable to perform data transfers of more than 512K |
|
3702 |
- Transfers greater than 512K will be split into multiple transactions. |
|
3703 |
*/ |
|
3704 |
EMaxTransferLength_512K = 0x200, |
|
3705 |
||
3706 |
/** |
|
3707 |
Set this in iFlags if the hardware is unable to perform data transfers of more than 1M |
|
3708 |
- Transfers greater than 1M will be split into multiple transactions. |
|
3709 |
*/ |
|
3710 |
EMaxTransferLength_1M = 0x300, |
|
3711 |
||
3712 |
/** |
|
3713 |
Set this in iFlags if the hardware is unable to perform data transfers of more than 2M |
|
3714 |
- Transfers greater than 2M will be split into multiple transactions. |
|
3715 |
*/ |
|
3716 |
EMaxTransferLength_2M = 0x400, |
|
3717 |
||
3718 |
/** |
|
3719 |
Set this in iFlags if the hardware is unable to perform data transfers of more than 4M |
|
3720 |
- Transfers greater than 4M will be split into multiple transactions. |
|
3721 |
*/ |
|
3722 |
EMaxTransferLength_4M = 0x500, |
|
3723 |
||
3724 |
/** |
|
3725 |
Set this in iFlags if the hardware is unable to perform data transfers of more than 8M |
|
3726 |
- Transfers greater than 8M will be split into multiple transactions. |
|
3727 |
*/ |
|
3728 |
EMaxTransferLength_8M = 0x600, |
|
3729 |
||
3730 |
/** |
|
3731 |
Set this in iFlags if the hardware is unable to perform data transfers of more than 16M |
|
3732 |
- Transfers greater than 16M will be split into multiple transactions. |
|
3733 |
*/ |
|
3734 |
EMaxTransferLength_16M = 0x700, |
|
3735 |
||
3736 |
/** |
|
3737 |
The card in slot 1 is internal, i.e. not removable |
|
3738 |
*/ |
|
3739 |
ESlot1Internal = 0x0800, |
|
3740 |
||
3741 |
/** |
|
3742 |
The card in slot 2 is internal, i.e. not removable |
|
3743 |
*/ |
|
3744 |
ESlot2Internal = 0x1000, |
|
3745 |
}; |
|
3746 |
||
3747 |
public: |
|
3748 |
/** |
|
3749 |
The total number of MultiMediaCard slots for this stack. |
|
3750 |
||
3751 |
Be aware that this refers to the stack, and NOT to the platform; |
|
3752 |
a platform can have multiple stacks. |
|
3753 |
*/ |
|
3754 |
TInt iTotalSockets; |
|
3755 |
||
3756 |
/** |
|
3757 |
Not currently used. |
|
3758 |
||
3759 |
Set this value to zero. |
|
3760 |
*/ |
|
3761 |
TInt iTotalMediaChanges; |
|
3762 |
||
3763 |
/** |
|
3764 |
Not currently used. |
|
3765 |
||
3766 |
Set this value to zero. |
|
3767 |
*/ |
|
3768 |
TInt iTotalPrimarySupplies; |
|
3769 |
||
3770 |
union |
|
3771 |
{ |
|
3772 |
/** |
|
3773 |
Indicates whether the SPI protocol is being used or not. |
|
3774 |
||
3775 |
SPI not currently supported; set this to EFalse. |
|
3776 |
*/ |
|
3777 |
TBool iSPIMode; // SPI mode not yet supported |
|
3778 |
/** |
|
3779 |
Hardware configuration flags |
|
3780 |
*/ |
|
3781 |
TUint32 iFlags; |
|
3782 |
}; |
|
3783 |
||
3784 |
/** |
|
3785 |
The number of the first peripheral bus slot claimed by the |
|
3786 |
MultiMediaCard controller. |
|
3787 |
||
3788 |
Symbian OS supports 4, so set this to a value in the range 0-3. |
|
3789 |
*/ |
|
3790 |
TInt iBaseBusNumber; |
|
3791 |
}; |
|
3792 |
||
3793 |
||
3794 |
||
3795 |
||
3796 |
typedef TPckg<TMMCMachineInfo> TMMCardMachineInfoPckg; |
|
3797 |
||
3798 |
/** |
|
3799 |
Platform-specific configuration information for the |
|
3800 |
MultiMediaCard stack. Contains information pertinent to |
|
3801 |
MMC specification version 4.0/4.1 |
|
3802 |
||
3803 |
An object of this type is passed to the Variant implementation |
|
3804 |
of DMMCStack::MachineInfo(), which should fill the public data |
|
3805 |
members with appropriate information and values. |
|
3806 |
||
3807 |
@internalComponent |
|
3808 |
*/ |
|
3809 |
class TMMCMachineInfoV4 : public TMMCMachineInfo |
|
3810 |
{ |
|
3811 |
public: |
|
3812 |
inline TMMCMachineInfoV4() {memclr(this, sizeof(*this));} |
|
3813 |
||
3814 |
/** |
|
3815 |
The version of the structure returned by the PSL in a call to DMMStack::MachineInfo() |
|
3816 |
The fields defined in TMMCMachineInfoV4 are only valid if the version is EVersion4 or higher |
|
3817 |
*/ |
|
3818 |
enum TVersion {EVersion3, EVersion4}; |
|
3819 |
TVersion iVersion; |
|
3820 |
||
3821 |
/** |
|
3822 |
The maximum bus width supported. |
|
3823 |
*/ |
|
3824 |
TBusWidth iMaxBusWidth; |
|
3825 |
||
3826 |
/** |
|
3827 |
Maximum clock frequency supported, |
|
3828 |
N.B. if the controller's maximum clock rate is only slightly less than one of the |
|
3829 |
"high-speed" clock frequencies defined in MMC spec 4.0 (i.e 26 Mhz and 52 Mhz), then |
|
3830 |
it can still report that it is supported and then run at the slightly lower clock rate. |
|
3831 |
*/ |
|
3832 |
enum THighSpeedClocks {EClockSpeed26Mhz = 26, EClockSpeed52Mhz = 52}; |
|
3833 |
TUint iMaxClockSpeedInMhz; |
|
3834 |
||
3835 |
/** |
|
3836 |
The power class supported for 3.6V (high voltage). |
|
3837 |
This is a 4-bit value encoded in the same way as the POWER_CLASS field in the EXT_CSD |
|
3838 |
register. i.e. 0=100mA, 1=120mA, ... 10=450mA. |
|
3839 |
See MMC sepcification version 4.1, EXT_CSD register. |
|
3840 |
*/ |
|
3841 |
enum THiVoltagePowerClasses {EHi100mA, EHi120mA, EHi150mA, EHi180mA, EHi200mA, EHi220mA, EHi250mA, EHi300mA, EHi350mA, EHi400mA, EHi450mA }; |
|
3842 |
TUint iHighVoltagePowerClass; |
|
3843 |
||
3844 |
/** |
|
3845 |
The power class supported for 1.95V (low voltage). |
|
3846 |
This is a 4-bit value encoded in the same way as the POWER_CLASS field in the EXT_CSD |
|
3847 |
register. i.e. 0=65mA, 1=70mA, ... 10=250mA. |
|
3848 |
See MMC sepcification version 4.1, EXT_CSD register. |
|
3849 |
*/ |
|
3850 |
enum TLoVoltagePowerClasses {ELo065mA, ELo070mA, ELo080mA, ELo090mA, ELo100mA, ELo120mA, ELo140mA, ELo160mA, ELo180mA, ELo200mA, ELo250mA }; |
|
3851 |
TUint iLowVoltagePowerClass; |
|
3852 |
}; |
|
3853 |
||
3854 |
||
3855 |
class DMMCPsu : public DPBusPsuBase |
|
3856 |
/** |
|
3857 |
DPBusPsuBase derived abstract class to control the MMC socket's power supply. |
|
3858 |
||
3859 |
This class is intended for derivation at the variant layer, which handles the |
|
3860 |
variant specific functionality of the power supply. |
|
3861 |
||
3862 |
@publishedPartner |
|
3863 |
@released |
|
3864 |
*/ |
|
3865 |
{ |
|
3866 |
public: |
|
3867 |
IMPORT_C DMMCPsu(TInt aPsuNum, TInt aMediaChangedNum); |
|
3868 |
||
3869 |
// Re-declaring virtual and pure-virtual interface defined in DPBusPsuBase for clarity... |
|
3870 |
||
3871 |
IMPORT_C virtual TInt DoCreate(); |
|
3872 |
||
3873 |
/** |
|
3874 |
* Controls the power supply. |
|
3875 |
* Implemented by the variant, directly controls the power to the MMC stack. |
|
3876 |
* @param aState A TPBusPsuState enumeration specifying the required state |
|
3877 |
* (EPsuOnFull, EPsuOff, EPsuOnCurLimit) |
|
3878 |
*/ |
|
3879 |
virtual void DoSetState(TPBusPsuState aState)=0; |
|
3880 |
||
3881 |
/** |
|
3882 |
* Checks the PSU's voltage. |
|
3883 |
* Implemented by the variant, uses a mechanism such as a comparator to check |
|
3884 |
* the PSU's voltage level. Upon reciept of the voltage level (the process may |
|
3885 |
* be asynchronous), the variant calls ReceiveVoltageCheckResult() with KErrNone |
|
3886 |
* if the voltage is OK, KErrGeneral if there is a problem, or KErrNotReady if the |
|
3887 |
* hardware has not yet powered up. |
|
3888 |
*/ |
|
3889 |
virtual void DoCheckVoltage()=0; |
|
3890 |
||
3891 |
/** |
|
3892 |
* Fills in the supplied TPBusPsuInfo object with the characteristics of the platform. |
|
3893 |
* Provided at the variant layer. |
|
3894 |
* @param anInfo A reference to a TPBusPsuInfo to be filled in with the PSU characteristics. |
|
3895 |
*/ |
|
3896 |
virtual void PsuInfo(TPBusPsuInfo &anInfo)=0; |
|
3897 |
||
3898 |
inline void SetVoltage(TUint32 aVoltage); |
|
3899 |
||
3900 |
static void SleepCheck(TAny* aPtr); |
|
3901 |
||
3902 |
protected: |
|
3903 |
/** |
|
3904 |
* The current voltage setting, in OCR register format |
|
3905 |
*/ |
|
3906 |
TUint32 iVoltageSetting; |
|
3907 |
}; |
|
3908 |
||
3909 |
class DMMCMediaChange : public DMediaChangeBase |
|
3910 |
/** |
|
3911 |
DMediaChangeBase derived abstract class to handle the isertion and removal of removable media. |
|
3912 |
||
3913 |
This class is intended for derivation at the variant layer, which handles the variant specific |
|
3914 |
functionality such as interrupt detection, and calls functions of the DMediaChangeBase class |
|
3915 |
to pass notifications of media change to the socket layers. |
|
3916 |
||
3917 |
@publishedPartner |
|
3918 |
@released |
|
3919 |
*/ |
|
3920 |
{ |
|
3921 |
public: |
|
3922 |
IMPORT_C DMMCMediaChange(TInt aMediaChangeNum); |
|
3923 |
||
3924 |
// Re-declaring virtual and pure-virtual interface defined in DMediaChangeBase for clarity... |
|
3925 |
||
3926 |
IMPORT_C virtual TInt Create(); |
|
3927 |
||
3928 |
/** |
|
3929 |
* Forces a media change, executing the same actions as if a door open has occurred. |
|
3930 |
* @see DoDoorOpen |
|
3931 |
*/ |
|
3932 |
virtual void ForceMediaChange()=0; |
|
3933 |
||
3934 |
/** |
|
3935 |
* Called by DMediaChangeBase when the door is opened. |
|
3936 |
* Implemented at the variant layer, DoDoorOpen is invoked in response to the variant |
|
3937 |
* calling ::DoDoorOpenService upon detection of a door open event. |
|
3938 |
* DoDoorOpen may queue a debounce timer which masks further events until it expires. |
|
3939 |
* @see DoDoorClosed |
|
3940 |
*/ |
|
3941 |
virtual void DoDoorOpen()=0; |
|
3942 |
||
3943 |
/** |
|
3944 |
* Called by DMediaChangeBase when the door is closed. |
|
3945 |
* Implemented at the variant layer, DoDoorClosed is invoked in response to the variant |
|
3946 |
* calling ::DoorOpenService upon detection of a door closed event. |
|
3947 |
* Systems without a door should perform this sequence when the debounce timer has |
|
3948 |
* expired after a door open event has been detected. |
|
3949 |
* @see DoDoorOpen |
|
3950 |
*/ |
|
3951 |
virtual void DoDoorClosed()=0; |
|
3952 |
||
3953 |
/** |
|
3954 |
* Returns the current state of the door. |
|
3955 |
* Implemented at the variant layer to provide information as to the state of the door. |
|
3956 |
* @return TMediaState enumeration descibing the state of door (EDoorOpen, EDoorClosed). |
|
3957 |
*/ |
|
3958 |
virtual TMediaState MediaState() = 0; |
|
3959 |
}; |
|
3960 |
||
3961 |
||
3962 |
/*===========================================================================*/ |
|
3963 |
/* CLASS : DMMCEmbeddedMediaChange */ |
|
3964 |
/*===========================================================================*/ |
|
3965 |
NONSHARABLE_CLASS(DMMCEmbeddedMediaChange) : public DMMCMediaChange |
|
3966 |
/** |
|
3967 |
* This class looks after the processing to be carried out when the media door |
|
3968 |
* is opened or closed. It may be queried without the interrupt being enabled. |
|
3969 |
* |
|
3970 |
*/ |
|
3971 |
{ |
|
3972 |
public: |
|
3973 |
DMMCEmbeddedMediaChange(TInt aMediaChangeNum) : DMMCMediaChange(aMediaChangeNum){}; |
|
3974 |
||
3975 |
/// Directly calls the media change event |
|
3976 |
virtual void ForceMediaChange() {return;}; |
|
3977 |
||
3978 |
/// Handle media door open (called on media door open interrupt). |
|
3979 |
virtual void DoDoorOpen() {return;}; |
|
3980 |
||
3981 |
/// Handle media door closing (called on media door open interrupt). |
|
3982 |
virtual void DoDoorClosed() {return;}; |
|
3983 |
||
3984 |
/// Return status of media changed signal. |
|
3985 |
virtual TMediaState MediaState() {return EDoorClosed;}; |
|
3986 |
}; |
|
3987 |
||
3988 |
||
3989 |
||
3990 |
class TMapping |
|
3991 |
/** |
|
3992 |
MMC Mapping |
|
3993 |
*/ |
|
3994 |
{ |
|
3995 |
public: |
|
3996 |
TBuf8<KMMCCIDLength> iCID; |
|
3997 |
TMediaPassword iPWD; |
|
3998 |
enum TState {EStPending, EStValid, EStInvalid}; |
|
3999 |
TState iState; |
|
4000 |
}; |
|
4001 |
||
4002 |
NONSHARABLE_CLASS(TMMCPasswordStore) : public TPasswordStore |
|
4003 |
/** |
|
4004 |
MMC Password Store |
|
4005 |
*/ |
|
4006 |
{ |
|
4007 |
public: |
|
4008 |
TMMCPasswordStore(); |
|
4009 |
||
4010 |
// Pure virtual... |
|
4011 |
TInt Init(); |
|
4012 |
TInt ReadPasswordData(TDes8 &aBuf); |
|
4013 |
TInt WritePasswordData(TDesC8 &aBuf); |
|
4014 |
TInt PasswordStoreLengthInBytes(); |
|
4015 |
||
4016 |
public: |
|
4017 |
TMapping *FindMappingInStore(const TCID &aCID); |
|
4018 |
TInt InsertMapping(const TCID &aCID, const TMediaPassword &aPWD, TMapping::TState aState); |
|
4019 |
IMPORT_C TBool IsMappingIncorrect(const TCID& aCID, const TMediaPassword& aPWD); |
|
4020 |
||
4021 |
static TInt CompareCID(const TMapping& aLeft, const TMapping& aRight); |
|
4022 |
TIdentityRelation<TMapping> iIdentityRelation; |
|
4023 |
||
4024 |
private: |
|
4025 |
RArray<TMapping> *iStore; |
|
4026 |
||
4027 |
friend class DMMCSocket; |
|
4028 |
}; |
|
4029 |
||
4030 |
class DMMCSocket : public DPBusSocket |
|
4031 |
/** |
|
4032 |
This DPBusSocket derived object oversees the power supplies |
|
4033 |
and media change functionality of DMMCStack Objects. A socket |
|
4034 |
directly corresponds to a single stack, which may support multiple cards. |
|
4035 |
||
4036 |
@publishedPartner |
|
4037 |
@released |
|
4038 |
*/ |
|
4039 |
{ |
|
4040 |
public: |
|
4041 |
IMPORT_C DMMCSocket(TInt aSocketNumber, TMMCPasswordStore* aPasswordStore); |
|
4042 |
||
4043 |
// Functions inherited from DPBusSocket |
|
4044 |
virtual TInt Init(); |
|
4045 |
virtual void InitiatePowerUpSequence(); |
|
4046 |
virtual TBool CardIsPresent(); |
|
4047 |
virtual void Reset1(); |
|
4048 |
virtual void Reset2(); |
|
4049 |
||
4050 |
TInt TotalSupportedCards(); |
|
4051 |
||
4052 |
// MMC specific functions |
|
4053 |
inline DMMCStack* Stack(TInt aBus); |
|
4054 |
inline void ResetInactivity(TInt aBus); |
|
4055 |
inline const TMMCMachineInfo& MachineInfo() const; |
|
4056 |
||
4057 |
virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const; |
|
4058 |
virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen); |
|
4059 |
virtual TInt PrepareStore(TInt aBus, TInt aFunc, TLocalDrivePasswordData &aData); |
|
4060 |
||
4061 |
inline TBool SupportsDoubleBuffering(); |
|
4062 |
inline TUint32 MaxDataTransferLength(); |
|
4063 |
inline TUint32 DmaAlignment(); |
|
4064 |
||
4065 |
protected: |
|
4066 |
// MMC specific functions |
|
4067 |
virtual void GetMachineInfo(); |
|
4068 |
||
4069 |
private: |
|
4070 |
// Password Store Control Functions |
|
4071 |
TInt PasswordControlStart(const TCID &aCID, const TMediaPassword *aPWD); |
|
4072 |
void PasswordControlEnd(DMMCSession *aSessP, TInt aResult); |
|
4073 |
TBool RefreshStore(); |
|
4074 |
||
4075 |
protected: |
|
4076 |
TMMCMachineInfo iMachineInfo; |
|
4077 |
TMMCPasswordStore* iPasswordStore; |
|
4078 |
||
4079 |
public: |
|
4080 |
DMMCStack* iStack; |
|
4081 |
DMMCPsu* iVccCore; |
|
4082 |
||
4083 |
private: |
|
4084 |
TUint32 iReserved[4]; |
|
4085 |
||
4086 |
public: |
|
4087 |
enum TMMCPanic |
|
4088 |
{ |
|
4089 |
EMMCMachineStack =0, |
|
4090 |
EMMCMachineState =1, |
|
4091 |
EMMCSessRingNoSession =2, |
|
4092 |
EMMCStackSessionEngaged =3, |
|
4093 |
EMMCInitStackBlocked =4, |
|
4094 |
EMMCNoFreeRCA =5, |
|
4095 |
EMMCCommandStack =6, |
|
4096 |
EMMCRWSessionID =7, |
|
4097 |
EMMCEraseSessionID =8, |
|
4098 |
EMMCIOSessionID =9, |
|
4099 |
EMMCSessionNoPswdCard =10, |
|
4100 |
EMMCSessionPswdCmd =11, |
|
4101 |
EMMCSessionBadSessionID =12, |
|
4102 |
EMMCSetBusWidthNotImplemented =13, |
|
4103 |
EMMCInvalidNumberOfCardSlots =14, |
|
4104 |
EMMCBadBusWidth =15, |
|
4105 |
EMMCInvalidDBCommand =16, |
|
4106 |
EMMCInvalidDBBlockLength =17, |
|
4107 |
EMMCUnblockingInWrongContext =18, |
|
4108 |
EMMCInvalidCardNumber =19, |
|
4109 |
EMMCNotInDfcContext =20, |
|
4110 |
}; |
|
4111 |
IMPORT_C static void Panic(TMMCPanic aPanic); |
|
4112 |
friend class DMMCStack; |
|
4113 |
friend class DMMCSession; |
|
4114 |
friend class DMMCMediaChange; |
|
4115 |
}; |
|
4116 |
||
4117 |
const TUint32 KMMCEraseClassCmdsSupported= KBit0; |
|
4118 |
const TUint32 KMMCEraseGroupCmdsSupported= KBit1; |
|
4119 |
NONSHARABLE_CLASS(TMMCEraseInfo) |
|
4120 |
{ |
|
4121 |
public: |
|
4122 |
inline TBool EraseClassCmdsSupported() const; |
|
4123 |
inline TBool EraseGroupCmdsSupported() const; |
|
4124 |
public: |
|
4125 |
TUint32 iEraseFlags; |
|
4126 |
TUint32 iPreferredEraseUnitSize; |
|
4127 |
TUint32 iMinEraseSectorSize; |
|
4128 |
}; |
|
4129 |
||
4130 |
#include <drivers/mmc.inl> |
|
4131 |
||
4132 |
#endif // __MMC_H__ |
|
4133 |