201029_03
authorhgs
Mon, 26 Jul 2010 10:52:56 +0100
changeset 231 75252ea6123b
parent 202 9aca3be14c27
child 243 c7a0ce20c48c
201029_03
halservices/hal/bld.inf
kernel/eka/common/mem.cpp
kernel/eka/common/win32/cmem.cpp
kernel/eka/drivers/dma/dma2_pil.cpp
kernel/eka/drivers/dma/dmapil.cpp
kernel/eka/include/cpudefs.h
kernel/eka/include/drivers/dma_v1.h
kernel/eka/include/drivers/dma_v2.h
kernel/eka/include/e32ver.h
kernel/eka/kernel/ekern.mmp
kernel/eka/release.txt
kernel/eka/rombuild/h4usbtest.iby
kernelhwsrv_info/doc_pub/Base_SMP_a_Brief_Description_of_the_Load_ Balancer.docx
kernelhwsrv_info/doc_pub/Base_SMP_a_Brief_Description_of_the_Load_Balancer.docx
kerneltest/e32test/active/t_ctimer.cpp
kerneltest/e32test/bench/d_kernasmfnc.cpp
kerneltest/e32test/buffer/t_bflat.cpp
kerneltest/e32test/buffer/t_bma.cpp
kerneltest/e32test/buffer/t_buf.cpp
kerneltest/e32test/buffer/t_circ.cpp
kerneltest/e32test/buffer/t_farray.cpp
kerneltest/e32test/buffer/t_parray.cpp
kerneltest/e32test/demandpaging/t_pagetable_limit.cpp
kerneltest/e32test/group/bld.inf
kerneltest/e32test/group/d_khal.mmp
kerneltest/e32test/group/t_atomicu.mmp
kerneltest/e32test/group/t_khal.mmp
kerneltest/e32test/group/t_reason2.mmp
kerneltest/e32test/misc/t_zip.cpp
kerneltest/e32test/mmu/freeram.h
kerneltest/e32test/pccd/t_medch.cpp
kerneltest/e32test/rm_debug/debug_targets/t_rmdebug_app.cpp
kerneltest/e32test/rm_debug/multi_agent_tests/t_multi_agent.cpp
kerneltest/e32test/system/d_khal.cpp
kerneltest/e32test/system/d_khal.h
kerneltest/e32test/system/t_atomicu.cpp
kerneltest/e32test/system/t_cobj.cpp
kerneltest/e32test/system/t_ctrap.cpp
kerneltest/e32test/system/t_inf.cpp
kerneltest/e32test/system/t_khal.cpp
kerneltest/e32test/system/t_reason2.cpp
kerneltest/f32test/server/t_dspace.cpp
kerneltest/f32test/server/t_nmbs.cpp
package_map.xml
userlibandfileserver/fileserver/group/release.txt
userlibandfileserver/fileserver/inc/f32ver.h
userlibandfileserver/fileserver/sfat32/inc/sl_std.h
userlibandfileserver/fileserver/sfat32/sl_file.cpp
userlibandfileserver/fileserver/sfile/sf_file.cpp
userlibandfileserver/fileserver/sfile/sf_request.cpp
userlibandfileserver/fileserver/sfile/sf_std.h
--- a/halservices/hal/bld.inf	Mon Jul 12 14:24:01 2010 +0100
+++ b/halservices/hal/bld.inf	Mon Jul 26 10:52:56 2010 +0100
@@ -41,9 +41,6 @@
 rom/haltests.iby		/epoc32/rom/include/haltests.iby
 rom/haltests.auto.bat	/epoc32/rom/include/haltests.auto.bat
 
-rom/tshell_haltests.oby	 ../../kernel/eka/rombuild/tshell_haltests.oby
-
-
 
 PRJ_MMPFILES
 src/hal_lib
--- a/kernel/eka/common/mem.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/common/mem.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -26,6 +26,8 @@
 
 extern "C" {
 
+#ifndef __MEMMOVE_MACHINE_CODED__
+
 // See header file e32cmn.h for the in-source documentation.
 EXPORT_C TAny* memcpy(TAny* aTrg, const TAny* aSrc, unsigned int aLength)
 	{
@@ -74,7 +76,7 @@
 	return aTrg;
 	}
 
-
+#endif // ! __MEMMOVE_MACHINE_CODED__
 
 // See header file e32cmn.h for the in-source documentation.
 EXPORT_C TAny* memclr(TAny* aTrg, unsigned int aLength)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/eka/common/win32/cmem.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,142 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32\common\win32\cmem.cpp
+//
+//
+
+#include "common.h"
+
+#ifdef __MEMMOVE_MACHINE_CODED__
+
+extern "C" {
+
+// See header file e32cmn.h for the in-source documentation.
+EXPORT_C __NAKED__ TAny* memmove(TAny* , const TAny* , unsigned int)
+	{
+	_asm push      ebx							; // Save used registers
+	_asm push      esi
+	_asm push      edi
+	_asm push      ebp
+
+	_asm cmp       dword ptr [esp+0x1c],0x0		; // Is aLength == 0?
+	_asm mov       eax,dword ptr [esp+0x14]		; // Ptr to destination
+	_asm mov       ebx,dword ptr [esp+0x18]		; // Ptr to source
+	_asm je        End							; // aLength is 0, just return
+
+	_asm mov       ecx,eax						; // Copy destination
+	_asm xor       ebp,ebp						; // ebp = 0
+	_asm test      ecx,0x3						; // Dest word aligned?
+	_asm mov       edx,ebx						; // Copy ptr to source
+	_asm jne       Misaligned					; // No
+	_asm test      edx,0x3						; // Source word aligned?
+	_asm jne       Misaligned					; // No
+	_asm mov       ebp,dword ptr [esp+0x1c]		; // ebp = aLength
+	_asm shr       ebp,0x2						; // ebp = aLength in words
+
+Misaligned:
+
+	_asm lea       edx,dword ptr [ebp*4+0x0]	; // edx = aLength in words
+	_asm sal       ebp,0x2						; // ebp = aLength in bytes
+	_asm add       ebp,ecx						; // Point to end of destination
+	_asm mov       edi,dword ptr [esp+0x1c]		; // Get number of bytes to copy
+	_asm sub       edi,edx						; // Find remainder (aLength % 3)
+	_asm cmp       eax,ebx						; // Dest >= source?
+	_asm mov       edx,ebp						; // Ptr to end of destination
+	_asm jae       DoDescendingCopy				; // Yes, copy downwards
+
+	_asm jmp       AscendingCopy				; // No, copy upwards
+
+AscendingCopyLoop:
+
+	_asm mov       ebp,dword ptr [ebx]			; // Get a word
+	_asm mov       dword ptr [ecx],ebp			; // And store it
+	_asm add       ebx,0x4						; // Increment source by a word
+	_asm add       ecx,0x4						; // Increment destination by a word
+
+AscendingCopy:
+
+	_asm cmp       ecx,edx						; // Still data to copy?
+	_asm jb        AscendingCopyLoop			; // Yes
+
+	_asm mov       ebp,eax						; // Copy ptr to destination
+	_asm add       ebp,dword ptr [esp+0x1c]		; // Point to end of destination
+	_asm jmp       CopyRemainder				; // Copy left over (aLength % 3) bytes
+
+CopyRemainderLoop:
+
+	_asm movzx     edx,byte ptr [ebx]			; // Get a byte
+	_asm mov       byte ptr [ecx],dl			; // And store it
+	_asm inc       ebx							; // Increment source by a byte
+	_asm inc       ecx							; // Increment destination by a byte
+
+CopyRemainder:
+
+	_asm cmp       ecx,ebp						; // Any remaining bytes to copy?
+	_asm jb        CopyRemainderLoop			; // Yes, go do it
+
+	_asm jmp       End							; // All done
+
+DoDescendingCopy:
+
+	_asm cmp       eax,ebx						; // Still data to copy?
+	_asm jbe       End							; // No, all done
+
+	_asm lea       esi,dword ptr [edi+ebp]		; // Get ptr to end of destination
+	_asm mov       edi,ebx						; // Get ptr to source
+	_asm add       edi,dword ptr [esp+0x1c]		; // Point to end of source
+	_asm jmp       DescendingCopyRemainder		; // Copy copy some data
+
+DescendingCopyRemainderLoop:
+
+	_asm dec       edi							; // Decrement source by a byte
+	_asm dec       esi							; // Decrement dest by a byte
+	_asm movzx     ebx,byte ptr [edi]			; // Get a byte
+	_asm mov       byte ptr [esi],bl			; // And store it
+
+DescendingCopyRemainder:
+
+	_asm cmp       esi,ebp						; // Still data to copy?
+	_asm ja        DescendingCopyRemainderLoop	; // Yes, go do it
+
+	_asm jmp       DescendingCopy				; // Go copy the bulk of the data
+
+DescendingCopyLoop:
+
+	_asm sub       edi,0x4						; // Decrement source by a word
+	_asm sub       edx,0x4						; // Decrement dest by a word
+	_asm mov       ebx,dword ptr [edi]			; // Get a word
+	_asm mov       dword ptr [edx],ebx			; // And store it
+
+DescendingCopy:
+
+	_asm cmp       edx,ecx						; // Still data to copy
+	_asm ja        DescendingCopyLoop			; // Yes, go do it
+
+End:
+
+	_asm pop       ebp							; // Restore used registers
+	_asm pop       edi
+	_asm pop       esi
+	_asm pop       ebx
+	_asm ret
+	}
+
+// See header file e32cmn.h for the in-source documentation.
+EXPORT_C __NAKED__ TAny* memcpy(TAny* , const TAny* , unsigned int)
+	{
+	__asm jmp (memmove);						; // memmove() will perform the same function
+	}
+}
+
+#endif // defined(__MEMMOVE_MACHINE_CODED__)
--- a/kernel/eka/drivers/dma/dma2_pil.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/drivers/dma/dma2_pil.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -1863,11 +1863,14 @@
 	iChannel.Wait();
 
 	TUint32 req_count = iChannel.iQueuedRequests++;
-	if (req_count == 0)
+	if (iChannel.iCallQueuedRequestFn)
 		{
-		iChannel.Signal();
-		iChannel.QueuedRequestCountChanged();
-		iChannel.Wait();
+		if (req_count == 0)
+			{
+			iChannel.Signal();
+			iChannel.QueuedRequestCountChanged();
+			iChannel.Wait();
+			}
 		}
 
 	TInt r = KErrGeneral;
@@ -1883,9 +1886,12 @@
 		req_count = --iChannel.iQueuedRequests;
 		__DMA_INVARIANT();
 		iChannel.Signal();
-		if (req_count == 0)
+		if (iChannel.iCallQueuedRequestFn)
 			{
-			iChannel.QueuedRequestCountChanged();
+			if (req_count == 0)
+				{
+				iChannel.QueuedRequestCountChanged();
+				}
 			}
 		}
 	else if (iIsrCb && !iChannel.IsQueueEmpty())
@@ -1899,9 +1905,12 @@
 		req_count = --iChannel.iQueuedRequests;
 		__DMA_INVARIANT();
 		iChannel.Signal();
-		if (req_count == 0)
+		if (iChannel.iCallQueuedRequestFn)
 			{
-			iChannel.QueuedRequestCountChanged();
+			if (req_count == 0)
+				{
+				iChannel.QueuedRequestCountChanged();
+				}
 			}
 		}
 	else if (iChannel.iIsrDfc & (TUint32)TDmaChannel::KCancelFlagMask)
@@ -1911,9 +1920,12 @@
 		req_count = --iChannel.iQueuedRequests;
 		__DMA_INVARIANT();
 		iChannel.Signal();
-		if (req_count == 0)
+		if (iChannel.iCallQueuedRequestFn)
 			{
-			iChannel.QueuedRequestCountChanged();
+			if (req_count == 0)
+				{
+				iChannel.QueuedRequestCountChanged();
+				}
 			}
 		}
 	else
@@ -2275,6 +2287,7 @@
 	  iReqQ(),
 	  iReqCount(0),
 	  iQueuedRequests(0),
+	  iCallQueuedRequestFn(ETrue),
 	  iCancelInfo(NULL),
 	  iRedoRequest(EFalse),
 	  iIsrCbRequest(EFalse)
@@ -2476,9 +2489,12 @@
 
 	// Only call PSL if there were requests queued when we entered AND there
 	// are now no requests left on the queue.
-	if ((req_count_before != 0) && (req_count_after == 0))
+	if (iCallQueuedRequestFn)
 		{
-		QueuedRequestCountChanged();
+		if ((req_count_before != 0) && (req_count_after == 0))
+			{
+			QueuedRequestCountChanged();
+			}
 		}
 
 	__DMA_INVARIANT();
@@ -2790,9 +2806,12 @@
 	// Only call PSL if there were requests queued when we entered AND there
 	// are now no requests left on the queue (after also having executed all
 	// client callbacks).
-	if ((req_count_before != 0) && (req_count_after == 0))
+	if (iCallQueuedRequestFn)
 		{
-		QueuedRequestCountChanged();
+		if ((req_count_before != 0) && (req_count_after == 0))
+			{
+			QueuedRequestCountChanged();
+			}
 		}
 
 	__DMA_INVARIANT();
@@ -2849,14 +2868,11 @@
 /** PSL may override */
 void TDmaChannel::QueuedRequestCountChanged()
 	{
-#ifdef _DEBUG
+	__KTRACE_OPT(KDMA, Kern::Printf("TDmaChannel::QueuedRequestCountChanged(): "
+									"disabling further calls"));
 	Wait();
-	__KTRACE_OPT(KDMA,
-				 Kern::Printf("TDmaChannel::QueuedRequestCountChanged() %d",
-							  iQueuedRequests));
-	__DMA_ASSERTA(iQueuedRequests >= 0);
+	iCallQueuedRequestFn = EFalse;
 	Signal();
-#endif
 	}
 
 
--- a/kernel/eka/drivers/dma/dmapil.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/drivers/dma/dmapil.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -13,7 +13,7 @@
 // Description:
 // e32\drivers\dmapil.cpp
 // DMA Platform Independent Layer (PIL)
-// 
+//
 //
 
 #include <drivers/dma.h>
@@ -477,11 +477,14 @@
 	iChannel.Wait();
 
 	TUint32 req_count = iChannel.iQueuedRequests++;
-	if (req_count == 0)
+	if (iChannel.iCallQueuedRequestFn)
 		{
-		iChannel.Signal();
-		iChannel.QueuedRequestCountChanged();
-		iChannel.Wait();
+		if (req_count == 0)
+			{
+			iChannel.Signal();
+			iChannel.QueuedRequestCountChanged();
+			iChannel.Wait();
+			}
 		}
 
 	if (!(iChannel.iIsrDfc & (TUint32)TDmaChannel::KCancelFlagMask))
@@ -500,9 +503,12 @@
 		req_count = --iChannel.iQueuedRequests;
 		__DMA_INVARIANT();
 		iChannel.Signal();
-		if (req_count == 0)
+		if (iChannel.iCallQueuedRequestFn)
 			{
-			iChannel.QueuedRequestCountChanged();
+			if (req_count == 0)
+				{
+				iChannel.QueuedRequestCountChanged();
+				}
 			}
 		}
 	}
@@ -628,6 +634,7 @@
 	  iReqQ(),
 	  iReqCount(0),
 	  iQueuedRequests(0),
+	  iCallQueuedRequestFn(ETrue),
 	  iCancelInfo(NULL)
 	{
 	__DMA_INVARIANT();
@@ -760,9 +767,12 @@
 
 	// Only call PSL if there were requests queued when we entered AND there
 	// are now no requests left on the queue.
-	if ((req_count_before != 0) && (req_count_after == 0))
+	if (iCallQueuedRequestFn)
 		{
-		QueuedRequestCountChanged();
+		if ((req_count_before != 0) && (req_count_after == 0))
+			{
+			QueuedRequestCountChanged();
+			}
 		}
 
 	__DMA_INVARIANT();
@@ -942,9 +952,12 @@
 	// Only call PSL if there were requests queued when we entered AND there
 	// are now no requests left on the queue (after also having executed all
 	// client callbacks).
-	if ((req_count_before != 0) && (req_count_after == 0))
+	if (iCallQueuedRequestFn)
 		{
-		QueuedRequestCountChanged();
+		if ((req_count_before != 0) && (req_count_after == 0))
+			{
+			QueuedRequestCountChanged();
+			}
 		}
 
 	__DMA_INVARIANT();
@@ -972,14 +985,11 @@
 /** PSL may override */
 void TDmaChannel::QueuedRequestCountChanged()
 	{
-#ifdef _DEBUG
+	__KTRACE_OPT(KDMA, Kern::Printf("TDmaChannel::QueuedRequestCountChanged(): "
+									"disabling further calls"));
 	Wait();
-	__KTRACE_OPT(KDMA,
-				 Kern::Printf("TDmaChannel::QueuedRequestCountChanged() %d",
-							  iQueuedRequests));
-	__DMA_ASSERTA(iQueuedRequests >= 0);
+	iCallQueuedRequestFn = EFalse;
 	Signal();
-#endif
 	}
 
 
--- a/kernel/eka/include/cpudefs.h	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/include/cpudefs.h	Mon Jul 26 10:52:56 2010 +0100
@@ -198,8 +198,9 @@
 
 #if defined(__WINS__)
 #define __NAKED__ __declspec( naked )
-#ifndef __MINIMUM_MACHINE_CODE__
-//#define __MEM_MACHINE_CODED__
+#if !defined(__MINIMUM_MACHINE_CODE__) && defined(__KERNEL_MODE__)
+// Assembly language memmove() and memcpy() are used for WINS but only in the kernel, not euser
+#define __MEMMOVE_MACHINE_CODED__
 #endif
 #define __CPU_X86
 #endif
--- a/kernel/eka/include/drivers/dma_v1.h	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/include/drivers/dma_v1.h	Mon Jul 26 10:52:56 2010 +0100
@@ -279,13 +279,7 @@
 		TUint32 iCookie;
 		/** Number of descriptors this channel can use */
 		TInt iDesCount;
-		/** DFC queue used to service DMA interrupts.  The DFC thread
-			priority must be higher than any client thread priority to
-			avoid a situation where a transfer completes while being
-			cancelled and another transfer is started before the DFC
-			thread gets a chance to run.  This would lead to a stray
-			DFC.
-		*/
+		/** DFC queue used to service DMA interrupts */
 		TDfcQue* iDfcQ;
 		/** DFC priority */
 		TUint8 iDfcPriority;
@@ -437,6 +431,7 @@
 	SDblQue iReqQ;											// being/about to be transferred request queue
 	TInt iReqCount;											// number of requests attached to this channel
 	TInt iQueuedRequests; 									// number of requests currently queued on this channel
+	TBool iCallQueuedRequestFn;								// call QueuedRequestCountChanged? (default: true)
 private:
 	TDmaCancelInfo* iCancelInfo;
 	__DMA_DECLARE_INVARIANT
--- a/kernel/eka/include/drivers/dma_v2.h	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/include/drivers/dma_v2.h	Mon Jul 26 10:52:56 2010 +0100
@@ -747,11 +747,6 @@
 		TInt iDesCount;
 		/** DFC queue used to service DMA interrupts.
 
-			The DFC thread priority must be higher than any client thread
-			priority to avoid a situation where a transfer completes while
-			being cancelled and another transfer is started before the DFC
-			thread gets a chance to run. This would lead to a stray DFC.
-
 			@released
 		*/
 		TDfcQue* iDfcQ;
@@ -1291,6 +1286,7 @@
 	SDblQue iReqQ;			// being/about to be transferred request queue
 	TInt iReqCount;			// number of requests attached to this channel
 	TInt iQueuedRequests; 	// number of requests currently queued on this channel
+	TBool iCallQueuedRequestFn;	// call QueuedRequestCountChanged? (default: true)
 
 private:
 	TDmaCancelInfo* iCancelInfo; // ...
--- a/kernel/eka/include/e32ver.h	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/include/e32ver.h	Mon Jul 26 10:52:56 2010 +0100
@@ -28,7 +28,7 @@
 
 const TInt KE32MajorVersionNumber=2;
 const TInt KE32MinorVersionNumber=0;
-const TInt KE32BuildVersionNumber=3107;
+const TInt KE32BuildVersionNumber=3109;
 
 const TInt KMachineConfigurationMajorVersionNumber=1;
 const TInt KMachineConfigurationMinorVersionNumber=0;
--- a/kernel/eka/kernel/ekern.mmp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/kernel/ekern.mmp	Mon Jul 26 10:52:56 2010 +0100
@@ -135,6 +135,10 @@
 source					 ckernel.cpp csched.cpp
 source					 cutils.cpp cache.cpp
 
+sourcepath				../common/win32
+userinclude				../common
+source					cmem.cpp
+
 library					emulator.lib
 #endif
 
--- a/kernel/eka/release.txt	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/release.txt	Mon Jul 26 10:52:56 2010 +0100
@@ -1,3 +1,44 @@
+Version 2.00.3108
+=================
+(Made by fadhliM 19/07/2010)
+
+1.	mipetzol
+	1.	ou1cimx1#467351 DMA PIL doesn't check client thread priorities
+	2.	ou1cimx1#467653 DMA PIL: Unnecessary calls to empty virtual function
+
+2.	mmoate
+	1.	ou1cimx1#422063 MCL Test Code Coverage Improvement Phase 1
+
+3.	garciato
+	1.	MINOR_CHANGE Corrections to document and diagram and corrected file name
+
+4.	jcoppear
+	1.	ou1cimx1#460995 ENV E32TEST T_PAGETABLE_LIMIT test failure investigation (t_pagetable_limit.cpp:276)
+
+5.	fagortz
+	1.	ou1cimx1#479558 t_medch does not find suitable drive for test if pagingMediaCheck is false
+
+6.	ferporta
+	1.	ou1cimx1#480991 10.1 Component build failures with f32file.h platform header removal changes
+
+
+Version 2.00.3108
+=================
+(Made by famustaf 12/07/2010)
+
+1.	coliward
+	1.	ou1cimx1#457854 Kernel's memmove() routine needs optimising for Win32 UDEB builds
+
+2.	stmansfi
+	1.	ou1cimx1#468733 ENV Remove unnecessary test exports
+
+3.	jimhofe
+	1.	MINOR_CHANGE Adding pkgdefs file for mounting the filesystem from the synergy package
+
+4.	niccox
+	1.	ou1cimx1#474990 h4usbtest.iby is missing t_usb_transfersrv.dll
+
+
 Version 2.00.3107
 =================
 (Made by famustaf 07/07/2010)
--- a/kernel/eka/rombuild/h4usbtest.iby	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/rombuild/h4usbtest.iby	Mon Jul 26 10:52:56 2010 +0100
@@ -30,6 +30,7 @@
 file=EPOCROOT##epoc32\release\##MAIN##\##BUILD##\t_usb_device.exe			sys\bin\t_usb_device.exe
 file=EPOCROOT##epoc32\release\##MAIN##\##BUILD##\t_usb_scdevice.exe			sys\bin\t_usb_scdevice.exe
 file=EPOCROOT##epoc32\release\##MAIN##\##BUILD##\t_usbcsc.exe				sys\bin\t_usbcsc.exe
+file=EPOCROOT##epoc32\release\##MAIN##\##BUILD##\t_usb_transfersrv.dll		sys\bin\t_usb_transfersrv.dll
 
 REM t_usb_device xml configuration files
 
Binary file kernelhwsrv_info/doc_pub/Base_SMP_a_Brief_Description_of_the_Load_ Balancer.docx has changed
Binary file kernelhwsrv_info/doc_pub/Base_SMP_a_Brief_Description_of_the_Load_Balancer.docx has changed
--- a/kerneltest/e32test/active/t_ctimer.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/active/t_ctimer.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -28,6 +28,7 @@
 // and check for panic.
 // - Call absolute timer's At function without adding it to the active scheduler and 
 // check for panic.
+// - Call 1s inactivity timer
 // - Check if heap has been corrupted by the tests.
 // Platforms/Drives/Compatibility:
 // All.
@@ -77,6 +78,15 @@
 	static TInt iTotalCount;
 	};
 
+// for inactivity test
+class myInactTimer : public CTimer
+	{
+public:
+	myInactTimer(const TInt aPriority):CTimer(aPriority){;}
+	void RunL(void);	
+	void Start(void);
+	};
+
 TInt myTimer::iTotalCount;
 TInt myTimer::iNum;
 
@@ -108,6 +118,23 @@
 	CActiveScheduler::Add(this);
 	}
 
+void myInactTimer::RunL(void)
+//
+// Timer has completed
+//
+	{
+	CActiveScheduler::Stop();
+	}
+
+void myInactTimer::Start(void)
+//
+// Start a timer going.
+//
+	{
+	ConstructL();
+	CActiveScheduler::Add(this);
+	}
+
 LOCAL_D TInt ThreadEntry(TAny* aDirective)
 //
 // Test thread
@@ -197,12 +224,22 @@
 	CActiveScheduler::Start();
 	test(A[0]==ID1 && pTimer1->iStatus==KErrNone);
 //
-
+	test.Next(_L("Inactivity 1s"));
+	User::ResetInactivityTime();
+	myInactTimer* pInactTimer=new myInactTimer(0);
+	pInactTimer->Start();
+	test.Printf(_L("inactivity..."));
+	pInactTimer->Inactivity(1);
+	CActiveScheduler::Start();
+	test.Printf(_L("...back"));
+	test(pInactTimer->iStatus==KErrNone);
+//
 	test.Next(_L("Destroy objects"));
 	delete pTimer1;
 	delete pTimer2;
 	delete pTimer3;
 	delete pRepeater;
+	delete pInactTimer;
 //
 	test.End();
 	}
--- a/kerneltest/e32test/bench/d_kernasmfnc.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/bench/d_kernasmfnc.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -262,7 +262,7 @@
 
 DEFINE_BENCHMARK(TPriList_HighestPri,
 				 TPriListLink link(15); PriList.Add(&link),
-				 PriList.First(),
+				 PriList.HighestPriority(),
 				 PriList.Remove(&link));
 
 DEFINE_BENCHMARK(TPriList_ChangePri,
--- a/kerneltest/e32test/buffer/t_bflat.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/buffer/t_bflat.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -18,7 +18,7 @@
 // CBufFlat.
 // Details:
 // - Test all the operations of the class and see if methods are implemented -- 
-// including NewL, Reset, Size, Set Reserve, InsertL, Delete, Ptr, Read, Write and Compress.
+// including NewL, Reset, Size, Set Reserve, InsertL, Delete, Ptr, Read, ResizeL, Write and Compress.
 // - Test CBufFlat constructor is as expected.
 // - Insert data into the flat storage dynamic buffer and verify that InsertL method
 // is as expected.
@@ -106,11 +106,13 @@
 	bf1->InsertL(5,tb1);
 	bf1->Delete(16,bf1->Size()-16);
 	test(bf1->Ptr(0)==TPtrC8((TText8*)"HelloHello World"));
+	bf1->InsertL(10,tb1,5);
+	test(bf1->Ptr(0)==TPtrC8((TText8*)"HelloHelloHello World"));
 //
 	test.Next(_L("SetReserve"));
 	bf1->SetReserveL(50); // SetReserve > 0
-	test(bf1->Size()==16);
-	test(bf1->Ptr(0).Length()==16);
+	test(bf1->Size()==21);
+	test(bf1->Ptr(0).Length()==21);
 	bf1->Reset();
 	bf1->SetReserveL(0); // SetReserve = 0
 	test(bf1->Size()==0);
@@ -136,10 +138,23 @@
 	bf1->Compress(); // Compress
 	test(bf1->Size()==7);
 
-	test.Next(_L("Read"));
+	test.Next(_L("Read, Resize"));
 	bf1->Read(4,tb1,bf1->Size()-4);
 	test(tb1.Size()==3);
 	test(tb1==TPtrC8((TText8*)"lol"));
+	TBuf8<0x10> tb4=(TText8*)"Hello Hello Sun ";;
+	TBuf8<0x10> tb5;
+	test(bf1->Size()==7);
+	bf1->ResizeL(64); // ResizeL
+	test(bf1->Size()==64);
+	bf1->Write(0,tb4,16);
+	bf1->Write(16,tb4,16);
+	bf1->Write(32,tb4,16);
+	bf1->Write(48,tb4,16);
+	bf1->Read(0,tb5); //Reads maxlength of tb5 that is 16
+	bf1->Read(0,tb3); //Reads maxlength of tb3 that is 64
+	test(tb5==TPtrC8((TText8*)"Hello Hello Sun "));
+	test(tb3==TPtrC8((TText8*)"Hello Hello Sun Hello Hello Sun Hello Hello Sun Hello Hello Sun "));
 //
 	test.End();
 	}
--- a/kerneltest/e32test/buffer/t_bma.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/buffer/t_bma.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -157,14 +157,31 @@
 		pBitMapAllocator->Free(i);
 	test(pBitMapAllocator->Avail()==pBitMapAllocator->Size());
 //
+	test.Next(_L("AllocFrom"));
+	i=0;
+	for (;i<available;i++)
+		{
+		TInt j=pBitMapAllocator->AllocFrom(i);
+		test(j==i);
+		}
+	test(pBitMapAllocator->Avail()==0);
+
+	test.Next(_L("Try AllocFrom for already allocated pos")); //should return KErrNoMemory
+	TInt j=pBitMapAllocator->AllocFrom(i-1);
+	test(j==KErrNoMemory);
+
+	test.Next(_L("Free (again)"));
+	for (i=0;i<available;i++)
+		{
+		pBitMapAllocator->Free(i);
+		}
+	test(pBitMapAllocator->Avail()==pBitMapAllocator->Size());
+//
+
 	test.Next(_L("AllocAt"));
 	pBitMapAllocator->AllocAt(aSize-1);
 	test(pBitMapAllocator->Avail()==pBitMapAllocator->Size()-1);
-//
-//	test.Next(_L("AllocAt an already allocated cell"));	// this test should cause a Panic.
-//	pBitMapAllocator->AllocAt(aSize-1);
-//	test(pBitMapAllocator->Avail()==pBitMapAllocator->Size()-1);
-//
+
 	test.Next(_L("Free (again)"));
 	pBitMapAllocator->Free(aSize-1);
 	test(pBitMapAllocator->Avail()==pBitMapAllocator->Size());
--- a/kerneltest/e32test/buffer/t_buf.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/buffer/t_buf.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -74,6 +74,7 @@
 #include <hal_data.h>
 #include <hal_data.h>
 #include <e32svr.h>
+#include <collate.h> 
 
 #ifdef __VC32__
     // Solve compilation problem caused by non-English locale
@@ -299,6 +300,9 @@
 	a.Zero();
 	a.AppendJustify(_TL("AB"),10,ELeft,' ');
 	a.AppendJustify(b,10,ELeft,' ');
+	a.AppendJustify(b,10,KDefaultJustifyWidth,ELeft,' ');
+	a.AppendJustify(b.Ptr(),10,ELeft,' ');
+	
 	TInt v1=10;
 	a.Num(v1);
 	a.AppendNum(v1);
@@ -307,6 +311,25 @@
 	a.AppendNum((TUint)v2,EHex);
 	a.NumUC((TUint)v2,EHex);
 	a.AppendNumUC((TUint)v2,EHex);
+	
+	//Converts the specified unsigned integer into a fixed width character representation
+	//based on the specified number system and copies the conversion into this descriptor,
+	//replacing any existing data. The length of this descriptor is set to reflect the new data.
+	a.NumFixedWidth(v1,EBinary,4); 
+	a.NumFixedWidth(v1,EOctal,3);
+	a.NumFixedWidth(v1,EDecimal,2);
+	a.NumFixedWidth(v1,EHex,1);
+	//When a hexadecimal conversion is specified, hexadecimal characters are in upper case.
+	a.NumFixedWidthUC(v1,EBinary,4);
+	a.NumFixedWidthUC(v1,EOctal,3);
+	a.NumFixedWidthUC(v1,EDecimal,2);
+	a.NumFixedWidthUC(v1,EHex,1);
+	//Appends the conversion onto the end of this descriptor's data.
+	a.AppendNumFixedWidthUC(v1,EBinary,4);
+	a.AppendNumFixedWidthUC(v1,EOctal,3);
+	a.AppendNumFixedWidthUC(v1,EDecimal,2);
+	a.AppendNumFixedWidthUC(v1,EHex,1); 
+	
 	TReal v3=10.0;
 	TRealFormat ff;
 	ff.iType=KRealFormatFixed;
@@ -1895,6 +1918,134 @@
 	lang = User::Language();
 	test(lang == defaultLang);
 	}
+
+// Test the surrogate aware version functions of the class. 
+GLDEF_C void SurrogateAware1()
+    {
+    test.Start(_L("Constructors"));
+    TBuf16<0x50> a;
+    TBuf16<0x50> b;
+    TBuf16<0x50> c;
+    TBuf16<0x50> d;
+    
+    a=_L("ABCD");
+    b=_L("abcd");
+    // Cannot define these on GCC (X86).
+	#if !(defined(__GCC32__) && defined(__X86__))
+    c=_L("àáâãäåçèéêëìíîïñòóôõöùúûüý");
+    d=_L("ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ");
+    #else
+    c=_L("aaaaaaceeeeiiiinooooouuuuy");
+    d=_L("AAAAAACEEEEIIIINOOOOOUUUUY");
+    #endif
+ 
+    test.Next(_L("Fill2"));
+    TInt maxBufLength=a.MaxLength();
+    a.Fill2(' ');
+    a.Fill2(' ',maxBufLength);
+    a.Fill2('z');
+    a.Fill2('*',maxBufLength);
+    a=c;
+    b=d;
+    a.Swap(b);
+    test(a==d);
+
+    test.Next(_L("Conversion 2"));
+    a.Fold2();
+    b.Collate2();
+    a.UpperCase2();
+    a.LowerCase2();
+    a.Capitalize2();
+    b.Capitalize2();
+    
+    test.Next(_L("Locating"));
+    a=_L("ABCDabcd");
+    test(a.Locate('A')==0);
+    test(a.LocateF('b')==1);
+    test(a.LocateReverse('A')==0);
+    test(a.LocateReverse('a')==4);
+    test(a.LocateReverse('b')==5);
+
+    test.Next(_L("Copying"));
+    a.Copy(b); // Copies a 16 bit descriptor
+    a.Copy(_L("AB")); 
+    a.Copy(b.Ptr(),3); // Copies aLength characters from the aBuf pointer
+    a.CopyF2(c); // Copies and folds
+    a.CopyF2(_L("AB"));
+    a.CopyC2(d); // Copies and collates
+    a.CopyC2(_L("AB"));
+    a.CopyLC(d); // Copies and converts the text to lower case
+    a.CopyLC(_L("AB"));
+    a.CopyUC2(c); // Copies and converts the text to upper case
+    a.CopyUC2(_L("AB"));
+    a.CopyCP2(b); // Copies and capitalizes the text
+    a.CopyCP2(_L("AB"));
+    
+    test.Next(_L("Finding"));
+    a=_L("ABCDabcd");
+    b=_L("bc");
+    test(a.Find(b)==5);
+    test(a.Find(_L("ab"))==4);
+    test(a.FindF(b)==1);
+    test(a.FindF(_L("ab"))==0);
+    test(a.FindC(b)==1);
+    test(a.FindC(_L("AB"))==0);
+    test(a.FindC(b.Ptr(), b.Length(), 3)==1);
+    test(a.FindC(b.Ptr(), b.Length(), 2)==1);
+    test(a.FindC(b.Ptr(), b.Length(), 1)==1);
+    test(a.FindC(b.Ptr(), b.Length(), 0)==1); 
+    test(a.FindF(b.Ptr(), b.Length())==1);
+    
+    test.Next(_L("Formating"));
+    TInt width = 10;
+    a.Justify2(_L("AB"),width,ELeft,' ');
+    a.Justify2(b,10,ELeft,' ');
+    b.Fill2('A',2);
+    a.Zero();
+    a.AppendJustify2(_L("AB"),width,ELeft,' ');
+    a.AppendJustify2(b,width,ELeft,' ');
+    a=_L("ABCDE");
+    b=_L("abcde");
+    a.AppendJustify2(b,width,ELeft,'*');
+    a.AppendJustify2(b.Ptr(),width,ELeft,'*');
+    // Append and justify with explicit length
+    TInt length = 5;
+    a.AppendJustify2(b,length,KDefaultJustifyWidth,ELeft,'*');
+    a.AppendJustify2(b.Ptr(),length,KDefaultJustifyWidth,ELeft,'*');
+    
+    TCollationMethod cm = *Mem::CollationMethodByIndex( 0 ); // default collation method
+    cm.iFlags |= TCollationMethod::EIgnoreNone;
+    TDesC::TPrefix prefix = a.HasPrefixC(a, 0, &cm);
+    test(prefix==TDesC16::EIsPrefix);
+    test.End();
+    }
+
+// Test the surrogate aware versions of conversion operators (test7) 
+// 
+void SurrogateAware7()
+    {
+    test.Start(_L("Fold2, Collate2 ..."));
+    TBuf16<0x50> a;
+    TBuf16<0x50> b;
+    a=_L("abc AbC");
+    b=_L("ABC ABC");
+    a.Fold2();
+    b.Fold2();
+    test(a==b);
+    a=_L("abc AbC");
+    b=_L("ABC ABC");
+    a.Collate2();
+    b.Collate2();
+    test(a==b);
+    a.UpperCase2();
+    test(a==_L("ABC ABC"));
+    a.LowerCase2();
+    test(a==_L("abc abc"));
+    a.Capitalize2();
+    test(a==_L("Abc abc"));
+    test.End();
+    }
+
 #ifndef _DEBUG
 #pragma warning( disable : 4702) //Unreachable code
 #pragma warning( disable : 4710) //Function not expanded
@@ -1930,6 +2081,12 @@
 
 	test.Next(_L("INC061330"));
 	INC061330();
+	
+	test.Next(_L("Surrogate aware version"));
+	SurrogateAware1();
+	    
+	test.Next(_L("Surrogate aware version"));
+	SurrogateAware7();
 
 	test.End();
 
--- a/kerneltest/e32test/buffer/t_circ.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/buffer/t_circ.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -232,6 +232,34 @@
 			test(Mem::Compare(buf,arraySize,theCharArray,arraySize)==KErrNone);
 			}
 		}
+	
+	// Test Reset, Put and Get
+	TInt count = cbInt->Count();
+	test(count>0);
+	cbInt->Reset();
+	count = cbInt->Count();
+	test(count==0);
+	TUint index = 0;
+	
+	// Put 100 integers to the circular buffer.
+	TUint numberOfObjects= 100;
+	for(index=1;index<=numberOfObjects; index++)
+	    {
+	    TInt result= cbInt->Put(index);
+	    User::LeaveIfError(result);
+	    }
+	count = cbInt->Count();
+	test(count==100);
+	
+	// Get 50 integers from the circular buffer.
+	for(index=1;index<=(numberOfObjects/2); index++)
+	    {
+	    TUint cb = cbInt->Get();
+	    test(cb==index);
+	    }
+	count = cbInt->Count();
+	test(count==50);
+		
 	delete [] buf;
 	delete cbInt;
 	}
--- a/kerneltest/e32test/buffer/t_farray.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/buffer/t_farray.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -157,6 +157,30 @@
 			}
 		test(&aFix[index3-1]==--ptr);
 		}
+	
+	//Test ExpandL
+	//Expand array in slot 1
+	TBuf16<0x10> exp;
+	exp=_L("abc AbC");
+	aFix.InsertL(0,exp);
+	aFix.InsertL(1,exp);
+	aFix.InsertL(2,exp);
+	exp=aFix.ExpandL(1);
+	test(aFix[0]==_L("abc AbC"));
+	test(aFix[1]==_L(""));
+	test(aFix[2]==_L("abc AbC"));
+	test(aFix[3]==_L("abc AbC"));
+	
+	//Test ResizeL and InsertReplL
+	//Resize the array to containing 20 records,
+	//copying a record into any new slots.
+	TBuf<0x10> res(_L("bbbbb"));
+	aFix.Reset();
+	aFix.ResizeL(20,res);
+	for(TInt i=0;i<20;i++)
+	    {
+        test(aFix[1]==_L("bbbbb"));
+	    }
 	}
 
 LOCAL_C void test1(CArrayFix<TText>& aFix)
@@ -342,6 +366,13 @@
 	CArrayFixFlat<TInt>* pFixFlatInt=new CArrayFixFlat<TInt>(KTestGranularity);
 	test3(*pFixFlatInt);
 	delete pFixFlatInt;
+	
+	CArrayFixFlat<TUid>* pFixFlatTUid=new CArrayFixFlat<TUid>(KTestGranularity);
+	if (pFixFlatTUid==NULL)
+		{
+	    test.Panic(_L("Allocating array of TUid"));
+		}
+	delete pFixFlatTUid; 
 
 	test.Next(_L("class CArrayPtrFlat of CBase"));
 	
--- a/kerneltest/e32test/buffer/t_parray.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/buffer/t_parray.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -80,9 +80,12 @@
 	test(TRUE);
 	TKeyArrayPak kk(sizeof(TText),ECmpNormal,0);
 	TKeyArrayVar vv(sizeof(TText),ECmpNormal,0);
+	TKeyArrayPak hh(sizeof(TText),ECmpNormal);
 	test(TRUE);
 	TRAPD(res,aPakVar.SortL(vv));
 	test(res==KErrNone);
+	TRAPD(err,aPakVar.SortL(hh));
+	test(err==KErrNone);
 	const TText* aa=_S("a");
 	aPakVar.InsertL(0,*aa,sizeof(TText));
 	TBuf<0x10> des1(1);
--- a/kerneltest/e32test/demandpaging/t_pagetable_limit.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/demandpaging/t_pagetable_limit.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -33,9 +33,24 @@
 #include <hal.h>
 
 #include "t_dpcmn.h"
+#include "../mmu/freeram.h"
 
 RTest test(_L("T_PAGETABLE_LIMIT"));
 
+// The flexible memory model reserves 0xF800000-0xFFF00000 for page tables, which allows 130,048
+// pages tables.
+//
+// We attempt to map 40 * 40 * 100 == 160,000 page tables.
+// 
+// So that the limit is reached in the middle, half the chunks are mapped as paged and half as
+// unpaged.
+
+const TUint KPageTablesPerChunk = 40;
+const TUint KChunksPerProcess = 40;
+const TUint KNumProcesses = 100;
+
+const TUint KSizeMappedByPageTable = 1024 * 1024;  // the amount of RAM mapped by one page table
+
 
 _LIT(KClientPtServerName, "CClientPtServer");
 _LIT(KClientProcessName, "T_PAGETABLE_LIMIT");
@@ -46,6 +61,7 @@
 	EClientDisconnect = -2,
 	EClientGetChunk = 0,
 	EClientReadChunks = 1,
+	EClientGetParentProcess = 2,
 	};
 
 class RDataPagingSession : public RSessionBase
@@ -57,176 +73,244 @@
 		}
 	TInt PublicSendReceive(TInt aFunction, const TIpcArgs &aPtr)
 		{
-		return (SendReceive(aFunction, aPtr));
-		}
-	TInt PublicSend(TInt aFunction, const TIpcArgs &aPtr)
-		{
-		return (Send(aFunction, aPtr));
+		return SendReceive(aFunction, aPtr);
 		}
 	};
 
+#define CLIENT_TEST_IMPL(condition, code, line)			\
+	if (!(condition))									\
+		{												\
+		RDebug::Printf("Test %s failed at line %d");	\
+		r = (code);										\
+		goto exit;										\
+		}
+
+#define CLIENT_TEST(condition, code) CLIENT_TEST_IMPL(condition, code, __LINE__)
 
 TInt ClientProcess(TInt aLen)
 	{
-	// Read the command line to get the number of chunk to map and whether or 
-	// not to access their data.
+	// Read the command line to get the number of chunk to map and whether or not to access their
+	// data.
 	HBufC* buf = HBufC::New(aLen);
 	test(buf != NULL);
 	TPtr ptr = buf->Des();
 	User::CommandLine(ptr);
+	TLex lex(ptr);
 
-	TLex lex(ptr);
+	RChunk* chunks = NULL;
+	RDataPagingSession session;
+	RProcess parent;
+	TRequestStatus parentStatus;
+	TInt offset = 0;
+	TInt i;
+	
 	TInt chunkCount;
 	TInt r = lex.Val(chunkCount);
-	test_KErrNone(r);
+	CLIENT_TEST(r == KErrNone, r);	
 	lex.SkipSpace();
+	chunks = new RChunk[chunkCount];
+	CLIENT_TEST(chunks, KErrNoMemory);
 
 	TBool accessData;
 	r = lex.Val(accessData);
-	test_KErrNone(r);
+	CLIENT_TEST(r == KErrNone, r);
 
+	r = session.CreateSession(KClientPtServerName, 1);
+	CLIENT_TEST(r == KErrNone, r);
 
-	RDataPagingSession session;
-	test_KErrNone(session.CreateSession(KClientPtServerName, 1));
-
-	RChunk* chunks = new RChunk[chunkCount];
-	for (TInt i = 0; i < chunkCount; i++)
+	r = parent.SetReturnedHandle(session.PublicSendReceive(EClientGetParentProcess, TIpcArgs()));
+	CLIENT_TEST(r == KErrNone, r);
+	
+	for (i = 0; i < chunkCount; i++)
 		{
-		TInt r = chunks[i].SetReturnedHandle(session.PublicSendReceive(EClientGetChunk, TIpcArgs(i)));
+		r = chunks[i].SetReturnedHandle(session.PublicSendReceive(EClientGetChunk, TIpcArgs(i)));
 		if (r != KErrNone)
 			{
-			test.Printf(_L("Failed to create a handle to the server's chunk r=%d\n"), r);
-			for (TInt j = 0; j < i; j++)
-				chunks[j].Close();
-			session.Close();
-			return r;
+			RDebug::Printf("Failed to create a handle to chunk %d r=%d", i, r);
+			goto exit;
 			}
-		test_Value(chunks[i].Size(), chunks[i].Size() >= gPageSize);
+		CLIENT_TEST(chunks[i].Size() >= gPageSize, KErrGeneral);
 		}
-	if (!accessData)
+
+	// Logon to parent process
+	parent.Logon(parentStatus);
+
+	// Touch each mapped page of all of the chunks.
+	do
 		{
-		// Touch the 1st page of each of the chunks.
 		for (TInt i = 0; i < chunkCount; i++)
 			{
-			// Write the chunk data from top to bottom of the chunk's first page.
-			TUint8* base = chunks[i].Base();
-			TUint8* end = base + gPageSize - 1;
-			*base = *end;
-			}
-		// Tell parent we've touched each chunk.
-		TInt r =  (TThreadId)session.PublicSendReceive(EClientReadChunks,TIpcArgs());	// Assumes id is only 32-bit.
-		test_KErrNone(r);
-		for(;;)
-			{// Wake up every 100ms to be killed by the main process.
-			User::After(100000);
-			}
-		}
-	else
-		{
-		for (;;)
-			{
-			TInt offset = 0;
-			for (TInt i = 0; i < chunkCount; i++)
+			for (TUint j = 0 ; j < KPageTablesPerChunk ; j++)
 				{
 				// Write the chunk data from top to bottom of the chunk's first page.
-				TUint8* base = chunks[i].Base();
+				TUint8* base = chunks[i].Base() + j * KSizeMappedByPageTable;
 				TUint8* end = base + gPageSize - 1;
 				*(base + offset) = *(end - offset);
+
+				User::After(0);
+
+				// Check whether main process is still running
+				if (parentStatus != KRequestPending)
+					{
+					// if we get here the test failed and the main process exited without killing
+					// us, so just exit quietly
+					User::WaitForRequest(parentStatus);
+					r = KErrGeneral;
+					goto exit;
+					}
 				}
-			if (++offset >= (gPageSize >> 1))
-				offset = 0;
 			}
+		offset = (offset + 1) % (gPageSize / 2);
 		}
+	while (accessData);
+
+	// Tell parent we've touched each page.
+	r = (TThreadId)session.PublicSendReceive(EClientReadChunks,TIpcArgs());	
+	CLIENT_TEST(r == KErrNone, r);
+		
+	// Wait till we get killed by the main process or the main process dies
+	User::WaitForRequest(parentStatus);
+	// if we get here the test failed and the main process exited without killing us, so just exit
+	r = KErrGeneral;
+
+exit:
+	if (chunks)
+		{
+		for (TInt i = 0 ; i < chunkCount; ++i)
+			chunks[i].Close();
+		}
+	session.Close();
+	parent.Close();
+			
+	return r;
 	}
 
+TInt FreeSwap()
+	{
+	SVMSwapInfo swapInfo;
+	test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0));
+	return swapInfo.iSwapFree;
+	}
+
+void PrintFreeRam()
+	{
+	test.Printf(_L("%d KB RAM / %d KB swap free\n"), FreeRam() / 1024, FreeSwap() / 1024);
+	}
+
+void CreateChunk(RChunk& aChunk, TInt aChunkIndex, TInt aPageTables, TBool aPaged)
+	{
+	// Creates a global chunk.
+	//
+	// The chunk uses KPageTablesPerChunk page tables by committing that number of pages at 1MB
+	// intervals.  Its max size is set so that it is not a multiple of 1MB and hence the FMM will
+	// use a fine mapping objects whose page tables are not shared between processes.
+	
+	test.Printf(_L("  creating chunk %d: "), aChunkIndex);
+	PrintFreeRam();
+	
+	TChunkCreateInfo createInfo;
+	createInfo.SetDisconnected(0, 0, aPageTables * KSizeMappedByPageTable + gPageSize);
+	createInfo.SetPaging(aPaged ? TChunkCreateInfo::EPaged : TChunkCreateInfo::EUnpaged);
+	TBuf<32> name;
+	name.AppendFormat(_L("t_pagetable_limit chunk %d"), aChunkIndex);
+	createInfo.SetGlobal(name);
+	test_KErrNone(aChunk.Create(createInfo));
+	for (TInt i = 0 ; i < aPageTables ; ++i)
+		test_KErrNone(aChunk.Commit(i * KSizeMappedByPageTable, gPageSize));
+	}
+
+void CreateProcess(RProcess& aProcess, TInt aProcessIndex, TInt aNumChunks, TBool aAccessData)
+	{
+	test.Printf(_L("  creating process %d: "), aProcessIndex);
+	PrintFreeRam();
+	
+	TBuf<80> args;
+	args.AppendFormat(_L("%d %d"), aNumChunks, aAccessData);
+	test_KErrNone(aProcess.Create(KClientProcessName, args));
+	aProcess.SetPriority(EPriorityLow);
+	}
 
 void TestMaxPt()
 	{
-	// Flexible memory model reserves 0xF800000-0xFFF00000 for page tables
-	// this allows 130,048 pages tables.  Therefore mapping 1000 one 
-	// page chunks into 256 processes would require 256,000 page tables, i.e.
-	// more than enough to hit the limit.  So that the limit is reached in the middle,
-	// map 500 unpaged and 500 paged chunks in each process.
-	const TUint KNumChunks = 1000;
-	const TUint KPagedChunksStart = (KNumChunks >> 1);
-	const TUint KNumProcesses = 256;
+	test.Printf(_L("Waiting for system idle and kernel cleanup\n"));
+	// If this test was run previously, there may be lots of dead processes waiting to be cleaned up
+	TInt r;
+	while((r = FreeRam(10 * 1000)), r == KErrTimedOut)
+		{
+		test.Printf(_L("  waiting: "));
+		PrintFreeRam();
+		}
+
+	// Remove the maximum limit on the cache size as the test requires that it can
+	// allocate as many page tables as possible but without stealing any pages as
+	// stealing pages may indirectly steal paged page table pages.
+	test.Printf(_L("Set paging cache max size unlimited\n"));
+	TUint minCacheSize, maxCacheSize, currentCacheSize;
+	test_KErrNone(DPTest::CacheSize(minCacheSize,maxCacheSize,currentCacheSize));
+	test_KErrNone(DPTest::SetCacheSize(minCacheSize, KMaxTUint));
+
 	const TInt KMinFreeRam = (1000 * gPageSize) + (130048 * (gPageSize>>2));
-	TInt freeRam;
-	HAL::Get(HALData::EMemoryRAMFree, freeRam);
+
+	// Ensure enough RAM available
+	PrintFreeRam();
+	TInt freeRam = FreeRam();
 	if (freeRam < KMinFreeRam)
 		{
 		test.Printf(_L("Only 0x%x bytes of free RAM not enough to perform the test.  Skipping test.\n"), freeRam);
 		return;
 		}
 
-	// Remove the maximum limit on the cache size as the test requires that it can
-	// allocate as many page tables as possible but without stealing any pages as
-	// stealing pages may indirectly steal paged page table pages.
-	TUint minCacheSize, maxCacheSize, currentCacheSize;
-	DPTest::CacheSize(minCacheSize,maxCacheSize,currentCacheSize);
-	test_KErrNone(DPTest::SetCacheSize(minCacheSize, KMaxTUint));
-
+	test.Printf(_L("Start server\n"));
 	RServer2 ptServer;
-	TInt r = ptServer.CreateGlobal(KClientPtServerName);
+	r = ptServer.CreateGlobal(KClientPtServerName);
 	test_KErrNone(r);
 
-	// Create the global unpaged chunks.  They have one page committed
-	// but have a maximum size large enough to prevent their page tables being
-	// shared between the chunks.  On arm with 4KB pages each page table maps 1MB
-	// so make chunk 1MB+4KB so chunk requires 2 page tables and is not aligned on
-	// a 1MB boundary so it is a fine memory object.
-	const TUint KChunkSize = (1024 * 1024) + gPageSize;
-	RChunk* chunks = new RChunk[KNumChunks];
-	TChunkCreateInfo createInfo;
-	createInfo.SetNormal(gPageSize, KChunkSize);
-	createInfo.SetGlobal(KNullDesC);
-	createInfo.SetPaging(TChunkCreateInfo::EUnpaged);
+	test.Printf(_L("Create chunks\n"));
+	const TUint KPagedChunksStart = (KChunksPerProcess >> 1);
+	RChunk* chunks = new RChunk[KChunksPerProcess];
+	test_NotNull(chunks);
 	TUint i = 0;
-	for (; i < KPagedChunksStart; i++)
-		{
-		r = chunks[i].Create(createInfo);
-		test_KErrNone(r);
-		}
-	// Create paged chunks.
-	createInfo.SetPaging(TChunkCreateInfo::EPaged);
-	for (; i< KNumChunks; i++)
-		{
-		r = chunks[i].Create(createInfo);
-		test_KErrNone(r);
-		}
+	for (i = 0 ; i< KChunksPerProcess; i++)
+		CreateChunk(chunks[i], i, KPageTablesPerChunk, i >= KPagedChunksStart);
 
 	// Start remote processes, giving each process handles to each chunk.
+	test.Printf(_L("Start remote processes\n"));
 	RProcess* processes = new RProcess[KNumProcesses];
-	RMessage2 ptMessage;
-	TUint processIndex = 0;
-	TUint processLimit = 0;
+	test_NotNull(processes);
+	TRequestStatus* statuses = new TRequestStatus[KNumProcesses];
+	test_NotNull(statuses);
+	TUint processIndex = 0;	
 	for (; processIndex < KNumProcesses; processIndex++)
 		{
 		// Start the process.
-		test.Printf(_L("Creating process %d\n"), processIndex);
-		TBuf<80> args;
-		args.AppendFormat(_L("%d %d"), KNumChunks, EFalse);
-		r = processes[processIndex].Create(KClientProcessName, args);
-		test_KErrNone(r);
-		TRequestStatus s;
-		processes[processIndex].Logon(s);
-		test_Equal(KRequestPending, s.Int());
+		CreateProcess(processes[processIndex], processIndex, KChunksPerProcess, EFalse);
+		
+		// logon to process
+		processes[processIndex].Logon(statuses[processIndex]);
+		test_Equal(KRequestPending, statuses[processIndex].Int());
 		processes[processIndex].Resume();
 
+		// wait for connect message
+		RMessage2 ptMessage;
 		ptServer.Receive(ptMessage);
 		test_Equal(EClientConnect, ptMessage.Function());
 		ptMessage.Complete(KErrNone);
-		TInt func = EClientGetChunk;
+
+		// pass client a handle to this process
+		ptServer.Receive(ptMessage);
+		test_Equal(EClientGetParentProcess, ptMessage.Function());
+		ptMessage.Complete(RProcess());
+
+		// pass client chunk handles
+		TInt func;
 		TUint chunkIndex = 0;
-		for (; chunkIndex < KNumChunks && func == EClientGetChunk; chunkIndex++)
+		for (; chunkIndex < KChunksPerProcess ; chunkIndex++)
 			{// Pass handles to all the unpaged chunks to the new process.
 			ptServer.Receive(ptMessage);
 			func = ptMessage.Function();
-			if (func == EClientGetChunk)
-				{
-				TUint index = ptMessage.Int0();
-				ptMessage.Complete(chunks[index]);
-				}
+			if (func != EClientGetChunk)
+				break;
+			ptMessage.Complete(chunks[ptMessage.Int0()]);
 			}
 		if (func != EClientGetChunk)
 			{
@@ -234,9 +318,10 @@
 			// sending a disconnect message in the process.
 			test_Equal(EClientDisconnect, func);
 			// Should only fail when mapping unpaged chunks.
-			test_Value(chunkIndex, chunkIndex < (KNumChunks >> 1));
+			test_Value(chunkIndex, chunkIndex < (KChunksPerProcess >> 1));
 			break;
 			}
+		
 		// Wait for the process to access all the chunks and therefore 
 		// allocate the paged page tables before moving onto the next process.
 		ptServer.Receive(ptMessage);
@@ -245,45 +330,44 @@
 		ptMessage.Complete(KErrNone);
 
 		// Should have mapped all the required chunks.
-		test_Equal(KNumChunks, chunkIndex);
+		test_Equal(KChunksPerProcess, chunkIndex);
 		}
+	
 	// Should hit page table limit before KNumProcesses have been created.
 	test_Value(processIndex, processIndex < KNumProcesses - 1);
-	processLimit = processIndex;
+	TUint processLimit = processIndex;
 
-	// Now create more processes to access paged data even though the page table 
-	// address space has been exhausted.  Limit to 10 more processes as test takes 
-	// long enough already.
+	// Now create more processes to access paged data even though the page table address space has
+	// been exhausted.  Limit to 10 more processes as test takes long enough already.
+	test.Printf(_L("Start accessor processes\n"));
 	processIndex++;
 	TUint excessProcesses = KNumProcesses - processIndex;
 	TUint pagedIndexEnd = (excessProcesses > 10)? processIndex + 10 : processIndex + excessProcesses;
 	for (; processIndex < pagedIndexEnd; processIndex++)
 		{
-		// Start the process.
-		test.Printf(_L("Creating process %d\n"), processIndex);
-		TBuf<80> args;
-		args.AppendFormat(_L("%d %d"), KNumChunks-KPagedChunksStart, ETrue);
-		r = processes[processIndex].Create(KClientProcessName, args);
-		if (r != KErrNone)
-			{// Have hit the limit of processes.
-			processIndex--;
-			// Should have created at least one more process.
-			test_Value(processIndex, processIndex > processLimit);
-			break;
-			}
-		TRequestStatus s;
-		processes[processIndex].Logon(s);
-		test_Equal(KRequestPending, s.Int());
+		// start the process.
+		CreateProcess(processes[processIndex], processIndex, KChunksPerProcess-KPagedChunksStart, ETrue);
+
+		// logon to process
+		processes[processIndex].Logon(statuses[processIndex]);
+		test_Equal(KRequestPending, statuses[processIndex].Int());
 		processes[processIndex].Resume();
 
+		// wait for connect message
+		RMessage2 ptMessage;
 		ptServer.Receive(ptMessage);
 		test_Equal(EClientConnect, ptMessage.Function());
 		ptMessage.Complete(KErrNone);
 
+		// pass client a handle to this process
+		ptServer.Receive(ptMessage);
+		test_Equal(EClientGetParentProcess, ptMessage.Function());
+		ptMessage.Complete(RProcess());
+		
 		TInt func = EClientGetChunk;
 		TUint chunkIndex = KPagedChunksStart;
-		for (; chunkIndex < KNumChunks && func == EClientGetChunk; chunkIndex++)
-			{// Pass handles to all the unpaged chunks to the new process.
+		for (; chunkIndex < KChunksPerProcess && func == EClientGetChunk; chunkIndex++)
+			{// Pass handles to all the paged chunks to the new process.
 			ptServer.Receive(ptMessage);
 			func = ptMessage.Function();
 			if (func == EClientGetChunk)
@@ -301,30 +385,36 @@
 			}
 
 		// Should have mapped all the required chunks.
-		test_Equal(KNumChunks, chunkIndex);
+		test_Equal(KChunksPerProcess, chunkIndex);
 		}
+	
 	// If we reached the end of then ensure that we kill only the running processes.
 	if (processIndex == pagedIndexEnd)
 		processIndex--;
+
+	// Let the accessor processes run awhile
+	test.Printf(_L("Waiting...\n"));
+	User::After(10 * 1000000);
+	
 	// Kill all the remote processes
+	test.Printf(_L("Killing processes...\n"));
 	for(TInt j = processIndex; j >= 0; j--)
 		{
-		test.Printf(_L("killing process %d\n"), j);
-		TRequestStatus req;
-		processes[j].Logon(req);
-		if (req == KRequestPending)
-			{
+		test.Printf(_L("  killing process %d\n"), j);
+		if (statuses[j] == KRequestPending)
 			processes[j].Kill(KErrNone);
-			User::WaitForRequest(req);
-			}
 		processes[j].Close();
+		User::WaitForRequest(statuses[j]);
 		}
-	delete[] processes;
+	delete [] processes;
+	delete [] statuses;
+	
 	// Close the chunks.
-	for (TUint k = 0; k < KNumChunks; k++)
+	for (TUint k = 0; k < KChunksPerProcess; k++)
 		chunks[k].Close();
 	delete[] chunks;
-	
+
+	// Reset live list size
 	test_KErrNone(DPTest::SetCacheSize(minCacheSize, maxCacheSize));
 	}
 
--- a/kerneltest/e32test/group/bld.inf	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/group/bld.inf	Mon Jul 26 10:52:56 2010 +0100
@@ -121,6 +121,7 @@
 d_shbuf_own					support
 d_asid						support
 d_entropysources			support
+d_khal						support
 
 #ifdef GENERIC_MARM
 d_schedhook					support
@@ -512,13 +513,11 @@
 ../ethernet/pump/etherpump  manual
 ../ethernet/macset/macset   manual
 
-// /E32TEST/HEAP tests
-t_fail
-
+// /e32test/heap tests
 #ifdef EPOC32
-t_hcomp     support
+t_hcomp			support
 #endif
-
+t_fail
 t_heap
 t_heap2
 t_heapdb
@@ -635,7 +634,7 @@
 t_loadsim	support
 
 #if !defined(WINS)
-t_zip       manual
+t_zip       
 #endif
 
 #ifdef EPOC32
@@ -756,16 +755,18 @@
 
 // /E32TEST/SYSTEM tests
 t_atomic
+t_atomicu
 t_chnot     
 t_cobj      
 t_ctrap     
 t_exc       
-t_inf       manual
+t_inf
 t_multin    
 t_prot
 t_prot2     support
 t_prot2a    support
 t_reason    support 
+t_reason2
 t_ref       
 t_reg       
 t_trap
@@ -791,6 +792,7 @@
 //  T_REGRAM    support
 t_panic     support
 #endif
+t_khal
 
 // /E32TEST/THREAD tests
 t_killer    support // because it takes several minutes to run
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/d_khal.mmp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,34 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test/group/d_khal.mmp
+// 
+//
+
+#include "kernel/kern_ext.mmh"
+
+target			  d_khal.ldd
+targettype		ldd
+sourcepath		../system
+source			  d_khal.cpp
+userinclude   ../system
+epocallowdlldata
+
+start wins
+win32_library	kernel32.lib
+end
+
+capability		all
+
+VENDORID 0x70000001
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_atomicu.mmp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,30 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test/group/t_atomicu.mmp
+// 
+//
+
+TARGET         t_atomicu.exe        
+TARGETTYPE     EXE
+SOURCEPATH	../system
+SOURCE         t_atomicu.cpp
+LIBRARY        euser.lib
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+
+capability		all
+
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_khal.mmp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,30 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test/group/t_khal.mmp
+// 
+//
+
+TARGET         t_khal.exe        
+TARGETTYPE     EXE
+SOURCEPATH	   ../system
+SOURCE         t_khal.cpp
+USERINCLUDE		 ../system
+LIBRARY        euser.lib
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+capability		all
+
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_reason2.mmp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,31 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test/group/t_reason2.mmp
+// 
+//
+
+TARGET         t_reason2.exe        
+TARGETTYPE     EXE
+SOURCEPATH	../system
+SOURCE         t_reason2.cpp
+LIBRARY        euser.lib
+LIBRARY        hal.lib
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+
+capability		all
+
+VENDORID 0x70000001
+
+SMPSAFE
--- a/kerneltest/e32test/misc/t_zip.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/misc/t_zip.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -22,8 +22,10 @@
 
 TInt64 CrashTime() {return 0;}
 
-RFs TheFs;
+RFs gFs;
 RFile TheOutFile;
+CFileMan* gFileMan;
+_LIT(KZipFile,"c:\\out.zip");
 				
 class TCrashTestGzip : public MCrashGzip
 	{
@@ -38,9 +40,10 @@
 
 void TCrashTestGzip::SetOutput()
 	{
-	TInt r=TheOutFile.Replace(TheFs, _L("c:\\out.zip"),EFileWrite);
+	TInt r=TheOutFile.Replace(gFs, KZipFile, EFileWrite);
 	test(r==KErrNone);
-	Init();
+	TBool bOk=Init();
+	test(bOk);
 	}
 
 
@@ -59,14 +62,18 @@
 
 
 _LIT8(KText, "12345");
-
+const TUint32 KTextSize = 5;
 
 GLDEF_C TInt E32Main()
 	{
 	test.Title();
 
 	test.Start(_L("Connect to file server"));
-	TInt r=TheFs.Connect();
+
+	CTrapCleanup* ct = CTrapCleanup::New();
+	test(ct!=0);
+	test(gFs.Connect()==KErrNone);
+	TRAPD(r, gFileMan=CFileMan::NewL(gFs));
 	test(r==KErrNone);
 
 	test.Next(_L("Making zip file"));
@@ -75,8 +82,30 @@
 	zip.Write(KText);
 	zip.FlushEnd();
 
+	// get the number of uncompressed bytes and check that it matches the string
+	TUint32 uncompressedBytes=zip.GetDataCompressed();
+	test(uncompressedBytes==KTextSize);
+
 	TheOutFile.Close();
-	TheFs.Close();
+
+	test.Next(_L("Re-open zip file and check size"));
+	// Check that file exists
+	r=TheOutFile.Open(gFs, KZipFile, EFileRead);
+	test(r==KErrNone);
+	
+	//check size
+	TInt size=0;
+	r=TheOutFile.Size(size);
+	test(r==KErrNone && size>0);
+
+	TheOutFile.Close();
+
+	// Cleanup
+	gFileMan->Delete(KZipFile);
+	delete gFileMan;
+	gFs.Close();
+	delete ct;
+	test.End();
 
 	return KErrNone;
 	}
--- a/kerneltest/e32test/mmu/freeram.h	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/mmu/freeram.h	Mon Jul 26 10:52:56 2010 +0100
@@ -18,16 +18,32 @@
 #ifndef __FREERAM_H__
 #define __FREERAM_H__
 
-//
-// returns the free RAM in bytes
-//
-inline TInt FreeRam()
+/**
+Get the amount of free RAM in the system in bytes.
+
+This calls the kernel HAL supervisor barrier to ensure that asynchronous cleanup in the supervisor
+happens before the amount of free RAM is measured.
+
+There is also the option to wait for upto a specified timeout for the system to become idle.
+
+@param aIdleTimeoutMs If non-zero, the number of milliseconds to wait for the system to become idle.
+
+@return On sucess returns the amount of free RAM in bytes, KErrTimedOut if the timeout expired
+        without the system becoming idle, or one of the other system-wide error codes.
+*/
+TInt FreeRam(TInt aIdleTimeoutMs = 0)
 	{
 	// wait for any async cleanup in the supervisor to finish first...
-	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
+	TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier,
+								  (TAny*)aIdleTimeoutMs, 0);
+	if (r != KErrNone)
+		return r;
 
 	TMemoryInfoV1Buf meminfo;
-	UserHal::MemoryInfo(meminfo);
+	r = UserHal::MemoryInfo(meminfo);
+	if (r != KErrNone)
+		return r;
+	
 	return meminfo().iFreeRamInBytes;
 	}
 
--- a/kerneltest/e32test/pccd/t_medch.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/pccd/t_medch.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -220,6 +220,10 @@
 					break;
 					}
 				}
+			else
+				{
+				break;
+				}
 			}
 		}
 
--- a/kerneltest/e32test/rm_debug/debug_targets/t_rmdebug_app.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/rm_debug/debug_targets/t_rmdebug_app.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -21,7 +21,7 @@
 #include <e32property.h> 
 #include <u32hal.h>
 #include <f32file.h>
-
+#include <e32svr.h>
 
 
 #include "t_rmdebug_app.h"
--- a/kerneltest/e32test/rm_debug/multi_agent_tests/t_multi_agent.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/rm_debug/multi_agent_tests/t_multi_agent.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -20,6 +20,7 @@
 #include <hal.h>
 #include <e32test.h>
 #include <e32def.h>
+#include <e32svr.h>
 
 #include "t_rmdebug_app.h"
 #include "t_multi_agent.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/system/d_khal.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,284 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test\system\d_khal.cpp
+// LDD for testing class Kern HAL APIs
+// Kern::AddHalEntry(), Kern::RemoveHalEntry(), Kern::FindHalEntry()
+// 
+//
+
+#include <kernel/kernel.h>
+
+#include "d_khal.h"
+
+#define KMaxDeviceNumber 8 // same as KMaxHalEntries
+
+TUint 	gDeviceNumber=1;			// Device Number
+TUint	gRegisteredDeviceNumber;	// Holds the device number which we managed to register for
+TBool	gEntryForDevice0Registered; // indicator whether the device0 got registered
+TBool	gEntryForDeviceXRegistered;	// States HAL Entry Successfully registered or not
+TBool	gFirstCall=ETrue;			// for add function, this tells if this is first call or not
+
+class DKHalLDDTestFactory : public DLogicalDevice
+//
+// Test LDD factory
+//
+	{
+public:
+	DKHalLDDTestFactory();
+	virtual TInt Install(); 								//overriding pure virtual
+	virtual void GetCaps(TDes8& aDes) const;				//overriding pure virtual
+	virtual TInt Create(DLogicalChannelBase*& aChannel); 	//overriding pure virtual
+	};
+
+class DKHalLDDTestChannel : public DLogicalChannelBase
+//
+// Test logical channel
+//
+	{
+public:
+	virtual ~DKHalLDDTestChannel();
+protected:
+	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
+	};
+
+
+LOCAL_C TInt halFunction0(TAny* /*aPtr*/, TInt aFunction, TAny* /*a1*/, TAny* /*a2*/)
+	{
+	TInt r=KErrNotSupported;
+
+	switch(aFunction)
+		{
+		case RLddKHalTest::ETestHalFunc:
+			Kern::Printf("HAL function0 called successfully !");
+			r=KErrNone; // just return KErrNone
+			break;
+		default:
+			break;
+		}
+	return r;
+	}
+
+
+LOCAL_C TInt halFunctionX(TAny* /*aPtr*/, TInt aFunction, TAny* /*a1*/, TAny* /*a2*/)
+	{
+	TInt r=KErrNotSupported;
+
+	switch(aFunction)
+		{
+		case RLddKHalTest::ETestHalFunc:
+			Kern::Printf("HAL functionX called successfully !");
+			r=KErrNone; // just return KErrNone
+			break;
+		default:
+			break;
+		}
+	return r;
+	}
+
+DECLARE_STANDARD_LDD()
+	{
+	return new DKHalLDDTestFactory;
+	}
+
+//
+// Constructor
+//
+DKHalLDDTestFactory::DKHalLDDTestFactory()
+	{
+	}
+
+TInt DKHalLDDTestFactory::Create(DLogicalChannelBase*& aChannel)
+	{
+//
+// Create new channel
+//  
+	aChannel=new DKHalLDDTestChannel;
+	return aChannel?KErrNone:KErrNoMemory;
+	}
+
+TInt DKHalLDDTestFactory::Install()
+//
+// Install the LDD - overriding pure virtual
+	{
+	return SetName(&KLddName);
+	}
+
+void DKHalLDDTestFactory::GetCaps(TDes8& /*aDes*/) const
+//
+// Get capabilities - overriding pure virtual
+//
+	{
+	}
+
+TInt DKHalLDDTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
+//
+// Create channel
+//
+	{
+	return KErrNone;
+	}
+
+DKHalLDDTestChannel::~DKHalLDDTestChannel()
+//
+// Destructor
+//
+	{
+	}
+
+TInt DKHalLDDTestChannel::Request(TInt aReqNo, TAny* /*a1*/, TAny* /*a2*/)
+	{
+	TInt r=KErrNone;
+	switch(aReqNo)
+		{
+		case RLddKHalTest::EAddHalEntryDevice0:
+			{
+			// try to register the halfunction for PlatformSpecific category, device 0
+            NKern::ThreadEnterCS();
+			r=Kern::AddHalEntry(EHalGroupPlatformSpecific2,halFunction0,this);
+			NKern::ThreadLeaveCS();
+			//this function gets called twice, second time must not changed these values
+			if (gFirstCall)
+				{
+				if (r==KErrNone)
+					{
+					gEntryForDevice0Registered=ETrue;
+					}
+				else
+					{
+					gEntryForDevice0Registered=EFalse;
+					}
+				gFirstCall=EFalse;
+				}
+
+			break;
+			}
+		case RLddKHalTest::EAddHalEntryDeviceX:
+			{
+			// try to register the halfunction for PlatformSpecific category, device x
+            NKern::ThreadEnterCS();
+			do
+				{
+				r=Kern::AddHalEntry(EHalGroupPlatformSpecific2,halFunctionX,this,gDeviceNumber);
+				}
+            while((r==KErrInUse) && (++gDeviceNumber < KMaxDeviceNumber));
+			NKern::ThreadLeaveCS();
+
+			if((gDeviceNumber < KMaxDeviceNumber) && (r==KErrNone))
+				{
+				gEntryForDeviceXRegistered=ETrue;
+				gRegisteredDeviceNumber=gDeviceNumber;
+				}
+			else
+				{
+				gEntryForDeviceXRegistered=EFalse;
+				r=KErrInUse;
+				}
+
+			break;
+			}
+		case RLddKHalTest::EAddHalEntryForExistingFixed:
+			{
+			// try to add HAL entry for Kernel, should fail
+            NKern::ThreadEnterCS();
+			r=Kern::AddHalEntry(EHalGroupKernel,halFunction0,this);
+			NKern::ThreadLeaveCS();
+			break;
+			}
+		case RLddKHalTest::ERemoveHalEntryDevice0:
+			{
+			// try to remove the registered halfunction for device 0
+			if(gEntryForDevice0Registered)
+				r=Kern::RemoveHalEntry(EHalGroupPlatformSpecific2);
+		
+			break;
+			}
+		case RLddKHalTest::ERemoveHalEntryDeviceX:
+			{
+			// try to remove the registered halfunction for device x
+			if(gEntryForDeviceXRegistered)
+				r=Kern::RemoveHalEntry(EHalGroupPlatformSpecific2,gRegisteredDeviceNumber);
+			break;
+			}
+		case RLddKHalTest::ERemoveHalEntryExistingFixed:
+			{
+			// try to remove EGroupHalKernel. This operation should return an error
+			r=Kern::RemoveHalEntry(EHalGroupKernel);
+			break;
+			}
+		case RLddKHalTest::EGetRegisteredDeviceNumber:
+			{
+			// return the device number which we managed to register
+			if(gEntryForDeviceXRegistered)
+				{
+				r=gRegisteredDeviceNumber;
+				}
+			else
+				{
+				r=KErrNotFound;
+				}
+			break;
+			}
+		case RLddKHalTest::EFindHalEntryDevice0:
+			{
+			SHalEntry* pEntry=Kern::FindHalEntry(EHalGroupPlatformSpecific2);
+			// returns valid pEntry if EAddHalEntryForDevice0 managed to register
+			// an entry earlier
+			if (pEntry && pEntry->iFunction!=NULL)
+				{
+				r=KErrNone;
+				}
+			else
+				{
+				r=KErrNotFound;
+				}
+			break;
+			}
+		case RLddKHalTest::EFindHalEntryDevice0Other:
+			{
+			SHalEntry* pEntry=Kern::FindHalEntry(EHalGroupKernel);
+			//try to find an existing HAL group (kernel must exist)
+			if (pEntry && pEntry->iFunction!=NULL)
+				{
+				r=KErrNone;
+				}
+			else
+				{
+				r=KErrNotFound;
+				}
+			break;
+			}
+		case RLddKHalTest::EFindHalEntryDeviceX:
+			{
+			SHalEntry* pEntry=Kern::FindHalEntry(EHalGroupPlatformSpecific2,gRegisteredDeviceNumber);
+			// Should return valid pEntry if EAddHalEntryForDeviceX managed to register
+			// one earlier
+			if (pEntry && pEntry->iFunction!=NULL)
+				{
+				r=KErrNone;
+				}
+			else
+				{
+				r=KErrNotFound; 
+				}
+			break;
+			}
+
+		default:
+			r=KErrNotSupported;
+			break;
+		} 
+
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/system/d_khal.h	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,123 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test\system\d_khal.h
+// 
+//
+
+#if !defined(__D_KHAL_H__)
+#define __D_KHAL_H__
+
+#include <e32cmn.h>
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
+
+_LIT(KLddName,"D_KHAL.LDD");
+
+class RLddKHalTest : public RBusLogicalChannel
+	{
+public:
+
+	enum TControl
+		{
+		EAddHalEntryDevice0 = 1,
+		EAddHalEntryDeviceX,
+		EAddHalEntryForExistingFixed,
+		ERemoveHalEntryDevice0,
+		ERemoveHalEntryDeviceX,
+		ERemoveHalEntryExistingFixed,
+		EGetRegisteredDeviceNumber,
+		EFindHalEntryDevice0,
+		EFindHalEntryDevice0Other,
+		EFindHalEntryDeviceX
+		};
+
+	enum THalFunc
+		{
+		ETestHalFunc
+		};
+
+public:
+	inline TInt Open();
+	inline TInt AddHalEntryDevice0();
+	inline TInt AddHalEntryDeviceX();
+	inline TInt AddHalEntryForExistingFixed();
+	inline TInt RemoveHalEntryDevice0();
+	inline TInt RemoveHalEntryDeviceX();
+	inline TInt RemoveHalEntryExistingFixed();
+	inline TInt GetRegisteredDeviceNumber();
+	inline TInt FindHalEntryDevice0();
+	inline TInt FindHalEntryDevice0Other();
+	inline TInt FindHalEntryDeviceX();
+	};
+
+
+#ifndef __KERNEL_MODE__
+inline TInt RLddKHalTest::Open()
+	{
+	return DoCreate(KLddName,TVersion(0,1,0),KNullUnit,NULL,NULL);
+	}
+
+inline TInt RLddKHalTest::AddHalEntryDevice0()
+	{
+    return DoControl(EAddHalEntryDevice0);
+	}
+
+inline TInt RLddKHalTest::AddHalEntryDeviceX()
+	{
+    return DoControl(EAddHalEntryDeviceX);
+	}
+
+inline TInt RLddKHalTest::AddHalEntryForExistingFixed()
+	{
+    return DoControl(EAddHalEntryForExistingFixed);
+	}
+
+inline TInt RLddKHalTest::RemoveHalEntryDevice0()
+	{
+    return DoControl(ERemoveHalEntryDevice0);
+	}
+
+inline TInt RLddKHalTest::RemoveHalEntryDeviceX()
+	{
+    return DoControl(ERemoveHalEntryDeviceX);
+	}
+
+inline TInt RLddKHalTest::RemoveHalEntryExistingFixed()
+	{
+    return DoControl(ERemoveHalEntryExistingFixed);
+	}
+
+inline TInt RLddKHalTest::GetRegisteredDeviceNumber()
+	{
+    return DoControl(EGetRegisteredDeviceNumber);
+	}
+
+inline TInt RLddKHalTest::FindHalEntryDevice0()
+	{
+    return DoControl(EFindHalEntryDevice0);
+	}
+
+inline TInt RLddKHalTest::FindHalEntryDevice0Other()
+	{
+    return DoControl(EFindHalEntryDevice0Other);
+	}
+
+inline TInt RLddKHalTest::FindHalEntryDeviceX()
+	{
+    return DoControl(EFindHalEntryDeviceX);
+	}
+#endif //__KERNEL_MODE__
+
+#endif   //__D_KHAL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/system/t_atomicu.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,205 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test\system\t_atomicu.cpp
+// Overview:
+// Simple test for class User atomic operations
+// API Information:
+// User::SafeInc(), User::SafeDec(), User::LockedInc(),
+// User::LockedDec()
+// Details:
+// - Tests SafeInc, SafeDec, LockedInc and LockedDec
+// functions in single thread and determines that counts
+// match after finished
+// - Tests SafeInc, SafeDec, LockedInc and LockedDec
+// functions in multithreaded configuration and determines
+// that counts match after finished
+// Platforms/Drives/Compatibility:
+// All.
+// Assumptions/Requirement/Pre-requisites:
+// Failures and causes:
+// Base Port information:
+// 
+//
+
+#define __E32TEST_EXTENSION__
+#include <e32test.h>
+#include <e32svr.h>
+#include <e32def.h>
+
+LOCAL_D RTest test(_L("T_ATOMICU"));
+
+const TInt KMaxOps=20000;
+#define KNumThreads 20
+TInt gValue=0;
+
+void TestSafeIncAndSafeDec()
+	{
+	gValue=0;
+	// increasing when 0, should return 0
+	test(User::SafeInc(gValue)==0);
+	// value also should be 0
+	test(gValue==0);
+	
+	gValue=1;
+	TInt expected=0;
+	// gValue should vary only between 1 and 2
+	for (TInt i=0; i<KMaxOps; i++)
+		{
+		expected=User::SafeInc(gValue)+1;
+		test(expected==User::SafeDec(gValue));
+		}
+
+	// after running these, it should be 1
+	test(gValue==1);
+	
+	// should stay zero after decreasing from 1 multiple times
+	test(User::SafeDec(gValue)==1);
+	test(User::SafeDec(gValue)==0);
+	test(User::SafeDec(gValue)==0);
+	test(gValue==0);
+	}
+
+void TestLockedIncAndLockedDec()
+	{
+	gValue=0;
+	// increasing when 0, should return 0 as old value
+	test(User::LockedInc(gValue)==0);
+	// new value should be 1
+	test(gValue==1);
+
+	gValue=-1;
+
+	// gValue should vary only between 1 and 2
+	for (TInt i=0; i<KMaxOps; i++)
+		{
+		test((User::LockedInc(gValue)+1)==User::LockedDec(gValue));
+		}
+
+	// after running these, it should be back in -1
+	test(gValue==-1);
+	}
+
+TInt MultiThreadSafeIncAndSafeDec_FUNC(TAny*)
+	{
+	for (TInt i=0; i<KMaxOps; i++)
+		{
+		User::SafeInc(gValue);
+		User::SafeDec(gValue);
+		}
+	return KErrNone;
+	}
+
+TInt MultiThreadLockedIncAndLockedDec_FUNC(TAny*)
+	{
+	for (TInt i=0; i<KMaxOps; i++)
+		{
+		User::LockedInc(gValue);
+		User::LockedDec(gValue);
+		}
+	return KErrNone;
+	}
+
+void MultiThreadSafeIncAndSafeDec()
+	{
+	gValue=1; // start value 1
+	RThread threads[KNumThreads];
+	TRequestStatus stats[KNumThreads];
+	TInt i;
+
+	for (i=0;i<KNumThreads;i++)
+		{
+		test_KErrNone(threads[i].Create(KNullDesC,MultiThreadSafeIncAndSafeDec_FUNC,KDefaultStackSize,NULL,NULL));
+		threads[i].Logon(stats[i]);
+		}
+	
+	//lets increase our priority first, so that all the threads start
+	RThread().SetPriority(EPriorityMore);
+
+	test.Printf(_L("Resuming threads...\n"));
+	for(i=0; i<KNumThreads; i++)
+		threads[i].Resume();
+
+	for(i=0; i<KNumThreads; i++)
+		{
+		User::WaitForRequest(stats[i]);
+		test_KErrNone(stats[i].Int());
+		CLOSE_AND_WAIT(threads[i]);
+		}
+
+	test.Printf(_L("...Threads finished\n"));
+	
+	// back to normal
+	RThread().SetPriority(EPriorityNormal);
+
+	// test that we returned to the startvalue
+	test(gValue==1);
+	}
+
+void MultiThreadLockedIncAndLockedDec()
+	{
+	gValue=-1; // set start value to -1
+	RThread threads[KNumThreads];
+	TRequestStatus stats[KNumThreads];
+	TInt i;
+
+	for (i=0;i<KNumThreads;i++)
+		{
+		test_KErrNone(threads[i].Create(KNullDesC,MultiThreadLockedIncAndLockedDec_FUNC,KDefaultStackSize,NULL,NULL));
+		threads[i].Logon(stats[i]);
+		}
+	
+	//lets increase our priority first, so that all the threads start
+	RThread().SetPriority(EPriorityMore);
+
+	test.Printf(_L("Resuming threads...\n"));
+	for(i=0; i<KNumThreads; i++)
+		threads[i].Resume();
+
+	for(i=0; i<KNumThreads; i++)
+		{
+		User::WaitForRequest(stats[i]);
+		test_KErrNone(stats[i].Int());
+		CLOSE_AND_WAIT(threads[i]);
+		}
+
+	test.Printf(_L("...Threads finished\n"));
+	
+	// back to normal
+	RThread().SetPriority(EPriorityNormal);
+
+	// test that we returned to the startvalue
+	test(gValue==-1);
+	}
+
+
+TInt E32Main()
+	{
+	test.Title();
+	
+	test.Start(_L("Test single thread User::SafeInc and User::SafeDec"));
+	TestSafeIncAndSafeDec();
+	
+	test.Next(_L("Test single thread User::LockedInc and User::LockedDec"));
+	TestLockedIncAndLockedDec();
+
+	test.Next(_L("Test multiple thread User::SafeInc and User::SafeDec"));
+	MultiThreadSafeIncAndSafeDec();
+	
+	test.Next(_L("Test multiple thread User::LockedInc and User::LockedDec"));
+	MultiThreadLockedIncAndLockedDec();
+
+	test.End();
+
+	return KErrNone;
+	}
--- a/kerneltest/e32test/system/t_cobj.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/system/t_cobj.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -30,6 +30,7 @@
 // - Test all the objects together: create two containers, find objects by 
 // name in a variety of ways, delete objects and verify the results are 
 // as expected.
+// - Test panic functions by behaving badly
 // Platforms/Drives/Compatibility:
 // All.
 // Assumptions/Requirement/Pre-requisites:
@@ -45,6 +46,7 @@
 #include <e32test.h>
 #include <e32svr.h>
 #include <e32ver.h>
+#include <e32panic.h>
 #include "../misc/prbs.h"
 
 struct TCObjectDump
@@ -206,6 +208,7 @@
 	void Test6(void);
 	void Test7(void);
 	void Test8(void);
+	void Test9(void);
 private:
 	static void GetObjName(TName& aDest,const CObject& aObj);
 	static void GetObjFullName(TFullName& aDest,const CObject& aObj);
@@ -360,6 +363,9 @@
 	pCon->AddL(pObj2);
 	test(pCon->Count()==2);
 
+	test((*pCon)[0]==pObj1);
+	test((*pCon)[1]==pObj2);
+
 	aFindHandle=0;
 	test(pCon->FindByName(aFindHandle, _L("xxx"), gName)==KErrNotFound);
 	aFindHandle=0;
@@ -746,6 +752,119 @@
 
 	}
 
+
+TInt PanicCObjectConIndexOutOfRangeFn(TAny* aCObjectCon)
+	{	
+	CObjectCon* pCObjectCon=(CObjectCon*)aCObjectCon;
+	(*pCObjectCon)[1]; // no objects added to the container
+	return KErrNone; // should not come here
+	}
+
+TInt PanicCObjectConFindIndexOutOfRangeFn(TAny* aCObjectCon)
+	{
+	CObjectCon* pCObjectCon=(CObjectCon*)aCObjectCon;
+	TInt aFindHandle=1;
+	pCObjectCon->At(aFindHandle);
+	return KErrNone; // should not come here
+	}
+
+TInt PanicCObjectConFindBadHandleFn(TAny* aCObjectCon)
+	{	
+	CObjectCon* pCObjectCon=(CObjectCon*)aCObjectCon;
+	TInt aFindHandle=KMaxTInt;
+	pCObjectCon->At(aFindHandle);
+	return KErrNone; // should not come here
+	}
+
+TInt PanicCObjectIxIndexOutOfRangeFn(TAny* aCObjectIx)
+	{	
+	CObjectIx* pCObjectIx=(CObjectIx*)aCObjectIx;
+	(*pCObjectIx)[1]; // no objects added to the container
+	return KErrNone; // should not come here
+	}
+	
+void StartPanicTest(TInt aPanicType)
+	{
+	CObjectCon* pCObjectCon=CObjectCon::NewL();
+	CObjectIx* pCObjectIx=CObjectIx::NewL();
+	RThread thread;
+	TRequestStatus status;
+	TInt r=KErrNone;
+
+	switch (aPanicType)
+		{
+		case 0:		// this index used for (PanicCObjectIxIndexOutOfRange) CObjectIx index out of range
+			r=thread.Create(_L("PanicCObjectIxIndexOutOfRangeThread"),PanicCObjectIxIndexOutOfRangeFn,KDefaultStackSize,NULL,(TAny*)pCObjectIx);
+			break;
+		case EObjFindBadHandle:			// for testing CObjectCon panic (PanicCObjectConFindBadHandle)
+			r=thread.Create(_L("PanicCObjectConFindBadHandleThread"),PanicCObjectConFindBadHandleFn,KDefaultStackSize,NULL,(TAny*)pCObjectCon);
+			break;
+		case EObjFindIndexOutOfRange:	// for testing CObjectCon panic (PanicCObjectConFindIndexOutOfRange)
+			r=thread.Create(_L("PanicCObjectConFindIndexOutOfRangeThread"),PanicCObjectConFindIndexOutOfRangeFn,KDefaultStackSize,NULL,(TAny*)pCObjectCon);
+			break;
+		case EArrayIndexOutOfRange:		// for testing CObjectCon panic (PanicCObjectConIndexOutOfRange)
+			r=thread.Create(_L("PanicCObjectConIndexOutOfRangeThread"),PanicCObjectConIndexOutOfRangeFn,KDefaultStackSize,NULL,(TAny*)pCObjectCon);
+			break;
+		default:
+			break;
+		}
+
+	test (r==KErrNone);
+	thread.SetPriority(EPriorityMore);
+	thread.Logon(status);
+	thread.Resume();
+	User::WaitForRequest(status);
+
+	test(status.Int() != KErrNone);
+	test(thread.ExitType()==EExitPanic);
+	test(thread.ExitCategory()==_L("E32USER-CBase"));
+
+	switch (aPanicType)
+		{
+		case 0:		// this index used for (PanicCObjectIxIndexOutOfRange) CObjectIx index out of range
+			test(thread.ExitReason()==EArrayIndexOutOfRange);
+			break;
+		case EObjFindBadHandle:			// for testing CObjectCon panic (PanicCObjectConFindBadHandle)
+			test(thread.ExitReason()==EObjFindBadHandle);
+			break;
+		case EObjFindIndexOutOfRange:	// for testing CObjectCon panic (PanicCObjectConFindIndexOutOfRange)
+			test(thread.ExitReason()==EObjFindIndexOutOfRange);
+			break;
+		case EArrayIndexOutOfRange:		// for testing CObjectCon panic (PanicCObjectConIndexOutOfRange)
+			test(thread.ExitReason()==EArrayIndexOutOfRange);
+			break;
+		default:
+			break;
+		}
+	
+	CLOSE_AND_WAIT(thread);
+	delete pCObjectCon;
+	delete pCObjectIx;
+	}
+
+
+GLDEF_C void TestCObjects::Test9(void)
+	{
+	// Disable JIT debugging.
+	TBool justInTime=User::JustInTime();
+	User::SetJustInTime(EFalse);
+
+	test.Next(_L("test PanicCObjectConFindBadHandle"));
+	StartPanicTest(EObjFindBadHandle);
+	test.Next(_L("test PanicCObjectConFindIndexOutOfRange"));
+	StartPanicTest(EObjFindIndexOutOfRange);
+	test.Next(_L("test PanicCObjectConIndexOutOfRange"));
+	StartPanicTest(EArrayIndexOutOfRange);
+	test.Next(_L("test PanicCObjectIxIndexOutOfRange"));
+	StartPanicTest(0);
+
+	// Put JIT debugging back to previous status.
+	User::SetJustInTime(justInTime);
+
+	test.End();
+	}
+
+
 GLDEF_C void TestCObjects::GetObjName(TName& aDest,const CObject& aObj)
 //
 // Utility function to reduce stack usage in functions, and so get rid of __chkstk errors
@@ -1055,7 +1174,9 @@
 		
 		TInt handle = ix->AddL(obj);
 		test(ix->At(handle) == obj);
+		test(ix->AtL(handle) == obj);
 		test(ix->At(handle, con->UniqueID()) == obj);
+		test(ix->AtL(handle, con->UniqueID()) == obj);
 
 		TName name;
 		TInt findHandle = 0;
@@ -1178,6 +1299,10 @@
 		test.Printf(_L("TestCObjectConIxL left with %d\n"), err);
 	test(err == KErrNone);
 
+	//Test Panics
+	test.Start(_L("Test Panic functions"));
+	T.Test9();
+
 	test.End();
 
    	delete trapHandler;
--- a/kerneltest/e32test/system/t_ctrap.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/system/t_ctrap.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -39,6 +39,8 @@
 // - Test that the Cleanup stack can go re-entrant.
 // - Ensure that the stack is properly balanced with and without
 // leaving.
+// - Test creating cleanup with CCleanup::NewL in normal
+// memory conditions and condition where heap is full (panic)
 // Platforms/Drives/Compatibility:
 // All.
 // Assumptions/Requirement/Pre-requisites:
@@ -62,9 +64,11 @@
 
 const TInt KLeaveValue=0x12345678;
 const TInt KMaxAlloc=6;	
+const TInt KTableSize = 1000;
 
 static const TInt KHeapSize = 0x2000;
 
+
 enum TWhat {EPop,EPopAndDestroy,EMulti,ENull};
 
 class CTest : public CBase
@@ -1538,6 +1542,70 @@
 	test.End();
 	}
 
+void testCCleanupNewL()
+	{
+	// don't want just in time debugging as we trap panics
+	TBool justInTime=User::JustInTime(); 
+	User::SetJustInTime(EFalse); 
+
+	// no need to test otherwise, since this calls only
+	// CCleanup::New and that has been tested.
+	test.Start(_L("Create cleanup NewL"));
+	CCleanup* pC=CCleanup::NewL();
+	test(pC!=NULL);
+	delete pC;
+
+	TAny* ptrTable[KTableSize];
+	TInt allocSize=sizeof(CCleanup);
+	TAny* ptr=0;
+
+	__UHEAP_MARK;
+
+	TInt i=0;
+	// first alloc 4Kb bits
+	do
+		{
+		ptr=User::Alloc(0x1000);
+		if(ptr!=NULL)
+			{
+			ptrTable[i]=ptr;
+			i++;
+			}
+		}
+		while (ptr!=NULL && i<KTableSize);
+
+	// then eat memory with size of CCleanup object granurality
+	do
+		{
+		ptr=User::Alloc(allocSize);
+		if(ptr!=NULL)
+			{
+			ptrTable[i]=ptr;
+			i++;
+			}
+		}
+		while (ptr!=NULL && i<KTableSize);
+	
+	i--; // last one failed, so lets adjust this to last successfull entry
+
+	TInt r=KErrNone;
+	test.Next(_L("Create cleanup NewL while no room in heap"));
+	TRAP(r,pC=CCleanup::NewL());
+	test_Equal(KErrNoMemory,r);
+
+	for (;i>=0;i--)
+		{
+		User::Free(ptrTable[i]);
+		}
+	
+	__UHEAP_MARKEND;
+
+	//restore settings
+	User::SetJustInTime(justInTime); 
+
+	test.End();
+	}
+
 GLDEF_C TInt E32Main()
     {
 	test.Title();
@@ -1597,6 +1665,11 @@
 	test.Next(_L("Test TRAP_IGNORE"));
 	testTrapIgnore();
 
+	test.Next(_L("Test CCleanup::NewL"));
+	testCCleanupNewL();
+
+	delete pT;
+
 	test.End();
 	return(0);
     }
--- a/kerneltest/e32test/system/t_inf.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/e32test/system/t_inf.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -43,7 +43,7 @@
 // Test the HAL info.
 //
 	{
-
+	test.Next(_L("Test UserHal::MemoryInfo"));
     TInt pageSize=0;
     UserHal::PageSizeInBytes(pageSize);
 
@@ -56,55 +56,43 @@
 	TInt freeMem=memoryInfo.iFreeRamInBytes;
 #endif
 	TInt8* someMem = new TInt8[0x4000];
+	// make an access to each page in order to get pages actually allocated also on data paged systems
+	someMem[0]=1;
+	someMem[0x1000]=2;
+	someMem[0x2000]=3;
+	someMem[0x3000]=4;
  	UserHal::MemoryInfo(membuf);
 	delete someMem;
 #if !defined(__WINS__)
-	test(freeMem>memoryInfo.iFreeRamInBytes);
+	if (!(freeMem>memoryInfo.iFreeRamInBytes))
+		test.Printf(_L("Warning: free RAM value didn't go down"));
 #endif
 
     test.Printf(_L("Total RAM size= %- 5dKBytes      : Free RAM size   = %- 5dKBytes\n"),memoryInfo.iTotalRamInBytes/1024,memoryInfo.iFreeRamInBytes/1024);
     test.Printf(_L("Max free RAM  = %- 5dKBytes      : ROM size        = %- 5dKBytes\n"),memoryInfo.iMaxFreeRamInBytes/1024,memoryInfo.iTotalRomInBytes/1024);
 	test.Printf(_L("RAM disk size = %- 5dKBytes\n"),memoryInfo.iInternalDiskRamInBytes/1024);
 
+	test.Next(_L("Test UserHal::MachineInfo"));
+
     TMachineInfoV2Buf mbuf;
     UserHal::MachineInfo(mbuf);
     TMachineInfoV2& machineInfo=*(TMachineInfoV2*)mbuf.Ptr();
 
-        TName tn = machineInfo.iRomVersion.Name();
+    TName tn = machineInfo.iRomVersion.Name();
  	test.Printf(_L("Page Size     = %- 16d : Rom version     = %- 16S\n"),pageSize,&tn);
    	test.Printf(_L("ScreenOffsetX = %- 16d : ScreenOffsetY   = %- 16d\n"),machineInfo.iOffsetToDisplayInPixels.iX,machineInfo.iOffsetToDisplayInPixels.iY);
    
-        TBool password=EFalse; // Password::IsEnabled(); This API was removed by __SECURE_API__
+    TBool password=EFalse; // Password::IsEnabled(); This API was removed by __SECURE_API__
   
-        TPtrC t1=onOff(password);
-        TPtrC t2=yesNo(machineInfo.iBacklightPresent);
+    TPtrC t1=onOff(password);
+    TPtrC t2=yesNo(machineInfo.iBacklightPresent);
+
  	test.Printf(_L("Password      = %- 16S : BacklightPresent= %S\n"),&t1,&t2);
 	test.Printf(_L("LanguageIndex = %- 16d : KeyboardIndex   = %d\n"),machineInfo.iLanguageIndex,machineInfo.iKeyboardIndex);
 
+	test.Next(_L("Test deprecated UserHal::RomInfo API"));
 	TRomInfoV1Buf rombuf;
-	TRomInfoV1& rom=rombuf();
-	if (UserHal::RomInfo(rombuf)==KErrNone)		// KErrNotSupported in WINS
-		{
-		test.Getch();
-		TInt i, j;
-		j=0;
-		for( i=2; i<8; i++ )
-			{
-			j |= rom.iEntry[i].iSize;
-			j |= rom.iEntry[i].iWidth;
-			j |= rom.iEntry[i].iSpeed;
-			j |= (TInt)rom.iEntry[i].iType;
-			}
-		test(j==0);		// check that CS2-7 entries left blank
-		test.Printf(_L("CS0 ROM size      %08X\n"), rom.iEntry[0].iSize );
-		test.Printf(_L("CS0 ROM width     %d\n"), rom.iEntry[0].iWidth );
-		test.Printf(_L("CS0 ROM speed     %d\n"), rom.iEntry[0].iSpeed );
-		test.Printf(_L("CS0 ROM type      %d\n"), rom.iEntry[0].iType );
-		test.Printf(_L("CS1 ROM size      %08X\n"), rom.iEntry[1].iSize );
-		test.Printf(_L("CS1 ROM width     %d\n"), rom.iEntry[1].iWidth );
-		test.Printf(_L("CS1 ROM speed     %d\n"), rom.iEntry[1].iSpeed );
-		test.Printf(_L("CS1 ROM type      %d\n"), rom.iEntry[1].iType );
-		}
+	test(UserHal::RomInfo(rombuf)==KErrNotSupported); // kernel side API has been deprecated
 	}
 
 GLDEF_C TInt E32Main()
@@ -112,10 +100,10 @@
 // Display system information
 //
     {
-
 	test.Title();
+	test.Start(_L("Test UserHal info APIs"));
 	testInfo();
-    test.Getch();
+	test.End();
 	return(KErrNone);
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/system/t_khal.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,278 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test\system\t_khal.cpp
+// Overview:
+// Test class Kern HAL APIs
+// API Information:
+// Kern::AddHalEntry(), Kern::RemoveHalEntry(), Kern::FindHalEntry()
+// Details:
+// - Adds a new HAL handler for EHalGroupPlatformSpecific2
+// - Tries to add handler for an existing group
+// - Calls the installed handler
+// - Tests Find API to find the installed handler 
+// - Removes the handler and tries to remove some fixed HAL group
+// - Tries to find removed handler
+// - Tries to call removed handler
+// Platforms/Drives/Compatibility:
+// All.
+// Assumptions/Requirement/Pre-requisites:
+// Failures and causes:
+// Base Port information:
+// 
+//
+
+#define __E32TEST_EXTENSION__
+
+#include <e32test.h>
+#include <e32hal.h>
+#include <u32hal.h>
+#include <e32svr.h>
+#include "d_khal.h"
+#include <hal.h>
+
+RLddKHalTest gLdd;
+GLDEF_D RTest test(_L("T_KHAL - class Kern HAL API test"));
+
+
+TBool gEntryForDevice0Registered; // indicator whether the device0 got registered
+TBool gEntryForDeviceXRegistered; // indicator whether the deviceX got registered
+TInt gTestDeviceNumber;			  // device number that was registered
+
+
+void TestAddHalHandler()
+	{
+	TInt r;
+
+	// Try to register PlatformSpecific2 handler for Device 0
+	test.Next(_L("Register new HAL handler - device 0"));
+	r=gLdd.AddHalEntryDevice0();
+	// we dont want to test() the value, since it might actually not be able to register the
+	// default device, if one already exists in the system
+	if (r==KErrNone)
+		{
+		gEntryForDevice0Registered=ETrue;
+		}
+	else
+		{
+		gEntryForDevice0Registered=EFalse;
+		test.Printf(_L("Couldn't register handler for device 0 (r=%d). Some test cases will not be executed"),r);
+		}
+	// lets try again for device0 if succeeded for the first time, should return error
+	if (gEntryForDevice0Registered)
+		{
+		test.Next(_L("Try to register new HAL handler again for Device0"));
+		test_Equal(KErrInUse,gLdd.AddHalEntryDevice0());
+		}
+
+	// Try to register PlatformSpecific2 handler for Device X. Trying for multiple devices, so
+	// it's highly unlikely that baseport has added this many devices for this group.
+	test.Next(_L("Register new HAL handler - device X"));
+	
+	r=gLdd.AddHalEntryDeviceX();
+	if (r==KErrNone)
+		{
+		gEntryForDeviceXRegistered = ETrue;
+		}
+	else
+		{
+		gEntryForDeviceXRegistered = EFalse;
+		test.Printf(_L("FAILED to register any device for EHalGroupPlatformSpecific2 (r=%d). Some test cases will not be executed"),r);
+		}
+
+    test_Value(r, (r==KErrNone || r==KErrInUse)); // this should not fail, but if it does, print indication
+
+	if (gEntryForDeviceXRegistered)
+		{
+		gTestDeviceNumber=gLdd.GetRegisteredDeviceNumber();
+		test(gTestDeviceNumber != KErrNotFound);
+		}
+
+	test.Next(_L("Try to register new HAL handler for fixed group (EHalGroupKernel) - should not be possible"));
+	test_Equal(KErrArgument,gLdd.AddHalEntryForExistingFixed());
+	}
+
+void TestCallHalHandler()
+	{
+	test.Next(_L("Call HAL handler function - device 0"));
+	if (gEntryForDevice0Registered)
+		{
+		test_KErrNone(UserSvr::HalFunction(EHalGroupPlatformSpecific2,RLddKHalTest::ETestHalFunc,0,0));
+		}
+	else
+		{
+		test.Printf(_L("Didn't try to call handler for device 0, since it wasn't registered in the beginning"));
+		}
+
+	test.Next(_L("Call HAL handler function - device X"));
+	if (gEntryForDeviceXRegistered)
+		{
+		test_KErrNone(UserSvr::HalFunction(EHalGroupPlatformSpecific2,RLddKHalTest::ETestHalFunc,0,0,gTestDeviceNumber));
+		}
+	else
+		{
+		test.Printf(_L("Didn't try to call handler for device x, since it wasn't registered in the beginning"));
+		}
+	}
+
+void TestCallRemovedHalHandler()
+	{
+	TInt r;
+
+	test.Next(_L("Call removed HAL handler function - device 0"));
+	if (gEntryForDevice0Registered)
+		{
+		r=UserSvr::HalFunction(EHalGroupPlatformSpecific2,RLddKHalTest::ETestHalFunc,0,0);
+		test_Compare(r, !=, KErrNone);
+		}
+	else
+		{
+		test.Printf(_L("Didn't try to call removed handler for device 0, since it wasn't registered in the beginning"));
+		}
+
+	test.Next(_L("Call removed HAL handler function - device X"));
+	if (gEntryForDeviceXRegistered)
+		{
+		r=UserSvr::HalFunction(EHalGroupPlatformSpecific2,RLddKHalTest::ETestHalFunc,0,0,gTestDeviceNumber);
+		test_Compare(r, !=, KErrNone);
+		}
+	else
+		{
+		test.Printf(_L("Didn't try to call removed handler for device x, since it wasn't registered in the beginning"));
+		}
+	}
+
+void TestFindHalHandler()
+	{
+	test.Next(_L("Try with one parameter find (device 0) for own handler"));
+	if (gEntryForDevice0Registered)
+		{
+		test_KErrNone(gLdd.FindHalEntryDevice0());
+		}
+	else
+		{
+		test.Printf(_L("Didn't try to find handler for device 0, since it wasn't registered in the beginning"));
+		}
+
+	test.Next(_L("Try with one parameter find (device 0) for an existing group"));
+	test_KErrNone(gLdd.FindHalEntryDevice0Other()); // should find because trying to get EHalGroupKernel, which must exist
+
+	test.Next(_L("Try with two parameter find (device x)"));
+	if (gEntryForDeviceXRegistered)
+		{
+		test_KErrNone(gLdd.FindHalEntryDeviceX()); // should find because handler for device x has been registered
+		}
+	else
+		{
+		test.Printf(_L("Didn't try to find handler for device X, since it wasn't registered in the beginning"));
+		}
+	}
+
+void TestRemoveHalHandler()
+	{
+	test.Next(_L("Remove HAL handler - device 0"));
+	if (gEntryForDevice0Registered)
+		{
+		test_KErrNone(gLdd.RemoveHalEntryDevice0());
+		}
+	else
+		{
+		test.Printf(_L("Didn't try to remove handler for device 0, since it wasn't registered in the beginning"));
+		}
+
+	test.Next(_L("Remove HAL handler - device X"));
+	if (gEntryForDeviceXRegistered)
+		{
+		test_KErrNone(gLdd.RemoveHalEntryDeviceX());
+		}
+	else
+		{
+		test.Printf(_L("Didn't try to remove handler for device x, since it wasn't registered in the beginning"));
+		}
+
+	test.Next(_L("Remove fixed HAL handler (EHalGroupKernel) - should not be possible"));
+	test_Equal(KErrArgument,gLdd.RemoveHalEntryExistingFixed());
+	}
+
+void TestFindRemovedHalHandler()
+	{
+	test.Next(_L("Try with one parameter find (device 0) for removed handler"));
+	if (gEntryForDevice0Registered)
+		{
+		test_Equal(KErrNotFound,gLdd.FindHalEntryDevice0());
+		}
+	else
+		{
+		test.Printf(_L("didn't try to find removed HAL handler for device 0 since it wasn't registered in the beginning"));
+		}
+
+	test.Next(_L("Try with two parameter find (device x) for removed handler"));
+	if (gEntryForDeviceXRegistered)
+		{
+		test_Equal(KErrNotFound,gLdd.FindHalEntryDeviceX());
+		}
+	else
+		{
+		test.Printf(_L("didn't try to find removed HAL handler for device X since it wasn't registered in the beginning"));
+		}
+	}
+
+void LoadDeviceDriver()
+	{
+	test_KErrNone(User::LoadLogicalDevice(KLddName));
+	test_KErrNone(gLdd.Open());
+	}
+
+void UnLoadDeviceDriver()
+	{
+	gLdd.Close();
+	test_KErrNone(User::FreeLogicalDevice(KLddName));
+	}
+
+
+GLDEF_C TInt E32Main()
+//
+// Test Kern HAL API
+//
+	{
+	test.Title();
+
+	test.Start(_L("Test class Kern HAL API functions"));
+	// load the driver
+	LoadDeviceDriver();
+
+	// add handlers for default device (0) and Device X
+	TestAddHalHandler();
+	
+	// call handlers that were managed to register
+	TestCallHalHandler();
+
+	// test find APIs
+	TestFindHalHandler();
+
+	// test removal of HAL handlers
+	TestRemoveHalHandler();
+
+	// test find APIs for removed handlers
+	TestFindRemovedHalHandler();
+
+	// try to call removed handlers
+	TestCallRemovedHalHandler();
+
+	// unload the driver
+	UnLoadDeviceDriver();
+
+	test.End();
+	test.Close();
+ 	return(KErrNone);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/system/t_reason2.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,141 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test\system\t_reason2.cpp
+// Overview:
+// Tests system startup reason HAL functions and exception info functions:
+// API Information:
+// UserHal::StartupReason() (deprecated), HAL:.Get(ESystemStartupReason,..),
+// UserHal::FaultReason, UserHal::ExceptionId and UserHal::ExceptionInfo
+// Details:
+// - Asks system startup reason from user hal
+// - Asks system startup reason with replacing hal::get method
+// - Asks Exception info
+// Platforms/Drives/Compatibility:
+// All.
+// Assumptions/Requirement/Pre-requisites:
+// Failures and causes:
+// Base Port information:
+// 
+//
+#define __E32TEST_EXTENSION__
+
+#include <e32hal.h>
+#include <e32test.h>
+#include <hal.h>
+#include <u32hal.h>
+#include <e32svr.h>
+
+LOCAL_D RTest test(_L("T_REASON2"));
+
+TInt gSysReason=KErrNotSupported;
+
+void GetSysStartupReason()
+	{
+	test.Next(_L("Get startup reason using (deprecated) UserHal::StartupReason API"));
+
+	TMachineStartupType reason;
+
+	test_KErrNone(UserHal::StartupReason(reason));
+	switch (reason)
+		{
+		case EStartupCold:			RDebug::Print(_L("Cold Start    ")); break;
+		case EStartupColdReset: 	RDebug::Print(_L("Cold Reset    ")); break;
+		case EStartupNewOs: 		RDebug::Print(_L("New OS        ")); break;
+		case EStartupPowerFail:		RDebug::Print(_L("Power failed  ")); break;
+		case EStartupWarmReset:		RDebug::Print(_L("Warm Reset    ")); break;
+		case EStartupKernelFault:	RDebug::Print(_L("Kernel fault  ")); break;
+		case EStartupSafeReset:		RDebug::Print(_L("Safe Reset    ")); break;
+		default:
+			RDebug::Print(_L("<?reason=%d>  "), reason);
+			test(EFalse); // fail, unknown reason returned
+			break;
+		}
+
+	// test the replacing API
+	TInt r=KErrNone;
+	test.Next(_L("Get system startup reason using HAL::Get()"));
+	r=HAL::Get(HAL::ESystemStartupReason,gSysReason);
+#if defined(__WINS__)
+	test(r=KErrNotSupported);
+#else
+	test_KErrNone(r);
+	switch (gSysReason)
+		{
+		case HAL::ESystemStartupReason_Cold:	RDebug::Print(_L("reason:Cold ")); break;
+		case HAL::ESystemStartupReason_Warm:	RDebug::Print(_L("reason:Warm ")); break;
+		case HAL::ESystemStartupReason_Fault: 	RDebug::Print(_L("reason:Fault")); break;
+		default:
+			RDebug::Print(_L("<?reason=%d>  "), gSysReason);
+			test(EFalse); // fail, unknown reason returned
+			break;
+		}
+#endif
+	}
+
+void GetExceptionInfo()
+	{
+	test.Next(_L("Get exception ID"));
+	TInt exceptno;
+	TInt faultno;
+
+	TExcInfo exceptInfo;
+	test_KErrNone(UserHal::ExceptionId(exceptno));
+				
+	test.Next(_L("Get exception info"));
+	test_KErrNone(UserHal::ExceptionInfo(exceptInfo));
+
+	test.Next(_L("Get fault reason"));
+	test_KErrNone(UserHal::FaultReason(faultno));
+
+	if (gSysReason==HAL::ESystemStartupReason_Warm || gSysReason==HAL::ESystemStartupReason_Fault)
+		{
+		RDebug::Print(_L("(last exception %d: code %08x data %08x) "), exceptno, exceptInfo.iCodeAddress,exceptInfo.iDataAddress);
+		}
+				
+	if (gSysReason==HAL::ESystemStartupReason_Fault)
+		{
+		if (faultno == 0x10000000)
+			{
+			RDebug::Print(_L("Kernel Exception  "));
+			}
+		else
+			{
+			if (faultno >= 0x10000)
+				{
+				RDebug::Print(_L("Kernel PANIC: %d  "), faultno-0x10000);
+				}
+			else
+				{
+				RDebug::Print(_L("Kernel FAULT: %d  "), faultno);
+				}
+			}
+		}
+	}
+
+TInt E32Main()
+	{
+	test.Title();
+
+	test.Start(_L("Test startup reasons from Hal"));
+
+	// test startup reason
+	GetSysStartupReason();
+
+	// test exception and fault info UserHal functions
+	GetExceptionInfo();
+
+	test.End();
+
+	return KErrNone;
+	}
--- a/kerneltest/f32test/server/t_dspace.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/f32test/server/t_dspace.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -1697,6 +1697,102 @@
 
 	}
 
+//-------------------------------------------------------------------------------------------------
+// Test the fix for:
+// ou1cimx#410349 Not getting any Notification from RFs::NotifyDiskSpace() for E and F drive when when tested multiple
+// 
+// Action: Enable a plugin to intercept RFs::Delete, and test RFs::Delet can still trigger disk space
+// notification
+//-------------------------------------------------------------------------------------------------
+
+_LIT(KPreModifierPluginFileName,"premodifier_plugin");
+_LIT(KPreModifierPluginName,"PreModifierPlugin");
+const TUint KTestFileSize = KKilo * 100;
+
+#define SAFETEST_KErrNone(a)        if(a != KErrNone)\
+                                        {\
+                                        TheFs.DismountPlugin(KPreModifierPluginName);\
+                                        TheFs.RemovePlugin(KPreModifierPluginName);\
+                                        test_KErrNone(a);\
+                                        }
+
+TInt PluginTestThreadFunction(TAny*)
+    {
+    RTest test(_L("PluginTestThreadFunction"));
+    RFs fs;
+    fs.Connect();
+    
+    TInt r = fs.SetSessionPath(gSessionPath);
+    test_KErrNone(r);
+    
+    RFile file;
+    r = file.Create(fs, KTestFile1, EFileShareAny|EFileWrite);
+    test_KErrNone(r);
+    r = file.SetSize(KTestFileSize);
+    test_KErrNone(r);
+    file.Close();
+      
+    User::After(5000000); // wait for 5 seconds, to ensure first notification received.
+    
+    r = fs.Delete(KTestFile1);
+    test_KErrNone(r);
+    
+    fs.Close();
+    return KErrNone;
+    }
+
+void TestDiskSpaceNotifyWithPlugin()
+    {
+    test.Next(_L("Test Disk Space Notify With Plugin"));
+      
+    TInt drive;
+    TInt r = RFs::CharToDrive(gSessionPath[0],drive);
+    SAFETEST_KErrNone(r);
+    Format(drive);
+    
+    r = TheFs.MkDirAll(gSessionPath);
+    SAFETEST_KErrNone(r);
+     
+    r = TheFs.AddPlugin(KPreModifierPluginFileName);
+    SAFETEST_KErrNone(r);
+
+    r = TheFs.MountPlugin(KPreModifierPluginName);
+    SAFETEST_KErrNone(r);
+    
+    TInt64 free = FreeDiskSpace(drive);
+    TInt64 threshold = free - KTestFileSize + 1;
+    
+    TRequestStatus status;
+    TRequestStatus statusDeath;
+    
+    TheFs.NotifyDiskSpace(threshold, drive, status);
+    
+    RThread thread;
+    r = thread.Create(_L("PluginTestThread"), PluginTestThreadFunction, KStackSize, KHeapSize, KHeapSize, NULL);
+    SAFETEST_KErrNone(r);
+    thread.Logon(statusDeath);
+    thread.Resume();
+    
+    User::WaitForRequest(status);
+    SAFETEST_KErrNone(status.Int());
+    
+    TheFs.NotifyDiskSpace(threshold, drive, status);
+    User::WaitForRequest(status);
+    SAFETEST_KErrNone(status.Int());
+    
+    User::WaitForRequest(statusDeath);
+    SAFETEST_KErrNone(statusDeath.Int());
+    thread.Close();
+    
+    r = TheFs.DismountPlugin(KPreModifierPluginName);
+    SAFETEST_KErrNone(r);
+
+    r = TheFs.RemovePlugin(KPreModifierPluginName);
+    SAFETEST_KErrNone(r);
+
+    Format(drive);
+    }
+
 GLDEF_C void CallTestsL()
 //
 // Do all tests
@@ -1753,6 +1849,7 @@
 		}
 
 	TestChangeNotification();
+	TestDiskSpaceNotifyWithPlugin();
 
 	if( LffsDrive )
 		{
--- a/kerneltest/f32test/server/t_nmbs.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kerneltest/f32test/server/t_nmbs.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -18,6 +18,9 @@
 #include <e32test.h>
 #include "t_server.h"
 #include "t_chlffs.h"
+#include "f32_test_utils.h"
+
+using namespace F32_Test_Utils;
 
 GLDEF_D RTest test(_L("T_NMBS"));
 
@@ -225,13 +228,17 @@
 	}
 LOCAL_C void TestLongFileName()
 	{
-	#ifndef __EPOC32__ //emulator
-	if (gDriveToTest.GetLowerCase()=='c')
-		return;//don't perform this test for c: in emulator as emulator uses windows system calls
-		//windows doesn't create a directory with length more than 244 characters
-	#endif 
+	if (Is_SimulatedSystemDrive(TheFs, CurrentDrive()))
+		{
+		// Do not perform this test for the system drive of the emulator or PlatSim
+		// as they use Windows system calls.
+		// Windows does not create a directory with length more than 244 characters
+		// (247 including <drive>:\)
+		test.Printf(_L("TestLongFileName() skipped on simulated system drive.\n"));
+		return;
+		}
 	
-	 test.Next(_L("Test renaming 257 characters directories"));
+	test.Next(_L("Test renaming 257 characters directories"));
 	_LIT(KLongFileName256, "256dir_IncludingBackslash_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
 	_LIT(KLongFileName257, "257dir_IncludingBackslash_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
 	TBuf<260> Path;
@@ -884,7 +891,7 @@
 	r=file.Att(atts);
 	test_KErrNone(r);
 	file.Close();
-	test(atts&KEntryAttSystem);
+	test_Value((TInt)atts, atts&KEntryAttSystem);
 
 //	Change attributes to normal
 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
@@ -897,7 +904,7 @@
 	r=file.Att(atts);
 	test_KErrNone(r);
 	file.Close();
-	test(atts==KEntryAttNormal);
+	test_Value((TInt)atts, atts==KEntryAttNormal);
 
 //	Attempt to change attributes from normal file to directory	
 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
@@ -910,7 +917,7 @@
 	r=file.Att(atts);
 	test_KErrNone(r);
 	file.Close();
-	test((TInt)(atts&KEntryAttDir)==KErrNone);
+	test_Value((TInt)atts, (TInt)(atts&KEntryAttDir)==KErrNone);
 
 //	Change the attributes from normal file to hidden file
 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
@@ -923,7 +930,7 @@
 	r=file.Att(atts);
 	test_KErrNone(r);
 	file.Close();
-	test(atts&KEntryAttHidden);
+	test_Value((TInt)atts, atts&KEntryAttHidden);
 
 //	Try to change the attributes from hidden file to volume	
 	file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
@@ -936,7 +943,7 @@
 	r=file.Att(atts);
 	test_KErrNone(r);
 	file.Close();
-	test((TInt)(atts&KEntryAttVolume)==KErrNone);
+	test_Value((TInt)atts, (TInt)(atts&KEntryAttVolume)==KErrNone);
 
 //	Test RFile::Set() function	
 	
@@ -947,7 +954,7 @@
 	r=file.Att(atts);
 	test_KErrNone(r);
 	file.Close();
-	test(atts==KEntryAttNormal);
+	test_Value((TInt)atts, atts==KEntryAttNormal);
 
 //	Change attributes from hidden to system	- and change modification time
 	TDateTime dateTime(1998,EMay,25,18,23,0,0);
@@ -965,7 +972,7 @@
 	r=file.Modified(retTime);
 	test_KErrNone(r);
 	file.Close();
-	test(atts&KEntryAttSystem);
+	test_Value((TInt)atts, atts&KEntryAttSystem);
 	test(retTime==modTime1);
 
 //	Change attributes to normal - and change modification time
@@ -983,7 +990,7 @@
 	r=file.Modified(retTime);
 	test_KErrNone(r);
 	file.Close();
-	test(atts==KEntryAttNormal);
+	test_Value((TInt)atts, atts==KEntryAttNormal);
 	test(retTime==modTime2);
 
 //	Attempt to change attributes from normal file to directory	
@@ -999,7 +1006,7 @@
 	r=file.Modified(retTime);
 	test_KErrNone(r);
 	file.Close();
-	test((TInt)(atts&KEntryAttDir)==KErrNone);
+	test_Value((TInt)atts, (TInt)(atts&KEntryAttDir)==KErrNone);
 	test(retTime==modTime1);//	Modification time should have been set successfully
 
 //	Change the attributes from normal file to hidden file - and change modification time
@@ -1014,7 +1021,7 @@
 	test_KErrNone(r);
 	r=file.Modified(retTime);
 	file.Close();
-	test(atts&KEntryAttHidden);
+	test_Value((TInt)atts, atts&KEntryAttHidden);
 	test(retTime==modTime1);
 
 //	Try to change the attributes from hidden file to volume	
@@ -1030,7 +1037,7 @@
 	r=file.Modified(retTime);
 	test_KErrNone(r);
 	file.Close();
-	test((TInt)(atts&KEntryAttVolume)==KErrNone);
+	test_Value((TInt)atts, (TInt)(atts&KEntryAttVolume)==KErrNone);
 	test(retTime==modTime2);	//	Modification time should have been set successfully
 	
 	r=TheFs.Delete(_L("TEMPFILE.TMP"));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_map.xml	Mon Jul 26 10:52:56 2010 +0100
@@ -0,0 +1,1 @@
+<PackageMap root="sf" layer="os"/>
--- a/userlibandfileserver/fileserver/group/release.txt	Mon Jul 12 14:24:01 2010 +0100
+++ b/userlibandfileserver/fileserver/group/release.txt	Mon Jul 26 10:52:56 2010 +0100
@@ -1,3 +1,25 @@
+Version 2.00.3054
+=================
+(Made by fadhliM 19/07/2010)
+
+1.	migubarr
+	1.	ou1cimx1#476545 Inefficiencies in RFile::SetSize() & RFile::Write()
+
+
+Version 2.00.3053
+=================
+(Made by famustaf 12/07/2010)
+
+1.	h14jiang
+	1.	ou1cimx1#428840 Not getting any Notification from RFs::NotifyDiskSpace() for E and F drive when when tested multiple time.
+
+2.	famustaf
+	1.	ou1cimx1#466351 Modify t_nmbs for Platsim's HVFS
+
+3.	migubarr
+	1.	ou1cimx1#437919 File Server flushes FAT metadata too often
+
+
 Version 2.00.3052
 =================
 (Made by famustaf 01/07/2010)
--- a/userlibandfileserver/fileserver/inc/f32ver.h	Mon Jul 12 14:24:01 2010 +0100
+++ b/userlibandfileserver/fileserver/inc/f32ver.h	Mon Jul 26 10:52:56 2010 +0100
@@ -58,6 +58,6 @@
 
 @see TVersion
 */
-const TInt KF32BuildVersionNumber=3052;
+const TInt KF32BuildVersionNumber=3054;
 //
 #endif
--- a/userlibandfileserver/fileserver/sfat32/inc/sl_std.h	Mon Jul 12 14:24:01 2010 +0100
+++ b/userlibandfileserver/fileserver/sfat32/inc/sl_std.h	Mon Jul 26 10:52:56 2010 +0100
@@ -863,7 +863,6 @@
 	void SetSeekIndexValueL(TUint aFileCluster,TUint aStoredCluster);
 	void ResizeIndex(TInt aNewMult,TUint aNewSize);
 	TInt CalcSeekIndexSize(TUint aSize);
-	TBool IsSeekBackwards(TUint aPos);
 	void ClearIndex(TUint aNewSize);
 	void DoSetSizeL(TUint aSize, TBool aForceCachesFlush);
 	void WriteFileSizeL(TUint aSize);
--- a/userlibandfileserver/fileserver/sfat32/sl_file.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/userlibandfileserver/fileserver/sfat32/sl_file.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -103,18 +103,6 @@
     iSeekIndex[seekPos] = aStoredCluster;
     }
 
-TBool CFatFileCB::IsSeekBackwards(TUint aPos)
-//
-// Return true if aPos<currentPos
-//
-    {
-    
-    TUint cluster=iCurrentPos.iCluster<<ClusterSizeLog2();
-    TInt offset=ClusterRelativePos(iCurrentPos.iPos);
-    TUint currentPos=cluster+offset;
-    return(aPos<currentPos);
-    }
-
 void CFatFileCB::CheckPosL(TUint aPos)
 //
 // Check that the file is positioned correctly.
@@ -126,9 +114,6 @@
         return;
     __ASSERT_DEBUG(aPos <= FCB_FileSize(), Fault(EFatFilePosBeyondEnd));
 
-    if (FileSizeModified() && IsSeekBackwards(aPos))
-        FlushDataL(); 
-    
     TUint newRelCluster=aPos>>ClusterSizeLog2();
     if ( aPos && (aPos==(newRelCluster<<ClusterSizeLog2())) )
         newRelCluster--;
--- a/userlibandfileserver/fileserver/sfile/sf_file.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_file.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -970,10 +970,6 @@
         {//-- this call is originated from explicit file write operation. Set 'Archive' attribute and new file time.
         aFile->SetArchiveAttribute(); //-- it will also set KEntryAttModified
         }
-    else
-        {//-- don't touch data and attributes if it is cache flushing dirty data
-        aFile->iAtt |= KEntryAttModified;
-        }
 
 
 	return KErrNone;
@@ -1587,13 +1583,11 @@
 	
 	CFileCB& file=share->File();
 
-	// flush the write cache
-	CFileCache* fileCache = share->File().FileCache();
-	if (fileCache && (r = fileCache->FlushDirty(aRequest)) != CFsRequest::EReqActionComplete)
-		return r;
-	
 	if (size==file.Size64())
+		{
+		file.SetCachedSize64(size);	// Ensure the cache size doesn't exceeed the physical size
 		return(KErrNone);
+		}
 	
 	TBool fileHasGrown = size > file.Size64();
 	if (fileHasGrown)
--- a/userlibandfileserver/fileserver/sfile/sf_request.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_request.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -1116,7 +1116,9 @@
 		}
 
 	SetError(err);
-
+	
+    if (IsExpectedResult(err) && !IsPluginSpecific() && !IsNotifierSpecific())
+        DoNotifyDiskSpace(KErrNone);
 
 	// Start issuing the post-operation requests starting from the bottom of the chain
 	iCurrentPlugin = NULL;
@@ -1142,16 +1144,6 @@
 	{
 	__THRD_PRINT2(_L("----- CFsMessageRequest::Complete() req %08x with %d"), this, aError);
 
-	if (aError==KErrNoMemory)
-		{
-		if (iDrive)	// Not all message requests are associated with a drive!
-			{
-			TDriveInfo di;
-			iDrive->DriveInfo(di);
-			if (di.iType == EMediaRam)
-				aError = KErrNoMemory;
-			}
-		}
 	if(aError!=KErrNone)
 		{
 		if(iOperation->IsOpenSubSess())
@@ -1298,9 +1290,7 @@
 	if(aError==KErrNone)
 		{
 		if(!(FsNotify::IsChangeQueEmpty(driveNumber)))
-			FsNotify::HandleChange(this,driveNumber);	
-		if ((driveNumber != KDriveInvalid) && !(FsNotify::IsDiskSpaceQueEmpty(driveNumber)))
-			FsNotify::HandleDiskSpace(this, DriveNumber());
+			FsNotify::HandleChange(this,driveNumber);
 	
 #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
 		if 	(iOperation->iFunction == EFsFileWrite)
@@ -1337,6 +1327,16 @@
 		}
 	}
 
+void CFsMessageRequest::DoNotifyDiskSpace(TInt aError)
+    {
+    __PRINT1(_L("----- CFsMessageRequest::DoNotifyDiskSpace() with %d"),aError);
+    if(aError != KErrNone)
+        return;
+
+    TInt driveNumber = DriveNumber();
+    if ((driveNumber != KDriveInvalid) && !(FsNotify::IsDiskSpaceQueEmpty(driveNumber)))
+        FsNotify::HandleDiskSpace(this, driveNumber);
+    }
 
 void CFsMessageRequest::Free()
 //
--- a/userlibandfileserver/fileserver/sfile/sf_std.h	Mon Jul 12 14:24:01 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_std.h	Mon Jul 26 10:52:56 2010 +0100
@@ -32,7 +32,7 @@
 #include <e32const_private.h>
 #include "sf_plugin.h"
 #include "sf_func.h"
-#include <f32plugin.h>
+#include <F32plugin.h>
 #include "f32trace.h"
 
 #define __PRINT1TEMP_ALWAYS(t,a) {{TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}}
@@ -1320,6 +1320,7 @@
    // TUid iUID;
 private:
 	void DoNotify(TInt aError);
+	void DoNotifyDiskSpace(TInt aError);
 	TInt DoInitialise();
 	TInt PostInitialise();
 	TBool DispatchToPlugin();