398 * Return info. on erase services for this card |
412 * Return info. on erase services for this card |
399 * @param aEraseInfo A reference to the TMMCEraseInfo to be filled in with the erase information. |
413 * @param aEraseInfo A reference to the TMMCEraseInfo to be filled in with the erase information. |
400 * @return Symbian OS error code. |
414 * @return Symbian OS error code. |
401 */ |
415 */ |
402 { |
416 { |
|
417 OstTraceFunctionEntry1( TMMCARD_GETERASEINFO_ENTRY, this ); |
403 |
418 |
404 // Check whether this card supports Erase Class Commands. Also, validate the erase group size |
419 // Check whether this card supports Erase Class Commands. Also, validate the erase group size |
405 if ((CSD().CCC() & KMMCCmdClassErase) && IsPowerOfTwo(CSD().EraseGroupSize())) |
420 if ((CSD().CCC() & KMMCCmdClassErase) && IsPowerOfTwo(CSD().EraseGroupSize())) |
406 { |
421 { |
407 // This card supports erase cmds. Also, all versions of MMC cards support Erase Group commands (i.e. CMD35, CMD36). |
422 // This card supports erase cmds. Also, all versions of MMC cards support Erase Group commands (i.e. CMD35, CMD36). |
|
423 OstTrace0( TRACE_INTERNALS, TMMCARD_GETERASEINFO, "Card supports erase class commands" ); |
408 aEraseInfo.iEraseFlags=(KMMCEraseClassCmdsSupported|KMMCEraseGroupCmdsSupported); |
424 aEraseInfo.iEraseFlags=(KMMCEraseClassCmdsSupported|KMMCEraseGroupCmdsSupported); |
409 |
425 |
410 // Return the preferred size to be used as the unit for format operations. We need to return a sensible |
426 // Return the preferred size to be used as the unit for format operations. We need to return a sensible |
411 // multiple of the erase group size - as calculated by the CSD. A value around 1/32th of the total disk |
427 // multiple of the erase group size - as calculated by the CSD. A value around 1/32th of the total disk |
412 // size generally results in an appropriate number of individual format calls. |
428 // size generally results in an appropriate number of individual format calls. |
443 * Normally this is the same as the READ_BL_LEN field in the CSD register, |
461 * Normally this is the same as the READ_BL_LEN field in the CSD register, |
444 * but for high capacity cards (>- 2GB) this is set to a maximum of 512 bytes, |
462 * but for high capacity cards (>- 2GB) this is set to a maximum of 512 bytes, |
445 * if possible, to try to avoid compatibility issues. |
463 * if possible, to try to avoid compatibility issues. |
446 */ |
464 */ |
447 { |
465 { |
|
466 OstTraceFunctionEntry1( TMMCARD_MAXREADBLLEN_ENTRY, this ); |
448 const TInt KDefaultReadBlockLen = 9; // 2^9 = 512 bytes |
467 const TInt KDefaultReadBlockLen = 9; // 2^9 = 512 bytes |
449 const TCSD& csd = CSD(); |
468 const TCSD& csd = CSD(); |
450 |
469 |
451 TInt blkLenLog2 = csd.ReadBlLen(); |
470 TInt blkLenLog2 = csd.ReadBlLen(); |
452 |
471 |
453 if (blkLenLog2 > KDefaultReadBlockLen) |
472 if (blkLenLog2 > KDefaultReadBlockLen) |
454 { |
473 { |
455 __KTRACE_OPT(KPBUS1, Kern::Printf("=mmc:mrbl %d", blkLenLog2)); |
474 __KTRACE_OPT(KPBUS1, Kern::Printf("=mmc:mrbl %d", blkLenLog2)); |
|
475 OstTrace1( TRACE_INTERNALS, TMMCARD_MAXREADBLLEN1, "Block length 1=%d", blkLenLog2 ); |
|
476 |
|
477 |
456 if (csd.ReadBlPartial() || CSD().SpecVers() >= 4) |
478 if (csd.ReadBlPartial() || CSD().SpecVers() >= 4) |
457 { |
479 { |
458 // |
480 // |
459 // MMC System Spec 4.2 states that 512 bytes blocks are always supported, |
481 // MMC System Spec 4.2 states that 512 bytes blocks are always supported, |
460 // regardless of the state of READ_BL_PARTIAL |
482 // regardless of the state of READ_BL_PARTIAL |
461 // |
483 // |
462 blkLenLog2 = KDefaultReadBlockLen; |
484 blkLenLog2 = KDefaultReadBlockLen; |
463 __KTRACE_OPT(KPBUS1, Kern::Printf("=mmc:mrbl -> %d", blkLenLog2)); |
485 __KTRACE_OPT(KPBUS1, Kern::Printf("=mmc:mrbl -> %d", blkLenLog2)); |
464 } |
486 OstTrace1( TRACE_INTERNALS, TMMCARD_MAXREADBLLEN2, "Block length 2=%d", blkLenLog2 ); |
465 } |
487 } |
466 |
488 } |
|
489 |
|
490 OstTraceFunctionExitExt( TMMCARD_MAXREADBLLEN_EXIT, this, blkLenLog2 ); |
467 return blkLenLog2; |
491 return blkLenLog2; |
468 |
492 |
469 } |
493 } |
470 |
494 |
471 TInt TMMCard::MaxWriteBlLen() const |
495 TInt TMMCard::MaxWriteBlLen() const |
474 * Normally this is the same as the WRITE_BL_LEN field in the CSD register, |
498 * Normally this is the same as the WRITE_BL_LEN field in the CSD register, |
475 * but for high capacity cards (>- 2GB) this is set to a maximum of 512 bytes, |
499 * but for high capacity cards (>- 2GB) this is set to a maximum of 512 bytes, |
476 * if possible, to try to avoid compatibility issues. |
500 * if possible, to try to avoid compatibility issues. |
477 */ |
501 */ |
478 { |
502 { |
|
503 OstTraceFunctionEntry1( TMMCARD_MAXWRITEBLLEN_ENTRY, this ); |
479 const TInt KDefaultWriteBlockLen = 9; // 2^9 = 512 bytes |
504 const TInt KDefaultWriteBlockLen = 9; // 2^9 = 512 bytes |
480 const TCSD& csd = CSD(); |
505 const TCSD& csd = CSD(); |
481 |
506 |
482 TInt blkLenLog2 = csd.WriteBlLen(); |
507 TInt blkLenLog2 = csd.WriteBlLen(); |
483 |
508 |
484 if (blkLenLog2 > KDefaultWriteBlockLen) |
509 if (blkLenLog2 > KDefaultWriteBlockLen) |
485 { |
510 { |
486 __KTRACE_OPT(KPBUS1, Kern::Printf("=mmc:mrbl %d", blkLenLog2)); |
511 __KTRACE_OPT(KPBUS1, Kern::Printf("=mmc:mrbl %d", blkLenLog2)); |
|
512 OstTrace1( TRACE_INTERNALS, TMMCARD_MAXWRITEBLLEN1, "Block length 1=%d", blkLenLog2 ); |
487 if (csd.WriteBlPartial() || CSD().SpecVers() >= 4) |
513 if (csd.WriteBlPartial() || CSD().SpecVers() >= 4) |
488 { |
514 { |
489 // |
515 // |
490 // MMC System Spec 4.2 states that 512 bytes blocks are always supported, |
516 // MMC System Spec 4.2 states that 512 bytes blocks are always supported, |
491 // regardless of the state of READ_BL_PARTIAL |
517 // regardless of the state of READ_BL_PARTIAL |
492 // |
518 // |
493 blkLenLog2 = KDefaultWriteBlockLen; |
519 blkLenLog2 = KDefaultWriteBlockLen; |
494 __KTRACE_OPT(KPBUS1, Kern::Printf("=mmc:mrbl -> %d", blkLenLog2)); |
520 __KTRACE_OPT(KPBUS1, Kern::Printf("=mmc:mrbl -> %d", blkLenLog2)); |
495 } |
521 OstTrace1( TRACE_INTERNALS, TMMCARD_MAXWRITEBLLEN2, "Block length 1=%d", blkLenLog2 ); |
496 } |
522 } |
497 |
523 } |
|
524 |
|
525 OstTraceFunctionExitExt( TMMCARD_MAXWRITEBLLEN_EXIT, this, blkLenLog2 ); |
498 return blkLenLog2; |
526 return blkLenLog2; |
499 |
527 |
500 } |
528 } |
501 |
529 |
502 // -------- class TMMCardArray -------- |
530 // -------- class TMMCardArray -------- |
508 * is no cleanup if it fails. |
536 * is no cleanup if it fails. |
509 * |
537 * |
510 * @return KErrNone if successful, Standard Symbian OS error code otherwise. |
538 * @return KErrNone if successful, Standard Symbian OS error code otherwise. |
511 */ |
539 */ |
512 { |
540 { |
|
541 OstTraceFunctionEntry1( TMMCARDARRAY_ALLOCCARDS_ENTRY, this ); |
513 for (TUint i = 0; i < KMaxMMCardsPerStack; ++i) |
542 for (TUint i = 0; i < KMaxMMCardsPerStack; ++i) |
514 { |
543 { |
515 // zeroing the card data used to be implicit because embedded in |
544 // zeroing the card data used to be implicit because embedded in |
516 // CBase-derived DMMCStack. |
545 // CBase-derived DMMCStack. |
517 if ((iCards[i] = new TMMCard) == 0) |
546 if ((iCards[i] = new TMMCard) == 0) |
|
547 { |
|
548 OstTraceFunctionExitExt( TMMCARDARRAY_ALLOCCARDS_EXIT1, this, KErrNoMemory ); |
518 return KErrNoMemory; |
549 return KErrNoMemory; |
|
550 } |
519 iCards[i]->iUsingSessionP = 0; |
551 iCards[i]->iUsingSessionP = 0; |
520 if ((iNewCards[i] = new TMMCard) == 0) |
552 if ((iNewCards[i] = new TMMCard) == 0) |
|
553 { |
|
554 OstTraceFunctionExitExt( TMMCARDARRAY_ALLOCCARDS_EXIT2, this, KErrNoMemory ); |
521 return KErrNoMemory; |
555 return KErrNoMemory; |
|
556 } |
522 iNewCards[i]->iUsingSessionP = 0; |
557 iNewCards[i]->iUsingSessionP = 0; |
523 } |
558 } |
524 |
559 |
|
560 OstTraceFunctionExitExt( TMMCARDARRAY_ALLOCCARDS_EXIT3, this, KErrNone ); |
525 return KErrNone; |
561 return KErrNone; |
526 } |
562 } |
527 |
563 |
528 void TMMCardArray::InitNewCardScan() |
564 void TMMCardArray::InitNewCardScan() |
529 /** |
565 /** |
530 * Prepare card array for new scan. |
566 * Prepare card array for new scan. |
531 */ |
567 */ |
532 { |
568 { |
|
569 OstTraceFunctionEntry1( TMMCARDARRAY_INITNEWCARDSCAN_ENTRY, this ); |
533 iNewCardsCount=0; |
570 iNewCardsCount=0; |
|
571 OstTraceFunctionExit1( TMMCARDARRAY_INITNEWCARDSCAN_EXIT, this ); |
534 } |
572 } |
535 |
573 |
536 void TMMCardArray::MoveCardAndLockRCA(TMMCard& aSrcCard,TMMCard& aDestCard,TInt aDestIndex) |
574 void TMMCardArray::MoveCardAndLockRCA(TMMCard& aSrcCard,TMMCard& aDestCard,TInt aDestIndex) |
537 /** |
575 /** |
538 * Copy card object and lock RCA. |
576 * Copy card object and lock RCA. |
539 */ |
577 */ |
540 { |
578 { |
|
579 OstTraceExt2(TRACE_FLOW, TMMCARDARRAY_MOVECARDANDLOCKRCA_ENTRY, "TMMCardArray::MoveCardAndLockRCA;aDestIndex=%d;this=%x", aDestIndex, (TUint) this); |
541 __KTRACE_OPT(KPBUS1, Kern::Printf("=mca:mclr:%d", aDestIndex)); |
580 __KTRACE_OPT(KPBUS1, Kern::Printf("=mca:mclr:%d", aDestIndex)); |
542 |
581 |
543 aDestCard.iCID=aSrcCard.iCID; |
582 aDestCard.iCID=aSrcCard.iCID; |
544 aDestCard.iRCA=aSrcCard.iRCA; |
583 aDestCard.iRCA=aSrcCard.iRCA; |
545 aDestCard.iCSD=aSrcCard.iCSD; |
584 aDestCard.iCSD=aSrcCard.iCSD; |
554 aSrcCard.iRCA = aSrcCard.iIndex = aSrcCard.iFlags = 0; |
593 aSrcCard.iRCA = aSrcCard.iIndex = aSrcCard.iFlags = 0; |
555 aSrcCard.iBusWidth = 1; |
594 aSrcCard.iBusWidth = 1; |
556 aSrcCard.iHighSpeedClock = 0; |
595 aSrcCard.iHighSpeedClock = 0; |
557 |
596 |
558 aSrcCard.iUsingSessionP = NULL; |
597 aSrcCard.iUsingSessionP = NULL; |
|
598 OstTraceFunctionExit1( TMMCARDARRAY_MOVECARDANDLOCKRCA_EXIT, this ); |
559 } |
599 } |
560 |
600 |
561 EXPORT_C void TMMCardArray::AddNewCard(const TUint8* aCID,TRCA* aNewRCA) |
601 EXPORT_C void TMMCardArray::AddNewCard(const TUint8* aCID,TRCA* aNewRCA) |
562 /** |
602 /** |
563 * Found a new card to add to the array. Add it to a separate array for now |
603 * Found a new card to add to the array. Add it to a separate array for now |
564 * since we need to know all the cards present before we start replacing old |
604 * since we need to know all the cards present before we start replacing old |
565 * entries. |
605 * entries. |
566 */ |
606 */ |
567 { |
607 { |
|
608 OstTraceFunctionEntryExt( TMMCARDARRAY_ADDNEWCARD_ENTRY, this ); |
568 // Store the CID in the next free slot |
609 // Store the CID in the next free slot |
569 NewCard(iNewCardsCount).iCID = aCID; |
610 NewCard(iNewCardsCount).iCID = aCID; |
570 |
611 |
571 *aNewRCA=0; |
612 *aNewRCA=0; |
572 |
613 |
587 NewCard(iNewCardsCount).iIndex=0; |
628 NewCard(iNewCardsCount).iIndex=0; |
588 __ASSERT_ALWAYS( (*aNewRCA=iOwningStack->iRCAPool.GetFreeRCA())!=0,DMMCSocket::Panic(DMMCSocket::EMMCNoFreeRCA) ); |
629 __ASSERT_ALWAYS( (*aNewRCA=iOwningStack->iRCAPool.GetFreeRCA())!=0,DMMCSocket::Panic(DMMCSocket::EMMCNoFreeRCA) ); |
589 } |
630 } |
590 |
631 |
591 __KTRACE_OPT(KPBUS1, Kern::Printf("mca:adn: assigning new card %d rca 0x%04x", iNewCardsCount, TUint16(*aNewRCA) )); |
632 __KTRACE_OPT(KPBUS1, Kern::Printf("mca:adn: assigning new card %d rca 0x%04x", iNewCardsCount, TUint16(*aNewRCA) )); |
|
633 OstTraceExt2( TRACE_INTERNALS, TMMCARDARRAY_ADDNEWCARD, "iNewCardsCount=%d; RCA=0x%04x", iNewCardsCount, (TUint) *aNewRCA ); |
|
634 |
592 NewCard(iNewCardsCount).iRCA=*aNewRCA; |
635 NewCard(iNewCardsCount).iRCA=*aNewRCA; |
593 iNewCardsCount++; |
636 iNewCardsCount++; |
|
637 OstTraceFunctionExit1( TMMCARDARRAY_ADDNEWCARD_EXIT, this ); |
594 } |
638 } |
595 |
639 |
596 TInt TMMCardArray::MergeCards(TBool aFirstPass) |
640 TInt TMMCardArray::MergeCards(TBool aFirstPass) |
597 /** |
641 /** |
598 * This function places newly acquired cards from the new card array into free |
642 * This function places newly acquired cards from the new card array into free |
599 * slots of the main card array. |
643 * slots of the main card array. |
600 * Returns KErrNotFound if not able to successfully place all the new cards. |
644 * Returns KErrNotFound if not able to successfully place all the new cards. |
601 */ |
645 */ |
602 { |
646 { |
603 |
647 OstTraceFunctionEntryExt( TMMCARDARRAY_MERGECARDS_ENTRY, this ); |
|
648 |
|
649 |
604 __KTRACE_OPT(KPBUS1,Kern::Printf("=mca:mc:%d,%d", aFirstPass, iNewCardsCount)); |
650 __KTRACE_OPT(KPBUS1,Kern::Printf("=mca:mc:%d,%d", aFirstPass, iNewCardsCount)); |
|
651 OstTrace1( TRACE_INTERNALS, TMMCARDARRAY_MERGECARDS1, "iNewCardsCount=%d", iNewCardsCount ); |
|
652 |
605 TUint i; // New card index |
653 TUint i; // New card index |
606 TUint j; // Main card index |
654 TUint j; // Main card index |
607 |
655 |
608 // Only do this on first pass. Setup any new cards which were already there |
656 // Only do this on first pass. Setup any new cards which were already there |
609 if (aFirstPass) |
657 if (aFirstPass) |
610 { |
658 { |
611 for ( i=0 ; i<iNewCardsCount ; i++ ) |
659 for ( i=0 ; i<iNewCardsCount ; i++ ) |
612 { |
660 { |
613 __KTRACE_OPT(KPBUS1, Kern::Printf("-mca:fp,i=%d,idx=0x%x", i, NewCard(i).iIndex)); |
661 __KTRACE_OPT(KPBUS1, Kern::Printf("-mca:fp,i=%d,idx=0x%x", i, NewCard(i).iIndex)); |
|
662 OstTraceExt2( TRACE_INTERNALS, TMMCARDARRAY_MERGECARDS2, "i=%d; Index=0x%x", i, NewCard(i).iIndex ); |
614 if( NewCard(i).iIndex != 0 ) // Signifies card was here before (iIndex has old slot number +1) |
663 if( NewCard(i).iIndex != 0 ) // Signifies card was here before (iIndex has old slot number +1) |
615 { |
664 { |
616 // Put it in the same slot as before |
665 // Put it in the same slot as before |
617 j=(NewCard(i).iIndex-1); |
666 j=(NewCard(i).iIndex-1); |
618 MoveCardAndLockRCA(NewCard(i),Card(j),(j+1)); |
667 MoveCardAndLockRCA(NewCard(i),Card(j),(j+1)); |
626 if ( NewCard(i).iRCA != 0 ) |
675 if ( NewCard(i).iRCA != 0 ) |
627 { |
676 { |
628 // Find a spare slot in main array for this new card |
677 // Find a spare slot in main array for this new card |
629 while ( Card(j).IsPresent() ) |
678 while ( Card(j).IsPresent() ) |
630 if ( ++j==iOwningStack->iMaxCardsInStack ) |
679 if ( ++j==iOwningStack->iMaxCardsInStack ) |
631 return(KErrNotFound); |
680 { |
|
681 OstTraceFunctionExitExt( TMMCARDARRAY_MERGECARDS_EXIT1, this, KErrNotFound ); |
|
682 return KErrNotFound; |
|
683 } |
632 |
684 |
633 // Found a free slot; move the card info there |
685 // Found a free slot; move the card info there |
634 __KTRACE_OPT(KPBUS1, Kern::Printf("-mca:freej=%d,rca=0x%04x", j, TUint16(Card(j).iRCA) )); |
686 __KTRACE_OPT(KPBUS1, Kern::Printf("-mca:freej=%d,rca=0x%04x", j, TUint16(Card(j).iRCA) )); |
|
687 OstTraceExt2( TRACE_INTERNALS, TMMCARDARRAY_MERGECARDS3, "j=%d; RCA=0x%04x", j, (TUint) (Card(j).iRCA) ); |
635 if ( Card(j).iRCA != 0 ) |
688 if ( Card(j).iRCA != 0 ) |
636 iOwningStack->iRCAPool.UnlockRCA(Card(j).iRCA); |
689 iOwningStack->iRCAPool.UnlockRCA(Card(j).iRCA); |
637 |
690 |
638 __KTRACE_OPT(KPBUS1, Kern::Printf("merging new card %d to card %d dest index %d", i, j, j+1)); |
691 __KTRACE_OPT(KPBUS1, Kern::Printf("merging new card %d to card %d dest index %d", i, j, j+1)); |
|
692 OstTraceExt3( TRACE_INTERNALS, TMMCARDARRAY_MERGECARDS4, "Merging new card %d to card %d; Destination index=%d", (TInt) i, (TInt) j, (TInt) j+1 ); |
639 MoveCardAndLockRCA(NewCard(i),Card(j),(j+1)); |
693 MoveCardAndLockRCA(NewCard(i),Card(j),(j+1)); |
640 } |
694 } |
641 } |
695 } |
642 return(KErrNone); |
696 OstTraceFunctionExitExt( TMMCARDARRAY_MERGECARDS_EXIT2, this, KErrNone ); |
|
697 return KErrNone; |
643 } |
698 } |
644 |
699 |
645 void TMMCardArray::UpdateAcquisitions(TUint* aMaxClock) |
700 void TMMCardArray::UpdateAcquisitions(TUint* aMaxClock) |
646 /** |
701 /** |
647 * Called when we have successfully stored a new set of cards in the card array. |
702 * Called when we have successfully stored a new set of cards in the card array. |
648 * This performs final initialisation of the card entries and determines the |
703 * This performs final initialisation of the card entries and determines the |
649 * maximum bus clock that can be employed - by checking the CSD of each card. |
704 * maximum bus clock that can be employed - by checking the CSD of each card. |
650 */ |
705 */ |
651 { |
706 { |
652 |
707 OstTraceFunctionEntryExt( TMMCARDARRAY_UPDATEACQUISITIONS_ENTRY, this ); |
|
708 |
653 __KTRACE_OPT(KPBUS1,Kern::Printf("=mca:uda")); |
709 __KTRACE_OPT(KPBUS1,Kern::Printf("=mca:uda")); |
654 iCardsPresent=0; |
710 iCardsPresent=0; |
655 TUint maxClk = iOwningStack->iMultiplexedBus ? 1 : 800000; // ??? |
711 TUint maxClk = iOwningStack->iMultiplexedBus ? 1 : 800000; // ??? |
656 for ( TUint i=0 ; i < (iOwningStack->iMaxCardsInStack) ; i++ ) |
712 for ( TUint i=0 ; i < (iOwningStack->iMaxCardsInStack) ; i++ ) |
657 { |
713 { |
704 card.iUsingSessionP=NULL; |
762 card.iUsingSessionP=NULL; |
705 card.iSetBlockLen=0; |
763 card.iSetBlockLen=0; |
706 card.iFlags=0; // Reset 'has password' and 'write protected' bit fields |
764 card.iFlags=0; // Reset 'has password' and 'write protected' bit fields |
707 card.iHighSpeedClock=0; |
765 card.iHighSpeedClock=0; |
708 card.iBusWidth=1; |
766 card.iBusWidth=1; |
|
767 OstTraceFunctionExit1( TMMCARDARRAY_DECLARECARDASGONE_EXIT, this ); |
709 } |
768 } |
710 |
769 |
711 // return this card's index in the array or KErrNotFound if not found |
770 // return this card's index in the array or KErrNotFound if not found |
712 TInt TMMCardArray::CardIndex(const TMMCard* aCard) |
771 TInt TMMCardArray::CardIndex(const TMMCard* aCard) |
713 { |
772 { |
|
773 OstTraceFunctionEntryExt( TMMCARDARRAY_CARDINDEX_ENTRY, this ); |
714 TInt i; |
774 TInt i; |
715 for (i = KMaxMMCardsPerStack-1; i>= 0; i--) |
775 for (i = KMaxMMCardsPerStack-1; i>= 0; i--) |
716 { |
776 { |
717 if (iCards[i] == aCard) |
777 if (iCards[i] == aCard) |
718 break; |
778 break; |
719 } |
779 } |
|
780 OstTraceFunctionExitExt( TMMCARDARRAY_CARDINDEX_EXIT, this, i ); |
720 return i; |
781 return i; |
721 } |
782 } |
722 |
783 |
723 // -------- class TMMCCommandDesc -------- |
784 // -------- class TMMCCommandDesc -------- |
724 |
785 |
725 EXPORT_C TInt TMMCCommandDesc::Direction() const |
786 EXPORT_C TInt TMMCCommandDesc::Direction() const |
726 /** |
787 /** |
727 * returns -1, 0 or +1 for DT directions read, none or write respectively |
788 * returns -1, 0 or +1 for DT directions read, none or write respectively |
728 */ |
789 */ |
729 { |
790 { |
|
791 OstTraceFunctionEntry1( TMMCCOMMANDDESC_DIRECTION_ENTRY, this ); |
730 TUint dir = iSpec.iDirection; |
792 TUint dir = iSpec.iDirection; |
731 TInt result = dir; |
793 TInt result = dir; |
|
794 TInt ret; |
732 |
795 |
733 if( dir == 0 ) |
796 if( dir == 0 ) |
734 return( 0 ); |
797 { |
|
798 ret = 0; |
|
799 OstTraceFunctionExitExt( TMMCCOMMANDDESC_DIRECTION_EXIT1, this, ret ); |
|
800 return ret; |
|
801 } |
735 |
802 |
736 if( dir & KMMCCmdDirWBitArgument ) |
803 if( dir & KMMCCmdDirWBitArgument ) |
737 result = TUint(iArgument) >> (dir & KMMCCmdDirIndBitPosition); |
804 result = TUint(iArgument) >> (dir & KMMCCmdDirIndBitPosition); |
738 |
805 |
739 if( dir & KMMCCmdDirNegate ) |
806 if( dir & KMMCCmdDirNegate ) |
740 result = ~result; |
807 result = ~result; |
741 |
808 |
742 return( ((result&1)-1)|1 ); |
809 ret = ((result&1)-1)|1; |
|
810 |
|
811 OstTraceFunctionExitExt( TMMCCOMMANDDESC_DIRECTION_EXIT2, this, ret ); |
|
812 return ret; |
743 } |
813 } |
744 |
814 |
745 |
815 |
746 TBool TMMCCommandDesc::AdjustForBlockOrByteAccess(const DMMCSession& aSession) |
816 TBool TMMCCommandDesc::AdjustForBlockOrByteAccess(const DMMCSession& aSession) |
747 { |
817 { |
|
818 OstTraceExt2(TRACE_FLOW, TMMCCOMMANDDESC_ADJUSTFORBLOCKORBYTEACCESS_ENTRY, "TMMCCommandDesc::AdjustForBlockOrByteAccess;Session ID=%d;this=%x", (TInt) aSession.SessionID(), (TUint) this); |
748 /** |
819 /** |
749 * The MMC session provides both block and byte based IO methods, all of which can |
820 * The MMC session provides both block and byte based IO methods, all of which can |
750 * be used on both block and byte based MMC cards. This method adjusts the command |
821 * be used on both block and byte based MMC cards. This method adjusts the command |
751 * arguments so that they match the underlying cards access mode. |
822 * arguments so that they match the underlying cards access mode. |
752 * |
823 * |
790 const TUint32 maxBlocks = 4 * 1024 * ((1024 * 1024) >> KMMCardHighCapBlockSizeLog2); |
863 const TUint32 maxBlocks = 4 * 1024 * ((1024 * 1024) >> KMMCardHighCapBlockSizeLog2); |
791 |
864 |
792 if(iArgument > maxBlocks) |
865 if(iArgument > maxBlocks) |
793 { |
866 { |
794 // The address is out of range (>2G) - cannot convert |
867 // The address is out of range (>2G) - cannot convert |
795 return(EFalse); |
868 OstTraceFunctionExitExt( TMMCCOMMANDDESC_ADJUSTFORBLOCKORBYTEACCESS_EXIT3, this, (TUint) EFalse ); |
|
869 return EFalse; |
796 } |
870 } |
797 |
871 |
798 // adjust for byte-based access |
872 // adjust for byte-based access |
799 iArgument = iArgument << KMMCardHighCapBlockSizeLog2; |
873 iArgument = iArgument << KMMCardHighCapBlockSizeLog2; |
800 iFlags &= ~KMMCCmdFlagBlockAddress; |
874 iFlags &= ~KMMCCmdFlagBlockAddress; |
801 } |
875 } |
802 else if(iArgument % KMMCardHighCapBlockSize != 0) |
876 else if(iArgument % KMMCardHighCapBlockSize != 0) |
803 { |
877 { |
804 // byte addressing, unaligned address |
878 // byte addressing, unaligned address |
805 return(EFalse); |
879 OstTraceFunctionExitExt( TMMCCOMMANDDESC_ADJUSTFORBLOCKORBYTEACCESS_EXIT4, this, (TUint) EFalse ); |
806 } |
880 return EFalse; |
807 } |
881 } |
808 |
882 } |
809 return(ETrue); |
883 |
|
884 OstTraceFunctionExitExt( TMMCCOMMANDDESC_ADJUSTFORBLOCKORBYTEACCESS_EXIT5, this, (TUint) ETrue ); |
|
885 return ETrue; |
810 } |
886 } |
811 |
887 |
812 void TMMCCommandDesc::Dump(TUint8* aResponseP, TMMCErr aErr) |
888 void TMMCCommandDesc::Dump(TUint8* aResponseP, TMMCErr aErr) |
813 { |
889 { |
814 |
890 |
1028 TBool TMMCSessRing::Point(DMMCSession* aSessP) |
1116 TBool TMMCSessRing::Point(DMMCSession* aSessP) |
1029 /** |
1117 /** |
1030 * Finds aSessP and sets Point to that position |
1118 * Finds aSessP and sets Point to that position |
1031 */ |
1119 */ |
1032 { |
1120 { |
|
1121 OstTraceFunctionEntryExt( TMMCSESSRING_POINT_ENTRY, this ); |
1033 Point(); |
1122 Point(); |
1034 |
1123 |
1035 while( iPoint != NULL ) |
1124 while( iPoint != NULL ) |
1036 if( iPoint == aSessP ) |
1125 if( iPoint == aSessP ) |
1037 return( ETrue ); |
1126 { |
|
1127 OstTraceFunctionExitExt( TMMCSESSRING_POINT_EXIT1, this, (TUint) ETrue ); |
|
1128 return ETrue; |
|
1129 } |
1038 else |
1130 else |
1039 this->operator++(0); |
1131 this->operator++(0); |
1040 |
1132 |
1041 return( EFalse ); |
1133 OstTraceFunctionExitExt( TMMCSESSRING_POINT_EXIT2, this, (TUint) EFalse ); |
|
1134 return EFalse; |
1042 } |
1135 } |
1043 |
1136 |
1044 void TMMCSessRing::Add(DMMCSession* aSessP) |
1137 void TMMCSessRing::Add(DMMCSession* aSessP) |
1045 /** |
1138 /** |
1046 * Inserts aSessP before Marker. Point is moved into the Marker position. |
1139 * Inserts aSessP before Marker. Point is moved into the Marker position. |
1047 */ |
1140 */ |
1048 { |
1141 { |
|
1142 OstTraceFunctionEntryExt( TMMCSESSRING_ADD1_ENTRY, this ); |
1049 if( iSize == 0 ) |
1143 if( iSize == 0 ) |
1050 { |
1144 { |
1051 iPMark = iPrevP = iPoint = aSessP; |
1145 iPMark = iPrevP = iPoint = aSessP; |
1052 aSessP->iLinkP = aSessP; |
1146 aSessP->iLinkP = aSessP; |
1053 iSize = 1; |
1147 iSize = 1; |
|
1148 OstTraceFunctionExit1( TMMCSESSRING_ADD1_EXIT1, this ); |
1054 return; |
1149 return; |
1055 } |
1150 } |
1056 |
1151 |
1057 iPoint = iPMark->iLinkP; |
1152 iPoint = iPMark->iLinkP; |
1058 iPMark->iLinkP = aSessP; |
1153 iPMark->iLinkP = aSessP; |
1059 aSessP->iLinkP = iPoint; |
1154 aSessP->iLinkP = iPoint; |
1060 iPMark = iPrevP = aSessP; |
1155 iPMark = iPrevP = aSessP; |
1061 iSize++; |
1156 iSize++; |
|
1157 OstTraceFunctionExit1( TMMCSESSRING_ADD1_EXIT2, this ); |
1062 } |
1158 } |
1063 |
1159 |
1064 |
1160 |
1065 void TMMCSessRing::Add(TMMCSessRing& aRing) |
1161 void TMMCSessRing::Add(TMMCSessRing& aRing) |
1066 /** |
1162 /** |
1067 * Inserts aRing before Marker. Point is moved into the Marker position. |
1163 * Inserts aRing before Marker. Point is moved into the Marker position. |
1068 * aRing Marker becomes the fisrt inserted element. |
1164 * aRing Marker becomes the fisrt inserted element. |
1069 * Erases aRing. |
1165 * Erases aRing. |
1070 */ |
1166 */ |
1071 { |
1167 { |
|
1168 OstTraceFunctionEntry1( TMMCSESSRING_ADD2_ENTRY, this ); |
1072 Point(); |
1169 Point(); |
1073 |
1170 |
1074 if( aRing.iSize == 0 ) |
1171 if( aRing.iSize == 0 ) |
|
1172 { |
|
1173 OstTraceFunctionExit1( TMMCSESSRING_ADD2_EXIT1, this ); |
1075 return; |
1174 return; |
|
1175 } |
1076 |
1176 |
1077 if( iSize == 0 ) |
1177 if( iSize == 0 ) |
1078 { |
1178 { |
1079 iPrevP = iPMark = aRing.iPMark; |
1179 iPrevP = iPMark = aRing.iPMark; |
1080 iPoint = iPrevP->iLinkP; |
1180 iPoint = iPrevP->iLinkP; |
1318 /** |
1434 /** |
1319 * Initialises the generic MMC stack. |
1435 * Initialises the generic MMC stack. |
1320 * @return KErrNone if successful, standard error code otherwise. |
1436 * @return KErrNone if successful, standard error code otherwise. |
1321 */ |
1437 */ |
1322 { |
1438 { |
|
1439 OstTraceFunctionEntry1( DMMCSTACK_INIT_ENTRY, this ); |
1323 // allocate and initialize session object |
1440 // allocate and initialize session object |
1324 if ((iStackSession = AllocSession(TMMCCallBack(StackSessionCBST, this))) == 0) |
1441 if ((iStackSession = AllocSession(TMMCCallBack(StackSessionCBST, this))) == 0) |
1325 return(KErrNoMemory); |
1442 { |
|
1443 OstTraceFunctionExitExt( DMMCSTACK_INIT_EXIT1, this, KErrNoMemory ); |
|
1444 return KErrNoMemory; |
|
1445 } |
1326 |
1446 |
1327 // create helper class |
1447 // create helper class |
1328 if ((iBody = new DBody(*this)) == NULL) |
1448 if ((iBody = new DBody(*this)) == NULL) |
1329 return(KErrNoMemory); |
1449 { |
|
1450 OstTraceFunctionExitExt( DMMCSTACK_INIT_EXIT2, this, KErrNoMemory ); |
|
1451 return KErrNoMemory; |
|
1452 } |
1330 |
1453 |
1331 iStackSession->SetStack(this); |
1454 iStackSession->SetStack(this); |
1332 |
1455 |
1333 iStackDFC.SetDfcQ(&iSocket->iDfcQ); |
1456 iStackDFC.SetDfcQ(&iSocket->iDfcQ); |
1334 |
1457 |
1337 if ( iMaxCardsInStack > KMaxMMCardsPerStack ) |
1460 if ( iMaxCardsInStack > KMaxMMCardsPerStack ) |
1338 iMaxCardsInStack=KMaxMMCardsPerStack; |
1461 iMaxCardsInStack=KMaxMMCardsPerStack; |
1339 |
1462 |
1340 TInt r = iCardArray->AllocCards(); |
1463 TInt r = iCardArray->AllocCards(); |
1341 |
1464 |
1342 return(r); |
1465 OstTraceFunctionExitExt( DMMCSTACK_INIT_EXIT3, this, r ); |
|
1466 return r; |
1343 } |
1467 } |
1344 |
1468 |
1345 EXPORT_C void DMMCStack::PowerUpStack() |
1469 EXPORT_C void DMMCStack::PowerUpStack() |
1346 /** |
1470 /** |
1347 * Enforce stack power-up and initialisation. |
1471 * Enforce stack power-up and initialisation. |
1348 * This is an asynchronous operation, which calls DMMCSocket::PowerUpSequenceComplete upon completion. |
1472 * This is an asynchronous operation, which calls DMMCSocket::PowerUpSequenceComplete upon completion. |
1349 */ |
1473 */ |
1350 { |
1474 { |
|
1475 OstTraceFunctionEntry1( DMMCSTACK_POWERUPSTACK_ENTRY, this ); |
1351 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:pus")); |
1476 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:pus")); |
1352 |
1477 |
1353 if (iPSLBuf == NULL) |
1478 if (iPSLBuf == NULL) |
1354 { |
1479 { |
1355 GetBufferInfo(&iPSLBuf, &iPSLBufLen); |
1480 GetBufferInfo(&iPSLBuf, &iPSLBufLen); |
1433 // The stack may have powered down while attempting to power up (e.g. because a card has not responded), |
1562 // The stack may have powered down while attempting to power up (e.g. because a card has not responded), |
1434 // so ensure stack doesn't attempt to initialize itself again until next PowerUpStack() |
1563 // so ensure stack doesn't attempt to initialize itself again until next PowerUpStack() |
1435 iInitialise = EFalse; |
1564 iInitialise = EFalse; |
1436 iStackState &= ~(KMMCStackStateInitInProgress | KMMCStackStateInitPending | KMMCStackStateBusInconsistent | KMMCStackStateWaitingDFC); |
1565 iStackState &= ~(KMMCStackStateInitInProgress | KMMCStackStateInitPending | KMMCStackStateBusInconsistent | KMMCStackStateWaitingDFC); |
1437 iSessionP = NULL; |
1566 iSessionP = NULL; |
|
1567 OstTraceFunctionExit1( DMMCSTACK_POWERDOWNSTACK_EXIT, this ); |
1438 } |
1568 } |
1439 |
1569 |
1440 // |
1570 // |
1441 // DMMCStack:: --- Stack Scheduler and its supplementary functions --- |
1571 // DMMCStack:: --- Stack Scheduler and its supplementary functions --- |
1442 // |
1572 // |
1443 DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedGetOnDFC() |
1573 DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedGetOnDFC() |
1444 /** |
1574 /** |
1445 * Initiates stack DFC. Returns either Continue or Loop. |
1575 * Initiates stack DFC. Returns either Continue or Loop. |
1446 */ |
1576 */ |
1447 { |
1577 { |
|
1578 OstTraceFunctionEntry1( DMMCSTACK_SCHEDGETONDFC_ENTRY, this ); |
1448 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sgd")); |
1579 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sgd")); |
1449 |
1580 |
1450 if( iDFCRunning ) |
1581 if( iDFCRunning ) |
1451 return( ESchedContinue ); |
1582 { |
|
1583 OstTraceFunctionExitExt( DMMCSTACK_SCHEDGETONDFC_EXIT1, this, (TInt) ESchedContinue); |
|
1584 return ESchedContinue; |
|
1585 } |
1452 |
1586 |
1453 if( (iStackState & KMMCStackStateWaitingDFC) == 0 ) |
1587 if( (iStackState & KMMCStackStateWaitingDFC) == 0 ) |
1454 { |
1588 { |
1455 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sgd:q")); |
1589 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sgd:q")); |
1456 iStackState |= KMMCStackStateWaitingDFC; |
1590 iStackState |= KMMCStackStateWaitingDFC; |
1458 iStackDFC.Add(); |
1592 iStackDFC.Add(); |
1459 else |
1593 else |
1460 iStackDFC.Enque(); |
1594 iStackDFC.Enque(); |
1461 } |
1595 } |
1462 |
1596 |
1463 return( ESchedLoop ); |
1597 OstTraceFunctionExitExt( DMMCSTACK_SCHEDGETONDFC_EXIT2, this, (TInt) ESchedLoop); |
|
1598 return ESchedLoop; |
1464 } |
1599 } |
1465 |
1600 |
1466 void DMMCStack::SchedSetContext(DMMCSession* aSessP) |
1601 void DMMCStack::SchedSetContext(DMMCSession* aSessP) |
1467 /** |
1602 /** |
1468 * Sets up the specified session as the current session. |
1603 * Sets up the specified session as the current session. |
1469 * Invoked by JobChooser and Initialiser. |
1604 * Invoked by JobChooser and Initialiser. |
1470 * @param aSessP A pointer to the session. |
1605 * @param aSessP A pointer to the session. |
1471 */ |
1606 */ |
1472 { |
1607 { |
|
1608 OstTraceFunctionEntry1( DMMCSTACK_SCHEDSETCONTEXT_ENTRY, this ); |
1473 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ssc")); |
1609 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ssc")); |
1474 |
1610 |
1475 if( (iStackState & (KMMCStackStateInitPending|KMMCStackStateBusInconsistent)) != 0 && |
1611 if( (iStackState & (KMMCStackStateInitPending|KMMCStackStateBusInconsistent)) != 0 && |
1476 aSessP->iSessionID != ECIMInitStack ) |
1612 aSessP->iSessionID != ECIMInitStack ) |
1477 { |
1613 { |
1478 iInitialise = ETrue; |
1614 iInitialise = ETrue; |
|
1615 OstTraceFunctionExit1( DMMCSTACK_SCHEDSETCONTEXT_EXIT1, this ); |
1479 return; |
1616 return; |
1480 } |
1617 } |
1481 |
1618 |
1482 if( iSessionP != aSessP ) |
1619 if( iSessionP != aSessP ) |
1483 { |
1620 { |
1530 |
1669 |
1531 |
1670 |
1532 (void)__e32_atomic_and_ord32(&aSessP->iBlockOn, ~(KMMCBlockOnPollTimer | KMMCBlockOnRetryTimer | |
1671 (void)__e32_atomic_and_ord32(&aSessP->iBlockOn, ~(KMMCBlockOnPollTimer | KMMCBlockOnRetryTimer | |
1533 KMMCBlockOnWaitToLock | KMMCBlockOnASSPFunction | |
1672 KMMCBlockOnWaitToLock | KMMCBlockOnASSPFunction | |
1534 KMMCBlockOnInterrupt | KMMCBlockOnDataTransfer) ); |
1673 KMMCBlockOnInterrupt | KMMCBlockOnDataTransfer) ); |
|
1674 OstTraceFunctionExit1( DMMCSTACK_SCHEDDOABORT_EXIT, this ); |
1535 } |
1675 } |
1536 |
1676 |
1537 DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedResolveStatBlocks(DMMCSession* aSessP) |
1677 DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedResolveStatBlocks(DMMCSession* aSessP) |
1538 /** |
1678 /** |
1539 * Checks static blocking conditions and removes them as necessary |
1679 * Checks static blocking conditions and removes them as necessary |
1540 * @param aSessP A pointer to the session. |
1680 * @param aSessP A pointer to the session. |
1541 * @return EschedContinue or ESchedLoop (if scheduler is to be restarted) |
1681 * @return EschedContinue or ESchedLoop (if scheduler is to be restarted) |
1542 */ |
1682 */ |
1543 { |
1683 { |
|
1684 OstTraceFunctionEntryExt( DMMCSTACK_SCHEDRESOLVESTATBLOCKS_ENTRY, this ); |
1544 |
1685 |
1545 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:srsb")); |
1686 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:srsb")); |
1546 |
1687 |
1547 if( (aSessP->iBlockOn & KMMCBlockOnCardInUse) && aSessP->iCardP->iUsingSessionP == NULL ) |
1688 if( (aSessP->iBlockOn & KMMCBlockOnCardInUse) && aSessP->iCardP->iUsingSessionP == NULL ) |
1548 aSessP->SynchUnBlock( KMMCBlockOnCardInUse ); |
1689 aSessP->SynchUnBlock( KMMCBlockOnCardInUse ); |
1552 // ECIMLockStack processed here |
1693 // ECIMLockStack processed here |
1553 iLockingSessionP = aSessP; // in this order |
1694 iLockingSessionP = aSessP; // in this order |
1554 iStackState &= ~KMMCStackStateWaitingToLock; |
1695 iStackState &= ~KMMCStackStateWaitingToLock; |
1555 aSessP->SynchUnBlock( KMMCBlockOnWaitToLock ); |
1696 aSessP->SynchUnBlock( KMMCBlockOnWaitToLock ); |
1556 MarkComplete( aSessP, KMMCErrNone ); |
1697 MarkComplete( aSessP, KMMCErrNone ); |
1557 return( ESchedLoop ); |
1698 OstTraceFunctionExitExt( DMMCSTACK_SCHEDRESOLVESTATBLOCKS_EXIT1, this, (TInt) ESchedLoop ); |
1558 } |
1699 return ESchedLoop; |
1559 |
1700 } |
1560 return( ESchedContinue ); |
1701 |
|
1702 OstTraceFunctionExitExt( DMMCSTACK_SCHEDRESOLVESTATBLOCKS_EXIT2, this, (TInt) ESchedContinue ); |
|
1703 return ESchedContinue; |
1561 } |
1704 } |
1562 |
1705 |
1563 DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedGroundDown(DMMCSession* aSessP, TMMCErr aReason) |
1706 DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedGroundDown(DMMCSession* aSessP, TMMCErr aReason) |
1564 /** |
1707 /** |
1565 * Aborts all asynchronous activities of session aSessP with |
1708 * Aborts all asynchronous activities of session aSessP with |
1573 * @return ESchedLoop if the session can not be safely grounded (eg |
1716 * @return ESchedLoop if the session can not be safely grounded (eg |
1574 * iStackSession) and should therefore be aborted and/or completed by a |
1717 * iStackSession) and should therefore be aborted and/or completed by a |
1575 * separate scheduler pass. |
1718 * separate scheduler pass. |
1576 */ |
1719 */ |
1577 { |
1720 { |
|
1721 OstTraceExt3(TRACE_FLOW, DMMCSTACK_SCHEDGROUNDDOWN_ENTRY, "DMMCStack::SchedGroundDown;aSessionP=%x;aReason=%d;this=%x", (TUint) aSessP, (TInt) aReason, (TUint) this); |
1578 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sgdn")); |
1722 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sgdn")); |
1579 |
1723 |
1580 if( (aSessP == iStackSession) || InitStackInProgress() ) |
1724 if( (aSessP == iStackSession) || InitStackInProgress() ) |
1581 return( ESchedLoop ); |
1725 { |
|
1726 OstTraceFunctionExitExt( DMMCSTACK_SCHEDGROUNDDOWN_EXIT1, this, (TInt) ESchedLoop ); |
|
1727 return ESchedLoop; |
|
1728 } |
1582 |
1729 |
1583 if( aSessP->iState & KMMCSessStateInProgress ) |
1730 if( aSessP->iState & KMMCSessStateInProgress ) |
1584 { |
1731 { |
1585 SchedDoAbort( aSessP ); |
1732 SchedDoAbort( aSessP ); |
1586 //coverity[check_return] |
1733 //coverity[check_return] |
1588 aSessP->iMachine.SetExitCode( aReason ); |
1735 aSessP->iMachine.SetExitCode( aReason ); |
1589 aSessP->iState &= ~(KMMCSessStateSafeInGaps | KMMCSessStateDoReSchedule | |
1736 aSessP->iState &= ~(KMMCSessStateSafeInGaps | KMMCSessStateDoReSchedule | |
1590 KMMCSessStateDoDFC); |
1737 KMMCSessStateDoDFC); |
1591 } |
1738 } |
1592 |
1739 |
1593 return( ESchedContinue ); |
1740 OstTraceFunctionExitExt( DMMCSTACK_SCHEDGROUNDDOWN_EXIT2, this, (TInt) ESchedContinue ); |
|
1741 return ESchedContinue; |
1594 } |
1742 } |
1595 |
1743 |
1596 DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedEnqueStackSession(TMMCSessionTypeEnum aSessID) |
1744 DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedEnqueStackSession(TMMCSessionTypeEnum aSessID) |
1597 /** |
1745 /** |
1598 * Prepare internal session for InitStack and enque it into WorkSet. |
1746 * Prepare internal session for InitStack and enque it into WorkSet. |
1599 * @return EschedContinue or ESchedLoop |
1747 * @return EschedContinue or ESchedLoop |
1600 */ |
1748 */ |
1601 { |
1749 { |
|
1750 OstTraceExt2(TRACE_FLOW, DMMCSTACK_SCHEDENQUESTACKSESSION_ENTRY ,"DMMCStack::SchedEnqueStackSession;aSessID=%d;this=%x", (TInt) aSessID, (TUint) this); |
1602 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sess")); |
1751 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sess")); |
1603 |
1752 |
1604 if( iStackSession->IsEngaged() ) |
1753 if( iStackSession->IsEngaged() ) |
1605 { |
1754 { |
1606 MarkComplete( iStackSession, KMMCErrAbort ); |
1755 MarkComplete( iStackSession, KMMCErrAbort ); |
1607 return( ESchedLoop ); |
1756 OstTraceFunctionExitExt( DMMCSTACK_SCHEDENQUESTACKSESSION_EXIT1, this, (TInt) ESchedLoop ); |
|
1757 return ESchedLoop; |
1608 } |
1758 } |
1609 |
1759 |
1610 iStackSession->SetupCIMControl( aSessID ); |
1760 iStackSession->SetupCIMControl( aSessID ); |
1611 iWorkSet.Add( iStackSession ); |
1761 iWorkSet.Add( iStackSession ); |
1612 iStackSession->iState |= KMMCSessStateEngaged; |
1762 iStackSession->iState |= KMMCSessStateEngaged; |
1613 return( ESchedContinue ); |
1763 OstTraceFunctionExitExt( DMMCSTACK_SCHEDENQUESTACKSESSION_EXIT2, this, (TInt) ESchedContinue ); |
|
1764 return ESchedContinue; |
1614 } |
1765 } |
1615 |
1766 |
1616 void DMMCStack::SchedGrabEntries() |
1767 void DMMCStack::SchedGrabEntries() |
1617 /** |
1768 /** |
1618 * Merges Entry queue into Ready queue. Invoked at the scheduler entry and |
1769 * Merges Entry queue into Ready queue. Invoked at the scheduler entry and |
1619 * after the completion pass |
1770 * after the completion pass |
1620 */ |
1771 */ |
1621 { |
1772 { |
|
1773 OstTraceFunctionEntry1( DMMCSTACK_SCHEDGRABENTRIES_ENTRY, this ); |
|
1774 |
1622 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sge")); |
1775 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sge")); |
1623 |
1776 |
1624 iAttention = EFalse; // Strictly in this order |
1777 iAttention = EFalse; // Strictly in this order |
1625 if( !iEntryQueue.IsEmpty() ) |
1778 if( !iEntryQueue.IsEmpty() ) |
1626 { |
1779 { |
1627 DISABLEPREEMPTION |
1780 DISABLEPREEMPTION |
1628 iReadyQueue.Add( iEntryQueue ); |
1781 iReadyQueue.Add( iEntryQueue ); |
1629 RESTOREPREEMPTION |
1782 RESTOREPREEMPTION |
1630 } |
1783 } |
|
1784 OstTraceFunctionExit1( DMMCSTACK_SCHEDGRABENTRIES_EXIT, this ); |
1631 } |
1785 } |
1632 |
1786 |
1633 void DMMCStack::SchedDisengage() |
1787 void DMMCStack::SchedDisengage() |
1634 /** |
1788 /** |
1635 * This function is called by AbortPass() and CompletionPass() to remove the session |
1789 * This function is called by AbortPass() and CompletionPass() to remove the session |
1636 * at WorkSet Point, to abort its asynchronous activities (if any) and |
1790 * at WorkSet Point, to abort its asynchronous activities (if any) and |
1637 * clear up the dependent resources |
1791 * clear up the dependent resources |
1638 */ |
1792 */ |
1639 { |
1793 { |
|
1794 OstTraceFunctionEntry1( DMMCSTACK_SCHEDDISENGAGE_ENTRY, this ); |
1640 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sd")); |
1795 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sd")); |
1641 |
1796 |
1642 DMMCSession* sessP = iWorkSet.Remove(); |
1797 DMMCSession* sessP = iWorkSet.Remove(); |
1643 |
1798 |
1644 SchedDoAbort( sessP ); |
1799 SchedDoAbort( sessP ); |
1697 } |
1854 } |
1698 else |
1855 else |
1699 iReadyQueue++; |
1856 iReadyQueue++; |
1700 |
1857 |
1701 if( iAbortReq ) |
1858 if( iAbortReq ) |
1702 return( ESchedLoop ); |
1859 { |
|
1860 OstTraceFunctionExitExt( DMMCSTACK_SCHEDABORTPASS_EXIT1, this, (TInt) ESchedLoop ); |
|
1861 return ESchedLoop; |
|
1862 } |
1703 |
1863 |
1704 // Clearing iAbortAll here is a bit dodgy. It wouldn't work if somebody interrupted us |
1864 // Clearing iAbortAll here is a bit dodgy. It wouldn't work if somebody interrupted us |
1705 // at this point, enqued a session and then immediately called Reset() - that session |
1865 // at this point, enqued a session and then immediately called Reset() - that session |
1706 // would not be discarded. However, the correct solution (enque Reset() requests |
1866 // would not be discarded. However, the correct solution (enque Reset() requests |
1707 // and process them in the Scheduler main loop) seems to be too expensive just to avoid |
1867 // and process them in the Scheduler main loop) seems to be too expensive just to avoid |
1708 // this particular effect. |
1868 // this particular effect. |
1709 iAbortAll = EFalse; |
1869 iAbortAll = EFalse; |
1710 return( ESchedContinue ); |
1870 OstTraceFunctionExitExt( DMMCSTACK_SCHEDABORTPASS_EXIT2, this, (TInt) ESchedContinue ); |
|
1871 return ESchedContinue; |
1711 } |
1872 } |
1712 |
1873 |
1713 inline DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedCompletionPass() |
1874 inline DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedCompletionPass() |
1714 /** |
1875 /** |
1715 * This function calls back all the sessions waiting to be completed |
1876 * This function calls back all the sessions waiting to be completed |
1716 * Returns either Continue or Loop. |
1877 * Returns either Continue or Loop. |
1717 */ |
1878 */ |
1718 { |
1879 { |
|
1880 OstTraceFunctionEntry1( DMMCSTACK_SCHEDCOMPLETIONPASS_ENTRY, this ); |
1719 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:scp")); |
1881 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:scp")); |
1720 |
1882 |
1721 iCompReq = EFalse; |
1883 iCompReq = EFalse; |
1722 DMMCSession* sessP; |
1884 DMMCSession* sessP; |
1723 |
1885 |
1785 } |
1948 } |
1786 else |
1949 else |
1787 iWorkSet++; |
1950 iWorkSet++; |
1788 |
1951 |
1789 if( iCompReq ) |
1952 if( iCompReq ) |
1790 return( ESchedLoop ); |
1953 { |
|
1954 OstTraceFunctionExitExt( DMMCSTACK_SCHEDCOMPLETIONPASS_EXIT2, this, (TInt) ESchedLoop ); |
|
1955 return ESchedLoop; |
|
1956 } |
1791 |
1957 |
1792 iCompleteAllExitCode = 0; |
1958 iCompleteAllExitCode = 0; |
1793 |
1959 |
1794 return( ESchedContinue ); |
1960 OstTraceFunctionExitExt( DMMCSTACK_SCHEDCOMPLETIONPASS_EXIT3, this, ( TInt) ESchedContinue ); |
|
1961 return ESchedContinue; |
1795 } |
1962 } |
1796 |
1963 |
1797 inline DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedInitStack() |
1964 inline DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedInitStack() |
1798 /** |
1965 /** |
1799 * "Immediate" InitStack initiator. Returns either Continue or Loop. |
1966 * "Immediate" InitStack initiator. Returns either Continue or Loop. |
1800 */ |
1967 */ |
1801 { |
1968 { |
|
1969 OstTraceFunctionEntry1( DMMCSTACK_SCHEDINITSTACK_ENTRY, this ); |
1802 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sis")); |
1970 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sis")); |
1803 |
1971 |
1804 if( SchedGetOnDFC() ) |
1972 if( SchedGetOnDFC() ) |
1805 return( ESchedLoop ); |
1973 { |
|
1974 OstTraceFunctionExitExt( DMMCSTACK_SCHEDINITSTACK_EXIT1, this, (TInt) ESchedLoop ); |
|
1975 return ESchedLoop; |
|
1976 } |
1806 |
1977 |
1807 if( iSessionP != NULL && (iStackState & KMMCStackStateJobChooser) == 0 ) |
1978 if( iSessionP != NULL && (iStackState & KMMCStackStateJobChooser) == 0 ) |
1808 { |
1979 { |
1809 if( (iSessionP->iState & KMMCSessStateInProgress) ) |
1980 if( (iSessionP->iState & KMMCSessStateInProgress) ) |
1810 { |
1981 { |
1811 if( SchedGroundDown(iSessionP, KMMCErrPowerDown) ) |
1982 if( SchedGroundDown(iSessionP, KMMCErrPowerDown) ) |
1812 { |
1983 { |
1813 MarkComplete( iSessionP, KMMCErrPowerDown ); |
1984 MarkComplete( iSessionP, KMMCErrPowerDown ); |
1814 return( ESchedLoop ); |
1985 OstTraceFunctionExitExt( DMMCSTACK_SCHEDINITSTACK_EXIT2, this, (TInt) ESchedLoop ); |
|
1986 return ESchedLoop; |
1815 } |
1987 } |
1816 } |
1988 } |
1817 else |
1989 else |
1818 iSessionP->iMachine.Reset(); |
1990 iSessionP->iMachine.Reset(); |
1819 } |
1991 } |
1839 DMMCSocket::Panic(DMMCSocket::EMMCInitStackBlocked) ); |
2014 DMMCSocket::Panic(DMMCSocket::EMMCInitStackBlocked) ); |
1840 |
2015 |
1841 iStackState |= KMMCStackStateInitInProgress; |
2016 iStackState |= KMMCStackStateInitInProgress; |
1842 // nothing can stop this session now; it's safe to clear iInitialise here. |
2017 // nothing can stop this session now; it's safe to clear iInitialise here. |
1843 iInitialise = EFalse; |
2018 iInitialise = EFalse; |
1844 return( ESchedContinue ); |
2019 OstTraceFunctionExitExt( DMMCSTACK_SCHEDINITSTACK_EXIT4, this, (TInt) ESchedContinue ); |
|
2020 return ESchedContinue; |
1845 } |
2021 } |
1846 |
2022 |
1847 inline DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedSleepStack() |
2023 inline DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedSleepStack() |
1848 /** |
2024 /** |
1849 * "Immediate" Stack sleep mode. Returns either Continue or Loop. |
2025 * "Immediate" Stack sleep mode. Returns either Continue or Loop. |
1850 */ |
2026 */ |
1851 { |
2027 { |
|
2028 OstTraceFunctionEntry1( DMMCSTACK_SCHEDSLEEPSTACK_ENTRY, this ); |
1852 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:SchdSlp!")); |
2029 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:SchdSlp!")); |
1853 |
2030 |
1854 // Make sure Stack DFC is Running! |
2031 // Make sure Stack DFC is Running! |
1855 if( SchedGetOnDFC() ) |
2032 if( SchedGetOnDFC() ) |
1856 { |
2033 { |
1857 __KTRACE_OPT(KPBUS1, Kern::Printf("mst:SchdSlp - DFC not running")); |
2034 __KTRACE_OPT(KPBUS1, Kern::Printf("mst:SchdSlp - DFC not running")); |
1858 return( ESchedLoop ); |
2035 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSLEEPSTACK_EXIT1, this, (TInt) ESchedLoop ); |
|
2036 return ESchedLoop; |
1859 } |
2037 } |
1860 |
2038 |
1861 if( iSessionP != NULL && (iStackState & KMMCStackStateJobChooser) == 0 ) |
2039 if( iSessionP != NULL && (iStackState & KMMCStackStateJobChooser) == 0 ) |
1862 { |
2040 { |
1863 if( (iSessionP->iState & KMMCSessStateInProgress) ) |
2041 if( (iSessionP->iState & KMMCSessStateInProgress) ) |
1864 { |
2042 { |
1865 // A session has been queued before sleep, |
2043 // A session has been queued before sleep, |
1866 // cancel sleep and loop for next session |
2044 // cancel sleep and loop for next session |
1867 iSleep = EFalse; |
2045 iSleep = EFalse; |
1868 return( ESchedLoop ); |
2046 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSLEEPSTACK_EXIT2, this, (TInt) ESchedLoop ); |
|
2047 return ESchedLoop; |
1869 } |
2048 } |
1870 } |
2049 } |
1871 |
2050 |
1872 // Use the stack session to perform the stack sleep. |
2051 // Use the stack session to perform the stack sleep. |
1873 if( SchedEnqueStackSession(ECIMSleep) ) |
2052 if( SchedEnqueStackSession(ECIMSleep) ) |
1874 { |
2053 { |
1875 __KTRACE_OPT(KPBUS1,Kern::Printf("SchdSlp: already Enqued")); |
2054 __KTRACE_OPT(KPBUS1,Kern::Printf("SchdSlp: already Enqued")); |
1876 // Stack already busy cancel sleep |
2055 // Stack already busy cancel sleep |
1877 iSleep = EFalse; |
2056 iSleep = EFalse; |
1878 return( ESchedLoop ); |
2057 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSLEEPSTACK_EXIT3, this, (TInt) ESchedLoop ); |
|
2058 return ESchedLoop; |
1879 } |
2059 } |
1880 |
2060 |
1881 SchedSetContext( iStackSession ); // make the internal session to be current job |
2061 SchedSetContext( iStackSession ); // make the internal session to be current job |
1882 |
2062 |
1883 // Sleep has now been queued |
2063 // Sleep has now been queued |
1884 iSleep = EFalse; |
2064 iSleep = EFalse; |
1885 iStackState |= KMMCStackStateSleepinProgress; |
2065 iStackState |= KMMCStackStateSleepinProgress; |
1886 __KTRACE_OPT(KPBUS1, Kern::Printf("<mst:SchdSlp")); |
2066 __KTRACE_OPT(KPBUS1, Kern::Printf("<mst:SchdSlp")); |
1887 |
2067 |
1888 return( ESchedLoop ); |
2068 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSLEEPSTACK_EXIT4, this, (TInt) ESchedLoop ); |
|
2069 return ESchedLoop; |
1889 } |
2070 } |
1890 |
2071 |
1891 |
2072 |
1892 inline TBool DMMCStack::SchedPreemptable() |
2073 inline TBool DMMCStack::SchedPreemptable() |
1893 /** |
2074 /** |
1894 * Checks if the current session can be preempted |
2075 * Checks if the current session can be preempted |
1895 */ |
2076 */ |
1896 { // strictly in the following order |
2077 { // strictly in the following order |
|
2078 OstTraceFunctionEntry1( DMMCSTACK_SCHEDPREEMPTABLE_ENTRY, this ); |
1897 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:spe")); |
2079 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:spe")); |
1898 |
2080 |
1899 if( (iStackState & KMMCStackStateJobChooser) || |
2081 if( (iStackState & KMMCStackStateJobChooser) || |
1900 (iSessionP->iState & KMMCSessStateDoReSchedule) ) |
2082 (iSessionP->iState & KMMCSessStateDoReSchedule) ) |
1901 return( ETrue ); |
2083 { |
|
2084 OstTraceFunctionExitExt( DMMCSTACK_SCHEDPREEMPTABLE_EXIT1, this, (TUint) ETrue ); |
|
2085 return ETrue; |
|
2086 } |
1902 |
2087 |
1903 if( (iSessionP->iBlockOn & KMMCBlockOnASSPFunction) ) |
2088 if( (iSessionP->iBlockOn & KMMCBlockOnASSPFunction) ) |
1904 return( EFalse ); |
2089 { |
|
2090 OstTraceFunctionExitExt( DMMCSTACK_SCHEDPREEMPTABLE_EXIT2, this, (TUint) EFalse ); |
|
2091 return EFalse; |
|
2092 } |
1905 |
2093 |
1906 TBool preemptDC = EFalse; |
2094 TBool preemptDC = EFalse; |
1907 |
2095 |
1908 if (iSessionP->iBlockOn & KMMCBlockOnYielding) |
2096 if (iSessionP->iBlockOn & KMMCBlockOnYielding) |
1909 { |
2097 { |
1914 { |
2102 { |
1915 // Added for SDIO Read/Wait and SDC support. This condition |
2103 // Added for SDIO Read/Wait and SDC support. This condition |
1916 // is set at the variant, and determines whether commands may be |
2104 // is set at the variant, and determines whether commands may be |
1917 // issued during the data transfer period. |
2105 // issued during the data transfer period. |
1918 if(!(iSessionP->iState & KMMCSessStateAllowDirectCommands)) |
2106 if(!(iSessionP->iState & KMMCSessStateAllowDirectCommands)) |
1919 return( EFalse ); |
2107 { |
|
2108 OstTraceFunctionExitExt( DMMCSTACK_SCHEDPREEMPTABLE_EXIT3, this, (TUint) EFalse ); |
|
2109 return EFalse; |
|
2110 } |
1920 |
2111 |
1921 // We must consider the remaining blocking conditions |
2112 // We must consider the remaining blocking conditions |
1922 // before being sure that we can enable pre-emtion of this session |
2113 // before being sure that we can enable pre-emtion of this session |
1923 preemptDC = ETrue; |
2114 preemptDC = ETrue; |
1924 } |
2115 } |
1925 |
2116 |
1926 if( (iSessionP->iBlockOn & (KMMCBlockOnCardInUse | KMMCBlockOnNoRun)) ) |
2117 if( (iSessionP->iBlockOn & (KMMCBlockOnCardInUse | KMMCBlockOnNoRun)) ) |
1927 return( ETrue ); |
2118 { |
|
2119 OstTraceFunctionExitExt( DMMCSTACK_SCHEDPREEMPTABLE_EXIT4, this, (TUint) ETrue ); |
|
2120 return ETrue; |
|
2121 } |
1928 |
2122 |
1929 if( (iConfig.iModes & KMMCModeEnablePreemption) == 0 ) |
2123 if( (iConfig.iModes & KMMCModeEnablePreemption) == 0 ) |
1930 return( EFalse ); |
2124 { |
|
2125 OstTraceFunctionExitExt( DMMCSTACK_SCHEDPREEMPTABLE_EXIT5, this, (TUint) EFalse ); |
|
2126 return EFalse; |
|
2127 } |
1931 |
2128 |
1932 if( (iSessionP->iBlockOn & KMMCBlockOnGapTimersMask) && |
2129 if( (iSessionP->iBlockOn & KMMCBlockOnGapTimersMask) && |
1933 (iConfig.iModes & KMMCModePreemptInGaps) && |
2130 (iConfig.iModes & KMMCModePreemptInGaps) && |
1934 (iSessionP->iState & KMMCSessStateSafeInGaps) ) |
2131 (iSessionP->iState & KMMCSessStateSafeInGaps) ) |
1935 return( ETrue ); |
2132 { |
|
2133 OstTraceFunctionExitExt( DMMCSTACK_SCHEDPREEMPTABLE_EXIT6, this, (TUint) ETrue ); |
|
2134 return ETrue; |
|
2135 } |
1936 |
2136 |
1937 if( iSessionP->iBlockOn & KMMCBlockOnInterrupt ) |
2137 if( iSessionP->iBlockOn & KMMCBlockOnInterrupt ) |
1938 return( ETrue ); |
2138 { |
|
2139 OstTraceFunctionExitExt( DMMCSTACK_SCHEDPREEMPTABLE_EXIT7, this, (TUint) ETrue ); |
|
2140 return ETrue; |
|
2141 } |
1939 |
2142 |
1940 if(preemptDC) |
2143 if(preemptDC) |
1941 return( ETrue ); |
2144 { |
|
2145 OstTraceFunctionExitExt( DDMMCSTACK_SCHEDPREEMPTABLE_EXIT8, this, (TUint) ETrue ); |
|
2146 return ETrue; |
|
2147 } |
1942 |
2148 |
1943 return( EFalse ); |
2149 OstTraceFunctionExitExt( DMMCSTACK_SCHEDPREEMPTABLE_EXIT9, this, (TUint) EFalse ); |
|
2150 return EFalse; |
1944 } |
2151 } |
1945 |
2152 |
1946 inline DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedSession() |
2153 inline DMMCStack::TMMCStackSchedStateEnum DMMCStack::SchedSession() |
1947 /** |
2154 /** |
1948 * Current context analyser. Returns Exit, Loop or ChooseJob. |
2155 * Current context analyser. Returns Exit, Loop or ChooseJob. |
1949 */ |
2156 */ |
1950 { |
2157 { |
|
2158 OstTraceFunctionEntry1( DMMCSTACK_SCHEDSESSION_ENTRY, this ); |
1951 |
2159 |
1952 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ss")); |
2160 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ss")); |
1953 |
2161 |
1954 // If no current session selected then we need to choose one |
2162 // If no current session selected then we need to choose one |
1955 if (iSessionP == NULL) |
2163 if (iSessionP == NULL) |
1956 return(ESchedChooseJob); |
2164 { |
|
2165 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSESSION_EXIT1, this, (TInt) ESchedChooseJob ); |
|
2166 return ESchedChooseJob; |
|
2167 } |
1957 |
2168 |
1958 // Check any static blocking conditions on the current session and remove if possible |
2169 // Check any static blocking conditions on the current session and remove if possible |
1959 if (SchedResolveStatBlocks(iSessionP)==ESchedLoop) |
2170 if (SchedResolveStatBlocks(iSessionP)==ESchedLoop) |
1960 return(ESchedLoop); |
2171 { |
|
2172 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSESSION_EXIT2, this, (TInt) ESchedLoop ); |
|
2173 return ESchedLoop; |
|
2174 } |
1961 |
2175 |
1962 // If current session is still blocked, see if we could pre-empt the session |
2176 // If current session is still blocked, see if we could pre-empt the session |
1963 if (iSessionP->iBlockOn) |
2177 if (iSessionP->iBlockOn) |
1964 { |
2178 { |
1965 if( SchedPreemptable() ) |
2179 if( SchedPreemptable() ) |
1966 return(ESchedChooseJob); |
2180 { |
1967 |
2181 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSESSION_EXIT3, this, (TInt) ESchedChooseJob ); |
1968 return( ESchedExit ); // No preemption possible |
2182 return ESchedChooseJob; |
|
2183 } |
|
2184 |
|
2185 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSESSION_EXIT4, this, (TInt) ESchedExit ); |
|
2186 return ESchedExit; // No preemption possible |
1969 } |
2187 } |
1970 |
2188 |
1971 // If the current session has been marked to be 'un-scheduled' then we |
2189 // If the current session has been marked to be 'un-scheduled' then we |
1972 // need to choose another session if ones available |
2190 // need to choose another session if ones available |
1973 if ( (iSessionP->iState & KMMCSessStateDoReSchedule) ) |
2191 if ( (iSessionP->iState & KMMCSessStateDoReSchedule) ) |
1974 return( ESchedChooseJob ); |
2192 { |
|
2193 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSESSION_EXIT5, this, (TInt) ESchedChooseJob ); |
|
2194 return ESchedChooseJob; |
|
2195 } |
1975 |
2196 |
1976 // Check if this session requires to be run in DFC context - loop if necessary |
2197 // Check if this session requires to be run in DFC context - loop if necessary |
1977 if ( (iSessionP->iState & KMMCSessStateDoDFC) ) |
2198 if ( (iSessionP->iState & KMMCSessStateDoDFC) ) |
1978 { |
2199 { |
1979 iSessionP->iState &= ~KMMCSessStateDoDFC; |
2200 iSessionP->iState &= ~KMMCSessStateDoDFC; |
1980 if( SchedGetOnDFC()==ESchedLoop ) |
2201 if( SchedGetOnDFC()==ESchedLoop ) |
1981 return( ESchedLoop ); |
2202 { |
|
2203 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSESSION_EXIT6, this, (TInt) ESchedLoop ); |
|
2204 return ESchedLoop; |
|
2205 } |
1982 } |
2206 } |
1983 |
2207 |
1984 // Now we actually execute the current session |
2208 // Now we actually execute the current session |
1985 if( iLockingSessionP != NULL ) |
2209 if( iLockingSessionP != NULL ) |
1986 { |
2210 { |
2021 iStackState &= ~KMMCStackStateReScheduled; |
2245 iStackState &= ~KMMCStackStateReScheduled; |
2022 |
2246 |
2023 if( exitCode ) |
2247 if( exitCode ) |
2024 MarkComplete( iSessionP, (exitCode & ~KMMCErrBypass) ); |
2248 MarkComplete( iSessionP, (exitCode & ~KMMCErrBypass) ); |
2025 |
2249 |
2026 return(ESchedLoop); |
2250 OstTraceFunctionExitExt( DMMCSTACK_SCHEDSESSION_EXIT7, this, (TInt) ESchedLoop ); |
|
2251 return ESchedLoop; |
2027 } |
2252 } |
2028 |
2253 |
2029 TBool DMMCStack::SchedYielding(DMMCSession* aSessP) |
2254 TBool DMMCStack::SchedYielding(DMMCSession* aSessP) |
2030 /** |
2255 /** |
2031 * Check whether the scheduler should yield to another command |
2256 * Check whether the scheduler should yield to another command |
2032 */ |
2257 */ |
2033 { |
2258 { |
|
2259 OstTraceFunctionEntryExt( DMMCSTACK_SCHEDYIELDING_ENTRY, this ); |
2034 // Test whether a full loop through the sessions has occurred during a yield |
2260 // Test whether a full loop through the sessions has occurred during a yield |
2035 if ((aSessP->iBlockOn & KMMCBlockOnYielding) && (iStackState & KMMCStackStateYielding)) |
2261 if ((aSessP->iBlockOn & KMMCBlockOnYielding) && (iStackState & KMMCStackStateYielding)) |
2036 { |
2262 { |
2037 // We've looped, now stop yielding |
2263 // We've looped, now stop yielding |
2038 aSessP->iBlockOn &= ~KMMCBlockOnYielding; |
2264 aSessP->iBlockOn &= ~KMMCBlockOnYielding; |
2039 iStackState &= ~KMMCStackStateYielding; |
2265 iStackState &= ~KMMCStackStateYielding; |
2040 } |
2266 } |
2041 return(iStackState & KMMCStackStateYielding) != 0; |
2267 TBool ret = (iStackState & KMMCStackStateYielding) != 0; |
|
2268 OstTraceFunctionExitExt( DMMCSTACK_SCHEDYIELDING_EXIT, this, ret ); |
|
2269 return ret; |
2042 } |
2270 } |
2043 |
2271 |
2044 TBool DMMCStack::SchedAllowDirectCommands(DMMCSession* aSessP) |
2272 TBool DMMCStack::SchedAllowDirectCommands(DMMCSession* aSessP) |
2045 /** |
2273 /** |
2046 * Check whether direct only commands can be run. |
2274 * Check whether direct only commands can be run. |
2047 */ |
2275 */ |
2048 { |
2276 { |
|
2277 OstTraceFunctionEntryExt( DMMCSTACK_SCHEDALLOWDIRECTCOMMANDS_ENTRY, this ); |
2049 TBool allowDirectCommands = EFalse; |
2278 TBool allowDirectCommands = EFalse; |
2050 |
2279 |
2051 // Test the remaining sessions to see if they have a DMA data transfer blockage which allow direct commands only |
2280 // Test the remaining sessions to see if they have a DMA data transfer blockage which allow direct commands only |
2052 DMMCSession* testSessP = aSessP; |
2281 DMMCSession* testSessP = aSessP; |
2053 do |
2282 do |
2125 |
2359 |
2126 if (scheduleSession) |
2360 if (scheduleSession) |
2127 { |
2361 { |
2128 iWorkSet.SetMarker(); |
2362 iWorkSet.SetMarker(); |
2129 SchedSetContext( sessP ); |
2363 SchedSetContext( sessP ); |
2130 return( ESchedLoop ); |
2364 OstTraceFunctionExitExt( DMMCSTACK_SCHEDCHOOSEJOB_EXIT2, this, (TInt) ESchedLoop ); |
|
2365 return ESchedLoop; |
2131 } |
2366 } |
2132 |
2367 |
2133 iWorkSet++; |
2368 iWorkSet++; |
2134 } |
2369 } |
2135 |
2370 |
2136 return( ESchedExit ); |
2371 OstTraceFunctionExitExt( DMMCSTACK_SCHEDCHOOSEJOB_EXIT3, this, (TInt) ESchedExit ); |
|
2372 return ESchedExit; |
2137 } |
2373 } |
2138 |
2374 |
2139 void DMMCStack::StackDFC(TAny* aStackP) |
2375 void DMMCStack::StackDFC(TAny* aStackP) |
2140 /** |
2376 /** |
2141 * This DFC is used to startup Stack Scheduler from the background. |
2377 * This DFC is used to startup Stack Scheduler from the background. |
2142 */ |
2378 */ |
2143 { |
2379 { |
|
2380 OstTraceFunctionEntry0( DMMCSTACK_STACKDFC_ENTRY ); |
2144 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sdf")); |
2381 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sdf")); |
2145 |
2382 |
2146 DMMCStack* const stackP = static_cast<DMMCStack*>(aStackP); |
2383 DMMCStack* const stackP = static_cast<DMMCStack*>(aStackP); |
2147 stackP->Scheduler( stackP->iDFCRunning ); |
2384 stackP->Scheduler( stackP->iDFCRunning ); |
|
2385 OstTraceFunctionExit0( DMMCSTACK_STACKDFC_EXIT ); |
2148 } |
2386 } |
2149 |
2387 |
2150 void DMMCStack::Scheduler(volatile TBool& aFlag) |
2388 void DMMCStack::Scheduler(volatile TBool& aFlag) |
2151 /** |
2389 /** |
2152 * This is the main function which controls, monitors and synchronises session execution. |
2390 * This is the main function which controls, monitors and synchronises session execution. |
2153 * It's divided into the entry function Scheduler() and the scheduling mechanism itself, |
2391 * It's divided into the entry function Scheduler() and the scheduling mechanism itself, |
2154 * DoSchedule() |
2392 * DoSchedule() |
2155 */ |
2393 */ |
2156 { |
2394 { |
|
2395 OstTraceFunctionEntry0( DMMCSTACK_SCHEDULER_ENTRY ); |
2157 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sch")); |
2396 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sch")); |
2158 |
2397 |
2159 DISABLEPREEMPTION |
2398 DISABLEPREEMPTION |
2160 aFlag = ETrue; |
2399 aFlag = ETrue; |
2161 |
2400 |
2237 void DMMCStack::Add(DMMCSession* aSessP) |
2479 void DMMCStack::Add(DMMCSession* aSessP) |
2238 /** |
2480 /** |
2239 * Adds session aSessP to the EntryQueue (asynchronous function) |
2481 * Adds session aSessP to the EntryQueue (asynchronous function) |
2240 */ |
2482 */ |
2241 { |
2483 { |
|
2484 OstTraceFunctionEntryExt( DMMCSTACK_ADD_ENTRY, this ); |
2242 ASSERT_NOT_ISR_CONTEXT |
2485 ASSERT_NOT_ISR_CONTEXT |
2243 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:Add %d",TUint(aSessP->iSessionID))); |
2486 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:Add %d",TUint(aSessP->iSessionID))); |
2244 |
2487 |
2245 DISABLEPREEMPTION |
2488 DISABLEPREEMPTION |
2246 iEntryQueue.Add( aSessP ); |
2489 iEntryQueue.Add( aSessP ); |
2247 aSessP->iState |= KMMCSessStateEngaged; |
2490 aSessP->iState |= KMMCSessStateEngaged; |
2248 RESTOREPREEMPTION |
2491 RESTOREPREEMPTION |
2249 Scheduler( iAttention ); |
2492 Scheduler( iAttention ); |
|
2493 OstTraceFunctionExit1( DMMCSTACK_ADD_EXIT, this ); |
2250 } |
2494 } |
2251 |
2495 |
2252 void DMMCStack::Abort(DMMCSession* aSessP) |
2496 void DMMCStack::Abort(DMMCSession* aSessP) |
2253 /** |
2497 /** |
2254 * Aborts a session |
2498 * Aborts a session |
2255 */ |
2499 */ |
2256 { |
2500 { |
|
2501 OstTraceFunctionEntryExt( DMMCSTACK_ABORT_ENTRY, this ); |
2257 ASSERT_NOT_ISR_CONTEXT |
2502 ASSERT_NOT_ISR_CONTEXT |
2258 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:abt")); |
2503 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:abt")); |
2259 |
2504 |
2260 if( !aSessP->IsEngaged() ) |
2505 if( !aSessP->IsEngaged() ) |
|
2506 { |
|
2507 OstTraceFunctionExit1( DMMCSTACK_ABORT_EXIT1, this ); |
2261 return; |
2508 return; |
|
2509 } |
2262 |
2510 |
2263 aSessP->iDoAbort = ETrue; |
2511 aSessP->iDoAbort = ETrue; |
2264 aSessP->iMachine.Abort(); |
2512 aSessP->iMachine.Abort(); |
2265 |
2513 |
2266 Scheduler( iAbortReq ); |
2514 Scheduler( iAbortReq ); |
|
2515 OstTraceFunctionExit1( DMMCSTACK_ABORT_EXIT2, this ); |
2267 } |
2516 } |
2268 |
2517 |
2269 void DMMCStack::Stop(DMMCSession* aSessP) |
2518 void DMMCStack::Stop(DMMCSession* aSessP) |
2270 /** |
2519 /** |
2271 * Signals session to stop |
2520 * Signals session to stop |
2272 */ |
2521 */ |
2273 { |
2522 { |
|
2523 OstTraceFunctionEntryExt( DMMCSTACK_STOP1_ENTRY, this ); |
2274 ASSERT_NOT_ISR_CONTEXT |
2524 ASSERT_NOT_ISR_CONTEXT |
2275 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:stp")); |
2525 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:stp")); |
2276 |
2526 |
2277 if( !aSessP->IsEngaged() ) |
2527 if( !aSessP->IsEngaged() ) |
|
2528 { |
|
2529 OstTraceFunctionExit1( DMMCSTACK_STOP1_EXIT1, this ); |
2278 return; |
2530 return; |
|
2531 } |
2279 |
2532 |
2280 aSessP->iDoStop = ETrue; |
2533 aSessP->iDoStop = ETrue; |
|
2534 OstTraceFunctionExit1( DMMCSTACK_STOP1_EXIT2, this ); |
2281 } |
2535 } |
2282 |
2536 |
2283 EXPORT_C void DMMCStack::Block(DMMCSession* aSessP, TUint32 aFlag) |
2537 EXPORT_C void DMMCStack::Block(DMMCSession* aSessP, TUint32 aFlag) |
2284 { |
2538 { |
|
2539 OstTraceFunctionEntryExt( DMMCSTACK_BLOCK_ENTRY, this ); |
2285 ASSERT_NOT_ISR_CONTEXT |
2540 ASSERT_NOT_ISR_CONTEXT |
2286 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:blk")); |
2541 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:blk")); |
2287 |
2542 |
2288 if( !aSessP->IsEngaged() ) |
2543 if( !aSessP->IsEngaged() ) |
|
2544 { |
|
2545 OstTraceFunctionExit1( DMMCSTACK_BLOCK_EXIT1, this ); |
2289 return; |
2546 return; |
|
2547 } |
2290 |
2548 |
2291 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:blk:[aFlag=%08x, iBlockOn=%08x]", aFlag, aSessP->iBlockOn)); |
2549 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:blk:[aFlag=%08x, iBlockOn=%08x]", aFlag, aSessP->iBlockOn)); |
|
2550 OstTraceExt2( TRACE_INTERNALS, DMMCSTACK_BLOCK, "aFlag=0x%08x; iBlockOn=0x%08x", aFlag, aSessP->iBlockOn ); |
|
2551 |
2292 |
2552 |
2293 (void)__e32_atomic_ior_ord32(&aSessP->iBlockOn, aFlag); |
2553 (void)__e32_atomic_ior_ord32(&aSessP->iBlockOn, aFlag); |
|
2554 OstTraceFunctionExit1( DMMCSTACK_BLOCK_EXIT2, this ); |
2294 } |
2555 } |
2295 |
2556 |
2296 EXPORT_C void DMMCStack::UnBlock(DMMCSession* aSessP, TUint32 aFlag, TMMCErr anExitCode) |
2557 EXPORT_C void DMMCStack::UnBlock(DMMCSession* aSessP, TUint32 aFlag, TMMCErr anExitCode) |
2297 /** |
2558 /** |
2298 * aFlag is a bitset of KMMCBlockOnXXX events that have occured. If the stack's |
2559 * aFlag is a bitset of KMMCBlockOnXXX events that have occured. If the stack's |
2299 * session is waiting on all of these events, then it is scheduled. |
2560 * session is waiting on all of these events, then it is scheduled. |
2300 */ |
2561 */ |
2301 { |
2562 { |
|
2563 OstTraceExt4(TRACE_FLOW, DMMCSTACK_UNBLOCK_ENTRY , "DMMCStack::UnBlock;aSessP=%x;aFlag=%x;anExitCode=%d;this=%x", (TUint) aSessP, (TUint) aFlag, (TInt) anExitCode, (TUint) this); |
2302 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ubl")); |
2564 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ubl")); |
2303 |
2565 |
2304 if (aSessP != NULL) |
2566 if (aSessP != NULL) |
2305 { |
2567 { |
2306 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ubl:[aFlag=%08x, iBlockOn=%08x", aFlag, aSessP->iBlockOn)); |
2568 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ubl:[aFlag=%08x, iBlockOn=%08x", aFlag, aSessP->iBlockOn)); |
|
2569 OstTraceExt2( TRACE_INTERNALS, DMMCSTACK_UNBLOCK, "aFlag=0x%08x; iBlockOn=0x%08x", aFlag, aSessP->iBlockOn ); |
|
2570 |
2307 |
2571 |
2308 if( (aSessP->iBlockOn & aFlag) == 0 ) |
2572 if( (aSessP->iBlockOn & aFlag) == 0 ) |
|
2573 { |
|
2574 OstTraceFunctionExit1( DMMCSTACK_UNBLOCK_EXIT1, this ); |
2309 return; |
2575 return; |
|
2576 } |
2310 |
2577 |
2311 // Must be either in a DFC or have the KMMCSessStateDoDFC flag set |
2578 // Must be either in a DFC or have the KMMCSessStateDoDFC flag set |
2312 __ASSERT_DEBUG( |
2579 __ASSERT_DEBUG( |
2313 (aSessP->iState & KMMCSessStateDoDFC) != 0 || |
2580 (aSessP->iState & KMMCSessStateDoDFC) != 0 || |
2314 NKern::CurrentContext() != NKern::EInterrupt, |
2581 NKern::CurrentContext() != NKern::EInterrupt, |
2318 aSessP->iMachine.SetExitCode( anExitCode ); |
2585 aSessP->iMachine.SetExitCode( anExitCode ); |
2319 |
2586 |
2320 if( aSessP->iBlockOn == 0 ) |
2587 if( aSessP->iBlockOn == 0 ) |
2321 Scheduler( iAttention ); |
2588 Scheduler( iAttention ); |
2322 } |
2589 } |
|
2590 OstTraceFunctionExit1( DMMCSTACK_UNBLOCK_EXIT2, this ); |
2323 } |
2591 } |
2324 |
2592 |
2325 void DMMCStack::UnlockStack(DMMCSession* aSessP) |
2593 void DMMCStack::UnlockStack(DMMCSession* aSessP) |
2326 /** |
2594 /** |
2327 * Removes stack lock. Asynchronous function. |
2595 * Removes stack lock. Asynchronous function. |
2328 */ |
2596 */ |
2329 { |
2597 { |
|
2598 OstTraceFunctionEntryExt( DMMCSTACK_UNLOCKSTACK_ENTRY, this ); |
2330 ASSERT_NOT_ISR_CONTEXT |
2599 ASSERT_NOT_ISR_CONTEXT |
2331 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ust")); |
2600 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:ust")); |
2332 |
2601 |
2333 aSessP->iBrokenLock = EFalse; |
2602 aSessP->iBrokenLock = EFalse; |
2334 |
2603 |
2335 if( aSessP == iLockingSessionP ) |
2604 if( aSessP == iLockingSessionP ) |
2336 { |
2605 { |
2337 iLockingSessionP = NULL; |
2606 iLockingSessionP = NULL; |
2338 Scheduler( iAttention ); |
2607 Scheduler( iAttention ); |
2339 } |
2608 } |
|
2609 OstTraceFunctionExit1( DMMCSTACK_UNLOCKSTACK_EXIT1, this ); |
2340 } |
2610 } |
2341 |
2611 |
2342 EXPORT_C TInt DMMCStack::Stop(TMMCard* aCardP) |
2612 EXPORT_C TInt DMMCStack::Stop(TMMCard* aCardP) |
2343 /** |
2613 /** |
2344 * Completes all sessions operating with a specified card with KMMCErrAbort. |
2614 * Completes all sessions operating with a specified card with KMMCErrAbort. |
2345 * Returns either KErrNone or KErrServerBusy. |
2615 * Returns either KErrNone or KErrServerBusy. |
2346 */ |
2616 */ |
2347 { |
2617 { |
|
2618 OstTraceFunctionEntryExt( DMMCSTACK_STOP2_ENTRY, this ); |
2348 ASSERT_NOT_ISR_CONTEXT |
2619 ASSERT_NOT_ISR_CONTEXT |
2349 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:stp")); |
2620 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:stp")); |
2350 |
2621 |
2351 DISABLEPREEMPTION |
2622 DISABLEPREEMPTION |
2352 |
2623 |
2353 if( iStackState & KMMCStackStateRunning ) |
2624 if( iStackState & KMMCStackStateRunning ) |
2354 { |
2625 { |
2355 RESTOREPREEMPTION |
2626 RESTOREPREEMPTION |
2356 return( KErrServerBusy ); // can not operate in foreground |
2627 return KErrServerBusy; // can not operate in foreground |
2357 } |
2628 } |
2358 |
2629 |
2359 iStackState |= KMMCStackStateRunning; |
2630 iStackState |= KMMCStackStateRunning; |
2360 RESTOREPREEMPTION |
2631 RESTOREPREEMPTION |
2361 |
2632 |
2380 else |
2651 else |
2381 iReadyQueue++; |
2652 iReadyQueue++; |
2382 |
2653 |
2383 SchedGetOnDFC(); |
2654 SchedGetOnDFC(); |
2384 DoSchedule(); |
2655 DoSchedule(); |
2385 return( KErrNone ); |
2656 OstTraceFunctionExitExt( DMMCSTACK_STOP2_EXIT, this, KErrNone ); |
|
2657 return KErrNone; |
2386 } |
2658 } |
2387 |
2659 |
2388 void DMMCStack::MarkComplete(DMMCSession* aSessP, TMMCErr anExitCode) |
2660 void DMMCStack::MarkComplete(DMMCSession* aSessP, TMMCErr anExitCode) |
2389 /** |
2661 /** |
2390 * Marks session to be completed on the next scheduler pass. |
2662 * Marks session to be completed on the next scheduler pass. |
2391 */ |
2663 */ |
2392 { |
2664 { |
|
2665 OstTraceExt3(TRACE_FLOW, DMMCSTACK_MARKCOMPLETE_ENTRY ,"DMMCStack::MarkComplete;aSessP=%x;anExitCode=%d;this=%x", (TUint) aSessP, (TInt) anExitCode, (TUint) this); |
2393 ASSERT_NOT_ISR_CONTEXT |
2666 ASSERT_NOT_ISR_CONTEXT |
2394 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:mcp")); |
2667 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:mcp")); |
2395 |
2668 |
2396 aSessP->SynchBlock( KMMCBlockOnNoRun ); |
2669 aSessP->SynchBlock( KMMCBlockOnNoRun ); |
2397 aSessP->iMMCExitCode = anExitCode; |
2670 aSessP->iMMCExitCode = anExitCode; |
2398 aSessP->iDoComplete = ETrue; |
2671 aSessP->iDoComplete = ETrue; |
2399 iCompReq = ETrue; |
2672 iCompReq = ETrue; |
|
2673 OstTraceFunctionExit1( DMMCSTACK_MARKCOMPLETE_EXIT, this ); |
2400 } |
2674 } |
2401 |
2675 |
2402 // |
2676 // |
2403 // DMMCStack:: --- Miscellaneous --- |
2677 // DMMCStack:: --- Miscellaneous --- |
2404 // |
2678 // |
2405 EXPORT_C TUint32 DMMCStack::EffectiveModes(const TMMCStackConfig& aClientConfig) |
2679 EXPORT_C TUint32 DMMCStack::EffectiveModes(const TMMCStackConfig& aClientConfig) |
2406 /** |
2680 /** |
2407 * Calculates effective client modes as real client modes merged with iMasterConfig modes |
2681 * Calculates effective client modes as real client modes merged with iMasterConfig modes |
2408 */ |
2682 */ |
2409 { |
2683 { |
|
2684 OstTraceFunctionEntry1( DMMCSTACK_EFFECTIVEMODES_ENTRY, this ); |
2410 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:em")); |
2685 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:em")); |
2411 |
2686 |
2412 const TUint32 masterMode = (iMasterConfig.iModes & iMasterConfig.iUpdateMask) | |
2687 const TUint32 masterMode = (iMasterConfig.iModes & iMasterConfig.iUpdateMask) | |
2413 (KMMCModeDefault & ~iMasterConfig.iUpdateMask); |
2688 (KMMCModeDefault & ~iMasterConfig.iUpdateMask); |
2414 |
2689 |
2420 ((masterMode & KMMCModeMasterOverrides) | ~KMMCModeMasterOverrides); |
2695 ((masterMode & KMMCModeMasterOverrides) | ~KMMCModeMasterOverrides); |
2421 |
2696 |
2422 const TUint32 effectiveMode = (userMode & userMask) | (masterMode & ~userMask); |
2697 const TUint32 effectiveMode = (userMode & userMask) | (masterMode & ~userMask); |
2423 |
2698 |
2424 if( effectiveMode & KMMCModeEnableClientConfig ) |
2699 if( effectiveMode & KMMCModeEnableClientConfig ) |
2425 return( effectiveMode ); |
2700 { |
|
2701 OstTraceFunctionExitExt( DMMCSTACK_EFFECTIVEMODES_EXIT1, this, ( TUint )( effectiveMode ) ); |
|
2702 return effectiveMode; |
|
2703 } |
2426 else |
2704 else |
2427 return( (effectiveMode & KMMCModeClientOverrides) | |
2705 { |
2428 (masterMode & ~(KMMCModeClientOverrides | KMMCModeClientMask)) ); |
2706 |
|
2707 TUint32 ret = (effectiveMode & KMMCModeClientOverrides) | |
|
2708 (masterMode & ~(KMMCModeClientOverrides | KMMCModeClientMask)); |
|
2709 OstTraceFunctionExitExt( DMMCSTACK_EFFECTIVEMODES_EXIT2, this, ( TUint )( ret ) ); |
|
2710 return ret; |
|
2711 } |
2429 } |
2712 } |
2430 |
2713 |
2431 void DMMCStack::MergeConfig(DMMCSession* aSessP) |
2714 void DMMCStack::MergeConfig(DMMCSession* aSessP) |
2432 /** |
2715 /** |
2433 * Merges client and master configuration into iConfig |
2716 * Merges client and master configuration into iConfig |
2434 */ |
2717 */ |
2435 { |
2718 { |
|
2719 OstTraceFunctionEntryExt( DMMCSTACK_MERGECONFIG_ENTRY, this ); |
2436 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:mc")); |
2720 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:mc")); |
2437 |
2721 |
2438 TMMCStackConfig& cC = aSessP->iConfig; |
2722 TMMCStackConfig& cC = aSessP->iConfig; |
2439 TMMCStackConfig& mC = iMasterConfig; |
2723 TMMCStackConfig& mC = iMasterConfig; |
2440 const TUint32 modes = EffectiveModes( cC ); |
2724 const TUint32 modes = EffectiveModes( cC ); |
2512 : mC.iBusConfig.iDataTimeOut; |
2796 : mC.iBusConfig.iDataTimeOut; |
2513 |
2797 |
2514 iConfig.iBusConfig.iBusyTimeOut = (modes & KMMCModeClientBusyTimeOut) |
2798 iConfig.iBusConfig.iBusyTimeOut = (modes & KMMCModeClientBusyTimeOut) |
2515 ? cC.iBusConfig.iBusyTimeOut |
2799 ? cC.iBusConfig.iBusyTimeOut |
2516 : mC.iBusConfig.iBusyTimeOut; |
2800 : mC.iBusConfig.iBusyTimeOut; |
|
2801 OstTraceFunctionExit1( DMMCSTACK_MERGECONFIG_EXIT, this ); |
2517 } |
2802 } |
2518 |
2803 |
2519 TBool DMMCStack::StaticBlocks() |
2804 TBool DMMCStack::StaticBlocks() |
2520 /** |
2805 /** |
2521 * This function realises the potential blocking conditions of the current session. |
2806 * This function realises the potential blocking conditions of the current session. |
2522 * Returns ETrue if the session has to be stopped right now |
2807 * Returns ETrue if the session has to be stopped right now |
2523 */ |
2808 */ |
2524 { |
2809 { |
|
2810 OstTraceFunctionEntry1( DMMCSTACK_STATICBLOCKS_ENTRY, this ); |
2525 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:stb")); |
2811 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:stb")); |
2526 |
2812 |
2527 if( iSessionP->iDoStop ) |
2813 if( iSessionP->iDoStop ) |
2528 { |
2814 { |
2529 MarkComplete( iSessionP, KMMCErrAbort ); |
2815 MarkComplete( iSessionP, KMMCErrAbort ); |
2530 return( ETrue ); |
2816 OstTraceFunctionExitExt( DMMCSTACK_STATICBLOCKS_EXIT1, this, (TUint) ETrue ); |
|
2817 return ETrue; |
2531 } |
2818 } |
2532 |
2819 |
2533 if( !iDFCRunning && (iSessionP->iState & KMMCSessStateDoDFC) ) |
2820 if( !iDFCRunning && (iSessionP->iState & KMMCSessStateDoDFC) ) |
2534 return( ETrue ); |
2821 { |
2535 |
2822 OstTraceFunctionExitExt( DMMCSTACK_STATICBLOCKS_EXIT2, this, (TUint) ETrue ); |
2536 return( (iSessionP->iState & KMMCSessStateDoReSchedule) != 0 ); |
2823 return ETrue; |
|
2824 } |
|
2825 |
|
2826 TBool ret = (iSessionP->iState & KMMCSessStateDoReSchedule) != 0; |
|
2827 OstTraceFunctionExitExt( DMMCSTACK_STATICBLOCKS_EXIT3, this, ret ); |
|
2828 return ret; |
2537 } |
2829 } |
2538 |
2830 |
2539 |
2831 |
2540 EXPORT_C TBool DMMCStack::CardDetect(TUint /*aCardNumber*/) |
2832 EXPORT_C TBool DMMCStack::CardDetect(TUint /*aCardNumber*/) |
2541 /** |
2833 /** |
2564 void DMMCStack::StackSessionCBST(TAny* aStackP) |
2856 void DMMCStack::StackSessionCBST(TAny* aStackP) |
2565 /** |
2857 /** |
2566 * Stack Session completion routine. |
2858 * Stack Session completion routine. |
2567 */ |
2859 */ |
2568 { |
2860 { |
2569 |
|
2570 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sscbs")); |
2861 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sscbs")); |
2571 static_cast<DMMCStack *>(aStackP)->StackSessionCB(); |
2862 static_cast<DMMCStack *>(aStackP)->StackSessionCB(); |
2572 } |
2863 } |
2573 |
2864 |
2574 |
2865 |
2575 TInt DMMCStack::StackSessionCB() |
2866 TInt DMMCStack::StackSessionCB() |
2576 { |
2867 { |
|
2868 OstTraceFunctionEntry1( DMMCSTACK_STACKSESSIONCB_ENTRY, this ); |
2577 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sscb ")); |
2869 __KTRACE_OPT(KPBUS1,Kern::Printf("=mst:sscb ")); |
2578 |
2870 |
2579 if (iStackState & KMMCStackStateSleepinProgress) |
2871 if (iStackState & KMMCStackStateSleepinProgress) |
2580 { |
2872 { |
2581 // Sleep completed update stack state |
2873 // Sleep completed update stack state |
2582 iStackState &= ~KMMCStackStateSleepinProgress; |
2874 iStackState &= ~KMMCStackStateSleepinProgress; |
2583 return( 0 ); |
2875 OstTraceFunctionExit1( DMMCSTACK_STACKSESSIONCB_EXIT1, this ); |
|
2876 return 0; |
2584 } |
2877 } |
2585 |
2878 |
2586 TMMCErr mmcError = iStackSession->MMCExitCode(); |
2879 TMMCErr mmcError = iStackSession->MMCExitCode(); |
2587 iStackState &= ~KMMCStackStateInitInProgress; |
2880 iStackState &= ~KMMCStackStateInitInProgress; |
2588 |
2881 |
2738 EStAttStatus, |
3035 EStAttStatus, |
2739 EStEnd |
3036 EStEnd |
2740 }; |
3037 }; |
2741 |
3038 |
2742 DMMCSession& s=Session(); |
3039 DMMCSession& s=Session(); |
|
3040 OstTrace1( TRACE_INTERNALS, DMMCSTACK_ATTACHCARDSM1, "Current session=0x%x", &s ); |
2743 |
3041 |
2744 SMF_BEGIN |
3042 SMF_BEGIN |
2745 |
3043 |
|
3044 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ATTACHCARDSM2, "EStBegin" ); |
2746 if( s.iCardP == NULL ) |
3045 if( s.iCardP == NULL ) |
2747 return( KMMCErrNoCard ); |
3046 { |
|
3047 OstTraceFunctionExitExt( DMMCSTACK_ATTACHCARDSM_EXIT1, this, (TInt) KMMCErrNoCard ); |
|
3048 return KMMCErrNoCard; |
|
3049 } |
2748 |
3050 |
2749 if( s.iCardP->iUsingSessionP != NULL && s.iCardP->iUsingSessionP != &s ) |
3051 if( s.iCardP->iUsingSessionP != NULL && s.iCardP->iUsingSessionP != &s ) |
2750 { |
3052 { |
2751 s.SynchBlock( KMMCBlockOnCardInUse ); |
3053 s.SynchBlock( KMMCBlockOnCardInUse ); |
2752 SMF_WAIT |
3054 SMF_WAIT |
2753 } |
3055 } |
2754 |
3056 |
2755 if( s.iCardP->IsPresent() && s.iCardP->iCID == s.iCID ) |
3057 if( s.iCardP->IsPresent() && s.iCardP->iCID == s.iCID ) |
2756 s.iCardP->iUsingSessionP = &s; |
3058 s.iCardP->iUsingSessionP = &s; |
2757 else |
3059 else |
2758 return( KMMCErrNoCard ); |
3060 { |
|
3061 OstTraceFunctionExitExt( DMMCSTACK_ATTACHCARDSM_EXIT2, this, (TInt) KMMCErrNoCard ); |
|
3062 return KMMCErrNoCard; |
|
3063 } |
2759 |
3064 |
2760 s.iConfig.SetMode( KMMCModeCardControlled ); // for future context switching |
3065 s.iConfig.SetMode( KMMCModeCardControlled ); // for future context switching |
2761 iConfig.SetMode( KMMCModeCardControlled ); // for this context |
3066 iConfig.SetMode( KMMCModeCardControlled ); // for this context |
2762 |
3067 |
2763 // read card status if there are sticky bits in it |
3068 // read card status if there are sticky bits in it |
2793 }; |
3100 }; |
2794 |
3101 |
2795 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:InitStackSM")); |
3102 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:InitStackSM")); |
2796 |
3103 |
2797 DMMCSession& s=Session(); |
3104 DMMCSession& s=Session(); |
|
3105 OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMINITSTACKSM1, "Current session=0x%x", &s ); |
2798 |
3106 |
2799 SMF_BEGIN |
3107 SMF_BEGIN |
2800 |
3108 |
|
3109 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMINITSTACKSM2, "EStBegin" ); |
2801 m.SetTraps( KMMCErrAll ); // to prevent this macro from infinite restarts via iInitialise |
3110 m.SetTraps( KMMCErrAll ); // to prevent this macro from infinite restarts via iInitialise |
2802 |
3111 |
2803 SMF_INVOKES( CIMUpdateAcqSMST, EStInitDone ) |
3112 SMF_INVOKES( CIMUpdateAcqSMST, EStInitDone ) |
2804 |
3113 |
2805 SMF_STATE(EStInitDone) |
3114 SMF_STATE(EStInitDone) |
2806 |
3115 |
|
3116 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMINITSTACKSM3, "EStInitDone" ); |
2807 s.iState &= ~KMMCSessStateInProgress; // now we won't be restarted |
3117 s.iState &= ~KMMCSessStateInProgress; // now we won't be restarted |
2808 SchedGetOnDFC(); // StackSessionCB must be on DFC |
3118 SchedGetOnDFC(); // StackSessionCB must be on DFC |
|
3119 OstTraceFunctionExitExt( DMMCSTACK_CIMINITSTACKSM_EXIT, this, (TInt) err ); |
2809 SMF_RETURN( err ) // _?_ power cycles can be performed here if error |
3120 SMF_RETURN( err ) // _?_ power cycles can be performed here if error |
2810 |
3121 |
2811 SMF_END |
3122 SMF_END |
2812 } |
3123 } |
2813 |
3124 |
2893 iInitContext++; // Pass number must never be zero |
3208 iInitContext++; // Pass number must never be zero |
2894 s.iInitContext = iInitContext; // this session is always in a proper context |
3209 s.iInitContext = iInitContext; // this session is always in a proper context |
2895 |
3210 |
2896 SMF_STATE(EStStartInterrogation) |
3211 SMF_STATE(EStStartInterrogation) |
2897 |
3212 |
|
3213 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMUPDATEACQSM5, "EStStartInterrogation" ); |
2898 // NB: RCAs are not unlocked here. They will be unlocked one by one during the update of card info array. |
3214 // NB: RCAs are not unlocked here. They will be unlocked one by one during the update of card info array. |
2899 SMF_INVOKES( AcquireStackSMST, EStCheckStack ) |
3215 SMF_INVOKES( AcquireStackSMST, EStCheckStack ) |
2900 |
3216 |
2901 SMF_STATE(EStCheckStack) |
3217 SMF_STATE(EStCheckStack) |
2902 |
3218 |
|
3219 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMUPDATEACQSM6, "EStCheckStack" ); |
2903 // Check that all known cards are still present by issuing select/deselect |
3220 // Check that all known cards are still present by issuing select/deselect |
2904 SMF_INVOKES( CheckStackSMST, EStCardCap ) |
3221 SMF_INVOKES( CheckStackSMST, EStCardCap ) |
2905 |
3222 |
2906 SMF_STATE(EStCardCap) |
3223 SMF_STATE(EStCardCap) |
2907 |
3224 |
|
3225 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMUPDATEACQSM7, "EStCardCap" ); |
2908 // Call a licencee-specific state machine to allow card capabilities to be modified. |
3226 // Call a licencee-specific state machine to allow card capabilities to be modified. |
2909 SMF_INVOKES( ModifyCardCapabilitySMST, EStIssueDSR ) |
3227 SMF_INVOKES( ModifyCardCapabilitySMST, EStIssueDSR ) |
2910 |
3228 |
2911 SMF_STATE(EStIssueDSR) |
3229 SMF_STATE(EStIssueDSR) |
2912 |
3230 |
3009 if(cardP->IsLocked()) |
3333 if(cardP->IsLocked()) |
3010 SMF_GOTOS(EStTestNextCard); |
3334 SMF_GOTOS(EStTestNextCard); |
3011 |
3335 |
3012 SMF_STATE(EStGetExtendedCSD) |
3336 SMF_STATE(EStGetExtendedCSD) |
3013 |
3337 |
|
3338 OstTrace0( TRACE_INTERNALS, DMMCSTACK_INITSTACKAFTERUNLOCKSM4, "EStGetExtendedCSD" ); |
|
3339 |
3014 // Get the Extended CSD if this is an MMC version 4 card |
3340 // Get the Extended CSD if this is an MMC version 4 card |
3015 |
3341 |
3016 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), SpecVers() %u", s.CardP()->CSD().SpecVers())); |
3342 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), SpecVers() %u", s.CardP()->CSD().SpecVers())); |
|
3343 OstTrace1( TRACE_INTERNALS, DMMCSTACK_INITSTACKAFTERUNLOCKSM5, "SpecVers()=%u", s.CardP()->CSD().SpecVers() ); |
|
3344 |
3017 |
3345 |
3018 // clear the Extended CSD contents in case this is a pre-version 4 card or the read fails. |
3346 // clear the Extended CSD contents in case this is a pre-version 4 card or the read fails. |
3019 memset(s.CardP()->iExtendedCSD.Ptr(), 0, KMMCExtendedCSDLength); |
3347 memset(s.CardP()->iExtendedCSD.Ptr(), 0, KMMCExtendedCSDLength); |
3020 |
3348 |
3021 if (s.CardP()->CSD().SpecVers() < 4) |
3349 if (s.CardP()->CSD().SpecVers() < 4) |
3041 // Call a licencee-specific state machine to allow the Extended CSD register to be modified. |
3370 // Call a licencee-specific state machine to allow the Extended CSD register to be modified. |
3042 SMF_INVOKES( ModifyCardCapabilitySMST, EStGotModifiedExtendedCSD ) |
3371 SMF_INVOKES( ModifyCardCapabilitySMST, EStGotModifiedExtendedCSD ) |
3043 |
3372 |
3044 SMF_STATE(EStGotModifiedExtendedCSD) |
3373 SMF_STATE(EStGotModifiedExtendedCSD) |
3045 |
3374 |
|
3375 OstTrace0( TRACE_INTERNALS, DMMCSTACK_INITSTACKAFTERUNLOCKSM7, "EStGotExtendedCSD" ); |
|
3376 |
3046 __KTRACE_OPT(KPBUS1, Kern::Printf("Extended CSD")); |
3377 __KTRACE_OPT(KPBUS1, Kern::Printf("Extended CSD")); |
3047 __KTRACE_OPT(KPBUS1, Kern::Printf("CSDStructureVer: %u", s.CardP()->ExtendedCSD().CSDStructureVer())); |
3378 __KTRACE_OPT(KPBUS1, Kern::Printf("CSDStructureVer: %u", s.CardP()->ExtendedCSD().CSDStructureVer())); |
3048 __KTRACE_OPT(KPBUS1, Kern::Printf("ExtendedCSDRev: %u", s.CardP()->ExtendedCSD().ExtendedCSDRev())); |
3379 __KTRACE_OPT(KPBUS1, Kern::Printf("ExtendedCSDRev: %u", s.CardP()->ExtendedCSD().ExtendedCSDRev())); |
3049 __KTRACE_OPT(KPBUS1, Kern::Printf("-------------------------------")); |
3380 __KTRACE_OPT(KPBUS1, Kern::Printf("-------------------------------")); |
3050 __KTRACE_OPT(KPBUS1, Kern::Printf("SupportedCmdSet: %u", s.CardP()->ExtendedCSD().SupportedCmdSet())); |
3381 __KTRACE_OPT(KPBUS1, Kern::Printf("SupportedCmdSet: %u", s.CardP()->ExtendedCSD().SupportedCmdSet())); |
3068 __KTRACE_OPT(KPBUS1, Kern::Printf("SleepCurrentVccQ: %u", s.CardP()->ExtendedCSD().SleepCurrentVccQ())); |
3399 __KTRACE_OPT(KPBUS1, Kern::Printf("SleepCurrentVccQ: %u", s.CardP()->ExtendedCSD().SleepCurrentVccQ())); |
3069 __KTRACE_OPT(KPBUS1, Kern::Printf("SleepAwakeTimeout: %u", s.CardP()->ExtendedCSD().SleepAwakeTimeout())); |
3400 __KTRACE_OPT(KPBUS1, Kern::Printf("SleepAwakeTimeout: %u", s.CardP()->ExtendedCSD().SleepAwakeTimeout())); |
3070 __KTRACE_OPT(KPBUS1, Kern::Printf("BootConfig: %u", s.CardP()->ExtendedCSD().BootConfig())); |
3401 __KTRACE_OPT(KPBUS1, Kern::Printf("BootConfig: %u", s.CardP()->ExtendedCSD().BootConfig())); |
3071 __KTRACE_OPT(KPBUS1, Kern::Printf("BootBusWidth: %u", s.CardP()->ExtendedCSD().BootBusWidth())); |
3402 __KTRACE_OPT(KPBUS1, Kern::Printf("BootBusWidth: %u", s.CardP()->ExtendedCSD().BootBusWidth())); |
3072 __KTRACE_OPT(KPBUS1, Kern::Printf("EraseGroupDef: %u", s.CardP()->ExtendedCSD().EraseGroupDef())); |
3403 __KTRACE_OPT(KPBUS1, Kern::Printf("EraseGroupDef: %u", s.CardP()->ExtendedCSD().EraseGroupDef())); |
3073 |
3404 |
|
3405 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSTACK_INITSTACKAFTERUNLOCKSM8, "CSDStructureVer=%u; ExtendedCSDRev=%u; SupportedCmdSet=%u", s.CardP()->ExtendedCSD().CSDStructureVer(), s.CardP()->ExtendedCSD().ExtendedCSDRev(), s.CardP()->ExtendedCSD().SupportedCmdSet() ); |
|
3406 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSTACK_INITSTACKAFTERUNLOCKSM9, "PowerClass26Mhz360V=0x%02x; PowerClass52Mhz360V=0x%02x; PowerClass26Mhz195V=0x%02x; PowerClass52Mhz195V=0x%02x", s.CardP()->ExtendedCSD().PowerClass26Mhz360V(), s.CardP()->ExtendedCSD().PowerClass52Mhz360V(), s.CardP()->ExtendedCSD().PowerClass26Mhz195V(), s.CardP()->ExtendedCSD().PowerClass52Mhz195V() ); |
|
3407 OstTraceDefExt5( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSTACK_INITSTACKAFTERUNLOCKSM10, "CardType=%u; CmdSet=%u; CmdSetRev=%u; PowerClass=%u; HighSpeedTiming=%u", s.CardP()->ExtendedCSD().CardType(), s.CardP()->ExtendedCSD().CmdSet(), s.CardP()->ExtendedCSD().CmdSetRev(), s.CardP()->ExtendedCSD().PowerClass(), s.CardP()->ExtendedCSD().HighSpeedTiming() ); |
|
3408 OstTraceDefExt5( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSTACK_INITSTACKAFTERUNLOCKSM11, "HighCapacityEraseGroupSize=%u; AccessSize=%u; BootInfo=%u; BootSizeMultiple=%u; EraseTimeoutMultiple=%u", s.CardP()->ExtendedCSD().HighCapacityEraseGroupSize(), s.CardP()->ExtendedCSD().AccessSize(), s.CardP()->ExtendedCSD().BootInfo(), s.CardP()->ExtendedCSD().BootSizeMultiple(), s.CardP()->ExtendedCSD().EraseTimeoutMultiple() ); |
|
3409 OstTraceDefExt5( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSTACK_INITSTACKAFTERUNLOCKSM12, "ReliableWriteSector=%u; HighCapWriteProtGroupSize=%u; SleepCurrentVcc=%u; SleepCurrentVccQ=%u; SleepAwakeTimeout=%u", s.CardP()->ExtendedCSD().ReliableWriteSector(), s.CardP()->ExtendedCSD().HighCapacityWriteProtectGroupSize(), s.CardP()->ExtendedCSD().SleepCurrentVcc(), s.CardP()->ExtendedCSD().SleepCurrentVccQ(), s.CardP()->ExtendedCSD().SleepAwakeTimeout() ); |
|
3410 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSTACK_INITSTACKAFTERUNLOCKSM13, "BootConfig=%u; BootBusWidth=%u; EraseGroupDef=%u", s.CardP()->ExtendedCSD().BootConfig(), s.CardP()->ExtendedCSD().BootBusWidth(), s.CardP()->ExtendedCSD().EraseGroupDef() ); |
|
3411 |
3074 if (s.CardP()->ExtendedCSD().ExtendedCSDRev() >= 3) |
3412 if (s.CardP()->ExtendedCSD().ExtendedCSDRev() >= 3) |
3075 { |
3413 { |
3076 if (!(s.CardP()->ExtendedCSD().EraseGroupDef()) && s.CardP()->ExtendedCSD().HighCapacityEraseGroupSize()) |
3414 if (!(s.CardP()->ExtendedCSD().EraseGroupDef()) && s.CardP()->ExtendedCSD().HighCapacityEraseGroupSize()) |
3077 { |
3415 { |
3078 // Need to ensure that media is using correct erase group sizes. |
3416 // Need to ensure that media is using correct erase group sizes. |
3081 TExtendedCSD::EEraseGroupDefIndex, |
3419 TExtendedCSD::EEraseGroupDefIndex, |
3082 TExtendedCSD::EEraseGrpDefEnableHighCapSizes, |
3420 TExtendedCSD::EEraseGrpDefEnableHighCapSizes, |
3083 0); |
3421 0); |
3084 |
3422 |
3085 __KTRACE_OPT(KPBUS1, Kern::Printf(">Writing to EXT_CSD (EEraseGroupDefIndex), arg %08X", (TUint32) arg)); |
3423 __KTRACE_OPT(KPBUS1, Kern::Printf(">Writing to EXT_CSD (EEraseGroupDefIndex), arg %08X", (TUint32) arg)); |
|
3424 OstTrace1( TRACE_INTERNALS, DMMCSTACK_INITSTACKAFTERUNLOCKSM14, "Writing to EXT_CSD (EEraseGroupDefIndex); arg=0x%08x", (TUint32) arg ); |
|
3425 |
3086 s.FillCommandDesc(ECmdSwitch, arg); |
3426 s.FillCommandDesc(ECmdSwitch, arg); |
3087 |
3427 |
3088 SMF_INVOKES(ExecSwitchCommandST, EStEraseGroupDefSet) |
3428 SMF_INVOKES(ExecSwitchCommandST, EStEraseGroupDefSet) |
3089 } |
3429 } |
3090 } |
3430 } |
3091 |
3431 |
3092 SMF_GOTOS(EStDetermineBusWidthAndClock) |
3432 SMF_GOTOS(EStDetermineBusWidthAndClock) |
3093 |
3433 |
3094 SMF_STATE(EStEraseGroupDefSet) |
3434 SMF_STATE(EStEraseGroupDefSet) |
3095 |
3435 |
|
3436 OstTrace0( TRACE_INTERNALS, DMMCSTACK_INITSTACKAFTERUNLOCKSM15, "EStEraseGroupDefSet" ); |
|
3437 |
3096 if (err == KMMCErrNone) |
3438 if (err == KMMCErrNone) |
3097 { |
3439 { |
3098 // EEraseGroupDef has been updated succussfully, |
3440 // EEraseGroupDef has been updated succussfully, |
3099 // update the Extended CSD to reflect this |
3441 // update the Extended CSD to reflect this |
3100 memset( s.CardP()->iExtendedCSD.Ptr()+TExtendedCSD::EEraseGroupDefIndex, TExtendedCSD::EEraseGrpDefEnableHighCapSizes, 1); |
3442 memset( s.CardP()->iExtendedCSD.Ptr()+TExtendedCSD::EEraseGroupDefIndex, TExtendedCSD::EEraseGrpDefEnableHighCapSizes, 1); |
3101 } |
3443 } |
3102 |
3444 |
3103 SMF_STATE(EStDetermineBusWidthAndClock) |
3445 SMF_STATE(EStDetermineBusWidthAndClock) |
3104 |
3446 |
|
3447 OstTrace0( TRACE_INTERNALS, DMMCSTACK_INITSTACKAFTERUNLOCKSM16, "EStDetermineBusWidthAndClock" ); |
3105 SMF_INVOKES( DetermineBusWidthAndClockSMST, EStGotBusWidthAndClock ) |
3448 SMF_INVOKES( DetermineBusWidthAndClockSMST, EStGotBusWidthAndClock ) |
3106 |
3449 |
3107 SMF_STATE(EStGotBusWidthAndClock) |
3450 SMF_STATE(EStGotBusWidthAndClock) |
3108 |
3451 |
|
3452 OstTrace0( TRACE_INTERNALS, DMMCSTACK_INITSTACKAFTERUNLOCKSM17, "EStGotBusWidthAndClock" ); |
3109 SMF_NEXTS(initSingleCard ? EStExit : EStTestNextCard) |
3453 SMF_NEXTS(initSingleCard ? EStExit : EStTestNextCard) |
3110 |
3454 |
3111 if(iMultiplexedBus || iCardArray->CardsPresent() == 1) |
3455 if(iMultiplexedBus || iCardArray->CardsPresent() == 1) |
3112 { |
3456 { |
3113 SMF_CALL( ConfigureHighSpeedSMST ) |
3457 SMF_CALL( ConfigureHighSpeedSMST ) |
3152 EStEnd |
3499 EStEnd |
3153 }; |
3500 }; |
3154 |
3501 |
3155 DMMCSession& s = Session(); |
3502 DMMCSession& s = Session(); |
3156 TMMCard* cardP = iCardArray->CardP(iSelectedCardIndex); |
3503 TMMCard* cardP = iCardArray->CardP(iSelectedCardIndex); |
|
3504 OstTrace1( TRACE_INTERNALS, DMMCSTACK_DETERMINEBUSWIDTHANDCLOCKSM1, "Current session=0x%x", &s ); |
3157 |
3505 |
3158 SMF_BEGIN |
3506 SMF_BEGIN |
|
3507 |
|
3508 OstTrace0( TRACE_INTERNALS, DMMCSTACK_DETERMINEBUSWIDTHANDCLOCKSM2, "EStBegin" ); |
3159 // Trap Switch errors & no-response errors |
3509 // Trap Switch errors & no-response errors |
3160 m.SetTraps(KMMCErrResponseTimeOut | KMMCErrStatus); |
3510 m.SetTraps(KMMCErrResponseTimeOut | KMMCErrStatus); |
3161 |
3511 |
3162 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), iCxCardCount %u", iCxCardCount)); |
3512 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), iCxCardCount %u", iCxCardCount)); |
3163 |
3513 |
3164 |
3514 |
3165 SMF_STATE(EStWritePowerClass) |
3515 SMF_STATE(EStWritePowerClass) |
3166 |
3516 |
|
3517 OstTrace0( TRACE_INTERNALS, DMMCSTACK_DETERMINEBUSWIDTHANDCLOCKSM3, "EStWritePowerClass" ); |
|
3518 |
3167 // Check the card type is valid |
3519 // Check the card type is valid |
3168 // The only currently valid values for this field are 0x01 or 0x03 |
3520 // The only currently valid values for this field are 0x01 or 0x03 |
3169 TUint cardType = cardP->iExtendedCSD.CardType(); |
3521 TUint cardType = cardP->iExtendedCSD.CardType(); |
3170 if (cardType != (TExtendedCSD::EHighSpeedCard26Mhz) && |
3522 if (cardType != (TExtendedCSD::EHighSpeedCard26Mhz) && |
3171 cardType != (TExtendedCSD::EHighSpeedCard26Mhz | TExtendedCSD::EHighSpeedCard52Mhz)) |
3523 cardType != (TExtendedCSD::EHighSpeedCard26Mhz | TExtendedCSD::EHighSpeedCard52Mhz)) |
3172 { |
3524 { |
3173 __KTRACE_OPT(KPBUS1, Kern::Printf("Unsupported card type %u", cardType)); |
3525 __KTRACE_OPT(KPBUS1, Kern::Printf("Unsupported card type %u", cardType)); |
|
3526 OstTrace1( TRACE_INTERNALS, DMMCSTACK_DETERMINEBUSWIDTHANDCLOCKSM4, "Unsupported card type=%u", cardType ); |
|
3527 |
3174 SMF_GOTOS(EStExit); |
3528 SMF_GOTOS(EStExit); |
3175 } |
3529 } |
3176 |
3530 |
3177 // determine the optimum bus width & clock speed which match the power constraints |
3531 // determine the optimum bus width & clock speed which match the power constraints |
3178 TUint powerClass; |
3532 TUint powerClass; |
3191 TExtendedCSD::EPowerClassIndex, |
3545 TExtendedCSD::EPowerClassIndex, |
3192 powerClass, |
3546 powerClass, |
3193 0); |
3547 0); |
3194 |
3548 |
3195 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), Writing to EXT_CSD (EPowerClass), arg %08X", (TUint32) arg)); |
3549 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), Writing to EXT_CSD (EPowerClass), arg %08X", (TUint32) arg)); |
|
3550 OstTrace1( TRACE_INTERNALS, DMMCSTACK_DETERMINEBUSWIDTHANDCLOCKSM5, "Writing to EXT_CSD (EPowerClass); arg=0x%08x", (TUint32) arg ); |
3196 s.FillCommandDesc(ECmdSwitch, arg); |
3551 s.FillCommandDesc(ECmdSwitch, arg); |
3197 SMF_INVOKES(ExecSwitchCommandST, EStStartBusTest) |
3552 SMF_INVOKES(ExecSwitchCommandST, EStStartBusTest) |
3198 } |
3553 } |
3199 |
3554 |
3200 SMF_STATE(EStStartBusTest) |
3555 SMF_STATE(EStStartBusTest) |
3201 |
3556 |
|
3557 OstTrace0( TRACE_INTERNALS, DMMCSTACK_DETERMINEBUSWIDTHANDCLOCKSM6, "EStStartBusTest" ); |
|
3558 |
3202 if (err != KMMCErrNone) |
3559 if (err != KMMCErrNone) |
3203 { |
3560 { |
3204 SMF_GOTOS(EStExit); |
3561 SMF_GOTOS(EStExit); |
3205 } |
3562 } |
3206 |
3563 |
3207 // We have determined the capabilities of the host and card. |
3564 // We have determined the capabilities of the host and card. |
3208 // - Before switching to the required bus width, perform the BUSTEST sequence |
3565 // - Before switching to the required bus width, perform the BUSTEST sequence |
3209 SMF_INVOKES(ExecBusTestSMST, EStExit); |
3566 SMF_INVOKES(ExecBusTestSMST, EStExit); |
3210 |
3567 |
3211 SMF_STATE(EStExit) |
3568 SMF_STATE(EStExit) |
|
3569 |
|
3570 OstTrace0( TRACE_INTERNALS, DMMCSTACK_DETERMINEBUSWIDTHANDCLOCKSM7, "EStExit" ); |
3212 m.ResetTraps(); |
3571 m.ResetTraps(); |
3213 |
3572 |
3214 SMF_END |
3573 SMF_END |
3215 } |
3574 } |
3216 |
3575 |
3242 EStEnd |
3601 EStEnd |
3243 }; |
3602 }; |
3244 |
3603 |
3245 DMMCSession& s = Session(); |
3604 DMMCSession& s = Session(); |
3246 TMMCard* cardP = iCardArray->CardP(iSelectedCardIndex); |
3605 TMMCard* cardP = iCardArray->CardP(iSelectedCardIndex); |
|
3606 OstTrace1( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM1, "Current session=0x%x", &s ); |
3247 |
3607 |
3248 SMF_BEGIN |
3608 SMF_BEGIN |
3249 |
3609 |
|
3610 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM2, "EStBegin" ); |
|
3611 |
3250 // Trap Switch errors & no-response errors |
3612 // Trap Switch errors & no-response errors |
3251 m.SetTraps(KMMCErrResponseTimeOut | KMMCErrStatus); |
3613 m.SetTraps(KMMCErrResponseTimeOut | KMMCErrStatus); |
3252 |
3614 |
3253 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), iCxCardCount %u", iCxCardCount)); |
3615 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), iCxCardCount %u", iCxCardCount)); |
|
3616 OstTrace1( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM3, "iCxCardCount=%d", iCxCardCount ); |
3254 |
3617 |
3255 cardP->SetHighSpeedClock(0); |
3618 cardP->SetHighSpeedClock(0); |
3256 |
3619 |
3257 // Check the card type is valid |
3620 // Check the card type is valid |
3258 // The only currently valid values for this field are 0x01 or 0x03 |
3621 // The only currently valid values for this field are 0x01 or 0x03 |
3259 TUint cardType = cardP->iExtendedCSD.CardType(); |
3622 TUint cardType = cardP->iExtendedCSD.CardType(); |
3260 if (cardType != (TExtendedCSD::EHighSpeedCard26Mhz) && |
3623 if (cardType != (TExtendedCSD::EHighSpeedCard26Mhz) && |
3261 cardType != (TExtendedCSD::EHighSpeedCard26Mhz | TExtendedCSD::EHighSpeedCard52Mhz)) |
3624 cardType != (TExtendedCSD::EHighSpeedCard26Mhz | TExtendedCSD::EHighSpeedCard52Mhz)) |
3262 { |
3625 { |
3263 __KTRACE_OPT(KPBUS1, Kern::Printf("Unsupported card type %u", cardType)); |
3626 __KTRACE_OPT(KPBUS1, Kern::Printf("Unsupported card type %u", cardType)); |
|
3627 OstTrace1( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM4, "Unsupported card type=%u", cardType ); |
3264 SMF_GOTOS(EStExit); |
3628 SMF_GOTOS(EStExit); |
3265 } |
3629 } |
3266 |
3630 |
3267 // If the bus width is 4 or 8, send SWITCH cmd and write the BUS_WIDTH byte of the EXT_CSD register |
3631 // If the bus width is 4 or 8, send SWITCH cmd and write the BUS_WIDTH byte of the EXT_CSD register |
3268 |
3632 |
3273 TExtendedCSD::EBusWidthModeIndex, |
3637 TExtendedCSD::EBusWidthModeIndex, |
3274 (iBusWidthAndClock & E4BitMask) ? TExtendedCSD::EExtCsdBusWidth4 : TExtendedCSD::EExtCsdBusWidth8, |
3638 (iBusWidthAndClock & E4BitMask) ? TExtendedCSD::EExtCsdBusWidth4 : TExtendedCSD::EExtCsdBusWidth8, |
3275 0); |
3639 0); |
3276 |
3640 |
3277 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), Writing to EXT_CSD (EBusWidthMode), arg %08X", (TUint32) arg)); |
3641 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), Writing to EXT_CSD (EBusWidthMode), arg %08X", (TUint32) arg)); |
|
3642 OstTrace1( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM5, "Writing to EXT_CSD (EBusWidthMode); arg=0x%x", (TUint32) arg ); |
3278 s.FillCommandDesc(ECmdSwitch, arg); |
3643 s.FillCommandDesc(ECmdSwitch, arg); |
3279 SMF_INVOKES(ExecSwitchCommandST, EStConfigureBusWidth) |
3644 SMF_INVOKES(ExecSwitchCommandST, EStConfigureBusWidth) |
3280 } |
3645 } |
3281 |
3646 |
3282 SMF_STATE(EStConfigureBusWidth) |
3647 SMF_STATE(EStConfigureBusWidth) |
3283 |
3648 |
|
3649 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM6, "EStConfigureBusWidth" ); |
|
3650 |
3284 if (err != KMMCErrNone) |
3651 if (err != KMMCErrNone) |
3285 { |
3652 { |
3286 SMF_GOTOS(EStExit); |
3653 SMF_GOTOS(EStExit); |
3287 } |
3654 } |
3288 |
3655 |
3297 DoSetBusWidth(EBusWidth8); |
3664 DoSetBusWidth(EBusWidth8); |
3298 } |
3665 } |
3299 // fall through to next state |
3666 // fall through to next state |
3300 |
3667 |
3301 SMF_STATE(EStWriteHsTiming) |
3668 SMF_STATE(EStWriteHsTiming) |
|
3669 |
|
3670 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM7, "EStWriteHsTiming" ); |
|
3671 |
3302 if (iBusWidthAndClock == E1Bit20Mhz) |
3672 if (iBusWidthAndClock == E1Bit20Mhz) |
3303 SMF_GOTOS(EStExit); |
3673 SMF_GOTOS(EStExit); |
3304 |
3674 |
3305 TMMCArgument arg = TExtendedCSD::GetWriteArg( |
3675 TMMCArgument arg = TExtendedCSD::GetWriteArg( |
3306 TExtendedCSD::EWriteByte, |
3676 TExtendedCSD::EWriteByte, |
3307 TExtendedCSD::EHighSpeedInterfaceTimingIndex, |
3677 TExtendedCSD::EHighSpeedInterfaceTimingIndex, |
3308 1, // turn on high speed (26 or 52 Mhz, depending on the card type) |
3678 1, // turn on high speed (26 or 52 Mhz, depending on the card type) |
3309 0); |
3679 0); |
3310 |
3680 |
3311 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), Writing to EXT_CSD (EHighSpeedInterfaceTiming), arg %08X", (TUint32) arg)); |
3681 __KTRACE_OPT(KPBUS1, Kern::Printf(">ConfigureHighSpeed(), Writing to EXT_CSD (EHighSpeedInterfaceTiming), arg %08X", (TUint32) arg)); |
|
3682 OstTrace1( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM8, "Writing to EXT_CSD (EHighSpeedInterfaceTiming); arg=0x%x", (TUint32) arg ); |
3312 s.FillCommandDesc(ECmdSwitch, arg); |
3683 s.FillCommandDesc(ECmdSwitch, arg); |
3313 SMF_INVOKES(ExecSwitchCommandST, EStConfigureClock) |
3684 SMF_INVOKES(ExecSwitchCommandST, EStConfigureClock) |
3314 |
3685 |
3315 |
3686 |
3316 SMF_STATE(EStConfigureClock) |
3687 SMF_STATE(EStConfigureClock) |
3317 |
3688 |
|
3689 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CONFIGUREHIGHSPEEDSM9, "EStConfigureClock" ); |
|
3690 |
3318 if (err != KMMCErrNone) |
3691 if (err != KMMCErrNone) |
3319 { |
3692 { |
3320 DoSetBusWidth(EBusWidth1); |
3693 DoSetBusWidth(EBusWidth1); |
3321 SMF_GOTOS(EStExit); |
3694 SMF_GOTOS(EStExit); |
3322 } |
3695 } |
3343 EStGetStatus, |
3719 EStGetStatus, |
3344 EStEnd |
3720 EStEnd |
3345 }; |
3721 }; |
3346 |
3722 |
3347 DMMCSession& s=Session(); |
3723 DMMCSession& s=Session(); |
|
3724 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECSWITCHCOMMAND1, "Current session=0x%x", &s ); |
3348 |
3725 |
3349 SMF_BEGIN |
3726 SMF_BEGIN |
3350 SMF_INVOKES(ExecCommandSMST, EStSendStatus) |
3727 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECSWITCHCOMMAND2, "EStBegin" ); |
|
3728 SMF_INVOKES(ExecCommandSMST, EStSendStatus) |
3351 |
3729 |
3352 SMF_STATE(EStSendStatus) |
3730 SMF_STATE(EStSendStatus) |
|
3731 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECSWITCHCOMMAND3, "EStSendStatus" ); |
3353 s.FillCommandDesc(ECmdSendStatus, 0); |
3732 s.FillCommandDesc(ECmdSendStatus, 0); |
3354 SMF_INVOKES(ExecCommandSMST, EStGetStatus) |
3733 SMF_INVOKES(ExecCommandSMST, EStGetStatus) |
3355 |
3734 |
3356 SMF_STATE(EStGetStatus) |
3735 SMF_STATE(EStGetStatus) |
|
3736 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECSWITCHCOMMAND4, "EStGetStatus" ); |
3357 const TMMCStatus st(s.ResponseP()); |
3737 const TMMCStatus st(s.ResponseP()); |
3358 |
3738 |
3359 const TMMCardStateEnum st1 = st.State(); |
3739 const TMMCardStateEnum st1 = st.State(); |
3360 if (st1 == ECardStatePrg) |
3740 if (st1 == ECardStatePrg) |
3361 { |
3741 { |
3381 EStDone, |
3761 EStDone, |
3382 EStEnd |
3762 EStEnd |
3383 }; |
3763 }; |
3384 |
3764 |
3385 DMMCSession& s=Session(); |
3765 DMMCSession& s=Session(); |
|
3766 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECSLEEPCOMMANDSM1, "Current session=0x%x", &s ); |
3386 |
3767 |
3387 SMF_BEGIN |
3768 SMF_BEGIN |
3388 |
3769 |
|
3770 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECSLEEPCOMMANDSM2, "EStBegin" ); |
|
3771 |
3389 __KTRACE_OPT(KPBUS1, Kern::Printf(">ExecSleepCommandSM()")); |
3772 __KTRACE_OPT(KPBUS1, Kern::Printf(">ExecSleepCommandSM()")); |
3390 |
3773 |
3391 iAutoUnlockIndex = -1; |
3774 iAutoUnlockIndex = -1; |
3392 // drop through.... |
3775 // drop through.... |
3393 |
3776 |
3394 SMF_STATE(EStIndexNxtCard) |
3777 SMF_STATE(EStIndexNxtCard) |
3395 |
3778 |
|
3779 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECSLEEPCOMMANDSM3, "EStIndexNxtCard" ); |
3396 __KTRACE_OPT(KPBUS1, Kern::Printf(">EStIndexNxtCard")); |
3780 __KTRACE_OPT(KPBUS1, Kern::Printf(">EStIndexNxtCard")); |
3397 // the cycle is finished when iAutoUnlockIndex == KMaxMultiMediaCardsPerStack |
3781 // the cycle is finished when iAutoUnlockIndex == KMaxMultiMediaCardsPerStack |
3398 if(iAutoUnlockIndex >= TInt(KMaxMMCardsPerStack)) |
3782 if(iAutoUnlockIndex >= TInt(KMaxMMCardsPerStack)) |
3399 { |
3783 { |
3400 SMF_GOTOS(EStUpdateStackState); |
3784 SMF_GOTOS(EStUpdateStackState); |
3444 if(status.State() == ECardStateStby || status.State() == ECardStateSlp) |
3830 if(status.State() == ECardStateStby || status.State() == ECardStateSlp) |
3445 { |
3831 { |
3446 // R1b is issued before Sleep state is achieved and |
3832 // R1b is issued before Sleep state is achieved and |
3447 // will therefore return the previous state which was Standby |
3833 // will therefore return the previous state which was Standby |
3448 __KTRACE_OPT(KPBUS1, Kern::Printf(">Card[%d]: SLEEP",iAutoUnlockIndex)); |
3834 __KTRACE_OPT(KPBUS1, Kern::Printf(">Card[%d]: SLEEP",iAutoUnlockIndex)); |
|
3835 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECSLEEPCOMMANDSM6, "Card[%d]: SLEEP", iAutoUnlockIndex ); |
3449 |
3836 |
3450 // Ensure card status is ECardStateSlp |
3837 // Ensure card status is ECardStateSlp |
3451 s.CardP()->iStatus.UpdateState(ECardStateSlp); |
3838 s.CardP()->iStatus.UpdateState(ECardStateSlp); |
3452 |
3839 |
3453 // Update Stack state to indicate media is sleep mode |
3840 // Update Stack state to indicate media is sleep mode |
3454 iStackState |= KMMCStackStateSleep; |
3841 iStackState |= KMMCStackStateSleep; |
3455 } |
3842 } |
3456 else |
3843 else |
3457 { |
3844 { |
3458 __KTRACE_OPT(KPBUS1, Kern::Printf(">Card[%d]: UNKNOWN",iAutoUnlockIndex)); |
3845 __KTRACE_OPT(KPBUS1, Kern::Printf(">Card[%d]: UNKNOWN",iAutoUnlockIndex)); |
|
3846 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECSLEEPCOMMANDSM7, "Card[%d]: UNKNOWN", iAutoUnlockIndex ); |
|
3847 |
3459 return (KMMCErrStatus); |
3848 return (KMMCErrStatus); |
3460 } |
3849 } |
3461 |
3850 |
3462 SMF_GOTOS(EStIndexNxtCard) |
3851 SMF_GOTOS(EStIndexNxtCard) |
3463 |
3852 |
3464 SMF_STATE(EStUpdateStackState) |
3853 SMF_STATE(EStUpdateStackState) |
3465 |
3854 |
|
3855 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECSLEEPCOMMANDSM8, "EStUpdateStackState" ); |
3466 if (iStackState & KMMCStackStateSleep) |
3856 if (iStackState & KMMCStackStateSleep) |
3467 { |
3857 { |
3468 // Media has been transitioned to sleep state |
3858 // Media has been transitioned to sleep state |
3469 iStackState &= ~KMMCStackStateSleep; |
3859 iStackState &= ~KMMCStackStateSleep; |
3470 |
3860 |
3494 EStDone, |
3885 EStDone, |
3495 EStEnd |
3886 EStEnd |
3496 }; |
3887 }; |
3497 |
3888 |
3498 DMMCSession& s=Session(); |
3889 DMMCSession& s=Session(); |
|
3890 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECAWAKECOMMANDSM1, "Current session=0x%x", &s ); |
3499 |
3891 |
3500 SMF_BEGIN |
3892 SMF_BEGIN |
3501 |
3893 |
|
3894 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECAWAKECOMMANDSM2, "EStBegin" ); |
3502 __KTRACE_OPT(KPBUS1, Kern::Printf(">ExecAwakeCommandSM()")); |
3895 __KTRACE_OPT(KPBUS1, Kern::Printf(">ExecAwakeCommandSM()")); |
3503 |
3896 |
3504 // Call PSL to ensure VccQ is powered up before continuing |
3897 // Call PSL to ensure VccQ is powered up before continuing |
3505 SMF_INVOKES( DoWakeUpSMST, EStPoweredUp ) |
3898 SMF_INVOKES( DoWakeUpSMST, EStPoweredUp ) |
3506 |
3899 |
3507 SMF_STATE(EStPoweredUp) |
3900 SMF_STATE(EStPoweredUp) |
3508 |
3901 |
|
3902 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECAWAKECOMMANDSM3, "EStPoweredUp" ); |
3509 __KTRACE_OPT(KPBUS1, Kern::Printf("VccQ Powered Up")); |
3903 __KTRACE_OPT(KPBUS1, Kern::Printf("VccQ Powered Up")); |
3510 |
3904 |
3511 //Issue CMD5 to awaken media |
3905 //Issue CMD5 to awaken media |
3512 s.PushCommandStack(); |
3906 s.PushCommandStack(); |
3513 s.FillCommandDesc(ECmdSleepAwake); |
3907 s.FillCommandDesc(ECmdSleepAwake); |
3515 |
3909 |
3516 SMF_INVOKES(IssueCommandCheckResponseSMST, EStAwakeIssued) |
3910 SMF_INVOKES(IssueCommandCheckResponseSMST, EStAwakeIssued) |
3517 |
3911 |
3518 SMF_STATE(EStAwakeIssued) |
3912 SMF_STATE(EStAwakeIssued) |
3519 |
3913 |
|
3914 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECAWAKECOMMANDSM4, "EStAwakeIssued" ); |
3520 __KTRACE_OPT(KPBUS1, Kern::Printf(">>EStAwakeIssued!")); |
3915 __KTRACE_OPT(KPBUS1, Kern::Printf(">>EStAwakeIssued!")); |
3521 |
3916 |
3522 TMMCStatus status(s.ResponseP()); |
3917 TMMCStatus status(s.ResponseP()); |
3523 |
3918 |
3524 if(status.State() == ECardStateStby || status.State() == ECardStateSlp) |
3919 if(status.State() == ECardStateStby || status.State() == ECardStateSlp) |
3525 { |
3920 { |
3526 // R1b is issued before Standby state is achieved and |
3921 // R1b is issued before Standby state is achieved and |
3527 // will therefore return the previous state which was Sleep |
3922 // will therefore return the previous state which was Sleep |
3528 __KTRACE_OPT(KPBUS1, Kern::Printf(">Card[%d]: STANDBY",iAutoUnlockIndex)); |
3923 __KTRACE_OPT(KPBUS1, Kern::Printf(">Card[%d]: STANDBY",iAutoUnlockIndex)); |
3529 |
3924 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECAWAKECOMMANDSM5, "Card[%d]: STANDBY", iAutoUnlockIndex ); |
3530 s.CardP()->iStatus.UpdateState(ECardStateStby); |
3925 s.CardP()->iStatus.UpdateState(ECardStateStby); |
3531 } |
3926 } |
3532 else |
3927 else |
3533 { |
3928 { |
3534 __KTRACE_OPT(KPBUS1, Kern::Printf(">Card[%d]: UNKNOWN",iAutoUnlockIndex)); |
3929 __KTRACE_OPT(KPBUS1, Kern::Printf(">Card[%d]: UNKNOWN",iAutoUnlockIndex)); |
3535 return (KMMCErrStatus); |
3930 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECAWAKECOMMANDSM6, "Card[%d]: UNKNOWN", iAutoUnlockIndex ); |
|
3931 OstTraceFunctionExitExt( DMMCSTACK_EXECAWAKECOMMANDSM_EXIT, this, (TInt) KMMCErrStatus ); |
|
3932 return KMMCErrStatus; |
3536 } |
3933 } |
3537 |
3934 |
3538 s.PopCommandStack(); |
3935 s.PopCommandStack(); |
3539 |
3936 |
3540 SMF_STATE(EStDone) |
3937 SMF_STATE(EStDone) |
3541 |
3938 |
|
3939 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECAWAKECOMMANDSM7, "EStDone" ); |
3542 __KTRACE_OPT(KPBUS1, Kern::Printf("<ExecAwakeCommandSM()")); |
3940 __KTRACE_OPT(KPBUS1, Kern::Printf("<ExecAwakeCommandSM()")); |
3543 |
3941 |
3544 SMF_END |
3942 SMF_END |
3545 } |
3943 } |
3546 |
3944 |
3612 aBusWidthAndClock = TBusWidthAndClock(targetWidthAndClock); |
4014 aBusWidthAndClock = TBusWidthAndClock(targetWidthAndClock); |
3613 break; |
4015 break; |
3614 } |
4016 } |
3615 |
4017 |
3616 __KTRACE_OPT(KPBUS1, Kern::Printf("aPowerClass %u, targetWidthAndClock = %08X", aPowerClass, aBusWidthAndClock)); |
4018 __KTRACE_OPT(KPBUS1, Kern::Printf("aPowerClass %u, targetWidthAndClock = %08X", aPowerClass, aBusWidthAndClock)); |
|
4019 OstTraceExt2( TRACE_INTERNALS, DMMCSTACK_DETERMINEBUSWIDTHANDCLOCK, "aPowerClass=%u; targetWidthAndClock=0x%08x", aPowerClass, (TUint) aBusWidthAndClock ); |
|
4020 OstTraceFunctionExit1( DMMCSTACK_DETERMINEBUSWIDTHANDCLOCK_EXIT2, this ); |
3617 } |
4021 } |
3618 |
4022 |
3619 TUint DMMCStack::GetPowerClass(const TMMCard& aCard, TBusWidthAndClock aWidthAndClock, TBool aLowVoltage) |
4023 TUint DMMCStack::GetPowerClass(const TMMCard& aCard, TBusWidthAndClock aWidthAndClock, TBool aLowVoltage) |
3620 { |
4024 { |
|
4025 OstTraceExt3(TRACE_FLOW, DMMCSTACK_GETPOWERCLASS_ENTRY, "DMMCStack::GetPowerClass;aWidthAndClock=%d;aLowVoltage=%d;this=%x", (TInt) aWidthAndClock, (TInt) aLowVoltage, (TUint) this); |
3621 // The power class for 4 bit bus configurations is in the low nibble, |
4026 // The power class for 4 bit bus configurations is in the low nibble, |
3622 // The power class for 8 bit bus configurations is in the high nibble, |
4027 // The power class for 8 bit bus configurations is in the high nibble, |
3623 #define LO_NIBBLE(val) (val & 0x0F) |
4028 #define LO_NIBBLE(val) (val & 0x0F) |
3624 #define HI_NIBBLE(val) ((val >> 4) & 0x0F) |
4029 #define HI_NIBBLE(val) ((val >> 4) & 0x0F) |
3625 |
4030 |
3687 EStExit, |
4093 EStExit, |
3688 EStEnd |
4094 EStEnd |
3689 }; |
4095 }; |
3690 |
4096 |
3691 DMMCSession& s = Session(); |
4097 DMMCSession& s = Session(); |
|
4098 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM1, "Current session=0x%x", &s ); |
3692 |
4099 |
3693 SMF_BEGIN |
4100 SMF_BEGIN |
3694 // |
4101 // |
3695 // Start the BUSTEST sequence at the maximum supported by the PSL |
4102 // Start the BUSTEST sequence at the maximum supported by the PSL |
3696 // - iSpare[0] keeps track of the current bus width |
4103 // - iSpare[0] keeps track of the current bus width |
3697 // |
4104 // |
|
4105 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM2, "EStBegin" ); |
3698 if (iBusWidthAndClock & E8BitMask) |
4106 if (iBusWidthAndClock & E8BitMask) |
3699 { |
4107 { |
3700 iSpare[0] = EBusWidth8; |
4108 iSpare[0] = EBusWidth8; |
3701 __KTRACE_OPT(KPBUS1, Kern::Printf("...Hardware supports 8-bit bus")); |
4109 __KTRACE_OPT(KPBUS1, Kern::Printf("...Hardware supports 8-bit bus")); |
|
4110 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM3, "Hardware supports 8-bit bus" ); |
3702 } |
4111 } |
3703 else if(iBusWidthAndClock & E4BitMask) |
4112 else if(iBusWidthAndClock & E4BitMask) |
3704 { |
4113 { |
3705 iSpare[0] = EBusWidth4; |
4114 iSpare[0] = EBusWidth4; |
3706 __KTRACE_OPT(KPBUS1, Kern::Printf("...Hardware supports 4-bit bus")); |
4115 __KTRACE_OPT(KPBUS1, Kern::Printf("...Hardware supports 4-bit bus")); |
|
4116 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM4, "Hardware supports 4-bit bus" ); |
3707 } |
4117 } |
3708 else |
4118 else |
3709 { |
4119 { |
3710 __KTRACE_OPT(KPBUS1, Kern::Printf("...Hardware supports 1-bit bus")); |
4120 __KTRACE_OPT(KPBUS1, Kern::Printf("...Hardware supports 1-bit bus")); |
|
4121 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM5, "Hardware supports 1-bit bus" ); |
3711 iSpare[0] = EBusWidth1; |
4122 iSpare[0] = EBusWidth1; |
3712 } |
4123 } |
3713 |
4124 |
3714 // remove KMMCModeCardControlled so that IssueCommandCheckResponseSMST doesn't try to |
4125 // remove KMMCModeCardControlled so that IssueCommandCheckResponseSMST doesn't try to |
3715 // override the bus width & clock rate using the card settings |
4126 // override the bus width & clock rate using the card settings |
3717 |
4128 |
3718 SMF_STATE(EstSendBusTest_W) |
4129 SMF_STATE(EstSendBusTest_W) |
3719 // |
4130 // |
3720 // Issue the BUSTEST_W command |
4131 // Issue the BUSTEST_W command |
3721 // |
4132 // |
|
4133 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM6, "EStSendBusTest_W" ); |
3722 TInt length = 2; |
4134 TInt length = 2; |
3723 switch(iSpare[0]) |
4135 switch(iSpare[0]) |
3724 { |
4136 { |
3725 case EBusWidth8: |
4137 case EBusWidth8: |
3726 // Set the host to 8-bit mode |
4138 // Set the host to 8-bit mode |
3727 __KTRACE_OPT(KPBUS1, Kern::Printf("BUSTEST : EBusWidth8")); |
4139 __KTRACE_OPT(KPBUS1, Kern::Printf("BUSTEST : EBusWidth8")); |
|
4140 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM7, "BUSTEST : EBusWidth8" ); |
3728 DoSetBusWidth(EBusWidth8); |
4141 DoSetBusWidth(EBusWidth8); |
3729 iPSLBuf[0] = 0x55; |
4142 iPSLBuf[0] = 0x55; |
3730 iPSLBuf[1] = 0xaa; |
4143 iPSLBuf[1] = 0xaa; |
3731 break; |
4144 break; |
3732 |
4145 |
3733 case EBusWidth4: |
4146 case EBusWidth4: |
3734 // Set the host to 4-bit mode |
4147 // Set the host to 4-bit mode |
3735 __KTRACE_OPT(KPBUS1, Kern::Printf("BUSTEST : EBusWidth4")); |
4148 __KTRACE_OPT(KPBUS1, Kern::Printf("BUSTEST : EBusWidth4")); |
|
4149 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM8, "BUSTEST : EBusWidth4" ); |
3736 DoSetBusWidth(EBusWidth4); |
4150 DoSetBusWidth(EBusWidth4); |
3737 iPSLBuf[0] = 0x5a; |
4151 iPSLBuf[0] = 0x5a; |
3738 iPSLBuf[1] = 0x00; |
4152 iPSLBuf[1] = 0x00; |
3739 break; |
4153 break; |
3740 |
4154 |
3741 case EBusWidth1: |
4155 case EBusWidth1: |
3742 default: |
4156 default: |
3743 // Set the host to 1-bit mode |
4157 // Set the host to 1-bit mode |
3744 __KTRACE_OPT(KPBUS1, Kern::Printf("BUSTEST : EBusWidth1")); |
4158 __KTRACE_OPT(KPBUS1, Kern::Printf("BUSTEST : EBusWidth1")); |
|
4159 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM9, "BUSTEST : EBusWidth1" ); |
3745 DoSetBusWidth(EBusWidth1); |
4160 DoSetBusWidth(EBusWidth1); |
3746 iPSLBuf[0] = 0x40; |
4161 iPSLBuf[0] = 0x40; |
3747 iPSLBuf[1] = 0x00; |
4162 iPSLBuf[1] = 0x00; |
3748 break; |
4163 break; |
3749 } |
4164 } |
3750 |
4165 |
3751 // Issue BUSTEST_W |
4166 // Issue BUSTEST_W |
3752 |
4167 |
3753 __KTRACE_OPT(KPBUS1, Kern::Printf("...Issue BUSTEST_W [%02x:%02x]", iPSLBuf[1], iPSLBuf[0])); |
4168 __KTRACE_OPT(KPBUS1, Kern::Printf("...Issue BUSTEST_W [%02x:%02x]", iPSLBuf[1], iPSLBuf[0])); |
|
4169 OstTraceExt2( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM10, "Issue BUSTEST_W [%02x:%02x]", (TUint) iPSLBuf[1], (TUint) iPSLBuf[0] ); |
3754 |
4170 |
3755 m.SetTraps(KMMCErrDataCRC); // CRC check is optional for BUSTEST |
4171 m.SetTraps(KMMCErrDataCRC); // CRC check is optional for BUSTEST |
3756 |
4172 |
3757 s.FillCommandDesc(ECmdBustest_W); |
4173 s.FillCommandDesc(ECmdBustest_W); |
3758 s.FillCommandArgs(0, length, &iPSLBuf[0], length); |
4174 s.FillCommandArgs(0, length, &iPSLBuf[0], length); |
3760 |
4176 |
3761 SMF_STATE(EstSendBusTest_R) |
4177 SMF_STATE(EstSendBusTest_R) |
3762 // |
4178 // |
3763 // Issue the BUSTEST_R command |
4179 // Issue the BUSTEST_R command |
3764 // |
4180 // |
|
4181 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM11, "EStSendBusTest_R" ); |
3765 __KTRACE_OPT(KPBUS1, Kern::Printf("...got BUSTEST_W response : %02x", err)); |
4182 __KTRACE_OPT(KPBUS1, Kern::Printf("...got BUSTEST_W response : %02x", err)); |
|
4183 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM12, "Got BUSTEST_W response=0x%02x", err ); |
3766 |
4184 |
3767 if(err == KMMCErrNone || err == KMMCErrDataCRC) |
4185 if(err == KMMCErrNone || err == KMMCErrDataCRC) |
3768 { |
4186 { |
3769 __KTRACE_OPT(KPBUS1, Kern::Printf("...sending BUSTEST_R")); |
4187 __KTRACE_OPT(KPBUS1, Kern::Printf("...sending BUSTEST_R")); |
|
4188 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM13, "Sending BUSTEST_R" ); |
3770 |
4189 |
3771 iPSLBuf[0] = 0; |
4190 iPSLBuf[0] = 0; |
3772 iPSLBuf[1] = 0; |
4191 iPSLBuf[1] = 0; |
3773 |
4192 |
3774 s.FillCommandDesc(ECmdBustest_R); |
4193 s.FillCommandDesc(ECmdBustest_R); |
3775 s.FillCommandArgs(0, 2, &iPSLBuf[0], 2); |
4194 s.FillCommandArgs(0, 2, &iPSLBuf[0], 2); |
3776 SMF_INVOKES(IssueCommandCheckResponseSMST, EstGotBusTest_R) |
4195 SMF_INVOKES(IssueCommandCheckResponseSMST, EstGotBusTest_R) |
3777 } |
4196 } |
3778 else |
4197 else |
3779 { |
4198 { |
|
4199 OstTraceFunctionExitExt( DMMCSTACK_EXECBUSTESTSM_EXIT, this, (TInt) KMMCErrNotSupported ); |
3780 SMF_RETURN(KMMCErrNotSupported); |
4200 SMF_RETURN(KMMCErrNotSupported); |
3781 } |
4201 } |
3782 |
4202 |
3783 SMF_STATE(EstGotBusTest_R) |
4203 SMF_STATE(EstGotBusTest_R) |
3784 // |
4204 // |
3785 // Validate the BUSTEST_R data with that issued by BUSTEST_W |
4205 // Validate the BUSTEST_R data with that issued by BUSTEST_W |
3786 // |
4206 // |
|
4207 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM14, "EStGotBusTest_R" ); |
3787 __KTRACE_OPT(KPBUS1, Kern::Printf("...got BUSTEST_R response [%02x:%02x] : err(%02x)", iPSLBuf[1], iPSLBuf[0], err)); |
4208 __KTRACE_OPT(KPBUS1, Kern::Printf("...got BUSTEST_R response [%02x:%02x] : err(%02x)", iPSLBuf[1], iPSLBuf[0], err)); |
|
4209 OstTraceExt3( TRACE_INTERNALS, DMMCSTACK_EXECBUSTESTSM15, "Got BUSTEST_R response [%02x:%02x]; err(%x)", (TUint) iPSLBuf[1], (TUint) iPSLBuf[0], (TUint) err ); |
3788 |
4210 |
3789 TBool retry = EFalse; |
4211 TBool retry = EFalse; |
3790 TBool is52MHzSupported = (iBusWidthAndClock & E52MhzMask) ? (TBool)ETrue : (TBool)EFalse; |
4212 TBool is52MHzSupported = (iBusWidthAndClock & E52MhzMask) ? (TBool)ETrue : (TBool)EFalse; |
3791 |
4213 |
3792 switch(iSpare[0]) |
4214 switch(iSpare[0]) |
3909 EStIdleEndCheck, |
4336 EStIdleEndCheck, |
3910 EStEnd |
4337 EStEnd |
3911 }; |
4338 }; |
3912 |
4339 |
3913 DMMCSession& s=Session(); |
4340 DMMCSession& s=Session(); |
|
4341 OstTrace1( TRACE_INTERNALS, DMMCSTACK_GOIDLESM1, "Current session=0x%x", &s ); |
3914 |
4342 |
3915 SMF_BEGIN |
4343 SMF_BEGIN |
3916 |
4344 |
|
4345 OstTrace0( TRACE_INTERNALS, DMMCSTACK_GOIDLESM2, "EStBegin" ); |
3917 s.FillCommandDesc( ECmdGoIdleState, 0 ); |
4346 s.FillCommandDesc( ECmdGoIdleState, 0 ); |
3918 iCxPollRetryCount = KMMCIdleCommandsAtRestart; |
4347 iCxPollRetryCount = KMMCIdleCommandsAtRestart; |
3919 |
4348 |
3920 SMF_STATE(EStIdleLoop) |
4349 SMF_STATE(EStIdleLoop) |
|
4350 OstTrace0( TRACE_INTERNALS, DMMCSTACK_GOIDLESM3, "EStIdleLoop" ); |
3921 SMF_INVOKES( ExecCommandSMST, EStIdleEndCheck ) |
4351 SMF_INVOKES( ExecCommandSMST, EStIdleEndCheck ) |
3922 |
4352 |
3923 SMF_STATE(EStIdleEndCheck) |
4353 SMF_STATE(EStIdleEndCheck) |
3924 |
4354 |
|
4355 OstTrace0( TRACE_INTERNALS, DMMCSTACK_GOIDLESM4, "EStIdleEndCheck" ); |
3925 if( --iCxPollRetryCount > 0 ) |
4356 if( --iCxPollRetryCount > 0 ) |
3926 SMF_INVOKES( RetryGapTimerSMST, EStIdleLoop ) |
4357 SMF_INVOKES( RetryGapTimerSMST, EStIdleLoop ) |
3927 |
4358 |
3928 iStackState &= ~(KMMCStackStateDoDeselect|KMMCStackStateBusInconsistent); |
4359 iStackState &= ~(KMMCStackStateDoDeselect|KMMCStackStateBusInconsistent); |
3929 iSelectedCard = 0; |
4360 iSelectedCard = 0; |
3963 EStEnd |
4394 EStEnd |
3964 }; |
4395 }; |
3965 |
4396 |
3966 DMMCSession& s=Session(); |
4397 DMMCSession& s=Session(); |
3967 DMMCPsu* psu=(DMMCPsu*)iSocket->iVcc; |
4398 DMMCPsu* psu=(DMMCPsu*)iSocket->iVcc; |
|
4399 OstTrace1( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM1, "Current session=0x%x", &s ); |
3968 |
4400 |
3969 SMF_BEGIN |
4401 SMF_BEGIN |
3970 |
4402 |
|
4403 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM2, "EStBegin" ); |
3971 iRCAPool.ReleaseUnlocked(); |
4404 iRCAPool.ReleaseUnlocked(); |
3972 iCxPollRetryCount = 0; // Reset max number of poll attempts on card busy |
4405 iCxPollRetryCount = 0; // Reset max number of poll attempts on card busy |
3973 |
4406 |
3974 SMF_INVOKES( GoIdleSMST, EStIdle ) |
4407 SMF_INVOKES( GoIdleSMST, EStIdle ) |
3975 |
4408 |
3976 SMF_STATE(EStIdle) |
4409 SMF_STATE(EStIdle) |
3977 |
4410 |
|
4411 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM3, "EStIdle" ); |
3978 // If this platform doesn't support an adjustable voltage PSU then there is |
4412 // If this platform doesn't support an adjustable voltage PSU then there is |
3979 // no point in interogating the card(s) present for their supported range |
4413 // no point in interogating the card(s) present for their supported range |
3980 if ( !(psu->VoltageSupported()&KMMCAdjustableOpVoltage) ) |
4414 if ( !(psu->VoltageSupported()&KMMCAdjustableOpVoltage) ) |
3981 { |
4415 { |
3982 // if the PSU isn't adjustable then it can't support low voltage mode |
4416 // if the PSU isn't adjustable then it can't support low voltage mode |
4024 SMF_INVOKES( SwitchToLowVoltageSMST, EStSetRangeLoop ) |
4462 SMF_INVOKES( SwitchToLowVoltageSMST, EStSetRangeLoop ) |
4025 } |
4463 } |
4026 |
4464 |
4027 SMF_STATE(EStSetRangeLoop) |
4465 SMF_STATE(EStSetRangeLoop) |
4028 |
4466 |
|
4467 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM5, "EStSetRangeLoop" ); |
4029 // Repeat CMD1 this time setting Current Op Range |
4468 // Repeat CMD1 this time setting Current Op Range |
4030 s.Command().iArgument = iCurrentOpRange | KMMCOCRAccessModeHCS | KMMCOCRBusy; |
4469 s.Command().iArgument = iCurrentOpRange | KMMCOCRAccessModeHCS | KMMCOCRBusy; |
4031 |
4470 |
4032 m.SetTraps( KMMCErrResponseTimeOut ); |
4471 m.SetTraps( KMMCErrResponseTimeOut ); |
4033 |
4472 |
4034 SMF_INVOKES( ExecCommandSMST, EStSetRangeBusyCheck ) |
4473 SMF_INVOKES( ExecCommandSMST, EStSetRangeBusyCheck ) |
4035 |
4474 |
4036 SMF_STATE(EStSetRangeBusyCheck) |
4475 SMF_STATE(EStSetRangeBusyCheck) |
4037 |
4476 |
|
4477 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM6, "EStSetRangeLoop" ); |
4038 if( !err ) |
4478 if( !err ) |
4039 { |
4479 { |
4040 // Bit31 of the OCR response is low if the cards are still powering up. |
4480 // Bit31 of the OCR response is low if the cards are still powering up. |
4041 const TUint32 ocrResponse = TMMC::BigEndian32(s.ResponseP()); |
4481 const TUint32 ocrResponse = TMMC::BigEndian32(s.ResponseP()); |
4042 |
4482 |
4043 const TBool isBusy = ((ocrResponse & KMMCOCRBusy) == 0); |
4483 const TBool isBusy = ((ocrResponse & KMMCOCRBusy) == 0); |
4044 __KTRACE_OPT(KPBUS1,Kern::Printf("-mmc:upd:bsy%d", isBusy)); |
4484 __KTRACE_OPT(KPBUS1,Kern::Printf("-mmc:upd:bsy%d", isBusy)); |
|
4485 OstTrace1( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM7, "MMC busy status=%d", isBusy ); |
4045 |
4486 |
4046 if (isBusy) |
4487 if (isBusy) |
4047 { |
4488 { |
4048 // Some cards are still busy powering up. Check if we should timeout |
4489 // Some cards are still busy powering up. Check if we should timeout |
4049 if ( ++iCxPollRetryCount > iConfig.OpCondBusyTimeout() ) |
4490 if ( ++iCxPollRetryCount > iConfig.OpCondBusyTimeout() ) |
4050 return( KMMCErrBusTimeOut ); |
4491 { |
|
4492 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM8, "Peripheral bus timeout" ); |
|
4493 OstTraceFunctionExitExt( DMMCSTACK_ACQUIRESTACKSM_EXIT2, this, (TInt) KMMCErrBusTimeOut ); |
|
4494 return KMMCErrBusTimeOut; |
|
4495 } |
4051 m.ResetTraps(); |
4496 m.ResetTraps(); |
4052 SMF_INVOKES( RetryGapTimerSMST, EStSetRangeLoop ) |
4497 SMF_INVOKES( RetryGapTimerSMST, EStSetRangeLoop ) |
4053 } |
4498 } |
4054 |
4499 |
4055 iSpare[0] = 0; |
4500 iSpare[0] = 0; |
4056 |
4501 |
4057 if((ocrResponse & KMMCOCRAccessModeMask) == KMMCOCRAccessModeHCS) |
4502 if((ocrResponse & KMMCOCRAccessModeMask) == KMMCOCRAccessModeHCS) |
4058 { |
4503 { |
4059 __KTRACE_OPT(KPBUS1, Kern::Printf("Found large MMC card.")); |
4504 __KTRACE_OPT(KPBUS1, Kern::Printf("Found large MMC card.")); |
|
4505 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM9, "Found large MMC card" ); |
4060 iSpare[0] = KMMCardIsHighCapacity; |
4506 iSpare[0] = KMMCardIsHighCapacity; |
4061 } |
4507 } |
4062 } |
4508 } |
4063 |
4509 |
4064 iConfig.SetMode( EffectiveModes(s.iConfig) & KMMCModeEnableTimeOutRetry ); // Restore original setting |
4510 iConfig.SetMode( EffectiveModes(s.iConfig) & KMMCModeEnableTimeOutRetry ); // Restore original setting |
4065 |
4511 |
4066 // All cards are now ready and notified of the voltage range - ask ASSP to set it up |
4512 // All cards are now ready and notified of the voltage range - ask ASSP to set it up |
4067 psu->SetVoltage(iCurrentOpRange); |
4513 psu->SetVoltage(iCurrentOpRange); |
4068 if (psu->SetState(EPsuOnFull) != KErrNone) |
4514 if (psu->SetState(EPsuOnFull) != KErrNone) |
4069 return(KMMCErrHardware); |
4515 { |
|
4516 OstTraceFunctionExitExt( DMMCSTACK_ACQUIRESTACKSM_EXIT3, this, (TInt) KMMCErrHardware ); |
|
4517 return KMMCErrHardware; |
|
4518 } |
4070 |
4519 |
4071 iCardArray->InitNewCardScan(); // Collect new cards, one by one |
4520 iCardArray->InitNewCardScan(); // Collect new cards, one by one |
4072 |
4521 |
4073 SMF_STATE(EStCIDLoop) |
4522 SMF_STATE(EStCIDLoop) |
4074 |
4523 |
|
4524 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM10, "EStCIDLoop" ); |
4075 if ( iCardArray->NewCardCount() >= iMaxCardsInStack ) |
4525 if ( iCardArray->NewCardCount() >= iMaxCardsInStack ) |
4076 SMF_GOTOS( EStCIDsDone ) |
4526 SMF_GOTOS( EStCIDsDone ) |
4077 |
4527 |
4078 s.FillCommandDesc( ECmdAllSendCID, 0 ); |
4528 s.FillCommandDesc( ECmdAllSendCID, 0 ); |
4079 m.SetTraps( KMMCErrResponseTimeOut ); |
4529 m.SetTraps( KMMCErrResponseTimeOut ); |
4080 |
4530 |
4081 SMF_INVOKES( ExecCommandSMST, EStSendCIDIssued ) |
4531 SMF_INVOKES( ExecCommandSMST, EStSendCIDIssued ) |
4082 |
4532 |
4083 SMF_STATE(EStSendCIDIssued) |
4533 SMF_STATE(EStSendCIDIssued) |
4084 |
4534 |
|
4535 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM11, "EStSendCIDIssued" ); |
4085 if( !err ) |
4536 if( !err ) |
4086 { |
4537 { |
4087 // A card responded with a CID. Create a new card entry in the card array |
4538 // A card responded with a CID. Create a new card entry in the card array |
4088 // and initialise this entry with the CID. The card array allocates it an |
4539 // and initialise this entry with the CID. The card array allocates it an |
4089 // RCA, either the old RCA if we have seen this card before, or a new one. |
4540 // RCA, either the old RCA if we have seen this card before, or a new one. |
4107 iCxCardCount=0; // New cards index |
4559 iCxCardCount=0; // New cards index |
4108 s.FillCommandDesc( ECmdSendCSD ); |
4560 s.FillCommandDesc( ECmdSendCSD ); |
4109 |
4561 |
4110 SMF_STATE(EStCSDLoop) |
4562 SMF_STATE(EStCSDLoop) |
4111 |
4563 |
|
4564 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM13, "EStCSDLoop" ); |
4112 s.Command().iArgument = TMMCArgument(iCardArray->NewCardP(iCxCardCount)->iRCA); |
4565 s.Command().iArgument = TMMCArgument(iCardArray->NewCardP(iCxCardCount)->iRCA); |
4113 SMF_INVOKES( ExecCommandSMST, EStSendCSDDone ) |
4566 SMF_INVOKES( ExecCommandSMST, EStSendCSDDone ) |
4114 |
4567 |
4115 SMF_STATE(EStSendCSDDone) |
4568 SMF_STATE(EStSendCSDDone) |
4116 |
4569 |
|
4570 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ACQUIRESTACKSM14, "EStSendCSDDone" ); |
4117 // Store the CSD in the new card entry |
4571 // Store the CSD in the new card entry |
4118 TMMCard* cardP = iCardArray->NewCardP(iCxCardCount); |
4572 TMMCard* cardP = iCardArray->NewCardP(iCxCardCount); |
4119 cardP->iCSD = s.ResponseP(); |
4573 cardP->iCSD = s.ResponseP(); |
4120 |
4574 |
4121 // Perform MMC Specific parsing of the CSD structure |
4575 // Perform MMC Specific parsing of the CSD structure |
4174 }; |
4633 }; |
4175 |
4634 |
4176 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:SwLowVolt")); |
4635 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:SwLowVolt")); |
4177 |
4636 |
4178 DMMCPsu* psu=(DMMCPsu*)iSocket->iVcc; |
4637 DMMCPsu* psu=(DMMCPsu*)iSocket->iVcc; |
|
4638 OstTrace1( TRACE_INTERNALS, DMMCSTACK_SWITCHTOLOWVOLTAGESM1, "Current PSU=0x%x", psu ); |
4179 |
4639 |
4180 SMF_BEGIN |
4640 SMF_BEGIN |
|
4641 OstTrace0( TRACE_INTERNALS, DMMCSTACK_SWITCHTOLOWVOLTAGESM2, "EStBegin" ); |
4181 // turn power off |
4642 // turn power off |
4182 DoPowerDown(); |
4643 DoPowerDown(); |
4183 psu->SetState(EPsuOff); |
4644 psu->SetState(EPsuOff); |
4184 |
4645 |
4185 // turn power back on in low voltage mode |
4646 // turn power back on in low voltage mode |
4186 psu->SetVoltage(iCurrentOpRange); |
4647 psu->SetVoltage(iCurrentOpRange); |
4187 if (psu->SetState(EPsuOnFull) != KErrNone) |
4648 if (psu->SetState(EPsuOnFull) != KErrNone) |
4188 return(KMMCErrHardware); |
4649 { |
|
4650 OstTraceFunctionExitExt( DMMCSTACK_SWITCHTOLOWVOLTAGESM_EXIT, this, (TInt) KMMCErrHardware ); |
|
4651 return KMMCErrHardware; |
|
4652 } |
4189 |
4653 |
4190 SMF_INVOKES( DoPowerUpSMST, EStPoweredUp ) |
4654 SMF_INVOKES( DoPowerUpSMST, EStPoweredUp ) |
4191 |
4655 |
4192 SMF_STATE(EStPoweredUp) |
4656 SMF_STATE(EStPoweredUp) |
|
4657 OstTrace0( TRACE_INTERNALS, DMMCSTACK_SWITCHTOLOWVOLTAGESM3, "EStPoweredUp" ); |
4193 // turn the clock back on |
4658 // turn the clock back on |
4194 SMF_INVOKES( InitClockOnSMST, EStClockOn ) // Feed init clock to the bus |
4659 SMF_INVOKES( InitClockOnSMST, EStClockOn ) // Feed init clock to the bus |
4195 |
4660 |
4196 SMF_STATE(EStClockOn) |
4661 SMF_STATE(EStClockOn) |
|
4662 OstTrace0( TRACE_INTERNALS, DMMCSTACK_SWITCHTOLOWVOLTAGESM4, "EStClockOn" ); |
4197 // wait for 1ms and then 74 clock cycles |
4663 // wait for 1ms and then 74 clock cycles |
4198 // 74 clock cylces @ 400 Khz = 74 / 400,000 = 0.000185 secs = 0.185 ms |
4664 // 74 clock cylces @ 400 Khz = 74 / 400,000 = 0.000185 secs = 0.185 ms |
4199 // so total wait = 1.185 ms |
4665 // so total wait = 1.185 ms |
4200 SMF_INVOKES(LowVoltagePowerupTimerSMST, EStEnd); |
4666 SMF_INVOKES(LowVoltagePowerupTimerSMST, EStEnd); |
4201 |
4667 |
4614 EStErrRecover, |
5102 EStErrRecover, |
4615 EStEnd |
5103 EStEnd |
4616 }; |
5104 }; |
4617 |
5105 |
4618 DMMCSession& s=Session(); |
5106 DMMCSession& s=Session(); |
|
5107 OstTrace1( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM1, "Current session=0x%x", &s ); |
4619 |
5108 |
4620 SMF_BEGIN |
5109 SMF_BEGIN |
4621 |
5110 |
|
5111 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM2, "EStBegin" ); |
4622 if ( ( s.CardRCA() != 0 ) && ( (s.CardP()->iStatus.State()) == ECardStateSlp) ) |
5112 if ( ( s.CardRCA() != 0 ) && ( (s.CardP()->iStatus.State()) == ECardStateSlp) ) |
4623 { |
5113 { |
4624 // Currently selected media is asleep, so it must be awoken |
5114 // Currently selected media is asleep, so it must be awoken |
4625 SMF_INVOKES(ExecAwakeCommandSMST,EStExecCmd) |
5115 SMF_INVOKES(ExecAwakeCommandSMST,EStExecCmd) |
4626 } |
5116 } |
4627 |
5117 |
4628 SMF_STATE(EStExecCmd) |
5118 SMF_STATE(EStExecCmd) |
4629 |
5119 |
|
5120 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM3, "EStExecCmd" ); |
4630 TMMCCommandDesc& cmd = s.Command(); |
5121 TMMCCommandDesc& cmd = s.Command(); |
4631 // clearup some internally used flags |
5122 // clearup some internally used flags |
4632 cmd.iFlags &= ~(KMMCCmdFlagExecTopBusy|KMMCCmdFlagExecSelBusy); |
5123 cmd.iFlags &= ~(KMMCCmdFlagExecTopBusy|KMMCCmdFlagExecSelBusy); |
4633 cmd.iPollAttempts = cmd.iTimeOutRetries = cmd.iCRCRetries = 0; |
5124 cmd.iPollAttempts = cmd.iTimeOutRetries = cmd.iCRCRetries = 0; |
4634 |
5125 |
4635 SMF_STATE(EStRetry) |
5126 SMF_STATE(EStRetry) |
4636 |
5127 |
|
5128 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM4, "EStRetry" ); |
4637 TMMCCommandDesc& cmd = s.Command(); |
5129 TMMCCommandDesc& cmd = s.Command(); |
4638 m.SetTraps( KMMCErrBasic & ~Command().iExecNotHandle); // Processing all trappable errors |
5130 m.SetTraps( KMMCErrBasic & ~Command().iExecNotHandle); // Processing all trappable errors |
4639 |
5131 |
4640 if (iMultiplexedBus) |
5132 if (iMultiplexedBus) |
4641 { |
5133 { |
4666 s.PushCommandStack(); |
5158 s.PushCommandStack(); |
4667 s.FillCommandDesc( ECmdSelectCard, 0 ); // Deselect - RCA=0 |
5159 s.FillCommandDesc( ECmdSelectCard, 0 ); // Deselect - RCA=0 |
4668 iCxDeselectCount=iDeselectsToIssue; |
5160 iCxDeselectCount=iDeselectsToIssue; |
4669 |
5161 |
4670 SMF_STATE(EStDeselectLoop) |
5162 SMF_STATE(EStDeselectLoop) |
4671 |
5163 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM5, "EStDeselectLoop" ); |
4672 SMF_INVOKES(IssueCommandCheckResponseSMST,EStDeselectEndCheck) |
5164 SMF_INVOKES(IssueCommandCheckResponseSMST,EStDeselectEndCheck) |
4673 |
5165 |
4674 SMF_STATE(EStDeselectEndCheck) |
5166 SMF_STATE(EStDeselectEndCheck) |
4675 |
5167 |
|
5168 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM6, "EStDeselectEndCheck" ); |
4676 // If we got an error and this is the last de-select then give up |
5169 // If we got an error and this is the last de-select then give up |
4677 if (err && iCxDeselectCount == 1) |
5170 if (err && iCxDeselectCount == 1) |
4678 { |
5171 { |
4679 s.PopCommandStack(); |
5172 s.PopCommandStack(); |
|
5173 OstTraceFunctionExitExt( DMMCSTACK_EXECCOMMANDSM_EXIT1, this, (TInt) err ); |
4680 SMF_RETURN(err) |
5174 SMF_RETURN(err) |
4681 } |
5175 } |
4682 |
5176 |
4683 if (--iCxDeselectCount > 0) |
5177 if (--iCxDeselectCount > 0) |
4684 SMF_INVOKES(RetryGapTimerSMST,EStDeselectLoop) |
5178 SMF_INVOKES(RetryGapTimerSMST,EStDeselectLoop) |
4686 s.PopCommandStack(); |
5180 s.PopCommandStack(); |
4687 iStackState &= ~KMMCStackStateDoDeselect; |
5181 iStackState &= ~KMMCStackStateDoDeselect; |
4688 |
5182 |
4689 SMF_STATE(EStAnalyseCommand) |
5183 SMF_STATE(EStAnalyseCommand) |
4690 |
5184 |
|
5185 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM7, "EStAnalyseCommand" ); |
4691 TMMCCommandDesc& cmd = s.Command(); |
5186 TMMCCommandDesc& cmd = s.Command(); |
4692 // Check if its un-important whether the card is in transfer state (i.e |
5187 // Check if its un-important whether the card is in transfer state (i.e |
4693 // selected) or not for the command we are about to execute. Such |
5188 // selected) or not for the command we are about to execute. Such |
4694 // commands are CMD0, CMD7 and CMD13. |
5189 // commands are CMD0, CMD7 and CMD13. |
4695 |
5190 |
4696 // This state machine should never send CMD55 |
5191 // This state machine should never send CMD55 |
4697 if (cmd.iCommand == ECmdAppCmd) |
5192 if (cmd.iCommand == ECmdAppCmd) |
|
5193 { |
|
5194 OstTraceFunctionExitExt( DMMCSTACK_EXECCOMMANDSM_EXIT2, this, (TInt) KMMCErrNotSupported ); |
4698 SMF_RETURN (KMMCErrNotSupported) |
5195 SMF_RETURN (KMMCErrNotSupported) |
|
5196 } |
4699 |
5197 |
4700 SMF_NEXTS( EStTestAppCommand ) |
5198 SMF_NEXTS( EStTestAppCommand ) |
4701 if (cmd.iCommand == ECmdGoIdleState || cmd.iCommand == ECmdSelectCard || cmd.iCommand == ECmdSendStatus) |
5199 if (cmd.iCommand == ECmdGoIdleState || cmd.iCommand == ECmdSelectCard || cmd.iCommand == ECmdSendStatus) |
4702 { |
5200 { |
4703 SMF_GOTONEXTS |
5201 SMF_GOTONEXTS |
4787 SMF_GOTOS( EStTestAppCommand ) |
5290 SMF_GOTOS( EStTestAppCommand ) |
4788 } |
5291 } |
4789 |
5292 |
4790 SMF_STATE(EStBlockCountCmdIssued) |
5293 SMF_STATE(EStBlockCountCmdIssued) |
4791 |
5294 |
|
5295 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM9, "EStBlockCountCmdIssued" ); |
4792 const TMMCStatus status(s.ResponseP()); |
5296 const TMMCStatus status(s.ResponseP()); |
4793 s.PopCommandStack(); |
5297 s.PopCommandStack(); |
4794 if (status.Error()) |
5298 if (status.Error()) |
|
5299 { |
|
5300 OstTraceFunctionExitExt( DMMCSTACK_EXECCOMMANDSM_EXIT5, this, (TInt) KMMCErrStatus ); |
4795 SMF_RETURN(KMMCErrStatus) |
5301 SMF_RETURN(KMMCErrStatus) |
|
5302 } |
4796 |
5303 |
4797 if(err & KMMCErrNotSupported) |
5304 if(err & KMMCErrNotSupported) |
4798 { |
5305 { |
4799 // Not supported by the PSL, so use standard Stop Transmission mode |
5306 // Not supported by the PSL, so use standard Stop Transmission mode |
4800 s.Command().iSpec.iUseStopTransmission = ETrue; |
5307 s.Command().iSpec.iUseStopTransmission = ETrue; |
4801 } |
5308 } |
4802 // Fall through... |
5309 // Fall through... |
4803 |
5310 |
4804 SMF_STATE(EStTestAppCommand) |
5311 SMF_STATE(EStTestAppCommand) |
|
5312 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM10, "EStTestAppCommand" ); |
4805 TMMCCommandDesc& cmd = s.Command(); |
5313 TMMCCommandDesc& cmd = s.Command(); |
4806 if (cmd.iSpec.iCommandClass != KMMCCmdClassApplication) |
5314 if (cmd.iSpec.iCommandClass != KMMCCmdClassApplication) |
4807 SMF_GOTOS( EStIssueCommand ) |
5315 SMF_GOTOS( EStIssueCommand ) |
4808 |
5316 |
4809 s.PushCommandStack(); |
5317 s.PushCommandStack(); |
4810 s.FillCommandDesc(ECmdAppCmd, s.CardRCA()); // Send APP_CMD (CMD55) |
5318 s.FillCommandDesc(ECmdAppCmd, s.CardRCA()); // Send APP_CMD (CMD55) |
4811 SMF_INVOKES(IssueCommandCheckResponseSMST,EStIssueAppCommandDone) |
5319 SMF_INVOKES(IssueCommandCheckResponseSMST,EStIssueAppCommandDone) |
4812 |
5320 |
4813 SMF_STATE(EStIssueAppCommandDone) |
5321 SMF_STATE(EStIssueAppCommandDone) |
|
5322 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM11, "EStIssueAppCommandDone" ); |
4814 s.PopCommandStack(); |
5323 s.PopCommandStack(); |
4815 if ( err ) |
5324 if ( err ) |
4816 { |
5325 { |
4817 SMF_NEXTS(EStErrRecover) |
5326 SMF_NEXTS(EStErrRecover) |
4818 return(err); // re-enter the next state with that error |
5327 OstTraceFunctionExitExt( DMMCSTACK_EXECCOMMANDSM_EXIT6, this, (TInt) err ); |
|
5328 return err; // re-enter the next state with that error |
4819 } |
5329 } |
4820 |
5330 |
4821 |
5331 |
4822 SMF_STATE(EStIssueCommand) |
5332 SMF_STATE(EStIssueCommand) |
4823 |
5333 |
|
5334 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM12, "EStIssueCommand" ); |
4824 TMMCCommandDesc& cmd = s.Command(); |
5335 TMMCCommandDesc& cmd = s.Command(); |
4825 // If its an addressed command (rather than a selected command), then |
5336 // If its an addressed command (rather than a selected command), then |
4826 // setup the argument with the RCA. (Commands requiring card to be |
5337 // setup the argument with the RCA. (Commands requiring card to be |
4827 // selected - ACS don't matter since selected cards don't need an RCA now). |
5338 // selected - ACS don't matter since selected cards don't need an RCA now). |
4828 if ((iConfig.iModes & KMMCModeCardControlled) && cmd.iSpec.iCommandType==ECmdTypeAC ) |
5339 if ((iConfig.iModes & KMMCModeCardControlled) && cmd.iSpec.iCommandType==ECmdTypeAC ) |
4829 { |
5340 { |
4830 const TRCA targetRCA = s.CardRCA(); |
5341 const TRCA targetRCA = s.CardRCA(); |
4831 if ( targetRCA == 0 ) |
5342 if ( targetRCA == 0 ) |
|
5343 { |
|
5344 OstTraceFunctionExitExt( DMMCSTACK_EXECCOMMANDSM_EXIT7, this, (TInt) KMMCErrNoCard ); |
4832 SMF_RETURN( KMMCErrNoCard ) |
5345 SMF_RETURN( KMMCErrNoCard ) |
|
5346 } |
4833 cmd.iArgument.SetRCA(targetRCA); |
5347 cmd.iArgument.SetRCA(targetRCA); |
4834 } |
5348 } |
4835 |
5349 |
4836 // Issue the top-level command |
5350 // Issue the top-level command |
4837 SMF_INVOKES(IssueCommandCheckResponseSMST,EStCommandIssued) |
5351 SMF_INVOKES(IssueCommandCheckResponseSMST,EStCommandIssued) |
4838 |
5352 |
4839 SMF_STATE(EStCommandIssued) |
5353 SMF_STATE(EStCommandIssued) |
4840 |
5354 |
|
5355 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM13, "EStCommandIssued" ); |
4841 // If command was succesful then we've finished. |
5356 // If command was succesful then we've finished. |
4842 if (!err) |
5357 if (!err) |
4843 SMF_EXIT |
5358 SMF_EXIT |
4844 |
5359 |
4845 SMF_STATE(EStErrRecover) |
5360 SMF_STATE(EStErrRecover) |
4846 |
5361 |
|
5362 OstTrace0( TRACE_INTERNALS, DMMCSTACK_EXECCOMMANDSM14, "EStErrRecover" ); |
4847 TMMCCommandDesc& cmd = s.Command(); |
5363 TMMCCommandDesc& cmd = s.Command(); |
4848 const TUint32 modes=iConfig.iModes; |
5364 const TUint32 modes=iConfig.iModes; |
4849 SMF_NEXTS(EStRetry) |
5365 SMF_NEXTS(EStRetry) |
4850 |
5366 |
4851 m.ResetTraps(); // no more re-entries via return() |
5367 m.ResetTraps(); // no more re-entries via return() |
4890 cmd.iTimeOutRetries++; |
5413 cmd.iTimeOutRetries++; |
4891 gapEnabled |= KMMCModeTimeOutRetryGap; |
5414 gapEnabled |= KMMCModeTimeOutRetryGap; |
4892 |
5415 |
4893 if( (modes & KMMCModeEnableTimeOutRetry) == 0 || |
5416 if( (modes & KMMCModeEnableTimeOutRetry) == 0 || |
4894 cmd.iTimeOutRetries > iConfig.iTimeOutRetries ) |
5417 cmd.iTimeOutRetries > iConfig.iTimeOutRetries ) |
4895 return( err ); |
5418 { |
|
5419 OstTraceFunctionExitExt( DMMCSTACK_EXECCOMMANDSM_EXIT11, this, (TInt) err ); |
|
5420 return err; |
|
5421 } |
4896 } |
5422 } |
4897 |
5423 |
4898 if( err & crcMask ) |
5424 if( err & crcMask ) |
4899 { |
5425 { |
4900 cmd.iCRCRetries++; |
5426 cmd.iCRCRetries++; |
4901 gapEnabled |= KMMCModeCRCRetryGap; |
5427 gapEnabled |= KMMCModeCRCRetryGap; |
4902 |
5428 |
4903 if( (modes & KMMCModeEnableCRCRetry) == 0 || |
5429 if( (modes & KMMCModeEnableCRCRetry) == 0 || |
4904 cmd.iCRCRetries > iConfig.iCRCRetries || |
5430 cmd.iCRCRetries > iConfig.iCRCRetries || |
4905 ((err & KMMCErrDataCRC) != 0 && (modes & KMMCModeDataCRCRetry) == 0) ) |
5431 ((err & KMMCErrDataCRC) != 0 && (modes & KMMCModeDataCRCRetry) == 0) ) |
4906 return( err ); |
5432 { |
|
5433 OstTraceFunctionExitExt( DMMCSTACK_EXECCOMMANDSM_EXIT12, this, (TInt) err ); |
|
5434 return err; |
|
5435 } |
4907 } |
5436 } |
4908 |
5437 |
4909 if( (modes & gapEnabled) == gapEnabled ) |
5438 if( (modes & gapEnabled) == gapEnabled ) |
4910 { |
5439 { |
4911 if( modes & KMMCModeCardControlled ) |
5440 if( modes & KMMCModeCardControlled ) |
4993 EStEnd |
5529 EStEnd |
4994 }; |
5530 }; |
4995 |
5531 |
4996 DMMCSession& s=Session(); |
5532 DMMCSession& s=Session(); |
4997 TMMCCommandDesc& cmd = Command(); |
5533 TMMCCommandDesc& cmd = Command(); |
|
5534 OstTrace1( TRACE_INTERNALS, DMMCSTACK_ISSUECOMMANDCHECKRESPONSESM1, "Current session=0x%x", &s ); |
4998 |
5535 |
4999 SMF_BEGIN |
5536 SMF_BEGIN |
5000 |
5537 |
|
5538 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ISSUECOMMANDCHECKRESPONSESM2, "EStBegin" ); |
5001 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:Issue %d %x",TUint(cmd.iCommand),TUint(cmd.iArgument))); |
5539 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:Issue %d %x",TUint(cmd.iCommand),TUint(cmd.iArgument))); |
5002 |
5540 OstTraceExt2( TRACE_INTERNALS, DMMCSTACK_ISSUECOMMANDCHECKRESPONSESM3, "CMD%02d(0x%08x)", TUint(cmd.iCommand), TUint(cmd.iArgument) ); |
|
5541 |
5003 // Stop the Controller from powering down the card due to bus inactivity |
5542 // Stop the Controller from powering down the card due to bus inactivity |
5004 iSocket->ResetInactivity(0); |
5543 iSocket->ResetInactivity(0); |
5005 |
5544 |
5006 SMF_STATE(EStIssueCommand) |
5545 SMF_STATE(EStIssueCommand) |
5007 |
5546 |
|
5547 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ISSUECOMMANDCHECKRESPONSESM4, "EStIssueCommand" ); |
5008 // If command is directed at a specific card then save this command in card object |
5548 // If command is directed at a specific card then save this command in card object |
5009 if (iConfig.iModes & KMMCModeCardControlled) |
5549 if (iConfig.iModes & KMMCModeCardControlled) |
5010 { |
5550 { |
5011 s.iCardP->iLastCommand = cmd.iCommand; |
5551 s.iCardP->iLastCommand = cmd.iCommand; |
5012 |
5552 |
5026 m.SetTraps(KMMCErrAll); |
5566 m.SetTraps(KMMCErrAll); |
5027 SMF_INVOKES(IssueMMCCommandSMST,EStCommandIssued) |
5567 SMF_INVOKES(IssueMMCCommandSMST,EStCommandIssued) |
5028 |
5568 |
5029 SMF_STATE(EStCommandIssued) |
5569 SMF_STATE(EStCommandIssued) |
5030 |
5570 |
|
5571 OstTrace0( TRACE_INTERNALS, DMMCSTACK_ISSUECOMMANDCHECKRESPONSESM5, "EStCommandIssued" ); |
5031 #ifdef ENABLE_DETAILED_SD_COMMAND_TRACE |
5572 #ifdef ENABLE_DETAILED_SD_COMMAND_TRACE |
5032 cmd.Dump(s.ResponseP(), err); |
5573 cmd.Dump(s.ResponseP(), err); |
5033 #endif |
5574 #endif |
5034 |
5575 |
|
5576 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSTACK_ISSUECOMMANDCHECKRESPONSESM6, "MMC Protocol: CMD%02d(0x%08x)", (TInt) cmd.iCommand, (TUint) cmd.iArgument ); |
|
5577 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSTACK_ISSUECOMMANDCHECKRESPONSESM7, "MMC Protocol: RSP%d - LEN 0x%08x - ERR 0x%08x - STAT 0x%08x", (TUint) cmd.iSpec.iResponseType, (TUint) cmd.iSpec.iResponseLength, (TUint) err, (TUint) TMMC::BigEndian32(s.ResponseP()) ); |
|
5578 |
5035 TMMCErr exitCode=err; |
5579 TMMCErr exitCode=err; |
5036 // If we have just de-selected all cards in the stack, RCA(0) then ignore response timeout. |
5580 // If we have just de-selected all cards in the stack, RCA(0) then ignore response timeout. |
5037 if ( cmd.iCommand==ECmdSelectCard && TRCA(cmd.iArgument)==0 ) |
5581 if ( cmd.iCommand==ECmdSelectCard && TRCA(cmd.iArgument)==0 ) |
5038 exitCode &= ~KMMCErrResponseTimeOut; |
5582 exitCode &= ~KMMCErrResponseTimeOut; |
5039 else |
5583 else |
5087 EStFinish, |
5633 EStFinish, |
5088 EStEnd |
5634 EStEnd |
5089 }; |
5635 }; |
5090 |
5636 |
5091 DMMCSession& s=Session(); |
5637 DMMCSession& s=Session(); |
|
5638 OstTrace1( TRACE_INTERNALS, DMMCSTACK_NAKEDSESSIONSM1, "Current session=0x%x", &s ); |
5092 |
5639 |
5093 SMF_BEGIN |
5640 SMF_BEGIN |
|
5641 OstTrace0( TRACE_INTERNALS, DMMCSTACK_NAKEDSESSIONSM2, "EStBegin" ); |
5094 s.iState |= KMMCSessStateInProgress; |
5642 s.iState |= KMMCSessStateInProgress; |
5095 |
5643 |
5096 if( (iConfig.iModes & KMMCModeCardControlled) != 0 ) |
5644 if( (iConfig.iModes & KMMCModeCardControlled) != 0 ) |
5097 SMF_INVOKES( AttachCardSMST, EStAttached ) |
5645 SMF_INVOKES( AttachCardSMST, EStAttached ) |
5098 |
5646 |
5099 SMF_BPOINT(EStAttached) |
5647 SMF_BPOINT(EStAttached) |
5100 |
5648 |
|
5649 OstTrace0( TRACE_INTERNALS, DMMCSTACK_NAKEDSESSIONSM3, "EStAttached" ); |
5101 SMF_INVOKES( ExecCommandSMST, EStFinish ) |
5650 SMF_INVOKES( ExecCommandSMST, EStFinish ) |
5102 |
5651 |
5103 SMF_STATE(EStFinish) |
5652 SMF_STATE(EStFinish) |
5104 |
5653 |
|
5654 OstTrace0( TRACE_INTERNALS, DMMCSTACK_NAKEDSESSIONSM4, "EStFinish" ); |
5105 s.iState &= ~KMMCSessStateInProgress; |
5655 s.iState &= ~KMMCSessStateInProgress; |
5106 SMF_END |
5656 SMF_END |
5107 } |
5657 } |
5108 |
5658 |
5109 inline TMMCErr DMMCStack::CIMSetupCardSM() |
5659 inline TMMCErr DMMCStack::CIMSetupCardSM() |
5121 EStGotCSD, |
5671 EStGotCSD, |
5122 EStEnd |
5672 EStEnd |
5123 }; |
5673 }; |
5124 |
5674 |
5125 DMMCSession& s=Session(); |
5675 DMMCSession& s=Session(); |
|
5676 OstTraceExt2( TRACE_INTERNALS, DMMCSTACK_CIMSETUPCARDSM1, "Current session=0x%x; Last status=0x%x", (TUint) &s, (TUint) s.iLastStatus ); |
5126 |
5677 |
5127 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:SetupCardSM %x",TUint(s.iLastStatus))); |
5678 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:SetupCardSM %x",TUint(s.iLastStatus))); |
5128 |
5679 |
5129 SMF_BEGIN |
5680 SMF_BEGIN |
|
5681 |
|
5682 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMSETUPCARDSM2, "EStBegin" ); |
5130 s.iState |= KMMCSessStateInProgress; |
5683 s.iState |= KMMCSessStateInProgress; |
5131 |
5684 |
5132 SMF_INVOKES( AttachCardSMST, EStAttached ) // attachment is mandatory here |
5685 SMF_INVOKES( AttachCardSMST, EStAttached ) // attachment is mandatory here |
5133 |
5686 |
5134 SMF_BPOINT(EStAttached) |
5687 SMF_BPOINT(EStAttached) |
5135 |
5688 |
|
5689 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMSETUPCARDSM3, "EStAttached" ); |
5136 s.FillCommandDesc( ECmdSelectCard, 0 ); |
5690 s.FillCommandDesc( ECmdSelectCard, 0 ); |
5137 SMF_INVOKES( ExecCommandSMST, EStSelected ) |
5691 SMF_INVOKES( ExecCommandSMST, EStSelected ) |
5138 |
5692 |
5139 SMF_STATE(EStSelected) |
5693 SMF_STATE(EStSelected) |
5140 |
5694 |
|
5695 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMSETUPCARDSM4, "EStSelected" ); |
5141 if( !s.iCardP->IsReady() ) |
5696 if( !s.iCardP->IsReady() ) |
5142 return( KMMCErrNoCard ); |
5697 { |
|
5698 OstTraceFunctionExitExt( DMMCSTACK_CIMSETUPCARDSM_EXIT, this, (TInt) KMMCErrNoCard ); |
|
5699 return KMMCErrNoCard; |
|
5700 } |
5143 |
5701 |
5144 s.FillCommandDesc( ECmdSendCSD, Command().iArgument ); // NB: the card will be deselected to execute this command |
5702 s.FillCommandDesc( ECmdSendCSD, Command().iArgument ); // NB: the card will be deselected to execute this command |
5145 SMF_INVOKES( ExecCommandSMST, EStGotCSD ) |
5703 SMF_INVOKES( ExecCommandSMST, EStGotCSD ) |
5146 |
5704 |
5147 SMF_STATE(EStGotCSD) |
5705 SMF_STATE(EStGotCSD) |
5148 |
5706 |
|
5707 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMSETUPCARDSM5, "EStGotCSD" ); |
5149 s.iCardP->iCSD = s.ResponseP(); |
5708 s.iCardP->iCSD = s.ResponseP(); |
5150 |
5709 |
5151 s.iState &= ~KMMCSessStateInProgress; |
5710 s.iState &= ~KMMCSessStateInProgress; |
5152 SMF_END |
5711 SMF_END |
5153 } |
5712 } |
5186 EStRWFinish, |
5745 EStRWFinish, |
5187 EStEnd |
5746 EStEnd |
5188 }; |
5747 }; |
5189 |
5748 |
5190 DMMCSession& s=Session(); |
5749 DMMCSession& s=Session(); |
|
5750 OstTraceExt2( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM1, "Current session=0x%x; Last status=0x%x", (TUint) &s, (TUint) s.iLastStatus ); |
5191 |
5751 |
5192 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:RWBlocksSM %x",TUint(s.iLastStatus))); |
5752 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:RWBlocksSM %x",TUint(s.iLastStatus))); |
5193 |
5753 |
5194 SMF_BEGIN |
5754 SMF_BEGIN |
5195 |
5755 |
|
5756 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM2, "EStBegin" ); |
5196 if(s.iSessionID == ECIMWriteBlock || s.iSessionID == ECIMWriteMBlock) |
5757 if(s.iSessionID == ECIMWriteBlock || s.iSessionID == ECIMWriteMBlock) |
5197 { |
5758 { |
5198 // Check that the card supports class 4 (Write) commands |
5759 // Check that the card supports class 4 (Write) commands |
5199 const TUint ccc = s.iCardP->CSD().CCC(); |
5760 const TUint ccc = s.iCardP->CSD().CCC(); |
5200 if(!(ccc & KMMCCmdClassBlockWrite)) |
5761 if(!(ccc & KMMCCmdClassBlockWrite)) |
5201 return( KMMCErrNotSupported ); |
5762 { |
|
5763 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT1, this, (TInt) KMMCErrNotSupported ); |
|
5764 return KMMCErrNotSupported; |
|
5765 } |
5202 } |
5766 } |
5203 |
5767 |
5204 s.iState |= KMMCSessStateInProgress; |
5768 s.iState |= KMMCSessStateInProgress; |
5205 m.SetTraps(KMMCErrInitContext); |
5769 m.SetTraps(KMMCErrInitContext); |
5206 |
5770 |
5207 SMF_STATE(EStRestart) // NB: ErrBypass is not processed here |
5771 SMF_STATE(EStRestart) // NB: ErrBypass is not processed here |
5208 |
5772 |
|
5773 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM3, "EStRestart" ); |
5209 SMF_CALLMEWR(EStRestart) // Create a recursive call entry to recover from the errors trapped |
5774 SMF_CALLMEWR(EStRestart) // Create a recursive call entry to recover from the errors trapped |
5210 m.SetTraps(KMMCErrStatus); |
5775 m.SetTraps(KMMCErrStatus); |
5211 if (s.Command().iSpec.iCommandClass!=KMMCCmdClassApplication || s.Command().iCommand==ECmdAppCmd) |
5776 if (s.Command().iSpec.iCommandClass!=KMMCCmdClassApplication || s.Command().iCommand==ECmdAppCmd) |
5212 { |
5777 { |
5213 s.ResetCommandStack(); |
5778 s.ResetCommandStack(); |
5214 SMF_INVOKES( AttachCardSMST, EStAttached ) // attachment is mandatory here |
5779 SMF_INVOKES( AttachCardSMST, EStAttached ) // attachment is mandatory here |
5215 } |
5780 } |
5216 |
5781 |
5217 SMF_BPOINT(EStAttached) |
5782 SMF_BPOINT(EStAttached) |
5218 |
5783 |
|
5784 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM4, "EStAttached" ); |
5219 TMMCCommandDesc& cmd = s.Command(); |
5785 TMMCCommandDesc& cmd = s.Command(); |
5220 |
5786 |
5221 const TUint32 blockLength = cmd.BlockLength(); |
5787 const TUint32 blockLength = cmd.BlockLength(); |
5222 if(blockLength == 0) |
5788 if(blockLength == 0) |
|
5789 { |
|
5790 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT2, this, (TInt) KMMCErrArgument ); |
5223 return KMMCErrArgument; |
5791 return KMMCErrArgument; |
|
5792 } |
5224 |
5793 |
5225 if(s.iSessionID == ECIMReadBlock || |
5794 if(s.iSessionID == ECIMReadBlock || |
5226 s.iSessionID == ECIMWriteBlock || |
5795 s.iSessionID == ECIMWriteBlock || |
5227 s.iSessionID == ECIMReadMBlock || |
5796 s.iSessionID == ECIMReadMBlock || |
5228 s.iSessionID == ECIMWriteMBlock) |
5797 s.iSessionID == ECIMWriteMBlock) |
5229 { |
5798 { |
5230 // read/write operation |
5799 // read/write operation |
5231 if(!cmd.AdjustForBlockOrByteAccess(s)) |
5800 if(!cmd.AdjustForBlockOrByteAccess(s)) |
5232 { |
5801 { |
5233 // unable to convert command arguments to suit the underlying block/byte access mode |
5802 // unable to convert command arguments to suit the underlying block/byte access mode |
|
5803 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT3, this, (TInt) KMMCErrArgument ); |
5234 return KMMCErrArgument; |
5804 return KMMCErrArgument; |
5235 } |
5805 } |
5236 } |
5806 } |
5237 |
5807 |
5238 // Set the block length if it has changed. Always set for ECIMLockUnlock. |
5808 // Set the block length if it has changed. Always set for ECIMLockUnlock. |
5246 s.FillCommandDesc( ECmdSetBlockLen, blockLength ); |
5816 s.FillCommandDesc( ECmdSetBlockLen, blockLength ); |
5247 SMF_INVOKES( ExecCommandSMST, EStLength1 ) |
5817 SMF_INVOKES( ExecCommandSMST, EStLength1 ) |
5248 |
5818 |
5249 SMF_STATE(EStLength1) |
5819 SMF_STATE(EStLength1) |
5250 |
5820 |
|
5821 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM5, "EStAttached" ); |
5251 const TMMCStatus status(s.ResponseP()); |
5822 const TMMCStatus status(s.ResponseP()); |
5252 s.PopCommandStack(); |
5823 s.PopCommandStack(); |
5253 if (status.Error()) |
5824 if (status.Error()) |
|
5825 { |
|
5826 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT4, this, (TInt) KMMCErrStatus ); |
5254 SMF_RETURN(KMMCErrStatus) |
5827 SMF_RETURN(KMMCErrStatus) |
|
5828 } |
5255 s.iCardP->iSetBlockLen = s.Command().BlockLength(); |
5829 s.iCardP->iSetBlockLen = s.Command().BlockLength(); |
5256 |
5830 |
5257 SMF_STATE(EStLengthSet) |
5831 SMF_STATE(EStLengthSet) |
5258 |
5832 |
|
5833 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM6, "EStLengthSet" ); |
5259 TMMCCommandDesc& cmd = s.Command(); |
5834 TMMCCommandDesc& cmd = s.Command(); |
5260 TUint opType = 0; |
5835 TUint opType = 0; |
5261 const TUint kTypeWrite = KBit0; |
5836 const TUint kTypeWrite = KBit0; |
5262 const TUint kTypeMultiple = KBit1; |
5837 const TUint kTypeMultiple = KBit1; |
5263 const TUint kTypeSpecial = KBit2; |
5838 const TUint kTypeSpecial = KBit2; |
5350 s.FillCommandDesc( ECmdSetBlockCount, args ); |
5928 s.FillCommandDesc( ECmdSetBlockCount, args ); |
5351 SMF_INVOKES( ExecCommandSMST, EStBlockCountCmdIssued ) |
5929 SMF_INVOKES( ExecCommandSMST, EStBlockCountCmdIssued ) |
5352 |
5930 |
5353 SMF_STATE(EStBlockCountCmdIssued) |
5931 SMF_STATE(EStBlockCountCmdIssued) |
5354 |
5932 |
|
5933 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM9, "EStBlockCountCmdIssued" ); |
5355 const TMMCStatus status(s.ResponseP()); |
5934 const TMMCStatus status(s.ResponseP()); |
5356 s.PopCommandStack(); |
5935 s.PopCommandStack(); |
5357 if (status.Error()) |
5936 if (status.Error()) |
|
5937 { |
|
5938 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT5, this, (TInt) KMMCErrStatus ); |
5358 SMF_RETURN(KMMCErrStatus) |
5939 SMF_RETURN(KMMCErrStatus) |
|
5940 } |
5359 |
5941 |
5360 if(err & KMMCErrNotSupported) |
5942 if(err & KMMCErrNotSupported) |
5361 { |
5943 { |
5362 // Not supported by the PSL, so use standard Stop Transmission mode |
5944 // Not supported by the PSL, so use standard Stop Transmission mode |
5363 s.Command().iSpec.iUseStopTransmission = ETrue; |
5945 s.Command().iSpec.iUseStopTransmission = ETrue; |
5365 |
5947 |
5366 SMF_GOTOS(EStBpoint1) |
5948 SMF_GOTOS(EStBpoint1) |
5367 |
5949 |
5368 SMF_STATE(EStAppCmdIssued) |
5950 SMF_STATE(EStAppCmdIssued) |
5369 |
5951 |
|
5952 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM10, "EStAppCmdIssued" ); |
5370 const TMMCStatus status(s.ResponseP()); |
5953 const TMMCStatus status(s.ResponseP()); |
5371 s.PopCommandStack(); |
5954 s.PopCommandStack(); |
5372 if (status.Error()) |
5955 if (status.Error()) |
|
5956 { |
|
5957 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT6, this, (TInt) KMMCErrStatus ); |
5373 SMF_RETURN(KMMCErrStatus) |
5958 SMF_RETURN(KMMCErrStatus) |
|
5959 } |
5374 |
5960 |
5375 SMF_BPOINT(EStBpoint1) |
5961 SMF_BPOINT(EStBpoint1) |
5376 |
5962 |
|
5963 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM11, "EStBpoint1" ); |
5377 // NB We need to trap KMMCErrStatus errors, because if one occurs, |
5964 // NB We need to trap KMMCErrStatus errors, because if one occurs, |
5378 // we still need to wait to exit PRG/RCV/DATA state |
5965 // we still need to wait to exit PRG/RCV/DATA state |
5379 m.SetTraps(KMMCErrStatus); |
5966 m.SetTraps(KMMCErrStatus); |
5380 |
5967 |
5381 SMF_INVOKES( ExecCommandSMST, EStIssued ) |
5968 SMF_INVOKES( ExecCommandSMST, EStIssued ) |
5382 |
5969 |
5383 SMF_STATE(EStIssued) |
5970 SMF_STATE(EStIssued) |
5384 |
5971 |
|
5972 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM12, "EStIssued" ); |
5385 // check state of card after data transfer with CMD13. |
5973 // check state of card after data transfer with CMD13. |
5386 |
5974 |
5387 if (s.Command().Direction() != 0) |
5975 if (s.Command().Direction() != 0) |
5388 { |
5976 { |
5389 SMF_GOTOS(EStWaitFinish) |
5977 SMF_GOTOS(EStWaitFinish) |
5390 } |
5978 } |
5391 |
5979 |
5392 SMF_GOTOS(EStRWFinish); |
5980 SMF_GOTOS(EStRWFinish); |
5393 |
5981 |
5394 SMF_STATE(EStWaitFinish) |
5982 SMF_STATE(EStWaitFinish) |
|
5983 |
|
5984 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM13, "EStWaitFinish" ); |
5395 // Save the status and examine it after issuing CMD13... |
5985 // Save the status and examine it after issuing CMD13... |
5396 // NB We don't know where in the command stack the last response is stored (e.g. there may |
5986 // NB We don't know where in the command stack the last response is stored (e.g. there may |
5397 // have bee a Deselect/Select issued), but we do know last response is stored in iLastStatus |
5987 // have bee a Deselect/Select issued), but we do know last response is stored in iLastStatus |
5398 TMMC::BigEndian4Bytes(s.ResponseP(), s.iLastStatus); |
5988 TMMC::BigEndian4Bytes(s.ResponseP(), s.iLastStatus); |
5399 |
5989 |
5400 s.PushCommandStack(); |
5990 s.PushCommandStack(); |
5401 s.FillCommandDesc(ECmdSendStatus, 0); |
5991 s.FillCommandDesc(ECmdSendStatus, 0); |
5402 SMF_INVOKES(ExecCommandSMST, EStWaitFinish1) |
5992 SMF_INVOKES(ExecCommandSMST, EStWaitFinish1) |
5403 |
5993 |
5404 SMF_STATE(EStWaitFinish1) |
5994 SMF_STATE(EStWaitFinish1) |
|
5995 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM14, "EStWaitFinish1" ); |
5405 const TMMCStatus status(s.ResponseP()); |
5996 const TMMCStatus status(s.ResponseP()); |
5406 s.PopCommandStack(); |
5997 s.PopCommandStack(); |
5407 |
5998 |
5408 #ifdef __WINS__ |
5999 #ifdef __WINS__ |
5409 SMF_GOTOS(EStRWFinish); |
6000 SMF_GOTOS(EStRWFinish); |
5412 if (st1 == ECardStatePrg || st1 == ECardStateRcv || st1 == ECardStateData) |
6003 if (st1 == ECardStatePrg || st1 == ECardStateRcv || st1 == ECardStateData) |
5413 { |
6004 { |
5414 SMF_INVOKES(ProgramTimerSMST, EStWaitFinish); |
6005 SMF_INVOKES(ProgramTimerSMST, EStWaitFinish); |
5415 } |
6006 } |
5416 if (status.Error()) |
6007 if (status.Error()) |
|
6008 { |
|
6009 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT7, this, (TInt) KMMCErrStatus ); |
5417 SMF_RETURN(KMMCErrStatus) |
6010 SMF_RETURN(KMMCErrStatus) |
|
6011 } |
5418 #endif |
6012 #endif |
5419 |
6013 |
5420 // Fall through if CURRENT_STATE is not PGM or DATA |
6014 // Fall through if CURRENT_STATE is not PGM or DATA |
5421 SMF_STATE(EStRWFinish) |
6015 SMF_STATE(EStRWFinish) |
5422 |
6016 |
|
6017 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMREADWRITEBLOCKSSM15, "EStRWFinish" ); |
5423 if (TMMCStatus(s.ResponseP()).Error() != 0) |
6018 if (TMMCStatus(s.ResponseP()).Error() != 0) |
|
6019 { |
|
6020 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT8, this, (TInt) KMMCErrStatus ); |
5424 SMF_RETURN(KMMCErrStatus); |
6021 SMF_RETURN(KMMCErrStatus); |
|
6022 } |
5425 |
6023 |
5426 s.iState &= ~KMMCSessStateInProgress; |
6024 s.iState &= ~KMMCSessStateInProgress; |
5427 |
6025 |
5428 // skip over recursive entry or throw error and catch in CIMLockUnlockSM() |
6026 // skip over recursive entry or throw error and catch in CIMLockUnlockSM() |
5429 return (s.Command().iCommand == ECmdLockUnlock) ? KMMCErrUpdPswd : KMMCErrBypass; |
6027 TMMCErr ret = (s.Command().iCommand == ECmdLockUnlock) ? KMMCErrUpdPswd : KMMCErrBypass; |
|
6028 OstTraceFunctionExitExt( DMMCSTACK_CIMREADWRITEBLOCKSSM_EXIT9, this, (TInt) ret ); |
|
6029 return ret; |
5430 |
6030 |
5431 SMF_END |
6031 SMF_END |
5432 } |
6032 } |
5433 |
6033 |
5434 inline TMMCErr DMMCStack::CIMEraseSM() |
6034 inline TMMCErr DMMCStack::CIMEraseSM() |
5451 EStEraseFinish, |
6051 EStEraseFinish, |
5452 EStEnd |
6052 EStEnd |
5453 }; |
6053 }; |
5454 |
6054 |
5455 DMMCSession& s=Session(); |
6055 DMMCSession& s=Session(); |
|
6056 OstTraceExt2( TRACE_INTERNALS, DMMCSTACK_CIMERASESM1, "Current session=0x%x; Last status=0x%x", (TUint) &s, (TUint) s.iLastStatus ); |
|
6057 |
5456 |
6058 |
5457 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:EraseSM %x",TUint(s.iLastStatus))); |
6059 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:EraseSM %x",TUint(s.iLastStatus))); |
5458 |
6060 |
5459 SMF_BEGIN |
6061 SMF_BEGIN |
5460 |
6062 |
|
6063 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM2, "EStBegin" ); |
5461 // Check that the card supports class 4 (Write) commands |
6064 // Check that the card supports class 4 (Write) commands |
5462 const TUint ccc = s.iCardP->CSD().CCC(); |
6065 const TUint ccc = s.iCardP->CSD().CCC(); |
5463 if(!(ccc & KMMCCmdClassErase)) |
6066 if(!(ccc & KMMCCmdClassErase)) |
5464 return( KMMCErrNotSupported ); |
6067 { |
|
6068 OstTraceFunctionExitExt( DMMCSTACK_CIMERASESM_EXIT1, this, (TInt) KMMCErrNotSupported ); |
|
6069 return KMMCErrNotSupported; |
|
6070 } |
5465 |
6071 |
5466 s.iState |= KMMCSessStateInProgress; |
6072 s.iState |= KMMCSessStateInProgress; |
5467 m.SetTraps( KMMCErrInitContext ); |
6073 m.SetTraps( KMMCErrInitContext ); |
5468 |
6074 |
5469 SMF_STATE(EStRestart) |
6075 SMF_STATE(EStRestart) |
5470 |
6076 |
|
6077 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM3, "EStRestart" ); |
5471 SMF_CALLMEWR(EStRestart) // Create a recursive call entry to recover from Init |
6078 SMF_CALLMEWR(EStRestart) // Create a recursive call entry to recover from Init |
5472 |
6079 |
5473 s.ResetCommandStack(); |
6080 s.ResetCommandStack(); |
5474 SMF_INVOKES( AttachCardSMST, EStAttached ) // attachment is mandatory |
6081 SMF_INVOKES( AttachCardSMST, EStAttached ) // attachment is mandatory |
5475 |
6082 |
5476 SMF_BPOINT(EStAttached) |
6083 SMF_BPOINT(EStAttached) |
5477 |
6084 |
|
6085 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM4, "EStAttached" ); |
5478 TMMCCommandDesc& cmd = s.Command(); |
6086 TMMCCommandDesc& cmd = s.Command(); |
5479 |
6087 |
5480 if(cmd.iTotalLength == 0) |
6088 if(cmd.iTotalLength == 0) |
5481 return( KMMCErrArgument ); |
6089 { |
|
6090 OstTraceFunctionExitExt( DMMCSTACK_CIMERASESM_EXIT2, this, (TInt) KMMCErrArgument ); |
|
6091 return KMMCErrArgument; |
|
6092 } |
5482 |
6093 |
5483 switch( s.iSessionID ) |
6094 switch( s.iSessionID ) |
5484 { |
6095 { |
5485 case ECIMEraseSector: |
6096 case ECIMEraseSector: |
|
6097 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM5, "ECIMEraseSector" ); |
5486 TMMCEraseInfo eraseInfo; |
6098 TMMCEraseInfo eraseInfo; |
5487 s.iCardP->GetEraseInfo(eraseInfo); |
6099 s.iCardP->GetEraseInfo(eraseInfo); |
5488 cmd.iBlockLength = eraseInfo.iMinEraseSectorSize; |
6100 cmd.iBlockLength = eraseInfo.iMinEraseSectorSize; |
5489 cmd.iCommand = ECmdTagSectorStart; |
6101 cmd.iCommand = ECmdTagSectorStart; |
5490 break; |
6102 break; |
5491 case ECIMEraseGroup: |
6103 case ECIMEraseGroup: |
|
6104 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM6, "ECIMEraseGroup" ); |
5492 cmd.iBlockLength = s.iCardP->iCSD.EraseGroupSize(); |
6105 cmd.iBlockLength = s.iCardP->iCSD.EraseGroupSize(); |
5493 if(cmd.iBlockLength == 0 || cmd.iTotalLength % cmd.iBlockLength != 0) |
6106 if(cmd.iBlockLength == 0 || cmd.iTotalLength % cmd.iBlockLength != 0) |
|
6107 { |
|
6108 OstTraceFunctionExitExt( DMMCSTACK_CIMERASESM_EXIT3, this, (TInt) KMMCErrArgument ); |
5494 return KMMCErrArgument; |
6109 return KMMCErrArgument; |
|
6110 } |
5495 cmd.iCommand = ECmdTagEraseGroupStart; |
6111 cmd.iCommand = ECmdTagEraseGroupStart; |
5496 break; |
6112 break; |
5497 default: |
6113 default: |
5498 DMMCSocket::Panic(DMMCSocket::EMMCEraseSessionID); |
6114 DMMCSocket::Panic(DMMCSocket::EMMCEraseSessionID); |
5499 } |
6115 } |
5500 |
6116 |
5501 if(!cmd.AdjustForBlockOrByteAccess(s)) |
6117 if(!cmd.AdjustForBlockOrByteAccess(s)) |
|
6118 { |
|
6119 OstTraceFunctionExitExt( DMMCSTACK_CIMERASESM_EXIT4, this, (TInt) KMMCErrArgument ); |
5502 return KMMCErrArgument; |
6120 return KMMCErrArgument; |
|
6121 } |
5503 |
6122 |
5504 iConfig.RemoveMode( KMMCModeEnablePreemption ); // erase sequence must not be pre-empted |
6123 iConfig.RemoveMode( KMMCModeEnablePreemption ); // erase sequence must not be pre-empted |
5505 |
6124 |
5506 const TUint flags = cmd.iFlags; |
6125 const TUint flags = cmd.iFlags; |
5507 s.FillCommandDesc(); |
6126 s.FillCommandDesc(); |
5508 cmd.iFlags = flags; |
6127 cmd.iFlags = flags; |
5509 SMF_INVOKES( ExecCommandSMST, EStStartTagged ) |
6128 SMF_INVOKES( ExecCommandSMST, EStStartTagged ) |
5510 |
6129 |
5511 SMF_STATE(EStStartTagged) |
6130 SMF_STATE(EStStartTagged) |
5512 |
6131 |
|
6132 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM7, "EStStartTagged" ); |
5513 const TMMCCommandDesc& cmd = s.Command(); |
6133 const TMMCCommandDesc& cmd = s.Command(); |
5514 |
6134 |
5515 TMMCCommandEnum command; |
6135 TMMCCommandEnum command; |
5516 TUint endAddr = cmd.iArgument; |
6136 TUint endAddr = cmd.iArgument; |
5517 if(s.iSessionID == ECIMEraseSector) |
6137 if(s.iSessionID == ECIMEraseSector) |
5537 s.FillCommandDesc( command, endAddr ); |
6157 s.FillCommandDesc( command, endAddr ); |
5538 SMF_INVOKES( ExecCommandSMST, EStEndTagged ) |
6158 SMF_INVOKES( ExecCommandSMST, EStEndTagged ) |
5539 |
6159 |
5540 SMF_STATE(EStEndTagged) |
6160 SMF_STATE(EStEndTagged) |
5541 |
6161 |
|
6162 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM8, "EStEndTagged" ); |
5542 // Increase the inactivity timeout as an erase operation can potentially take a long time |
6163 // Increase the inactivity timeout as an erase operation can potentially take a long time |
5543 // At the moment this is a somewhat arbitrary 30 seconds. This could be calculated more accurately |
6164 // At the moment this is a somewhat arbitrary 30 seconds. This could be calculated more accurately |
5544 // using TAAC,NSAC, R2W_FACTOR etc. but that seems to yield very large values (?) |
6165 // using TAAC,NSAC, R2W_FACTOR etc. but that seems to yield very large values (?) |
5545 const TInt KMaxEraseTimeoutInSeconds = 30; |
6166 const TInt KMaxEraseTimeoutInSeconds = 30; |
5546 iBody->SetInactivityTimeout(KMaxEraseTimeoutInSeconds); |
6167 iBody->SetInactivityTimeout(KMaxEraseTimeoutInSeconds); |
5547 m.SetTraps(KMMCErrAll); |
6168 m.SetTraps(KMMCErrAll); |
5548 s.FillCommandDesc( ECmdErase, 0 ); |
6169 s.FillCommandDesc( ECmdErase, 0 ); |
5549 SMF_INVOKES( ExecCommandSMST, EStErased ) |
6170 SMF_INVOKES( ExecCommandSMST, EStErased ) |
5550 |
6171 |
5551 SMF_STATE(EStErased) |
6172 SMF_STATE(EStErased) |
|
6173 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM9, "EStErased" ); |
5552 m.SetTraps( KMMCErrInitContext ); |
6174 m.SetTraps( KMMCErrInitContext ); |
5553 iBody->RestoreInactivityTimeout(); |
6175 iBody->RestoreInactivityTimeout(); |
5554 if (err != KMMCErrNone) |
6176 if (err != KMMCErrNone) |
|
6177 { |
|
6178 OstTraceFunctionExitExt( DMMCSTACK_CIMERASESM_EXIT5, this, (TInt) err ); |
5555 SMF_RETURN(err); |
6179 SMF_RETURN(err); |
|
6180 } |
5556 |
6181 |
5557 |
6182 |
5558 SMF_STATE(EStWaitFinish) |
6183 SMF_STATE(EStWaitFinish) |
5559 |
6184 |
|
6185 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM10, "EStWaitFinish" ); |
5560 s.PushCommandStack(); |
6186 s.PushCommandStack(); |
5561 s.FillCommandDesc(ECmdSendStatus, 0); |
6187 s.FillCommandDesc(ECmdSendStatus, 0); |
5562 SMF_INVOKES(ExecCommandSMST, EStWaitFinish1) |
6188 SMF_INVOKES(ExecCommandSMST, EStWaitFinish1) |
5563 |
6189 |
5564 SMF_STATE(EStWaitFinish1) |
6190 SMF_STATE(EStWaitFinish1) |
5565 |
6191 |
|
6192 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMERASESM11, "EStWaitFinish1" ); |
5566 const TMMCStatus st(s.ResponseP()); |
6193 const TMMCStatus st(s.ResponseP()); |
5567 s.PopCommandStack(); |
6194 s.PopCommandStack(); |
5568 |
6195 |
5569 #ifdef __WINS__ |
6196 #ifdef __WINS__ |
5570 SMF_GOTOS(EStEraseFinish); |
6197 SMF_GOTOS(EStEraseFinish); |
5674 EStEnd |
6308 EStEnd |
5675 }; |
6309 }; |
5676 |
6310 |
5677 DMMCSession& s=Session(); |
6311 DMMCSession& s=Session(); |
5678 TMMCCommandDesc& cmd = Command(); |
6312 TMMCCommandDesc& cmd = Command(); |
|
6313 OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMLOCKUNLOCKSM1, "Current session=0x%x", &s ); |
5679 |
6314 |
5680 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm")); |
6315 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm")); |
5681 |
6316 |
5682 SMF_BEGIN |
6317 SMF_BEGIN |
|
6318 |
|
6319 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMLOCKUNLOCKSM2, "EStBegin" ); |
5683 m.SetTraps(KMMCErrStatus | KMMCErrUpdPswd); |
6320 m.SetTraps(KMMCErrStatus | KMMCErrUpdPswd); |
5684 cmd.iUnlockRetries = 0; // attempt counter |
6321 cmd.iUnlockRetries = 0; // attempt counter |
5685 iCMD42CmdByte = cmd.iDataMemoryP[0]; |
6322 iCMD42CmdByte = cmd.iDataMemoryP[0]; |
5686 |
6323 |
5687 SMF_STATE(EStRetry) |
6324 SMF_STATE(EStRetry) |
|
6325 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMLOCKUNLOCKSM3, "EStRetry" ); |
5688 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm:%x/%x", cmd.iUnlockRetries, (iSessionP == &iAutoUnlockSession) ? KMMCMaxAutoUnlockRetries : iConfig.iUnlockRetries)); |
6326 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm:%x/%x", cmd.iUnlockRetries, (iSessionP == &iAutoUnlockSession) ? KMMCMaxAutoUnlockRetries : iConfig.iUnlockRetries)); |
5689 |
6327 |
5690 if (iCMD42CmdByte == KMMCLockUnlockErase) |
6328 if (iCMD42CmdByte == KMMCLockUnlockErase) |
5691 { |
6329 { |
5692 // Section 4.6.2 of version 4.2 of the the MMC specification states that |
6330 // Section 4.6.2 of version 4.2 of the the MMC specification states that |
5711 const TMMCStatus st = s.LastStatus(); // set in ExecCommandSM() / EStCommandIssued |
6350 const TMMCStatus st = s.LastStatus(); // set in ExecCommandSM() / EStCommandIssued |
5712 TMMCCommandDesc& cmd0 = Command(); |
6351 TMMCCommandDesc& cmd0 = Command(); |
5713 |
6352 |
5714 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm:EStTestR1 [err: %08x, st:%08x] : RETRY [%d]", |
6353 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm:EStTestR1 [err: %08x, st:%08x] : RETRY [%d]", |
5715 err, (TInt)s.LastStatus(), cmd0.iUnlockRetries)); |
6354 err, (TInt)s.LastStatus(), cmd0.iUnlockRetries)); |
|
6355 OstTraceExt3( TRACE_INTERNALS, DMMCSTACK_CIMLOCKUNLOCKSM5, "err=%08x; Last status=%d; Unlock retries=%d", (TUint) err, (TInt) s.LastStatus(), (TUint) cmd0.iUnlockRetries ); |
5716 |
6356 |
5717 const TInt KMaxRetries = (iSessionP == &iAutoUnlockSession) ? KMMCMaxAutoUnlockRetries : iConfig.iUnlockRetries; |
6357 const TInt KMaxRetries = (iSessionP == &iAutoUnlockSession) ? KMMCMaxAutoUnlockRetries : iConfig.iUnlockRetries; |
5718 |
6358 |
5719 // retry if LOCK_UNLOCK_FAIL only error bit |
6359 // retry if LOCK_UNLOCK_FAIL only error bit |
5720 if (!( iCMD42CmdByte == 0 // LOCK_UNLOCK = 0; SET_PWD = 0 |
6360 if (!( iCMD42CmdByte == 0 // LOCK_UNLOCK = 0; SET_PWD = 0 |
5721 && err == KMMCErrStatus && st.Error() == KMMCStatErrLockUnlock |
6361 && err == KMMCErrStatus && st.Error() == KMMCStatErrLockUnlock |
5722 && (iConfig.iModes & KMMCModeEnableUnlockRetry) != 0 |
6362 && (iConfig.iModes & KMMCModeEnableUnlockRetry) != 0 |
5723 && ++cmd0.iUnlockRetries < KMaxRetries )) |
6363 && ++cmd0.iUnlockRetries < KMaxRetries )) |
5724 { |
6364 { |
5725 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm:abt")); |
6365 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm:abt")); |
5726 |
6366 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMLOCKUNLOCKSM6, "LockUnlock abort" ); |
|
6367 OstTraceFunctionExitExt( DMMCSTACK_CIMLOCKUNLOCKSM_EXIT, this, (TInt) err ); |
5727 SMF_RETURN(err); |
6368 SMF_RETURN(err); |
5728 } |
6369 } |
5729 |
6370 |
5730 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm:retry")); |
6371 __KTRACE_OPT(KPBUS1, Kern::Printf("mmc:clusm:retry")); |
|
6372 OstTrace0( TRACE_INTERNALS, DMMCSTACK_CIMLOCKUNLOCKSM7, "LockUnlock retry" ); |
5731 |
6373 |
5732 #ifdef __EPOC32__ |
6374 #ifdef __EPOC32__ |
5733 s.SynchBlock(KMMCBlockOnRetryTimer); |
6375 s.SynchBlock(KMMCBlockOnRetryTimer); |
5734 s.iRetryTimer.OneShot(KMMCUnlockRetryGapInMilliseconds,EFalse); |
6376 s.iRetryTimer.OneShot(KMMCUnlockRetryGapInMilliseconds,EFalse); |
5735 SMF_WAITS(EStRetry) |
6377 SMF_WAITS(EStRetry) |
6042 * |
6695 * |
6043 * @param aClock The requested clock frequency in Kilohertz |
6696 * @param aClock The requested clock frequency in Kilohertz |
6044 */ |
6697 */ |
6045 void DMMCStack::DoSetClock(TUint32 aClock) |
6698 void DMMCStack::DoSetClock(TUint32 aClock) |
6046 { |
6699 { |
|
6700 OstTraceFunctionEntryExt( DMMCSTACK_DOSETCLOCK_ENTRY, this ); |
6047 iConfig.iBusConfig.iBusClock = aClock; |
6701 iConfig.iBusConfig.iBusClock = aClock; |
6048 |
6702 |
6049 if (iPoweredUp&&(iBody->iCurrentSelectedClock != aClock)) |
6703 if (iPoweredUp&&(iBody->iCurrentSelectedClock != aClock)) |
6050 { |
6704 { |
6051 iBody->iCurrentSelectedClock = aClock; |
6705 iBody->iCurrentSelectedClock = aClock; |
6052 SetBusConfigDefaults(iConfig.iBusConfig, aClock); |
6706 SetBusConfigDefaults(iConfig.iBusConfig, aClock); |
6053 } |
6707 } |
|
6708 OstTraceFunctionExit1( DMMCSTACK_DOSETCLOCK_EXIT, this ); |
6054 } |
6709 } |
6055 |
6710 |
6056 |
6711 |
6057 TUint DMMCStack::MaxTranSpeedInKilohertz(const TMMCard& aCard) const |
6712 TUint DMMCStack::MaxTranSpeedInKilohertz(const TMMCard& aCard) const |
6058 { |
6713 { |
|
6714 OstTraceFunctionEntry1( DMMCSTACK_MAXTRANSPEEDINKILOHERTZ_ENTRY, this ); |
6059 TUint32 highSpeedClock = aCard.HighSpeedClock(); |
6715 TUint32 highSpeedClock = aCard.HighSpeedClock(); |
6060 return highSpeedClock ? highSpeedClock : aCard.MaxTranSpeedInKilohertz(); |
6716 TUint ret = highSpeedClock ? highSpeedClock : aCard.MaxTranSpeedInKilohertz(); |
|
6717 OstTraceFunctionExitExt( DMMCSTACK_MAXTRANSPEEDINKILOHERTZ_EXIT, this, ret ); |
|
6718 return ret; |
6061 } |
6719 } |
6062 |
6720 |
6063 |
6721 |
6064 |
6722 |
6065 EXPORT_C void DMMCStack::SetBusWidth(TUint32 /*aBusWidth*/) |
6723 EXPORT_C void DMMCStack::SetBusWidth(TUint32 /*aBusWidth*/) |
6384 if (s) // s & ~t & ~f |
7056 if (s) // s & ~t & ~f |
6385 pmp->iState = TMapping::EStInvalid; // wipe |
7057 pmp->iState = TMapping::EStInvalid; // wipe |
6386 } |
7058 } |
6387 } // else (f) |
7059 } // else (f) |
6388 } // else if (aSessP == &iStack->iAutoUnlockSession) |
7060 } // else if (aSessP == &iStack->iAutoUnlockSession) |
|
7061 OstTraceFunctionExit1( DMMCSOCKET_PASSWORDCONTROLEND_EXIT2, this ); |
6389 } |
7062 } |
6390 |
7063 |
6391 |
7064 |
6392 TMMCPasswordStore::TMMCPasswordStore() |
7065 TMMCPasswordStore::TMMCPasswordStore() |
6393 /** |
7066 /** |
6394 * Contructor |
7067 * Contructor |
6395 */ |
7068 */ |
6396 : iIdentityRelation(TMMCPasswordStore::CompareCID) |
7069 : iIdentityRelation(TMMCPasswordStore::CompareCID) |
6397 { |
7070 { |
|
7071 OstTraceFunctionEntry1( TMMCPASSWORDSTORE_TMMCPASSWORDSTORE_ENTRY, this ); |
6398 } |
7072 } |
6399 |
7073 |
6400 TInt TMMCPasswordStore::Init() |
7074 TInt TMMCPasswordStore::Init() |
6401 /** |
7075 /** |
6402 * Initialises the password store and allocates resources. |
7076 * Initialises the password store and allocates resources. |
6403 * @return KErrNone if successful, standard error code otherwise. |
7077 * @return KErrNone if successful, standard error code otherwise. |
6404 */ |
7078 */ |
6405 { |
7079 { |
|
7080 OstTraceFunctionEntry1( TMMCPASSWORDSTORE_INIT_ENTRY, this ); |
6406 // We don't have a destructor yet as this object lasts forever |
7081 // We don't have a destructor yet as this object lasts forever |
6407 iStore = new RArray<TMapping>(4, _FOFF(TMapping, iCID)); |
7082 iStore = new RArray<TMapping>(4, _FOFF(TMapping, iCID)); |
6408 if(!iStore) |
7083 if(!iStore) |
|
7084 { |
|
7085 OstTraceFunctionExitExt( TMMCPASSWORDSTORE_INIT_EXIT1, this, KErrNoMemory ); |
6409 return KErrNoMemory; |
7086 return KErrNoMemory; |
|
7087 } |
|
7088 OstTraceFunctionExitExt( TMMCPASSWORDSTORE_INIT_EXIT2, this, KErrNone ); |
6410 return KErrNone; |
7089 return KErrNone; |
6411 } |
7090 } |
6412 |
7091 |
6413 EXPORT_C TBool TMMCPasswordStore::IsMappingIncorrect(const TCID& aCID, const TMediaPassword& aPWD) |
7092 EXPORT_C TBool TMMCPasswordStore::IsMappingIncorrect(const TCID& aCID, const TMediaPassword& aPWD) |
6414 /** |
7093 /** |
6415 * Returns true if the password is definitely incorrect, i.e. if a valid entry with a |
7094 * Returns true if the password is definitely incorrect, i.e. if a valid entry with a |
6416 * different password exists. Returns false if correct (because the mapping matches,) |
7095 * different password exists. Returns false if correct (because the mapping matches,) |
6417 * or if cannot tell (because no valid mapping.) |
7096 * or if cannot tell (because no valid mapping.) |
6418 */ |
7097 */ |
6419 { |
7098 { |
|
7099 OstTraceFunctionEntry1( TMMCPASSWORDSTORE_ISMAPPINGINCORRECT_ENTRY, this ); |
6420 TMapping* pmp = FindMappingInStore(aCID); |
7100 TMapping* pmp = FindMappingInStore(aCID); |
6421 return (pmp != 0 && pmp->iState == TMapping::EStValid && pmp->iPWD.Compare(aPWD) != 0); |
7101 TBool ret = pmp != 0 && pmp->iState == TMapping::EStValid && pmp->iPWD.Compare(aPWD) != 0; |
|
7102 OstTraceFunctionExitExt( TMMCPASSWORDSTORE_ISMAPPINGINCORRECT_EXIT, this, ret ); |
|
7103 return ret; |
6422 } |
7104 } |
6423 |
7105 |
6424 TMapping *TMMCPasswordStore::FindMappingInStore(const TCID &aCID) |
7106 TMapping *TMMCPasswordStore::FindMappingInStore(const TCID &aCID) |
6425 /** |
7107 /** |
6426 * return pointer to aCID mapping in store or NULL if not found |
7108 * return pointer to aCID mapping in store or NULL if not found |
6427 */ |
7109 */ |
6428 { |
7110 { |
|
7111 OstTraceFunctionEntry1( TMMCPASSWORDSTORE_FINDMAPPINGINSTORE_ENTRY, this ); |
6429 TMapping *pmp = NULL; |
7112 TMapping *pmp = NULL; |
6430 TMapping mp; // 8 + 16 + 8 + 16 + 4 bytes |
7113 TMapping mp; // 8 + 16 + 8 + 16 + 4 bytes |
6431 mp.iCID.SetLength(KMMCCIDLength); |
7114 mp.iCID.SetLength(KMMCCIDLength); |
6432 aCID.Copy(&mp.iCID[0]); |
7115 aCID.Copy(&mp.iCID[0]); |
6433 |
7116 |
6434 TInt psn=iStore->Find(mp, iIdentityRelation); |
7117 TInt psn=iStore->Find(mp, iIdentityRelation); |
6435 if(psn!=KErrNotFound) |
7118 if(psn!=KErrNotFound) |
6436 { |
7119 { |
6437 pmp = &(*iStore)[psn]; |
7120 pmp = &(*iStore)[psn]; |
6438 } |
7121 } |
|
7122 OstTraceFunctionExitExt( TMMCPASSWORDSTORE_FINDMAPPINGINSTORE_EXIT, this, ( TUint )( pmp ) ); |
6439 return pmp; |
7123 return pmp; |
6440 } |
7124 } |
6441 |
7125 |
6442 TInt TMMCPasswordStore::InsertMapping(const TCID &aCID, const TMediaPassword &aPWD, TMapping::TState aState) |
7126 TInt TMMCPasswordStore::InsertMapping(const TCID &aCID, const TMediaPassword &aPWD, TMapping::TState aState) |
6443 /** |
7127 /** |
6467 mpE.iPWD.Copy(aPWD); |
7152 mpE.iPWD.Copy(aPWD); |
6468 mpE.iState = aState; |
7153 mpE.iState = aState; |
6469 r = KErrNone; |
7154 r = KErrNone; |
6470 } |
7155 } |
6471 |
7156 |
|
7157 OstTraceFunctionExitExt( TMMCPASSWORDSTORE_INSERTMAPPING_EXIT, this, r ); |
6472 return r; |
7158 return r; |
6473 } |
7159 } |
6474 |
7160 |
6475 TInt TMMCPasswordStore::PasswordStoreLengthInBytes() |
7161 TInt TMMCPasswordStore::PasswordStoreLengthInBytes() |
6476 /** |
7162 /** |
6477 * virtual from DPeriphBusController, kern exec |
7163 * virtual from DPeriphBusController, kern exec |
6478 * return number of bytes needed for persistent file representation |
7164 * return number of bytes needed for persistent file representation |
6479 * of the password store |
7165 * of the password store |
6480 */ |
7166 */ |
6481 { |
7167 { |
|
7168 OstTraceFunctionEntry1( TMMCPASSWORDSTORE_PASSWORDSTORELENGTHINBYTES_ENTRY, this ); |
6482 TInt sz = 0; |
7169 TInt sz = 0; |
6483 |
7170 |
6484 for (TInt i = 0; i < iStore->Count(); ++i) |
7171 for (TInt i = 0; i < iStore->Count(); ++i) |
6485 { |
7172 { |
6486 const TMapping &mp = (*iStore)[i]; |
7173 const TMapping &mp = (*iStore)[i]; |
6487 if (mp.iState == TMapping::EStValid) |
7174 if (mp.iState == TMapping::EStValid) |
6488 sz += KMMCCIDLength + sizeof(TInt32) + mp.iPWD.Length(); |
7175 sz += KMMCCIDLength + sizeof(TInt32) + mp.iPWD.Length(); |
6489 } |
7176 } |
6490 |
7177 |
|
7178 OstTraceFunctionExitExt( TMMCPASSWORDSTORE_PASSWORDSTORELENGTHINBYTES_EXIT, this, sz ); |
6491 return sz; |
7179 return sz; |
6492 } |
7180 } |
6493 |
7181 |
6494 TBool TMMCPasswordStore::ReadPasswordData(TDes8 &aBuf) |
7182 TBool TMMCPasswordStore::ReadPasswordData(TDes8 &aBuf) |
6495 /** |
7183 /** |
6587 // atomic from the startup thread's point of view. |
7281 // atomic from the startup thread's point of view. |
6588 |
7282 |
6589 if (r != KErrNone) |
7283 if (r != KErrNone) |
6590 iStore->Reset(); |
7284 iStore->Reset(); |
6591 |
7285 |
|
7286 OstTraceFunctionExitExt( TMMCPASSWORDSTORE_WRITEPASSWORDDATA_EXIT2, this, r ); |
6592 return r; |
7287 return r; |
6593 } |
7288 } |
6594 |
7289 |
6595 TInt TMMCPasswordStore::CompareCID(const TMapping& aLeft, const TMapping& aRight) |
7290 TInt TMMCPasswordStore::CompareCID(const TMapping& aLeft, const TMapping& aRight) |
6596 /** |
7291 /** |
6597 * CID Comparason Functions for RArray::Find |
7292 * CID Comparason Functions for RArray::Find |
6598 */ |
7293 */ |
6599 { |
7294 { |
|
7295 OstTraceFunctionEntry0( TMMCPASSWORDSTORE_COMPARECID_ENTRY ); |
6600 return(aLeft.iCID == aRight.iCID); |
7296 return(aLeft.iCID == aRight.iCID); |
6601 } |
7297 } |
6602 |
7298 |
6603 void DMMCSocket::InitiatePowerUpSequence() |
7299 void DMMCSocket::InitiatePowerUpSequence() |
6604 /** |
7300 /** |
6605 * Initiates a power up sequence on the stack |
7301 * Initiates a power up sequence on the stack |
6606 */ |
7302 */ |
6607 { |
7303 { |
|
7304 OstTraceFunctionEntry1( DMMCSOCKET_INITIATEPOWERUPSEQUENCE_ENTRY, this ); |
6608 iStack->PowerUpStack(); |
7305 iStack->PowerUpStack(); |
|
7306 OstTraceFunctionExit1( DMMCSOCKET_INITIATEPOWERUPSEQUENCE_EXIT, this ); |
6609 } |
7307 } |
6610 |
7308 |
6611 TBool DMMCSocket::CardIsPresent() |
7309 TBool DMMCSocket::CardIsPresent() |
6612 /** |
7310 /** |
6613 * Indicates the presence of a card. |
7311 * Indicates the presence of a card. |
6614 * @return ETrue if a card is present, EFalse otherwise |
7312 * @return ETrue if a card is present, EFalse otherwise |
6615 */ |
7313 */ |
6616 { |
7314 { |
6617 return(iStack->HasCardsPresent()); |
7315 OstTraceFunctionEntry1( DMMCSOCKET_CARDISPRESENT_ENTRY, this ); |
|
7316 TInt r = iStack->HasCardsPresent(); |
|
7317 OstTraceFunctionExitExt( DMMCSOCKET_CARDISPRESENT_EXIT, this, r ); |
|
7318 return r; |
6618 } |
7319 } |
6619 |
7320 |
6620 void DMMCSocket::AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const |
7321 void DMMCSocket::AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const |
6621 /** |
7322 /** |
6622 * Calculates the minimum range that must be read off a card, an optimisation that takes advantage |
7323 * Calculates the minimum range that must be read off a card, an optimisation that takes advantage |
6640 * allocated for DMA transfers. |
7343 * allocated for DMA transfers. |
6641 * @param aMDBuf A pointer to the allocated buffer |
7344 * @param aMDBuf A pointer to the allocated buffer |
6642 * @param aMDBufLen The length of the allocated buffer |
7345 * @param aMDBufLen The length of the allocated buffer |
6643 */ |
7346 */ |
6644 { |
7347 { |
|
7348 OstTraceFunctionEntryExt( DMMCSOCKET_GETBUFFERINFO_ENTRY, this ); |
6645 iStack->GetBufferInfo(aMDBuf, aMDBufLen); |
7349 iStack->GetBufferInfo(aMDBuf, aMDBufLen); |
|
7350 OstTraceFunctionExit1( DMMCSOCKET_GETBUFFERINFO_EXIT, this ); |
6646 } |
7351 } |
6647 |
7352 |
6648 void DMMCSocket::Reset1() |
7353 void DMMCSocket::Reset1() |
6649 /** |
7354 /** |
6650 * Resets the socket by powering down the stack. |
7355 * Resets the socket by powering down the stack. |
6651 * If there are operations in progress (inCritical), this call will be deferred |
7356 * If there are operations in progress (inCritical), this call will be deferred |
6652 * until the operation is complete. In the case of an emergency power down, |
7357 * until the operation is complete. In the case of an emergency power down, |
6653 * this will occur immediately. |
7358 * this will occur immediately. |
6654 */ |
7359 */ |
6655 { |
7360 { |
|
7361 OstTraceFunctionEntry1( DMMCSOCKET_RESET1_ENTRY, this ); |
6656 if (iState == EPBusCardAbsent) |
7362 if (iState == EPBusCardAbsent) |
6657 { |
7363 { |
6658 // Reset is result of card eject! |
7364 // Reset is result of card eject! |
6659 iStack->iStackState |= KMMCStackStateCardRemoved; |
7365 iStack->iStackState |= KMMCStackStateCardRemoved; |
6660 } |
7366 } |
6661 |
7367 |
6662 |
7368 |
6663 iStack->PowerDownStack(); |
7369 iStack->PowerDownStack(); |
|
7370 OstTraceFunctionExit1( DMMCSOCKET_RESET1_EXIT, this ); |
6664 } |
7371 } |
6665 |
7372 |
6666 void DMMCSocket::Reset2() |
7373 void DMMCSocket::Reset2() |
6667 /** |
7374 /** |
6668 * Resets the socket in response to a PSU fault or media change. |
7375 * Resets the socket in response to a PSU fault or media change. |
6677 /** |
7384 /** |
6678 * Allocates resources and initialises the MMC socket and associated stack object. |
7385 * Allocates resources and initialises the MMC socket and associated stack object. |
6679 * @return KErrNotReady if no stack has been allocated, standard error code otherwise |
7386 * @return KErrNotReady if no stack has been allocated, standard error code otherwise |
6680 */ |
7387 */ |
6681 { |
7388 { |
|
7389 OstTraceFunctionEntry1( DMMCSOCKET_INIT_ENTRY, this ); |
6682 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:Init")); |
7390 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:Init")); |
6683 |
7391 |
6684 GetMachineInfo(); |
7392 GetMachineInfo(); |
6685 |
7393 |
6686 // We need to make sure the stack is initialised, |
7394 // We need to make sure the stack is initialised, |
6687 // as DPBusSocket::Init() will initiate a power up sequence |
7395 // as DPBusSocket::Init() will initiate a power up sequence |
6688 if(iStack == NULL) |
7396 if(iStack == NULL) |
|
7397 { |
|
7398 OstTraceFunctionExitExt( DMMCSOCKET_INIT_EXIT1, this, KErrNotReady ); |
6689 return KErrNotReady; |
7399 return KErrNotReady; |
|
7400 } |
6690 |
7401 |
6691 TInt r = iStack->Init(); |
7402 TInt r = iStack->Init(); |
6692 if (r!=KErrNone) |
7403 if (r!=KErrNone) |
|
7404 { |
|
7405 OstTraceFunctionExitExt( DMMCSOCKET_INIT_EXIT2, this, r ); |
6693 return r; |
7406 return r; |
|
7407 } |
6694 |
7408 |
6695 r = DPBusSocket::Init(); |
7409 r = DPBusSocket::Init(); |
6696 if (r!=KErrNone) |
7410 if (r!=KErrNone) |
|
7411 { |
|
7412 OstTraceFunctionExitExt( DMMCSOCKET_INIT_EXIT3, this, r ); |
6697 return r; |
7413 return r; |
|
7414 } |
6698 |
7415 |
|
7416 OstTraceFunctionExitExt( DMMCSOCKET_INIT_EXIT4, this, KErrNone ); |
6699 return KErrNone; |
7417 return KErrNone; |
6700 } |
7418 } |
6701 |
7419 |
6702 void DMMCSocket::GetMachineInfo() |
7420 void DMMCSocket::GetMachineInfo() |
6703 /** |
7421 /** |
6704 * Gets the platform specific configuration information. |
7422 * Gets the platform specific configuration information. |
6705 * @see TMMCMachineInfo |
7423 * @see TMMCMachineInfo |
6706 */ |
7424 */ |
6707 { |
7425 { |
|
7426 OstTraceFunctionEntry1( DMMCSOCKET_GETMACHINEINFO_ENTRY, this ); |
6708 // Get machine info from the stack |
7427 // Get machine info from the stack |
6709 iStack->MachineInfo(iMachineInfo); |
7428 iStack->MachineInfo(iMachineInfo); |
6710 |
7429 |
6711 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iTotalSockets %u", iMachineInfo.iTotalSockets)); |
7430 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iTotalSockets %u", iMachineInfo.iTotalSockets)); |
6712 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iTotalMediaChanges %u", iMachineInfo.iTotalMediaChanges)); |
7431 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iTotalMediaChanges %u", iMachineInfo.iTotalMediaChanges)); |
6713 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iTotalPrimarySupplies %u", iMachineInfo.iTotalPrimarySupplies)); |
7432 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iTotalPrimarySupplies %u", iMachineInfo.iTotalPrimarySupplies)); |
6714 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iSPIMode %u", iMachineInfo.iSPIMode)); |
7433 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iSPIMode %u", iMachineInfo.iSPIMode)); |
6715 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iBaseBusNumber %u", iMachineInfo.iBaseBusNumber)); |
7434 __KTRACE_OPT(KPBUS1, Kern::Printf(">GetMI : iBaseBusNumber %u", iMachineInfo.iBaseBusNumber)); |
6716 |
7435 OstTraceDefExt5( OST_TRACE_CATEGORY_RND, TRACE_MMCDEBUG, DMMCSOCKET_GETMACHINEINFO, "iTotalSockets=%d; iTotalMediaChanges=%d; iTotalPrimarySupplies=%d; iSPIMode=%d; iBaseBusNumber=%d", iMachineInfo.iTotalSockets, iMachineInfo.iTotalMediaChanges, iMachineInfo.iTotalPrimarySupplies, iMachineInfo.iSPIMode, iMachineInfo.iBaseBusNumber ); |
|
7436 |
|
7437 |
|
7438 OstTraceFunctionExit1( DMMCSOCKET_GETMACHINEINFO_EXIT, this ); |
6717 } |
7439 } |
6718 |
7440 |
6719 |
7441 |
6720 // MMC specific functions |
7442 // MMC specific functions |
6721 |
7443 |
6761 * and therefore if VccQ supply can be turned off. |
7485 * and therefore if VccQ supply can be turned off. |
6762 * |
7486 * |
6763 * @Param aPtr reference to DMMCPsu Object to be acted upon. |
7487 * @Param aPtr reference to DMMCPsu Object to be acted upon. |
6764 */ |
7488 */ |
6765 { |
7489 { |
|
7490 OstTraceFunctionEntry0( DMMCPSU_SLEEPCHECK_ENTRY ); |
6766 DMMCPsu& self = *static_cast<DMMCPsu*>(aPtr); |
7491 DMMCPsu& self = *static_cast<DMMCPsu*>(aPtr); |
6767 |
7492 |
6768 if ( |
7493 if ( |
6769 (self.iNotLockedTimeout&&!self.IsLocked()&&++self.iNotLockedCount>self.iNotLockedTimeout) || |
7494 (self.iNotLockedTimeout&&!self.IsLocked()&&++self.iNotLockedCount>self.iNotLockedTimeout) || |
6770 (self.iInactivityTimeout&&++self.iInactivityCount>self.iInactivityTimeout) |
7495 (self.iInactivityTimeout&&++self.iInactivityCount>self.iInactivityTimeout) |
6771 ) |
7496 ) |
6772 { |
7497 { |
6773 DMMCSocket* socket = static_cast<DMMCSocket*>(self.iSocket); |
7498 DMMCSocket* socket = static_cast<DMMCSocket*>(self.iSocket); |
6774 socket->iStack->QSleepStack(); |
7499 socket->iStack->QSleepStack(); |
6775 } |
7500 } |
|
7501 OstTraceFunctionExit0( DMMCPSU_SLEEPCHECK_EXIT ); |
6776 } |
7502 } |
6777 |
7503 |
6778 EXPORT_C DMMCMediaChange::DMMCMediaChange(TInt aMediaChangeNum) |
7504 EXPORT_C DMMCMediaChange::DMMCMediaChange(TInt aMediaChangeNum) |
6779 /** |
7505 /** |
6780 * Constructor for a DMMCMediaChange object |
7506 * Constructor for a DMMCMediaChange object |
6781 * @param aMediaChangeNum The media change number |
7507 * @param aMediaChangeNum The media change number |
6782 */ |
7508 */ |
6783 : DMediaChangeBase(aMediaChangeNum) |
7509 : DMediaChangeBase(aMediaChangeNum) |
6784 {} |
7510 { |
|
7511 OstTraceFunctionEntryExt( DMMCMEDIACHANGE_DMMCMEDIACHANGE_ENTRY, this ); |
|
7512 } |
6785 |
7513 |
6786 EXPORT_C TInt DMMCMediaChange::Create() |
7514 EXPORT_C TInt DMMCMediaChange::Create() |
6787 /** |
7515 /** |
6788 * Create a DMMCMediaChange object. |
7516 * Create a DMMCMediaChange object. |
6789 * This should be overridden at the variant layer to allow interrupts and |
7517 * This should be overridden at the variant layer to allow interrupts and |
6790 * other variant-specific parameters to be initialised. The base class implementation |
7518 * other variant-specific parameters to be initialised. The base class implementation |
6791 * should be called prior to any variant-specific initialisation. |
7519 * should be called prior to any variant-specific initialisation. |
6792 * @return Standard Symbian OS error code. |
7520 * @return Standard Symbian OS error code. |
6793 */ |
7521 */ |
6794 { |
7522 { |
6795 return DMediaChangeBase::Create(); |
7523 OstTraceFunctionEntry1( DMMCMEDIACHANGE_CREATE_ENTRY, this ); |
6796 } |
7524 TInt r = DMediaChangeBase::Create(); |
6797 |
7525 OstTraceFunctionExitExt( DMMCMEDIACHANGE_CREATE_EXIT, this, r ); |
|
7526 return r; |
|
7527 } |
|
7528 |