diff -r c7a0ce20c48c -r a77889bee936 kernel/eka/drivers/pbus/mmc/stack.cpp --- a/kernel/eka/drivers/pbus/mmc/stack.cpp Fri Aug 06 16:34:38 2010 +0100 +++ b/kernel/eka/drivers/pbus/mmc/stack.cpp Thu Aug 12 11:55:14 2010 +0100 @@ -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 ); @@ -6474,30 +6483,31 @@ // Upon completion, test the next card before performing further initialisation. // - SMF_STATE(EStSendStatus) + 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) + SMF_STATE(EStGetStatus) const TMMCStatus st = s.LastStatus(); if((st & KMMCStatCardIsLocked) == 0) { - SMF_RETURN(err) + SMF_GOTOS(EStNextIndex); } - SMF_STATE(EStUnlock) + SMF_STATE(EStUnlock) const TMapping *mp = NULL; mp = iSocket->iPasswordStore->FindMappingInStore(iCardArray->CardP(iAutoUnlockIndex)->CID()); - TMMCard &cd = *(iCardArray->CardP(iAutoUnlockIndex++)); - OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMAUTOUNLOCKSM4, "Attempting to unlock card %d", cd.Number() ); + OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMAUTOUNLOCKSM4, "Attempting to unlock card %d", iCardArray->CardP(iAutoUnlockIndex)->Number() ); - s.SetCard(&cd); - const TInt kPWD_LEN = mp->iPWD.Length(); iPSLBuf[0] = 0; // LOCK_UNLOCK = 0; unlock iPSLBuf[1] = static_cast(kPWD_LEN); @@ -6774,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 */