1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/mmc.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,4129 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Generic MMC controller types and standard classes for MMC manipulation
1.18 +// This controller follows MMC spec V2.1
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file
1.24 + @internalComponent
1.25 +*/
1.26 +
1.27 +#if !defined(__MMC_H__)
1.28 +#define __MMC_H__
1.29 +
1.30 +#include <drivers/pbus.h>
1.31 +#include <d32locd.h>
1.32 +
1.33 +// MMC Card maximum system settings
1.34 +
1.35 +const TInt KMaxMmcSockets = KMaxPBusSockets;
1.36 +
1.37 +// Forward type declarations
1.38 +
1.39 +class TMMC;
1.40 +class TCID;
1.41 +class TCSD;
1.42 +class TExtendedCSD;
1.43 +class TRCA;
1.44 +class TDSR;
1.45 +class TMMCStatus;
1.46 +class TMMCArgument;
1.47 +class TMMCard;
1.48 +class TMMCCommandDesc;
1.49 +class TMMCBusConfig;
1.50 +class TMMCStackConfig;
1.51 +class TMMCRCAPool;
1.52 +class TMMCSessRing;
1.53 +class TMMCStateMachine;
1.54 +class DMMCSocket;
1.55 +class DMMCSession;
1.56 +class DMMCStack;
1.57 +class TMMCMachineInfo;
1.58 +class TMapping;
1.59 +class TMMCPasswordStore;
1.60 +class TMMCEraseInfo;
1.61 +class TMMCMachineInfoV4;
1.62 +typedef TPckg<TMMCMachineInfoV4> TMMCMachineInfoV4Pckg;
1.63 +
1.64 +enum TMMCAppCommand {EMMCNormalCmd,EMMCApplicationCmd};
1.65 +
1.66 +// Typedefs
1.67 +
1.68 +/**
1.69 +@publishedPartner
1.70 +@released
1.71 +
1.72 +Represents the MultiMediaCard error code bit set.
1.73 +
1.74 +MultiMediaCard error codes are defined as bit masks, mainly for use with
1.75 +the state machine where the error trap mask may be used.
1.76 +The function DMMCSession::EpocErrorCode() converts these error bit values
1.77 +into standard Symbian OS error values.
1.78 +
1.79 +@see KMMCErrNone
1.80 +@see KMMCErrResponseTimeOut
1.81 +@see KMMCErrDataTimeOut
1.82 +@see KMMCErrBusyTimeOut
1.83 +@see KMMCErrBusTimeOut
1.84 +@see KMMCErrTooManyCards
1.85 +@see KMMCErrResponseCRC
1.86 +@see KMMCErrDataCRC
1.87 +@see KMMCErrCommandCRC
1.88 +@see KMMCErrStatus
1.89 +@see KMMCErrNoCard
1.90 +@see KMMCErrBrokenLock
1.91 +@see KMMCErrPowerDown
1.92 +@see KMMCErrAbort
1.93 +@see KMMCErrStackNotReady
1.94 +@see KMMCErrNotSupported
1.95 +@see KMMCErrHardware
1.96 +@see KMMCErrBusInconsistent
1.97 +@see KMMCErrBypass
1.98 +@see KMMCErrInitContext
1.99 +@see KMMCErrArgument
1.100 +@see KMMCErrSingleBlock
1.101 +@see KMMCErrLocked
1.102 +@see KMMCErrNotFound
1.103 +@see KMMCErrAlreadyExists
1.104 +@see KMMCErrGeneral
1.105 +@see KMMCErrAll
1.106 +@see KMMCErrBasic
1.107 +*/
1.108 +typedef TUint32 TMMCErr;
1.109 +
1.110 +// MMC Enums and inline functions
1.111 +
1.112 +
1.113 +
1.114 +
1.115 +/**
1.116 +@publishedPartner
1.117 +@released
1.118 +
1.119 +Defines a set of symbols corresponding to the MultiMediaCard bus commands.
1.120 +
1.121 +A command is one of the parameter values inserted into a TMMCCommandDesc object.
1.122 +The commands themselves are defined by the MultiMediaCard specification.
1.123 +
1.124 +@see TMMCCommandDesc
1.125 +*/
1.126 +enum TMMCCommandEnum
1.127 + {
1.128 + /**
1.129 + CMD0; reset all cards to idle state.
1.130 + */
1.131 + ECmdGoIdleState =0,
1.132 +
1.133 +
1.134 + /**
1.135 + CMD1; all cards in the idle state send their operating conditions.
1.136 + */
1.137 + ECmdSendOpCond =1,
1.138 +
1.139 +
1.140 + /**
1.141 + CMD2; all cards send their CID number.
1.142 + */
1.143 + ECmdAllSendCID =2,
1.144 +
1.145 +
1.146 + /**
1.147 + CMD3; assign relative address to a card.
1.148 + */
1.149 + ECmdSetRelativeAddr =3,
1.150 +
1.151 +
1.152 + /**
1.153 + CMD4; program the DSR register of all cards.
1.154 + */
1.155 + ECmdSetDSR =4,
1.156 +
1.157 +
1.158 + /**
1.159 + CMD5; toggle device between Sleep and Awake states.
1.160 + */
1.161 + ECmd5 =5,
1.162 + ECmdSleepAwake =5,
1.163 +
1.164 +
1.165 + /**
1.166 + CMD6; Switch
1.167 + */
1.168 + ECmd6 =6,
1.169 + ECmdSwitch =6,
1.170 +
1.171 +
1.172 + /**
1.173 + CMD7; toggle a card between standby and transfer state, or between
1.174 + programming and disconnected state.
1.175 +
1.176 + The card is selected by its RCA and deselected by any other address.
1.177 + */
1.178 + ECmdSelectCard =7,
1.179 +
1.180 +
1.181 + /**
1.182 + CMD8; addressed card sends its extended CSD.
1.183 + */
1.184 + ECmd8 =8,
1.185 + ECmdSendExtendedCSD =8,
1.186 +
1.187 +
1.188 + /**
1.189 + CMD9; addressed card sends its CSD.
1.190 + */
1.191 + ECmdSendCSD =9,
1.192 +
1.193 +
1.194 + /**
1.195 + CMD10; addressed card sends its CID.
1.196 + */
1.197 + ECmdSendCID =10,
1.198 +
1.199 +
1.200 + /**
1.201 + CMD11; read data stream from the card starting at the given address until
1.202 + an ECmdStopTransmission follows.
1.203 +
1.204 + @see ECmdStopTransmission
1.205 + */
1.206 + ECmdReadDatUntilStop =11,
1.207 +
1.208 +
1.209 + /**
1.210 + CMD12; force the card to stop transmission.
1.211 + */
1.212 + ECmdStopTransmission =12,
1.213 +
1.214 +
1.215 + /**
1.216 + CMD13; addressed card sends its status register.
1.217 + */
1.218 + ECmdSendStatus =13,
1.219 +
1.220 +
1.221 + /**
1.222 + CMD14; BUSTEST_R - Reads the reversed bus testing data pattern from the card.
1.223 +
1.224 + @see ECmdBustest_W
1.225 + */
1.226 + ECmd14 =14,
1.227 + ECmdBustest_R =14,
1.228 +
1.229 +
1.230 + /**
1.231 + CMD15; set the card to the inactive state.
1.232 + */
1.233 + ECmdGoInactiveState =15,
1.234 +
1.235 +
1.236 + /**
1.237 + CMD16; set the block length for all following block commands.
1.238 + */
1.239 + ECmdSetBlockLen =16,
1.240 +
1.241 +
1.242 + /**
1.243 + CMD17; read a single data block from the card.
1.244 + */
1.245 + ECmdReadSingleBlock =17,
1.246 +
1.247 +
1.248 + /**
1.249 + CMD18; continuously transfer data blocks from the card until interrupted
1.250 + by ECmdStopTransmission.
1.251 +
1.252 + @see ECmdStopTransmission
1.253 + */
1.254 + ECmdReadMultipleBlock =18,
1.255 +
1.256 +
1.257 + /**
1.258 + CMD19; BUSTEST_W - Sends a test data pattern to the card to determine the bus characteristics
1.259 +
1.260 + @see ECmdBustest_R
1.261 + */
1.262 + ECmd19 =19,
1.263 + ECmdBustest_W =19,
1.264 +
1.265 +
1.266 + /**
1.267 + CMD20; write data stream from the host starting at the given address
1.268 + until interrupted by ECmdStopTransmission.
1.269 +
1.270 + @see ECmdStopTransmission
1.271 + */
1.272 + ECmdWriteDatUntilStop =20,
1.273 +
1.274 +
1.275 + /**
1.276 + CMD21; reserved for future use.
1.277 + */
1.278 + ECmd21 =21,
1.279 +
1.280 +
1.281 + /**
1.282 + CMD22; reserved for future use.
1.283 + */
1.284 + ECmd22 =22,
1.285 +
1.286 +
1.287 + /**
1.288 + CMD23; define the number of blocks to be transferred in the following
1.289 + multiple block read or write command.
1.290 + */
1.291 + ECmdSetBlockCount =23,
1.292 +
1.293 +
1.294 + /**
1.295 + CMD24; write a single block to the card.
1.296 + */
1.297 + ECmdWriteBlock =24,
1.298 +
1.299 +
1.300 + /**
1.301 + CMD25; continuously transfer data blocks to the card until interrupted
1.302 + by ECmdStopTransmission.
1.303 +
1.304 + @see ECmdStopTransmission
1.305 + */
1.306 + ECmdWriteMultipleBlock =25,
1.307 +
1.308 +
1.309 + /**
1.310 + CMD26; programming of the CID.
1.311 +
1.312 + This is issued once per card, and is normally reserved for
1.313 + the manufacturer.
1.314 + */
1.315 + ECmdProgramCID =26,
1.316 +
1.317 +
1.318 + /**
1.319 + CMD27; programming of the programmable bits of the CSD.
1.320 + */
1.321 + ECmdProgramCSD =27,
1.322 +
1.323 +
1.324 + /**
1.325 + CMD28; set the write protect bit of the addressed group, if the card has
1.326 + write protection features.
1.327 + */
1.328 + ECmdSetWriteProt =28,
1.329 +
1.330 +
1.331 + /**
1.332 + CMD29; clear the write protect bit of the addressed group, if the card has
1.333 + write protection features.
1.334 + */
1.335 + ECmdClearWriteProt =29,
1.336 +
1.337 +
1.338 + /**
1.339 + CMD30; ask the card to send the status of the write protect bit, if
1.340 + the card has write protection features.
1.341 + */
1.342 + ECmdSendWriteProt =30,
1.343 +
1.344 +
1.345 + /**
1.346 + CMD31; reserved for future use.
1.347 + */
1.348 + ECmd31 =31,
1.349 +
1.350 +
1.351 + /**
1.352 + CMD32; set the address of the first sector of the erase group.
1.353 + */
1.354 + ECmdTagSectorStart =32,
1.355 +
1.356 +
1.357 + /**
1.358 + CMD33; set the address of the last sector in a continuous range within
1.359 + the selected erase group, or the address of a single sector to be
1.360 + selected for erase.
1.361 + */
1.362 + ECmdTagSectorEnd =33,
1.363 +
1.364 +
1.365 + /**
1.366 + CMD34; remove one previously selected sector from the erase selection.
1.367 + */
1.368 + ECmdUntagSector =34,
1.369 +
1.370 +
1.371 + /**
1.372 + CMD35; set the the address of the first erase group within a continuous
1.373 + range to be selected for erase.
1.374 + */
1.375 + ECmdTagEraseGroupStart =35,
1.376 +
1.377 +
1.378 + /**
1.379 + CMD36; set the address of the last erase group within a continuous range
1.380 + to be selected for erase.
1.381 + */
1.382 + ECmdTagEraseGroupEnd =36,
1.383 +
1.384 +
1.385 + /**
1.386 + CMD37; removes one previously selected erase group from the erase selection.
1.387 + */
1.388 + ECmdUntagEraseGroup =37,
1.389 +
1.390 +
1.391 + /**
1.392 + CMD38; erase all previously selected sectors.
1.393 + */
1.394 + ECmdErase =38,
1.395 +
1.396 +
1.397 + /**
1.398 + CMD39; read and write 8 bit (register) data fields.
1.399 + */
1.400 + ECmdFastIO =39,
1.401 +
1.402 +
1.403 + /**
1.404 + CMD40; set the system into interrupt mode.
1.405 + */
1.406 + ECmdGoIRQState =40,
1.407 +
1.408 +
1.409 + /**
1.410 + CMD41; reserved for future use.
1.411 + */
1.412 + ECmd41 =41,
1.413 +
1.414 +
1.415 + /**
1.416 + CMD42; set/reset the password or lock/unlock the card.
1.417 + */
1.418 + ECmdLockUnlock =42,
1.419 +
1.420 +
1.421 + /**
1.422 + CMD43; reserved for future use.
1.423 + */
1.424 + ECmd43 =43,
1.425 +
1.426 +
1.427 + /**
1.428 + CMD44; reserved for future use.
1.429 + */
1.430 + ECmd44 =44,
1.431 +
1.432 +
1.433 + /**
1.434 + CMD45; reserved for future use.
1.435 + */
1.436 + ECmd45 =45,
1.437 +
1.438 +
1.439 + /**
1.440 + CMD46; reserved for future use.
1.441 + */
1.442 + ECmd46 =46,
1.443 +
1.444 +
1.445 + /**
1.446 + CMD47; reserved for future use.
1.447 + */
1.448 + ECmd47 =47,
1.449 +
1.450 +
1.451 + /**
1.452 + CMD48; reserved for future use.
1.453 + */
1.454 + ECmd48 =48,
1.455 +
1.456 +
1.457 + /**
1.458 + CMD49; reserved for future use.
1.459 + */
1.460 + ECmd49 =49,
1.461 +
1.462 +
1.463 + /**
1.464 + CMD50; reserved for future use.
1.465 + */
1.466 + ECmd50 =50,
1.467 +
1.468 +
1.469 + /**
1.470 + CMD51; reserved for future use.
1.471 + */
1.472 + ECmd51 =51,
1.473 +
1.474 +
1.475 + /**
1.476 + CMD52; reserved for future use.
1.477 + */
1.478 + ECmd52 =52,
1.479 +
1.480 +
1.481 + /**
1.482 + CMD53; reserved for future use.
1.483 + */
1.484 + ECmd53 =53,
1.485 +
1.486 +
1.487 + /**
1.488 + CMD54; reserved for future use.
1.489 + */
1.490 + ECmd54 =54,
1.491 +
1.492 +
1.493 + /**
1.494 + CMD55; indicate to the card that the next command is an application
1.495 + specific command rather than a standard command.
1.496 + */
1.497 + ECmdAppCmd =55,
1.498 +
1.499 +
1.500 + /**
1.501 + CMD56; transfer a data block to the card, or get a data block from the card,
1.502 + for general purpose/application specific commands.
1.503 + */
1.504 + ECmdGenCmd =56,
1.505 +
1.506 +
1.507 + /**
1.508 + CMD57; reserved for future use.
1.509 + */
1.510 + ECmd57 =57,
1.511 +
1.512 +
1.513 + /**
1.514 + CMD58; reserved for future use.
1.515 + */
1.516 + ECmd58 =58,
1.517 +
1.518 +
1.519 + /**
1.520 + CMD59; reserved for future use.
1.521 + */
1.522 + ECmd59 =59,
1.523 +
1.524 +
1.525 + /**
1.526 + CMD60; reserved for future use.
1.527 + */
1.528 + ECmd60 =60,
1.529 +
1.530 +
1.531 + /**
1.532 + CMD61; reserved for future use.
1.533 + */
1.534 + ECmd61 =61,
1.535 +
1.536 +
1.537 + /**
1.538 + CMD62; reserved for future use.
1.539 + */
1.540 + ECmd62 =62,
1.541 +
1.542 +
1.543 + /**
1.544 + CMD63; reserved for future use.
1.545 + */
1.546 + ECmd63 =63
1.547 + };
1.548 +
1.549 +enum TMMCCommandTypeEnum
1.550 + {
1.551 + ECmdTypeUK, // UnKnown command type
1.552 + ECmdTypeBC, // Broadcast Command
1.553 + ECmdTypeBCR, // Broadcast Command with Response
1.554 + ECmdTypeAC, // Addressed Command
1.555 + ECmdTypeACS, // Addressed Command to a Selected card
1.556 + ECmdTypeADTCS, // Addressed Data Transfer Command to a Selected card
1.557 + ECmdTypeADC // Addressed Direct Command to a Selected card
1.558 + };
1.559 +
1.560 +enum TMMCResponseTypeEnum
1.561 + {
1.562 + ERespTypeNone,
1.563 + ERespTypeUnknown,
1.564 + ERespTypeR1, // 32 bits Status
1.565 + ERespTypeR1B, // 32 bits Status with possible busy signal
1.566 + ERespTypeR2, // 128 bits CID or CSD register
1.567 + ERespTypeR3, // 32 bits OCR register
1.568 + ERespTypeR4, // 32 bits Fast I/O
1.569 + ERespTypeR5, // 32 bits IRQ
1.570 + ERespTypeR6,
1.571 + ERespTypeR7 // not currently defined for MMC
1.572 + };
1.573 +
1.574 +
1.575 +/**
1.576 +@publishedPartner
1.577 +@released
1.578 +
1.579 +Defines the set of media types for a MultiMediaCard.
1.580 +*/
1.581 +enum TMMCMediaTypeEnum
1.582 + {
1.583 + /**
1.584 + A read only card.
1.585 + */
1.586 + EMultiMediaROM,
1.587 +
1.588 +
1.589 + /**
1.590 + A writable card.
1.591 + */
1.592 + EMultiMediaFlash,
1.593 +
1.594 +
1.595 + /**
1.596 + An I/O card.
1.597 + */
1.598 + EMultiMediaIO,
1.599 +
1.600 +
1.601 + /**
1.602 + A card type that is neither read only, writable nor I/O.
1.603 + */
1.604 + EMultiMediaOther,
1.605 +
1.606 +
1.607 + /**
1.608 + A card type that is not supported.
1.609 + */
1.610 + EMultiMediaNotSupported
1.611 + };
1.612 +
1.613 +enum TMMCSessionTypeEnum
1.614 + {
1.615 + ECIMNakedSession =0,
1.616 + ECIMUpdateAcq =1,
1.617 + ECIMInitStack =2,
1.618 + ECIMCheckStack =3,
1.619 + ECIMSetupCard =4,
1.620 + ECIMReadBlock =5,
1.621 + ECIMWriteBlock =6,
1.622 + ECIMReadMBlock =7,
1.623 + ECIMWriteMBlock =8,
1.624 + ECIMEraseSector =9,
1.625 + ECIMEraseGroup =10,
1.626 + ECIMReadIO =11,
1.627 + ECIMWriteIO =12,
1.628 + ECIMLockUnlock =13,
1.629 + ECIMLockStack =14,
1.630 + ECIMInitStackAfterUnlock =15,
1.631 + ECIMAutoUnlock =16,
1.632 + ECIMSleep =17
1.633 + };
1.634 +
1.635 +const TUint KMMCMaxSessionTypeNumber = 18;
1.636 +const TUint KMMCMinCustomSession = 1024;
1.637 +
1.638 +const TUint KMMCCmdDirDirBitPosition= KBit0; //fixed - dont change it
1.639 +const TUint KMMCCmdDirIndBitPosition= (KBit5-KBit0); //fixed - dont change it
1.640 +const TUint KMMCCmdDirWBitArgument= KBit5;
1.641 +const TUint KMMCCmdDirNegate= KBit6;
1.642 +const TUint KMMCCmdDirWBitDirect= KBit7;
1.643 +
1.644 +const TUint KMMCCmdReliableWrite = KBit31;
1.645 +
1.646 +
1.647 +/**
1.648 +@publishedPartner
1.649 +@released
1.650 +
1.651 +An enum whose values specify the data transfer direction.
1.652 +
1.653 +@see TMMCCommandSpec
1.654 +*/
1.655 +enum TMMCCmdDirEnum
1.656 + {
1.657 + EDirNone = 0,
1.658 + EDirRead = KMMCCmdDirWBitDirect,
1.659 + EDirWrite = KMMCCmdDirWBitDirect|KMMCCmdDirDirBitPosition,
1.660 + EDirWBit0 = KMMCCmdDirWBitArgument + 0,
1.661 + EDirRBit0 = (KMMCCmdDirWBitArgument|KMMCCmdDirNegate) + 0
1.662 + };
1.663 +
1.664 +
1.665 +
1.666 +
1.667 +/**
1.668 +@publishedPartner
1.669 +@released
1.670 +
1.671 +An enum whose values specify the width of the data bus
1.672 +
1.673 +This enum is used by the DMMCStack::SetBusWidth() and TMMCMachineInfo.iMaxBusWidth.
1.674 +*/
1.675 +enum TBusWidth
1.676 + {
1.677 + EBusWidth1 = 0x00,
1.678 + EBusWidth4 = 0x02,
1.679 + EBusWidth8 = 0x03,
1.680 + EBusWidthInvalid = KMaxTUint32
1.681 + };
1.682 +
1.683 +/**
1.684 +@publishedPartner
1.685 +@released
1.686 +*/
1.687 +const TUint8 KMMCLockUnlockErase = KBit3; // In first byte of CMD42 data block
1.688 +
1.689 +/**
1.690 +@publishedPartner
1.691 +@released
1.692 +*/
1.693 +const TUint8 KMMCLockUnlockLockUnlock = KBit2;
1.694 +
1.695 +/**
1.696 +@publishedPartner
1.697 +@released
1.698 +*/
1.699 +const TUint8 KMMCLockUnlockClrPwd = KBit1;
1.700 +
1.701 +/**
1.702 +@publishedPartner
1.703 +@released
1.704 +*/
1.705 +const TUint8 KMMCLockUnlockSetPwd = KBit0;
1.706 +
1.707 +
1.708 +
1.709 +
1.710 +/**
1.711 +@publishedPartner
1.712 +@released
1.713 +
1.714 +A utility class that contains convenience functions to handle conversion
1.715 +to and from big-endian format.
1.716 +*/
1.717 +class TMMC
1.718 + {
1.719 +public:
1.720 + static inline TUint32 BigEndian32(const TUint8*);
1.721 + static inline void BigEndian4Bytes(TUint8* aPtr, TUint32 aVal);
1.722 + };
1.723 +
1.724 +
1.725 +// Generic MMC layer constants
1.726 +
1.727 +const TInt KMaxMMCStacks=1; // Number of separate MMC buses
1.728 +const TUint KMaxMMCardsPerStack=4; // Limits the number of cards in each stack
1.729 +
1.730 +const TUint KBroadcastToAllCards=0xFFFFFFFF;
1.731 +
1.732 +// MMC Spec related constants
1.733 +
1.734 +const TUint KMMCMaxResponseLength=16; // in bytes
1.735 +const TUint KMMCCIDLength=16;
1.736 +const TUint KMMCCSDLength=16;
1.737 +const TUint KMMCExtendedCSDLength=512;
1.738 +const TUint KMMCBusClockFOD=400; // Identification clock in kiloherz
1.739 +const TUint KMMCCommandMask = 63; // Size of TMMCCommandEnum enumerator
1.740 +
1.741 +// Command Classes Bit Set
1.742 +
1.743 +/**
1.744 +@publishedPartner
1.745 +@released
1.746 +*/
1.747 +const TUint32 KMMCCmdClassNone= 0;
1.748 +
1.749 +/**
1.750 +@publishedPartner
1.751 +@released
1.752 +*/
1.753 +const TUint32 KMMCCmdClassBasic= KBit0;
1.754 +
1.755 +/**
1.756 +@publishedPartner
1.757 +@released
1.758 +*/
1.759 +const TUint32 KMMCCmdClassStreamRead= KBit1;
1.760 +
1.761 +/**
1.762 +@publishedPartner
1.763 +@released
1.764 +*/
1.765 +const TUint32 KMMCCmdClassBlockRead= KBit2;
1.766 +
1.767 +/**
1.768 +@publishedPartner
1.769 +@released
1.770 +*/
1.771 +const TUint32 KMMCCmdClassStreamWrite= KBit3;
1.772 +
1.773 +/**
1.774 +@publishedPartner
1.775 +@released
1.776 +*/
1.777 +const TUint32 KMMCCmdClassBlockWrite= KBit4;
1.778 +
1.779 +/**
1.780 +@publishedPartner
1.781 +@released
1.782 +*/
1.783 +const TUint32 KMMCCmdClassErase= KBit5;
1.784 +
1.785 +/**
1.786 +@publishedPartner
1.787 +@released
1.788 +*/
1.789 +const TUint32 KMMCCmdClassWriteProtection=KBit6;
1.790 +
1.791 +/**
1.792 +@publishedPartner
1.793 +@released
1.794 +*/
1.795 +const TUint32 KMMCCmdClassLockCard= KBit7;
1.796 +
1.797 +/**
1.798 +@publishedPartner
1.799 +@released
1.800 +*/
1.801 +const TUint32 KMMCCmdClassApplication= KBit8;
1.802 +
1.803 +/**
1.804 +@publishedPartner
1.805 +@released
1.806 +*/
1.807 +const TUint32 KMMCCmdClassIOMode= KBit9;
1.808 +
1.809 +/**
1.810 +@publishedPartner
1.811 +@released
1.812 +*/
1.813 +const TUint32 KMMCCmdClassReserved10= KBit10;
1.814 +const TUint32 KMMCCmdClassSwitch= KBit10;
1.815 +
1.816 +/**
1.817 +@publishedPartner
1.818 +@released
1.819 +*/
1.820 +const TUint32 KMMCCmdClassReserved11= KBit11;
1.821 +
1.822 +// Specific MMC implementation constants
1.823 +
1.824 +const TUint KMaxMMCMachineStackDepth=20; // TMMCStateMachine stack depth
1.825 +const TUint KMaxMMCCommandStackDepth=9; // Session TMMCCommandDesc stack depth
1.826 +const TUint KMMCIdleCommandsAtRestart=2; // Number of CMD0s to be issued at initialisation
1.827 +const TUint KMMCMaxJobsInStackWorkSet=8; // Number of sessions simultaneously served
1.828 +const TUint KMMCPollGapInMilliseconds=40;
1.829 +const TUint KMMCMaxPollAttempts=5; // 40*5 = 200ms
1.830 +const TUint KMMCRetryGapInMilliseconds=10;
1.831 +const TUint KMMCMaxTimeOutRetries=1;
1.832 +const TUint KMMCMaxCRCRetries=1;
1.833 +const TUint16 KMMCMaxUnlockRetries=4;
1.834 +const TUint16 KMMCMaxAutoUnlockRetries=25;
1.835 +const TUint KMMCMaxGlobalRetries=1;
1.836 +const TUint16 KMMCSpecOpCondBusyTimeout=100 ; //MMC/SD Standard OCR timeout 1 second
1.837 +const TUint16 KMMCMaxOpCondBusyTimeout=150; // 10*150 = 1500ms
1.838 +const TUint KMMCLowVoltagePowerUpTimeoutInMilliseconds=2; // 1ms + 74 400KHz clock cycles
1.839 +const TUint KMMCUnlockRetryGapInMilliseconds = 200; // Unlock retry gap
1.840 +
1.841 +// DMMCStack Modes Bit Set
1.842 +const TUint32 KMMCModeEnableClientConfig = KBit0; // Merge with session iConfig
1.843 +const TUint32 KMMCModeEnableTimeOutRetry = KBit1; // Auto retry on response time-outs
1.844 +const TUint32 KMMCModeTimeOutRetryGap = KBit2; // Force timer delay between retries
1.845 +const TUint32 KMMCModeEnableCRCRetry = KBit3; // Command or response CRC errors
1.846 +const TUint32 KMMCModeCRCRetryGap = KBit4;
1.847 +const TUint32 KMMCModeDataCRCRetry = KBit5; // Repeat data transaction from the last valid position
1.848 +const TUint32 KMMCModeEnableUnlockRetry = KBit6; // Resend CMD42 for unreliable cards
1.849 +const TUint32 KMMCModeEnablePreemption = KBit7; // Allow sessions to share the MMC bus
1.850 +const TUint32 KMMCModePreemptOnBusy = KBit8; // Release bus control if busy
1.851 +const TUint32 KMMCModePreemptOnRetry = KBit9; // Release bus control before timeout/crc retries
1.852 +const TUint32 KMMCModePreemptInGaps = KBit10; // Preempt whenever gap timer is invoked
1.853 +const TUint32 KMMCModeEnqueIfLocked = KBit11; // Enque session if DMMCStack is locked
1.854 +const TUint32 KMMCModeCardControlled = KBit12; // Use Session CardP to get RCAs etc.
1.855 +const TUint32 KMMCModeCompleteInStackDFC = KBit13; // Run DMMCStack in DFC when completing
1.856 +const TUint32 KMMCModeEnableBusyPoll = KBit14; // Enables mechanism recovering from busy timeouts
1.857 +const TUint32 KMMCModeBusyPollGap = KBit15;
1.858 +const TUint32 KMMCModeEnableRetries = KBit16; // This mode removed disables all retries/polls
1.859 +const TUint32 KMMCModeMask = KBit17 - KBit0;
1.860 +
1.861 +// The following modes are effective for MasterConfig only
1.862 +const TUint32 KMMCModeClientPollAttempts = KBit20;
1.863 +const TUint32 KMMCModeClientTimeOutRetries = KBit21;
1.864 +const TUint32 KMMCModeClientCRCRetries = KBit22;
1.865 +const TUint32 KMMCModeClientUnlockRetries = KBit23;
1.866 +const TUint32 KMMCModeClientBusClock = KBit24;
1.867 +const TUint32 KMMCModeClientClockIn = KBit25;
1.868 +const TUint32 KMMCModeClientClockOut = KBit26;
1.869 +const TUint32 KMMCModeClientResponseTimeOut = KBit27;
1.870 +const TUint32 KMMCModeClientDataTimeOut = KBit28;
1.871 +const TUint32 KMMCModeClientBusyTimeOut = KBit29;
1.872 +const TUint32 KMMCModeClientiOpCondBusyTimeout = KBit30;
1.873 +const TUint32 KMMCModeClientMask = KBit31 - KBit20;
1.874 +
1.875 +// The following modes cannot be enabled by a client if disabled in MasterConfig
1.876 +const TUint32 KMMCModeMasterOverrides=
1.877 + KMMCModeEnableClientConfig |
1.878 + KMMCModeEnablePreemption |
1.879 + KMMCModeEnqueIfLocked |
1.880 + KMMCModeClientMask;
1.881 +
1.882 +// The following modes are always effective, even if the ClientConfig is disabled
1.883 +const TUint32 KMMCModeClientOverrides=
1.884 + KMMCModeEnableClientConfig |
1.885 + KMMCModeCardControlled;
1.886 +
1.887 +
1.888 +// The default MasterConfig modes
1.889 +const TUint32 KMMCModeDefault= KMMCModeEnableClientConfig |
1.890 + KMMCModeEnableRetries |
1.891 + KMMCModeEnableTimeOutRetry |
1.892 + KMMCModeTimeOutRetryGap |
1.893 + KMMCModeEnableCRCRetry |
1.894 + KMMCModeCRCRetryGap |
1.895 + KMMCModeDataCRCRetry |
1.896 + KMMCModeEnableUnlockRetry |
1.897 + KMMCModeEnablePreemption |
1.898 + KMMCModePreemptInGaps |
1.899 + KMMCModeEnqueIfLocked |
1.900 + KMMCModeCardControlled |
1.901 + KMMCModeClientMask;
1.902 +
1.903 +
1.904 +// MMC Error Code Bit Set
1.905 +
1.906 +/**
1.907 +@publishedPartner
1.908 +@released
1.909 +
1.910 +A MultiMediaCard error code.
1.911 +
1.912 +Indicates no error.
1.913 +
1.914 +@see TMMCErr
1.915 +*/
1.916 +const TUint32 KMMCErrNone=0;
1.917 +
1.918 +
1.919 +/**
1.920 +@publishedPartner
1.921 +@released
1.922 +
1.923 +A MultiMediaCard error code.
1.924 +
1.925 +Timed out waiting for a response from the card after issuing a command.
1.926 +
1.927 +@see TMMCErr
1.928 +*/
1.929 +const TUint32 KMMCErrResponseTimeOut=KBit0;
1.930 +
1.931 +
1.932 +/**
1.933 +@publishedPartner
1.934 +@released
1.935 +
1.936 +A MultiMediaCard error code.
1.937 +
1.938 +Timed out waiting for a data block to be received during a data read command.
1.939 +
1.940 +@see TMMCErr
1.941 +*/
1.942 +const TUint32 KMMCErrDataTimeOut= KBit1;
1.943 +
1.944 +
1.945 +/**
1.946 +@publishedPartner
1.947 +@released
1.948 +
1.949 +A MultiMediaCard error code.
1.950 +
1.951 +Timed out waiting for a data block to be requested during a data write command.
1.952 +
1.953 +@see TMMCErr
1.954 +*/
1.955 +const TUint32 KMMCErrBusyTimeOut= KBit2;
1.956 +
1.957 +
1.958 +/**
1.959 +@publishedPartner
1.960 +@released
1.961 +
1.962 +A MultiMediaCard error code.
1.963 +
1.964 +Timed out during the CIM_UPDATE_ACQ macro waiting for a card to power up.
1.965 +Cards that are still powering up return busy in response to a SEND_OP_COND command.
1.966 +
1.967 +@see TMMCErr
1.968 +*/
1.969 +const TUint32 KMMCErrBusTimeOut= KBit3;
1.970 +
1.971 +
1.972 +/**
1.973 +@publishedPartner
1.974 +@released
1.975 +
1.976 +A MultiMediaCard error code.
1.977 +
1.978 +The host has detected more cards in a stack that it can handle, or it has
1.979 +detected more cards than it was expecting, for example, more cards than physical slots.
1.980 +
1.981 +@see TMMCErr
1.982 +*/
1.983 +const TUint32 KMMCErrTooManyCards= KBit4;
1.984 +
1.985 +
1.986 +/**
1.987 +@publishedPartner
1.988 +@released
1.989 +
1.990 +A MultiMediaCard error code.
1.991 +
1.992 +The host has detected a CRC error in a response received from a card.
1.993 +
1.994 +@see TMMCErr
1.995 +*/
1.996 +const TUint32 KMMCErrResponseCRC= KBit5;
1.997 +
1.998 +
1.999 +/**
1.1000 +@publishedPartner
1.1001 +@released
1.1002 +
1.1003 +A MultiMediaCard error code.
1.1004 +
1.1005 +The host has detected a CRC error in a data block received from a card.
1.1006 +
1.1007 +@see TMMCErr
1.1008 +*/
1.1009 +const TUint32 KMMCErrDataCRC= KBit6;
1.1010 +
1.1011 +
1.1012 +/**
1.1013 +@publishedPartner
1.1014 +@released
1.1015 +
1.1016 +A MultiMediaCard error code.
1.1017 +
1.1018 +The card has detected a CRC error in a command received from the host.
1.1019 +
1.1020 +@see TMMCErr
1.1021 +*/
1.1022 +const TUint32 KMMCErrCommandCRC= KBit7;
1.1023 +
1.1024 +
1.1025 +/**
1.1026 +@publishedPartner
1.1027 +@released
1.1028 +
1.1029 +A MultiMediaCard error code.
1.1030 +
1.1031 +An R1 response was received from the card with one or more of the error flags
1.1032 +set in the card status field.
1.1033 +
1.1034 +@see TMMCErr
1.1035 +*/
1.1036 +const TUint32 KMMCErrStatus= KBit8;
1.1037 +
1.1038 +
1.1039 +/**
1.1040 +@publishedPartner
1.1041 +@released
1.1042 +
1.1043 +A MultiMediaCard error code.
1.1044 +
1.1045 +A session was submitted without first being set-up with a card object,
1.1046 +or was set-up with a card object that is no longer present.
1.1047 +
1.1048 +@see TMMCErr
1.1049 +*/
1.1050 +const TUint32 KMMCErrNoCard= KBit9;
1.1051 +
1.1052 +
1.1053 +/**
1.1054 +@publishedPartner
1.1055 +@released
1.1056 +
1.1057 +A MultiMediaCard error code.
1.1058 +
1.1059 +The session had the stack locked but the MultiMediaCard controller had
1.1060 +to override the lock to perform some other bus activity.
1.1061 +
1.1062 +@see TMMCErr
1.1063 +*/
1.1064 +const TUint32 KMMCErrBrokenLock= KBit10;
1.1065 +
1.1066 +
1.1067 +/**
1.1068 +@publishedPartner
1.1069 +@released
1.1070 +
1.1071 +A MultiMediaCard error code.
1.1072 +
1.1073 +The card was powered down.
1.1074 +
1.1075 +@see TMMCErr
1.1076 +*/
1.1077 +const TUint32 KMMCErrPowerDown= KBit11;
1.1078 +
1.1079 +
1.1080 +/**
1.1081 +@publishedPartner
1.1082 +@released
1.1083 +
1.1084 +A MultiMediaCard error code.
1.1085 +
1.1086 +The session was stopped.
1.1087 +
1.1088 +@see TMMCErr
1.1089 +*/
1.1090 +const TUint32 KMMCErrAbort= KBit12;
1.1091 +
1.1092 +
1.1093 +/**
1.1094 +@publishedPartner
1.1095 +@released
1.1096 +
1.1097 +A MultiMediaCard error code.
1.1098 +
1.1099 +The stack has not yet been initialised.
1.1100 +
1.1101 +@see TMMCErr
1.1102 +*/
1.1103 +const TUint32 KMMCErrStackNotReady= KBit13;
1.1104 +
1.1105 +
1.1106 +/**
1.1107 +@publishedPartner
1.1108 +@released
1.1109 +
1.1110 +A MultiMediaCard error code.
1.1111 +
1.1112 +The session requested a service or feature that is not supported.
1.1113 +
1.1114 +@see TMMCErr
1.1115 +*/
1.1116 +const TUint32 KMMCErrNotSupported= KBit14;
1.1117 +
1.1118 +
1.1119 +/**
1.1120 +@publishedPartner
1.1121 +@released
1.1122 +
1.1123 +A MultiMediaCard error code.
1.1124 +
1.1125 +Indicates a general hardware related error.
1.1126 +
1.1127 +@see TMMCErr
1.1128 +*/
1.1129 +const TUint32 KMMCErrHardware= KBit15;
1.1130 +
1.1131 +
1.1132 +/**
1.1133 +@publishedPartner
1.1134 +@released
1.1135 +
1.1136 +A MultiMediaCard error code.
1.1137 +
1.1138 +An unexpected or inconsistent bus state has been detected.
1.1139 +
1.1140 +@see TMMCErr
1.1141 +*/
1.1142 +const TUint32 KMMCErrBusInconsistent=KBit16;
1.1143 +
1.1144 +
1.1145 +
1.1146 +
1.1147 +// SM control error codes
1.1148 +
1.1149 +/**
1.1150 +@publishedPartner
1.1151 +@released
1.1152 +
1.1153 +A MultiMediaCard error code.
1.1154 +
1.1155 +This is used interally by the MultiMediaCard controller.
1.1156 +
1.1157 +@see TMMCErr
1.1158 +*/
1.1159 +const TUint32 KMMCErrBypass= KBit17;
1.1160 +
1.1161 +
1.1162 +/**
1.1163 +@publishedPartner
1.1164 +@released
1.1165 +
1.1166 +A MultiMediaCard error code.
1.1167 +
1.1168 +This is used internally by the MultiMediaCard controller in the process
1.1169 +of re-initialising a card to recover from an inconsistent bus state.
1.1170 +
1.1171 +@see TMMCErr
1.1172 +*/
1.1173 +const TUint32 KMMCErrInitContext= KBit18;
1.1174 +
1.1175 +
1.1176 +/**
1.1177 +@publishedPartner
1.1178 +@released
1.1179 +
1.1180 +A MultiMediaCard error code.
1.1181 +
1.1182 +Indicates a bad argument.
1.1183 +
1.1184 +@see TMMCErr
1.1185 +*/
1.1186 +const TUint32 KMMCErrArgument= KBit19;
1.1187 +
1.1188 +
1.1189 +/**
1.1190 +@publishedPartner
1.1191 +@released
1.1192 +
1.1193 +A MultiMediaCard error code.
1.1194 +
1.1195 +A multiple block operation was requested, but the length specified was
1.1196 +less than that of a block.
1.1197 +
1.1198 +@see TMMCErr
1.1199 +*/
1.1200 +const TUint32 KMMCErrSingleBlock= KBit20;
1.1201 +
1.1202 +
1.1203 +
1.1204 +/**
1.1205 +@internalComponent
1.1206 +*/
1.1207 +const TUint32 KMMCErrUpdPswd= KBit21;
1.1208 +
1.1209 +
1.1210 +
1.1211 +
1.1212 +// General error codes
1.1213 +
1.1214 +/**
1.1215 +@publishedPartner
1.1216 +@released
1.1217 +
1.1218 +A MultiMediaCard error code.
1.1219 +
1.1220 +The card is locked.
1.1221 +
1.1222 +@see TMMCErr
1.1223 +*/
1.1224 +const TUint32 KMMCErrLocked= KBit22;
1.1225 +
1.1226 +
1.1227 +/**
1.1228 +@publishedPartner
1.1229 +@released
1.1230 +
1.1231 +A MultiMediaCard error code.
1.1232 +
1.1233 +Indicates a general 'not found' type error.
1.1234 +
1.1235 +@see TMMCErr
1.1236 +*/
1.1237 +const TUint32 KMMCErrNotFound= KBit23;
1.1238 +
1.1239 +
1.1240 +/**
1.1241 +@publishedPartner
1.1242 +@released
1.1243 +
1.1244 +An MultiMediaCard error code:
1.1245 +
1.1246 +Indicates a general already 'exists type' error.
1.1247 +
1.1248 +@see TMMCErr
1.1249 +*/
1.1250 +const TUint32 KMMCErrAlreadyExists= KBit24;
1.1251 +
1.1252 +
1.1253 +/**
1.1254 +@publishedPartner
1.1255 +@released
1.1256 +
1.1257 +An MultiMediaCard error code:
1.1258 +
1.1259 +Indicates an unspecified error.
1.1260 +
1.1261 +@see TMMCErr
1.1262 +*/
1.1263 +const TUint32 KMMCErrGeneral= KBit25;
1.1264 +
1.1265 +
1.1266 +/**
1.1267 +@publishedPartner
1.1268 +@released
1.1269 +
1.1270 +A bitmask of all MultiMediaCard error codes.
1.1271 +*/
1.1272 +const TUint32 KMMCErrAll = (KBit26 - KBit0);
1.1273 +
1.1274 +/**
1.1275 +@publishedPartner
1.1276 +@released
1.1277 +
1.1278 +A subset of MultiMediaCard error codes.
1.1279 +*/
1.1280 +const TUint32 KMMCErrBasic = (KMMCErrAll & ~(
1.1281 + KMMCErrBypass |
1.1282 + KMMCErrUpdPswd |
1.1283 + KMMCErrInitContext |
1.1284 + KMMCErrArgument |
1.1285 + KMMCErrSingleBlock |
1.1286 + KMMCErrLocked |
1.1287 + KMMCErrNotFound |
1.1288 + KMMCErrAlreadyExists|
1.1289 + KMMCErrGeneral));
1.1290 +
1.1291 +// DMMC Stack and Session control bits
1.1292 +
1.1293 +// Stack State bits
1.1294 +const TUint32 KMMCStackStateRunning= KBit0; // Stack scheduler active
1.1295 +const TUint32 KMMCStackStateWaitingToLock= KBit1; //
1.1296 +const TUint32 KMMCStackStateLocked= KBit2; //
1.1297 +const TUint32 KMMCStackStateWaitingDFC= KBit3;
1.1298 +const TUint32 KMMCStackStateInitInProgress= KBit4;
1.1299 +const TUint32 KMMCStackStateReScheduled= KBit5;
1.1300 +const TUint32 KMMCStackStateJobChooser= KBit6;
1.1301 +const TUint32 KMMCStackStateDoDeselect= KBit7;
1.1302 +const TUint32 KMMCStackStateBusInconsistent=KBit8;
1.1303 +const TUint32 KMMCStackStateInitPending= KBit9;
1.1304 +const TUint32 KMMCStackStateCardRemoved= KBit10;
1.1305 +const TUint32 KMMCStackStateSleepinProgress=KBit11;
1.1306 +const TUint32 KMMCStackStateSleep= KBit12;
1.1307 +const TUint32 KMMCStackStateYielding= KBit13;
1.1308 +
1.1309 +// Session Blocking bits definition
1.1310 +
1.1311 +/**
1.1312 +@publishedPartner
1.1313 +@released
1.1314 +
1.1315 +A bit, which when set in a call to DMMCStack::BlockCurrentSession(), indicates
1.1316 +that the current session is to be blocked, awaiting an event that is to
1.1317 +be handled at the platform specific level.
1.1318 +
1.1319 +For example, the session may be waiting for:
1.1320 +
1.1321 +- a response following a command
1.1322 +- an interrupt indicating that data transfer is required
1.1323 +- a platform specific layer specific timer.
1.1324 +
1.1325 +@see DMMCStack::BlockCurrentSession()
1.1326 +*/
1.1327 +const TUint32 KMMCBlockOnASSPFunction= KBit0;
1.1328 +
1.1329 +const TUint32 KMMCBlockOnPollTimer = KBit1;
1.1330 +const TUint32 KMMCBlockOnRetryTimer = KBit2;
1.1331 +const TUint32 KMMCBlockOnNoRun = KBit3;
1.1332 +const TUint32 KMMCBlockOnDoor = KBit4;
1.1333 +const TUint32 KMMCBlockOnWaitToLock = KBit5;
1.1334 +const TUint32 KMMCBlockOnCardInUse = KBit6;
1.1335 +const TUint32 KMMCBlockOnPgmTimer = KBit7;
1.1336 +const TUint32 KMMCBlockOnInterrupt = KBit8;
1.1337 +const TUint32 KMMCBlockOnDataTransfer = KBit9;
1.1338 +const TUint32 KMMCBlockOnMoreData = KBit10;
1.1339 +const TUint32 KMMCBlockOnYielding = KBit11; // Yielding to other commands
1.1340 +
1.1341 +const TUint32 KMMCBlockOnAsynchMask = KMMCBlockOnASSPFunction |
1.1342 + KMMCBlockOnPollTimer |
1.1343 + KMMCBlockOnRetryTimer |
1.1344 + KMMCBlockOnPgmTimer |
1.1345 + KMMCBlockOnInterrupt |
1.1346 + KMMCBlockOnDataTransfer |
1.1347 + KMMCBlockOnMoreData;
1.1348 +
1.1349 +const TUint32 KMMCBlockOnGapTimersMask = KMMCBlockOnPollTimer |
1.1350 + KMMCBlockOnRetryTimer |
1.1351 + KMMCBlockOnPgmTimer;
1.1352 +
1.1353 +// Session State bits definition
1.1354 +const TUint32 KMMCSessStateEngaged = KBit0; // Processed by DMMCStack
1.1355 +const TUint32 KMMCSessStateInProgress = KBit1; // No longer safe to restart
1.1356 +const TUint32 KMMCSessStateCritical = KBit2; // Re-initialise the stack if aborted
1.1357 +const TUint32 KMMCSessStateSafeInGaps = KBit3;
1.1358 +const TUint32 KMMCSessStateDoReSchedule= KBit4;
1.1359 +
1.1360 +/**
1.1361 +@publishedPartner
1.1362 +@released
1.1363 +
1.1364 +A bit that when set into DMMCSession::iState before calling
1.1365 +DMMCStack::UnBlockCurrentSession(), causes a DFC to be queued in order
1.1366 +to resume the state machine at some later stage.
1.1367 +*/
1.1368 +const TUint32 KMMCSessStateDoDFC = KBit5;
1.1369 +const TUint32 KMMCSessStateBlockOnDoor = KBit6;
1.1370 +const TUint32 KMMCSessStateCardIsGone = KBit7;
1.1371 +const TUint32 KMMCSessStateASSPEngaged = KBit8;
1.1372 +const TUint32 KMMCSessStateAllowDirectCommands = KBit9; // Allow Direct Commands (Using CMD) during Data Transfer
1.1373 +
1.1374 +class TCID
1.1375 +/**
1.1376 + CID class
1.1377 +
1.1378 + @publishedPartner
1.1379 + @released
1.1380 +*/
1.1381 + {
1.1382 +public:
1.1383 + inline TCID() {} // Default constructor
1.1384 + inline TCID(const TUint8*);
1.1385 + inline TCID& operator=(const TCID&);
1.1386 + inline TCID& operator=(const TUint8*);
1.1387 + inline TBool operator==(const TCID&) const;
1.1388 + inline TBool operator==(const TUint8*) const;
1.1389 + inline void Copy(TUint8*) const; // Copies big endian 16 bytes CID
1.1390 + inline TUint8 At(TUint anIndex) const; // Byte from CID at anIndex
1.1391 +private:
1.1392 + TUint8 iData[KMMCCIDLength]; // Big endian 128 bit bitfield representing CID
1.1393 + };
1.1394 +
1.1395 +
1.1396 +class TCSD
1.1397 +/**
1.1398 + CSD class
1.1399 +
1.1400 + @publishedPartner
1.1401 + @released
1.1402 +*/
1.1403 + {
1.1404 +public:
1.1405 + inline TCSD() {memclr(this, sizeof(*this));} // Default constructor
1.1406 + inline TCSD(const TUint8*);
1.1407 + inline TCSD& operator=(const TCSD&);
1.1408 + inline TCSD& operator=(const TUint8*);
1.1409 + inline void Copy(TUint8*) const; // Copies big endian 16 bytes CSD
1.1410 + inline TUint8 At(TUint anIndex) const; // Byte from CSD at anIndex
1.1411 +public:
1.1412 + inline TUint CSDStructure() const;
1.1413 + inline TUint SpecVers() const;
1.1414 + inline TUint Reserved120() const;
1.1415 + inline TUint TAAC() const;
1.1416 + inline TUint NSAC() const;
1.1417 + inline TUint TranSpeed() const;
1.1418 + inline TUint CCC() const;
1.1419 + inline TUint ReadBlLen() const;
1.1420 + inline TBool ReadBlPartial() const;
1.1421 + inline TBool WriteBlkMisalign() const;
1.1422 + inline TBool ReadBlkMisalign() const;
1.1423 + inline TBool DSRImp() const;
1.1424 + inline TUint Reserved74() const;
1.1425 + inline TUint CSize() const;
1.1426 + inline TUint VDDRCurrMin() const;
1.1427 + inline TUint VDDRCurrMax() const;
1.1428 + inline TUint VDDWCurrMin() const;
1.1429 + inline TUint VDDWCurrMax() const;
1.1430 + inline TUint CSizeMult() const;
1.1431 + inline TUint EraseGrpSize() const;
1.1432 + inline TUint EraseGrpMult() const;
1.1433 + inline TUint WPGrpSize() const;
1.1434 + inline TBool WPGrpEnable() const;
1.1435 + inline TUint DefaultECC() const;
1.1436 + inline TUint R2WFactor() const;
1.1437 + inline TUint WriteBlLen() const;
1.1438 + inline TBool WriteBlPartial() const;
1.1439 + inline TUint Reserved16() const;
1.1440 + inline TBool FileFormatGrp() const;
1.1441 + inline TBool Copy() const;
1.1442 + inline TBool PermWriteProtect() const;
1.1443 + inline TBool TmpWriteProtect() const;
1.1444 + inline TUint FileFormat() const;
1.1445 + inline TUint ECC() const;
1.1446 + inline TUint CRC() const;
1.1447 +public:
1.1448 + IMPORT_C TUint DeviceSize() const; // Uses functions above to calculate device capacity
1.1449 + IMPORT_C TMMCMediaTypeEnum MediaType() const;
1.1450 + IMPORT_C TUint ReadBlockLength() const; // Read Block Length in bytes
1.1451 + IMPORT_C TUint WriteBlockLength() const;// Write Block Length in bytes
1.1452 + IMPORT_C TUint EraseSectorSize() const; // Erase sector size (default 512 bytes)
1.1453 + IMPORT_C TUint EraseGroupSize() const; // Erase group size (default 16*<sector size> bytes)
1.1454 + IMPORT_C TUint MinReadCurrentInMilliamps() const;
1.1455 + IMPORT_C TUint MinWriteCurrentInMilliamps() const;
1.1456 + IMPORT_C TUint MaxReadCurrentInMilliamps() const;
1.1457 + IMPORT_C TUint MaxWriteCurrentInMilliamps() const;
1.1458 + IMPORT_C TUint MaxTranSpeedInKilohertz() const;
1.1459 +public:
1.1460 + IMPORT_C TUint CSDField(const TUint& aTopBit, const TUint& aBottomBit) const; /**< @internalComponent */
1.1461 + TUint8 iData[KMMCCSDLength]; /**< @internalComponent */ // Big endian 128 bit bitfield representing CSD
1.1462 + };
1.1463 +
1.1464 +
1.1465 +class TExtendedCSD
1.1466 +/**
1.1467 + Extended CSD register class.
1.1468 + For more information about this register, see the MultimediaCard System
1.1469 + Specification, Version 4.1+
1.1470 +
1.1471 + @publishedPartner
1.1472 + @released
1.1473 +*/
1.1474 + {
1.1475 +public:
1.1476 + /**
1.1477 + An enum used by TExtendedCSD::GetWriteArg() to construct a TMMCArgument object.
1.1478 + The value chosen defines how the register or command set is to be modified.
1.1479 + */
1.1480 + enum TExtCSDAccessBits
1.1481 + {
1.1482 + /** Change the card's command set */
1.1483 + ECmdSet,
1.1484 + /** Set the specified bits */
1.1485 + ESetBits,
1.1486 + /** Clear the specified bits */
1.1487 + EClearBits,
1.1488 + /** Write the specified byte */
1.1489 + EWriteByte
1.1490 + };
1.1491 + /**
1.1492 + This enum defines various field offsets into the Modes Segment (i.e.
1.1493 + the writable part) of the Extended CSD register.
1.1494 + */
1.1495 + enum TExtCSDModesFieldIndex
1.1496 + {
1.1497 + /** Offset of the CMD_SET field */
1.1498 + ECmdSetIndex = 191,
1.1499 + /** Offset of the CMD_SET_REV field */
1.1500 + ECmdSetRevIndex = 189,
1.1501 + /** Offset of the POWER_CLASS field */
1.1502 + EPowerClassIndex = 187,
1.1503 + /** Offset of the HS_TIMING field */
1.1504 + EHighSpeedInterfaceTimingIndex = 185,
1.1505 + /** Offset of the BUS_WIDTH field */
1.1506 + EBusWidthModeIndex = 183,
1.1507 + /** Offset of the BOOT_CONFIG field */
1.1508 + EBootConfigIndex = 179,
1.1509 + /** Offset of the BOOT_BUS_WIDTH field */
1.1510 + EBootBusWidthIndex = 177,
1.1511 + /** Offset of the ERASE_GROUP_DEF field */
1.1512 + EEraseGroupDefIndex = 175
1.1513 + };
1.1514 +
1.1515 + /**
1.1516 + This enum defines various field offsets into the Properties Segment (i.e.
1.1517 + the read-only part) of the Extended CSD register.
1.1518 + */
1.1519 + enum TExtCSDPropertiesFieldIndex
1.1520 + {
1.1521 + /** Offset of the EXT_CSD_REV field */
1.1522 + EExtendedCSDRevIndex = 192,
1.1523 + /** Offset of the CARD_TYPE field */
1.1524 + ECardTypeIndex = 196,
1.1525 + /** Offset of the ACC_SIZE field */
1.1526 + EAccessSizeIndex = 225,
1.1527 + /** Offset of the HC_ERASE_GRP_SIZE field */
1.1528 + EHighCapacityEraseGroupSizeIndex = 224
1.1529 + };
1.1530 +
1.1531 + /** This enum defines the bus width encoding used by the BUS_WIDTH field */
1.1532 + enum TExtCSDBusWidths
1.1533 + {
1.1534 + EExtCsdBusWidth1 = 0x00,
1.1535 + EExtCsdBusWidth4 = 0x01,
1.1536 + EExtCsdBusWidth8 = 0x02
1.1537 + };
1.1538 +
1.1539 + /**
1.1540 + This enum defines the different MMCV4.x card types available as defined
1.1541 + in the CARD_TYPE field
1.1542 + */
1.1543 + enum TCardTypes
1.1544 + {
1.1545 + EHighSpeedCard26Mhz = 0x01,
1.1546 + EHighSpeedCard52Mhz = 0x02
1.1547 + };
1.1548 +
1.1549 + /**
1.1550 + This enum defines the boot config encoding used by the BOOT_CONFIG field
1.1551 + */
1.1552 + enum TExtCSDBootConfig
1.1553 + {
1.1554 + ESelectUserArea = 0x00,
1.1555 + ESelectBootPartition1 = 0x01,
1.1556 + ESelectBootPartition2 = 0x02,
1.1557 + EEnableBootPartition1forBoot = 0x08,
1.1558 + EEnableBootPartition2forBoot = 0x10,
1.1559 + EEnableUserAreaforBoot = 0x38,
1.1560 + EEnableBootAck = 0x40
1.1561 + };
1.1562 +
1.1563 + /**
1.1564 + This enum defines the Boot Bus Width encoding used by the BOOT_BUS_WIDTH field
1.1565 + */
1.1566 + enum TExtCSDBootBusWidth
1.1567 + {
1.1568 + EBootBusWidth1Bit = 0x00,
1.1569 + EBootBusWidth4Bit = 0x01,
1.1570 + EBootBusWidth8Bit = 0x02,
1.1571 + EResetBusWidthafterBoot = 0x08
1.1572 + };
1.1573 +
1.1574 + /**
1.1575 + This enum defines the Erase Group Definition encoding
1.1576 + used by the ERASE_GROUP_DEF field
1.1577 + */
1.1578 + enum TExtCSDEraseGroupDef
1.1579 + {
1.1580 +
1.1581 + EEraseGrpDefEnableOldSizes = 0x00,
1.1582 + EEraseGrpDefEnableHighCapSizes = 0x01
1.1583 + };
1.1584 +
1.1585 +public:
1.1586 + /** Default constructor */
1.1587 + inline TExtendedCSD();
1.1588 + /**
1.1589 + Constructor
1.1590 + @param aPtr a byte buffer containing the contents of the register
1.1591 + */
1.1592 + inline TExtendedCSD(const TUint8* aPtr);
1.1593 + /**
1.1594 + Copy constructor
1.1595 + @param aCSD a reference to another instance of the same class
1.1596 + */
1.1597 + inline TExtendedCSD& operator=(const TExtendedCSD& aCSD);
1.1598 + /**
1.1599 + Copy constructor
1.1600 + @param aPtr a byte buffer containing the contents of the register
1.1601 + */
1.1602 + inline TExtendedCSD& operator=(const TUint8* aPtr);
1.1603 +
1.1604 + /** Returns the byte at a particular offset into the register
1.1605 + @param anIndex the offset into the register
1.1606 + */
1.1607 + inline TUint8 At(TUint anIndex) const;
1.1608 +
1.1609 + /** returns a pointer to the raw data */
1.1610 + inline TUint8* Ptr();
1.1611 +
1.1612 + /**
1.1613 + Constructs and then returns a TMMCArgument which can be used to
1.1614 + write to the register using the SWITCH command (CMD6)
1.1615 + @param aAccess specifies how the register or command set is to be modified.
1.1616 + @param aIndex the offset into the register
1.1617 + @param aValue the value to write to the field in the register
1.1618 + @param aCmdSet The command set to write. Valid if aAccess = ECmdSet
1.1619 + */
1.1620 + inline static TMMCArgument GetWriteArg(TExtCSDAccessBits aAccess, TExtCSDModesFieldIndex aIndex, TUint aValue, TUint aCmdSet);
1.1621 +
1.1622 + /** returns the contents of the CMD_SET field */
1.1623 + inline TUint SupportedCmdSet() const;
1.1624 +
1.1625 + /** returns the contents of the SEC_COUNT field */
1.1626 + inline TUint SectorCount() const;
1.1627 +
1.1628 + /** returns the contents of the MIN_PERF_W_8_52 field */
1.1629 + inline TUint MinPerfWrite8Bit52Mhz() const;
1.1630 +
1.1631 + /** returns the contents of the MIN_PERF_R_8_52 field */
1.1632 + inline TUint MinPerfRead8Bit52Mhz() const;
1.1633 +
1.1634 + /** returns the contents of the MIN_PERF_W_8_26_4_52 field */
1.1635 + inline TUint MinPerfWrite8Bit26Mhz_4Bit52Mhz() const;
1.1636 +
1.1637 + /** returns the contents of the MIN_PERF_R_8_26_4_52 field */
1.1638 + inline TUint MinPerfRead8Bit26Mhz_4Bit52Mhz() const;
1.1639 +
1.1640 + /** returns the contents of the MIN_PERF_W_4_26 field */
1.1641 + inline TUint MinPerfWrite4Bit26Mhz() const;
1.1642 +
1.1643 + /** returns the contents of the MIN_PERF_R_4_26 field */
1.1644 + inline TUint MinPerfRead4Bit26Mhz() const;
1.1645 +
1.1646 + /** returns the contents of the PWR_CL_26_360 field */
1.1647 + inline TUint PowerClass26Mhz360V() const;
1.1648 +
1.1649 + /** returns the contents of the PWR_CL_52_360 field */
1.1650 + inline TUint PowerClass52Mhz360V() const;
1.1651 +
1.1652 + /** returns the contents of the PWR_CL_26_195 field */
1.1653 + inline TUint PowerClass26Mhz195V() const;
1.1654 +
1.1655 + /** returns the contents of the PWR_CL_52_195 field */
1.1656 + inline TUint PowerClass52Mhz195V() const;
1.1657 +
1.1658 + /** returns the contents of the CARD_TYPE field */
1.1659 + inline TUint CardType() const;
1.1660 +
1.1661 + /** returns the contents of the CSD_STRUCTURE field */
1.1662 + inline TUint CSDStructureVer() const;
1.1663 +
1.1664 + /** returns the contents of the EXT_CSD_REV field */
1.1665 + inline TUint ExtendedCSDRev() const;
1.1666 +
1.1667 + /** returns the contents of the CMD_SET field */
1.1668 + inline TUint CmdSet() const;
1.1669 +
1.1670 + /** returns the contents of the CMD_SET_REV field */
1.1671 + inline TUint CmdSetRev() const;
1.1672 +
1.1673 + /** returns the contents of the POWER_CLASS field */
1.1674 + inline TUint PowerClass() const;
1.1675 +
1.1676 + /** returns the contents of the HS_TIMING field */
1.1677 + inline TUint HighSpeedTiming() const;
1.1678 +
1.1679 + /** returns the contents of the BUS_WIDTH field */
1.1680 + inline TUint BusWidthMode() const;
1.1681 +
1.1682 + /** returns the contents of the BOOT_CONFIG field */
1.1683 + inline TUint BootConfig() const;
1.1684 +
1.1685 + /** returns the contents of the BOOT_BUS_WIDTH field */
1.1686 + inline TUint BootBusWidth() const;
1.1687 +
1.1688 + /** returns the contents of the ERASE_GROUP_DEF field */
1.1689 + inline TUint EraseGroupDef() const;
1.1690 +
1.1691 + /** returns the contents of the ACC_SIZE field */
1.1692 + inline TUint AccessSize() const;
1.1693 +
1.1694 + /** returns the contents of the HC_ERASE_GRP_SIZE field */
1.1695 + inline TUint HighCapacityEraseGroupSize() const;
1.1696 +
1.1697 + /** returns the contents of the BOOT_INFO field */
1.1698 + inline TUint BootInfo() const;
1.1699 +
1.1700 + /** returns the contents of the BOOT_SIZE_MUTLI field */
1.1701 + inline TUint BootSizeMultiple() const;
1.1702 +
1.1703 + /** returns the contents of the ERASE_TIMEOUT_MULT field */
1.1704 + inline TUint EraseTimeoutMultiple() const;
1.1705 +
1.1706 + /** returns the contents of the REL_WR_SEC_C field */
1.1707 + inline TUint ReliableWriteSector() const;
1.1708 +
1.1709 + /** returns the contents of the HC_WP_GRP_SIZE field */
1.1710 + inline TUint HighCapacityWriteProtectGroupSize() const;
1.1711 +
1.1712 + /** returns the contents of the S_C_VCC field */
1.1713 + inline TUint SleepCurrentVcc() const;
1.1714 +
1.1715 + /** returns the contents of the S_C_VCCQ field */
1.1716 + inline TUint SleepCurrentVccQ() const;
1.1717 +
1.1718 + /** returns the contents of the S_A_TIMEOUT field */
1.1719 + inline TUint SleepAwakeTimeout() const;
1.1720 +
1.1721 +private:
1.1722 + /**
1.1723 + @internalComponent little endian 512 byte field representing extended CSD
1.1724 + */
1.1725 + TUint8 iData[KMMCExtendedCSDLength];
1.1726 + };
1.1727 +
1.1728 +
1.1729 +// 32 bit MMC card status field (response R1)
1.1730 +
1.1731 +const TUint32 KMMCStatAppCmd= KBit5;
1.1732 +const TUint32 KMMCStatSwitchError= KBit7;
1.1733 +const TUint32 KMMCStatReadyForData= KBit8;
1.1734 +const TUint32 KMMCStatCurrentStateMask= (KBit13-KBit9);
1.1735 +const TUint32 KMMCStatEraseReset= KBit13;
1.1736 +const TUint32 KMMCStatCardECCDisabled= KBit14;
1.1737 +const TUint32 KMMCStatWPEraseSkip= KBit15;
1.1738 +const TUint32 KMMCStatErrCSDOverwrite= KBit16;
1.1739 +const TUint32 KMMCStatErrOverrun= KBit17;
1.1740 +const TUint32 KMMCStatErrUnderrun= KBit18;
1.1741 +const TUint32 KMMCStatErrUnknown= KBit19;
1.1742 +const TUint32 KMMCStatErrCCError= KBit20;
1.1743 +const TUint32 KMMCStatErrCardECCFailed= KBit21;
1.1744 +const TUint32 KMMCStatErrIllegalCommand=KBit22;
1.1745 +const TUint32 KMMCStatErrComCRCError= KBit23;
1.1746 +const TUint32 KMMCStatErrLockUnlock= KBit24;
1.1747 +const TUint32 KMMCStatCardIsLocked= KBit25;
1.1748 +const TUint32 KMMCStatErrWPViolation= KBit26;
1.1749 +const TUint32 KMMCStatErrEraseParam= KBit27;
1.1750 +const TUint32 KMMCStatErrEraseSeqError= KBit28;
1.1751 +const TUint32 KMMCStatErrBlockLenError= KBit29;
1.1752 +const TUint32 KMMCStatErrAddressError= KBit30;
1.1753 +const TUint32 KMMCStatErrOutOfRange= KBit31;
1.1754 +
1.1755 +const TUint32 KMMCStatErrorMask= KMMCStatErrOutOfRange |
1.1756 + KMMCStatErrAddressError |
1.1757 + KMMCStatErrBlockLenError|
1.1758 + KMMCStatErrEraseSeqError|
1.1759 + KMMCStatErrEraseParam |
1.1760 + KMMCStatErrWPViolation |
1.1761 + KMMCStatErrLockUnlock |
1.1762 + KMMCStatErrCardECCFailed|
1.1763 + KMMCStatErrCCError |
1.1764 + KMMCStatErrUnknown |
1.1765 + KMMCStatErrUnderrun |
1.1766 + KMMCStatErrOverrun |
1.1767 + KMMCStatErrCSDOverwrite;
1.1768 +
1.1769 +
1.1770 +const TUint32 KMMCStatClearByReadMask= KMMCStatErrOutOfRange |
1.1771 + KMMCStatErrAddressError |
1.1772 + KMMCStatErrBlockLenError|
1.1773 + KMMCStatErrEraseSeqError|
1.1774 + KMMCStatErrEraseParam |
1.1775 + KMMCStatErrWPViolation |
1.1776 + KMMCStatErrLockUnlock |
1.1777 + KMMCStatErrCardECCFailed|
1.1778 + KMMCStatErrCCError |
1.1779 + KMMCStatErrUnknown |
1.1780 + KMMCStatErrUnderrun |
1.1781 + KMMCStatErrOverrun |
1.1782 + KMMCStatErrCSDOverwrite |
1.1783 + KMMCStatWPEraseSkip |
1.1784 + KMMCStatEraseReset |
1.1785 + KMMCStatAppCmd;
1.1786 +
1.1787 +enum TMMCardStateEnum
1.1788 + {
1.1789 + ECardStateIdle = 0,
1.1790 + ECardStateReady = (1 << 9),
1.1791 + ECardStateIdent = (2 << 9),
1.1792 + ECardStateStby = (3 << 9),
1.1793 + ECardStateTran = (4 << 9),
1.1794 + ECardStateData = (5 << 9),
1.1795 + ECardStateRcv = (6 << 9),
1.1796 + ECardStatePrg = (7 << 9),
1.1797 + ECardStateDis = (8 << 9),
1.1798 + ECardStateBtst = (9 << 9),
1.1799 + ECardStateSlp = (10 << 9)
1.1800 + };
1.1801 +
1.1802 +class TMMCStatus
1.1803 +/**
1.1804 + MMC Status class.
1.1805 + This class can be used to get the MMC card state machine and response status.
1.1806 + For the details of MMC card state machine and command response refer to MMC card specification.
1.1807 +
1.1808 + @see DMMCStack
1.1809 + @publishedPartner
1.1810 + @released
1.1811 +*/
1.1812 + {
1.1813 +public:
1.1814 + /**
1.1815 + * Default constructor.
1.1816 + */
1.1817 + inline TMMCStatus() {}
1.1818 + inline TMMCStatus(const TUint8*);
1.1819 + inline TMMCStatus(const TUint32&);
1.1820 + inline operator TUint32() const;
1.1821 + inline TUint32 Error() const;
1.1822 + inline TMMCardStateEnum State() const;
1.1823 + inline void UpdateState(TMMCardStateEnum aState);
1.1824 +private:
1.1825 + TUint32 iData; // 32 bit bitfield representing status register
1.1826 + };
1.1827 +
1.1828 +
1.1829 +
1.1830 +const TUint32 KMMCOCRBusy = KBit31; // OCR Busy Bit (Response R3)
1.1831 +const TUint32 KMMCOCRAccessModeHCS = KBit30; // OCR Access Mode + SD HCS Bit (Response R3)
1.1832 +const TUint32 KMMCOCRLowVoltage = KBit7; // 1.65 - 1.95 volt support
1.1833 +const TUint32 KMMCOCRAccessModeMask = KBit30 | KBit29; // OCR Access Mode : [00 : Byte], [10 : Block]
1.1834 +
1.1835 +
1.1836 +
1.1837 +/**
1.1838 + Defines the bit value that can be used in TPBusPsuInfo::iVoltageSupported
1.1839 + to indicate that the MultiMediaCard PSU supports voltage adjustment.
1.1840 +
1.1841 + @publishedPartner
1.1842 + @released
1.1843 +*/
1.1844 +#define KMMCAdjustableOpVoltage KMMCOCRBusy // Use same bit to flag ASSP PSU supports voltage adjustment.
1.1845 +
1.1846 +
1.1847 +class TMMCArgument
1.1848 +/**
1.1849 + MMC Argument class
1.1850 +
1.1851 + @publishedPartner
1.1852 + @released
1.1853 +*/
1.1854 + {
1.1855 +public:
1.1856 + inline TMMCArgument();
1.1857 + inline TMMCArgument(const TUint32&);
1.1858 + inline TMMCArgument(TRCA);
1.1859 + inline TMMCArgument(TDSR);
1.1860 + inline operator TUint32() const;
1.1861 + inline void SetRCA(TRCA);
1.1862 +private:
1.1863 + TUint32 iData; // 32 bit bitfield representing the argument
1.1864 + };
1.1865 +
1.1866 +
1.1867 +class TRCA
1.1868 +/**
1.1869 + MMC RCA (Relative Card Address) class
1.1870 +*/
1.1871 + {
1.1872 +public:
1.1873 + inline TRCA() {}
1.1874 + inline TRCA(TUint16);
1.1875 + inline TRCA(TInt);
1.1876 + inline TRCA(TMMCArgument);
1.1877 + inline operator TUint16() const;
1.1878 +private:
1.1879 + TUint16 iData; // 16 bit bitfield representing MultiMedia Card's RCA
1.1880 + };
1.1881 +
1.1882 +
1.1883 +class TDSR
1.1884 +/**
1.1885 + MMC DSR (Driver Stage Register) class
1.1886 +*/
1.1887 + {
1.1888 +public:
1.1889 + inline TDSR();
1.1890 + inline TDSR(TUint16);
1.1891 + inline operator TUint16() const;
1.1892 +private:
1.1893 + TUint16 iData; // 16 bit bitfield representing MultiMedia Card's DSR
1.1894 + };
1.1895 +
1.1896 +
1.1897 +// Card specific information and context
1.1898 +
1.1899 +/**
1.1900 +@publishedPartner
1.1901 +@released
1.1902 +*/
1.1903 +const TUint32 KMMCardHasPassword= KBit0;
1.1904 +
1.1905 +/**
1.1906 +@publishedPartner
1.1907 +@released
1.1908 +*/
1.1909 +const TUint32 KMMCardIsWriteProtected= KBit1;
1.1910 +
1.1911 +/**
1.1912 +@publishedPartner
1.1913 +@released
1.1914 +*/
1.1915 +const TUint32 KMMCardIsLockable= KBit2;
1.1916 +const TUint32 KMMCardIsHighCapacity= KBit3;
1.1917 +const TUint32 KMMCardIsHighSpeed= KBit4;
1.1918 +
1.1919 +const TUint32 KMMCardMMCFlagMask= 0x0000ffff;
1.1920 +
1.1921 +const TUint32 KMMCardFirstCustomFlag= KBit16;
1.1922 +const TUint32 KMMCardCustomFlagMask= 0xffff0000;
1.1923 +
1.1924 +const TUint32 KMMCardHighCapBlockSize= 512;
1.1925 +const TUint32 KMMCardHighCapBlockSizeLog2= 9;
1.1926 +
1.1927 +NONSHARABLE_CLASS(TMMCard)
1.1928 +/**
1.1929 + MMC card class
1.1930 +*/
1.1931 + {
1.1932 +public:
1.1933 + inline TBool IsHighCapacity() const;
1.1934 +
1.1935 + /** @publishedPartner
1.1936 + @released */
1.1937 + TMMCard();
1.1938 +
1.1939 + /** @publishedPartner
1.1940 + @released */
1.1941 + inline TBool IsPresent() const;
1.1942 +
1.1943 + /** @publishedPartner
1.1944 + @released */
1.1945 + IMPORT_C TBool IsReady() const;
1.1946 +
1.1947 + /** @publishedPartner
1.1948 + @released */
1.1949 + IMPORT_C TBool IsLocked() const;
1.1950 +
1.1951 + /** @publishedPartner
1.1952 + @released */
1.1953 + inline TMMCMediaTypeEnum MediaType() const;
1.1954 +
1.1955 + /** @publishedPartner
1.1956 + @released */
1.1957 + inline TUint DeviceSize() const;
1.1958 +
1.1959 + /** @publishedPartner
1.1960 + @released */
1.1961 + inline const TCID& CID() const;
1.1962 +
1.1963 + /** @publishedPartner
1.1964 + @released */
1.1965 + inline const TCSD& CSD() const;
1.1966 +
1.1967 + /** @publishedPartner
1.1968 + @released */
1.1969 + inline const TExtendedCSD& ExtendedCSD() const;
1.1970 +
1.1971 + /** @publishedPartner
1.1972 + @released */
1.1973 + inline TRCA RCA() const;
1.1974 +
1.1975 + /** @publishedPartner
1.1976 + @released */
1.1977 + inline TBool HasPassword() const;
1.1978 +
1.1979 + /** @publishedPartner
1.1980 + @released */
1.1981 + inline TBool IsWriteProtected() const; // Always EFalse in MMC build
1.1982 +
1.1983 + /** @publishedPartner
1.1984 + @released */
1.1985 + inline TInt BusWidth() const;
1.1986 +
1.1987 + /** @publishedPartner
1.1988 + @released */
1.1989 + inline void SetBusWidth(TInt aBusWidth);
1.1990 +
1.1991 + /** @internalTechnology */
1.1992 + inline void SetHighSpeedClock(TUint32 aHighSpeedClock);
1.1993 +
1.1994 + /** @internalTechnology */
1.1995 + inline TUint32 HighSpeedClock() const;
1.1996 +
1.1997 + /** @publishedPartner
1.1998 + @released */
1.1999 + virtual TUint32 PreferredWriteGroupLength() const;
1.2000 +
1.2001 + /** @publishedPartner
1.2002 + @released */
1.2003 + virtual TInt GetFormatInfo(TLDFormatInfo& aFormatInfo) const;
1.2004 +
1.2005 + /** @publishedPartner
1.2006 + @released */
1.2007 + virtual TUint32 MinEraseSectorSize() const;
1.2008 +
1.2009 + /** @publishedPartner
1.2010 + @released */
1.2011 + virtual TUint32 EraseSectorSize() const;
1.2012 +
1.2013 + virtual TUint MaxTranSpeedInKilohertz() const;
1.2014 +
1.2015 + virtual TInt GetEraseInfo(TMMCEraseInfo& anEraseInfo) const;
1.2016 +
1.2017 + /** @publishedPartner
1.2018 + @released
1.2019 +
1.2020 + Returns the maximum block length supported by the card encoded as a logarithm.
1.2021 + This may be less than the READ_BL_LEN field in the CSD
1.2022 + register depending on the type of card and it's capacity.
1.2023 + */
1.2024 + virtual TInt MaxReadBlLen() const;
1.2025 +
1.2026 + /** @publishedPartner
1.2027 + @released
1.2028 +
1.2029 + Returns the maximum write block length supported by the card encoded as a logarithm.
1.2030 + This may be less than the WRITE_BL_LEN field in the CSD
1.2031 + register depending on the type of card and it's capacity.
1.2032 + */
1.2033 + virtual TInt MaxWriteBlLen() const;
1.2034 +
1.2035 + /** @publishedPartner
1.2036 + @released */
1.2037 + virtual TInt64 DeviceSize64() const;
1.2038 +
1.2039 +private:
1.2040 + inline TInt Number() const;
1.2041 +public:
1.2042 + TInt iIndex;
1.2043 + TMMCStatus iStatus; // last card's status
1.2044 + TUint32 iSetBlockLen; // current block length set for the card
1.2045 + TMMCCommandEnum iLastCommand; // Last Command code issued for the card
1.2046 + TCID iCID;
1.2047 + TCSD iCSD;
1.2048 + TRCA iRCA;
1.2049 + DMMCSession* iUsingSessionP; // session which has this card attached
1.2050 + TUint32 iFlags;
1.2051 + TExtendedCSD iExtendedCSD;
1.2052 +private:
1.2053 + TUint32 iHighSpeedClock;
1.2054 + TInt iSpare[4];
1.2055 + TInt iBusWidth;
1.2056 + friend class DMMCStack;
1.2057 + friend class TMMCardArray;
1.2058 + };
1.2059 +
1.2060 +class TMMCardArray
1.2061 +/**
1.2062 + MMC card array class
1.2063 +*/
1.2064 + {
1.2065 +public:
1.2066 + inline TMMCardArray(DMMCStack* anOwningStack);
1.2067 +
1.2068 + /** @publishedPartner
1.2069 + @released */
1.2070 + IMPORT_C virtual TInt AllocCards();
1.2071 +
1.2072 + void InitNewCardScan();
1.2073 +
1.2074 + /** @publishedPartner
1.2075 + @released */
1.2076 + IMPORT_C void AddNewCard(const TUint8* aCID,TRCA* aNewRCA);
1.2077 +
1.2078 + inline TUint NewCardCount();
1.2079 + inline TInt CardsPresent();
1.2080 + inline TMMCard* NewCardP(TUint aNewCardNumber);
1.2081 + inline TMMCard* CardP(TUint aCardNumber);
1.2082 + inline TMMCard& Card(TUint aCardNumber);
1.2083 + inline TMMCard& NewCard(TUint aCardNumber);
1.2084 + TInt MergeCards(TBool aFirstPass);
1.2085 + void UpdateAcquisitions(TUint* aMaxClock);
1.2086 +
1.2087 + /** @internalTechnology */
1.2088 + TInt CardIndex(const TMMCard* aCard);
1.2089 +
1.2090 + /** @publishedPartner
1.2091 + @released */
1.2092 + IMPORT_C virtual void DeclareCardAsGone(TUint aCardNumber);
1.2093 +
1.2094 +protected: // initialized by AllocCards()
1.2095 + void MoveCardAndLockRCA(TMMCard& aSrc,TMMCard& aDest,TInt aDestIndex);
1.2096 + DMMCStack* iOwningStack;
1.2097 + TInt iCardsPresent;
1.2098 + TUint iNewCardsCount;
1.2099 + TMMCard* iCards[KMaxMMCardsPerStack];
1.2100 + TMMCard* iNewCards[KMaxMMCardsPerStack];
1.2101 + };
1.2102 +
1.2103 +// MMC Command descriptor
1.2104 +
1.2105 +const TUint32 KMMCCmdFlagBytesValid= KBit0; // iBytesDone has a valid data
1.2106 +const TUint32 KMMCCmdFlagTransStopped= KBit1; // CMD12 has been successfully issued
1.2107 +const TUint32 KMMCCmdFlagStatusReceived=KBit2; // Raised by ASSP layer, cleared by ExecCommandSM()
1.2108 +const TUint32 KMMCCmdFlagExecTopBusy= KBit3; // ExecCommandSM() flag
1.2109 +const TUint32 KMMCCmdFlagExecSelBusy= KBit4; // ExecCommandSM() flag
1.2110 +const TUint32 KMMCCmdFlagBlockAddress= KBit5; // Block addressing mode
1.2111 +const TUint32 KMMCCmdFlagDMARamValid= KBit6; // Memory is DMA'able flag
1.2112 +const TUint32 KMMCCmdFlagDoubleBuffer= KBit7; // The current DT command is double-buffered
1.2113 +const TUint32 KMMCCmdFlagPhysAddr= KBit8; // Address is a physical address
1.2114 +const TUint32 KMMCCmdFlagReliableWrite= KBit9; // Current command is Reliable Write
1.2115 +
1.2116 +const TUint32 KMMCCmdFlagASSPFlags= KMMCCmdFlagBytesValid |
1.2117 + KMMCCmdFlagTransStopped |
1.2118 + KMMCCmdFlagStatusReceived;
1.2119 +
1.2120 +
1.2121 +
1.2122 +
1.2123 +/**
1.2124 +The MultiMediaCard command specification.
1.2125 +
1.2126 +@publishedPartner
1.2127 +@released
1.2128 +*/
1.2129 +class TMMCCommandSpec
1.2130 + {
1.2131 +public:
1.2132 + /**
1.2133 + The command class as defined by the MultiMediaCard System Specification.
1.2134 + */
1.2135 + TUint32 iCommandClass;
1.2136 +
1.2137 + /**
1.2138 + The command type as defined by the MultiMediaCard System Specification.
1.2139 + */
1.2140 + TMMCCommandTypeEnum iCommandType;
1.2141 +
1.2142 + /**
1.2143 + The data transfer direction.
1.2144 + */
1.2145 + TMMCCmdDirEnum iDirection;
1.2146 +
1.2147 + /**
1.2148 + ETrue indicates more than one data block is to be tranferred.
1.2149 + */
1.2150 + TBool iMultipleBlocks;
1.2151 +
1.2152 + /**
1.2153 + ETrue indicates use standard stop transmission mode.
1.2154 + */
1.2155 + TBool iUseStopTransmission; // CMD12 has to be used in the end
1.2156 +
1.2157 + /**
1.2158 + The expected response type.
1.2159 +
1.2160 + Note:
1.2161 +
1.2162 + - if this is EResponseTypeNone, then no response is expected.
1.2163 + - if this is ERespTypeR2, then a long (128-bit) response is expected.
1.2164 + - for all other types, a standard (32-bit) response is expected.
1.2165 + */
1.2166 + TMMCResponseTypeEnum iResponseType;
1.2167 +
1.2168 + /**
1.2169 + Expected response length (currently 4 or 16 bytes).
1.2170 + */
1.2171 + TUint iResponseLength;
1.2172 + };
1.2173 +
1.2174 +class TMMCIdxCommandSpec
1.2175 +/**
1.2176 + MMC Index command spec class
1.2177 +*/
1.2178 + {
1.2179 +public:
1.2180 + TInt iIdx;
1.2181 + TMMCCommandSpec iSpec;
1.2182 + };
1.2183 +
1.2184 +
1.2185 +
1.2186 +
1.2187 +/**
1.2188 + MMC command description.
1.2189 +
1.2190 + When issuing an individual command over the bus, the MultiMediaCard
1.2191 + controller uses an object of this type to specify the parameters
1.2192 + for the command, and to receive back any response.
1.2193 +
1.2194 + Commands are issued by passing an object of this type to
1.2195 + the DMMCStack::IssueMMCCommandSM() function, which is implemented by
1.2196 + the platform specific layer.
1.2197 +
1.2198 + @publishedPartner
1.2199 + @released
1.2200 +*/
1.2201 +class TMMCCommandDesc
1.2202 + {
1.2203 +public:
1.2204 + IMPORT_C TInt Direction() const; // returns -1/0/+1 for read/none/write
1.2205 +
1.2206 + inline TBool IsBlockCmd() const;
1.2207 + inline TUint32 NumBlocks() const;
1.2208 + inline TInt64 Arg64() const;
1.2209 + inline TBool IsDoubleBuffered() const;
1.2210 + inline TUint32 BufferLength() const;
1.2211 + inline TUint32 BlockLength() const;
1.2212 + inline TBool IsPhysicalAddress() const;
1.2213 + TBool AdjustForBlockOrByteAccess(const DMMCSession& aSession);
1.2214 +
1.2215 + void Dump(TUint8* aResponseP, TMMCErr aErr);
1.2216 +
1.2217 +public:
1.2218 + /**
1.2219 + @internalComponent
1.2220 + */
1.2221 + TUint32 iFlags;
1.2222 +
1.2223 + /**
1.2224 + The command code.
1.2225 +
1.2226 + This can be written directly to the MMC controller hardware.
1.2227 + */
1.2228 + TMMCCommandEnum iCommand;
1.2229 +
1.2230 + /**
1.2231 + The argument to be supplied with the command.
1.2232 +
1.2233 + This can be written directly to the MMC controller hardware.
1.2234 + */
1.2235 + TMMCArgument iArgument;
1.2236 +
1.2237 + /**
1.2238 + The total length of the data to be tranferred.
1.2239 + */
1.2240 + TUint32 iTotalLength;
1.2241 +
1.2242 + /**
1.2243 + A pointer to the location from where the data is to be read, or written.
1.2244 + */
1.2245 + TUint8* iDataMemoryP;
1.2246 +
1.2247 + /**
1.2248 + The block length to be used in a data transaction.
1.2249 + */
1.2250 + TUint32 iBlockLength;
1.2251 +
1.2252 + /**
1.2253 + The MultiMediaCard command specification.
1.2254 + */
1.2255 + TMMCCommandSpec iSpec;
1.2256 +
1.2257 + /**
1.2258 + The number of bytes transferred since the last time the card was selected.
1.2259 + */
1.2260 + TUint32 iBytesDone;
1.2261 +
1.2262 + /**
1.2263 + @internalComponent
1.2264 + */
1.2265 + TUint iPollAttempts; // Retry counters
1.2266 +
1.2267 + /**
1.2268 + @internalComponent
1.2269 + */
1.2270 + TUint iTimeOutRetries;
1.2271 +
1.2272 + /**
1.2273 + @internalComponent
1.2274 + */
1.2275 + TUint iCRCRetries;
1.2276 +
1.2277 + /**
1.2278 + @internalComponent
1.2279 + */
1.2280 + TUint16 iUnlockRetries;
1.2281 +
1.2282 + /**
1.2283 + @internalComponent
1.2284 + */
1.2285 + TUint16 iOpCondBusyTimeout; // Units of 10mS
1.2286 +
1.2287 + /**
1.2288 + @internalComponent
1.2289 + */
1.2290 + TUint iCustomRetries;
1.2291 +
1.2292 + /**
1.2293 + @internalComponent
1.2294 + */
1.2295 + TUint32 iExecNotHandle; // error codes to not handle in ExecCommandSM()
1.2296 +
1.2297 + /**
1.2298 + The area into which the command response is put.
1.2299 +
1.2300 + This is in big-endian format.
1.2301 + */
1.2302 + TUint8 iResponse[KMMCMaxResponseLength];
1.2303 + };
1.2304 +
1.2305 +
1.2306 +
1.2307 +
1.2308 +/**
1.2309 + MMC bus configuration.
1.2310 +
1.2311 + An object of this type is passed to the Variant implementation
1.2312 + of DMMCStack::SetBusConfigDefaults(), which should fill the public data
1.2313 + members with appropriate information and values.
1.2314 +
1.2315 + @publishedPartner
1.2316 + @released
1.2317 +*/
1.2318 +class TMMCBusConfig
1.2319 + {
1.2320 +public:
1.2321 + /**
1.2322 + The hardware interface clock, in KHz.
1.2323 + */
1.2324 + TUint iBusClock;
1.2325 +
1.2326 +
1.2327 + /**
1.2328 + The bus clock when clocking in data, in KHz.
1.2329 + */
1.2330 + TUint iClockIn;
1.2331 +
1.2332 +
1.2333 + /**
1.2334 + The bus clock when clocking out data, in KHz.
1.2335 + */
1.2336 + TUint iClockOut;
1.2337 +
1.2338 +
1.2339 + /**
1.2340 + The response timeout value, in uS.
1.2341 + */
1.2342 + TUint iResponseTimeOut;
1.2343 +
1.2344 +
1.2345 + /**
1.2346 + The data timeout value, in uS.
1.2347 + */
1.2348 + TUint iDataTimeOut;
1.2349 +
1.2350 +
1.2351 + /**
1.2352 + The busy timeout value, in uS.
1.2353 + */
1.2354 + TUint iBusyTimeOut;
1.2355 + };
1.2356 +
1.2357 +
1.2358 +class TMMCStackConfig
1.2359 +/**
1.2360 + @publishedPartner
1.2361 + @released
1.2362 +
1.2363 + Holds the stack configuration settings on behalf of a session.
1.2364 +
1.2365 + Each DMMCSession object contains the public member DMMCSession::iConfig - an instance of the TMMCStackConfig class.
1.2366 + By changing these settings, the client can override the master (i.e. default) stack configuration settings.
1.2367 +
1.2368 + However, these changes only remain in effect for the period that the session remains the current session.
1.2369 + In this way, the client is able to change the settings employed by the Controller (e.g. bus clock, enable retries,
1.2370 + change time-out values, restore defaults etc) while it performs that client's request.
1.2371 +
1.2372 + The client would generally set-up the stack configuration it requires prior to submitting the session.
1.2373 +*/
1.2374 + {
1.2375 +public:
1.2376 + inline TMMCStackConfig();
1.2377 + inline void SetMode(TUint32 aMask);
1.2378 + inline void RemoveMode(TUint32 aMask);
1.2379 + inline void UseDefault(TUint32 aMask);
1.2380 + inline void SetPollAttempts(TUint aData);
1.2381 + inline void SetTimeOutRetries(TUint aData);
1.2382 + inline void SetCRCRetries(TUint aData);
1.2383 + inline void SetBusClockInKhz(TUint aParam); // In kilohertz
1.2384 + inline void SetTicksClockIn(TUint aParam); // Number of clock ticks in ClockIn phase
1.2385 + inline void SetTicksClockOut(TUint aParam); // Number of clock ticks in ClockOut phase
1.2386 + inline void SetResponseTimeOutInTicks(TUint aParam); // Timeout in bus clock ticks
1.2387 + inline void SetDataTimeOutInMcs(TUint aParam); // in microseconds
1.2388 + inline void SetBusyTimeOutInMcs(TUint aParam); // in microseconds
1.2389 + inline void SetOpCondBusyTimeout(TUint16 aData); // Units of 10mS
1.2390 + inline TInt OpCondBusyTimeout();
1.2391 + TUint iPollAttempts;
1.2392 +private:
1.2393 + TUint32 iModes;
1.2394 + TUint32 iUpdateMask;
1.2395 + TUint32 iClientMask;
1.2396 + TUint iTimeOutRetries;
1.2397 + TUint iCRCRetries;
1.2398 + TUint16 iUnlockRetries;
1.2399 + TUint16 iOpCondBusyTimeout; // Units of 10mS
1.2400 + TMMCBusConfig iBusConfig;
1.2401 + friend class DMMCStack;
1.2402 + };
1.2403 +
1.2404 +
1.2405 +class TMMCRCAPool
1.2406 +/**
1.2407 + MMC RCA Pool
1.2408 +*/
1.2409 + {
1.2410 +public:
1.2411 + inline TMMCRCAPool();
1.2412 + TRCA GetFreeRCA();
1.2413 + inline void LockRCA(TRCA);
1.2414 + inline void UnlockRCA(TRCA);
1.2415 + inline void ReleaseUnlocked();
1.2416 +private:
1.2417 + TUint32 iPool;
1.2418 + TUint32 iLocked;
1.2419 + };
1.2420 +
1.2421 +
1.2422 +class TMMCSessRing
1.2423 +/**
1.2424 + MMC session ring
1.2425 +*/
1.2426 + {
1.2427 +public:
1.2428 + TMMCSessRing();
1.2429 + inline TBool IsEmpty() const;
1.2430 + void Erase();
1.2431 + inline void SetMarker(); // Sets Marker into Point position
1.2432 + inline void AdvanceMarker(); // Moves Marker one position forward
1.2433 + inline void Point(); // Sets Point into Marker position
1.2434 + TBool Point(DMMCSession* aSessP); // Finds aSessP and sets Point to it
1.2435 + void Add(DMMCSession* aSessP); // Inserts aSessP before the Marker; Point moves to Marker
1.2436 + void Add(TMMCSessRing& aRing);
1.2437 + DMMCSession* Remove(); // Removes at Point; Point moves forward
1.2438 + void Remove(DMMCSession* aSessP); // Points aSessP first, then remove()
1.2439 + inline TUint Size() const;
1.2440 + inline operator DMMCSession*() const;
1.2441 + DMMCSession* operator++(TInt); // returns Point and moves it forward; stops at Marker
1.2442 +private:
1.2443 + DMMCSession* iPMark;
1.2444 + DMMCSession* iPoint;
1.2445 + DMMCSession* iPrevP;
1.2446 + TUint iSize;
1.2447 + };
1.2448 +
1.2449 +
1.2450 +//
1.2451 +// DMMCStack State Machine Functions are supported by TMMCStateMachine class
1.2452 +//
1.2453 +// The structure of state machine functions is assumed to be as follows
1.2454 +//
1.2455 +// TMMCErr DMMCStack::FunctionNameSMST( TAny* aPtr )
1.2456 +// { return( STATIC_CAST(DMMCStack*,aPtr)->FunctionNameSM() ); }
1.2457 +//
1.2458 +// TMMCErr DMMCStack::FunctionNameSM()
1.2459 +// {
1.2460 +// enum states {EStBegin=0, ..., EStEnd };
1.2461 +// DMMCSession& s = Session();
1.2462 +// TMMCStateMachine& m = Machine();
1.2463 +// const TMMCErr err = m.SetExitCode( 0 );
1.2464 +//
1.2465 +// for(;;)
1.2466 +// {
1.2467 +// switch(m.State())
1.2468 +// {
1.2469 +// case EStBegin:
1.2470 +// {
1.2471 +// ....
1.2472 +// }
1.2473 +// case EStNext:
1.2474 +// {
1.2475 +// .....
1.2476 +// }
1.2477 +// case EStEnd: break;
1.2478 +// default: Panic(...);
1.2479 +// }
1.2480 +// break;
1.2481 +// }
1.2482 +// return(m.Pop());
1.2483 +// }
1.2484 +//
1.2485 +// State Machine remembers the next state number and function name and goes there as soon
1.2486 +// as the control is returned to the session. To release the control and wait for the next
1.2487 +// re-entrance (which will happen immediately if the session is not blocked or, as soon as
1.2488 +// an asynchronous event removes the blocking condition), a state machine function has to
1.2489 +// return( 0 ); Returning non-zero exit code will result in the session being completed with
1.2490 +// that error code unless a caller state machine function has explicitly intercepted such
1.2491 +// an error with m.SetTraps( TMMCErr aMask ).
1.2492 +//
1.2493 +// To make a state machine function code more readable, the following macros are provided:
1.2494 +//
1.2495 +// SMF_NEXTS(nexts) - set the next state to "nexts"
1.2496 +// SMF_CALL(func) - invoke SM function "func", then go to the next state
1.2497 +// SMF_CALLWAIT(func) - the same as above, but sleep at the entry point
1.2498 +// SMF_CALLMYS(nexts,retst) - invoke current SM function at "nexts" entry point
1.2499 +// SMF_CALLMEWR(retst) - invoke me right here with return state retst
1.2500 +// SMF_INVOKES(func,nexts) - invoke SM function "func", then go to the state "nexts"
1.2501 +// SMF_INVOKEWAITS(func,nexts) - the same as above, but sleep at the entry point
1.2502 +// SMF_WAIT - sleep at the next state
1.2503 +// SMF_WAITS(nexts) - set next state to "nexts", then sleep
1.2504 +// SMF_RETURN(value) - return an error to the caller SM function
1.2505 +// SMF_EXIT - return to the caller SM function
1.2506 +// SMF_EXITWAIT - the same as above, but sleep at the exit point
1.2507 +// SMF_JUMP(func) - transfer the control to SM function "func"
1.2508 +// SMF_JUMPWAIT(func) - the same as above, but sleep at the entry point
1.2509 +// SMF_GOTONEXTS - goto the next state
1.2510 +// SMF_GOTOS(nexts) - set the next state to "nexts", then go to it
1.2511 +// SMF_STATE(sname) - declare the state name "sname"
1.2512 +// SMF_BPOINT(sname) - declare the state "sname" and sleep here if blocked statically
1.2513 +//
1.2514 +
1.2515 +/**
1.2516 +@publishedPartner
1.2517 +@released
1.2518 +
1.2519 +Declares the start of a state machine case switch statement.
1.2520 +
1.2521 +The macro assumes that the first state defined by the state machine
1.2522 +function is EStBegin.
1.2523 +
1.2524 +NOTES:
1.2525 +
1.2526 +- the code generates an opening curly brace that must be matched by
1.2527 +a closing curly brace. Typically, this is provided by the SMF_STATE or
1.2528 +the SMF_END macros.
1.2529 +
1.2530 +@see SMF_STATE
1.2531 +@see SMF_END
1.2532 +*/
1.2533 +#define SMF_BEGIN TMMCStateMachine& m=Machine();const TMMCErr err=m.SetExitCode(0);\
1.2534 + for(;;){switch(m.State()){case EStBegin:{if(err) (void)0;
1.2535 +
1.2536 +/**
1.2537 +@publishedPartner
1.2538 +@released
1.2539 +
1.2540 +Declares the end of a state machine case switch statement.
1.2541 +
1.2542 +The macro assumes that the last state defined by the state machine
1.2543 +function is EStEnd.
1.2544 +
1.2545 +NOTES:
1.2546 +
1.2547 +- the code generated assumes that there are earlier calls to SMF_BEGIN,
1.2548 +and zero or more calls to SMF_STATE.
1.2549 +
1.2550 +@see SMF_BEGIN
1.2551 +@see SMF_STATE
1.2552 +*/
1.2553 +#define SMF_END }case EStEnd:break;default:DMMCSocket::Panic(DMMCSocket::EMMCMachineState);}break;}\
1.2554 + return(m.Pop());
1.2555 +
1.2556 +
1.2557 +/**
1.2558 +@publishedPartner
1.2559 +@released
1.2560 +
1.2561 +Sets the next state when the current state machine
1.2562 +function is re-entered.
1.2563 +
1.2564 +@param nexts The next state to be entered in the current state machine.
1.2565 +*/
1.2566 +#define SMF_NEXTS(nexts) m.SetState(nexts);
1.2567 +
1.2568 +
1.2569 +/**
1.2570 +@publishedPartner
1.2571 +@released
1.2572 +
1.2573 +Pushes a state machine entry onto the stack, specifying the child state machine
1.2574 +function to be invoked.
1.2575 +
1.2576 +The child function will be entered at state 0 (EStBegin), when the state machine
1.2577 +is next dispatched.
1.2578 +
1.2579 +Control returns from this state machine function after completion of
1.2580 +all functions coded by this macro.
1.2581 +
1.2582 +@param func The child state machine function to be invoked.
1.2583 +*/
1.2584 +#define SMF_CALL(func) return(m.Push(func));
1.2585 +
1.2586 +
1.2587 +/**
1.2588 +@publishedPartner
1.2589 +@released
1.2590 +
1.2591 +Pushes a state machine entry onto the stack, specifying the child state machine
1.2592 +function to be invoked.
1.2593 +
1.2594 +The state machine is blocked before entry to the child function, but when
1.2595 +it becomes unblocked, the child function will be entered at state 0 (EStBegin)
1.2596 +when the state machine is next dispatched.
1.2597 +
1.2598 +Control returns from this state machine function after completion of
1.2599 +all functions coded by this macro.
1.2600 +
1.2601 +@param func The child state machine function to be invoked.
1.2602 +*/
1.2603 +#define SMF_CALLWAIT(func) return(m.Push(func,ETrue));
1.2604 +
1.2605 +
1.2606 +/**
1.2607 +@publishedPartner
1.2608 +@released
1.2609 +
1.2610 +Sets the next state for the current state machine function - control will
1.2611 +flow to this state on completion of all functions coded by this macro.
1.2612 +
1.2613 +The macro also pushes a state machine entry onto the stack, specifying
1.2614 +the CURRENT state machine function as the child state machine function to be
1.2615 +invoked, and sets the state in which this child state machine function will
1.2616 +be entered, when it gains control.
1.2617 +
1.2618 +NOTES:
1.2619 +
1.2620 +- the child function is the same as the parent function.
1.2621 +- the state machine is blocked on return from the current state machine function.
1.2622 +
1.2623 +@param nexts The state in which the child state machine function will
1.2624 + gain control.
1.2625 +@param retst The next state for the current state machine function.
1.2626 +*/
1.2627 +#define SMF_CALLMYS(nexts,retst) {m.SetState(retst);m.PushMe();m.SetState(nexts);continue;}
1.2628 +
1.2629 +
1.2630 +/**
1.2631 +@publishedPartner
1.2632 +@released
1.2633 +
1.2634 +Sets the next state for the current state machine function - control flows to
1.2635 +the next instruction on completion of all functions coded by this macro.
1.2636 +
1.2637 +The macro also pushes a state machine entry onto the stack, specifying
1.2638 +the CURRENT state machine function as the child state machine function to be
1.2639 +invoked. The child function will be entered at state 0 (EStBegin), when the state machine
1.2640 +is next dispatched.
1.2641 +
1.2642 +NOTES:
1.2643 +
1.2644 +- the child function is the same as the parent function.
1.2645 +- the state machine is blocked on return from the current state machine function.
1.2646 +
1.2647 +@param retst The next state for the current state machine function.
1.2648 +*/
1.2649 +#define SMF_CALLMEWR(retst) {m.SetState(retst);m.PushMe();}
1.2650 +
1.2651 +
1.2652 +/**
1.2653 +@publishedPartner
1.2654 +@released
1.2655 +
1.2656 +Sets the next state for the current state machine function.
1.2657 +
1.2658 +The macro also pushes a state machine entry onto the stack, specifying
1.2659 +the child state machine function to be
1.2660 +invoked. The child function will be entered at state 0 (EStBegin), when the state machine
1.2661 +is next dispatched.
1.2662 +
1.2663 +Control returns from the current state machine function after completion of
1.2664 +all functions coded by this macro.
1.2665 +
1.2666 +@param func The child state machine function to be invoked.
1.2667 +@param nexts The next state for the current state machine function.
1.2668 +*/
1.2669 +#define SMF_INVOKES(func,nexts) {m.SetState(nexts);return(m.Push(func));}
1.2670 +
1.2671 +
1.2672 +/**
1.2673 +@publishedPartner
1.2674 +@released
1.2675 +
1.2676 +Sets the next state for the current state machine function.
1.2677 +
1.2678 +The macro also pushes a state machine entry onto the stack, specifying
1.2679 +the child state machine function to be
1.2680 +invoked. The child function will be entered at state 0 (EStBegin), when the state machine
1.2681 +is next dispatched.
1.2682 +
1.2683 +Control returns from the current state machine function after completion of
1.2684 +all functions coded by this macro.
1.2685 +
1.2686 +NOTES:
1.2687 +
1.2688 +- the state machine is blocked on return from the current state machine function.
1.2689 +
1.2690 +@param func The child state machine function to be invoked.
1.2691 +@param nexts The next state for the current state machine function.
1.2692 +*/
1.2693 +#define SMF_INVOKEWAITS(func,nexts) {m.SetState(nexts);return(m.Push(func,ETrue));}
1.2694 +
1.2695 +
1.2696 +/**
1.2697 +@publishedPartner
1.2698 +@released
1.2699 +
1.2700 +Returns from the current state machine function, and the state machine then blocks (waits).
1.2701 +*/
1.2702 +#define SMF_WAIT return(0);
1.2703 +
1.2704 +
1.2705 +/**
1.2706 +@publishedPartner
1.2707 +@released
1.2708 +
1.2709 +Sets the next state for the current state machine function; control then returns
1.2710 +from the current state machine function, and the state machine blocks (waits).
1.2711 +
1.2712 +@param nexts The next state for the current state machine function.
1.2713 +*/
1.2714 +#define SMF_WAITS(nexts) return(m.SetState(nexts));
1.2715 +
1.2716 +
1.2717 +/**
1.2718 +@publishedPartner
1.2719 +@released
1.2720 +
1.2721 +Returns the specified error value to the calling (parent) state machine function.
1.2722 +
1.2723 +@param value The error value to be returned.
1.2724 +*/
1.2725 +#define SMF_RETURN(value) {m.Pop();return(value);}
1.2726 +
1.2727 +
1.2728 +/**
1.2729 +@publishedPartner
1.2730 +@released
1.2731 +
1.2732 +Returns to the calling state machine function.
1.2733 +*/
1.2734 +#define SMF_EXIT break;
1.2735 +
1.2736 +
1.2737 +/**
1.2738 +@publishedPartner
1.2739 +@released
1.2740 +
1.2741 +Returns to the calling state machine function, and the state machine blocks (waits).
1.2742 +*/
1.2743 +#define SMF_EXITWAIT return(m.Pop(ETrue));
1.2744 +
1.2745 +
1.2746 +/**
1.2747 +@publishedPartner
1.2748 +@released
1.2749 +
1.2750 +Transfers control to the specified state machine function.
1.2751 +
1.2752 +NOTES:
1.2753 +
1.2754 +- this function is executed at the same stack entry level as the current state machine function.
1.2755 +
1.2756 +@param func The state machine function to which control is to be transferred.
1.2757 +*/
1.2758 +#define SMF_JUMP(func) return(m.Jump(func));
1.2759 +
1.2760 +
1.2761 +/**
1.2762 +@publishedPartner
1.2763 +@released
1.2764 +
1.2765 +Transfers control to the specified state machine function, and waits
1.2766 +at its entry point.
1.2767 +
1.2768 +@param func The state machine function to which control is to be transferred.
1.2769 +*/
1.2770 +#define SMF_JUMPWAIT(func) return(m.Jump(func,ETrue));
1.2771 +
1.2772 +
1.2773 +/**
1.2774 +@publishedPartner
1.2775 +@released
1.2776 +
1.2777 +Goes to the next state.
1.2778 +*/
1.2779 +#define SMF_GOTONEXTS continue;
1.2780 +
1.2781 +
1.2782 +/**
1.2783 +@publishedPartner
1.2784 +@released
1.2785 +
1.2786 +Sets the next state and then goes to that state.
1.2787 +
1.2788 +@param nexts The next state.
1.2789 +*/
1.2790 +#define SMF_GOTOS(nexts) {m.SetState(nexts);continue;}
1.2791 +
1.2792 +
1.2793 +/**
1.2794 +@publishedPartner
1.2795 +@released
1.2796 +
1.2797 +Declares the name of a state.
1.2798 +
1.2799 +This is used to generate a case statement based on the state name.
1.2800 +
1.2801 +@param sname The state name.
1.2802 +*/
1.2803 +#define SMF_STATE(sname) }case sname:{
1.2804 +
1.2805 +
1.2806 +/**
1.2807 +@publishedPartner
1.2808 +@released
1.2809 +
1.2810 +Declares the name of a state, and sleeps here
1.2811 +if blocked statically.
1.2812 +
1.2813 +@param sname The state name.
1.2814 +*/
1.2815 +#define SMF_BPOINT(sname) }case sname: if(StaticBlocks()) return(m.SetState(sname));{
1.2816 +
1.2817 +
1.2818 +
1.2819 +
1.2820 +class TMMCStateMachine
1.2821 +/**
1.2822 + The MultiMediaCard state machine.
1.2823 +
1.2824 + @publishedPartner
1.2825 + @released
1.2826 +*/
1.2827 + {
1.2828 +public:
1.2829 + inline void Setup(TMMCErr (*anEntry)(TAny*), TAny* aContextP);
1.2830 + IMPORT_C void Reset();
1.2831 + IMPORT_C TMMCErr Dispatch();
1.2832 + inline TMMCErr ExitCode();
1.2833 + inline TMMCErr SetExitCode(TMMCErr aCode);
1.2834 + inline TUint State();
1.2835 + inline TMMCErr SetState(TUint aState);
1.2836 + inline void SuppressSuspension();
1.2837 + inline void SetTraps(TMMCErr aMask);
1.2838 + inline void ResetTraps();
1.2839 + inline void Abort();
1.2840 + inline TMMCErr Pop(TBool aSuspend=EFalse);
1.2841 + inline TMMCErr PushMe();
1.2842 + IMPORT_C TMMCErr Push(TMMCErr (*anEntry)(TAny*), TBool aSuspend=EFalse);
1.2843 + IMPORT_C TMMCErr Jump(TMMCErr (*anEntry)(TAny*), TBool aSuspend=EFalse);
1.2844 +private:
1.2845 + class TMMCMachineStackEntry
1.2846 + {
1.2847 + public:
1.2848 + TMMCErr (*iFunction)(TAny*);
1.2849 + TUint iState;
1.2850 + TMMCErr iTrapMask;
1.2851 + };
1.2852 + TBool iAbort;
1.2853 + TBool iSuspend;
1.2854 + TAny* iContextP;
1.2855 + TMMCErr iExitCode;
1.2856 + TInt iSP;
1.2857 + TMMCMachineStackEntry iStack[KMaxMMCMachineStackDepth];
1.2858 + };
1.2859 +
1.2860 +class TMMCCallBack
1.2861 +/**
1.2862 + This class is used to notify the request completion as a callback function for the clients of DMMCSession.
1.2863 + The callback function will be called on session completion.
1.2864 + Callback function is used to indicate Asynchronous Completion.
1.2865 +
1.2866 + @see DMMCSession
1.2867 + @publishedPartner
1.2868 + @released
1.2869 +*/
1.2870 + {
1.2871 +public:
1.2872 + inline TMMCCallBack();
1.2873 + inline TMMCCallBack(void (*aFunction)(TAny* aPtr));
1.2874 + inline TMMCCallBack(void (*aFunction)(TAny* aPtr), TAny* aPtr);
1.2875 + inline void CallBack() const;
1.2876 +public:
1.2877 + /**
1.2878 + A pointer to the callback function.
1.2879 + */
1.2880 + void (*iFunction)(TAny* aPtr);
1.2881 +
1.2882 + /**
1.2883 + A pointer that is passed to the callback function when
1.2884 + the callback function is called.
1.2885 + */
1.2886 + TAny* iPtr;
1.2887 + };
1.2888 +
1.2889 +// DMMCStack serves an incoming queue of session requests.
1.2890 +// Each queue element is represented by an instance of the following class
1.2891 +
1.2892 +typedef TMMCErr (*TMMCSMSTFunc)(TAny*);
1.2893 +
1.2894 +class DMMCSession : public DBase
1.2895 +/**
1.2896 + Provides the main interface between the client and the MMC Socket, allowing commands and responses
1.2897 + to be processed asynchronously on the stack.
1.2898 +
1.2899 + Each client creates it own instance of this class. It is then able to make MultiMediaCard requests
1.2900 + on the selected stack by configuring the DMMCSession object with relevant information for the request
1.2901 + and then submitting (or engaging) this session object.
1.2902 +
1.2903 + The session is used to pass commands either to the entire stack (a broadcast command), or to individual
1.2904 + cards in the stack. The class contains functions for initiating macro functions as laid down by the
1.2905 + MultiMediaCard Association (MMCA) as well as lower level functions allowing a client to control the
1.2906 + stack in a more explicit manner.
1.2907 +
1.2908 + All requests on the MultiMediaCard stack which involve bus activity are inherently asynchronous. When
1.2909 + creating a DMMCSession object, a client supplies a call-back function as part of the constructor.
1.2910 + Once a client has engaged a session on the stack, it is informed of the completion of the request by
1.2911 + the Controller calling this call-back function.
1.2912 +
1.2913 + @publishedPartner
1.2914 + @released
1.2915 +*/
1.2916 + {
1.2917 +public:
1.2918 + IMPORT_C virtual ~DMMCSession();
1.2919 + IMPORT_C DMMCSession(const TMMCCallBack& aCallBack);
1.2920 +
1.2921 + // Object initialisation
1.2922 + inline void SetStack(DMMCStack* aStackP);
1.2923 + IMPORT_C void SetCard(TMMCard* aCardP);
1.2924 +
1.2925 + // Control macros setup
1.2926 + inline void SetupCIMUpdateAcq();
1.2927 + inline void SetupCIMInitStack();
1.2928 + inline void SetupCIMCheckStack();
1.2929 + inline void SetupCIMSetupCard();
1.2930 + inline void SetupCIMLockStack();
1.2931 + inline void SetupCIMInitStackAfterUnlock();
1.2932 + inline void SetupCIMAutoUnlock();
1.2933 +
1.2934 + // Data transfer macros setup
1.2935 + IMPORT_C void SetupCIMReadBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP);
1.2936 + IMPORT_C void SetupCIMWriteBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP);
1.2937 + IMPORT_C void SetupCIMReadMBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen);
1.2938 + IMPORT_C void SetupCIMWriteMBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen);
1.2939 + IMPORT_C void SetupCIMEraseSector(TMMCArgument aDevAddr, TUint32 aLength);
1.2940 + IMPORT_C void SetupCIMEraseGroup(TMMCArgument aDevAddr, TUint32 aLength);
1.2941 + IMPORT_C void SetupCIMReadIO(TUint8 aRegAddr, TUint32 aLength, TUint8* aMemoryP);
1.2942 + IMPORT_C void SetupCIMWriteIO(TUint8 aRegAddr, TUint32 aLength, TUint8* aMemoryP);
1.2943 + IMPORT_C void SetupCIMLockUnlock(TUint32 aLength, TUint8* aMemoryP);
1.2944 +
1.2945 + // Data transfer macros setup (block mode)
1.2946 + inline void SetupCIMReadBlock(TMMCArgument aBlockAddr, TUint8* aMemoryP, TUint32 aBlocks = 1);
1.2947 + inline void SetupCIMWriteBlock(TMMCArgument aBlockAddr, TUint8* aMemoryP, TUint32 aBlocks = 1);
1.2948 + inline void SetupCIMEraseMSector(TMMCArgument aBlockAddr, TUint32 aBlocks = 1);
1.2949 + inline void SetupCIMEraseMGroup(TMMCArgument aBlockAddr, TUint32 aBlocks = 1);
1.2950 +
1.2951 + // Raw commands (must be used in the locked bus state only)
1.2952 + // Known commands with or without (with a default) argument
1.2953 + IMPORT_C void SetupCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument=0);
1.2954 +
1.2955 + // Generic unknown command with unknown response type
1.2956 + IMPORT_C void SetupRSCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument,
1.2957 + TUint32 aResponseLength, TMMCCommandTypeEnum aCommandType=ECmdTypeUK,
1.2958 + TMMCResponseTypeEnum aResponseType=ERespTypeUnknown,
1.2959 + TUint32 aCommandClass=KMMCCmdClassNone);
1.2960 +
1.2961 + // Generic data transfer command
1.2962 + IMPORT_C void SetupDTCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument,
1.2963 + TUint32 aTotalLength, TUint8* aMemoryAddress, TUint32 aBlockLength=0,
1.2964 + TBool aStopTransmission=EFalse, TMMCCmdDirEnum aDir=EDirNone,
1.2965 + TUint32 aCommandClass=KMMCCmdClassNone);
1.2966 + // Actions
1.2967 + IMPORT_C TInt Engage(); // Enque session for execution
1.2968 + inline void UnlockStack(); // Unlock the bus
1.2969 + inline void Stop(); // Signal session to complete (stop and complete)
1.2970 + inline void Abort(); // Abort only (no completion)
1.2971 +
1.2972 + // Info retrieval
1.2973 + IMPORT_C TInt EpocErrorCode() const; // Derived from MMCExitCode and LastStatus
1.2974 + inline TMMCSessionTypeEnum SessionID() const;
1.2975 + inline DMMCStack* StackP() const; // DMMCStack serving this session
1.2976 + inline TMMCard* CardP() const; // The current card pointer
1.2977 + inline TBool IsEngaged() const; // Session is being served by DMMCStack
1.2978 + inline TMMCErr MMCExitCode() const; // MMC specific error code returned by DMMCStack
1.2979 + inline TMMCStatus LastStatus() const; // Last R1 response received from the card
1.2980 + inline TUint32 BytesTransferred() const;// The actual amount of data transferred in this session
1.2981 + inline TUint8* ResponseP(); // Current command response (&iCommand[iCmdSP].iResponse)
1.2982 + inline TUint32 EffectiveModes() const; // Modes which DMMCStack will consider as effective
1.2983 + //
1.2984 + inline void ResetCommandStack();
1.2985 +private:
1.2986 + void SetupCIMControl(TInt aSessNum);
1.2987 +protected:
1.2988 + IMPORT_C virtual TMMCSMSTFunc GetMacro(TInt aSessNum) const;
1.2989 + inline void Block(TUint32 aFlag);
1.2990 + inline void UnBlock(TUint32 aFlag, TMMCErr anExitCode);
1.2991 +private:
1.2992 +#ifdef __EPOC32__
1.2993 + static void PollTimerCallBack(TAny* aSessP);
1.2994 + static void RetryTimerCallBack(TAny* aSessP);
1.2995 + static void ProgramTimerCallBack(TAny* aSessP);
1.2996 +#endif
1.2997 + inline void SwapMe();
1.2998 + void SynchBlock(TUint32 aFlag);
1.2999 + void SynchUnBlock(TUint32 aFlag);
1.3000 +public:
1.3001 + static const TMMCCommandSpec& FindCommandSpec(const TMMCIdxCommandSpec aSpecs[], TInt aIdx);
1.3002 + IMPORT_C void FillCommandDesc();
1.3003 + IMPORT_C void FillCommandDesc(TMMCCommandEnum aCommand);
1.3004 + IMPORT_C void FillCommandDesc(TMMCCommandEnum aCommand, TMMCArgument anArgument);
1.3005 + IMPORT_C void FillCommandArgs(TMMCArgument anArgument, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen);
1.3006 + inline TMMCCommandDesc& Command(); // The current command descriptor
1.3007 +
1.3008 + inline void PushCommandStack();
1.3009 + inline void PopCommandStack();
1.3010 +
1.3011 + // Methods for double-buffered data transfer:
1.3012 + inline TBool RequestMoreData();
1.3013 + inline void EnableDoubleBuffering(TUint32 aNumBlocks); /**< @internalTechnology */
1.3014 + inline void SetDataTransferCallback(TMMCCallBack& aCallback); /**< @internalTechnology */
1.3015 + inline void MoreDataAvailable(TUint32 aNumBlocks, TUint8* aMemoryP, TInt aError); /**< @internalTechnology */
1.3016 +public:
1.3017 + /**
1.3018 + The last R1 response.
1.3019 + */
1.3020 + TMMCStatus iLastStatus;
1.3021 +
1.3022 + /**
1.3023 + A pointer to the card object.
1.3024 + */
1.3025 + TMMCard* iCardP; // Pointer to Card Info object
1.3026 + IMPORT_C TRCA CardRCA(); // Checks that card is still ready - otherwise returns 0
1.3027 + TMMCSessionTypeEnum iSessionID;
1.3028 +private:
1.3029 + DMMCSession* iLinkP; //
1.3030 +protected:
1.3031 + TMMCCallBack iCallBack; // Where to report the completion
1.3032 +private:
1.3033 + DMMCStack* iStackP; // Pointer to Stack Controller
1.3034 + TCID iCID; // Card ID to ensure we are still talking to the same card
1.3035 + TUint32 iBytesTransferred; // The actual amount of data transferred in this session
1.3036 + TMMCErr iMMCExitCode; // State Machine exit code (MMC specific)
1.3037 +public:
1.3038 + /**
1.3039 + Session state flags (synchronous).
1.3040 + */
1.3041 + TUint32 iState;
1.3042 +private:
1.3043 + TUint iInitContext; // Stack Initialiser pass number
1.3044 + TUint iGlobalRetries; // Global retry counter
1.3045 +
1.3046 + // Asynchronous flags analysed by scheduler
1.3047 + TBool volatile iDoAbort; // Marks the session for abort
1.3048 + TBool volatile iDoStop; // Stop the session as soon as it's safe
1.3049 + TBool volatile iDoComplete; // Completion callback is now to be invoked
1.3050 + TBool iBrokenLock; // Stack lock is broken by force major
1.3051 + //
1.3052 + TUint32 iBlockOn; // blocking reasons
1.3053 + TInt iCmdSP; // Current Command stack index
1.3054 +
1.3055 + TMMCCommandDesc iCommand[KMaxMMCCommandStackDepth]; // Command stack
1.3056 +
1.3057 + TMMCCallBack iDataTransferCallback; // A callback function, used to request more data when performing double-buffering
1.3058 +
1.3059 + TUint32 iSpare[22]; // Spare data (stolen from iCommand)
1.3060 +
1.3061 + TMMCStateMachine iMachine; // State Machine context
1.3062 +#ifdef __EPOC32__
1.3063 + NTimer iPollTimer;
1.3064 + NTimer iRetryTimer;
1.3065 + NTimer iProgramTimer;
1.3066 +#endif
1.3067 +public:
1.3068 + TMMCStackConfig iConfig; // Client configuration parameters
1.3069 + friend class DMMCStack;
1.3070 + friend class TMMCSessRing;
1.3071 + friend class TMMCardArray;
1.3072 + };
1.3073 +
1.3074 +
1.3075 +class DMMCStack : public DBase
1.3076 +/**
1.3077 + This object controls access to the MultiMediaCard stack.
1.3078 + The DMMCSocket owns an instance of this class for the MultiMediaCard stack that it manages.
1.3079 +
1.3080 + @publishedPartner
1.3081 + @released
1.3082 +*/
1.3083 + {
1.3084 +public:
1.3085 + /** extension interfaces Ids */
1.3086 + enum TInterfaceId
1.3087 + {
1.3088 + KInterfaceMachineInfo,
1.3089 + KInterfaceSwitchToLowVoltageSM,
1.3090 + KInterfaceSetBusWidth,
1.3091 + KInterfaceDemandPagingInfo,
1.3092 + KInterfaceCancelSession,
1.3093 + KInterfaceDoWakeUpSM
1.3094 + };
1.3095 +
1.3096 + /** generic interface */
1.3097 + class MInterface
1.3098 + {
1.3099 + public:
1.3100 + virtual TInt Function() = 0;
1.3101 + };
1.3102 +
1.3103 + /**
1.3104 + Demand paging support
1.3105 + @see KInterfaceDemandPagingInfo
1.3106 + */
1.3107 + class TDemandPagingInfo
1.3108 + {
1.3109 + public:
1.3110 + const TInt* iPagingDriveList;
1.3111 + TInt iDriveCount;
1.3112 + TUint iPagingType;
1.3113 + TInt iReadShift;
1.3114 + TUint iNumPages;
1.3115 + TBool iWriteProtected;
1.3116 + TInt iSlotNumber;
1.3117 + TUint iSpare[2];
1.3118 + } ;
1.3119 + /**
1.3120 + * An optional interface implemented by the PSL for returning demand-paging information.
1.3121 + * @see KInterfaceDemandPagingInfo
1.3122 + */
1.3123 + class MDemandPagingInfo
1.3124 + {
1.3125 + public:
1.3126 + virtual TInt DemandPagingInfo(TDemandPagingInfo& aInfo) = 0;
1.3127 + };
1.3128 +
1.3129 + /**
1.3130 + * An optional interface State machine implemented by the PSL for handling asynchronous VccCore powerup
1.3131 + * @see KInterfaceDoWakeUpSM
1.3132 + */
1.3133 + class MDoWakeUp
1.3134 + {
1.3135 + public:
1.3136 + virtual TMMCErr DoWakeUpSM()=0;
1.3137 + };
1.3138 +
1.3139 +
1.3140 +public:
1.3141 + IMPORT_C DMMCStack(TInt aBus, DMMCSocket* aSocket);
1.3142 + IMPORT_C virtual TInt Init();
1.3143 + //
1.3144 + // Actions
1.3145 + inline void ReportPowerUp();
1.3146 + inline void ReportPowerDown();
1.3147 + inline void Reset(); // Discard all requests and clear up
1.3148 + inline void CompleteAll(TMMCErr aCode); // Complete all operations with an error
1.3149 + inline void CancelSession(DMMCSession* aSession);
1.3150 +
1.3151 + IMPORT_C void PowerUpStack();
1.3152 + IMPORT_C void PowerDownStack();
1.3153 + void QSleepStack();
1.3154 + IMPORT_C TInt Stop(TMMCard* aCardP);
1.3155 + //
1.3156 + // Inquiries
1.3157 + inline TUint MaxCardsInStack() const;
1.3158 + inline TMMCard* CardP(TUint aCardNumber);
1.3159 + inline DMMCSocket* MMCSocket() const;
1.3160 + inline TMMCPasswordStore* PasswordStore() const;
1.3161 + inline TBool InitStackInProgress() const;
1.3162 + inline TBool HasSessionsQueued() const;
1.3163 + inline TBool HasCardsPresent();
1.3164 + inline void BufferInfo(TUint8*& aBuf, TInt& aBufLen, TInt& aMinorBufLen);
1.3165 + inline TInt DemandPagingInfo(TDemandPagingInfo& aInfo);
1.3166 + inline TBool StackRunning() const;
1.3167 +
1.3168 +
1.3169 +#ifdef __EPOC32__
1.3170 +
1.3171 + /**
1.3172 + Defines the period for the poll timer.
1.3173 +
1.3174 + The poll timer is used by the generic layer for platforms
1.3175 + that do not provide an interrupt to indicate
1.3176 + when programming mode is finished.
1.3177 +
1.3178 + @return The poll timer period, in milliseconds.
1.3179 + */
1.3180 + virtual TInt ProgramPeriodInMilliSeconds() const =0;
1.3181 +#endif
1.3182 +
1.3183 + /**
1.3184 + * Calculates the minimum range that must be read off a card, an optimisation that takes advantage
1.3185 + * of the partial read feature found on some cards. It takes the logical range that the media driver
1.3186 + * wants to read from the card, and increases it to take into account factors such as FIFO width and
1.3187 + * minimum DMA transfer size.
1.3188 + * @param aCard A pointer to the MMC Card
1.3189 + * @param aStart The required start position
1.3190 + * @param aEnd The required end position
1.3191 + * @param aPhysStart The adjusted start position
1.3192 + * @param aPhysEnd The adjusted end position
1.3193 + */
1.3194 + virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const =0;
1.3195 +
1.3196 + /**
1.3197 + * Returns the details of the buffer allocated by the socket for data transfer operations. The buffer
1.3198 + * is allocated and configured at the variant layer to allow , for example, contiguous pages to be
1.3199 + * allocated for DMA transfers.
1.3200 + * @param aMDBuf A pointer to the allocated buffer
1.3201 + * @param aMDBufLen The length of the allocated buffer
1.3202 + */
1.3203 + virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen) =0;
1.3204 +
1.3205 + /**
1.3206 + * Gets the platform specific configuration information.
1.3207 + * @see TMMCMachineInfo
1.3208 + */
1.3209 + virtual void MachineInfo(TMMCMachineInfo& aMachineInfo) =0;
1.3210 +
1.3211 + /**
1.3212 + * Creates the session object
1.3213 + */
1.3214 + IMPORT_C virtual DMMCSession* AllocSession(const TMMCCallBack& aCallBack) const;
1.3215 +
1.3216 +protected:
1.3217 + // Platform layer service
1.3218 + inline TMMCBusConfig& BusConfig();
1.3219 + inline TMMCBusConfig& MasterBusConfig();
1.3220 + inline DMMCSession& Session(); // Current session
1.3221 + inline TMMCCommandDesc& Command(); // Current command descriptor of current session
1.3222 + inline TMMCStateMachine& Machine(); // State machine of current session
1.3223 + inline void BlockCurrentSession(TUint32 aFlag);
1.3224 + inline void UnBlockCurrentSession(TUint32 aFlag, TMMCErr anExitCode);
1.3225 + inline void ReportInconsistentBusState();
1.3226 + inline void ReportASSPEngaged();
1.3227 + inline void ReportASSPDisengaged();
1.3228 + inline TRCA CurrentSessCardRCA(); // Checks that card is still ready - otherwise returns 0
1.3229 + inline void CurrentSessPushCmdStack();
1.3230 + inline void CurrentSessPopCmdStack();
1.3231 + inline void CurrentSessFillCmdDesc(TMMCCommandEnum aCommand);
1.3232 + inline void CurrentSessFillCmdDesc(TMMCCommandEnum aCommand,TMMCArgument anArgument);
1.3233 + inline void CurrentSessFillCmdArgs(TMMCArgument anArgument,TUint32 aLength,TUint8* aMemoryP,TUint32 aBlkLen);
1.3234 + inline TRCA SelectedCard() const;
1.3235 + inline void YieldStack(TMMCCommandTypeEnum aCommand);
1.3236 +
1.3237 + void DoSetClock(TUint32 aClock);
1.3238 + void DoSetBusWidth(TUint32 aBusWidth);
1.3239 + TBusWidth BusWidthEncoding(TInt aBusWidth) const;
1.3240 + TUint MaxTranSpeedInKilohertz(const TMMCard& aCard) const;
1.3241 +
1.3242 + // Stack service provided by platform/variant layer.
1.3243 +
1.3244 + /**
1.3245 + * Returns the default master settings for the platform.
1.3246 + * @param aConfig A TMMCBusConfig reference to be filled in with the default settings.
1.3247 + * @param aClock The requested clock frequency (may be ignored if the hardware cannot support it).
1.3248 + */
1.3249 + virtual void SetBusConfigDefaults(TMMCBusConfig& aConfig, TUint aClock)=0;
1.3250 +
1.3251 + /**
1.3252 + * Switches from identification mode of operation to data transfer mode operation.
1.3253 + *
1.3254 + * Note that at this point the clock information in iBusConfig will not have been updated
1.3255 + * to the new data transfer rate. This function should generally just switch from open drain
1.3256 + * to push-pull bus mode - with the clock rate being changed at the start of IssueMMCCommandSM,
1.3257 + * where iBusConfig will be valid.
1.3258 + */
1.3259 + virtual void InitClockOff()=0;
1.3260 +
1.3261 + /**
1.3262 + * Stop all activities on the host stack.
1.3263 + *
1.3264 + * This will generally perform the same operations as for ASSPDisengage() but this will additionally
1.3265 + * turn off the clock to the hardware interface and release any requested power requirements made on
1.3266 + * the power model. (That is release any power requirements made as part of the InitClockOnSM() function).
1.3267 + *
1.3268 + * Called from the platform independent layer when it is required to immediately cancel any PSL asynchronous
1.3269 + * activity because the current session has been aborted.
1.3270 + *
1.3271 + * This function should normally include a call to ReportAsspDisengaged() at the end, to report to the PIL
1.3272 + * that the PSL level resources have been disengaged.
1.3273 + */
1.3274 + virtual void ASSPReset()=0;
1.3275 +
1.3276 + /**
1.3277 + * Called each time a session which has engaged PSL resources has completed or has been aborted.
1.3278 + *
1.3279 + * This should disable any activities which were required to perform the session just completed/aborted.
1.3280 + * It shouldn't however turn off the clock to the hardware interface (which will be turned off instead
1.3281 + * by the inactivity timer). This typically disables DMA and interface interrupts and forces the hardware
1.3282 + * interface into idle.
1.3283 + *
1.3284 + * This function should normally include a call to ReportAsspDisengaged() at the end, to report to the PIL
1.3285 + * that the PSL level resources have been disengaged.
1.3286 + */
1.3287 + virtual void ASSPDisengage()=0;
1.3288 +
1.3289 + /**
1.3290 + * Called as part of the bus power down sequence. It stops all activities on the host stack, turns off the clock
1.3291 + * to the hardware interface and releases any requested power requirements made on the power model
1.3292 + * (i.e. very often a straight call of ASSPReset()).
1.3293 + *
1.3294 + * This shouldn't turn off the MMC PSU as this will be performed immediately afterwards by the PSU class.
1.3295 + */
1.3296 + virtual void DoPowerDown()=0;
1.3297 +
1.3298 + IMPORT_C virtual TBool CardDetect(TUint aCardNumber);
1.3299 + IMPORT_C virtual TBool WriteProtected(TUint aCardNumber);
1.3300 + //
1.3301 + // State Machine functions implemented in platform layer.
1.3302 +
1.3303 + /**
1.3304 + * Called as a child function at the start of the CIM_UPDATE_ACQ macro state machine.
1.3305 + *
1.3306 + * It should perform the necessary PSL level actions associated with powering up the bus. This includes
1.3307 + * turning on the MMC PSU. However, the hardware interface clock should not be turned on as part of this function.
1.3308 + *
1.3309 + * If the Controller has to request power resources from the power model (e.g a fast system clock required all the
1.3310 + * time the bus is powered) then this state machine function can be used to asynchronously wait for this resource
1.3311 + * to become available.
1.3312 + *
1.3313 + * Upon completion, DMMCStack::ReportPowerUp() should be called.
1.3314 + *
1.3315 + * @return KMMCErrNone if completed successfully or standard TMMCErr code otherwise
1.3316 + */
1.3317 + virtual TMMCErr DoPowerUpSM()=0;
1.3318 +
1.3319 + /**
1.3320 + * Turns on the clock to the hardware interface.
1.3321 + *
1.3322 + * This state machine function is called as a child function as part of the CIM_UPDATE_ACQ macro state machine.
1.3323 + *
1.3324 + * It is implemented as a state machine function since it may be necessary to include a short delay after the
1.3325 + * clock has been turned on to allow it to stabilise, or in some cases it may be necessary to wait for a power
1.3326 + * resource to become available.
1.3327 + *
1.3328 + * This function should normally include a call to ReportAsspEngaged() at the start, to report to the PIL that the PSL
1.3329 + * level resources have been engaged.
1.3330 + *
1.3331 + * @return KMMCErrNone if completed successfully or standard TMMCErr code otherwise
1.3332 + */
1.3333 + virtual TMMCErr InitClockOnSM()=0;
1.3334 +
1.3335 + /**
1.3336 + * Executes a single command over the bus.
1.3337 + *
1.3338 + * The input parameters are passed via the current command descriptor on the session's command stack
1.3339 + * (TMMCCommandDesc class), which specifies the type of command, response type, arguments etc..
1.3340 + *
1.3341 + * @return KMMCErrNone if completed successfully or standard TMMCErr code otherwise
1.3342 + */
1.3343 + IMPORT_C virtual TMMCErr IssueMMCCommandSM()=0;
1.3344 +
1.3345 + TBool StaticBlocks();
1.3346 +
1.3347 + /**
1.3348 + * Indicates that the PSL should change the bus width.
1.3349 + * Must be implemented by the Platform Specific Layer if MMCV4 4/8-bit bus mode is required
1.3350 + */
1.3351 + IMPORT_C virtual void SetBusWidth(TUint32 aBusWidth);
1.3352 +
1.3353 + /**
1.3354 + * Retrieves a TMMCMachineInfoV4 from the PSL
1.3355 + * Must be implemented by the Platform Specific Layer if MMCV4 support is required
1.3356 + */
1.3357 +public:
1.3358 + IMPORT_C virtual void MachineInfo(TDes8& aMachineInfo);
1.3359 +
1.3360 +protected:
1.3361 + /**
1.3362 + * Switches the MMC bus to low voltage mode
1.3363 + */
1.3364 + TMMCErr SwitchToLowVoltageSM();
1.3365 +
1.3366 +
1.3367 +private:
1.3368 + //
1.3369 + // Session service
1.3370 + void Add(DMMCSession* aSessP);
1.3371 + void Abort(DMMCSession* aSessP);
1.3372 + void Stop(DMMCSession* aSessP);
1.3373 + void UnlockStack(DMMCSession* aSessP);
1.3374 + void MarkComplete(DMMCSession* aSessP, TMMCErr anExitCode);
1.3375 + //
1.3376 + // Stack control and operations support
1.3377 + // Scheduler and its supplementary functions
1.3378 + enum TMMCStackSchedStateEnum
1.3379 + {
1.3380 + ESchedContinue=0,
1.3381 + ESchedLoop=1,
1.3382 + ESchedExit,
1.3383 + ESchedChooseJob
1.3384 + };
1.3385 + void Scheduler(volatile TBool& aFlag);
1.3386 + void DoSchedule();
1.3387 + TMMCStackSchedStateEnum SchedGetOnDFC();
1.3388 + void SchedSetContext(DMMCSession* aSessP);
1.3389 + void SchedDoAbort(DMMCSession* aSessP);
1.3390 + TMMCStackSchedStateEnum SchedResolveStatBlocks(DMMCSession* aSessP);
1.3391 + TMMCStackSchedStateEnum SchedGroundDown(DMMCSession* aSessP, TMMCErr aReason);
1.3392 + TMMCStackSchedStateEnum SchedEnqueStackSession(TMMCSessionTypeEnum aSessID);
1.3393 + void SchedGrabEntries();
1.3394 + void SchedDisengage();
1.3395 + TBool SchedAllowDirectCommands(DMMCSession* aSessP);
1.3396 + TBool SchedYielding(DMMCSession* aSessP);
1.3397 + inline TMMCStackSchedStateEnum SchedAbortPass();
1.3398 + inline TMMCStackSchedStateEnum SchedCompletionPass();
1.3399 + inline TMMCStackSchedStateEnum SchedInitStack();
1.3400 + inline TMMCStackSchedStateEnum SchedSleepStack();
1.3401 + inline TBool SchedPreemptable();
1.3402 + inline TMMCStackSchedStateEnum SchedSession();
1.3403 + inline TMMCStackSchedStateEnum SchedChooseJob();
1.3404 + //
1.3405 + // Miscellaneous SM function service
1.3406 +protected:
1.3407 + void MergeConfig(DMMCSession* aSessP);
1.3408 +private:
1.3409 + inline void DeselectsToIssue(TUint aNumber);
1.3410 +
1.3411 + // Static Completion routines.
1.3412 + static void StackDFC(TAny* aStackP);
1.3413 + static void StackSessionCBST(TAny* aStackP);
1.3414 + TInt StackSessionCB();
1.3415 + static void AutoUnlockCBST(TAny *aStackP);
1.3416 + TInt AutoUnlockCB();
1.3417 +
1.3418 +protected:
1.3419 + IMPORT_C void Block(DMMCSession* aSessP, TUint32 aFlag);
1.3420 + IMPORT_C void UnBlock(DMMCSession* aSessP, TUint32 aFlag, TMMCErr anExitCode);
1.3421 +
1.3422 +protected:
1.3423 + // State machines. The adapter functions just call the non-static versions.
1.3424 + // Top-level state machines.
1.3425 + static TMMCErr NakedSessionSMST(TAny* aStackP); // ECIMNakedSession
1.3426 + inline TMMCErr NakedSessionSM();
1.3427 + static TMMCErr CIMUpdateAcqSMST(TAny* aStackP); // ECIMUpdateAcq
1.3428 + TMMCErr CIMUpdateAcqSM();
1.3429 + static TMMCErr CIMInitStackSMST(TAny* aStackP); // ECIMInitStack
1.3430 + inline TMMCErr CIMInitStackSM();
1.3431 + static TMMCErr CIMCheckStackSMST(TAny* aStackP); // ECIMCheckStack
1.3432 + inline TMMCErr CIMCheckStackSM();
1.3433 + static TMMCErr CIMSetupCardSMST(TAny* aStackP); // ECIMSetupCard
1.3434 + inline TMMCErr CIMSetupCardSM();
1.3435 + IMPORT_C static TMMCErr CIMReadWriteBlocksSMST(TAny* aStackP); // ECIMReadBlock, ECIMWriteBlock, ECIMReadMBlock, ECIMWriteMBlock
1.3436 + IMPORT_C virtual TMMCErr CIMReadWriteBlocksSM();
1.3437 + static TMMCErr CIMEraseSMST(TAny* aStackP); // ECIMEraseSector, ECIMEraseGroup
1.3438 + inline TMMCErr CIMEraseSM();
1.3439 + static TMMCErr CIMReadWriteIOSMST(TAny* aStackP); // ECIMReadIO, ECIMWriteIO
1.3440 + inline TMMCErr CIMReadWriteIOSM();
1.3441 + static TMMCErr CIMLockUnlockSMST(TAny *aStackP); // ECIMLockUnlock
1.3442 + inline TMMCErr CIMLockUnlockSM();
1.3443 + static TMMCErr NoSessionSMST(TAny* aStackP); // ECIMLockStack
1.3444 + inline TMMCErr NoSessionSM();
1.3445 + static TMMCErr AcquireStackSMST(TAny* aStackP);
1.3446 + IMPORT_C virtual TMMCErr AcquireStackSM();
1.3447 + static TMMCErr CheckStackSMST(TAny* aStackP); // ECIMCheckStack
1.3448 + inline TMMCErr CheckStackSM();
1.3449 + static TMMCErr CheckLockStatusSMST(TAny* aStackP);
1.3450 + inline TMMCErr CheckLockStatusSM();
1.3451 + static TMMCErr ModifyCardCapabilitySMST(TAny* aStackP);
1.3452 + IMPORT_C virtual TMMCErr ModifyCardCapabilitySM();
1.3453 + static TMMCErr BaseModifyCardCapabilitySMST(TAny* aStackP);
1.3454 + static TMMCErr DoPowerUpSMST(TAny* aStackP);
1.3455 + static TMMCErr InitClockOnSMST(TAny* aStackP);
1.3456 + IMPORT_C static TMMCErr IssueMMCCommandSMST(TAny* aStackP);
1.3457 +
1.3458 + static TMMCErr CIMAutoUnlockSMST(TAny* aStackP);
1.3459 + inline TMMCErr CIMAutoUnlockSM();
1.3460 +
1.3461 + static TMMCErr InitStackAfterUnlockSMST(TAny* aStackP); // ECIMInitStackAfterUnlock
1.3462 + IMPORT_C virtual TMMCErr InitStackAfterUnlockSM();
1.3463 +
1.3464 + static TMMCErr InitCurrentCardAfterUnlockSMST(TAny* aStackP);
1.3465 +
1.3466 + static TMMCErr AttachCardSMST(TAny* aStackP);
1.3467 + inline TMMCErr AttachCardSM();
1.3468 + static TMMCErr ExecCommandSMST(TAny* aStackP);
1.3469 + inline TMMCErr ExecCommandSM();
1.3470 + static TMMCErr IssueCommandCheckResponseSMST(TAny* aStackP);
1.3471 + inline TMMCErr IssueCommandCheckResponseSM();
1.3472 + static TMMCErr PollGapTimerSMST(TAny* aStackP);
1.3473 + inline TMMCErr PollGapTimerSM();
1.3474 + static TMMCErr RetryGapTimerSMST(TAny* aStackP);
1.3475 + inline TMMCErr RetryGapTimerSM();
1.3476 + static TMMCErr ProgramTimerSMST(TAny *aStackP);
1.3477 + inline TMMCErr ProgramTimerSM();
1.3478 + static TMMCErr GoIdleSMST(TAny* aStackP);
1.3479 + inline TMMCErr GoIdleSM();
1.3480 +
1.3481 + static TMMCErr SwitchToLowVoltageSMST(TAny* aStackP);
1.3482 +
1.3483 + static TMMCErr DoWakeUpSMST(TAny* aStackP);
1.3484 +
1.3485 +
1.3486 +private:
1.3487 + static TMMCErr ConfigureHighSpeedSMST(TAny* aStackP);
1.3488 + inline TMMCErr ConfigureHighSpeedSM();
1.3489 +
1.3490 + static TMMCErr DetermineBusWidthAndClockSMST(TAny* aStackP);
1.3491 + inline TMMCErr DetermineBusWidthAndClockSM();
1.3492 +
1.3493 + static TMMCErr ExecSwitchCommandST(TAny* aStackP);
1.3494 + inline TMMCErr ExecSwitchCommand();
1.3495 +
1.3496 + static TMMCErr ExecSleepCommandSMST(TAny* aStackP);
1.3497 + inline TMMCErr ExecSleepCommandSM();
1.3498 +
1.3499 + static TMMCErr ExecAwakeCommandSMST(TAny* aStackP);
1.3500 + inline TMMCErr ExecAwakeCommandSM();
1.3501 +
1.3502 + static TMMCErr LowVoltagePowerupTimerSMST(TAny *aStackP);
1.3503 + TMMCErr LowVoltagePowerupTimerSM();
1.3504 +
1.3505 + static TMMCErr ExecBusTestSMST(TAny* aStackP);
1.3506 + inline TMMCErr ExecBusTestSM();
1.3507 +
1.3508 + enum TBusWidthAndClock
1.3509 + {
1.3510 + E1Bit20Mhz = 0x0000,
1.3511 +
1.3512 + E4Bits26Mhz = 0x0001,
1.3513 + E4Bits52Mhz = 0x0002,
1.3514 +
1.3515 + E8Bits26Mhz = 0x0004,
1.3516 + E8Bits52Mhz = 0x0008,
1.3517 + };
1.3518 + enum TBusWidthAndClockMasks
1.3519 + {
1.3520 + E4BitMask = E4Bits26Mhz | E4Bits52Mhz,
1.3521 + E8BitMask = E8Bits26Mhz | E8Bits52Mhz,
1.3522 + E26MhzMask = E4Bits26Mhz | E8Bits26Mhz,
1.3523 + E52MhzMask = E4Bits52Mhz | E8Bits52Mhz
1.3524 + };
1.3525 +
1.3526 + void DetermineBusWidthAndClock(const TMMCard& aCard, TBool aLowVoltage, TUint& aPowerClass, TBusWidthAndClock& aBusWidthAndClock);
1.3527 + TUint GetPowerClass(const TMMCard& aCard, TBusWidthAndClock aWidthAndClock, TBool aLowVoltage);
1.3528 +
1.3529 +
1.3530 + // ----------- Data Members -------------
1.3531 +private:
1.3532 + //
1.3533 + // Synchronous status, data structures and control info.
1.3534 + TUint32 iStackState;
1.3535 + TUint iInitContext; // Stack Initialiser pass number
1.3536 + DMMCSession* iLockingSessionP;
1.3537 + TMMCSessRing iWorkSet;
1.3538 + TMMCSessRing iReadyQueue;
1.3539 + TMMCSessRing iEntryQueue;
1.3540 + TDfc iStackDFC;
1.3541 + TRCA iSelectedCard;
1.3542 + DMMCSocket* iSocket;
1.3543 + DMMCSession* iStackSession;
1.3544 + DMMCSession iAutoUnlockSession;
1.3545 + TInt iAutoUnlockIndex; // index into iCards
1.3546 +protected:
1.3547 + TUint8* iPSLBuf;
1.3548 +private:
1.3549 + TInt iPSLBufLen;
1.3550 + TInt iMinorBufLen;
1.3551 + TUint8 iSpare[2];
1.3552 + TBool volatile iSleep;
1.3553 + DThread* iNotifierThread;
1.3554 + TRequestStatus* iNotifierReqStat;
1.3555 + enum TInitState {EISPending, EISDone};
1.3556 + TInitState iInitState;
1.3557 + //
1.3558 + // Stack and Scheduler control
1.3559 + // Asynchronous sheduler attention flags
1.3560 + TBool volatile iAttention; // There are ready sessions
1.3561 + TBool volatile iAbortReq; // There are sessions marked for abort
1.3562 + TBool volatile iCompReq; // There are sessions to complete
1.3563 + TBool volatile iInitialise; // Enforce InitStack (after enforced PowerDown)
1.3564 + TBool volatile iUpdate; // Enque InitStack into iWorkSet
1.3565 + // Other asynchronous flags
1.3566 + TBool volatile iPoweredUp;
1.3567 + TBool volatile iDFCRunning;
1.3568 + TBool volatile iAbortAll;
1.3569 + TMMCErr volatile iCompleteAllExitCode;
1.3570 + //
1.3571 + // Session context
1.3572 +protected:
1.3573 + DMMCSession* iSessionP;
1.3574 +private:
1.3575 + //
1.3576 + // Bus control
1.3577 + TDSR iCurrentDSR;
1.3578 + //
1.3579 + // Stack data structures and Session/StateMachine miscellaneous
1.3580 + TUint iDeselectsToIssue;
1.3581 + TInt iCxDeselectCount;
1.3582 + TUint8 iCMD42CmdByte;
1.3583 + TMediaPassword iMPTgt;
1.3584 +public:
1.3585 + IMPORT_C TUint32 EffectiveModes(const TMMCStackConfig& aClientConfig);
1.3586 + TUint32 iCurrentOpRange;
1.3587 + TInt iCxCardCount;
1.3588 + TInt iCxPollRetryCount;
1.3589 + TMMCStackConfig iConfig;
1.3590 + TUint iMaxCardsInStack;
1.3591 + TMMCRCAPool iRCAPool;
1.3592 + TMMCardArray* iCardArray;
1.3593 + TMMCStackConfig iMasterConfig;
1.3594 + friend class DMMCSocket;
1.3595 + friend class DMMCSession;
1.3596 + friend class TMMCardArray;
1.3597 +
1.3598 +private:
1.3599 + //
1.3600 + // Dummy functions to maintain binary compatibility
1.3601 + IMPORT_C virtual void Dummy1();
1.3602 +
1.3603 +protected:
1.3604 + /**
1.3605 + Gets an interface from a derived class
1.3606 + replaces reserved virtual Dummy4()
1.3607 + */
1.3608 + IMPORT_C virtual void GetInterface(TInterfaceId aInterfaceId, MInterface*& aInterfacePtr);
1.3609 +
1.3610 +private:
1.3611 + TBusWidthAndClock iBusWidthAndClock;
1.3612 + TInt iSelectedCardIndex;
1.3613 + //
1.3614 + // Reserved members to maintain binary compatibility
1.3615 +protected:
1.3616 + TBool iMultiplexedBus; // ETrue if cards are individually selectable. EFalse if stacked on a common bus.
1.3617 +private:
1.3618 + TMMCCommandTypeEnum iYieldCommandType;
1.3619 + TInt iReserved;
1.3620 +
1.3621 +protected:
1.3622 + // Pointer to protected utility class which allows class to grow while maintining BC
1.3623 + // replaces fourth element of iReserved[]
1.3624 + class DBody;
1.3625 + friend class DBody;
1.3626 + DBody* iBody;
1.3627 + };
1.3628 +
1.3629 +
1.3630 +
1.3631 +
1.3632 +class TMMCMachineInfo
1.3633 +/**
1.3634 + Platform-specific configuration information for the
1.3635 + MultiMediaCard stack.
1.3636 +
1.3637 + An object of this type is passed to the Variant implementation
1.3638 + of DMMCStack::MachineInfo(), which should fill the public data
1.3639 + members with appropriate information and values.
1.3640 +
1.3641 + @publishedPartner
1.3642 + @released
1.3643 +*/
1.3644 + {
1.3645 +
1.3646 +public:
1.3647 + enum THardwareConfig
1.3648 + {
1.3649 + /**
1.3650 + Set this bit in iFlags if hardware supports SPI mode (not currently supported - set this bit to zero)
1.3651 + */
1.3652 + ESupportsSPIMode = 0x01,
1.3653 +
1.3654 + /**
1.3655 + Set this bit in iFlags if the PSL is enabled for double-buffered data transfers
1.3656 + */
1.3657 + ESupportsDoubleBuffering = 0x02,
1.3658 +
1.3659 + /**
1.3660 + Set this bit in iFlags if the PSL supports response type R7
1.3661 + */
1.3662 + ESupportsR7 = 0x04,
1.3663 +
1.3664 + /**
1.3665 + Set this bit in iFlags if the hardware DMA controller utilises 8-Bit Addressing
1.3666 + */
1.3667 + EDma8BitAddressing = 0x08,
1.3668 +
1.3669 + /**
1.3670 + Set this bit in iFlags if the hardware DMA controller utilises 16-Bit Addressing
1.3671 + */
1.3672 + EDma16BitAddressing = 0x10,
1.3673 +
1.3674 + /**
1.3675 + Set this bit in iFlags if the hardware DMA controller utilises 32-Bit Addressing
1.3676 + */
1.3677 + EDma32BitAddressing = 0x20,
1.3678 +
1.3679 + /**
1.3680 + Set this bit in iFlags if the hardware DMA controller utilises 64-Bit Addressing
1.3681 + */
1.3682 + EDma64BitAddressing = 0x40,
1.3683 +
1.3684 + /**
1.3685 + Set this in iFlags if the hardware supports DMA and can cope with being given a physical address.
1.3686 + This also sets the ESupportsDoubleBuffering flag, physical addressing is dependent on
1.3687 + doublebuffering functionality.
1.3688 + @see ESupportsDoubleBuffering
1.3689 + @see KMMCCmdFlagPhysAddr flag
1.3690 + */
1.3691 + ESupportsDMA = 0x082,
1.3692 +
1.3693 + /**
1.3694 + Set this in iFlags if the hardware is unable to perform data transfers of more than 256K
1.3695 + - Transfers greater than 256K will be split into multiple transactions.
1.3696 + */
1.3697 + EMaxTransferLength_256K = 0x100,
1.3698 +
1.3699 + /**
1.3700 + Set this in iFlags if the hardware is unable to perform data transfers of more than 512K
1.3701 + - Transfers greater than 512K will be split into multiple transactions.
1.3702 + */
1.3703 + EMaxTransferLength_512K = 0x200,
1.3704 +
1.3705 + /**
1.3706 + Set this in iFlags if the hardware is unable to perform data transfers of more than 1M
1.3707 + - Transfers greater than 1M will be split into multiple transactions.
1.3708 + */
1.3709 + EMaxTransferLength_1M = 0x300,
1.3710 +
1.3711 + /**
1.3712 + Set this in iFlags if the hardware is unable to perform data transfers of more than 2M
1.3713 + - Transfers greater than 2M will be split into multiple transactions.
1.3714 + */
1.3715 + EMaxTransferLength_2M = 0x400,
1.3716 +
1.3717 + /**
1.3718 + Set this in iFlags if the hardware is unable to perform data transfers of more than 4M
1.3719 + - Transfers greater than 4M will be split into multiple transactions.
1.3720 + */
1.3721 + EMaxTransferLength_4M = 0x500,
1.3722 +
1.3723 + /**
1.3724 + Set this in iFlags if the hardware is unable to perform data transfers of more than 8M
1.3725 + - Transfers greater than 8M will be split into multiple transactions.
1.3726 + */
1.3727 + EMaxTransferLength_8M = 0x600,
1.3728 +
1.3729 + /**
1.3730 + Set this in iFlags if the hardware is unable to perform data transfers of more than 16M
1.3731 + - Transfers greater than 16M will be split into multiple transactions.
1.3732 + */
1.3733 + EMaxTransferLength_16M = 0x700,
1.3734 +
1.3735 + /**
1.3736 + The card in slot 1 is internal, i.e. not removable
1.3737 + */
1.3738 + ESlot1Internal = 0x0800,
1.3739 +
1.3740 + /**
1.3741 + The card in slot 2 is internal, i.e. not removable
1.3742 + */
1.3743 + ESlot2Internal = 0x1000,
1.3744 + };
1.3745 +
1.3746 +public:
1.3747 + /**
1.3748 + The total number of MultiMediaCard slots for this stack.
1.3749 +
1.3750 + Be aware that this refers to the stack, and NOT to the platform;
1.3751 + a platform can have multiple stacks.
1.3752 + */
1.3753 + TInt iTotalSockets;
1.3754 +
1.3755 + /**
1.3756 + Not currently used.
1.3757 +
1.3758 + Set this value to zero.
1.3759 + */
1.3760 + TInt iTotalMediaChanges;
1.3761 +
1.3762 + /**
1.3763 + Not currently used.
1.3764 +
1.3765 + Set this value to zero.
1.3766 + */
1.3767 + TInt iTotalPrimarySupplies;
1.3768 +
1.3769 + union
1.3770 + {
1.3771 + /**
1.3772 + Indicates whether the SPI protocol is being used or not.
1.3773 +
1.3774 + SPI not currently supported; set this to EFalse.
1.3775 + */
1.3776 + TBool iSPIMode; // SPI mode not yet supported
1.3777 + /**
1.3778 + Hardware configuration flags
1.3779 + */
1.3780 + TUint32 iFlags;
1.3781 + };
1.3782 +
1.3783 + /**
1.3784 + The number of the first peripheral bus slot claimed by the
1.3785 + MultiMediaCard controller.
1.3786 +
1.3787 + Symbian OS supports 4, so set this to a value in the range 0-3.
1.3788 + */
1.3789 + TInt iBaseBusNumber;
1.3790 + };
1.3791 +
1.3792 +
1.3793 +
1.3794 +
1.3795 +typedef TPckg<TMMCMachineInfo> TMMCardMachineInfoPckg;
1.3796 +
1.3797 +/**
1.3798 + Platform-specific configuration information for the
1.3799 + MultiMediaCard stack. Contains information pertinent to
1.3800 + MMC specification version 4.0/4.1
1.3801 +
1.3802 + An object of this type is passed to the Variant implementation
1.3803 + of DMMCStack::MachineInfo(), which should fill the public data
1.3804 + members with appropriate information and values.
1.3805 +
1.3806 +@internalComponent
1.3807 +*/
1.3808 +class TMMCMachineInfoV4 : public TMMCMachineInfo
1.3809 + {
1.3810 +public:
1.3811 + inline TMMCMachineInfoV4() {memclr(this, sizeof(*this));}
1.3812 +
1.3813 + /**
1.3814 + The version of the structure returned by the PSL in a call to DMMStack::MachineInfo()
1.3815 + The fields defined in TMMCMachineInfoV4 are only valid if the version is EVersion4 or higher
1.3816 + */
1.3817 + enum TVersion {EVersion3, EVersion4};
1.3818 + TVersion iVersion;
1.3819 +
1.3820 + /**
1.3821 + The maximum bus width supported.
1.3822 + */
1.3823 + TBusWidth iMaxBusWidth;
1.3824 +
1.3825 + /**
1.3826 + Maximum clock frequency supported,
1.3827 + N.B. if the controller's maximum clock rate is only slightly less than one of the
1.3828 + "high-speed" clock frequencies defined in MMC spec 4.0 (i.e 26 Mhz and 52 Mhz), then
1.3829 + it can still report that it is supported and then run at the slightly lower clock rate.
1.3830 + */
1.3831 + enum THighSpeedClocks {EClockSpeed26Mhz = 26, EClockSpeed52Mhz = 52};
1.3832 + TUint iMaxClockSpeedInMhz;
1.3833 +
1.3834 + /**
1.3835 + The power class supported for 3.6V (high voltage).
1.3836 + This is a 4-bit value encoded in the same way as the POWER_CLASS field in the EXT_CSD
1.3837 + register. i.e. 0=100mA, 1=120mA, ... 10=450mA.
1.3838 + See MMC sepcification version 4.1, EXT_CSD register.
1.3839 + */
1.3840 + enum THiVoltagePowerClasses {EHi100mA, EHi120mA, EHi150mA, EHi180mA, EHi200mA, EHi220mA, EHi250mA, EHi300mA, EHi350mA, EHi400mA, EHi450mA };
1.3841 + TUint iHighVoltagePowerClass;
1.3842 +
1.3843 + /**
1.3844 + The power class supported for 1.95V (low voltage).
1.3845 + This is a 4-bit value encoded in the same way as the POWER_CLASS field in the EXT_CSD
1.3846 + register. i.e. 0=65mA, 1=70mA, ... 10=250mA.
1.3847 + See MMC sepcification version 4.1, EXT_CSD register.
1.3848 + */
1.3849 + enum TLoVoltagePowerClasses {ELo065mA, ELo070mA, ELo080mA, ELo090mA, ELo100mA, ELo120mA, ELo140mA, ELo160mA, ELo180mA, ELo200mA, ELo250mA };
1.3850 + TUint iLowVoltagePowerClass;
1.3851 + };
1.3852 +
1.3853 +
1.3854 +class DMMCPsu : public DPBusPsuBase
1.3855 +/**
1.3856 + DPBusPsuBase derived abstract class to control the MMC socket's power supply.
1.3857 +
1.3858 + This class is intended for derivation at the variant layer, which handles the
1.3859 + variant specific functionality of the power supply.
1.3860 +
1.3861 + @publishedPartner
1.3862 + @released
1.3863 +*/
1.3864 + {
1.3865 +public:
1.3866 + IMPORT_C DMMCPsu(TInt aPsuNum, TInt aMediaChangedNum);
1.3867 +
1.3868 + // Re-declaring virtual and pure-virtual interface defined in DPBusPsuBase for clarity...
1.3869 +
1.3870 + IMPORT_C virtual TInt DoCreate();
1.3871 +
1.3872 + /**
1.3873 + * Controls the power supply.
1.3874 + * Implemented by the variant, directly controls the power to the MMC stack.
1.3875 + * @param aState A TPBusPsuState enumeration specifying the required state
1.3876 + * (EPsuOnFull, EPsuOff, EPsuOnCurLimit)
1.3877 + */
1.3878 + virtual void DoSetState(TPBusPsuState aState)=0;
1.3879 +
1.3880 + /**
1.3881 + * Checks the PSU's voltage.
1.3882 + * Implemented by the variant, uses a mechanism such as a comparator to check
1.3883 + * the PSU's voltage level. Upon reciept of the voltage level (the process may
1.3884 + * be asynchronous), the variant calls ReceiveVoltageCheckResult() with KErrNone
1.3885 + * if the voltage is OK, KErrGeneral if there is a problem, or KErrNotReady if the
1.3886 + * hardware has not yet powered up.
1.3887 + */
1.3888 + virtual void DoCheckVoltage()=0;
1.3889 +
1.3890 + /**
1.3891 + * Fills in the supplied TPBusPsuInfo object with the characteristics of the platform.
1.3892 + * Provided at the variant layer.
1.3893 + * @param anInfo A reference to a TPBusPsuInfo to be filled in with the PSU characteristics.
1.3894 + */
1.3895 + virtual void PsuInfo(TPBusPsuInfo &anInfo)=0;
1.3896 +
1.3897 + inline void SetVoltage(TUint32 aVoltage);
1.3898 +
1.3899 + static void SleepCheck(TAny* aPtr);
1.3900 +
1.3901 +protected:
1.3902 + /**
1.3903 + * The current voltage setting, in OCR register format
1.3904 + */
1.3905 + TUint32 iVoltageSetting;
1.3906 + };
1.3907 +
1.3908 +class DMMCMediaChange : public DMediaChangeBase
1.3909 +/**
1.3910 + DMediaChangeBase derived abstract class to handle the isertion and removal of removable media.
1.3911 +
1.3912 + This class is intended for derivation at the variant layer, which handles the variant specific
1.3913 + functionality such as interrupt detection, and calls functions of the DMediaChangeBase class
1.3914 + to pass notifications of media change to the socket layers.
1.3915 +
1.3916 + @publishedPartner
1.3917 + @released
1.3918 +*/
1.3919 + {
1.3920 +public:
1.3921 + IMPORT_C DMMCMediaChange(TInt aMediaChangeNum);
1.3922 +
1.3923 + // Re-declaring virtual and pure-virtual interface defined in DMediaChangeBase for clarity...
1.3924 +
1.3925 + IMPORT_C virtual TInt Create();
1.3926 +
1.3927 + /**
1.3928 + * Forces a media change, executing the same actions as if a door open has occurred.
1.3929 + * @see DoDoorOpen
1.3930 + */
1.3931 + virtual void ForceMediaChange()=0;
1.3932 +
1.3933 + /**
1.3934 + * Called by DMediaChangeBase when the door is opened.
1.3935 + * Implemented at the variant layer, DoDoorOpen is invoked in response to the variant
1.3936 + * calling ::DoDoorOpenService upon detection of a door open event.
1.3937 + * DoDoorOpen may queue a debounce timer which masks further events until it expires.
1.3938 + * @see DoDoorClosed
1.3939 + */
1.3940 + virtual void DoDoorOpen()=0;
1.3941 +
1.3942 + /**
1.3943 + * Called by DMediaChangeBase when the door is closed.
1.3944 + * Implemented at the variant layer, DoDoorClosed is invoked in response to the variant
1.3945 + * calling ::DoorOpenService upon detection of a door closed event.
1.3946 + * Systems without a door should perform this sequence when the debounce timer has
1.3947 + * expired after a door open event has been detected.
1.3948 + * @see DoDoorOpen
1.3949 + */
1.3950 + virtual void DoDoorClosed()=0;
1.3951 +
1.3952 + /**
1.3953 + * Returns the current state of the door.
1.3954 + * Implemented at the variant layer to provide information as to the state of the door.
1.3955 + * @return TMediaState enumeration descibing the state of door (EDoorOpen, EDoorClosed).
1.3956 + */
1.3957 + virtual TMediaState MediaState() = 0;
1.3958 + };
1.3959 +
1.3960 +
1.3961 +/*===========================================================================*/
1.3962 +/* CLASS : DMMCEmbeddedMediaChange */
1.3963 +/*===========================================================================*/
1.3964 +NONSHARABLE_CLASS(DMMCEmbeddedMediaChange) : public DMMCMediaChange
1.3965 +/**
1.3966 + * This class looks after the processing to be carried out when the media door
1.3967 + * is opened or closed. It may be queried without the interrupt being enabled.
1.3968 + *
1.3969 + */
1.3970 + {
1.3971 +public:
1.3972 + DMMCEmbeddedMediaChange(TInt aMediaChangeNum) : DMMCMediaChange(aMediaChangeNum){};
1.3973 +
1.3974 + /// Directly calls the media change event
1.3975 + virtual void ForceMediaChange() {return;};
1.3976 +
1.3977 + /// Handle media door open (called on media door open interrupt).
1.3978 + virtual void DoDoorOpen() {return;};
1.3979 +
1.3980 + /// Handle media door closing (called on media door open interrupt).
1.3981 + virtual void DoDoorClosed() {return;};
1.3982 +
1.3983 + /// Return status of media changed signal.
1.3984 + virtual TMediaState MediaState() {return EDoorClosed;};
1.3985 + };
1.3986 +
1.3987 +
1.3988 +
1.3989 +class TMapping
1.3990 +/**
1.3991 + MMC Mapping
1.3992 +*/
1.3993 + {
1.3994 +public:
1.3995 + TBuf8<KMMCCIDLength> iCID;
1.3996 + TMediaPassword iPWD;
1.3997 + enum TState {EStPending, EStValid, EStInvalid};
1.3998 + TState iState;
1.3999 + };
1.4000 +
1.4001 +NONSHARABLE_CLASS(TMMCPasswordStore) : public TPasswordStore
1.4002 +/**
1.4003 + MMC Password Store
1.4004 +*/
1.4005 + {
1.4006 +public:
1.4007 + TMMCPasswordStore();
1.4008 +
1.4009 + // Pure virtual...
1.4010 + TInt Init();
1.4011 + TInt ReadPasswordData(TDes8 &aBuf);
1.4012 + TInt WritePasswordData(TDesC8 &aBuf);
1.4013 + TInt PasswordStoreLengthInBytes();
1.4014 +
1.4015 +public:
1.4016 + TMapping *FindMappingInStore(const TCID &aCID);
1.4017 + TInt InsertMapping(const TCID &aCID, const TMediaPassword &aPWD, TMapping::TState aState);
1.4018 + IMPORT_C TBool IsMappingIncorrect(const TCID& aCID, const TMediaPassword& aPWD);
1.4019 +
1.4020 + static TInt CompareCID(const TMapping& aLeft, const TMapping& aRight);
1.4021 + TIdentityRelation<TMapping> iIdentityRelation;
1.4022 +
1.4023 +private:
1.4024 + RArray<TMapping> *iStore;
1.4025 +
1.4026 + friend class DMMCSocket;
1.4027 + };
1.4028 +
1.4029 +class DMMCSocket : public DPBusSocket
1.4030 +/**
1.4031 + This DPBusSocket derived object oversees the power supplies
1.4032 + and media change functionality of DMMCStack Objects. A socket
1.4033 + directly corresponds to a single stack, which may support multiple cards.
1.4034 +
1.4035 + @publishedPartner
1.4036 + @released
1.4037 +*/
1.4038 + {
1.4039 +public:
1.4040 + IMPORT_C DMMCSocket(TInt aSocketNumber, TMMCPasswordStore* aPasswordStore);
1.4041 +
1.4042 + // Functions inherited from DPBusSocket
1.4043 + virtual TInt Init();
1.4044 + virtual void InitiatePowerUpSequence();
1.4045 + virtual TBool CardIsPresent();
1.4046 + virtual void Reset1();
1.4047 + virtual void Reset2();
1.4048 +
1.4049 + TInt TotalSupportedCards();
1.4050 +
1.4051 + // MMC specific functions
1.4052 + inline DMMCStack* Stack(TInt aBus);
1.4053 + inline void ResetInactivity(TInt aBus);
1.4054 + inline const TMMCMachineInfo& MachineInfo() const;
1.4055 +
1.4056 + virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const;
1.4057 + virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen);
1.4058 + virtual TInt PrepareStore(TInt aBus, TInt aFunc, TLocalDrivePasswordData &aData);
1.4059 +
1.4060 + inline TBool SupportsDoubleBuffering();
1.4061 + inline TUint32 MaxDataTransferLength();
1.4062 + inline TUint32 DmaAlignment();
1.4063 +
1.4064 +protected:
1.4065 + // MMC specific functions
1.4066 + virtual void GetMachineInfo();
1.4067 +
1.4068 +private:
1.4069 + // Password Store Control Functions
1.4070 + TInt PasswordControlStart(const TCID &aCID, const TMediaPassword *aPWD);
1.4071 + void PasswordControlEnd(DMMCSession *aSessP, TInt aResult);
1.4072 + TBool RefreshStore();
1.4073 +
1.4074 +protected:
1.4075 + TMMCMachineInfo iMachineInfo;
1.4076 + TMMCPasswordStore* iPasswordStore;
1.4077 +
1.4078 +public:
1.4079 + DMMCStack* iStack;
1.4080 + DMMCPsu* iVccCore;
1.4081 +
1.4082 +private:
1.4083 + TUint32 iReserved[4];
1.4084 +
1.4085 +public:
1.4086 + enum TMMCPanic
1.4087 + {
1.4088 + EMMCMachineStack =0,
1.4089 + EMMCMachineState =1,
1.4090 + EMMCSessRingNoSession =2,
1.4091 + EMMCStackSessionEngaged =3,
1.4092 + EMMCInitStackBlocked =4,
1.4093 + EMMCNoFreeRCA =5,
1.4094 + EMMCCommandStack =6,
1.4095 + EMMCRWSessionID =7,
1.4096 + EMMCEraseSessionID =8,
1.4097 + EMMCIOSessionID =9,
1.4098 + EMMCSessionNoPswdCard =10,
1.4099 + EMMCSessionPswdCmd =11,
1.4100 + EMMCSessionBadSessionID =12,
1.4101 + EMMCSetBusWidthNotImplemented =13,
1.4102 + EMMCInvalidNumberOfCardSlots =14,
1.4103 + EMMCBadBusWidth =15,
1.4104 + EMMCInvalidDBCommand =16,
1.4105 + EMMCInvalidDBBlockLength =17,
1.4106 + EMMCUnblockingInWrongContext =18,
1.4107 + EMMCInvalidCardNumber =19,
1.4108 + EMMCNotInDfcContext =20,
1.4109 + };
1.4110 + IMPORT_C static void Panic(TMMCPanic aPanic);
1.4111 + friend class DMMCStack;
1.4112 + friend class DMMCSession;
1.4113 + friend class DMMCMediaChange;
1.4114 + };
1.4115 +
1.4116 +const TUint32 KMMCEraseClassCmdsSupported= KBit0;
1.4117 +const TUint32 KMMCEraseGroupCmdsSupported= KBit1;
1.4118 +NONSHARABLE_CLASS(TMMCEraseInfo)
1.4119 + {
1.4120 +public:
1.4121 + inline TBool EraseClassCmdsSupported() const;
1.4122 + inline TBool EraseGroupCmdsSupported() const;
1.4123 +public:
1.4124 + TUint32 iEraseFlags;
1.4125 + TUint32 iPreferredEraseUnitSize;
1.4126 + TUint32 iMinEraseSectorSize;
1.4127 + };
1.4128 +
1.4129 +#include <drivers/mmc.inl>
1.4130 +
1.4131 +#endif // __MMC_H__
1.4132 +