sl@0
|
1 |
// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// PP_MMC.H
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#ifndef __PP_MMC_H__
|
sl@0
|
19 |
|
sl@0
|
20 |
#if defined(_UNICODE) && !defined(UNICODE)
|
sl@0
|
21 |
#define UNICODE
|
sl@0
|
22 |
#endif
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <mmc.h>
|
sl@0
|
25 |
#include <emulator.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
// MultiMedia Card Controller - platform specific layer.
|
sl@0
|
28 |
|
sl@0
|
29 |
GLREF_C TInt MapLastErrorEpoc();
|
sl@0
|
30 |
GLREF_C TMMCErr MapLastErrorMmc();
|
sl@0
|
31 |
|
sl@0
|
32 |
const TInt KMediaChangeTickInterval=20000; // Units 1uS
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
const TInt KMax_TotalWinsCardSlots=8; ///< Maximal number of MMC cards supported by the emulator
|
sl@0
|
36 |
const TInt KMax_TotalWinsCards=(KMax_TotalWinsCardSlots+1); ///< Maximal number of MMC slots, supported by the emulator. Need 2 cards for slot 0
|
sl@0
|
37 |
|
sl@0
|
38 |
const TInt KDefault_TotalWinsCardSlots=2; ///< Default number of MMC cards supported by the emulator
|
sl@0
|
39 |
const TInt KDefault_TotalWinsCards=(KDefault_TotalWinsCardSlots+1); ///< Default number of MMC slots, supported by the emulator. Need 2 cards for slot 0
|
sl@0
|
40 |
|
sl@0
|
41 |
|
sl@0
|
42 |
const TUint32 KMMCWinsCardOCRValue = 0x00FFFF00;
|
sl@0
|
43 |
|
sl@0
|
44 |
class TWinsCardInfo
|
sl@0
|
45 |
{
|
sl@0
|
46 |
public:
|
sl@0
|
47 |
void GetCSD(TUint8* aResp) const;
|
sl@0
|
48 |
public:
|
sl@0
|
49 |
TCID iCID;
|
sl@0
|
50 |
TMediaPassword* iPWD; // PWD_LEN calculated from PWD.
|
sl@0
|
51 |
TBool iIsLocked; // Could use iCurrentCardIsLocked
|
sl@0
|
52 |
TMMCardStateEnum iState; // Simulation of card's current state
|
sl@0
|
53 |
HANDLE iWinHandle;
|
sl@0
|
54 |
TRCA iRCA;
|
sl@0
|
55 |
};
|
sl@0
|
56 |
|
sl@0
|
57 |
class DWinsMMCStack : public DMMCStack
|
sl@0
|
58 |
{
|
sl@0
|
59 |
private:
|
sl@0
|
60 |
DWinsMMCStack(TInt aBus, DMMCSocket* aSocket);
|
sl@0
|
61 |
TInt Init();
|
sl@0
|
62 |
private:
|
sl@0
|
63 |
virtual void MachineInfo(TMMCMachineInfo& aMachineInfo);
|
sl@0
|
64 |
public:
|
sl@0
|
65 |
virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const;
|
sl@0
|
66 |
virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen);
|
sl@0
|
67 |
|
sl@0
|
68 |
enum TWinsMMCPanic
|
sl@0
|
69 |
{
|
sl@0
|
70 |
EWinsMMCLidOpenIntBind=0,
|
sl@0
|
71 |
EWinsMMCBadMachineInfo=1,
|
sl@0
|
72 |
EWinsMMCMediaChangeTickFault = 2,
|
sl@0
|
73 |
EWinsMMCCorruptCommand = 3,
|
sl@0
|
74 |
EWinsMMCLockAttempt = 4,
|
sl@0
|
75 |
EWinsMMCAPRNotSupp = 5,
|
sl@0
|
76 |
EWinsMMCAPRRange = 6,
|
sl@0
|
77 |
EWinsMMCAPRBoundary = 7,
|
sl@0
|
78 |
|
sl@0
|
79 |
EStkFFCNotSelCard = 0x010, EStkFFCNoneSel,
|
sl@0
|
80 |
EStkFOCNotSelCard = 0x011, EStkFOCMultiSel, EStkFOCNoneSel
|
sl@0
|
81 |
};
|
sl@0
|
82 |
|
sl@0
|
83 |
static TInt TotalMDiskSize; // mmc card size for emulator
|
sl@0
|
84 |
static TUint CSIZE; // mmc card size field
|
sl@0
|
85 |
static TUint CSIZE_MULT; // mmc card size field
|
sl@0
|
86 |
|
sl@0
|
87 |
static TInt TotalWinsMMC_CardSlots; // total number of MMC card slots for the emulator
|
sl@0
|
88 |
static TInt TotalWinsMMC_Cards; // total number of MMC cards for the emulator
|
sl@0
|
89 |
|
sl@0
|
90 |
static void Panic(TWinsMMCPanic aPanic);
|
sl@0
|
91 |
|
sl@0
|
92 |
private:
|
sl@0
|
93 |
TUint8* iMDBuf;
|
sl@0
|
94 |
TInt iMDBufLen;
|
sl@0
|
95 |
|
sl@0
|
96 |
private:
|
sl@0
|
97 |
// Stack service provided by ASSP layer
|
sl@0
|
98 |
void SetBusConfigDefaults(TMMCBusConfig&, TUint aClock);
|
sl@0
|
99 |
void InitClockOff();
|
sl@0
|
100 |
void ASSPReset();
|
sl@0
|
101 |
void ASSPDisengage();
|
sl@0
|
102 |
void DoPowerDown();
|
sl@0
|
103 |
// State Machine functions implemented in ASSP layer
|
sl@0
|
104 |
TMMCErr DoPowerUpSM();
|
sl@0
|
105 |
TMMCErr InitClockOnSM();
|
sl@0
|
106 |
TMMCErr IssueMMCCommandSM();
|
sl@0
|
107 |
TMMCErr ModifyCardCapabilitySM();
|
sl@0
|
108 |
private:
|
sl@0
|
109 |
TInt SetupSimulatedCard(TInt aCardNum); // init
|
sl@0
|
110 |
TInt CreateBinFileForCard(TInt aCardNum, HANDLE* aHandle, TBool aCreateNew = EFalse);
|
sl@0
|
111 |
TInt GetTargetSlotNumber(TBool anRCASupplied, const TRCA& anRCA);
|
sl@0
|
112 |
TInt FindAnyCardInStack(TMMCardStateEnum aState);
|
sl@0
|
113 |
TInt FindFirstCardInStack(TMMCardStateEnum aState);
|
sl@0
|
114 |
TInt FindOneCardInStack(TMMCardStateEnum aState);
|
sl@0
|
115 |
void SetupDiskParms(TUint);
|
sl@0
|
116 |
TMMCErr ReadWriteData(TInt aCardIdx, TUint8* aDataP, TUint32 aLength, TMMCCmdDirEnum aDir);
|
sl@0
|
117 |
private:
|
sl@0
|
118 |
TWinsCardInfo* iCardPool[KMax_TotalWinsCards]; // All the cards created
|
sl@0
|
119 |
TWinsCardInfo* iCardInfo[KMax_TotalWinsCardSlots]; // Cards currently present (1 per slot)
|
sl@0
|
120 |
TBool iCMD42Failed;
|
sl@0
|
121 |
TUint32 iBytesToTransfer;
|
sl@0
|
122 |
friend class DWinsMMCMediaChange;
|
sl@0
|
123 |
friend class TMMCardControllerInterfaceWins;
|
sl@0
|
124 |
};
|
sl@0
|
125 |
|
sl@0
|
126 |
class DWinsMMCStack;
|
sl@0
|
127 |
class DWinsMMCMediaChange : public DMMCMediaChange
|
sl@0
|
128 |
{
|
sl@0
|
129 |
public:
|
sl@0
|
130 |
DWinsMMCMediaChange(TInt aMediaChangeNum);
|
sl@0
|
131 |
virtual TInt Create();
|
sl@0
|
132 |
virtual void ForceMediaChange();
|
sl@0
|
133 |
virtual void DoDoorOpen();
|
sl@0
|
134 |
virtual void DoDoorClosed();
|
sl@0
|
135 |
virtual TMediaState MediaState();
|
sl@0
|
136 |
inline void SetStackP(DWinsMMCStack* aStackP) {iStackP=aStackP;}
|
sl@0
|
137 |
protected:
|
sl@0
|
138 |
void DoorOpenService();
|
sl@0
|
139 |
private:
|
sl@0
|
140 |
static void Tick(TAny *aPtr);
|
sl@0
|
141 |
void TickService();
|
sl@0
|
142 |
void Enable();
|
sl@0
|
143 |
void Disable();
|
sl@0
|
144 |
static void MediaChangeCallBack(TAny *aPtr);
|
sl@0
|
145 |
static void MediaChangeDFC(TAny* aPtr);
|
sl@0
|
146 |
private:
|
sl@0
|
147 |
TTickLink iTickLink;
|
sl@0
|
148 |
TInt iDoorClosedCount;
|
sl@0
|
149 |
TBool iMediaChangeEnable;
|
sl@0
|
150 |
TInt iMediaDoorCloseReload; // Units: In theory-20ms, Actual-100ms
|
sl@0
|
151 |
DWinsMMCStack* iStackP;
|
sl@0
|
152 |
friend class DWinsMMCStack;
|
sl@0
|
153 |
};
|
sl@0
|
154 |
|
sl@0
|
155 |
class DWinsMMCPsu : public DMMCPsu
|
sl@0
|
156 |
{
|
sl@0
|
157 |
public:
|
sl@0
|
158 |
DWinsMMCPsu(TInt aVccNum, TInt aMcId);
|
sl@0
|
159 |
virtual TInt DoCreate();
|
sl@0
|
160 |
virtual void DoSetState(TPBusPsuState aState);
|
sl@0
|
161 |
virtual TInt VoltageInMilliVolts();
|
sl@0
|
162 |
private:
|
sl@0
|
163 |
virtual void DoCheckVoltage();
|
sl@0
|
164 |
virtual void PsuInfo(TPBusPsuInfo &anInfo);
|
sl@0
|
165 |
};
|
sl@0
|
166 |
|
sl@0
|
167 |
#endif // #ifndef __PP_MMC_H__
|