kernel/eka/drivers/pbus/mmc/stack.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 26 c734af59ce98
child 44 3e88ff8f41d5
equal deleted inserted replaced
42:a179b74831c9 43:c1f20ce4abcf
  1802 		iSessionP = NULL;
  1802 		iSessionP = NULL;
  1803 
  1803 
  1804 	if( sessP->iCardP != NULL && sessP->iCardP->iUsingSessionP == sessP )
  1804 	if( sessP->iCardP != NULL && sessP->iCardP->iUsingSessionP == sessP )
  1805 		sessP->iCardP->iUsingSessionP = NULL;
  1805 		sessP->iCardP->iUsingSessionP = NULL;
  1806 
  1806 
  1807 	// iAutoUnlockSession may attach to more than once card, so need to iterate 
  1807 	// Some sessions may attach to more than once card, so need to iterate 
  1808 	// through all cards and clear their session pointers if they match sessP
  1808 	// through all cards and clear their session pointers if they match sessP
  1809 	if (sessP == &iAutoUnlockSession)
  1809 	if (sessP == &iAutoUnlockSession || 
       
  1810 		sessP->iSessionID == ECIMLockUnlock || 
       
  1811 		sessP->iSessionID == ECIMInitStackAfterUnlock)
  1810 		{
  1812 		{
  1811 		for (TUint i = 0; i < iMaxCardsInStack; i++)
  1813 		for (TUint i = 0; i < iMaxCardsInStack; i++)
  1812 			{
  1814 			{
  1813 			TMMCard& cd = *(iCardArray->CardP(i));
  1815 			TMMCard& cd = *(iCardArray->CardP(i));
  1814 			if (cd.iUsingSessionP == sessP)
  1816 			if (cd.iUsingSessionP == sessP)
  1940 				DoSetClock(maxClk);
  1942 				DoSetClock(maxClk);
  1941 				}
  1943 				}
  1942 
  1944 
  1943 			if(doCallback)
  1945 			if(doCallback)
  1944 				{
  1946 				{
       
  1947 				// Restore the callers card pointer as some state machines 
       
  1948 				// (e.g. ECIMLockUnlock, ECIMInitStackAfterUnlock) can change it
       
  1949 				sessP->RestoreCard();
       
  1950 
       
  1951 
  1945 				// call media driver completion routine or StackSessionCBST().
  1952 				// call media driver completion routine or StackSessionCBST().
  1946 				sessP->iCallBack.CallBack();
  1953 				sessP->iCallBack.CallBack();
  1947 				}
  1954 				}
  1948 			}
  1955 			}
  1949 		else
  1956 		else
  6061 		    {
  6068 		    {
  6062 			OstTraceFunctionExitExt( DMMCSTACK_CIMERASESM_EXIT1, this, (TInt) KMMCErrNotSupported );
  6069 			OstTraceFunctionExitExt( DMMCSTACK_CIMERASESM_EXIT1, this, (TInt) KMMCErrNotSupported );
  6063 			return KMMCErrNotSupported;
  6070 			return KMMCErrNotSupported;
  6064 		    }
  6071 		    }
  6065 
  6072 
       
  6073 		DoAddressCard(s.iCardP->iIndex-1);
       
  6074 
  6066 		s.iState |= KMMCSessStateInProgress;
  6075 		s.iState |= KMMCSessStateInProgress;
  6067 		m.SetTraps( KMMCErrInitContext );
  6076 		m.SetTraps( KMMCErrInitContext );
  6068 
  6077 
  6069 	SMF_STATE(EStRestart)
  6078 	SMF_STATE(EStRestart)
  6070 
  6079 
  6406 	{
  6415 	{
  6407 		enum states
  6416 		enum states
  6408 			{
  6417 			{
  6409 			EStBegin=0,
  6418 			EStBegin=0,
  6410 			EStNextIndex,
  6419 			EStNextIndex,
       
  6420 			EStSendStatus,
       
  6421 			EStGetStatus,
       
  6422 			EStUnlock,
  6411 			EStInitStackAfterUnlock,
  6423 			EStInitStackAfterUnlock,
  6412 			EStIssuedLockUnlock,
  6424 			EStIssuedLockUnlock,
  6413 			EStDone,
  6425 			EStDone,
  6414 			EStEnd
  6426 			EStEnd
  6415 			};
  6427 			};
  6468 		// We've found a locked card with a password in the password store,
  6480 		// We've found a locked card with a password in the password store,
  6469 		// so attempt to unlock using the CIMLockUnlockSMST state machine.
  6481 		// so attempt to unlock using the CIMLockUnlockSMST state machine.
  6470 		//
  6482 		//
  6471 		// Upon completion, test the next card before performing further initialisation.
  6483 		// Upon completion, test the next card before performing further initialisation.
  6472 		//
  6484 		//
  6473 
       
  6474 		TMMCard &cd = *(iCardArray->CardP(iAutoUnlockIndex++));
       
  6475 		OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMAUTOUNLOCKSM4, "Attempting to unlock card %d", cd.Number() );
       
  6476 		
  6485 		
  6477 		s.SetCard(&cd);
  6486 		DoAddressCard(iAutoUnlockIndex); 	// Address the card
  6478 
  6487 		TMMCard* cd = iCardArray->CardP(iAutoUnlockIndex);
       
  6488 		s.SetCard(cd);
       
  6489 
       
  6490 	SMF_STATE(EStSendStatus)
       
  6491 		        
       
  6492 		s.FillCommandDesc(ECmdSendStatus, 0);
       
  6493 		                        
       
  6494 		SMF_INVOKES(ExecCommandSMST,EStGetStatus)
       
  6495 		                        
       
  6496 	SMF_STATE(EStGetStatus)
       
  6497 		                        
       
  6498 		const TMMCStatus st = s.LastStatus();
       
  6499 		if((st & KMMCStatCardIsLocked) == 0)
       
  6500 			{
       
  6501 			SMF_GOTOS(EStNextIndex);
       
  6502 		    }
       
  6503 		                        
       
  6504 	SMF_STATE(EStUnlock)
       
  6505 		                        
       
  6506 		const TMapping *mp = NULL;
       
  6507 		mp = iSocket->iPasswordStore->FindMappingInStore(iCardArray->CardP(iAutoUnlockIndex)->CID());
       
  6508 
       
  6509 		OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMAUTOUNLOCKSM4, "Attempting to unlock card %d", iCardArray->CardP(iAutoUnlockIndex)->Number() );
       
  6510 		
  6479 		const TInt kPWD_LEN = mp->iPWD.Length();
  6511 		const TInt kPWD_LEN = mp->iPWD.Length();
  6480 		iPSLBuf[0] = 0;				// LOCK_UNLOCK = 0; unlock
  6512 		iPSLBuf[0] = 0;				// LOCK_UNLOCK = 0; unlock
  6481 		iPSLBuf[1] = static_cast<TUint8>(kPWD_LEN);
  6513 		iPSLBuf[1] = static_cast<TUint8>(kPWD_LEN);
  6482 		TPtr8 pwd(&iPSLBuf[2], kPWD_LEN);
  6514 		TPtr8 pwd(&iPSLBuf[2], kPWD_LEN);
  6483 		pwd.Copy(mp->iPWD);
  6515 		pwd.Copy(mp->iPWD);
  6748 			DMMCSocket::Panic(DMMCSocket::EMMCBadBusWidth);
  6780 			DMMCSocket::Panic(DMMCSocket::EMMCBadBusWidth);
  6749 
  6781 
  6750 		}
  6782 		}
  6751 	OstTraceFunctionExitExt( DMMCSTACK_BUSWIDTHENCODING_EXIT, this, ( TUint )&( busWidth ) );
  6783 	OstTraceFunctionExitExt( DMMCSTACK_BUSWIDTHENCODING_EXIT, this, ( TUint )&( busWidth ) );
  6752 	return busWidth;
  6784 	return busWidth;
       
  6785 	}
       
  6786 
       
  6787 void DMMCStack::DoAddressCard(TInt aCardNumber)
       
  6788 	{
       
  6789 	MAddressCard* addressCardInterface = NULL;
       
  6790 	GetInterface(KInterfaceAddressCard, (MInterface*&) addressCardInterface);
       
  6791 	if (addressCardInterface)
       
  6792 		addressCardInterface->AddressCard(aCardNumber);
       
  6793 	else
       
  6794 		{
       
  6795 		// if the interface isn't supported on a multiplexed bus, then panic if the card number > 0 - 
       
  6796 		// one cause of this panic is if the PSL 's implementation of GetInterface() does not call the 
       
  6797 		// base class's implementation of GetInterface()
       
  6798 		__ASSERT_ALWAYS((!iMultiplexedBus) || (aCardNumber <= 0), DMMCSocket::Panic(DMMCSocket::EMMCAddressCardNotSupported));
       
  6799 		}
  6753 	}
  6800 	}
  6754 
  6801 
  6755 /**
  6802 /**
  6756  * class DMMCSocket 
  6803  * class DMMCSocket 
  6757  */
  6804  */