152 if (virtualPinContainer.iObject) |
163 if (virtualPinContainer.iObject) |
153 Kern::DestroyVirtualPinObject(virtualPinContainer.iObject); |
164 Kern::DestroyVirtualPinObject(virtualPinContainer.iObject); |
154 } |
165 } |
155 |
166 |
156 delete [] iVirtualPinContainers; |
167 delete [] iVirtualPinContainers; |
|
168 OstTraceFunctionExit1( DPINOBJECTALLOCATOR_DPINOBJECTALLOCATOR_EXIT, this ); |
157 } |
169 } |
158 |
170 |
159 TInt DPinObjectAllocator::Construct(TInt aObjectCount, TUint aNumPages) |
171 TInt DPinObjectAllocator::Construct(TInt aObjectCount, TUint aNumPages) |
160 { |
172 { |
|
173 OstTraceFunctionEntryExt( DPINOBJECTALLOCATOR_CONSTRUCT_ENTRY, this ); |
161 TInt pageSize = Kern::RoundToPageSize(1); |
174 TInt pageSize = Kern::RoundToPageSize(1); |
162 iFragmentGranularity = pageSize * aNumPages; |
175 iFragmentGranularity = pageSize * aNumPages; |
163 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation granularity set to 0x%x", iFragmentGranularity)); |
176 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation granularity set to 0x%x", iFragmentGranularity)); |
164 |
177 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPINOBJECTALLOCATOR_CONSTRUCT, "Fragmentation granularity=0x%x", iFragmentGranularity); |
|
178 |
165 // construct the paging lock containing pre-allocated buffers |
179 // construct the paging lock containing pre-allocated buffers |
166 |
180 |
167 iPreAllocatedDataLock = new DFragmentationPagingLock(); |
181 iPreAllocatedDataLock = new DFragmentationPagingLock(); |
168 if(!iPreAllocatedDataLock) |
182 if(!iPreAllocatedDataLock) |
|
183 { |
|
184 OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT1, this, KErrNoMemory ); |
169 return KErrNoMemory; |
185 return KErrNoMemory; |
|
186 } |
170 TInt r = iPreAllocatedDataLock->Construct(aNumPages); |
187 TInt r = iPreAllocatedDataLock->Construct(aNumPages); |
171 if (r != KErrNone) |
188 if (r != KErrNone) |
|
189 { |
|
190 OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT2, this, r ); |
172 return r; |
191 return r; |
|
192 } |
173 |
193 |
174 |
194 |
175 SVirtualPinContainer* iVirtualPinContainers = new SVirtualPinContainer[aObjectCount]; |
195 SVirtualPinContainer* iVirtualPinContainers = new SVirtualPinContainer[aObjectCount]; |
176 if (iVirtualPinContainers == NULL) |
196 if (iVirtualPinContainers == NULL) |
|
197 { |
|
198 OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT3, this, KErrNoMemory ); |
177 return KErrNoMemory; |
199 return KErrNoMemory; |
|
200 } |
178 memclr(iVirtualPinContainers, sizeof(SVirtualPinContainer) * aObjectCount); |
201 memclr(iVirtualPinContainers, sizeof(SVirtualPinContainer) * aObjectCount); |
179 iObjectCount = aObjectCount; |
202 iObjectCount = aObjectCount; |
180 |
203 |
181 // construct the queue of dynamic paging locks |
204 // construct the queue of dynamic paging locks |
182 for (TInt n=0; n<aObjectCount; n++) |
205 for (TInt n=0; n<aObjectCount; n++) |
183 { |
206 { |
184 SVirtualPinContainer& pinContainer = iVirtualPinContainers[n]; |
207 SVirtualPinContainer& pinContainer = iVirtualPinContainers[n]; |
185 |
208 |
186 TInt r = Kern::CreateVirtualPinObject(pinContainer.iObject); |
209 TInt r = Kern::CreateVirtualPinObject(pinContainer.iObject); |
187 if (r != KErrNone) |
210 if (r != KErrNone) |
|
211 { |
|
212 OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT4, this, KErrNoMemory ); |
188 return KErrNoMemory; |
213 return KErrNoMemory; |
189 |
214 } |
190 |
215 |
191 iFreeQ.Add(&pinContainer.iLink); |
216 iFreeQ.Add(&pinContainer.iLink); |
192 } |
217 } |
|
218 |
|
219 OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT5, this, KErrNone ); |
193 return KErrNone; |
220 return KErrNone; |
194 } |
221 } |
195 |
222 |
196 /** |
223 /** |
197 returns a SVirtualPinContainer object or NULL if NULL available |
224 returns a SVirtualPinContainer object or NULL if NULL available |
198 */ |
225 */ |
199 DPinObjectAllocator::SVirtualPinContainer* DPinObjectAllocator::AcquirePinObject() |
226 DPinObjectAllocator::SVirtualPinContainer* DPinObjectAllocator::AcquirePinObject() |
200 { |
227 { |
|
228 OstTraceFunctionEntry1( DPINOBJECTALLOCATOR_ACQUIREPINOBJECT_ENTRY, this ); |
201 SVirtualPinContainer* pinContainer = NULL; |
229 SVirtualPinContainer* pinContainer = NULL; |
202 |
230 |
203 NKern::FMWait(&iLock); |
231 NKern::FMWait(&iLock); |
204 |
232 |
205 if (!iFreeQ.IsEmpty()) |
233 if (!iFreeQ.IsEmpty()) |
306 Kern::QueueRequestComplete(pC,iNotifyChangeRequest,KErrCancel); |
341 Kern::QueueRequestComplete(pC,iNotifyChangeRequest,KErrCancel); |
307 pC->Close(NULL); // balances Open() in DoCreate |
342 pC->Close(NULL); // balances Open() in DoCreate |
308 } |
343 } |
309 if (iNotifyChangeRequest) |
344 if (iNotifyChangeRequest) |
310 Kern::DestroyClientRequest(iNotifyChangeRequest); |
345 Kern::DestroyClientRequest(iNotifyChangeRequest); |
|
346 OstTraceFunctionExit1( DLOCALDRIVE_DLOCALDRIVE_EXIT, this ); |
311 } |
347 } |
312 |
348 |
313 TInt DLocalDrive::DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer) |
349 TInt DLocalDrive::DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer) |
314 { |
350 { |
|
351 OstTraceFunctionEntry1( DLOCALDRIVE_DOCREATE_ENTRY, this ); |
|
352 |
315 if(!Kern::CurrentThreadHasCapability(ECapabilityTCB,__PLATSEC_DIAGNOSTIC_STRING("Checked by ELOCD.LDD (Local Media Driver)"))) |
353 if(!Kern::CurrentThreadHasCapability(ECapabilityTCB,__PLATSEC_DIAGNOSTIC_STRING("Checked by ELOCD.LDD (Local Media Driver)"))) |
|
354 { |
|
355 OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT1, this, KErrPermissionDenied ); |
316 return KErrPermissionDenied; |
356 return KErrPermissionDenied; |
|
357 } |
317 if (!Kern::QueryVersionSupported(TVersion(KLocalDriveMajorVersion,KLocalDriveMinorVersion,KLocalDriveBuildVersion),aVer)) |
358 if (!Kern::QueryVersionSupported(TVersion(KLocalDriveMajorVersion,KLocalDriveMinorVersion,KLocalDriveBuildVersion),aVer)) |
|
359 { |
|
360 OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT2, this, KErrNotSupported ); |
318 return KErrNotSupported; |
361 return KErrNotSupported; |
|
362 } |
319 |
363 |
320 NKern::ThreadEnterCS(); |
364 NKern::ThreadEnterCS(); |
321 TInt r = Kern::CreateClientDataRequest(iNotifyChangeRequest); |
365 TInt r = Kern::CreateClientDataRequest(iNotifyChangeRequest); |
322 NKern::ThreadLeaveCS(); |
366 NKern::ThreadLeaveCS(); |
323 if (r != KErrNone) |
367 if (r != KErrNone) |
|
368 { |
|
369 OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT3, this, r ); |
324 return r; |
370 return r; |
325 |
371 } |
|
372 |
326 DThread& t=Kern::CurrentThread(); |
373 DThread& t=Kern::CurrentThread(); |
327 NKern::LockSystem(); |
374 NKern::LockSystem(); |
328 t.AddCleanup(&iCleanup); |
375 t.AddCleanup(&iCleanup); |
329 NKern::UnlockSystem(); |
376 NKern::UnlockSystem(); |
330 t.Open(); |
377 t.Open(); |
331 iNotifyChangeRequest->SetDestPtr((TBool*) anInfo); |
378 iNotifyChangeRequest->SetDestPtr((TBool*) anInfo); |
332 |
379 |
333 iDrive=TheDrives[aUnit]; |
380 iDrive=TheDrives[aUnit]; |
334 if (!iDrive) |
381 if (!iDrive) |
|
382 { |
|
383 OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT4, this, KErrNotSupported ); |
335 return KErrNotSupported; |
384 return KErrNotSupported; |
|
385 } |
336 __KTRACE_OPT(KLOCDRV,Kern::Printf("DLocalDrive Create - connect to drive %d, M:%08x",iDrive->iDriveNumber,iDrive->iMedia)); |
386 __KTRACE_OPT(KLOCDRV,Kern::Printf("DLocalDrive Create - connect to drive %d, M:%08x",iDrive->iDriveNumber,iDrive->iMedia)); |
337 r=iDrive->Connect(this); |
387 r=iDrive->Connect(this); |
338 __KTRACE_OPT(KLOCDRV,Kern::Printf("<DLocalDrive Create D:%d, M:%08x r:%d",iDrive->iDriveNumber,iDrive->iMedia,r)); |
388 __KTRACE_OPT(KLOCDRV,Kern::Printf("<DLocalDrive Create D:%d, M:%08x r:%d",iDrive->iDriveNumber,iDrive->iMedia,r)); |
|
389 |
339 if (r!=KErrNone) |
390 if (r!=KErrNone) |
340 iDrive=NULL; // didn't connect so don't disconnect |
391 iDrive=NULL; // didn't connect so don't disconnect |
|
392 |
|
393 OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT5, this, r ); |
341 return r; |
394 return r; |
342 } |
395 } |
343 |
396 |
344 #if defined(_DEBUG) |
397 #if defined(_DEBUG) |
345 void DebugDumpDriveCaps(const TLocDrv* aDrive, const TAny* aCaps) |
398 void DebugDumpDriveCaps(const TLocDrv* aDrive, const TAny* aCaps) |
400 r=m.ProcessMessageData(a1); |
456 r=m.ProcessMessageData(a1); |
401 __TRACE_TIMING(1); |
457 __TRACE_TIMING(1); |
402 if (r==KErrNone) |
458 if (r==KErrNone) |
403 { |
459 { |
404 __TRACE_TIMING(2); |
460 __TRACE_TIMING(2); |
|
461 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READ, "ERead iDriveNumber=%d; length=0x%x; position=0x%x; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) m.Length(), (TUint) m.Pos(), (TUint) &m); |
405 r=iDrive->Request(m); |
462 r=iDrive->Request(m); |
406 __TRACE_TIMING(3); |
463 __TRACE_TIMING(3); |
|
464 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READ_RETURN, "ERead Return iDriveNumber=%d; length=0x%x; position=0x%x; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) m.Length(), (TUint) m.Pos(), (TUint) &m ); |
407 } |
465 } |
408 m.CloseRemoteThread(); |
466 m.CloseRemoteThread(); |
409 break; |
467 break; |
410 } |
468 } |
411 case RLocalDrive::EControlWrite: |
469 case RLocalDrive::EControlWrite: |
412 { |
470 { |
413 m.Id()=EWrite; |
471 m.Id()=EWrite; |
414 r=m.ProcessMessageData(a1); |
472 r=m.ProcessMessageData(a1); |
415 if (r==KErrNone) |
473 if (r==KErrNone) |
|
474 { |
|
475 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITE, "EWrite iDriveNumber=%d; length=0x%x; position=0x%x; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) m.Length(), (TUint) m.Pos(), (TUint) &m ); |
416 r=iDrive->Request(m); |
476 r=iDrive->Request(m); |
|
477 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITE_RETURN, "EWrite Return iDriveNumber=%d; length=0x%x; position=0x%x; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) m.Length(), (TUint) m.Pos(), (TUint) &m ); |
|
478 } |
417 m.CloseRemoteThread(); |
479 m.CloseRemoteThread(); |
418 break; |
480 break; |
419 } |
481 } |
420 case RLocalDrive::EControlCaps: |
482 case RLocalDrive::EControlCaps: |
421 { |
483 { |
496 break; |
571 break; |
497 } |
572 } |
498 m.Pos()=(TInt)a1; |
573 m.Pos()=(TInt)a1; |
499 m.Length()=(TInt)a2; |
574 m.Length()=(TInt)a2; |
500 m.Id()=EReduce; |
575 m.Id()=EReduce; |
|
576 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_REDUCE, "EReduce; TLocDrvRequest Object=0x%x", (TUint) &m); |
501 r=iDrive->Request(m); |
577 r=iDrive->Request(m); |
|
578 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_REDUCE_RETURN, "EReduce Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
502 break; |
579 break; |
503 } |
580 } |
504 case RLocalDrive::EControlForceMediaChange: |
581 case RLocalDrive::EControlForceMediaChange: |
505 m.Pos()=(TInt)a1; |
582 m.Pos()=(TInt)a1; |
506 m.Id()=EForceMediaChange; |
583 m.Id()=EForceMediaChange; |
|
584 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORCEMEDIACHANGE, "EForceMediaChange; TLocDrvRequest Object=0x%x", (TUint) &m); |
507 r = iDrive->Request(m); |
585 r = iDrive->Request(m); |
|
586 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORCEMEDIACHANGE_RETURN, "EForceMediaChange Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
508 break; |
587 break; |
509 case RLocalDrive::EControlMediaDevice: |
588 case RLocalDrive::EControlMediaDevice: |
|
589 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLMEDIADEVICE, "EControlMediaDevice; TLocDrvRequest Object=0x%x", (TUint) &m); |
510 r=iDrive->iPrimaryMedia->iDevice; |
590 r=iDrive->iPrimaryMedia->iDevice; |
511 break; |
591 break; |
512 case RLocalDrive::EControlIsRemovable: |
592 case RLocalDrive::EControlIsRemovable: |
513 { |
593 { |
|
594 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLISREMOVABLE, "EControlIsRemovable; TLocDrvRequest Object=0x%x", (TUint) &m); |
514 TInt sockNum; |
595 TInt sockNum; |
515 r=iDrive->iPrimaryMedia->IsRemovableDevice(sockNum); |
596 r=iDrive->iPrimaryMedia->IsRemovableDevice(sockNum); |
516 if (r) |
597 if (r) |
517 kumemput32(a1,&sockNum,sizeof(TInt)); |
598 kumemput32(a1,&sockNum,sizeof(TInt)); |
518 break; |
599 break; |
542 //We're highjacking fields representing |
623 //We're highjacking fields representing |
543 //length and position in a normal message, so |
624 //length and position in a normal message, so |
544 //let's not have the dispatcher function attempt |
625 //let's not have the dispatcher function attempt |
545 //to adjust for partition size. |
626 //to adjust for partition size. |
546 m.Flags() |= TLocDrvRequest::EAdjusted; |
627 m.Flags() |= TLocDrvRequest::EAdjusted; |
547 |
628 |
|
629 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLCONTROLIO, "EControlControlIO; TLocDrvRequest Object=0x%x", (TUint) &m); |
548 r=iDrive->Request(m); |
630 r=iDrive->Request(m); |
|
631 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLCONTROLIO_RETURN, "EControlControlIO Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
549 break; |
632 break; |
550 } |
633 } |
551 case RLocalDrive::EControlSetMountInfo: |
634 case RLocalDrive::EControlSetMountInfo: |
552 { |
635 { |
|
636 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLSETMOUNTINFO, "EControlSetMountInfo; TLocDrvRequest Object=0x%x", (TUint) &m); |
553 m.Id()=ERead; |
637 m.Id()=ERead; |
554 r=m.ProcessMessageData(a1); |
638 r=m.ProcessMessageData(a1); |
555 DPrimaryMediaBase* pM=iDrive->iPrimaryMedia; |
639 DPrimaryMediaBase* pM=iDrive->iPrimaryMedia; |
556 if(!pM || r!=KErrNone) |
640 if(!pM || r!=KErrNone) |
557 break; |
641 break; |
651 TMediaPassword newPasswd; |
743 TMediaPassword newPasswd; |
652 TLocalDrivePasswordData pswData; |
744 TLocalDrivePasswordData pswData; |
653 r = ReadPasswordData(m, pswData, oldPasswd, newPasswd); |
745 r = ReadPasswordData(m, pswData, oldPasswd, newPasswd); |
654 |
746 |
655 if (r == KErrNone) |
747 if (r == KErrNone) |
|
748 { |
|
749 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDCLEAR, "EPasswordClear; TLocDrvRequest Object=0x%x", (TUint) &m); |
656 r = iDrive->Request(m); |
750 r = iDrive->Request(m); |
|
751 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDCLEAR_RETURN, "EPasswordClear Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
|
752 } |
657 break; |
753 break; |
658 } |
754 } |
659 case RLocalDrive::EControlPasswordErase: |
755 case RLocalDrive::EControlPasswordErase: |
660 { |
756 { |
661 m.Id()=EPasswordErase; |
757 m.Id()=EPasswordErase; |
|
758 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDERASE, "EPasswordErase; TLocDrvRequest Object=0x%x", (TUint) &m); |
662 r=iDrive->Request(m); |
759 r=iDrive->Request(m); |
|
760 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDERASE_RETURN, "EPasswordErase Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
663 if(r == KErrNone) |
761 if(r == KErrNone) |
664 iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
762 iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
665 break; |
763 break; |
666 } |
764 } |
667 case RLocalDrive::EControlNotifyChange: |
765 case RLocalDrive::EControlNotifyChange: |
668 if (iCleanup.iThread != &Kern::CurrentThread()) |
766 if (iCleanup.iThread != &Kern::CurrentThread()) |
669 Kern::PanicCurrentThread(KLitLocMedia,KErrAccessDenied); |
767 Kern::PanicCurrentThread(KLitLocMedia,KErrAccessDenied); |
670 r=KErrNone; |
768 r=KErrNone; |
671 if (!iNotifyChangeRequest->StatusPtr()) |
769 if (!iNotifyChangeRequest->StatusPtr()) |
672 r = iNotifyChangeRequest->SetStatus((TRequestStatus*) a1); |
770 r = iNotifyChangeRequest->SetStatus((TRequestStatus*) a1); |
|
771 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLNOTIFYCHANGE, "EControlNotifyChange; TLocDrvRequest Object=0x%x", (TUint) &m); |
673 break; |
772 break; |
674 case RLocalDrive::EControlNotifyChangeCancel: |
773 case RLocalDrive::EControlNotifyChangeCancel: |
675 if (iCleanup.iThread != &Kern::CurrentThread()) |
774 if (iCleanup.iThread != &Kern::CurrentThread()) |
676 Kern::PanicCurrentThread(KLitLocMedia,KErrAccessDenied); |
775 Kern::PanicCurrentThread(KLitLocMedia,KErrAccessDenied); |
677 Kern::QueueRequestComplete(iCleanup.iThread,iNotifyChangeRequest,KErrCancel); |
776 Kern::QueueRequestComplete(iCleanup.iThread,iNotifyChangeRequest,KErrCancel); |
|
777 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLNOTIFYCHANGECANCEL, "EControlNotifyChangeCancel; TLocDrvRequest Object=0x%x", (TUint) &m); |
678 break; |
778 break; |
679 case RLocalDrive::EControlReadPasswordStore: |
779 case RLocalDrive::EControlReadPasswordStore: |
680 { |
780 { |
681 TUint8 passData[TPasswordStore::EMaxPasswordLength]; |
781 TUint8 passData[TPasswordStore::EMaxPasswordLength]; |
682 m.RemoteDes() = (TAny*) passData; |
782 m.RemoteDes() = (TAny*) passData; |
683 m.Length() = sizeof(passData); |
783 m.Length() = sizeof(passData); |
684 m.Id()=EReadPasswordStore; |
784 m.Id()=EReadPasswordStore; |
|
785 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READPASSWORDSTORE, "EReadPasswordStore; TLocDrvRequest Object=0x%x", (TUint) &m); |
685 r=iDrive->Request(m); |
786 r=iDrive->Request(m); |
|
787 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READPASSWORDSTORE_RETURN, "EReadPasswordStore Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
686 if (r==KErrNone) |
788 if (r==KErrNone) |
687 { |
789 { |
688 TPtr8 pData(passData, (TInt) m.Length(), TPasswordStore::EMaxPasswordLength); |
790 TPtr8 pData(passData, (TInt) m.Length(), TPasswordStore::EMaxPasswordLength); |
689 m.RemoteDes()=(TDes8*)a1; |
791 m.RemoteDes()=(TDes8*)a1; |
690 r = m.WriteRemote(&pData,0); |
792 r = m.WriteRemote(&pData,0); |
713 |
815 |
714 |
816 |
715 m.RemoteDes() = (TAny*) pData.Ptr(); |
817 m.RemoteDes() = (TAny*) pData.Ptr(); |
716 m.Length() = pData.Length(); |
818 m.Length() = pData.Length(); |
717 m.Id()=EWritePasswordStore; |
819 m.Id()=EWritePasswordStore; |
|
820 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITEPASSWORDSTORE, "EWritePasswordStore; TLocDrvRequest Object=0x%x", (TUint) &m); |
718 r=iDrive->Request(m); |
821 r=iDrive->Request(m); |
|
822 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITEPASSWORDSTORE_RETURN, "EReadPasswordStore Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
719 if(r == KErrNone) |
823 if(r == KErrNone) |
720 iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
824 iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
721 break; |
825 break; |
722 } |
826 } |
723 case RLocalDrive::EControlPasswordStoreLengthInBytes: |
827 case RLocalDrive::EControlPasswordStoreLengthInBytes: |
724 { |
828 { |
725 m.Id()=EPasswordStoreLengthInBytes; |
829 m.Id()=EPasswordStoreLengthInBytes; |
726 TInt length; |
830 TInt length; |
727 m.RemoteDes() = (TAny*) &length; |
831 m.RemoteDes() = (TAny*) &length; |
|
832 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDSTORELENGTH, "EPasswordStoreLengthInBytes; TLocDrvRequest Object=0x%x", (TUint) &m); |
728 r=iDrive->Request(m); |
833 r=iDrive->Request(m); |
|
834 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDSTORELENGTH_RETURN, "EPasswordStoreLengthInBytes Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
729 |
835 |
730 if (r == KErrNone) |
836 if (r == KErrNone) |
731 { |
837 { |
732 m.RemoteDes()=a1; |
838 m.RemoteDes()=a1; |
733 r = m.WriteRemoteRaw(&length,sizeof(TInt)); |
839 r = m.WriteRemoteRaw(&length,sizeof(TInt)); |
742 TErrorInfoBuf errorInfoBuf; |
848 TErrorInfoBuf errorInfoBuf; |
743 errorInfoBuf.SetMax(); |
849 errorInfoBuf.SetMax(); |
744 errorInfoBuf.FillZ(); |
850 errorInfoBuf.FillZ(); |
745 m.RemoteDes()=(TAny*) errorInfoBuf.Ptr(); // overload this |
851 m.RemoteDes()=(TAny*) errorInfoBuf.Ptr(); // overload this |
746 m.Length() = errorInfoBuf.MaxLength(); |
852 m.Length() = errorInfoBuf.MaxLength(); |
|
853 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_GETLASTERRORINFO, "EGetLastErrorInfo; TLocDrvRequest Object=0x%x", (TUint) &m); |
747 r=iDrive->Request(m); |
854 r=iDrive->Request(m); |
|
855 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLGETLASTERRORINFO_RETURN, "EControlGetLastErrorInfo Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
748 Kern::InfoCopy(*(TDes8*)a1, errorInfoBuf); |
856 Kern::InfoCopy(*(TDes8*)a1, errorInfoBuf); |
749 break; |
857 break; |
750 } |
858 } |
751 case RLocalDrive::EControlDeleteNotify: |
859 case RLocalDrive::EControlDeleteNotify: |
752 { |
860 { |
753 m.Id()=EDeleteNotify; |
861 m.Id()=EDeleteNotify; |
754 r=m.ProcessMessageData(a1); |
862 r=m.ProcessMessageData(a1); |
755 if (r==KErrNone) |
863 if (r==KErrNone) |
|
864 { |
|
865 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_DELETENOTIFY, "EDeleteNotify; TLocDrvRequest Object=0x%x", (TUint) &m); |
756 r=iDrive->Request(m); |
866 r=iDrive->Request(m); |
|
867 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_DELETENOTIFY_RETURN, "EDeleteNotify Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
|
868 } |
757 break; |
869 break; |
758 } |
870 } |
759 |
871 |
760 case RLocalDrive::EControlQueryDevice: |
872 case RLocalDrive::EControlQueryDevice: |
761 { |
873 { |
762 TBuf8<KMaxQueryDeviceLength> queryBuf; |
874 TBuf8<KMaxQueryDeviceLength> queryBuf; |
763 queryBuf.SetMax(); |
875 queryBuf.SetMax(); |
764 queryBuf.FillZ(); |
876 queryBuf.FillZ(); |
765 |
877 |
766 m.Id() = EQueryDevice; |
878 m.Id() = EQueryDevice; |
767 m.iArg[0] = a1; // RLocalDrive::TQueryDevice |
879 m.iArg[0] = a1; // RLocalDrive::TQueryDevice |
768 m.RemoteDes() = (TAny*)queryBuf.Ptr(); // overload this |
880 m.RemoteDes() = (TAny*)queryBuf.Ptr(); // overload this |
769 m.Length() = KMaxLocalDriveCapsLength; // for pinning |
881 m.Length() = KMaxLocalDriveCapsLength; // for pinning |
|
882 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_QUERYDEVICE, "EQueryDevice; TLocDrvRequest Object=0x%x", (TUint) &m); |
770 r=iDrive->Request(m); |
883 r=iDrive->Request(m); |
771 |
884 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_QUERYDEVICE_RETURN, "EQueryDevice Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
772 Kern::InfoCopy(*(TDes8*)a2, queryBuf); |
885 Kern::InfoCopy(*(TDes8*)a2, queryBuf); |
773 break; |
886 break; |
774 } |
887 } |
775 |
888 |
776 } |
889 } |
777 __KTRACE_OPT(KLOCDRV,Kern::Printf("<DLocalDrive::DoControl D:%d M:%08x ret %d",iDrive->iDriveNumber, iDrive->iMedia, r)); |
890 __KTRACE_OPT(KLOCDRV,Kern::Printf("<DLocalDrive::DoControl D:%d M:%08x ret %d",iDrive->iDriveNumber, iDrive->iMedia, r)); |
778 __TRACE_TIMING(4); |
891 __TRACE_TIMING(4); |
|
892 OstTraceFunctionExitExt( DLOCALDRIVE_REQUEST_EXIT, this, r ); |
779 return r; |
893 return r; |
780 } |
894 } |
781 |
895 |
782 TInt DLocalDrive::ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd) |
896 TInt DLocalDrive::ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd) |
783 { |
897 { |
823 TInt length = 0; |
941 TInt length = 0; |
824 TInt maxLength = 0; |
942 TInt maxLength = 0; |
825 TUint8* desAddress = NULL; |
943 TUint8* desAddress = NULL; |
826 TInt r = Kern::ThreadGetDesInfo(pT,aReq.RemoteDes(),length,maxLength,desAddress,EFalse); // get descriptor length, maxlength and desAddress |
944 TInt r = Kern::ThreadGetDesInfo(pT,aReq.RemoteDes(),length,maxLength,desAddress,EFalse); // get descriptor length, maxlength and desAddress |
827 if (r != KErrNone) |
945 if (r != KErrNone) |
|
946 { |
|
947 OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT2, this, r ); |
828 return r; |
948 return r; |
|
949 } |
829 if (length == 0) |
950 if (length == 0) |
|
951 { |
|
952 OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT3, this, KErrNone ); |
830 return KErrNone; |
953 return KErrNone; |
|
954 } |
831 |
955 |
832 |
956 |
833 static const TUint8 LengthLookup[16]={4,8,12,8,12,0,0,0,0,0,0,0,0,0,0,0}; |
957 static const TUint8 LengthLookup[16]={4,8,12,8,12,0,0,0,0,0,0,0,0,0,0,0}; |
834 TUint32 desHdr; |
958 TUint32 desHdr; |
835 r = Kern::ThreadRawRead(pT, aReq.RemoteDes(), &desHdr, sizeof(desHdr)); |
959 r = Kern::ThreadRawRead(pT, aReq.RemoteDes(), &desHdr, sizeof(desHdr)); |
836 if(r!=KErrNone) |
960 if(r!=KErrNone) |
|
961 { |
|
962 OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT4, this, r ); |
837 return r; |
963 return r; |
|
964 } |
838 TInt desType = desHdr >>KShiftDesType8; |
965 TInt desType = desHdr >>KShiftDesType8; |
839 TInt desHdrLen = LengthLookup[desType]; |
966 TInt desHdrLen = LengthLookup[desType]; |
840 if(!desHdrLen) |
967 if(!desHdrLen) |
|
968 { |
|
969 OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT5, this, KErrBadDescriptor ); |
841 return KErrBadDescriptor; |
970 return KErrBadDescriptor; |
|
971 } |
842 |
972 |
843 |
973 |
844 pagingDevice->iMountInfoDataLock = ThePinObjectAllocator->AcquirePinObject(); |
974 pagingDevice->iMountInfoDataLock = ThePinObjectAllocator->AcquirePinObject(); |
845 pagingDevice->iMountInfoDescHdrLock = ThePinObjectAllocator->AcquirePinObject(); |
975 pagingDevice->iMountInfoDescHdrLock = ThePinObjectAllocator->AcquirePinObject(); |
846 pagingDevice->iMountInfoDescLenLock = ThePinObjectAllocator->AcquirePinObject(); |
976 pagingDevice->iMountInfoDescLenLock = ThePinObjectAllocator->AcquirePinObject(); |
884 lock = (DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock; |
1017 lock = (DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock; |
885 r = Kern::PinVirtualMemory(lock->iObject, (TLinAddr) desAddress, length, pT); |
1018 r = Kern::PinVirtualMemory(lock->iObject, (TLinAddr) desAddress, length, pT); |
886 if (r != KErrNone) |
1019 if (r != KErrNone) |
887 { |
1020 { |
888 UnlockMountInfo(aPrimaryMedia); // tidy up |
1021 UnlockMountInfo(aPrimaryMedia); // tidy up |
|
1022 OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT9, this, KErrNoMemory ); |
889 return KErrNoMemory; |
1023 return KErrNoMemory; |
890 } |
1024 } |
891 |
1025 |
892 |
1026 OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT10, this, KErrNone ); |
893 return KErrNone; |
1027 return KErrNone; |
894 } |
1028 } |
895 |
1029 |
896 |
1030 |
897 void DLocalDrive::UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia) |
1031 void DLocalDrive::UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia) |
898 { |
1032 { |
|
1033 OstTrace1(TRACE_FLOW, DLOCALDRIVE_UNLOCKMOUNTINFO_ENTRY, "> DLocalDrive::UnlockMountInfo;aPrimaryMedia=%x", (TUint) &aPrimaryMedia); |
|
1034 |
899 DMediaPagingDevice* pagingDevice = aPrimaryMedia.iBody->iPagingDevice; |
1035 DMediaPagingDevice* pagingDevice = aPrimaryMedia.iBody->iPagingDevice; |
900 if (pagingDevice == NULL || pagingDevice->iMountInfoDataLock == NULL) |
1036 if (pagingDevice == NULL || pagingDevice->iMountInfoDataLock == NULL) |
|
1037 { |
|
1038 OstTraceFunctionExit1( DLOCALDRIVE_UNLOCKMOUNTINFO_EXIT1, this ); |
901 return; |
1039 return; |
|
1040 } |
902 |
1041 |
903 |
1042 |
904 if (pagingDevice->iMountInfoDataLock) |
1043 if (pagingDevice->iMountInfoDataLock) |
905 { |
1044 { |
906 Kern::UnpinVirtualMemory(((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock)->iObject); |
1045 Kern::UnpinVirtualMemory(((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock)->iObject); |
1009 |
1151 |
1010 @see Kern::ThreadDesRead() |
1152 @see Kern::ThreadDesRead() |
1011 */ |
1153 */ |
1012 EXPORT_C TInt TLocDrvRequest::ReadRemote(TDes8* aDes, TInt anOffset) |
1154 EXPORT_C TInt TLocDrvRequest::ReadRemote(TDes8* aDes, TInt anOffset) |
1013 { |
1155 { |
|
1156 OstTraceFunctionEntry1( TLOCDRVREQUEST_READREMOTE_ENTRY, this ); |
|
1157 TInt r; |
1014 DThread* pT=RemoteThread(); |
1158 DThread* pT=RemoteThread(); |
1015 if (!pT) |
1159 if (!pT) |
1016 pT=Client(); |
1160 pT=Client(); |
1017 |
1161 |
1018 #ifdef __DEMAND_PAGING__ // only if driver has its own thread, we don't support paging in MD which run in the context of their clients |
1162 #ifdef __DEMAND_PAGING__ // only if driver has its own thread, we don't support paging in MD which run in the context of their clients |
1019 if (Flags() & ETClientBuffer) |
1163 if (Flags() & ETClientBuffer) |
1020 return Kern::ThreadBufRead(pT, (TClientBuffer*) RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0); |
1164 { |
1021 |
1165 r = Kern::ThreadBufRead(pT, (TClientBuffer*) RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0); |
|
1166 OstTraceFunctionExitExt( TLOCDRVREQUEST_READREMOTE_EXIT1, this, r ); |
|
1167 return r; |
|
1168 } |
|
1169 |
1022 __ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
1170 __ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
1023 #endif |
1171 #endif |
1024 |
1172 r = Kern::ThreadDesRead(pT,RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0); |
1025 return Kern::ThreadDesRead(pT,RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0); |
1173 OstTraceFunctionExitExt( TLOCDRVREQUEST_READREMOTE_EXIT2, this, r ); |
|
1174 return r; |
1026 } |
1175 } |
1027 |
1176 |
1028 |
1177 |
1029 |
1178 |
1030 |
1179 |
1050 |
1199 |
1051 @see Kern::ThreadDesRead() |
1200 @see Kern::ThreadDesRead() |
1052 */ |
1201 */ |
1053 EXPORT_C TInt TLocDrvRequest::ReadRemote(const TAny* aSrc, TDes8* aDes) |
1202 EXPORT_C TInt TLocDrvRequest::ReadRemote(const TAny* aSrc, TDes8* aDes) |
1054 { |
1203 { |
|
1204 OstTraceFunctionEntry1( TLOCDRVREQUEST_READ_REMOTE_ENTRY, this ); |
1055 if (Flags() & TLocDrvRequest::EKernelBuffer) |
1205 if (Flags() & TLocDrvRequest::EKernelBuffer) |
1056 { |
1206 { |
1057 aDes->Copy(* (TDesC8*) aSrc); |
1207 aDes->Copy(* (TDesC8*) aSrc); |
1058 return KErrNone; |
1208 return KErrNone; |
1059 } |
1209 } |
1060 |
1210 |
|
1211 TInt r; |
1061 DThread* pT=RemoteThread(); |
1212 DThread* pT=RemoteThread(); |
1062 if (!pT) |
1213 if (!pT) |
1063 pT=Client(); |
1214 pT=Client(); |
1064 |
1215 |
1065 #ifdef __DEMAND_PAGING__ |
1216 #ifdef __DEMAND_PAGING__ |
1066 __ASSERT_DEBUG(!DataPagingDfcQ(Drive()->iPrimaryMedia), LOCM_FAULT()); |
1217 __ASSERT_DEBUG(!DataPagingDfcQ(Drive()->iPrimaryMedia), LOCM_FAULT()); |
1067 |
1218 |
1068 if (DataPagingDfcQ(Drive()->iPrimaryMedia)) |
1219 if (DataPagingDfcQ(Drive()->iPrimaryMedia)) |
|
1220 { |
|
1221 OstTraceFunctionExitExt( TLOCDRVREQUEST_READ_REMOTE_EXIT1, this, KErrNotSupported ); |
1069 return KErrNotSupported; |
1222 return KErrNotSupported; |
1070 #endif |
1223 } |
1071 |
1224 #endif |
1072 return Kern::ThreadDesRead(pT,aSrc,*aDes,0,KChunkShiftBy0); |
1225 |
|
1226 r = Kern::ThreadDesRead(pT,aSrc,*aDes,0,KChunkShiftBy0); |
|
1227 OstTraceFunctionExitExt( TLOCDRVREQUEST_READ_REMOTE_EXIT2, this, r ); |
|
1228 return r; |
1073 } |
1229 } |
1074 |
1230 |
1075 |
1231 |
1076 |
1232 |
1077 |
1233 |
1130 |
1290 |
1131 @see Kern::ThreadDesWrite() |
1291 @see Kern::ThreadDesWrite() |
1132 */ |
1292 */ |
1133 EXPORT_C TInt TLocDrvRequest::WriteRemote(const TDesC8* aDes, TInt anOffset) |
1293 EXPORT_C TInt TLocDrvRequest::WriteRemote(const TDesC8* aDes, TInt anOffset) |
1134 { |
1294 { |
|
1295 OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITEREMOTE_ENTRY, this ); |
|
1296 TInt r; |
1135 DThread* pC=Client(); |
1297 DThread* pC=Client(); |
1136 DThread* pT=RemoteThread(); |
1298 DThread* pT=RemoteThread(); |
1137 if (!pT) |
1299 if (!pT) |
1138 pT=pC; |
1300 pT=pC; |
1139 |
1301 |
1140 #ifdef __DEMAND_PAGING__ |
1302 #ifdef __DEMAND_PAGING__ |
1141 if (Flags() & ETClientBuffer) |
1303 if (Flags() & ETClientBuffer) |
1142 return Kern::ThreadBufWrite(pT, (TClientBuffer*) RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0,pC); |
1304 { |
1143 #endif |
1305 r = Kern::ThreadBufWrite(pT, (TClientBuffer*) RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0,pC); |
1144 |
1306 OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTE_EXIT1, this, r ); |
1145 return Kern::ThreadDesWrite(pT,RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0,pC); |
1307 return r; |
|
1308 } |
|
1309 #endif |
|
1310 r = Kern::ThreadDesWrite(pT,RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0,pC); |
|
1311 OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTE_EXIT2, this, r ); |
|
1312 return r; |
1146 } |
1313 } |
1147 |
1314 |
1148 |
1315 |
1149 /** |
1316 /** |
1150 Writes raw data to the requesting thread's process. |
1317 Writes raw data to the requesting thread's process. |
1162 |
1329 |
1163 @see Kern::ThreadRawWrite() |
1330 @see Kern::ThreadRawWrite() |
1164 */ |
1331 */ |
1165 EXPORT_C TInt TLocDrvRequest::WriteRemoteRaw(const TAny* aSrc, TInt aSize) |
1332 EXPORT_C TInt TLocDrvRequest::WriteRemoteRaw(const TAny* aSrc, TInt aSize) |
1166 { |
1333 { |
|
1334 OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITEREMOTERAW_ENTRY, this ); |
|
1335 TInt r; |
1167 DThread* pC=Client(); |
1336 DThread* pC=Client(); |
1168 DThread* pT=RemoteThread(); |
1337 DThread* pT=RemoteThread(); |
1169 if (!pT) |
1338 if (!pT) |
1170 pT=pC; |
1339 pT=pC; |
1171 |
1340 |
1172 #ifdef __DEMAND_PAGING__ |
1341 #ifdef __DEMAND_PAGING__ |
1173 __ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
1342 __ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
1174 #endif |
1343 #endif |
1175 |
1344 r = Kern::ThreadRawWrite(pT,RemoteDes(),aSrc,aSize,pC); |
1176 return Kern::ThreadRawWrite(pT,RemoteDes(),aSrc,aSize,pC); |
1345 OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTERAW_EXIT, this, r ); |
|
1346 return r; |
1177 } |
1347 } |
1178 |
1348 |
1179 |
1349 |
1180 TInt TLocDrvRequest::ProcessMessageData(TAny* aPtr) |
1350 TInt TLocDrvRequest::ProcessMessageData(TAny* aPtr) |
1181 // |
1351 // |
1182 // Get read/write parameters from client and open remote thread |
1352 // Get read/write parameters from client and open remote thread |
1183 // |
1353 // |
1184 { |
1354 { |
|
1355 OstTraceFunctionEntry1( TLOCDRVREQUEST_PROCESSMESSAGEDATA_ENTRY, this ); |
1185 RemoteThread()=NULL; |
1356 RemoteThread()=NULL; |
1186 DThread& t=Kern::CurrentThread(); |
1357 DThread& t=Kern::CurrentThread(); |
1187 TLocalDriveMessageData d; |
1358 TLocalDriveMessageData d; |
1188 kumemget32(&d,aPtr,sizeof(d)); |
1359 kumemget32(&d,aPtr,sizeof(d)); |
|
1360 OstTrace1( TRACE_INTERNALS, TLOCDRVREQUEST_PROCESSMESSAGEDATA, "Message handle=%d", d.iHandle ); |
1189 if (d.iHandle!=KLocalMessageHandle && Id()!=DLocalDrive::EFormat) |
1361 if (d.iHandle!=KLocalMessageHandle && Id()!=DLocalDrive::EFormat) |
1190 { |
1362 { |
1191 NKern::LockSystem(); |
1363 NKern::LockSystem(); |
1192 DThread* pT = RMessageK::MessageK(d.iHandle)->iClient; |
1364 DThread* pT = RMessageK::MessageK(d.iHandle)->iClient; |
1193 if (!pT || pT->Open()!=KErrNone) |
1365 if (!pT || pT->Open()!=KErrNone) |
1194 { |
1366 { |
1195 NKern::UnlockSystem(); |
1367 NKern::UnlockSystem(); |
|
1368 OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT1, this, KErrBadHandle ); |
1196 return KErrBadHandle; |
1369 return KErrBadHandle; |
1197 } |
1370 } |
1198 t.iExtTempObj=pT; |
1371 t.iExtTempObj=pT; |
1199 RemoteThread()=pT; |
1372 RemoteThread()=pT; |
1200 NKern::UnlockSystem(); |
1373 NKern::UnlockSystem(); |
1203 Length()=d.iLength; |
1376 Length()=d.iLength; |
1204 RemoteDes()=(TAny*)d.iPtr; |
1377 RemoteDes()=(TAny*)d.iPtr; |
1205 RemoteDesOffset()=d.iOffset; |
1378 RemoteDesOffset()=d.iOffset; |
1206 DriverFlags()=d.iFlags; |
1379 DriverFlags()=d.iFlags; |
1207 if (Pos()<0 || Length()<0) |
1380 if (Pos()<0 || Length()<0) |
|
1381 { |
|
1382 OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT2, this, KErrArgument ); |
1208 return KErrArgument; |
1383 return KErrArgument; |
|
1384 } |
|
1385 OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT3, this, KErrNone ); |
1209 return KErrNone; |
1386 return KErrNone; |
1210 } |
1387 } |
1211 |
1388 |
1212 void TLocDrvRequest::CloseRemoteThread() |
1389 void TLocDrvRequest::CloseRemoteThread() |
1213 { |
1390 { |
|
1391 OstTraceFunctionEntry1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_ENTRY, this ); |
|
1392 |
1214 if (!RemoteThread()) |
1393 if (!RemoteThread()) |
|
1394 { |
|
1395 OstTraceFunctionExit1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_EXIT1, this ); |
1215 return; |
1396 return; |
|
1397 } |
1216 NKern::ThreadEnterCS(); |
1398 NKern::ThreadEnterCS(); |
1217 DThread& t=Kern::CurrentThread(); |
1399 DThread& t=Kern::CurrentThread(); |
1218 RemoteThread()=NULL; |
1400 RemoteThread()=NULL; |
1219 Kern::SafeClose((DObject*&)t.iExtTempObj,NULL); |
1401 Kern::SafeClose((DObject*&)t.iExtTempObj,NULL); |
1220 NKern::ThreadLeaveCS(); |
1402 NKern::ThreadLeaveCS(); |
|
1403 OstTraceFunctionExit1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_EXIT2, this ); |
1221 } |
1404 } |
1222 |
1405 |
1223 EXPORT_C TInt TLocDrvRequest::CheckAndAdjustForPartition() |
1406 EXPORT_C TInt TLocDrvRequest::CheckAndAdjustForPartition() |
1224 { |
1407 { |
|
1408 OstTraceFunctionEntry1( TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION_ENTRY, this ); |
1225 TLocDrv& d=*Drive(); |
1409 TLocDrv& d=*Drive(); |
1226 __KTRACE_OPT(KLOCDRV,Kern::Printf("CheckAndAdjustForPartition drive %d partition len %lx",d.iDriveNumber,d.iPartitionLen)); |
1410 __KTRACE_OPT(KLOCDRV,Kern::Printf("CheckAndAdjustForPartition drive %d partition len %lx",d.iDriveNumber,d.iPartitionLen)); |
|
1411 OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION1, "iDriveNumber=%d; partition length=0x%lx", d.iDriveNumber, (TInt) d.iPartitionLen ); |
1227 Flags() |= EAdjusted; |
1412 Flags() |= EAdjusted; |
|
1413 TInt r; |
1228 switch (Id()) |
1414 switch (Id()) |
1229 { |
1415 { |
1230 case DLocalDrive::ECaps: |
1416 case DLocalDrive::ECaps: |
1231 case DLocalDrive::EForceMediaChange: |
1417 case DLocalDrive::EForceMediaChange: |
1232 case DLocalDrive::EPasswordLock: |
1418 case DLocalDrive::EPasswordLock: |
1235 case DLocalDrive::EPasswordErase: |
1421 case DLocalDrive::EPasswordErase: |
1236 case DLocalDrive::EReadPasswordStore: |
1422 case DLocalDrive::EReadPasswordStore: |
1237 case DLocalDrive::EWritePasswordStore: |
1423 case DLocalDrive::EWritePasswordStore: |
1238 case DLocalDrive::EPasswordStoreLengthInBytes: |
1424 case DLocalDrive::EPasswordStoreLengthInBytes: |
1239 case DLocalDrive::EQueryDevice: |
1425 case DLocalDrive::EQueryDevice: |
1240 return KErrNone; |
1426 { |
|
1427 r = KErrNone; |
|
1428 break; |
|
1429 } |
1241 case DLocalDrive::EEnlarge: |
1430 case DLocalDrive::EEnlarge: |
1242 __KTRACE_OPT(KLOCDRV,Kern::Printf("Enlarge request %lx",Length())); |
1431 __KTRACE_OPT(KLOCDRV,Kern::Printf("Enlarge request %lx",Length())); |
|
1432 OstTrace1( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION2, "Enlarge request=0x%lx", Length() ); |
1243 if (Length()>KMaxTInt) |
1433 if (Length()>KMaxTInt) |
1244 return KErrArgument; |
1434 r = KErrArgument; |
1245 return KErrNone; |
1435 else |
|
1436 r = KErrNone; |
|
1437 break; |
1246 case DLocalDrive::EReduce: |
1438 case DLocalDrive::EReduce: |
1247 __KTRACE_OPT(KLOCDRV,Kern::Printf("Reduce request %lx@%lx",Length(),Pos())); |
1439 __KTRACE_OPT(KLOCDRV,Kern::Printf("Reduce request %lx@%lx",Length(),Pos())); |
|
1440 OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION3, "Reduce request length=0x%lx; position=0x%lx", (TUint) Length(), (TUint) Pos() ); |
1248 if (Pos()+Length()>d.iPartitionLen) |
1441 if (Pos()+Length()>d.iPartitionLen) |
1249 return KErrArgument; |
1442 r = KErrArgument; |
1250 return KErrNone; |
1443 else |
|
1444 r = KErrNone; |
|
1445 break; |
1251 case DLocalDrive::EFormat: |
1446 case DLocalDrive::EFormat: |
1252 __KTRACE_OPT(KLOCDRV,Kern::Printf("Format request %lx@%lx",Length(),Pos())); |
1447 __KTRACE_OPT(KLOCDRV,Kern::Printf("Format request %lx@%lx",Length(),Pos())); |
|
1448 OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION4, "Format request length=0x%lx; position=0x%lx", (TUint) Length(), (TUint) Pos() ); |
1253 if (!(DriverFlags() & RLocalDrive::ELocDrvWholeMedia)) |
1449 if (!(DriverFlags() & RLocalDrive::ELocDrvWholeMedia)) |
1254 { |
1450 { |
1255 if (Pos()>d.iPartitionLen) |
1451 if (Pos()>d.iPartitionLen) |
1256 { |
1452 { |
1257 Length()=0; |
1453 Length()=0; |
1258 return KErrEof; |
1454 r = KErrEof; |
|
1455 break; |
1259 } |
1456 } |
1260 Int64 left=d.iPartitionLen-Pos(); |
1457 Int64 left=d.iPartitionLen-Pos(); |
1261 if (left<Length()) |
1458 if (left<Length()) |
1262 Length()=left; |
1459 Length()=left; |
1263 Pos()+=d.iPartitionBaseAddr; |
1460 Pos()+=d.iPartitionBaseAddr; |
1264 if (Length()==0) |
1461 if (Length()==0) |
1265 return KErrEof; |
1462 { |
|
1463 r = KErrEof; |
|
1464 break; |
|
1465 } |
1266 } |
1466 } |
1267 return KErrNone; |
1467 r = KErrNone; |
|
1468 break; |
1268 |
1469 |
1269 #ifdef __DEMAND_PAGING__ |
1470 #ifdef __DEMAND_PAGING__ |
1270 case DMediaPagingDevice::ERomPageInRequest: |
1471 case DMediaPagingDevice::ERomPageInRequest: |
1271 // if the ROM was reported to LOCM then it will also need to be adjusted.... |
1472 // if the ROM was reported to LOCM then it will also need to be adjusted.... |
1272 // Otherwise the media driver adjust it internally |
1473 // Otherwise the media driver adjust it internally |
1273 case DMediaPagingDevice::ECodePageInRequest: |
1474 case DMediaPagingDevice::ECodePageInRequest: |
1274 __KTRACE_OPT(KLOCDPAGING,Kern::Printf("Adjusted Paging read request %lx@%lx",Length(),Pos())); |
1475 __KTRACE_OPT(KLOCDPAGING,Kern::Printf("Adjusted Paging read request %lx@%lx",Length(),Pos())); |
|
1476 OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, TLOCDRVREQUESTCHECKANDADJUSTFORPARTITION5, "Adjusted Paging read request length=0x%lx; position=0x%lx", (TUint) Length(), (TUint) Pos()); |
1275 if (Pos()+Length()>d.iPartitionLen) |
1477 if (Pos()+Length()>d.iPartitionLen) |
1276 return KErrArgument; |
1478 { |
|
1479 r = KErrArgument; |
|
1480 break; |
|
1481 } |
1277 Pos()+=d.iPartitionBaseAddr; |
1482 Pos()+=d.iPartitionBaseAddr; |
1278 return KErrNone; |
1483 r = KErrNone; |
|
1484 break; |
1279 #endif |
1485 #endif |
1280 |
1486 |
1281 default: // read or write or fragment |
1487 default: // read or write or fragment |
1282 __KTRACE_OPT(KLOCDRV,Kern::Printf("R/W request %lx@%lx",Length(),Pos())); |
1488 __KTRACE_OPT(KLOCDRV,Kern::Printf("R/W request %lx@%lx",Length(),Pos())); |
1283 |
1489 OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION6, "Read/Write request length=0x%x; position=0x%x", (TUint) Length(), (TUint) Pos() ); |
1284 if (DriverFlags() & RLocalDrive::ELocDrvWholeMedia) |
1490 if (DriverFlags() & RLocalDrive::ELocDrvWholeMedia) |
1285 { |
1491 { |
1286 if (d.iMedia && d.iMedia->iDriver && Pos()+Length() > d.iMedia->iDriver->iTotalSizeInBytes) |
1492 if (d.iMedia && d.iMedia->iDriver && Pos()+Length() > d.iMedia->iDriver->iTotalSizeInBytes) |
1287 return KErrArgument; |
1493 { |
|
1494 r = KErrArgument; |
|
1495 break; |
|
1496 } |
1288 } |
1497 } |
1289 else |
1498 else |
1290 { |
1499 { |
1291 if (Pos()+Length() > d.iPartitionLen) |
1500 if (Pos()+Length() > d.iPartitionLen) |
1292 return KErrArgument; |
1501 { |
|
1502 r = KErrArgument; |
|
1503 break; |
|
1504 } |
1293 Pos()+=d.iPartitionBaseAddr; |
1505 Pos()+=d.iPartitionBaseAddr; |
1294 } |
1506 } |
1295 return KErrNone; |
1507 r = KErrNone; |
1296 } |
1508 } |
|
1509 OstTraceFunctionExitExt( TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION_EXIT, this, r ); |
|
1510 return r; |
1297 } |
1511 } |
1298 |
1512 |
1299 /******************************************** |
1513 /******************************************** |
1300 * Local drive class |
1514 * Local drive class |
1301 ********************************************/ |
1515 ********************************************/ |
1302 TLocDrv::TLocDrv(TInt aDriveNumber) |
1516 TLocDrv::TLocDrv(TInt aDriveNumber) |
1303 { |
1517 { |
|
1518 OstTraceFunctionEntryExt( TLOCDRV_TLOCDRV_ENTRY, this ); |
1304 memclr(this, sizeof(TLocDrv)); |
1519 memclr(this, sizeof(TLocDrv)); |
1305 iDriveNumber=aDriveNumber; |
1520 iDriveNumber=aDriveNumber; |
1306 iPartitionNumber=-1; |
1521 iPartitionNumber=-1; |
|
1522 OstTraceFunctionExit1( TLOCDRV_TLOCDRV_EXIT, this ); |
1307 } |
1523 } |
1308 |
1524 |
1309 /** |
1525 /** |
1310 Initialises the DMedia entity with the media device number and ID. |
1526 Initialises the DMedia entity with the media device number and ID. |
1311 |
1527 |
1319 |
1535 |
1320 @see TMediaDevice |
1536 @see TMediaDevice |
1321 */ |
1537 */ |
1322 EXPORT_C TInt DMedia::Create(TMediaDevice aDevice, TInt aMediaId, TInt) |
1538 EXPORT_C TInt DMedia::Create(TMediaDevice aDevice, TInt aMediaId, TInt) |
1323 { |
1539 { |
|
1540 OstTraceFunctionEntry1( DMEDIA_CREATE_ENTRY, this ); |
1324 __KTRACE_OPT(KLOCDRV,Kern::Printf("DMedia::Create media %d device %d",aMediaId,aDevice)); |
1541 __KTRACE_OPT(KLOCDRV,Kern::Printf("DMedia::Create media %d device %d",aMediaId,aDevice)); |
|
1542 OstTraceExt2(TRACE_INTERNALS, DMEDIA_CREATE, "media=%d; device=%d", aMediaId, (TUint) aDevice); |
1325 iMediaId=aMediaId; |
1543 iMediaId=aMediaId; |
1326 iDevice=aDevice; |
1544 iDevice=aDevice; |
|
1545 OstTraceFunctionExitExt( DMEDIA_CREATE_EXIT, this, KErrNone ); |
1327 return KErrNone; |
1546 return KErrNone; |
1328 } |
1547 } |
1329 |
1548 |
1330 /******************************************** |
1549 /******************************************** |
1331 * Primary Media Class |
1550 * Primary Media Class |
1332 ********************************************/ |
1551 ********************************************/ |
1333 void asyncDfc(TAny* aPtr) |
1552 void asyncDfc(TAny* aPtr) |
1334 { |
1553 { |
|
1554 OstTraceFunctionEntry0( _ASYNCDFC_ENTRY ); |
1335 DPrimaryMediaBase* pM=(DPrimaryMediaBase*)aPtr; |
1555 DPrimaryMediaBase* pM=(DPrimaryMediaBase*)aPtr; |
1336 if (pM->iState==DMedia::EOpening) |
1556 if (pM->iState==DMedia::EOpening) |
1337 pM->DoOpenMediaDriverComplete(pM->iAsyncErrorCode); |
1557 pM->DoOpenMediaDriverComplete(pM->iAsyncErrorCode); |
1338 else if (pM->iState==DMedia::EReadPartitionInfo) |
1558 else if (pM->iState==DMedia::EReadPartitionInfo) |
1339 pM->DoPartitionInfoComplete(pM->iAsyncErrorCode); |
1559 pM->DoPartitionInfoComplete(pM->iAsyncErrorCode); |
|
1560 OstTraceFunctionExit0( _ASYNCDFC_EXIT ); |
1340 } |
1561 } |
1341 |
1562 |
1342 void handleMsg(TAny* aPtr) |
1563 void handleMsg(TAny* aPtr) |
1343 { |
1564 { |
|
1565 OstTraceFunctionEntry0( _HANDLEMSG_ENTRY ); |
1344 DPrimaryMediaBase* primaryMedia=(DPrimaryMediaBase*)aPtr; |
1566 DPrimaryMediaBase* primaryMedia=(DPrimaryMediaBase*)aPtr; |
1345 |
1567 |
1346 for(TLocDrvRequest* m = (TLocDrvRequest*) primaryMedia->iMsgQ.iMessage; |
1568 for(TLocDrvRequest* m = (TLocDrvRequest*) primaryMedia->iMsgQ.iMessage; |
1347 m != NULL; |
1569 m != NULL; |
1348 m = (TLocDrvRequest*) primaryMedia->iMsgQ.Poll()) |
1570 m = (TLocDrvRequest*) primaryMedia->iMsgQ.Poll()) |
1437 otherwise, one of the other system wide error codes. |
1673 otherwise, one of the other system wide error codes. |
1438 |
1674 |
1439 @see DLocalDrive |
1675 @see DLocalDrive |
1440 */ |
1676 */ |
1441 { |
1677 { |
|
1678 OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_CONNECT_ENTRY, this ); |
1442 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::Connect %O",iMediaId,aLocalDrive)); |
1679 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::Connect %O",iMediaId,aLocalDrive)); |
|
1680 OstTraceExt2( TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CONNECT, "iMediaId=%d; iDriveNumber=%d", iMediaId, aLocalDrive->iDrive->iDriveNumber ); |
|
1681 |
|
1682 TInt r=KErrNone; |
|
1683 |
1443 if (iDfcQ) |
1684 if (iDfcQ) |
1444 { |
1685 { |
1445 TThreadMessage& m=Kern::Message(); |
1686 TThreadMessage& m=Kern::Message(); |
1446 m.iValue=EConnect; |
1687 m.iValue=EConnect; |
1447 m.iArg[0]=aLocalDrive; |
1688 m.iArg[0]=aLocalDrive; |
1448 return m.SendReceive(&iMsgQ); |
1689 r=m.SendReceive(&iMsgQ); |
|
1690 OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CONNECT_EXIT1, this, r ); |
|
1691 return r; |
1449 } |
1692 } |
1450 |
1693 |
1451 // If no DFC queue, must be a fixed media device |
1694 // If no DFC queue, must be a fixed media device |
1452 // If this is the first connection, open media driver now |
1695 // If this is the first connection, open media driver now |
1453 // Assume no non-primary media exist on this device |
1696 // Assume no non-primary media exist on this device |
1454 TInt r=KErrNone; |
1697 |
1455 NKern::LockSystem(); |
1698 NKern::LockSystem(); |
1456 TBool first=iConnectionQ.IsEmpty(); |
1699 TBool first=iConnectionQ.IsEmpty(); |
1457 iConnectionQ.Add(&aLocalDrive->iLink); |
1700 iConnectionQ.Add(&aLocalDrive->iLink); |
1458 NKern::UnlockSystem(); |
1701 NKern::UnlockSystem(); |
1459 if (first) |
1702 if (first) |
1533 Otherwise, one of the other system wide error codes. |
1783 Otherwise, one of the other system wide error codes. |
1534 |
1784 |
1535 @see TLocDrvRequest |
1785 @see TLocDrvRequest |
1536 */ |
1786 */ |
1537 { |
1787 { |
|
1788 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_REQUEST_ENTRY, this ); |
1538 |
1789 |
1539 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::Request(%08x)",iMediaId,&aReq)); |
1790 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::Request(%08x)",iMediaId,&aReq)); |
1540 __KTRACE_OPT(KLOCDRV,Kern::Printf("this=%x, ReqId=%d, Pos=%lx, Len=%lx, remote thread %O",this,aReq.Id(),aReq.Pos(),aReq.Length(),aReq.RemoteThread())); |
1791 __KTRACE_OPT(KLOCDRV,Kern::Printf("this=%x, ReqId=%d, Pos=%lx, Len=%lx, remote thread %O",this,aReq.Id(),aReq.Pos(),aReq.Length(),aReq.RemoteThread())); |
1541 |
1792 |
|
1793 OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_REQUEST, "reqId=%d; length=0x%lx; position=0x%lx; remote thread=0x%x", (TInt) aReq.Id(), (TUint) aReq.Length(), (TUint) aReq.Pos(), (TUint) aReq.RemoteThread()); |
|
1794 |
1542 TInt reqId = aReq.Id(); |
1795 TInt reqId = aReq.Id(); |
1543 |
1796 |
1544 if (reqId == DLocalDrive::ECaps) |
1797 if (reqId == DLocalDrive::ECaps) |
1545 DefaultDriveCaps(*(TLocalDriveCapsV2*)aReq.RemoteDes()); // fill in stuff we know even if no media present |
1798 DefaultDriveCaps(*(TLocalDriveCapsV2*)aReq.RemoteDes()); // fill in stuff we know even if no media present |
1546 |
1799 |
1574 if (reqId == DLocalDrive::ERead) |
1828 if (reqId == DLocalDrive::ERead) |
1575 { |
1829 { |
1576 TPtrC8 ptr(NULL, 0); |
1830 TPtrC8 ptr(NULL, 0); |
1577 r = Kern::ThreadDesWrite(pT, aReq.RemoteDes(), ptr, aReq.RemoteDesOffset(), KChunkShiftBy0,pC); |
1831 r = Kern::ThreadDesWrite(pT, aReq.RemoteDes(), ptr, aReq.RemoteDesOffset(), KChunkShiftBy0,pC); |
1578 } |
1832 } |
|
1833 OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT2, this, r ); |
1579 return r; |
1834 return r; |
1580 } |
1835 } |
1581 |
1836 |
1582 clientBuffer.SetFromDescriptor(aReq.RemoteDes(), pT); |
1837 clientBuffer.SetFromDescriptor(aReq.RemoteDes(), pT); |
1583 |
1838 |
1584 TInt length = 0; |
1839 TInt length = 0; |
1585 TInt maxLength = 0; |
1840 TInt maxLength = 0; |
1586 TInt r = Kern::ThreadGetDesInfo(pT,aReq.RemoteDes(),length,maxLength,linAddress,EFalse); // get descriptor length, maxlength and linAddress |
1841 TInt r = Kern::ThreadGetDesInfo(pT,aReq.RemoteDes(),length,maxLength,linAddress,EFalse); // get descriptor length, maxlength and linAddress |
1587 if (r != KErrNone) |
1842 if (r != KErrNone) |
|
1843 { |
|
1844 OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT3, this, r ); |
1588 return r; |
1845 return r; |
|
1846 } |
1589 linAddress+= aReq.RemoteDesOffset(); |
1847 linAddress+= aReq.RemoteDesOffset(); |
1590 |
1848 |
1591 #ifdef __DEMAND_PAGING__ |
1849 #ifdef __DEMAND_PAGING__ |
1592 // NB change in behavior IF DATA PAGING IS ENABLED: TLocDrvRequest::RemoteDes() points |
1850 // NB change in behavior IF DATA PAGING IS ENABLED: TLocDrvRequest::RemoteDes() points |
1593 // to a TClientBuffer rather than the client's remote descriptor |
1851 // to a TClientBuffer rather than the client's remote descriptor |
1606 |
1864 |
1607 #ifdef __DEMAND_PAGING__ |
1865 #ifdef __DEMAND_PAGING__ |
1608 // If this is a ROM/Code paging media, pin writes |
1866 // If this is a ROM/Code paging media, pin writes |
1609 // If there is a Data paging media registered, pin all requests with descriptors |
1867 // If there is a Data paging media registered, pin all requests with descriptors |
1610 if ( (DataPagingDeviceRegistered) || (reqId == DLocalDrive::EWrite && RomPagingDfcQ(this)) ) |
1868 if ( (DataPagingDeviceRegistered) || (reqId == DLocalDrive::EWrite && RomPagingDfcQ(this)) ) |
|
1869 { |
1611 r = PinSendReceive(aReq, (TLinAddr) linAddress); |
1870 r = PinSendReceive(aReq, (TLinAddr) linAddress); |
|
1871 } |
1612 else |
1872 else |
1613 #endif // __DEMAND_PAGING__ |
1873 #endif // __DEMAND_PAGING__ |
1614 |
|
1615 r = SendReceive(aReq, (TLinAddr) linAddress); |
1874 r = SendReceive(aReq, (TLinAddr) linAddress); |
1616 } |
1875 } |
1617 else |
1876 else |
1618 { |
1877 { |
1619 // If no DFC queue, must be a fixed media device |
1878 // If no DFC queue, must be a fixed media device |
1620 // Media driver must already have been opened |
1879 // Media driver must already have been opened |
1621 // Assume no non-primary media exist on this device |
1880 // Assume no non-primary media exist on this device |
1622 // Just pass request straight through to media driver |
1881 // Just pass request straight through to media driver |
1623 r = aReq.CheckAndAdjustForPartition(); |
1882 r = aReq.CheckAndAdjustForPartition(); |
1624 if (r == KErrNone) |
1883 if (r == KErrNone) |
1625 r = iDriver->Request(aReq); |
1884 r = iDriver->Request(aReq); |
1626 } |
1885 } |
1627 |
1886 |
1628 #ifdef __DEMAND_PAGING__ |
1887 #ifdef __DEMAND_PAGING__ |
1629 // NB change in behavior IF DATA PAGING IS ENABLED: TLocDrvRequest::RemoteDes() points |
1888 // NB change in behavior IF DATA PAGING IS ENABLED: TLocDrvRequest::RemoteDes() points |
1630 // to a TClientBuffer rather than the client's remote descriptor |
1889 // to a TClientBuffer rather than the client's remote descriptor |
1631 if (reqId == DLocalDrive::ERead && DataPagingDeviceRegistered && r == KErrNone) |
1890 if (reqId == DLocalDrive::ERead && DataPagingDeviceRegistered && r == KErrNone) |
1632 { |
1891 { |
1633 r = clientBuffer.UpdateDescriptorLength(pT); |
1892 r = clientBuffer.UpdateDescriptorLength(pT); |
1634 } |
1893 } |
1635 #endif |
1894 #endif |
1636 |
1895 OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT4, this, r ); |
1637 return r; |
1896 return r; |
1638 } |
1897 } |
1639 |
1898 |
1640 |
1899 |
1641 #ifdef __DEMAND_PAGING__ |
1900 #ifdef __DEMAND_PAGING__ |
1642 TInt DPrimaryMediaBase::PinSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress) |
1901 TInt DPrimaryMediaBase::PinSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress) |
1643 { |
1902 { |
|
1903 OstTraceExt2(TRACE_FLOW, DPRIMARYMEDIABASE_PINSENDRECEIVE_ENTRY, "> DPrimaryMediaBase::PinSendReceive;aReq=%x;aLinAddress=%x;", (TUint) &aReq, (TUint) &aLinAddress ); |
|
1904 |
1644 __ASSERT_DEBUG(ThePinObjectAllocator, LOCM_FAULT()); |
1905 __ASSERT_DEBUG(ThePinObjectAllocator, LOCM_FAULT()); |
1645 |
1906 |
1646 |
1907 |
1647 TInt msgId = aReq.Id(); |
1908 TInt msgId = aReq.Id(); |
1648 |
1909 TInt r; |
1649 |
1910 |
1650 switch(msgId) |
1911 switch(msgId) |
1651 { |
1912 { |
1652 case DLocalDrive::EControlIO: |
1913 case DLocalDrive::EControlIO: |
1653 { |
1914 { |
1658 // ControlIo is not supported if either of the two bare (TAny*) pointers are non-NULL |
1919 // ControlIo is not supported if either of the two bare (TAny*) pointers are non-NULL |
1659 // as it's not possible to determine what the pointers are pointing at... |
1920 // as it's not possible to determine what the pointers are pointing at... |
1660 if (aReq.Int1() || aReq.Int2()) |
1921 if (aReq.Int1() || aReq.Int2()) |
1661 { |
1922 { |
1662 __KTRACE_OPT(KDATAPAGEWARN, Kern::Printf("Data paging: Naked EControlIO not supported on paging device: fn=%x", aReq.Int0())); |
1923 __KTRACE_OPT(KDATAPAGEWARN, Kern::Printf("Data paging: Naked EControlIO not supported on paging device: fn=%x", aReq.Int0())); |
1663 return KErrNotSupported; |
1924 r = KErrNotSupported; |
|
1925 break; |
1664 } |
1926 } |
1665 // fall into... |
1927 // fall into... |
1666 case 0: |
1928 case 0: |
1667 return SendReceive(aReq); |
1929 r = SendReceive(aReq); |
|
1930 break; |
1668 |
1931 |
1669 default: |
1932 default: |
1670 // if Int3() is > 0, Int1() is a data pointer, and Int3() is a length |
1933 // if Int3() is > 0, Int1() is a data pointer, and Int3() is a length |
1671 if (controlIoType > (TInt) ThePinObjectAllocator->iFragmentGranularity) |
1934 if (controlIoType > (TInt) ThePinObjectAllocator->iFragmentGranularity) |
1672 return KErrTooBig; |
1935 { |
|
1936 r = KErrTooBig; |
|
1937 break; |
|
1938 } |
1673 if (controlIoType < 0) |
1939 if (controlIoType < 0) |
1674 return KErrArgument; |
1940 { |
1675 return PinFragmentSendReceive(aReq, (TLinAddr) aReq.Ptr1(), controlIoType); |
1941 r = KErrArgument; |
|
1942 break; |
|
1943 } |
|
1944 r = PinFragmentSendReceive(aReq, (TLinAddr) aReq.Ptr1(), controlIoType); |
|
1945 break; |
1676 } |
1946 } |
|
1947 break; |
1677 } |
1948 } |
1678 |
1949 |
1679 case DLocalDrive::ERead: |
1950 case DLocalDrive::ERead: |
1680 case DLocalDrive::EWrite: |
1951 case DLocalDrive::EWrite: |
1681 { |
1952 { |
1682 return PinFragmentSendReceive(aReq, aLinAddress, aReq.Length()); |
1953 r = PinFragmentSendReceive(aReq, aLinAddress, aReq.Length()); |
|
1954 break; |
1683 } |
1955 } |
1684 |
1956 |
1685 // For all these requests, aReq.RemoteDes() points to a buffer on the stack in DLocalDrive::Request() |
1957 // For all these requests, aReq.RemoteDes() points to a buffer on the stack in DLocalDrive::Request() |
1686 // This is a kernel stack & so should be unpaged & not require pinning... |
1958 // This is a kernel stack & so should be unpaged & not require pinning... |
1687 case DLocalDrive::ECaps: |
1959 case DLocalDrive::ECaps: |
1694 case DLocalDrive::EWritePasswordStore: |
1966 case DLocalDrive::EWritePasswordStore: |
1695 case DLocalDrive::EPasswordStoreLengthInBytes: |
1967 case DLocalDrive::EPasswordStoreLengthInBytes: |
1696 case DLocalDrive::EPasswordErase: |
1968 case DLocalDrive::EPasswordErase: |
1697 |
1969 |
1698 default: |
1970 default: |
1699 return SendReceive(aReq); |
1971 r = SendReceive(aReq); |
1700 } |
1972 } |
|
1973 OstTraceFunctionExitExt( DPRIMARYMEDIABASE_PINSENDRECEIVE_EXIT, this, r ); |
|
1974 return r; |
1701 } |
1975 } |
1702 |
1976 |
1703 TInt DPrimaryMediaBase::PinFragmentSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress, TInt aLength) |
1977 TInt DPrimaryMediaBase::PinFragmentSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress, TInt aLength) |
1704 { |
1978 { |
|
1979 OstTraceExt3(TRACE_FLOW, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE_ENTRY, "> DPrimaryMediaBase::PinFragmentSendReceive;aReq=%x;aLinAddress=%x;aLength=%d;", (TUint) &aReq, (TUint) &aLinAddress, aLength ); |
|
1980 |
1705 TLocDrvRequest fragment = aReq; // create a request on the stack for use during fragmentation, pre-fill with the original req args, leave original Kernel message as repository (thread will block, message contents won't change) |
1981 TLocDrvRequest fragment = aReq; // create a request on the stack for use during fragmentation, pre-fill with the original req args, leave original Kernel message as repository (thread will block, message contents won't change) |
1706 TInt r = KErrNone; |
1982 TInt r = KErrNone; |
1707 |
1983 |
1708 // Kern::Printf(">PFSR %02X aReq %08X aLinAddress %08X aLen %08X offset %08X", aReq.Id(), &aReq, aLinAddress, aLength, aReq.RemoteDesOffset()); |
1984 // Kern::Printf(">PFSR %02X aReq %08X aLinAddress %08X aLen %08X offset %08X", aReq.Id(), &aReq, aLinAddress, aLength, aReq.RemoteDesOffset()); |
1709 |
1985 |
1711 if (!pT) |
1987 if (!pT) |
1712 pT=&Kern::CurrentThread(); // e.g. when using TBusLocalDrive directly |
1988 pT=&Kern::CurrentThread(); // e.g. when using TBusLocalDrive directly |
1713 |
1989 |
1714 __KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Fragmenting Read/Write Request(0x%08x) on drive(%d), remote des(0x%x), offset into des(0x%x), original req Length(0x%x)",&aReq,aReq.Drive()->iDriveNumber,(TInt)(aReq.RemoteDes()),aReq.RemoteDesOffset(),aLength)); |
1990 __KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Fragmenting Read/Write Request(0x%08x) on drive(%d), remote des(0x%x), offset into des(0x%x), original req Length(0x%x)",&aReq,aReq.Drive()->iDriveNumber,(TInt)(aReq.RemoteDes()),aReq.RemoteDesOffset(),aLength)); |
1715 __KTRACE_OPT(KLOCDPAGING,Kern::Printf("Remote thread(0x%08x), current thread(0x%08x), start of data to write(0x%08x)",aReq.RemoteThread(),&Kern::CurrentThread(),(TInt)aLinAddress)); |
1991 __KTRACE_OPT(KLOCDPAGING,Kern::Printf("Remote thread(0x%08x), current thread(0x%08x), start of data to write(0x%08x)",aReq.RemoteThread(),&Kern::CurrentThread(),(TInt)aLinAddress)); |
1716 |
1992 OstTraceDefExt5(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE1, "Fragmenting Read/Write Request=0x%08x; drive=%d; remote des=0x%x; offset into des=0x%x; original length=0x%x", (TUint) &aReq, (TUint) aReq.Drive()->iDriveNumber, (TInt) (aReq.RemoteDes()), (TInt) aReq.RemoteDesOffset(), (TInt) aLength ); |
|
1993 OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE2, "Remote Thread=0x%08x; current Thread=0x%x; start of data to write=0x%08x", (TUint) aReq.RemoteThread(), (TUint) &Kern::CurrentThread(),(TUint)aLinAddress ); |
|
1994 |
1717 // don't want this thread to be terminated until last fragment is sent to MD and mem can be free'd up |
1995 // don't want this thread to be terminated until last fragment is sent to MD and mem can be free'd up |
1718 NKern::ThreadEnterCS(); |
1996 NKern::ThreadEnterCS(); |
1719 |
1997 |
1720 __ASSERT_DEBUG(ThePinObjectAllocator, LOCM_FAULT()); |
1998 __ASSERT_DEBUG(ThePinObjectAllocator, LOCM_FAULT()); |
1721 |
1999 |
1803 fragment.RemoteDesOffset() = aReq.RemoteDesOffset() + pos; |
2081 fragment.RemoteDesOffset() = aReq.RemoteDesOffset() + pos; |
1804 fragment.Pos() = aReq.Pos() + pos; |
2082 fragment.Pos() = aReq.Pos() + pos; |
1805 fragment.Flags() = aReq.Flags(); |
2083 fragment.Flags() = aReq.Flags(); |
1806 |
2084 |
1807 __KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Send fragment (0x%08x) type(%d), length(0x%x), offset within original req(0x%x), pos in media(0x%lx)",&fragment,fragment.Id(), pinnedLen, pos, fragment.Pos())); |
2085 __KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Send fragment (0x%08x) type(%d), length(0x%x), offset within original req(0x%x), pos in media(0x%lx)",&fragment,fragment.Id(), pinnedLen, pos, fragment.Pos())); |
1808 |
2086 OstTraceDefExt5(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE3, "Send fragment 0x%08x; type=%d; length=0x%x; offset within original req=0x%x; position in media=0x%lx", (TUint) &fragment, (TInt) fragment.Id(), (TUint) pinnedLen, (TUint) pos, (TUint) fragment.Pos()); |
|
2087 |
1809 #ifdef BTRACE_PAGING_MEDIA |
2088 #ifdef BTRACE_PAGING_MEDIA |
1810 TInt buf[4]; |
2089 TInt buf[4]; |
1811 buf[0] = pinnedLen; // fragment length |
2090 buf[0] = pinnedLen; // fragment length |
1812 buf[1] = pos; // offset within original request |
2091 buf[1] = pos; // offset within original request |
1813 buf[2] = fragment.Pos(); // offset in media |
2092 buf[2] = fragment.Pos(); // offset in media |
1814 buf[3] = (TInt)&pT->iNThread; // thread that issued the original write req |
2093 buf[3] = (TInt)&pT->iNThread; // thread that issued the original write req |
1815 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedFragmentBegin,&fragment,fragment.Id(),buf,sizeof(buf)); |
2094 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedFragmentBegin,&fragment,fragment.Id(),buf,sizeof(buf)); |
1816 #endif |
2095 #endif |
1817 |
|
1818 r = SendReceive(fragment, aLinAddress); // only come back here when message (fragment) has been completed |
2096 r = SendReceive(fragment, aLinAddress); // only come back here when message (fragment) has been completed |
1819 |
2097 |
1820 // unpin memory |
2098 // unpin memory |
1821 if (pinDataObject) |
2099 if (pinDataObject) |
1822 { |
2100 { |
1823 Kern::UnpinVirtualMemory(pinDataObject->iObject); |
2101 Kern::UnpinVirtualMemory(pinDataObject->iObject); |
1824 ThePinObjectAllocator->ReleasePinObject(pinDataObject); |
2102 ThePinObjectAllocator->ReleasePinObject(pinDataObject); |
2049 { |
2339 { |
2050 DLocalDrive* pD=(DLocalDrive*)m.Ptr0(); |
2340 DLocalDrive* pD=(DLocalDrive*)m.Ptr0(); |
2051 TLocDrv* pL=pD->iDrive; |
2341 TLocDrv* pL=pD->iDrive; |
2052 *((TErrorInfo*) m.RemoteDes()) = pL->iLastErrorInfo; |
2342 *((TErrorInfo*) m.RemoteDes()) = pL->iLastErrorInfo; |
2053 CompleteRequest(m, KErrNone); |
2343 CompleteRequest(m, KErrNone); |
|
2344 OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT6, this ); |
2054 return; |
2345 return; |
2055 } |
2346 } |
2056 case DLocalDrive::EReadPasswordStore: |
2347 case DLocalDrive::EReadPasswordStore: |
2057 { |
2348 { |
2058 TPtr8 pswData ((TUint8*) m.RemoteDes(), (TInt) m.Length()); |
2349 TPtr8 pswData ((TUint8*) m.RemoteDes(), (TInt) m.Length()); |
2059 TInt r = ThePasswordStore->ReadPasswordData(pswData); |
2350 TInt r = ThePasswordStore->ReadPasswordData(pswData); |
2060 m.Length() = pswData.Length(); |
2351 m.Length() = pswData.Length(); |
2061 CompleteRequest(m, r); |
2352 CompleteRequest(m, r); |
|
2353 OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT7, this ); |
2062 return; |
2354 return; |
2063 } |
2355 } |
2064 case DLocalDrive::EWritePasswordStore: |
2356 case DLocalDrive::EWritePasswordStore: |
2065 { |
2357 { |
2066 TPtrC8 pData((TUint8*) m.RemoteDes(), (TInt) m.Length()); |
2358 TPtrC8 pData((TUint8*) m.RemoteDes(), (TInt) m.Length()); |
2067 TInt r = ThePasswordStore->WritePasswordData(pData); |
2359 TInt r = ThePasswordStore->WritePasswordData(pData); |
2068 |
2360 |
2069 if(r != KErrNone) |
2361 if(r != KErrNone) |
2070 { |
2362 { |
2071 CompleteRequest(m, r); |
2363 CompleteRequest(m, r); |
|
2364 OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT8, this ); |
2072 return; |
2365 return; |
2073 } |
2366 } |
2074 |
2367 |
2075 r = QuickCheckStatus(); |
2368 r = QuickCheckStatus(); |
2076 if(r != KErrNone) |
2369 if(r != KErrNone) |
2077 { |
2370 { |
2078 // Don't try to power up the device if it's not ready. |
2371 // Don't try to power up the device if it's not ready. |
2079 // - Note that this isn't an error that needs to be returned to the client. |
2372 // - Note that this isn't an error that needs to be returned to the client. |
2080 CompleteRequest(m, KErrNone); |
2373 CompleteRequest(m, KErrNone); |
|
2374 OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT9, this ); |
2081 return; |
2375 return; |
2082 } |
2376 } |
2083 |
2377 |
2084 break; |
2378 break; |
2085 } |
2379 } |
2086 case DLocalDrive::EPasswordStoreLengthInBytes: |
2380 case DLocalDrive::EPasswordStoreLengthInBytes: |
2087 { |
2381 { |
2088 TInt length = ThePasswordStore->PasswordStoreLengthInBytes(); |
2382 TInt length = ThePasswordStore->PasswordStoreLengthInBytes(); |
2089 *(TInt*) m.RemoteDes() = length; |
2383 *(TInt*) m.RemoteDes() = length; |
2090 CompleteRequest(m, KErrNone); |
2384 CompleteRequest(m, KErrNone); |
|
2385 OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT10, this ); |
2091 return; |
2386 return; |
2092 } |
2387 } |
2093 default: |
2388 default: |
2094 CHECK_RET(KErrNotSupported); |
2389 CHECK_RET(KErrNotSupported); |
2095 CompleteRequest(m, KErrNotSupported); |
2390 CompleteRequest(m, KErrNotSupported); |
|
2391 OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT11, this ); |
2096 return; |
2392 return; |
2097 } |
2393 } |
2098 |
2394 |
2099 __KTRACE_OPT(KFAIL,Kern::Printf("mdrq %d",m.Id())); |
2395 __KTRACE_OPT(KFAIL,Kern::Printf("mdrq %d",m.Id())); |
2100 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::HandleMsg state %d req %d",iMediaId,iState,m.Id())); |
2396 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::HandleMsg state %d req %d",iMediaId,iState,m.Id())); |
2101 |
2397 |
|
2398 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_HANDLEMSG2, "iMediaId=%d; iState=%d; req Id=%d", iMediaId, iState, m.Id()); |
|
2399 |
2102 // if media driver already open, pass request through |
2400 // if media driver already open, pass request through |
2103 if (iState==EReady) |
2401 if (iState==EReady) |
2104 { |
2402 { |
2105 DoRequest(m); |
2403 DoRequest(m); |
2106 __TRACE_TIMING(0x101); |
2404 __TRACE_TIMING(0x101); |
|
2405 OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT12, this ); |
2107 return; |
2406 return; |
2108 } |
2407 } |
2109 |
2408 |
2110 // if open or close in progress, defer this message |
2409 // if open or close in progress, defer this message |
2111 if (iState!=EClosed && iState!=EPoweredDown) |
2410 if (iState!=EClosed && iState!=EPoweredDown) |
2116 __ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
2415 __ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
2117 __ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
2416 __ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
2118 __ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
2417 __ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
2119 |
2418 |
2120 __KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Deferring PageIn request 0x%08x because opening or closing",&m)); |
2419 __KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Deferring PageIn request 0x%08x because opening or closing",&m)); |
|
2420 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_HANDLEMSG3, "Deferring PageIn request 0x%08x because opening or closing", &m); |
2121 iBody->iPagingDevice->SendToDeferredQ(&m); |
2421 iBody->iPagingDevice->SendToDeferredQ(&m); |
2122 } |
2422 } |
2123 else |
2423 else |
2124 #endif |
2424 #endif |
2125 m.Forward(&iDeferred,EFalse); |
2425 m.Forward(&iDeferred,EFalse); |
|
2426 OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT13, this ); |
2126 return; |
2427 return; |
2127 } |
2428 } |
2128 |
2429 |
2129 // nothing is open, so try to open something |
2430 // nothing is open, so try to open something |
2130 __ASSERT_ALWAYS(!iCurrentReq,LOCM_FAULT()); |
2431 __ASSERT_ALWAYS(!iCurrentReq,LOCM_FAULT()); |
2307 { |
2621 { |
2308 __ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
2622 __ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
2309 __ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
2623 __ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
2310 __ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
2624 __ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
2311 __KTRACE_OPT(KLOCDPAGING,Kern::Printf("media driver cannot service or defer PageIn request 0x%08x or serviced it synchronously (%d)",&m, s)); |
2625 __KTRACE_OPT(KLOCDPAGING,Kern::Printf("media driver cannot service or defer PageIn request 0x%08x or serviced it synchronously (%d)",&m, s)); |
|
2626 OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_DOREQUEST4, "Media driver cannot service or defer PageIn request 0x%08x or serviced it synchronously; retval=%d",(TUint) &m, s); |
2312 iBody->iPagingDevice->CompleteRequest(&m, s); |
2627 iBody->iPagingDevice->CompleteRequest(&m, s); |
2313 } |
2628 } |
2314 else |
2629 else |
2315 #endif |
2630 #endif |
2316 |
2631 |
2317 CompleteRequest(m, s); |
2632 CompleteRequest(m, s); |
2318 |
2633 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_INTERNALS, DPRIMARYMEDIABASE_DOREQUEST_RETURN, "Return req Id=%d; Remote Thread=0x%x; retval=%d", (TInt) m.Id(), (TUint) m.RemoteThread(), (TInt) s); |
2319 } |
2634 } |
2320 |
2635 |
2321 iCurrentReq=NULL; |
2636 iCurrentReq=NULL; |
|
2637 OstTraceFunctionExitExt( DPRIMARYMEDIABASE_DOREQUEST_EXIT3, this, r ); |
2322 return r; |
2638 return r; |
2323 } |
2639 } |
2324 |
2640 |
2325 EXPORT_C void DPrimaryMediaBase::PowerUpComplete(TInt anError) |
2641 EXPORT_C void DPrimaryMediaBase::PowerUpComplete(TInt anError) |
2326 /** |
2642 /** |
2351 else if (iState==EPoweringUp2) |
2672 else if (iState==EPoweringUp2) |
2352 { |
2673 { |
2353 // media is powered up and ready, so handle the current/pending requests |
2674 // media is powered up and ready, so handle the current/pending requests |
2354 MediaReadyHandleRequest(); |
2675 MediaReadyHandleRequest(); |
2355 } |
2676 } |
|
2677 OstTraceFunctionExit1( DPRIMARYMEDIABASE_POWERUPCOMPLETE_EXIT2, this ); |
2356 } |
2678 } |
2357 |
2679 |
2358 void DPrimaryMediaBase::CloseMediaDrivers(DMedia* aMedia) |
2680 void DPrimaryMediaBase::CloseMediaDrivers(DMedia* aMedia) |
2359 { |
2681 { |
|
2682 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_ENTRY, this ); |
2360 __KTRACE_OPT(KLOCDRV,Kern::Printf(">DPrimaryMediaBase(%d)::CloseMediaDrivers",iMediaId)); |
2683 __KTRACE_OPT(KLOCDRV,Kern::Printf(">DPrimaryMediaBase(%d)::CloseMediaDrivers",iMediaId)); |
2361 |
2684 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS1, "DPrimaryMediaBase iMediaId=%d", iMediaId ); |
|
2685 |
2362 // we mustn't ever close the media driver if it's responsible for data paging as re-opening the drive |
2686 // we mustn't ever close the media driver if it's responsible for data paging as re-opening the drive |
2363 // would involve memory allocation which might cause deadlock if the kernel heap were to grow |
2687 // would involve memory allocation which might cause deadlock if the kernel heap were to grow |
2364 #ifdef __DEMAND_PAGING__ |
2688 #ifdef __DEMAND_PAGING__ |
2365 if (DataPagingDfcQ(this)) |
2689 if (DataPagingDfcQ(this)) |
2366 { |
2690 { |
2367 __KTRACE_OPT(KLOCDRV,Kern::Printf("CloseMediaDrivers aborting for data paging media %08X", this)); |
2691 __KTRACE_OPT(KLOCDRV,Kern::Printf("CloseMediaDrivers aborting for data paging media %08X", this)); |
|
2692 OstTrace1(TRACE_FLOW, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_EXIT1, "CloseMediaDrivers aborting for data paging media 0x%08x", this); |
2368 return; |
2693 return; |
2369 } |
2694 } |
2370 #endif |
2695 #endif |
2371 |
2696 |
2372 TInt i; |
2697 TInt i; |
2388 if (aMedia == NULL || pM == aMedia) |
2714 if (aMedia == NULL || pM == aMedia) |
2389 { |
2715 { |
2390 DMediaDriver* pD=pM->iDriver; |
2716 DMediaDriver* pD=pM->iDriver; |
2391 pM->iDriver=NULL; |
2717 pM->iDriver=NULL; |
2392 __KTRACE_OPT(KLOCDRV,Kern::Printf("DMedia[%d] @ %08x Driver @ %08x",i,pM,pD)); |
2718 __KTRACE_OPT(KLOCDRV,Kern::Printf("DMedia[%d] @ %08x Driver @ %08x",i,pM,pD)); |
|
2719 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS3, "MediaId=%d; DMedia=0x%08x; MediaDriver=0x%08x", (TInt) i, (TUint) pM, (TUint) pD ); |
2393 if (pD) |
2720 if (pD) |
2394 pD->Close(); |
2721 pD->Close(); |
2395 } |
2722 } |
2396 } |
2723 } |
2397 __KTRACE_OPT(KLOCDRV,Kern::Printf("<DPrimaryMediaBase(%d)::CloseMediaDrivers",iMediaId)); |
2724 __KTRACE_OPT(KLOCDRV,Kern::Printf("<DPrimaryMediaBase(%d)::CloseMediaDrivers",iMediaId)); |
|
2725 OstTraceFunctionExit1( DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_EXIT2, this ); |
2398 } |
2726 } |
2399 |
2727 |
2400 void DPrimaryMediaBase::StartOpenMediaDrivers() |
2728 void DPrimaryMediaBase::StartOpenMediaDrivers() |
2401 { |
2729 { |
|
2730 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_ENTRY, this ); |
2402 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::StartOpenMediaDrivers",iMediaId)); |
2731 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::StartOpenMediaDrivers",iMediaId)); |
|
2732 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS, "DPrimaryMediaBase iMediaId=%d ",iMediaId); |
2403 TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
2733 TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
2404 |
2734 |
2405 // Get a list of all currently loaded media drivers |
2735 // Get a list of all currently loaded media drivers |
2406 // Most media drivers do not make use of the pointer iMountInfo.iInfo when |
2736 // Most media drivers do not make use of the pointer iMountInfo.iInfo when |
2407 // their Validate() procedures are called from RPhysicalDeviceArray::GetDriverList(). |
2737 // their Validate() procedures are called from RPhysicalDeviceArray::GetDriverList(). |
2412 TInt r=iPhysDevArray.GetDriverList(KLitMediaDriverName,iDevice,iMountInfo.iInfo,ver); |
2742 TInt r=iPhysDevArray.GetDriverList(KLitMediaDriverName,iDevice,iMountInfo.iInfo,ver); |
2413 if (r!=KErrNone) |
2743 if (r!=KErrNone) |
2414 { |
2744 { |
2415 // out of memory or no driver exists |
2745 // out of memory or no driver exists |
2416 SetClosed(r); |
2746 SetClosed(r); |
|
2747 OstTraceFunctionExit1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_EXIT1, this ); |
2417 return; |
2748 return; |
2418 } |
2749 } |
2419 |
2750 |
2420 // Go through them starting with highest priority |
2751 // Go through them starting with highest priority |
2421 iNextMediaId=iMediaId; |
2752 iNextMediaId=iMediaId; |
2422 iBody->iPhysDevIndex=iPhysDevArray.Count()-1; |
2753 iBody->iPhysDevIndex=iPhysDevArray.Count()-1; |
2423 iTotalPartitionsOpened=0; |
2754 iTotalPartitionsOpened=0; |
2424 iMediaDriversOpened=0; |
2755 iMediaDriversOpened=0; |
2425 iNextMediaDriver=NULL; |
2756 iNextMediaDriver=NULL; |
2426 OpenNextMediaDriver(); |
2757 OpenNextMediaDriver(); |
|
2758 OstTraceFunctionExit1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_EXIT2, this ); |
2427 } |
2759 } |
2428 |
2760 |
2429 void DPrimaryMediaBase::OpenNextMediaDriver() |
2761 void DPrimaryMediaBase::OpenNextMediaDriver() |
2430 { |
2762 { |
|
2763 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_ENTRY, this ); |
2431 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::OpenNextMediaDriver, this %x mediaId %d iBody->iPhysDevIndex %d",iNextMediaId, this, iMediaId, iBody->iPhysDevIndex)); |
2764 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::OpenNextMediaDriver, this %x mediaId %d iBody->iPhysDevIndex %d",iNextMediaId, this, iMediaId, iBody->iPhysDevIndex)); |
2432 |
2765 OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER, "DPrimaryMediaBase iNextMediaId=%d; this=%x; imediaId=%d; iBody->iPhysDevIndex=%d",iNextMediaId, (TUint) this, iMediaId, iBody->iPhysDevIndex); |
|
2766 |
2433 TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
2767 TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
2434 SPhysicalDeviceEntry& e=iPhysDevArray[iBody->iPhysDevIndex]; |
2768 SPhysicalDeviceEntry& e=iPhysDevArray[iBody->iPhysDevIndex]; |
2435 DPhysicalDevice* pD=e.iPhysicalDevice; |
2769 DPhysicalDevice* pD=e.iPhysicalDevice; |
2436 |
2770 |
2437 iState = EOpening; |
2771 iState = EOpening; |
2439 DMedia* pM=TheMedia[iNextMediaId]; |
2773 DMedia* pM=TheMedia[iNextMediaId]; |
2440 if (pM && pM->iDriver != NULL) |
2774 if (pM && pM->iDriver != NULL) |
2441 { |
2775 { |
2442 iNextMediaDriver = pM->iDriver; |
2776 iNextMediaDriver = pM->iDriver; |
2443 DoOpenMediaDriverComplete(KErrNone); |
2777 DoOpenMediaDriverComplete(KErrNone); |
|
2778 OstTraceFunctionExit1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_EXIT1, this ); |
2444 return; |
2779 return; |
2445 } |
2780 } |
2446 |
2781 |
2447 // this may be asynchronous |
2782 // this may be asynchronous |
2448 TInt s=pD->Create( (DBase*&)iNextMediaDriver, iMediaId, (TDesC8*) &iMountInfo, ver); |
2783 TInt s=pD->Create( (DBase*&)iNextMediaDriver, iMediaId, (TDesC8*) &iMountInfo, ver); |
2449 |
2784 |
2450 __KTRACE_OPT(KLOCDRV,Kern::Printf("Media:Open-Opening %o(PRI:%d)-%d",pD,e.iPriority,s)); |
2785 __KTRACE_OPT(KLOCDRV,Kern::Printf("Media:Open-Opening %o(PRI:%d)-%d",pD,e.iPriority,s)); |
2451 if (s!=KErrNone) |
2786 if (s!=KErrNone) |
2452 { |
2787 { |
2453 iAsyncErrorCode=s; |
2788 iAsyncErrorCode=s; |
2454 iAsyncDfc.Enque(); |
2789 iAsyncDfc.Enque(); |
2455 } |
2790 } |
|
2791 OstTraceFunctionExit1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_EXIT2, this ); |
2456 } |
2792 } |
2457 |
2793 |
2458 // Called when a media driver has responded to the Open request |
2794 // Called when a media driver has responded to the Open request |
2459 void DPrimaryMediaBase::DoOpenMediaDriverComplete(TInt anError) |
2795 void DPrimaryMediaBase::DoOpenMediaDriverComplete(TInt anError) |
2460 { |
2796 { |
|
2797 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE_ENTRY, this ); |
2461 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::DoOpenMediaDriverComplete error %d iNextMediaDriver %x",iNextMediaId,anError,iNextMediaDriver)); |
2798 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::DoOpenMediaDriverComplete error %d iNextMediaDriver %x",iNextMediaId,anError,iNextMediaDriver)); |
2462 |
2799 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE, "iMediaId=%d; anError=%d; iNextMediaDriver=0x%x", (TInt) iNextMediaId, (TInt) anError, (TUint) iNextMediaDriver); |
|
2800 |
|
2801 |
2463 if (anError!=KErrNone) |
2802 if (anError!=KErrNone) |
2464 { |
2803 { |
2465 DMediaDriver* md = iNextMediaDriver; |
2804 DMediaDriver* md = iNextMediaDriver; |
2466 iNextMediaDriver = NULL; |
2805 iNextMediaDriver = NULL; |
2467 if (md) |
2806 if (md) |
2549 else |
2896 else |
2550 iBody->iPhysDevIndex--; |
2897 iBody->iPhysDevIndex--; |
2551 if (!complete) |
2898 if (!complete) |
2552 { |
2899 { |
2553 OpenNextMediaDriver(); |
2900 OpenNextMediaDriver(); |
|
2901 OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT2, this ); |
2554 return; |
2902 return; |
2555 } |
2903 } |
2556 |
2904 |
2557 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase %d All media drivers open & partitions read",iMediaId)); |
2905 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase %d All media drivers open & partitions read",iMediaId)); |
2558 __KTRACE_OPT(KLOCDRV,Kern::Printf("%d media drivers opened",iMediaDriversOpened)); |
2906 __KTRACE_OPT(KLOCDRV,Kern::Printf("%d media drivers opened",iMediaDriversOpened)); |
|
2907 OstTrace1( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE3, "iMediaDriversOpened=%d", iMediaDriversOpened ); |
2559 if (iMediaDriversOpened==0) |
2908 if (iMediaDriversOpened==0) |
2560 { |
2909 { |
2561 SetClosed(KErrNotSupported); |
2910 SetClosed(KErrNotSupported); |
|
2911 OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT3, this ); |
2562 return; |
2912 return; |
2563 } |
2913 } |
2564 |
2914 |
2565 // we are now finished with media driver list |
2915 // we are now finished with media driver list |
2566 iPhysDevArray.Close(); |
2916 iPhysDevArray.Close(); |
2567 |
2917 |
2568 // Finished reading partition info |
2918 // Finished reading partition info |
2569 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase %d Read partition info complete",iMediaId)); |
2919 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase %d Read partition info complete",iMediaId)); |
2570 __KTRACE_OPT(KLOCDRV,Kern::Printf("%d total partitions",iTotalPartitionsOpened)); |
2920 __KTRACE_OPT(KLOCDRV,Kern::Printf("%d total partitions",iTotalPartitionsOpened)); |
|
2921 OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE4, "Read partition info complete iMediaId=%d; iPartitionsOpened=%d", iMediaId, iTotalPartitionsOpened ); |
2571 if (iTotalPartitionsOpened==0) |
2922 if (iTotalPartitionsOpened==0) |
2572 { |
2923 { |
2573 SetClosed(KErrNotSupported); |
2924 SetClosed(KErrNotSupported); |
|
2925 OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT4, this ); |
2574 return; |
2926 return; |
2575 } |
2927 } |
2576 |
2928 |
2577 // work out mapping of drives to partitions/media |
2929 // work out mapping of drives to partitions/media |
2578 TInt totalPartitions=iTotalPartitionsOpened; |
2930 TInt totalPartitions=iTotalPartitionsOpened; |
2579 TInt id=iMediaId; // start with primary media |
2931 TInt id=iMediaId; // start with primary media |
2580 TInt partitionsOnThisMedia=PartitionCount(); |
2932 TInt partitionsOnThisMedia=PartitionCount(); |
2581 TInt partition=0; |
2933 TInt partition=0; |
2595 id++; |
2947 id++; |
2596 partition=0; |
2948 partition=0; |
2597 partitionsOnThisMedia=TheMedia[id]->PartitionCount(); |
2949 partitionsOnThisMedia=TheMedia[id]->PartitionCount(); |
2598 } |
2950 } |
2599 __KTRACE_OPT(KLOCDRV,Kern::Printf("Drive %d = Media %d Partition %d",j,id,partition)); |
2951 __KTRACE_OPT(KLOCDRV,Kern::Printf("Drive %d = Media %d Partition %d",j,id,partition)); |
|
2952 OstTraceExt3( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE5, "Local Drive=%d; iMediaId=%d; partition=%d", j, id, partition ); |
|
2953 |
2600 pD->iMedia=TheMedia[id]; |
2954 pD->iMedia=TheMedia[id]; |
2601 pD->iPartitionNumber=partition; |
2955 pD->iPartitionNumber=partition; |
2602 memcpy(pD, pD->iMedia->iPartitionInfo.iEntry+partition, sizeof(TPartitionEntry)); |
2956 memcpy(pD, pD->iMedia->iPartitionInfo.iEntry+partition, sizeof(TPartitionEntry)); |
2603 partition++; |
2957 partition++; |
2604 totalPartitions--; |
2958 totalPartitions--; |
2605 } |
2959 } |
2606 } |
2960 } |
2607 |
2961 |
2608 // media is now ready - handle current or deferred requests |
2962 // media is now ready - handle current or deferred requests |
2609 MediaReadyHandleRequest(); |
2963 MediaReadyHandleRequest(); |
|
2964 OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT5, this ); |
2610 } |
2965 } |
2611 |
2966 |
2612 void DPrimaryMediaBase::MediaReadyHandleRequest() |
2967 void DPrimaryMediaBase::MediaReadyHandleRequest() |
2613 { |
2968 { |
|
2969 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_MEDIAREADYHANDLEREQUEST_ENTRY, this ); |
2614 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase::MediaReadyHandleRequest() this %x", this)); |
2970 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase::MediaReadyHandleRequest() this %x", this)); |
2615 iState = EReady; |
2971 iState = EReady; |
2616 |
2972 |
2617 // now we can process the current request |
2973 // now we can process the current request |
2618 // careful - thread may have exited while we were powering up |
2974 // careful - thread may have exited while we were powering up |
2621 DoRequest(*iCurrentReq); // this sets iCurrentReq=NULL |
2977 DoRequest(*iCurrentReq); // this sets iCurrentReq=NULL |
2622 } |
2978 } |
2623 |
2979 |
2624 // see if we can process any other requests concurrently |
2980 // see if we can process any other requests concurrently |
2625 RunDeferred(); |
2981 RunDeferred(); |
|
2982 OstTraceFunctionExit1( DPRIMARYMEDIABASE_MEDIAREADYHANDLEREQUEST_EXIT, this ); |
2626 } |
2983 } |
2627 |
2984 |
2628 void DPrimaryMediaBase::UpdatePartitionInfo() |
2985 void DPrimaryMediaBase::UpdatePartitionInfo() |
2629 { |
2986 { |
|
2987 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_UPDATEPARTITIONINFO_ENTRY, this ); |
2630 iState=EReadPartitionInfo; |
2988 iState=EReadPartitionInfo; |
2631 iNextMediaId=iMediaId; |
2989 iNextMediaId=iMediaId; |
2632 DMedia* pM=TheMedia[iNextMediaId]; |
2990 DMedia* pM=TheMedia[iNextMediaId]; |
2633 TInt r=pM->iDriver->PartitionInfo(pM->iPartitionInfo); |
2991 TInt r=pM->iDriver->PartitionInfo(pM->iPartitionInfo); |
2634 if (r!=KErrNone) |
2992 if (r!=KErrNone) |
2635 { |
2993 { |
2636 if (r==KErrCompletion) |
2994 if (r==KErrCompletion) |
2637 r=KErrNone; |
2995 r=KErrNone; |
2638 DoPartitionInfoComplete(r); |
2996 DoPartitionInfoComplete(r); |
2639 } |
2997 } |
|
2998 OstTraceFunctionExit1( DPRIMARYMEDIABASE_UPDATEPARTITIONINFO_EXIT, this ); |
2640 } |
2999 } |
2641 |
3000 |
2642 void DPrimaryMediaBase::CompleteCurrent(TInt anError) |
3001 void DPrimaryMediaBase::CompleteCurrent(TInt anError) |
2643 { |
3002 { |
|
3003 OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_COMPLETECURRENT_ENTRY, this ); |
2644 if (iCurrentReq) |
3004 if (iCurrentReq) |
2645 { |
3005 { |
2646 CHECK_RET(anError); |
3006 CHECK_RET(anError); |
2647 #ifdef __DEMAND_PAGING__ |
3007 #ifdef __DEMAND_PAGING__ |
2648 // got here because it was powered down when powering up, or failed powering up or failed opening MD or got media change |
3008 // got here because it was powered down when powering up, or failed powering up or failed opening MD or got media change |
2651 __ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
3011 __ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
2652 __ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
3012 __ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
2653 __ASSERT_ALWAYS( ((iCurrentReq->Flags() & TLocDrvRequest::ECodePaging) == 0) || (iCurrentReq->Drive()->iPagingDrv), LOCM_FAULT()); |
3013 __ASSERT_ALWAYS( ((iCurrentReq->Flags() & TLocDrvRequest::ECodePaging) == 0) || (iCurrentReq->Drive()->iPagingDrv), LOCM_FAULT()); |
2654 |
3014 |
2655 __KTRACE_OPT2(KLOCDPAGING,KFAIL,Kern::Printf("Got here because it was powered down when powering up, or failed powering up or failed opening MD or got media change")); |
3015 __KTRACE_OPT2(KLOCDPAGING,KFAIL,Kern::Printf("Got here because it was powered down when powering up, or failed powering up or failed opening MD or got media change")); |
|
3016 OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_COMPLETECURRENT, "Completed request due to powered down when powering up, or failed powering up or failed opening MD or got media change"); |
2656 iBody->iPagingDevice->CompleteRequest(iCurrentReq, anError); |
3017 iBody->iPagingDevice->CompleteRequest(iCurrentReq, anError); |
2657 } |
3018 } |
2658 else |
3019 else |
2659 #endif |
3020 #endif |
2660 CompleteRequest(*iCurrentReq, anError); |
3021 CompleteRequest(*iCurrentReq, anError); |
2661 iCurrentReq=NULL; |
3022 iCurrentReq=NULL; |
2662 } |
3023 } |
|
3024 OstTraceFunctionExit1( DPRIMARYMEDIABASE_COMPLETECURRENT_EXIT, this ); |
2663 } |
3025 } |
2664 |
3026 |
2665 |
3027 |
2666 void DPrimaryMediaBase::CompleteRequest(TLocDrvRequest& aMsg, TInt aResult) |
3028 void DPrimaryMediaBase::CompleteRequest(TLocDrvRequest& aMsg, TInt aResult) |
2667 { |
3029 { |
|
3030 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_COMPLETEREQUEST_ENTRY, this ); |
|
3031 OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_COMPLETEREQUEST1, "TLocDrvRequest Object=0x%x; aResult=%d", (TUint) &aMsg, aResult); |
2668 aMsg.Complete(aResult,EFalse); |
3032 aMsg.Complete(aResult,EFalse); |
|
3033 OstTraceFunctionExit1( DPRIMARYMEDIABASE_COMPLETEREQUEST_EXIT, this ); |
2669 } |
3034 } |
2670 |
3035 |
2671 EXPORT_C void DPrimaryMediaBase::RunDeferred() |
3036 EXPORT_C void DPrimaryMediaBase::RunDeferred() |
2672 /** |
3037 /** |
2673 Runs deferred Requests. Initiated from DPrimaryMediaBase::PowerUpComplete() function |
3038 Runs deferred Requests. Initiated from DPrimaryMediaBase::PowerUpComplete() function |
2674 to see if any other requests can be processed concurrently. |
3039 to see if any other requests can be processed concurrently. |
2675 Can also be called from DPrimaryMediaBase::NotifyPowerDown |
3040 Can also be called from DPrimaryMediaBase::NotifyPowerDown |
2676 or DPrimaryMediaBase::NotifyEmergencyPowerDown() function or DMediaDriver::Complete() |
3041 or DPrimaryMediaBase::NotifyEmergencyPowerDown() function or DMediaDriver::Complete() |
2677 */ |
3042 */ |
2678 { |
3043 { |
|
3044 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_RUNDEFERRED_ENTRY, this ); |
2679 // Do nothing if an open or close is in progress - this might be the case, for example, |
3045 // Do nothing if an open or close is in progress - this might be the case, for example, |
2680 // if a EForceMediaChange request (with the KForceMediaChangeReOpenMediaDriver flag) |
3046 // if a EForceMediaChange request (with the KForceMediaChangeReOpenMediaDriver flag) |
2681 // has recently been processed |
3047 // has recently been processed |
2682 if (iState!=EReady && iState!=EClosed && iState!=EPoweredDown) |
3048 if (iState!=EReady && iState!=EClosed && iState!=EPoweredDown) |
|
3049 { |
|
3050 OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT1, this ); |
2683 return; |
3051 return; |
2684 |
3052 } |
|
3053 |
2685 // rerun deferred requests; |
3054 // rerun deferred requests; |
2686 #ifdef __DEMAND_PAGING__ |
3055 #ifdef __DEMAND_PAGING__ |
2687 #ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
3056 #ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
2688 TInt countROM=0; |
3057 TInt countROM=0; |
2689 TInt countCode=0; |
3058 TInt countCode=0; |
2791 #endif |
3164 #endif |
2792 } // if (pM) |
3165 } // if (pM) |
2793 } // if(iPagingMedia) |
3166 } // if(iPagingMedia) |
2794 #endif |
3167 #endif |
2795 if (iRunningDeferred) |
3168 if (iRunningDeferred) |
|
3169 { |
|
3170 OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT4, this ); |
2796 return; |
3171 return; |
|
3172 } |
2797 TMessageBase* pL = iDeferred.Last(); |
3173 TMessageBase* pL = iDeferred.Last(); |
2798 if (!pL) |
3174 if (!pL) |
|
3175 { |
|
3176 OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT5, this ); |
2799 return; // no deferred requests |
3177 return; // no deferred requests |
|
3178 } |
2800 iRunningDeferred=1; |
3179 iRunningDeferred=1; |
2801 TMessageBase* pM=NULL; |
3180 TMessageBase* pM=NULL; |
2802 |
3181 |
2803 while( pM != pL && (pM=iDeferred.Poll()) != NULL) // stop after processing last one (requests may be re-deferred) |
3182 while( pM != pL && (pM=iDeferred.Poll()) != NULL) // stop after processing last one (requests may be re-deferred) |
2804 DoRequest(*(TLocDrvRequest*)pM); |
3183 DoRequest(*(TLocDrvRequest*)pM); |
2805 iRunningDeferred=0; |
3184 iRunningDeferred=0; |
|
3185 |
|
3186 OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT6, this ); |
2806 } |
3187 } |
2807 |
3188 |
2808 void DPrimaryMediaBase::SetClosed(TInt anError) |
3189 void DPrimaryMediaBase::SetClosed(TInt anError) |
2809 { |
3190 { |
|
3191 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_SETCLOSED_ENTRY, this ); |
2810 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::SetClosed error %d",iMediaId,anError)); |
3192 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::SetClosed error %d",iMediaId,anError)); |
|
3193 OstTraceExt2( TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_SETCLOSED, "iMediaId=%d; anError=%d", iMediaId, anError ); |
2811 CHECK_RET(anError); |
3194 CHECK_RET(anError); |
2812 |
3195 |
2813 // cancel DMediaDriver::OpenMediaDriverComplete() / DMediaDriver::PartitionInfoComplete() DFC |
3196 // cancel DMediaDriver::OpenMediaDriverComplete() / DMediaDriver::PartitionInfoComplete() DFC |
2814 iAsyncDfc.Cancel(); |
3197 iAsyncDfc.Cancel(); |
2815 |
3198 |
2828 iPhysDevArray.Close(); |
3211 iPhysDevArray.Close(); |
2829 |
3212 |
2830 iState = EClosed; |
3213 iState = EClosed; |
2831 |
3214 |
2832 iWaitMedChg.CompleteAll(KErrNone); |
3215 iWaitMedChg.CompleteAll(KErrNone); |
|
3216 OstTraceFunctionExit1( DPRIMARYMEDIABASE_SETCLOSED_EXIT, this ); |
2833 } |
3217 } |
2834 |
3218 |
2835 void DPrimaryMediaBase::NotifyClients(TBool aMediaChange,TLocDrv* aLocDrv) |
3219 void DPrimaryMediaBase::NotifyClients(TBool aMediaChange,TLocDrv* aLocDrv) |
2836 |
3220 |
2837 // |
3221 // |
2838 // Notify all clients of a media change or power-down event |
3222 // Notify all clients of a media change or power-down event |
2839 // |
3223 // |
2840 { |
3224 { |
|
3225 OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_NOTIFYCLIENTS_ENTRY, this ); |
|
3226 |
2841 SDblQueLink* pL=iConnectionQ.iA.iNext; |
3227 SDblQueLink* pL=iConnectionQ.iA.iNext; |
2842 while (pL!=&iConnectionQ.iA) |
3228 while (pL!=&iConnectionQ.iA) |
2843 { |
3229 { |
2844 DLocalDrive* pD=_LOFF(pL,DLocalDrive,iLink); |
3230 DLocalDrive* pD=_LOFF(pL,DLocalDrive,iLink); |
2845 // Issue the notification if the caller wants to notify all drives (aLocDrv == NULL) or |
3231 // Issue the notification if the caller wants to notify all drives (aLocDrv == NULL) or |
2846 // the specified drive matches this one |
3232 // the specified drive matches this one |
2847 if (aLocDrv == NULL || aLocDrv == pD->iDrive) |
3233 if (aLocDrv == NULL || aLocDrv == pD->iDrive) |
2848 pD->NotifyChange(*this, aMediaChange); |
3234 pD->NotifyChange(*this, aMediaChange); |
2849 pL=pL->iNext; |
3235 pL=pL->iNext; |
2850 } |
3236 } |
|
3237 OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYCLIENTS_EXIT, this ); |
2851 } |
3238 } |
2852 |
3239 |
2853 EXPORT_C void DPrimaryMediaBase::NotifyMediaChange() |
3240 EXPORT_C void DPrimaryMediaBase::NotifyMediaChange() |
2854 /** |
3241 /** |
2855 Closes all media drivers on this device and notifies all connections that media change has occurred |
3242 Closes all media drivers on this device and notifies all connections that media change has occurred |
2856 and completes any outstanding requests with KErrNotReady. |
3243 and completes any outstanding requests with KErrNotReady. |
2857 This also completes any force media change requests with KErrNone. |
3244 This also completes any force media change requests with KErrNone. |
2858 */ |
3245 */ |
2859 { |
3246 { |
|
3247 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYMEDIACHANGE_ENTRY, this ); |
2860 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyMediaChange state %d",iMediaId,iState)); |
3248 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyMediaChange state %d",iMediaId,iState)); |
2861 |
3249 |
|
3250 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_NOTIFYMEDIACHANGE, "iMediaId=%d; iState=%d", iMediaId, iState ); |
|
3251 |
2862 TInt state=iState; |
3252 TInt state=iState; |
2863 |
3253 |
2864 __ASSERT_DEBUG(iBody, LOCM_FAULT()); |
3254 __ASSERT_DEBUG(iBody, LOCM_FAULT()); |
2865 |
3255 |
2866 #ifdef __DEMAND_PAGING__ |
3256 #ifdef __DEMAND_PAGING__ |
2948 CloseMediaDrivers(); |
3343 CloseMediaDrivers(); |
2949 SetClosed(KErrNotReady); |
3344 SetClosed(KErrNotReady); |
2950 } |
3345 } |
2951 |
3346 |
2952 NotifyClients(EFalse); |
3347 NotifyClients(EFalse); |
|
3348 OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYPOWERDOWN_EXIT, this ); |
2953 } |
3349 } |
2954 |
3350 |
2955 |
3351 |
2956 EXPORT_C void DPrimaryMediaBase::NotifyPsuFault(TInt anError) |
3352 EXPORT_C void DPrimaryMediaBase::NotifyPsuFault(TInt anError) |
2957 /** |
3353 /** |
2958 Closes all media drivers on this device and completes any outstanding requests with error code. |
3354 Closes all media drivers on this device and completes any outstanding requests with error code. |
2959 @param anError Error code to be passed on while closing media drivers and completing outstanding requests. |
3355 @param anError Error code to be passed on while closing media drivers and completing outstanding requests. |
2960 */ |
3356 */ |
2961 |
3357 |
2962 { |
3358 { |
|
3359 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYPSUFAULT_ENTRY, this ); |
2963 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyPsuFault state %d, err %d",iMediaId,iState,anError)); |
3360 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyPsuFault state %d, err %d",iMediaId,iState,anError)); |
2964 |
3361 OstTraceExt3( TRACE_INTERNALS, DPRIMARYMEDIABASE_NOTIFYPSUFAULT, "iMediaId=%d; iState=%d; anError=%d", iMediaId, iState, anError ); |
|
3362 |
2965 if (iState>=EOpening) |
3363 if (iState>=EOpening) |
2966 { |
3364 { |
2967 CloseMediaDrivers(); |
3365 CloseMediaDrivers(); |
2968 } |
3366 } |
2969 |
3367 |
2970 // complete any outstanding requests with error |
3368 // complete any outstanding requests with error |
2971 SetClosed(anError); |
3369 SetClosed(anError); |
|
3370 OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYPSUFAULT_EXIT, this ); |
2972 } |
3371 } |
2973 |
3372 |
2974 EXPORT_C void DPrimaryMediaBase::NotifyEmergencyPowerDown() |
3373 EXPORT_C void DPrimaryMediaBase::NotifyEmergencyPowerDown() |
2975 /** |
3374 /** |
2976 Called on emergency power down. Notifies all media drivers on this device. |
3375 Called on emergency power down. Notifies all media drivers on this device. |
2977 If it is not in a ready state then it completes the current request but leaves other outstanding requests. |
3376 If it is not in a ready state then it completes the current request but leaves other outstanding requests. |
2978 If it is ready then the media driver should complete the current request. |
3377 If it is ready then the media driver should complete the current request. |
2979 It closes all media drivers and notifies all clients of a power down event. |
3378 It closes all media drivers and notifies all clients of a power down event. |
2980 */ |
3379 */ |
2981 { |
3380 { |
|
3381 OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYEMERGENCYPOWERDOWN_ENTRY, this ); |
2982 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyEmergencyPowerDown state %d",iMediaId,iState)); |
3382 __KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyEmergencyPowerDown state %d",iMediaId,iState)); |
|
3383 OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_NOTIFYEMERGENCYPOWERDOWN, "iMediaId=%d; iState=%d", iMediaId, iState ); |
|
3384 |
2983 TBool recover=EFalse; |
3385 TBool recover=EFalse; |
2984 if (iState==EReady && iCritical!=0) |
3386 if (iState==EReady && iCritical!=0) |
2985 { |
3387 { |
2986 // check if emergency power recovery supported |
3388 // check if emergency power recovery supported |
2987 ; |
3389 ; |
3212 void DPrimaryMediaBase::RequestCountDec() |
3635 void DPrimaryMediaBase::RequestCountDec() |
3213 { |
3636 { |
3214 __ASSERT_DEBUG(iBody, LOCM_FAULT()); |
3637 __ASSERT_DEBUG(iBody, LOCM_FAULT()); |
3215 TInt oldVal = (TInt) __e32_atomic_add_ord32(&iBody->iRequestCount, (TUint) -1); |
3638 TInt oldVal = (TInt) __e32_atomic_add_ord32(&iBody->iRequestCount, (TUint) -1); |
3216 //Kern::Printf("RCDEC: this %x cnt %d, old %d", this, iBody->iRequestCount, oldVal); |
3639 //Kern::Printf("RCDEC: this %x cnt %d, old %d", this, iBody->iRequestCount, oldVal); |
|
3640 |
|
3641 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_REQUESTCOUNTDEC, "new count=%d; old count=%d", iBody->iRequestCount, oldVal ); |
|
3642 |
3217 if (oldVal == 1 && iBody->iPagingDevice) |
3643 if (oldVal == 1 && iBody->iPagingDevice) |
3218 { |
3644 { |
3219 //Kern::Printf("RCDEC: NotifyIdle()"); |
3645 //Kern::Printf("RCDEC: NotifyIdle()"); |
3220 iBody->iPagingDevice->NotifyIdle(); |
3646 iBody->iPagingDevice->NotifyIdle(); |
3221 } |
3647 } |
3222 __ASSERT_DEBUG(iBody->iRequestCount >= 0, LOCM_FAULT()); |
3648 __ASSERT_DEBUG(iBody->iRequestCount >= 0, LOCM_FAULT()); |
3223 } |
3649 } |
3224 #endif // __DEMAND_PAGING__ |
3650 #endif // __DEMAND_PAGING__ |
3225 |
|
3226 |
3651 |
3227 TPartitionInfo::TPartitionInfo() |
3652 TPartitionInfo::TPartitionInfo() |
3228 // |
3653 // |
3229 // Constructor |
3654 // Constructor |
3230 // |
3655 // |
3305 iDataOutBenchmarkData.iCount=iDataOutBenchmarkData.iTotalTime=iDataOutBenchmarkData.iMaxTime=0; |
3734 iDataOutBenchmarkData.iCount=iDataOutBenchmarkData.iTotalTime=iDataOutBenchmarkData.iMaxTime=0; |
3306 iDataOutBenchmarkData.iMinTime = KMaxTInt; |
3735 iDataOutBenchmarkData.iMinTime = KMaxTInt; |
3307 #endif |
3736 #endif |
3308 |
3737 |
3309 iMainQ.Receive(); |
3738 iMainQ.Receive(); |
|
3739 OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_CONSTRUCTOR_EXIT, this ); |
3310 } |
3740 } |
3311 |
3741 |
3312 DMediaPagingDevice::~DMediaPagingDevice() |
3742 DMediaPagingDevice::~DMediaPagingDevice() |
3313 { |
3743 { |
|
3744 OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_DESTRUCTOR_ENTRY, this ); |
3314 |
3745 |
3315 if (iMountInfoDataLock) |
3746 if (iMountInfoDataLock) |
3316 ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDataLock); |
3747 ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDataLock); |
3317 |
3748 |
3318 if (iMountInfoDescHdrLock) |
3749 if (iMountInfoDescHdrLock) |
3319 ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDescHdrLock); |
3750 ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDescHdrLock); |
3320 |
3751 |
3321 if (iMountInfoDescLenLock) |
3752 if (iMountInfoDescLenLock) |
3322 ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDescLenLock); |
3753 ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDescLenLock); |
|
3754 OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_DESTRUCTOR_EXIT, this ); |
3323 } |
3755 } |
3324 |
3756 |
3325 |
3757 |
3326 void DMediaPagingDevice::SendToMainQueueDfcAndBlock(TThreadMessage* aMsg) |
3758 void DMediaPagingDevice::SendToMainQueueDfcAndBlock(TThreadMessage* aMsg) |
3327 { |
3759 { |
|
3760 OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_SENDTOMAINQUEUEDFCANDBLOCK_ENTRY, this ); |
3328 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("Send request 0x%08x to main queue",aMsg)); |
3761 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("Send request 0x%08x to main queue",aMsg)); |
3329 __ASSERT_ALWAYS(aMsg->iState==TMessageBase::EFree,LOCM_FAULT()); // check that message was previously completed or never queued |
3762 __ASSERT_ALWAYS(aMsg->iState==TMessageBase::EFree,LOCM_FAULT()); // check that message was previously completed or never queued |
3330 |
3763 |
3331 // if drive supports DMA, turn on Physical memory flag & sync memory |
3764 // if drive supports DMA, turn on Physical memory flag & sync memory |
3332 TLocDrvRequest& m=*(TLocDrvRequest*)(aMsg); |
3765 TLocDrvRequest& m=*(TLocDrvRequest*)(aMsg); |
3367 } |
3800 } |
3368 |
3801 |
3369 |
3802 |
3370 // come back here when request is completed |
3803 // come back here when request is completed |
3371 __ASSERT_DEBUG(aMsg->iState==TMessageBase::EFree,LOCM_FAULT()); // check message has been completed |
3804 __ASSERT_DEBUG(aMsg->iState==TMessageBase::EFree,LOCM_FAULT()); // check message has been completed |
|
3805 OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_SENDTOMAINQUEUEDFCANDBLOCK_EXIT, this ); |
3372 } |
3806 } |
3373 |
3807 |
3374 void DMediaPagingDevice::SendToDeferredQ(TThreadMessage* aMsg) |
3808 void DMediaPagingDevice::SendToDeferredQ(TThreadMessage* aMsg) |
3375 { |
3809 { |
|
3810 OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_SENDTODEFERREDQ_ENTRY, this ); |
3376 // This queue is only accessed from MD thread |
3811 // This queue is only accessed from MD thread |
3377 __ASSERT_ALWAYS(aMsg->iState==TMessageBase::EAccepted,LOCM_FAULT()); // check that message was previously dequeued |
3812 __ASSERT_ALWAYS(aMsg->iState==TMessageBase::EAccepted,LOCM_FAULT()); // check that message was previously dequeued |
3378 #ifdef BTRACE_PAGING_MEDIA |
3813 #ifdef BTRACE_PAGING_MEDIA |
3379 if(iEmptyingQ&DMediaPagingDevice::EDeferredQ) // already deferring |
3814 if(iEmptyingQ&DMediaPagingDevice::EDeferredQ) // already deferring |
3380 BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInReDeferred,aMsg,aMsg->iValue); |
3815 BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInReDeferred,aMsg,aMsg->iValue); |
3381 else |
3816 else |
3382 BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInDeferred,aMsg,aMsg->iValue); |
3817 BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInDeferred,aMsg,aMsg->iValue); |
3383 #endif |
3818 #endif |
3384 |
3819 |
3385 aMsg->Forward(&iDeferredQ, EFalse); |
3820 aMsg->Forward(&iDeferredQ, EFalse); |
|
3821 OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_SENDTODEFERREDQ_EXIT, this ); |
3386 } |
3822 } |
3387 |
3823 |
3388 |
3824 |
3389 void DMediaPagingDevice::CompleteRequest(TThreadMessage* aMsg, TInt aResult) |
3825 void DMediaPagingDevice::CompleteRequest(TThreadMessage* aMsg, TInt aResult) |
3390 { |
3826 { |
|
3827 OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_COMPLETEREQUEST_ENTRY, this ); |
3391 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::CompleteRequest, request 0x%08x result %d", aMsg, aResult)); |
3828 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::CompleteRequest, request 0x%08x result %d", aMsg, aResult)); |
3392 __ASSERT_DEBUG(aMsg->iState==TMessageBase::EAccepted,LOCM_FAULT()); |
3829 __ASSERT_DEBUG(aMsg->iState==TMessageBase::EAccepted,LOCM_FAULT()); |
3393 |
3830 |
3394 #ifdef BTRACE_PAGING_MEDIA |
3831 #ifdef BTRACE_PAGING_MEDIA |
3395 BTraceContext12(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInPagedIn,aMsg,aResult,aMsg->iValue); |
3832 BTraceContext12(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInPagedIn,aMsg,aResult,aMsg->iValue); |
3396 #endif |
3833 #endif |
3397 |
3834 |
3398 iPrimaryMedia->CompleteRequest(*((TLocDrvRequest*) aMsg), aResult); |
3835 iPrimaryMedia->CompleteRequest(*((TLocDrvRequest*) aMsg), aResult); |
|
3836 OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_COMPLETEREQUEST_EXIT, this ); |
3399 } |
3837 } |
3400 |
3838 |
3401 TInt DMediaPagingDevice::Read(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber) |
3839 TInt DMediaPagingDevice::Read(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber) |
3402 { |
3840 { |
|
3841 OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_READ_ENTRY, this ); |
3403 __ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
3842 __ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
3404 __ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
3843 __ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
3405 __ASSERT_CRITICAL |
3844 __ASSERT_CRITICAL |
3406 |
3845 |
3407 #ifdef __DEMAND_PAGING_BENCHMARKS__ |
3846 #ifdef __DEMAND_PAGING_BENCHMARKS__ |
3466 buf[2]=(TInt)aReq; // address of request object |
3905 buf[2]=(TInt)aReq; // address of request object |
3467 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInBegin,aBuffer,offset,buf,sizeof(buf)); |
3906 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInBegin,aBuffer,offset,buf,sizeof(buf)); |
3468 #endif |
3907 #endif |
3469 |
3908 |
3470 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Read, Req(0x%08x), Buff(0x%x),Offset(%d),Size(%d),DrvNo(%d)",aReq,aBuffer,offset,size,aDrvNumber)); |
3909 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Read, Req(0x%08x), Buff(0x%x),Offset(%d),Size(%d),DrvNo(%d)",aReq,aBuffer,offset,size,aDrvNumber)); |
|
3910 OstTraceDefExt5(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ1, "req=0x%08x; aBuffer=0x%x; offset=%d; size=%d; aDrvNumber=%d", (TUint) aReq, (TInt) aBuffer, (TInt) offset, (TUint) size, (TUint) aDrvNumber); |
3471 |
3911 |
3472 // no DFCQ, media driver executes in the context of calling thread |
3912 // no DFCQ, media driver executes in the context of calling thread |
3473 if (!iPrimaryMedia->iDfcQ) |
3913 if (!iPrimaryMedia->iDfcQ) |
3474 { |
3914 { |
3475 LOCM_FAULT(); // don't allow paging |
3915 LOCM_FAULT(); // don't allow paging |
|
3916 OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_READ_EXIT, this, KErrNone ); |
3476 return KErrNone; // keep compiler happy |
3917 return KErrNone; // keep compiler happy |
3477 } |
3918 } |
3478 |
3919 |
3479 |
3920 |
3480 TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
3921 TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
|
3922 |
3481 |
3923 |
3482 #ifdef __DEMAND_PAGING_BENCHMARKS__ |
3924 #ifdef __DEMAND_PAGING_BENCHMARKS__ |
3483 SPagingBenchmarkInfo* info = NULL; |
3925 SPagingBenchmarkInfo* info = NULL; |
3484 #endif |
3926 #endif |
3485 |
3927 |
3543 m.Length()=Int64(size); |
3985 m.Length()=Int64(size); |
3544 m.RemoteDes()=(TAny*)aBuffer; |
3986 m.RemoteDes()=(TAny*)aBuffer; |
3545 m.RemoteDesOffset()=0; // pre-aligned |
3987 m.RemoteDesOffset()=0; // pre-aligned |
3546 m.DriverFlags()=0; |
3988 m.DriverFlags()=0; |
3547 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes())); |
3989 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes())); |
3548 |
3990 OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ2, "reqId=%d; position=0x%lx; length=0x%x; remote Des=0x%x", (TInt) m.Id(), (TUint) m.Pos(), (TUint) m.Length(), (TUint) m.RemoteDes()); |
|
3991 |
3549 __ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT()); |
3992 __ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT()); |
3550 TInt mediaChanges = iPrimaryMedia->iBody->iMediaChanges; |
3993 TInt mediaChanges = iPrimaryMedia->iBody->iMediaChanges; |
3551 |
3994 |
3552 SendToMainQueueDfcAndBlock(&m); // queues request, sets and opens client thread, queues dfc and blocks thread until request is completed |
3995 SendToMainQueueDfcAndBlock(&m); // queues request, sets and opens client thread, queues dfc and blocks thread until request is completed |
3553 retVal = m.iValue; |
3996 retVal = m.iValue; |
3554 |
3997 |
3555 #ifdef __DEBUG_DEMAND_PAGING__ |
3998 #ifdef __DEBUG_DEMAND_PAGING__ |
3556 if (retVal != KErrNone) |
3999 if (retVal != KErrNone) |
|
4000 { |
3557 Kern::Printf("Pagin Failure %d, retry %d", retVal, i); |
4001 Kern::Printf("Pagin Failure %d, retry %d", retVal, i); |
|
4002 } |
3558 #endif |
4003 #endif |
3559 |
4004 |
3560 // reset retry count if there's ben a media change |
4005 // reset retry count if there's ben a media change |
3561 if (retVal != KErrNone && mediaChanges != iPrimaryMedia->iBody->iMediaChanges) |
4006 if (retVal != KErrNone && mediaChanges != iPrimaryMedia->iBody->iMediaChanges) |
3562 i = 0; |
4007 i = 0; |
3621 buf[1] = (TInt)aReq; // address of request object |
4067 buf[1] = (TInt)aReq; // address of request object |
3622 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageOutBegin,aBuffer,offset,buf,sizeof(buf)); |
4068 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageOutBegin,aBuffer,offset,buf,sizeof(buf)); |
3623 #endif |
4069 #endif |
3624 |
4070 |
3625 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Write, Req(0x%08x), Buff(0x%x),Offset(%d),Size(%d)",aReq,aBuffer,offset,size)); |
4071 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Write, Req(0x%08x), Buff(0x%x),Offset(%d),Size(%d)",aReq,aBuffer,offset,size)); |
|
4072 OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE1, "req=0x%08x; aBuffer=0x%x; offset=%d; size=%d", (TUint) aReq, (TUint) aBuffer, offset, size); |
3626 |
4073 |
3627 // no DFCQ, media driver executes in the context of calling thread |
4074 // no DFCQ, media driver executes in the context of calling thread |
3628 if (!iPrimaryMedia->iDfcQ) |
4075 if (!iPrimaryMedia->iDfcQ) |
3629 { |
4076 { |
3630 LOCM_FAULT(); // don't allow paging |
4077 LOCM_FAULT(); // don't allow paging |
|
4078 OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_WRITE_EXIT, this, KErrNone ); |
3631 return KErrNone; // keep compiler happy |
4079 return KErrNone; // keep compiler happy |
3632 } |
4080 } |
3633 |
4081 |
3634 |
4082 |
3635 TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
4083 TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
3636 |
4084 |
3637 #ifdef __DEMAND_PAGING_BENCHMARKS__ |
4085 #ifdef __DEMAND_PAGING_BENCHMARKS__ |
3638 __e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageOutCount, (TUint) 1); |
4086 __e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageOutCount, (TUint) 1); |
3639 if (aBackground) |
4087 if (aBackground) |
3640 __e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageOutBackgroundCount, (TUint) 1); |
4088 __e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageOutBackgroundCount, (TUint) 1); |
3641 #endif |
4089 #endif |
3655 m.Length()=Int64(size); |
4103 m.Length()=Int64(size); |
3656 m.RemoteDes()=(TAny*)aBuffer; |
4104 m.RemoteDes()=(TAny*)aBuffer; |
3657 m.RemoteDesOffset()=0; // pre-aligned |
4105 m.RemoteDesOffset()=0; // pre-aligned |
3658 m.DriverFlags()=0; |
4106 m.DriverFlags()=0; |
3659 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes())); |
4107 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes())); |
3660 |
4108 OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE2, "reqId=%d; position=0x%lx; length=0x%lx; remote Des=0x%x", (TInt) m.Id(), (TUint) m.Pos(), (TUint) m.Length(), (TUint) m.RemoteDes()); |
|
4109 |
3661 __ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT()); |
4110 __ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT()); |
3662 TInt mediaChanges = iPrimaryMedia->iBody->iMediaChanges; |
4111 TInt mediaChanges = iPrimaryMedia->iBody->iMediaChanges; |
3663 |
4112 |
3664 SendToMainQueueDfcAndBlock(&m); // queues request, sets and opens client thread, queues dfc and blocks thread until request is completed |
4113 SendToMainQueueDfcAndBlock(&m); // queues request, sets and opens client thread, queues dfc and blocks thread until request is completed |
|
4114 |
3665 retVal = m.iValue; |
4115 retVal = m.iValue; |
3666 |
4116 |
3667 #ifdef __DEBUG_DEMAND_PAGING__ |
4117 #ifdef __DEBUG_DEMAND_PAGING__ |
3668 if (retVal != KErrNone) |
4118 if (retVal != KErrNone) |
3669 Kern::Printf("Pagout Failure %d, retry %d", retVal, i); |
4119 Kern::Printf("Pagout Failure %d, retry %d", retVal, i); |
3693 if (elapsed > info.iMaxTime) |
4143 if (elapsed > info.iMaxTime) |
3694 info.iMaxTime = elapsed; |
4144 info.iMaxTime = elapsed; |
3695 if (elapsed < info.iMinTime) |
4145 if (elapsed < info.iMinTime) |
3696 info.iMinTime = elapsed; |
4146 info.iMinTime = elapsed; |
3697 #endif // __DEMAND_PAGING_BENCHMARKS__ |
4147 #endif // __DEMAND_PAGING_BENCHMARKS__ |
3698 |
4148 |
|
4149 OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_WRITE_EXIT2, this, retVal ); |
3699 return retVal; |
4150 return retVal; |
3700 } |
4151 } |
3701 |
4152 |
3702 |
4153 |
3703 TInt DMediaPagingDevice::DeleteNotify(TThreadMessage* aReq,TUint aOffset,TUint aSize) |
4154 TInt DMediaPagingDevice::DeleteNotify(TThreadMessage* aReq,TUint aOffset,TUint aSize) |
3704 { |
4155 { |
|
4156 OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_DELETENOTIFY_ENTRY, this ); |
3705 if (iDeleteNotifyNotSupported) |
4157 if (iDeleteNotifyNotSupported) |
|
4158 { |
|
4159 OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT1, this, KErrNotSupported ); |
3706 return KErrNotSupported; |
4160 return KErrNotSupported; |
|
4161 } |
3707 |
4162 |
3708 __ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
4163 __ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
3709 __ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
4164 __ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
3710 __ASSERT_ALWAYS(DataPagingDfcQ(iPrimaryMedia),LOCM_FAULT()); |
4165 __ASSERT_ALWAYS(DataPagingDfcQ(iPrimaryMedia),LOCM_FAULT()); |
3711 __ASSERT_CRITICAL |
4166 __ASSERT_CRITICAL |
3719 buf[1] = (TInt)aReq; // address of request object |
4174 buf[1] = (TInt)aReq; // address of request object |
3720 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedDeleteNotifyBegin,NULL,offset,buf,sizeof(buf)); |
4175 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedDeleteNotifyBegin,NULL,offset,buf,sizeof(buf)); |
3721 #endif |
4176 #endif |
3722 |
4177 |
3723 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Write, Req(0x%08x), Offset(%d),Size(%d)",aReq,offset,size)); |
4178 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Write, Req(0x%08x), Offset(%d),Size(%d)",aReq,offset,size)); |
|
4179 OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_DELETENOTIFY1 , "req=0x%08x; offset=%d; size=%d", (TUint) aReq, offset, size); |
3724 |
4180 |
3725 // no DFCQ, media driver executes in the context of calling thread |
4181 // no DFCQ, media driver executes in the context of calling thread |
3726 if (!iPrimaryMedia->iDfcQ) |
4182 if (!iPrimaryMedia->iDfcQ) |
3727 { |
4183 { |
3728 LOCM_FAULT(); // don't allow paging |
4184 LOCM_FAULT(); // don't allow paging |
|
4185 OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT2, this, KErrNone ); |
3729 return KErrNone; // keep compiler happy |
4186 return KErrNone; // keep compiler happy |
3730 } |
4187 } |
3731 |
4188 |
3732 TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
4189 TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
3733 |
4190 |
3758 TInt retVal = m.iValue; |
4215 TInt retVal = m.iValue; |
3759 |
4216 |
3760 if (retVal == KErrNotSupported) |
4217 if (retVal == KErrNotSupported) |
3761 iDeleteNotifyNotSupported = ETrue; |
4218 iDeleteNotifyNotSupported = ETrue; |
3762 |
4219 |
|
4220 OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT3, this, retVal ); |
3763 return retVal; |
4221 return retVal; |
3764 } |
4222 } |
3765 |
4223 |
3766 |
4224 |
3767 |
4225 |
3768 EXPORT_C TInt TLocDrvRequest::WriteToPageHandler(const TAny* aSrc, TInt aSize, TInt anOffset) |
4226 EXPORT_C TInt TLocDrvRequest::WriteToPageHandler(const TAny* aSrc, TInt aSize, TInt anOffset) |
3769 { |
4227 { |
|
4228 OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITETOPAGEHANDLER_ENTRY, this ); |
3770 #ifdef BTRACE_PAGING_MEDIA |
4229 #ifdef BTRACE_PAGING_MEDIA |
3771 TMediaDevice medDev=Drive()->iMedia->iDevice; |
4230 TMediaDevice medDev=Drive()->iMedia->iDevice; |
3772 TInt buf[3]; |
4231 TInt buf[3]; |
3773 buf[0]=(TUint32)RemoteDes(); |
4232 buf[0]=(TUint32)RemoteDes(); |
3774 buf[1]=anOffset; |
4233 buf[1]=anOffset; |
3775 buf[2]=aSize; |
4234 buf[2]=aSize; |
3776 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaMedDrvWriteBack,medDev,this,buf,sizeof(buf)); |
4235 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaMedDrvWriteBack,medDev,this,buf,sizeof(buf)); |
3777 #endif |
4236 #endif |
3778 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("TLocDrvRequest::WriteToPageHandler, memcpy((aTrg)%08x, (aSrc)%08x, (aLength)%08x)",(TUint32)RemoteDes()+anOffset,aSrc,aSize)); |
4237 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("TLocDrvRequest::WriteToPageHandler, memcpy((aTrg)%08x, (aSrc)%08x, (aLength)%08x)",(TUint32)RemoteDes()+anOffset,aSrc,aSize)); |
3779 (void)memcpy((TAny*)((TUint32)RemoteDes()+anOffset), aSrc, aSize); // maybe in later versions this could be something else |
4238 (void)memcpy((TAny*)((TUint32)RemoteDes()+anOffset), aSrc, aSize); // maybe in later versions this could be something else |
|
4239 OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITETOPAGEHANDLER_EXIT, this, KErrNone ); |
3780 return KErrNone; |
4240 return KErrNone; |
3781 } |
4241 } |
3782 |
4242 |
3783 EXPORT_C TInt TLocDrvRequest::ReadFromPageHandler(TAny* aDst, TInt aSize, TInt anOffset) |
4243 EXPORT_C TInt TLocDrvRequest::ReadFromPageHandler(TAny* aDst, TInt aSize, TInt anOffset) |
3784 { |
4244 { |
|
4245 OstTraceFunctionEntry1( TLOCDRVREQUEST_READFROMPAGEHANDLER_ENTRY, this ); |
3785 #ifdef BTRACE_PAGING_MEDIA |
4246 #ifdef BTRACE_PAGING_MEDIA |
3786 TMediaDevice medDev=Drive()->iMedia->iDevice; |
4247 TMediaDevice medDev=Drive()->iMedia->iDevice; |
3787 TInt buf[3]; |
4248 TInt buf[3]; |
3788 buf[0]=(TUint32)RemoteDes(); |
4249 buf[0]=(TUint32)RemoteDes(); |
3789 buf[1]=anOffset; |
4250 buf[1]=anOffset; |
3790 buf[2]=aSize; |
4251 buf[2]=aSize; |
3791 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaMedDrvRead,medDev,this,buf,sizeof(buf)); |
4252 BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaMedDrvRead,medDev,this,buf,sizeof(buf)); |
3792 #endif |
4253 #endif |
3793 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("TLocDrvRequest::ReadFromPageHandler, memcpy((aDst)%08x, (aTrg)%08x, (aLength)%08x)",aDst,(TUint32)RemoteDes()+anOffset,aSize)); |
4254 __KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("TLocDrvRequest::ReadFromPageHandler, memcpy((aDst)%08x, (aTrg)%08x, (aLength)%08x)",aDst,(TUint32)RemoteDes()+anOffset,aSize)); |
3794 (void)memcpy(aDst, (TAny*)((TUint32)RemoteDes()+anOffset), aSize); // maybe in later versions this could be something else |
4255 (void)memcpy(aDst, (TAny*)((TUint32)RemoteDes()+anOffset), aSize); // maybe in later versions this could be something else |
|
4256 OstTraceFunctionExitExt( TLOCDRVREQUEST_READFROMPAGEHANDLER_EXIT, this, KErrNone ); |
3795 return KErrNone; |
4257 return KErrNone; |
3796 } |
4258 } |
3797 |
4259 |
3798 _LIT(KLitFragmentationMutexName, "FRAGMENTATION_MUTEX"); |
4260 _LIT(KLitFragmentationMutexName, "FRAGMENTATION_MUTEX"); |
3799 |
4261 |
3800 TInt DFragmentationPagingLock::Construct(TUint aNumPages) |
4262 TInt DFragmentationPagingLock::Construct(TUint aNumPages) |
3801 { |
4263 { |
|
4264 OstTraceFunctionEntryExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_ENTRY, this ); |
3802 TInt r=KErrNone; |
4265 TInt r=KErrNone; |
3803 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation Lock: creating Mutex")); |
4266 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation Lock: creating Mutex")); |
3804 r=Kern::MutexCreate(this->iFragmentationMutex, KLitFragmentationMutexName, KMutexOrdNone); |
4267 r=Kern::MutexCreate(this->iFragmentationMutex, KLitFragmentationMutexName, KMutexOrdNone); |
3805 if (r!=KErrNone) |
4268 if (r!=KErrNone) |
|
4269 { |
|
4270 OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT1, this, r ); |
3806 return r; |
4271 return r; |
|
4272 } |
3807 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation Lock: Mutex created OK")); |
4273 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation Lock: Mutex created OK")); |
|
4274 OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DFRAGMENTATIONPAGINGLOCK_CONSTRUCT1 , "Fragmentation Lock: Mutex created OK"); |
3808 |
4275 |
3809 iFragmentGranularity = 0; |
4276 iFragmentGranularity = 0; |
3810 if (aNumPages == 0) |
4277 if (aNumPages == 0) |
|
4278 { |
|
4279 OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT2, this, KErrNone ); |
3811 return KErrNone; |
4280 return KErrNone; |
3812 |
4281 } |
|
4282 |
3813 // in CS |
4283 // in CS |
3814 TInt pageSize=Kern::RoundToPageSize(1); |
4284 TInt pageSize=Kern::RoundToPageSize(1); |
3815 LockFragmentation(); |
4285 LockFragmentation(); |
3816 r=Alloc(pageSize*aNumPages); // alloc pages |
4286 r=Alloc(pageSize*aNumPages); // alloc pages |
3817 UnlockFragmentation(); |
4287 UnlockFragmentation(); |
3818 |
4288 |
3819 if(r==KErrNone) |
4289 if(r==KErrNone) |
3820 { |
4290 { |
3821 iFragmentGranularity = pageSize * aNumPages; |
4291 iFragmentGranularity = pageSize * aNumPages; |
3822 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation granularity set to 0x%x", iFragmentGranularity)); |
4292 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation granularity set to 0x%x", iFragmentGranularity)); |
3823 } |
4293 OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DFRAGMENTATIONPAGINGLOCK_CONSTRUCT2, "Fragmentation granularity=0x%x", iFragmentGranularity); |
3824 |
4294 } |
|
4295 |
|
4296 OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT3, this, r ); |
3825 return r; |
4297 return r; |
3826 } |
4298 } |
3827 |
4299 |
3828 void DFragmentationPagingLock::Cleanup() |
4300 void DFragmentationPagingLock::Cleanup() |
3829 { |
4301 { |
|
4302 OstTraceFunctionEntry1( DFRAGMENTATIONPAGINGLOCK_CLEANUP_ENTRY, this ); |
3830 // in CS |
4303 // in CS |
3831 if (iFragmentationMutex) |
4304 if (iFragmentationMutex) |
3832 { |
4305 { |
3833 LockFragmentation(); |
4306 LockFragmentation(); |
3834 Free(); // at last! |
4307 Free(); // at last! |
3835 UnlockFragmentation(); |
4308 UnlockFragmentation(); |
3836 Kern::SafeClose((DObject*&)iFragmentationMutex,NULL); |
4309 Kern::SafeClose((DObject*&)iFragmentationMutex,NULL); |
3837 } |
4310 } |
|
4311 OstTraceFunctionExit1( DFRAGMENTATIONPAGINGLOCK_CLEANUP_EXIT, this ); |
3838 } |
4312 } |
3839 |
4313 |
3840 #else |
4314 #else |
3841 #if !defined(__WINS__) |
4315 #if !defined(__WINS__) |
3842 EXPORT_C TInt TLocDrvRequest::WriteToPageHandler(const TAny* , TInt , TInt) |
4316 EXPORT_C TInt TLocDrvRequest::WriteToPageHandler(const TAny* , TInt , TInt) |
4135 KErrNoMemory, if there is insufficient memory; |
4635 KErrNoMemory, if there is insufficient memory; |
4136 or one of the other system-wide error codes. |
4636 or one of the other system-wide error codes. |
4137 */ |
4637 */ |
4138 EXPORT_C TInt LocDrv::RegisterMediaDevice(TMediaDevice aDevice, TInt aDriveCount, const TInt* aDriveList, DPrimaryMediaBase* aPrimaryMedia, TInt aNumMedia, const TDesC& aName) |
4638 EXPORT_C TInt LocDrv::RegisterMediaDevice(TMediaDevice aDevice, TInt aDriveCount, const TInt* aDriveList, DPrimaryMediaBase* aPrimaryMedia, TInt aNumMedia, const TDesC& aName) |
4139 { |
4639 { |
|
4640 OstTraceFunctionEntry0( LOCDRV_REGISTERMEDIADEVICE_ENTRY ); |
4140 // Create TLocDrv / DMedia objects to handle a media device |
4641 // Create TLocDrv / DMedia objects to handle a media device |
4141 __KTRACE_OPT(KBOOT,Kern::Printf("RegisterMediaDevice %lS dev=%1d #drives=%d 1st=%d PM=%08x #media=%d",&aName,aDevice,aDriveCount,*aDriveList,aPrimaryMedia,aNumMedia)); |
4642 __KTRACE_OPT(KBOOT,Kern::Printf("RegisterMediaDevice %lS dev=%1d #drives=%d 1st=%d PM=%08x #media=%d",&aName,aDevice,aDriveCount,*aDriveList,aPrimaryMedia,aNumMedia)); |
|
4643 OstTraceExt5( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE1, "aDevice=%d; aDriveCount=%d; aDriveList=%d; aPrimaryMedia=0x%08x; aNumMedia=%d", (TInt) aDevice, (TInt) aDriveCount, (TInt) *aDriveList, (TUint) aPrimaryMedia, (TInt) aNumMedia ); |
|
4644 |
4142 const TInt* p=aDriveList; |
4645 const TInt* p=aDriveList; |
4143 TInt i; |
4646 TInt i; |
4144 TInt r=0; |
4647 TInt r=0; |
4145 if (UsedMedia+aNumMedia>KMaxLocalDrives) |
4648 if (UsedMedia+aNumMedia>KMaxLocalDrives) |
|
4649 { |
|
4650 OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT1, "< KErrInUse"); |
4146 return KErrInUse; |
4651 return KErrInUse; |
|
4652 } |
4147 for (i=0; i<aDriveCount; ++i) |
4653 for (i=0; i<aDriveCount; ++i) |
4148 { |
4654 { |
4149 TInt drv = *p++; |
4655 TInt drv = *p++; |
4150 // -1 means not used; this is to enable Dual-slot MMC support |
4656 // -1 means not used; this is to enable Dual-slot MMC support |
4151 if (drv == -1) |
4657 if (drv == -1) |
4152 continue; |
4658 continue; |
4153 __KTRACE_OPT(KBOOT,Kern::Printf("Registering drive %d", drv)); |
4659 __KTRACE_OPT(KBOOT,Kern::Printf("Registering drive %d", drv)); |
|
4660 OstTrace1( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE2, "Registering drive=%d", drv ); |
4154 if (TheDrives[drv]) |
4661 if (TheDrives[drv]) |
4155 { |
4662 { |
4156 __KTRACE_OPT(KBOOT,Kern::Printf("Drive %d already in use", drv)); |
4663 __KTRACE_OPT(KBOOT,Kern::Printf("Drive %d already in use", drv)); |
|
4664 OstTrace1( TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT2, "< Drive %d already in use; KErrInUse", drv); |
4157 return KErrInUse; |
4665 return KErrInUse; |
4158 } |
4666 } |
4159 } |
4667 } |
4160 HBuf* pN=HBuf::New(aName); |
4668 HBuf* pN=HBuf::New(aName); |
4161 if (!pN) |
4669 if (!pN) |
|
4670 { |
|
4671 OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT3, "< KErrNoMemory"); |
4162 return KErrNoMemory; |
4672 return KErrNoMemory; |
|
4673 } |
4163 TInt lastMedia=UsedMedia+aNumMedia-1; |
4674 TInt lastMedia=UsedMedia+aNumMedia-1; |
4164 for (i=UsedMedia; i<=lastMedia; ++i) |
4675 for (i=UsedMedia; i<=lastMedia; ++i) |
4165 { |
4676 { |
4166 if (i==UsedMedia) |
4677 if (i==UsedMedia) |
4167 TheMedia[i]=aPrimaryMedia; |
4678 TheMedia[i]=aPrimaryMedia; |
4168 else |
4679 else |
4169 TheMedia[i]=new DMedia; |
4680 TheMedia[i]=new DMedia; |
4170 if (!TheMedia[i]) |
4681 if (!TheMedia[i]) |
|
4682 { |
|
4683 OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT4, "< KErrNoMemory"); |
4171 return KErrNoMemory; |
4684 return KErrNoMemory; |
|
4685 } |
4172 r=TheMedia[i]->Create(aDevice,i,lastMedia); |
4686 r=TheMedia[i]->Create(aDevice,i,lastMedia); |
4173 __KTRACE_OPT(KBOOT,Kern::Printf("Media %d Create() returns %d",i,r)); |
4687 __KTRACE_OPT(KBOOT,Kern::Printf("Media %d Create() returns %d",i,r)); |
|
4688 OstTraceExt2( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE3, "Media=%d Create(); retval=%d", i, r ); |
4174 if (r!=KErrNone) |
4689 if (r!=KErrNone) |
|
4690 { |
|
4691 OstTrace1(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT5, "< retval=%d", r); |
4175 return r; |
4692 return r; |
|
4693 } |
4176 } |
4694 } |
4177 |
4695 |
4178 __KTRACE_OPT(KBOOT,Kern::Printf("FirstMedia %d LastMedia %d",UsedMedia,lastMedia)); |
4696 __KTRACE_OPT(KBOOT,Kern::Printf("FirstMedia %d LastMedia %d",UsedMedia,lastMedia)); |
|
4697 OstTraceExt2( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE4, "FirstMedia=%d; LastMedia=%d", UsedMedia, lastMedia ); |
4179 UsedMedia+=aNumMedia; |
4698 UsedMedia+=aNumMedia; |
4180 p=aDriveList; |
4699 p=aDriveList; |
4181 for (i=0; i<aDriveCount; ++i) |
4700 for (i=0; i<aDriveCount; ++i) |
4182 { |
4701 { |
4183 TInt drv=*p++; |
4702 TInt drv=*p++; |
4184 if (drv == -1) |
4703 if (drv == -1) |
4185 continue; |
4704 continue; |
4186 TLocDrv* pL=new TLocDrv(drv); |
4705 TLocDrv* pL=new TLocDrv(drv); |
4187 if (!pL) |
4706 if (!pL) |
|
4707 { |
|
4708 OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT6, "< KErrNoMemory"); |
4188 return KErrNoMemory; |
4709 return KErrNoMemory; |
|
4710 } |
4189 TheDrives[drv]=pL; |
4711 TheDrives[drv]=pL; |
4190 DriveNames[drv]=pN; |
4712 DriveNames[drv]=pN; |
4191 pL->iPrimaryMedia=aPrimaryMedia; |
4713 pL->iPrimaryMedia=aPrimaryMedia; |
4192 __KTRACE_OPT(KBOOT,Kern::Printf("Drive %d: TLocDrv @ %08x",drv,pL)); |
4714 __KTRACE_OPT(KBOOT,Kern::Printf("Drive %d: TLocDrv @ %08x",drv,pL)); |
4193 } |
4715 OstTraceExt2( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE5, "Drive=%d; TLocDrv 0x%08x;", (TInt) drv, (TUint) pL ); |
|
4716 } |
|
4717 |
|
4718 OstTraceFunctionExit0( LOCDRV_REGISTERMEDIADEVICE_EXIT7 ); |
4194 return KErrNone; |
4719 return KErrNone; |
4195 } |
4720 } |
4196 |
4721 |
4197 |
4722 |
4198 |
4723 |
4270 KErrNoMemory, if there is insufficient memory; |
4796 KErrNoMemory, if there is insufficient memory; |
4271 or one of the other system-wide error codes. |
4797 or one of the other system-wide error codes. |
4272 */ |
4798 */ |
4273 EXPORT_C TInt LocDrv::RegisterPagingDevice(DPrimaryMediaBase* aPrimaryMedia, const TInt* aPagingDriveList, TInt aDriveCount, TUint aPagingType, TInt aReadShift, TUint aNumPages) |
4799 EXPORT_C TInt LocDrv::RegisterPagingDevice(DPrimaryMediaBase* aPrimaryMedia, const TInt* aPagingDriveList, TInt aDriveCount, TUint aPagingType, TInt aReadShift, TUint aNumPages) |
4274 { |
4800 { |
|
4801 OstTraceFunctionEntry0( LOCDRV_REGISTERPAGINGDEVICE_ENTRY ); |
|
4802 |
4275 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf(">RegisterPagingDevice: paging type=%d PM=0x%x read shift=%d",aPagingType,aPrimaryMedia,aReadShift)); |
4803 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf(">RegisterPagingDevice: paging type=%d PM=0x%x read shift=%d",aPagingType,aPrimaryMedia,aReadShift)); |
|
4804 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE1, "aPagingType=%d; aPrimaryMedia=0x%x; aReadShift=%d", (TInt) aPagingType, (TUint) aPrimaryMedia, (TInt) aReadShift); |
|
4805 |
4276 TInt i; |
4806 TInt i; |
4277 |
4807 |
4278 if(!aPagingType || (aPagingType&~(DPagingDevice::ERom | DPagingDevice::ECode | DPagingDevice::EData))) |
4808 if(!aPagingType || (aPagingType&~(DPagingDevice::ERom | DPagingDevice::ECode | DPagingDevice::EData))) |
4279 { |
4809 { |
4280 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Unsupported paging type, exiting")); |
4810 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Unsupported paging type, exiting")); |
|
4811 OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT1, "< Unsupported paging type; KErrArgument"); |
4281 return KErrArgument; |
4812 return KErrArgument; |
4282 } |
4813 } |
4283 |
4814 |
4284 |
4815 |
4285 |
4816 |
4302 |
4833 |
4303 if (aPagingType == 0) |
4834 if (aPagingType == 0) |
4304 { |
4835 { |
4305 // there's already a ROM or Data paging device & this doesn't support code paging so quietly exit without further addo |
4836 // there's already a ROM or Data paging device & this doesn't support code paging so quietly exit without further addo |
4306 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Nothing left to register on locdrv no %d, exiting",i)); |
4837 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Nothing left to register on locdrv no %d, exiting",i)); |
|
4838 OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT2, "< Nothing left to register on locdrv no %d; KErrNone",i); |
4307 return KErrNone; |
4839 return KErrNone; |
4308 } |
4840 } |
4309 |
4841 |
4310 const TInt* p=aPagingDriveList; |
4842 const TInt* p=aPagingDriveList; |
4311 if(aPagingType&DPagingDevice::ECode) // supports code paging, do argument check |
4843 if(aPagingType&DPagingDevice::ECode) // supports code paging, do argument check |
4312 { |
4844 { |
4313 if(!aDriveCount || (aDriveCount>=KMaxLocalDrives)) |
4845 if(!aDriveCount || (aDriveCount>=KMaxLocalDrives)) |
4314 { |
4846 { |
4315 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive count: %d", aDriveCount)); |
4847 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive count: %d", aDriveCount)); |
|
4848 OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT3, "< Invalid code paging drive count=%d; KErrArgument", aDriveCount); |
4316 return KErrArgument; |
4849 return KErrArgument; |
4317 } |
4850 } |
4318 |
4851 |
4319 TInt drvCount=0; |
4852 TInt drvCount=0; |
4320 for(i=0; i<KMaxLocalDrives; i++) |
4853 for(i=0; i<KMaxLocalDrives; i++) |
4321 if(TheDrives[i] && TheDrives[i]->iPrimaryMedia==aPrimaryMedia) |
4854 if(TheDrives[i] && TheDrives[i]->iPrimaryMedia==aPrimaryMedia) |
4322 drvCount++; |
4855 drvCount++; |
4323 if(aDriveCount>drvCount) // can't exceed number of drives registered by this device |
4856 if(aDriveCount>drvCount) // can't exceed number of drives registered by this device |
4324 { |
4857 { |
4325 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive count: %d total %d", aDriveCount, drvCount)); |
4858 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive count=%d; total=%d", aDriveCount, drvCount)); |
|
4859 OstTraceExt2(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT4, "< Invalid code paging drive count=%d; total=%d; KErrArgument", aDriveCount, drvCount); |
4326 return KErrArgument; |
4860 return KErrArgument; |
4327 } |
4861 } |
4328 |
4862 |
4329 for (i=0; i<aDriveCount; ++i) |
4863 for (i=0; i<aDriveCount; ++i) |
4330 { |
4864 { |
4331 __KTRACE_OPT(KBOOT,Kern::Printf("RegisterPagingDevice: registering drive=%d ",*p)); |
4865 __KTRACE_OPT(KBOOT,Kern::Printf("RegisterPagingDevice: registering drive=%d ",*p)); |
|
4866 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE2, "Registering Drive=%d", *p ); |
4332 TInt drv=*p++; |
4867 TInt drv=*p++; |
4333 if(drv>=KMaxLocalDrives) |
4868 if(drv>=KMaxLocalDrives) |
4334 { |
4869 { |
4335 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive number: %d", drv)); |
4870 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive number: %d", drv)); |
|
4871 OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT5, "< Invalid code paging drive number=%d; KErrArgument", drv); |
4336 return KErrArgument; |
4872 return KErrArgument; |
4337 } |
4873 } |
4338 TLocDrv* pD=TheDrives[drv]; |
4874 TLocDrv* pD=TheDrives[drv]; |
4339 if (!pD) |
4875 if (!pD) |
|
4876 { |
|
4877 OstTrace0(TRACE_FLOW, LOCRV_REGISTERPAGINGDEVICE_EXIT6, "< KErrNotFound"); |
4340 return KErrNotFound; |
4878 return KErrNotFound; |
|
4879 } |
4341 if (pD->iPrimaryMedia!=aPrimaryMedia) |
4880 if (pD->iPrimaryMedia!=aPrimaryMedia) |
|
4881 { |
|
4882 OstTrace0(TRACE_FLOW, LOCRV_REGISTERPAGINGDEVICE_EXIT7, "< KErrNotSupported"); |
4342 return KErrNotSupported; |
4883 return KErrNotSupported; |
|
4884 } |
4343 } |
4885 } |
4344 } |
4886 } |
4345 |
4887 |
4346 |
4888 |
4347 TInt firstLocalDriveNumber = KErrNotFound; |
4889 TInt firstLocalDriveNumber = KErrNotFound; |
4358 firstLocalDriveNumber = i; |
4900 firstLocalDriveNumber = i; |
4359 break; |
4901 break; |
4360 } |
4902 } |
4361 } |
4903 } |
4362 __ASSERT_ALWAYS(i < KMaxLocalDrives, LOCM_FAULT()); |
4904 __ASSERT_ALWAYS(i < KMaxLocalDrives, LOCM_FAULT()); |
4363 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("DMediaPagingDevice(), firstLocalDriveNumber %d", firstLocalDriveNumber)); |
4905 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("DMediaPagingDevice(), firstLocalDriveNumber %d", firstLocalDriveNumber)); |
4364 |
4906 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE3, "firstLocalDriveNumber=%d", firstLocalDriveNumber ); |
4365 |
4907 |
4366 // Send an ECaps message to wake up the media driver & ensure all partitions are |
4908 // Send an ECaps message to wake up the media driver & ensure all partitions are |
4367 // reported, then search for paged-data or paged-ROM partitions |
4909 // reported, then search for paged-data or paged-ROM partitions |
4368 if ((aPagingType & DPagingDevice::EData) || |
4910 if ((aPagingType & DPagingDevice::EData) || |
4369 (aPagingType & DPagingDevice::ERom && aPrimaryMedia->iDfcQ && aPrimaryMedia->iMsgQ.iReady)) |
4911 (aPagingType & DPagingDevice::ERom && aPrimaryMedia->iDfcQ && aPrimaryMedia->iMsgQ.iReady)) |
4370 { |
4912 { |
4371 // the message queue must have been started already (by the media driver calling iMsgQ.Receive()) |
4913 // the message queue must have been started already (by the media driver calling iMsgQ.Receive()) |
4372 // otherwise we can't send the DLocalDrive::EQueryDevice request |
4914 // otherwise we can't send the DLocalDrive::EQueryDevice request |
4373 if (aPrimaryMedia->iDfcQ && !aPrimaryMedia->iMsgQ.iReady) |
4915 if (aPrimaryMedia->iDfcQ && !aPrimaryMedia->iMsgQ.iReady) |
4374 { |
4916 { |
4375 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: Message queue not started")); |
4917 __KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: Message queue not started")); |
|
4918 OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT8, "< RegisterPagingDevice: Message queue not started; KErrNotReady"); |
4376 return KErrNotReady; |
4919 return KErrNotReady; |
4377 } |
4920 } |
4378 |
4921 |
4379 |
4922 |
4380 TLocDrvRequest m; |
4923 TLocDrvRequest m; |
4413 __KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("RegisterPagingDevice: local drive %d, partition type %x size %x", i, drive->iPartitionType, I64LOW(drive->iPartitionLen))); |
4960 __KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("RegisterPagingDevice: local drive %d, partition type %x size %x", i, drive->iPartitionType, I64LOW(drive->iPartitionLen))); |
4414 // ROM partition ? |
4961 // ROM partition ? |
4415 if ((romPagingDriveNumber == KErrNotFound) && (drive->iPartitionType == KPartitionTypeROM)) |
4962 if ((romPagingDriveNumber == KErrNotFound) && (drive->iPartitionType == KPartitionTypeROM)) |
4416 { |
4963 { |
4417 __KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Found ROM partition on local drive %d, size %x", i, I64LOW(drive->iPartitionLen))); |
4964 __KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Found ROM partition on local drive %d, size %x", i, I64LOW(drive->iPartitionLen))); |
|
4965 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE5, "Found ROM partition on local drive=%d; size=0x%x", (TInt) i, (TUint) I64LOW(drive->iPartitionLen)); |
4418 romPagingDriveNumber = i; |
4966 romPagingDriveNumber = i; |
4419 } |
4967 } |
4420 // swap partition ? |
4968 // swap partition ? |
4421 else if ((dataPagingDriveNumber == KErrNotFound) && (drive->iPartitionType == KPartitionTypePagedData)) |
4969 else if ((dataPagingDriveNumber == KErrNotFound) && (drive->iPartitionType == KPartitionTypePagedData)) |
4422 { |
4970 { |
4423 __KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Found swap partition on local drive %d, size %x", i, I64LOW(drive->iPartitionLen))); |
4971 __KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Found swap partition on local drive %d, size %x", i, I64LOW(drive->iPartitionLen))); |
|
4972 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE6, "Found SWAP partition on local drive=%d; size=0x%x", (TInt) i, (TUint) I64LOW(drive->iPartitionLen) ); |
4424 dataPagingDriveNumber = i; |
4973 dataPagingDriveNumber = i; |
4425 swapSize = drive->iPartitionLen >> aReadShift; |
4974 swapSize = drive->iPartitionLen >> aReadShift; |
4426 } |
4975 } |
4427 } |
4976 } |
4428 } |
4977 } |
4429 |
4978 |
4430 if (swapSize == 0) |
4979 if (swapSize == 0) |
4431 { |
4980 { |
4432 __KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Disabling data paging")); |
4981 __KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Disabling data paging")); |
|
4982 OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE7, "Disabling data paging"); |
4433 aPagingType &= ~DPagingDevice::EData; |
4983 aPagingType &= ~DPagingDevice::EData; |
4434 } |
4984 } |
4435 |
4985 |
4436 } |
4986 } |
4437 |
4987 |
4596 EXPORT_C TInt LocDrv::RegisterDmaDevice(DPrimaryMediaBase* aPrimaryMedia, |
5153 EXPORT_C TInt LocDrv::RegisterDmaDevice(DPrimaryMediaBase* aPrimaryMedia, |
4597 TInt aMediaBlockSize, // Minimum transfer size (bytes) for the media |
5154 TInt aMediaBlockSize, // Minimum transfer size (bytes) for the media |
4598 TInt aDmaMaxAddressable, // Max Addressing Range for DMA controller, 0 if None. |
5155 TInt aDmaMaxAddressable, // Max Addressing Range for DMA controller, 0 if None. |
4599 TInt aDmaAlignment) // DMA Alignment e.g. word alignment required = 2 |
5156 TInt aDmaAlignment) // DMA Alignment e.g. word alignment required = 2 |
4600 { |
5157 { |
|
5158 OstTraceFunctionEntry0( LOCDRV_REGISTERDMADEVICE_ENTRY ); |
|
5159 |
4601 __KTRACE_OPT(KBOOT ,Kern::Printf("RegisterPhysicalAddrDevice: PM=0x%x BS=%d MaxAddr=%d DMA=%d", |
5160 __KTRACE_OPT(KBOOT ,Kern::Printf("RegisterPhysicalAddrDevice: PM=0x%x BS=%d MaxAddr=%d DMA=%d", |
4602 aPrimaryMedia, aMediaBlockSize, aDmaMaxAddressable, aDmaAlignment)); |
5161 aPrimaryMedia, aMediaBlockSize, aDmaMaxAddressable, aDmaAlignment)); |
4603 |
5162 OstTraceExt4( TRACE_INTERNALS, LOCDRV_REGISTERDMADEVICE, "aPrimaryMedia=0x%x; aMediaBlockSize=%d; aDmaMaxAddressable=%d; aDmaAlignment=%d", (TUint) aPrimaryMedia, (TInt) aMediaBlockSize, (TInt) aDmaMaxAddressable, (TInt) aDmaAlignment ); |
|
5163 |
4604 for (TInt i=0; i<KMaxLocalDrives; ++i) |
5164 for (TInt i=0; i<KMaxLocalDrives; ++i) |
4605 { |
5165 { |
4606 TLocDrv* pL=TheDrives[i]; |
5166 TLocDrv* pL=TheDrives[i]; |
4607 if (pL && pL->iPrimaryMedia == aPrimaryMedia && pL->iDmaHelper == NULL) |
5167 if (pL && pL->iPrimaryMedia == aPrimaryMedia && pL->iDmaHelper == NULL) |
4608 { |
5168 { |
4643 { |
5205 { |
4644 if (!(sock_mask & (1<<sockNum))) |
5206 if (!(sock_mask & (1<<sockNum))) |
4645 { |
5207 { |
4646 info.iSocketName[sockNum]=*DriveNames[i]; |
5208 info.iSocketName[sockNum]=*DriveNames[i]; |
4647 __KTRACE_OPT(KLOCDRV,Kern::Printf("Socket %d device %d name %lS", sockNum, pM->iDevice, DriveNames[i])); |
5209 __KTRACE_OPT(KLOCDRV,Kern::Printf("Socket %d device %d name %lS", sockNum, pM->iDevice, DriveNames[i])); |
|
5210 OstTraceExt2( TRACE_INTERNALS, GETDRIVEINFO1, "Socket=%d; device=%d", sockNum, (TUint) pM->iDevice ); |
4648 if ( (sockNum + 1) > sockets ) |
5211 if ( (sockNum + 1) > sockets ) |
4649 sockets = sockNum + 1; |
5212 sockets = sockNum + 1; |
4650 } |
5213 } |
4651 sock_mask |= (1<<sockNum); |
5214 sock_mask |= (1<<sockNum); |
4652 } |
5215 } |
4653 info.iDriveName[i]=*DriveNames[i]; |
5216 info.iDriveName[i]=*DriveNames[i]; |
4654 __KTRACE_OPT(KLOCDRV,Kern::Printf("Drive %d device %d name %lS",i,pM->iDevice,DriveNames[i])); |
5217 __KTRACE_OPT(KLOCDRV,Kern::Printf("Drive %d device %d name %lS",i,pM->iDevice,DriveNames[i])); |
|
5218 OstTraceExt2( TRACE_INTERNALS, GETDRIVEINFO2, "Drive=%d; device=%d", i, (TUint) pM->iDevice ); |
4655 |
5219 |
4656 info.iRegisteredDriveBitmask |= (0x01 << i); |
5220 info.iRegisteredDriveBitmask |= (0x01 << i); |
4657 } |
5221 } |
4658 } |
5222 } |
4659 info.iTotalSupportedDrives=drives; |
5223 info.iTotalSupportedDrives=drives; |
4660 info.iTotalSockets=sockets; |
5224 info.iTotalSockets=sockets; |
4661 info.iRuggedFileSystem=ETrue; |
5225 info.iRuggedFileSystem=ETrue; |
4662 __KTRACE_OPT(KLOCDRV,Kern::Printf("Total drives=%d, sockets=%d",drives,sockets)); |
5226 __KTRACE_OPT(KLOCDRV,Kern::Printf("Total drives=%d, sockets=%d",drives,sockets)); |
|
5227 OstTraceExt2( TRACE_INTERNALS, GETDRIVEINFO3, "Total drives=%d; sockets=%d", drives, sockets ); |
|
5228 OstTraceFunctionExit0( GETDRIVEINFO_EXIT ); |
4663 } |
5229 } |
4664 |
5230 |
4665 #if defined(__DEMAND_PAGING__) && defined(__CONCURRENT_PAGING_INSTRUMENTATION__) |
5231 #if defined(__DEMAND_PAGING__) && defined(__CONCURRENT_PAGING_INSTRUMENTATION__) |
4666 void ResetConcurrencyStats(DMediaPagingDevice* aDevice, TMediaPagingStats aStats) |
5232 void ResetConcurrencyStats(DMediaPagingDevice* aDevice, TMediaPagingStats aStats) |
4667 { |
5233 { |
4964 |
5530 |
4965 EXPORT_C void TPartitionTableScanner::Set(TUint8* aSectorBuffer, TPartitionEntry* aEntry, TInt aMaxPartitions, TInt64 aMediaSize) |
5531 EXPORT_C void TPartitionTableScanner::Set(TUint8* aSectorBuffer, TPartitionEntry* aEntry, TInt aMaxPartitions, TInt64 aMediaSize) |
4966 { |
5532 { |
4967 __KTRACE_OPT(KLOCDRV, Kern::Printf("TPartitionTableScanner @ %08x : buf %08x entry %08x max %d sz %08x %08x", |
5533 __KTRACE_OPT(KLOCDRV, Kern::Printf("TPartitionTableScanner @ %08x : buf %08x entry %08x max %d sz %08x %08x", |
4968 this, aSectorBuffer, aEntry, aMaxPartitions, I64HIGH(aMediaSize), I64LOW(aMediaSize))); |
5534 this, aSectorBuffer, aEntry, aMaxPartitions, I64HIGH(aMediaSize), I64LOW(aMediaSize))); |
|
5535 OstTraceExt4( TRACE_INTERNALS, TPARTITIONTABLESCANNER_SET, "TPartitionTableScanner at 0x%08x; aSectorBuffer=0x%08x; aEntry=0x%08x; aMaxPartitions=%d", (TUint) this, (TUint) aSectorBuffer, (TUint) aEntry, aMaxPartitions ); |
4969 __ASSERT_ALWAYS(aMaxPartitions>0, LOCM_FAULT()); |
5536 __ASSERT_ALWAYS(aMaxPartitions>0, LOCM_FAULT()); |
4970 memclr(this, sizeof(TPartitionTableScanner)); |
5537 memclr(this, sizeof(TPartitionTableScanner)); |
4971 iLBA = -1; |
5538 iLBA = -1; |
4972 iSectorBuffer = aSectorBuffer; |
5539 iSectorBuffer = aSectorBuffer; |
4973 iFirstEntry = aEntry; |
5540 iFirstEntry = aEntry; |
4978 |
5545 |
4979 EXPORT_C TInt TPartitionTableScanner::NumberOfPartitionsFound() const |
5546 EXPORT_C TInt TPartitionTableScanner::NumberOfPartitionsFound() const |
4980 { |
5547 { |
4981 TInt n = iNextEntry - iFirstEntry; |
5548 TInt n = iNextEntry - iFirstEntry; |
4982 __KTRACE_OPT(KLOCDRV, Kern::Printf("TPartitionTableScanner N=%d", n)); |
5549 __KTRACE_OPT(KLOCDRV, Kern::Printf("TPartitionTableScanner N=%d", n)); |
|
5550 OstTrace1( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NUMBERPARTITIONS, "Number of partitions=%d", n ); |
4983 return n; |
5551 return n; |
4984 } |
5552 } |
4985 |
5553 |
4986 TPartitionTableScanner::SPart::SPart(const TUint8* a) |
5554 TPartitionTableScanner::SPart::SPart(const TUint8* a) |
4987 { |
5555 { |
4988 iBootInd = a[0]; |
5556 iBootInd = a[0]; |
4989 iType = a[4]; |
5557 iType = a[4]; |
4990 iRSS = a[8]|(a[9]<<8)|(a[10]<<16)|(a[11]<<24); |
5558 iRSS = a[8]|(a[9]<<8)|(a[10]<<16)|(a[11]<<24); |
4991 iSectors = a[12]|(a[13]<<8)|(a[14]<<16)|(a[15]<<24); |
5559 iSectors = a[12]|(a[13]<<8)|(a[14]<<16)|(a[15]<<24); |
4992 __KTRACE_OPT(KLOCDRV, Kern::Printf("SPart: BI=%02x TYPE=%02x RSS=%08x SIZE=%08x", iBootInd, iType, iRSS, iSectors)); |
5560 __KTRACE_OPT(KLOCDRV, Kern::Printf("SPart: BI=%02x TYPE=%02x RSS=%08x SIZE=%08x", iBootInd, iType, iRSS, iSectors)); |
|
5561 OstTraceExt4(TRACE_INTERNALS, TPARTITIONTABLESCANNER_SPART_SPART, "SPart: iBootInd=%02x; iType=%02x; iRSS=%08x; iSectors=%08x", (TUint) iBootInd, (TUint) iType, (TUint) iRSS, (TUint) iSectors); |
4993 } |
5562 } |
4994 |
5563 |
4995 TInt TPartitionTableScanner::MakeEntry(const SPart& a) |
5564 TInt TPartitionTableScanner::MakeEntry(const SPart& a) |
4996 { |
5565 { |
|
5566 OstTraceFunctionEntry1( TPARTITIONTABLESCANNER_MAKEENTRY_ENTRY, this ); |
4997 if (iNextEntry == iLimit) |
5567 if (iNextEntry == iLimit) |
|
5568 { |
|
5569 OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT1, this, KErrOverflow ); |
4998 return KErrOverflow; |
5570 return KErrOverflow; |
|
5571 } |
4999 if (a.iRSS<=0 || a.iSectors<=0 || a.iRSS>=iMediaSize) |
5572 if (a.iRSS<=0 || a.iSectors<=0 || a.iRSS>=iMediaSize) |
|
5573 { |
|
5574 OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT2, this, KErrCorrupt ); |
5000 return KErrCorrupt; |
5575 return KErrCorrupt; |
|
5576 } |
5001 if (TUint64(a.iRSS) + TUint64(a.iSectors) > TUint64(iMediaSize)) |
5577 if (TUint64(a.iRSS) + TUint64(a.iSectors) > TUint64(iMediaSize)) |
|
5578 { |
|
5579 OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT3, this, KErrCorrupt ); |
5002 return KErrCorrupt; |
5580 return KErrCorrupt; |
|
5581 } |
5003 iNextEntry->iBootIndicator = a.iBootInd; |
5582 iNextEntry->iBootIndicator = a.iBootInd; |
5004 iNextEntry->iPartitionType = a.iType; |
5583 iNextEntry->iPartitionType = a.iType; |
5005 iNextEntry->iPartitionBaseAddr = TInt64(a.iRSS)<<ESectorShift; |
5584 iNextEntry->iPartitionBaseAddr = TInt64(a.iRSS)<<ESectorShift; |
5006 iNextEntry->iPartitionLen = TInt64(a.iSectors)<<ESectorShift; |
5585 iNextEntry->iPartitionLen = TInt64(a.iSectors)<<ESectorShift; |
5007 ++iNextEntry; |
5586 ++iNextEntry; |
|
5587 OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT4, this, KErrNone ); |
5008 return KErrNone; |
5588 return KErrNone; |
5009 } |
5589 } |
5010 |
5590 |
5011 EXPORT_C TInt64 TPartitionTableScanner::NextLBA() |
5591 EXPORT_C TInt64 TPartitionTableScanner::NextLBA() |
5012 { |
5592 { |
|
5593 OstTraceFunctionEntry0( TPARTITIONTABLESCANNER_NEXTLBA_ENTRY ); |
5013 __KTRACE_OPT(KLOCDRV, Kern::Printf(">TPartitionTableScanner iLBA=%08x %08x", I64HIGH(iLBA), I64LOW(iLBA))); |
5594 __KTRACE_OPT(KLOCDRV, Kern::Printf(">TPartitionTableScanner iLBA=%08x %08x", I64HIGH(iLBA), I64LOW(iLBA))); |
|
5595 OstTraceExt2( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NEXTLBA1, "TPartitionTableScanner iLBA=%08x %08x", I64HIGH(iLBA), I64LOW(iLBA) ); |
5014 TInt r; |
5596 TInt r; |
5015 TUint8* b = iSectorBuffer; |
5597 TUint8* b = iSectorBuffer; |
5016 TUint8* pS = b + 0x1be; |
5598 TUint8* pS = b + 0x1be; |
5017 TUint8* pE = pS + 64; |
5599 TUint8* pE = pS + 64; |
5018 TUint8* p = pS; |
5600 TUint8* p = pS; |