First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 #if defined(_UNICODE) && !defined(UNICODE)
27 // MultiMedia Card Controller - platform specific layer.
29 GLREF_C TInt MapLastErrorEpoc();
30 GLREF_C TMMCErr MapLastErrorMmc();
32 const TInt KMediaChangeTickInterval=20000; // Units 1uS
35 const TInt KMax_TotalWinsCardSlots=8; ///< Maximal number of MMC cards supported by the emulator
36 const TInt KMax_TotalWinsCards=(KMax_TotalWinsCardSlots+1); ///< Maximal number of MMC slots, supported by the emulator. Need 2 cards for slot 0
38 const TInt KDefault_TotalWinsCardSlots=2; ///< Default number of MMC cards supported by the emulator
39 const TInt KDefault_TotalWinsCards=(KDefault_TotalWinsCardSlots+1); ///< Default number of MMC slots, supported by the emulator. Need 2 cards for slot 0
42 const TUint32 KMMCWinsCardOCRValue = 0x00FFFF00;
47 void GetCSD(TUint8* aResp) const;
50 TMediaPassword* iPWD; // PWD_LEN calculated from PWD.
51 TBool iIsLocked; // Could use iCurrentCardIsLocked
52 TMMCardStateEnum iState; // Simulation of card's current state
57 class DWinsMMCStack : public DMMCStack
60 DWinsMMCStack(TInt aBus, DMMCSocket* aSocket);
63 virtual void MachineInfo(TMMCMachineInfo& aMachineInfo);
65 virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const;
66 virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen);
70 EWinsMMCLidOpenIntBind=0,
71 EWinsMMCBadMachineInfo=1,
72 EWinsMMCMediaChangeTickFault = 2,
73 EWinsMMCCorruptCommand = 3,
74 EWinsMMCLockAttempt = 4,
75 EWinsMMCAPRNotSupp = 5,
77 EWinsMMCAPRBoundary = 7,
79 EStkFFCNotSelCard = 0x010, EStkFFCNoneSel,
80 EStkFOCNotSelCard = 0x011, EStkFOCMultiSel, EStkFOCNoneSel
83 static TInt TotalMDiskSize; // mmc card size for emulator
84 static TUint CSIZE; // mmc card size field
85 static TUint CSIZE_MULT; // mmc card size field
87 static TInt TotalWinsMMC_CardSlots; // total number of MMC card slots for the emulator
88 static TInt TotalWinsMMC_Cards; // total number of MMC cards for the emulator
90 static void Panic(TWinsMMCPanic aPanic);
97 // Stack service provided by ASSP layer
98 void SetBusConfigDefaults(TMMCBusConfig&, TUint aClock);
101 void ASSPDisengage();
103 // State Machine functions implemented in ASSP layer
104 TMMCErr DoPowerUpSM();
105 TMMCErr InitClockOnSM();
106 TMMCErr IssueMMCCommandSM();
107 TMMCErr ModifyCardCapabilitySM();
109 TInt SetupSimulatedCard(TInt aCardNum); // init
110 TInt CreateBinFileForCard(TInt aCardNum, HANDLE* aHandle, TBool aCreateNew = EFalse);
111 TInt GetTargetSlotNumber(TBool anRCASupplied, const TRCA& anRCA);
112 TInt FindAnyCardInStack(TMMCardStateEnum aState);
113 TInt FindFirstCardInStack(TMMCardStateEnum aState);
114 TInt FindOneCardInStack(TMMCardStateEnum aState);
115 void SetupDiskParms(TUint);
116 TMMCErr ReadWriteData(TInt aCardIdx, TUint8* aDataP, TUint32 aLength, TMMCCmdDirEnum aDir);
118 TWinsCardInfo* iCardPool[KMax_TotalWinsCards]; // All the cards created
119 TWinsCardInfo* iCardInfo[KMax_TotalWinsCardSlots]; // Cards currently present (1 per slot)
121 TUint32 iBytesToTransfer;
122 friend class DWinsMMCMediaChange;
123 friend class TMMCardControllerInterfaceWins;
127 class DWinsMMCMediaChange : public DMMCMediaChange
130 DWinsMMCMediaChange(TInt aMediaChangeNum);
131 virtual TInt Create();
132 virtual void ForceMediaChange();
133 virtual void DoDoorOpen();
134 virtual void DoDoorClosed();
135 virtual TMediaState MediaState();
136 inline void SetStackP(DWinsMMCStack* aStackP) {iStackP=aStackP;}
138 void DoorOpenService();
140 static void Tick(TAny *aPtr);
144 static void MediaChangeCallBack(TAny *aPtr);
145 static void MediaChangeDFC(TAny* aPtr);
148 TInt iDoorClosedCount;
149 TBool iMediaChangeEnable;
150 TInt iMediaDoorCloseReload; // Units: In theory-20ms, Actual-100ms
151 DWinsMMCStack* iStackP;
152 friend class DWinsMMCStack;
155 class DWinsMMCPsu : public DMMCPsu
158 DWinsMMCPsu(TInt aVccNum, TInt aMcId);
159 virtual TInt DoCreate();
160 virtual void DoSetState(TPBusPsuState aState);
161 virtual TInt VoltageInMilliVolts();
163 virtual void DoCheckVoltage();
164 virtual void PsuInfo(TPBusPsuInfo &anInfo);
167 #endif // #ifndef __PP_MMC_H__