os/kernelhwsrv/kerneltest/f32test/ext/t_logext.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\ext\logext.cpp
    15 // extension that records/prints out accesses to each function and length of reads and writes
    16 // 
    17 //
    18 
    19 #include <f32fsys.h>
    20 
    21 struct TAccessLength
    22 	{
    23 	TInt iless512;
    24 	TInt i512;
    25 	TInt imore512;
    26 	};
    27 
    28 class CLoggerExtProxyDrive : public CBaseExtProxyDrive
    29 	{
    30 public:
    31 	static CLoggerExtProxyDrive* NewL(CProxyDrive* aProxyDrive, CMountCB* aMount);
    32 	~CLoggerExtProxyDrive();
    33 public:
    34 	virtual TInt Initialise();
    35 	virtual TInt Dismounted();
    36 	virtual TInt Enlarge(TInt aLength);
    37 	virtual TInt ReduceSize(TInt aPos, TInt aLength);
    38 	virtual TInt Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset);
    39 	virtual TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg);
    40 	virtual TInt Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset);
    41 	virtual TInt Write(TInt64 aPos,const TDesC8& aSrc);
    42 	virtual TInt Caps(TDes8& anInfo);
    43 	virtual TInt Format(TFormatInfo& anInfo);
    44 	virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
    45 private:
    46 	CLoggerExtProxyDrive(CProxyDrive* aProxyDrive, CMountCB* aMount);
    47 private:
    48 	TInt iInitialise;
    49 	TInt iDismounted;
    50 	TInt iEnlarge;
    51 	TInt iReduceSize;
    52 	TInt iReadThread;
    53 	TAccessLength iReadThreadLength;
    54 	TInt iRead;
    55 	TAccessLength iReadLength;
    56 	TInt iWriteThread;
    57 	TAccessLength iWriteThreadLength;
    58 	TInt iWrite;
    59 	TAccessLength iWriteLength;
    60 	TInt iCaps;
    61 	TInt iFormat;
    62 	};
    63 
    64 class CLoggerProxyDriveFactory : public CProxyDriveFactory
    65 	{
    66 public:
    67 	CLoggerProxyDriveFactory();
    68 	virtual TInt Install();			
    69 	virtual CProxyDrive* NewProxyDriveL(CProxyDrive* aProxy,CMountCB* aMount);
    70 	};
    71 
    72 
    73 
    74 LOCAL_C void LogLength(TAccessLength& aAccess,TInt aLength)
    75 //
    76 //
    77 //
    78 	{
    79 	if(aLength<512)
    80 		{
    81 		aAccess.iless512++;
    82 		}
    83 	else if(aLength==512)
    84 		{
    85 		aAccess.i512++;
    86 		}
    87 	else
    88 		aAccess.imore512++;
    89 	}
    90 
    91 LOCAL_C void PrintLength(TAccessLength& aAccess)
    92 //
    93 //
    94 //
    95 	{
    96 	RDebug::Print(_L("\t<512 = %d"),aAccess.iless512);
    97 	RDebug::Print(_L("\t 512 = %d"),aAccess.i512);
    98 	RDebug::Print(_L("\t>512 = %d"),aAccess.imore512);
    99 	}
   100 
   101 
   102 CLoggerExtProxyDrive* CLoggerExtProxyDrive::NewL(CProxyDrive* aProxyDrive, CMountCB* aMount)
   103 //
   104 //
   105 //
   106 	{
   107 	CLoggerExtProxyDrive* temp=new(ELeave) CLoggerExtProxyDrive(aProxyDrive,aMount);
   108 	return(temp);
   109 	}
   110 
   111 
   112 CLoggerExtProxyDrive::CLoggerExtProxyDrive(CProxyDrive* aProxyDrive, CMountCB* aMount):CBaseExtProxyDrive(aProxyDrive,aMount)
   113 	{
   114 	RDebug::Print(_L("CLoggerExtProxyDrive::CLoggerExtProxyDrive"));
   115 	}
   116 
   117 CLoggerExtProxyDrive::~CLoggerExtProxyDrive()
   118 //
   119 //
   120 //
   121 	{
   122 	// print out the figures obtained
   123 	RDebug::Print(_L("Initialise = %d"),iInitialise);
   124 	RDebug::Print(_L("Dismounted = %d"),iDismounted);
   125 	RDebug::Print(_L("Enlarge = %d"),iEnlarge);
   126 	RDebug::Print(_L("ReduceSize = %d"),iReduceSize);
   127 	RDebug::Print(_L("Read Thread = %d"),iReadThread);
   128 	if(iReadThread)
   129 		PrintLength(iReadThreadLength);
   130 	RDebug::Print(_L("Read = %d"),iRead);
   131 	if(iRead)
   132 		PrintLength(iReadLength);
   133 	RDebug::Print(_L("Write Thread = %d"),iWriteThread);
   134 	if(iWriteThread)
   135 		PrintLength(iWriteThreadLength);
   136 	RDebug::Print(_L("Write = %d"),iWrite);
   137 	if(iWrite)
   138 		PrintLength(iWriteLength);
   139 	RDebug::Print(_L("Caps = %d"),iCaps);
   140 	RDebug::Print(_L("Format = %d"),iFormat);
   141 	}
   142 
   143 TInt CLoggerExtProxyDrive::Initialise()
   144 //
   145 //
   146 //
   147 	{
   148 	RDebug::Print(_L("CLoggerExtProxyDrive::Initialise()"));
   149 	++iInitialise;
   150 	return(CBaseExtProxyDrive::Initialise());
   151 	}
   152 
   153 TInt CLoggerExtProxyDrive::Dismounted()
   154 //
   155 //
   156 //
   157 	{
   158 	RDebug::Print(_L("CLoggerExtProxyDrive::Dismounted()"));
   159 	++iDismounted;
   160 	return(CBaseExtProxyDrive::Dismounted());
   161 	}
   162 
   163 TInt CLoggerExtProxyDrive::Enlarge(TInt aLength)
   164 //
   165 //
   166 //
   167 	{
   168 	++iEnlarge;
   169 	return(CBaseExtProxyDrive::Enlarge(aLength));
   170 	}
   171 
   172 
   173 TInt CLoggerExtProxyDrive::ReduceSize(TInt aPos, TInt aLength)
   174 //
   175 //
   176 //
   177 	{
   178 	++iReduceSize;
   179 	return(CBaseExtProxyDrive::ReduceSize(aPos,aLength));
   180 	}
   181 
   182 TInt CLoggerExtProxyDrive::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset)
   183 //
   184 //
   185 //
   186 	{
   187 	++iReadThread;
   188 	LogLength(iReadThreadLength,aLength);
   189 	return(CBaseExtProxyDrive::Read(aPos,aLength,aTrg,aThreadHandle,anOffset));
   190 	}
   191 
   192 TInt CLoggerExtProxyDrive::Read(TInt64 aPos,TInt aLength,TDes8& aTrg)
   193 //
   194 //
   195 //
   196 	{
   197 	++iRead;
   198 	LogLength(iReadLength,aLength);
   199 	return(CBaseExtProxyDrive::Read(aPos,aLength,aTrg));
   200 	}
   201 
   202 TInt CLoggerExtProxyDrive::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset)
   203 //
   204 //
   205 //
   206 	{
   207 	++iWriteThread;
   208 	LogLength(iWriteThreadLength,aLength);
   209 	return(CBaseExtProxyDrive::Write(aPos,aLength,aSrc,aThreadHandle,anOffset));
   210 	}
   211 
   212 TInt CLoggerExtProxyDrive::Write(TInt64 aPos,const TDesC8& aSrc)
   213 //
   214 //
   215 //
   216 	{
   217 	++iWrite;
   218 	LogLength(iWriteLength,aSrc.Length());
   219 	return(CBaseExtProxyDrive::Write(aPos,aSrc));
   220 	}
   221 
   222 TInt CLoggerExtProxyDrive::Caps(TDes8& anInfo)
   223 //
   224 //
   225 //
   226 	{
   227 	++iCaps;
   228 	return(CBaseExtProxyDrive::Caps(anInfo));
   229 	}
   230 
   231 TInt CLoggerExtProxyDrive::Format(TFormatInfo& anInfo)
   232 //
   233 //
   234 //
   235 	{
   236 	++iFormat;
   237 	return(CBaseExtProxyDrive::Format(anInfo));
   238 	}
   239 
   240 
   241 TInt CLoggerExtProxyDrive::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput)
   242 	{
   243 	switch(aInterfaceId)
   244 		{
   245 		// file caching supported, so pass query on to next extension
   246 		case ELocalBufferSupport:
   247 			return CBaseExtProxyDrive::LocalBufferSupport();
   248 
   249 		default:
   250 			return CBaseExtProxyDrive::GetInterface(aInterfaceId, aInterface, aInput);
   251 		}
   252 	}
   253 
   254 CLoggerProxyDriveFactory::CLoggerProxyDriveFactory()
   255 //
   256 //
   257 //
   258 	{
   259 	RDebug::Print(_L("CLoggerProxyDriveFactory::CLoggerProxyDriveFactory"));
   260 	}
   261 
   262 TInt CLoggerProxyDriveFactory::Install()
   263 //
   264 //
   265 //
   266 	{
   267 	_LIT(KLoggerName,"Logger");
   268 	return(SetName(&KLoggerName));
   269 	}
   270 
   271 
   272 CProxyDrive* CLoggerProxyDriveFactory::NewProxyDriveL(CProxyDrive* aProxy,CMountCB* aMount)
   273 //
   274 //
   275 //
   276 	{
   277 	return(CLoggerExtProxyDrive::NewL(aProxy,aMount));
   278 	}
   279 
   280 extern "C" {
   281 
   282 EXPORT_C CProxyDriveFactory* CreateFileSystem()
   283 //
   284 // Create a new file system
   285 //
   286 	{
   287 	return(new CLoggerProxyDriveFactory());
   288 	}
   289 }
   290