os/kernelhwsrv/kerneltest/e32test/defrag/t_ramdefrag.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-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 // e32test\defrag\t_ramdefrag.h
    15 // 
    16 //
    17 
    18 #ifndef _T_RAMDEFRAG_H_
    19 #define _T_RAMDEFRAG_H_
    20 
    21 #include <e32cmn.h>
    22 #ifndef __KERNEL_MODE__
    23 #include <e32std.h>
    24 #endif
    25 
    26 #define DEFRAG_TYPE_GEN 		(1)
    27 #define DEFRAG_TYPE_EMPTY 		(2)
    28 #define DEFRAG_TYPE_CLAIM		(3)
    29 
    30 #define DEFRAG_VER_SYNC 		(1)
    31 #define DEFRAG_VER_SEM	 		(2)
    32 #define DEFRAG_VER_DFC			(3)
    33 
    34 #define NO_FIXED_FLAG			(1)
    35 #define NO_MOVE_FLAG			(2)
    36 #define NO_DISCARD_FLAG			(3)
    37 #define NO_ALLOC_FLAG			(4)
    38 #define ONLY_DISCARD_FLAG		(5)
    39 #define RESET_FLAG				(6)
    40 #define ORIG_FLAG				(7)
    41 
    42 #define FREE_ALL_FIXED			(0)
    43 #define FILL_ALL_FIXED			(-1)
    44 
    45 #define FREE_VALID				(0)
    46 #define FREE_INVALID			(-1)
    47 //#define DEBUG_VER
    48 #ifdef DEBUG_VER
    49 #define TESTDEBUG(a) {a;}
    50 #else
    51 #define TESTDEBUG(a) {}
    52 #endif
    53 
    54 struct SCapsPageMoveV01
    55 	{
    56 	TVersion	iVersion;
    57 	};
    58 	
    59 struct STestRamDefragVars
    60 	{
    61 	TInt iRamSize;
    62 	TInt iFreeRam;
    63 	TInt iPageSize;
    64 	TInt iRamUsed;
    65 	TInt iNumFreePages;
    66 	};
    67 
    68 struct STestUserSidePageCount
    69 	{
    70 	TUint iFreePages;		/**<the number of free pages in the RAM zone*/
    71 	TUint iFixedPages;		/**<the number of fixed pages in the RAM zone*/
    72 	TUint iMovablePages;	/**<the number of movable pages in the RAM zone*/
    73 	TUint iDiscardablePages;/**<the number of discardable pages in the RAM zone*/
    74 	TUint iReserved[4];		/**<@internalAll reserved for internal use only*/
    75 	};
    76 
    77 struct STestPageCount
    78 	{
    79 	TUint iFreePages;
    80 	TUint iUnknownPages;
    81 	TUint iFixedPages;
    82 	TUint iMovablePages;
    83 	TUint iDiscardablePages;
    84 	TUint iOtherPages;
    85 	};
    86 
    87 struct STestFlagParams
    88 	{
    89 	TUint	iZoneID;
    90 	TUint8	iZoneFlag;
    91 	TInt	iSetFlag;
    92 	TUint8	iOptSetFlag;
    93 	};
    94 
    95 
    96 struct STestParameters
    97 	{
    98 	TInt iDefragVersion; 
    99 	TInt iDefragType;
   100 	TInt iPriority;
   101 	TInt iMaxPages;
   102 	TUint iID;
   103 	TRequestStatus* iReqStat;
   104 	TRequestStatus* iReqStat2;
   105 	TRequestStatus* iReqStat3;
   106 	};
   107 
   108 // struct for passing multiple RAM zone IDs to the LDD.
   109 struct SMultiZoneAlloc
   110 	{
   111 	TUint* iZoneId;			/**< An array of RAM zone IDs*/
   112 	TUint iZoneIdSize;		/**< The number of IDs in iZoneId*/
   113 	};
   114 
   115 _LIT(KRamDefragFuncTestLddName,"D_RAMDEFRAG");
   116 
   117 class RRamDefragFuncTestLdd : public RBusLogicalChannel
   118 	{
   119 public:
   120 	enum TControl
   121 		{
   122 		EDoConsumeRamFinish,
   123 		EDoSetDebugFlag,
   124 		EAllocateFixed,
   125 		EAllocFixedArray, 
   126 		EAllocateFixed2,
   127 		EGetAllocDiff,
   128 		EFreeAllFixed,
   129 		EAllocateFixedWrite,
   130 		EFreeAllFixedRead,
   131 		EPageCount,
   132 		EZoneAllocContiguous,
   133 		EMultiZoneAllocContiguous,
   134 		EZoneAllocDiscontiguous,
   135 		EMultiZoneAllocDiscontiguous,
   136 		EZoneAllocDiscontiguous2,
   137 		EZoneAllocToMany,
   138 		EZoneAllocToManyArray,
   139 		EZoneAllocToMany2,
   140 		EAllocContiguous,
   141 		EFreeZone,
   142 		EFreeFromAllZones,
   143 		EFreeFromAddr, 
   144 		ECheckCancel,
   145 		ECheckPriorities,
   146 		ECallDefrag,
   147 		ESetZoneFlag,
   148 		EGetDefragOrder,
   149 		EResetDriver,
   150 		};
   151 
   152 #ifndef __KERNEL_MODE__
   153 public:
   154 	inline TInt Open()
   155 		{ return DoCreate(KRamDefragFuncTestLddName,TVersion(),KNullUnit,NULL,NULL,EOwnerProcess,ETrue); }
   156 
   157 	inline TInt ResetDriver()
   158 		{ return DoControl(EResetDriver,(TAny*)NULL, (TAny*)NULL); }
   159 
   160 	inline TInt DoSetDebugFlag(TInt aState)
   161 		{ return DoControl(EDoSetDebugFlag,(TAny*)aState, (TAny*)NULL); }
   162 
   163 	inline TInt AllocateFixed(TInt aNumOfPages)
   164 		{ return DoControl(EAllocateFixed,(TAny*)aNumOfPages, (TAny*)NULL); }
   165 
   166 	inline TInt AllocFixedArray(TInt aNumOfPages)
   167 		{ return DoControl(EAllocFixedArray,(TAny*)aNumOfPages, (TAny*)NULL); }
   168 
   169 	inline TInt AllocateFixed2(TInt aNumOfPages)
   170 		{ return DoControl(EAllocateFixed2,(TAny*)aNumOfPages, (TAny*)NULL); }
   171 
   172 	inline TInt GetAllocDiff(TInt aNumOfPages)
   173 		{ return DoControl(EGetAllocDiff,(TAny*)aNumOfPages, (TAny*)NULL); }
   174 
   175 	inline TInt FreeAllFixedPages()
   176 		{ return DoControl(EFreeAllFixed); }
   177 
   178 	inline TInt AllocateFixedWrite(TInt aNumOfPages)
   179 		{ return DoControl(EAllocateFixedWrite,(TAny*)aNumOfPages, (TAny*)NULL); }
   180 
   181 	inline TInt FreeAllFixedPagesRead()
   182 		{ return DoControl(EFreeAllFixedRead,(TAny*)NULL, (TAny*)NULL); }
   183 
   184 	inline TInt ZoneAllocContiguous(TUint aZoneID, TInt aSize)
   185 		{ return DoControl(EZoneAllocContiguous,(TAny*)aZoneID, (TAny*)aSize); }
   186 
   187 	inline TInt MultiZoneAllocContiguous(TUint* aZoneId, TUint aZoneIdSize, TInt aSize)
   188 		{ 
   189 		SMultiZoneAlloc multiZoneAlloc;
   190 		multiZoneAlloc.iZoneId = aZoneId;
   191 		multiZoneAlloc.iZoneIdSize = aZoneIdSize;
   192 		return DoControl(EMultiZoneAllocContiguous,(TAny*)&multiZoneAlloc, (TAny*)aSize); 
   193 		}
   194 
   195 	inline TInt ZoneAllocDiscontiguous(TUint aZoneID, TInt aNumPages)
   196 		{ return DoControl(EZoneAllocDiscontiguous,(TAny*)aZoneID, (TAny*)aNumPages); }
   197 
   198 	inline TInt MultiZoneAllocDiscontiguous(TUint* aZoneId, TUint aZoneIdSize, TInt aNumPages)
   199 		{ 
   200 		SMultiZoneAlloc multiZoneAlloc;
   201 		multiZoneAlloc.iZoneId = aZoneId;
   202 		multiZoneAlloc.iZoneIdSize = aZoneIdSize;
   203 		return DoControl(EMultiZoneAllocDiscontiguous,(TAny*)&multiZoneAlloc, (TAny*)aNumPages);
   204 		}
   205 
   206 	inline TInt ZoneAllocDiscontiguous2(TUint aZoneID, TInt aNumPages)
   207 		{ return DoControl(EZoneAllocDiscontiguous2,(TAny*)aZoneID, (TAny*)aNumPages); }
   208 
   209 	inline TInt ZoneAllocToMany(TInt aZoneIndex, TInt aNumPages)
   210 		{ return DoControl(EZoneAllocToMany,(TAny*)aZoneIndex, (TAny*)aNumPages); }
   211 
   212 	inline TInt ZoneAllocToManyArray(TInt aZoneIndex, TInt aNumPages)
   213 		{ return DoControl(EZoneAllocToManyArray,(TAny*)aZoneIndex, (TAny*)aNumPages); }
   214 
   215 	inline TInt ZoneAllocToMany2(TInt aZoneIndex, TInt aNumPages)
   216 		{ return DoControl(EZoneAllocToMany2,(TAny*)aZoneIndex, (TAny*)aNumPages); }
   217 	
   218 	inline TInt AllocContiguous(TInt aSize)
   219 		{ return DoControl(EAllocContiguous,(TAny*)aSize, (TAny*)NULL); }
   220 
   221 	inline TInt FreeZone(TInt aNumPages)
   222 		{ return DoControl(EFreeZone,(TAny*)aNumPages, (TAny*)NULL); }
   223 
   224 	inline TInt FreeFromAllZones()
   225 		{ return DoControl(EFreeFromAllZones,(TAny*)NULL, (TAny*)NULL); }
   226 
   227 
   228 	inline TInt CheckCancel(TInt aDefragType, TUint aID = 0)
   229 		{ 
   230 		STestParameters params;
   231 		
   232 		params.iDefragType = aDefragType;
   233 		params.iDefragVersion = 0;
   234 		params.iID = aID;
   235 		params.iPriority = 0;
   236 		params.iMaxPages = 0;
   237 		params.iReqStat = NULL; 
   238 		params.iReqStat2 = NULL; 
   239 		params.iReqStat3 = NULL; 
   240 		return DoControl(ECheckCancel,(TAny*)&params); 
   241 		}
   242 
   243 	inline TInt FreeFromAddr(TInt aNumPages, TUint32 aAddr)
   244 		{ return DoControl(EFreeFromAddr,(TAny*)aNumPages, (TAny*)aAddr); }
   245 
   246 	inline TInt PageCount(TUint aID, STestUserSidePageCount* aPageData)
   247 		{ return DoControl(EPageCount,(TAny*)aID, (TAny*)aPageData); }
   248 
   249 	inline TInt CallDefrag(TInt aDefragType, TInt aDefragVersion, TUint aID = 0, TInt aMaxPages = 0, TInt aPriority = -1, TRequestStatus* aReqStat = NULL)
   250 		{ 
   251 		STestParameters params;
   252 		
   253 		params.iDefragType = aDefragType;
   254 		params.iDefragVersion = aDefragVersion;
   255 		params.iID = aID;
   256 		params.iPriority = aPriority;
   257 		params.iMaxPages = aMaxPages;
   258 		params.iReqStat = aReqStat;
   259 		if (aReqStat)
   260 			{
   261 			*aReqStat = KRequestPending;
   262 			}
   263 		params.iReqStat2 = NULL; 
   264 		params.iReqStat3 = NULL; 
   265 		TInt ret = DoControl(ECallDefrag,(TAny*)&params); 
   266 		return ret;
   267 		}
   268 
   269 	/**
   270 	@param aZoneID		The ID of the RAM zone to modify
   271 	@param aZoneFlag	The flags to clear, if want only aSetFlags to be enabled after this then
   272 						aZoneFlag should be the current flags sets on the RAM zone.
   273 	@param aSetFlag		The flags to set
   274 	@param aOptSetFlag	If aSetFlag==ORIG_FLAG then aOptSetFlag will be the flags to set 
   275 						on the RAM zone.
   276 	*/
   277 	inline TInt SetZoneFlag(TUint aZoneID, TUint8 aZoneFlag, TInt aSetFlag, TUint8 aOptSetFlag = 0x00)
   278 		{ 
   279 		STestFlagParams flagParams;
   280 		
   281 		flagParams.iZoneID = aZoneID;
   282 		flagParams.iZoneFlag = aZoneFlag;
   283 		flagParams.iSetFlag = aSetFlag;
   284 		flagParams.iOptSetFlag = aOptSetFlag;
   285 		
   286 		return DoControl(ESetZoneFlag,(TAny*)&flagParams, (TAny*)NULL); 
   287 		}
   288 
   289 	inline TInt CheckPriorities(TInt aDefragType, TUint aID = 0, TRequestStatus* aReqStat = NULL, TRequestStatus* aReqStat2 = NULL, TRequestStatus* aReqStat3 = NULL)
   290 		{ 
   291 		STestParameters params;
   292 		
   293 		params.iDefragType = aDefragType;
   294 		params.iDefragVersion = 0;
   295 		params.iID = aID;
   296 		params.iPriority = 0;
   297 		params.iMaxPages = 0;
   298 		params.iReqStat = aReqStat;
   299 		if (aReqStat)
   300 			{
   301 			*aReqStat = KRequestPending;
   302 			}
   303 		params.iReqStat2 = aReqStat2; 
   304 		if (aReqStat2)
   305 			{
   306 			*aReqStat2 = KRequestPending;
   307 			}
   308 		params.iReqStat3 = aReqStat3;  
   309 		if (aReqStat3)
   310 			{
   311 			*aReqStat3 = KRequestPending;
   312 			}
   313 
   314 		return DoControl(ECheckPriorities,(TAny*)&params); 
   315 		}
   316 
   317 	inline TInt GetDefragOrder()
   318 		{ return DoControl(EGetDefragOrder,(TAny*)NULL, (TAny*)NULL); }
   319 
   320 
   321 #endif
   322 	};
   323 
   324 
   325 #endif //_T_RAMDEFRAG_H_