kerneltest/e32test/mmu/freeram.h
changeset 247 d8d70de2bd36
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
    16 //
    16 //
    17 
    17 
    18 #ifndef __FREERAM_H__
    18 #ifndef __FREERAM_H__
    19 #define __FREERAM_H__
    19 #define __FREERAM_H__
    20 
    20 
    21 //
    21 /**
    22 // returns the free RAM in bytes
    22 Get the amount of free RAM in the system in bytes.
    23 //
    23 
    24 inline TInt FreeRam()
    24 This calls the kernel HAL supervisor barrier to ensure that asynchronous cleanup in the supervisor
       
    25 happens before the amount of free RAM is measured.
       
    26 
       
    27 There is also the option to wait for upto a specified timeout for the system to become idle.
       
    28 
       
    29 @param aIdleTimeoutMs If non-zero, the number of milliseconds to wait for the system to become idle.
       
    30 
       
    31 @return On sucess returns the amount of free RAM in bytes, KErrTimedOut if the timeout expired
       
    32         without the system becoming idle, or one of the other system-wide error codes.
       
    33 */
       
    34 TInt FreeRam(TInt aIdleTimeoutMs = 0)
    25 	{
    35 	{
    26 	// wait for any async cleanup in the supervisor to finish first...
    36 	// wait for any async cleanup in the supervisor to finish first...
    27 	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
    37 	TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier,
       
    38 								  (TAny*)aIdleTimeoutMs, 0);
       
    39 	if (r != KErrNone)
       
    40 		return r;
    28 
    41 
    29 	TMemoryInfoV1Buf meminfo;
    42 	TMemoryInfoV1Buf meminfo;
    30 	UserHal::MemoryInfo(meminfo);
    43 	r = UserHal::MemoryInfo(meminfo);
       
    44 	if (r != KErrNone)
       
    45 		return r;
       
    46 	
    31 	return meminfo().iFreeRamInBytes;
    47 	return meminfo().iFreeRamInBytes;
    32 	}
    48 	}
    33 
    49 
    34 #endif
    50 #endif