32 iRetryTimer(DMMCSession::RetryTimerCallBack, this), |
41 iRetryTimer(DMMCSession::RetryTimerCallBack, this), |
33 iProgramTimer(DMMCSession::ProgramTimerCallBack, this), |
42 iProgramTimer(DMMCSession::ProgramTimerCallBack, this), |
34 #endif // #ifdef __EPOC32__ |
43 #endif // #ifdef __EPOC32__ |
35 iConfig() |
44 iConfig() |
36 { |
45 { |
|
46 OstTraceFunctionEntry1( DMMCSESSION_DMMCSESSION_ENTRY, this ); |
37 } |
47 } |
38 |
48 |
39 EXPORT_C DMMCSession::~DMMCSession() |
49 EXPORT_C DMMCSession::~DMMCSession() |
40 /** |
50 /** |
41 * Destructor. |
51 * Destructor. |
42 */ |
52 */ |
43 { |
53 { |
|
54 OstTraceFunctionEntry1( DUP1_DMMCSESSION_DMMCSESSION_ENTRY, this ); |
44 // Ensure that the stack isn't currently running in another thread's context, otherwise this session won't be |
55 // Ensure that the stack isn't currently running in another thread's context, otherwise this session won't be |
45 // removed from the stack's workset until some time later - by which time the session will have been deleted |
56 // removed from the stack's workset until some time later - by which time the session will have been deleted |
46 __ASSERT_ALWAYS(!iStackP->StackRunning(), DMMCSocket::Panic(DMMCSocket::EMMCNotInDfcContext)); |
57 __ASSERT_ALWAYS(!iStackP->StackRunning(), DMMCSocket::Panic(DMMCSocket::EMMCNotInDfcContext)); |
47 Abort(); |
58 Abort(); |
48 UnlockStack(); |
59 UnlockStack(); |
|
60 OstTraceFunctionExit1( DUP1_DMMCSESSION_DMMCSESSION_EXIT, this ); |
49 } |
61 } |
50 |
62 |
51 EXPORT_C void DMMCSession::SetCard(TMMCard* aCardP) |
63 EXPORT_C void DMMCSession::SetCard(TMMCard* aCardP) |
52 /** |
64 /** |
53 * Assigns a card to the session. The card pointer would normally be obtained via a call of DMMCStack::CardP(). |
65 * Assigns a card to the session. The card pointer would normally be obtained via a call of DMMCStack::CardP(). |
57 * been assigned to it will generally fail straight away. It is possible to change the card assigned to the |
69 * been assigned to it will generally fail straight away. It is possible to change the card assigned to the |
58 * session as long as this is not attempted while the session is engaged. |
70 * session as long as this is not attempted while the session is engaged. |
59 * @param aCardP A pointer to the card to be assigned to the session. |
71 * @param aCardP A pointer to the card to be assigned to the session. |
60 */ |
72 */ |
61 { |
73 { |
|
74 OstTraceFunctionEntryExt( DMMCSESSION_SETCARD_ENTRY, this ); |
62 iCardP = aCardP; |
75 iCardP = aCardP; |
63 iCID = iCardP->CID(); |
76 iCID = iCardP->CID(); |
|
77 OstTraceFunctionExit1( DMMCSESSION_SETCARD_EXIT, this ); |
64 } |
78 } |
65 |
79 |
66 EXPORT_C void DMMCSession::SetupCIMReadBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP) |
80 EXPORT_C void DMMCSession::SetupCIMReadBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP) |
67 /** |
81 /** |
68 * Sets the session up to perform the CIM_READ_BLOCK macro as outlined by the MMCA. |
82 * Sets the session up to perform the CIM_READ_BLOCK macro as outlined by the MMCA. |
73 * @param aDevAddr Contains offset to the block to be read from the card |
87 * @param aDevAddr Contains offset to the block to be read from the card |
74 * @param aLength Block length |
88 * @param aLength Block length |
75 * @param aMemoryP host destination address |
89 * @param aMemoryP host destination address |
76 */ |
90 */ |
77 { |
91 { |
|
92 OstTraceExt4(TRACE_FLOW, DMMCSESSION_SETUPCIMREADBLOCK_ENTRY, "DMMCSession::SetupCIMReadBlock;aDevAddr=%x;aLength=%x;aMemoryP=%x;this=%x", (TUint) aDevAddr, (TUint) aLength, (TUint) aMemoryP, (TUint) this); |
78 ResetCommandStack(); |
93 ResetCommandStack(); |
79 FillCommandArgs(aDevAddr, aLength, aMemoryP, aLength); |
94 FillCommandArgs(aDevAddr, aLength, aMemoryP, aLength); |
80 iSessionID = ECIMReadBlock; |
95 iSessionID = ECIMReadBlock; |
|
96 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMREADBLOCK_EXIT, this ); |
81 } |
97 } |
82 |
98 |
83 EXPORT_C void DMMCSession::SetupCIMWriteBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP) |
99 EXPORT_C void DMMCSession::SetupCIMWriteBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP) |
84 /** |
100 /** |
85 * Set up the session to perform the CIM_WRITE_BLOCK macro as outlined by the MMCA. |
101 * Set up the session to perform the CIM_WRITE_BLOCK macro as outlined by the MMCA. |
90 * @param aDevAddr Contains offset to the block to be written on the card |
106 * @param aDevAddr Contains offset to the block to be written on the card |
91 * @param aLength Block length |
107 * @param aLength Block length |
92 * @param aMemoryP Host source address |
108 * @param aMemoryP Host source address |
93 */ |
109 */ |
94 { |
110 { |
|
111 OstTraceExt4(TRACE_FLOW, DMMCSESSION_SETUPCIMWRITEBLOCK_ENTRY, "DMMCSession::SetupCIMWriteBlock;aDevAddr=%x;aLength=%x;aMemoryP=%x;this=%x", (TUint) aDevAddr, (TUint) aLength, (TUint) aMemoryP, (TUint) this); |
95 ResetCommandStack(); |
112 ResetCommandStack(); |
96 FillCommandArgs(aDevAddr, aLength, aMemoryP, aLength); |
113 FillCommandArgs(aDevAddr, aLength, aMemoryP, aLength); |
97 iSessionID = ECIMWriteBlock; |
114 iSessionID = ECIMWriteBlock; |
|
115 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMWRITEBLOCK_EXIT, this ); |
98 } |
116 } |
99 |
117 |
100 EXPORT_C void DMMCSession::SetupCIMReadMBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen) |
118 EXPORT_C void DMMCSession::SetupCIMReadMBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen) |
101 /** |
119 /** |
102 * Set up the session to perform the CIM_READ_MBLOCK macro as outlined by the MMCA. |
120 * Set up the session to perform the CIM_READ_MBLOCK macro as outlined by the MMCA. |
109 * @param aLength Total number of bytes to read. |
127 * @param aLength Total number of bytes to read. |
110 * @param aMemoryP Host destination address |
128 * @param aMemoryP Host destination address |
111 * @param aBlkLen Block length |
129 * @param aBlkLen Block length |
112 */ |
130 */ |
113 { |
131 { |
|
132 OstTraceExt5(TRACE_FLOW, DMMCSESSION_SETUPCIMREADMBLOCK_ENTRY, "DMMCSession::SetupCIMReadMBlock;aDevAddr=%x;aLength=%x;aMemoryP=%x;aBlkLen=%x;this=%x", (TUint) aDevAddr, (TUint) aLength, (TUint) aMemoryP, (TUint) aBlkLen,(TUint) this); |
114 ResetCommandStack(); |
133 ResetCommandStack(); |
115 FillCommandArgs(aDevAddr, aLength, aMemoryP, aBlkLen); |
134 FillCommandArgs(aDevAddr, aLength, aMemoryP, aBlkLen); |
116 iSessionID = ECIMReadMBlock; |
135 iSessionID = ECIMReadMBlock; |
|
136 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMREADMBLOCK_EXIT, this ); |
117 } |
137 } |
118 |
138 |
119 EXPORT_C void DMMCSession::SetupCIMWriteMBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen) |
139 EXPORT_C void DMMCSession::SetupCIMWriteMBlock(TMMCArgument aDevAddr, TUint32 aLength, TUint8* aMemoryP, TUint32 aBlkLen) |
120 /** |
140 /** |
121 * Set up the session to perform the CIM_WRITE_MBLOCK macro as outlined by the MMCA. |
141 * Set up the session to perform the CIM_WRITE_MBLOCK macro as outlined by the MMCA. |
128 * @param aLength Total number of bytes to write. |
148 * @param aLength Total number of bytes to write. |
129 * @param aMemoryP Host source address |
149 * @param aMemoryP Host source address |
130 * @param aBlkLen Block length |
150 * @param aBlkLen Block length |
131 */ |
151 */ |
132 { |
152 { |
|
153 OstTraceExt5(TRACE_FLOW, DMMCSESSION_SETUPCIMWRITEMBLOCK_ENTRY, "DMMCSession::SetupCIMWriteMBlock;aDevAddr=%x;aLength=%x;aMemoryP=%x;aBlkLen=%x;this=%x", (TUint) aDevAddr, (TUint) aLength, (TUint) aMemoryP, (TUint) aBlkLen,(TUint) this); |
133 ResetCommandStack(); |
154 ResetCommandStack(); |
134 FillCommandArgs(aDevAddr, aLength, aMemoryP, aBlkLen); |
155 FillCommandArgs(aDevAddr, aLength, aMemoryP, aBlkLen); |
135 iSessionID = ECIMWriteMBlock; |
156 iSessionID = ECIMWriteMBlock; |
|
157 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMWRITEMBLOCK_EXIT, this ); |
136 } |
158 } |
137 |
159 |
138 EXPORT_C void DMMCSession::SetupCIMEraseSector(TMMCArgument aDevAddr, TUint32 aLength) |
160 EXPORT_C void DMMCSession::SetupCIMEraseSector(TMMCArgument aDevAddr, TUint32 aLength) |
139 /** |
161 /** |
140 * Set up the session to perform the CIM_ERASE_SECTOR macro broadly as outlined by the MMCA. |
162 * Set up the session to perform the CIM_ERASE_SECTOR macro broadly as outlined by the MMCA. |
150 * information from the card. |
172 * information from the card. |
151 * @param aDevAddr Contains offset to the first block to be erased |
173 * @param aDevAddr Contains offset to the first block to be erased |
152 * @param aLength Total number of bytes to erase |
174 * @param aLength Total number of bytes to erase |
153 */ |
175 */ |
154 { |
176 { |
|
177 OstTraceExt3(TRACE_FLOW, DMMCSESSION_SETUPCIMERASESECTOR_ENTRY, "DMMCSession::SetupCIMEraseSector;aDevAddr=%x;aLength=%x;this=%x", (TUint) aDevAddr, (TUint) aLength, (TUint) this); |
155 ResetCommandStack(); |
178 ResetCommandStack(); |
156 FillCommandArgs(aDevAddr, aLength, NULL, 0); |
179 FillCommandArgs(aDevAddr, aLength, NULL, 0); |
157 iSessionID = ECIMEraseSector; |
180 iSessionID = ECIMEraseSector; |
|
181 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMERASESECTOR_EXIT, this ); |
158 } |
182 } |
159 |
183 |
160 EXPORT_C void DMMCSession::SetupCIMEraseGroup(TMMCArgument aDevAddr, TUint32 aLength) |
184 EXPORT_C void DMMCSession::SetupCIMEraseGroup(TMMCArgument aDevAddr, TUint32 aLength) |
161 /** |
185 /** |
162 * Set up the session to perform the CIM_ERASE_GROUP macro broadly as outlined by the MMCA. |
186 * Set up the session to perform the CIM_ERASE_GROUP macro broadly as outlined by the MMCA. |
171 * by a send status command (CMD13) to read any additional status information from the card. |
195 * by a send status command (CMD13) to read any additional status information from the card. |
172 * @param aDevAddr Contains offset to the first block to be erased |
196 * @param aDevAddr Contains offset to the first block to be erased |
173 * @param aLength Total number of bytes to erase |
197 * @param aLength Total number of bytes to erase |
174 */ |
198 */ |
175 { |
199 { |
|
200 OstTraceExt3(TRACE_FLOW, DMMCSESSION_SETUPCIMERASEGROUP_ENTRY, "DMMCSession::SetupCIMEraseGroup;aDevAddr=%x;aLength=%x;this=%x", (TUint) aDevAddr, (TUint) aLength, (TUint) this); |
176 ResetCommandStack(); |
201 ResetCommandStack(); |
177 FillCommandArgs(aDevAddr, aLength, NULL, 0); |
202 FillCommandArgs(aDevAddr, aLength, NULL, 0); |
178 iSessionID = ECIMEraseGroup; |
203 iSessionID = ECIMEraseGroup; |
|
204 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMERASEGROUP_EXIT, this ); |
179 } |
205 } |
180 |
206 |
181 EXPORT_C void DMMCSession::SetupCIMReadIO(TUint8 aRegAddr, TUint32 aLength, TUint8* aMemoryP) |
207 EXPORT_C void DMMCSession::SetupCIMReadIO(TUint8 aRegAddr, TUint32 aLength, TUint8* aMemoryP) |
182 /** |
208 /** |
183 * Set up the session to perform the read i/o macro (CMD39). |
209 * Set up the session to perform the read i/o macro (CMD39). |
187 * @param aRegAddr Address of IO register |
213 * @param aRegAddr Address of IO register |
188 * @param aLength Total number of bytes to read |
214 * @param aLength Total number of bytes to read |
189 * @param aMemoryP Host destination address |
215 * @param aMemoryP Host destination address |
190 */ |
216 */ |
191 { |
217 { |
|
218 OstTraceFunctionEntryExt( DMMCSESSION_SETUPCIMREADIO_ENTRY, this ); |
192 ResetCommandStack(); |
219 ResetCommandStack(); |
193 FillCommandArgs(aRegAddr, aLength, aMemoryP, 0); |
220 FillCommandArgs(aRegAddr, aLength, aMemoryP, 0); |
194 iSessionID = ECIMReadIO; |
221 iSessionID = ECIMReadIO; |
|
222 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMREADIO_EXIT, this ); |
195 } |
223 } |
196 |
224 |
197 EXPORT_C void DMMCSession::SetupCIMWriteIO(TUint8 aRegAddr, TUint32 aLength, TUint8* aMemoryP) |
225 EXPORT_C void DMMCSession::SetupCIMWriteIO(TUint8 aRegAddr, TUint32 aLength, TUint8* aMemoryP) |
198 /** |
226 /** |
199 * Set up the session to perform the write i/o macro (CMD39). |
227 * Set up the session to perform the write i/o macro (CMD39). |
203 * @param aRegAddr Address of IO register |
231 * @param aRegAddr Address of IO register |
204 * @param aLength Total number of bytes to write |
232 * @param aLength Total number of bytes to write |
205 * @param aMemoryP Host source address |
233 * @param aMemoryP Host source address |
206 */ |
234 */ |
207 { |
235 { |
|
236 OstTraceFunctionEntryExt( DMMCSESSION_SETUPCIMWRITEIO_ENTRY, this ); |
208 ResetCommandStack(); |
237 ResetCommandStack(); |
209 FillCommandArgs(aRegAddr, aLength, aMemoryP, 0); |
238 FillCommandArgs(aRegAddr, aLength, aMemoryP, 0); |
210 iSessionID = ECIMWriteIO; |
239 iSessionID = ECIMWriteIO; |
|
240 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMWRITEIO_EXIT, this ); |
211 } |
241 } |
212 |
242 |
213 EXPORT_C void DMMCSession::SetupCIMLockUnlock(TUint32 aLength, TUint8* aMemoryP) |
243 EXPORT_C void DMMCSession::SetupCIMLockUnlock(TUint32 aLength, TUint8* aMemoryP) |
214 /** |
244 /** |
215 * Set up the session to perform the lock-unlock macro (CMD42). |
245 * Set up the session to perform the lock-unlock macro (CMD42). |
223 * data block should contain the password setting mode, the password length and the password data if appropriate. |
253 * data block should contain the password setting mode, the password length and the password data if appropriate. |
224 * @param aLength Block length |
254 * @param aLength Block length |
225 * @param aMemoryP Host source address containing password data |
255 * @param aMemoryP Host source address containing password data |
226 */ |
256 */ |
227 { |
257 { |
|
258 OstTraceFunctionEntryExt( DMMCSESSION_SETUPCIMLOCKUNLOCK_ENTRY, this ); |
228 __KTRACE_OPT(KPBUS1, Kern::Printf("ms:slu%08x", aLength)); |
259 __KTRACE_OPT(KPBUS1, Kern::Printf("ms:slu%08x", aLength)); |
229 |
260 |
230 ResetCommandStack(); |
261 ResetCommandStack(); |
231 FillCommandDesc(ECmdLockUnlock); |
262 FillCommandDesc(ECmdLockUnlock); |
232 FillCommandArgs(0, aLength, aMemoryP, aLength); |
263 FillCommandArgs(0, aLength, aMemoryP, aLength); |
233 iSessionID = ECIMLockUnlock; |
264 iSessionID = ECIMLockUnlock; |
|
265 OstTraceFunctionExit1( DMMCSESSION_SETUPCIMLOCKUNLOCK_EXIT, this ); |
234 } |
266 } |
235 |
267 |
236 EXPORT_C void DMMCSession::SetupCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument) |
268 EXPORT_C void DMMCSession::SetupCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument) |
237 /** |
269 /** |
238 * Set up the session to issue a raw command to the card. |
270 * Set up the session to issue a raw command to the card. |
241 * the operation can commence. |
273 * the operation can commence. |
242 * @param aCommand Command to be sent |
274 * @param aCommand Command to be sent |
243 * @param anArgument Associated argument |
275 * @param anArgument Associated argument |
244 */ |
276 */ |
245 { |
277 { |
|
278 OstTraceExt3(TRACE_FLOW, DMMCSESSION_SETUPCOMMAND_ENTRY, "DMMCSession::SetupCommand;aCommand=%d;anArgument=%x;this=%x", (TInt) aCommand, (TUint) anArgument, (TUint) this); |
246 ResetCommandStack(); |
279 ResetCommandStack(); |
247 FillCommandDesc(aCommand, anArgument); |
280 FillCommandDesc(aCommand, anArgument); |
248 iSessionID = ECIMNakedSession; |
281 iSessionID = ECIMNakedSession; |
|
282 OstTraceFunctionExit1( DMMCSESSION_SETUPCOMMAND_EXIT, this ); |
249 } |
283 } |
250 |
284 |
251 EXPORT_C void DMMCSession::SetupRSCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument, |
285 EXPORT_C void DMMCSession::SetupRSCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument, |
252 TUint32 aResponseLength, TMMCCommandTypeEnum aCommandType, |
286 TUint32 aResponseLength, TMMCCommandTypeEnum aCommandType, |
253 TMMCResponseTypeEnum aResponseType, |
287 TMMCResponseTypeEnum aResponseType, |
263 * @param aResponseType |
297 * @param aResponseType |
264 * @param aCommandClass |
298 * @param aCommandClass |
265 * @todo Complete the parameter descriptions |
299 * @todo Complete the parameter descriptions |
266 */ |
300 */ |
267 { |
301 { |
|
302 OstTraceExt4( TRACE_FLOW, DMMCSESSION_SETUPRSCOMMAND_ENTRY1, "DMMCSession::SetupRSCommand;aCommand=%d;anArgument=%x;aResponseLength=%x;this=%x", (TInt) aCommand, (TUint) anArgument, (TUint) aResponseLength, (TUint) this ); |
|
303 OstTraceExt4( TRACE_FLOW, DMMCSESSION_SETUPRSCOMMAND_ENTRY2, "DMMCSession::SetupRSCommand;aCommandType=%d;aResponseType=%d;aCommandClass=%x;this=%x", (TInt) aCommandType, (TInt) aResponseType, (TUint) aCommandClass, (TUint) this ); |
268 ResetCommandStack(); |
304 ResetCommandStack(); |
269 FillCommandDesc(aCommand, anArgument); |
305 FillCommandDesc(aCommand, anArgument); |
270 TMMCCommandSpec& cmdSpec = Command().iSpec; |
306 TMMCCommandSpec& cmdSpec = Command().iSpec; |
271 cmdSpec.iDirection = EDirNone; |
307 cmdSpec.iDirection = EDirNone; |
272 |
308 |
281 |
317 |
282 if( aCommandClass != KMMCCmdClassNone ) |
318 if( aCommandClass != KMMCCmdClassNone ) |
283 cmdSpec.iCommandClass = aCommandClass; |
319 cmdSpec.iCommandClass = aCommandClass; |
284 |
320 |
285 iSessionID = ECIMNakedSession; |
321 iSessionID = ECIMNakedSession; |
|
322 OstTraceFunctionExit1( DMMCSESSION_SETUPRSCOMMAND_EXIT, this ); |
286 } |
323 } |
287 |
324 |
288 EXPORT_C void DMMCSession::SetupDTCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument, |
325 EXPORT_C void DMMCSession::SetupDTCommand(TMMCCommandEnum aCommand, TMMCArgument anArgument, |
289 TUint32 aTotalLength, TUint8* aMemoryAddress, TUint32 aBlockLength, |
326 TUint32 aTotalLength, TUint8* aMemoryAddress, TUint32 aBlockLength, |
290 TBool aStopTransmission, TMMCCmdDirEnum aDir, |
327 TBool aStopTransmission, TMMCCmdDirEnum aDir, |
303 * @param aDir |
340 * @param aDir |
304 * @param aCommandClass |
341 * @param aCommandClass |
305 * @todo Complete the parameter descriptions |
342 * @todo Complete the parameter descriptions |
306 */ |
343 */ |
307 { |
344 { |
|
345 OstTraceExt5( TRACE_FLOW, DMMCSESSION_SETUPDTCOMMAND_ENTRY1, "DMMCSession::SetupDTCommand;aCommand=%d;anArgument=%x;aTotalLength=%x;aMemoryAddress=%x;this=%x", (TInt) aCommand, (TUint) anArgument, (TUint) aTotalLength, (TUint) aMemoryAddress, (TUint) this ); |
|
346 OstTraceExt5( TRACE_FLOW, DMMCSESSION_SETUPDTCOMMAND_ENTRY2, "DMMCSession::SetupDTCommand;aBlockLength=%x;aStopTransmission=%d;aDir=%d;aCommandClass=%x;this=%x", (TUint) aBlockLength, (TInt) aStopTransmission, (TInt) aDir, (TUint) aCommandClass , (TUint) this ); |
308 ResetCommandStack(); |
347 ResetCommandStack(); |
309 FillCommandDesc(aCommand); |
348 FillCommandDesc(aCommand); |
310 FillCommandArgs(anArgument, aTotalLength, aMemoryAddress, aBlockLength); |
349 FillCommandArgs(anArgument, aTotalLength, aMemoryAddress, aBlockLength); |
311 TMMCCommandDesc& cmd = Command(); |
350 TMMCCommandDesc& cmd = Command(); |
312 |
351 |
326 |
365 |
327 if( aCommandClass != KMMCCmdClassNone ) |
366 if( aCommandClass != KMMCCmdClassNone ) |
328 cmd.iSpec.iCommandClass = aCommandClass; |
367 cmd.iSpec.iCommandClass = aCommandClass; |
329 |
368 |
330 iSessionID = ECIMNakedSession; |
369 iSessionID = ECIMNakedSession; |
|
370 OstTraceFunctionExit1( DMMCSESSION_SETUPDTCOMMAND_EXIT, this ); |
331 } |
371 } |
332 |
372 |
333 void DMMCSession::SetupCIMControl(TInt aSessID) |
373 void DMMCSession::SetupCIMControl(TInt aSessID) |
334 // |
374 // |
335 // find matching macro function for supplied session |
375 // find matching macro function for supplied session |
336 // |
376 // |
337 { |
377 { |
|
378 OstTraceFunctionEntryExt( DMMCSESSION_SETUPCIMCONTROL_ENTRY, this ); |
338 TMMCSMSTFunc f = GetMacro(aSessID); |
379 TMMCSMSTFunc f = GetMacro(aSessID); |
339 |
380 |
340 if (f == 0) |
381 if (f == 0) |
341 f = DMMCStack::NoSessionSMST; |
382 f = DMMCStack::NoSessionSMST; |
342 |
383 |
393 * @return KErrServerBusy if the stack is currently locked (and KMMCModeEnqueIfLocked flag is cleared) |
435 * @return KErrServerBusy if the stack is currently locked (and KMMCModeEnqueIfLocked flag is cleared) |
394 * @return KErrNotReady if the media is not present |
436 * @return KErrNotReady if the media is not present |
395 * @return KErrNone if successful |
437 * @return KErrNone if successful |
396 */ |
438 */ |
397 { |
439 { |
|
440 OstTraceFunctionEntry1( DMMCSESSION_ENGAGE_ENTRY, this ); |
398 __KTRACE_OPT(KPBUS1,Kern::Printf(">ms:eng")); |
441 __KTRACE_OPT(KPBUS1,Kern::Printf(">ms:eng")); |
399 |
442 |
400 if( iStackP == NULL ) |
443 if( iStackP == NULL ) |
401 return( KErrBadDriver ); |
444 { |
|
445 OstTraceFunctionExitExt( DMMCSESSION_ENGAGE_EXIT, this, KErrBadDriver ); |
|
446 return KErrBadDriver; |
|
447 } |
402 |
448 |
403 if( iStackP->iLockingSessionP != NULL && iStackP->iLockingSessionP != this && |
449 if( iStackP->iLockingSessionP != NULL && iStackP->iLockingSessionP != this && |
404 (iStackP->EffectiveModes(iConfig) & KMMCModeEnqueIfLocked) == 0 ) |
450 (iStackP->EffectiveModes(iConfig) & KMMCModeEnqueIfLocked) == 0 ) |
405 return( KErrServerBusy ); |
451 { |
|
452 OstTraceFunctionExitExt( DUP1_DMMCSESSION_ENGAGE_EXIT, this, KErrServerBusy ); |
|
453 return KErrServerBusy; |
|
454 } |
406 |
455 |
407 const TMediaState doorState=iStackP->MMCSocket()->iMediaChange->MediaState(); |
456 const TMediaState doorState=iStackP->MMCSocket()->iMediaChange->MediaState(); |
408 |
457 |
409 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:Eng ds = %x", doorState)); |
458 __KTRACE_OPT(KPBUS1,Kern::Printf(">MMC:Eng ds = %x", doorState)); |
|
459 OstTrace1( TRACE_INTERNALS, DMMCSESSION_ENGAGE, "doorState = 0x%x", doorState); |
410 |
460 |
411 if (doorState == EDoorOpen) |
461 if (doorState == EDoorOpen) |
|
462 { |
|
463 OstTraceFunctionExitExt( DUP2_DMMCSESSION_ENGAGE_EXIT, this, KErrNotReady ); |
412 return KErrNotReady; |
464 return KErrNotReady; |
|
465 } |
413 |
466 |
414 SetupCIMControl(iSessionID); |
467 SetupCIMControl(iSessionID); |
415 |
468 |
416 iStackP->Add(this); |
469 iStackP->Add(this); |
417 |
470 |
418 __KTRACE_OPT(KPBUS1,Kern::Printf("<ms:eng")); |
471 __KTRACE_OPT(KPBUS1,Kern::Printf("<ms:eng")); |
419 return(KErrNone); |
472 OstTraceFunctionExitExt( DUP3_DMMCSESSION_ENGAGE_EXIT, this, KErrNone ); |
|
473 return KErrNone; |
420 } |
474 } |
421 |
475 |
422 // Command specification table for standard MMC commands (CMD0 - CMD63) |
476 // Command specification table for standard MMC commands (CMD0 - CMD63) |
423 extern const TMMCCommandSpec CommandTable[KMMCCommandMask+1] = |
477 extern const TMMCCommandSpec CommandTable[KMMCCommandMask+1] = |
424 {// Class Type Dir MBlk StopT Rsp Type Len Cmd No |
478 {// Class Type Dir MBlk StopT Rsp Type Len Cmd No |
493 EXPORT_C void DMMCSession::FillCommandDesc() |
547 EXPORT_C void DMMCSession::FillCommandDesc() |
494 /** |
548 /** |
495 * Fills the current command descriptor with the default data according to MMC spec V2.1 |
549 * Fills the current command descriptor with the default data according to MMC spec V2.1 |
496 */ |
550 */ |
497 { |
551 { |
|
552 OstTraceFunctionEntry1( DMMCSESSION_FILLCOMMANDDESC1_ENTRY, this ); |
498 TMMCCommandDesc& cmd = Command(); |
553 TMMCCommandDesc& cmd = Command(); |
499 cmd.iSpec = CommandTable[cmd.iCommand & KMMCCommandMask]; |
554 cmd.iSpec = CommandTable[cmd.iCommand & KMMCCommandMask]; |
500 |
555 |
501 cmd.iFlags = 0; |
556 cmd.iFlags = 0; |
502 cmd.iBytesDone = 0; |
557 cmd.iBytesDone = 0; |
|
558 OstTraceFunctionExit1( DMMCSESSION_FILLCOMMANDDESC1_EXIT, this ); |
503 } |
559 } |
504 |
560 |
505 EXPORT_C void DMMCSession::FillCommandDesc(TMMCCommandEnum aCommand) |
561 EXPORT_C void DMMCSession::FillCommandDesc(TMMCCommandEnum aCommand) |
506 /** |
562 /** |
507 * Initialises the current command according to whether it is a normal |
563 * Initialises the current command according to whether it is a normal |
508 * or an application command. |
564 * or an application command. |
509 * @param aCommand Contains the command. |
565 * @param aCommand Contains the command. |
510 */ |
566 */ |
511 { |
567 { |
|
568 OstTraceExt2(TRACE_FLOW, DMMCSESSION_FILLCOMMANDDESC2_ENTRY, "DMMCSession::FillCommandDesc;aCommand=%d;this=%x", (TInt) aCommand, (TUint) this); |
512 Command().iCommand = aCommand; |
569 Command().iCommand = aCommand; |
513 Command().iArgument = 0; // set stuff bits to zero |
570 Command().iArgument = 0; // set stuff bits to zero |
514 FillCommandDesc(); |
571 FillCommandDesc(); |
|
572 OstTraceFunctionExit1( DMMCSESSION_FILLCOMMANDDESC2_EXIT, this ); |
515 } |
573 } |
516 |
574 |
517 EXPORT_C void DMMCSession::FillCommandDesc(TMMCCommandEnum aCommand, TMMCArgument anArgument) |
575 EXPORT_C void DMMCSession::FillCommandDesc(TMMCCommandEnum aCommand, TMMCArgument anArgument) |
518 /** |
576 /** |
519 * Initialises the current command with an argument according to whether |
577 * Initialises the current command with an argument according to whether |
520 * it is a normal or an application command. |
578 * it is a normal or an application command. |
521 * @param aCommand Contains the command. |
579 * @param aCommand Contains the command. |
522 * @param anArgument Specifies the argument. |
580 * @param anArgument Specifies the argument. |
523 */ |
581 */ |
524 { |
582 { |
|
583 OstTraceExt3(TRACE_FLOW, DMMCSESSION_FILLCOMMANDDESC3_ENTRY, "DMMCSession::FillCommandDesc;aCommand=%d;anArgument=%x;this=%x", (TInt) aCommand, (TUint) anArgument, (TUint) this); |
525 TMMCCommandDesc& cmd = Command(); |
584 TMMCCommandDesc& cmd = Command(); |
526 cmd.iCommand = aCommand; |
585 cmd.iCommand = aCommand; |
527 FillCommandDesc(); |
586 FillCommandDesc(); |
528 cmd.iArgument = anArgument; |
587 cmd.iArgument = anArgument; |
|
588 OstTraceFunctionExit1( DMMCSESSION_FILLCOMMANDDESC3_EXIT, this ); |
529 } |
589 } |
530 |
590 |
531 EXPORT_C void DMMCSession::FillCommandArgs(TMMCArgument anArgument, TUint32 aLength, TUint8* aMemoryP, |
591 EXPORT_C void DMMCSession::FillCommandArgs(TMMCArgument anArgument, TUint32 aLength, TUint8* aMemoryP, |
532 TUint32 aBlkLen) |
592 TUint32 aBlkLen) |
533 /** |
593 /** |
538 * @param aLength aLength Total number of bytes to read/write. |
598 * @param aLength aLength Total number of bytes to read/write. |
539 * @param aMemoryP Host source/destination address |
599 * @param aMemoryP Host source/destination address |
540 * @param aBlkLen Block length |
600 * @param aBlkLen Block length |
541 */ |
601 */ |
542 { |
602 { |
|
603 OstTraceExt5(TRACE_FLOW, DMMCSESSION_FILLCOMMANDARGS_ENTRY ,"DMMCSession::FillCommandArgs;anArgument=%x;aLength=%x;aMemoryP=%x;aBlkLen=%x;this=%x", (TUint) anArgument, (TUint) aLength, (TUint) aMemoryP, (TUint) aBlkLen, (TUint) this); |
543 TMMCCommandDesc& cmd = Command(); |
604 TMMCCommandDesc& cmd = Command(); |
544 |
605 |
545 cmd.iArgument = anArgument; |
606 cmd.iArgument = anArgument; |
546 cmd.iTotalLength = aLength; |
607 cmd.iTotalLength = aLength; |
547 cmd.iDataMemoryP = aMemoryP; |
608 cmd.iDataMemoryP = aMemoryP; |
548 cmd.iBlockLength = aBlkLen; |
609 cmd.iBlockLength = aBlkLen; |
549 cmd.iFlags = 0; |
610 cmd.iFlags = 0; |
|
611 OstTraceFunctionExit1( DMMCSESSION_FILLCOMMANDARGS_EXIT, this ); |
550 } |
612 } |
551 |
613 |
552 const TMMCCommandSpec& DMMCSession::FindCommandSpec(const TMMCIdxCommandSpec aSpecs[], TInt aIdx) |
614 const TMMCCommandSpec& DMMCSession::FindCommandSpec(const TMMCIdxCommandSpec aSpecs[], TInt aIdx) |
553 /** |
615 /** |
554 * Searches the supplied command specification list for the specification corresponding to the |
616 * Searches the supplied command specification list for the specification corresponding to the |
555 * supplied command. |
617 * supplied command. |
556 * @param aSpecs The command specification list to be searched. |
618 * @param aSpecs The command specification list to be searched. |
557 * @param aIdx The requested command. |
619 * @param aIdx The requested command. |
558 */ |
620 */ |
559 { |
621 { |
|
622 OstTraceFunctionEntry0( DMMCSESSION_FINDCOMMANDSPEC_ENTRY ); |
560 TInt i = 0; |
623 TInt i = 0; |
561 while (aSpecs[i].iIdx != aIdx) |
624 while (aSpecs[i].iIdx != aIdx) |
562 ++i; |
625 ++i; |
|
626 OstTraceFunctionExit0( DMMCSESSION_FINDCOMMANDSPEC_EXIT ); |
563 return aSpecs[i].iSpec; |
627 return aSpecs[i].iSpec; |
564 } |
628 } |
565 |
629 |
566 void DMMCSession::SynchBlock(TUint32 aFlag) |
630 void DMMCSession::SynchBlock(TUint32 aFlag) |
567 // |
631 // |
568 // Blocks a session synchronously (within scheduler context) |
632 // Blocks a session synchronously (within scheduler context) |
569 // |
633 // |
570 { |
634 { |
|
635 OstTraceFunctionEntryExt( DMMCSESSION_SYNCHBLOCK_ENTRY, this ); |
571 (void)__e32_atomic_ior_ord32(&iBlockOn, aFlag); |
636 (void)__e32_atomic_ior_ord32(&iBlockOn, aFlag); |
|
637 OstTraceFunctionExit1( DMMCSESSION_SYNCHBLOCK_EXIT, this ); |
572 } |
638 } |
573 |
639 |
574 void DMMCSession::SynchUnBlock(TUint32 aFlag) |
640 void DMMCSession::SynchUnBlock(TUint32 aFlag) |
575 // |
641 // |
576 // Unblocks a session synchronously (within scheduler context) |
642 // Unblocks a session synchronously (within scheduler context) |
577 // |
643 // |
578 { |
644 { |
|
645 OstTraceFunctionEntryExt( DMMCSESSION_SYNCHUNBLOCK_ENTRY, this ); |
579 if( (iBlockOn & aFlag) == 0 ) |
646 if( (iBlockOn & aFlag) == 0 ) |
|
647 { |
|
648 OstTraceFunctionExit1( DMMCSESSION_SYNCHUNBLOCK_EXIT, this ); |
580 return; |
649 return; |
|
650 } |
581 |
651 |
582 (void)__e32_atomic_and_ord32(&iBlockOn, ~aFlag); |
652 (void)__e32_atomic_and_ord32(&iBlockOn, ~aFlag); |
|
653 OstTraceFunctionExit1( DUP1_DMMCSESSION_SYNCHUNBLOCK_EXIT, this ); |
583 } |
654 } |
584 |
655 |
585 EXPORT_C TRCA DMMCSession::CardRCA() |
656 EXPORT_C TRCA DMMCSession::CardRCA() |
586 /** |
657 /** |
587 * Checks that the card is still the same and ready |
658 * Checks that the card is still the same and ready |
596 } |
667 } |
597 |
668 |
598 #ifdef __EPOC32__ |
669 #ifdef __EPOC32__ |
599 void DMMCSession::ProgramTimerCallBack(TAny* aSessP) |
670 void DMMCSession::ProgramTimerCallBack(TAny* aSessP) |
600 { |
671 { |
|
672 OstTraceFunctionEntry0( DMMCSESSION_PROGRAMTIMERCALLBACK_ENTRY ); |
601 __KTRACE_OPT(KPBUS1,Kern::Printf("=mss:pgtcb")); |
673 __KTRACE_OPT(KPBUS1,Kern::Printf("=mss:pgtcb")); |
602 |
674 |
603 static_cast<DMMCSession *>(aSessP)->iState |= KMMCSessStateDoDFC; |
675 static_cast<DMMCSession *>(aSessP)->iState |= KMMCSessStateDoDFC; |
604 static_cast<DMMCSession *>(aSessP)->UnBlock(KMMCBlockOnPgmTimer, KMMCErrNone); |
676 static_cast<DMMCSession *>(aSessP)->UnBlock(KMMCBlockOnPgmTimer, KMMCErrNone); |
|
677 OstTraceFunctionExit0( DMMCSESSION_PROGRAMTIMERCALLBACK_EXIT ); |
605 } |
678 } |
606 |
679 |
607 void DMMCSession::PollTimerCallBack(TAny* aSessP) |
680 void DMMCSession::PollTimerCallBack(TAny* aSessP) |
608 { |
681 { |
|
682 OstTraceFunctionEntry0( DMMCSESSION_POLLTIMERCALLBACK_ENTRY ); |
609 __KTRACE_OPT(KPBUS1,Kern::Printf("=mss:ptcb")); |
683 __KTRACE_OPT(KPBUS1,Kern::Printf("=mss:ptcb")); |
610 |
684 |
611 static_cast<DMMCSession *>(aSessP)->iState |= KMMCSessStateDoDFC; |
685 static_cast<DMMCSession *>(aSessP)->iState |= KMMCSessStateDoDFC; |
612 static_cast<DMMCSession *>(aSessP)->UnBlock(KMMCBlockOnPollTimer, KMMCErrNone); |
686 static_cast<DMMCSession *>(aSessP)->UnBlock(KMMCBlockOnPollTimer, KMMCErrNone); |
|
687 OstTraceFunctionExit0( DMMCSESSION_POLLTIMERCALLBACK_EXIT ); |
613 } |
688 } |
614 |
689 |
615 void DMMCSession::RetryTimerCallBack(TAny* aSessP) |
690 void DMMCSession::RetryTimerCallBack(TAny* aSessP) |
616 { |
691 { |
|
692 OstTraceFunctionEntry0( DMMCSESSION_RETRYTIMERCALLBACK_ENTRY ); |
617 __KTRACE_OPT(KPBUS1,Kern::Printf("=mss:rtcb")); |
693 __KTRACE_OPT(KPBUS1,Kern::Printf("=mss:rtcb")); |
618 |
694 |
619 static_cast<DMMCSession *>(aSessP)->iState |= KMMCSessStateDoDFC; |
695 static_cast<DMMCSession *>(aSessP)->iState |= KMMCSessStateDoDFC; |
620 static_cast<DMMCSession *>(aSessP)->UnBlock(KMMCBlockOnRetryTimer, KMMCErrNone); |
696 static_cast<DMMCSession *>(aSessP)->UnBlock(KMMCBlockOnRetryTimer, KMMCErrNone); |
|
697 OstTraceFunctionExit0( DMMCSESSION_RETRYTIMERCALLBACK_EXIT ); |
621 } |
698 } |
622 |
699 |
623 #endif // #ifdef __EPOC32__ |
700 #endif // #ifdef __EPOC32__ |
624 |
701 |
625 EXPORT_C TInt DMMCSession::EpocErrorCode() const |
702 EXPORT_C TInt DMMCSession::EpocErrorCode() const |
628 * The Symbian OS error code is derived from both the last MMC specific exit code MMCExitCode() |
705 * The Symbian OS error code is derived from both the last MMC specific exit code MMCExitCode() |
629 * and the last status information from the card (iLastStatus). |
706 * and the last status information from the card (iLastStatus). |
630 * @return Standard Symbian OS error code |
707 * @return Standard Symbian OS error code |
631 */ |
708 */ |
632 { |
709 { |
|
710 OstTraceFunctionEntry1( DMMCSESSION_EPOCERRORCODE_ENTRY, this ); |
633 __KTRACE_OPT(KPBUS1,Kern::Printf("=mss:eee:%08x,%08x", MMCExitCode(), LastStatus().State() )); |
711 __KTRACE_OPT(KPBUS1,Kern::Printf("=mss:eee:%08x,%08x", MMCExitCode(), LastStatus().State() )); |
634 |
712 OstTraceExt2( TRACE_INTERNALS, DMMCSESSION_EPOCERRORCODE, "MMCExitCode = 0x%08x; LastStatus State = 0x%08x", (TUint) MMCExitCode(), (TUint) LastStatus().State()); |
|
713 |
635 struct errorTableEntry |
714 struct errorTableEntry |
636 { |
715 { |
637 TUint32 iMask; |
716 TUint32 iMask; |
638 TInt iErrorCode; |
717 TInt iErrorCode; |
639 }; |
718 }; |
668 }; |
747 }; |
669 |
748 |
670 TUint32 errCode = MMCExitCode(); |
749 TUint32 errCode = MMCExitCode(); |
671 |
750 |
672 if( errCode == 0 ) |
751 if( errCode == 0 ) |
|
752 { |
|
753 OstTraceFunctionExitExt( DMMCSESSION_EPOCERRORCODE_EXIT, this, KErrNone ); |
673 return KErrNone; |
754 return KErrNone; |
|
755 } |
674 |
756 |
675 const errorTableEntry* ptr = &mmcTable[0]; |
757 const errorTableEntry* ptr = &mmcTable[0]; |
676 |
758 |
677 if( errCode == KMMCErrStatus ) |
759 if( errCode == KMMCErrStatus ) |
678 { |
760 { |
679 ptr = &statusTable[0]; |
761 ptr = &statusTable[0]; |
680 |
762 |
681 if( (errCode = LastStatus()) == 0 ) |
763 if( (errCode = LastStatus()) == 0 ) |
682 return( KErrUnknown ); |
764 { |
|
765 OstTraceFunctionExitExt( DUP1_DMMCSESSION_EPOCERRORCODE_EXIT, this, KErrUnknown ); |
|
766 return KErrUnknown; |
|
767 } |
683 } |
768 } |
684 |
769 |
685 for( ;; ) |
770 for( ;; ) |
686 if( (errCode & ptr->iMask) != 0 ) |
771 if( (errCode & ptr->iMask) != 0 ) |
687 return( ptr->iErrorCode ); |
772 { |
|
773 TInt ret = ptr->iErrorCode; |
|
774 OstTraceFunctionExitExt( DUP2_DMMCSESSION_EPOCERRORCODE_EXIT, this, ret ); |
|
775 return ret; |
|
776 } |
688 else |
777 else |
689 ptr++; |
778 ptr++; |
690 } |
779 } |