0
|
1 |
// Copyright (c) 2003-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 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 |
//
|
|
15 |
|
|
16 |
#include <drivers/sdio/cisreader.h>
|
|
17 |
#include <drivers/sdio/sdiocard.h>
|
|
18 |
#include <drivers/sdio/regifc.h>
|
|
19 |
#include "utraceepbussdio.h"
|
|
20 |
|
|
21 |
TInt TCisReader::ParseConfigTuple(TDes8 &configTpl,TSDIOCardConfig &anInfo)
|
|
22 |
/**
|
|
23 |
Parse a KSdioCisTplConfig tuple.
|
|
24 |
*/
|
|
25 |
{
|
|
26 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "CisReader:ParseConfigTuple")); // @SymTraceDataInternalTechnology
|
|
27 |
|
|
28 |
anInfo.iManufacturerID = 0;
|
|
29 |
anInfo.iCardID = 0;
|
|
30 |
|
|
31 |
anInfo.iManufacturerID = (TUint16)((configTpl[KSdioManfIdOffManfIdHi] << 8) | configTpl[KSdioManfIdOffManfIdLo]);
|
|
32 |
anInfo.iCardID = (TUint16)((configTpl[KSdioManfIdOffCardIdHi] << 8) | configTpl[KSdioManfIdOffCardIdLo]);
|
|
33 |
|
|
34 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iManufacturerID = 0x%04x", anInfo.iFn0MaxBlockSize)); // @SymTraceDataInternalTechnology
|
|
35 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iCardID = 0x%04x", anInfo.iMaxTranSpeed)); // @SymTraceDataInternalTechnology
|
|
36 |
|
|
37 |
return(KErrNone);
|
|
38 |
}
|
|
39 |
|
|
40 |
TInt TCisReader::ParseExtensionTupleCommon(TDes8 &configTpl,TSDIOCardConfig &anInfo)
|
|
41 |
/**
|
|
42 |
Parse an extension tuple (common)
|
|
43 |
*/
|
|
44 |
{
|
|
45 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "CisReader:ParseExtensionTupleCommon")); // @SymTraceDataInternalTechnology
|
|
46 |
|
|
47 |
if(configTpl[KSdioExtOffIdent] != KSdioExtCmnIdent)
|
|
48 |
return KErrCorrupt;
|
|
49 |
|
|
50 |
anInfo.iFn0MaxBlockSize = (TUint16)((configTpl[KSdioExtCmnOffFn0MBSHi] << 8) | configTpl[KSdioExtCmnOffFn0MBSLo]);
|
|
51 |
anInfo.iMaxTranSpeed = configTpl[KSdioExtCmnOffMaxTranSpeed];
|
|
52 |
|
|
53 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iFn0MaxBlockSize = 0x%04x", anInfo.iFn0MaxBlockSize)); // @SymTraceDataInternalTechnology
|
|
54 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iMaxTranSpeed = 0x%02x", anInfo.iMaxTranSpeed)); // @SymTraceDataInternalTechnology
|
|
55 |
|
|
56 |
return(KErrNone);
|
|
57 |
}
|
|
58 |
|
|
59 |
TInt TCisReader::ParseExtensionTupleFunction(TDes8 &configTpl,TSDIOFunctionCaps& aCaps)
|
|
60 |
/**
|
|
61 |
Parse an extension tuple (function)
|
|
62 |
*/
|
|
63 |
{
|
|
64 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "CisReader:ParseExtensionTupleFunction")); // @SymTraceDataInternalTechnology
|
|
65 |
|
|
66 |
if(configTpl[KSdioExtOffIdent] != KSdioExtFuncIdent)
|
|
67 |
return KErrCorrupt;
|
|
68 |
|
|
69 |
if(configTpl.Length() < KSdioCisTplExtFuncLen1_0)
|
|
70 |
return KErrCorrupt;
|
|
71 |
|
|
72 |
aCaps.iFunctionInfo = configTpl[KSdioExtFuncOffFuncInfo];
|
|
73 |
aCaps.iRevision = configTpl[KSdioExtFuncOffRevision];
|
|
74 |
|
|
75 |
aCaps.iSerialNumber = (configTpl[KSdioExtFuncOffSerialNo3] << 24) | (configTpl[KSdioExtFuncOffSerialNo2] << 16) |
|
|
76 |
(configTpl[KSdioExtFuncOffSerialNo1] << 8) | configTpl[KSdioExtFuncOffSerialNo0];
|
|
77 |
|
|
78 |
aCaps.iCSASize = (configTpl[KSdioExtFuncOffCSASize3] << 24) | (configTpl[KSdioExtFuncOffCSASize2] << 16) |
|
|
79 |
(configTpl[KSdioExtFuncOffCSASize1] << 8) | configTpl[KSdioExtFuncOffCSASize0];
|
|
80 |
|
|
81 |
aCaps.iCSAProperties = configTpl[KSdioExtFuncOffCSAProps];
|
|
82 |
|
|
83 |
aCaps.iMaxBlockSize = (TUint16)((configTpl[KSdioExtFuncOffMaxBlkSzHi] << 8) | configTpl[KSdioExtFuncOffMaxBlkSzLo]);
|
|
84 |
|
|
85 |
aCaps.iOCR = (configTpl[KSdioExtFuncOffOCR3] << 24) | (configTpl[KSdioExtFuncOffOCR2] << 16) |
|
|
86 |
(configTpl[KSdioExtFuncOffOCR1] << 8) | configTpl[KSdioExtFuncOffOCR0];
|
|
87 |
|
|
88 |
aCaps.iMinPwrOp = configTpl[KSdioExtFuncOffMinPwrOp];
|
|
89 |
aCaps.iAvePwrOp = configTpl[KSdioExtFuncOffAvePwrOp];
|
|
90 |
aCaps.iMaxPwrOp = configTpl[KSdioExtFuncOffMaxPwrOp];
|
|
91 |
aCaps.iMinPwrStby = configTpl[KSdioExtFuncOffMinPwrStby];
|
|
92 |
aCaps.iAvePwrStby = configTpl[KSdioExtFuncOffAvePwrStby];
|
|
93 |
aCaps.iMaxPwrStby = configTpl[KSdioExtFuncOffMaxPwrStby];
|
|
94 |
|
|
95 |
aCaps.iMinBandwidth = (TUint16)((configTpl[KSdioExtFuncOffMinBwHi] << 8) | configTpl[KSdioExtFuncOffMinBwLo]);
|
|
96 |
aCaps.iOptBandwidth = (TUint16)((configTpl[KSdioExtFuncOffOptBwHi] << 8) | configTpl[KSdioExtFuncOffOptBwLo]);
|
|
97 |
|
|
98 |
// The following values were added in SDIO Rev 1.1
|
|
99 |
if(configTpl.Length() > KSdioCisTplExtFuncLen1_0 && configTpl.Length() >= KSdioCisTplExtFuncLen1_1)
|
|
100 |
{
|
|
101 |
aCaps.iEnableTimeout = (TUint16)((configTpl[KSdioExtFuncOffEnableToHi] << 8) | configTpl[KSdioExtFuncOffEnableToLo]);
|
|
102 |
aCaps.iAveHiPwr = (TUint16)((configTpl[KSdioExtFuncOffAveHiPwrHi] << 8) | configTpl[KSdioExtFuncOffAveHiPwrLo]);
|
|
103 |
aCaps.iMaxHiPwr = (TUint16)((configTpl[KSdioExtFuncOffMaxHiPwrHi] << 8) | configTpl[KSdioExtFuncOffMaxHiPwrLo]);
|
|
104 |
}
|
|
105 |
else
|
|
106 |
{
|
|
107 |
aCaps.iEnableTimeout = 0;
|
|
108 |
aCaps.iAveHiPwr = 0;
|
|
109 |
aCaps.iMaxHiPwr = 0;
|
|
110 |
}
|
|
111 |
|
|
112 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iFunctionInfo: 0x%02X", aCaps.iFunctionInfo)); // @SymTraceDataInternalTechnology
|
|
113 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iRevision: 0x%02X", aCaps.iRevision)); // @SymTraceDataInternalTechnology
|
|
114 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iSerialNumber: 0x%08X", aCaps.iSerialNumber)); // @SymTraceDataInternalTechnology
|
|
115 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iCSASize: 0x%08X", aCaps.iCSASize)); // @SymTraceDataInternalTechnology
|
|
116 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iCSAProperties: 0x%02X", aCaps.iCSAProperties)); // @SymTraceDataInternalTechnology
|
|
117 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iMaxBlockSize: 0x%04X", aCaps.iMaxBlockSize)); // @SymTraceDataInternalTechnology
|
|
118 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iOCR: 0x%08X", aCaps.iOCR)); // @SymTraceDataInternalTechnology
|
|
119 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iMinPwrStby: 0x%02X", aCaps.iMinPwrStby)); // @SymTraceDataInternalTechnology
|
|
120 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iAvePwrStby: 0x%02X", aCaps.iAvePwrStby)); // @SymTraceDataInternalTechnology
|
|
121 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iMaxPwrStby: 0x%02X", aCaps.iMaxPwrStby)); // @SymTraceDataInternalTechnology
|
|
122 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iMinPwrOp: 0x%02X", aCaps.iMinPwrOp)); // @SymTraceDataInternalTechnology
|
|
123 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iAvePwrOp: 0x%02X", aCaps.iAvePwrOp)); // @SymTraceDataInternalTechnology
|
|
124 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iMaxPwrOp: 0x%02X", aCaps.iMaxPwrOp)); // @SymTraceDataInternalTechnology
|
|
125 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iMinBandwidth: 0x%04X", aCaps.iMinBandwidth)); // @SymTraceDataInternalTechnology
|
|
126 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iOptBandwidth: 0x%04X", aCaps.iOptBandwidth)); // @SymTraceDataInternalTechnology
|
|
127 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iEnableTimeout: 0x%02X", aCaps.iEnableTimeout)); // @SymTraceDataInternalTechnology
|
|
128 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iAveHiPwr: 0x%02X", aCaps.iAveHiPwr)); // @SymTraceDataInternalTechnology
|
|
129 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "iMaxHiPwr: 0x%02X", aCaps.iMaxHiPwr)); // @SymTraceDataInternalTechnology
|
|
130 |
|
|
131 |
return(KErrNone);
|
|
132 |
}
|
|
133 |
|
|
134 |
TInt TCisReader::ParseTupleStandardFunction(TDes8 &configTpl, TSDIOFunctionCaps& aCaps)
|
|
135 |
/**
|
|
136 |
Parse an extension tuple (function)
|
|
137 |
*/
|
|
138 |
{
|
|
139 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:ParseTupleStandardFunction")); // @SymTraceDataInternalTechnology
|
|
140 |
|
|
141 |
aCaps.iStandardFunctionID = configTpl[KSdioStdOffFunctionId];
|
|
142 |
aCaps.iStandardFunctionType = configTpl[KSdioStdOffFunctionType];
|
|
143 |
|
|
144 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"iStandardFunctionID: 0x%02x", aCaps.iStandardFunctionID)); // @SymTraceDataInternalTechnology
|
|
145 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"iStandardFunctionType: 0x%02x", aCaps.iStandardFunctionType)); // @SymTraceDataInternalTechnology
|
|
146 |
|
|
147 |
return(KErrNone);
|
|
148 |
}
|
|
149 |
|
|
150 |
EXPORT_C TCisReader::TCisReader()
|
|
151 |
/**
|
|
152 |
Constructor.
|
|
153 |
*/
|
|
154 |
: iFunc(0),
|
|
155 |
iCisOffset(0),
|
|
156 |
iRestarted(EFalse)
|
|
157 |
{
|
|
158 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisReaderConstructor, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
159 |
|
|
160 |
iSocketP = NULL;
|
|
161 |
iStackP = NULL;
|
|
162 |
iCardP = NULL;
|
|
163 |
|
|
164 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisReaderConstructorReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
165 |
}
|
|
166 |
|
|
167 |
EXPORT_C TInt TCisReader::SelectCis(TUint aSocket,TUint aStack,TUint aCard,TUint8 aCardFunc)
|
|
168 |
/**
|
|
169 |
Assign the CIS reader to a socket and function.
|
|
170 |
*/
|
|
171 |
{
|
|
172 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisSelectCis, reinterpret_cast<TUint32>(this), aCard); // @SymTraceDataPublishedTvk
|
|
173 |
|
|
174 |
// We need to have read the CIS format
|
|
175 |
//
|
|
176 |
// Obtain the appropriate card from the socket/stack
|
|
177 |
//
|
|
178 |
iSocketP = static_cast<DMMCSocket*>(DPBusSocket::SocketFromId(aSocket));
|
|
179 |
if(iSocketP == NULL)
|
|
180 |
{
|
|
181 |
TRACE1(TTraceContext(EError), UTraceModuleEPBusSDIO::ESDIOSocketOOM, reinterpret_cast<TUint32>(this));
|
|
182 |
return KErrNoMemory;
|
|
183 |
}
|
|
184 |
|
|
185 |
iStackP = static_cast<DSDIOStack*>(iSocketP->Stack(aStack));
|
|
186 |
if(iStackP == NULL)
|
|
187 |
{
|
|
188 |
TRACE1(TTraceContext(EError), UTraceModuleEPBusSDIO::ESDIOStackOOM, reinterpret_cast<TUint32>(this));
|
|
189 |
return KErrNoMemory;
|
|
190 |
}
|
|
191 |
|
|
192 |
iCardP = static_cast<TSDIOCard*>(iStackP->CardP(aCard));
|
|
193 |
if(iCardP == NULL)
|
|
194 |
{
|
|
195 |
TRACE1(TTraceContext(EError), UTraceModuleEPBusSDIO::ESDIOCardOOM, reinterpret_cast<TUint32>(this));
|
|
196 |
return KErrNoMemory;
|
|
197 |
}
|
|
198 |
|
|
199 |
TInt ret = DoSelectCis(aCardFunc);
|
|
200 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisSelectCisReturning, reinterpret_cast<TUint32>(this), ret); // @SymTraceDataPublishedTvk
|
|
201 |
|
|
202 |
return(ret);
|
|
203 |
}
|
|
204 |
|
|
205 |
TInt TCisReader::DoSelectCis(TUint8 aCardFunc)
|
|
206 |
/**
|
|
207 |
Actually assign the CIS reader to a socket and function.
|
|
208 |
@internalTechnology
|
|
209 |
*/
|
|
210 |
{
|
|
211 |
// Check that the function is valid
|
|
212 |
TInt r = KErrNone;
|
|
213 |
iFunc=aCardFunc;
|
|
214 |
DoRestart();
|
|
215 |
|
|
216 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:DoSelectCis(F:%d)-%d",aCardFunc,r)); // @SymTraceDataInternalTechnology
|
|
217 |
return(r);
|
|
218 |
}
|
|
219 |
|
|
220 |
EXPORT_C TInt TCisReader::Restart()
|
|
221 |
/**
|
|
222 |
Restart the CIS reader back to the start of the CIS, and re-initialise
|
|
223 |
config entry parsing.
|
|
224 |
*/
|
|
225 |
{
|
|
226 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisRestart, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
227 |
|
|
228 |
DoRestart();
|
|
229 |
|
|
230 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisRestart, reinterpret_cast<TUint32>(this), KErrNone); // @SymTraceDataPublishedTvk
|
|
231 |
|
|
232 |
return(KErrNone);
|
|
233 |
}
|
|
234 |
|
|
235 |
void TCisReader::DoRestart()
|
|
236 |
/**
|
|
237 |
Restart the CIS reader back to the start of the CIS
|
|
238 |
@internalTechnology
|
|
239 |
*/
|
|
240 |
{
|
|
241 |
if(iFunc != 0)
|
|
242 |
{
|
|
243 |
TSDIOFunction* functionP = iCardP->IoFunction(iFunc);
|
|
244 |
if(functionP == NULL)
|
|
245 |
{
|
|
246 |
iRestarted = EFalse;
|
|
247 |
return;
|
|
248 |
}
|
|
249 |
|
|
250 |
iCisOffset = functionP->CisPtr();
|
|
251 |
}
|
|
252 |
else
|
|
253 |
{
|
|
254 |
iCisOffset = iCardP->CommonConfig().CisPtr();
|
|
255 |
}
|
|
256 |
|
|
257 |
iRestarted=ETrue;
|
|
258 |
|
|
259 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:DoRestart")); // @SymTraceDataInternalTechnology
|
|
260 |
}
|
|
261 |
|
|
262 |
EXPORT_C TInt TCisReader::FindReadTuple(TUint8 aDesiredTpl,TDes8 &aDes,TUint aFlag)
|
|
263 |
/**
|
|
264 |
Find a specified tuple from the CIS and read it.
|
|
265 |
*/
|
|
266 |
{
|
|
267 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisFindReadTuple, reinterpret_cast<TUint32>(this), aDesiredTpl); // @SymTraceDataPublishedTvk
|
|
268 |
|
|
269 |
TInt ret = DoFindReadTuple(aDesiredTpl,aDes,aFlag);
|
|
270 |
|
|
271 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisFindReadTupleReturning, reinterpret_cast<TUint32>(this), ret); // @SymTraceDataPublishedTvk
|
|
272 |
|
|
273 |
return(ret);
|
|
274 |
}
|
|
275 |
|
|
276 |
TInt TCisReader::DoFindReadTuple(TUint8 aDesiredTpl,TDes8 &aDes,TUint aFlag)
|
|
277 |
/**
|
|
278 |
Actually find a specified tuple from the CIS and read it.
|
|
279 |
@internalTechnology
|
|
280 |
*/
|
|
281 |
{
|
|
282 |
|
|
283 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:DoFindReadTuple(T:%xH)",aDesiredTpl)); // @SymTraceDataInternalTechnology
|
|
284 |
|
|
285 |
TBuf8<KSmallTplBufSize> tpl;
|
|
286 |
TInt j,err;
|
|
287 |
|
|
288 |
if ((err=ReadCis(iCisOffset,tpl,2))!=KErrNone)
|
|
289 |
return(err);
|
|
290 |
|
|
291 |
for (j=0;j<KMaxTuplesPerCis;j++)
|
|
292 |
{
|
|
293 |
// Adjust CIS offset beyond last tuple read (unless we've just restarted)
|
|
294 |
if (iRestarted)
|
|
295 |
iRestarted=EFalse;
|
|
296 |
else
|
|
297 |
{
|
|
298 |
if (tpl[0]!=KSdioCisTplEnd && tpl[1]!=0xff)
|
|
299 |
iCisOffset += (tpl[0] == KSdioCisTplNull) ? 1 : (tpl[1] + 2); // A null tuple has no link field
|
|
300 |
else
|
|
301 |
{
|
|
302 |
return(KErrNotFound);
|
|
303 |
}
|
|
304 |
}
|
|
305 |
|
|
306 |
// Read the next tuple
|
|
307 |
if ((err=ReadCis(iCisOffset,tpl,2))!=KErrNone)
|
|
308 |
return(err);
|
|
309 |
|
|
310 |
// Check if we have found the specified tuple
|
|
311 |
if (aDesiredTpl==KNonSpecificTpl || aDesiredTpl==tpl[0])
|
|
312 |
{
|
|
313 |
// The following are ignored.
|
|
314 |
if ((tpl[0]==KSdioCisTplNull)||
|
|
315 |
(tpl[0]==KSdioCisTplEnd))
|
|
316 |
{
|
|
317 |
}
|
|
318 |
else
|
|
319 |
break;
|
|
320 |
}
|
|
321 |
}
|
|
322 |
|
|
323 |
// We got a result (or we've wandered off into the weeds)
|
|
324 |
if (j >= KMaxTuplesPerCis)
|
|
325 |
{
|
|
326 |
return( (aFlag&KReportErrors) ? KErrCorrupt : KErrNotFound );
|
|
327 |
}
|
|
328 |
else
|
|
329 |
{
|
|
330 |
return((aFlag&KFindOnly) ? KErrNone : DoReadTuple(aDes));
|
|
331 |
}
|
|
332 |
}
|
|
333 |
|
|
334 |
EXPORT_C TInt TCisReader::ReadTuple(TDes8 &aDes)
|
|
335 |
/**
|
|
336 |
Read the tuple at the current CIS offset.
|
|
337 |
*/
|
|
338 |
{
|
|
339 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisReadTuple, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
340 |
TInt ret = DoReadTuple(aDes);
|
|
341 |
|
|
342 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisReadTupleReturning, reinterpret_cast<TUint32>(this), ret); // @SymTraceDataPublishedTvk
|
|
343 |
|
|
344 |
return (ret);
|
|
345 |
}
|
|
346 |
|
|
347 |
TInt TCisReader::DoReadTuple(TDes8 &aDes)
|
|
348 |
/**
|
|
349 |
Actually read the tuple at the current CIS offset.
|
|
350 |
@internalTechnology
|
|
351 |
*/
|
|
352 |
{
|
|
353 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:DoReadTuple")); // @SymTraceDataInternalTechnology
|
|
354 |
|
|
355 |
TInt err;
|
|
356 |
|
|
357 |
// Read the tuple type and link
|
|
358 |
TBuf8<KSmallTplBufSize> tpl;
|
|
359 |
if ((err= ReadCis(iCisOffset,tpl,2)) != KErrNone)
|
|
360 |
return(err);
|
|
361 |
|
|
362 |
TInt tplLen ;
|
|
363 |
if ((tpl[0] == KSdioCisTplNull) || (tpl[0] == KSdioCisTplEnd))
|
|
364 |
tplLen = 1 ; // These tuples dont have a link.
|
|
365 |
else
|
|
366 |
tplLen = (tpl[1]+2) ;
|
|
367 |
|
|
368 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:TupleLength %d",tplLen)); // @SymTraceDataInternalTechnology
|
|
369 |
|
|
370 |
if ( tplLen>aDes.MaxLength() ) // We dont want a panic if aDes too small
|
|
371 |
return(KErrArgument);
|
|
372 |
|
|
373 |
// Lets copy the tuple
|
|
374 |
if ((err= ReadCis(iCisOffset,aDes,tplLen)) != KErrNone)
|
|
375 |
return(err);
|
|
376 |
else
|
|
377 |
return(KErrNone);
|
|
378 |
}
|
|
379 |
|
|
380 |
|
|
381 |
EXPORT_C TInt TCisReader::FindReadCommonConfig(TSDIOCardConfig &anInfo)
|
|
382 |
/**
|
|
383 |
Searches for the Card and Common Function Identification Tuples.
|
|
384 |
*/
|
|
385 |
{
|
|
386 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisFindReadCommonConfig, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
387 |
|
|
388 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:FindReadCommonConfig")); // @SymTraceDataInternalTechnology
|
|
389 |
|
|
390 |
// Copy stuff from the CCCR that doesn't come from the CIS (iRevision, etc.)
|
|
391 |
anInfo = iCardP->CommonConfig();
|
|
392 |
|
|
393 |
DoRestart(); // Start from beginning of CIS each time
|
|
394 |
|
|
395 |
TBuf8<KLargeTplBufSize> configTpl;
|
|
396 |
TInt err;
|
|
397 |
|
|
398 |
// Look for the Manufacturer ID Tuple
|
|
399 |
if ((err = FindReadTuple(KSdioCisTplManfId, configTpl)) == KErrNone &&
|
|
400 |
(err = ParseConfigTuple(configTpl, anInfo)) == KErrNone)
|
|
401 |
{
|
|
402 |
// Although these are manditory, they may not exist in
|
|
403 |
// some cards so we should carry on if not found.
|
|
404 |
}
|
|
405 |
|
|
406 |
DoRestart(); // Start from beginning of CIS
|
|
407 |
|
|
408 |
// Now look for the Function Identification Tuple. This is followed
|
|
409 |
// by the Function Extension Tuples, which contain information about each
|
|
410 |
// function. Here, we are interested in Function 0 (Common) info.
|
|
411 |
if ((err = FindReadTuple(KSdioCisTplFuncId, configTpl)) == KErrNone)
|
|
412 |
{
|
|
413 |
if(configTpl[2] == 0x0C)
|
|
414 |
{
|
|
415 |
DoRestart(); // Start from beginning of CIS
|
|
416 |
|
|
417 |
// This is an SDIO Function. Follow up the extended data
|
|
418 |
if ((err = FindReadTuple(KSdioCisTplFunce, configTpl)) == KErrNone)
|
|
419 |
{
|
|
420 |
if(configTpl[2] == 0x00) // Common Function Tuple Info.
|
|
421 |
{
|
|
422 |
err = ParseExtensionTupleCommon(configTpl,anInfo);
|
|
423 |
}
|
|
424 |
else
|
|
425 |
{
|
|
426 |
Printf(TTraceContext(EError),"TCisReader::FindReadCommonConfig, SDIO Function not supported");
|
|
427 |
return(KErrNotSupported);
|
|
428 |
}
|
|
429 |
}
|
|
430 |
}
|
|
431 |
}
|
|
432 |
|
|
433 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:FindReadCommonConfig-%d",err)); // @SymTraceDataInternalTechnology
|
|
434 |
|
|
435 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisFindReadCommonConfigReturning, reinterpret_cast<TUint32>(this), err); // @SymTraceDataPublishedTvk
|
|
436 |
|
|
437 |
return(err);
|
|
438 |
}
|
|
439 |
|
|
440 |
EXPORT_C TInt TCisReader::FindReadFunctionConfig(TSDIOFunctionCaps& aCaps)
|
|
441 |
/**
|
|
442 |
Searches for the Function Identification Tuple. This is followed
|
|
443 |
by the Function Extension Tuples, which contain information about each
|
|
444 |
function. Here, we are interested in Function 1:7 (Function) info.
|
|
445 |
*/
|
|
446 |
{
|
|
447 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisFindReadFunctionConfig, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
448 |
|
|
449 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:FindReadFunctionConfig")); // @SymTraceDataInternalTechnology
|
|
450 |
|
|
451 |
TInt err = KErrNone;
|
|
452 |
|
|
453 |
// Copy stuff from the FBR that doesn't come from the CIS (iNumber, etc.)
|
|
454 |
TSDIOFunction* pFunction = iCardP->IoFunction(iFunc);
|
|
455 |
if(pFunction)
|
|
456 |
aCaps = pFunction->Capabilities();
|
|
457 |
|
|
458 |
DoRestart(); // Start from beginning of CIS
|
|
459 |
|
|
460 |
TBuf8<KLargeTplBufSize> configTpl;
|
|
461 |
if ((err = FindReadTuple(KSdioCisTplFunce, configTpl)) == KErrNone)
|
|
462 |
{
|
|
463 |
if(configTpl[2] == 0x01) // Function Tuple Info.
|
|
464 |
{
|
|
465 |
err = ParseExtensionTupleFunction(configTpl, aCaps);
|
|
466 |
}
|
|
467 |
else
|
|
468 |
{
|
|
469 |
return(KErrNotSupported);
|
|
470 |
}
|
|
471 |
}
|
|
472 |
|
|
473 |
if(err != KErrNone)
|
|
474 |
{
|
|
475 |
return(err);
|
|
476 |
}
|
|
477 |
|
|
478 |
// If we have found the function tuple, follow up the SDIO Standard Code Tuple
|
|
479 |
// (This is mandatory for cards that conform to the standard SDIO interface API's)
|
|
480 |
|
|
481 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:FindReadFunctionConfig DoRestart()")); // @SymTraceDataInternalTechnology
|
|
482 |
DoRestart(); // Start from beginning of CIS
|
|
483 |
|
|
484 |
if ((err = FindReadTuple(KSdioCisTplSdioStd, configTpl)) == KErrNone)
|
|
485 |
{
|
|
486 |
err=ParseTupleStandardFunction(configTpl, aCaps);
|
|
487 |
}
|
|
488 |
else if(err == KErrNotFound)
|
|
489 |
{
|
|
490 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:KErrNotFound!")); // @SymTraceDataInternalTechnology
|
|
491 |
err = KErrNone;
|
|
492 |
}
|
|
493 |
|
|
494 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"CisReader:FindReadFunctionConfig-%d",err)); // @SymTraceDataInternalTechnology
|
|
495 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOTCisFindReadFunctionConfig, reinterpret_cast<TUint32>(this), err); // @SymTraceDataPublishedTvk
|
|
496 |
return(err);
|
|
497 |
}
|
|
498 |
|
|
499 |
const TInt KReadCisBufferSize=0x80; // 128 Bytes
|
|
500 |
TInt TCisReader::ReadCis(TInt aPos,TDes8 &aDes,TInt aLen)
|
|
501 |
/**
|
|
502 |
Read from CIS
|
|
503 |
@internalTechnology
|
|
504 |
*/
|
|
505 |
{
|
|
506 |
|
|
507 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"TCisReader::ReadCis(LE:%xH PO:0x%08x)",aLen,aPos)); // @SymTraceDataInternalTechnology
|
|
508 |
|
|
509 |
TInt err = KErrNone;
|
|
510 |
|
|
511 |
TInt cisE=(aPos+aLen);
|
|
512 |
aDes.Zero();
|
|
513 |
TText8 buf[KReadCisBufferSize];
|
|
514 |
TInt s;
|
|
515 |
for (;aPos<cisE;aPos+=s)
|
|
516 |
{
|
|
517 |
s=Min(KReadCisBufferSize,(cisE-aPos));
|
|
518 |
|
|
519 |
// It is faster to do read direct than multiple for one byte
|
|
520 |
if(s>1)
|
|
521 |
{
|
|
522 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"ReadMultiple8")); // @SymTraceDataInternalTechnology
|
|
523 |
err = iCardP->CommonRegisterInterface()->ReadMultiple8(aPos, buf, s);
|
|
524 |
}
|
|
525 |
else
|
|
526 |
{
|
|
527 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals),"Read8")); // @SymTraceDataInternalTechnology
|
|
528 |
err = iCardP->CommonRegisterInterface()->Read8(aPos, buf);
|
|
529 |
}
|
|
530 |
|
|
531 |
if(err != KErrNone)
|
|
532 |
{
|
|
533 |
return err;
|
|
534 |
}
|
|
535 |
|
|
536 |
for (TInt i=0;i<s;i++)
|
|
537 |
{
|
|
538 |
aDes.Append((TChar)buf[i]);
|
|
539 |
}
|
|
540 |
}
|
|
541 |
|
|
542 |
return(err);
|
|
543 |
}
|
|
544 |
|