author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 200 | 73ea206103e6 |
child 256 | c1f20ce4abcf |
permissions | -rw-r--r-- |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
1 |
// Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "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 |
// SD-specific extensions of generic MMC classes adhering to SD Physical layer simplified spec v2.0 |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
/** |
|
19 |
@file |
|
20 |
@internalComponent |
|
21 |
*/ |
|
22 |
||
23 |
#ifndef __SDCARD_H__ |
|
24 |
#define __SDCARD_H__ |
|
25 |
||
26 |
#include <drivers/mmc.h> |
|
27 |
||
28 |
class DSDStack; |
|
29 |
||
30 |
enum TSDSessionTypeEnum |
|
31 |
{ |
|
32 |
// empty. |
|
33 |
}; |
|
34 |
||
35 |
const TUint KSDMinCustomSession = KMMCMinCustomSession + 1024; |
|
36 |
||
37 |
const TUint32 KSDBusWidth1 = 0x00; |
|
38 |
const TUint32 KSDBusWidth4 = 0x02; |
|
39 |
const TUint32 KSDStatusBlockLength = 0x40; |
|
40 |
||
41 |
const TUint32 KSDSCRLength = 0x08; |
|
42 |
const TUint32 KSDSwitchFuncLength = 0x40; |
|
43 |
const TUint32 KSDCheckFunctionHighSpeed = 0x00FFFF01; |
|
44 |
const TUint32 KSDSwitchFunctionHighSpeed = 0x80FFFF01; |
|
45 |
||
46 |
const TUint32 KSDCardIsSDCard = KBit16; // KMMCardFirstCustomFlag |
|
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
47 |
const TUint32 KSDCardIsCorrupt = KBit17; |
0 | 48 |
const TUint32 KSDCardFirstCustomFlag = KBit24; |
49 |
||
50 |
const TUint KSDDTClk25MHz = 25000; //25000KHz |
|
51 |
const TUint KSDDTClk50MHz = 50000; //50000KHz |
|
52 |
||
53 |
class TSDCSD : public TCSD |
|
54 |
{ |
|
55 |
public: |
|
56 |
inline TSDCSD(const TCSD& aCSD); |
|
57 |
||
58 |
inline TBool SDEraseBlkEn() const; |
|
59 |
inline TBool SDSectorSize() const; |
|
60 |
inline TBool SDWPGrpSize() const; |
|
61 |
}; |
|
62 |
||
63 |
class TSDCard : public TMMCard |
|
64 |
{ |
|
65 |
public: |
|
66 |
TSDCard(); |
|
67 |
inline TBool IsSDCard() const; |
|
68 |
inline TUint32 ProtectedAreaSize() const; |
|
69 |
inline void SetProtectedAreaSize(TUint32 aPAS); |
|
70 |
inline TUint8 GetAUSize() const; |
|
71 |
inline void SetAUSize(TUint8 aAU); |
|
72 |
inline TInt DeviceSize() const; |
|
73 |
virtual TUint32 PreferredWriteGroupLength() const; |
|
74 |
virtual TInt GetFormatInfo(TLDFormatInfo& aFormatInfo) const; |
|
75 |
virtual TUint32 MinEraseSectorSize() const; |
|
76 |
virtual TUint32 EraseSectorSize() const; |
|
77 |
virtual TInt GetEraseInfo(TMMCEraseInfo& anEraseInfo) const; |
|
78 |
virtual TInt MaxReadBlLen() const; |
|
79 |
virtual TInt MaxWriteBlLen() const; |
|
80 |
virtual TInt64 DeviceSize64() const; |
|
81 |
enum {KPARootDirEndUnknown = 0}; |
|
82 |
inline TUint32 PARootDirEnd() const; |
|
83 |
inline void SetPARootDirEnd(TUint32 aPARootDirEnd); |
|
84 |
virtual TUint MaxTranSpeedInKilohertz() const; |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
85 |
inline void RegisterClient(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
86 |
inline void DeregisterClient(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
87 |
inline TBool ClientsRegistered(); |
0 | 88 |
private: |
89 |
TUint32 iProtectedAreaSize; |
|
90 |
TUint32 iPARootDirEnd; |
|
91 |
TUint8 iAUSize; |
|
92 |
TUint8 iPad[3]; |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
93 |
TUint32 iClientCountSD; |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
94 |
TUint32 iSpare[3]; |
0 | 95 |
}; |
96 |
||
97 |
class TSDCardArray : public TMMCardArray |
|
98 |
{ |
|
99 |
public: |
|
100 |
inline TSDCardArray(DSDStack* aOwningStack); |
|
101 |
IMPORT_C virtual TInt AllocCards(); |
|
102 |
||
103 |
inline TSDCard& Card(TUint aCardNumber) const; |
|
104 |
inline TSDCard& NewCard(TUint aCardNumber) const; |
|
105 |
void AddCardSDMode(TUint aCardNumber,const TUint8* aCID,TRCA* aNewRCA); |
|
106 |
TInt StoreRCAIfUnique(TUint aCardNumber,TRCA& anRCA); |
|
107 |
IMPORT_C virtual void DeclareCardAsGone(TUint aCardNumber); |
|
108 |
}; |
|
109 |
||
110 |
enum TSDAppCmd |
|
111 |
{ |
|
112 |
ESDACmdSetBusWidth = 6, |
|
113 |
ESDACmdSDStatus = 13, |
|
114 |
ESDACmdSendNumWrBlocks = 22, |
|
115 |
ESDACmdSetWrBlkEraseCount = 23, |
|
116 |
ESDACmdSDAppOpCond = 41, |
|
117 |
ESDACmdSetClrCardDetect = 42, |
|
118 |
ESDACmdSendSCR = 51 |
|
119 |
}; |
|
120 |
||
121 |
enum TSDSpecificCmd |
|
122 |
{ |
|
123 |
ESDCmdSendRelativeAddress = 3, |
|
124 |
ESDCmdSwitchFunction = 6, |
|
125 |
ESDCmdSendIfCond = 8 |
|
126 |
}; |
|
127 |
||
128 |
class DSDSession : public DMMCSession |
|
129 |
{ |
|
130 |
public: |
|
131 |
inline DSDSession(const TMMCCallBack& aCallBack); |
|
132 |
||
133 |
static void FillAppCommandDesc(TMMCCommandDesc& aDesc, TSDAppCmd aCmd); |
|
134 |
static void FillAppCommandDesc(TMMCCommandDesc& aDesc, TSDAppCmd aCmd, TMMCArgument aArg); |
|
135 |
||
136 |
static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc, TSDSpecificCmd aCmd); |
|
137 |
static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc, TSDSpecificCmd aCmd, TMMCArgument aArg); |
|
138 |
||
139 |
protected: |
|
140 |
// not implemented. No SD specific macros |
|
141 |
// virtual TMMCSMSTFunc GetMacro(TInt aSessNum) const; |
|
142 |
||
143 |
private: |
|
144 |
static void FillAppCommandDesc(TMMCCommandDesc& aDesc); |
|
145 |
static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc); |
|
146 |
}; |
|
147 |
||
148 |
const TInt KSDMaxMBWRetries = 1; |
|
149 |
const TUint32 KSDACMD22BlockLen = 4; |
|
150 |
class DSDStack : public DMMCStack |
|
151 |
{ |
|
152 |
public: |
|
153 |
inline DSDStack(TInt aBus, DMMCSocket* aSocket); |
|
154 |
||
155 |
IMPORT_C virtual TInt Init(); |
|
156 |
IMPORT_C virtual TMMCErr AcquireStackSM(); |
|
157 |
IMPORT_C virtual TMMCErr CIMReadWriteBlocksSM(); |
|
158 |
IMPORT_C virtual DMMCSession* AllocSession(const TMMCCallBack& aCallBack) const; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
|
0 | 160 |
virtual void AddressCard(TInt aCardNumber) = 0; |
161 |
||
162 |
inline TSDCardArray& CardArray() const; |
|
163 |
||
164 |
protected: |
|
165 |
IMPORT_C virtual TMMCErr InitStackAfterUnlockSM(); |
|
166 |
||
167 |
static TMMCErr InitialiseMemoryCardSMST(TAny* aStackP); |
|
168 |
TMMCErr InitialiseMemoryCardSM(); |
|
169 |
||
170 |
static TMMCErr ConfigureMemoryCardSMST(TAny* aStackP); |
|
171 |
TMMCErr ConfigureMemoryCardSM(); |
|
172 |
||
173 |
static TMMCErr CIMReadWriteMemoryBlocksSMST(TAny* aStackP); |
|
174 |
||
175 |
static TMMCErr BaseModifyCardCapabilitySMST(TAny* aStackP); |
|
176 |
IMPORT_C virtual TMMCErr ModifyCardCapabilitySM(); |
|
177 |
||
178 |
static TMMCErr SwitchToHighSpeedModeSMST(TAny* aStackP); |
|
179 |
TMMCErr SwitchToHighSpeedModeSM(); |
|
180 |
||
181 |
private: |
|
182 |
TInt iSpare; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
183 |
protected: |
0 | 184 |
enum TSDCardType {ESDCardTypeUnknown, ESDCardTypeIsMMC, ESDCardTypeIsSD}; |
185 |
TSDCardType iCxCardType; // Used when detecting whether an SD Memory card is present. |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
private: |
0 | 187 |
TUint8 iACMD22[KSDACMD22BlockLen]; |
188 |
||
189 |
private: |
|
190 |
// |
|
191 |
// Dummy functions to maintain binary compatibility |
|
192 |
IMPORT_C virtual void Dummy1(); |
|
193 |
IMPORT_C virtual void Dummy2(); |
|
194 |
IMPORT_C virtual void Dummy3(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
IMPORT_C virtual DSDStack::TSDCardType CardType(TInt aSocket, TInt aCardNumber); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
198 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
private: |
0 | 200 |
// |
201 |
// Reserved members to maintain binary compatibility |
|
202 |
TInt iReserved[68]; |
|
203 |
}; |
|
204 |
||
205 |
#include <drivers/sdcard.inl> |
|
206 |
||
207 |
#endif // #ifndef __SDCARD_H__ |