17 |
17 |
18 #include "sf_std.h" |
18 #include "sf_std.h" |
19 #include <f32dbg.h> |
19 #include <f32dbg.h> |
20 #include "f32image.h" |
20 #include "f32image.h" |
21 #include <F32plugin.h> |
21 #include <F32plugin.h> |
|
22 #include <filesystem_fat.h> |
22 #include "sf_file_cache.h" |
23 #include "sf_file_cache.h" |
23 |
24 #include "sf_memory_man.h" |
24 |
25 |
25 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
26 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
26 |
27 |
27 // |
28 // |
28 // ONLY INCLUDED IN DEBUG BUILDS |
29 // ONLY INCLUDED IN DEBUG BUILDS |
29 // |
30 // |
|
31 |
|
32 void PrintOpenFiles() |
|
33 { |
|
34 CCacheManager* manager = CCacheManagerFactory::CacheManager(); |
|
35 TInt allocatedSegmentCount = manager ? manager->Stats().iAllocatedSegmentCount : 0; |
|
36 TInt lockedSegmentCount = manager ? manager->Stats().iLockedSegmentCount : 0; |
|
37 TInt fileCount = manager ? manager->Stats().iFileCount : 0; |
|
38 TInt filesOnClosedQueue = manager ? manager->Stats().iFilesOnClosedQueue : 0; |
|
39 |
|
40 RDebug::Print(_L("TRACE: Open files %d allocatedSegmentCount %d lockedSegmentCount %d fileCount %d filesOnClosedQueue %d\n"), |
|
41 Files->Count(), allocatedSegmentCount, lockedSegmentCount, fileCount, filesOnClosedQueue); |
|
42 |
|
43 Files->Lock(); |
|
44 TInt count=Files->Count(); |
|
45 |
|
46 for (TInt n=0; n<count; n++) |
|
47 { |
|
48 CFileCB* file=(CFileCB*)(*Files)[n]; |
|
49 |
|
50 RDebug::Print(_L("%3d: %C:%S fc %x sz %lx\n"), n, file->Drive().DriveNumber() + 'A', &file->FileNameF(), file->FileCache(), file->CachedSize64()); |
|
51 } |
|
52 Files->Unlock(); |
|
53 } |
30 |
54 |
31 void PrintHeapSize(const TDesC& aMessage) |
55 void PrintHeapSize(const TDesC& aMessage) |
32 // |
56 // |
33 // Display the total memory available |
57 // Display the total memory available |
34 // |
58 // |
623 TPtr8 pkgBuf(&isFileSequential,1,1); |
647 TPtr8 pkgBuf(&isFileSequential,1,1); |
624 aRequest->Write(3, pkgBuf); |
648 aRequest->Write(3, pkgBuf); |
625 |
649 |
626 return KErrNone; |
650 return KErrNone; |
627 } |
651 } |
|
652 case KControlIoGlobalCacheConfig: |
|
653 // read ESTART.TXT file for global memory settings |
|
654 { |
|
655 TGlobalCacheConfig globalCacheConfig; |
|
656 TInt32 rel; |
|
657 |
|
658 const TInt KByteToByteShift = 10; |
|
659 _LIT8(KLitSectionNameCacheMemory,"CacheMemory"); |
|
660 |
|
661 if (F32Properties::GetInt(KLitSectionNameCacheMemory, _L8("GlobalCacheMemorySize"), rel)) |
|
662 globalCacheConfig.iGlobalCacheSizeInBytes = rel << KByteToByteShift; |
|
663 else |
|
664 globalCacheConfig.iGlobalCacheSizeInBytes = KErrNotFound; |
|
665 |
|
666 if (F32Properties::GetInt(KLitSectionNameCacheMemory, _L8("LowMemoryThreshold"), rel)) |
|
667 globalCacheConfig.iGlobalLowMemoryThreshold = rel; |
|
668 else |
|
669 globalCacheConfig.iGlobalLowMemoryThreshold = KErrNotFound; |
|
670 |
|
671 TPckgBuf<TGlobalCacheConfig> pkgBuf(globalCacheConfig); |
|
672 TInt r=aRequest->Write(2,pkgBuf); |
|
673 return r; |
|
674 } |
|
675 case KControlIoGlobalCacheInfo: |
|
676 // get system's current global cache memory info |
|
677 { |
|
678 TGlobalCacheInfo info; |
|
679 info.iGlobalCacheSizeInBytes = TGlobalCacheMemorySettings::CacheSize(); |
|
680 info.iGlobalLowMemoryThreshold = TGlobalCacheMemorySettings::LowMemoryThreshold(); |
|
681 TPckgBuf<TGlobalCacheInfo> pkgBuf(info); |
|
682 TInt r=aRequest->Write(2,pkgBuf); |
|
683 return r; |
|
684 } |
|
685 case KControlIoDirCacheConfig: |
|
686 // read ESTART.TXT file for per-drive directory cache settings |
|
687 { |
|
688 TInt driveNumber = aRequest->Drive()->DriveNumber(); |
|
689 TDirCacheConfig dirCacheConfig; |
|
690 TInt32 rel; |
|
691 dirCacheConfig.iDrive = driveNumber; |
|
692 TBuf8<32> driveSection; |
|
693 driveSection.Format(_L8("Drive%c"), 'A' + driveNumber); |
|
694 |
|
695 if (F32Properties::GetInt(driveSection, _L8("FAT_LeafDirCacheSize"), rel)) |
|
696 dirCacheConfig.iLeafDirCacheSize = rel; |
|
697 else |
|
698 dirCacheConfig.iLeafDirCacheSize = KErrNotFound; |
|
699 |
|
700 if (F32Properties::GetInt(driveSection, _L8("FAT_DirCacheSizeMin"), rel)) |
|
701 dirCacheConfig.iDirCacheSizeMin = rel << KByteToByteShift; |
|
702 else |
|
703 dirCacheConfig.iDirCacheSizeMin = KErrNotFound; |
|
704 |
|
705 if (F32Properties::GetInt(driveSection, _L8("FAT_DirCacheSizeMax"), rel)) |
|
706 dirCacheConfig.iDirCacheSizeMax = rel << KByteToByteShift; |
|
707 else |
|
708 dirCacheConfig.iDirCacheSizeMax = KErrNotFound; |
|
709 |
|
710 TPckgBuf<TDirCacheConfig> pkgBuf(dirCacheConfig); |
|
711 TInt r=aRequest->Write(2,pkgBuf); |
|
712 return r; |
|
713 } |
|
714 case KControlIoDirCacheInfo: |
|
715 // get system's current per-drive directory cache settings |
|
716 // currently only supports FAT file system |
|
717 { |
|
718 TFSName fsName; |
|
719 aRequest->Drive()->CurrentMount().FileSystemName(fsName); |
|
720 if (fsName.CompareF(KFileSystemName_FAT) == 0) |
|
721 { |
|
722 // 16 is the control cmd used for FAT |
|
723 // see EFATDirCacheInfo in FAT code please. |
|
724 const TInt KFATDirCacheInfo = 16; |
|
725 return(aRequest->Drive()->ControlIO(aRequest->Message(),KFATDirCacheInfo,param1,param2)); |
|
726 } |
|
727 return KErrNotSupported; |
|
728 } |
|
729 case KControlIoSimulateMemoryLow: |
|
730 { |
|
731 CCacheMemoryManager* cacheMemManager = CCacheMemoryManagerFactory::CacheMemoryManager(); |
|
732 if (cacheMemManager) |
|
733 cacheMemManager->SetMemoryLow(ETrue); |
|
734 else |
|
735 return KErrNotSupported; |
|
736 return KErrNone; |
|
737 } |
|
738 case KControlIoStopSimulateMemoryLow: |
|
739 { |
|
740 CCacheMemoryManager* cacheMemManager = CCacheMemoryManagerFactory::CacheMemoryManager(); |
|
741 if (cacheMemManager) |
|
742 cacheMemManager->SetMemoryLow(EFalse); |
|
743 else |
|
744 return KErrNotSupported; |
|
745 return KErrNone; |
|
746 } |
628 |
747 |
629 } |
748 } |
630 #endif |
749 #endif |
631 |
750 |
632 return(aRequest->Drive()->ControlIO(aRequest->Message(),command,param1,param2)); |
751 return(aRequest->Drive()->ControlIO(aRequest->Message(),command,param1,param2)); |