os/boardsupport/emulator/emulatorbsp/specific/sdcard/sdcard3c/pp_sdc.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __PP_SDC_H__
    17 #define __PP_SDC_H__
    18 #if defined(_UNICODE) && !defined(UNICODE)
    19 	#define UNICODE
    20 #endif
    21 
    22 #include <sdcard.h>
    23 #include <emulator.h>
    24 
    25 GLREF_C TInt MapLastErrorEpoc();
    26 GLREF_C TMMCErr MapLastErrorMmc();
    27 
    28 const TInt KMediaChangeTickInterval=20000;	// Units 1uS
    29 
    30 const TInt KTotalWinsCardSlots=2;
    31 const TInt KTotalWinsCards=(KTotalWinsCardSlots+1); // Need 2 cards for slot 0
    32 
    33 const TUint32 KMMCWinsCardOCRValue = 0x00FFFF00;
    34 
    35 const TInt KSDMediaAreasPerCard = 2;
    36 const TInt KSDUserArea = 0;
    37 const TInt KSDProtectedArea = 1;
    38 
    39 class TWinsCardInfo
    40 	{
    41 public:
    42 	void GetCSD(TUint8* aResp) const;
    43 public:
    44 	TCID iCID;
    45 	TMediaPassword* iPWD;				// PWD_LEN calculated from PWD.
    46 	TBool iIsLocked;					// Could use iCurrentCardIsLocked
    47 	TMMCardStateEnum iState;			// Simulation of card's current state
    48 	HANDLE iAreaHandles[KSDMediaAreasPerCard];
    49 	TRCA iRCA;
    50 	TBool iIsSDCard;
    51 	TInt iBusWidth;
    52 	};
    53 
    54 class DWinsSDStack : public DSDStack
    55 	{
    56 private:
    57 	DWinsSDStack(TInt aBus, DMMCSocket* aSocket);
    58 	TInt Init();
    59 private:
    60 	virtual void MachineInfo(TMMCMachineInfo& aMachineInfo);
    61 public:
    62 	virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const;
    63 	virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen);
    64 	virtual void AddressCard(TInt aCardNumber);
    65 
    66 	enum TWinsMMCPanic
    67 		{
    68 	    EWinsMMCLidOpenIntBind=0,
    69 		EWinsMMCBadMachineInfo=1,
    70 		EWinsMMCMediaChangeTickFault = 2,
    71 		EWinsMMCCorruptCommand = 3,
    72 		EWinsMMCLockAttempt = 4,
    73 		EWinsMMCAPRNotSupp = 5,
    74 		EWinsMMCAPRRange = 6,
    75 		EWinsMMCAPRBoundary = 7,
    76 
    77 		EStkFFCNotSelCard = 0x010, EStkFFCNoneSel,
    78 		EStkFOCNotSelCard = 0x020, EStkFOCMultiSel, EStkFOCNoneSel,
    79 		EStkIMCBadStateCmd2 = 0x30, EStkIMCBadStateCmd3, EStkIMCCmd6InvalidWidth,
    80 			EStkICMACMD13NotSD, EStkICMACMD22NotSD,
    81 		};
    82     static void Panic(TWinsMMCPanic aPanic);
    83 
    84 private:
    85 	// Stack service provided by ASSP layer
    86 	void SetBusConfigDefaults(TMMCBusConfig&, TUint aClock);
    87 	void InitClockOff();
    88 	void ASSPReset();
    89 	void ASSPDisengage();
    90 	void DoPowerDown();
    91 	// State Machine functions implemented in ASSP layer
    92 	TMMCErr DoPowerUpSM();
    93 	TMMCErr InitClockOnSM();
    94 	TMMCErr IssueMMCCommandSM();
    95     TMMCErr ModifyCardCapabilitySM();
    96 private:
    97 	TInt SetupSimulatedCard(TInt aCardNum);						// init
    98 	TInt CreateBinFileForCard(TInt aCardNum, TInt aAreaNum, HANDLE* aHandle);
    99 	TInt GetTargetSlotNumber(const TRCA& anRCA);
   100 	TInt FindAnyCardInStack(TMMCardStateEnum aState);
   101 	TInt FindFirstCardInStack(TMMCardStateEnum aState);
   102 	TInt FindOneCardInStack(TMMCardStateEnum aState);
   103 private:
   104 	TWinsCardInfo* iCardPool[KTotalWinsCards];		// all cards
   105 	TWinsCardInfo* iCardInfo[KTotalWinsCardSlots];		// present cards
   106 	TInt iAddressedCard;
   107 	TBool iCMD42Failed;
   108 	TInt iMBWOKBlocks;
   109 	TUint8* iMDBuf;
   110 	TInt iMDBufLen;
   111 
   112 	friend class TSDCardControllerInterfaceWins;
   113 	friend class DWinsMMCMediaChange;
   114 	};
   115 
   116 class DWinsMMCMediaChange : public DMMCMediaChange
   117 	{
   118 public:
   119 	DWinsMMCMediaChange(TInt aMediaChangeNum);
   120 	virtual TInt Create();
   121 	virtual void ForceMediaChange();
   122 	virtual void DoDoorOpen();
   123 	virtual void DoDoorClosed();
   124 	virtual TMediaState MediaState();
   125 protected:
   126     void DoorOpenService();
   127 private:
   128 	static TInt MediaChangeDfc(TAny *aPtr);
   129 	static void Tick(TAny *aPtr);
   130 	void TickService();
   131 	void Enable();
   132 	void Disable();
   133 	static void MediaChangeCallBack(TAny *aPtr);
   134 	inline void SetStackP(DWinsSDStack* aStackP) {iStackP=aStackP;}	
   135 private:
   136 	TTickLink iTickLink;
   137 	TInt iDoorClosedCount;
   138 	TBool iMediaChangeEnable;
   139 	TInt iMediaDoorCloseReload; 	// Units: In theory-20ms, Actual-100ms  
   140 	DWinsSDStack* iStackP;
   141 	friend class DWinsSDStack;
   142 	};
   143 
   144 class DWinsMMCPsu : public DMMCPsu 
   145     {
   146 public:
   147     DWinsMMCPsu(TInt aVccNum, TInt aMcId);
   148     virtual void Init();
   149 	virtual void DoSetState(TPBusPsuState aState);
   150 	virtual TInt VoltageInMilliVolts();
   151 private:
   152 	virtual void DoCheckVoltage();
   153     virtual void PsuInfo(TPBusPsuInfo &anInfo);
   154     };
   155 
   156 
   157 #endif	// #ifndef __PP_SDC_H__