diff -r a179b74831c9 -r c1f20ce4abcf kernel/eka/drivers/pbus/mmc/stack.cpp --- a/kernel/eka/drivers/pbus/mmc/stack.cpp Thu Aug 19 11:14:22 2010 +0300 +++ b/kernel/eka/drivers/pbus/mmc/stack.cpp Tue Aug 31 16:34:26 2010 +0300 @@ -1804,9 +1804,11 @@ if( sessP->iCardP != NULL && sessP->iCardP->iUsingSessionP == sessP ) sessP->iCardP->iUsingSessionP = NULL; - // iAutoUnlockSession may attach to more than once card, so need to iterate + // Some sessions may attach to more than once card, so need to iterate // through all cards and clear their session pointers if they match sessP - if (sessP == &iAutoUnlockSession) + if (sessP == &iAutoUnlockSession || + sessP->iSessionID == ECIMLockUnlock || + sessP->iSessionID == ECIMInitStackAfterUnlock) { for (TUint i = 0; i < iMaxCardsInStack; i++) { @@ -1942,6 +1944,11 @@ if(doCallback) { + // Restore the callers card pointer as some state machines + // (e.g. ECIMLockUnlock, ECIMInitStackAfterUnlock) can change it + sessP->RestoreCard(); + + // call media driver completion routine or StackSessionCBST(). sessP->iCallBack.CallBack(); } @@ -6063,6 +6070,8 @@ return KMMCErrNotSupported; } + DoAddressCard(s.iCardP->iIndex-1); + s.iState |= KMMCSessStateInProgress; m.SetTraps( KMMCErrInitContext ); @@ -6408,6 +6417,9 @@ { EStBegin=0, EStNextIndex, + EStSendStatus, + EStGetStatus, + EStUnlock, EStInitStackAfterUnlock, EStIssuedLockUnlock, EStDone, @@ -6470,12 +6482,32 @@ // // Upon completion, test the next card before performing further initialisation. // - - TMMCard &cd = *(iCardArray->CardP(iAutoUnlockIndex++)); - OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMAUTOUNLOCKSM4, "Attempting to unlock card %d", cd.Number() ); - s.SetCard(&cd); - + DoAddressCard(iAutoUnlockIndex); // Address the card + TMMCard* cd = iCardArray->CardP(iAutoUnlockIndex); + s.SetCard(cd); + + SMF_STATE(EStSendStatus) + + s.FillCommandDesc(ECmdSendStatus, 0); + + SMF_INVOKES(ExecCommandSMST,EStGetStatus) + + SMF_STATE(EStGetStatus) + + const TMMCStatus st = s.LastStatus(); + if((st & KMMCStatCardIsLocked) == 0) + { + SMF_GOTOS(EStNextIndex); + } + + SMF_STATE(EStUnlock) + + const TMapping *mp = NULL; + mp = iSocket->iPasswordStore->FindMappingInStore(iCardArray->CardP(iAutoUnlockIndex)->CID()); + + OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMAUTOUNLOCKSM4, "Attempting to unlock card %d", iCardArray->CardP(iAutoUnlockIndex)->Number() ); + const TInt kPWD_LEN = mp->iPWD.Length(); iPSLBuf[0] = 0; // LOCK_UNLOCK = 0; unlock iPSLBuf[1] = static_cast(kPWD_LEN); @@ -6752,6 +6784,21 @@ return busWidth; } +void DMMCStack::DoAddressCard(TInt aCardNumber) + { + MAddressCard* addressCardInterface = NULL; + GetInterface(KInterfaceAddressCard, (MInterface*&) addressCardInterface); + if (addressCardInterface) + addressCardInterface->AddressCard(aCardNumber); + else + { + // if the interface isn't supported on a multiplexed bus, then panic if the card number > 0 - + // one cause of this panic is if the PSL 's implementation of GetInterface() does not call the + // base class's implementation of GetInterface() + __ASSERT_ALWAYS((!iMultiplexedBus) || (aCardNumber <= 0), DMMCSocket::Panic(DMMCSocket::EMMCAddressCardNotSupported)); + } + } + /** * class DMMCSocket */