Revision: 201033
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 18 Aug 2010 11:08:29 +0300
changeset 247 d8d70de2bd36
parent 201 43365a9b78a3
child 250 ac18961ed598
child 259 57b9594f5772
Revision: 201033 Kit: 201033
bsptemplate/asspandvariant/template_variant/bld.inf
bsptemplate/asspandvariant/template_variant/camerasc/camerasc.cpp
bsptemplate/asspandvariant/template_variant/camerasc/camerasc_plat.h
bsptemplate/asspandvariant/template_variant/camerasc/camerasc_sensor.cpp
bsptemplate/asspandvariant/template_variant/camerasc/logo.cpp
bsptemplate/asspandvariant/template_variant/camerasc/logoyuv2.cpp
bsptemplate/asspandvariant/template_variant/camerasctemplate.mmp
bsptemplate/asspandvariant/template_variant/rom/base_template.iby
bsptemplate/asspandvariant/template_variant/rom/kernel.iby
build.config.xml
halservices/hal/bld.inf
kernel/eka/bld.inf
kernel/eka/bmarm/usbcscu.def
kernel/eka/common/mem.cpp
kernel/eka/common/win32/cmem.cpp
kernel/eka/debug/crashMonitor/inc/scmbytestreamutil.inl
kernel/eka/drivers/camerasc/base_drivers_camerasc.mrp
kernel/eka/drivers/camerasc/bld.inf
kernel/eka/drivers/camerasc/cameraldd.cpp
kernel/eka/drivers/camerasc/ecamerasc.mmp
kernel/eka/drivers/debug/group/bld.inf
kernel/eka/drivers/dma/dma2_pil.cpp
kernel/eka/drivers/dma/dmapil.cpp
kernel/eka/drivers/iic/iic.cpp
kernel/eka/drivers/locmedia/traces/OstTraceDefinitions.h
kernel/eka/drivers/medmmc/bgahsmmcptn.cpp
kernel/eka/drivers/medmmc/bgahsmmcptn.h
kernel/eka/drivers/medmmc/bgahsmmcptn.mmp
kernel/eka/drivers/medmmc/toc.cpp
kernel/eka/drivers/medmmc/toc.h
kernel/eka/drivers/medmmc/traces/OstTraceDefinitions.h
kernel/eka/drivers/pbus/mmc/traces/OstTraceDefinitions.h
kernel/eka/drivers/resourceman/resourcecontrol.cpp
kernel/eka/drivers/usbcsc/d_usbcsc.cpp
kernel/eka/drivers/usbcsc/usbcsc_bil.cpp
kernel/eka/eabi/usbcscu.def
kernel/eka/ewsrv/ky_capt.cpp
kernel/eka/ewsrv/ky_tran.cpp
kernel/eka/include/cpudefs.h
kernel/eka/include/d32camerasc.h
kernel/eka/include/d32camerasc.inl
kernel/eka/include/d32usbcsc.h
kernel/eka/include/d32usbcsc.inl
kernel/eka/include/drivers/camerasc.h
kernel/eka/include/drivers/camerasc.inl
kernel/eka/include/drivers/dma_hai.h
kernel/eka/include/drivers/dma_v1.h
kernel/eka/include/drivers/dma_v2.h
kernel/eka/include/drivers/iic.h
kernel/eka/include/drivers/iic_transaction.h
kernel/eka/include/drivers/iic_transaction.inl
kernel/eka/include/drivers/resmanus_trace.h
kernel/eka/include/drivers/resource.h
kernel/eka/include/drivers/resourcecontrol_trace.h
kernel/eka/include/drivers/rm_debug_eventhandler.h
kernel/eka/include/drivers/rm_debug_eventhandler.inl
kernel/eka/include/drivers/usbcsc.h
kernel/eka/include/e32btrace.h
kernel/eka/include/e32ktran.h
kernel/eka/include/e32ver.h
kernel/eka/include/k32keys.h
kernel/eka/include/k32keys.inl
kernel/eka/kernel/arm/ckernel.cpp
kernel/eka/kernel/ekern.mmp
kernel/eka/kernel/sbtrace.cpp
kernel/eka/kernel/sutils.cpp
kernel/eka/nkernsmp/nkern.mmp
kernel/eka/release.txt
kernel/eka/rombuild/h4usbtest.iby
kernelhwsrv_info/doc_pub/Base_SMP_Power_Management_Impacts_on_Kernel_Use_of_Hardware_Timers.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/bmarm/d_dma2_simu.def
kerneltest/e32test/bmarm/i2c_masterstubs_ctrlessu.def
kerneltest/e32test/bmarm/i2c_slavestubs_ctrlessu.def
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/bwins/d_dma2_simu.def
kerneltest/e32test/bwins/i2c_masterstubs_ctrlessu.def
kerneltest/e32test/bwins/i2c_slavestubs_ctrlessu.def
kerneltest/e32test/bx86/d_dma2_simu.def
kerneltest/e32test/defrag/t_ramdefrag.cpp
kerneltest/e32test/demandpaging/t_pagetable_limit.cpp
kerneltest/e32test/dll/t_xxver2.cpp
kerneltest/e32test/dma/d_dma.cpp
kerneltest/e32test/dmav2/cap_reqs.h
kerneltest/e32test/dmav2/d_dma2.cpp
kerneltest/e32test/dmav2/d_dma2.h
kerneltest/e32test/dmav2/d_dma2_cmn.cpp
kerneltest/e32test/dmav2/dma2_sim.cpp
kerneltest/e32test/dmav2/self_test.cpp
kerneltest/e32test/dmav2/t_dma2.cpp
kerneltest/e32test/dmav2/t_dma2.h
kerneltest/e32test/dmav2/test_cases.cpp
kerneltest/e32test/eabi/d_dma2_simu.def
kerneltest/e32test/eabi/i2c_masterstubs_ctrlessu.def
kerneltest/e32test/eabi/i2c_slavestubs_ctrlessu.def
kerneltest/e32test/eabi/t_usb_tranhandlesrvu.def
kerneltest/e32test/eabi/t_usb_transfersrvu.def
kerneltest/e32test/group/bld.inf
kerneltest/e32test/group/d_dma2_sim.mmp
kerneltest/e32test/group/d_khal.mmp
kerneltest/e32test/group/d_rescontrolclisync.mmp
kerneltest/e32test/group/refkeymap.mmp
kerneltest/e32test/group/t_atomicu.mmp
kerneltest/e32test/group/t_camera_api.mmp
kerneltest/e32test/group/t_camera_gen.mmp
kerneltest/e32test/group/t_khal.mmp
kerneltest/e32test/group/t_reason2.mmp
kerneltest/e32test/group/t_rescontrolclisync.mmp
kerneltest/e32test/group/t_usb_scdevice.mmp
kerneltest/e32test/group/t_usb_tranhandleclient.mmp
kerneltest/e32test/group/t_usb_transfersrv.mmp
kerneltest/e32test/group/t_usb_transfersrvclient.mmp
kerneltest/e32test/heap/t_kheap.cpp
kerneltest/e32test/iic/iic_psl/d_iic_client_stubs.mmp
kerneltest/e32test/iic/iic_psl/d_iic_slaveclient_stubs.mmp
kerneltest/e32test/iic/iic_psl/i2c.cpp
kerneltest/e32test/iic/iic_psl/i2c.h
kerneltest/e32test/iic/iic_psl/i2c_masterstubs_ctrless.mmp
kerneltest/e32test/iic/iic_psl/i2c_slavestubs_ctrless.mmp
kerneltest/e32test/iic/iic_psl/iic_client.cpp
kerneltest/e32test/iic/iic_psl/iic_slaveclient.cpp
kerneltest/e32test/iic/iic_psl/iic_testpsl.cpp
kerneltest/e32test/iic/iic_psl/iic_testpsl.h
kerneltest/e32test/iic/iic_psl/iic_testpsl.mmp
kerneltest/e32test/iic/t_iic.cpp
kerneltest/e32test/iic/t_iic.h
kerneltest/e32test/misc/t_zip.cpp
kerneltest/e32test/mmu/freeram.h
kerneltest/e32test/mmu/t_alias_remove.cpp
kerneltest/e32test/multimedia/t_camera_api.cpp
kerneltest/e32test/multimedia/t_camera_bitmap.cpp
kerneltest/e32test/multimedia/t_camera_bitmap.h
kerneltest/e32test/multimedia/t_camera_display.cpp
kerneltest/e32test/multimedia/t_camera_display.h
kerneltest/e32test/multimedia/t_camera_gen.cpp
kerneltest/e32test/pccd/t_medch.cpp
kerneltest/e32test/power/t_domain.cpp
kerneltest/e32test/resmanus/d_resmanusbtrace.cpp
kerneltest/e32test/resmanus/d_resmanusbtrace.h
kerneltest/e32test/resmanus/d_resmanusbtrace.mmp
kerneltest/e32test/resmanus/d_resmanusbtraceconst.h
kerneltest/e32test/resmanus/t_resmanusbtrace.cpp
kerneltest/e32test/resmanus/t_resmanusbtrace.mmp
kerneltest/e32test/resourceman/d_rescontrolclisync.cpp
kerneltest/e32test/resourceman/d_rescontrolclisync.h
kerneltest/e32test/resourceman/t_rescontrolclisync.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/e32test/usb/t_usb_device/configs/scvascobm.xml
kerneltest/e32test/usb/t_usb_device/configs/scvascoif0.xml
kerneltest/e32test/usb/t_usb_device/configs/scvascoif0a3.xml
kerneltest/e32test/usb/t_usb_device/configs/scvascoif0a3if1a2if2.xml
kerneltest/e32test/usb/t_usb_device/include/activecontrol.h
kerneltest/e32test/usb/t_usb_device/include/activedevicestatenotifier.h
kerneltest/e32test/usb/t_usb_device/include/activerw.h
kerneltest/e32test/usb/t_usb_device/include/activestallnotifier.h
kerneltest/e32test/usb/t_usb_device/include/general.h
kerneltest/e32test/usb/t_usb_device/include/tranhandleserver.h
kerneltest/e32test/usb/t_usb_device/include/tranhandleserverconsts.h
kerneltest/e32test/usb/t_usb_device/include/tranhandleserversecuritypolicy.h
kerneltest/e32test/usb/t_usb_device/include/tranhandlesession.h
kerneltest/e32test/usb/t_usb_device/include/tranhandlesrv.h
kerneltest/e32test/usb/t_usb_device/include/tranhandlsession.h
kerneltest/e32test/usb/t_usb_device/include/transferhandle.h
kerneltest/e32test/usb/t_usb_device/include/transferserver.h
kerneltest/e32test/usb/t_usb_device/include/transferserversecuritypolicy.h
kerneltest/e32test/usb/t_usb_device/include/transfersession.h
kerneltest/e32test/usb/t_usb_device/include/transfersrv.h
kerneltest/e32test/usb/t_usb_device/src/activecontrol.cpp
kerneltest/e32test/usb/t_usb_device/src/activedevicestatenotifier.cpp
kerneltest/e32test/usb/t_usb_device/src/activerw.cpp
kerneltest/e32test/usb/t_usb_device/src/main.cpp
kerneltest/e32test/usb/t_usb_device/src/tranhandleserver.cpp
kerneltest/e32test/usb/t_usb_device/src/tranhandlesession.cpp
kerneltest/e32test/usb/t_usb_device/src/tranhandlesrv.cpp
kerneltest/e32test/usb/t_usb_device/src/transferhandle.cpp
kerneltest/e32test/usb/t_usb_device/src/transferserver.cpp
kerneltest/e32test/usb/t_usb_device/src/transfersession.cpp
kerneltest/e32test/usb/t_usb_device/src/transfersrv.cpp
kerneltest/e32test/usb/t_usb_device/src/transfersrvmain.cpp
kerneltest/e32test/window/t_keys.cpp
kerneltest/f32test/filesystem/fat/t_mount.cpp
kerneltest/f32test/fileutils/inc/tf32testtimer.h
kerneltest/f32test/group/t_wcache.mmp
kerneltest/f32test/server/t_bigfile.cpp
kerneltest/f32test/server/t_dspace.cpp
kerneltest/f32test/server/t_fman.cpp
kerneltest/f32test/server/t_fsched.cpp
kerneltest/f32test/server/t_misc.cpp
kerneltest/f32test/server/t_nmbs.cpp
kerneltest/f32test/server/t_proxydrive1.cpp
kerneltest/f32test/server/t_wcache.cpp
package_definition.xml
package_map.xml
userlibandfileserver/domainmgr/src/domaincli.cpp
userlibandfileserver/fileserver/etshell/ts_com.cpp
userlibandfileserver/fileserver/group/bld.inf
userlibandfileserver/fileserver/group/release.txt
userlibandfileserver/fileserver/inc/F32plugin.h
userlibandfileserver/fileserver/inc/f32file.h
userlibandfileserver/fileserver/inc/f32fsys.inl
userlibandfileserver/fileserver/inc/f32ver.h
userlibandfileserver/fileserver/sfat32/fat_table32.cpp
userlibandfileserver/fileserver/sfat32/inc/sl_std.h
userlibandfileserver/fileserver/sfat32/sl_file.cpp
userlibandfileserver/fileserver/sfat32/sl_mnt.cpp
userlibandfileserver/fileserver/sfat32/sl_mnt32.cpp
userlibandfileserver/fileserver/sfile/sf_debug.cpp
userlibandfileserver/fileserver/sfile/sf_dir.cpp
userlibandfileserver/fileserver/sfile/sf_drv.cpp
userlibandfileserver/fileserver/sfile/sf_file.cpp
userlibandfileserver/fileserver/sfile/sf_ops.h
userlibandfileserver/fileserver/sfile/sf_plugin.cpp
userlibandfileserver/fileserver/sfile/sf_plugin.h
userlibandfileserver/fileserver/sfile/sf_plugin_man.cpp
userlibandfileserver/fileserver/sfile/sf_plugin_ops.cpp
userlibandfileserver/fileserver/sfile/sf_request.cpp
userlibandfileserver/fileserver/sfile/sf_std.h
userlibandfileserver/fileserver/sfile/sf_utl.cpp
userlibandfileserver/fileserver/sfsrv/cl_cli.cpp
userlibandfileserver/fileserver/sfsrv/cl_fman.cpp
userlibandfileserver/fileserver/sfsrv/cl_scan.cpp
--- a/bsptemplate/asspandvariant/template_variant/bld.inf	Tue Jul 06 15:50:07 2010 +0300
+++ b/bsptemplate/asspandvariant/template_variant/bld.inf	Wed Aug 18 11:08:29 2010 +0300
@@ -82,7 +82,6 @@
 medlffstemplate
 soundsctemplate
 soundsctemplate_v2
-camerasctemplate
 exi2s
 //epbus
 //exbusab
--- a/bsptemplate/asspandvariant/template_variant/camerasc/camerasc.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,535 +0,0 @@
-// Copyright (c) 2006-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:
-// template\template_variant\camerasc\camerasc.cpp
-// Implementation of the template shared chunk camera physical device driver (PDD).
-// This file is part of the Template Base port
-// 
-//
-#include "camerasc_plat.h"
-
-_LIT(KCameraScPddName, "CameraSc.TE");
-_LIT(KCameraScDfcQueueName, "CameraSc.TE.DfcQ");
-
-/**
-Standard export function for PDD factories.  This creates a DPhysicalDevice derived object, in this case,
-DTemplateCameraScPddFactory.
-*/
-DECLARE_STANDARD_PDD()
-	{
-	return new DTemplateCameraScPddFactory;
-	}
-
-/**
-Constructor for the shared chunk camera PDD factory class.
-*/
-DTemplateCameraScPddFactory::DTemplateCameraScPddFactory()
-	{
-	// We currently support only unit 0
-	iUnitsMask = 0x01;
-
-	// Set the version number for this device.  This is used to allow code to specify that it requires a
-	// minimum version of the device in order to operate.  If the version requested is less than this then
-	// the device is safe to be used
-	iVersion = RDevCameraSc::VersionRequired();
-	}
-
-/**
-Destructor for the shared chunk camera PDD factory class.
-*/
-DTemplateCameraScPddFactory::~DTemplateCameraScPddFactory()
-	{
-	}
-
-/**
-Second stage constructor for the shared chunk camera PDD factory class.  This must at least set a name for
-the driver object.
-@return KErrNone if successful, otherwise one of the system wide error codes.
-*/
-TInt DTemplateCameraScPddFactory::Install()
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPddFactory::Install()"));
-
-	TInt r;
-
-	// Create a DFC queue so that handling of both camera hardware callbacks and requests made to the LDD from
-	// user mode can be processed in the same thread, to avoid the use of semaphores
-	if ((r = Kern::DynamicDfcQCreate(iDfcQ, 26, KCameraScDfcQueueName)) == KErrNone)
-		{
-		// All PDD factories must have a unique name
-		r = SetName(&KCameraScPddName);
-		}
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPddFactory::Install() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-Returns the PDD's capabilities.  This is not used by the Symbian OS device driver framework
-or by the LDD but is here as some LDDs will make use of it.
-@param aDes	A descriptor into which to write capability information.
-*/
-void DTemplateCameraScPddFactory::GetCaps(TDes8& /*aDes*/) const
-	{
-	}
-
-/**
-Called by the kernel's device driver framework to check if this PDD is suitable for use
-with a logical channel.  This is called in the context of the client thread which requested
-the creation of a logical channel, through a call to RBusLogicalChannel::DoCreate().  The
-thread is in a critical section.
-@param aUnit	The unit argument supplied by the client to RBusLogicalChannel::DoCreate()
-				This is used to determine which sensor to use.
-@param aInfo	The info argument supplied by the client to RBusLogicalChannel::DoCreate().
-@param aVer		The version number of the logical channel which will use this physical channel.
-@return KErrNone if successful, otherwise one of the system wide error codes.
-*/
-TInt DTemplateCameraScPddFactory::Validate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
-	{
-	// Check that the version requested is less than or equal to the version of this PDD
-	if (!Kern::QueryVersionSupported(RDevCameraSc::VersionRequired(), aVer))
-		{
-		return KErrNotSupported;
-		}
-
-	// Check that the unit number specifies the available sensor
-	if ((aUnit < 0) || (aUnit > 0))
-		{
-		return KErrNotSupported;
-		}
-
-	return KErrNone;
-	}
-
-/**
-Called by the kernel's device driver framework to create a physical channel object.  This
-is called in the context of the client thread which requested the creation of a logical
-channel, through a call to RBusLogicalChannel::DoCreate().  The thread is in a critical section.
-@param aChannel	Set by this function to point to the created physical channel object.
-@param aUnit	The unit argument supplied by the client to RBusLogicalChannel::DoCreate().
-@param aInfo	The info argument supplied by the client to RBusLogicalChannel::DoCreate().
-@param aVer		The version number of the logical channel which will use this physical channel.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DTemplateCameraScPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/)
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPddFactory::Create()"));
-
-	// Create an instance of the PDD channel object that will work with the Template sensor
-	DTemplateCameraScPdd* pD = new DTemplateCameraScPdd;
-
-	aChannel = pD;
-	TInt r = KErrNoMemory;
-
-	if (pD)
-		{
-		r = pD->DoCreate(this, aUnit);
-		}
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPddFactory::Create() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-Called by SetUnitOpen() to see if a particular unit is open.  When called, the
-iUnitInfoMutex fast mutex will be taken, ensuring safe access to iUnitsOpenMask.
-@param aUnit	The unit number to be checked for being open.
-@return ETrue if the unit specified by aUnit is already open, otherwise EFalse.
-*/
-TBool DTemplateCameraScPddFactory::IsUnitOpen(TInt aUnit)
-	{
-	return (iUnitsOpenMask & (1 << aUnit));
-	}
-
-/**
-Attempt to change the state of the unit open state for a particular unit.
-@param aUnit	The unit number to be set to open or closed state.
-@param aIsOpen	The required new state for the unit;  either ETrue to set the state
-				to open or EFalse to set the state to closed.
-@return KErrNone if the state was updated successfully, otherwise KErrInUse if an attempt
-		was made to set the unit status to open while it is already open.
-*/
-TInt DTemplateCameraScPddFactory::SetUnitOpen(TInt aUnit, TBool aIsOpen)
-	{
-	// Wait until it is safe to access the unit state mask
-	NKern::FMWait(&iUnitInfoMutex);
-
-	// Fail a request to open a unit that is already open
-	if (aIsOpen && IsUnitOpen(aUnit))
-		{
-		__KTRACE_CAM(Kern::Printf("+ DTemplateCameraScPddFactory::SetUnitOpen() => Unit %d is already in use", aUnit));
-
-		// Release the unit state mask mutex
-		NKern::FMSignal(&iUnitInfoMutex);
-
-		return KErrInUse;
-		}
-
-	// Set or clear the unit's open status bit as required
-	if (aIsOpen)
-		{
-		iUnitsOpenMask |= (1 << aUnit);
-		}
-	else
-		{
-		iUnitsOpenMask &= ~(1 << aUnit);
-		}
-
-	// Release the unit state mask mutex
-	NKern::FMSignal(&iUnitInfoMutex);
-
-	return KErrNone;
-	}
-
-/**
-Constructor for the shared chunk camera PDD class.
-*/
-DTemplateCameraScPdd::DTemplateCameraScPdd()
-	{
-	// Set the unit number to -1 to indicate that this channel has never been registered
-	// with the PDD factory
-	iUnit = -1;
-
-	// The channel has been created but not yet configured */
-	iState = EUnconfigured;
-	}
-
-/**
-Destructor for the shared chunk camera PDD class.  This is called in the context of the client thread
-once an 'ECloseMsg' message has been sent to the device driver DFC thread.
-*/
-DTemplateCameraScPdd::~DTemplateCameraScPdd()
-	{
-	delete [] iCapsBuffer;
-	delete iSensor;
-
-	// Indicate that a physical channel is no longer open on this unit
-	if (iUnit >= 0)
-		{
-		iPhysicalDevice->SetUnitOpen(iUnit, EFalse);
-		}
-	}
-
-/**
-Second stage constructor for the H4 camera PDD.
-@param aPhysicalDevice	A pointer to the factory class that is creating this PDD
-@param aUnit			The unit argument supplied by the client to RBusLogicalChannel::DoCreate().
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DTemplateCameraScPdd::DoCreate(DTemplateCameraScPddFactory* aPhysicalDevice, TInt aUnit)
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::DoCreate()"));
-
-	TInt r;
-
-	iPhysicalDevice = aPhysicalDevice;
-
-	// Check that a physical channel hasn't already been opened on this unit
-	if ((r = iPhysicalDevice->SetUnitOpen(aUnit, ETrue)) == KErrNone)
-		{
-		iUnit = aUnit;
-
-		// Create an abstracted sensor interface
-		if ((iSensor = new DTemplateSensorIf(*this, DfcQ(aUnit))) != NULL)
-			{
-			if ((r = iSensor->DoCreate()) == KErrNone)
-				{
-				// Setup the capabilities of this device for later reference
-				if ((r = iSensor->GetCaps(iCaps)) > 0)
-					{
-					// And save the size as returned from the sensor
-					iCapsSize = r;
-
-					// Although iCaps now points to a TCameraCapsV02 structure, it is actually a variable
-					// sized structure that was allocated as an array of TUint8 so save it to a TUint8
-					// ptr so that it can be deleted properly
-					iCapsBuffer = (TUint8*) iCaps;
-
-					// Enable the clocks needed by the camera subsystem and power up the sensor
-					r = iSensor->RequestPower();
-
-					// Some sensors power themselves up automatically in their DoCreate() function,
-					// so take this into account here
-					if (r == KErrAlreadyExists)
-						{
-						r = KErrNone;
-						}
-					}
-				}
-			}
-		else
-			{
-			r = KErrNoMemory;
-			}
-		}
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::DoCreate() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-An appropriate DFC queue to use for processing client requests (that is, those that won't be processed
-in the context of the client thread), and also for processing image completion requests from the sensor
-will have been setup by the PDD factory.  Anything needing to run in this same DFC thread can access the
-queue via this function.
-@param	aUnit	The unit number for which to get the DFC queue.
-@return	The DFC queue to be used.
-*/
-TDfcQue* DTemplateCameraScPdd::DfcQ(TInt /*aUnit*/)
-	{
-	return iPhysicalDevice->iDfcQ;
-	}
-
-/**
-Called by the LDD in order to query the capabilities of the PDD.
-@param	aCapsBuf	A reference to a descriptor owned by the LDD, containing a TCameraCapsV02 structure
-					for the capabilities.
-*/
-void DTemplateCameraScPdd::Caps(TDes8& aCapsBuf) const
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::Caps()"));
-
-	// The iCaps structure will already have been created by a call to iSensor->SetCaps() in DoCreate().
-	// Simply copy it into the supplied TPckgBuf, taking into account the fact that the TCameraCapsV02
-	// buffer is of a variable size *and* may be smaller or larger than the iCaps structure
-	TPtrC8 ptr((const TUint8*) iCaps, iCapsSize);
-	aCapsBuf.FillZ(aCapsBuf.MaxLength());
-	aCapsBuf = ptr.Left(Min(ptr.Length(), aCapsBuf.MaxLength()));
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::Caps()"));
-	}
-
-/**
-Called by the LDD to setup a new image configuration, including such things as image size, framerate
-and pixel format.
-@param	aConfigBuf	A reference to a TPckgBuf containing a TCameraConfigV02 configuration structure.
-@return KErrNone if successful, otherwise one of the system wide error codes.
-*/
-TInt DTemplateCameraScPdd::SetConfig(const TDesC8& aConfigBuf)
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::SetConfig()"));
-
-	TInt r;
-
-	// It is only legal to call this if image capture is not already underway, so check for this
-	// before doing anything
-	if (iState <= EConfigured)
-		{
-		// Read the new configuration from the LDD into a local copy of the configuration structure,
-		// taking into account for compatibility that the TPckgBuf may be smaller or larger than the
-		// TCameraConfigV02 structure
-		TCameraConfigV02 config;
-		TPtr8 ptr((TUint8*) &config, sizeof(config));
-		Kern::InfoCopy(ptr, aConfigBuf);
-
-		// Save the new configuration for later and let the sensor also know about it
-		iConfig = config;
-		iSensor->SetConfig(config);
-
-		// Signal success and set the channel to the configured state
-		r = KErrNone;
-		iState = EConfigured;
-		}
-	else
-		{
-		r = KErrInUse;
-		}
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::SetConfig() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-Begins capture into the address pointed to by aLinAddr and aPhysAddr.  Both of these addresses point to
-the same buffer;  The address used by the sensor is hardware dependent.
-@param	aCaptureMode	Whether to capture in video, viewfinder or single image mode.
-@param	aLinAddr		The virtual address of the buffer into which to capture the image.
-@param	aPhysAddr		The physical address of the buffer into which to capture the image.
-@return	KErrNone if successful, otherwise one of the other system wide error codes.
-@pre	SetConfig() must first have been called.
-*/
-TInt DTemplateCameraScPdd::Start(TDevCamCaptureMode aCaptureMode, TLinAddr aLinAddr, TPhysAddr aPhysAddr)
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::Start() => Configuring sensor for %d x %d capture", iConfig.iFrameSize.iWidth, iConfig.iFrameSize.iHeight));
-
-	// Ensure the precondition is met
-	__ASSERT_DEBUG((iState == EConfigured), Kern::Fault("camerasc", ENotConfigured));
-
-	// Save the capture mode for use when we call back into the LDD with the captured image
-	iCaptureMode = aCaptureMode;
-
-	// And start the sensor running
-	TInt r = iSensor->Start(aCaptureMode, aLinAddr, aPhysAddr);
-
-	// If everything was ok, set the channel to the capturing state
-	if (r == KErrNone)
-		{
-		iState = ECapturing;
-		}
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::Start() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-Sets the address of the buffer info which the next image will be captured.  Called by the LDD for successive
-images that are requested after the initial call to Start().
-@param	aLinAddr		The virtual address of the buffer into which to capture the image.
-@param	aPhysAddr		The physical address of the buffer into which to capture the image.
-@return	KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DTemplateCameraScPdd::CaptureNextImage(TLinAddr aLinAddr, TPhysAddr aPhysAddr)
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::CaptureNextImage()"));
-
-	// Pass the call directly to the sensor abstraction
-	TInt r = iSensor->CaptureNextImage(aLinAddr, aPhysAddr);
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::CaptureNextImage()=> Returning %d", r));
-
-	return(r);
-	}
-
-/**
-Stops any image capturing that is currently underway.  It is safe to call this without having called Start().
-@return	KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DTemplateCameraScPdd::Stop()
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::Stop()"));
-
-	// Pass the call directly to the sensor abstraction
-	iSensor->Stop();
-
-	// Det the channel back to the configured state as it is now safe to call Start() again
-	iState = EConfigured;
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::Stop()"));
-
-	return KErrNone;
-	}
-
-/**
-Power down the camera device.  This is called by the LDD when the driver channel is being closed or
-when the system is being powered down.  This is always called in the context of the DFC thread.
-*/
-void DTemplateCameraScPdd::PowerDown()
-	{
-
-#ifdef _DEBUG
-
-	// Power off the camera
-	TInt r = iSensor->RelinquishPower();
-
-	// Not being able to power down indicates a serious programming error
-	__ASSERT_DEBUG((r == KErrNone), Kern::Fault("camerasc", ECannotPowerDown));
-
-#else // ! _DEBUG
-
-	// Power off the camera
-	iSensor->RelinquishPower();
-
-#endif // ! _DEBUG
-
-	}
-
-/**
-Return the shared chunk creation information to be used by this device.
-@param	aChunkCreateInfo	A structure to be filled with the settings required for this device.
-*/
-void DTemplateCameraScPdd::GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo)
-	{
-	// Can be opened by any number of user side processes
-	aChunkCreateInfo.iType = TChunkCreateInfo::ESharedKernelMultiple;
-	// Use both L1 and L2 cache if available.  LDD will take care of pre and post DMA cache handling
-#ifdef __WINS__
-	aChunkCreateInfo.iMapAttr = 0xFF000;
-#else
-	aChunkCreateInfo.iMapAttr = EMapAttrCachedMax;
-#endif
-	// Chunk owns the memory which will be freed when the chunk is destroyed
-	aChunkCreateInfo.iOwnsMemory = ETrue;
-	// Don't queue the chunk's destruction on an DFC
-	aChunkCreateInfo.iDestroyedDfc = NULL;
-	}
-
-/**
-Returns the size of the variable sized capabilities structure in bytes.  The buffer passed into
-DTemplateCameraScPdd::GetCaps() must be at least this large to hold the fixed portion of the TCameraCapsV02
-structure, as well as the array of SDevCamPixelFormat structures that follows it.
-@return	The size in bytes of the variable sized capabilities structure.
-*/
-TInt DTemplateCameraScPdd::CapsSize()
-	{
-	return iCapsSize;
-	}
-
-/**
-Obtains information regarding the frame sizes and frame rates supported for a given combination of capture mode
-and pixel format.
-@param	aCaptureMode		The capture mode for which to obtain the information.
-@param	aUidPixelFormat		The pixel format for which to obtain the information.
-@param	aFrameSizeCapsBuf	A reference to an array of packaged SDevCamFrameSize structures, owned by the LDD, into
-							which to place the information.
-@@return	KErrNone if successful, else one of the other system wide error codes.
-*/
-TInt DTemplateCameraScPdd::FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf)
-	{
-	return iSensor->FrameSizeCaps(aCaptureMode, aUidPixelFormat, aFrameSizeCapsBuf);
-	}
-
-/**
-Called by the sensor abstraction when an image is available.
-@param	aResult	KErrNone if successful, otherwise one of the system wide error codes.
-@param	aLinAddr		The virtual address of the buffer into which to capture the image.
-@param	aPhysAddr		The physical address of the buffer into which to capture the image.
-*/
-TInt DTemplateCameraScPdd::NotifyImageCaptureEvent(TInt aResult, TLinAddr& aLinAddr, TPhysAddr& aPhysAddr)
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateCameraScPdd::NotifyImageCaptureEvent() => aResult = %d", aResult));
-
-	// Inform the LDD that a new image has been received
-	TInt r = iLdd->ImageCaptureCallback(iCaptureMode, aResult, &aLinAddr, &aPhysAddr);
-
-	// If the LDD has returned KErrAbort then something has gone wrong, and if it has returned KErrNotReady
-	// then it has no more frames available, so call Stop()
-	if (r != KErrNone)
-		{
-		Stop();
-		}
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateCameraScPdd::NotifyImageCaptureEvent() => Returning %d", r));
-
-	return r;
-	}
-
-TInt DTemplateCameraScPdd::SetBrightness(TUint /*aBrightness*/)
-	{
-	return KErrNone;
-	}
-
-TInt DTemplateCameraScPdd::SetContrast(TUint /*aContrast*/)
-	{
-	return KErrNone;
-	}
-
-TInt DTemplateCameraScPdd::SetColorEffect(TUint /*aColorEffect*/)
-	{
-	return KErrNone;
-	}
-
--- a/bsptemplate/asspandvariant/template_variant/camerasc/camerasc_plat.h	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,342 +0,0 @@
-// Copyright (c) 2006-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:
-// template\template_variant\camerasc\camerasc_plat.h
-// Implementation of the Template shared chunk camera physical device driver (PDD).
-// This file is part of the Template Base port
-// 
-//
-
-#ifndef __CAMERASC_PLAT_H__
-#define __CAMERASC_PLAT_H__
-
-#include <drivers/camerasc.h>
-#include <pixelformats.h>
-
-// Comment out the first #define, and uncomment the second #define in order to have debug
-// output for the shared chunk camera driver
-#define __KTRACE_CAM(s)
-//#define __KTRACE_CAM(s) s
-
-/** Total number of image capture requests that can be handled by the sensor at one time */
-const TInt KTotalCameraRequests = 2;
-
-/** NaviEngine specific panics that can be thrown by the shared chunk camera driver */
-enum TTemplateCameraScPddPanic
-	{
-	/** Start() has been called before SetConfig() */
-	ENotConfigured,
-	/** Unable to power down the camera hardware */
-	ECannotPowerDown,
-	/** Buffer passed to DSensorIf::FrameSizeCaps() by LDD is too small */
-	ECapsBufferTooSmall
-	};
-
-/**
-The physical device (factory class) for the NaviEngine shared chunk camera driver.
-
-This class is used by the device driver framework to instantiate one or more shared chunk camera driver
-PDDs.  An instance of one PDD is allowed for each physical sensor on the device.
-*/
-class DTemplateCameraScPddFactory : public DPhysicalDevice
-	{
-public:
-
-	DTemplateCameraScPddFactory();
-	~DTemplateCameraScPddFactory();
-	virtual TInt Install();
-	virtual void GetCaps(TDes8 &aDes) const;
-	virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion &aVer);
-	virtual TInt Validate(TInt aUnit, const TDesC8* anInfo, const TVersion &aVer);
-	TBool IsUnitOpen(TInt aUnit);
-	TInt SetUnitOpen(TInt aUnit, TBool aIsOpen);
-
-private:
-
-	/** The DFC queue to be used by both the LDD and the PDD to serialise access to the PDD. */
-	TDynamicDfcQue*	iDfcQ;
-	/** Mask to keep track of which units have a channel open on them. */
-	TUint			iUnitsOpenMask;
-	/** A mutex to protect access to the unit information mask. */
-	NFastMutex		iUnitInfoMutex;
-
-	friend class DTemplateCameraScPdd;
-	};
-
-/**
-Defines the interface for notification of an image being captured.
-
-Used by concrete instances of the DSensorIf abstract base class in order to notify an observer class
-(typically an DCameraScPdd derived class) that an image has been captured for processing.
-*/
-class MSensorObserver
-	{
-public:
-
-	virtual TInt NotifyImageCaptureEvent(TInt aResult, TLinAddr& aLinAddr, TPhysAddr& aPhysAddr) = 0;
-	};
-
-/**
-Defines an abstract base class for implementing concrete classes for camera sensors.
-
-This class provides an abstract interface to the sensor;  one class is derived from this and implemented
-for each sensor available to the camera driver.
-*/
-class DSensorIf : public DBase
-	{
-public:
-
-	/**
-	Second phase constructor for the sensor interface.  Acquires any resources required for communication with the sensor.
-	When this returns, the sensor is ready for use.
-	*/
-	virtual TInt DoCreate() = 0;
-
-	/**
-	Obtains information regarding the frame sizes and frame rates supported for a given combination of capture mode and pixel format.
-	@param	aCaptureMode		The capture mode for which to obtain the information.
-	@param	aUidPixelFormat		The pixel format for which to obtain the information.
-	@param	aFrameSizeCapsBuf	A referenced to an array of packaged SDevCamFrameSize structures into which to place the information.
-	@return	KErrNone if successful, else one of the other system wide error codes.
-	*/
-	virtual TInt FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf) = 0;
-
-	/**
-	Obtains the capabilities of the sensor.  This either interrogates the sensor to find out its capabilities, or hard codes
-	them into aCameraCaps, or a combination of the two.
-	@param	aCameraCaps		A reference to a ptr to the structure into which to place the capabilities of the sensor.
-							This structure is of a variable size and contains the fixed part, followed by an array of
-							SDevCamPixelFormat structures.
-	@return	The size of the variable length structure pointed to by aCameraCaps if successful, else one of the other
-			system wide error codes.
-	*/
-	virtual TInt GetCaps(TCameraCapsV02*& aCameraCaps) = 0;
-
-	/**
-	Powers up the sensor.
-	*/
-	virtual TInt RequestPower() = 0;
-
-	/**
-	Powers down the sensor.
-	*/
-	virtual TInt RelinquishPower() = 0;
-
-	/**
-	Configures the sensor for capture in the configuration previously set by SetConfig(), and begins capture into the
-	address pointed to by aLinAddr and aPhysAddr.  Both of these addresses point to the same buffer;  The address used
-	by the sensor is hardware dependent.
-	@param	aCaptureMode	Whether to capture in video, viewfinder or single image mode.
-	@param	aLinAddr		The virtual address of the buffer into which to capture the image.
-	@param	aPhysAddr		The physical address of the buffer into which to capture the image.
-	@return	KErrNone if successful, otherwise one of the other system wide error codes.
-	@pre	SetConfig() must first have been called.
-	*/
-	virtual TInt Start(TDevCamCaptureMode aCaptureMode, TLinAddr aLinAddr, TPhysAddr aPhysAddr) = 0;
-
-	/**
-	Sets the address of the buffer into which the next image will be captured.  If is common for this to be called by Start() as
-	well as by the class that owns the sensor interface.
-	@param	aLinAddr		The virtual address of the buffer into which to capture the image.
-	@param	aPhysAddr		The physical address of the buffer into which to capture the image.
-	@return	KErrNone if successful, otherwise one of the other system wide error codes.
-	@pre	Start() must first have been called.
-	*/
-	virtual TInt CaptureNextImage(TLinAddr aLinAddr, TPhysAddr aPhysAddr) = 0;
-
-	/**
-	Stops any image capturing that is currently underway.  It is safe to call this without having called Start().
-	@return	KErrNone if successful, otherwise one of the other system wide error codes.
-	*/
-	virtual TInt Stop() = 0;
-
-	/**
-	Saves a configuration specifying such details as dimensions and pixel format in which the sensor should
-	capture images.  The shared implementation of this contains generic code, but this can be overridden by
-	derived classes if desired.
-	@param	aConfig	A TCameraConfigV02 structure containing the settings to be used.
-	@return	KErrNone if successful, otherwise one of the other system wide error codes.
-	*/
-	virtual TInt SetConfig(const TCameraConfigV02& aConfig);
-
-protected:
-
-	/** Pointer to the observer to call when a frame of data is available */
-	MSensorObserver*	iObserver;
-	/** ETrue if capture is under way, else EFalse*/
-	TBool				iEnabled;
-	/** Width of the frames to be captured in pixels */
-	TInt				iWidth;
-	/** Height of the frames to be captured in pixels */
-	TInt				iHeight;
-	/** Number of bytes from the start of one line to the start of the next */
-	TInt				iLineOffset;
-	/** The number of requests setup ready for transfer */
-	TInt				iPendingRequests;
-	/** The next request to be setup ready for transfer */
-	TUint				iNextRequest;
-	/** The configuration in which to capture images */
-	TCameraConfigV02	iConfig;
-	};
-
-/**
-This class provides an abstract interface to the Template sensor.
-*/
-class DTemplateSensorIf : public DSensorIf
-	{
-public:
-
-	DTemplateSensorIf(MSensorObserver& aObserver, TDfcQue* aDFCQueue);
-	TInt DoCreate();
-	~DTemplateSensorIf();
-	TInt BufferDoneCallback(TInt aResult);
-	void FillBuffer(TLinAddr aBuffer);
-	TInt FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf);
-	TInt GetCaps(TCameraCapsV02*& aCameraCaps);
-	TInt RequestPower();
-	TInt RelinquishPower();
-	TInt Start(TDevCamCaptureMode aCaptureMode, TLinAddr aLinAddr, TPhysAddr aPhysAddr);
-	TInt Stop();
-	TInt CaptureNextImage(TLinAddr aLinAddr, TPhysAddr aPhysAddr);
-
-	// Static callbacks for various sensor related asynchronous functions
-	static TInt HostPowerCallback(TAny* aPtr, TAny* aPoweredUp);
-	static TInt SensorClkReqCallback(TAny* aPtr);
-
-private:
-
-	/** X position at which to display the logo */
-	TInt		iX;
-	/** Y position at which to display the logo */
-	TInt		iY;
-	/** Current X direction and speed at which the logo is moving */
-	TInt		iXDirection;
-	/** Current Y direction and speed at which the logo is moving */
-	TInt		iYDirection;
-	/** Number of nanokernel ticks that represent the time to capture one frame */
-	TInt		iImageTimerTicks;
-	/** Timers used for emulating images being captured */
-	NTimer		iImageTimers[KTotalCameraRequests];
-	/** DFC queue used for completing image capture requests */
-	TDfcQue*	iDFCQueue;
-	/** DFCs used for image capture timer callbacks happeing in our DFC thread */
-	TDfc		*iImageTimerDFCs[KTotalCameraRequests];
-    
-    /* Used for cheesy animation effect */
-    TUint8 iCounter;
-    TBool iFlipSwitch;
-	};
-
-/**
-The physical device driver for the NaviEngine shared chunk camera driver.
-
-This is the concrete implementation of the abstract DCameraScPdd base class.  One instance of this
-class will be created by the factory class per physical sensor on the device.  Only one instance
-per sensor can be instantiated at any given time.  Access to the sensor itself is achieved via the
-appropriate DSensorIf derived class.
-*/
-class DTemplateCameraScPdd : public DCameraScPdd, public MSensorObserver
-	{
-private:
-
-	/** States in which the channel can be */
-	enum TState
-		{
-		/** Channel created but not yet configured */
-		EUnconfigured,
-		/** Channel configured but idle and not capturing images */
-		EConfigured,
-		/** Channel capturing images */
-		ECapturing
-		};
-
-public:
-
-	DTemplateCameraScPdd();
-	TInt DoCreate(DTemplateCameraScPddFactory* aPhysicalDevice, TInt aUnit);
-	~DTemplateCameraScPdd();
-	TDfcQue* DfcQ(TInt aUnit);
-	void Caps(TDes8& aCapsBuf) const;
-	void GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo);
-	TInt SetConfig(const TDesC8& aConfigBuf);
-	TInt Start(TDevCamCaptureMode aCaptureMode,TLinAddr aLinAddr, TPhysAddr aPhysAddr);
-	TInt CaptureNextImage(TLinAddr aLinAddr, TPhysAddr aPhysAddr);
-	TInt Stop();
-	void PowerDown();
-	TInt CapsSize();
-	TInt FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf);
-
-	/**
-	Sets the sensor brightness to the desired setting.
-
-	@param aValue A verified brightness setting.
-	@return KErrNone if successful, KErrNotSupported if not supported.
-	*/
-	TInt SetBrightness(TUint aBrightness);
-
-	/**
-	Sets the sensor contrast to the desired setting.
-
-	@param aValue A verified contrast setting.
-	@return KErrNone if successful, KErrNotSupported if not supported.
-	*/
-	TInt SetContrast(TUint aContrast);
-
-	/**
-	Sets the sensor color effect to the desired setting.
-
-	@param aValue A verified color effect setting.
-	@return KErrNone if successful, KErrNotSupported if not supported.
-	*/
-	TInt SetColorEffect(TUint aColorEffect);
-
-private:
-
-	TInt NotifyImageCaptureEvent(TInt aResult, TLinAddr& aLinAddr, TPhysAddr& aPhysAddr);
-
-private:
-
-	/** The unit number of this channel.  The unit number determines the sensor used. */
-	TInt						iUnit;
-	/** A pointer to the PDD factory that created this device. */
-	DTemplateCameraScPddFactory* iPhysicalDevice;
-	/** Ptr to a buffer large enough to hold the variable sized capabilities structure. */
-	TUint8*						iCapsBuffer;
-	/** The size of the variable sized capabilities structure. */
-	TUint						iCapsSize;
-	/** The capabilities of this device. */
-	TCameraCapsV02*				iCaps;
-	/** The current configuration of this device. */
-	TCameraConfigV02			iConfig;
-	/** The current capture mode of the camera. */
-	TDevCamCaptureMode			iCaptureMode;
-	/** Abstracted interface to the sensor */
-	DSensorIf*					iSensor;
-	/** Current state of the channel (configured, capturing etc) */
-	TState						iState;
-	};
-
-/**
-XXX - This structure holds information pertaining to the logo to be rendered in
-"photos" returned by the template camera driver.  This structure is temporary and
-should be removed when changing this template into a "real" camera driver.
-*/
-struct SLogo
-	{
-	TUint	iWidth;
-	TUint	iHeight;
-	TUint8	iPixelData[80 * 61 * 3 + 1];
-    TUint8  iPixelData2[80 * 61 * 3 + 1];
-	};
-
-#endif /* __CAMERASC_PLAT_H__ */
--- a/bsptemplate/asspandvariant/template_variant/camerasc/camerasc_sensor.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,552 +0,0 @@
-// Copyright (c) 2006-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:
-// template\template_variant\camerasc\camerasc_sensor.cpp
-// Implementation of the template shared chunk camera physical device driver (PDD).
-// This file is part of the Template Base port
-// 
-//
-
-/**
- @file
-*/
-
-#include "camerasc_plat.h"
-#include <kernel/cache.h>
-
-// XXX - Temporary structure containing a logo to be displayed.  Remove this when
-//       changing this template into a "real" camera driver
-#include "logoyuv2.cpp"
-
-
-#define RGBtoBGR565(red, green, blue) (((blue & 0xf8) << 8) | ((green & 0xfc) << 3) | ((red & 0xf8) >> 3));
-
-#define YUVtoYUV565(luma, blueC, redC) (((luma & 0xf8) << 8) | ((blueC & 0xfc) << 3) | ((redC & 0xf8) >> 3));
-
-// Frame sizes and their associated frame rates supported by the Template sensor.  This selection was
-// obtained by observation of typical formats supported by phones already on the market;  It is arbitrary
-// and can be easily added to if desired
-static const SDevCamFrameSize FrameSizes[] =
-	{
-		{ 320, 240, 1, 30 }	,		// QVGA - 0.075 MP
-		// XXX: Although not used in this template driver, the following are suggested standard frame sizes
-		// that should be implemented in your camera driver, as well as 320 x 240 above.  Remember to change
-		// KNumFrameSizes below if you change the number of sizes defined in here!
-		{ 640, 480, 1, 30 },		// VGA - 0.3 MP
-		{ 800, 600, 1, 30 },		// SVGA - 0.5 MP
-		{ 1024, 768, 1, 30 },		// XGA - 0.8 MP
-		{ 2048, 1536, 1, 15 },	// QXGA - 3 MP
-		//{ 2560, 1600, 1, 30 }		// WQXGA - 4.1 MP
-	};
-
-// This constant must be updated if the number of frame sizes listed above changes
-static const TInt KNumFrameSizes = sizeof(FrameSizes) / sizeof(SDevCamFrameSize);
-
-// Pixel formats supported by the three different capture modes.  These are mapped onto the appropriate
-// array of supported frame rates by the FrameSizeCaps() function
-static const SDevCamPixelFormat PixelFormats[] =
-	{
-		// Image pixel formats
-		{ EUidPixelFormatYUV_422Interleaved, KNumFrameSizes, 2 },
-		
-		// Video pixel formats
-		{ EUidPixelFormatYUV_422Interleaved, KNumFrameSizes, 2 },
-
-		// View finder pixel formats
-		{ EUidPixelFormatYUV_422Interleaved, KNumFrameSizes, 2 }
-
-	};
-
-// These constants must be updated if the number of pixel formats listed above changes
-static const TInt KNumImagePixelFormats = 1;
-static const TInt KNumVideoPixelFormats = 1;
-static const TInt KNumViewFinderPixelFormats = 1;
-
-// Alternate logo images after this many frames
-static const TInt KAlternateLogoFrameInterval = 5;
-
-static void ImageTimerCallback(TAny* aSensorIf)
-	{
-	DTemplateSensorIf* sensor = (DTemplateSensorIf*) aSensorIf;
-
-	// XXX - Call the buffer done function in the sensor class.  In this case we are just emulating the
-	// interrupt and DFC callback that would happen when an image is captured, so we always pass in KErrNone.
-	// In a real driver, we would read the hardware here to check that the capture happened successfully and
-	// would pass in the appropriate error code
-	sensor->BufferDoneCallback(KErrNone);
-	}
-
-/**
-Saves a configuration specifying such details as dimensions and pixel format in which the sensor should
-capture images.
-@param	aConfig	A TCameraConfigV02 structure containing the settings to be used.
-@return	KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DSensorIf::SetConfig(const TCameraConfigV02& aConfig)
-	{
-	// Manual settings for flash mode, focus, white balance etc. are not supported by the sensor,
-	// so check for these and return KErrNotSupported if they have been requested
-	if ((aConfig.iFlashMode != ECamFlashNone) ||
-		(aConfig.iExposureMode != ECamExposureAuto) ||
-		(aConfig.iZoom != 0) /*||
-        (aConfig.iWhiteBalanceMode != ECamWBAuto) ||
-		(aConfig.iContrast != ECamContrastAuto) ||
-		(aConfig.iBrightness != ECamBrightnessAuto)*/)
-		{
-		// XXX: Remove this once support is addded for these modes
-		return KErrNotSupported;
-		}
-
-	// As well as saving the configuration, also save copies of the width and height for easy access,
-	// as they are accessed frequently, as well as the offset in bytes between lines
-	iConfig = aConfig;
-	iWidth = aConfig.iFrameSize.iWidth;
-	iHeight = aConfig.iFrameSize.iHeight;
-	iLineOffset = (iWidth * iConfig.iPixelFormat.iPixelWidthInBytes);
-
-	return KErrNone;
-	}
-
-/**
-Constructor for the Template sensor class.
-*/
-
-DTemplateSensorIf::DTemplateSensorIf(MSensorObserver& aObserver, TDfcQue* aDFCQueue)
-	: iDFCQueue(aDFCQueue)
-	{
-	iObserver = &aObserver;
-	iXDirection = iYDirection = 1;
-	
-	iCounter = 0;
-	iFlipSwitch = EFalse;
-	}
-
-/**
-Second stage constructor for the Template sensor class.
-
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DTemplateSensorIf::DoCreate()
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateSensorIf::DoCreate()"));
-
-	TInt r = KErrNone;
-
-	for (TInt index = 0; index < KTotalCameraRequests; ++index)
-		{
-		if ((iImageTimerDFCs[index] = new TDfc(ImageTimerCallback, this, iDFCQueue, 0)) == NULL)
-			{
-			r = KErrNoMemory;
-
-			break;
-			}
-		}
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateSensorIf::DoCreate() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-Destructor for the Template sensor class.
-*/
-DTemplateSensorIf::~DTemplateSensorIf()
-	{
-	for (TInt index = 0; index < KTotalCameraRequests; ++index)
-		{
-		iImageTimers[index].Cancel();
-		delete iImageTimerDFCs[index];
-		}
-	}
-
-/**
-Called by the underlying sensor class when an image has been captured.
-@param aResult	KErrNone if the image was captured successfully, otherwise one of
-				the other system wide error codes.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DTemplateSensorIf::BufferDoneCallback(TInt aResult)
-	{
-	TInt r = KErrNone;
-
-	NKern::LockedDec(iPendingRequests);
-
-	TLinAddr linAddr;
-	TPhysAddr physAddr;
-
-	// Call the LDD to let it know that an image capture has completed.  If the LDD needs more images
-	// to be captured, then it will return KErrNone and the virtual and physical addresses of the
-	// next buffer to be filled will be returned in linAddr and physAddr respectively.  Note that as
-	// will as starting a capture of an image in here, the LDD may also call CaptureNextImage() to start
-	// capture as well
-	r = iObserver->NotifyImageCaptureEvent(aResult, linAddr, physAddr);
-
-	if (r == KErrNone)
-		{
-		iNextRequest = ((iNextRequest + 1) % KTotalCameraRequests);
-		NKern::LockedInc(iPendingRequests);
-
-		// XXX: Temporary code to be removed in a real driver.  Fill the buffer for testing
-		//      with user side code
-		FillBuffer(linAddr);
-
-		// XXX: Send buffer to sensor.  Normally the address of the buffer passed in in aLinAddr and
-		//      aPhysAddr would be programmed into the sensor and/or bus hardware here and an interrupt
-		//      would be generated when the iamge had been captured into the buffer.  In this simulated
-		//      driver we will use a nanokernel timer to simulate this process
-		iImageTimers[iNextRequest].OneShot(iImageTimerTicks, *iImageTimerDFCs[iNextRequest]);
-		}
-
-	return r;
-	}
-
-/**
-Fills a buffer with a white background with a moving logo on top.
-@param aBuffer	Pointer to the buffer to be filled.
-*/
-void DTemplateSensorIf::FillBuffer(TLinAddr aBuffer)
-	{
-	const TUint8* LogoData = Logo.iPixelData;
-	const TUint8* LogoData2 = Logo.iPixelData2;
-	TInt index = 0;
-	TInt numPixels = (iConfig.iFrameSize.iWidth * iConfig.iFrameSize.iHeight);
-	TUint yC, uC, vC;
-	TUint16* buffer = (TUint16*) aBuffer;
-
-    // Alternate between the two logos for cheesy animation effect
-    if( ++iCounter == KAlternateLogoFrameInterval )
-         {
-         iFlipSwitch ^= 1;
-         iCounter = 0;
-         }
-	
-	
-	// Set the "photo" background to be all white
-	memset(buffer, 0xff, (numPixels * 2));
-
-	// Point to the correct location in the buffer at which to render the logo
-	buffer += ((iY * iConfig.iFrameSize.iWidth) + iX);
-
-	// Iterate through the data for the logo and copy it into the "photo"
-	for (TUint y = 0; y < Logo.iHeight; ++y)
-		{
-		for (TUint x = 0; x < Logo.iWidth; ++x)
-			{
-			// The logo is in 24 bit BGR format so read each pixel and convert it to 16 bit BGR565
-			// before writing it into the "photo" buffer
-			if( iFlipSwitch )
-			    {
-                yC = LogoData[index];
-                uC = LogoData[index + 1];
-                vC = LogoData[index + 2];
-			    }
-			else
-                {
-                yC = LogoData2[index];
-                uC = LogoData2[index + 1];
-                vC = LogoData2[index + 2];
-                }
-
-			*buffer++ = YUVtoYUV565(yC, uC, vC);
-			// Point to the next source pixel
-			index += 3;
-			}
-
-			// Point to the start of the next line in the buffer, taking into account that the logo
-			// is narrower than the buffer
-			buffer += (iConfig.iFrameSize.iWidth - Logo.iWidth);
-		}
-
-	// Bounce the logo around in the X direction.  This will take effect the next time this is called
-	iX += iXDirection;
-
-	if (iX <= 0)
-		{
-		iX = 0;
-		iXDirection = -iXDirection;
-		}
-	else if (iX >= (TInt) (iConfig.iFrameSize.iWidth - Logo.iWidth))
-		{
-		iX = (iConfig.iFrameSize.iWidth - Logo.iWidth);
-		iXDirection = -iXDirection;
-		}
-
-	// Bounce the logo around in the Y direction.  This will take effect the next time this is called
-	iY += iYDirection;
-
-	if (iY <= 0)
-		{
-		iY = 0;
-		iYDirection = -iYDirection;
-		}
-	else if (iY >= (TInt) (iConfig.iFrameSize.iHeight - Logo.iHeight))
-		{
-		iY = (iConfig.iFrameSize.iHeight - Logo.iHeight);
-		iYDirection = -iYDirection;
-		}
-
-	// Now flush the cache to memory, taking into account the size of each pixel.  This is not normally
-	// necessary but given that we are emulating a camera driver in software we must ensure that the
-	// cache is flushed to memory.  This is because in a real driver the buffer will have been filled
-	// by DMA so upon return to the LDD, the LDD will discard the contents of the cache to ensure the
-	// DMA-written data is ok.  In the case of filling the buffer using the CPU in this virtual camera
-	// driver, that would result in the data being discarded!
-	Cache::SyncMemoryBeforeDmaWrite((TLinAddr) aBuffer, (numPixels * iConfig.iPixelFormat.iPixelWidthInBytes));
-	}
-
-/**
-Based on the capture mode and pixel format passed in, copies an array of supported SFrameSize
-structures into a buffer supplied by the LDD.  These frame sizes and their associated frame rates
-will reflect the capabilities of the given capture mode and pixel format.
-@param aCaptureMode			The capture mode for which to obtain the supported frame sizes.
-@param aUidPixelFormat		The UID of the pixel format (as defined in \epoc32\include\pixelformats.h)
-							for which to obtain the supported frame sizes.
-@param aFrameSizeCapsBuf	A reference to a descriptor that contains a buffer into which to place
-							the frame size structures.  It is up to the LDD to ensure that this is
-							large enough to hold all of the frame sizes.
-@return Always KErrNone.
-*/
-TInt DTemplateSensorIf::FrameSizeCaps(TDevCamCaptureMode /*aCaptureMode*/, TUidPixelFormat /*aUidPixelFormat*/, TDes8& aFrameSizeCapsBuf)
-	{
-	TPtrC8 sourceFrameSizes((const TUint8*) FrameSizes, sizeof(FrameSizes));
-
-	// Ensure the buffer passed in from the LDD is large enough and copy the requested frame sizes
-	if (aFrameSizeCapsBuf.Size() < sourceFrameSizes.Size())
-		{
-		Kern::Printf("*** ECapsBufferTooSmall: %d vs %d",
-				aFrameSizeCapsBuf.Size(),
-				sourceFrameSizes.Size());
-		Kern::Fault("camerasc", ECapsBufferTooSmall);
-		}
-	
-	//__ASSERT_DEBUG((aFrameSizeCapsBuf.Size() >= sourceFrameSizes.Size()), Kern::Fault("camerasc", ECapsBufferTooSmall));
-	aFrameSizeCapsBuf = sourceFrameSizes;
-
-	return KErrNone;
-	}
-
-/**
-Allocates a buffer large enough to hold the TCameraCapsV02 structure and its succeeding array of
-pixel formats, and populates the structure and array with information about the capabilities of
-the sensor.
-@param aCameraCaps	Reference to a pointer into which to place the pointer to allocated buffer
-@return	Size of the capabilities structure if successful, otherwise one of the other system wide
-		error codes.
-*/
-TInt DTemplateSensorIf::GetCaps(TCameraCapsV02*& aCameraCaps)
-	{
-	// Allocate a buffer large enough to hold the TCameraCapsV02 structure and the array of pixel formats
-	// that will follow it
-	TInt r = (sizeof(TCameraCapsV02) + sizeof(PixelFormats));
-	TUint8* capsBuffer = new TUint8[r];
-
-	if (capsBuffer)
-		{
-		aCameraCaps = (TCameraCapsV02*) capsBuffer;
-
-		// No special modes are supported at the moment
-		aCameraCaps->iFlashModes = ECamFlashNone;
-		aCameraCaps->iExposureModes = ECamExposureAuto; // or None?
-		// do we still need whitebalance mode filed?
-		aCameraCaps->iWhiteBalanceModes = ECamWBAuto | ECamWBDaylight | ECamWBCloudy | ECamWBTungsten | ECamWBFluorescent | ECamWBFlash | ECamWBSnow | ECamWBBeach;
-		aCameraCaps->iMinZoom = 0;
-		aCameraCaps->iMaxZoom = 0;
-		aCameraCaps->iCapsMisc = KCamMiscContrast | KCamMiscBrightness | KCamMiscColorEffect;
-
-		// There isn't really such thing as inwards or outwards orientation on an SDP, but we'll pretend it's
-		// an outwards facing camera
-		aCameraCaps->iOrientation = ECamOrientationOutwards;
-
-		// Initialise the number of different pixel formats supported
-		aCameraCaps->iNumImagePixelFormats = KNumImagePixelFormats;
-		aCameraCaps->iNumVideoPixelFormats = KNumVideoPixelFormats;
-		aCameraCaps->iNumViewFinderPixelFormats = KNumViewFinderPixelFormats;
-
-		for (TInt i = 0; i < ECamAttributeMax; i++)
-		    {
-		    if (ECamAttributeColorEffect == (TDevCamDynamicAttribute)(i))
-		        {
-		        // WhiteBalance
-		        // In case of white balance, we shouldn't use MIN and MAX values as some of them in between MIN and MAX can be missed out.
-		        // As this is fake driver, There doesn't seem to be any major issue though.
-		        aCameraCaps->iDynamicRange[i].iMin = ECamWBAuto;
-		        aCameraCaps->iDynamicRange[i].iMax = ECamWBBeach;
-		        aCameraCaps->iDynamicRange[i].iDefault = ECamWBAuto;
-		        }
-		    else
-		        {    
-		        // TBC :: Contrast, Brightness
-		        aCameraCaps->iDynamicRange[i].iMin = 0;
-		        aCameraCaps->iDynamicRange[i].iMax = 6;
-		        aCameraCaps->iDynamicRange[i].iDefault = 3;
-		        }
-		    }
-
-		// Setup some descriptors pointing to the pixel format array and the array passed in by the LDD
-		// (located at the end of the TCameraCapsV02 structure) and copy the pixel format array
-		TPtrC8 sourcePixelFormats((const TUint8*) PixelFormats, sizeof(PixelFormats));
-		TPtr8 destPixelFormats((capsBuffer + sizeof(TCameraCapsV02)), sizeof(PixelFormats), sizeof(PixelFormats));
-		destPixelFormats = sourcePixelFormats;
-		}
-	else
-		{
-		r = KErrNoMemory;
-		}
-
-	return r;
-	}
-
-/**
-Powers up the sensor hardware.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DTemplateSensorIf::RequestPower()
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateSensorIf::RequestPower()"));
-
-	TInt r = KErrNone;
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateSensorIf::RequestPower() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-Powers down the sensor hardware.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DTemplateSensorIf::RelinquishPower()
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateSensorIf::RelinquishPower()"));
-
-	TInt r = KErrNone;
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateSensorIf::RelinquishPower() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-Begins capture of the next image into the buffer provided.  This function assumes that
-Start() has already been called to start capture.  However, Stop() may also have been
-subsequently called (for example to pause capture) and in this case, this function will
-handle restarting the sensor.
-@param aLinAddr		A virtual pointer to the buffer into which to capture the image.
-@param aPhysAddr	A physical pointer to the buffer into which to capture the image.
-					This points to the same memory as aLinAddr.
-@return KErrNone if successful.
-		KErrNotReady if there are no free requests to capture the image.
-		Otherwise one of the other system wide error codes.
-*/
-TInt DTemplateSensorIf::CaptureNextImage(TLinAddr aLinAddr, TPhysAddr /*aPhysAddr*/)
-	{
-	TInt r = KErrNone;
-
-	// Only start capturing the next image if there are any pending request slots available
-	if (iPendingRequests < KTotalCameraRequests)
-		{
-		// Queue a transfer on the next available channel and indicate that the channel is
-		// in use
-		iNextRequest = ((iNextRequest + 1) % KTotalCameraRequests);
-		NKern::LockedInc(iPendingRequests);
-
-		// XXX: Temporary code to be removed in a real driver.  Fill the buffer for testing
-		//      with user side code.  This is to simulate an image being captured into the buffer that
-		//      has been passed in in aLinAddr.  As well as aLinAddr, which points to the virtual
-		//      address of the buffer, the LDD will pass in the physical address as well, in aPhysAddr.
-		//      Depending on the underlying sensor hardware and/or bus in use, you will have to choose
-		//      which of these to use
-		FillBuffer(aLinAddr);
-
-		// XXX: Send buffer to sensor.  Normally the address of the buffer passed in in aLinAddr and
-		//      aPhysAddr would be programmed into the sensor and/or bus hardware here and an interrupt
-		//      would be generated when the iamge had been captured into the buffer.  In this simulated
-		//      driver we will use a nanokernel timer to simulate this process
-		iImageTimers[iNextRequest].OneShot(iImageTimerTicks, *iImageTimerDFCs[iNextRequest]);
-
-		// If capturing has not yet started or has been paused by Stop(), start it
-		if (!(iEnabled))
-			{
-			iEnabled = ETrue;
-			}
-		}
-	else
-		{
-		r = KErrNotReady;
-		}
-
-	return r;
-	}
-
-/**
-Begins capture of the first image into the buffer provided.  This function is similar to
-CaptureNextImage(), except that it will perform any extra sensor intitialisation required
-to start capture.
-@param aCaptureMode	The capture mode for which to start capturing.
-@param aLinAddr		A virtual pointer to the buffer into which to capture the image.
-@param aPhysAddr	A physical pointer to the buffer into which to capture the image.
-					This points to the same memory as aLinAddr.
-@return KErrNone if successful
-		KErrInUse if capture is already under way.
-		KErrNotSupported if the frame size and/or frame rate are out of range.
-		Otherwise one of the other system wide error codes.
-*/
-TInt DTemplateSensorIf::Start(TDevCamCaptureMode /*aCaptureMode*/, TLinAddr aLinAddr, TPhysAddr aPhysAddr)
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateSensorIf::Start()"));
-
-	TInt r = KErrNone;
-
-	// XXX - In a real camera driver, in here we would initialise start the capturing process in here.
-	//       When an image is captured, the sensor hardware (or maybe the CSI bus) will generate an
-	//       which will then be enqueued into the DFC queue that was passed into the constructor of
-	//       the sensor class.  It is important to do the DFC processing in this DFC queue rather than
-	//       a separate one because it ensures that fucntions in the PDD and LDD are called in a serialised
-	//       manner, without the need for mutexts.  In this example camera driver we will convert the
-	//       framerate into a nanokernel tick count and will use an NTimer.OneShot() call to simulate
-	//       the sensor interrupt and DFC callback.  Divides are slow so we'll calculate the tick count
-	//       here and will save it for later use
-	iImageTimerTicks = ((1000000 / NKern::TickPeriod()) / iConfig.iFrameRate);
-
-	// XXX - Once the one off hardware initialisation has been done for starting a new capture, then
-	//       subsequent captures can usually reuse the same code in CaptureNextImage() for starting
-	//       the next capture
-	r = CaptureNextImage(aLinAddr, aPhysAddr);
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateSensorIf::Start() => Returning %d", r));
-
-	return r;
-	}
-
-/**
-Stops capturing any image capture that is currently in progress.  This function will act
-more like a Pause() than a Stop() capturing can be restarted from where it was stopped.
-*/
-TInt DTemplateSensorIf::Stop()
-	{
-	__KTRACE_CAM(Kern::Printf("> DTemplateSensorIf::Stop()"));
-
-	iEnabled = EFalse;
-	iPendingRequests = iNextRequest = 0;
-
-	// XXX - Cancel all of our pending image timer callbacks.  In a real driver we would write to the
-	//       sensor and/or bus hardware here to cause them to cancel any pending image captures
-	for (TInt index = 0; index < KTotalCameraRequests; ++index)
-		{
-		iImageTimers[index].Cancel();
-		}
-
-	__KTRACE_CAM(Kern::Printf("< DTemplateSensorIf::Stop()"));
-
-	return KErrNone;
-	}
--- a/bsptemplate/asspandvariant/template_variant/camerasc/logo.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,883 +0,0 @@
-// Copyright (c) 2006-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:
-// template\template_variant\camerasc\logo.cpp
-// This file contains the binary data for the logo that gets rendered in the
-// "photos" taken by this template camera driver.
-// 
-//
-
-#include "camerasc_plat.h"
-
-/** The logo rendered in "photos" returned by the template camera driver. */
-const struct SLogo Logo =
-	{
-	124, 47,
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\342\347\373\320\332\371\321\332\371\321\333\371\322\333\372\321\333\371"
-	"\322\333\371\322\333\371\321\333\371\321\332\371\322\333\371\321\332\371"
-	"\322\333\372\321\333\371\321\332\371\315\327\370\367\371\376\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\0""7\336\0K\341\0J\341\0L\343\0J\341"
-	"\0J\341\0L\343\0J\341\0I\341\36n\347\362\363\375\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\300\322\370\22`\346\0G\341\0J\341\0L\343\0A\340j\241\360\377\377\377\377"
-	"\377\377\364\367\376\213\252\361\7]\345\0K\341\0O\342\0O\342\0O\342\0O\342"
-	"\0P\344\0O\342\0O\342\0O\342\0O\342\0P\342\0O\342\0O\342\0P\344\0O\342\0"
-	"P\342\0H\3414q\347\317\334\370\377\377\377\377\377\377\377\377\377E{\351"
-	"\0F\340\0J\341\0L\341\0K\343\0C\341\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\267\314\367\0L\342"
-	"\0K\343\0J\341\0L\343\0J\341\0G\341\0M\342k\227\355\377\377\377\340\346\372"
-	"F\202\352\0E\342\0J\341\0K\341\0F\341(r\347\314\330\367\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377K\212\353\0I\340\0K\343\0J\341\0K\341\0K\341\0J\341\0?\341"
-	"\272\321\367\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\0L\343\0]\344\0_\346\0^"
-	"\344\0_\346\0_\346\0_\346\0]\344\0\\\344\0[\344[\215\354\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\310\327\371*q\347\0[\344\0]\345\0]\344\0T\343y\253\362\377\377\377"
-	"\365\367\374`\226\356\0S\343\0[\344\0^\345\0]\344\0^\345\0]\344\0^\345\0"
-	"]\344\0]\344\0_\346\0]\344\0_\346\0]\344\0]\344\0]\344\0_\344\0]\344\0]\344"
-	"\0_\346\0Y\344\0O\341\316\332\371\377\377\377\377\377\377Y\210\353\0X\343"
-	"\0]\345\0]\344\0\\\344\0U\342\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\374\374\375\215\256\361\0T\344\0]\344\0]\344"
-	"\0]\344\0\\\344\0Z\345\36m\347\267\310\367\377\377\377\377\377\377\343\351"
-	"\373Y\216\354\0W\343\0]\345\0_\344\0Z\344>\200\353\322\335\370\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\275\316\366%q\350\0[\344\0^\346\0_\344\0]\344\0^\345\0]\344"
-	"\0Y\343N\204\352\357\363\375\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\0J\341\0]\344\0]\344"
-	"\0]\345\0]\344\0]\344\0]\344\0]\345\0]\344\0[\344\4^\344\200\243\360\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\310\327\371*o\347\0Z\344\0]\345\0_\345\0U\343y\253\362\377\377\377"
-	"\256\305\365\36k\350\0Z\344\0]\345\0_\344\0]\345\0^\344\0]\344\0^\346\0^"
-	"\346\0\\\344\0^\344\0]\344\0\\\344\0^\346\0]\344\0]\344\0^\346\0]\344\0]"
-	"\344\0_\346\0]\344\0X\3444s\350\377\377\377\377\377\377Y\211\355\0X\343\0"
-	"]\344\0]\344\0^\346\0S\342\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\372\372\376\212\256\361\0K\343\0^\346\0]\344\0]\344\0\\\344"
-	"\0Y\344.w\350\334\341\371\377\377\377\377\377\377\377\377\377\343\351\373"
-	"Y\217\354\0X\345\0_\346\0]\344\0X\344>\200\353\322\335\371\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375"
-	"\373\376>\204\352\0T\343\0]\345\0]\344\0]\344\0]\344\0_\346\0]\344\0]\345"
-	"\0N\342\243\276\364\377\376\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\0L\343\0]\344\0_\345\0]\344\0]\344"
-	"\0]\344\0^\344\0]\344\0^\345\0]\344\0Z\344\10b\345\234\266\363\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\310\327\370"
-	"*p\347\0Z\344\0]\345\0_\345\0U\343y\253\362\377\377\377s\250\361\0Q\342\0"
-	"^\345\0]\344\0]\344\0^\346\0]\344\1^\344\1]\344\1]\344\1]\345\1]\345\1]\345"
-	"\1]\344\1_\346\1]\344\1_\344\2_\346\0\\\344\0]\344\0]\344\0^\345\0]\344\0"
-	"H\342\377\377\377\377\377\377Y\211\354\0Z\345\0]\344\0^\345\0\\\344\0S\343"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\363\366\375]\215\354\0N"
-	"\343\0^\345\0_\346\0]\344\0[\344\0^\345J\211\353\361\357\373\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\343\351\372Y\217\354\0X\345\0]\344\0"
-	"_\346\0X\344>\200\352\322\335\370\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\230\265\364\24f\346\0[\344\0"
-	"]\345\0]\344\0]\344\0]\344\0]\344\0^\345\0]\345\0Z\344-o\350\353\360\375"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\0J\341\0_\344\0_\346\0]\344\1_\344%q\350\0\\\344\0]\344\0_\346"
-	"\0]\344\0_\346\0X\344\23i\347\304\322\370\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\310\330\370*q\350\0Z\344\0]\344\0]\345\0U\343"
-	"y\253\362\377\377\377y\253\362\0T\343\0_\346\0]\344\0]\345\20h\347V\213\355"
-	"r\231\356o\227\356o\227\356o\230\357o\230\357o\230\357m\227\356m\227\356"
-	"o\227\356o\227\357v\233\356/w\350\0^\344\0]\344\0]\344\0^\345\0M\342\343"
-	"\351\373\377\377\377Y\210\353\0X\343\0]\345\0]\344\0\\\344\0U\342\377\377"
-	"\377\377\377\377\377\377\377\356\362\374N\202\354\0Q\342\0^\345\0^\345\0"
-	"]\344\0\\\346\12a\345k\231\356\377\375\376\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\342\351\373W\216\354\0W\343\0_\346\0]\344\0"
-	"X\344>\201\353\322\335\371\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\346\353\373:\201\352\0V\343\0]\345\0^\344\0[\344"
-	"\32l\346\14d\346\0]\344\0]\344\0]\344\0_\345\0Q\344\204\251\361\374\375\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\0K\342\0]\344\0]\344\0\\\344\10c\347\260\301\365Q\207\352\0W\344\0_\345"
-	"\0]\344\0]\344\0]\344\0Y\3440y\350\342\350\373\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\310\327\370*p\347\0Z\344\0^\345\0]\344\0T\343y\253\362"
-	"\377\377\377y\253\362\0T\343\0]\344\0_\345\0V\343u\242\357\377\375\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\341\344\373\20f"
-	"\346\0[\344\0]\344\0_\346\0P\343\311\325\367\377\377\377Y\210\353\0X\343"
-	"\0]\344\0^\345\0]\345\0S\343\377\377\377\377\377\377\334\345\371-n\347\0"
-	"T\343\0]\344\0_\346\0^\345\0Z\344\26j\350\226\263\363\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\343\351"
-	"\374Y\217\355\0X\345\0]\344\0]\345\0Y\344>\200\353\322\335\371\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\215\257\362"
-	"\17c\346\0\\\344\0]\345\0^\344\0U\344\206\254\361\216\252\362\22g\346\0["
-	"\344\0]\344\0_\346\0\\\344\7Z\343\343\353\373\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\0L\343\0]\344\0]\344\0\\\344"
-	"\4_\345\264\305\366\373\375\375\27j\347\0Y\345\0]\344\0]\344\0^\345\0^\344"
-	"\0Y\344N\207\352\371\370\376\377\377\377\377\377\377\377\377\377\310\327"
-	"\370*q\350\0[\345\0_\346\0]\344\0T\343y\253\362\377\377\377y\253\362\0T\343"
-	"\0^\345\0_\346\0T\343}\251\361\370\371\376\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\352\354\373\20h\347\0[\344\0]\345\0^\344\0O"
-	"\342\313\330\370\377\377\377Y\211\354\0Y\344\0]\344\0_\346\0^\345\0U\344"
-	"\377\377\377\327\342\372\32d\345\0V\343\0]\344\0^\345\0]\344\0Z\344&t\350"
-	"\263\304\364\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\343\351\373Y\216\354\0W\344\0^\344\0"
-	"]\345\0Z\344>\202\353\322\335\371\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\317\332\3700y\350\0Y\345\0]\344\0]\344\0Z\344\14d\345"
-	"\313\335\371\377\377\377=\203\353\0Z\344\0]\344\0]\344\0_\345\0T\343d\224"
-	"\354\372\373\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\0J\341\0]\344\0]\344\0]\346\4_\345\257\302\365\377\377\377\327\342\372"
-	"\2^\344\0Y\344\0]\344\0_\346\0^\344\0\\\344\5^\345r\234\356\377\377\377\377"
-	"\377\377\377\377\377\310\327\371*o\347\0Z\344\0^\345\0]\344\0T\343y\253\362"
-	"\377\377\377y\253\361\0T\343\0_\346\0]\344\0T\343|\250\361\367\370\376\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\347\353\373\17g"
-	"\345\0[\344\0]\345\0_\344\0O\342\313\330\370\377\377\377Y\210\353\0Z\345"
-	"\0]\344\0^\345\0]\344\0X\343\314\333\370\7Y\343\0Z\345\0^\344\0^\345\0^\344"
-	"\0]\344/x\351\353\354\373\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\343\351\374"
-	"Y\217\355\0X\345\0_\344\0]\344\0Y\344>\201\351\322\335\370\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\376\375\376n\235\357\1[\344\0]\344\0]\344"
-	"\0]\345\0T\343\221\263\362\373\372\376\377\377\377\271\311\365\24i\347\0"
-	"Z\344\0^\345\0]\345\0]\344\0R\342\317\335\371\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\0K\341\0^\345\0^\344\0]\346\4_\345\256\300"
-	"\364\377\377\377\377\377\376\262\307\365\1]\344\0[\344\0]\344\0]\344\0_\346"
-	"\0Z\344\12c\345\215\256\362\377\377\377\377\377\377\310\327\371*o\347\0Z"
-	"\344\0_\346\0]\344\0T\343y\253\362\377\377\377y\253\361\0U\344\0^\345\0]"
-	"\344\0T\343}\250\361\367\370\376\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\350\353\374\17g\346\0[\344\0]\344\0]\344\0P\343\314"
-	"\330\371\377\377\377Y\210\354\0X\343\0^\344\0_\346\0]\345\0[\344'r\350\0"
-	"V\343\0^\346\0^\344\0^\346\0\\\344\11c\345\223\262\362\377\376\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\343\351\373X\217\355\0W\343\0^\345\0^\345\0"
-	"Z\344>\200\352\322\335\370\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\271\314\366%r\350\0Y\344\0^\345\0]\344\0Z\345)p\350\330\344\372\377\377"
-	"\377\377\377\377\377\377\377G\210\353\0[\344\0]\344\0]\344\0]\344\0X\344"
-	"A|\352\370\371\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0L\341\0"
-	"_\346\0_\344\0]\346\4_\345\256\300\364\377\377\377\377\377\377\376\376\376"
-	"\214\256\361\0Z\344\0\\\345\0^\344\0]\344\0^\345\0X\344\33n\347\270\314\366"
-	"\377\377\377\311\330\371*p\347\0Z\344\0^\345\0]\344\0T\343y\253\362\377\377"
-	"\377y\253\361\0T\343\0_\345\0^\345\0T\343|\250\360\367\370\376\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\347\353\373\17g\346\0\\"
-	"\345\0^\345\0^\344\0O\342\313\327\370\377\377\377Y\210\354\0Y\343\0]\344"
-	"\0_\346\0^\345\0V\343\354\354\374/y\350\0X\344\0]\344\0]\344\0_\345\0\\\345"
-	"\0Z\344o\231\357\361\364\375\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\342\351\373X\216\354"
-	"\0W\344\0_\346\0_\346\0Y\344>\202\353\322\335\372\377\377\377\377\377\377"
-	"\377\377\377\372\371\375]\226\355\0X\344\0]\344\0]\344\0]\345\0X\344\230"
-	"\270\363\372\370\375\376\375\376\374\373\376\377\377\377\320\330\367\34n"
-	"\347\0[\344\0^\345\0^\345\0_\345\0M\342\270\315\366\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\0K\341\0_\346\0^\344\0]\345\4`\346\256\301\365\377"
-	"\377\377\377\377\377\377\377\377\370\372\376b\222\355\0Y\345\0^\345\0]\344"
-	"\0_\345\0]\344\0V\344&v\351\334\346\372\321\335\371*q\350\0[\345\0^\345\0"
-	"^\344\0T\343y\253\361\377\377\377y\253\361\0U\344\0_\345\0_\345\0T\343~\250"
-	"\361\370\370\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\351\353\373\17g\345\0\\\345\0^\345\0^\344\0P\342\314\330\370\377\377"
-	"\377Y\210\353\0Y\344\0]\344\0^\345\0\\\344\0T\343\377\377\377\362\363\374"
-	"0y\350\0X\344\0\\\345\0_\344\0]\344\0\\\344\0Y\343Q\206\353\342\351\373\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\343\351\374Y\217\355\0X\345\0^\345\0^\345\0X\343>\201\353\322\335"
-	"\371\377\377\377\377\377\377\377\377\377\241\276\364\27h\347\0[\344\0]\344"
-	"\0]\344\0^\346\24e\346\177\250\361\241\277\365\233\272\363\233\272\363\232"
-	"\273\364\246\301\365\32m\347\0[\344\0^\345\0_\346\0_\346\0Z\344\"i\346\364"
-	"\365\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\0K\342\0^\345\0]\344\0\\\344"
-	"\4_\345\256\300\364\377\377\377\377\377\377\377\377\377\377\377\377\351\357"
-	"\374>~\351\0Y\345\0]\345\0]\344\0]\344\0^\345\0X\344I\212\354\265\310\365"
-	"1t\350\0Z\344\0^\345\0^\344\0U\344y\253\361\377\377\377y\253\362\0T\343\0"
-	"^\345\0_\345\0U\343y\245\361\372\371\376\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\347\351\373\20h\346\0[\344\0]\344\0]\345\0P"
-	"\342\312\326\370\377\377\377Y\210\353\0X\344\0^\345\0]\344\0\\\344\0U\344"
-	"\377\377\377\377\377\377\357\361\374=\202\353\3]\345\0\\\344\0]\344\0^\345"
-	"\0\\\344\0Y\344>|\351\300\325\370\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\343\351\373X\217\355\0X\344\0^\344\0^\345"
-	"\0Y\344>\200\352\322\335\370\377\377\377\377\377\377\346\354\374F\210\354"
-	"\0U\343\0]\344\0^\345\0]\344\0^\345\0\\\345\0U\343\0R\343\0R\343\0R\343\0"
-	"S\344\0T\344\0[\344\0^\345\0]\344\0^\345\0_\345\0^\345\0Q\344\224\264\363"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\0K\342\0]\344\0]\344\0]\345\4`\346\256"
-	"\301\365\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\317"
-	"\335\371\"p\350\0X\344\0^\345\0]\344\0]\344\0\\\344\11b\3454v\350(r\350\0"
-	"\\\345\0]\344\0^\345\0U\344y\253\361\377\377\377y\253\361\0T\343\0]\344\0"
-	"^\345\0Y\344A\202\352\270\315\366\331\343\372\324\340\372\325\340\372\325"
-	"\340\372\325\340\371\325\340\372\325\341\372\325\340\371\325\341\372\325"
-	"\341\372\334\345\372\234\271\364\12d\347\0\\\345\0]\344\0]\344\0O\343\323"
-	"\335\371\377\377\377Y\210\353\0X\343\0^\345\0]\345\0\\\344\0U\342\377\377"
-	"\377\377\377\377\377\377\377\377\377\377i\226\355\0\\\345\0Z\344\0^\345\0"
-	"]\345\0]\344\0X\343\32l\347\257\310\366\376\374\376\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\342\351\373X\216\354\0W\343\0_\345\0^\345\0Z\345"
-	">\200\352\322\335\371\377\377\377\377\377\377\217\262\362\15b\345\0\\\344"
-	"\0]\344\0^\345\0]\344\0]\344\0^\345\0]\344\0]\345\0^\344\0^\345\0]\344\0"
-	"]\344\0^\344\0]\344\0^\345\0]\344\0^\344\0_\346\0\\\345\0X\343\347\354\374"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\0J\341\0^\345\0]\344\0]\345\4_\345\256\301\365\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\256"
-	"\306\365\20e\345\0Z\345\0]\344\0^\345\0]\344\0\\\344\0Z\344\0[\344\0]\344"
-	"\0]\344\0^\345\0T\343y\253\362\377\377\377w\251\361\0T\344\0^\345\0]\344"
-	"\0^\345\0V\343\31h\3463t\350/r\3500s\3500r\3500s\3500r\3510s\3510r\3500s"
-	"\3510s\3513t\350\10a\345\0^\345\0^\345\0]\344\0]\344\0L\342\362\365\375\377"
-	"\377\377Y\210\354\0Y\344\0]\344\0^\345\0\\\344\0U\343\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\376\375\377m\231\355\22f\346\0Y\344\0^\345\0"
-	"]\345\0]\345\0X\343\11b\346\230\267\363\356\362\375\377\377\377\377\377\377"
-	"\377\377\377\343\351\374Y\217\355\0W\343\0^\345\0]\344\0Z\344>\200\353\322"
-	"\335\371\377\377\377\321\335\3718~\351\0X\344\0]\345\0^\345\0]\344\0[\344"
-	"\0W\343\0V\343\0W\343\0V\343\0W\343\0W\344\0V\343\0V\343\0X\344\0V\343\0"
-	"Z\345\0]\344\0]\344\0^\345\0^\345\0U\344d\225\355\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\0K\342\0_\346\0^\345\0\\\344\4`\346\256\300\364\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\375\374\376\230\266\362"
-	"\6_\345\0[\344\0^\345\0]\344\0^\345\0]\344\0^\345\0]\344\0^\345\0]\344\0"
-	"T\343y\253\362\377\377\377\213\263\363\0\\\345\0]\345\0^\344\0]\344\0^\344"
-	"\0\\\345\0Z\344\0Z\344\0[\344\0Z\344\0[\345\0Z\344\0Z\344\0Z\344\0Z\344\0"
-	"Z\344\0Z\344\0]\345\0_\346\0]\344\0^\345\0[\344\0Y\344\377\377\377\377\377"
-	"\377Y\211\355\0Y\344\0^\345\0]\344\0\\\344\0U\344\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\376\376\232\266\363\20d\346\0Y\344"
-	"\0]\345\0]\344\0^\344\0[\345\0\\\344m\233\357\346\354\373\377\377\377\377"
-	"\377\377\343\351\374Y\217\355\0W\344\0]\344\0]\345\0Z\344>\201\353\324\337"
-	"\372\377\377\377{\245\360\0Z\344\0]\344\0]\345\0^\345\0X\344%u\350P\217\355"
-	"S\222\355R\223\355R\222\355R\222\355R\222\355R\222\355R\222\355R\223\356"
-	"V\224\355;\200\352\1^\345\0]\344\0]\344\0_\345\0]\345\0R\343\330\340\372"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\0K\342\0_\346\0^\345\0\\\344\4`\346\256\301\365\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\363\366\375s\236\356\1\\\344\0\\\345\0]\344\0^\345\0^\345\0^\345\0]\344"
-	"\0]\344\0^\345\0U\343y\253\362\377\377\377\321\334\370=\177\352\0V\343\0"
-	"]\344\0]\345\0^\344\0]\344\0]\344\0^\345\0]\344\0]\344\0^\345\0^\344\0]\344"
-	"\0^\345\0]\344\0_\346\0]\344\0]\344\0_\346\0]\344\0\\\344\0S\343|\242\360"
-	"\377\377\377\377\377\377X\210\354\0X\343\0^\345\0^\345\0\\\344\0U\344\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\233\267\364\34l\346\0V\343\0^\345\0^\344\0]\344\0[\345\0\\\344U"
-	"\212\353\326\340\372\377\377\377\346\353\374X\217\355\0X\344\0]\344\0]\345"
-	"\0Y\344>\201\352\333\343\372\305\326\371)t\350\0Y\344\0^\344\0]\345\0\\\344"
-	"\11a\345\246\301\364\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\355"
-	"\355\373!n\347\0[\344\0]\344\0_\345\0^\345\0V\343J\205\353\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0B\340"
-	"\0V\344\0U\343\0T\343\0W\344\251\275\364\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\344\353"
-	"\373R\212\354\0T\343\0U\343\0U\344\0V\344\0U\344\0U\343\0U\343\0V\344\0L"
-	"\341r\246\361\377\377\377\377\377\376\243\302\3641x\351\0[\344\0U\343\0W"
-	"\344\0W\343\0X\343\0W\343\0W\343\0X\344\0W\343\0X\343\0W\343\0W\343\0W\343"
-	"\0X\344\0W\343\0W\344\0X\344\0T\343\17b\345N\214\353\356\361\375\377\377"
-	"\377\377\377\377O\202\352\0P\342\0U\343\0V\344\0T\343\0L\342\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\262\307\365't\350\0R\344\0U\343\0U\344\0V\344\0S\343\0S\344"
-	"1u\351\256\311\366\332\342\371Q\211\353\0N\342\0V\344\0U\343\0P\3437|\351"
-	"\277\315\366`\230\356\0N\342\0U\343\0U\344\0U\343\0N\342^\223\356\353\357"
-	"\374\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\177\243"
-	"\357\0X\344\0T\343\0V\344\0U\343\0U\344\0D\341\252\302\365\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377T\223\355f\237\360"
-	"f\237\357d\236\357h\237\357\316\332\371\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\317\336\372g\236\356d\235\357f\237\360f\236\357f\237\360f\236\357f\236\357"
-	"f\236\357]\231\356\257\314\367\377\377\377\377\377\377\377\377\376\312\327"
-	"\370y\246\360S\221\355N\215\355O\215\354O\215\354O\215\354O\215\354O\216"
-	"\355O\215\355O\215\354O\215\354O\215\354O\214\354O\216\354O\215\354O\216"
-	"\355N\214\354Y\226\356\225\264\363\362\364\374\377\377\377\377\377\377\377"
-	"\377\377\233\267\363a\233\356e\237\357f\236\357e\235\357]\230\356\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\307\326\371[\231\357f\237\357f\237\360f\237"
-	"\357f\236\357c\236\357\\\230\356\215\265\362\340\347\372\235\275\364_\232"
-	"\356f\237\360f\236\357`\234\357\217\266\363\303\322\367\211\261\362`\233"
-	"\356f\237\357f\237\360f\236\357\\\230\356\277\326\370\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\351\354\373p\243\360"
-	"c\235\360f\237\357f\236\357f\237\360^\233\357\224\261\362\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372"
-	"\371\377\360\361\374\361\362\375\361\361\375\361\361\375\361\362\374\361"
-	"\362\375\361\362\375\361\362\374\361\362\375\361\361\375\361\361\375\361"
-	"\362\375\360\362\375\361\362\374\357\361\374\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\367\371\376\276"
-	"\317\366\355\361\374\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\366\370\375\265\311\366\320"
-	"\334\371\374\375\376\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\337\345\373v\250\361j\241\357"
-	"l\243\360\255\304\365\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\323\336\371\356\362\375\377"
-	"\377\377\377\377\377\256\303\364\32i\347\244\276\364\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\367\370"
-	"\376\262\312\366n\244\360l\243\360u\247\360\243\277\364\346\354\373\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\350\355"
-	"\374-s\350\201\246\357\367\371\376\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\356\361\3759~\351\24b\345\\"
-	"\224\355^\225\356\207\250\360\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377F\205\352\301\323\370"
-	"\377\377\377\377\377\377\270\313\3663y\351\254\303\365\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\356\362"
-	"\375b\223\355\0X\344P\212\353?~\352,p\350g\233\357\347\355\373\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\351\354\374\11d\347q\234"
-	"\355\367\370\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\203\245\361\0J\341\245\274\364\371\370\375\364"
-	"\365\375\343\352\373\377\377\377\377\377\377\355\360\374\363\364\375\377"
-	"\377\377\377\377\377\377\377\377\373\374\376\361\363\375\377\377\377\377"
-	"\376\376\356\357\374\372\372\376\377\377\377\377\377\377\371\371\375\365"
-	"\365\375\377\377\377\376\374\376\356\360\375\377\375\376\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\373\372\376\356\360\374\377\375\376\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\366\366\376\357"
-	"\361\374\366\370\375\372\372\375\304\321\367\0Z\344\241\274\363\360\360\374"
-	"\372\373\376\352\355\374\300\315\366\355\361\375\377\377\377\355\357\374"
-	"\377\377\377\377\377\377\357\360\375\356\360\375\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\355\357\374\363\363\376\377\377\377"
-	"\370\371\376\367\370\376\377\377\377\377\377\377\377\377\377\360\363\375"
-	"f\226\355\37p\350\337\342\372\336\345\373v\244\361\7`\346\227\266\363\377"
-	"\377\377\377\377\377\377\377\376\356\360\374\372\371\376\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\367\367\375\356\360\375\377"
-	"\377\377\377\377\377\377\377\377\371\372\376\367\371\376\377\377\377\376"
-	"\374\376\361\362\374\372\372\376\377\377\377\377\377\377\351\354\373\16f"
-	"\346t\235\356\370\371\376\377\377\377\377\377\377\362\363\375\357\360\375"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\2Y\344#n\347\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\367\371\376\200\247\360;\201\352>\203\353n\242\360"
-	"\357\360\374\377\377\377\322\342\372a\227\356\265\313\366S\221\355;\201\353"
-	"]\224\355\301\322\367\377\377\377\264\316\366y\245\360\244\301\365M\215\354"
-	"<\201\353h\232\356\322\337\371\377\377\377\377\377\377\306\326\370]\224\355"
-	":\200\352S\220\355\272\320\367\373\373\376\377\377\377\365\366\375\215\263"
-	"\363G\210\3542|\351\234\272\364\224\262\3623y\351\0Y\344,w\3506~\352\261"
-	"\306\365N\215\354C\207\353\331\343\372\377\377\377=\202\352\323\333\370d"
-	"\234\356:\177\352A\206\353\224\263\362\377\377\377\377\377\377\377\377\376"
-	"\207\253\361:\202\353C\206\354\227\266\362\226\264\363\301\322\367\377\377"
-	"\377\377\377\377\377\377\377\360\363\375f\226\355\37q\350\357\360\374\377"
-	"\377\377\312\333\371\25d\346\\\225\356\377\377\377\320\337\371c\227\355:"
-	"\201\353L\213\354\251\307\366\377\377\376\377\377\377\366\366\375\222\267"
-	"\363A\206\353<\201\353m\235\357\332\344\372\377\377\377\320\335\371\231\266"
-	"\363\262\306\366e\233\356;\202\353T\221\354\306\327\367\377\377\377\352\354"
-	"\373\15f\345t\236\357\370\371\376\377\377\377\244\276\364E\207\353:\200\353"
-	"]\227\356\340\347\372\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\343\350\373\0I\342o\226\355\377\377\377\377\377\377"
-	"\377\377\377\375\374\377\223\261\362\2[\344g\231\356~\253\362\16_\345d\233"
-	"\356\377\377\377\300\330\371\0R\3438|\351[\221\355v\246\361\25d\346X\221"
-	"\355\377\377\377\224\274\364\0Z\3457{\352m\236\356j\237\357\17a\346u\244"
-	"\360\377\376\376\335\344\373D\203\3533z\351\201\255\3628|\351;z\351\325\342"
-	"\371\377\377\377\207\260\362\5_\345Q\215\355\214\266\362\276\322\370\260"
-	"\306\365V\215\354\0Z\344N\212\353j\235\357\312\327\370N\207\354\0I\341\303"
-	"\323\370\377\377\377\0N\3432z\3519x\351\235\302\365(n\347\0W\344\372\371"
-	"\375\377\377\377\245\274\363\0W\344`\225\356\204\257\362)l\346\36m\350\252"
-	"\277\363\377\377\377\377\377\377\377\377\377\360\363\375f\226\355\37q\350"
-	"\355\356\374\377\377\377\325\340\372&m\347Q\223\356\363\364\375M\207\353"
-	"\"q\347\202\255\361>\204\3523x\351\314\332\370\377\377\377\227\273\363\27"
-	"g\346Z\223\355q\241\357\30g\345f\226\355\361\363\375\303\323\3678{\352\31"
-	"h\346l\240\357\203\255\362\10c\345=|\351\353\361\375\356\357\374\15f\346"
-	"t\235\356\377\377\377\305\322\367\15c\344T\216\355\216\267\362\17a\346T\211"
-	"\352\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\321\333\371\0K\342\234\264\362\377\377\377\377\377\377\377\377\377\363"
-	"\367\375\31h\3469z\351\377\375\376\375\373\376k\231\356\13d\345\335\343\371"
-	"\313\337\372\0I\341+x\351\362\362\374\364\365\375]\223\355(u\350\343\347"
-	"\373\240\303\366\0I\342N\216\354\375\372\375\350\354\373A\203\352C\203\353"
-	"\354\357\373\224\270\364\23c\346\233\273\363\377\377\377\246\276\364\21c"
-	"\345\240\301\365\355\355\373,y\350@\201\352\332\343\372\377\377\377\377\377"
-	"\377\377\377\377\257\302\364\0Z\344\251\302\364\367\367\375\377\377\377\246"
-	"\273\364\0Q\343\305\324\370\377\377\377\0X\344\0H\342\325\336\372\377\377"
-	"\377\252\276\364\0I\341\270\310\365\377\377\377\12`\345'o\347\376\373\376"
-	"\377\377\377r\234\356\0Z\345\261\303\364\377\377\377\377\377\377\377\377"
-	"\377\360\363\375f\226\355\37q\350\355\356\374\377\377\377\317\336\371\24"
-	"b\345]\231\356\272\322\367\14_\345\212\257\362\377\377\377\266\314\366\40"
-	"k\347\211\264\363\366\366\375D\206\3539}\352\337\346\372\377\377\377e\230"
-	"\356\20a\345\277\326\367\316\331\370\36n\3478|\351\336\347\373\377\377\377"
-	"m\234\357\0V\344\307\332\371\356\356\374\15f\346t\236\356\377\377\377J\207"
-	"\353\16`\345\340\350\373\377\377\377s\233\356\0O\342\354\360\374\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\324\334\371\0L\342\250"
-	"\274\363\377\377\377\377\377\377\377\377\377\334\351\373\0R\343\204\245\361"
-	"\377\377\377\377\377\376\260\312\366\0Y\343\246\274\364\316\341\372\0Q\342"
-	"v\241\360\377\377\377\371\371\376}\251\360\37n\350\324\335\371\237\303\365"
-	"\0S\343\214\262\361\377\377\377\364\364\375Y\224\355;}\351\337\345\372g\240"
-	"\3572v\351\333\344\372\377\377\377\337\344\372%r\347\211\263\362\305\321"
-	"\367\30l\347\207\255\362\373\372\376\377\377\377\377\377\377\377\377\377"
-	"\267\310\366\0Y\344\260\307\366\377\377\377\377\377\377\254\300\364\0Q\343"
-	"\305\324\367\377\377\377\0T\343&l\347\377\377\377\377\377\377\333\340\372"
-	"\0I\341\242\270\362\370\371\376\0H\341u\233\356\377\377\377\377\377\377\260"
-	"\306\365\0W\344\261\303\364\377\377\377\377\377\377\377\377\377\360\363\375"
-	"f\225\355#s\350\377\373\376\377\377\377\214\261\361\11_\345\215\257\361\216"
-	"\266\363\36n\350\317\332\371\377\377\377\343\351\373<~\352f\235\357\271\312"
-	"\366\33i\346y\252\361\377\377\377\377\377\377\230\267\363\1Y\344\254\315"
-	"\366\323\333\371\32l\347\200\251\360\370\370\376\377\377\377\263\305\365"
-	"\3^\345\251\305\366\351\352\374\16g\346u\237\357\377\377\376\15g\346`\216"
-	"\354\377\377\377\377\377\377\305\321\366\0L\341\320\334\371\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\323\333\371\0K\342\246\273\363"
-	"\377\377\377\377\377\377\377\377\377\277\321\370\0T\343\252\300\365\377\377"
-	"\377\377\377\377\313\336\371\0S\343\217\256\363\320\342\372\0V\343\221\256"
-	"\362\377\377\377\371\371\376}\252\361\40n\347\326\336\371\235\302\365\7\\"
-	"\344\246\277\364\377\377\377\364\365\376Z\224\356=\177\352\317\331\370Y\225"
-	"\356\32j\347s\234\357\213\255\361w\236\357\6_\345\210\261\362\241\270\364"
-	"\10`\345\237\300\365\377\377\377\377\377\377\377\377\377\377\377\377\265"
-	"\307\366\0Z\345\257\306\366\377\377\376\377\377\377\253\300\365\0Q\344\305"
-	"\324\367\377\377\377\0R\343L\177\352\377\377\377\377\377\377\335\342\372"
-	"\0H\342\246\273\362\336\345\374\0L\341\237\270\363\377\377\377\377\377\377"
-	"\324\341\372\0S\343\261\303\364\377\377\377\377\377\377\377\377\377\360\363"
-	"\375k\230\356\0\\\344=\204\3536\201\352\24e\346W\215\354\345\352\373\200"
-	"\253\362\12a\346j\227\356\215\256\361o\232\356\21d\346[\226\356\242\272\364"
-	"\20a\344\206\263\363\377\377\377\377\377\377\270\313\366\25g\346\215\265"
-	"\362\304\321\367\33l\347\207\257\362\372\372\376\377\377\377\275\315\366"
-	"\10b\346\242\277\365\350\351\374\17g\347x\241\357\350\352\374\11e\345;z\351"
-	"\205\252\361\212\255\361m\227\355\0G\340\313\330\371\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\321\332\372\0K\341\253\277\364\377"
-	"\377\377\377\377\377\377\377\376\264\311\366\0W\344\265\307\364\377\377\377"
-	"\377\377\377\323\343\372\0R\343\212\252\361\320\342\372\0U\343\216\255\361"
-	"\377\377\377\370\371\376}\252\361\40o\350\327\337\372\235\302\365\12^\344"
-	"\250\301\365\377\377\377\364\364\375Z\224\356>\200\352\312\325\367V\223\356"
-	"\31g\347g\223\356y\236\356t\234\356_\220\354\277\323\370\225\261\363\0[\345"
-	"\257\314\366\377\377\377\377\377\377\377\377\377\377\377\377\265\307\366"
-	"\0Z\344\257\306\366\377\377\376\377\377\377\254\277\364\0P\343\305\325\367"
-	"\377\377\377\0R\343I}\353\377\377\377\377\377\377\335\341\373\0G\341\247"
-	"\273\362\330\342\373\0L\341\252\300\364\377\377\377\377\377\377\344\353\373"
-	"\0S\343\261\303\364\377\377\377\377\377\377\377\377\377\360\363\375k\231"
-	"\356\0]\344U\212\354o\236\357\236\275\364\345\354\373\375\374\376|\251\361"
-	"\7^\345]\215\355z\237\357s\233\356a\222\355\246\301\364\250\300\365\21c\346"
-	"\205\263\362\377\377\377\377\377\377\305\323\370\36n\347\205\257\361\300"
-	"\316\366\32l\347\206\256\362\371\371\376\377\377\377\275\315\366\10b\345"
-	"\243\277\365\350\351\374\17h\347x\241\357\340\343\373\11e\3467w\350v\234"
-	"\357w\235\357u\234\357U\214\354\337\346\373\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\346\354\374\0H\341y\234\360\377\377\377\377"
-	"\377\377\377\377\377\311\332\372\0S\343\223\257\361\377\377\377\377\377\377"
-	"\303\330\371\0W\345\237\270\363\316\341\372\0U\343\216\255\361\377\377\377"
-	"\371\371\376}\252\361\40o\347\326\336\371\235\302\364\11]\344\250\300\365"
-	"\377\377\377\364\364\376Z\224\356=\177\352\316\330\370W\224\3569{\352\306"
-	"\324\370\354\361\374\347\355\374\350\355\373\376\376\377\266\310\365\14d"
-	"\347\232\274\364\376\375\376\377\377\377\377\377\377\377\377\377\264\306"
-	"\365\0Y\344\257\306\365\377\377\376\377\377\377\254\300\365\0P\343\305\323"
-	"\367\377\377\377\0S\343I~\353\377\377\377\377\377\377\334\342\373\0H\340"
-	"\246\273\363\341\351\374\0K\342\241\270\362\377\377\377\377\377\376\304\324"
-	"\370\0U\343\261\303\364\377\377\377\377\377\377\377\377\377\360\363\375g"
-	"\227\355\33n\350\331\337\372\365\367\375\377\376\376\377\377\377\370\367"
-	"\376x\245\360\40n\350\272\314\367\356\362\375\350\356\374\350\356\374\374"
-	"\373\376\256\305\366\15_\345\201\260\362\377\377\377\377\377\377\253\302"
-	"\365\11`\345\237\303\365\316\330\370\31l\347\206\255\361\371\371\376\377"
-	"\377\377\270\311\366\6`\344\237\275\364\347\351\373\17h\346w\240\356\347"
-	"\351\373\5c\345k\226\355\345\354\373\351\357\374\350\356\374\347\355\374"
-	"\372\373\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\1W\343\15e\346\377\377\377\377\377\377\377\377\377\353\363\375"
-	"\0R\342\\\214\355\377\377\377\377\376\376\233\271\364\5`\345\303\320\367"
-	"\312\336\372\0V\343\216\256\362\377\377\377\370\371\376}\252\361\40n\347"
-	"\327\336\371\235\302\365\11^\345\250\300\365\377\377\377\364\364\376Z\224"
-	"\357;~\351\344\351\373e\236\360\27e\346\314\332\370\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\320\332\370\30l\350\206\254\361\374\373\375\377"
-	"\377\377\377\377\377\377\377\377\265\306\366\0Y\344\262\310\365\377\377\377"
-	"\377\377\377\254\300\365\0Q\344\305\324\370\377\377\377\0T\344I}\352\377"
-	"\377\377\377\377\377\333\340\372\0G\340\245\272\363\377\377\377\0P\342d\220"
-	"\354\377\377\377\377\377\377\253\302\366\0X\344\260\303\364\377\377\377\377"
-	"\377\377\377\377\377\360\363\375f\225\355\40q\350\357\360\374\377\377\377"
-	"\377\377\377\377\377\377\376\375\376\204\257\361\22e\346\300\317\367\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\311\327\370(r\350g\235\357\372"
-	"\371\375\377\377\377\217\262\362\16]\344\266\320\367\320\332\370\31k\347"
-	"\211\260\362\376\374\376\377\377\377{\242\360\0V\343\310\333\371\357\357"
-	"\374\15f\346s\235\356\377\377\377\3d\345>y\350\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377n\227\356\0M\343\220\256\362\377\374\375"
-	"\367\367\376\345\354\373@|\352\15d\346\344\347\373\360\361\3748w\350\21j"
-	"\347\375\372\376\305\332\371\0V\343\216\255\362\377\377\377\367\371\376}"
-	"\251\361\40o\347\326\336\371\235\302\365\11^\345\250\300\365\377\377\377"
-	"\364\364\375Z\225\355:}\351\343\352\373\253\304\365\22d\345_\224\355\361"
-	"\361\374\377\377\376\331\340\371\362\364\375\377\376\376;\202\352\21f\346"
-	"\277\321\367\377\376\376\357\362\375\377\377\377\261\304\366\0[\344\236\271"
-	"\362\376\373\376\377\376\376\254\301\364\0P\343\305\325\370\377\377\377\0"
-	"R\343G}\352\377\377\377\377\377\377\335\341\372\0H\341\243\271\363\377\377"
-	"\377F\177\351\0\\\344\317\327\370\333\343\371/t\350\1^\345\261\304\364\377"
-	"\377\377\377\377\377\377\377\377\360\363\375f\226\355\37p\350\354\356\374"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\267\315\367\23b\345R\216"
-	"\354\361\361\374\377\376\377\323\334\371\343\350\372\374\373\376S\223\355"
-	"\27g\346\305\324\367\353\354\373>\201\352;{\351\336\346\372\314\327\370\33"
-	"m\350z\245\360\352\354\373\300\315\366\24h\346G\203\352\356\363\375\356\360"
-	"\374\15f\345s\236\356\377\377\377m\232\356\0X\344\233\266\363\377\377\377"
-	"\372\370\375\314\326\370\377\377\376\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\362\365\375E\177\351\0P\343\22j\347"
-	"\23j\347u\235\360\330\342\373\20^\344\5a\345\15f\346\7_\346\254\304\365\377"
-	"\377\377\273\323\370\0G\341\203\245\360\377\377\377\367\367\375q\241\360"
-	"\14b\345\321\332\371\222\274\363\0O\342\237\272\364\377\377\377\361\363\374"
-	"K\212\354)r\350\325\340\371\376\375\376s\237\356\4[\345\14e\346\24k\346\0"
-	"V\343\257\314\366\377\377\377\270\314\367\33k\346\5`\346\15g\346C\177\352"
-	"\351\360\374\351\354\373\1^\344\0]\344\7d\347\222\261\361\237\267\363\0B"
-	"\341\276\320\367\377\377\377\0E\3408r\351\377\377\377\377\377\377\327\334"
-	"\372\0""9\336\231\261\362\377\377\377\334\344\372\20^\344\0[\344\21g\345"
-	"Z\212\353\0]\344\260\304\364\377\377\377\377\377\377\377\377\377\355\361"
-	"\374X\215\354\13e\346\351\353\374\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\362\365\375y\243\357\0X\344\15g\346\24k\350\0Z\345z\252\361\377"
-	"\377\377\312\331\370/w\347\0^\345\10c\345\25c\345\242\276\364\377\377\377"
-	"\307\324\367's\350\1`\346\21h\346\0X\344<{\352\322\336\371\377\377\377\346"
-	"\352\373\0Z\344g\224\355\372\372\376\365\365\3744u\350\0Y\345\26m\350\22"
-	"i\346\0N\342\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\354\360\374\270\320\367\240\275\364"
-	"\244\300\364\324\337\371\377\377\377\333\346\372\252\305\366\244\301\365"
-	"\312\333\371\377\375\376\377\377\377\366\371\376\325\344\372\356\362\374"
-	"\377\377\377\376\376\376\353\362\374\333\350\373\372\373\376\360\366\375"
-	"\330\345\372\362\365\375\377\377\377\376\376\376\345\356\374\340\352\373"
-	"\372\373\376\377\377\377\364\366\375\304\327\371\246\302\365\236\274\364"
-	"\276\324\370\363\370\375\377\377\377\375\375\376\334\347\373\253\306\365"
-	"\234\272\364\311\330\371\372\374\376\377\377\377\312\334\371\247\302\365"
-	"\234\273\364\334\345\372\362\366\375\323\343\372\367\371\376\377\377\377"
-	"\323\343\372\342\353\374\377\377\377\377\377\377\372\373\376\317\341\372"
-	"\361\364\375\377\377\377\377\377\377\351\360\374\300\326\370\324\344\373"
-	"\325\342\372\0U\343\254\300\363\377\377\377\377\377\377\377\377\377\375\375"
-	"\376\347\356\374\333\350\373\375\375\376\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\364\367\375\307\330\370\240\275\364\241\276"
-	"\364\266\316\367\352\362\375\377\377\377\377\376\376\332\345\373\253\306"
-	"\366\245\303\365\321\337\371\371\372\376\377\377\377\305\323\367\37o\347"
-	"S\215\354\234\273\363\275\324\371\347\355\374\377\377\377\377\377\377\374"
-	"\374\376\330\347\373\351\357\374\377\376\377\377\377\377\352\360\374\264"
-	"\315\370\242\276\364\237\274\365\314\337\372\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\375\375\376\376\375\376\377\377\376\377\377\377\377"
-	"\377\377\377\376\377\376\375\376\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\376\376\376\375\375\376\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\376\376\375\374\376\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\376\375\376\375\375\376\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\376\266\310\365\262"
-	"\306\365\325\333\370\335\342\371I\202\352\0X\344\333\341\371\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\375\375\376\375\375\376\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\376\377\376\376\376\377\377\377\377\377\377"
-	"\377\377\377\305\323\367\32k\347\206\256\361\370\367\375\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\376\375\376\375\374\376\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\376\240\270\362\26b\346\0U\343\0W\344\10_\344\255\303\365"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\276\316\366\4]\345{\247\360\371\371"
-	"\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\371\372\376\353\361\374\346\360"
-	"\374\347\360\374\354\363\375\377\376\376\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\373\374\376\353\362\375\365\370\375\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-	};
--- a/bsptemplate/asspandvariant/template_variant/camerasc/logoyuv2.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1238 +0,0 @@
-// Copyright (c) 2006-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:
-// template\template_variant\camerasc\logo.cpp
-// This file contains the binary data for the logo that gets rendered in the
-// "photos" taken by this template camera driver.
-// 
-//
-
-#include "camerasc_plat.h"
-
-#ifdef __ARMCC__
-#pragma diag_suppress=177 // Disable the warning on  LogoYUV not being in use
-#endif
-/** The logo rendered in "photos" returned by the template camera driver. */
-const struct SLogo Logo =
-	{
-    80, 61,
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377"
-    "\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377"
-    "\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377"
-    "\376\377\377\377\377\377\372\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377"
-    "\374\377\377[\377\377\216QQ\222PPY\16\16\230\377\377\262\377\377\347\377\377\377\377\377\376\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377N\377\377\177jj\377\203"
-    "\203\354\203\203\302rr\310ll\27__\36\377\377\256\377\377\376\377\377\376\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377"
-    "\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\330\377\377Uee\375\200\200\375\200\200\376\200"
-    "\200\377\200\200\377\200\200\326\201\201&PP\344\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\0"
-    "\0\377\377\377\376\377\377\376\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\376\0"
-    "\0\377\377\377\377\377\377\374\377\377\377\377\377|\377\377\242bb\376\200\200\376\200\200\377"
-    "\200\200\373\200\200\322\201\201EPP\212\377\377\376\377\377\376\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\0"
-    "\0\332\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\0"
-    "\0\234\377\377c22\212>>\201>>,::{qq\375\200\200\377\200\200\221\200\200d\200"
-    "\200\0\204\204'\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\0"
-    "\0\376\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\334\377\377e\377\377\23CClCCb\6\6\342"
-    "\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\376\377\377\377\377\377\375\377\377\377\377\377\225\377\377J//z\177\177\307\203\203\255"
-    "\203\203z\203\203A\200\200\371\177\177\377\200\200\250\200\200\22\200\200"
-    "\0\204\204\22\377\377\317\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\376\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377"
-    "\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\376\377\377\377\377\377\315\377\377*\377\377\202dd\202\205\205~\205\205"
-    "\177ppV\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\376\377\377\377\377\377\317\377\377\"\36\36\351\205\205\376\200\200"
-    "\376\200\200\376\200\200\375\200\200\377\200\200\375\200\200\376\200\200"
-    "\376\200\200\377\200\200\202\200\200\30nnA\377\377\312\377\377\347\377\377\376\377\377\377"
-    "\377\377\377\377\377\377\377\377\354\377\377\334\377\377\335\377\377\335\377\377\336\377\377\265\377\377\12\0"
-    "\0\24\377\377\25\377\377\25\377\377\15\377\377k\377\377\333\377\377\335\377\377\336\377\377\377\377\377\377\0"
-    "\0\377\377\377\376\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\376\377\377\377\0"
-    "\0\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\204\377\377\277hh\375\200\200\375"
-    "\177\177\377\177\177\352\211\211=\1\1\377\377\377\377\377\377\377\377\377\376\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\274\5\5[\217"
-    "\217\376\177\177\376\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200\377\200"
-    "\200\246\210\210\15\221\2217\12\12\377\377\377\370\377\377\251\377\377s\16\16%\24\24"
-    "\10\220\220\15\207\207\14\207\207\14\207\207g\207\207\215\207\207\212\207"
-    "\207\212\207\207\213\207\207\203\207\207*\207\207\14\207\207\15\210\210\3"
-    "]]H\13\13m\22\22\210\377\377\351\377\377\343\377\377\341\377\377\376\377\377\377\377\377\377\377\377"
-    "\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377"
-    "\376\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\204\377\377\317kk\377"
-    "\200\200\377\200\200\344\200\200\36\211\211G\1\1\377\377\377\377\377\377\376\377\377"
-    "\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377"
-    "\26\5\5\241\211\211\377\200\200\376\200\200\376\200\200\377\200\200\377\200"
-    "\200\251\200\200\226\200\200\261\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\376\200\200\371\205\205K88s11g110++Z}}a\210\210\350\177"
-    "\177\354\200\200\353\200\200\353\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\353\200\200\355\177"
-    "\177\276\203\203X\211\211Z\215\215\\..211\32""11\21""55\222\377\377\223\377\377\216"
-    "\377\377\262\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\376"
-    "\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\213\377\377\205"
-    "kk\377\200\200\344\200\200c\200\200\15\211\211%\377\377\251\377\377\370\377\377\377\0"
-    "\0\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\377\377\5\5\250\211\211\377\200\200\376\200\200\377\177\177\375\200\200\211"
-    "\205\205\0\211\211\0\211\211\0\211\211Z\211\211\256\212\212\377\200\200\376"
-    "\200\200\377\200\200\327\177\1774\204\2048\205\205\271\205\205\337\205\205"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\177\177"
-    "\377\205\205\317\205\205\272\205\205\275\210\210\246UUCUUMUUAUU/UU9DD\215"
-    "\377\377\243\377\377\346\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\376\377\377\376"
-    "\377\377\377\377\377\377\377\377\377\377\377\245\377\377\4kk\306\200\200\324\200\200=\200\200"
-    "\244\202\202SVVEWW5**\311\377\377\377\377\377\376\377\377\376\377\377\377\377\377\376\377\377\377"
-    "\377\377\376\377\377\377\377\377\377\377\377\244\5\5:\216\216\372\177\177\377\200\200\374"
-    "\200\200\233\205\205\0>>\235\10\10\303\13\13\305\13\13\205\13\13\4\2\2\224"
-    "\200\200\377\206\206\330\201\201%\177\1776\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\376\200\200\376\200\200\377\200\200"
-    "\376\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\376\200\200\376\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\377\200\200\377\177\177\377\200\200"
-    "\377\200\200\377\200\200\343\200\200\301\200\200\261~~1ss\6}}#\377\377?\377\377\266"
-    "\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\373\377\377\373\377\377\271\377\377\21\0"
-    "\0\12jj\347\200\200\376\200\200\377\200\200\375\177\177\377\200\200\377\201"
-    "\201\247\202\2026\31\31G\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377"
-    "\377\377\376\377\377\377\377\377\336\377\377""6\33\33\235\204\204\262yy\24vv\36\377\377\247\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\210\377\377?\377\377\336\1\1A\\\\,\202\202\377"
-    "\200\200\376\200\200\376\200\200\377\200\200\377\200\200\376\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\376\200\200\377\200\200\376\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\352\177\177V\204\204D}}\0**n\5\5\242\4\4"
-    "\351\377\377\374\377\377\377\377\377\24\377\377\0cc\30jj\233\207\207\376\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\177"
-    "\177\252\214\214F\15\15Y\3\3\377\377\377\376\377\377\376\377\377\377\377\377\376\377\377\377"
-    "\377\377\376\377\377\377\377\377\305\377\377""644*\11\11\264\377\377\350\377\377\377\377\377\376\377\377"
-    "\376\377\377\376\377\377\376\377\377\377\377\377\377\377\377\324\6\6\15\\\\\336\202\202\377\200"
-    "\200\376\200\200\377\200\200\376\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200\311\206"
-    "\206e\215\2155^^2\36\36t\377\377\304\377\377O99\233\204\204\341\202\202\377\177\177"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200"
-    "\377\200\200\376\200\200\377\177\177\377\212\212\0KK\307\377\377\377\377\377\376"
-    "\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377a\12"
-    "\12xvv\372\201\201\376\200\200\377\200\200\376\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\177\177\377\202\202\244\201\201SDD\0GGt"
-    "``\377\200\200\377\200\200\377\177\177\317\202\202^\202\202_\202\202V\202"
-    "\202\322\200\200\377\177\177\376\200\200\376\200\200\377\200\200\377\177"
-    "\177DssP\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376"
-    "\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376"
-    "\377\377\377\377\377\266\377\377\22\6\6\377\212\212\377\177\177\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200"
-    "\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200"
-    "\376\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\376\200\200\377\200\200\376\200\200\376\200\200"
-    "\376\200\200\377\200\200\355\202\202E\202\202\0\201\201V\177\177\377\202"
-    "\202q\213\213\15kk\0ff\0ff\0dd?\201\201\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\374\200\2004pp\256\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\376\377\377\376\377\377\377\377\377Z\377\377\332\210\210\377\177\177\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\376\200\200\376\200\200\377\200\200\376\200\200\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200"
-    "\376\200\200\377\200\200\377\200\200\376\200\200\375\200\200\375\200\200"
-    "\374\200\200\323\200\200\325\200\200\333\200\200\375\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200"
-    "3\200\200\0\200\200\17[[\20\377\377\311\377\377\377\377\377\377\377\377\301\377\377\26\377\377@}"
-    "}\342\177\177\326\200\200\346\200\200\31\200\200\27oo\354\377\377\377\377\377\376"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\306\377\377@\24\24\374\205"
-    "\205\377\200\200\375\200\200\331\200\200\327\200\200\327\200\200\327\200"
-    "\200\327\200\200\330\200\200\377\200\200\377\200\200\377\200\200\376\200"
-    "\200\376\200\200\377\200\200\376\200\200\376\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\377\200\200\377\200\200\376\200\200\333\200\200\327\200\200\305\200"
-    "\200o\200\200f\200\200f\200\200\0\200\200\0\200\200\0\200\200\277\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\375\200\200"
-    "\377\200\200\336\200\200\7\200\200\23\\\\\313\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\277\377\377r\377\377\0&&\0kk\0ff\0iim\377\377\372\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377I\377\377\202\201\201\377\177\177\377"
-    "\200\200\375\200\200%\200\200\16\200\200\17\200\200\17\200\200\17\200\200"
-    "\17\200\200\203\200\200\177\200\200\326\200\200\371\200\200\377\200\200\377"
-    "\200\200\376\200\200\377\200\200\376\200\200\377\200\200\376\200\200\376"
-    "\200\200\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\245"
-    "\200\200v\200\200\31\200\200\17\200\200\14\200\200\0\200\200\0\200\200\0"
-    "\200\200\0\200\200\0\200\200\0\200\200\224\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200\200"
-    "I\200\200\15\\\\\276\377\377\377\377\377\376\377\377\376\377\377\376\377\377\377\377\377\377\377\377"
-    "\223\377\377s\377\377u\377\377\201\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\345\377\377$\377\377tyy\377\200\200\377\200\200\377\200"
-    "\200\221\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200"
-    "\200\0\200\200\40\200\200X\200\200\244\200\200\334\200\200\377\200\200\377"
-    "\200\200\375\200\200\376\200\200\376\200\200\377\200\200\377\200\200\350"
-    "\200\200\242\200\200O\200\200.\200\200\12\200\200\0\200\200\0\200\200\0\200"
-    "\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\230\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\376\200\200\377\200\200\216\200\200\20\\\\\275\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376"
-    "\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\252"
-    "\377\377\32XX\341\200\200\377\200\200\376\200\200\377\200\200\261\200\200\0\200"
-    "\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\1\200\200\4\200\200\33\200\200\"\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\"\200\200!\200\200\3\200\200\0\200\200\0\200"
-    "\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\226\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200"
-    "\200\377\200\200\26\\\\\273\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\372\377\377\202\377\377\31``\355\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200J\200\200\0\200\200\0\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0"
-    "\200\200\20\200\200\265\200\200\374\200\200\377\200\200\32\200\200\0\200"
-    "\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\17"
-    "\200\200\275\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\200\200\376\200\200\377\200\200\265\177\177\21SS\273\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\354"
-    "\377\377>>>\0\211\211\226\177\177\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\312\200\200\0\200\200\0\200\200\15\200\200_\200\200Z\200\200=\200\200"
-    "\10\200\200\0\200\200\0\200\200\0\200\200\0\200\200\10\200\200\235\200\200"
-    "\377\200\200\377\200\200(\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\3\200\200\0\200\200\0"
-    "\200\200\0\200\200\0\200\200\27\200\200\273\200\200\377\200\200\376\200\200"
-    "\376\200\200\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200Jzz!\3\3\327\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377R\16\16\0qqf\200\200\333\200\200\377"
-    "\200\200\376\200\200\376\200\200\372\200\200y\200\200\12\200\200\0\200\200"
-    "\241\200\200\324\200\200\273\200\200\213\200\200\0\200\200\0\200\200\0\200"
-    "\200\16\200\200\267\200\200\377\200\200\377\200\200\377\200\200\35\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\16\200\200\215\200\200"
-    "\276\200\200\267\200\200p\200\200\15\200\200\0\200\200\0\200\200>\200\200"
-    "\263\200\200\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\376\200\200\377\200\200\377\200\200\275\177\177\31\202\202w"
-    "\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\340\377\377&\377\377\5\200\200\34\206\206\303\177\177\377\200"
-    "\200\377\200\200\377\200\200\374\200\200\313\200\200\213\200\200\0\200\200"
-    "\12\200\200\20\200\200\15\200\200\0\200\200\25\200\200\242\200\200\315\200"
-    "\200\377\200\200\375\200\200\377\200\200\346\200\200\16\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\23\200\200Z\200\200_\200\200W\200"
-    "\200\11\200\200\0\200\200-\200\200\237\200\200\377\200\200\374\200\200\376"
-    "\200\200\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377"
-    "\200\200\351\200\200z\200\200\23\206\206\4\10\10\377\377\377\377\377\377\376\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\377\377"
-    "\377\377\377\353\377\377""7\377\377\7\11\11\0\202\202|~~\332\200\200\371\200\200\371"
-    "\177\177\377\200\200\377\200\200\377\200\200\277\200\200\26\200\200\305\200"
-    "\200\377\200\200\371\200\200\377\200\200\377\200\200\376\200\200\377\200"
-    "\200\376\200\200\377\200\200\370\200\200\371\200\200\265\200\200*\200\200"
-    "1\200\2002\200\2001\200\200.\200\200.\200\200.\200\200+\200\200\223\200\200"
-    "\376\200\200\377\200\200\376\200\200\376\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\376\200\200\374\200\200\377\200\200f\200\200\0\200"
-    "\200\0\207\207\224\377\377\377\377\377\376\377\377\376\377\377\376\377\377\377\377\377\376\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\375\377\377\377\377\377\377\377\377\251"
-    "\377\377\210\377\377""2::\14^^]__h\202\202\263\200\200\321\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\376"
-    "\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376"
-    "\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377"
-    "\200\200\377\200\200\241\200\200N\200\200\5\200\2007\200\2007\205\205\6\35"
-    "\35\203\377\377\374\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\376\0"
-    "\0\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\0"
-    "\0\225\377\377)\2\2\0\212\212\0\200\200\17\200\200v\200\200\225\200\200\375\200"
-    "\200\377\200\200\376\200\200\376\200\200\377\200\200\377\200\200\376\200"
-    "\200\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\376\200\200\377\200\200\377\200\200\377\200\200\314\177\177w\205\205"
-    "\0\210\210\12\207\207\316\177\177\377\200\200\377\177\177\247\204\204\6+"
-    "+I\377\377\331\377\377\377\377\377\377\377\377\376\377\377\376\377\377\376\377\377\377\377\377\376\377\377\377"
-    "\377\377\377\377\377\376\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\376\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\222"
-    "\10\10\3\211\211V\200\200Z\200\200\0\200\200\4\200\200H\200\200\216\200\200"
-    "\377\200\200\376\200\200\376\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\376\200\200\377\200\200\376\200\200\375\200\200\377\200\200\377\200\200"
-    "\260\200\200\224\177\177~\211\211\13\216\216\0::h\26\26\36!!\263\216\216"
-    "\377\177\177\377\200\200\377\200\200\266{{*oo\35\11\11\227\377\377\377\377\377\377"
-    "\377\377\376\377\377\376\377\377\377\377\377\377\377\377\302\377\377\377\377\377\377\377\377\377\377\377\375"
-    "\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376"
-    "\377\377\377\377\377\374\377\377\377\377\377/\377\377\23\10\10*\211\211\316\200\200\373\200\200"
-    "\324\200\200\13\200\200\0\200\200\0\200\200m\200\200\377\200\200\377\200"
-    "\200\376\200\200\376\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\375\200"
-    "\200\377\200\200\245\200\200\32\200\200\11\200\200\0\203\203\377\377\0F\377\377\316"
-    "\377\377\377\377\377,\377\377\0++\212\206\206\374\200\200\376\200\200\377\200\200\375"
-    "\200\2008\200\200\5}}O\377\377\377\377\377\376\377\377\376\377\377V\377\377!\377\377\14\377\377\40\0"
-    "\0""4\377\377\351\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\343\377\377\320\377\377l\6\6>\20\20\225~~\377\210\210\377\177\177"
-    "\377\177\177\350\202\202\336\201\201\17ff\20hh\0gg\0\200\200u\200\200\321"
-    "\200\200\377\200\200\376\200\200\377\200\200\376\200\200\377\200\200\346"
-    "\200\200\377\200\200\377\200\200\370\200\200\377\200\200\376\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\373"
-    "\200\200\236\200\200\0\200\200\0\206\206!\30\30k\377\377\216\377\377\377\377\377\377"
-    "\377\377\376\377\377\371\377\377""6\34\34\0dd\216\200\200\373\177\177\377\200\200\376"
-    "\200\200\377\200\200\301\200\200\12ii\22\20\20\207\27\27f\27\27\0**\21\220"
-    "\220a\210\210l\210\2107{{1\6\6\347\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376"
-    "\377\377\377\377\377\271\377\377\223\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377"
-    "\377\377\371\377\377\262\377\377\207\377\377\"66x88\222VV\372\214\214\377\200\200\377\177"
-    "\177\377\200\200\260\212\2122OO#CC\205\377\377\300\377\377\"\377\377\0\200\200\0\200"
-    "\200[\200\200\377\200\200\377\200\200\376\200\200\377\200\200\334\200\200"
-    "4\200\200\207\200\200\272\200\200g\200\200\337\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\275\200"
-    "\200\0\200\200\0\200\200\0||\260\32\32\377\377\377\377\377\377\376\377\377\376\377\377\376"
-    "\377\377\377\377\377\344\377\377:\377\377\0::y\202\202\377\177\177\377\200\200\376\200\200"
-    "\377\200\200\302\202\202A\211\211\0\210\210\0\210\210\12\207\207\246\177"
-    "\177\377\200\200\377\200\200\335\202\202\22TT\271\377\377\377\377\377\377\377\377\377"
-    "\377\377\376\377\377\377\377\377\253\377\377$\21\21""4jj.\7\7\270\377\377\377\377\377\377\377\377\375"
-    "\377\377\271\377\377*\6\6""0dd>ZZ\265\202\202\373\204\204\377\202\202\342\204\204"
-    "\312\206\206Z\211\211#||\33""88C\377\377\301\377\377\376\377\377\377\377\377""9\377\377\0\211"
-    "\211*\177\177\245\200\200\340\200\200\376\200\200\377\200\200\377\200\200"
-    "{\200\200\0\200\200i\200\200\262\200\200\0\200\200\257\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\373\200\200"
-    "H\200\200\0\200\200\0\200\200\0||B\32\32\345\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\376\377\377\377\377\377\345\377\377""6\377\377\0\215\215r\206\206\375\177\177\377"
-    "\200\200\376\200\200\377\200\200\377\200\200h\200\2004\200\200\250\200\200"
-    "\377\200\200\377\200\200\377\200\200\326\202\202\17UU\270\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\225\377\377\27\377\377\347\204\204\373\201\201g\203\203\3\0"
-    "\0V\377\377S\377\377""1\377\377xww\260zz\337\200\200\370\200\200\377\200\200\350\177"
-    "\177J\205\205#HH\3**\7\4\4\256\5\5\315\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\277\377\377\0\6\6\20\215\215\270\202\202\377\177\177\376\200\200\377\200\200"
-    "\351\200\200,\200\200\0\200\200\334\200\200\252\200\200\0\200\200\256\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\370\200\200\"\200\200\0\200\200/\177\1774\211\211\0!!\226\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\376\377\377\375\377\377\377\377\377\377\377\377""0\6\6\0))\204"
-    "\210\210\374\177\177\375\200\200\376\200\200\377\200\200\370\200\200\377"
-    "\200\200\347\200\200O\200\200S\177\177U\204\204#uu=\377\377\377\377\377\377\377\377\376"
-    "\377\377\377\377\377\376\377\377:\377\377\370\212\212\377\177\177\376\200\200\377\177\177"
-    "\377\206\206)\206\2063\206\206d\207\207\377\200\200\377\200\200\375\200\200"
-    "\370\200\200a\200\200\0ss\20EE2\377\377\377\377\377\374\377\377\377\377\377\377\377\377\376\0"
-    "\0\377\377\377\376\377\377\376\377\377\377\377\377\267\377\377)\377\377\0""99\213\203\203\375\200"
-    "\200\377\200\200\376\200\200\373\200\200\374\200\200\377\200\200\265\200"
-    "\200e\200\200\377\200\200\376\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\376\200\200\377\200\200^\177\177\334\201\201'99"
-    "I\377\377\373\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377"
-    "\377\377\377\377\377\266\377\377\0==\233\201\201\373\177\177\377\200\200\376\200\200"
-    "\377\200\200\270\200\200\0\200\200\0\200\200\0\207\207\11\377\377M\377\377\377\0"
-    "\0\377\377\377\376\377\377\376\377\377\377\377\377\240\377\377h99\377\201\201\376\200\200\376"
-    "\200\200\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376"
-    "\200\200\372\200\200\244\200\200H\200\200\0\204\204K\377\377\312\377\377\377\377\377"
-    "\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\376\377\377\377\377\377\376\377\377\376\377\377"
-    "\377\377\377\373\377\377A==H\203\203\370\200\200\377\200\200\376\200\200\377\200"
-    "\200\377\200\200\375\200\200\377\200\200\377\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\377\177\177\327\205\205*>>O\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\240\377\377\0AA"
-    "\205\200\200\373\200\200\377\200\200\377\200\200\345\200\200\213\200\200"
-    "\0\204\204\0OO\245\2\2\377\377\377\377\377\377\375\377\377\377\377\377\376\377\377\374\377\377G."
-    ".\234\177\177\377\177\177\376\200\200\376\200\200\376\200\200\374\200\200"
-    "\352\200\200\373\200\200\377\200\200\376\200\200\372\200\200\211\200\200"
-    "\0\200\200\0\204\204\355\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377"
-    "\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377k==\213\203\203"
-    "\377\200\200\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\375\200\200\377\200\200\376\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\377\200\200{\205\205\31//F\377\377\377\0"
-    "\0\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\0"
-    "\0\377\377\377\376\377\377\377\377\377\377\377\377\257\377\377\0\201\201\341\200\200\377\200"
-    "\200\376\200\200\377\200\200\336\200\200\0\207\207I\36\36\370\377\377\377\377\377"
-    "\376\377\377\376\377\377\377\377\377\377\377\377\262\377\377\0PP\246\201\201\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\373\200\200\"\200\200\332\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200:\200\200\0\204\204\223\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\376\377\377\346\377\377""2==M\203\203\241\200\200\377\200\200\377\200"
-    "\200\227\200\200\371\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\210\200\200\0\211\211\377\377\0\373\377\377\377\377\377\376\377\377\377\377\377\376\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377"
-    "\377\377\377\233\377\377""2\201\201\377\200\200\377\200\200\377\200\200\376\200\200"
-    "\376\200\200s\207\207z!!\374\377\377\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377"
-    "\371\377\377NFF\3{{\344\200\200\377\200\200\377\177\177\377\200\2005\200\200"
-    "\33\200\200\330\200\200\377\200\200\377\200\200\376\200\200\377\200\200\333"
-    "\200\200\15\204\204'\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\312\377\377\0==\0\203\203\0"
-    "\200\200\220\200\200$\200\200\2\200\200\26\200\200o\200\200=\200\200K\200"
-    "\200\331\200\200\376\200\200\377\200\200\344\200\200\344\200\200\344\200"
-    "\200\377\177\177~\200\200\0\204\204\266\377\377\377\377\377\376\377\377\376\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\0"
-    "\0\377\377\377\246\377\377\2\377\377\204\201\201\377\200\200\376\200\200\376\200\200"
-    "\377\200\200\331\200\200\0\204\204~\40\40\374\377\377\377\377\377\376\377\377\377\377\377"
-    "\377\377\377\376\377\377\377\377\377\255\377\377B\377\377\22bb#iiA\205\205\207\203\203\16\203"
-    "\203\36\203\203\330\177\177\377\200\200\377\200\200\376\200\200\376\200\200"
-    "\377\200\200t\204\204%\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\262\377\377:::\210\203\203"
-    "O\200\200\0\200\200F\200\200\214\200\200\21\200\200\0\200\200Q\200\200\40"
-    "\200\200\0\200\200\233\200\200\244\200\200\11\200\200\27\200\200\27\177\177"
-    "\37\201\2016ww\31\11\11\343\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\210"
-    "\377\377\31ss\377\177\177\376\200\200\376\200\200\377\200\200\372\177\177\201"
-    "\177\177\0--\246\377\377\375\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376"
-    "\377\377\377\377\377\377\377\377\311\377\377l\12\12q??v<<\12<<\37JJ\336\204\204\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\241\177\177\22\214\214$\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\375\377\377@\14\14\230dd\321\201\201'\200\200\30\200\200\377\200\200"
-    "\345\200\200\31\200\200\11\200\200\232\200\200\354\200\200A\200\200\0\200"
-    "\200\31\200\200\210\200\200\337\200\200\331\200\200eqq\0\24\24\225\377\377\377"
-    "\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\355\377\377H\"\"\20ww\377\200\200\377\200"
-    "\200\377\200\200\377\200\200k\200\200\0++L\377\377\377\377\377\376\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376\377\377\376"
-    "\377\377\377\377\377\311\377\377\2\32\32\244\220\220\272\201\201\372\177\177\277\177"
-    "\177\221\177\177\20\216\216\0\37\37V\377\377\377\377\377\377\377\377\376\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\377\377/\31\31T"
-    "\216\216\34\211\2114\211\211!\177\177\340\200\2006\200\200\0\200\200\0\200"
-    "\200Z\200\200\377\200\200Q\177\177\0\211\211\0\211\211~\203\203\377\177\177"
-    "\377\200\200Xhhz\377\377\372\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\350"
-    "\377\377""9OO\0\214\214r\177\177\377\200\200\346\177\177[\207\207\0\212\212>"
-    "\377\377\354\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377\371\377\377_\377\377\0\15\15"
-    "\0mm6\201\201\0\201\201\0\207\207\0$$X\377\377\375\377\377\377\377\377\376\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\0"
-    "\0,\34\34\0LLm\377\377\317\377\377\0\210\210+\200\200\0\201\201\2\201\201\0\201\201"
-    "\35\201\201\250\200\200\37\207\207\5\377\377[\377\377\14LLD\202\202D}}#\377\377\346\0"
-    "\0\377\377\377\375\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\377\377\177\377\377\4\377\377"
-    "\1\202\202@\201\201\36\211\211\0\33\33.\1\1\377\377\377\377\377\377\375\377\377\376\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\260\377\377I\377\377G\377\377L\377\377A\377\377\314"
-    "\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\377\377e\377\377g\377\377\377\377\377\333\377\377\30"
-    "\11\11\10CC\216\377\377\370\377\377@\377\377""6\377\377\5JJ6\3\3y\377\377\377\377\377\213\377\377\16"
-    "aa\21\377\377\261\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377"
-    "\377\377\377\377\377\377n\377\377J\377\377G\377\377=\377\377\306\377\377\377\377\377\377\377\377\376\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\325\377\377\271\377\377\373\377\377\377\377\377\377\377\377\377"
-    "\377\377\253\377\377\377\377\377\377\377\377\377\377\377\377\377\377\275\377\377\277\377\377\377\377\377\375"
-    "\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\375\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\372\377\377\311"
-    "\377\377S\377\377\373\377\377\377\377\377\377\377\377\253\377\377S\377\377\373\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\354\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\376"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\376\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\376"
-    "\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\325\377\377\0@@\0\33\33\220\377\377"
-    "\377\377\377\304\377\377\24\16\16\0wwx\377\377\377\377\377\376\377\377\377\377\377_\377\377\36\377\377\320"
-    "\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377"
-    "\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376"
-    "\377\377\377\377\377\374\377\377""7\377\377\12CC\3\221\221&\2\2\322\377\377\10\377\377\203aa#\205"
-    "\205c\377\377\377\377\377\377\377\377O\377\377\3\23\23\32kk\40\377\377\326\377\377\37\377\377\201\377\377"
-    "\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\322\377\377\33??\252"
-    "\213\213P\205\205\0,,\0((JRR\377\206\206\236\203\203\0%%e**S**\0%%\257\214"
-    "\214\327\205\205\1RR\0((***\37\37\37\252\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377B\377\377\5\217\217\231\177\177c\177\177\0\206\206\0\206"
-    "\2061\203\203t\177\177q\177\177\0\206\206\0\206\206\0\206\206\0\206\206\377"
-    "\177\177\303\177\177\0\203\203H\206\206\344\206\206duup\26\26\377\377\377\377"
-    "\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\376\377\377\377\377\377\313\377\377\0oo+\201\201\0\200\200\0\200\200]\200"
-    "\200\325\200\200G\200\200E\200\200B\200\200\212\200\200\350\200\200]\200"
-    "\200\0\200\200\26\200\200\24\200\200\0\200\200a\200\200\271\200\200Pttw\36"
-    "\36\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\376\377\377\377\377\377\305\377\377\20\377\377F\200\200\377\200\200r\200"
-    "\200\233\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\275\200\200\266\200\200;\200\200"
-    "\6\200\200\12\200\200\0\200\200\0ss{\33\33\377\377\377\376\377\377\377\377\377\376\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\0"
-    "\0\210\377\377\1ppv\177\177\377\200\200\377\200\200\377\200\200\377\200\200\376"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200c\200"
-    "\200Jvv\3""33\245\4\4\376\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377l\377\377\2ooy\177\177\370\200\200"
-    "\377\200\200\376\200\200\376\200\200\377\200\200\377\200\200\377\200\200"
-    "\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\376\200\200\377\177\177\336\200\200\12\214\214O"
-    "\31\31\377\377\377\376\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\376\377\377\377\377\377\265\377\377\11\17\17\10\211\211O\177\177\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200"
-    "\200\376\200\200\376\200\200\377\200\200\371\177\177g\210\210\4\21\21\333"
-    "\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\376\377\377\377\377\377\377\377\377\243\377\377\0\2\2\0\212\212\30\201\201b\177\177"
-    "\375\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\201\200\200\0\206\206a\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376"
-    "\377\377\376\377\377\377\377\377\250\377\377)\377\377\32//\0nn\16\201\201$\201\201\307\201\201"
-    "\312\202\202\312\200\200\312\200\200\312\200\200\312\200\200\312\200\200"
-    "\312\200\200\312\200\200\312\200\200\312\200\200\312\200\200\320\200\200"
-    "h\177\177\0\212\212\6\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\376\377\377\376\377\377\377\377\377\377\377\377"
-    "\320\377\377]\377\377""9II8KK)KK\0GG\0\203\203\0\206\206\0\206\206\0\206\206\0\206"
-    "\206\0\206\206\0\206\206\0\206\206\0\206\206\0\206\206\0\206\206\0\212\212"
-    "\0\\\\w\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\346\377\377\347\377\377\341\377\377\252\377\377\233$$\233''\233''\233''\233''\233''\233"
-    "''\233''\233''\233''\233''\234**\225\3\3\377\377\377\377\377\377\376\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\376\377\377\377\377\377\377\377\377\377\377\377\376\377\377\376\377\377"
-    "\376\377\377\376\377\377\376\377\377\376\377\377\376\377\377\376\377\377\376\377\377\376\377\377\376\377\377"
-    "\376\377\377\376\377\377\376\377\377\376\377\377\376\377\377\376\377\377\377\377\377\376\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377",
-    
-    
-    // second image
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377[\377\377\216QQ\222PPY\16\16\230\377\377\262\377\377\347\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377N\377\377\177jj\377\203"
-    "\203\354\203\203\302rr\310ll\27__\36\377\377\256\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\330\377\377Uee\375\200\200\375\200\200\376\200"
-    "\200\377\200\200\377\200\200\326\201\201&PP\344\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377|\377\377\242bb\376\200\200\376\200\200\377"
-    "\200\200\373\200\200\322\201\201EPP\212\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\332\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\234\377\377c22\212>>\201>>,::{qq\375\200\200\377\200\200\221\200\200d\200"
-    "\200\0\204\204'\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\334\377\377e\377\377\23CClCCb\6\6\342"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\225\377\377J//z\177\177\307\203\203\255"
-    "\203\203z\203\203A\200\200\371\177\177\377\200\200\250\200\200\22\200\200"
-    "\0\204\204\22\377\377\317\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\315\377\377*\377\377\202dd\202\205\205~\205\205"
-    "\177ppV\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\317\377\377\"\36\36\351\205\205\376\200\200"
-    "\376\200\200\376\200\200\375\200\200\377\200\200\375\200\200\376\200\200"
-    "\376\200\200\377\200\200\202\200\200\30nnA\377\377\312\377\377\347\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\354\377\377\334\377\377\335\377\377\335\377\377\336\377\377\265\377\377\12\0"
-    "\0\24\377\377\25\377\377\25\377\377\15\377\377k\377\377\333\377\377\335\377\377\336\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\204\377\377\277hh\375\200\200\375"
-    "\177\177\377\177\177\352\211\211=\1\1\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\274\5\5[\217"
-    "\217\376\177\177\376\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200\377\200"
-    "\200\246\210\210\15\221\2217\12\12\377\377\377\377\377\377\251\377\377s\16\16%\24\24"
-    "\10\220\220\15\207\207\14\207\207\14\207\207g\207\207\215\207\207\212\207"
-    "\207\212\207\207\213\207\207\203\207\207*\207\207\14\207\207\15\210\210\3"
-    "]]H\13\13m\22\22\210\377\377\351\377\377\343\377\377\341\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\204\377\377\317kk\377"
-    "\200\200\377\200\200\344\200\200\36\211\211G\1\1\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\26\5\5\241\211\211\377\200\200\376\200\200\376\200\200\377\200\200\377\200"
-    "\200\251\200\200\226\200\200\261\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\376\200\200\371\205\205K88s11g110++Z}}a\210\210\350\177"
-    "\177\354\200\200\353\200\200\353\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\353\200\200\355\177"
-    "\177\276\203\203X\211\211Z\215\215\\..211\32""11\21""55\222\377\377\223\377\377\216"
-    "\377\377\262\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\213\377\377\205"
-    "kk\377\200\200\344\200\200c\200\200\15\211\211%\377\377\251\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\377\377\5\5\250\211\211\377\200\200\376\200\200\377\177\177\375\200\200\211"
-    "\205\205\0\211\211\0\211\211\0\211\211Z\211\211\256\212\212\377\200\200\376"
-    "\200\200\377\200\200\327\177\1774\204\2048\205\205\271\205\205\337\205\205"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\177\177"
-    "\377\205\205\317\205\205\272\205\205\275\210\210\246UUCUUMUUAUU/UU9DD\215"
-    "\377\377\243\377\377\346\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\245\377\377\4kk\306\200\200\324\200\200=\200\200"
-    "\244\202\202SVVEWW5**\311\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\244\5\5:\216\216\372\177\177\377\200\200\374"
-    "\200\200\233\205\205\0>>\235\10\10\303\13\13\305\13\13\205\13\13\4\2\2\224"
-    "\200\200\377\206\206\330\201\201%\177\1776\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\376\200\200\376\200\200\377\200\200"
-    "\376\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\376\200\200\376\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\377\200\200\377\177\177\377\200\200"
-    "\377\200\200\377\200\200\343\200\200\301\200\200\261~~1ss\6}}#\377\377?\377\377\266"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\271\377\377\21\0"
-    "\0\12jj\347\200\200\376\200\200\377\200\200\375\177\177\377\200\200\377\201"
-    "\201\247\202\2026\31\31G\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\336\377\377""6\33\33\235\204\204\262yy\24vv\36\377\377\247\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\210\377\377?\377\377\336\1\1A\\\\,\202\202\377"
-    "\200\200\376\200\200\376\200\200\377\200\200\377\200\200\376\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\376\200\200\377\200\200\376\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\352\177\177V\204\204D}}\0**n\5\5\242\4\4"
-    "\351\377\377\377\377\377\377\377\377\24\377\377\0cc\30jj\233\207\207\376\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\177"
-    "\177\252\214\214F\15\15Y\3\3\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\305\377\377""644*\11\11\264\377\377\350\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\324\6\6\15\\\\\336\202\202\377\200"
-    "\200\376\200\200\377\200\200\376\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200\311\206"
-    "\206e\215\2155^^2\36\36t\377\377\304\377\377O99\233\204\204\341\202\202\377\177\177"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200"
-    "\377\200\200\376\200\200\377\177\177\377\212\212\0KK\307\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377a\12"
-    "\12xvv\372\201\201\376\200\200\377\200\200\376\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\177\177\377\202\202\244\201\201SDD\0GGt"
-    "``\377\200\200\377\200\200\377\177\177\317\202\202^\202\202_\202\202V\202"
-    "\202\322\200\200\377\177\177\376\200\200\376\200\200\377\200\200\377\177"
-    "\177DssP\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\266\377\377\22\6\6\377\212\212\377\177\177\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200"
-    "\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200"
-    "\376\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\376\200\200\377\200\200\376\200\200\376\200\200"
-    "\376\200\200\377\200\200\355\202\202E\202\202\0\201\201V\177\177\377\202"
-    "\202q\213\213\15kk\0ff\0ff\0dd?\201\201\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\374\200\2004pp\256\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377Z\377\377\332\210\210\377\177\177\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\376\200\200\376\200\200\377\200\200\376\200\200\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200"
-    "\376\200\200\377\200\200\377\200\200\376\200\200\375\200\200\375\200\200"
-    "\374\200\200\323\200\200\325\200\200\333\200\200\375\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200"
-    "3\200\200\0\200\200\17[[\20\377\377\311\377\377\377\377\377\377\377\377\301\377\377\26\377\377@}"
-    "}\342\177\177\326\200\200\346\200\200\31\200\200\27oo\354\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\306\377\377@\24\24\374\205"
-    "\205\377\200\200\375\200\200\331\200\200\327\200\200\327\200\200\327\200"
-    "\200\327\200\200\330\200\200\377\200\200\377\200\200\377\200\200\376\200"
-    "\200\376\200\200\377\200\200\376\200\200\376\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\377\200\200\377\200\200\376\200\200\333\200\200\327\200\200\305\200"
-    "\200o\200\200f\200\200f\200\200\0\200\200\0\200\200\0\200\200\277\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\375\200\200"
-    "\377\200\200\336\200\200\7\200\200\23\\\\\313\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\277\377\377r\377\377\0&&\0kk\0ff\0iim\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377I\377\377\202\201\201\377\177\177\377"
-    "\200\200\375\200\200%\200\200\16\200\200\17\200\200\17\200\200\17\200\200"
-    "\17\200\200\203\200\200\177\200\200\326\200\200\371\200\200\377\200\200\377"
-    "\200\200\376\200\200\377\200\200\376\200\200\377\200\200\376\200\200\376"
-    "\200\200\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\245"
-    "\200\200v\200\200\31\200\200\17\200\200\14\200\200\0\200\200\0\200\200\0"
-    "\200\200\0\200\200\0\200\200\0\200\200\224\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200\200"
-    "I\200\200\15\\\\\276\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\223\377\377s\377\377u\377\377\201\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\345\377\377$\377\377tyy\377\200\200\377\200\200\377\200"
-    "\200\221\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200"
-    "\200\0\200\200\40\200\200X\200\200\244\200\200\334\200\200\377\200\200\377"
-    "\200\200\375\200\200\376\200\200\376\200\200\377\200\200\377\200\200\350"
-    "\200\200\242\200\200O\200\200.\200\200\12\200\200\0\200\200\0\200\200\0\200"
-    "\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\230\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\376\200\200\377\200\200\216\200\200\20\\\\\275\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\252"
-    "\377\377\32XX\341\200\200\377\200\200\376\200\200\377\200\200\261\200\200\0\200"
-    "\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\1\200\200\4\200\200\33\200\200\"\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\"\200\200!\200\200\3\200\200\0\200\200\0\200"
-    "\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\226\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200"
-    "\200\377\200\200\26\\\\\273\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\202\377\377\31``\355\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200J\200\200\0\200\200\0\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0"
-    "\200\200\20\200\200\265\200\200\374\200\200\377\200\200\32\200\200\0\200"
-    "\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\17"
-    "\200\200\275\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\200\200\376\200\200\377\200\200\265\177\177\21SS\273\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\354"
-    "\377\377>>>\0\211\211\226\177\177\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\312\200\200\0\200\200\0\200\200\15\200\200_\200\200Z\200\200=\200\200"
-    "\10\200\200\0\200\200\0\200\200\0\200\200\0\200\200\10\200\200\235\200\200"
-    "\377\200\200\377\200\200(\200\200\0\200\200\0\200\200\0\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\3\200\200\0\200\200\0"
-    "\200\200\0\200\200\0\200\200\27\200\200\273\200\200\377\200\200\376\200\200"
-    "\376\200\200\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200Jzz!\3\3\327\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377R\16\16\0qqf\200\200\333\200\200\377"
-    "\200\200\376\200\200\376\200\200\372\200\200y\200\200\12\200\200\0\200\200"
-    "\241\200\200\324\200\200\273\200\200\213\200\200\0\200\200\0\200\200\0\200"
-    "\200\16\200\200\267\200\200\377\200\200\377\200\200\377\200\200\35\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\0\200\200\16\200\200\215\200\200"
-    "\276\200\200\267\200\200p\200\200\15\200\200\0\200\200\0\200\200>\200\200"
-    "\263\200\200\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\376\200\200\377\200\200\377\200\200\275\177\177\31\202\202w"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\340\377\377&\377\377\5\200\200\34\206\206\303\177\177\377\200"
-    "\200\377\200\200\377\200\200\374\200\200\313\200\200\213\200\200\0\200\200"
-    "\12\200\200\20\200\200\15\200\200\0\200\200\25\200\200\242\200\200\315\200"
-    "\200\377\200\200\375\200\200\377\200\200\346\200\200\16\200\200\0\200\200"
-    "\0\200\200\0\200\200\0\200\200\0\200\200\23\200\200Z\200\200_\200\200W\200"
-    "\200\11\200\200\0\200\200-\200\200\237\200\200\377\200\200\374\200\200\376"
-    "\200\200\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377"
-    "\200\200\351\200\200z\200\200\23\206\206\4\10\10\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\353\377\377""7\377\377\7\11\11\0\202\202|~~\332\200\200\371\200\200\371"
-    "\177\177\377\200\200\377\200\200\377\200\200\277\200\200\26\200\200\305\200"
-    "\200\377\200\200\371\200\200\377\200\200\377\200\200\376\200\200\377\200"
-    "\200\376\200\200\377\200\200\370\200\200\371\200\200\265\200\200*\200\200"
-    "1\200\2002\200\2001\200\200.\200\200.\200\200.\200\200+\200\200\223\200\200"
-    "\376\200\200\377\200\200\376\200\200\376\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\376\200\200\374\200\200\377\200\200f\200\200\0\200"
-    "\200\0\207\207\224\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\251"
-    "\377\377\210\377\377""2::\14^^]__h\202\202\263\200\200\321\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\376"
-    "\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376"
-    "\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377"
-    "\200\200\377\200\200\241\200\200N\200\200\5\200\2007\200\2007\205\205\6\35"
-    "\35\203\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\225\377\377)\2\2\0\212\212\0\200\200\17\200\200v\200\200\225\200\200\375\200"
-    "\200\377\200\200\376\200\200\376\200\200\377\200\200\377\200\200\376\200"
-    "\200\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\376\200\200\377\200\200\377\200\200\377\200\200\314\177\177w\205\205"
-    "\0\210\210\12\207\207\316\177\177\377\200\200\377\177\177\247\204\204\6+"
-    "+I\377\377\331\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\222"
-    "\10\10\3\211\211V\200\200Z\200\200\0\200\200\4\200\200H\200\200\216\200\200"
-    "\377\200\200\376\200\200\376\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\376\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\376\200\200\377\200\200\376\200\200\375\200\200\377\200\200\377\200\200"
-    "\260\200\200\224\177\177~\211\211\13\216\216\0::h\26\26\36!!\263\216\216"
-    "\377\177\177\377\200\200\377\200\200\266{{*oo\35\11\11\227\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\302\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377/\377\377\23\10\10*\211\211\316\200\200\373\200\200"
-    "\324\200\200\13\200\200\0\200\200\0\200\200m\200\200\377\200\200\377\200"
-    "\200\376\200\200\376\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200\200\375\200"
-    "\200\377\200\200\245\200\200\32\200\200\11\200\200\0\203\203\377\377\0F\377\377\316"
-    "\377\377\377\377\377,\377\377\0++\212\206\206\374\200\200\376\200\200\377\200\200\375"
-    "\200\2008\200\200\5}}O\377\377\377\377\377\377\377\377\377\377\377V\377\377!\377\377\14\377\377\40\0"
-    "\0""4\377\377\351\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\343\377\377\320\377\377l\6\6>\20\20\225~~\377\210\210\377\177\177"
-    "\377\177\177\350\202\202\336\201\201\17ff\20hh\0gg\0\200\200u\200\200\321"
-    "\200\200\377\200\200\376\200\200\377\200\200\376\200\200\377\200\200\346"
-    "\200\200\377\200\200\377\200\200\370\200\200\377\200\200\376\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\373"
-    "\200\200\236\200\200\0\200\200\0\206\206!\30\30k\377\377\216\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377""6\34\34\0dd\216\200\200\373\177\177\377\200\200\376"
-    "\200\200\377\200\200\301\200\200\12ii\22\20\20\207\27\27f\27\27\0**\21\220"
-    "\220a\210\210l\210\2107{{1\6\6\347\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\271\377\377\223\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\262\377\377\207\377\377\"66x88\222VV\372\214\214\377\200\200\377\177"
-    "\177\377\200\200\260\212\2122OO#CC\205\377\377\300\377\377\"\377\377\0\200\200\0\200"
-    "\200[\200\200\377\200\200\377\200\200\376\200\200\377\200\200\334\200\200"
-    "4\200\200\207\200\200\272\200\200g\200\200\337\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\275\200"
-    "\200\0\200\200\0\200\200\0||\260\32\32\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\344\377\377:\377\377\0::y\202\202\377\177\177\377\200\200\376\200\200"
-    "\377\200\200\302\202\202A\211\211\0\210\210\0\210\210\12\207\207\246\177"
-    "\177\377\200\200\377\200\200\335\202\202\22TT\271\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\253\377\377$\21\21""4jj.\7\7\270\377\377\377\377\377\377\377\377\377"
-    "\377\377\271\377\377*\6\6""0dd>ZZ\265\202\202\373\204\204\377\202\202\342\204\204"
-    "\312\206\206Z\211\211#||\33""88C\377\377\301\377\377\377\377\377\377\377\377""9\377\377\0\211"
-    "\211*\177\177\245\200\200\340\200\200\376\200\200\377\200\200\377\200\200"
-    "{\200\200\0\200\200i\200\200\262\200\200\0\200\200\257\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\373\200\200"
-    "H\200\200\0\200\200\0\200\200\0||B\32\32\345\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\345\377\377""6\377\377\0\215\215r\206\206\375\177\177\377"
-    "\200\200\376\200\200\377\200\200\377\200\200h\200\2004\200\200\250\200\200"
-    "\377\200\200\377\200\200\377\200\200\326\202\202\17UU\270\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\225\377\377\27\377\377\347\204\204\373\201\201g\203\203\3\0"
-    "\0V\377\377S\377\377""1\377\377xww\260zz\337\200\200\370\200\200\377\200\200\350\177"
-    "\177J\205\205#HH\3**\7\4\4\256\5\5\315\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\277\377\377\0\6\6\20\215\215\270\202\202\377\177\177\376\200\200\377\200\200"
-    "\351\200\200,\200\200\0\200\200\334\200\200\252\200\200\0\200\200\256\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\370\200\200\"\200\200\0\200\200/\177\1774\211\211\0!!\226\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377""0\6\6\0))\204"
-    "\210\210\374\177\177\375\200\200\376\200\200\377\200\200\370\200\200\377"
-    "\200\200\347\200\200O\200\200S\177\177U\204\204#uu=\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377:\377\377\370\212\212\377\177\177\376\200\200\377\177\177"
-    "\377\206\206)\206\2063\206\206d\207\207\377\200\200\377\200\200\375\200\200"
-    "\370\200\200a\200\200\0ss\20EE2\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\267\377\377)\377\377\0""99\213\203\203\375\200"
-    "\200\377\200\200\376\200\200\373\200\200\374\200\200\377\200\200\265\200"
-    "\200e\200\200\377\200\200\376\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\376\200\200\376\200\200\377\200\200^\177\177\334\201\201'99"
-    "I\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\266\377\377\0==\233\201\201\373\177\177\377\200\200\376\200\200"
-    "\377\200\200\270\200\200\0\200\200\0\200\200\0\207\207\11\377\377M\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\240\377\377h99\377\201\201\376\200\200\376"
-    "\200\200\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376"
-    "\200\200\372\200\200\244\200\200H\200\200\0\204\204K\377\377\312\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377A==H\203\203\370\200\200\377\200\200\376\200\200\377\200"
-    "\200\377\200\200\375\200\200\377\200\200\377\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\376\200\200\377\200"
-    "\200\377\177\177\327\205\205*>>O\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\240\377\377\0AA"
-    "\205\200\200\373\200\200\377\200\200\377\200\200\345\200\200\213\200\200"
-    "\0\204\204\0OO\245\2\2\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377G."
-    ".\234\177\177\377\177\177\376\200\200\376\200\200\376\200\200\374\200\200"
-    "\352\200\200\373\200\200\377\200\200\376\200\200\372\200\200\211\200\200"
-    "\0\200\200\0\204\204\355\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377k==\213\203\203"
-    "\377\200\200\376\200\200\377\200\200\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\375\200\200\377\200\200\376\200\200\377\200\200"
-    "\377\200\200\376\200\200\377\200\200\377\200\200{\205\205\31//F\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\257\377\377\0\201\201\341\200\200\377\200"
-    "\200\376\200\200\377\200\200\336\200\200\0\207\207I\36\36\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\262\377\377\0PP\246\201\201\377\200\200\377"
-    "\200\200\377\200\200\377\200\200\373\200\200\"\200\200\332\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200:\200\200\0\204\204\223\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\346\377\377""2==M\203\203\241\200\200\377\200\200\377\200"
-    "\200\227\200\200\371\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\376\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\210\200\200\0\211\211\377\377\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\233\377\377""2\201\201\377\200\200\377\200\200\377\200\200\376\200\200"
-    "\376\200\200s\207\207z!!\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377NFF\3{{\344\200\200\377\200\200\377\177\177\377\200\2005\200\200"
-    "\33\200\200\330\200\200\377\200\200\377\200\200\376\200\200\377\200\200\333"
-    "\200\200\15\204\204'\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\312\377\377\0==\0\203\203\0"
-    "\200\200\220\200\200$\200\200\2\200\200\26\200\200o\200\200=\200\200K\200"
-    "\200\331\200\200\376\200\200\377\200\200\344\200\200\344\200\200\344\200"
-    "\200\377\177\177~\200\200\0\204\204\266\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\246\377\377\2\377\377\204\201\201\377\200\200\376\200\200\376\200\200"
-    "\377\200\200\331\200\200\0\204\204~\40\40\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\255\377\377B\377\377\22bb#iiA\205\205\207\203\203\16\203"
-    "\203\36\203\203\330\177\177\377\200\200\377\200\200\376\200\200\376\200\200"
-    "\377\200\200t\204\204%\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\262\377\377<::\211\203\203"
-    "O\200\200\0\200\200F\200\200\214\200\200\21\200\200\0\200\200Q\200\200\40"
-    "\200\200\0\200\200\233\200\200\244\200\200\12\200\200\30\200\200\27\200\200"
-    "\37\200\2006uu\31\11\11\343\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\210"
-    "\377\377\31ss\377\177\177\376\200\200\376\200\200\377\200\200\372\177\177\201"
-    "\177\177\0--\246\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\311\377\377l\12\12q??v<<\12<<\37JJ\336\204\204\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\241\177\177\22\214\214$\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377A\14\14~dd\255\201\201+\200\200\30\200\200\377\200\200\345"
-    "\200\200\31\200\200\11\200\200\232\200\200\354\200\200A\200\200\0\200\200"
-    "\31\200\200\211\200\200\341\200\200\331\200\200f\203\203\0""88\226\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\355\377\377H\"\"\20ww\377\200\200\377\200"
-    "\200\377\200\200\377\200\200k\200\200\0++L\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\311\377\377\2\32\32\244\220\220\272\201\201\372\177\177\277\177"
-    "\177\221\177\177\20\216\216\0\37\37V\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377-\31\31\16"
-    "\212\212\6\177\177\0\200\200$\200\200\340\200\2007\200\200\0\200\200\0\200"
-    "\200Z\200\200\377\200\200R\200\200\0\200\200\0\200\200(\200\200\335\200\200"
-    "\377\200\200O\203\203H==\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\350\377\377""9OO\0\214\214r\177\177\377\200\200\346\177\177[\207\207\0\212\212"
-    ">\377\377\354\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377_\377\377\0\15\15"
-    "\0mm6\201\201\0\201\201\0\207\207\0$$X\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0"
-    "\0.\31\31\0\210\210\0\200\200\0\200\200\13\200\200+\200\200\0\200\200\235"
-    "\200\200\0\200\200\31\200\200R\200\200\27\200\200\0\200\200\1\200\200\0\200"
-    "\200(\200\200D\200\200\0\203\203\4==\323\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\177\377\377\4\377\377\1\202\202@\201\201\36\211\211\0\33\33"
-    ".\1\1\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\260\377\377I\377\377G\377\377L\377\377A\377\377\314\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377,\31\31B\210\210\203\200\200\4\200\200\0\200\200\0\200\200\217\200"
-    "\200\374\200\200!\200\200\0\200\200\0\200\200\0\200\200\31\200\200\332\200"
-    "\200m\200\200\0\200\200\0\200\200\17\203\203\7==\324\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377n\377\377J\377\377G\377\377=\377\377\306\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\341\377\377\31\23\23>\210\210\373\200\200\22\200\200\0\200\200\12"
-    "\200\200\215\200\200\254\200\200g\200\200\0\200\200\0\200\200\0\200\200L"
-    "\200\200\377\200\200j\200\200\0\200\200[\200\200\244\203\203\26==\323\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\225\377\377\0hh\13\202\2021\200\200"
-    "\0\200\200}\200\200r\200\200\25\200\200\36\200\200\"\200\200\241\200\200"
-    "\216\200\200\4\200\200\13\200\200N\200\200\37\200\200\0\200\200\326\200\200"
-    "\311\203\203\32==\322\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\240\377\377\7\377\377\201"
-    "\211\211\232\177\177K\200\200\221\200\200\377\200\200\372\200\200\377\200"
-    "\200\377\200\200\377\200\200\376\200\200\377\200\200\236\200\200{\200\200"
-    "[\200\200\0\200\200\0\200\200\4\200\200\11\203\203\7==\331\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377""9\377\377\2\206\206\326\177\177\376\200\200\373\200\200"
-    "\377\200\200\376\200\200\376\200\200\377\200\200\377\200\200\377\200\200"
-    "\376\200\200\376\200\200\377\200\200\377\200\200\374\200\200\346\200\200"
-    "\350\200\200\323\200\200\26\203\203\14CCP\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\267"
-    "\377\377\20\377\377\"\205\205\311\177\177\377\200\200\377\200\200\375\200\200\377"
-    "\200\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377"
-    "\200\200\377\200\200\376\200\200\377\200\200\377\200\200\377\200\200\377"
-    "\200\200\377\177\177\203\213\213\0??\313\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377""7\0"
-    "\0\12""221\205\205\304\200\200\377\200\200\377\200\200\376\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\376\200"
-    "\200\377\200\200\377\200\200\377\200\200\376\200\200\377\200\200\377\200"
-    "\200\303\177\177\17\216\216\\\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\352\377\377$\377\377\0\221"
-    "\221\11\204\204z\200\200\305\177\177\377\200\200\377\200\200\376\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200"
-    "\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\372\200\200"
-    "*\211\211\2\377\377\331\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\352\377\377$\377\377\4//\0zz\7||D\200"
-    "\200\220\200\200\371\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200\200\377\200"
-    "\200\377\200\200\377\200\200(\200\200\0\177\177W\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\344\377\377r\377\377\30\377\377\21hh\23bb\6__\0\201\201\0\203\203"
-    "\0\203\203\0\203\203\0\203\203\0\203\203\0\203\203\0\203\203\0\203\203\0"
-    "\203\203\0\203\203\0\203\203\0\215\215\377\377\0\230\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\303\377\377\300\377\377\304\377\377\226\377\377c::a"
-    ">>a>>a>>a>>a>>a>>a>>a>>a>>a>>a>>bCCe\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
-    "\377\377\377"
-    };
-
--- a/bsptemplate/asspandvariant/template_variant/camerasctemplate.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-// Copyright (c) 2006-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:
-// template/template_variant/camerasctemplate.mmp
-// soundsc.pdd Template shared chunk camera PDD
-// 
-//
-
-/**
- @file
-*/
-#define __USING_ASSP_REGISTER_API__
-#define __USING_ASSP_INTERRUPT_API__
-
-#include		<variant.mmh>
-#include		"kernel/kern_ext.mmh"
-
-#if defined(WINS) || defined(WINSCW)
-TARGET			_template_camerasc.pdd
-#else
-//
-// This will generate a file '_template_camerasc.pdd'
-TARGET			VariantTarget(camerasc,pdd)
-#endif
-
-TARGETTYPE		pdd
-ROMTARGET		camerasc.pdd
-
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-USERINCLUDE		camerasc
-
-SOURCEPATH		camerasc
-SOURCE			camerasc.cpp
-SOURCE			camerasc_sensor.cpp
-SOURCE			logoyuv2.cpp
-
-UID			0x100039d0 0x100039eb
-VENDORID		0x70000001
-
-CAPABILITY		all
-
-SMPSAFE
--- a/bsptemplate/asspandvariant/template_variant/rom/base_template.iby	Tue Jul 06 15:50:07 2010 +0300
+++ b/bsptemplate/asspandvariant/template_variant/rom/base_template.iby	Wed Aug 18 11:08:29 2010 +0300
@@ -62,8 +62,6 @@
 device[VARID]	=KERNEL_DIR\DEBUG_DIR\pipelib.ldd						\sys\bin\pipelib.ldd
 device[VARID]	=KERNEL_DIR\DEBUG_DIR\minkda.ldd						\sys\bin\minkda.ldd
 extension[VARID]=KERNEL_DIR\DEBUG_DIR\exstart.dll						\sys\bin\exstart.dll
-device[VARID]	=KERNEL_DIR\DEBUG_DIR\ecamerasc.ldd						\sys\bin\ecamerasc.ldd
-device[VARID]	=KERNEL_DIR\DEBUG_DIR\_template_camerasc.pdd					\sys\bin\camerasc.pdd
 
 // USB Drivers
 extension[VARID]=KERNEL_DIR\DEBUG_DIR\_template_usbcc.dll				\sys\bin\usbcc.dll
--- a/bsptemplate/asspandvariant/template_variant/rom/kernel.iby	Tue Jul 06 15:50:07 2010 +0300
+++ b/bsptemplate/asspandvariant/template_variant/rom/kernel.iby	Wed Aug 18 11:08:29 2010 +0300
@@ -66,8 +66,6 @@
 device[VARID]=		\Epoc32\Release\##KMAIN##\##BUILD##\PIPELIB.LDD					\sys\bin\pipelib.ldd
 device[VARID]= 		\Epoc32\Release\##KMAIN##\##BUILD##\ESOUNDSC.LDD				\sys\bin\esoundsc.ldd
 extension[VARID]=	\Epoc32\Release\##KMAIN##\##BUILD##\EXSTART.DLL					\sys\bin\exstart.dll
-device[VARID]=		\Epoc32\Release\##KMAIN##\##BUILD##\ECAMERASC.LDD			\sys\bin\ecamerasc.ldd
-device[VARID]=		\Epoc32\Release\##KMAIN##\##BUILD##\_##VARIANT##_CAMERASC.PDD		\sys\bin\camerasc.pdd
 
 // USB Client
 device[VARID]=		\Epoc32\Release\##KMAIN##\##BUILD##\USBC.LDD					\sys\bin\EUSBC.LDD
--- a/build.config.xml	Tue Jul 06 15:50:07 2010 +0300
+++ b/build.config.xml	Wed Aug 18 11:08:29 2010 +0300
@@ -103,7 +103,6 @@
 			<unit name="eka" unitID="sos.eka" bldFile="\sf\os\kernelhwsrv\kernel\eka" mrp="\sf\os\kernelhwsrv\kernel\eka\base_e32.mrp"/>
 			<unit name="eka_compsupp" unitID="sos.eka_compsupp" bldFile="\sf\os\kernelhwsrv\kernel\eka\compsupp" mrp="\sf\os\kernelhwsrv\kernel\eka\compsupp\base_e32_compsupp.mrp"/>
 			<unit name="eka_drivers_bsp" unitID="sos.eka_drivers_bsp" bldFile="\sf\os\kernelhwsrv\kernel\eka\drivers\bsp\" mrp="\sf\os\kernelhwsrv\kernel\eka\drivers\bsp\base_e32_drivers_bsp.mrp.mrp"/>
-			<unit name="eka_drivers_camerasc" unitID="sos.eka_drivers_camerasc" bldFile="\sf\os\kernelhwsrv\kernel\eka\drivers\camerasc" mrp="\sf\os\kernelhwsrv\kernel\eka\drivers\camerasc\base_drivers_camerasc.mrp"/>
 			<unit name="eka_drivers_cf_unistore2" unitID="sos.eka_drivers_cf_unistore2" bldFile="\sf\os\kernelhwsrv\kernel\eka\drivers\crashflash\unistore2" mrp="\sf\os\kernelhwsrv\kernel\eka\drivers\crashflash\unistore2\base_crashflash_unistore2.mrp"/>
 			<unit name="eka_drivers_debug" unitID="sos.eka_drivers_debug" bldFile="\sf\os\kernelhwsrv\kernel\eka\drivers\debug\group" mrp="\sf\os\kernelhwsrv\kernel\eka\drivers\debug\group\base_e32_drivers_debug.mrp"/>
 			<unit name="eka_drivers_display" unitID="sos.eka_drivers_display" bldFile="\sf\os\kernelhwsrv\kernel\eka\drivers\display" mrp="\sf\os\kernelhwsrv\kernel\eka\drivers\display\base_e32_drivers_display.mrp"/>
@@ -147,12 +146,13 @@
 		<module name="KHS_E32utils"> 
 			<unit name="e32utils" unitID="sos.e32utils" bldFile="\sf\os\kernelhwsrv\kerneltest\e32utils\group" mrp="\sf\os\kernelhwsrv\kerneltest\e32utils\group\base_e32utils.mrp"/>
 			<unit name="e32utils_restricted" unitID="sos.e32utils_restricted" bldFile="\sf\os\kernelhwsrv\kerneltest\e32utils\group\restricted" mrp="\sf\os\kernelhwsrv\kerneltest\e32utils\group\restricted\base_e32utils_restricted.mrp"/>
-		</module> 
-		<!--
+		</module>
+
 		<module name="BSP_Emulator"> 
 			<unit name="emulatorbsp" unitID="sos.emulatorbsp" bldFile="\sf\os\boardsupport\emulator\emulatorbsp" mrp="\sf\os\boardsupport\emulator\emulatorbsp\base_wins.mrp"/>
 			<unit name="unistore2emulatorsupport" unitID="sos.unistore2emulatorsupport" bldFile="\sf\os\boardsupport\emulator\unistore2emulatorsupport" mrp="\sf\os\boardsupport\emulator\unistore2emulatorsupport\base_wins_unistore2.mrp"/>
 		</module>
+		<!--
 		<module name="BSP_NaviEngine"> 
 			<unit name="navienginebootldr" unitID="sos.navienginebootldr" bldFile="\sf\os\boardsupport\naviengine\navienginebootldr" mrp="\sf\os\boardsupport\naviengine\navienginebootldr\base_wins.mrp"/>
 			<unit name="navienginebsp_ne1_tb" unitID="sos.navienginebsp_ne1_tb" bldFile="\sf\os\boardsupport\naviengine\navienginebsp\ne1_tb" mrp=""/>
@@ -163,6 +163,7 @@
 			<unit name="naviengineusbhcd" unitID="sos.naviengineusbhcd" bldFile="\sf\os\boardsupport\naviengine\naviengineusbhcd" mrp="\sf\os\boardsupport\naviengine\naviengineusbhcd\base_naviengine_usbhost.mrp"/>
 			<unit name="naviengineusbhcd_flexible" unitID="sos.naviengineusbhcd_flexible" bldFile="\sf\os\boardsupport\naviengine\naviengineusbhcd\flexible" mrp=""/>
 		</module>
+		-->
 		<module name="BSP_OMAP3Variants"> 
 			<unit name="34xx_sdp" unitID="sos.34xx_sdp" bldFile="\sf\os\boardsupport\omap3variants\tiomap3bsp\variant\34xx_sdp" mrp=""/>
 			<unit name="34xx_sdp_bootloader" unitID="sos.34xx_sdp_bootloader" bldFile="\sf\os\boardsupport\omap3variants\tiomap3bsp\variant\34xx_sdp\34xx_sdp_bootloader" mrp=""/>
@@ -185,12 +186,13 @@
 		<module name="BSP_OMAPH4"> 
 			<unit name="h4bootloader" unitID="sos.h4bootloader" bldFile="\sf\os\boardsupport\omaph4\h4bootloader" mrp="\sf\os\boardsupport\omaph4\h4bootloader\base_omaph4hrp_bootldr.mrp"/>
 			<unit name="omaph4bsp_h4" unitID="sos.omaph4bsp_h4" bldFile="\sf\os\boardsupport\omaph4\omaph4bsp\h4" mrp="\sf\os\boardsupport\omaph4\omaph4bsp\h4\base_omaph4hrp.mrp"/>
-			<unit name="omaph4bsp_h4_flexible" unitID="sos.omaph4bsp_h4_flexible" bldFile="\sf\os\boardsupport\omaph4\omaph4bsp\h4\flexible" mrp="\sf\os\boardsupport\omaph4\omaph4bsp\h4\flexible\base_omaph4hrp_flexible.mrp"/>
+			<!--<unit name="omaph4bsp_h4_flexible" unitID="sos.omaph4bsp_h4_flexible" bldFile="\sf\os\boardsupport\omaph4\omaph4bsp\h4\flexible" mrp="\sf\os\boardsupport\omaph4\omaph4bsp\h4\flexible\base_omaph4hrp_flexible.mrp"/>-->
 			<unit name="omaph4minienvbootloader" unitID="sos.omaph4minienvbootloader" bldFile="\sf\os\boardsupport\omaph4\omaph4minienvbootloader" mrp="\sf\os\boardsupport\omaph4\omaph4minienvbootloader\base_omaph4hrp_mebootldr.mrp"/>
 			<unit name="omaph4sdio" unitID="sos.omaph4sdio" bldFile="\sf\os\boardsupport\omaph4\omaph4sdio" mrp="\sf\os\boardsupport\omaph4\omaph4sdio\base_omaph4hrp_sdio.mrp"/>
 			<unit name="omaph4unistore2" unitID="sos.omaph4unistore2" bldFile="\sf\os\boardsupport\omaph4\omaph4unistore2" mrp="\sf\os\boardsupport\omaph4\omaph4unistore2\base_omaph4hrp_unistore2.mrp"/>
-			<unit name="omapusbhotgdrivers" unitID="sos.omapusbhotgdrivers" bldFile="\sf\os\boardsupport\omaph4\omapusbhotgdrivers" mrp="\sf\os\boardsupport\omaph4\omapusbhotgdrivers\base_omaph4hrp_usbhostotg_usbware.mrp"/>
+			<!-- <unit name="omapusbhotgdrivers" unitID="sos.omapusbhotgdrivers" bldFile="\sf\os\boardsupport\omaph4\omapusbhotgdrivers" mrp="\sf\os\boardsupport\omaph4\omapusbhotgdrivers\base_omaph4hrp_usbhostotg_usbware.mrp"/> -->
 		</module>
+		<!-- 
 		<module name="BSP_STVariants"> 
 			<unit name="montblanc_test" unitID="sos.montblanc_test" bldFile="\sf\os\boardsupport\stvariants\montblanc\test" mrp=""/>
 			<unit name="nokia_smpower" unitID="sos.nokia_smpower" bldFile="\sf\os\boardsupport\emulator\unistore2emulatorsupport" mrp=""/>
@@ -223,7 +225,7 @@
 			<unit name="isaaccessdriver" unitID="sos.isaaccessdriver" bldFile="\ncp_sw\corecom\modemadaptation_ext\connectivitylayer_ext\isaaccessdriver\group" mrp=""/>
 			<unit name="ist" unitID="sos.ist" bldFile="\ncp_sw\corecom\modemadaptation_ext\connectivitylayer_ext\ist\group" mrp=""/>
 			<unit name="isimessage" unitID="sos.isimessage" bldFile="\ncp_sw\corecom\modemadaptation_ext\connectivitylayer_ext\isimessage\group" mrp=""/>
-			<unit name="TraceCore" unitID="sos.TraceCore" bldFile="\ncp_sw\corecom\SWATI_Symbian_Tools\Trace\TraceCore\group" mrp=""/>
+			<!-- <unit name="TraceCore" unitID="sos.TraceCore" bldFile="\ncp_sw\corecom\SWATI_Symbian_Tools\Trace\TraceCore\group" mrp=""/> -->
 			<unit name="rapu" unitID="sos.rapu" bldFile="\ncp_sw\core7.0\base_rapu\rapu" mrp=""/>
             <!-- RJC added -->
 			<unit name="rapu_flexible" unitID="sos.rapu.flexible" bldFile="\ncp_sw\core7.0\base_rapu\rapu\flexible" mrp=""/>
@@ -244,21 +246,21 @@
 			<unit name="e32test_usbdi" unitID="sos.e32test_usbdi" bldFile="\sf\os\kernelhwsrv\kerneltest\e32test\usbho\t_usbdi" mrp=""/>
 		</module> 
 
-		<!-- <module name="KHS_Test_F32test"> 
-			<unit name="f32test_automounter" unitID="sos.f32test_automounter" bldFile="\sf\os\kernelhwsrv\kerneltest\f32test\filesystem\automounter" mrp=""/>
+		<module name="KHS_Test_F32test"> 
 			<unit name="f32test" unitID="sos.f32test" bldFile="\sf\os\kernelhwsrv\kerneltest\f32test\group" mrp="\sf\os\kernelhwsrv\kerneltest\f32test\group\base_f32test.mrp"/>
 			<unit name="f32test_loader" unitID="sos.f32test_loader" bldFile="\sf\os\kernelhwsrv\kerneltest\f32test\loader" mrp="\sf\os\kernelhwsrv\kerneltest\f32test\loader\base_loader.mrp"/>
 			<unit name="f32test_rofs" unitID="sos.f32test_rofs" bldFile="\sf\os\kernelhwsrv\kerneltest\f32test\rofs" mrp=""/>
 			<unit name="f32test_shostmassstorage" unitID="sos.f32test_shostmassstorage" bldFile="\sf\os\kernelhwsrv\kerneltest\f32test\shostmassstorage" mrp=""/>
 			<unit name="f32test_tools" unitID="sos.f32test_tools" bldFile="\sf\os\kernelhwsrv\kerneltest\f32test\tools" mrp=""/>
-		</module> -->
+		</module>
 
+        <!--
 		<module name="KHS_Test_SDIOTest"> 
 			<unit name="sdiotest" unitID="sos.sdiotest" bldFile="\sf\os\kernelhwsrv\kerneltest\sdiotest" mrp="\sf\os\kernelhwsrv\kerneltest\sdiotest\base_sdiotests.mrp"/>
 			<unit name="sdiotest_restricted" unitID="sos.sdiotest_restricted" bldFile="\sf\os\kernelhwsrv\kerneltest\sdiotest_restricted" mrp="\sf\os\kernelhwsrv\kerneltest\sdiotest_restricted\base_sdiotests_restricted.mrp"/>
-			<unit name="sdiotest_restricted_btsdiodriver" unitID="sos.sdiotest_restricted_btsdiodriver" bldFile="\sf\os\kernelhwsrv\kerneltest\sdiotest_restricted\btsdiodriver\group" mrp=""/>
 		</module>
-		<!--
+
+
 		<module name="BSP_Test_Emulator"> 
 			<unit name="emulatorbsp_test" unitID="sos.emulatorbsp_test" bldFile="\sf\os\boardsupport\emulator\emulatorbsp\test" mrp=""/>
 		</module>
@@ -266,19 +268,20 @@
 			<unit name="navienginebsp_ne1_tb_test" unitID="sos.navienginebsp_ne1_tb_test" bldFile="\sf\os\boardsupport\naviengine\navienginebsp\ne1_tb\test" mrp=""/>
 			<unit name="navienginebspflexible_test" unitID="sos.navienginebspflexible_test" bldFile="\sf\os\boardsupport\naviengine\navienginebspflexible\test" mrp=""/>
 		</module>
+		<module name="BSP_Test_OMAPH2"> 
+			<unit name="omaph2bsp_h2_test" unitID="sos.omaph2bsp_h2_test" bldFile="\sf\os\boardsupport\omaph2\omaph2bsp\h2\test" mrp=""/>
+		</module>
+		-->
+
 		<module name="BSP_Test_OMAP3Variants"> 
 			<unit name="34xx_sdp_flexible_test" unitID="sos.34xx_sdp_flexible_test" bldFile="\sf\os\boardsupport\omap3variants\tiomap3bsp\variant\34xx_sdp\flexible\test" mrp=""/>
 			<unit name="34xx_sdp_test" unitID="sos.34xx_sdp_test" bldFile="\sf\os\boardsupport\omap3variants\tiomap3bsp\variant\34xx_sdp\test" mrp=""/>
 			<unit name="lab_test" unitID="sos.lab_test" bldFile="\sf\os\boardsupport\omap3variants\tiomap3bsp\variant\lab\test" mrp=""/>
 		</module>
-		<module name="BSP_Test_OMAPH2"> 
-			<unit name="omaph2bsp_h2_test" unitID="sos.omaph2bsp_h2_test" bldFile="\sf\os\boardsupport\omaph2\omaph2bsp\h2\test" mrp=""/>
-		</module>
 		<module name="BSP_Test_OMAPH4"> 
 			<unit name="omaph4bsp_h4_test" unitID="sos.omaph4bsp_h4_test" bldFile="\sf\os\boardsupport\omaph4\omaph4bsp\h4\test" mrp=""/>
 			<unit name="omaph4bsp_h4_flexible_test" unitID="sos.omaph4bsp_h4_flexible_test" bldFile="\sf\os\boardsupport\omaph4\omaph4bsp\h4\flexible\test" mrp=""/>
 		</module>
-		-->
 	</layer>
   </systemModel>
-</SystemDefinition>
\ No newline at end of file
+</SystemDefinition>
--- a/halservices/hal/bld.inf	Tue Jul 06 15:50:07 2010 +0300
+++ b/halservices/hal/bld.inf	Wed Aug 18 11:08:29 2010 +0300
@@ -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/bld.inf	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/bld.inf	Wed Aug 18 11:08:29 2010 +0300
@@ -41,7 +41,6 @@
 #include "drivers/media/bld.inf"
 #include "drivers/trace/bld.inf"
 #include "drivers/usbc/bld.inf"
-#include "drivers/camerasc/bld.inf"
 #include "drivers/display/bld.inf"
 #include "euser/bld.inf"
 #include "ewsrv/bld.inf"
@@ -242,9 +241,6 @@
 include/drivers/usbdi_hub.h                     drivers/						//
 include/drivers/usbdi_channel.h                 drivers/						//
 
-include/drivers/camerasc.h						drivers/						//
-include/drivers/camerasc.inl					drivers/						//
-
 include/drivers/otgdi.h                         drivers/
 
 include/drivers/crashflash.h					SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(drivers/)
@@ -365,8 +361,6 @@
 include/d32usbdi_hubdriver.inl					SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(d32usbdi_hubdriver.inl)
 include/d32usbtransfers.h						SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(d32usbtransfers.h)
 include/d32usbdescriptors.h						SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(d32usbdescriptors.h)
-include/d32camerasc.h							SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(d32camerasc.h)
-include/d32camerasc.inl							SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(d32camerasc.inl)
 include/d32otgdi.h								SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(d32otgdi.h)
 include/d32otgdi.inl							SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(d32otgdi.inl)
 include/d32otgdi_errors.h						SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(d32otgdi_errors.h)
--- a/kernel/eka/bmarm/usbcscu.def	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/bmarm/usbcscu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -18,4 +18,5 @@
 	Expire__15TEndpointBuffer @ 17 NONAME R3UNUSED ; TEndpointBuffer::Expire(void)
 	TakeBuffer__15TEndpointBufferRPvRUiRiR14TRequestStatusUi @ 18 NONAME ; TEndpointBuffer::TakeBuffer(void *&, unsigned int &, int &, TRequestStatus &, unsigned int)
 	Expire__15TEndpointBufferPv @ 19 NONAME R3UNUSED ; TEndpointBuffer::Expire(void *)
+	ResetAltSetting__16RDevUsbcScClient @ 20 NONAME R3UNUSED ; RDevUsbcScClient::ResetAltSetting(void)
 
--- a/kernel/eka/common/mem.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/common/mem.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Wed Aug 18 11:08:29 2010 +0300
@@ -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/debug/crashMonitor/inc/scmbytestreamutil.inl	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/debug/crashMonitor/inc/scmbytestreamutil.inl	Wed Aug 18 11:08:29 2010 +0300
@@ -62,7 +62,9 @@
 	 */		
 	inline TUint64 TByteStreamReader::ReadInt64()
 		{
-		return  MAKE_TUINT64(ReadInt(), ReadInt()) ;
+		TUint32 high = ReadInt();
+		TUint32 low = ReadInt();
+		return  MAKE_TUINT64(high, low) ;
 		}
 	
 	/**
--- a/kernel/eka/drivers/camerasc/base_drivers_camerasc.mrp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-# component name "Camera Driver - Shared Chunk"
-
-component	base_drivers_camerasc
-
-source	\sf\os\kernelhwsrv\kernel\eka\drivers\camerasc
-exports	\sf\os\kernelhwsrv\kernel\eka\drivers\camerasc
-binary	\sf\os\kernelhwsrv\kernel\eka\drivers\camerasc	all
-
-notes_source	\component_defs\release.src
-
-
-
-ipr E
\ No newline at end of file
--- a/kernel/eka/drivers/camerasc/bld.inf	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-// Copyright (c) 1998-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/drivers/camerasc/bld.inf
-// Shared Chunk Camera driver LDD
-// 
-//
-
-/**
- @file
-*/
-
-#include <variant/platform_paths.hrh>
-
-PRJ_PLATFORMS
-
-BASEDEFAULT
-
-PRJ_EXPORTS
-
-PRJ_MMPFILES
-
-#if !defined(WINS) || !defined(WINSCW)
-ecamerasc
-#endif
--- a/kernel/eka/drivers/camerasc/cameraldd.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2223 +0,0 @@
-// Copyright (c) 2008-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/drivers/camerasc/cameraldd.cpp
-// 
-//
-
-#include <drivers/camerasc.h>
-#include <kernel/kern_priv.h>
-#include <kernel/cache.h>
-
-//#define __KTRACE_CAM(s) s;
-#define __KTRACE_CAM(s)
-
-#define DISCARD_COMPLETED_TO_AVOID_OVERFLOW
-
-static const char KCameraLddPanic[]="CameraSc LDD";
-
-/**
-Standard export function for LDDs. This creates a DLogicalDevice derived object,
-in this case, DSoundScLddFactory.
-*/
-DECLARE_STANDARD_LDD()
-	{
-	return new DCameraScLddFactory;
-	}
-
-/**
-Constructor for the camera driver factory class.
-*/
-DCameraScLddFactory::DCameraScLddFactory()
-	{
-//	iUnitsOpenMask=0;
-
-	__KTRACE_CAM(Kern::Printf(">DCameraScLddFactory::DCameraScLddFactory"));
-
-	// Set version number for this device.
-	iVersion=RDevCameraSc::VersionRequired();
-
-	// Indicate that units / PDD are supported.
-	iParseMask=KDeviceAllowUnit|KDeviceAllowPhysicalDevice;
-
-	// Leave the units decision to the PDD
-	iUnitsMask=0xffffffff;
-	}
-
-/**
-Second stage constructor for the camera driver factory class.
-This must at least set a name for the driver object.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DCameraScLddFactory::Install()
-	{
-	return(SetName(&KDevCameraScName));
-	}
-
-/**
-Return the 'capabilities' of the camera driver in general.
-Called in the response to an RDevice::GetCaps() request.
-@param aDes A user-side descriptor to write the capabilities information into.
-*/
-void DCameraScLddFactory::GetCaps(TDes8 &aDes) const
-	{
-	// Create a capabilities object
-	TCapsDevCameraV01 caps;
-	caps.iVersion=iVersion;
-
-	// Write it back to user memory
-	Kern::InfoCopy(aDes,(TUint8*)&caps,sizeof(caps));
-	}
-
-/**
-Called by the kernel's device driver framework to create a logical channel.
-This is called in the context of the client thread which requested the creation of a logical
-channel - through a call to RBusLogicalChannel::DoCreate().
-The thread is in a critical section.
-@param aChannel Set by this function to point to the created logical channel.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DCameraScLddFactory::Create(DLogicalChannelBase*& aChannel)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLddFactory::Create"));
-
-	aChannel=new DCameraScLdd;
-	if (!aChannel)
-		return(KErrNoMemory);
-
-	return(KErrNone);
-	}
-
-/**
-Check whether a channel has is currently open on the specified unit.
-@param aUnit The number of the unit to be checked.
-@return ETrue if a channel is open on the specified channel, EFalse otherwise.
-@pre The unit info. mutex must be held.
-*/
-TBool DCameraScLddFactory::IsUnitOpen(TInt aUnit)
-	{
-	return(iUnitsOpenMask&(1<<aUnit));
-	}
-
-/**
-Attempt to change the state of the channel open status for a particular channel.
-@param aUnit The number of the unit to be updated.
-@param aIsOpenSetting	The required new state for the channel open status: either ETrue to set the status to open or
-						EFalse to set the status to closed.
-@return KErrNone if the status was updated successfully;
-		KErrInUse if an attempt has been made to set the channnel status to open while it is already open.
-*/
-TInt DCameraScLddFactory::SetUnitOpen(TInt aUnit,TBool aIsOpenSetting)
-	{
-	NKern::FMWait(&iUnitInfoMutex); // Acquire the unit info. mutex.
-
-	// Fail a request to open an channel that is already open
-	if (aIsOpenSetting && IsUnitOpen(aUnit))
-		{
-		NKern::FMSignal(&iUnitInfoMutex); // Release the unit info. mutex.
-		return(KErrInUse);
-		}
-
-	// Update the open status as requested
-	if (aIsOpenSetting)
-		iUnitsOpenMask|=(1<<aUnit);
-	else
-		iUnitsOpenMask&=~(1<<aUnit);
-
-	NKern::FMSignal(&iUnitInfoMutex); // Release the unit info. mutex.
-	return(KErrNone);
-	}
-
-/**
-Constructor for the camera driver logical channel.
-*/
-DCameraScLdd::DCameraScLdd()
-	:	iRequestQueue(&iMutex),
-		iRestartDfc(DCameraScLdd::RestartDfc,this,5),
-		iPowerDownDfc(DCameraScLdd::PowerDownDfc,this,3),
-		iPowerUpDfc(DCameraScLdd::PowerUpDfc,this,3)
-	{
-	iState=EOpen;
-//	iCaptureMode=ECaptureModeImage;
-//	iFrameHeight=0;
-//	iFrameWidth=0;
-//	iBufManager=NULL;
-//	iPowerHandler=NULL;
-//	iImageGatherCount=0;
-
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::DCameraScLdd"));
-
-	iUnit=-1;	// Invalid unit number
-
-	// Get pointer to client thread's DThread object
-	iOwningThread=&Kern::CurrentThread();
-
-	// Open a reference on client thread so it's control block can't dissapear until
-	// this driver has finished with it. Note, this call to Open() can't fail since
-	// it is the thread we are currently running in
-	iOwningThread->Open();
-	}
-
-/**
-Destructor for the camera driver logical channel.
-This is called in the context of the client thread once a 'ECloseMsg' message has been
-sent to the device driver DFC thread.
-*/
-DCameraScLdd::~DCameraScLdd()
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::~DCameraScLdd"));
-
-	TInt captureMode;
-
-	// Remove and delete the power handler.
-	if (iPowerHandler)
-		{
-		iPowerHandler->Remove();
-		delete iPowerHandler;
-		}
-
-	if (iCaptureModeConfig)
-		{
-		// Delete any buffers and shared chunk we created.
-		for (captureMode=0; captureMode < ECamCaptureModeMax; captureMode++)
-			{
-			if (iCaptureModeConfig[captureMode].iBufManager)
-				delete iCaptureModeConfig[captureMode].iBufManager;
-			}
-
-		// Delete the buffer config. info. structure.
-		for (captureMode=0; captureMode < ECamCaptureModeMax; captureMode++)
-			{
-			if (iCaptureModeConfig[captureMode].iBufConfig)
-				Kern::Free(iCaptureModeConfig[captureMode].iBufConfig);
-			}
-
-			if (iCaptureModeConfig)
-				delete[] iCaptureModeConfig;
-		}
-	// Close our reference on the client thread
-	Kern::SafeClose((DObject*&)iOwningThread,NULL);
-
-	// Clear the 'units open mask' in the LDD factory.
-	if (iUnit>=0)
-		((DCameraScLddFactory*)iDevice)->SetUnitOpen(iUnit,EFalse);
-	}
-
-/**
-Second stage constructor for the camera driver - called by the kernel's device driver framework.
-This is called in the context of the client thread which requested the creation of a logical channel
-(e.g. through a call to RBusLogicalChannel::DoCreate()).
-The thread is in a critical section.
-@param aUnit The unit argument supplied by the client. This is checked by the PDD and not used here.
-@param aInfo The info argument supplied by the client. Always NULL in this case.
-@param aVer The version argument supplied by the client.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DCameraScLdd::DoCreate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::DoCreate"));
-
-	// Check the client has EMultimediaDD capability.
-	if (!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by ECAMERA.LDD (Camera driver)")))
-		return(KErrPermissionDenied);
-
-	// Check that the camera driver version specified by the client is compatible.
-	if (!Kern::QueryVersionSupported(RDevCameraSc::VersionRequired(),aVer))
-		return(KErrNotSupported);
-
-	// Check that a channel hasn't already been opened on this unit.
-	TInt r=((DCameraScLddFactory*)iDevice)->SetUnitOpen(aUnit,ETrue); // Try to update 'units open mask' in the LDD factory.
-	if (r!=KErrNone)
-		return(r);
-	iUnit=aUnit;
-
-	// Create the power handler
-	iPowerHandler=new DCameraScPowerHandler(this);
-	if (!iPowerHandler)
-		return(KErrNoMemory);
-	iPowerHandler->Add();
-
-	// Create the pending capture request list
-	r=iRequestQueue.Create(iOwningThread);
-	if (r!=KErrNone)
-		return(r);
-
-	// Initialise the PDD
-	((DCameraScPdd*)iPdd)->iLdd=this;
-
-	// Setup the default camera config
-	iCaptureMode=ECamCaptureModeImage;
-
-	iCaptureModeConfig = new TCaptureModeConfig[ECamCaptureModeMax];
-	if(!iCaptureModeConfig)
-		return KErrNoMemory;
-	TInt capsSize = Pdd()->CapsSize();
-	TInt captureMode;
-	TAny* capsBuf;
-	capsBuf = Kern::Alloc(capsSize);
-	if(!capsBuf)
-		return KErrNoMemory;
-
-	// Query the driver for its capabilities and set a default pixel format
-	// and frame size for each available capture mode.
-	TPtr8 capsPtr( (TUint8*)capsBuf, capsSize, capsSize );
-	Pdd()->Caps(capsPtr);
-
-	TCameraCapsV02* caps = (TCameraCapsV02*) capsPtr.Ptr();
-	SDevCamPixelFormat* pixelFormat = (SDevCamPixelFormat*) (caps + 1);
-	SDevCamFrameSize* frameSize;
-	TAny* frameSizeCapsBuf=0;
-	TPtr8 frameSizeCapsPtr(0,0,0);
-
-	// Set the cache to hold the default dynamic attribute values.
-	iBrightnessValue = caps->iDynamicRange[ECamAttributeBrightness].iDefault;
-	iContrastValue = caps->iDynamicRange[ECamAttributeContrast].iDefault;
-	iColorEffectValue = caps->iDynamicRange[ECamAttributeColorEffect].iDefault;
-	
-	for (captureMode=0; captureMode < ECamCaptureModeMax; captureMode++)
-		{
-		if ((captureMode==ECamCaptureModeImage) && (caps->iNumImagePixelFormats==0))
-			continue;
-
-		if ((captureMode==ECamCaptureModeVideo) && (caps->iNumVideoPixelFormats==0))
-			continue;
-
-		if ((captureMode==ECamCaptureModeViewFinder) && (caps->iNumViewFinderPixelFormats==0))
-			continue;
-
-		iCaptureModeConfig[captureMode].iCamConfig.iPixelFormat=*pixelFormat;
-		frameSizeCapsBuf = Kern::Alloc(pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		new (&frameSizeCapsPtr) TPtr8((TUint8*)frameSizeCapsBuf, pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize), pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		r=Pdd()->FrameSizeCaps((TDevCamCaptureMode)captureMode, pixelFormat->iPixelFormat, frameSizeCapsPtr);
-		if(r!=KErrNone)
-			{
-			Kern::Free(frameSizeCapsBuf);
-			return r;
-			}
-		frameSize=(SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
-		iCaptureModeConfig[captureMode].iCamConfig.iFrameSize = *frameSize;
-		iCaptureModeConfig[captureMode].iCamConfig.iFrameRate = frameSize->iMinFrameRate;
-		Kern::Free(frameSizeCapsBuf);
-
-		iCaptureModeConfig[captureMode].iCamConfig.iFlashMode = ECamFlashNone;
-		iCaptureModeConfig[captureMode].iCamConfig.iExposureMode = ECamExposureAuto;
-		iCaptureModeConfig[captureMode].iCamConfig.iWhiteBalanceMode = ECamWBAuto;
-		iCaptureModeConfig[captureMode].iCamConfig.iZoom = 0;
-		iCaptureModeConfig[captureMode].iCamConfig.iPixelWidthInBytes = 0;
-		}
-	Kern::Free(capsBuf);
-	// Setup the default buffer config.
-	r=ReAllocBufferConfigInfo(0);	// Zeros the structure
-	if (r!=KErrNone)
-		return(r);
-	for (captureMode=0; captureMode < ECamCaptureModeMax; captureMode++)
-		{
-		iCaptureModeConfig[captureMode].iBufConfig->iNumBuffers=KDefaultNumClientBuffers;
-		}
-
-	// Set up the correct DFC queue and enable the reception of client messages.
-	TDfcQue* dfcq=((DCameraScPdd*)iPdd)->DfcQ(aUnit);
-	SetDfcQ(dfcq);
-	iRestartDfc.SetDfcQ(dfcq);
-	iPowerDownDfc.SetDfcQ(dfcq);
-	iPowerUpDfc.SetDfcQ(dfcq);
-	iMsgQ.Receive();
-
-	__KTRACE_CAM(Kern::Printf("<DCameraScLdd::DoCreate"));
-
-	return(KErrNone);
-	}
-
-/**
-Shutdown the camera device.
-Terminate all device activity and power down the hardware.
-*/
-void DCameraScLdd::Shutdown()
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::Shutdown"));
-
-	iState=EOpen;
-
-	// Power down the hardware
-	Pdd()->PowerDown();
-
-	// Cancel any requests that we may be handling
-	DoCancel(RDevCameraSc::EAllRequests);
-
-	// Make sure DFCs are not queued.
-	iRestartDfc.Cancel();
-	iPowerDownDfc.Cancel();
-	iPowerUpDfc.Cancel();
-	}
-
-/**
-Notification to the driver that a handle to it has been requested by a user thread.
-The use of a camera driver channel is restricted here to a single thread (that has
-EMultimediaDD capability).
-@param aThread A pointer to thread which is requesting the handle.
-@param aType Whether the requested handle is thread or process relative.
-@return	KErrNone, if the request is for a thread relative handle - originating from
-		the same the thread that created the channel object;
-		KErrAccessDenied, otherwise.
-*/
-TInt DCameraScLdd::RequestUserHandle(DThread* aThread, TOwnerType aType)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::RequestUserHandle"));
-
-	// Ensure that each channel can only be used by a single thread.
-	if (aType!=EOwnerThread || aThread!=iOwningThread)
-		return(KErrAccessDenied);
-	return(KErrNone);
-	}
-
-/**
-Process a request on this logical channel
-Called in the context of the client thread.
-@param aReqNo	The request number:
-				==KMaxTInt: a 'DoCancel' message;
-				>=0: a 'DoControl' message with function number equal to value.
-				<0: a 'DoRequest' message with function number equal to ~value.
-@param a1 The first request argument. For DoRequest(), this is a pointer to the TRequestStatus.
-@param a2 The second request argument. For DoRequest(), this is a pointer to the 2 actual TAny* arguments.
-@return The result of the request. This is ignored by device driver framework for DoRequest().
-*/
-TInt DCameraScLdd::Request(TInt aReqNo, TAny* a1, TAny* a2)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::Request(%d)",aReqNo));
-	TInt r;
-	if (aReqNo<RDevCameraSc::EMsgControlMax && aReqNo>(~RDevCameraSc::EMsgRequestMax))
-		{
-		// Implement in the context of the kernel thread - prepare and issue a kernel message.
-		r=DLogicalChannel::Request(aReqNo,a1,a2);
-		}
-	else
-		{
-		// Implement in the context of the client thread.
-		// Decode the message type and dispatch it to the relevent handler function.
-		if ((TUint)aReqNo<(TUint)KMaxTInt)
-			r=DoControl(aReqNo,a1,a2);		// DoControl - process the request.
-
-		else if (aReqNo==KMaxTInt)
-			{
-			r=DoCancel((TInt)a1);			// DoCancel - cancel the request.
-			}
-
-		else
-			{
-			// DoRequest
-			TInt func=~aReqNo;
-
-			// NotifyNewImage() during image capture mode is another case which must be handled in the kernel thread.
-			if (iCaptureMode==ECamCaptureModeImage && func==RDevCameraSc::ERequestNotifyNewImage)
-				r=DLogicalChannel::Request(aReqNo,a1,a2);
-			else
-				{
-				// Read the arguments from the client thread and process the request.
-				TAny* a[2];
-				kumemget32(a,a2,sizeof(a));
-				TRequestStatus* status=(TRequestStatus*)a1;
-				r=DoRequest(func,status,a[0],a[1]);
-
-				// Complete request if there was an error
-				if (r!=KErrNone)
-					Kern::RequestComplete(iOwningThread,status,r);
-				r=KErrNone;
-				}
-			}
-		}
-	__KTRACE_CAM(Kern::Printf("<DCameraScLdd::Request - %d",r));
-	return(r);
-	}
-
-/**
-Process a message for this logical channel.
-This function is called in the context of the DFC thread.
-@param aMsg The message to process.
-			The iValue member of this distinguishes the message type:
-			iValue==ECloseMsg, channel close message.
-			iValue==KMaxTInt, a 'DoCancel' message.
-			iValue>=0, a 'DoControl' message with function number equal to iValue.
-			iValue<0, a 'DoRequest' message with function number equal to ~iValue.
-*/
-void DCameraScLdd::HandleMsg(TMessageBase* aMsg)
-	{
-	TThreadMessage& m=*(TThreadMessage*)aMsg;
-	TInt id=m.iValue;
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::HandleMsg(%d)",id));
-
-	// Decode the message type and dispatch it to the relevent handler function.
-	if (id==(TInt)ECloseMsg)
-		{
-		// Channel close.
-		Shutdown();
-		m.Complete(KErrNone,EFalse);
-		return;
-		}
-	else if (id<0)	// The only DoRequest handled in the kernel thread is NotifyNewImage(ECamCaptureModeImage).
-		{
-		// DoRequest
-		TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
-		TInt r=DoRequest(~id,pS,m.Ptr1(),m.Ptr2());
-		if (r!=KErrNone)
-			Kern::RequestComplete(iOwningThread,pS,r);
-		m.Complete(KErrNone,ETrue);
-		}
-	else
-		{
-		// Must be DoControl (Cancel is handled in the client thread).
-		TInt r=DoControl(id,m.Ptr0(),m.Ptr1());
-		m.Complete(r,ETrue);
-		}
-	}
-
-/**
-Process a synchronous 'DoControl' request.
-This function is called in the context of the DFC thread.
-@param aFunction The request number.
-@param a1 The first request argument.
-@param a2 The second request argument.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DCameraScLdd::DoControl(TInt aFunction, TAny* a1, TAny* a2)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::DoControl(%d)",aFunction));
-
-	TInt r=KErrNotSupported;
-	switch (aFunction)
-		{
-		case RDevCameraSc::EControlCaps:
-			{
-			r = GetSensorCaps(a1);
-			break;
-			}
-		case RDevCameraSc::EControlSetCaptureMode:
-			{
-			// Change the capture mode.
-			r=SetCaptureMode((TInt)a1);
-			break;
-			}
-		case RDevCameraSc::EControlSetCamConfig:
-			{
-			// Set the new camera configuration.
-			NKern::ThreadEnterCS();
-			r=SetCamConfig((TInt)a1, (const TDesC8*)a2);
-			NKern::ThreadLeaveCS();
-			break;
-			}
-		case RDevCameraSc::EControlGetCamConfig:
-			{
-			// Write the config to the client.
-			TPtrC8 ptr((const TUint8*)&iCaptureModeConfig[(TInt)a1].iCamConfig,sizeof(iCaptureModeConfig[(TInt)a1].iCamConfig));
-			Kern::InfoCopy(*((TDes8*)a2),ptr);
-			r=KErrNone;
-			break;
-			}
-		case RDevCameraSc::EControlGetBufferConfig:
-			if (iCaptureModeConfig[(TInt)a1].iBufConfig)
-				{
-				// Write the buffer config to the client.
-				TPtrC8 ptr((const TUint8*)&(*iCaptureModeConfig[(TInt)a1].iBufConfig),iCaptureModeConfig[(TInt)a1].iBufConfigSize);
-				Kern::InfoCopy(*((TDes8*)a2),ptr);
-				r=KErrNone;
-				}
-			break;
-		case RDevCameraSc::EControlSetBufConfigChunkCreate:
-			// Need to be in critical section while deleting an exisiting config and creating a new one
-			NKern::ThreadEnterCS();
-			r=SetBufConfig((TInt)a1,(TInt)a2);
-			NKern::ThreadLeaveCS();
-			break;
-		case RDevCameraSc::EControlSetBufConfigChunkOpen:
-			SSetBufConfigChunkOpenInfo info;
-			r=Kern::ThreadRawRead(iOwningThread,a2,&info,sizeof(info));
-			if (r==KErrNone)
-				{
-				// Need to be in critical section while deleting an exisiting config and creating a new one
-				NKern::ThreadEnterCS();
-				r=SetBufConfig((TInt)a1,info.iBufferConfigBuf,info.iChunkHandle);
-				NKern::ThreadLeaveCS();
-				}
-			break;
-		case RDevCameraSc::EControlChunkClose:
-			r=ChunkClose((TInt)a1);
-			break;
-		case RDevCameraSc::EControlStart:
-			r=Start();
-			break;
-		case RDevCameraSc::EControlStop:
-			if (iState==ECapturing)
-				{
-				r=Pdd()->Stop();
-				DoCancel(1<<RDevCameraSc::ERequestNotifyNewImage);
-				if (r==KErrNone)
-					iState=EConfigured;
-				}
-			else
-				{
-				r=KErrGeneral;
-				}
-			break;
-		case RDevCameraSc::EControlReleaseBuffer:
-			r=ReleaseBuffer((TInt)a1);
-			break;
-		case RDevCameraSc::EControlNotifyNewImageSpecificCancel:
-			{
-			NKern::FMWait(&iMutex); 		// Acquire the buffer/request list mutex.
-			iRequestQueue.Cancel((TRequestStatus*)a1);
-			NKern::FMSignal(&iMutex); 		// Release the buffer/request list mutex.
-			r=KErrNone;
-			break;
-			}
-			
-		case RDevCameraSc::EControlBufferIdToOffset:
-			{
-			// a1 has pointer to buffer for search criteria
-			// a2 has pointer to offset for result
-			TDevCamBufferModeAndId info;
-			TPtr8 inDesc((TUint8*)(&info), sizeof(info));
-
-			r = Kern::ThreadDesRead(iOwningThread,a1,inDesc,0);
-			if (r == KErrNone)
-				{
-				TInt id = info.iId;
-				TDevCamCaptureMode captureMode = info.iCaptureMode;
-
-				r = KErrNotFound;
-				DBufferManager* mgr = iCaptureModeConfig[captureMode].iBufManager;
-				if (mgr)
-					{
-					if (mgr->iImageBuffer[id].iId == id)
-						{
-						kumemput32(a2, &mgr->iImageBuffer[id].iChunkOffset, sizeof(TInt));
-						r = KErrNone;
-						}
-					}
-				}
-			
-			break;
-			}
-		case RDevCameraSc::EControlCapsSize:
-			{
-			r = Pdd()->CapsSize();
-			break;
-			}
-		case RDevCameraSc::EControlFrameSizeCaps:
-			{
-			r = GetFrameSizeCaps(a1, a2);
-			break;
-			}
-			
-		case RDevCameraSc::EControlSetDynamicAttribute:
-			{
-			NKern::ThreadEnterCS();
-			r = SetDynamicAttribute((TInt)a1, (TUint)a2);
-			NKern::ThreadLeaveCS();
-			break;
-			}
-			
-		case RDevCameraSc::EControlGetDynamicAttribute:
-			{
-			TInt attribute = (TInt)(a1);
-			TUint value = 0;
-			
-			r = GetDynamicAttribute(attribute, value);
-			if (r == KErrNone)
-				{
-				kumemput32(a2, &value, sizeof(TUint));
-				}
-				
-			break;
-			}
-			
-		}
-	return(r);
-	}
-
-/**
-Process an asynchronous 'DoRequest' request.
-This function is called in the context of the DFC thread.
-@param aFunction The request number.
-@param aStatus A pointer to the TRequestStatus.
-@param a1 The first request argument.
-@param a2 The second request argument.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DCameraScLdd::DoRequest(TInt aFunction, TRequestStatus* aStatus, TAny* /*a1*/, TAny* /*a2*/)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::DoRequest(%d)",aFunction));
-
-	TInt r=KErrNotSupported;
-	switch (aFunction)
-		{
-		case RDevCameraSc::ERequestNotifyNewImage:
-			r=NotifyNewImage(aStatus);
-			break;
-		}
-
-	__KTRACE_CAM(Kern::Printf("<DCameraScLdd::DoRequest - %d",r));
-	return(r);
-	}
-
-/**
-Process the cancelling of asynchronous requests.
-This function is called in the context of the DFC thread.
-@param aMask A mask indicating which requests need to be cancelled.
-@return The result of the cancel. Either KErrNone if successful, otherwise one of the other
-	system wide error codes.
-*/
-TInt DCameraScLdd::DoCancel(TUint aMask)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::DoCancel(%08x)",aMask));
-
-	if (aMask&(1<<RDevCameraSc::ERequestNotifyNewImage))
-		{
-		NKern::FMWait(&iMutex); 		// Acquire the buffer/request list mutex.
-		iRequestQueue.CancelAll();
-		NKern::FMSignal(&iMutex); 		// Release the buffer/request list mutex.
-		}
-	return(KErrNone);
-	}
-
-/**
-@pre The thread must be in a critical section.
-*/
-TInt DCameraScLdd::ReAllocBufferConfigInfo(TInt aNumBuffers)
-	{
-	for (TInt captureMode=0; captureMode < ECamCaptureModeMax; captureMode++)
-		{
-		if (iCaptureModeConfig[captureMode].iBufConfig)
-			{
-			Kern::Free(iCaptureModeConfig[captureMode].iBufConfig);
-			iCaptureModeConfig[captureMode].iBufConfig=NULL;
-			}
-
-		iCaptureModeConfig[captureMode].iBufConfigSize=aNumBuffers*(sizeof(SBufSpecList)); // Size of the three integers that hold the offset to the start of each buffer and the buffer id.
-		iCaptureModeConfig[captureMode].iBufConfigSize+=sizeof(TSharedChunkBufConfigBase);
-		iCaptureModeConfig[captureMode].iBufConfig=(TCameraSharedChunkBufConfig*)Kern::AllocZ(iCaptureModeConfig[captureMode].iBufConfigSize);
-		if (!iCaptureModeConfig[captureMode].iBufConfig)
-			return(KErrNoMemory);
-		}
-	return(KErrNone);
-	}
-
-/**
-Reallocate memory for the new buffer configuration.
-@param aNumBuffers The number of buffers.
-@pre The thread must be in a critical section.
-*/
-TInt DCameraScLdd::ReAllocBufferConfigInfo(TInt aCaptureMode, TInt aNumBuffers)
-	{
-	if (iCaptureModeConfig[aCaptureMode].iBufConfig)
-		{
-		Kern::Free(iCaptureModeConfig[aCaptureMode].iBufConfig);
-		iCaptureModeConfig[aCaptureMode].iBufConfig=NULL;
-		}
-
-	iCaptureModeConfig[aCaptureMode].iBufConfigSize=aNumBuffers*(sizeof(SBufSpecList)); // Size of the three integers that hold the offset to the start of each buffer and the buffer id.
-	iCaptureModeConfig[aCaptureMode].iBufConfigSize+=sizeof(TSharedChunkBufConfigBase);
-	iCaptureModeConfig[aCaptureMode].iBufConfig=(TCameraSharedChunkBufConfig*)Kern::AllocZ(iCaptureModeConfig[aCaptureMode].iBufConfigSize);
-	if (!iCaptureModeConfig[aCaptureMode].iBufConfig)
-		return(KErrNoMemory);
-
-	return(KErrNone);
-	}
-
-/**
-@return	A handle to the shared chunk for the owning thread (a value >0), if successful;
-		otherwise one of the other system wide error codes, (a value <0).
-@param aCamConfigBuf The supplied camera configuration.
-@pre The thread must be in a critical section.
-*/
-TInt DCameraScLdd::SetCamConfig(TInt aCaptureMode, const TDesC8* aCamConfigBuf)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::SetCamConfig()"));
-
-	// Set the configuration of the sensor
-	TInt r=DoSetConfig(aCaptureMode, aCamConfigBuf);
-	return(r);
-	}
-
-/**
-Allows changing of the dynamic settings.
-Checks locally the validity of the arguments passed so as to increase performance by not
-forcing a context switch.
-
-If the setting has been accepted by the sensor the new value is cached by the LDD so further
-querying does not involve another context switch.
-
-@param aAttribute An enum identifying the dynamic attribute to change.
-@param aValue The attributes value.
-@return KErrNone if successful, KErrNotSupported if not supported, KErrArgument if aValue out of range.
-		Otherwise, one of the system wide error codes.
-@pre The thread must be in a critical section.
-*/
-TInt DCameraScLdd::SetDynamicAttribute(TInt aAttribute, TUint aValue)
-	{
-	TUint* attrCachePtr = NULL;
-	TInt err = KErrNotSupported;
-	
-	switch (aAttribute)
-		{
-		case ECamAttributeBrightness:
-			err = Pdd()->SetBrightness(aValue);
-			attrCachePtr = &iBrightnessValue;
-			break;
-			
-		case ECamAttributeContrast:
-			err = Pdd()->SetContrast(aValue);
-			attrCachePtr = &iContrastValue;
-			break;
-			
-		case ECamAttributeColorEffect:
-			err = Pdd()->SetColorEffect(aValue);
-			attrCachePtr = &iColorEffectValue;
-			break;
-			
-		default:
-			return err;
-		}
-	
-	if (err == KErrNone)
-		{
-		// Cache the set value.
-		__ASSERT_DEBUG(attrCachePtr, Kern::Fault(KCameraLddPanic, __LINE__));
-		*attrCachePtr = aValue;
-		}
-		
-	return err;
-	}
-
-
-/**
-Allows querying of a dynamic setting.
-The value is read from the cached LDD values.
-
-@param aAttribute An enum identifying the dynamic attribute to change.
-@param aValue A reference to a variable that will receive the attribute value.
-@return KErrNone if successful, KErrNotFound if aAttribute is an unsupported
-        setting. The parameter aValue is not changed if this function fails.
-*/
-TInt DCameraScLdd::GetDynamicAttribute(TInt aAttribute, TUint& aValue)
-	{
-	switch (aAttribute)
-		{
-		case ECamAttributeBrightness:
-			aValue = iBrightnessValue;
-			break;
-			
-		case ECamAttributeContrast:
-			aValue = iContrastValue;
-			break;
-			
-		case ECamAttributeColorEffect:
-			aValue = iColorEffectValue;
-			break;
-			
-		default:
-			return KErrNotFound;
-		}
-		
-	return KErrNone;
-	}
-
-
-/**
-Updates the buffer configuration of the camera for the specified capture mode.
-@return	A handle to the shared chunk for the owning thread (a value >0), if successful;
-		otherwise one of the other system wide error codes, (a value <0).
-*/
-TInt DCameraScLdd::SetBufConfig(TInt aCaptureMode, TInt aNumBuffers)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::SetBufConfig(CaptureMode=%d,NumBuffers=%d)",aCaptureMode,aNumBuffers));
-
-	// Free any memory and chunk already allocated
-	TInt r=ChunkClose(aCaptureMode);
-	if (r!=KErrNone)
-		return(r);
-
-	// Allocate a new shared chunk and create the specified number of buffers within it.
-	TInt buffersize=((iCaptureModeConfig[aCaptureMode].iCamConfig.iFrameSize.iWidth*iCaptureModeConfig[aCaptureMode].iCamConfig.iFrameSize.iHeight) * iCaptureModeConfig[aCaptureMode].iCamConfig.iPixelWidthInBytes);
-	__KTRACE_CAM(Kern::Printf(">>DCameraScLdd::SetBufConfig - iFrameSize:%d, iPixelWidthInBytes:%d => bufferSize:%d",(iCaptureModeConfig[aCaptureMode].iCamConfig.iFrameSize.iWidth*iCaptureModeConfig[aCaptureMode].iCamConfig.iFrameSize.iHeight),iCaptureModeConfig[aCaptureMode].iCamConfig.iPixelWidthInBytes,buffersize));
-	iCaptureModeConfig[aCaptureMode].iBufManager=new DBufferManager(this);
-	if (!iCaptureModeConfig[aCaptureMode].iBufManager)
-		return(KErrNoMemory);
-	r=iCaptureModeConfig[aCaptureMode].iBufManager->Create(aNumBuffers,buffersize);
-	if (r!=KErrNone)
-		return(r);
-
-	// Update the LDD's chunk/buffer geometry info.
-	r=ReAllocBufferConfigInfo(aCaptureMode, aNumBuffers);
-	if (r!=KErrNone)
-		return(r);
-	iCaptureModeConfig[aCaptureMode].iBufManager->GetBufConfig(*iCaptureModeConfig[aCaptureMode].iBufConfig);
-
-	// Create handle to the shared chunk for the owning thread.
-	r=Kern::MakeHandleAndOpen(iOwningThread,iCaptureModeConfig[aCaptureMode].iBufManager->iChunk);
-	if (r>0)
-		{
-		// And save the the chunk and handle for later.  Normally the chunk handle will be closed when the chunk
-		// is closed, but if the chunk is re-allocated then it will need to be closed before re-allocation.
-		iCaptureModeConfig[aCaptureMode].iChunkHandle=r;
-		}
-
-	__KTRACE_CAM(Kern::Printf("<DCameraScLdd::SetBufConfig - %d",r));
-	return(r);
-	}
-
-/**
-Updates the buffer configuration of the camera, which has been supplied by the user, for the specified capture mode.
-@param aCaptureMode		The capture mode for which the setting of the buffer configuration is made.
-@param aBufferConfigBuf	A buffer that holds the buffer configuration for the camera.
-@param aChunkHandle		A handle for the shared chunk supplied by the client.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-@pre The thread must be in a critical section.
-*/
-TInt DCameraScLdd::SetBufConfig(TInt aCaptureMode,const TDesC8* aBufferConfigBuf,TInt aChunkHandle)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::SetConfig(Handle-%d)",aChunkHandle));
-
-	// Read the buffer config structure from the client.
-	TInt numBuffers;
-	TPtr8 ptr((TUint8*)&numBuffers,sizeof(numBuffers));
-	TInt r=Kern::ThreadDesRead(iOwningThread,aBufferConfigBuf,ptr,0);
-	if (r!=KErrNone)
-		return(r);
-	// Calculate the minimum length of the descriptor.
-	TInt minDesLen=(numBuffers*sizeof(SBufSpecList))+sizeof(TSharedChunkBufConfigBase);
-	r=Kern::ThreadGetDesLength(iOwningThread,aBufferConfigBuf);
-	if (r<minDesLen)
-		return(KErrArgument);
-	r=ReAllocBufferConfigInfo(aCaptureMode, numBuffers);
-	if (r!=KErrNone)
-		return(r);
-	ptr.Set((TUint8*)iCaptureModeConfig[aCaptureMode].iBufConfig,0,iCaptureModeConfig[aCaptureMode].iBufConfigSize);
-	r=Kern::ThreadDesRead(iOwningThread,aBufferConfigBuf,ptr,0);
-	if (r!=KErrNone)
-		return(r);
-
-	// Free any memory and chunk already allocated
-	r=ChunkClose(aCaptureMode);
-	if (r!=KErrNone)
-		return(r);
-
-	// Open the shared chunk supplied and create buffer objects for the committed buffers within it.
-	iCaptureModeConfig[aCaptureMode].iBufManager=new DBufferManager(this);
-	if (!iCaptureModeConfig[aCaptureMode].iBufManager)
-		return(KErrNoMemory);
-	r=iCaptureModeConfig[aCaptureMode].iBufManager->Create(*iCaptureModeConfig[aCaptureMode].iBufConfig,aChunkHandle,iOwningThread);
-	if (r!=KErrNone)
-		return(r);
-
-	__KTRACE_CAM(Kern::Printf("<DCameraScLdd::SetConfig - %d",KErrNone));
-	return(r);
-	}
-
-/**
-Frees the buffer manager associated with a chunk, and closes the chunk itself.  The chunk being closed,
-and its associated DBufferManager instance should have been allocated by the device driver.  However,
-this is not a requirement.
-@param aCaptureMode The capture mode for which to free the buffer manager and chunk.
-@return	KErrNone if successful.
-		KErrInUse if an attempt has been made to free the memory and chunk while they are in use.
-		Otherwise one of the other system-wide error codes.
-*/
-TInt DCameraScLdd::ChunkClose(TInt aCaptureMode)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::ChunkClose(Capture Mode-%d)",aCaptureMode));
-
-	if(iCaptureMode == aCaptureMode)
-        {
-        if (iState==ECapturing)
-            return(KErrInUse);
-        }
-
-	// Delete any existing buffers
-	if (iCaptureModeConfig[aCaptureMode].iBufManager)
-		{
-		delete iCaptureModeConfig[aCaptureMode].iBufManager;
-		iCaptureModeConfig[aCaptureMode].iBufManager=NULL;
-		}
-
-	// If a handle to the shared chunk was created, close it, using the handle of the thread on which
-	// it was created, in case a different thread is now calling us
-	if (iCaptureModeConfig[aCaptureMode].iChunkHandle>0)
-		{
-		Kern::CloseHandle(iOwningThread,iCaptureModeConfig[aCaptureMode].iChunkHandle);
-		iCaptureModeConfig[aCaptureMode].iChunkHandle=0;
-		}
-
-	return(KErrNone);
-	}
-
-/**
-Set the current capture mode and submits the camera configuration to the PDD, passing it as a descriptor
-to support future changes to the config structure.
-
-@param aCaptureMode	The capture mode that the camera switches to.
-@return KErrNone if successful;
-		otherwise one of the other system-wide error codes.
-*/
-TInt DCameraScLdd::SetCaptureMode(TInt aCaptureMode)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::SetCaptureMode(Mode-%d)",aCaptureMode));
-
-	TInt r=KErrNone;
-	if(aCaptureMode >= ECamCaptureModeMax || aCaptureMode < 0)
-		{
-		r=KErrNotFound;
-		return(r);
-		}
-
-	if (!iCaptureModeConfig[aCaptureMode].iBufManager)
-		{
-		r=KErrNotReady;
-		return(r);
-		}
-
-	iCaptureMode=(TDevCamCaptureMode)aCaptureMode;	// The capture mode has already been checked for its validity.
-
-	__KTRACE_CAM(Kern::Printf("DCameraScLdd::SetCaptureMode: iFrameSize:%dx%d)",iCaptureModeConfig[iCaptureMode].iCamConfig.iFrameSize.iWidth, iCaptureModeConfig[iCaptureMode].iCamConfig.iFrameSize.iHeight));
-
-	// Call the PDD to change the hardware configuration according to the new capture mode.
-	// Pass it as a descriptor - to support future changes to the config structure.
-	TPtr8 ptr((TUint8*)&iCaptureModeConfig[iCaptureMode].iCamConfig,sizeof(iCaptureModeConfig[iCaptureMode].iCamConfig),sizeof(iCaptureModeConfig[iCaptureMode].iCamConfig));
-	r=Pdd()->SetConfig(ptr);
-	if (r!=KErrNone)
-		return(r);
-	return KErrNone;
-	}
-
-
-/**
-Process a start image capture request from the client - in the capture mode supplied.
-If this is a free running mode then the PDD is called straight away to commence capturing frames. In one shot mode the driver postpones the capturing
-of frames until a NotifyNewImage() request is received.
-@return KErrNone if successful; whether capture mode was actually started or deferred until NotifyNewImage();
-		KErrNotReady if SetConfig() has not been previously called;
-		otherwise one of the other system-wide error codes.
-*/
-TInt DCameraScLdd::Start()
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::Start(Current Mode-%d)",iCaptureMode));
-
-	if (iState==ECapturing)
-		return(KErrInUse);
-	TInt r=KErrNone;
-
-	// Only continue if the mode being started has been configured
-	if (iCaptureModeConfig[iCaptureMode].iBufManager)
-		iState=EConfigured;
-
-	if (iState==EOpen)
-		r=KErrNotReady;
-	else if (iState==EConfigured)
-		{
-		iCaptureModeConfig[iCaptureMode].iBufManager->Reset();
-		if (iCaptureMode!=ECamCaptureModeImage)
-			r=DoStart();
-		if (r==KErrNone)
-			iState=ECapturing;
-		}
-	else
-		r=KErrGeneral;
-	return(r);
-	}
-
-/**
-Start the PDD capturing images.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-*/
-TInt DCameraScLdd::DoStart()
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::DoStart()"));
-
-	DBufferManager* bufManager=iCaptureModeConfig[iCaptureMode].iBufManager;
-	TLinAddr linAddr=(bufManager->iChunkBase)+(bufManager->iCurrentBuffer->iChunkOffset);
-	TPhysAddr physAddr=bufManager->iCurrentBuffer->iPhysicalAddress;
-	TInt r=Pdd()->Start(iCaptureMode,linAddr,physAddr);
-
-/*
- * 	James Cooper: Uncommenting this code will cause the ASSERT_DEBUG in SetImageCaptured() to fail
- * 	if (r==KErrNone && bufManager->iNextBuffer)
-		{
-		linAddr=(bufManager->iChunkBase)+(bufManager->iNextBuffer->iChunkOffset);
-		physAddr=bufManager->iNextBuffer->iPhysicalAddress;
-		r=Pdd()->CaptureNextImage(linAddr,physAddr);
-		}
-*/	
-	return(r);
-	}
-
-/**
-Process a notify a new image request from the client.
-If there is an image already available then the request is completed straight away, otherwise it is added to the capture request queue.
-@param aStatus	The request status to be signalled when the request is complete. If the request is successful then this is set
-				to the offset within the shared chunk where the record data resides. Alternatively, if an error occurs,
-				it will be set to one of the system wide error values.
-@return KErrNone if successful - whether the request was completed or simply queued;
-		KErrNotReady if Start() hasn't been previousely called;
-		KErrInUse: if the client needs to free up buffers before further requests can be accepted;
-		KErrGeneral: if the client has more requests queued than there are buffers;
-		otherwise one of the other system wide error codes.
-*/
-TInt DCameraScLdd::NotifyNewImage(TRequestStatus* aStatus)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::NotifyNewImage(%x) - iState(%d)",aStatus,iState));
-	DBufferManager* bufManager=iCaptureModeConfig[iCaptureMode].iBufManager;
-	TInt r;
-	if (iState!=ECapturing || !bufManager)
-		return(KErrNotReady);
-
-	NKern::FMWait(&iMutex); 		// Acquire the buffer/request list mutex.
-	if (iCaptureMode!=ECamCaptureModeImage)
-		{
-		// We're operating in one of the free running modes, see if an image is already available.
-		__KTRACE_CAM(Kern::Printf(">DCameraScLdd::NotifyNewImage - Getting image for client"));
-		TImageBuffer* buf=bufManager->GetImageForClient(EFalse);
-		if (buf)
-			{
-			__KTRACE_CAM(Kern::Printf(">DCameraScLdd::NotifyNewImage - There is an image available already"));
-			// There is an image available already - complete the request.
-			r=buf->iResult;
-			NKern::FMSignal(&iMutex); 	// Release the buffer/request list mutex.
-			if (r==KErrNone)
-				{
-				// Only complete if successful here. Errors will be completed on returning from this method.
-				__KTRACE_CAM(Kern::Printf(">DCameraScLdd::NotifyNewImage(iId:%d)",buf->iId));
-				Kern::RequestComplete(iOwningThread,aStatus,(buf->iId));
-				}
-			return(r);
-			}
-
-		// The buffer 'completed' list is empty. If the 'in-use' list contains all the buffers apart from the one being filled
-		// then let the client know they need to free some buffers.
-		if (bufManager->iFreeBufferQ.IsEmpty() && !bufManager->iNextBuffer)
-			{
-			NKern::FMSignal(&iMutex); 	// Release the buffer/request list mutex.
-			return(KErrInUse);
-			}
-		}
-	else
-		{
-		// We're operating in one shot image capture mode. Check if the client needs to free up some buffers
-		// before we can accept the request.
-		if (bufManager->iCompletedBufferQ.IsEmpty() && bufManager->iFreeBufferQ.IsEmpty() && !bufManager->iNextBuffer)
-			{
-			NKern::FMSignal(&iMutex); 	// Release the buffer/request list mutex.
-			return(KErrInUse);
-			}
-
-		// Enough buffers are available so we can start capturing data. First
-		// check that there isn't already a capture request in progress.
-		if (iRequestQueue.IsEmpty())
-			{
-			// No previous request in progress so start the PDD.
-			NKern::FMSignal(&iMutex); 	// Release the buffer/request list mutex.
-			r=DoStart();
-			if (r!=KErrNone)
-				return(r);
-			NKern::FMWait(&iMutex); 		// Acquire the buffer/request list mutex again.
-			}
-		}
-
-	// Save the request in the pending queue and return. The request will be completed from the PDD and the DFC thread when
-	// an image is available.
-	r=iRequestQueue.Add(aStatus);
-	NKern::FMSignal(&iMutex); 	// Release the buffer/request list mutex.
-	return(r);
-	}
-
-/**
-Process a release buffer request from the client.
-@param aChunkOffset The chunk offset corresponding to the buffer to be freed.
-@return KErrNone if successful;
-		KErrNotFound if no 'in use' buffer had the specified chunk offset;
-		KErrNotReady if the driver hasn't been configured for the current capture mode.
-*/
-TInt DCameraScLdd::ReleaseBuffer(TInt aBufferId)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::ReleaseBuffer(%d)",aBufferId));
-	if(!iCaptureModeConfig[iCaptureMode].iBufManager)
-		return KErrNotReady;
-	DBufferManager* bufManager=iCaptureModeConfig[iCaptureMode].iBufManager;
-	TInt chunkOffset = 0;
-
-	TInt r=KErrNone;
-	/*	The driver is left in an ECapturing state after capturing frames. However, it can be left in an
-		EConfigured state as a result of Stop() being called. Stop() cancels all pending capture requests and
-		leaves the driver in a state in which it can be restarted without needing reconfiguring.	*/
-	if (iState!=EOpen && bufManager)
-		{
-		chunkOffset = bufManager->iImageBuffer[aBufferId].iChunkOffset;
-		TImageBuffer* buf=NULL;
-		NKern::FMWait(&iMutex); 		// Acquire the buffer/request list mutex.
-		buf=bufManager->FindInUseImage(chunkOffset);
-		NKern::FMSignal(&iMutex); 		// Release the buffer/request list mutex.
-		if (buf)
-			{
-			// The buffer specified by the client has been found in the 'in-use' list.
-			bufManager->Purge(buf);
-			}
-		else
-			r=KErrNotFound;
-
-		if (r==KErrNone)
-			{
-			NKern::FMWait(&iMutex); 		// Acquire the buffer/request list mutex.
-			// Release it from the 'in-use list into the 'free' list.
-			r=bufManager->ReleaseImage(chunkOffset);
-			if (r>0)
-				{
-				// The buffer needs to be queued straight away - so signal this to the PDD
-				TLinAddr linAddr=(bufManager->iChunkBase)+(bufManager->iNextBuffer->iChunkOffset);
-				TPhysAddr physAddr=bufManager->iNextBuffer->iPhysicalAddress;
-				buf=bufManager->iNextBuffer;
-				NKern::FMSignal(&iMutex); 	// Release the buffer/request list mutex.
-				r=Pdd()->CaptureNextImage(linAddr,physAddr);
-				if (r==KErrNotReady)
-					r=KErrNone;
-				}
-			else
-				NKern::FMSignal(&iMutex); 	// Release the buffer/request list mutex.
-			}
-		}
-	else
-		r=KErrNotReady;
-	__KTRACE_CAM(Kern::Printf("<DCameraScLdd::ReleaseBuffer() - r(%d)",r));
-	return(r);
-	}
-
-/**
-Called from the PDD in the DFC thread each time it finishes capturing an image frame.
-This will complete a pending capture request and update buffer lists.
-@param aCaptureMode The capture mode of the image captured. @see TDevCamCaptureMode.
-@param aResult The result of the image capture request being completed.
-@param aLinAddr	If this function returns KErrNone then on return, this holds the linear address of the start of the next buffer
-				to use for image capture.
-@param aPhysAddr If this function returns KErrNone then on return, this holds the physical address that corresponds to the
-				 linear address: aLinAddr.
-@return KErrNone if capturing should continue - with holding information on the next buffer to use for image capture.
-		KErrNotReady if capturing should continue - but with no further buffer available for image capture just yet.
-		KErrAbort if image capturing should now be terminated.
-*/
-TInt DCameraScLdd::ImageCaptureCallback(TDevCamCaptureMode /*aCaptureMode*/,TInt aResult,TLinAddr* aLinAddr,TPhysAddr* aPhysAddr)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::ImageCaptureCallback"));
-
-	DBufferManager* bufManager=iCaptureModeConfig[iCaptureMode].iBufManager;
-	// Update the buffer list and get the next buffer for capture.
-	NKern::FMWait(&iMutex); 				// Acquire the buffer/request list mutex.
-	TImageBuffer* nextBuffer=bufManager->SetImageCaptured(aResult);	// Puts the captured image's buffer in the completed buffer queue.
-
-	// Check if there is a capture request pending.
-	if (!iRequestQueue.IsEmpty())
-		{
-		// A capture request is pending.
-		TBool removeLast=((iCaptureMode==ECamCaptureModeImage) ? (TBool) ETrue : (TBool) EFalse);
-		TImageBuffer* buf=bufManager->GetImageForClient(removeLast);	// Retrieved the captured image from the buffer in the completed buffer queue.
-		if (buf)
-			{
-			// Update the request pending list and complete the request.
-			TRequestStatus* rs=iRequestQueue.Remove();
-			TInt reason=(buf->iResult==KErrNone) ? buf->iId : buf->iResult;
-			NKern::FMSignal(&iMutex); 													// Release the buffer/request list mutex.
-			buf->SyncMemoryAfterDmaRead();
-			Kern::RequestComplete(iOwningThread,rs,reason);								// Complete the request.
-			}
-		else
-			NKern::FMSignal(&iMutex); 													// Release the buffer/request list mutex.
-		}
-	else
-		NKern::FMSignal(&iMutex); 														// Release the buffer/request list mutex.
-
-	// Now work out what instruction to give to the PDD
-	TInt r=KErrNone;
-	if (iCaptureMode==ECamCaptureModeImage)
-		{
-		// Image capture mode. If we've just completed a one shot request, see if there is yet another one pending.
-		if (!iRequestQueue.IsEmpty())
-			{
-			// Another request is pending so let the PDD carry on.
-			// If an error occured we need to first stop and re-start image capture
-			if (aResult!=KErrNone)
-				{
-				iRestartDfc.Enque();	// Queue a DFC to re-start the PDD later.
-				r=KErrAbort;
-				}
-			}
-		else
-			{
-			r=KErrAbort;	// End of image gather mode so stop the PDD.
-			}
-		}
-	else
-		{
-		// One of the free running modes. If an error occured we need to first stop and re-start image capture
-		if (aResult!=KErrNone)
-			{
-			iRestartDfc.Enque();	// Queue a DFC to re-start the PDD later.
-			r=KErrAbort;
-			}
-		}
-
-	// If capture should continue, check if there is a further buffer available to use for image capture.
-	if (r==KErrNone)
-		{
-		if (nextBuffer)
-			{
-			*aLinAddr=(bufManager->iChunkBase)+(nextBuffer->iChunkOffset);
-			*aPhysAddr=nextBuffer->iPhysicalAddress;
-			}
-		else
-			r=KErrNotReady;
-		}
-	return(r);
-	}
-
-/**
-Stores the camera configuration passed in from the user after checking and validating it.
-@param	aCaptureMode	The capture mode for which the setting of the camera configuration is made.
-@param	aCamConfigBuf	A buffer that contains the camera configuration.
-@return	KErrNone if successful
-		KErrInUse if the camera is capturing an image
-		KErrArgument if the camera configuration passed in is invalid
-		otherwise a system wide error code.
-*/
-TInt DCameraScLdd::DoSetConfig(TInt aCaptureMode, const TDesC8* aCamConfigBuf)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::DoSetConfig(CaptureMode=%d)",aCaptureMode));
-	
-    if(iCaptureMode == aCaptureMode)
-        {
-        if (iState==ECapturing)
-            return(KErrInUse);
-        }
-
-	// Read the config structure from the client
-	TCameraConfigV02 config;
-	TPtr8 ptr((TUint8*)&config,sizeof(config));
-	TInt r=Kern::ThreadDesRead(iOwningThread,aCamConfigBuf,ptr,0);
-	if (r!=KErrNone)
-		return(r);
-
-	// Check that it is compatible with this camera device
-	r=ValidateConfig(aCaptureMode, config);
-	if (r!=KErrNone)
-		{
-		if (r == KErrNotFound)
-			r = KErrArgument;
-		return(r);
-		}
-
-	// We're about to replace any previous configuration - so set the
-	// status back to un-configured. A new buffer configuration must be calculated as a result of that.
-	//iState=EOpen;
-
-	// Save the new configuration.
-	iCaptureModeConfig[aCaptureMode].iCamConfig=config;
-	iCaptureModeConfig[aCaptureMode].iFrameHeight=iCaptureModeConfig[aCaptureMode].iCamConfig.iFrameSize.iHeight;
-	iCaptureModeConfig[aCaptureMode].iFrameWidth=iCaptureModeConfig[aCaptureMode].iCamConfig.iFrameSize.iWidth;
-
-	__KTRACE_CAM(Kern::Printf("<DCameraScLdd::DoSetConfig - %d",KErrNone));
-	return(r);
-	}
-
-/**
-Validates the configuration that is about to be used with the driver.
-@param aCaptureMode	The capture mode that the configuration is for.
-@param aConfig 		The buffer that contains the camera configuration, as passed in from the user.
-@return	KErrNotFound if the configuration is not supported by the camera sensor.
-		KErrNotSupported if the driver does not support aCaptureMode
-		KErrNone if successful.
-*/
-TInt DCameraScLdd::ValidateConfig(TInt aCaptureMode, TCameraConfigV02& aConfig)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::ValidateConfig"));
-
-	TInt capsSize = Pdd()->CapsSize();
-	NKern::ThreadEnterCS();
-	TAny* capsBuf = Kern::Alloc(capsSize);
-	if(!capsBuf)
-		{
-		NKern::ThreadLeaveCS();
-		return KErrNoMemory;
-		}
-
-	TPtr8 capsPtr( (TUint8*)capsBuf, capsSize, capsSize );
-	Pdd()->Caps(capsPtr);
-	NKern::ThreadLeaveCS();
-
-	TCameraCapsV02* camCaps = (TCameraCapsV02*) capsPtr.Ptr();
-
-	TInt r;
-	if(aCaptureMode==ECamCaptureModeImage && camCaps->iNumImagePixelFormats)
-		{
-		r=DoValidateConfig(camCaps, aCaptureMode, aConfig);
-		}
-	else if(aCaptureMode==ECamCaptureModeVideo && camCaps->iNumVideoPixelFormats)
-		{
-		r=DoValidateConfig(camCaps, aCaptureMode, aConfig);
-		}
-	else if(aCaptureMode==ECamCaptureModeViewFinder && camCaps->iNumViewFinderPixelFormats)
-		{
-		r=DoValidateConfig(camCaps, aCaptureMode, aConfig);
-		}
-	else
-		r=KErrNotSupported;
-
-	if(r==KErrNone)
-		{
-		// Calculate the pixel width (in bytes) for the format specified
-		aConfig.iPixelWidthInBytes=aConfig.iPixelFormat.iPixelWidthInBytes;
-		}
-
-	NKern::ThreadEnterCS();
-	Kern::Free(capsBuf);
-	NKern::ThreadLeaveCS();
-
-	__KTRACE_CAM(Kern::Printf("<DCameraScLdd::ValidateConfig - %d",r));
-	return(r);
-	}
-
-/**
-Validates the configuration that is about to be used with the driver by checking it against what the camera sensor supports.
-@param aCamCaps		The buffer that contains the capabilities of the camera driver.
-@param aCaptureMode	The capture mode that the configuration is for.
-@param aConfig 		The buffer that contains the camera configuration, as passed in from the user.
-@return	KErrNotFound if the configuration is not supported by the camera sensor
-		KErrNone if successful
-		or one of the system wide error values.
-*/
-TInt DCameraScLdd::DoValidateConfig(TCameraCapsV02* aCamCaps, TInt& aCaptureMode, TCameraConfigV02& aConfig)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::DoValidateConfig"));
-	TAny* frameSizeCapsBuf;
-	TInt frameSizeCapsSize;
-	SFrameSizeCapsInfo info;
-	SDevCamFrameSize* frameSize;
-	TUint i;
-	TUint l;
-	SDevCamPixelFormat* pixelFormat;
-	TUint start;
-	TUint end;
-	TInt r;
-	pixelFormat = (SDevCamPixelFormat*) (aCamCaps + 1);
-	if(aCaptureMode==ECamCaptureModeImage)
-		{
-		start=0;
-		end=aCamCaps->iNumImagePixelFormats;
-		}
-	else if(aCaptureMode==ECamCaptureModeVideo)
-		{
-		start=aCamCaps->iNumImagePixelFormats;
-		end=aCamCaps->iNumImagePixelFormats + aCamCaps->iNumVideoPixelFormats;
-		pixelFormat += aCamCaps->iNumImagePixelFormats;
-		}
-	else if(aCaptureMode==ECamCaptureModeViewFinder)
-		{
-		start=aCamCaps->iNumImagePixelFormats+aCamCaps->iNumVideoPixelFormats;
-		end=aCamCaps->iNumImagePixelFormats + aCamCaps->iNumVideoPixelFormats + aCamCaps->iNumViewFinderPixelFormats;
-		pixelFormat += aCamCaps->iNumImagePixelFormats;
-		pixelFormat += aCamCaps->iNumVideoPixelFormats;
-		}
-	else
-		return KErrNotSupported;
-
-	for (i=start; i<end; i++)
-		{
-		if(aConfig.iPixelFormat.iPixelFormat==pixelFormat->iPixelFormat)
-			{
-			info.iUidPixelFormat = pixelFormat->iPixelFormat;
-			info.iCaptureMode = (TDevCamCaptureMode) aCaptureMode;
-			frameSizeCapsSize = pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize);
-			NKern::ThreadEnterCS();
-			frameSizeCapsBuf = Kern::Alloc(frameSizeCapsSize);
-			NKern::ThreadLeaveCS();
-			if (!frameSizeCapsBuf)
-				{
-				return KErrNoMemory;
-				}
-			TPtr8 frameSizeCapsPtr( (TUint8*)frameSizeCapsBuf, frameSizeCapsSize, frameSizeCapsSize );
-			if ((r = Pdd()->FrameSizeCaps(info.iCaptureMode, info.iUidPixelFormat, frameSizeCapsPtr)) == KErrNone)
-				{
-				frameSize = (SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
-				for(l=0; l<pixelFormat->iNumFrameSizes; l++ )
-					{
-					if (aConfig.iFrameSize.iWidth == frameSize->iWidth &&
-						aConfig.iFrameSize.iHeight == frameSize->iHeight &&
-						aConfig.iFrameRate >= frameSize->iMinFrameRate &&
-						aConfig.iFrameRate <= frameSize->iMaxFrameRate)
-						{
-						NKern::ThreadEnterCS();
-						Kern::Free(frameSizeCapsBuf);
-						NKern::ThreadLeaveCS();
-						__KTRACE_CAM(Kern::Printf("<DCameraScLdd::DoValidateConfig"));
-						return KErrNone;
-						}
-					frameSize++;
-					}
-				NKern::ThreadEnterCS();
-				Kern::Free(frameSizeCapsBuf);
-				NKern::ThreadLeaveCS();
-				return KErrNotFound;
-				}
-			else
-				{
-				NKern::ThreadEnterCS();
-				Kern::Free(frameSizeCapsBuf);
-				NKern::ThreadLeaveCS();
-				return r;
-				}
-			}
-		pixelFormat++;
-		}
-	return KErrNotFound;
-	}
-
-/**
-The DFC used to re-start the PDD following a data capture error.
-@param aChannel A pointer to the camera driver logical channel object.
-*/
-void DCameraScLdd::RestartDfc(TAny* aChannel)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::RestartDfc"));
-
-	DCameraScLdd& drv=*(DCameraScLdd*)aChannel;
-
-	if (!drv.iCaptureModeConfig[drv.iCaptureMode].iBufManager->iCurrentBuffer)
-		drv.iCaptureModeConfig[drv.iCaptureMode].iBufManager->iCurrentBuffer=drv.iCaptureModeConfig[drv.iCaptureMode].iBufManager->NextAvailableForCapture();
-	__ASSERT_ALWAYS(drv.iCaptureModeConfig[drv.iCaptureMode].iBufManager->iCurrentBuffer,Kern::Fault(KCameraLddPanic,__LINE__));
-
-	if (!drv.iCaptureModeConfig[drv.iCaptureMode].iBufManager->iNextBuffer)
-		drv.iCaptureModeConfig[drv.iCaptureMode].iBufManager->iNextBuffer=drv.iCaptureModeConfig[drv.iCaptureMode].iBufManager->NextAvailableForCapture();
-
-	drv.DoStart();
-	}
-
-/**
-The DFC used to handle power down requests from the power manager before a transition into system
-shutdown/standby.
-@param aChannel A pointer to the camera driver logical channel object.
-*/
-void DCameraScLdd::PowerDownDfc(TAny* aChannel)
-	{
-	DCameraScLdd& drv=*(DCameraScLdd*)aChannel;
-	drv.Shutdown();
-	drv.iPowerHandler->PowerDownDone();
-	}
-
-/**
-The DFC used to handle power up requests from the power manager following a transition out of system standby.
-@param aChannel A pointer to the camera driver logical channel object.
-*/
-void DCameraScLdd::PowerUpDfc(TAny* aChannel)
-	{
-	DCameraScLdd& drv=*(DCameraScLdd*)aChannel;
-	drv.iPowerHandler->PowerUpDone();
-	}
-
-void DCameraScLdd::PanicClientThread(TInt aReason)
-	{
-	Kern::ThreadKill(iOwningThread, EExitPanic, aReason, KDevCameraScName);
-	}
-
-/**
-Retrieves the capabilities of the camera sensor.
-@param aBuffer	A pointer to a descriptor passed in by the user.
-*/
-TInt DCameraScLdd::GetSensorCaps(TAny* aBuffer)
-	{
-	// Return the capabilities for this device. Read this from the PDD and
-	// then write it to the client
-	TInt capsSize = Pdd()->CapsSize();
-	TInt bufferSize;
-	TInt maxBufferSize;
-	Kern::KUDesInfo(*((TDes8*)aBuffer), bufferSize, maxBufferSize);
-	if(capsSize>maxBufferSize)
-		{
-		return KErrArgument;
-		}
-	NKern::ThreadEnterCS();
-	TAny* capsBuf = Kern::Alloc(capsSize);
-	if(!capsBuf)
-		{
-		NKern::ThreadLeaveCS();
-		return KErrNoMemory;
-		}
-
-	TPtr8 capsPtr( (TUint8*)capsBuf, capsSize, capsSize );
-	Pdd()->Caps(capsPtr);
-	NKern::ThreadLeaveCS();
-	Kern::InfoCopy(*((TDes8*)aBuffer), capsPtr.Ptr(), capsSize);
-	NKern::ThreadEnterCS();
-	Kern::Free((TAny*)capsBuf);
-	NKern::ThreadLeaveCS();
-	return KErrNone;
-	}
-
-/**
-Retrieves the frame sizes supported for a given pixel format.
-@param aBuffer	A pointer to descriptor passed in by the user.
-@param aFrameSizeCapsInfo A structure that holds information regarding the requested capabilities.
-*/
-TInt DCameraScLdd::GetFrameSizeCaps(TAny* aBuffer, TAny* aFrameSizeCapsInfo)
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScLdd::GetFrameSizeCaps()"));
-	TInt frameSizeCapsMaxSize;
-	TInt frameSizeCapsSize;
-	Kern::KUDesInfo(*((TDes8*)aBuffer),frameSizeCapsSize,frameSizeCapsMaxSize);
-	SFrameSizeCapsInfo info;
-	kumemget((TAny*)&info,aFrameSizeCapsInfo,sizeof(info));
-	NKern::ThreadEnterCS();
-	// Allocate memory on the heap for the frame size structure.
-	TAny* frameSizeCapsBuf = Kern::Alloc(frameSizeCapsMaxSize);
-	if (!frameSizeCapsBuf)
-		{
-		NKern::ThreadLeaveCS();
-		return KErrNoMemory;
-		}
-	TPtr8 frameSizeCapsPtr( (TUint8*)frameSizeCapsBuf, frameSizeCapsMaxSize, frameSizeCapsMaxSize );
-	// Request the frame sizes from the Pdd.
-	TInt r=Pdd()->FrameSizeCaps(info.iCaptureMode, info.iUidPixelFormat, frameSizeCapsPtr);
-	NKern::ThreadLeaveCS();
-	if (r!=KErrNone)
-		{
-		NKern::ThreadEnterCS();
-		Kern::Free((TAny*)frameSizeCapsBuf);
-		NKern::ThreadLeaveCS();
-		return r;
-		}
-	Kern::InfoCopy(*((TDes8*)aBuffer),frameSizeCapsPtr.Ptr(), frameSizeCapsMaxSize);
-	NKern::ThreadEnterCS();
-	Kern::Free((TAny*)frameSizeCapsBuf);
-	NKern::ThreadLeaveCS();
-	return KErrNone;
-	}
-
-
-/**
-Constructor for the buffer manager.
-*/
-DBufferManager::DBufferManager(DCameraScLdd* aLdd)
-	: iLdd(aLdd)
-	{
-//	iChunk=NULL;
-//	iNumBuffers=0;
-//	iImageBuffer=NULL;
-	}
-
-/**
-Destructor for the buffer manager.
-@pre The thread must be in a critical section.
-*/
-DBufferManager::~DBufferManager()
-	{
-	if (iChunk)
-		Kern::ChunkClose(iChunk);
-	delete[] iImageBuffer;
-	}
-
-/**
-Second stage constructor for the buffer manager. This version creates a shared chunk and a buffer object for each
-buffer specified within this. Then it commits memory within the chunk for each of these buffers. This also involves the
-creation of a set of buffer lists to manage the buffers.
-@param aNumBuffers The number of buffers required in the shared chunk.
-@param aBufferSize The size of each buffer required in the shared chunk.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-@pre The thread must be in a critical section.
-*/
-TInt DBufferManager::Create(TInt aNumBuffers,TInt aBufferSize)
-	{
-	__KTRACE_CAM(Kern::Printf(">DBufferManager::Create(Bufs-%d,Sz-%d)",aNumBuffers,aBufferSize));
-
-	TInt r=CreateBufferLists(aNumBuffers);
-	if (r!=KErrNone)
-		return(r);
-
-	// Calculate the size of the chunk required for the buffer configuration specified.
-	aBufferSize=Kern::RoundToPageSize(aBufferSize);
-	TInt pageSize=Kern::RoundToPageSize(1);
-	// Leave space for guard pages around each buffer.  There is a guard page in between each buffer but
-	// NO guard page before the first buffer or after the last buffer
-	TUint64 chunkSize=TUint64(aBufferSize+pageSize)*aNumBuffers-pageSize;
-	if (chunkSize>(TUint64)KMaxTInt)
-		return(KErrNoMemory); // Need more than 2GB of memory!
-
-	// Create the shared chunk. The PDD supplies most of the chunk create info - but not the maximum size.
-	TChunkCreateInfo info;
-	info.iMaxSize=(TInt)chunkSize;
-	iLdd->Pdd()->GetChunkCreateInfo(info);		// Call down to the PDD for the rest.
-
-	r = Kern::ChunkCreate(info,iChunk,iChunkBase,iChunkMapAttr);
-	if (r!=KErrNone)
-		return(r);
-
-	// Commit memory in the chunk for each buffer.
-	TInt offset=0;
-	TBool isContiguous;
-	for (TInt i=0; i<aNumBuffers ; i++)
-		{
-		r=CommitMemoryForBuffer(offset,aBufferSize,isContiguous);
-		if (r!=KErrNone)
-			return(r);
-		r=iImageBuffer[i].Create(iChunk,offset,aBufferSize,i,isContiguous);
-		iImageBuffer[i].iId=i;
-		if (r!=KErrNone)
-			return(r);
-		offset += (aBufferSize+pageSize);
-		}
-
-	return(KErrNone);
-	}
-
-/**
-Second stage constructor for the buffer manager. This version opens an existing shared chunk using a client supplied
-handle. It then creates a buffer object for each buffer that exists within the chunk as well as creating a set of buffer
-lists to manage the buffers.
-@param aBufConfig The shared chunk buffer configuration object - specifying the geometry of the buffer configuration
-within the shared chunk supplied.
-@param aChunkHandle A handle for the shared chunk supplied by the client.
-@param anOwningThread The thread in which the given handle is valid.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-@pre The thread must be in a critical section.
-*/
-TInt DBufferManager::Create(TCameraSharedChunkBufConfig& aBufConfig,TInt aChunkHandle,DThread* anOwningThread)
-	{
-	__KTRACE_CAM(Kern::Printf(">DBufferManager::Create(Handle-%d)",aChunkHandle));
-
-	// Validate the buffer configuration information
-	if (!aBufConfig.iFlags&KScFlagBufOffsetListInUse)
-		return(KErrArgument);
-
-	TInt numBuffers=aBufConfig.iNumBuffers;
-	TInt r=CreateBufferLists(numBuffers);
-	if (r!=KErrNone)
-		return(r);
-
-	DChunk* chunk;
-	chunk=Kern::OpenSharedChunk(anOwningThread,aChunkHandle,ETrue);
-	if (!chunk)
-		return(KErrBadHandle);
-	iChunk=chunk;
-
-	// Read the physical address for the 1st buffer in order to determine the kernel address and the map attributes.
-	TInt bufferSizeInBytes=aBufConfig.iBufferSizeInBytes;
-
-	SBufSpecList* bufferSpec=&aBufConfig.iSpec;
-
-	TInt offset=bufferSpec[0].iBufferOffset;
-
-	TPhysAddr physAddr;
-	r=Kern::ChunkPhysicalAddress(iChunk,offset,bufferSizeInBytes,iChunkBase,iChunkMapAttr,physAddr,NULL);
-	if (r!=KErrNone)
-		return(r);
-
-	// Store the supplied buffer info. into each buffer object.
-
-	for (TInt i=0; i<numBuffers; i++)
-		{
-		offset=bufferSpec[i].iBufferOffset;
-		// Assume it isn't contiguous here - Create() will detect and do the right thing if it is contiguous.
-		r=iImageBuffer[i].Create(iChunk,offset,bufferSizeInBytes,i,EFalse);
-		iImageBuffer[i].iId=i;
-		if (r!=KErrNone)
-			return(r);
-		}
-	__KTRACE_CAM(Kern::Printf("<DBufferManager::Create - %d",KErrNone));
-	return(KErrNone);
-	}
-
-/**
-Copies the contents of the Buffer Manager's configuration into aBufConfig
-@param aBufConfig The buffer that the data is copied into.
-*/
-void DBufferManager::GetBufConfig(TCameraSharedChunkBufConfig& aBufConfig)
-	{
-	__KTRACE_CAM(Kern::Printf(">DBufferManager::GetBufConfig"));
-	TInt numBuffers=iNumBuffers;
-	if (numBuffers<=0)
-		return;
-
-	SBufSpecList* bufferSpec=&aBufConfig.iSpec;
-
-	while (numBuffers--)
-		{
-		bufferSpec[numBuffers].iBufferOffset=iImageBuffer[numBuffers].iChunkOffset;
-		bufferSpec[numBuffers].iBufferId=iImageBuffer[numBuffers].iId;
-		}
-
-	aBufConfig.iNumBuffers=iNumBuffers;
-	aBufConfig.iBufferSizeInBytes=iImageBuffer[0].iSize;	// They're all the same size - so read from the 1st one.
-	aBufConfig.iFlags|=KScFlagBufOffsetListInUse;
-	return;
-	}
-
-/**
-Allocate an array of buffer objects, - one for each buffer contained within the shared chunk.
-@param aNumBuffers The number of buffer objects required.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-@pre The thread must be in a critical section.
-*/
-TInt DBufferManager::CreateBufferLists(TInt aNumBuffers)
-	{
-	__KTRACE_CAM(Kern::Printf(">DBufferManager::CreateBufferLists(Bufs-%d)",aNumBuffers));
-
-	// Construct the array of buffers.
-	iNumBuffers=aNumBuffers;
-	iImageBuffer=new TImageBuffer[aNumBuffers];
-	if (!iImageBuffer)
-		return(KErrNoMemory);
-	return(KErrNone);
-	}
-
-TInt DBufferManager::CommitMemoryForBuffer(TInt aChunkOffset,TInt aSize,TBool& aIsContiguous)
-	{
-	__KTRACE_CAM(Kern::Printf(">DBufferManager::CommitMemoryForBuffer(Offset-%x,Sz-%d)",aChunkOffset,aSize));
-
-	// Try for physically contiguous memory first.
-	TPhysAddr physicalAddress;
-	TInt r=Kern::ChunkCommitContiguous(iChunk,aChunkOffset,aSize,physicalAddress);
-	if (r==KErrNone)
-		{
-		aIsContiguous=ETrue;
-		return(r);
-		}
-
-	// Commit memory that isn't contiguous instead.
-	aIsContiguous=EFalse;
-	r=Kern::ChunkCommit(iChunk,aChunkOffset,aSize);
-	return(r);
-	}
-
-/**
-Reset all image buffer lists to reflect the state at the start of the image capture process.
-@pre The buffer/request queue mutex must be held.
-*/
-void DBufferManager::Reset()
-	{
-	__KTRACE_CAM(Kern::Printf(">DBufferManager::Reset"));
-
-	TImageBuffer* pBuf;
-
-	// Before reseting buffer lists, purge the cache for all cached buffers currently in use by client.
-	pBuf=(TImageBuffer*)iInUseBufferQ.First();
-	SDblQueLink* anchor=&iInUseBufferQ.iA;
-	while (pBuf!=anchor)
-		{
-		Purge(pBuf);
-		pBuf=(TImageBuffer*)pBuf->iNext;
-		}
-
-	// Start by reseting all the lists.
-	iFreeBufferQ.iA.iNext=iFreeBufferQ.iA.iPrev=&iFreeBufferQ.iA;
-	iCompletedBufferQ.iA.iNext=iCompletedBufferQ.iA.iPrev=&iCompletedBufferQ.iA;
-	iInUseBufferQ.iA.iNext=iInUseBufferQ.iA.iPrev=&iInUseBufferQ.iA;
-
-	// Set the pointers to the current and the next record buffers.
-	pBuf=iImageBuffer; 		// This is the first buffer
-	iCurrentBuffer=pBuf++;
-	iNextBuffer = pBuf++;
-
-	// Add all other buffers to the free list.
-	TImageBuffer* bufferLimit=iImageBuffer+iNumBuffers;
-	while(pBuf<bufferLimit)
-		iFreeBufferQ.Add(pBuf++);
-	}
-
-/**
-Purge the cache for a cached image buffer.
-@param aBuffer The buffer to be purged.
-*/
-void DBufferManager::Purge(TImageBuffer* aBuffer)
-	{
-	aBuffer->SyncMemoryBeforeDmaRead();
-	}
-
-/**
-Update buffer lists after an image has been captured.
-@param aResult The result of the image capture operation that has just completed.
-@return A pointer to the next image buffer for capture - or NULL if none are available.
-@pre The buffer/request queue mutex must be held.
-*/
-TImageBuffer* DBufferManager::SetImageCaptured(TInt aResult)
-	{
-	// Take a copy of the buffer with the image just captured.
-	__ASSERT_DEBUG(iCurrentBuffer,Kern::Fault(KCameraLddPanic,__LINE__));
-	TImageBuffer* cur=iCurrentBuffer;
-
-	// Make the queued buffer the current one.
-	iCurrentBuffer=iNextBuffer;
-
-	// Now we need to identify the next image buffer to queue.
-	iNextBuffer=NextAvailableForCapture();
-
-	// Now add the buffer with the image just captured to the 'completed' list.
-	if (cur)
-		{
-		cur->iResult=aResult;						// Store the result of the capture operation in the image buffer object.
-		iCompletedBufferQ.Add(cur);
-		}
-
-	__KTRACE_CAM(Kern::Printf("<DBufferManager::SetImageCaptured(buf=%08x)-%d",cur->iChunkOffset,aResult));
-	return(iNextBuffer);
-	}
-
-/**
-Remove from the buffer lists the next buffer that is available to queue for transfer.
-@return A pointer to the next image buffer for capture - or NULL if none are available.
-@pre The buffer/request queue mutex must be held.
-*/
-TImageBuffer* DBufferManager::NextAvailableForCapture()
-	{
-	// We need to identify the next image buffer to queue. Try to get one from the 'free' list.
-	TImageBuffer* buffer=(TImageBuffer*)iFreeBufferQ.GetFirst();
-#ifdef DISCARD_COMPLETED_TO_AVOID_OVERFLOW
-	// If there are none left on the 'free' list then take one from the completed list.
-	if (!buffer)
-		buffer=(TImageBuffer*)iCompletedBufferQ.GetFirst();
-#endif
-	return(buffer);
-	}
-
-/**
-Get the next image from the 'completed' capture list. If there is no error associated with the buffer,
-make it 'in use' by the client. Otherwise, return the buffer to the free list.
-@param aRemoveLast	If true, the buffer is removed from the tail of the completed capture list, otherwise
-					it is removed from the head of this list.
-@return A pointer to the next completed image buffer - or NULL if there is no buffer available.
-@pre The buffer/request queue mutex must be held.
-*/
-TImageBuffer* DBufferManager::GetImageForClient(TBool aRemoveLast)
-	{
-	__KTRACE_CAM(Kern::Printf("<DBufferManager::GetImageForClient"));
-	TImageBuffer* buffer=NULL;
-	if (!iCompletedBufferQ.IsEmpty())
-		{
-		buffer = (aRemoveLast) ? (TImageBuffer*)iCompletedBufferQ.Last() : (TImageBuffer*)iCompletedBufferQ.First();
-		buffer->Deque();
-
-		if (buffer->iResult==KErrNone)
-			iInUseBufferQ.Add(buffer);
-		else
-			iFreeBufferQ.Add(buffer);
-		}
-	return(buffer);
-	}
-
-/**
-Release (move to free list) the 'in use' image specified by the given chunk offset.
-@param aChunkOffset The chunk offset corresponding to the buffer to be freed.
-@return The freed image buffer, or NULL if no 'in use' buffer had the specified chunk offset.
-@return KErrNone if buffer moved to the free list;
-		1 if the buffer needs to be queued straight away
-		KErrArgument if no 'in use' buffer had the specified chunk offset;
-@pre The buffer/request queue mutex must be held.
-*/
-TInt DBufferManager::ReleaseImage(TInt aChunkOffset)
-	{
-	__KTRACE_CAM(Kern::Printf(">DBufferManager::ReleaseImage(chunkOffset=%08x)",aChunkOffset));
-	TInt r=KErrArgument;
-
-	// Scan 'in use' list for the image buffer
-	TImageBuffer* pBuf;
-	pBuf=(TImageBuffer*)iInUseBufferQ.First();
-	SDblQueLink* anchor=&iInUseBufferQ.iA;
-	while (pBuf!=anchor && pBuf->iChunkOffset!=aChunkOffset)
-		pBuf=(TImageBuffer*)pBuf->iNext;
-
-	if (pBuf!=anchor)
-		{
-		// Buffer found in 'in-use' list.
-		if (!iNextBuffer)
-			{
-			// We need to signal the pdd to queue this buffer straight away.
-			iNextBuffer=(TImageBuffer*)pBuf->Deque();
-			r=1;
-			}
-		else
-			{
-			// Move buffer to the free list.
-			iFreeBufferQ.Add(pBuf->Deque());
-			r=KErrNone;
-			}
-		}
-
-	__KTRACE_CAM(Kern::Printf("<DBufferManager::ReleaseImage(buf=%08x)",((pBuf!=anchor) ? pBuf->iChunkOffset : -1)));
-	return(r);
-	}
-
-/**
-Find the 'in use' image specified by the given chunk offset
-@param aChunkOffset The chunk offset corresponding to the buffer to be freed
-@return The image buffer, or NULL if no 'in use' buffer had the specified chunk offset
-@pre The buffer/request queue mutex must be held.
-*/
-TImageBuffer* DBufferManager::FindInUseImage(TInt aChunkOffset)
-	{
-	// Scan 'in use' list for the image buffer
-	TImageBuffer* pBuf;
-	pBuf=(TImageBuffer*)iInUseBufferQ.First();
-	SDblQueLink* anchor=&iInUseBufferQ.iA;
-	while (pBuf!=anchor && pBuf->iChunkOffset!=aChunkOffset)
-		pBuf=(TImageBuffer*)pBuf->iNext;
-
-	return((pBuf!=anchor)?pBuf:NULL);
-	}
-
-/**
-Constructor for the image buffer class.
-Clears all member data
-*/
-TImageBuffer::TImageBuffer()
-	{
-	memclr(this,sizeof(*this));
-	}
-
-/**
-Destructor for the image buffer class.
-*/
-TImageBuffer::~TImageBuffer()
-	{
-	delete[] iPhysicalPages;
-	}
-
-/**
-Second stage constructor for the image buffer class - get information on the memory
-allocated to this buffer.
-@param aChunk	The chunk into which the memory is to be commited
-@param aOffset	The offset within aChunk for the start of the comitted memory.
-				Must be a multiple of the MMU page size.
-@param aSize	The number of bytes of memory commited.
-				Must be a multiple of the MMU page size.
-@return KErrNone if successful, otherwise one of the other system wide error codes.
-@pre The thread must be in a critical section.
-*/
-TInt TImageBuffer::Create(DChunk* aChunk,TInt aOffset,TInt aSize, TInt aId, TBool aIsContiguous)
-	{
-	__KTRACE_CAM(Kern::Printf(">TImageBuffer::Create(Off-%x,Sz-%d,Contig-%d)",aOffset,aSize,aIsContiguous));
-
-	// Save info. on the chunk the buffer is in, and the offset and size of the buffer.
-	iChunk=aChunk;
-	iChunkOffset=aOffset;
-	iId=aId;
-	iSize=aSize;
-
-	TInt r=KErrNone;
-	iPhysicalPages=NULL;
-	if (!aIsContiguous)
-		{
-		// Allocate an array for a list of the physical pages.
-		iPhysicalPages = new TPhysAddr[aSize/Kern::RoundToPageSize(1)+2];
-		if (!iPhysicalPages)
-			r=KErrNoMemory;
-		}
-
-	if (r==KErrNone)
-		{
-		// Get the physical addresses of the pages in the buffer.
-		TUint32 mapAttr;
-		r=Kern::ChunkPhysicalAddress(aChunk,aOffset,aSize,iLinearAddress,mapAttr,iPhysicalAddress,iPhysicalPages);
-		// r = 0 or 1 on success. (1 meaning the physical pages are not contiguous).
-		if (r==1)
-			{
-			// The physical pages are not contiguous.
-			iPhysicalAddress=KPhysAddrInvalid;	// Mark the physical address as invalid.
-			r=(aIsContiguous) ? KErrGeneral : KErrNone;
-			}
-		if (r==0)
-			{
-			delete[] iPhysicalPages;	// We shouldn't retain this info. if the physical pages are contiguous.
-			iPhysicalPages=NULL;
-			}
-		}
-	__KTRACE_CAM(Kern::Printf("<TImageBuffer::Create - %d",r));
-	return(r);
-	}
-
-/**
-Prepares a cacheable buffer for use by the DMA engine, before an image capture.
-*/
-void TImageBuffer::SyncMemoryBeforeDmaRead()
-	{
-#ifndef __WINS__
-	if (iChunk->iMapAttr&EMapAttrCachedMax)
-		{
-		Cache::SyncMemoryBeforeDmaRead(iLinearAddress,iSize);
-		}
-#endif
-	}
-
-/**
-Prepare a cacheable buffer for use by the CPU, after an image capture using DMA.
-*/
-void TImageBuffer::SyncMemoryAfterDmaRead()
-	{
-#ifndef __WINS__
-	if (iChunk->iMapAttr&EMapAttrCachedMax)
-		{
-		Cache::SyncMemoryAfterDmaRead(iLinearAddress,iSize);
-		}
-#endif
-	}
-
-/**
-Constructor for the capture request queue.
-*/
-TCameraScRequestQueue::TCameraScRequestQueue(NFastMutex* aMutexPtr)
-	: iMutexPtr(aMutexPtr)
-	{
-	iOwningThread=NULL;
-	memclr(&iRequest[0],sizeof(TCameraScRequest*)*KMaxCamScRequestsPending);
-	}
-
-/**
-Destructor for the capture request queue.
-*/
-TCameraScRequestQueue::~TCameraScRequestQueue()
-	{
-	for (TInt i=0 ; i<KMaxCamScRequestsPending ; i++)
-		delete iRequest[i];
-	}
-
-/**
-Second stage constructor for the capture request queue.
-@param anOwningThread A pointer to the owning client thread.
-@return KErrNone if successful;
-		KErrNoMemory if unable to allocate memory for the capture request queue.
-@pre The thread must be in a critical section.
-*/
-TInt TCameraScRequestQueue::Create(DThread* anOwningThread)
-	{
-	iOwningThread=anOwningThread;
-
-	// Create the set of available request objects and add them to the unused request queue.
-	for (TInt i=0 ; i<KMaxCamScRequestsPending ; i++)
-		{
-		iRequest[i]=new TCameraScRequest;
-		if (!iRequest[i])
-			return(KErrNoMemory);
-		iUnusedRequestQ.Add(iRequest[i]);
-		}
-
-	return(KErrNone);
-	}
-
-/**
-Store a request status pointer onto the tail of the capture request queue.
-@param aStatus The request status pointer to be stored.
-@return KErrNone if successful;
-		KErrGeneral if the limit on the number of pending capture request (KMaxCamScRequestsPending) would be exceeded.
-@pre The buffer/request queue mutex must be held.
-*/
-TInt TCameraScRequestQueue::Add(TRequestStatus* aStatus)
-	{
-	TCameraScRequest* req=(TCameraScRequest*)iUnusedRequestQ.GetFirst();
-	if (!req)
-		return(KErrGeneral);								// Must have exceeded KMaxCamScRequestsPending
-
-	req->iStatus=aStatus;
-	iPendRequestQ.Add(req);
-	return(KErrNone);
-	}
-
-/**
-Retrieve the next request status pointer from the head of the capture request queue.
-@return The request status pointer removed or NULL if the list is empty.
-@pre The buffer/request queue mutex must be held.
-*/
-TRequestStatus* TCameraScRequestQueue::Remove()
-	{
-	TRequestStatus* status=NULL;
-	TCameraScRequest* req=(TCameraScRequest*)iPendRequestQ.GetFirst();
-	if (req)
-		{
-		status=req->iStatus;
-		iUnusedRequestQ.Add(req);
-		}
-	return(status);
-	}
-
-/**
-Remove a specifc request status pointer from the the capture request queue, completing it with a 'KErrCancel' completion reason.
-@param aStatus The request status pointer to be completed.
-@pre The buffer/request queue mutex must be held.
-*/
-void TCameraScRequestQueue::Cancel(TRequestStatus* aStatus)
-	{
-	// Find the entry concerned
-	TCameraScRequest* req=(TCameraScRequest*)iPendRequestQ.First();
-	SDblQueLink* anchor=&iPendRequestQ.iA;
-	while (req!=anchor && req->iStatus!=aStatus)
-		req=(TCameraScRequest*)req->iNext;
-	if (req==anchor)
-		return;
-
-	// Remove and cancel it.
-	req->Deque();
-	iUnusedRequestQ.Add(req);
-	NKern::FMSignal(iMutexPtr); 	// Release the request list mutex while we complete the request. This is safe.
-	Kern::RequestComplete(iOwningThread,req->iStatus,KErrCancel);
-	NKern::FMWait(iMutexPtr); 		// Re-acquire the request list mutex.
-	}
-
-/**
-Remove each request status pointer from the the capture request queue, completing each with a 'KErrCancel' completion reason.
-@pre The buffer/request queue mutex must be held.
-*/
-void TCameraScRequestQueue::CancelAll()
-	{
-
-	TRequestStatus* status;
-	while ((status=Remove())!=NULL)
-		{
-		NKern::FMSignal(iMutexPtr); 	// Release the request list mutex while we complete the request. This is safe.
-		Kern::RequestComplete(iOwningThread,status,KErrCancel);
-		NKern::FMWait(iMutexPtr); 		// Re-acquire the request list mutex.
-		}
-	}
-
-/**
-Constructor for the camera driver power handler class.
-@param aChannel A pointer to the camera driver logical channel which owns this power handler.
-*/
-DCameraScPowerHandler::DCameraScPowerHandler(DCameraScLdd* aChannel)
-:	DPowerHandler(KDevCameraScName),
-	iChannel(aChannel)
-	{
-	}
-
-/**
-A request from the power manager for the power down of the camera device.
-This is called during a transition of the phone into standby or power off.
-@param aState The target power state; can be EPwStandby or EPwOff only.
-*/
-void DCameraScPowerHandler::PowerDown(TPowerState aPowerState)
-	{
-	(void)aPowerState;
-	__KTRACE_CAM(Kern::Printf(">DCameraScPowerHandler::PowerDown(State-%d)",aPowerState));
-
-	// Power-down involves hardware access so queue a DFC to perform this from the driver thread.
-	iChannel->iPowerDownDfc.Enque();
-	}
-
-/**
-A request from the power manager for the power up of the camera device.
-This is called during a transition of the phone out of standby.
-*/
-void DCameraScPowerHandler::PowerUp()
-	{
-	__KTRACE_CAM(Kern::Printf(">DCameraScPowerHandler::PowerUp"));
-
-	// Power-up involves hardware access so queue a DFC to perform this from the driver thread.
-	iChannel->iPowerUpDfc.Enque();
-	}
--- a/kernel/eka/drivers/camerasc/ecamerasc.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-// Copyright (c) 2005-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/drivers/camerasc/ecamerasc.mmp
-// ecamerasc.ldd camera logical device driver
-// 
-//
-
-/**
- @file
-*/
-
-#include		"../../kernel/kern_ext.mmh"
-
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-
-TARGET			ecamerasc.ldd
-TARGETTYPE		ldd
-
-SOURCE			cameraldd.cpp
-
-UID 			0 0x100000c9
-VENDORID 		0x70000001
-
-CAPABILITY		all
-
-START WINS
-win32_headers
-END
--- a/kernel/eka/drivers/debug/group/bld.inf	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/debug/group/bld.inf	Wed Aug 18 11:08:29 2010 +0300
@@ -34,8 +34,8 @@
 ../../../debug/crashMonitor/inc/crashlogwalker.h         SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(crashlogwalker.h)
 ../../../debug/crashMonitor/inc/scmconfig.h              SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmconfig.h)
 ../../../debug/crashMonitor/inc/scmconfigitem.h          SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmconfigitem.h)
-../../../debug/crashmonitor/inc/scmdatasave.h            SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmdatasave.h)
-../../../debug/crashmonitor/inc/scmtrace.h               SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmtrace.h)
+../../../debug/crashMonitor/inc/scmdatasave.h            SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmdatasave.h)
+../../../debug/crashMonitor/inc/scmtrace.h               SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(scmtrace.h)
 
 PRJ_MMPFILES
 
--- a/kernel/eka/drivers/dma/dma2_pil.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/dma/dma2_pil.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -22,23 +22,21 @@
 #include <kernel/kern_priv.h>
 
 
-// Symbian Min() & Max() are broken, so we have to define them ourselves
-inline TUint Min(TUint aLeft, TUint aRight)
+// Symbian _Min() & _Max() are broken, so we have to define them ourselves
+inline TUint _Min(TUint aLeft, TUint aRight)
 	{return(aLeft < aRight ? aLeft : aRight);}
-inline TUint Max(TUint aLeft, TUint aRight)
+inline TUint _Max(TUint aLeft, TUint aRight)
 	{return(aLeft > aRight ? aLeft : aRight);}
 
 
-// Uncomment the following #define only when freezing the DMA2 export library.
-//#define __FREEZE_DMA2_LIB
-#ifdef __FREEZE_DMA2_LIB
+// The following section is used only when freezing the DMA2 export library
+/*
 TInt DmaChannelMgr::StaticExtension(TInt, TAny*) {return 0;}
 TDmaChannel* DmaChannelMgr::Open(TUint32, TBool, TUint) {return 0;}
 void DmaChannelMgr::Close(TDmaChannel*) {}
 EXPORT_C const TDmaTestInfo& DmaTestInfo() {static TDmaTestInfo a; return a;}
 EXPORT_C const TDmaV2TestInfo& DmaTestInfoV2() {static TDmaV2TestInfo a; return a;}
-#endif	// #ifdef __FREEZE_DMA2_LIB
-
+*/
 
 static const char KDmaPanicCat[] = "DMA " __FILE__;
 
@@ -202,7 +200,7 @@
 	{
 	// TDmac needs to override this function if it has reported the channel
 	// type for which the PIL calls it.
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	}
 
 
@@ -211,7 +209,7 @@
 	{
 	// TDmac needs to override this function if it has reported the channel
 	// type for which the PIL calls it.
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	}
 
 
@@ -265,7 +263,7 @@
 		}
 	else
 		{
-		iDesPool = new TDmaTransferArgs[iMaxDesCount];
+		iDesPool = Kern::Alloc(iMaxDesCount * sizeof(TDmaTransferArgs));
 		r = iDesPool ? KErrNone : KErrNoMemory;
 		}
 	return r;
@@ -450,7 +448,7 @@
 TInt TDmac::InitHwDes(const SDmaDesHdr& /*aHdr*/, const TDmaTransferArgs& /*aTransferArgs*/)
 	{
 	// concrete controller must override if SDmacCaps::iHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	return KErrGeneral;
 	}
 
@@ -458,7 +456,7 @@
 TInt TDmac::InitSrcHwDes(const SDmaDesHdr& /*aHdr*/, const TDmaTransferArgs& /*aTransferArgs*/)
 	{
 	// concrete controller must override if SDmacCaps::iAsymHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	return KErrGeneral;
 	}
 
@@ -466,7 +464,7 @@
 TInt TDmac::InitDstHwDes(const SDmaDesHdr& /*aHdr*/, const TDmaTransferArgs& /*aTransferArgs*/)
 	{
 	// concrete controller must override if SDmacCaps::iAsymHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	return KErrGeneral;
 	}
 
@@ -502,7 +500,7 @@
 						TUint /*aTransferCount*/, TUint32 /*aPslRequestInfo*/)
 	{
 	// concrete controller must override if SDmacCaps::iHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	return KErrGeneral;
 	}
 
@@ -511,7 +509,7 @@
 						   TUint /*aTransferCount*/, TUint32 /*aPslRequestInfo*/)
 	{
 	// concrete controller must override if SDmacCaps::iAsymHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	return KErrGeneral;
 	}
 
@@ -520,7 +518,7 @@
 						   TUint /*aTransferCount*/, TUint32 /*aPslRequestInfo*/)
 	{
 	// concrete controller must override if SDmacCaps::iAsymHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	return KErrGeneral;
 	}
 
@@ -528,7 +526,7 @@
 void TDmac::ChainHwDes(const SDmaDesHdr& /*aHdr*/, const SDmaDesHdr& /*aNextHdr*/)
 	{
 	// concrete controller must override if SDmacCaps::iHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	}
 
 
@@ -536,7 +534,7 @@
 						const SDmaDesHdr& /*aNewHdr*/)
 	{
  	// concrete controller must override if SDmacCaps::iHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	}
 
 
@@ -545,14 +543,14 @@
 						const SDmaDesHdr& /*aDstLastHdr*/, const SDmaDesHdr& /*aDstNewHdr*/)
 	{
 	// concrete controller must override if SDmacCaps::iAsymHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	}
 
 
 void TDmac::UnlinkHwDes(const TDmaChannel& /*aChannel*/, SDmaDesHdr& /*aHdr*/)
 	{
  	// concrete controller must override if SDmacCaps::iHwDescriptors set
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	}
 
 
@@ -601,7 +599,7 @@
 TUint32 TDmac::HwDesNumDstElementsTransferred(const SDmaDesHdr& /*aHdr*/)
 	{
  	// Concrete controller must override if SDmacCaps::iHwDescriptors set.
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	return 0;
 	}
 
@@ -609,7 +607,7 @@
 TUint32 TDmac::HwDesNumSrcElementsTransferred(const SDmaDesHdr& /*aHdr*/)
 	{
  	// Concrete controller must override if SDmacCaps::iHwDescriptors set.
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	return 0;
 	}
 
@@ -856,7 +854,7 @@
 	}
 
 
-TInt DDmaRequest::CheckMemFlags(const TDmaTransferConfig& aTarget, TUint aCount) const
+TInt DDmaRequest::CheckMemFlags(const TDmaTransferConfig& aTarget) const
 	{
 	__KTRACE_OPT(KDMA, Kern::Printf("DDmaRequest::CheckMemFlags"));
 
@@ -892,7 +890,7 @@
 	TUint rem = 0;
 	TInt r = KErrNone;
 
-	while (1)
+	FOREVER
 		{
 		// If an element size is defined, make sure the fragment size is
 		// greater or equal.
@@ -1101,13 +1099,13 @@
 	aTransferArgs.iChannelCookie = iChannel.PslId();
 
 	// Client shouldn't specify contradictory or invalid things
-	TInt r = CheckMemFlags(aTransferArgs.iSrcConfig, count);
+	TInt r = CheckMemFlags(aTransferArgs.iSrcConfig);
 	if (r != KErrNone)
 		{
 		__KTRACE_OPT(KPANIC, Kern::Printf("Error: CheckMemFlags(src)"));
 		return r;
 		}
-	r =  CheckMemFlags(aTransferArgs.iDstConfig, count);
+	r =  CheckMemFlags(aTransferArgs.iDstConfig);
 	if (r != KErrNone)
 		{
 		__KTRACE_OPT(KPANIC, Kern::Printf("Error: CheckMemFlags(dst)"));
@@ -1160,7 +1158,7 @@
 	// Max aligned length is used to make sure the beginnings of subtransfers
 	// (i.e. fragments) are correctly aligned.
 	const TUint max_aligned_len = (aMaxTransferLen &
-								   ~(Max(align_mask_src, align_mask_dst)));
+								   ~(_Max(align_mask_src, align_mask_dst)));
 	__KTRACE_OPT(KDMA, Kern::Printf("max_aligned_len: %d", max_aligned_len));
 	// Client and PSL sane?
 	__DMA_ASSERTD(max_aligned_len > 0);
@@ -1235,8 +1233,8 @@
 			break;
 			}
 		// Compute fragment size
-		TUint c = Min(aMaxTransferLen, aCount);
-		__KTRACE_OPT(KDMA, Kern::Printf("c = Min(aMaxTransferLen, aCount) = %d", c));
+		TUint c = _Min(aMaxTransferLen, aCount);
+		__KTRACE_OPT(KDMA, Kern::Printf("c = _Min(aMaxTransferLen, aCount) = %d", c));
 
 		// SRC
 		if (mem_src && !(src.iFlags & KDmaMemIsContiguous))
@@ -1422,8 +1420,8 @@
 			break;
 			}
 		// Compute fragment size
-		TUint c = Min(aMaxTransferLen, aCount);
-		__KTRACE_OPT(KDMA, Kern::Printf("c = Min(aMaxTransferLen, aCount) = %d", c));
+		TUint c = _Min(aMaxTransferLen, aCount);
+		__KTRACE_OPT(KDMA, Kern::Printf("c = _Min(aMaxTransferLen, aCount) = %d", c));
 
 		if (mem_src && !(src.iFlags & KDmaMemIsContiguous))
 			{
@@ -1536,8 +1534,8 @@
 			break;
 			}
 		// Compute fragment size
-		TUint c = Min(aMaxTransferLen, aCount);
-		__KTRACE_OPT(KDMA, Kern::Printf("c = Min(aMaxTransferLen, aCount) = %d", c));
+		TUint c = _Min(aMaxTransferLen, aCount);
+		__KTRACE_OPT(KDMA, Kern::Printf("c = _Min(aMaxTransferLen, aCount) = %d", c));
 
 		if (mem_dst && !(dst.iFlags & KDmaMemIsContiguous))
 			{
@@ -1642,7 +1640,7 @@
 	// Max aligned length is used to make sure the beginnings of subtransfers
 	// (i.e. fragments) are correctly aligned.
 	const TUint max_aligned_len = (aMaxTransferLen &
-								   ~(Max(align_mask_src, align_mask_dst)));
+								   ~(_Max(align_mask_src, align_mask_dst)));
 	__KTRACE_OPT(KDMA, Kern::Printf("max_aligned_len: %d", max_aligned_len));
 	// Client and PSL sane?
 	__DMA_ASSERTD(max_aligned_len > 0);
@@ -1708,6 +1706,7 @@
 	// Revert any previous fragmentation attempt
 	FreeSrcDesList();
 	FreeDstDesList();
+	__DMA_ASSERTD(iSrcDesCount == iDstDesCount);
 	do
 		{
 		// Allocate fragment
@@ -1721,9 +1720,10 @@
 			{
 			break;
 			}
+		__DMA_ASSERTD(iSrcDesCount == iDstDesCount);
 		// Compute fragment size
-		TUint c = Min(aMaxTransferLen, aCount);
-		__KTRACE_OPT(KDMA, Kern::Printf("c = Min(aMaxTransferLen, aCount) = %d", c));
+		TUint c = _Min(aMaxTransferLen, aCount);
+		__KTRACE_OPT(KDMA, Kern::Printf("c = _Min(aMaxTransferLen, aCount) = %d", c));
 
 		// SRC
 		if (mem_src && !(src.iFlags & KDmaMemIsContiguous))
@@ -1851,7 +1851,7 @@
 	// Not configured? Call Fragment() first!
 	if (iChannel.iDmacCaps->iAsymHwDescriptors)
 		{
-		__DMA_ASSERTD((iSrcDesCount < 0) && (iDstDesCount < 0));
+		__DMA_ASSERTD((iSrcDesCount > 0) && (iDstDesCount > 0));
 		}
 	else
 		{
@@ -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,18 +1920,19 @@
 		req_count = --iChannel.iQueuedRequests;
 		__DMA_INVARIANT();
 		iChannel.Signal();
-		if (req_count == 0)
+		if (iChannel.iCallQueuedRequestFn)
 			{
-			iChannel.QueuedRequestCountChanged();
+			if (req_count == 0)
+				{
+				iChannel.QueuedRequestCountChanged();
+				}
 			}
 		}
 	else
 		{
 		iQueued = ETrue;
 		iChannel.iReqQ.Add(&iLink);
-		// iChannel.iNullPtr points to iChannel.iCurHdr for an empty queue
-		*iChannel.iNullPtr = iFirstHdr;
-		iChannel.iNullPtr = &(iLastHdr->iNext);
+		iChannel.SetNullPtr(*this);
 		if (iIsrCb)
 			{
 			// Since we've made sure that there is no other request in the
@@ -1934,7 +1944,7 @@
 			// possible.
 			__e32_atomic_store_rel32(&iChannel.iIsrCbRequest, ETrue);
 			}
-		iChannel.DoQueue(const_cast<const DDmaRequest&>(*this));
+		iChannel.DoQueue(*this);
 		r = KErrNone;
 		__DMA_INVARIANT();
 		iChannel.Signal();
@@ -2112,21 +2122,6 @@
 	__KTRACE_OPT(KDMA, Kern::Printf("DDmaRequest::TotalNumSrcElementsTransferred"));
 
 	// Not yet implemented.
-
-	// So far largely bogus code (just to touch some symbols)...
-	iTotalNumSrcElementsTransferred = 0;
-	TDmac& c = *(iChannel.iController);
-	if (c.iCapsHwDes)
-		{
-		for (const SDmaDesHdr* pH = iFirstHdr; pH != NULL; pH = pH->iNext)
-			{
-			iTotalNumSrcElementsTransferred += c.HwDesNumDstElementsTransferred(*pH);
-			}
-		}
-	else
-		{
-		// Do something different for pseudo descriptors...
-		}
 	return iTotalNumSrcElementsTransferred;
 	}
 
@@ -2213,22 +2208,26 @@
 					  (0 <= iDstDesCount) && (iDstDesCount <= iChannel.iMaxDesCount));
 		if (iSrcDesCount == 0)
 			{
+			// Not fragmented yet
 			__DMA_ASSERTD(iDstDesCount == 0);
 			__DMA_ASSERTD(!iQueued);
 			__DMA_ASSERTD(!iSrcFirstHdr && !iSrcLastHdr &&
 						  !iDstFirstHdr && !iDstLastHdr);
 			}
+		else if (iDstDesCount == 0)
+			{
+			// Src side only fragmented yet
+			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iSrcFirstHdr));
+			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iSrcLastHdr));
+			}
 		else
 			{
+			// Src & Dst sides fragmented
 			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iSrcFirstHdr));
 			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iSrcLastHdr));
 			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iDstFirstHdr));
 			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iDstLastHdr));
 			}
-		if (iChannel.iDmacCaps->iBalancedAsymSegments)
-			{
-			__DMA_ASSERTD(iSrcDesCount == iDstDesCount);
-			}
 		}
 	else
 		{
@@ -2271,6 +2270,7 @@
 	  iReqQ(),
 	  iReqCount(0),
 	  iQueuedRequests(0),
+	  iCallQueuedRequestFn(ETrue),
 	  iCancelInfo(NULL),
 	  iRedoRequest(EFalse),
 	  iIsrCbRequest(EFalse)
@@ -2416,7 +2416,8 @@
 		// ISR should not happen after this function returns.
 		iController->StopTransfer(*this);
 
-		ResetStateMachine();
+		DoCancelAll();
+		ResetNullPtr();
 
 		// Clean-up the request queue.
 		SDblQueLink* pL;
@@ -2472,9 +2473,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();
@@ -2687,8 +2691,7 @@
 				{
 				SDmaDesHdr* pCompletedSrcHdr = NULL;
 				SDmaDesHdr* pCompletedDstHdr = NULL;
-				DoDfc(const_cast<const DDmaRequest&>(*pCurReq),
-					  pCompletedSrcHdr, pCompletedDstHdr);
+				DoDfc(*pCurReq, pCompletedSrcHdr, pCompletedDstHdr);
 				// We don't support asymmetrical ISR notifications and request
 				// completions yet, hence we can do the following assert test
 				// here; also 'complete' is determined equally by either the
@@ -2700,7 +2703,7 @@
 			else
 				{
 				SDmaDesHdr* pCompletedHdr = NULL;
-				DoDfc(const_cast<const DDmaRequest&>(*pCurReq), pCompletedHdr);
+				DoDfc(*pCurReq, pCompletedHdr);
 				complete = (pCompletedHdr == pCurReq->iLastHdr);
 				}
 			// If just completed last fragment from current request, switch to
@@ -2711,7 +2714,7 @@
 				pCurReq->iLink.Deque();
 				iQueuedRequests--;
 				if (iReqQ.IsEmpty())
-					iNullPtr = &iCurHdr;
+					ResetNullPtr();
 				pCompletedReq->OnDeque();
 				}
 			}
@@ -2786,30 +2789,22 @@
 	// 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();
 	}
 
 
-//
-// Reset state machine only, request queue is unchanged */
-//
-void TDmaChannel::ResetStateMachine()
-	{
-	DoCancelAll();
-	iCurHdr = NULL;
-	iNullPtr = &iCurHdr;
-	}
-
-
 void TDmaChannel::DoQueue(const DDmaRequest& /*aReq*/)
 	{
 	// Must be overridden
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	}
 
 
@@ -2828,7 +2823,7 @@
 	// To make sure this version of the function isn't called for channels for
 	// which it isn't appropriate (and which therefore don't override it) we
 	// put this check in here.
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
 	}
 
 
@@ -2838,21 +2833,33 @@
 	// To make sure this version of the function isn't called for channels for
 	// which it isn't appropriate (and which therefore don't override it) we
 	// put this check in here.
-	__DMA_CANT_HAPPEN();
+	__DMA_UNREACHABLE_DEFAULT();
+	}
+
+
+void TDmaChannel::SetNullPtr(const DDmaRequest& aReq)
+	{
+	// iNullPtr points to iCurHdr for an empty queue
+	*iNullPtr = aReq.iFirstHdr;
+	iNullPtr = &(aReq.iLastHdr->iNext);
+	}
+
+
+void TDmaChannel::ResetNullPtr()
+	{
+	iCurHdr = NULL;
+	iNullPtr = &iCurHdr;
 	}
 
 
 /** 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
 	}
 
 
@@ -3018,6 +3025,35 @@
 //////////////////////////////////////////////////////////////////////////////
 // TDmaAsymSgChannel
 
+TDmaAsymSgChannel::TDmaAsymSgChannel()
+	: iSrcCurHdr(NULL),
+	  iSrcNullPtr(&iSrcCurHdr),
+	  iDstCurHdr(NULL),
+	  iDstNullPtr(&iDstCurHdr)
+	{
+	__DMA_INVARIANT();
+	}
+
+
+void TDmaAsymSgChannel::SetNullPtr(const DDmaRequest& aReq)
+	{
+	// i{Src|Dst}NullPtr points to i{Src|Dst}CurHdr for an empty queue
+	*iSrcNullPtr = aReq.iSrcFirstHdr;
+	*iDstNullPtr = aReq.iDstFirstHdr;
+	iSrcNullPtr = &(aReq.iSrcLastHdr->iNext);
+	iDstNullPtr = &(aReq.iDstLastHdr->iNext);
+	}
+
+
+void TDmaAsymSgChannel::ResetNullPtr()
+	{
+	iSrcCurHdr = NULL;
+	iSrcNullPtr = &iSrcCurHdr;
+	iDstCurHdr = NULL;
+	iDstNullPtr = &iDstCurHdr;
+	}
+
+
 void TDmaAsymSgChannel::DoQueue(const DDmaRequest& aReq)
 	{
 	if (iState == ETransferring)
@@ -3062,3 +3098,34 @@
 	iState = (iSrcCurHdr != NULL) ? ETransferring : EIdle;
 	}
 
+
+#ifdef _DEBUG
+void TDmaAsymSgChannel::Invariant()
+	{
+	Wait();
+
+	__DMA_ASSERTD(iReqCount >= 0);
+
+	__DMA_ASSERTD(iSrcCurHdr == NULL || iController->IsValidHdr(iSrcCurHdr));
+	__DMA_ASSERTD(iDstCurHdr == NULL || iController->IsValidHdr(iDstCurHdr));
+
+	// should always point to NULL pointer ending fragment queue
+	__DMA_ASSERTD(*iSrcNullPtr == NULL);
+	__DMA_ASSERTD(*iDstNullPtr == NULL);
+
+	__DMA_ASSERTD((0 <= iAvailDesCount) && (iAvailDesCount <= iMaxDesCount));
+
+	__DMA_ASSERTD((iSrcCurHdr && iDstCurHdr && !IsQueueEmpty()) ||
+				  (!iSrcCurHdr && !iDstCurHdr && IsQueueEmpty()));
+	if (iSrcCurHdr == NULL)
+		{
+		__DMA_ASSERTD(iSrcNullPtr == &iSrcCurHdr);
+		}
+	if (iDstCurHdr == NULL)
+		{
+		__DMA_ASSERTD(iDstNullPtr == &iDstCurHdr);
+		}
+
+	Signal();
+	}
+#endif
--- a/kernel/eka/drivers/dma/dmapil.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/dma/dmapil.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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/drivers/iic/iic.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/iic/iic.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -26,6 +26,10 @@
 // Global Controller pointer
 static DIicBusController* TheController = NULL;
 
+#ifdef IIC_SIMULATED_PSL
+DIicBusController*& gTheController = TheController;
+#endif
+
 //
 //		Implementation of generic IicBus API for client interface
 //
@@ -1014,63 +1018,8 @@
 
 #endif
 
-#ifdef IIC_SIMULATED_PSL
-TVersion DIicPdd::VersionRequired()
-	{
-	const TInt KIicMajorVersionNumber=1;
-	const TInt KIicMinorVersionNumber=0;
-	const TInt KIicBuildVersionNumber=KE32BuildVersionNumber;
-	return TVersion(KIicMajorVersionNumber,KIicMinorVersionNumber,KIicBuildVersionNumber);
-	}
-
-/** Factory class constructor */
-DIicPdd::DIicPdd()
-	{
-    iVersion = DIicPdd::VersionRequired();
-	}
-
-DIicPdd::~DIicPdd()
-	{
-	delete TheController;
-	}
-
-TInt DIicPdd::Install()
-    {
-    return(SetName(&KPddName));
-    }
+#ifndef IIC_SIMULATED_PSL
 
-/**  Called by the kernel's device driver framework to create a Physical Channel. */
-TInt DIicPdd::Create(DBase*& /*aChannel*/, TInt /*aUint*/, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/)
-    {
-    return KErrNone;
-    }
-
-/**  Called by the kernel's device driver framework to check if this PDD is suitable for use with a Logical Channel.*/
-TInt DIicPdd::Validate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer)
-    {
-   	if (!Kern::QueryVersionSupported(DIicPdd::VersionRequired(),aVer))
-		return(KErrNotSupported);
-    return KErrNone;
-    }
-
-/** Return the driver capabilities */
-void DIicPdd::GetCaps(TDes8& aDes) const
-    {
-	// Create a capabilities object
-	TCaps caps;
-	caps.iVersion = iVersion;
-	// Zero the buffer
-	TInt maxLen = aDes.MaxLength();
-	aDes.FillZ(maxLen);
-	// Copy cpabilities
-	TInt size=sizeof(caps);
-	if(size>maxLen)
-	   size=maxLen;
-	aDes.Copy((TUint8*)&caps,size);
-    }
-#endif
-
-#ifndef IIC_SIMULATED_PSL
 // Client interface entry point
 DECLARE_EXTENSION_WITH_PRIORITY(KExtensionMaximumPriority-1)	// highest priority after Resource Manager
 	{
@@ -1080,26 +1029,6 @@
 	TInt r=TheController->Create();
 	return r;
 	}
-#else
-static DIicPdd* TheIicPdd;
-
-DECLARE_STANDARD_PDD()
-	{
-	TheController = new DIicBusController;
-	if(!TheController)
-		return NULL;
-	TInt r = TheController->Create();
-	if(r == KErrNone)
-		{
-		TheIicPdd = new DIicPdd;
-		if(TheIicPdd)
-			return TheIicPdd;
-		}
-	
-	delete TheController; 
-	return NULL;
-	}
 #endif
 
 
-
--- a/kernel/eka/drivers/locmedia/traces/OstTraceDefinitions.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/locmedia/traces/OstTraceDefinitions.h	Wed Aug 18 11:08:29 2010 +0300
@@ -17,5 +17,5 @@
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
 // REMOVE BEFORE CHECK-IN TO VERSION CONTROL
 //#define OST_TRACE_COMPILER_IN_USE
-#include <OpenSystemTrace.h>
+#include <opensystemtrace.h>
 #endif
--- a/kernel/eka/drivers/medmmc/bgahsmmcptn.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/medmmc/bgahsmmcptn.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -17,9 +17,10 @@
 
 #include <emmcptn.h>
 #include "bgahsmmcptn.h"
-
-const TInt	  KDiskSectorShift		= 9;
-const TUint32 KPIOffsetFromMediaEnd = 1;
+#include "toc.h"
+//#define __DEBUG_PARTITIONS_
+//#define __DEBUG_CHECK_PARTITION_
+const TInt    KDiskSectorShift          = 9;
 
 class DBB5PartitionInfo : public DEMMCPartitionInfo
 	{
@@ -36,6 +37,7 @@
 	void SetPartitionEntry(TPartitionEntry* aEntry, TUint aFirstSector, TUint aNumSectors);
 
 private:
+	virtual TInt ReadPartition(TUint32 aPtOffset);
 	static void SessionEndCallBack(TAny* aSelf);
 		   void DoSessionEndCallBack();
 	virtual TInt DecodePartitionInfo();
@@ -49,10 +51,13 @@
 	TMMCard*		iCard;
 	TUint8* 		iIntBuf;
 	TUint32 		iPartitionAttributes[KMaxLocalDrives];
+	TBool           iCheckTOC;
+	Toc*            iTocPtr;
 	};
 
 DBB5PartitionInfo::DBB5PartitionInfo()
-  : iSessionEndCallBack(DBB5PartitionInfo::SessionEndCallBack, this)
+  : iSessionEndCallBack(DBB5PartitionInfo::SessionEndCallBack, this),
+    iCheckTOC(EFalse)
 	{
 	}
 
@@ -91,13 +96,19 @@
 	iPartitionInfo = &aInfo;
 	iCallBack = aCallBack;
 
+	// Preferred partition scheme is BB5, which is located in the last block of the media.
+    const TUint32 ptiOffset = (I64LOW(iCard->DeviceSize64() >> KDiskSectorShift)) - KPIOffsetFromMediaEnd;
+	return ReadPartition(ptiOffset);
+	}
+	
+TInt DBB5PartitionInfo::ReadPartition(TUint32 aPtOffset)
+    {
 	// If media driver is persistent (see EMediaDriverPersistent)
 	// the card may have changed since last power down, so reset CID
 	iSession->SetCard(iCard);
 
-	const TUint32 ptiOffset = (I64LOW(iCard->DeviceSize64() >> KDiskSectorShift)) - KPIOffsetFromMediaEnd;
-	iSession->SetupCIMReadBlock(ptiOffset, iIntBuf);
-
+	iSession->SetupCIMReadBlock(aPtOffset, iIntBuf);
+	
 	TInt r = iDriver->InCritical();
 	if (r == KErrNone)
 		r = iSession->Engage();
@@ -117,6 +128,25 @@
 		Info().iFileSystemId = KDriveFileNone;
 		Info().iDriveAtt |= KDriveAttHidden;
 		}
+	else if (aDrive.iPartitionType == KPartitionTypeRofs)
+		{
+		Info().iFileSystemId = KDriveFileSysROFS;
+		Info().iMediaAtt &= ~KMediaAttFormattable;
+		Info().iMediaAtt |= KMediaAttWriteProtected;
+		}
+	else if ((aDrive.iPartitionType == KPartitionTypeROM) ||
+			 (aDrive.iPartitionType == KPartitionTypeEmpty))
+		{
+		Info().iFileSystemId = KDriveFileNone;
+		Info().iMediaAtt &= ~KMediaAttFormattable;
+		Info().iMediaAtt |= KMediaAttWriteProtected;
+		}
+    else if ((aDrive.iPartitionType == KPartitionTypePartitionMagic) || //CPS/PMM
+             (aDrive.iPartitionType == KPartitionTypeSymbianCrashLog))
+        {
+        Info().iFileSystemId = KDriveFileNone;
+        Info().iMediaAtt |= KMediaAttFormattable;
+        }
 	else if ( PartitionIsFAT(aDrive.iPartitionType) || PartitionIsFAT32(aDrive.iPartitionType)	)
 		{		
 		Info().iDriveAtt |= iPartitionAttributes[aDrive.iPartitionNumber];
@@ -140,81 +170,200 @@
 	if (r == KErrNone)
 		r = DecodePartitionInfo();
 
-	iDriver->PartitionInfoComplete(r == KErrNone ? r : KErrNotReady);
+	if (!iCheckTOC)
+	    {        
+	    iDriver->PartitionInfoComplete(r == KErrNone ? r : KErrNotReady);
+	    }
 	}
 
 TInt DBB5PartitionInfo::DecodePartitionInfo()
 //
-// decode partition info that was read into internal buffer
+// Decode partition info that was read into internal buffer
 //
 	{
 	__KTRACE_OPT(KPBUSDRV, Kern::Printf(">Mmc:PartitionInfo()"));
 	TUint partitionCount = iPartitionInfo->iPartitionCount = 0;
 
-	// For internal devices it is only valid to report up to 1 SWAP partition
-	TBool foundSwap = EFalse;
+	
+	if (iCheckTOC)
+	    {
+        // Try utilising the TOC (Table Of Contents) partitioning scheme 
+        const TText8* KRofsNames[KNoOfROFSPartitions] = { KTocRofs1Generic,
+                                                          KTocRofs2Generic,
+                                                          KTocRofs3Generic,
+                                                          KTocRofs4Generic,
+                                                          KTocRofs5Generic,                                                            
+                                                          KTocRofs6Generic,                                                            
+                                                          };
+                                        
+        STocItem item;
+        iTocPtr = reinterpret_cast<Toc*>(&iIntBuf[0]);
+        iTocPtr->iTocStartSector = KTocStartSector;
+        TInt r = KErrNone;
 
-	BGAHSMMCPTN_PI_STR *partitionTable = (BGAHSMMCPTN_PI_STR*)(&iIntBuf[0]);
+// USER Drive - Only 1        
+        r = iTocPtr->GetItemByName(KTocUserName, item); 
+        if (KErrNone == r)
+            {
+            __KTRACE_OPT(KPBUSDRV, Kern::Printf("[MD  :   ] (%11s) in TOC found : Start addr = 0x%X  Size = 0x%X", item.iFileName, item.iStart, item.iSize));
+            iPartitionInfo->iEntry[partitionCount].iPartitionType     = KPartitionTypeFAT16;           
+            iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64)item.iStart;                         
+            iPartitionInfo->iEntry[partitionCount].iPartitionLen      = (Int64)item.iSize;
+            iPartitionAttributes[partitionCount] = 0; // No Additional Attributes required.           
+            partitionCount++;
+            }   
+        
+// ROM Drive        
+        r = iTocPtr->GetItemByName(KTocRomGeneric, item); 
+        if (KErrNone == r)
+            {
+            __KTRACE_OPT(KPBUSDRV, Kern::Printf("[MD  :   ] (%11s) in TOC found : Start addr = 0x%x  Size = 0x%x", item.iFileName, item.iStart, item.iSize));
+            iPartitionInfo->iEntry[partitionCount].iPartitionType     = KPartitionTypeROM;           
+            iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) item.iStart + (KBB5HeaderSizeInSectors << KDiskSectorShift);                         
+            iPartitionInfo->iEntry[partitionCount].iPartitionLen      = (Int64) item.iSize - (KBB5HeaderSizeInSectors << KDiskSectorShift);          
+            partitionCount++;
+            }
+        
+// ROFS            
+        for (TUint i = 0; i < KNoOfROFSPartitions; i++)
+            {
+            /* Search ROFSn item */            
+            r = iTocPtr->GetItemByName(KRofsNames[i], item);
+            if (r == KErrNone)
+                {
+                __KTRACE_OPT(KPBUSDRV, Kern::Printf("[MD  :   ] (%11s) in TOC found : Start addr = 0x%X  Size = 0x%X", item.iFileName, item.iStart, item.iSize));
+                iPartitionInfo->iEntry[partitionCount].iPartitionType     = KPartitionTypeRofs;           
+                iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) item.iStart + (KBB5HeaderSizeInSectors << KDiskSectorShift);                         
+                iPartitionInfo->iEntry[partitionCount].iPartitionLen      = (Int64) item.iSize - (KBB5HeaderSizeInSectors << KDiskSectorShift);
+                partitionCount++;
+                }
+            }         
 
-	// Verify that this is the Nokia partition table
-	if( memcompare( (TUint8*)&(partitionTable->iId[0]), sizeof(BGAHSMMCPTN_PI_ID), (TUint8*)BGAHSMMCPTN_PI_ID, sizeof(BGAHSMMCPTN_PI_ID)) == 0 )
-		{
-		__KTRACE_OPT(KPBUSDRV, Kern::Printf("Nokia partition structure found"));
-		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->id..............: %s", partitionTable->iId ));
-		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->sector_size.....: %d = 0x%x", partitionTable->iSector_size, partitionTable->iSector_size));
-		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->major_ver.......: %d", partitionTable->iMajor_ver));
-		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->minor_ver.......: %d", partitionTable->iMinor_ver));
-		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->partition_amount: %d", partitionTable->iPartition_amount));
-		
-		
-		TUint8 PartitionType = 0;		
-		// Check Supported Version is present
-		if (partitionTable->iMajor_ver <= BGAHSMMCPTN_PI_VER_MAJOR)
-		    {
-            for( TUint8 index = 0; (index < partitionTable->iPartition_amount) && (index < BGAHSMMCPTN_LAST_DRIVE); index++ )
-                {
-                if (partitionTable->iMinor_ver >= BGAHSMMCPTN_PART_TYPE_SUPP_VER_MINOR)
-                    PartitionType = partitionTable->iPartitions[index].iPartition_type;
-                else                    
-                    PartitionType = partitionTable->iPartitions[index].iPartition_id;
+// CPS Drive - Only 1        
+        r = iTocPtr->GetItemByName(KTocCps, item); 
+        if (KErrNone == r)
+            {
+            __KTRACE_OPT(KPBUSDRV, Kern::Printf("[MD  :   ] (%11s) in TOC found : Start addr = 0x%X  Size = 0x%X", item.iFileName, item.iStart, item.iSize));
+            iPartitionInfo->iEntry[partitionCount].iPartitionType     = KPartitionTypePartitionMagic;           
+            iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) item.iStart;                         
+            iPartitionInfo->iEntry[partitionCount].iPartitionLen      = (Int64) item.iSize;
+            partitionCount++;
+            }
+        
+// CRASH Drive - Only 1        
+        r = iTocPtr->GetItemByName(KTocCrashLog, item); 
+        if (KErrNone == r)
+            {
+            __KTRACE_OPT(KPBUSDRV, Kern::Printf("[MD  :   ] (%11s) in TOC found : Start addr = 0x%X  Size = 0x%X", item.iFileName, item.iStart, item.iSize));
+            iPartitionInfo->iEntry[partitionCount].iPartitionType     = KPartitionTypeSymbianCrashLog;           
+            iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) item.iStart;                         
+            iPartitionInfo->iEntry[partitionCount].iPartitionLen      = (Int64) item.iSize;
+            partitionCount++;
+            }
+        
+// SWAP Partition - Only 1        
+        r = iTocPtr->GetItemByName(KTocSwap, item); 
+        if (KErrNone == r)
+            {
+            __KTRACE_OPT(KPBUSDRV, Kern::Printf("[MD  :   ] (%11s) in TOC found : Start addr = 0x%X  Size = 0x%X", item.iFileName, item.iStart, item.iSize));
+            iPartitionInfo->iEntry[partitionCount].iPartitionType     = KPartitionTypePagedData;           
+            iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) item.iStart;                         
+            iPartitionInfo->iEntry[partitionCount].iPartitionLen      = (Int64) item.iSize;
+            partitionCount++;
+            }                
+
+#ifdef __DEBUG_PARTITIONS_
+        for (TInt i = 0; i<partitionCount; i++)
+            {
+            Kern::Printf("iPartitionType....: %d", iPartitionInfo->iEntry[i].iPartitionType);                
+            Kern::Printf("iPartitionBaseAddr: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[i].iPartitionBaseAddr, (TUint32)(iPartitionInfo->iEntry[i].iPartitionBaseAddr >> KDiskSectorShift));                
+            Kern::Printf("iPartitionLen.....: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[i].iPartitionLen, iPartitionInfo->iEntry[i].iPartitionLen >> KDiskSectorShift);
+            Kern::Printf("iPartitionAttribs.: 0x%x", iPartitionAttributes[i]);
+            Kern::Printf(" ");
+            }
+#endif //__DEBUG_PARTITIONS_
+        
+        iCheckTOC = EFalse;
+	    }
+	else
+	    {
+        // Try utilising the BB5 partitioning scheme	
+        BGAHSMMCPTN_PI_STR *partitionTable = (BGAHSMMCPTN_PI_STR*)(&iIntBuf[0]);
+    
+        // Verify that this is the Nokia partition table
+        if( memcompare( (TUint8*)&(partitionTable->iId[0]), sizeof(BGAHSMMCPTN_PI_ID), (TUint8*)BGAHSMMCPTN_PI_ID, sizeof(BGAHSMMCPTN_PI_ID)) == 0 )
+            {
+			__KTRACE_OPT(KPBUSDRV, Kern::Printf("Nokia partition structure found"));
+			__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->id..............: %s", partitionTable->iId ));
+			__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->sector_size.....: %d = 0x%x", partitionTable->iSector_size, partitionTable->iSector_size));
+			__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->major_ver.......: %d", partitionTable->iMajor_ver));
+			__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->minor_ver.......: %d", partitionTable->iMinor_ver));
+			__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->partition_amount: %d", partitionTable->iPartition_amount));
             
-                if( (partitionTable->iPartitions[index].iSize > 0) &&
-                    ( PartitionIsFAT(PartitionType) ||
-                      PartitionIsFAT32(PartitionType) ||
-                     (KPartitionTypePagedData == PartitionType && !foundSwap) ) )
-                    {                   
-                    iPartitionInfo->iEntry[partitionCount].iPartitionType	  = PartitionType;                    
-                    iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) partitionTable->iPartitions[index].iStart_sector << KDiskSectorShift;
-                    iPartitionInfo->iEntry[partitionCount].iPartitionLen	  = (Int64) partitionTable->iPartitions[index].iSize << KDiskSectorShift;
-                    iPartitionAttributes[partitionCount]					  = partitionTable->iPartitions[index].iPartition_attributes;
-    
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf("Registering partition #%d:", partitionCount));
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionCount....: %d", partitionCount));
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf("startSector.......: 0x%x", partitionTable->iPartitions[index].iStart_sector ));
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionBaseAddr: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr, (TUint32)(iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr >> KDiskSectorShift)));
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf("size..............: 0x%lx", partitionTable->iPartitions[index].iSize ));
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionLen.....: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[partitionCount].iPartitionLen, iPartitionInfo->iEntry[partitionCount].iPartitionLen >> KDiskSectorShift));
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionType....: %d", iPartitionInfo->iEntry[partitionCount].iPartitionType));
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionAttribs.: 0x%x", iPartitionAttributes[partitionCount]));
-                    __KTRACE_OPT(KPBUSDRV, Kern::Printf(" "));
-    
-                    if(KPartitionTypePagedData == PartitionType)
-                        {
-                        foundSwap = ETrue;
+            TUint8 partitionType = 0;		
+            // Check Supported Version is present
+            if (partitionTable->iMajor_ver <= BGAHSMMCPTN_PI_VER_MAJOR)
+                {
+                for( TUint8 index = 0; (index < partitionTable->iPartition_amount) && (index < BGAHSMMCPTN_LAST_DRIVE); index++ )
+                    {
+                    if (partitionTable->iMinor_ver >= BGAHSMMCPTN_PART_TYPE_SUPP_VER_MINOR)
+                        partitionType = partitionTable->iPartitions[index].iPartition_type;
+                    else                    
+                        partitionType = partitionTable->iPartitions[index].iPartition_id;
+                
+                    // FAT/PMM/CPS/SWAP/CORE/ROFS/CRASH
+                    if( (partitionTable->iPartitions[index].iSize > 0) &&
+                        ( PartitionIsFAT(partitionType) ||
+                          PartitionIsFAT32(partitionType) ||
+                         (KPartitionTypeSymbianCrashLog == partitionType) ||
+                         (KPartitionTypePartitionMagic == partitionType) || //CPS/PMM
+                         (KPartitionTypeRofs == partitionType) || 
+                         (KPartitionTypeEmpty == partitionType) ||
+                         (KPartitionTypeROM == partitionType) ||
+                         (KPartitionTypePagedData == partitionType) ) )
+                        {                   
+                        iPartitionInfo->iEntry[partitionCount].iPartitionType	  = partitionType;
+                        iPartitionAttributes[partitionCount]                      = partitionTable->iPartitions[index].iPartition_attributes;
+                        
+                        // ROM/ROFS partitions have a BB5 checksum header that must be offset for the Symbian OS.
+                        const TUint32 KstartOffset = ((KPartitionTypeROM == partitionType) || (KPartitionTypeRofs == partitionType) || (KPartitionTypeEmpty == partitionType)) ? KBB5HeaderSizeInSectors : 0;
+                        
+                        iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) ((partitionTable->iPartitions[index].iStart_sector + KstartOffset) << KDiskSectorShift);
+                        iPartitionInfo->iEntry[partitionCount].iPartitionLen      = (Int64) ((partitionTable->iPartitions[index].iSize - KstartOffset) << KDiskSectorShift);
+        
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf("Registering partition #%d:", partitionCount));
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionCount....: %d", partitionCount));
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf("startSector.......: 0x%x", partitionTable->iPartitions[index].iStart_sector ));
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionBaseAddr: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr, (TUint32)(iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr >> KDiskSectorShift)));
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf("size..............: 0x%lx", partitionTable->iPartitions[index].iSize ));
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionLen.....: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[partitionCount].iPartitionLen, iPartitionInfo->iEntry[partitionCount].iPartitionLen >> KDiskSectorShift));
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionType....: %d", iPartitionInfo->iEntry[partitionCount].iPartitionType));
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionAttribs.: 0x%x", iPartitionAttributes[partitionCount]));
+                    	__KTRACE_OPT(KPBUSDRV, Kern::Printf(" "));
+        
+                        partitionCount++;
                         }
-    
-                    partitionCount++;
                     }
-                }
-            } 
-		} 
-
+                } 
+            }
+        else
+            {
+            __KTRACE_OPT(KPBUSDRV, Kern::Printf("BGAHSMMC signature not found - try TOC layout"));
+            iCheckTOC = ETrue;
+            
+            TInt r = ReadPartition(KTocStartSector);
+            return r;
+            }
+	    }
+	
+	
 	// Validate partition address boundaries
 	if(partitionCount == 0)
 		{
 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("Mmc: No supported partitions found!"));
 		return KErrCorrupt;
 		}
+#ifdef __DEBUG_CHECK_PARTITION_	
 	else
 		{
 		// at least one entry for a supported partition found
@@ -242,6 +391,7 @@
 				}
 			}
 		}
+#endif // _DEBUG_CHECK_PARTITION_
 
 	iPartitionInfo->iPartitionCount = partitionCount;
 	iPartitionInfo->iMediaSizeInBytes = iCard->DeviceSize64();
--- a/kernel/eka/drivers/medmmc/bgahsmmcptn.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/medmmc/bgahsmmcptn.h	Wed Aug 18 11:08:29 2010 +0300
@@ -33,7 +33,7 @@
 /* Partition type field supported from version 1.1 onwards */
 #define BGAHSMMCPTN_PART_TYPE_SUPP_VER_MINOR    1
 
-#define BGAHSMMCPTN_LAST_DRIVE		7 /* MMC1_DRIVECOUNT - defined in variantmediadef.h */
+#define BGAHSMMCPTN_LAST_DRIVE		16 /* MMC1_DRIVECOUNT - defined in variantmediadef.h */
 
 typedef struct
 {
@@ -62,4 +62,7 @@
 
 #define BGAHSMMCPTN_PI_STR_SIZE sizeof( BGAHSMMCPTN_PI_STR )
 
+const TUint32 KBB5HeaderSizeInSectors   = 8;
+const TUint32 KPIOffsetFromMediaEnd     = 1;
+
 #endif /*BGAHSMMCPTN_H*/
--- a/kernel/eka/drivers/medmmc/bgahsmmcptn.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/medmmc/bgahsmmcptn.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -22,6 +22,7 @@
 systeminclude	../../include/drivers
 
 source			bgahsmmcptn.cpp
+source			toc.cpp
 
 library			epbusmmc.lib
 library			elocd.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/eka/drivers/medmmc/toc.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,71 @@
+// 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:
+// TOC Partition Management for Embedded MMC devices
+// 
+//
+
+#include "toc.h"
+
+
+/*
+ * Search entry in TOC with aName as part of ItemName.
+ */
+TInt Toc::GetItemByName(const TText8* aName, STocItem& aItem)
+    {
+    if ( aName == NULL )
+        {
+        return KErrNotFound;
+        }
+    
+	// calculate length for name to be searched
+    TUint nameLen = 0;
+    for (; nameLen < KMaxItemNameLen && aName[nameLen] != 0; nameLen++) {};
+        
+	if ( !nameLen ) 
+	    return KErrGeneral; // zero length or Blank Name
+
+	// check all items in TOC	 
+	for (TUint i=0; i < KMaxNbrOfTocItems && iTOC[i].iStart != KEndOfToc; i++)
+		{	
+		// calculate length of current item 
+        TUint fileNameLen = 0;
+		for (; fileNameLen < KMaxItemNameLen && iTOC[i].iFileName[fileNameLen] != 0; fileNameLen++) {};
+		    
+		if ( fileNameLen < nameLen ) 
+		    continue;  // file name too short
+	
+		// compare Item with aName
+		for (TUint k = 0; k <= (fileNameLen - nameLen); k++ )				
+			{
+            TUint l=0;
+            for (; l < nameLen; l++ )
+                {
+                if ( aName[l] != iTOC[i].iFileName[k+l] ) 
+                    break;
+                }
+
+            if ( l == nameLen )
+                {
+                // item found
+                aItem = iTOC[i];
+                aItem.iStart += (iTocStartSector << KSectorShift);
+                return KErrNone;
+                }
+			}		
+		}
+	
+	return KErrNotFound;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/eka/drivers/medmmc/toc.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,89 @@
+// 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:
+// TOC Partition Management for Embedded MMC devices
+// 
+//
+
+
+#ifndef __EMMC_TOC_H__
+#define __EMMC_TOC_H__
+
+#include <emmcptn.h>
+
+// TOC item
+const TUint  KMaxItemNameLen = 12;
+
+struct STocItem
+    {
+    TUint32 iStart;
+    TUint32 iSize;
+    TUint32 iFlags;
+    TUint32 iAlign;
+    TUint32 iLoadAddress;
+    TText8  iFileName[KMaxItemNameLen];
+	};
+
+//- Constants ---------------------------------------------------------------
+
+const TUint32 KTocStartSector       = 1280; // TOC starts from 0xA0000 / 0x200
+
+const TText8  KTocRofsName[]        = "SOS-ROFS";
+const TText8  KTocRofsName1[]       = "SOS+ROFS"; 
+const TText8  KTocRofsExtName[]     = "SOS-ROFX";
+const TText8  KTocRofsGeneric[]     = "ROFS";  
+const TText8  KTocRomGeneric[]      = "SOS+CORE";  
+
+const TText8  KTocCps[]             = "SOS-CPS";
+const TText8  KTocRofsExtGeneric[]  = "ROFX";    
+const TText8  KTocSwap[]            = "SOS-SWAP";
+const TText8  KTocUserName[]        = "SOS-USER";
+const TText8  KTocCrashLog[]        = "SOS-CRASH";
+const TText8  KTocToc[]             = "TOC";
+const TText8  KTocSosToc[]          = "SOS-TOC";
+
+const TUint8  KMaxNbrOfTocItems     = 16;
+const TUint8  KXMaxNbrOfTocItems    = 16;
+const TUint32 KEndOfToc             = 0xFFFFFFFFUL;
+
+const TText8  KTocRofs1Generic[]    = "ROFS1";
+const TText8  KTocRofs2Generic[]    = "ROFS2";
+const TText8  KTocRofs3Generic[]    = "ROFS3"; 
+const TText8  KTocRofs4Generic[]    = "ROFS4";
+const TText8  KTocRofs5Generic[]    = "ROFS5";
+const TText8  KTocRofs6Generic[]    = "ROFS6";
+const TUint   KNoOfROFSPartitions   = 6;
+
+const TInt    KSectorShift          = 9;
+/**
+TOC access for kernel side clients.
+*/
+class Toc
+    {
+    public:
+        /**
+         *  Search entry in TOC with aName as part of ItemName.
+         *  @return KErrNone if successful 
+         */
+        TInt GetItemByName(const TText8* aName, STocItem& aItem);
+		
+	public:
+		/**	Array for keep whole TOC */
+		STocItem iTOC[KMaxNbrOfTocItems];
+				
+		/** Offset of TOC from beginning*/
+		TUint32  iTocStartSector;
+    };
+
+#endif // __EMMC_TOC_H__
+
--- a/kernel/eka/drivers/medmmc/traces/OstTraceDefinitions.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/medmmc/traces/OstTraceDefinitions.h	Wed Aug 18 11:08:29 2010 +0300
@@ -17,5 +17,5 @@
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
 // REMOVE BEFORE CHECK-IN TO VERSION CONTROL
 //#define OST_TRACE_COMPILER_IN_USE
-#include <OpenSystemTrace.h>
+#include <opensystemtrace.h>
 #endif
--- a/kernel/eka/drivers/pbus/mmc/traces/OstTraceDefinitions.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/pbus/mmc/traces/OstTraceDefinitions.h	Wed Aug 18 11:08:29 2010 +0300
@@ -17,5 +17,5 @@
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
 // REMOVE BEFORE CHECK-IN TO VERSION CONTROL
 //#define OST_TRACE_COMPILER_IN_USE
-#include <OpenSystemTrace.h>
+#include <opensystemtrace.h>
 #endif
--- a/kernel/eka/drivers/resourceman/resourcecontrol.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/resourceman/resourcecontrol.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-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"
@@ -403,6 +403,9 @@
 		//If dyanmic resource is deregistering, send notification to all clients requested for it
 		if((pN->iCallback.iResourceId & KIdMaskDynamic) && (aClientId == KDynamicResourceDeRegistering))
 			{
+			pN->iCallback.iResult=aReturnCode;			
+			pN->iCallback.iMutex = iResourceMutex;
+			pN->iCallback.iPendingRequestCount++;
 			pN->iCallback.iResult = aReturnCode;
 			pN->iCallback.iLevel = aState;
 			pN->iCallback.iClientId = aClientId;
@@ -418,14 +421,19 @@
 				(pN->iDirection && ((pN->iPreviousLevel < pN->iThreshold) && (aState >= pN->iThreshold))) ||
 				(!pN->iDirection && ((pN->iPreviousLevel > pN->iThreshold) && (aState <= pN->iThreshold))))
 			{
-            pN->iCallback.iResult=aReturnCode;
-            pN->iCallback.iLevel=aState;
-            pN->iCallback.iClientId = aClientId;
+			pN->iCallback.iResult=aReturnCode;
+			pN->iCallback.iMutex = iResourceMutex;
+            pN->iCallback.iPendingRequestCount++;			
+			pN->iCallback.iLevel=aState;
+			pN->iCallback.iClientId = aClientId;
 			pN->iCallback.iLevelOwnerId = aLevelOwnerId;
+			
 			__KTRACE_OPT(KRESMANAGER, Kern::Printf("Notifications ClientId = 0x%x, ResourceId = %d, State = %d, Result = %d",
 										pN->iCallback.iClientId, pN->iCallback.iResourceId, aState, aReturnCode));
 			PRM_POSTNOTIFICATION_SENT_TRACE
-            pN->iCallback.Enque();
+
+			pN->iCallback.Enque();
+
 			}
 		pN->iPreviousLevel = aState; //Update the state
 		}
@@ -708,6 +716,8 @@
     TPowerResourceCb* pCb = aReq->ResourceCb();
     if(pCb)
 		{
+        pCb->iMutex = pRC->iResourceMutex;
+        pCb->iPendingRequestCount++;    
         pCb->iResult=aReq->ReturnCode();
         pCb->iLevel=aReq->Level();
         pCb->iResourceId=aReq->ResourceId();
@@ -781,6 +791,8 @@
     TPowerResourceCb* pCb = aReq->ResourceCb();
     if(pCb)
 		{
+        pCb->iMutex = pRC->iResourceMutex;
+        pCb->iPendingRequestCount++;       
         pCb->iResult=aReq->ReturnCode();
         pCb->iLevel=aReq->Level();
         pCb->iResourceId=aReq->ResourceId();
@@ -2475,8 +2487,29 @@
 #endif
 	//Return if the resource is already in that state and client is also the same.
 	if((aNewState == pR->iCachedLevel) && ((TInt)aClientId == pR->iLevelOwnerId))
-		UNLOCK_RETURN(KErrNone);
-
+		{
+		if(aCb)
+			{
+			//Invoke callback function
+            TUint ClientId = aClientId;
+            TUint ResourceId = aResourceId;
+            TInt Level = aNewState;
+            TInt LevelOwnerId = pR->iLevelOwnerId;
+            TInt Result = KErrNone;
+            TAny* Param = aCb->iParam;
+            aCb->iPendingRequestCount++;
+            UnLock();
+            // Call the client specified callback function
+            aCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param);   
+            Lock();
+            aCb->iPendingRequestCount--;
+            if(aCb->iPendingRequestCount == 0)
+                {
+                aCb->iResult = KErrCompletion;
+                }
+			}
+        UNLOCK_RETURN(KErrNone);
+		}
 	
 	PRM_CLIENT_CHANGE_STATE_START_TRACE
 	//If long latency resource requested synchronously from DFC thread 0 Panic
@@ -2616,16 +2649,29 @@
 		    if(aResourceId & KIdMaskDynamic)
 				((DDynamicPowerResource*)pR)->UnLock();
 #endif
-			UnLock();
 			if(aCb)
 				{
-				//Invoke callback function
-				aCb->iCallback(req->ClientId(), aResourceId, req->Level(), pR->iLevelOwnerId, r, aCb->iParam);
-				//Mark the callback object to act properly during cancellation of this request.
-				aCb->iResult = KErrCompletion; 
-				}
+                //Invoke callback function
+                TUint ClientId = req->ClientId();
+                TUint ResourceId = aResourceId;
+                TInt Level = req->Level();
+                TInt LevelOwnerId = pR->iLevelOwnerId;
+                TInt Result = r;
+                TAny* Param = aCb->iParam;
+                aCb->iPendingRequestCount++;
+                UnLock();
+                // Call the client specified callback function
+                aCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param);   
+                Lock();
+                aCb->iPendingRequestCount--;
+                if(aCb->iPendingRequestCount == 0)
+                    {
+                    aCb->iResult = KErrCompletion;
+                    }
+                }
+
 			PRM_CLIENT_CHANGE_STATE_END_TRACE
-			return(r);
+			UNLOCK_RETURN(r);
 			}
 		}
 	else if(pR->iLevelOwnerId == -1)
@@ -2684,16 +2730,29 @@
 	if(aResourceId & KIdMaskDynamic)
 		((DDynamicPowerResource*)pR)->UnLock();
 #endif
-	UnLock();
 	if(aCb)
 		{
-		//Invoke callback function
-		aCb->iCallback(req->ClientId(), aResourceId, req->Level(), pR->iLevelOwnerId, r, aCb->iParam);
-		aCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+        //Invoke callback function
+        TUint ClientId = req->ClientId();
+        TUint ResourceId = aResourceId;
+        TInt Level = req->Level();
+        TInt LevelOwnerId = pR->iLevelOwnerId;
+        TInt Result = r;
+        TAny* Param = aCb->iParam;
+        aCb->iPendingRequestCount++;
+        UnLock();
+        // Call the client specified callback function
+        aCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param);   
+        Lock();
+        aCb->iPendingRequestCount--;
+        if(aCb->iPendingRequestCount == 0)
+            {
+            aCb->iResult = KErrCompletion;
+            }
 		}
 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::ChangeResourceState, Level = %d", req->Level()));
     PRM_CLIENT_CHANGE_STATE_END_TRACE
-    return r;
+    UNLOCK_RETURN(r);
 	}
 
 /**
@@ -2915,14 +2974,28 @@
 	PRM_RESOURCE_GET_STATE_START_TRACE
 	if(aCached) //Call the callback directly
 		{
-		UnLock();
-		aCb.iCallback(aClientId, aResourceId, pR->iCachedLevel, pR->iLevelOwnerId, KErrNone, aCb.iParam);
-		aCb.iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+        //Invoke callback function
+        TUint ClientId = aClientId;
+        TUint ResourceId = aResourceId;
+        TInt Level = pR->iCachedLevel;
+        TInt LevelOwnerId = pR->iLevelOwnerId;
+        TInt Result = KErrNone;
+        TAny* Param = aCb.iParam;
+        aCb.iPendingRequestCount++;
+        UnLock();
+        // Call the client specified callback function
+        aCb.iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param);   
+        Lock();
+        aCb.iPendingRequestCount--;
+        if(aCb.iPendingRequestCount == 0)
+            {
+            aCb.iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+            }
 #ifdef PRM_INSTRUMENTATION_MACRO
 		TInt aState = pR->iCachedLevel;
         PRM_RESOURCE_GET_STATE_END_TRACE
 #endif
-		return(KErrNone);
+		UNLOCK_RETURN(KErrNone);
 		}
 	TPowerRequest* req=NULL;
 	if(pR->LatencyGet())
@@ -2987,10 +3060,25 @@
 		if(aResourceId & KIdMaskDynamic)
 			((DDynamicPowerResource*)pR)->UnLock();
 #endif
-		UnLock();
-		// Call the client callback function directly as it is already executing in the context of client thread.
-		aCb.iCallback(aClientId, aResourceId, req->Level(), pR->iLevelOwnerId, r, aCb.iParam);
-		aCb.iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+
+        //Invoke callback function
+        TUint ClientId = aClientId;
+        TUint ResourceId = aResourceId;
+        TInt Level = req->Level();
+        TInt LevelOwnerId = pR->iLevelOwnerId;
+        TInt Result = r;
+        TAny* Param = aCb.iParam;
+        aCb.iPendingRequestCount++;
+        UnLock();
+        // Call the client specified callback function
+        aCb.iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param);   
+        Lock();
+        aCb.iPendingRequestCount--;
+        if(aCb.iPendingRequestCount == 0)
+            {
+            aCb.iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+            }       
+        UnLock(); 
 		}
 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::GetResourceState(asynchronous), Level = %d", req->Level()));
 	if(pR->LatencyGet())
--- a/kernel/eka/drivers/usbcsc/d_usbcsc.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/usbcsc/d_usbcsc.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2000-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"
@@ -98,7 +98,6 @@
 
 TUsbcScChunkInfo::TUsbcScChunkInfo(DLogicalDevice* aLdd)
 	: 	iChunk(NULL),
-		iCleanup((TDfcFn)&DfcChunkCleanup,this,Kern::SvMsgQue(),0),
 		iChunkMem(NULL),
 		iLdd(aLdd)
 	{
@@ -121,7 +120,7 @@
 		chunkInfo.iMaxSize = aTotalSize;
 		chunkInfo.iMapAttr = EMapAttrCachedMax;
 		chunkInfo.iOwnsMemory = EFalse;
-		chunkInfo.iDestroyedDfc = &iCleanup;
+		chunkInfo.iDestroyedDfc = NULL;
 
 		TLinAddr chunkMem;
 		r = Kern::ChunkCreate(chunkInfo, iChunk, chunkMem, iChunkMapAttr);
@@ -138,7 +137,14 @@
 // Note that nothing may happen immediately, as something else may have the chunk open.
 void TUsbcScChunkInfo::Close()
 {
-	Kern::ChunkClose(iChunk);	
+	__KTRACE_OPT(KUSB, Kern::Printf("TUsbcScChunkInfo::Close %d", iChunk->AccessCount()));
+
+	if (Kern::ChunkClose(iChunk))
+        {
+		__KTRACE_OPT(KUSB, Kern::Printf("TUsbcScChunkInfo::Close1"));
+         ChunkCleanup();    
+		__KTRACE_OPT(KUSB, Kern::Printf("TUsbcScChunkInfo::Close2"));
+        }
 }
 
 
@@ -342,6 +348,19 @@
 		}
 }
 
+
+TBool TUsbcScBuffer::IsRequestPending()
+	{
+		return iStatusList.IsRequestPending();
+	}
+
+TBool TUsbcScStatusList::IsRequestPending()
+	{
+		return (iLength != 0);
+	}
+
+
+
 /*
 TUsbcScBuffer::StartEndpoint
 
@@ -881,6 +900,13 @@
 	iHead = ((iHead+1) & (iSize-1));
 	}
 
+
+void TUsbcScStatusList::SetClient(DThread& aThread)
+	{
+	iClient = &aThread;
+	}
+
+
 // End TUsbcScStatusList
 
 /*****************************************************************************\
@@ -1240,12 +1266,14 @@
 	if (iRealizeCalled)
 		{
 		// Close Chunk
+		__KTRACE_OPT(KUSB, Kern::Printf("iChunkInfo->Close()"));
 		iChunkInfo->Close();
 		// ChunkInfo will delete itself with DFC, but the pointer here is no longer needed.		
 		iChunkInfo=NULL;
 		}
 	__KTRACE_OPT(KUSB, Kern::Printf("about to SafeClose"));
 	Kern::SafeClose((DObject*&)iClient, NULL);
+	__KTRACE_OPT(KUSB, Kern::Printf("about to SafeClose1"));
 	}
 
 
@@ -1326,6 +1354,13 @@
 		}
 
 	TInt r;
+
+	if (aMsg->Client() != iClient)
+		{
+		m.Complete(KErrAccessDenied, ETrue);
+		return;
+		}
+	
 	if (id < 0)
 		{
 		// DoRequest
@@ -2255,18 +2290,50 @@
 TInt DLddUsbcScChannel::RequestUserHandle(DThread* aThread, TOwnerType /*aType*/)
 	{
 	__KTRACE_OPT(KUSB, Kern::Printf("DLddUsbcScChannel::RequestUserHandle"));
-	// The USB client LDD is not designed for a channel to be shared between
-	// threads. It saves a pointer to the current thread when it is opened, and
-	// uses this to complete any asynchronous requests.
-	// It is therefore not acceptable for the handle to be duplicated and used
-	// by another thread:
+	// The USB client LDD can share across process, but can't use simultanously. 
+	// This mean if transfer the handle to another process, can't access this channel
+	// in the origin process and any call to the channel will return with KErrAccessDenied.
+	// If there is async request scheduled, can't transfer channel handle to another process
+	// and return KErrAccessDenied. 
 	if (aThread == iClient)
 		{
 		return KErrNone;
 		}
 	else
 		{
-		return KErrAccessDenied;
+		//check if async request has been called
+		for (TInt i = 1; i < KUsbcMaxRequests; i++)
+			{
+			if (iRequestStatus[i] != NULL)
+				{
+				return KErrAccessDenied;
+				}
+			}
+
+		if (iBuffers)
+			{
+			for (TInt i=0; i<(iNumBuffers+2); i++) 
+				{
+				if (iBuffers[i].IsRequestPending())
+					{
+					return KErrAccessDenied;	
+					}
+				}
+			}
+		
+		
+		Kern::SafeClose((DObject*&)iClient, NULL);
+		iClient = aThread;
+		iClient->Open();
+		if (iBuffers)
+			{
+			for (TInt i=0; i<(iNumBuffers+2); i++) 
+				{
+				iBuffers[i].iStatusList.SetClient(*iClient);
+				}
+			}
+		__KTRACE_OPT(KUSB, Kern::Printf("DLddUsbcScChannel::handle %d", iChunkInfo->iChunk->AccessCount()));
+		return KErrNone;
 		}
 	}
 
--- a/kernel/eka/drivers/usbcsc/usbcsc_bil.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/drivers/usbcsc/usbcsc_bil.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -38,6 +38,31 @@
 	return r;
 	}
 
+// empty a endpoint buffer, this is called when device state enter undefined
+TInt RDevUsbcScClient::Empty(TUint aBufferOffset)
+{
+	TUint8* base = iSharedChunk.Base();
+	SUsbcScBufferHeader* endpointHdr = (SUsbcScBufferHeader*) (aBufferOffset + base);
+	TUint localTail = endpointHdr->iBilTail;
+	TUsbcScTransferHeader* currentTransfer;
+	TInt err=KErrNone;
+
+	while (ETrue)
+		{
+		if (localTail == (TUint) endpointHdr->iHead)
+			{
+			err = KErrNone;			
+			break;
+			}
+		currentTransfer = (TUsbcScTransferHeader*) (base + localTail);
+		localTail = currentTransfer->iNext;
+		} // end while
+	endpointHdr->iBilTail = localTail;
+	endpointHdr->iTail = localTail;
+	return err;
+}
+
+
 
 EXPORT_C TInt RDevUsbcScClient::FinalizeInterface(RChunk*& aChunk)
 	{
@@ -49,6 +74,35 @@
 	}
 
 
+EXPORT_C void RDevUsbcScClient::ResetAltSetting()
+	{
+	if (iAlternateSetting == 0)
+		return;
+	TUsbcScChunkHeader chunkHeader(iSharedChunk);
+	
+	TInt ep;
+	TInt noEp;
+	TUint bufOff;
+	TUsbcScHdrEndpointRecord* endpointInf = NULL;
+
+	// check if alternate setting contains all IN endpoints
+	noEp = chunkHeader.GetNumberOfEndpoints(iAlternateSetting);
+
+	// for each used buffer. 
+	for (ep=1;ep<=noEp;ep++)
+		{
+		bufOff = chunkHeader.GetBuffer(iAlternateSetting,ep,endpointInf)->Offset();	
+	
+		if (endpointInf->Direction() & KUsbScHdrEpDirectionOut) 
+			{
+			Empty(bufOff); // we need to remove anythng in the way, and get it ready for reading.
+			}
+		}
+	
+	iAlternateSetting = 0;
+	}
+
+
 EXPORT_C TInt RDevUsbcScClient::OpenEndpoint(TEndpointBuffer& aEpB, TInt aEpI)
 	{
 	TUsbcScHdrEndpointRecord* endpointInf = NULL;
@@ -118,12 +172,14 @@
  
 TInt RDevUsbcScClient::Drain(TUint aBufferOffset)
 {
+
 	TUint8* base = iSharedChunk.Base();
 	SUsbcScBufferHeader* endpointHdr = (SUsbcScBufferHeader*) (aBufferOffset+base);
 	TUint localTail = endpointHdr->iBilTail;
 	TUsbcScTransferHeader* currentTransfer;
 	TUint16 next = (iAltSettingSeq+1)&0xFFFF;
 	TInt err=KErrNone;
+	TBool aZLP;
 
 	while (ETrue)
 		{
@@ -135,8 +191,13 @@
 		currentTransfer = (TUsbcScTransferHeader*) (base + localTail);
 
 		if (currentTransfer->iAltSettingSeq == next)
-			{
+			{			
 			iNewAltSetting=currentTransfer->iAltSetting; // record new alt setting
+			aZLP = (currentTransfer->iFlags & KUsbcScShortPacket)!=EFalse;
+			if ((currentTransfer->iBytes==0) && (!aZLP)) // take empty packet which is for alternate setting change
+				{
+				localTail = currentTransfer->iNext;
+				}
 			break;
 			}
 		else
@@ -164,7 +225,7 @@
 		// if alternate setting has not changed
 		return KErrNotReady;
 	else
-		{
+		{		
 		iNewAltSetting=currentTransfer->iAltSetting;
 		return KErrNone;
 		}
@@ -405,6 +466,7 @@
 
 	TUsbcScTransferHeader* currentTransfer;
 	TInt r;
+	TInt aBilTail;
 	do // until we have a transfer with data.
 		{
 		iEndpointHdr->iTail = iEndpointHdr->iBilTail; 
@@ -415,19 +477,22 @@
 				return r;
 			}
 		currentTransfer = (TUsbcScTransferHeader*) (iBaseAddr + iEndpointHdr->iBilTail);
-
+		aBilTail = iEndpointHdr->iBilTail;
 		iEndpointHdr->iBilTail = currentTransfer->iNext;
 		aZLP = (currentTransfer->iFlags & KUsbcScShortPacket)!=EFalse;
 
 		if(currentTransfer->iAltSettingSeq != (iClient->iAltSettingSeq))  // if alternate setting has changed
 			{
 			if (currentTransfer->iAltSettingSeq == (iClient->iAltSettingSeq+1))	   //Note- KIS ATM, if multiple alternate setting changes happen
+				{
 				iClient->iNewAltSetting = currentTransfer->iAltSetting; //before StartNextOutAlternateSetting is called, 		   
-																	   //this variable will reflect the latest requested AlternateSetting
+																	   //this variable will reflect the latest requested AlternateSetting		
+				}													   
 
 
 			if (iEndpointNumber != KEp0Number)
 				{
+				iEndpointHdr->iBilTail = aBilTail;
 //				iOutState =  EEOF;	
 				return KErrEof;
 				}
@@ -450,8 +515,10 @@
 	if (iOutState)
 		return iOutState;
 
+
 	TUsbcScTransferHeader* currentTransfer;
 	TInt r;
+	TInt aBilTail;
 	do // until we have a transfer with data.
 		{
 		if(iEndpointHdr->iBilTail == iEndpointHdr->iHead)  //If no new data, create request
@@ -464,6 +531,7 @@
 			}
 
 		currentTransfer = (TUsbcScTransferHeader*) (iBaseAddr + iEndpointHdr->iBilTail);
+		aBilTail = iEndpointHdr->iBilTail;
 		iEndpointHdr->iBilTail = currentTransfer->iNext;
 		aZLP = (currentTransfer->iFlags & KUsbcScShortPacket)!=EFalse; // True if short packet else false 
 
@@ -472,16 +540,19 @@
 			if (currentTransfer->iAltSettingSeq == (iClient->iAltSettingSeq+1))	   //Note- KIS ATM, if multiple alternate setting changes happen
 				iClient->iNewAltSetting = currentTransfer->iAltSetting; //before StartNextOutAlternateSetting is called, 		   
 																	   //this variable will reflect the latest requested AlternateSetting
-			Expire(currentTransfer->iData.i);
+			
 			if (iEndpointNumber != KEp0Number)
 				{
+				iEndpointHdr->iBilTail = aBilTail;
 //				iOutState = EEOF;
 				return KErrEof;
 				}
 			else if ((currentTransfer->iBytes==0) && (!aZLP)) 
 				{
+				Expire(currentTransfer->iData.i);
 				return KErrAlternateSettingChanged;
 				}
+			Expire(currentTransfer->iData.i);
 
 			}	
 
@@ -523,11 +594,12 @@
 
 	TInt prevTail = NULL;
 	TBool found = EFalse;
+	
 	while (currentTail != iEndpointHdr->iBilTail)
-		{
+		{			
 		TUsbcScTransferHeader* currentTransfer = (TUsbcScTransferHeader*) (iBaseAddr + currentTail);
 		if (currentTail == offsetToExpire)		// found which to expire
-			{
+			{			
 			found = ETrue;
 			// This offset is to be expired
 			if (prevTail == NULL)
@@ -547,7 +619,7 @@
 			}
 		prevTail = currentTail;
 		currentTail = currentTransfer->iNext;
-		}
+		}	
 	return found ? KErrNone : KErrNotFound;
 	}
 
--- a/kernel/eka/eabi/usbcscu.def	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/eabi/usbcscu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -20,4 +20,5 @@
 	_ZN15TEndpointBuffer10TakeBufferERPvRjRiR14TRequestStatusj @ 19 NONAME
 	_ZN15TEndpointBuffer6ExpireEv @ 20 NONAME
 	_ZN15TEndpointBuffer6ExpireEPv @ 21 NONAME
+	_ZN16RDevUsbcScClient15ResetAltSettingEv @ 22 NONAME
 
--- a/kernel/eka/ewsrv/ky_capt.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/ewsrv/ky_capt.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1996-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"
@@ -41,6 +41,10 @@
 	iCKarray.Close();
 	}
 
+/**
+@note This function can Leave and does not obey the
+coding standard
+*/
 void CCaptureKeys::CheckCaptureKey(const TCaptureKey& aCaptureKey)
 	{
 
@@ -69,6 +73,10 @@
 	User::LeaveIfError(iCKarray.Insert(captureKey,0));
 	}
 
+/**
+@note This function can Leave and does not obey the
+coding standard
+*/
 EXPORT_C void CCaptureKeys::SetCaptureKey(TUint32 aHandle, const TCaptureKey& aCaptureKey)
 //
 // Finds the first capture-key from the list that matches the handle and sets
@@ -79,6 +87,10 @@
 	SetCaptureKey(aHandle,aCaptureKey,0);
 	}
 
+/**
+@note This function can Leave and does not obey the
+coding standard
+*/
 EXPORT_C void CCaptureKeys::SetCaptureKey(TUint32 aHandle, const TCaptureKey& aCaptureKey, TUint8 aPriority)
 //
 // Finds the first capture-key from the list that matches the handle and sets
@@ -96,15 +108,6 @@
 		iCKarray[r]=captureKey;
 	}
 
-void CCaptureKeys::removeCaptureKey(TUint aIndex)
-//
-// Removes the capture-key at the given aIndex from the list
-//
-	{
-
-	iCKarray.Remove(aIndex);
-	}
-
 EXPORT_C void CCaptureKeys::CancelCaptureKey(TUint32 aHandle)
 //
 // Removes the first capture-key from the list that matches the handle;
--- a/kernel/eka/ewsrv/ky_tran.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/ewsrv/ky_tran.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1996-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"
@@ -23,8 +23,21 @@
 #include <e32keys.h>
 #include <e32uid.h>
 
-enum	{EDummy,EKeyDataConv,EKeyDataFunc,EKeyDataSettings};
-  
+/**
+Ordinals of the functions which keymap dlls export.
+
+@note These values depend on the ordering of the exports.
+If the existing def files were ever re-frozen, it would
+lead to a runtime error.
+*/
+enum
+	{
+	EDummy,
+	EKeyDataConv, ///< Access conversion tables, signature TLibFnDataConv
+	EKeyDataFunc, ///< Access function tables, signature TLibFnDataFunc
+	EKeyDataSettings ///< Access data needed for control code entry @see TCtrlDigits, signature TLibFnDataSetting
+	};
+
 EXPORT_C CKeyTranslator* CKeyTranslator::New()
 //
 // Return the actual key translator
@@ -482,7 +495,9 @@
 //
 typedef void (*TLibFnDataConv)(SConvTable &aConvTable, TUint &aConvTableFirstScanCode,TUint &aConvTableLastScanCode,
 							   SScanCodeBlockList &aKeypadScanCode,SKeyCodeList &aNonAutorepKeyCodes);
-//
+/**
+Populates the object with conversion table data from aLibrary
+*/
 void TConvTable::Update(RLibrary aLibrary)
 #pragma warning (disable: 4705)
 	{
--- a/kernel/eka/include/cpudefs.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/cpudefs.h	Wed Aug 18 11:08:29 2010 +0300
@@ -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/d32camerasc.h	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,711 +0,0 @@
-// Copyright (c) 2008-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\include\d32camerasc.h
-// User side class definition for the shared chunk camera driver.
-// 
-//
-
-/**
- @file
- @internalAll
- @prototype
-*/
-
-#ifndef __D32CAMERASC_H__
-#define __D32CAMERASC_H__
-
-#include <e32cmn.h>
-#include <e32ver.h>
-#include <pixelformats.h>
-
-_LIT(KDevCameraScName,"CameraSc");
-
-/**
-Camera capability constants - bitmasks of possible flash modes. @see TCameraCapsV02.
-*/
-/** Flash will automatically fire when required. */
-const TUint KCamFlashAuto = 0x0001;
-/** Flash will always fire. */
-const TUint KCamFlashForced = 0x0002;
-/** Reduced flash for general lighting */
-const TUint KCamFlashFillIn = 0x0004;
-/** Red-eye reduction mode. */
-const TUint KCamFlashRedEyeReduce = 0x0008;
-/** Flash at the moment when shutter opens. */
-const TUint KCamFlashSlowFrontSync = 0x0010;
-/** Flash at the moment when shutter closes. */
-const TUint KCamFlashSlowRearSync = 0x0020;
-/** User configurable setting */
-const TUint KCamFlashManual = 0x0040;
-
-/**
-Camera capability constants - bitmasks of possible exposure modes. @see TCameraCapsV02.
-*/
-/** Night-time setting for long exposures. */
-const TUint KCamExposureNight = 0x0001;
-/** Backlight setting for bright backgrounds. */
-const TUint KCamExposureBacklight = 0x0002;
-/** Centered mode for ignoring surroundings. */
-const TUint KCamExposureCenter = 0x0004;
-/** Sport setting for very short exposures. */
-const TUint KCamExposureSport = 0x0008;
-/** Generalised setting for very long exposures. */
-const TUint KCamExposureVeryLong = 0x0010;
-/** Snow setting for daylight exposure. */
-const TUint KCamExposureSnow = 0x0020;
-/** Beach setting for daylight exposure with reflective glare. */
-const TUint KCamExposureBeach = 0x0040;
-/** Programmed exposure setting. */
-const TUint KCamExposureProgram = 0x0080;
-/** Aperture setting is given priority. */
-const TUint KCamExposureAperturePriority = 0x0100;
-/** Shutter speed setting is given priority. */
-const TUint KCamExposureShutterPriority = 0x0200;
-/** User selectable exposure value setting. */
-const TUint KCamExposureManual = 0x0400;
-/** Exposure night setting with colour removed to get rid of colour noise. */
-const TUint KCamExposureSuperNight = 0x0800;
-/** Exposure for infra-red sensor on the camera */
-const TUint KCamExposureInfra = 0x1000;
-
-/**
-Camera capability constants - bitmasks of possible white balance modes. @see TCameraCapsV02.
-*/
-/** Normal daylight. */
-const TUint KCamWBDaylight = 0x0001;
-/** Overcast daylight. */
-const TUint KCamWBCloudy = 0x0002;
-/** Tungsten filament lighting. */
-const TUint KCamWBTungsten = 0x0004;
-/** Fluorescent tube lighting */
-const TUint KCamWBFluorescent = 0x0008;
-/** Flash lighting. */
-const TUint KCamWBFlash = 0x0010;
-/** High contrast daylight primarily snowy */
-const TUint KCamWBSnow = 0x0020;
-/** High contrast daylight primarily near the sea */
-const TUint KCamWBBeach = 0x0040;
-/** User configurable mode */
-const TUint KCamWBManual = 0x0080;
-
-/**
-Camera capability constants - bitmasks of other miscellaneous camera capabilities supported. @see TCameraCapsV02.
-*/
-/** The camera has zoom capability. */
-const TUint KCamMiscZoom = 0x0001;
-/** The camera supports contrast adjustment. */
-const TUint KCamMiscContrast = 0x0002;
-/** The camera supports brightness adjustment. */
-const TUint KCamMiscBrightness = 0x0004;
-/** The camera supports color effect adjustment. */
-const TUint KCamMiscColorEffect = 0x0008;
-
-
-/**
-Enumeration of capture modes in which to run the sensor.
-*/
-enum TDevCamCaptureMode
-	{
-	/** Used to specify that still image mode is to be used. */
-	ECamCaptureModeImage,
-	/** Used to specify that streaming video mode is to be used. */
-	ECamCaptureModeVideo,
-	/** Used to specify that streaming viewfinder mode is to be used. */
-	ECamCaptureModeViewFinder,
-	/** The last value here, helps keep track of the number of capture modes. */
-	ECamCaptureModeMax
-	};
-
-/**
-Enumeration of camera flash modes. @see TCameraConfigV02.
-*/
-enum TDevCamFlashMode
-	{
-	/** No flash, always supported. */
-	ECamFlashNone=0x0000,
-	/** Flash will automatically fire when required. */
-	ECamFlashAuto=0x0001,
-	/** Flash will always fire. */
-	ECamFlashForced=0x0002,
-	/** Reduced flash for general lighting */
-	ECamFlashFillIn=0x0004,
-	/** Red-eye reduction mode. */
-	ECamFlashRedEyeReduce=0x0008,
-	/** Flash at the moment when shutter opens. */
-	ECamFlashSlowFrontSync=0x0010,
-	/** Flash at the moment when shutter closes. */
-	ECamFlashSlowRearSync=0x0020,
-	/** User configurable setting */
-	ECamFlashManual=0x0040
-	};
-
-/**
-Enumeration of camera exposure modes. @see TCameraConfigV02.
-*/
-enum TDevCamExposureMode
-	{
-	/** Set exposure automatically. Default, always supported. */
-	ECamExposureAuto=0x0000,
-	/** Night-time setting for long exposures. */
-	ECamExposureNight=0x0001,
-	/** Backlight setting for bright backgrounds. */
-	ECamExposureBacklight=0x0002,
-	/** Centered mode for ignoring surroundings. */
-	ECamExposureCenter=0x0004,
-	/** Sport setting for very short exposures. */
-	ECamExposureSport=0x0008,
-	/** Generalised setting for very long exposures. */
-	ECamExposureVeryLong=0x0010,
-	/** Snow setting for daylight exposure. */
-	ECamExposureSnow=0x0020,
-	/** Beach setting for daylight exposure with reflective glare. */
-	ECamExposureBeach=0x0040,
-	/** Programmed exposure setting. */
-	ECamExposureProgram=0x0080,
-	/** Aperture setting is given priority. */
-	ECamExposureAperturePriority=0x0100,
-	/** Shutter speed setting is given priority. */
-	ECamExposureShutterPriority=0x0200,
-	/** User selectable exposure value setting. */
-	ECamExposureManual=0x0400,
-	/** Exposure night setting with colour removed to get rid of colour noise. */
-	ECamExposureSuperNight=0x0800,
-	/** Exposure for infra-red sensor on the camera */
-	ECamExposureInfra=0x1000
-	};
-
-/**
-Enumeration of camera white balance modes. @see TCameraConfigV02.
-*/
-enum TDevCamWhiteBalanceMode
-	{
-	/** Set white balance automatically. Default, always supported. */
-	ECamWBAuto=0x0000,
-	/** Normal daylight. */
-	ECamWBDaylight=0x0001,
-	/** Overcast daylight. */
-	ECamWBCloudy=0x0002,
-	/** Tungsten filament lighting. */
-	ECamWBTungsten=0x0004,
-	/** Fluorescent tube lighting */
-	ECamWBFluorescent=0x0008,
-	/** Flash lighting. */
-	ECamWBFlash=0x0010,
-	/** High contrast daylight primarily snowy */
-	ECamWBSnow=0x0020,
-	/** High contrast daylight primarily near the sea */
-	ECamWBBeach=0x0040,
-	/** User configurable mode */
-	ECamWBManual=0x0080
-	};
-
-/**
-Enumeration of possible directions in which the camera may point. @see TCameraCapsV02.
-*/
-enum TDevCamOrientation
-	{
-	/** Outward pointing camera for taking pictures. Camera is directed away from the user. */
-	ECamOrientationOutwards,
-	/** Inward pointing camera for conferencing. Camera is directed towards the user. */
-	ECamOrientationInwards,
-	/** Mobile camera capable of multiple orientations. Camera orientation may be changed by the user. */
-	ECamOrientationMobile,
-	/** Camera orientation is not known. */
-	ECamOrientationUnknown
-	};
-
-/**
-Each item in the iPixelFormatSupported array is represented by an instance of this structure.
-*/
-struct SDevCamPixelFormat
-	{
-	/** The UID of the pixel format supported */
-	TUidPixelFormat iPixelFormat;
-	/** The number of frame sizes represented by the pixel format. */
-	TUint iNumFrameSizes;
-	/** The pixel width in number of bytes */
-	TUint iPixelWidthInBytes;
-	};
-
-/**
-Each frame size supported is represented by an instance of this structure.
-*/
-struct SDevCamFrameSize
-	{
-	/** Width of the frame in pixels. */
-	TUint iWidth;
-	/** Height of the frame in pixels. */
-	TUint iHeight;
-	/** Minimum frame rate supported by this frame size. */
-	TUint iMinFrameRate;
-	/** Maximum frame rate supported by this frame size. */
-	TUint iMaxFrameRate;
-	};
-
-/**
-Lets us associate buffers to their mode when working out the buffer offset in a chunk.
-**/
-class TDevCamBufferModeAndId
-	{
-public:
-	TDevCamCaptureMode iCaptureMode;
-	TInt iId;
-	};
-typedef TPckgBuf<TDevCamBufferModeAndId> TDevCamBufferModeAndIdBuf;
-
-/**
-The general driver capabilites class - returned by the LDD factory in response to RDevice::GetCaps().
-*/
-class TCapsDevCameraV01
-	{
-public:
-	TVersion iVersion;
-	};
-
-/**
-Defines a list of settings that are changable often (dynamically) within a single use of the device.
-*/
-enum TDevCamDynamicAttribute
-	{
-	ECamAttributeBrightness,
-	ECamAttributeContrast,
-	ECamAttributeColorEffect,
-	ECamAttributeMax
-	};
-
-/**
-Holds the range and interval (rate of change) values for a dynamic capability.
-An array of these would be indexed by TDevCamDynamicAttribute
-*/
-struct TDynamicRange
-	{
-	TUint iMin;
-	TUint iMax;
-	TUint iDefault;
-	};
-
-/**
-The main camera capabilities class. This is used to get the capabilities of a specific camera
-device once a channel to it has been opened.
-*/
-class TCameraCapsV02
-	{
-public :
-	/** The flash modes supported - a bit field. */
-	TUint iFlashModes;
-	/** The exposure modes supported - a bit field. */
-	TUint iExposureModes;
-	/** The white balance modes supported - a bit field. */
-	TUint iWhiteBalanceModes;
-	/** The orientation of the camera device. */
-	TDevCamOrientation iOrientation;
-	/** The minimum value that may be set for the zoom factor. Must be negative or zero. Negative values
-	represent macro functionality. @see TCameraCapsV02::iCapsMisc. @see TCameraConfigV02::iZoom. */
-	TUint iMinZoom;
-	/** The maximum value that may be set for the zoom factor. Must be positive or zero.
-	@see TCameraCapsV02::iCapsMisc. @see TCameraConfigV02::iZoom. */
-	TUint iMaxZoom;
-	/** Whether other miscellaneous capabilities are supported - a bitfield. These
-	capabilities include whether the device supports simultaneous capture modes, zoom capabilities, contrast
-	adjustment, brightness, and color effect adjustment. */
-	TUint iCapsMisc;
-	/** Number of pixel formats supported in still image capture mode.
-	Will be set to 0 if image capture is not supported. */
-	TUint iNumImagePixelFormats;
-	/** Number of pixel formats supported in video capture mode.
-	Will be set to 0 if image capture is not supported. */
-	TUint iNumVideoPixelFormats;
-	/** Number of pixel formats supported in view finder capture mode.
-	Will be set to 0 if image capture is not supported. */
-	TUint iNumViewFinderPixelFormats;
-	
-	/** An array specifying the range in values for settings as defined by TDevCamDynamicAttribute.
-		Indices for settings are in the order defined in TDevCamDynamicAttribute.
-		If the setting is not supported then the entry is still present for performance reasons,
-		i.e. indexing over searching.
-		@see TDevCamDynamicAttribute
-		@see TDynamicRange
-	*/
-	TDynamicRange iDynamicRange[ECamAttributeMax];
-	
-	/** A variable length array specifying the pixel formats supported by the sensor.
-		The size of the TCameraCapsV02 structure is determined by each sensor's capabilities
-		thus the array of supported pixel formats is of variable length. It is stored in memory
-		exactly after TCameraCapsV02 whenever memory is allocated for it and the array cannot be
-		accessed by a private member.
-	SDevCamPixelFormat iPixelFormatsSupported[];
-	*/
-	};
-
-typedef TPckgBuf<TCameraCapsV02> TCameraCapsV02Buf;
-
-/**
-The camera configuration class. This is used to get and set the current
-configuration of the camera. @see SDevCamFrameSize and @see SDevCamPixelFormat.
-*/
-class TCameraConfigV02
-	{
-public:
-	/** The size of the image to get from the sensor. */
-	SDevCamFrameSize iFrameSize;
-	/** The pixel format (RGB, YUV, RGB Bayer etc). */
-	SDevCamPixelFormat iPixelFormat;
-	/** The frame rate (in frame/s). */
-	TUint iFrameRate;
-	/** The flash mode setting. */
-	TDevCamFlashMode iFlashMode;
-	/** The exposure mode setting. */
-	TDevCamExposureMode iExposureMode;
-	/** The white balance mode setting. */
-	TDevCamWhiteBalanceMode iWhiteBalanceMode;
-	/** The zoom factor. Can be zero, positive or negative, Negative values represent macro functionality.*/
-	TInt iZoom;
-	/** Specifies the number of bytes used to store one pixel's worth of data. */
-	TInt iPixelWidthInBytes;
-	};
-typedef TPckgBuf<TCameraConfigV02> TCameraConfigV02Buf;
-
-/** A structure used to assemble arguments for the function RDevCameraSc::SetBufConfigChunkOpen() and to pass
-these to the driver. */
-struct SSetBufConfigChunkOpenInfo
-	{
-	const TDesC8* iBufferConfigBuf;
-	TInt iChunkHandle;
-	};
-
-/** A structure used to assemble arguments for the function RDevCameraSc::FrameSizeCaps() and to pass
-these to the driver. */
-struct SFrameSizeCapsInfo
-	{
-	TUidPixelFormat iUidPixelFormat;
-	TDevCamCaptureMode iCaptureMode;
-	};
-
-/**
-The camera device driver API supporting shared chunks. This is the principle interface to communicate with
-an attached camera.
-*/
-class RDevCameraSc : public RBusLogicalChannel
-	{
-public:
-	enum TRequest
-	/**
-	 Asynchronous request types
-	*/
-		{
-		EMsgRequestMax=3,				// All requests less than this value are handled in the driver DFC thread.
-		ERequestNotifyNewImage,
-		ENumRequests,
-		EAllRequests = (1<<ENumRequests)-1
-		};
-
-	enum TControl
-	/**
-	 Synchronous request types
-	*/
-		{
-		EControlSetBufConfigChunkCreate,
-		EControlSetBufConfigChunkOpen,
-		EControlStart,
-		EControlStop,
-		EControlSetCamConfig,
-		EControlSetCaptureMode,
-		EControlChunkClose,
-		EMsgControlMax=100,				// All requests less than this value are handled in the driver DFC thread.
-		EControlCaps,
-		EControlGetCamConfig,
-		EControlGetBufferConfig,
-		EControlReleaseBuffer,
-		EControlNotifyNewImageSpecificCancel,
-		EControlBufferIdToOffset,
-		EControlCapsSize,
-		EControlFrameSizeCaps,
-		EControlSetDynamicAttribute,
-		EControlGetDynamicAttribute
-		};
-
-public:
-	/**
-	Get the version number of camera driver interface.
-	@return The camera driver interface version number.
-	*/
-	inline static TVersion VersionRequired();
-
-#ifndef __KERNEL_MODE__
-	
-	/**
-	 Constructor.
-	 Initialises private members.
-	 */
-	inline RDevCameraSc();
-	
-	/**
-	Open a channel on a specified camera device. This driver only allows one channel to be opened on each device.
-	@param aUnit The unit number of the camera device.
-	@return KErrNone, if successful;
-			KErrInUse, if a channel is already opened on the unit concerned;
-			otherwise one of the other system-wide error codes.
-	*/
-	inline TInt Open(TInt aUnit);
-
-	/**
-	Close the Channel and clean up.
-	*/
-	inline void Close();
-
-	/**
-	Get the capabilities of the camera device.
-	@param aCapsBuf A packaged TCameraCapsV02 object which on return will be filled with the capabilities of the device.
-	@return KErrNone, if successful;
-			KErrArgument, if aCapsBuf is too small.
-	@see TCameraCapsV02.
-	*/
-	inline TInt Caps(TDes8& aCapsBuf);
-
-	/**
-	Get the capabilities of the camera device.
-	@return TPtrC8 pointing to a locally held TCameraCapsV02 structure owned by the driver.
-	@see TCameraCapsV02.
-	*/
-	inline TPtrC8 Caps();
-
-	/**
-	Set the camera configuration settings.
-	@param aCaptureMode	The capture mode that camera will be configured for.
-	@param aConfigBuf	A packaged TCameraConfigV02 object which contains the configuration settings.
-	@see TCameraConfigV02.
-	*/
-	inline TInt SetCamConfig(TDevCamCaptureMode aCaptureMode, const TDesC8& aConfigBuf);
-
-	/**
-	Trigger the buffer allocation and configuration setting - creating a shared chunk.
-	From the frame size, pixel format (already supplied) and the number of camera buffers specified,
-	the driver will	calculate the size of the shared chunk this requires. It will create such
-	a shared chunk containing the specified number of buffers within it (each with memory committed to them).
-	This will replace a previous shared chunk created by this driver.
-	A handle to the chunk will then be created for the client thread which will be assigned to the
-	RChunk object supplied by the client.The configuration cannot be changed unless image capture is disabled.
-	@param aCaptureMode	The capture mode that camera will be configured for.
-	@param aNumBuffers	The desired number of buffers that is going to be used.
-	@param aChunk		An RChunk object to which the chunk handle will be assigned.
-	@return KErrNone if successful;
-			KErrInUse if image capturing is already in progress;
-			KErrArgument if any configuration values are invalid;
-			KErrNoMemory if the driver failed allocate memory for the shared chunk specified;
-			otherwise one of the other system-wide error codes.
-	*/
-	inline TInt SetBufConfigChunkCreate(TDevCamCaptureMode aCaptureMode, TInt aNumBuffers, RChunk& aChunk);
-
-	/**
-	Get the current camera configuration settings.
-	@param aCaptureMode	The capture mode that the user requested the configuration settings of.
-	@param aConfigBuf	A packaged TCameraConfigV02 object which will be filled with the configuration settings.
-	@see TCameraConfigV02.
-	*/
-	inline void GetCamConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf);
-
-	/**
-	Get the current buffer configuration settings.
-	@param aCaptureMode	The capture mode that the configuration request is for.
-	@param aConfigBuf	A packaged TSharedChunkBufConfigBase derived object which will be filled with the configuration settings.
-	@see TSharedChunkBufConfigBase.
-	*/
-	inline void GetBufferConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf);
-
-	/**
-	Set the current buffer configuration settings - using an existing shared chunk.
-	The client supplies an existing shared chunk which is to be used by the driver as the play buffer.
-	Any shared chunk previously created by the driver will be closed by it.
-	The configuration cannot be changed unless image capture is disabled.
-	@param aCaptureMode	The capture mode that the configuration is for.
-	@param aBufferConfigBuf	A packaged TSharedChunkBufConfigBase derived object holding information on the buffer configuration
-							settings of the chunk supplied.
-	@param aChunk			A handle to the shared chunk which is to be used as the buffer. (This must be a
-							valid handle for the calling thread).
-	@return KErrNone if successful;
-			KErrInUse if the playing of data is in progress;
-			KErrBadHandle if the chunk handle was invalid;
-			KErrArgument if any configuration values are invalid;
-			otherwise one of the other system-wide error codes.
-	@see TCameraConfigV02.
-	*/
-	inline TInt SetBufConfigChunkOpen(TDevCamCaptureMode aCaptureMode, const TDesC8& aBufferConfigBuf, RChunk& aChunk);
-
-	/**
-	Closes the chunk associated with a given capture mode, and frees the associated buffers.  The chunk being closed,
-	should have been allocated by the device driver by a call to SetBufConfigChunkCreate().
-	@param aCaptureMode The capture mode for which to close the chunk.
-	@return	KErrNone if successful.
-			KErrInUse if an attempt has been made to free the memory and chunk while they are in use.
-			Otherwise one of the other system-wide error codes.
-	*/
-	inline TInt ChunkClose(TDevCamCaptureMode aCaptureMode);
-
-	/**
-	Start the image capture process in the capture mode supplied.
-	If the driver is in free running mode then it will commence capturing frames - cycling between
-	each buffer available to it until Stop() is called. In one shot mode the driver postpones the capturing
-	of frames until a NotifyNewImage() request is received.
-	@return KErrNone if successful;
-			KErrNotReady if SetConfig() has not been previously called;
-			otherwise one of the other system-wide error codes.
-	@pre The driver must have been previousely initialised by a call to SetConfigNN()
-	*/
-	inline TInt Start();
-
-	/**
-	End the image capturing process.
-	Also performs NotifyNewImageCancel()
-	@return KErrGeneral if Start() has not been previously called;
-			KErrNone otherwise.
-	*/
-	inline TInt Stop();
-
-	/**
-	Get the next available image.
-	More than one request may be pending at any time.
-	If the camera is enabled for image capture and image capture is not already in progress then the issuing
-	of this request will start image capture mode.
-	@param aStatus 	The request status which is signaled when an image is available (or an error occurs).
-					If the request is successful then this result value is the offset within the shared chunk
-					where the capture image resides. Alternatively, if an error occurs it will be set to one of
-					the system wide error values:
-				 	KErrNotReady if Start() hasn't been previousely called;
-				 	KErrInUse if the client already has all the images buffers.
-	@pre Image capturing must have been started with Start().
-	*/
-	inline void NotifyNewImage(TRequestStatus& aStatus);
-
-	/**
-	Cancels all outstanding NotifyNewImage() requests.
-	All outstanding requests complete with KErrCancel.
-	*/
-	inline void NotifyNewImageCancel();
-
-	/**
-	Cancels a specific NotifyNewImage() request.
-	The outstanding request completes with KErrCancel.
-	@param aStatus The request status object associated with the request to be cancelled.
-	*/
-	inline void NotifyNewImageCancel(const TRequestStatus& aStatus);
-
-	/**
-	Release a buffer - making it available again for the driver to capture images into.
-	@param aBufferId	The buffer id of the buffer that the image to be released is stored.
-						This is a value returned by the NotifyNewImage() request when
-						the buffer was claimed by the client.
-	@return KErrNone if successful;
-			KErrNotFound if the buffer id is invalid;
-			otherwise one of the other system-wide error codes.
-	*/
-	inline TInt ReleaseBuffer(TInt aBufferId);
-
-	/**
-	Retrieves the offset to the start of the buffer using its id, in the specified capture mode.
-	@param aCaptureMode	The capture mode that the buffer in the chunk is related to.
-	@param aId			The id of the buffer in the chunk.
-	@param aOffset		The offset, in bytes, of the start of the buffer within the chunk.
-	@return KErrNone if successful;
-			KErrNotFound if the id doesn't exist;
-			otherwise one of the other system-wide error codes.
-	*/
-	inline TInt BufferIdToOffset(TDevCamCaptureMode aCaptureMode, TInt aId, TInt& aOffset);
-
-	/**
-	Sets the current capture mode. Submits the camera configuration	to the PDD.
-	@param aCaptureMode	The capture mode that the camera switches to.	@see TDevCamCaptureMode.
-	@return KErrNone if successful;
-			otherwise one of the other system-wide error codes.
-	*/
-	inline TInt SetCaptureMode(TDevCamCaptureMode aCaptureMode);
-
-	/**
-	Queries the driver for the size of the structure to be passed to Caps().
-	@return The size of the structure required to hold all capability information.
-			otherwise one of the system-wide error codes.
-	*/
-	inline TInt CapsSize();
-
-	/**
-	Gets information regarding the frame sizes and frame rates supported for a given combination of capture mode and pixel format.
-	The capture mode and pixel format chosen will be dependent upon the information returned by RDevCameraSc::Caps().
-	@param	aCaptureMode The capture mode concerned.
-	@param	aUidPixelFormat The UID of the pixel format mode concerned.
-	@param	aFrameSizeCapsBuf	A packaged array of SDevCamFrameSize structures.
-								This is a variable length array and must be large enough to hold all entries.
-								Its size is determined by SDevCamPixelFormat::iNumFrameSizes, returned by RDevCameraSc::Caps(),
-								multiplied by the size of SDevCamFrameSize.
-	@return	KErrNone if successful;
-			KErrArgument if an invalid capture mode or pixel format is specified, or if aFrameSizeCapsBuf is too small.
-			otherwise one of the other system-wide error codes.
-	*/
-	inline TInt FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf);
-	
-
-	/**
-	Allows changing of the dynamic settings as specified in TDevCamDynamicAttribute.
-	Checks locally the validity of the arguments passed so as to increase performance by not
-	forcing a context switch.
-	Check the allowable range of the settings via the TCameraCapsV02::iDynamicRange member.
-
-	@param aAttribute An enum identifying the dynamic attribute to change.
-	@param aValue The attributes value within a valid range.
-	@return KErrNone if successful, KErrNotSupported if not supported, 
-			KErrArgument if aValue is out of range.
-			Otherwise, one of the system wide error codes.
-	@see TDevCamDynamicAttribute
-	@see TCameraCapsV02
-	*/
-	TInt SetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint aValue);
-
-	/**
-	Queries the driver for a dynamic setting's value.
-	This function does not force a context switch by reading the values from a cache.
-	
-	@param aAttribute An enum identifying the dynamic attribute to query.
-	@param aValue A reference to a variable that will be set to the queried attribute's value.
-	@return KErrNone if successful, KErrNotFound if aAttribute is not supported by the driver.
-		Otherwise, one of the system-wide error codes.
-
-	@see TDevCamDynamicAttribute
-	@see TCameraCapsV02
-	*/
-	TInt GetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint& aValue);
-
-protected:
-	TInt CheckAttributeSupported(TDevCamDynamicAttribute aAttribute);
-
-
-private:
-	/** 
-	Capability of Sensor. 
-	Kept here for performance issues, i.e. to avoid context switches.
-	*/
-	TCameraCapsV02 *iCameraCaps;
-
-	/** 
-	Size of Camera Capabiliy struct. 
-	Kept here for performance issues, i.e. to avoid context switches.
-	*/
-	TInt iCapsSize;
-	
-#endif	// __KERNEL_MODE__
-	};
-
-
-
-
-#include <d32camerasc.inl>
-
-#endif	// __D32CAMERASC_H__
--- a/kernel/eka/include/d32camerasc.inl	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-// Copyright (c) 2006-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\include\d32camerasc.inl
-// 
-//
-
-inline TVersion RDevCameraSc::VersionRequired()
-	{
-	const TInt KCameraMajorVersionNumber=1;
-	const TInt KCameraMinorVersionNumber=0;
-	const TInt KCameraBuildVersionNumber=KE32BuildVersionNumber;
-	return TVersion(KCameraMajorVersionNumber,KCameraMinorVersionNumber,KCameraBuildVersionNumber);
-	}
-
-#ifndef __KERNEL_MODE__
-
-
-inline RDevCameraSc::RDevCameraSc()
-: RBusLogicalChannel()
-	{
-	iCameraCaps = NULL;
-	iCapsSize = 0;
-	}
-
-inline TInt RDevCameraSc::Open(TInt aUnit)
-	{
-	TInt r=DoCreate(KDevCameraScName,VersionRequired(),aUnit,NULL,NULL,EOwnerThread);
-	if (KErrNone == r)
-		{
-		// Obtain the Capability structure size then allocate memory for it on client side
-		r=iCapsSize=DoControl(EControlCapsSize);		
-		if (KErrNone > r)
-			{
-			iCapsSize = 0;
-			return r;
-			}
-
-		TAny* capsBufPtr = User::Alloc(iCapsSize);
-		if(NULL == capsBufPtr)
-			{
-			Close();
-			return KErrNoMemory;
-			}
-
-		TPtr8 capsPtr((TUint8*)capsBufPtr, iCapsSize, iCapsSize);
-		// Fill the Capability structure
-		r = DoControl(EControlCaps,(TAny*)&capsPtr);
-		if (KErrNone > r)
-			{
-			iCapsSize = 0;
-			return r;
-			}
-		iCameraCaps = (TCameraCapsV02*) capsPtr.Ptr();
-		}
-
-	return r;
-	}
-
-inline void RDevCameraSc::Close()
-	{
-	if (iCameraCaps != NULL)
-		{
-		User::Free(iCameraCaps);
-		iCameraCaps = NULL;
-		}
-	iCapsSize = 0;
-	RBusLogicalChannel::Close();
-	}
-
-inline TInt RDevCameraSc::Caps(TDes8& aCapsBuf)
-	{
-	if (aCapsBuf.MaxLength() < iCapsSize)
-		{
-		return KErrArgument;
-		}
-
-	TPtrC8 ptr ((TUint8*)iCameraCaps, iCapsSize);
-	aCapsBuf = ptr;
-	return KErrNone;
-	}
-
-inline TPtrC8 RDevCameraSc::Caps()
-	{
-	TPtrC8 ptr((TUint8*)iCameraCaps, iCapsSize);
-	return ptr;
-	}
-
-inline TInt RDevCameraSc::SetBufConfigChunkCreate(TDevCamCaptureMode aCaptureMode, TInt aNumBuffers, RChunk& aChunk)
-	{return(aChunk.SetReturnedHandle(DoControl(EControlSetBufConfigChunkCreate,(TAny*)aCaptureMode,(TAny*)aNumBuffers)));}
-
-inline TInt RDevCameraSc::SetBufConfigChunkOpen(TDevCamCaptureMode aCaptureMode, const TDesC8& aBufferConfigBuf, RChunk& aChunk)
-	{
-	SSetBufConfigChunkOpenInfo info = {&aBufferConfigBuf, aChunk.Handle()};
-	return(DoControl(EControlSetBufConfigChunkOpen,(TAny*)aCaptureMode,&info));
-	}
-
-inline TInt RDevCameraSc::ChunkClose(TDevCamCaptureMode aCaptureMode)
-	{return(DoControl(EControlChunkClose,(TAny*)aCaptureMode));}
-
-inline TInt RDevCameraSc::SetCamConfig(TDevCamCaptureMode aCaptureMode,const TDesC8& aConfigBuf)
-	{return(DoControl(EControlSetCamConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf));}
-
-inline void RDevCameraSc::GetCamConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf)
-	{DoControl(EControlGetCamConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf);}
-
-inline void RDevCameraSc::GetBufferConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf)
-	{DoControl(EControlGetBufferConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf);}
-
-inline TInt RDevCameraSc::SetCaptureMode(TDevCamCaptureMode aCaptureMode)
-	{return(DoControl(EControlSetCaptureMode,(TAny*)aCaptureMode));}
-
-inline TInt RDevCameraSc::Start()
-	{return(DoControl(EControlStart));}
-
-inline TInt RDevCameraSc::Stop()
-	{return(DoControl(EControlStop));}
-
-inline void RDevCameraSc::NotifyNewImage(TRequestStatus& aStatus)
-	{DoRequest(ERequestNotifyNewImage,aStatus);}
-
-inline void RDevCameraSc::NotifyNewImageCancel()
-	{DoCancel(1<<ERequestNotifyNewImage);}
-
-inline void RDevCameraSc::NotifyNewImageCancel(const TRequestStatus& aStatus)
-	{DoControl(EControlNotifyNewImageSpecificCancel,(TAny*)&aStatus);}
-
-inline TInt RDevCameraSc::ReleaseBuffer(TInt aBufferId)
-	{return(DoControl(EControlReleaseBuffer,(TAny*)aBufferId));}
-
-inline TInt RDevCameraSc::BufferIdToOffset(TDevCamCaptureMode aCaptureMode, TInt aId, TInt& aOffset)
-	{
-	// search criteria
-	TDevCamBufferModeAndIdBuf databuf;
-	TDevCamBufferModeAndId &data = databuf();
-	data.iCaptureMode = aCaptureMode;
-	data.iId = aId;
-
-	return (DoControl(EControlBufferIdToOffset,(TAny*)&databuf,(TAny*)&aOffset));
-	}
-
-inline TInt RDevCameraSc::CapsSize()
-	{return(iCapsSize);}
-
-inline TInt RDevCameraSc::FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf)
-	{
-	SFrameSizeCapsInfo info = {aUidPixelFormat, aCaptureMode};
-	return(DoControl(EControlFrameSizeCaps, (TAny*)&aFrameSizeCapsBuf, &info));
-	}
-
-//
-//
-//
-inline TInt RDevCameraSc::CheckAttributeSupported(TDevCamDynamicAttribute aAttribute)
-	{
-	TUint mask = 0;
-	
-	switch (aAttribute)
-		{
-		case ECamAttributeBrightness:
-			mask = KCamMiscBrightness;
-			break;
-			
-		case ECamAttributeContrast:
-			mask = KCamMiscContrast;
-			break;
-			
-		case ECamAttributeColorEffect:
-			mask = KCamMiscColorEffect;
-			break;
-			
-		default:
-			return KErrNotSupported;
-		}
-	
-	// Check that the attribute is supported by the hardware.
-	return (iCameraCaps->iCapsMisc & mask ? KErrNone : KErrNotSupported);
-	}
-	
-//
-//
-//
-inline TInt RDevCameraSc::SetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint aValue)
-	{
-	TInt err = CheckAttributeSupported(aAttribute);
-	if (err == KErrNone)
-		{
-		err = KErrArgument;
-		TDynamicRange &range = iCameraCaps->iDynamicRange[aAttribute];
-		if ((aValue >= range.iMin) && (aValue <= range.iMax))
-			{
-			err = DoControl(EControlSetDynamicAttribute, (TAny*)aAttribute, (TAny*)aValue);
-			}
-		}
-
-	return err;
-	}
-
-//
-//
-//
-inline TInt RDevCameraSc::GetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint& aValue)
-	{
-	TInt err = CheckAttributeSupported(aAttribute);
-	if (err == KErrNone)
-		{
-		err = DoControl(EControlGetDynamicAttribute, (TAny*)aAttribute, (TAny*)&aValue);
-		}
-		
-	return err;
-	}
-#endif	// __KERNEL_MODE__
--- a/kernel/eka/include/d32usbcsc.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/d32usbcsc.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -383,7 +383,7 @@
         EControlGetOtgDescriptor,
         EControlGetOtgFeatures, 
 		EControlRealizeInterface,
-		EControlStartNextInAlternateSetting	
+		EControlStartNextInAlternateSetting
 		};
 
 
@@ -399,13 +399,26 @@
 
 #ifndef __KERNEL_MODE__
 
+
 	/** Opens a channel.
 
 		@param aUnit This should be 0 (zero).
+		@param aShare if this channel can be used in another process.
 
 		@return KErrNone if successful.
 	*/
-	inline TInt Open(TInt aUnit);
+	inline TInt Open(TInt aUnit, TBool aShare=ETrue);
+
+	/** Opens a channel which has created.
+
+		@param aMsg client-server message contain the handle of this channel.
+		@param aPos index of message slot that contain handle.
+		@param aType ownership type of the handle.
+
+		@return KErrNone if successful.
+	*/
+
+	inline TInt Open(RMessagePtr2 aMsg, TInt aIndex, TOwnerType aType=EOwnerProcess);
 
 	inline TVersion VersionRequired() const;
 
@@ -1295,8 +1308,17 @@
 	@return KErrNone on success otherwise a system wide error code, if an error has occurred.
 	*/
 	IMPORT_C TInt GetDataTransferChunk(RChunk*& aChunk);
+	/**
+	Call this function to reset alternate setting related data to initial state,
+	this API should be called when device state goes to undefined.
+	*/
+	IMPORT_C void ResetAltSetting();
+
+	
 
 private:
+ 	/** @internalTechnology */
+	TInt Empty(TUint aBufferOffset);
 	/** @internalTechnology */
 	TInt Drain(TUint aBuffer);
 	/** @internalTechnology */ 
@@ -1487,6 +1509,8 @@
 	*/
 	inline TInt GetEndpointNumber();
 
+	inline TInt BufferNumber();
+
 private:
 	/** @internalTechnology */
 	void Construct(RDevUsbcScClient* aClient, TUint8* aBaseAddr, const TUsbcScHdrEndpointRecord* aEpType,
--- a/kernel/eka/include/d32usbcsc.inl	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/d32usbcsc.inl	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1995-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"
@@ -118,10 +118,19 @@
 
 /** @capability CommDD
 */
-inline TInt RDevUsbcScClient::Open(TInt aUnit)
+inline TInt RDevUsbcScClient::Open(TInt aUnit, TBool aShare)
 	{
 	_LIT(KUsbDevName, "usbcsc");
-	return (DoCreate(KUsbDevName, VersionRequired(), aUnit, NULL, NULL, EOwnerThread));
+	return (DoCreate(KUsbDevName, VersionRequired(), aUnit, NULL, NULL, EOwnerThread, aShare));
+	}
+
+inline TInt RDevUsbcScClient::Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType)
+	{
+	iEndpointStatus = 0;
+	iAltSettingSeq = 0;
+	iAlternateSetting = 0;
+	iNewAltSetting = 0;
+	return RBusLogicalChannel::Open(aMessage,aParam,aType);
 	}
 
 
@@ -714,6 +723,8 @@
 	return DoControl(EControlStartNextInAlternateSetting);
 	}
 
+
+
 //Buffer Interface Layer (BIL) inline functions
 
 
@@ -730,6 +741,12 @@
 	return iEndpointNumber;
 	}
 
+inline TInt TEndpointBuffer::BufferNumber()
+	{
+	return iBufferNum;
+	}
+
+
 #endif // #ifndef __KERNEL_MODE__
 
 #endif // #ifndef __D32USBCSC_INL__
--- a/kernel/eka/include/drivers/camerasc.h	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,460 +0,0 @@
-// Copyright (c) 2004-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\include\drivers\camerasc.h
-// 
-//
-
-/**
- @file
- @internalAll
- @prototype
-*/
-
-#ifndef __CAMERASC_H__
-#define __CAMERASC_H__
-
-#include <d32camerasc.h>
-#include <platform.h>
-#include <kernel/kpower.h>
-#include <e32ver.h>
-
-/** The default number of buffers available to the client. */
-const TInt KDefaultNumClientBuffers=6;
-
-/** The maximum number of client capture requests which may be outstanding at any time. */
-const TInt KMaxCamScRequestsPending=8;
-
-/**
-@internalAll
-@prototype
-*/
-struct SBufSpecList
-	{
-	/** The first entry of the buffer offset list. This list holds the offset from the start of the chunk
-	for each buffer. This list is only valid if the flag KScFlagBufOffsetListInUse is set in
-	TSharedChunkBufConfigBase::iFlags. */
-	TInt iBufferOffset;
-	TInt iBufferId;
-	};
-
-/**
-@internalAll
-@prototype
-*/
-class TCameraSharedChunkBufConfig : public TSharedChunkBufConfigBase
-	{
-public:
- 	struct SBufSpecList iSpec;
-	};
-
-// Forward declarations
-class TImageBuffer;
-class DCameraScLdd;
-class DBufferManager;
-
-/**
-The physical device driver (PDD) base class for the camera driver.
-@internalAll
-@prototype
-*/
-class DCameraScPdd : public DBase
-	{
-public:
-	/**
-    Return the DFC queue to be used by this device.
-    @param aUnit The unit number for which to get the DFC queue.
-    @return The DFC queue to use.
-    */
-	virtual TDfcQue* DfcQ(TInt aUnit)=0;
-
-	/**
-	Return the capabilities of this camera device.
-	@param aCapsBuf A packaged TCameraCapsV02 object to be filled with the capabilities of the
-		device. This descriptor is in kernel memory and can be accessed directly.
-	@see TCameraCapsV02.
-	*/
-	virtual void Caps(TDes8& aCapsBuf) const=0;
-
-	/**
-	Return data format information for a custom camera data format setting. Only required where support is
-	required for a data format that isn't supported by the LDD. Platforms which don't require support
-	for custom data settings need not implement this method.
-	@param aConfigBuf A packaged TCameraConfigV02 object containing the current camera driver configuration
-		(including an identifier for the custom setting required). This configuration object should be
-		updated by the PDD with the appropriate settings for the data format concerned. This descriptor
-		is in kernel memory and can be accessed directly.
-	@return KErrNone if successful, otherwise one of the other system wide error codes.
-	*/
-	virtual TInt SpecifyCustomConfig(TDes8& aConfigBuf);
-
-	/**
-	Return the shared chunk create information to be used by this device.
-	@param aChunkCreateInfo A chunk create info. object to be to be filled with the settings
-							required for this device.
-	*/
-	virtual void GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo)=0;
-
-	/**
-	Configure or reconfigure the device using the the configuration supplied.
-	@param aConfigBuf A packaged TCameraConfigV02 object which contains the new configuration settings.
-		This descriptor is in kernel memory and can be accessed directly.
-	@return KErrNone if successful, otherwise one of the other system wide error codes.
-	@see TCameraConfigV02.
-	*/
-	virtual TInt SetConfig(const TDesC8& aConfigBuf)=0;
-
-	/**
-    Start the camera - start pixel sourcing.
-    @param aCaptureMode The capture mode to start. @see TDevCamCaptureMode.
-    @param aLinAddr The linear address of the start of the first buffer to use for image capture.
-	@param aPhysAddr The physical address that corresponds to the linear address: aLinAddr.
-    @return KErrNone if successful;
-    		otherwise one of the other system wide error codes.
-    */
-	virtual TInt Start(TDevCamCaptureMode aCaptureMode,TLinAddr aLinAddr,TPhysAddr aPhysAddr)=0;
-
-	/**
-	Sets the address of the buffer into which the next image will be captured.
-    @param aLinAddr The linear address of the start of the buffer to use to capture the image frame.
-	@param aPhysAddr The physical address that corresponds to the linear address: aLinAddr.
-    @return KErrNone if the capture has been initiated successfully;
-  			KErrNotReady if the device is unable to accept the request for the moment;
-		  	otherwise one of the other system-wide error codes.
-    */
-	virtual TInt CaptureNextImage(TLinAddr aLinAddr,TPhysAddr aPhysAddr)=0;
-
-	/**
-    Stop the camera - stop pixel sourcing.
-    @return KErrNone if successful, otherwise one of the other system wide error codes.
-    */
-	virtual TInt Stop()=0;
-
-	/**
-	Power down the camera.
-	*/
-	virtual void PowerDown()=0;
-
-	/**
-	Queries the driver for the size of the structure to be passed to RDevCameraSc::Caps().
-	*/
-	virtual TInt CapsSize()=0;
-
-	/**
-	Returns the supported frame sizes that correspond to the desired capture mode and pixel format passed in.
-	@param aCaptureMode The capture mode for which to obtain the information.
-	@param aUidPixelFormat The pixel format for which to obtain the information.
-	@param aFrameSizeCapsBuf An appropriately sized buffer to be filled with the supported frame sizes.
-	@return KErrNone, if successful,
-			KErrArgument, if an invalid capture mode or pixel format is specified, or if aFrameSizeCapsBuf is too small;
-			otherwise one of the other system-wide error codes.
-	@see SDevCamFrameSize
-	*/
-	virtual TInt FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf)=0;
-
-	/**
-	Sets the sensor brightness to the desired setting.
-
-	@param aValue A verified brightness setting.
-	@return KErrNone if successful, KErrNotSupported if not supported.
-	*/
-	virtual TInt SetBrightness(TUint aValue) = 0;
-
-	// SYM_BRANCH: Add support for setting of Dynamic Attributes. Contrast.
-	/**
-	Sets the sensor contrast to the desired setting.
-
-	@param aValue A verified contrast setting.
-	@return KErrNone if successful, KErrNotSupported if not supported.
-	*/
-	virtual TInt SetContrast(TUint aValue) = 0;
-
-	// SYM_BRANCH: Add support for setting of Dynamic Attributes. Colour Effect.
-	/**
-	Sets the sensor color effect to the desired setting.
-
-	@param aValue A verified color effect setting.
-	@return KErrNone if successful, KErrNotSupported if not supported.
-	*/
-	virtual TInt SetColorEffect(TUint aValue) = 0;
-
-public:
-	DCameraScLdd* iLdd;
-	};
-
-/**
-The logical device (factory class) for the camera driver.
-*/
-class DCameraScLddFactory : public DLogicalDevice
-	{
-public:
-	DCameraScLddFactory();
-	virtual TInt Install();
-	virtual void GetCaps(TDes8 &aDes) const;
-	virtual TInt Create(DLogicalChannelBase*& aChannel);
-	TBool IsUnitOpen(TInt aUnit);
-	TInt SetUnitOpen(TInt aUnit,TBool aIsOpenSetting);
-private:
-	/** Mask to keep track of which units have a channel open on them. */
-	TUint iUnitsOpenMask;
-	/** A mutex to protect access to the unit info. mask. */
-	NFastMutex iUnitInfoMutex;
-	};
-
-/**
-The class representing a single image buffer.
-*/
-class TImageBuffer : public SDblQueLink
-	{
-public:
-	TImageBuffer();
-	~TImageBuffer();
-	TInt Create(DChunk* aChunk,TInt aOffset,TInt aSize,TInt aId,TBool aIsContiguous);
-	void SyncMemoryBeforeDmaRead();
-	void SyncMemoryAfterDmaRead();
-public:
-	/** The buffer id */
-	TInt iId;
-	/** The chunk used for this buffer */
-	DChunk* iChunk;
-	/** The offset, in bytes, of the start of the buffer within the chunk. */
-	TInt iChunkOffset;
-	/** The size of the buffer in bytes. */
-	TInt iSize;
-	/** The virtual address of buffer. */
-	TLinAddr iLinearAddress;
-	/** The physical address of buffer. KPhysAddrInvalid if the buffer is not physically contiguous. */
-	TPhysAddr iPhysicalAddress;
-	/** A list of physical addresses for buffer pages. 0 if the buffer is physically contiguous. */
-	TPhysAddr* iPhysicalPages;
-	/** This is the result of the transfer into this buffer. */
-	TInt iResult;
-	};
-
-/**
-An object encapsulating an image capture request from the client.
-*/
-class TCameraScRequest : public SDblQueLink
-	{
-public:
-	inline TCameraScRequest()
-		{}
-public:
-	/** The request status associated with the request - used to signal completion of the request and pass back a
-	completion code. */
-	TRequestStatus* iStatus;
-	};
-
-/**
-An object encapsulating a queue of image capture requests from the client.
-*/
-class TCameraScRequestQueue
-	{
-public:
-	TCameraScRequestQueue(NFastMutex* aMutexPtr);
-	~TCameraScRequestQueue();
-	TInt Create(DThread* anOwningThread);
-	TInt Add(TRequestStatus* aStatus);
-	TRequestStatus* Remove();
-	void Cancel(TRequestStatus* aStatus);
-	void CancelAll();
-	inline TBool IsEmpty();
-private:
-	/** The queue of pending capture requests. */
-	SDblQue iPendRequestQ;
-	/** The queue of unused capture requests. */
-	SDblQue iUnusedRequestQ;
-	/** The actual array of request objects. */
-	TCameraScRequest* iRequest[KMaxCamScRequestsPending];
-	NFastMutex* iMutexPtr;
-	DThread* iOwningThread;
-	};
-
-/**
-The buffer manager base class.
-*/
-class DBufferManager : public DBase
-	{
-public:
-	DBufferManager(DCameraScLdd* aLdd);
-	~DBufferManager();
-	TInt Create(TInt aNumBuffers,TInt aBufferSize);
-	TInt Create(TCameraSharedChunkBufConfig& aBufConfig,TInt aChunkHandle,DThread* anOwningThread);
-	void GetBufConfig(TCameraSharedChunkBufConfig& aBufConfig);
-	void Reset();
-	void Purge(TImageBuffer* aBuffer);
-	TImageBuffer* GetImageForClient(TBool aRemoveLast);
-	TImageBuffer* SetImageCaptured(TInt aResult);
-	TInt ReleaseImage(TInt aChunkOffset);
-	TImageBuffer* NextAvailableForCapture();
-	TImageBuffer* FindInUseImage(TInt aChunkOffset);
-protected:
-	TInt CreateBufferLists(TInt aNumBuffers);
-	TInt CommitMemoryForBuffer(TInt aChunkOffset,TInt aSize,TBool& aIsContiguous);
-protected:
-	/** The owning LDD object. */
-	DCameraScLdd* iLdd;
-	/** The chunk which contains the buffers. */
-	DChunk* iChunk;
-	/** The linear address in kernel process for the start of the chunk. */
-	TLinAddr iChunkBase;
-	/**< MMU mapping attributes that the chunk has actually been mapped with. */
-	TUint32 iChunkMapAttr;
-	/** The number of buffers. */
-	TInt iNumBuffers;
-	/** The actual array of buffer objects. */
-	TImageBuffer* iImageBuffer;
-	/** The buffer currently being filled by image capture. (Not in any list). */
-	TImageBuffer* iCurrentBuffer;
-	/** The next buffer to use for image capture. (Not in any list). */
-	TImageBuffer* iNextBuffer;
-	/** A queue of those buffers which are currently free. */
-	SDblQue iFreeBufferQ;
-	/** A queue of those buffers which currently contain captured images (and which aren't being used by the client). */
-	SDblQue iCompletedBufferQ;
-	/** A queue of those buffers which are currently being used by the client. */
-	SDblQue iInUseBufferQ;
-private:
-	friend class DCameraScLdd;
-	};
-
-/**
-The configuration class that is specific for each capture mode. This allows the driver to maintain different configurations,
-one for each capture mode, and make switching between capture modes faster.
-*/
-class TCaptureModeConfig
-	{
-	private:
-		/** The handle to the chunk that is returned to the user side code. */
-		TInt iChunkHandle;
-		/** The current configuration of the capture mode */
-		TCameraConfigV02 iCamConfig;
-		/** The current configuration of the chunk. */
-		TCameraSharedChunkBufConfig* iBufConfig;
-		/** The size in bytes of the chunk configuration info. structure. */
-		TInt iBufConfigSize;
-		/** The current frame height. */
-		TInt iFrameHeight;
-		/** The current frame width. */
-		TInt iFrameWidth;
-		/** The buffer manager. */
-		DBufferManager* iBufManager;
-	private:
-		friend class DCameraScLdd;
-	};
-
-/**
-The camera driver power handler class.
-*/
-class DCameraScPowerHandler : public DPowerHandler
-	{
-public:
-	DCameraScPowerHandler(DCameraScLdd* aChannel);
-	// Inherited from DPowerHandler
-	void PowerUp();
-	void PowerDown(TPowerState aPowerState);
-private:
-	DCameraScLdd* iChannel;
-	};
-
-/**
-The logical channel class for the camera driver.
-*/
-class DCameraScLdd : public DLogicalChannel
-	{
-public:
-	enum TState
-		{
-		/** Channel open - but not configured. */
-		EOpen,
-		/** Channel configured - but inactive. */
-		EConfigured,
-		/** Channel is active - capturing images. */
-		ECapturing
-		};
-public:
-	DCameraScLdd();
-	virtual ~DCameraScLdd();
-	// Inherited from DLogicalChannel
-	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
-	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
-	virtual void HandleMsg(TMessageBase* aMsg);
-	virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
-	inline DThread* OwningThread();
-	inline TInt CurrentFrameHeight();
-	inline TInt CurrentFrameWidth();
-	void Shutdown();
-	virtual TInt ImageCaptureCallback(TDevCamCaptureMode aCaptureMode,TInt aResult,TLinAddr* aLinAddr,TPhysAddr* aPhysAddr);
-	virtual void PanicClientThread(TInt aReason);
-private:
-	TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
-	TInt DoRequest(TInt aFunction, TRequestStatus* aStatus, TAny* a1, TAny* a2);
-	TInt DoCancel(TUint aMask);
-	TInt SetCaptureMode(TInt aCaptureMode);
-	TInt SetCamConfig(TInt aCaptureMode, const TDesC8* aCamConfigBuf);
-	TInt SetBufConfig(TInt aCaptureMode, const TDesC8* aBufferConfigBuf,TInt aChunkHandle);
-	TInt SetBufConfig(TInt aCaptureMode, TInt aNumBuffers);
-	TInt ChunkClose(TInt aCaptureMode);
-	TInt Start();
-	TInt NotifyNewImage(TRequestStatus* aStatus);
-	TInt ReleaseBuffer(TInt aChunkOffset);
-	TInt DoSetConfig(TInt aCaptureMode, const TDesC8* aCamConfigBuf);
-	TInt ValidateConfig(TInt aCaptureMode, TCameraConfigV02 &aConfig);
-	TInt DoValidateConfig(TCameraCapsV02* aCamCaps, TInt &aCaptureMode, TCameraConfigV02 &aConfig);
-	TInt DoStart();
-	TInt ReAllocBufferConfigInfo(TInt aCaptureMode, TInt aNumBuffers);
-	TInt ReAllocBufferConfigInfo(TInt aNumBuffers);
-	TInt GetSensorCaps(TAny* a1);
-	TInt GetFrameSizeCaps(TAny* a1, TAny* a2);
-	TInt GetDynamicAttribute(TInt aAttribute, TUint& aValue);
-	TInt SetDynamicAttribute(TInt aAttribute, TUint aValue);
-	inline DCameraScPdd* Pdd();
-	static void RestartDfc(TAny* aChannel);
-	static void PowerUpDfc(TAny* aPtr);
-	static void PowerDownDfc(TAny* aPtr);
-private:
-	/** An array of configurations for each capture mode. */
-	TCaptureModeConfig* iCaptureModeConfig;
-	/** The unit number of this channel. */
-	TInt iUnit;
-	/** The operating state of the channel. */
-	TState iState;
-	/** A pointer to the owning client thread. */
-	DThread* iOwningThread;
-	/** The current capture mode of the camera. */
-	TDevCamCaptureMode iCaptureMode;
-	/** The pending request queue. */
-	TCameraScRequestQueue iRequestQueue;
-	/** A mutex to protect access to the buffer lists and the pending request list. */
-	NFastMutex iMutex;
-	/** The camera driver power handler. */
-	DCameraScPowerHandler* iPowerHandler;
-	/** DFC used to re-start the PDD following a data capture error. */
-	TDfc iRestartDfc;
-	/** DFC used to handle power down requests from the power manager before a transition into system shutdown/standby. */
-	TDfc iPowerDownDfc;
-	/** DFC used to handle power up requests from the power manager following a transition out of system standby. */
-	TDfc iPowerUpDfc;
-	
-	// Used as a cache for values successfully set by SetDynamicAttribute().
-	TUint iBrightnessValue;
-	TUint iContrastValue;
-	TUint iColorEffectValue;
-	
-	friend class DCameraScPowerHandler;
-	friend class DBufferManager;
-	};
-
-#include <drivers/camerasc.inl>
-
-#endif	// __CAMERASC_H__
--- a/kernel/eka/include/drivers/camerasc.inl	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-// Copyright (c) 2004-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\include\drivers\camerasc.inl
-// 
-//
-
-inline DCameraScPdd* DCameraScLdd::Pdd()
-	{return((DCameraScPdd*)iPdd);}
-
-inline DThread* DCameraScLdd::OwningThread()
-	{return(iOwningThread);}
-
-inline TInt DCameraScLdd::CurrentFrameHeight()
-	{return(iCaptureModeConfig[iCaptureMode].iFrameHeight);}
-
-inline TInt DCameraScLdd::CurrentFrameWidth()
-	{return(iCaptureModeConfig[iCaptureMode].iFrameWidth);}
-
-inline TInt DCameraScPdd::SpecifyCustomConfig(TDes8& /*aConfig*/)
-	{return(KErrArgument);}
-
-inline TBool TCameraScRequestQueue::IsEmpty()
-	{return(iPendRequestQ.IsEmpty());}
--- a/kernel/eka/include/drivers/dma_hai.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/dma_hai.h	Wed Aug 18 11:08:29 2010 +0300
@@ -172,11 +172,13 @@
 	{
 friend class DmaChannelMgr;
 
-// The following two friend declarations will become obsolete once that
-// functionality is owned and provided by the controller class instead of the
-// request class. (TDmac::iFreeHdr could then also be made private.)
-friend TInt DDmaRequest::ExpandDesList(TInt, TInt&, SDmaDesHdr*&, SDmaDesHdr*&);
-friend void DDmaRequest::FreeDesList(TInt&, SDmaDesHdr*&, SDmaDesHdr*&);
+// The following friend declaration will become obsolete once header
+// pool manipulation functionality is owned and provided by the controller
+// class instead of the request class.
+// (TDmac::iFreeHdr could then also be made private.)
+friend class DDmaRequest;
+
+friend class TSkelDmac;
 
 protected:
 	/** Data required for creating a new instance. */
@@ -848,7 +850,7 @@
 	virtual void DoCancelAll();
 	virtual void DoDfc(const DDmaRequest& aCurReq, SDmaDesHdr*& aCompletedHdr);
 
-private:
+protected:
 	enum {EIdle = 0, ETransferring} iState;
 	};
 
@@ -864,7 +866,7 @@
 	virtual void DoCancelAll();
 	virtual void DoDfc(const DDmaRequest& aCurReq, SDmaDesHdr*& aCompletedHdr);
 
-private:
+protected:
 	enum {EIdle = 0, ETransferring, ETransferringLast} iState;
 	};
 
@@ -881,7 +883,7 @@
 	virtual void DoUnlink(SDmaDesHdr& aHdr);
 	virtual void DoDfc(const DDmaRequest& aCurReq, SDmaDesHdr*& aCompletedHdr);
 
-private:
+protected:
 	enum {EIdle = 0, ETransferring} iState;
 	};
 
@@ -894,19 +896,26 @@
 */
 class TDmaAsymSgChannel : public TDmaChannel
 	{
+public:
+	TDmaAsymSgChannel();
+
 private:
 	virtual void DoQueue(const DDmaRequest& aReq);
 	virtual void DoCancelAll();
 	virtual void DoUnlink(SDmaDesHdr& aHdr);
 	virtual void DoDfc(const DDmaRequest& aCurReq, SDmaDesHdr*& aSrcCompletedHdr,
 					   SDmaDesHdr*& aDstCompletedHdr);
+	virtual void SetNullPtr(const DDmaRequest& aReq);
+	virtual void ResetNullPtr();
 
-private:
+protected:
 	SDmaDesHdr* iSrcCurHdr;	  // source fragment being transferred or NULL
 	SDmaDesHdr** iSrcNullPtr; // Pointer to NULL pointer following last source fragment
 	SDmaDesHdr* iDstCurHdr;	  // destination fragment being transferred or NULL
 	SDmaDesHdr** iDstNullPtr; // Pointer to NULL pointer following last destination fragment
 	enum {EIdle = 0, ETransferring} iState;
+
+	__DMA_DECLARE_VIRTUAL_INVARIANT
 	};
 
 
--- a/kernel/eka/include/drivers/dma_v1.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/dma_v1.h	Wed Aug 18 11:08:29 2010 +0300
@@ -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;
@@ -393,15 +387,16 @@
 		void TFooDmaChannel::QueuedRequestCountChanged()
 			{
 			Kern::MutexWait(*iDmaMutex);
-			if ((iQueuedRequests > 0) && (iPrevQueuedRequests == 0))
+			const TInt queued_now = __e32_atomic_load_acq32(&iQueuedRequests);
+			if ((queued_now > 0) && (iPrevQueuedRequests == 0))
 				{
 				IncreasePowerCount(); // Base port specific
 				}
-			else if ((iQueuedRequests == 0) && (iPrevQueuedRequests > 0))
+			else if ((queued_now == 0) && (iPrevQueuedRequests > 0))
 				{
 				DecreasePowerCount(); // Base port specific
 				}
-			iPrevQueuedRequests = iQueuedRequests;
+			iPrevQueuedRequests = queued_now;
 			Kern::MutexSignal(*iDmaMutex);
 			}
 
@@ -436,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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/dma_v2.h	Wed Aug 18 11:08:29 2010 +0300
@@ -42,13 +42,24 @@
 #ifdef _DEBUG
 #define __DMA_CANT_HAPPEN() Kern::Fault(KDmaPanicCat, __LINE__)
 #define __DMA_DECLARE_INVARIANT public: void Invariant();
+#define __DMA_DECLARE_VIRTUAL_INVARIANT public: virtual void Invariant();
 #define __DMA_INVARIANT() Invariant()
 #else
 #define __DMA_CANT_HAPPEN()
 #define __DMA_DECLARE_INVARIANT
+#define __DMA_DECLARE_VIRTUAL_INVARIANT
 #define __DMA_INVARIANT()
 #endif
 
+#ifdef __DMASIM__
+#ifdef __PRETTY_FUNCTION__
+#define __DMA_UNREACHABLE_DEFAULT() DMA_PSL_TRACE1("Calling default virtual: %s", __PRETTY_FUNCTION__)
+#else
+#define __DMA_UNREACHABLE_DEFAULT() DMA_PSL_TRACE("Calling default virtual function")
+#endif
+#else
+#define __DMA_UNREACHABLE_DEFAULT() __DMA_CANT_HAPPEN()
+#endif
 
 //////////////////////////////////////////////////////////////////////////////
 // INTERFACE EXPOSED TO DEVICE-DRIVERS
@@ -637,7 +648,7 @@
 private:
 	inline void OnDeque();
 	TInt CheckTransferConfig(const TDmaTransferConfig& aTarget, TUint aCount) const;
-	TInt CheckMemFlags(const TDmaTransferConfig& aTarget, TUint aCount) const;
+	TInt CheckMemFlags(const TDmaTransferConfig& aTarget) const;
 	TInt AdjustFragmentSize(TUint& aFragSize, TUint aElementSize, TUint aFrameSize);
 	TUint GetTransferCount(const TDmaTransferArgs& aTransferArgs) const;
 	TUint GetMaxTransferlength(const TDmaTransferArgs& aTransferArgs, TUint aCount) const;
@@ -738,11 +749,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;
@@ -1232,15 +1238,16 @@
 		void TFooDmaChannel::QueuedRequestCountChanged()
 			{
 			Kern::MutexWait(*iDmaMutex);
-			if ((iQueuedRequests > 0) && (iPrevQueuedRequests == 0))
+			const TInt queued_now = __e32_atomic_load_acq32(&iQueuedRequests);
+			if ((queued_now > 0) && (iPrevQueuedRequests == 0))
 				{
 				IncreasePowerCount(); // Base port specific
 				}
-			else if ((iQueuedRequests == 0) && (iPrevQueuedRequests > 0))
+			else if ((queued_now == 0) && (iPrevQueuedRequests > 0))
 				{
 				DecreasePowerCount(); // Base port specific
 				}
-			iPrevQueuedRequests = iQueuedRequests;
+			iPrevQueuedRequests = queued_now;
 			Kern::MutexSignal(*iDmaMutex);
 			}
 
@@ -1250,17 +1257,18 @@
 	*/
 	virtual void QueuedRequestCountChanged();
 
-#if defined(__CPU_ARM) && !defined(__EABI__)
-	inline virtual ~TDmaChannel() {}	// kill really annoying warning
-#endif
+	virtual void SetNullPtr(const DDmaRequest& aReq);
+	virtual void ResetNullPtr();
+
+	inline virtual ~TDmaChannel() {}
+
+	inline void Wait();
+	inline void Signal();
+	inline TBool Flash();
 
 private:
 	static void Dfc(TAny*);
 	void DoDfc();
-	inline void Wait();
-	inline void Signal();
-	inline TBool Flash();
-	void ResetStateMachine();
 
 protected:
 	TDmac* iController;		 // DMAC this channel belongs to (NULL when closed)
@@ -1281,13 +1289,14 @@
 	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; // ...
 	TBool iRedoRequest;		// client ISR callback wants a redo of request
 	TBool iIsrCbRequest;	// request on queue using ISR callback
 
-	__DMA_DECLARE_INVARIANT
+	__DMA_DECLARE_VIRTUAL_INVARIANT
 	};
 
 
--- a/kernel/eka/include/drivers/iic.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/iic.h	Wed Aug 18 11:08:29 2010 +0300
@@ -335,28 +335,6 @@
 	TInt8 iChanRwFlags;		// Bit 0 for write, bit 1 for read
 	};
 
-#ifdef IIC_SIMULATED_PSL
-_LIT(KPddName,"iic.pdd");
-
-NONSHARABLE_CLASS(DIicPdd) : public DPhysicalDevice
-	{
-// Class to faciliate loading of the IIC classes
-public:
-	class TCaps
-		{
-	public:
-		TVersion iVersion;
-		};
-public:
-	DIicPdd();
-	~DIicPdd();
-	virtual TInt Install();
-	virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
-	virtual TInt Validate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
-	virtual void GetCaps(TDes8& aDes) const;
-	inline static TVersion VersionRequired();
-	};
-#endif
 
 #include <drivers/iic.inl>
 
--- a/kernel/eka/include/drivers/iic_transaction.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/iic_transaction.h	Wed Aug 18 11:08:29 2010 +0300
@@ -421,6 +421,7 @@
         inline TIicBusTransaction();
     
         // the client interface for creating half duplex transactions
+		// The parameter aPriority is required to be at least zero and less than KNumTrancPriorities.
         inline TIicBusTransaction(TDes8* aHeader, TIicBusTransfer* aHdTrans, TInt aPriority=0);
         inline ~TIicBusTransaction();
         inline TInt SetHalfDuplexTrans(TDes8* aHeader, TIicBusTransfer* aHdTrans);
--- a/kernel/eka/include/drivers/iic_transaction.inl	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/iic_transaction.inl	Wed Aug 18 11:08:29 2010 +0300
@@ -65,7 +65,8 @@
     iHeader(aHeader), iFlags(NULL), iState(EFree), iHalfDuplexTrans(aHdTrans),
     iFullDuplexTrans(NULL), iCallback(NULL)
     {
-    __ASSERT_ALWAYS((((TUint)aPriority<(TUint)KNumTrancPriorities)&&((TUint)aPriority>=0)),Kern::Fault("TIicBusTransaction",__LINE__));
+    //Check that the requested priority is at least zero and less than KNumTrancPriorities.
+    __ASSERT_ALWAYS(((aPriority<KNumTrancPriorities)&&(aPriority>=0)),Kern::Fault("TIicBusTransaction",__LINE__));
     __ASSERT_ALWAYS(aHeader && aHdTrans,Kern::Fault("TIicBusTransaction",__LINE__));
     iKey = aPriority;
     }
--- a/kernel/eka/include/drivers/resmanus_trace.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/resmanus_trace.h	Wed Aug 18 11:08:29 2010 +0300
@@ -26,16 +26,6 @@
 #define __RESMANUSCONTROL_TRACE_H__
 #ifdef BTRACE_RESMANUS
 
-//Function to format the output.
-static void UsTraceFormatPrint(TDes8& aBuf, const char* aFmt, ...)
-	{
-	if(!(&aBuf))
-		return;
-	VA_LIST list;
-	VA_START(list,aFmt);
-	Kern::AppendFormat(aBuf,aFmt,list);
-	}
-
 //definition of subcategories.
 #define PRM_US_OPEN_CHANNEL_START				BTrace::EOpenChannelUsStart
 #define PRM_US_OPEN_CHANNEL_END					BTrace::EOpenChannelUsEnd
@@ -52,31 +42,38 @@
 #define PRM_US_CANCEL_SET_RESOURCE_STATE_START	BTrace::ECancelSetResourceStateUsStart
 #define PRM_US_CANCEL_SET_RESOURCE_STATE_END	BTrace::ECancelSetResourceStateUsEnd
 
+#define APPEND_VAL(val)                                                                        \
+    {                                                                                               \
+    printBuf.Append((TUint8 *)&(val), sizeof(val));                                                       \
+    }     
+#define APPEND_STRING(des_ptr)                                                                           \
+    {                                                                                               \
+    TUint length = (des_ptr)->Length();                                                              \
+    printBuf.Append((TUint8 *)&length, sizeof(TUint));                                                     \
+    printBuf.Append(*(des_ptr));                                                                       \
+    }
+
 // Macro to output identification information provided in a request to open a channel
 #define PRM_US_OPEN_CHANNEL_START_TRACE						\
 	{														\
-    TBuf8<256> printBuf;									\
-    printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S", iUserNameUsed);	\
-	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_OPEN_CHANNEL_START, 0, (TInt)(iClient), printBuf.Ptr(), printBuf.Length()); \
+	Kern::Printf("PRM_US_OPEN_CHANNEL_START_TRACE");\
+	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_OPEN_CHANNEL_START, (TInt)(iClient), iUserNameUsed->Length(), iUserNameUsed->Ptr(), iUserNameUsed->Length()); \
 	}
 
 // Macro to output identification information generated during a request to open a channel
 #define PRM_US_OPEN_CHANNEL_END_TRACE						\
 	{														\
-    TBuf8<256> printBuf;									\
-    printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S", iUserNameUsed);		\
-	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_OPEN_CHANNEL_END, 0, (TInt)(ClientHandle()), printBuf.Ptr(), printBuf.Length()); \
+	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_OPEN_CHANNEL_END, (TInt)(ClientHandle()), iUserNameUsed->Length(), iUserNameUsed->Ptr(), iUserNameUsed->Length()); \
 	}
 
 // Macro to output information provided for a request to register with the Resource Controller
 #define PRM_US_REGISTER_CLIENT_START_TRACE					\
 	{														\
-    TBuf8<256> printBuf;									\
+    TUint32 stateRes32 = ((stateRes[0]&0xFF) << 16) | ((stateRes[1]&0xFF) << 8) | ((stateRes[2]&0xFF));\
+    TBuf8<80> printBuf;									\
     printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S 0x%x %d", iUserNameUsed, (TInt)(ClientHandle()),(TInt)(stateRes[0]));	\
-	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_REGISTER_CLIENT_START, (TInt)(stateRes[1]), (TInt)(stateRes[2]), printBuf.Ptr(), printBuf.Length()); \
+    APPEND_STRING(iUserNameUsed);                      \
+	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_REGISTER_CLIENT_START, (TInt)ClientHandle(), stateRes32, printBuf.Ptr(), printBuf.Length()); \
 	}
 
 // Macro to output information after issuing a request to register with the Resource Controller
@@ -88,10 +85,7 @@
 // Macro to output information provided for a request to de-register with the Resource Controller
 #define PRM_US_DEREGISTER_CLIENT_START_TRACE				\
 	{														\
-    TBuf8<256> printBuf;									\
-    printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S ", iUserNameUsed);		\
-	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_DEREGISTER_CLIENT_START, 0, (TInt)(ClientHandle()), printBuf.Ptr(), printBuf.Length()); \
+	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_DEREGISTER_CLIENT_START, (TInt)(ClientHandle()), iUserNameUsed->Length(), iUserNameUsed->Ptr(), iUserNameUsed->Length()); \
 	}
 
 // Macro to output information after issuing a request to de-register with the Resource Controller
@@ -103,72 +97,76 @@
 // Macro to output information provided for a request to get the state of a resource
 #define PRM_US_GET_RESOURCE_STATE_START_TRACE				\
 	{														\
-    TBuf8<256> printBuf;									\
-    printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S ", iUserNameUsed);		\
+    TBuf8<80> printBuf;                                    \
+    printBuf.Zero();                                        \
+    APPEND_STRING(iUserNameUsed);                      \
 	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_GET_RESOURCE_STATE_START, resourceId, (TInt)(ClientHandle()), printBuf.Ptr(), printBuf.Length()); \
 	}
 
 // Macro to output information on completion of a request to get the state of a resource
 #define PRM_US_GET_RESOURCE_STATE_END_TRACE					\
 	{														\
-    TBuf8<256> printBuf;									\
+    TBuf8<80> printBuf;									\
     printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%d %d", aClient, aResult);	\
+    APPEND_VAL(aClient);                                    \
+    APPEND_VAL(aResult);                                    \
 	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_GET_RESOURCE_STATE_END, aResourceId, aLevel, printBuf.Ptr(), printBuf.Length()); \
 	}
 
 // Macro to output information provided for a request to set the state of a resource
 #define PRM_US_SET_RESOURCE_STATE_START_TRACE				\
 	{														\
-    TBuf8<256> printBuf;									\
+    TBuf8<80> printBuf;									\
     printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S %d", iUserNameUsed, (TInt)(ClientHandle()));	\
+    TInt ch = ClientHandle();                               \
+    APPEND_VAL(ch);                                         \
+    APPEND_STRING(iUserNameUsed);                      \
 	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_SET_RESOURCE_STATE_START, resourceId, newState, printBuf.Ptr(), printBuf.Length()); \
 	}
 
 // Macro to output information on completion of a request to set the state of a resource
 #define PRM_US_SET_RESOURCE_STATE_END_TRACE					\
 	{														\
-    TBuf8<256> printBuf;									\
+    TBuf8<80> printBuf;									\
     printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%d %d", aClient, aResult);	\
+    APPEND_VAL(aClient);                                    \
+    APPEND_VAL(aResult);                                    \
 	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_SET_RESOURCE_STATE_END, aResourceId, aLevel, printBuf.Ptr(), printBuf.Length()); \
 	}
 
 // Macro to output information provided for a request to cancel the get resource state requests for a resource
 #define PRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE		\
 	{														\
-    TBuf8<256> printBuf;									\
-    printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S ", iUserNameUsed);		\
+    TBuf8<80> printBuf;                                    \
+    printBuf.Zero();                                        \
+    APPEND_STRING(iUserNameUsed);                      \
 	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_CANCEL_GET_RESOURCE_STATE_START, aResourceId, (TInt)(ClientHandle()), printBuf.Ptr(), printBuf.Length()); \
 	}
 
 // Macro to output information on completion of a request to cancel the get resource state requests for a resource
 #define PRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE			\
 	{														\
-    TBuf8<256> printBuf;									\
-    printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S ", iUserNameUsed);		\
+    TBuf8<80> printBuf;                                    \
+    printBuf.Zero();                                        \
+    APPEND_STRING(iUserNameUsed);                      \
 	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_CANCEL_GET_RESOURCE_STATE_END, aResourceId, (TInt)(ClientHandle()), printBuf.Ptr(), printBuf.Length()); \
 	}
 
 // Macro to output information provided for a request to cancel the set resource state requests for a resource
 #define PRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE		\
 	{														\
-    TBuf8<256> printBuf;									\
-    printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S ", iUserNameUsed);		\
+    TBuf8<80> printBuf;                                    \
+    printBuf.Zero();                                        \
+    APPEND_STRING(iUserNameUsed);                      \
 	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_CANCEL_SET_RESOURCE_STATE_START, aResourceId, (TInt)(ClientHandle()), printBuf.Ptr(), printBuf.Length()); \
 	}
 
 // Macro to output information on completion of a request to cancel the get resource state requests for a resource
 #define PRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE			\
 	{														\
-    TBuf8<256> printBuf;									\
-    printBuf.Zero();										\
-    UsTraceFormatPrint(printBuf, "%S ", iUserNameUsed);		\
+    TBuf8<80> printBuf;                                    \
+    printBuf.Zero();                                        \
+    APPEND_STRING(iUserNameUsed);                      \
 	BTraceContextN(BTrace::EResourceManagerUs, PRM_US_CANCEL_SET_RESOURCE_STATE_END, aResourceId, (TInt)(ClientHandle()), printBuf.Ptr(), printBuf.Length()); \
 	}
 
--- a/kernel/eka/include/drivers/resource.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/resource.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-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"
@@ -168,12 +168,37 @@
 	    __KTRACE_OPT(KRESMANAGER, Kern::Printf(">TPowerResourceCb::DfcFunc ClientId = 0x%x, ResourceId = %d, Level = %d, \
 			                    LevelOwnerId = %d, Result = %d", pCb->iClientId, pCb->iResourceId, pCb->iLevel, \
 								pCb->iLevelOwnerId, pCb->iResult));
-	    // Call the client specified callback function
-        pCb->iCallback(pCb->iClientId, pCb->iResourceId, pCb->iLevel, pCb->iLevelOwnerId, pCb->iResult, pCb->iParam);
-		pCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+
+        pCb->Lock();
+        TUint ClientId = pCb->iClientId;
+        TUint ResourceId = pCb->iResourceId;
+        TInt Level = pCb->iLevel;
+        TInt LevelOwnerId = pCb->iLevelOwnerId;
+        TInt Result = pCb->iResult;
+        TAny* Param = pCb->iParam;
+        pCb->UnLock();
+
+        // Call the client specified callback function
+        pCb->iCallback(ClientId, ResourceId, Level, LevelOwnerId, Result, Param);    
+
+        pCb->Lock();
+        pCb->iPendingRequestCount--;
+        if(pCb->iPendingRequestCount == 0)
+            pCb->iResult = KErrCompletion; //Mark the callback object to act properly during cancellation of this request.
+        pCb->UnLock();
         PRM_CALLBACK_COMPLETION_TRACE
         }
 private:
+    void Lock()
+        {
+        NKern::ThreadEnterCS();
+        Kern::MutexWait(*iMutex);
+        }
+    void UnLock()
+        {
+        Kern::MutexSignal(*iMutex);
+        NKern::ThreadLeaveCS();
+        }
     TAny* iParam; //Stores the aPtr argument passed in the constructor, to be passed as 5th argument to the callback function
     TInt iResult; //Used to store the result aswell as binary usage count for the callback
     TInt iLevel; // Level of the resource
@@ -181,6 +206,8 @@
     TUint iResourceId; //Stores the ID of the resource whose state is changed/read asynchronously
     TUint iClientId; //Stores the ID of the client that requested the asynchronous operation
     TPowerResourceCbFn iCallback; //Callback function object
+	DMutex* iMutex;   
+    TInt iPendingRequestCount;
 #ifdef PRM_CONTROLLER
     friend class DPowerResourceController;
 #endif
--- a/kernel/eka/include/drivers/resourcecontrol_trace.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/resourcecontrol_trace.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-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"
@@ -26,16 +26,6 @@
 #define __RESOURCECONTROL_TRACE_H__
 #ifdef BTRACE_RESOURCE_MANAGER
 
-//Function to format the output.
-static void TraceFormatPrint(TDes8& aBuf, const char* aFmt, ...)
-	{
-	if(aBuf.MaxLength() == 0)
-		return;
-	VA_LIST list;
-	VA_START(list,aFmt);
-	Kern::AppendFormat(aBuf,aFmt,list);
-	}
-
 //definition of subcategories.
 #define PRM_REGISTER_RESOURCE BTrace::ERegisterResource
 #define PRM_REGISTER_CLIENT BTrace::ERegisterClient
@@ -66,13 +56,27 @@
 #define PRM_REGISTER_RESOURCE_DEPENDENCY BTrace::ERegisterResourceDependency
 #define PRM_DEREGISTER_RESOURCE_DEPENDENCY BTrace::EDeRegisterResourceDependency
 #endif
+
+#define APPEND_VAL(val)                                                                        \
+    {                                                                                               \
+    printBuf.Append((TUint8 *)&(val), sizeof(val));                                                       \
+    }                                                                                           
+#define APPEND_STRING(des_ptr)                                                                           \
+    {                                                                                               \
+	TUint length = (des_ptr)->Length();                                                              \
+	printBuf.Append((TUint8 *)&length, sizeof(TUint));                                                     \
+	printBuf.Append(*(des_ptr));                                                                       \
+    }
+
 //Macro to output resource information
 #define PRM_REGISTER_RESOURCE_TRACE																	\
 	{																								\
     TBuf8<80> printBuf;																				\
     printBuf.Zero();													                            \
-    TraceFormatPrint(printBuf, "%S %d %d %d", pR->iName, pResInfo->iMinLevel, pResInfo->iMaxLevel,	\
-																		 pResInfo->iDefaultLevel);	\
+    APPEND_VAL(pResInfo->iMinLevel);                                                       \
+    APPEND_VAL(pResInfo->iMaxLevel);                                                       \
+    APPEND_VAL(pResInfo->iDefaultLevel);                                                   \
+    APPEND_STRING(pR->iName);                                                                     \
 	BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_RESOURCE, resCount+1, pR, printBuf.Ptr(), \
 	                                                                     printBuf.Length());		\
 	}
@@ -80,15 +84,21 @@
 //Macro to output client details. Used during client registration
 #define PRM_CLIENT_REGISTER_TRACE			                                                        \
 	{									                                                            \
+    TBuf8<80> printBuf;                                                                             \
+    printBuf.Zero();                                                                                \
+    APPEND_STRING(pC->iName);                                                                       \
 	BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_CLIENT, aClientId, (TUint)pC,				\
-                                                pC->iName->Ptr(), pC->iName->Length());             \
+                                                printBuf.Ptr(), printBuf.Length());             \
 	}
 
 //Used during client deregistration
 #define PRM_CLIENT_DEREGISTER_TRACE																	\
 	{																								\
+    TBuf8<80> printBuf;                                                                             \
+    printBuf.Zero();                                                                                \
+    APPEND_STRING(pC->iName);                                                                       \
 	BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_CLIENT, aClientId,						\
-                          (TUint)pC, pC->iName->Ptr(), pC->iName->Length());						\
+                          (TUint)pC, printBuf.Ptr(), printBuf.Length());						    \
 	}
 
 //Used to resource state change operation.Used at the start of the operation. 
@@ -96,7 +106,9 @@
 	{																								\
     TBuf8<80> printBuf;																				\
 	printBuf.Zero();																				\
-    TraceFormatPrint(printBuf, "%S %S %d", pC->iName, pR->iName, aNewState);						\
+	APPEND_VAL(aNewState);                                                                          \
+	APPEND_STRING(pC->iName);                                                                     \
+	APPEND_STRING(pR->iName);                                                                     \
 	BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_STATE_CHANGE_START, pC->iClientId,			\
 	                                      aResourceId, printBuf.Ptr(), printBuf.Length());			\
 	}
@@ -106,7 +118,10 @@
 	{																								\
 	TBuf8<80> printBuf;																				\
 	printBuf.Zero();																				\
-	TraceFormatPrint(printBuf, "%S %S %d %d", pC->iName, pR->iName, r, aNewState);					\
+	APPEND_VAL(r);                                                                                  \
+	APPEND_VAL(aNewState);                                                                          \
+	APPEND_STRING(pC->iName);                                                                  \
+	APPEND_STRING(pR->iName);                                                                  \
 	BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_STATE_CHANGE_END, pC->iClientId,			\
 						                 aResourceId, printBuf.Ptr(), printBuf.Length());			\
 	}
@@ -142,8 +157,6 @@
 //Calling TraceFormatPrint just to avoid warning
 #define PRM_CALLBACK_COMPLETION_TRACE																\
 	{																								\
-	TPtr8 zeroDes(NULL, 0);																		\
-	TraceFormatPrint(zeroDes, "%d", pCb->iClientId);												\
 	BTraceContext8(BTrace::EResourceManager, PRM_CALLBACK_COMPLETE, pCb->iClientId,					\
                                                                  pCb->iResourceId);					\
 	}
@@ -156,9 +169,9 @@
 
 #define PRM_PSL_RESOURCE_GET_STATE_START_TRACE														\
 	{																								\
-	TBuf8<80> printBuf;																				\
-	printBuf.Zero();																				\
-	TraceFormatPrint(printBuf, "%S ", iName);														\
+    TBuf8<80> printBuf;                                                                             \
+    printBuf.Zero();                                                                                \
+    APPEND_STRING(iName);                                                                           \
 	BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_GET_STATE_START, aRequest.ClientId(), \
 										 aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length());	\
 	}
@@ -168,7 +181,8 @@
 	{																								\
 	TBuf8<80> printBuf;																				\
 	printBuf.Zero();																				\
-    TraceFormatPrint(printBuf, "%S %S", pC->iName, pR->iName);										\
+	APPEND_STRING(pC->iName);                                                                     \
+	APPEND_STRING(pR->iName);                                                                  \
 	BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_GET_STATE_START, pC->iClientId, aResourceId,\
 												                 printBuf.Ptr(), printBuf.Length());\
 	}
@@ -177,7 +191,9 @@
 	{																								\
 	TBuf8<80> printBuf;																				\
 	printBuf.Zero();																				\
-	TraceFormatPrint(printBuf, "%S %d %d", iName, iCurLevel,retVal);								\
+	APPEND_VAL(iCurLevel);                                                                          \
+	APPEND_VAL(retVal);                                                                             \
+	APPEND_STRING(iName);                                                                      \
 	BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_GET_STATE_END, aRequest.ClientId(),	\
 										aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length());	\
 	}
@@ -187,7 +203,10 @@
 	{																								\
 	TBuf8<80> printBuf;																				\
 	printBuf.Zero();																				\
-	TraceFormatPrint(printBuf, "%S %S %d %d", pC->iName, pR->iName, aState, r);						\
+	APPEND_VAL(aState);                                                                             \
+	APPEND_VAL(r);                                                                                  \
+	APPEND_STRING(pC->iName);                                                                  \
+	APPEND_STRING(pR->iName);                                                                  \
 	BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_GET_STATE_END, pC->iClientId, aResourceId,	\
 																 printBuf.Ptr(), printBuf.Length());\
 	}
@@ -197,7 +216,9 @@
 	{																								\
 	TBuf8<80> printBuf;																				\
 	printBuf.Zero();																				\
-	TraceFormatPrint(printBuf, "%S %S %d", pC->iName, pR->iName, r);								\
+	APPEND_VAL(r);                                                                                  \
+	APPEND_STRING(pC->iName);                                                                  \
+	APPEND_STRING(pR->iName);                                                                  \
 	BTraceContextN(BTrace::EResourceManager, PRM_CANCEL_LONG_LATENCY_OPERATION, pC->iClientId,		\
 										      aResourceId, printBuf.Ptr(), printBuf.Length());		\
 	}
@@ -206,7 +227,10 @@
 	{																									\
 	TBuf8<80> printBuf;																					\
 	printBuf.Zero();																					\
-	TraceFormatPrint(printBuf, "%S %d %d", iName, iCurLevel, aRequest.Level());							\
+	APPEND_VAL(iCurLevel);                                                                              \
+	TInt RequestLevel = aRequest.Level();                                                                      \
+	APPEND_VAL(RequestLevel);                                                                                 \
+	APPEND_STRING(iName);                                                                          \
 	BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CHANGE_STATE_START, aRequest.ClientId(),	\
 											aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length());  \
 	}
@@ -215,7 +239,11 @@
 	{																									\
 	TBuf8<80> printBuf;																					\
 	printBuf.Zero();																					\
-	TraceFormatPrint(printBuf, "%S %d %d %d", iName, iCurLevel, aRequest.Level(),retVal);				\
+	APPEND_VAL(iCurLevel);                                                                              \
+    TInt RequestLevel = aRequest.Level();                                                                      \
+	APPEND_VAL(RequestLevel);                                                                                  \
+	APPEND_VAL(retVal);                                                                                 \
+	APPEND_STRING(iName);                                                                          \
 	BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CHANGE_STATE_END, aRequest.ClientId(),	\
 										  aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length());	\
 	}
@@ -224,7 +252,9 @@
 	{																									\
 	TBuf8<80> printBuf;																					\
 	printBuf.Zero();																					\
-	TraceFormatPrint(printBuf, "%d %d %S", iDefaultLevel, iFlags, iName);								\
+	APPEND_VAL(iDefaultLevel);                                                                          \
+	APPEND_VAL(iFlags);                                                                                 \
+	APPEND_STRING(iName);                                                                          \
 	BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CREATE, iMinLevel, iMaxLevel,				\
 											            printBuf.Ptr(), printBuf.Length());				\
 	}
@@ -233,8 +263,6 @@
 //Calling TraceFormatPrint just to avoid warning
 #define PRM_BOOTING_TRACE																				\
 	{																									\
-	TPtr8 zeroDes(NULL, 0);																			\
-	TraceFormatPrint(zeroDes, "%d", aReason);															\
 	BTraceContext4(BTrace::EResourceManager, PRM_BOOTING, (TUint)aReason);								\
 	}
 
@@ -242,12 +270,14 @@
 //Macro to output static resource with dependency
 #define PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE													\
 	{																										\
-	TBuf8<80> pBuf;																							\
-	pBuf.Zero();																							\
-	TraceFormatPrint(pBuf, "%S %d %d %d", pR->iName, pResInfo->iMinLevel, pResInfo->iMaxLevel,				\
-										                             pResInfo->iDefaultLevel);				\
+	TBuf8<80> printBuf;																							\
+	printBuf.Zero();																							\
+	APPEND_VAL(pResInfo->iMinLevel);                                                                        \
+	APPEND_VAL(pResInfo->iMaxLevel);                                                                        \
+	APPEND_VAL(pResInfo->iDefaultLevel);                                                                    \
+	APPEND_STRING(pR->iName);                                                                          \
 	BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY, pR->iResourceId, \
-	                                                                        pR, pBuf.Ptr(), pBuf.Length());	\
+	                                                               pR, printBuf.Ptr(), printBuf.Length());	\
 	}
 
 //Macro to output dynamic resource registration.
@@ -255,7 +285,9 @@
 	{																										\
 	TBuf8<80> printBuf;																						\
 	printBuf.Zero();																						\
-	TraceFormatPrint(printBuf, "%S %S %d", aClientPtr->iName, aPDRes->iName, aPDRes);						\
+	APPEND_VAL(aPDRes);                                                                                     \
+	APPEND_STRING(aClientPtr->iName);                                                                         \
+	APPEND_STRING(aPDRes->iName);                                                                      \
 	BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_DYNAMIC_RESOURCE, aClientPtr->iClientId,			\
 										   aPDRes->iResourceId, printBuf.Ptr(), printBuf.Length());			\
 	}
@@ -265,7 +297,10 @@
 	{																										\
 	TBuf8<80> printBuf;																						\
 	printBuf.Zero();																						\
-	TraceFormatPrint(printBuf, "%S %S %d %d", aClientPtr->iName, pDR->iName, pDR, level);					\
+	APPEND_VAL(pDR);                                                                                        \
+	APPEND_VAL(level);                                                                                      \
+	APPEND_STRING(aClientPtr->iName);                                                                  \
+	APPEND_STRING(pDR->iName);                                                                         \
 	BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_DYNAMIC_RESOURCE, aClientPtr->iClientId,		\
 												pDR->iResourceId, printBuf.Ptr(), printBuf.Length());		\
 	}
@@ -273,10 +308,14 @@
 //Macro to output registration of resource dependency.
 #define PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE																\
 	{																										\
-	TBuf8<256> printBuf;																					\
+	TBuf8<80> printBuf;																					\
 	printBuf.Zero();																						\
-	TraceFormatPrint(printBuf, "%S %S %d %S %d %d", aClientPtr->iName, pR1->iName, pR2->iResourceId,		\
-										                                      pR2->iName, pR1, pR2);		\
+	APPEND_VAL(pR2->iResourceId);                                                                           \
+    APPEND_VAL(pR1);                                                                                        \
+    APPEND_VAL(pR2);                                                                                        \
+    APPEND_STRING(aClientPtr->iName);                                                                  \
+    APPEND_STRING(pR1->iName);                                                                         \
+    APPEND_STRING(pR2->iName);                                                                         \
 	BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_RESOURCE_DEPENDENCY, aClientPtr->iClientId,		\
 	                                            pR1->iResourceId, printBuf.Ptr(), printBuf.Length());		\
 	}
@@ -284,10 +323,14 @@
 //Macro to output deregistration of resource dependency.
 #define PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE															\
 	{																										\
-	TBuf8<256> printBuf;																					\
+	TBuf8<80> printBuf;																					\
 	printBuf.Zero();																						\
-	TraceFormatPrint(printBuf, "%S %S %d %S %d %d", aClientPtr->iName, pDR1->iName, pDR2->iResourceId,		\
-												                             pDR2->iName, pDR1, pDR2);		\
+	APPEND_VAL(pDR2->iResourceId);                                                                          \
+    APPEND_VAL(pDR1);                                                                                       \
+    APPEND_VAL(pDR2);                                                                                       \
+    APPEND_STRING(aClientPtr->iName);                                                                  \
+    APPEND_STRING(pDR1->iName);                                                                        \
+    APPEND_STRING(pDR2->iName);                                                                        \
 	BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_RESOURCE_DEPENDENCY, aClientPtr->iClientId,		\
 	                                              pDR1->iResourceId, printBuf.Ptr(), printBuf.Length());	\
 	}
--- a/kernel/eka/include/drivers/rm_debug_eventhandler.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/rm_debug_eventhandler.h	Wed Aug 18 11:08:29 2010 +0300
@@ -27,15 +27,8 @@
 		TInt Start();
 		TInt Stop();
 		
-		inline void DRM_DebugEventHandler::LockDataAccess()
-		    {
-		    Kern::SemaphoreWait(*iProtectionLock);
-		    }
-
-		inline void DRM_DebugEventHandler::ReleaseDataAccess()
-		    {
-		    Kern::SemaphoreSignal(*iProtectionLock);
-		    }
+		inline void LockDataAccess();
+		inline void ReleaseDataAccess();
 		
 	private:
 		static TUint EventHandler(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis);
@@ -57,4 +50,6 @@
 		eventHandler iEventHandlers[EEventLimit];
 };
 
+#include <rm_debug_eventhandler.inl>
+
 #endif //__RM_DEBUG_EVENTHANDLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/eka/include/drivers/rm_debug_eventhandler.inl	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,27 @@
+// 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:
+// Event handler and container for all objects being tracked.
+//
+
+	
+inline void DRM_DebugEventHandler::LockDataAccess()
+    {
+    Kern::SemaphoreWait(*iProtectionLock);
+    }
+
+inline void DRM_DebugEventHandler::ReleaseDataAccess()
+    {
+    Kern::SemaphoreSignal(*iProtectionLock);
+    }
+		
--- a/kernel/eka/include/drivers/usbcsc.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/drivers/usbcsc.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2000-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"
@@ -235,7 +235,6 @@
 	TUint* iPhysicalMap;
 public:
 	DChunk* iChunk;
-	TDfc iCleanup;
 
 	TInt8 iPageNtz; // Number of trailing zeros for a page. (Eg 4k page has 12 t.z.)
 	TInt iAllocatedSize;
@@ -415,6 +414,8 @@
 	void CancelQueued(TInt aErrorCode=KErrCancel);
 	TInt Complete(TInt aError);
 	void Complete();
+	void SetClient(DThread& aThread);
+	TBool IsRequestPending();
 public:
 	TUsbcScStatusState iState;
 
@@ -457,6 +458,7 @@
 	void UpdateBufferList(TInt aByteCount,TUint aFlags, TBool aStartNextRead=ETrue);
 	void Ep0CancelLddRead();
 	void SendEp0StatusPacket(TInt aState);
+	TBool IsRequestPending();
 
 public:
 	
--- a/kernel/eka/include/e32btrace.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/e32btrace.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1437,462 +1437,500 @@
 		EPagingPageTableAlloc,
 		};
 
-	/**
-	Enumeration of sub-category values for trace category EResourceManager.
-	@see EResourceManager
-	@prototype 9.5
-	*/
-	enum TResourceManager
-		{
-		/**
-		Trace output for resource registration.
-
-		Trace data format:
-		- 4 bytes containing the Resource Id.
-		- 4 bytes containing the Resource address.
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing the Resource Minimum Level
-		- 4 bytes containing the Resource Maximum Level
-		- 4 bytes containing the Resource Default Level
-		*/
-		ERegisterResource = 0,
-
-		/**
-		Trace output for client registration
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing client address
-		- N bytes containing client name, where 0 < N < 32
-		*/
-		ERegisterClient,
-
-		/**
-		Trace output for client deregistration
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing client address
-		- N bytes containing client name, where 0 < N < 32
-		*/
-		EDeRegisterClient,
-
-		/**
-		Trace output for resource state change start operation
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing client name, where 0 < N < 32
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing the Resource state
-		*/
-		ESetResourceStateStart,
-
-		/**
-		Trace output for resource state change end operation
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing client name, where 0 < N < 32
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing return value.
-		- 4 bytes containing the Resource state.
-		*/
-		ESetResourceStateEnd,
-
-		/**
-		Trace output for registration for post notification
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- 4 bytest containing the callback address
-		- 4 bytes containing return value.
-		*/
-		EPostNotificationRegister,
-
-		/**
-		Trace output for deregistration for post notification
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- 4 bytes containing the callback address
-		- 4 bytes containing the return value.
-		*/
-		EPostNotificationDeRegister,
-
-		/**
-		Trace output for post notification sent.
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		*/
-		EPostNotificationSent,
-
-		/**
-		Trace output for Callback complete
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		*/
-		ECallbackComplete,
-
-		/**
-		Trace output for resource manager memory usage
-
-		Trace data format:
-		- 4 bytes containing memory allocated in bytes.
-		*/
-		EMemoryUsage,
-
-		/**
-		Trace output for get resource state start operation
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing client name, where 0 < N < 32
-		- N bytes containing the Resource name, where 0 < N < 32
-		*/
-		EGetResourceStateStart,
-
-		/**
-		Trace output for get resource state end operation
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing client name, where 0 < N < 32
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing the Resource state
-		- 4 bytes containing return value.
-		*/
-		EGetResourceStateEnd,
-
-		/**
-		Trace output for cancellation of long latency operation
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing client name, where 0 < N < 32
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing return value
-		*/
-		ECancelLongLatencyOperation,
-
-		/**
-		Trace output for booting of resource manager
-
-		Trace data format:
-		- 4 bytes containing entry point
-		*/
-		EBooting,
-
-		/**
-		Trace output for PSL resource state change operation
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing the Resource current state
-		- 4 bytes containing the resource requested state
-		*/
-		EPslChangeResourceStateStart,
-
-		/**
-		Trace output for PSL resource state change operation
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing the Resource current state
-		- 4 bytes containing the resource requested state
-		- 4 bytes containing return value
-		*/
-		EPslChangeResourceStateEnd,
-
-		/**
-		Trace output for get resource state start operation in PSL
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing the Resource name, where 0 < N < 32
-		*/
-		EPslGetResourceStateStart,
-
-		/**
-		Trace output for get resource state end operation in PSL
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id.
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing the Resource state
-		- 4 bytes containing return value.
-		*/
-		EPslGetResourceStateEnd,
-
-		/**
-		Trace output for resource creation
-
-		Trace data format:
-		- 4 bytes containing minimum value of resource
-		- 4 bytes containing maximum value of resource
-		- 4 bytes containing the default value of resource
-		- 4 bytes containing the properties of the resource
-		- N bytes containing the Resource name, where 0 < N < 32
-		*/
-		EPslResourceCreate,
-
-		/**
-		Trace output for static resource with dependency registration
-
-		Trace data format:
-		- 4 bytes containing the Resource Id
-		- 4 bytes containing the Resource address
-		- N bytes containing the Resource name, where 0 < N < 32
-		- 4 bytes containing the minimum value of resource
-		- 4 bytes containing the maximum value of resource
-		- 4 bytes containing the default value of resource
-		*/
-		ERegisterStaticResourceWithDependency,
-
-		/**
-		Trace output for dynamic resource registration
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id
-		- N bytes containing the client name, where 0 < N < 32
-		- N bytes containing the resource name, where 0 < N < 32
-		- 4 bytes containing the resouce address
-		*/
-		ERegisterDynamicResource,
-
-		/**
-		Trace output for dynamic resource deregistration
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id
-		- N bytes containing the client name, where 0 < N < 32
-		- N bytes containing the resource name, where 0 < N < 32
-		- 4 bytes containing the resource address
-		- 4 bytes containing the resource level.
-		*/
-		EDeRegisterDynamicResource,
-
-		/**
-		Trace output for resource dependency registration
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id of first dependent resource
-		- N bytes containing the client name, where 0 < N < 32
-		- N bytes containing the resource name of first dependent resource, where 0 < N < 32
-		- 4 bytes containing the Resource Id of second dependent resource
-		- N bytes containing the resource name of second dependent resource, where 0 < N < 32
-		- 4 bytes containing the address of first dependent resource
-		- 4 bytes containing the address of second dependent resource
-		*/
-		ERegisterResourceDependency,
-
-		/**
-		Trace output for resource dependency deregistration
-
-		Trace data format:
-		- 4 bytes containing clientId
-		- 4 bytes containing the Resource Id of first dependent resource
-		- N bytes containing the client name, where 0 < N < 32
-		- N bytes containing the resource name of first dependent resource, where 0 < N < 32
-		- 4 bytes containing the resource id of second dependent resource
-		- N bytes containing the resource name of second dependent resource, where 0 < N < 32
-		- 4 bytes containing the address of first dependent resource
-		- 4 bytes containing the address of second dependent resource
-		*/
-		EDeRegisterResourceDependency
-		};
-	/**
-	Enumeration of sub-category values for trace category EResourceManagerUs.
-	@see EResourceManagerUs
-	@prototype 9.5
-	*/
-	enum TResourceManagerUs
-		{
-		/**
-		Trace output for the start of opening a channel to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes unused (displays 0)
-		- 4 bytes containing the client thread identifier.
-		- N bytes containing the client name, where 0 < N < 32
-		*/
-		EOpenChannelUsStart = 0,
-		/**
-		Trace output for the end of opening a channel to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes unused (displays 0)
-		- 4 bytes containing the client identifier provided by the Resource Controller
-		- N bytes containing the client name, where 0 < N < 32
-		*/
-		EOpenChannelUsEnd,
-		/**
-		Trace output for the start of registering a client with the Resource Controller.
-
-		Trace data format:
-		- 4 bytes the number of concurrent change resource state operations to be supported
-		- 4 bytes the number of concurrent notification requests to be supported
-		- N bytes containing the client name, where 0 < N < 32
-		- 4 bytes the number of concurrent get resource state operations to be supported
-		*/
-		ERegisterClientUsStart,
-		/**
-		Trace output for the end of registering a client with the Resource Controller.
-
-		Trace data format:
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		- 4 bytes specifying the value returned from the call to Resource Controller's AllocReserve method
-		*/
-		ERegisterClientUsEnd,
-		/**
-		Trace output for the start of de-registering a client with the Resource Controller.
-
-		Trace data format:
-		- 4 bytes unused (displays 0)
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		- N bytes containing the client name, where 0 < N < 32
-		*/
-		EDeRegisterClientUsStart,
-		/**
-		Trace output for the end of registering a client with the Resource Controller.
-
-		Trace data format:
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		*/
-		EDeRegisterClientUsEnd,
-		/**
-		Trace output for the start of a GetResourceState request to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes specifying the resource ID
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		- N bytes containing the client name, where 0 < N < 32
-		*/
-		EGetResourceStateUsStart,
-		/**
-		Trace output for the end of a GetResourceState request to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes specifying the resource ID
-		- 4 bytes specifying the resource level
-		- 4 bytes containing the client identifier
-		- 4 bytes specifying the success code returned by the Resource Controller.
-		*/
-		EGetResourceStateUsEnd,
-		/**
-		Trace output for the start of a ChangeResourceState request to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes specifying the resource ID
-		- 4 bytes specifying the required state
-		- N bytes containing the client name, where 0 < N < 32
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		*/
-		ESetResourceStateUsStart,
-		/**
-		Trace output for the end of a ChangeResourceState request to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes specifying the resource ID
-		- 4 bytes specifying the requested state
-		- 4 bytes containing the client identifier
-		- 4 bytes specifying the success code returned by the Resource Controller.
-		*/
-		ESetResourceStateUsEnd,
-		/**
-		Trace output for the start of a cancel GetResourceState request to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes specifying the resource ID
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		- N bytes containing the client name, where 0 < N < 32
-		*/
-		ECancelGetResourceStateUsStart,
-		/**
-		Trace output for the end of a cancel GetResourceState request to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes specifying the resource ID
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		- N bytes containing the client name, where 0 < N < 32
-		*/
-		ECancelGetResourceStateUsEnd,
-		/**
-		Trace output for the start of a cancel ChangeResourceState request to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes specifying the resource ID
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		- N bytes containing the client name, where 0 < N < 32
-		*/
-		ECancelSetResourceStateUsStart,
-		/**
-		Trace output for the end of a cancel ChangeResourceState request to the Resource Controller.
-
-		Trace data format:
-		- 4 bytes specifying the resource ID
-		- 4 bytes containing the client identifier provided by the Resource Controller.
-		- N bytes containing the client name, where 0 < N < 32
-		*/
-		ECancelSetResourceStateUsEnd
-		};
-
-	/**
-	Enumeration of sub-category values for trace category EThreadPriority.
-	@see EThreadPriority
-	@internalTechnology
-	@prototype 9.3
-	*/
-	enum TThreadPriority
-		{
-		/**
-		Trace output when a nanothread priority is changed.
-
-		Trace data format:
-		- 4 bytes containing the context id (an NThread*) for the thread whose priority is changing.
-		- 4 bytes containing the new absolute priority.
-		*/
-		ENThreadPriority=0,
-
-		/**
-		Trace output when a DThread's default priority is set.
-
-		Trace data format:
-		- 4 bytes containing the context id (an NThread*) for the thread whose priority is changing.
-		- 4 bytes containing the iThreadPriority member - a value from enum ::TThrdPriority.
-		- 4 bytes containing the new default absolute priority.
-		*/
-		EDThreadPriority=1,
-
-		/**
-		Trace output when a DProcess priority is changed.
-
-		Trace data format:
-		- 4 bytes containing trace id (a DProcess*) for process.
-		- 4 bytes containing the new process priority, a value from enum ::TProcPriority
-		*/
-		EProcessPriority=2
-		};
+    /**
+    Enumeration of sub-category values for trace category EResourceManager.
+    @see EResourceManager
+    @prototype 9.5
+    */
+    enum TResourceManager
+        {
+        /**
+        Trace output for resource registration.
+
+        Trace data format:
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the Resource address.
+        - 4 bytes containing the Resource Minimum Level
+        - 4 bytes containing the Resource Maximum Level
+        - 4 bytes containing the Resource Default Level
+        - 4 bytes containing the length of resource name
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        ERegisterResource = 0,
+
+        /**
+        Trace output for client registration
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing client address
+        - 4 bytes containing the length of client name
+        - N bytes containing client name, where 0 < N < 32
+        */
+        ERegisterClient,
+
+        /**
+        Trace output for client deregistration
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing client address
+        - 4 bytes containing the length of client name
+        - N bytes containing client name, where 0 < N < 32
+        */
+        EDeRegisterClient,
+
+        /**
+        Trace output for resource state change start operation
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the Resource state
+        - 4 bytes containing the length of client name
+        - N bytes containing client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        ESetResourceStateStart,
+
+        /**
+        Trace output for resource state change end operation
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing return value.
+        - 4 bytes containing the Resource state.
+        - 4 bytes containing the length of client name
+        - N bytes containing client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name        
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        ESetResourceStateEnd,
+
+        /**
+        Trace output for registration for post notification
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytest containing the callback address
+        - 4 bytes containing return value.
+        */
+        EPostNotificationRegister,
+
+        /**
+        Trace output for deregistration for post notification
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the callback address
+        - 4 bytes containing the return value.
+        */
+        EPostNotificationDeRegister,
+
+        /**
+        Trace output for post notification sent.
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        */
+        EPostNotificationSent,
+
+        /**
+        Trace output for Callback complete
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        */
+        ECallbackComplete,
+
+        /**
+        Trace output for resource manager memory usage
+
+        Trace data format:
+        - 4 bytes containing memory allocated in bytes.
+        */
+        EMemoryUsage,
+
+        /**
+        Trace output for get resource state start operation
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the length of client name.
+        - N bytes containing client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name.
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        EGetResourceStateStart,
+
+        /**
+        Trace output for get resource state end operation
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the Resource state
+        - 4 bytes containing return value.
+        - 4 bytes containing the length of client name.
+        - N bytes containing client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name.
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        EGetResourceStateEnd,
+
+        /**
+        Trace output for cancellation of long latency operation
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing return value
+        - 4 bytes containing the length of client name.
+        - N bytes containing client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name.
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        ECancelLongLatencyOperation,
+
+        /**
+        Trace output for booting of resource manager
+
+        Trace data format:
+        - 4 bytes containing entry point
+        */
+        EBooting,
+
+        /**
+        Trace output for PSL resource state change operation
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the Resource current state
+        - 4 bytes containing the resource requested state
+        - 4 bytes containing the length of resource name.
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        EPslChangeResourceStateStart,
+
+        /**
+        Trace output for PSL resource state change operation
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the Resource current state
+        - 4 bytes containing the resource requested state
+        - 4 bytes containing return value
+        - 4 bytes containing the length of resource name.
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        EPslChangeResourceStateEnd,
+
+        /**
+        Trace output for get resource state start operation in PSL
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the length of resource name.
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        EPslGetResourceStateStart,
+
+        /**
+        Trace output for get resource state end operation in PSL
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id.
+        - 4 bytes containing the Resource state
+        - 4 bytes containing return value.
+        - 4 bytes containing the length of resource name.
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        EPslGetResourceStateEnd,
+
+        /**
+        Trace output for resource creation
+
+        Trace data format:
+        - 4 bytes containing minimum value of resource
+        - 4 bytes containing maximum value of resource
+        - 4 bytes containing the default value of resource
+        - 4 bytes containing the properties of the resource
+        - 4 bytes containing the length of resource name.
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        EPslResourceCreate,
+
+        /**
+        Trace output for static resource with dependency registration
+
+        Trace data format:
+        - 4 bytes containing the Resource Id
+        - 4 bytes containing the Resource address
+        - 4 bytes containing the minimum value of resource
+        - 4 bytes containing the maximum value of resource
+        - 4 bytes containing the default value of resource
+        - 4 bytes containing the length of resource name
+        - N bytes containing the Resource name, where 0 < N < 32
+        */
+        ERegisterStaticResourceWithDependency,
+
+        /**
+        Trace output for dynamic resource registration
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id
+        - 4 bytes containing the resouce address
+        - 4 bytes containing the length of client name
+        - N bytes containing the client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name
+        - N bytes containing the resource name, where 0 < N < 32
+        */
+        ERegisterDynamicResource,
+
+        /**
+        Trace output for dynamic resource deregistration
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id
+        - 4 bytes containing the resource address
+        - 4 bytes containing the resource level.
+        - 4 bytes containing the length of client name
+        - N bytes containing the client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name
+        - N bytes containing the resource name, where 0 < N < 32
+        */
+        EDeRegisterDynamicResource,
+
+        /**
+        Trace output for resource dependency registration
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id of first dependent resource
+        - 4 bytes containing the Resource Id of second dependent resource
+        - 4 bytes containing the address of first dependent resource
+        - 4 bytes containing the address of second dependent resource
+        - 4 bytes containing the length of client name
+        - N bytes containing the client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name of first dependent resource
+        - N bytes containing the resource name of first dependent resource, where 0 < N < 32
+        - 4 bytes containing the length of resource name of second dependent resource
+        - N bytes containing the resource name of second dependent resource, where 0 < N < 32
+        */
+        ERegisterResourceDependency,
+
+        /**
+        Trace output for resource dependency deregistration
+
+        Trace data format:
+        - 4 bytes containing clientId
+        - 4 bytes containing the Resource Id of first dependent resource
+        - 4 bytes containing the resource id of second dependent resource
+        - 4 bytes containing the address of first dependent resource
+        - 4 bytes containing the address of second dependent resource
+        - 4 bytes containing the length of client name
+        - N bytes containing the client name, where 0 < N < 32
+        - 4 bytes containing the length of resource name of first dependent resource
+        - N bytes containing the resource name of first dependent resource, where 0 < N < 32
+        - 4 bytes containing the length of resource name of second dependent resource
+        - N bytes containing the resource name of second dependent resource, where 0 < N < 32
+        */
+        EDeRegisterResourceDependency
+        };
+    /**
+    Enumeration of sub-category values for trace category EResourceManagerUs.
+    @see EResourceManagerUs
+    @prototype 9.5
+    */
+    enum TResourceManagerUs
+        {
+        /**
+        Trace output for the start of opening a channel to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes containing the client thread identifier.
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        EOpenChannelUsStart = 0,
+        /**
+        Trace output for the end of opening a channel to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes containing the client identifier provided by the Resource Controller
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        EOpenChannelUsEnd,
+        /**
+        Trace output for the start of registering a client with the Resource Controller.
+
+        Trace data format:
+        - 4 bytes containing the client identifier provided by the Resource Controller
+        - 1 bytes the number of concurrent change resource state operations to be supported
+        - 1 bytes the number of concurrent notification requests to be supported        
+        - 1 bytes the number of concurrent get resource state operations to be supported
+        - 1 bytes unused        
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        ERegisterClientUsStart,
+        /**
+        Trace output for the end of registering a client with the Resource Controller.
+
+        Trace data format:
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        - 4 bytes specifying the value returned from the call to Resource Controller's AllocReserve method
+        */
+        ERegisterClientUsEnd,
+        /**
+        Trace output for the start of de-registering a client with the Resource Controller.
+
+        Trace data format:
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        EDeRegisterClientUsStart,
+        /**
+        Trace output for the end of registering a client with the Resource Controller.
+
+        Trace data format:
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        */
+        EDeRegisterClientUsEnd,
+        /**
+        Trace output for the start of a GetResourceState request to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes specifying the resource ID
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        EGetResourceStateUsStart,
+        /**
+        Trace output for the end of a GetResourceState request to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes specifying the resource ID
+        - 4 bytes specifying the resource level
+        - 4 bytes containing the client identifier
+        - 4 bytes specifying the success code returned by the Resource Controller.
+        */
+        EGetResourceStateUsEnd,
+        /**
+        Trace output for the start of a ChangeResourceState request to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes specifying the resource ID
+        - 4 bytes specifying the required state
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        ESetResourceStateUsStart,
+        /**
+        Trace output for the end of a ChangeResourceState request to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes specifying the resource ID
+        - 4 bytes specifying the requested state
+        - 4 bytes containing the client identifier
+        - 4 bytes specifying the success code returned by the Resource Controller.
+        */
+        ESetResourceStateUsEnd,
+        /**
+        Trace output for the start of a cancel GetResourceState request to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes specifying the resource ID
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        ECancelGetResourceStateUsStart,
+        /**
+        Trace output for the end of a cancel GetResourceState request to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes specifying the resource ID
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        ECancelGetResourceStateUsEnd,
+        /**
+        Trace output for the start of a cancel ChangeResourceState request to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes specifying the resource ID
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        ECancelSetResourceStateUsStart,
+        /**
+        Trace output for the end of a cancel ChangeResourceState request to the Resource Controller.
+
+        Trace data format:
+        - 4 bytes specifying the resource ID
+        - 4 bytes containing the client identifier provided by the Resource Controller.
+        - 4 bytes containing the length of client name.
+        - N bytes containing the client name, where 0 < N < 32
+        */
+        ECancelSetResourceStateUsEnd
+        };
+
+    /**
+    Enumeration of sub-category values for trace category EThreadPriority.
+    @see EThreadPriority
+    @internalTechnology
+    @prototype 9.3
+    */
+    enum TThreadPriority
+        {
+        /**
+        Trace output when a nanothread priority is changed.
+
+        Trace data format:
+        - 4 bytes containing the context id (an NThread*) for the thread whose priority is changing.
+        - 4 bytes containing the new absolute priority.
+        */
+        ENThreadPriority=0,
+
+        /**
+        Trace output when a DThread's default priority is set.
+
+        Trace data format:
+        - 4 bytes containing the context id (an NThread*) for the thread whose priority is changing.
+        - 4 bytes containing the iThreadPriority member - a value from enum ::TThrdPriority.
+        - 4 bytes containing the new default absolute priority.
+        */
+        EDThreadPriority=1,
+
+        /**
+        Trace output when a DProcess priority is changed.
+
+        Trace data format:
+        - 4 bytes containing trace id (a DProcess*) for process.
+        - 4 bytes containing the new process priority, a value from enum ::TProcPriority
+        */
+        EProcessPriority=2
+        };
 
 	/**
 	Enumeration of sub-category values for trace category EPagingMedia.
@@ -3913,21 +3951,6 @@
 	/**
 	@internalComponent
 	*/
-	typedef TBool(*TBTrace1)(TUint32);
-
-	/**
-	@internalComponent
-	*/
-	typedef TBool(*TBTrace2)(TUint32,TUint32);
-
-	/**
-	@internalComponent
-	*/
-	typedef TBool(*TBTrace3)(TUint32,TUint32,TUint32);
-
-	/**
-	@internalComponent
-	*/
 	struct SExecExtension
 		{
 		TUint32 iA2;
@@ -4049,8 +4072,8 @@
 @released
 */
 #define BTrace0(aCategory,aSubCategory) \
-	((BTrace::TBTrace1)BTrace::Out) \
-		(BTRACE_HEADER(4,(aCategory),(aSubCategory)))
+	BTrace::Out \
+		(BTRACE_HEADER(4,(aCategory),(aSubCategory)),0,0,0)
 
 /**
 Output a trace record of the specified category.
@@ -4067,8 +4090,8 @@
 @released
 */
 #define BTrace4(aCategory,aSubCategory,a1) \
-	((BTrace::TBTrace2)BTrace::Out) \
-		(BTRACE_HEADER(8,(aCategory),(aSubCategory)),(TUint32)(a1))
+	BTrace::Out \
+		(BTRACE_HEADER(8,(aCategory),(aSubCategory)),(TUint32)(a1),0,0)
 
 /**
 Output a trace record of the specified category.
@@ -4086,8 +4109,8 @@
 @released
 */
 #define BTrace8(aCategory,aSubCategory,a1,a2) \
-	((BTrace::TBTrace3)BTrace::Out) \
-		(BTRACE_HEADER(12,(aCategory),(aSubCategory)),(TUint32)(a1),(TUint32)(a2))
+	BTrace::Out \
+		(BTRACE_HEADER(12,(aCategory),(aSubCategory)),(TUint32)(a1),(TUint32)(a2),0)
 
 /**
 Output a trace record of the specified category.
@@ -4169,8 +4192,8 @@
 @released
 */
 #define BTraceContext0(aCategory,aSubCategory) \
-	((BTrace::TBTrace1)BTrace::OutX) \
-		(BTRACE_HEADER_C(4,(aCategory),(aSubCategory)))
+	BTrace::OutX \
+		(BTRACE_HEADER_C(4,(aCategory),(aSubCategory)),0,0,0)
 
 /**
 Output a trace record of the specified category which also includes a Context ID.
@@ -4187,8 +4210,8 @@
 @released
 */
 #define BTraceContext4(aCategory,aSubCategory,a1) \
-	((BTrace::TBTrace2)BTrace::OutX) \
-		(BTRACE_HEADER_C(8,(aCategory),(aSubCategory)),(TUint32)(a1))
+	BTrace::OutX \
+		(BTRACE_HEADER_C(8,(aCategory),(aSubCategory)),(TUint32)(a1),0,0)
 
 /**
 Output a trace record of the specified category which also includes a Context ID.
@@ -4206,8 +4229,8 @@
 @released
 */
 #define BTraceContext8(aCategory,aSubCategory,a1,a2) \
-	((BTrace::TBTrace3)BTrace::OutX) \
-		(BTRACE_HEADER_C(12,(aCategory),(aSubCategory)),(TUint32)(a1),(TUint32)(a2))
+	BTrace::OutX \
+		(BTRACE_HEADER_C(12,(aCategory),(aSubCategory)),(TUint32)(a1),(TUint32)(a2),0)
 
 /**
 Output a trace record of the specified category which also includes a Context ID.
@@ -4289,8 +4312,8 @@
 @released
 */
 #define BTracePc0(aCategory,aSubCategory) \
-	((BTrace::TBTrace1)BTrace::Out) \
-		(BTRACE_HEADER_P(4,(aCategory),(aSubCategory)))
+	BTrace::Out \
+		(BTRACE_HEADER_P(4,(aCategory),(aSubCategory)),0,0,0)
 
 /**
 Output a trace record of the specified category which also includes a Program Counter value.
@@ -4307,8 +4330,8 @@
 @released
 */
 #define BTracePc4(aCategory,aSubCategory,a1)	\
-	((BTrace::TBTrace2)BTrace::Out) \
-		(BTRACE_HEADER_P(8,(aCategory),(aSubCategory)),(TUint32)(a1))
+	BTrace::Out \
+		(BTRACE_HEADER_P(8,(aCategory),(aSubCategory)),(TUint32)(a1),0,0)
 
 /**
 Output a trace record of the specified category which also includes a Program Counter value.
@@ -4326,8 +4349,8 @@
 @released
 */
 #define BTracePc8(aCategory,aSubCategory,a1,a2) \
-	((BTrace::TBTrace3)BTrace::Out) \
-		(BTRACE_HEADER_P(12,(aCategory),(aSubCategory)),(TUint32)(a1),(TUint32)(a2))
+	BTrace::Out \
+		(BTRACE_HEADER_P(12,(aCategory),(aSubCategory)),(TUint32)(a1),(TUint32)(a2),0)
 
 /**
 Output a trace record of the specified category which also includes a Program Counter value.
@@ -4411,8 +4434,8 @@
 @released
 */
 #define BTraceContextPc0(aCategory,aSubCategory)	\
-	((BTrace::TBTrace1)BTrace::OutX) \
-		(BTRACE_HEADER_CP(4,(aCategory),(aSubCategory)))
+	BTrace::OutX \
+		(BTRACE_HEADER_CP(4,(aCategory),(aSubCategory)),0,0,0)
 
 /**
 Output a trace record of the specified category which also includes
@@ -4430,8 +4453,8 @@
 @released
 */
 #define BTraceContextPc4(aCategory,aSubCategory,a1) \
-	((BTrace::TBTrace2)BTrace::OutX) \
-		(BTRACE_HEADER_CP(8,(aCategory),(aSubCategory)),(TUint32)(a1))
+	BTrace::OutX \
+		(BTRACE_HEADER_CP(8,(aCategory),(aSubCategory)),(TUint32)(a1),0,0)
 
 /**
 Output a trace record of the specified category which also includes
@@ -4450,8 +4473,8 @@
 @released
 */
 #define BTraceContextPc8(aCategory,aSubCategory,a1,a2) \
-	((BTrace::TBTrace3)BTrace::OutX) \
-		(BTRACE_HEADER_CP(12,(aCategory),(aSubCategory)),(TUint32)(a1),(TUint32)(a2))
+	BTrace::OutX \
+		(BTRACE_HEADER_CP(12,(aCategory),(aSubCategory)),(TUint32)(a1),(TUint32)(a2),0)
 
 /**
 Output a trace record of the specified category which also includes
@@ -4539,8 +4562,8 @@
 @released
 */
 #define BTraceFiltered4(aCategory,aSubCategory,aUid) \
-	((BTrace::TBTrace2)BTrace::OutFiltered) \
-		(BTRACE_HEADER(8,(aCategory),(aSubCategory)),(TUint32)(aUid))
+	BTrace::OutFiltered \
+		(BTRACE_HEADER(8,(aCategory),(aSubCategory)),(TUint32)(aUid),0,0)
 
 /**
 Output a trace record of the specified category.
@@ -4560,8 +4583,8 @@
 @released
 */
 #define BTraceFiltered8(aCategory,aSubCategory,aUid,a1) \
-	((BTrace::TBTrace3)BTrace::OutFiltered) \
-		(BTRACE_HEADER(12,(aCategory),(aSubCategory)),(TUint32)(aUid),(TUint32)(a1))
+	BTrace::OutFiltered \
+		(BTRACE_HEADER(12,(aCategory),(aSubCategory)),(TUint32)(aUid),(TUint32)(a1),0)
 
 /**
 Output a trace record of the specified category.
@@ -4652,8 +4675,8 @@
 @released
 */
 #define BTraceFilteredContext4(aCategory,aSubCategory,aUid) \
-	((BTrace::TBTrace2)BTrace::OutFilteredX) \
-		(BTRACE_HEADER_C(8,(aCategory),(aSubCategory)),(TUint32)(aUid))
+	BTrace::OutFilteredX \
+		(BTRACE_HEADER_C(8,(aCategory),(aSubCategory)),(TUint32)(aUid),0,0)
 
 /**
 Output a trace record of the specified category which also includes a Context ID.
@@ -4673,8 +4696,8 @@
 @released
 */
 #define BTraceFilteredContext8(aCategory,aSubCategory,aUid,a1) \
-	((BTrace::TBTrace3)BTrace::OutFilteredX) \
-		(BTRACE_HEADER_C(12,(aCategory),(aSubCategory)),(TUint32)(aUid),(TUint32)(a1))
+	BTrace::OutFilteredX \
+		(BTRACE_HEADER_C(12,(aCategory),(aSubCategory)),(TUint32)(aUid),(TUint32)(a1),0)
 
 /**
 Output a trace record of the specified category which also includes a Context ID.
@@ -4765,8 +4788,8 @@
 @released
 */
 #define BTraceFilteredPc4(aCategory,aSubCategory,aUid)	\
-	((BTrace::TBTrace2)BTrace::OutFiltered) \
-		(BTRACE_HEADER_P(8,(aCategory),(aSubCategory)),(TUint32)(aUid))
+	BTrace::OutFiltered \
+		(BTRACE_HEADER_P(8,(aCategory),(aSubCategory)),(TUint32)(aUid),0,0)
 
 /**
 Output a trace record of the specified category which also includes a Program Counter value.
@@ -4786,8 +4809,8 @@
 @released
 */
 #define BTraceFilteredPc8(aCategory,aSubCategory,aUid,a1) \
-	((BTrace::TBTrace3)BTrace::OutFiltered) \
-		(BTRACE_HEADER_P(12,(aCategory),(aSubCategory)),(TUint32)(aUid),(TUint32)(a1))
+	BTrace::OutFiltered \
+		(BTRACE_HEADER_P(12,(aCategory),(aSubCategory)),(TUint32)(aUid),(TUint32)(a1),0)
 
 /**
 Output a trace record of the specified category which also includes a Program Counter value.
@@ -4880,8 +4903,8 @@
 @released
 */
 #define BTraceFilteredContextPc4(aCategory,aSubCategory,aUid)	\
-	((BTrace::TBTrace2)BTrace::OutFilteredX) \
-		(BTRACE_HEADER_CP(8,(aCategory),(aSubCategory)),(TUint32)(aUid))
+	BTrace::OutFilteredX \
+		(BTRACE_HEADER_CP(8,(aCategory),(aSubCategory)),(TUint32)(aUid),0,0)
 
 /**
 Output a trace record of the specified category which also includes
@@ -4902,8 +4925,8 @@
 @released
 */
 #define BTraceFilteredContextPc8(aCategory,aSubCategory,aUid,a1) \
-	((BTrace::TBTrace3)BTrace::OutFilteredX) \
-		(BTRACE_HEADER_CP(12,(aCategory),(aSubCategory)),(TUint32)(aUid),(TUint32)(a1))
+	BTrace::OutFilteredX \
+		(BTRACE_HEADER_CP(12,(aCategory),(aSubCategory)),(TUint32)(aUid),(TUint32)(a1),0)
 
 /**
 Output a trace record of the specified category which also includes
--- a/kernel/eka/include/e32ktran.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/e32ktran.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1995-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"
@@ -28,37 +28,68 @@
 #include <e32std.h>
 #include <e32keys.h>
 #include <e32base.h>
-//
+
+/**
+Represents a specific combination of modifier
+keys.
+
+The definition will match a given a key combination
+bitfield, if when anded with the mask iMask, it equals
+iValue. Bitfields are made up of bits defined in TEventModifier.
+
+eg. to match Ctrl and Shift and not Fn modifiers
+
+iMask = EModifierShift | EModifierCtrl | EModifierFunc
+iValue = EModifierShift | EModifierCtrl
+*/
 class TMaskedModifiers
 	{
 public:
-	TUint iMask;
-	TUint iValue;
+	TUint iMask; //!< Mask to be binary anded with some value
+	TUint iValue; //!< Must match the masked bitfield
 	};
-//
+
+/**
+Defines different match types to be used
+in TKeyCodePattern
+*/
 enum TPattern
 	{
-	EAnyKey=0x00,
-	EAnyAlphaNumeric,
-	EAnyAlpha,
-	EAnyAlphaLowerCase,
-	EAnyAlphaUpperCase,
-	EAnyDecimalDigit,
+	EAnyKey=0x00, ///< match any key
+	EAnyAlphaNumeric, ///< match any alpha or numeric key
+	EAnyAlpha, ///< match any alpha key
+	EAnyAlphaLowerCase, ///< match any lower-case key
+	EAnyAlphaUpperCase, ///< match any upper-case key
+	EAnyDecimalDigit, ///< match any decimal digit
 	EAnyDigitGivenRadix,
-	EAnyModifierKey,
-	EMatchKey=0x40,
-	EMatchKeyCaseInsens,
-	EMatchLeftOrRight
+	EAnyModifierKey, ///< match any modifier key (e.g. alt, fn, ctrl)
+	EMatchKey=0x40, ///< match if equal to keycode value in first field
+	EMatchKeyCaseInsens, ///< like EMatchKey but perform case-insensitive comparison
+	EMatchLeftOrRight ///< match if equal to keycode value or (keycode value + 1)
 	};
-//
+
+/**
+Defines a keypress using one of the match types defined in TPattern
+and possibly a reference scan code. It is possible to specify generic
+or specific keypresses eg. any decimal digit, or a particular
+key, matched case insensitively.
+
+@see TPattern
+*/
 class TKeyCodePattern
 	{
 public:
-	TUint16 iKeyCode;
-	TInt8   iPattern;
+	TUint16 iKeyCode; ///< Reference scancode, used when iPattern is EMatchKey, EMatchKeyCaseInsens, or EMatchLeftOrRight
+	TInt8   iPattern; ///< Comparison, of type TPattern
 	TInt8   iFiller;
 	};
-//
+
+/**
+A Capture Key is a special key or key combination which should be
+sent to a specific window-group, instead of the currently
+active window. For example a camera application might request that
+camera button events always be sent to it.
+*/
 class TCaptureKey
 	{
 public:
@@ -67,7 +98,10 @@
 	TUint iApp;
 	TUint iHandle;
 	};
-//
+
+/**
+Used by CKeyTranslator to return translation results.
+*/
 class TKeyData
 	{
 public:
@@ -77,7 +111,12 @@
 	TBool iIsCaptureKey;
 	TUint iKeyCode;
 	};
-//
+
+/**
+A set of TCaptureKey objects which is passed to a CKeyTranslator
+when translating key events. This is so it can indicate if a
+translated key event should be treated as a special Capture Key.
+*/
 class CCaptureKeys: public CBase
 	{
 public:
@@ -93,11 +132,19 @@
 	IMPORT_C void ProcessCaptureKeys(TKeyData &aKeyData) const;
 protected:
 	void CheckCaptureKey(const TCaptureKey &aCaptureKey);
-	void removeCaptureKey(TUint index);
 protected:
 	RArray<TCaptureKey> iCKarray;
 	};
-//
+
+/**
+A CKeyTranslator derived object will be created by the window server
+in order to translate key scancode data, contained in a TRawEvent, in to
+generic logical key press, as defined in TKeyCode. Essentially, these
+translations
+
+The translator object will perform the actual lookups using data from
+a platform specific keymap DLL, conventionally named ekdata.dll.
+*/
 class CKeyTranslator: public CBase
 	{
 public:
--- a/kernel/eka/include/e32ver.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/e32ver.h	Wed Aug 18 11:08:29 2010 +0300
@@ -28,7 +28,7 @@
 
 const TInt KE32MajorVersionNumber=2;
 const TInt KE32MinorVersionNumber=0;
-const TInt KE32BuildVersionNumber=3098;
+const TInt KE32BuildVersionNumber=3110;
 
 const TInt KMachineConfigurationMajorVersionNumber=1;
 const TInt KMachineConfigurationMinorVersionNumber=0;
--- a/kernel/eka/include/k32keys.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/k32keys.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-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"
@@ -70,6 +70,12 @@
 
 
 /**
+A contiguous range of logical scancodes of type, and ordering, as
+defined in TStdScanCode.
+Once aligned with an array of target keycodes, a pairwise
+association between each scancode and its translation will
+be defined.
+
 @publishedPartner
 @released
 */
@@ -80,6 +86,9 @@
 	};
 
 /**
+An array of SScanCodeBlock scancode ranges. This allows
+a discontiguous set of scancodes to be treated contiguously.
+
 @publishedPartner
 @released
 */
@@ -90,27 +99,37 @@
 	};
 
 /**
+Associates an SScanCodeBlockList with
+a specific set of target keycodes. This defines a concrete
+translation for the scancodes in the scanCodes block list.
+
 @publishedPartner
 @released
 */
 struct SConvSubTable
 	{
-	const TUint16 *pkeyCode;
+	const TUint16 *pkeyCode; //<! An array of target keycodes
 	SScanCodeBlockList scanCodes;
 	};
 
 /**
+Associates a combination of modifier keys with the translation
+table to be used when the combination is active.
+
 @publishedPartner
 @released
 */
 struct SConvTableNode
 	{
-   TMaskedModifiers maskedModifiers;
+	TMaskedModifiers maskedModifiers;
 	TUint numSubTables;
 	const SConvSubTable * const *ppsubTables;
 	};
 
 /**
+The top level collection of all different translation
+tables.
+
 @publishedPartner
 @released
 */
@@ -131,6 +150,16 @@
 	};
 
 /**
+Defines an action to perform when a given key press
+occurs.
+
+@note This struct should not be used in a keymap table.
+It is used within the key translator to represent an
+SFuncAndState for the modifier table (where the state
+member is not meaningful).
+
+@see SFuncAndState
+
 @publishedPartner
 @released
 */
@@ -142,28 +171,41 @@
 	};
 
 /**
+Defines an action to perform and the next state transition
+when a given key press occurs.
+
 @publishedPartner
 @released
 */
 struct SFuncAndState
 	{
-	TUint8 state;
-	TUint8 func;
-	TInt32 funcParam;
+	TUint8 state; ///< The next TState to transition to
+	TUint8 func; ///< A TFuncGeneral action
+	TInt32 funcParam; ///< Parameter for func (key to translate to for EPassSpecialKeyThru)
 	};
 
 /**
+Associates a SFuncAndState, which defines an action, with a
+key press and modifier combination to trigger it.
+
 @publishedPartner
 @released
 */
 struct SFuncTableEntry
 	{
-	TMaskedModifiers maskedModifiers;
-	TKeyCodePattern keyCodePattern;
-	SFuncAndState funcAndNewState;
+	TMaskedModifiers maskedModifiers; ///< Required modifier combination
+	TKeyCodePattern keyCodePattern; ///< Required keypress
+	SFuncAndState funcAndNewState; ///< Action or translation
 	};
 
 /**
+A function table corresponds to a particular keyboard
+mode. When this mode is active this table's entries
+are used to perform actions or translations
+for certain keypresses.
+
+@see SFuncTableEntry
+
 @publishedPartner
 @released
 */
@@ -174,18 +216,46 @@
 	};
 
 /**
+Collection of all keyboard mode function tables
+
 @publishedPartner
 @released
 */
 struct SFuncTables
 	{
+	/**
+	This table is searched for a match if a match has not been
+	found in the current state's table
+	*/
 	SFuncTable defaultTable;
+
+	/**
+	This table controls which keys change which modifiers;
+	the state field in this table is ignored
+	*/
 	SFuncTable modifierTable;
+
+	/**
+	Number of entries in array pgenFuncTables.
+	This must in fact, always be equal to 13.
+	*/
 	TUint numGenFuncTables;
+
+	/**
+	Array of pointers to general state control tables.
+
+	Indicies 1-12 are possible tables, index 0
+	should be unused.
+
+	If a state is not used its SFuncTable array size should be set to
+	zero and the pointer to NULL
+	*/
 	const SFuncTable *pgenFuncTables;
 	};
 
 /**
+Extends TChar with some extra utility functions
+
 @internalComponent
 @released
 */
@@ -202,6 +272,9 @@
 	};
 
 /**
+Responsible for loading and performing lookups
+in a keyboard function table.
+
 @internalComponent
 @released
 */
@@ -230,16 +303,30 @@
 	};
 
 /**
+Used by a keymap to state what method is used to
+enter multi digit control codes for special characters.
+
 @publishedPartner
 @released
 */
 enum TCtrlDigitsTermination
 	{
+	/**
+	Keyboard will stay in code entry mode for a set number
+	of key presses.
+	*/
 	ETerminationByCount,
+
+	/**
+	Keyboard will stay in code entry mode while Ctrl is held
+	down.
+	*/
 	ETerminationByCtrlUp
 	};
 
 /**
+Responsible for loading and walking through a keymap conversion table.
+
 @internalComponent
 @released
 */
@@ -263,6 +350,9 @@
 	};
 
 /**
+Responsible for aggregating a series of digits
+from separate keypresses into a single character.
+
 @internalComponent
 @released
 */
@@ -292,15 +382,42 @@
 	};
 
 /**
+Definitions for keyboard states.
+The first 3 values identify special keyboard states and
+are used as an index to these states' tables. This is
+only a partial list of possible states, states 1-9
+are also valid, and should be used for translating
+isolated characters e.g. to apply diacritics to vowels.
+
+The next 3 do not specify particular states, but give
+information to the key translator so that it can
+decide the next state.
+
 @internalComponent
 @released
 */
 enum TState
 	{
-// values used as an index to a table
+	/**
+	Normal keyboard state, which defines keys
+	that transition	to the other states.
+	*/
 	EStateNormal						=0x0a,
+
+	/**
+	Allow characters to be specified
+	by a decimal code. The state will be transitioned
+	back to EStateNormal after a given count.
+	*/
 	EStateCtrlDigitsUntilCount			=0x0b,
+
+	/**
+	Allow characters to be specified
+	by a decimal code. The state will be transitioned
+	back to EStateNormal once Ctrl is released.
+	*/
 	EStateCtrlDigitsUntilCtrlUp			=0x0c,
+
 // values used as "rules" to be processed in a switch statement
 	EStateUnchanged						=0x40,
 	EStateDerivedFromDigitEntered,
@@ -308,19 +425,24 @@
 	};
 
 /**
+Defines an action to be performed for a keypress.
+@see SFuncAndState::func
+
 @internalComponent
 @released
 */
 enum TFuncGeneral
 	{
 	EDoNothing							=0x00,
-	EPassKeyThru,
-	EPassSpecialKeyThru,
-	EPassCtrlDigitsThru,
-	EAddOnCtrlDigit,
+	EPassKeyThru, ///< Pass key through, unchanged
+	EPassSpecialKeyThru, ///< Translate to a new character
+	EPassCtrlDigitsThru, ///< End accumulation of character digits
+	EAddOnCtrlDigit, ///< Allow another control digit to be entered
 	};
 
 /**
+Concrete implementation of a CKeyTranslator.
+
 @internalComponent
 @released
 */
--- a/kernel/eka/include/k32keys.inl	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/include/k32keys.inl	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-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"
@@ -24,7 +24,7 @@
 */
 inline TBool MatchesMaskedValue(TInt aModifiers,const TMaskedModifiers &aMaskedModifiers)
     {
-    return (TBool)((aModifiers&aMaskedModifiers.iMask)==aMaskedModifiers.iValue);
+    return (aModifiers&aMaskedModifiers.iMask)==aMaskedModifiers.iValue;
     }
 
 /**
--- a/kernel/eka/kernel/arm/ckernel.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/kernel/arm/ckernel.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -105,6 +105,10 @@
 				{
 				*(TUint32*)(pT->iNThread.iExtraContext) = Arm::FpScr() & VFP_FPSCR_MODE_MASK;
 				}
+			else
+				{
+				*(TUint32*)(pT->iNThread.iExtraContext) = *(TUint32*)(Kern::CurrentThread().iNThread.iExtraContext);
+				}
 			}
 		}
 #endif
--- a/kernel/eka/kernel/ekern.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/kernel/ekern.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -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/kernel/sbtrace.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/kernel/sbtrace.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -427,8 +427,13 @@
 
 #endif
 
-	   case EIic:
-		   return ETrue;
+#ifdef BTRACE_RESMANUS
+    case EResourceManagerUs:
+       return ETrue;
+#endif
+
+    case EIic:
+       return ETrue;
 
 #ifdef BTRACE_TRAWEVENT
 	case ERawEvent:
--- a/kernel/eka/kernel/sutils.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/kernel/sutils.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -3548,10 +3548,19 @@
 
 void TClientRequest::EndComplete(DThread* aThread)
 	{
+	// NB: if the callback is successfully queued, the target thread may run and
+	// process it before we get back from the call to QueueUserModeCallback().
+	// In that case, 'iStatus' will be changed; and in general it is not safe to
+	// look at any element of 'this' once the callback is queued, as it may change
+	// asynchronously.  Therefore, we must cache the value of 'iStatus' beforehand
+	// and later use this saved copy to decide whether to signal the target thread.
+	T_UintPtr status = iStatus;
 	TInt r = NKern::QueueUserModeCallback(&aThread->iNThread, this);
+
 	if (r == KErrNone)
 		{
-		if (iStatus != (KClientRequestNullStatus | KClientRequestFlagInUse))
+		__NK_ASSERT_DEBUG(status & KClientRequestFlagInUse);
+		if ((status & ~KClientRequestFlagInUse) != KClientRequestNullStatus)
 			NKern::ThreadRequestSignal(&aThread->iNThread);
 		}
 	else
--- a/kernel/eka/nkernsmp/nkern.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/nkernsmp/nkern.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -55,7 +55,11 @@
 ARMLIBS					h_a__un.l 
 #endif
 #else
+#ifdef ARMCC_4
+ARMLIBS					c_5.l     h_5.l     cpprt_5.l
+#else
 ARMLIBS					c_4.l     h_4.l     cpprt_4.l
 #endif
+#endif
 END
 
--- a/kernel/eka/release.txt	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/release.txt	Wed Aug 18 11:08:29 2010 +0300
@@ -1,3 +1,199 @@
+Version 2.00.3110
+=================
+(Made by fadhliM 22/07/2010)
+
+1.	davegord
+	1.	ou1cimx1#488456 (MCL) Kernel signals MTP server unexpectedly and cause it panic
+
+2.	dogunjom
+	1.	ou1cimx1#413278 MCL:Domain Manager - Correct the usage of RArray::Append()
+
+3.	jcoppear
+	1.	ou1cimx1#479322 ENV E32TEST T_RAMDEFRAG test failure investigation (t_ramdefrag.cpp:549)
+
+4.	vfebvre
+	1.	ou1cimx1#460995 ENV E32TEST T_PAGETABLE_LIMIT test failure investigation (t_pagetable_limit.cpp:276)
+
+5.	seolney
+	1.	ou1cimx1#486893 DEV DMA functions missing test code (pt. 2)
+
+6.	mipetzol
+	1.	ou1cimx1#479623 DMA V2 framework PIL enhancement required for management of AsymmmetricSgChannel class descriptors
+
+
+Version 2.00.3109
+=================
+(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)
+
+1.	necliffo
+	1.	REQ 428-72 Partition support for eMMC-only platforms
+
+
+Version 2.00.3106
+=================
+(Made by famustaf 01/07/2010)
+
+1.	jessiezh
+	1.	ou1cimx1#470771 Improve code coverage for IIC
+
+2.	niccox
+	1.	ou1cimx1#469034 ENV New usbcsc export not frozen
+
+3.	garciato
+	1.	MINOR_CHANGE Add more SMP documentation
+
+
+Version 2.00.3105
+=================
+(Made by vfebvre 28/06/2010)
+
+1.	seolney
+	1.	ou1cimx1#462430 DMA functions missing test code
+
+
+Version 2.00.3104
+=================
+(Made by vfebvre 25/06/2010)
+
+1.	snagappa
+	1.	ou1cimx1#460964 t_dma2 test failure investigation
+
+2.	indrasin
+	1.	MINOR_CHANGE Excluded H2, Emulator test code, H4 flexible memory build
+
+3.	cnotton
+	1.	ou1cimx1#440685 Multimedia headers in kernelhwsrv are including platform headers
+
+4.	erifung
+	1.	ou1cimx1#435148 Unsafe setting of DPowerResourceNotification data
+
+
+Version 2.00.3103
+=================
+(Made by vfebvre 24/06/2010)
+
+1.	snagappa
+	1.	ou1cimx1#432741 Ektran functions missing test cases
+
+2.	erifung
+	1.	ou1cimx1#436980 EResourceManager and TResourceManagerUs e32btrace.h formats cannot be correctly parsed by SymSEE TraceViewer
+
+
+Version 2.00.3102
+=================
+(Made by vfebvre 24/06/2010)
+
+1.	daniezho
+	1.	ou1cimx1#452612 [kernelhwsrvmcl] Not support NCM function in USB shared chunk LDD
+
+2.	cnotton
+	1.	ou1cimx1#435933 E32TEST T_TIMESTAMP test failure investigation (SMP, t_timestamp.cpp:194)
+
+
+Version 2.00.3101
+=================
+(Made by vfebvre 22/06/2010)
+
+1.	erifung
+	1.	ou1cimx1#436941 Category 20 (TResourceManagerUs) cannot be enabled in btrace
+
+2.	indrasin
+	1.	MINOR_CHANGE Included H2/H4/H6, emulator builds, excluded TraceCore from rapu for sirocco building
+	2.	MINOR_CHANGE Excluded TraceCore from rapu baseport for sirocco building
+
+
+Version 2.00.3100
+=================
+(Made by vfebvre 21/06/2010)
+
+1.	stmansfi
+	1.	ou1cimx1#451185 DEV MCL Warnings in DRM_DebugEventHandler header for coverage builds
+
+2.	mipetzol
+	1.	ou1cimx1#457256 Changes done in DMA PIL DMA V2 framework to adapt to ST PSL
+
+3.	lanerobe
+	1.	ou1cimx1#447463 VFP Mode inheritance fix
+
+4.	kmetherm
+	1.	ou1cimx1#442009 DEV RVCT4.0 Compilation issues in  when building bsp
+
+
+Version 2.00.3099
+=================
+(Made by vfebvre 18/06/2010)
+
+1.	jimhofe
+	1.	ou1cimx1#443337 Automouter is not referenced by the package_definition.xml file
+
+2.	mipetzol
+	1.	MINOR_CHANGE DMA header file in-source documentation update
+
+3.	tocosgro
+	1.	ou1cimx1#403437 RVCT 4.0: Definition of BTraceFiltered8 engenders undefined behaviour
+		RVCT4 with -O3 and -Otime creates incorrect object code when we cast a function
+		call in order to call a function that should have more parameters with fewer than it
+		needs.
+
+		This is done by various of the BTrace macros in e32btrace.h (Btrace0(), BTrace4(), etc, etc),
+		using internal typedefs TBTrace1, TBTrace2 and TBTrace 3.
+
+		The change is to remove the casts (and the typedefs to avoid this being done again
+		immediately) and add explicit 0 arguments to the calls in the macros.
+
+		The impact of this on the generated code is precisely to add the extra register load immediate
+		instructions (e.g. mov r3, #0).
+
+4.	shubmurt
+	1.	ou1cimx1#428765 Case and Slash fix for Linux Build
+
+5.	kmetherm
+	1.	ou1cimx1#419204 DEV-T_CrashMonitor_Lib test fails when built with RVCT4.0 compiler
+	2.	ou1cimx1#390590 DEV-T_KHEAP test fails when built with RVCT4.0 compiler
+	3.	ou1cimx1#423744 DEV-T_XXVer2 test fails/times out when built with RVCT4.0 compiler
+
+
 Version 2.00.3098
 =================
 (Made by vfebvre 18/06/2010)
--- a/kernel/eka/rombuild/h4usbtest.iby	Tue Jul 06 15:50:07 2010 +0300
+++ b/kernel/eka/rombuild/h4usbtest.iby	Wed Aug 18 11:08:29 2010 +0300
@@ -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_Power_Management_Impacts_on_Kernel_Use_of_Hardware_Timers.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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/active/t_ctimer.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/bench/d_kernasmfnc.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/bmarm/d_dma2_simu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,46 @@
+EXPORTS
+	CreateLogicalDevice__Fv @ 1 NONAME R3UNUSED ; CreateLogicalDevice(void)
+	__18TDmaTransferConfigUlUiUiUiiiUiUi13TDmaBurstSizeUiUii @ 2 NONAME ; TDmaTransferConfig::TDmaTransferConfig(unsigned long, unsigned int, unsigned int, unsigned int, int, int, unsigned int, unsigned int, TDmaBurstSize, unsigned int, unsigned int, int)
+	CancelAll__11TDmaChannel @ 3 NONAME R3UNUSED ; TDmaChannel::CancelAll(void)
+	Close__11TDmaChannel @ 4 NONAME R3UNUSED ; TDmaChannel::Close(void)
+	DisableDstElementCounting__11DDmaRequest @ 5 NONAME R3UNUSED ; DDmaRequest::DisableDstElementCounting(void)
+	DisableSrcElementCounting__11DDmaRequest @ 6 NONAME R3UNUSED ; DDmaRequest::DisableSrcElementCounting(void)
+	DmaTestInfoV2__Fv @ 7 NONAME R3UNUSED ; DmaTestInfoV2(void)
+	DmaTestInfo__Fv @ 8 NONAME R3UNUSED ; DmaTestInfo(void)
+	DmacCaps__11TDmaChannel @ 9 NONAME R3UNUSED ; TDmaChannel::DmacCaps(void)
+	DstFragmentCount__11DDmaRequest @ 10 NONAME R3UNUSED ; DDmaRequest::DstFragmentCount(void)
+	EnableDstElementCounting__11DDmaRequesti @ 11 NONAME R3UNUSED ; DDmaRequest::EnableDstElementCounting(int)
+	EnableSrcElementCounting__11DDmaRequesti @ 12 NONAME R3UNUSED ; DDmaRequest::EnableSrcElementCounting(int)
+	ExpandDesList__11DDmaRequesti @ 13 NONAME R3UNUSED ; DDmaRequest::ExpandDesList(int)
+	ExpandDstDesList__11DDmaRequesti @ 14 NONAME R3UNUSED ; DDmaRequest::ExpandDstDesList(int)
+	ExpandSrcDesList__11DDmaRequesti @ 15 NONAME R3UNUSED ; DDmaRequest::ExpandSrcDesList(int)
+	Extension__11TDmaChanneliPv @ 16 NONAME R3UNUSED ; TDmaChannel::Extension(int, void *)
+	FailNext__11TDmaChanneli @ 17 NONAME R3UNUSED ; TDmaChannel::FailNext(int)
+	FragmentCount__11DDmaRequest @ 18 NONAME R3UNUSED ; DDmaRequest::FragmentCount(void)
+	Fragment__11DDmaRequestRC16TDmaTransferArgs @ 19 NONAME R3UNUSED ; DDmaRequest::Fragment(TDmaTransferArgs const &)
+	Fragment__11DDmaRequestUlUliUiUl @ 20 NONAME ; DDmaRequest::Fragment(unsigned long, unsigned long, int, unsigned int, unsigned long)
+	FreeDesList__11DDmaRequest @ 21 NONAME R3UNUSED ; DDmaRequest::FreeDesList(void)
+	FreeDstDesList__11DDmaRequest @ 22 NONAME R3UNUSED ; DDmaRequest::FreeDstDesList(void)
+	FreeSrcDesList__11DDmaRequest @ 23 NONAME R3UNUSED ; DDmaRequest::FreeSrcDesList(void)
+	IsrRedoRequest__11TDmaChannelUlUlUiUli @ 24 NONAME ; TDmaChannel::IsrRedoRequest(unsigned long, unsigned long, unsigned int, unsigned long, int)
+	LinkToChannel__11TDmaChannelP11TDmaChannel @ 25 NONAME R3UNUSED ; TDmaChannel::LinkToChannel(TDmaChannel *)
+	MaxTransferLength__11TDmaChannelUiUiUl @ 26 NONAME ; TDmaChannel::MaxTransferLength(unsigned int, unsigned int, unsigned long)
+	MissNextInterrupts__11TDmaChanneli @ 27 NONAME R3UNUSED ; TDmaChannel::MissNextInterrupts(int)
+	Open__11TDmaChannelRCQ211TDmaChannel11SCreateInfoRP11TDmaChannel @ 28 NONAME R3UNUSED ; TDmaChannel::Open(TDmaChannel::SCreateInfo const &, TDmaChannel *&)
+	Pause__11TDmaChannel @ 29 NONAME R3UNUSED ; TDmaChannel::Pause(void)
+	Queue__11DDmaRequest @ 30 NONAME R3UNUSED ; DDmaRequest::Queue(void)
+	Resume__11TDmaChannel @ 31 NONAME R3UNUSED ; TDmaChannel::Resume(void)
+	SrcFragmentCount__11DDmaRequest @ 32 NONAME R3UNUSED ; DDmaRequest::SrcFragmentCount(void)
+	StaticExtension__11TDmaChanneliPv @ 33 NONAME R3UNUSED ; TDmaChannel::StaticExtension(int, void *)
+	TotalNumDstElementsTransferred__11DDmaRequest @ 34 NONAME R3UNUSED ; DDmaRequest::TotalNumDstElementsTransferred(void)
+	TotalNumSrcElementsTransferred__11DDmaRequest @ 35 NONAME R3UNUSED ; DDmaRequest::TotalNumSrcElementsTransferred(void)
+	"_._11DDmaRequest" @ 36 NONAME R3UNUSED ; DDmaRequest::~DDmaRequest(void)
+	__11DDmaRequestR11TDmaChannelPFQ211DDmaRequest7TResultPv_vPvi @ 37 NONAME ; DDmaRequest::DDmaRequest(TDmaChannel &, void (*)(DDmaRequest::TResult, void *), void *, int)
+	__11DDmaRequestR11TDmaChannelPFUi10TDmaResultPvP10SDmaDesHdr_vPvUi @ 38 NONAME ; DDmaRequest::DDmaRequest(TDmaChannel &, void (*)(unsigned int, TDmaResult, void *, SDmaDesHdr *), void *, unsigned int)
+	__16TDmaTransferArgs @ 39 NONAME R3UNUSED ; TDmaTransferArgs::TDmaTransferArgs(void)
+	__16TDmaTransferArgsRC18TDmaTransferConfigT1UlUiUi15TDmaGraphicsOpsUl @ 40 NONAME ; TDmaTransferArgs::TDmaTransferArgs(TDmaTransferConfig const &, TDmaTransferConfig const &, unsigned long, unsigned int, unsigned int, TDmaGraphicsOps, unsigned long)
+	__16TDmaTransferArgsUiUiUiUiUiUi12TDmaAddrModeUiUi13TDmaBurstSizeUi15TDmaGraphicsOpsUl @ 41 NONAME ; TDmaTransferArgs::TDmaTransferArgs(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, TDmaAddrMode, unsigned int, unsigned int, TDmaBurstSize, unsigned int, TDmaGraphicsOps, unsigned long)
+	__18TDmaTransferConfig @ 42 NONAME R3UNUSED ; TDmaTransferConfig::TDmaTransferConfig(void)
+	__18TDmaTransferConfigUlUi12TDmaAddrModeUi13TDmaBurstSizeUiUiUii @ 43 NONAME ; TDmaTransferConfig::TDmaTransferConfig(unsigned long, unsigned int, TDmaAddrMode, unsigned int, TDmaBurstSize, unsigned int, unsigned int, unsigned int, int)
+	AddressAlignMask__11TDmaChannelUiUiUl @ 44 NONAME ; TDmaChannel::AddressAlignMask(unsigned int, unsigned int, unsigned long)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/bmarm/i2c_masterstubs_ctrlessu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,8 @@
+EXPORTS
+	CreatePhysicalDevice__Fv @ 1 NONAME R3UNUSED ; CreatePhysicalDevice(void)
+	DfcFunc__20TIicBusSlaveCallbackPv @ 2 NONAME R3UNUSED ; TIicBusSlaveCallback::DfcFunc(void *)
+	__25DIicBusChannelMasterSlaveQ214DIicBusChannel8TBusTypeQ214DIicBusChannel14TChannelDuplexP20DIicBusChannelMasterP19DIicBusChannelSlave @ 3 NONAME ; DIicBusChannelMasterSlave::DIicBusChannelMasterSlave(DIicBusChannel::TBusType, DIicBusChannel::TChannelDuplex, DIicBusChannelMaster *, DIicBusChannelSlave *)
+	__31DSimulatedIicBusChannelSlaveI2cQ214DIicBusChannel8TBusTypeQ214DIicBusChannel14TChannelDuplex @ 4 NONAME R3UNUSED ; DSimulatedIicBusChannelSlaveI2c::DSimulatedIicBusChannelSlaveI2c(DIicBusChannel::TBusType, DIicBusChannel::TChannelDuplex)
+	__32DSimulatedIicBusChannelMasterI2cQ214DIicBusChannel8TBusTypeQ214DIicBusChannel14TChannelDuplex @ 5 NONAME R3UNUSED ; DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c(DIicBusChannel::TBusType, DIicBusChannel::TChannelDuplex)
+	__37DSimulatedIicBusChannelMasterSlaveI2cQ214DIicBusChannel8TBusTypeQ214DIicBusChannel14TChannelDuplexP32DSimulatedIicBusChannelMasterI2cP31DSimulatedIicBusChannelSlaveI2c @ 6 NONAME ; DSimulatedIicBusChannelMasterSlaveI2c::DSimulatedIicBusChannelMasterSlaveI2c(DIicBusChannel::TBusType, DIicBusChannel::TChannelDuplex, DSimulatedIicBusChannelMasterI2c *, DSimulatedIicBusChannelSlaveI2c *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/bmarm/i2c_slavestubs_ctrlessu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,8 @@
+EXPORTS
+	CreatePhysicalDevice__Fv @ 1 NONAME R3UNUSED ; CreatePhysicalDevice(void)
+	DfcFunc__20TIicBusSlaveCallbackPv @ 2 NONAME R3UNUSED ; TIicBusSlaveCallback::DfcFunc(void *)
+	__25DIicBusChannelMasterSlaveQ214DIicBusChannel8TBusTypeQ214DIicBusChannel14TChannelDuplexP20DIicBusChannelMasterP19DIicBusChannelSlave @ 3 NONAME ; DIicBusChannelMasterSlave::DIicBusChannelMasterSlave(DIicBusChannel::TBusType, DIicBusChannel::TChannelDuplex, DIicBusChannelMaster *, DIicBusChannelSlave *)
+	__31DSimulatedIicBusChannelSlaveI2cQ214DIicBusChannel8TBusTypeQ214DIicBusChannel14TChannelDuplex @ 4 NONAME R3UNUSED ; DSimulatedIicBusChannelSlaveI2c::DSimulatedIicBusChannelSlaveI2c(DIicBusChannel::TBusType, DIicBusChannel::TChannelDuplex)
+	__32DSimulatedIicBusChannelMasterI2cQ214DIicBusChannel8TBusTypeQ214DIicBusChannel14TChannelDuplex @ 5 NONAME R3UNUSED ; DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c(DIicBusChannel::TBusType, DIicBusChannel::TChannelDuplex)
+	__37DSimulatedIicBusChannelMasterSlaveI2cQ214DIicBusChannel8TBusTypeQ214DIicBusChannel14TChannelDuplexP32DSimulatedIicBusChannelMasterI2cP31DSimulatedIicBusChannelSlaveI2c @ 6 NONAME ; DSimulatedIicBusChannelMasterSlaveI2c::DSimulatedIicBusChannelMasterSlaveI2c(DIicBusChannel::TBusType, DIicBusChannel::TChannelDuplex, DSimulatedIicBusChannelMasterI2c *, DSimulatedIicBusChannelSlaveI2c *)
+
--- a/kerneltest/e32test/buffer/t_bflat.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/buffer/t_bflat.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/buffer/t_bma.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/buffer/t_buf.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/buffer/t_circ.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/buffer/t_farray.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/buffer/t_parray.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/bwins/d_dma2_simu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,46 @@
+EXPORTS
+	?CreateLogicalDevice@@YAPAVDLogicalDevice@@XZ @ 1 NONAME ; class DLogicalDevice * CreateLogicalDevice(void)
+	?FailNext@TDmaChannel@@QAEHH@Z @ 2 NONAME ; int TDmaChannel::FailNext(int)
+	?LinkToChannel@TDmaChannel@@QAEHPAV1@@Z @ 3 NONAME ; int TDmaChannel::LinkToChannel(class TDmaChannel *)
+	?FragmentCount@DDmaRequest@@QAEHXZ @ 4 NONAME ; int DDmaRequest::FragmentCount(void)
+	?Fragment@DDmaRequest@@QAEHABUTDmaTransferArgs@@@Z @ 5 NONAME ; int DDmaRequest::Fragment(struct TDmaTransferArgs const &)
+	?DmacCaps@TDmaChannel@@QAEABUSDmacCaps@@XZ @ 6 NONAME ; struct SDmacCaps const & TDmaChannel::DmacCaps(void)
+	?Open@TDmaChannel@@SAHABUSCreateInfo@1@AAPAV1@@Z @ 7 NONAME ; int TDmaChannel::Open(struct TDmaChannel::SCreateInfo const &, class TDmaChannel * &)
+	?TotalNumDstElementsTransferred@DDmaRequest@@QAEKXZ @ 8 NONAME ; unsigned long DDmaRequest::TotalNumDstElementsTransferred(void)
+	?Close@TDmaChannel@@QAEXXZ @ 9 NONAME ; void TDmaChannel::Close(void)
+	?TotalNumSrcElementsTransferred@DDmaRequest@@QAEKXZ @ 10 NONAME ; unsigned long DDmaRequest::TotalNumSrcElementsTransferred(void)
+	??0TDmaTransferArgs@@QAE@ABUTDmaTransferConfig@@0KIIW4TDmaGraphicsOps@@K@Z @ 11 NONAME ; TDmaTransferArgs::TDmaTransferArgs(struct TDmaTransferConfig const &, struct TDmaTransferConfig const &, unsigned long, unsigned int, unsigned int, enum TDmaGraphicsOps, unsigned long)
+	??0TDmaTransferArgs@@QAE@IIIIIIW4TDmaAddrMode@@IIW4TDmaBurstSize@@IW4TDmaGraphicsOps@@K@Z @ 12 NONAME ; TDmaTransferArgs::TDmaTransferArgs(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, enum TDmaAddrMode, unsigned int, unsigned int, enum TDmaBurstSize, unsigned int, enum TDmaGraphicsOps, unsigned long)
+	?Queue@DDmaRequest@@QAEHXZ @ 13 NONAME ; int DDmaRequest::Queue(void)
+	?IsrRedoRequest@TDmaChannel@@QAEHKKIKH@Z @ 14 NONAME ; int TDmaChannel::IsrRedoRequest(unsigned long, unsigned long, unsigned int, unsigned long, int)
+	?EnableSrcElementCounting@DDmaRequest@@QAEXH@Z @ 15 NONAME ; void DDmaRequest::EnableSrcElementCounting(int)
+	?CancelAll@TDmaChannel@@QAEXXZ @ 16 NONAME ; void TDmaChannel::CancelAll(void)
+	?FreeSrcDesList@DDmaRequest@@QAEXXZ @ 17 NONAME ; void DDmaRequest::FreeSrcDesList(void)
+	?AddressAlignMask@TDmaChannel@@QAEIIIK@Z @ 18 NONAME ; unsigned int TDmaChannel::AddressAlignMask(unsigned int, unsigned int, unsigned long)
+	??0TDmaTransferConfig@@QAE@KIIIHHIIW4TDmaBurstSize@@IIH@Z @ 19 NONAME ; TDmaTransferConfig::TDmaTransferConfig(unsigned long, unsigned int, unsigned int, unsigned int, int, int, unsigned int, unsigned int, enum TDmaBurstSize, unsigned int, unsigned int, int)
+	??0DDmaRequest@@QAE@AAVTDmaChannel@@P6AXIW4TDmaResult@@PAXPAUSDmaDesHdr@@@Z2I@Z @ 20 NONAME ; DDmaRequest::DDmaRequest(class TDmaChannel &, void (*)(unsigned int, enum TDmaResult, void *, struct SDmaDesHdr *), void *, unsigned int)
+	?Pause@TDmaChannel@@QAEHXZ @ 21 NONAME ; int TDmaChannel::Pause(void)
+	??0TDmaTransferArgs@@QAE@XZ @ 22 NONAME ; TDmaTransferArgs::TDmaTransferArgs(void)
+	?DmaTestInfo@@YAABUTDmaTestInfo@@XZ @ 23 NONAME ; struct TDmaTestInfo const & DmaTestInfo(void)
+	?EnableDstElementCounting@DDmaRequest@@QAEXH@Z @ 24 NONAME ; void DDmaRequest::EnableDstElementCounting(int)
+	??0TDmaTransferConfig@@QAE@XZ @ 25 NONAME ; TDmaTransferConfig::TDmaTransferConfig(void)
+	?DisableDstElementCounting@DDmaRequest@@QAEXXZ @ 26 NONAME ; void DDmaRequest::DisableDstElementCounting(void)
+	??0DDmaRequest@@QAE@AAVTDmaChannel@@P6AXW4TResult@0@PAX@Z2H@Z @ 27 NONAME ; DDmaRequest::DDmaRequest(class TDmaChannel &, void (*)(enum DDmaRequest::TResult, void *), void *, int)
+	?MaxTransferLength@TDmaChannel@@QAEIIIK@Z @ 28 NONAME ; unsigned int TDmaChannel::MaxTransferLength(unsigned int, unsigned int, unsigned long)
+	?ExpandDesList@DDmaRequest@@QAEHH@Z @ 29 NONAME ; int DDmaRequest::ExpandDesList(int)
+	?ExpandDstDesList@DDmaRequest@@QAEHH@Z @ 30 NONAME ; int DDmaRequest::ExpandDstDesList(int)
+	?Resume@TDmaChannel@@QAEHXZ @ 31 NONAME ; int TDmaChannel::Resume(void)
+	?FreeDstDesList@DDmaRequest@@QAEXXZ @ 32 NONAME ; void DDmaRequest::FreeDstDesList(void)
+	?SrcFragmentCount@DDmaRequest@@QAEHXZ @ 33 NONAME ; int DDmaRequest::SrcFragmentCount(void)
+	?DmaTestInfoV2@@YAABUTDmaV2TestInfo@@XZ @ 34 NONAME ; struct TDmaV2TestInfo const & DmaTestInfoV2(void)
+	?ExpandSrcDesList@DDmaRequest@@QAEHH@Z @ 35 NONAME ; int DDmaRequest::ExpandSrcDesList(int)
+	?Fragment@DDmaRequest@@QAEHKKHIK@Z @ 36 NONAME ; int DDmaRequest::Fragment(unsigned long, unsigned long, int, unsigned int, unsigned long)
+	?FreeDesList@DDmaRequest@@QAEXXZ @ 37 NONAME ; void DDmaRequest::FreeDesList(void)
+	?StaticExtension@TDmaChannel@@QAEHHPAX@Z @ 38 NONAME ; int TDmaChannel::StaticExtension(int, void *)
+	?Extension@TDmaChannel@@QAEHHPAX@Z @ 39 NONAME ; int TDmaChannel::Extension(int, void *)
+	?MissNextInterrupts@TDmaChannel@@QAEHH@Z @ 40 NONAME ; int TDmaChannel::MissNextInterrupts(int)
+	?DisableSrcElementCounting@DDmaRequest@@QAEXXZ @ 41 NONAME ; void DDmaRequest::DisableSrcElementCounting(void)
+	??1DDmaRequest@@UAE@XZ @ 42 NONAME ; DDmaRequest::~DDmaRequest(void)
+	?DstFragmentCount@DDmaRequest@@QAEHXZ @ 43 NONAME ; int DDmaRequest::DstFragmentCount(void)
+	??0TDmaTransferConfig@@QAE@KIW4TDmaAddrMode@@IW4TDmaBurstSize@@IIIH@Z @ 44 NONAME ; TDmaTransferConfig::TDmaTransferConfig(unsigned long, unsigned int, enum TDmaAddrMode, unsigned int, enum TDmaBurstSize, unsigned int, unsigned int, unsigned int, int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/bwins/i2c_masterstubs_ctrlessu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,8 @@
+EXPORTS
+	?CreatePhysicalDevice@@YAPAVDPhysicalDevice@@XZ @ 1 NONAME ; class DPhysicalDevice * CreatePhysicalDevice(void)
+	??0DIicBusChannelMasterSlave@@QAE@W4TBusType@DIicBusChannel@@W4TChannelDuplex@2@PAVDIicBusChannelMaster@@PAVDIicBusChannelSlave@@@Z @ 2 NONAME ; DIicBusChannelMasterSlave::DIicBusChannelMasterSlave(enum DIicBusChannel::TBusType, enum DIicBusChannel::TChannelDuplex, class DIicBusChannelMaster *, class DIicBusChannelSlave *)
+	?DfcFunc@TIicBusSlaveCallback@@CAXPAX@Z @ 3 NONAME ; void TIicBusSlaveCallback::DfcFunc(void *)
+	??0DSimulatedIicBusChannelSlaveI2c@@QAE@W4TBusType@DIicBusChannel@@W4TChannelDuplex@2@@Z @ 4 NONAME ; DSimulatedIicBusChannelSlaveI2c::DSimulatedIicBusChannelSlaveI2c(enum DIicBusChannel::TBusType, enum DIicBusChannel::TChannelDuplex)
+	??0DSimulatedIicBusChannelMasterI2c@@QAE@W4TBusType@DIicBusChannel@@W4TChannelDuplex@2@@Z @ 5 NONAME ; DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c(enum DIicBusChannel::TBusType, enum DIicBusChannel::TChannelDuplex)
+	??0DSimulatedIicBusChannelMasterSlaveI2c@@QAE@W4TBusType@DIicBusChannel@@W4TChannelDuplex@2@PAVDSimulatedIicBusChannelMasterI2c@@PAVDSimulatedIicBusChannelSlaveI2c@@@Z @ 6 NONAME ; DSimulatedIicBusChannelMasterSlaveI2c::DSimulatedIicBusChannelMasterSlaveI2c(enum DIicBusChannel::TBusType, enum DIicBusChannel::TChannelDuplex, class DSimulatedIicBusChannelMasterI2c *, class DSimulatedIicBusChannelSlaveI2c *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/bwins/i2c_slavestubs_ctrlessu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,8 @@
+EXPORTS
+	?CreatePhysicalDevice@@YAPAVDPhysicalDevice@@XZ @ 1 NONAME ; class DPhysicalDevice * CreatePhysicalDevice(void)
+	??0DIicBusChannelMasterSlave@@QAE@W4TBusType@DIicBusChannel@@W4TChannelDuplex@2@PAVDIicBusChannelMaster@@PAVDIicBusChannelSlave@@@Z @ 2 NONAME ; DIicBusChannelMasterSlave::DIicBusChannelMasterSlave(enum DIicBusChannel::TBusType, enum DIicBusChannel::TChannelDuplex, class DIicBusChannelMaster *, class DIicBusChannelSlave *)
+	?DfcFunc@TIicBusSlaveCallback@@CAXPAX@Z @ 3 NONAME ; void TIicBusSlaveCallback::DfcFunc(void *)
+	??0DSimulatedIicBusChannelMasterI2c@@QAE@W4TBusType@DIicBusChannel@@W4TChannelDuplex@2@@Z @ 4 NONAME ; DSimulatedIicBusChannelMasterI2c::DSimulatedIicBusChannelMasterI2c(enum DIicBusChannel::TBusType, enum DIicBusChannel::TChannelDuplex)
+	??0DSimulatedIicBusChannelSlaveI2c@@QAE@W4TBusType@DIicBusChannel@@W4TChannelDuplex@2@@Z @ 5 NONAME ; DSimulatedIicBusChannelSlaveI2c::DSimulatedIicBusChannelSlaveI2c(enum DIicBusChannel::TBusType, enum DIicBusChannel::TChannelDuplex)
+	??0DSimulatedIicBusChannelMasterSlaveI2c@@QAE@W4TBusType@DIicBusChannel@@W4TChannelDuplex@2@PAVDSimulatedIicBusChannelMasterI2c@@PAVDSimulatedIicBusChannelSlaveI2c@@@Z @ 6 NONAME ; DSimulatedIicBusChannelMasterSlaveI2c::DSimulatedIicBusChannelMasterSlaveI2c(enum DIicBusChannel::TBusType, enum DIicBusChannel::TChannelDuplex, class DSimulatedIicBusChannelMasterI2c *, class DSimulatedIicBusChannelSlaveI2c *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/bx86/d_dma2_simu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,46 @@
+EXPORTS
+	?CreateLogicalDevice@@YAPAVDLogicalDevice@@XZ @ 1 NONAME ; class DLogicalDevice * __cdecl CreateLogicalDevice(void)
+	??0DDmaRequest@@QAE@AAVTDmaChannel@@P6AXIW4TDmaResult@@PAXPAUSDmaDesHdr@@@Z2I@Z @ 2 NONAME ; public: __thiscall DDmaRequest::DDmaRequest(class TDmaChannel &,void (__cdecl*)(unsigned int,enum TDmaResult,void *,struct SDmaDesHdr *),void *,unsigned int)
+	??0DDmaRequest@@QAE@AAVTDmaChannel@@P6AXW4TResult@0@PAX@Z2H@Z @ 3 NONAME ; public: __thiscall DDmaRequest::DDmaRequest(class TDmaChannel &,void (__cdecl*)(enum DDmaRequest::TResult,void *),void *,int)
+	??0TDmaTransferArgs@@QAE@ABUTDmaTransferConfig@@0KIIW4TDmaGraphicsOps@@K@Z @ 4 NONAME ; public: __thiscall TDmaTransferArgs::TDmaTransferArgs(struct TDmaTransferConfig const &,struct TDmaTransferConfig const &,unsigned long,unsigned int,unsigned int,enum TDmaGraphicsOps,unsigned long)
+	??0TDmaTransferArgs@@QAE@IIIIIIW4TDmaAddrMode@@IIW4TDmaBurstSize@@IW4TDmaGraphicsOps@@K@Z @ 5 NONAME ; public: __thiscall TDmaTransferArgs::TDmaTransferArgs(unsigned int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int,enum TDmaAddrMode,unsigned int,unsigned int,enum TDmaBurstSize,unsigned int,enum TDmaGraphicsOps,unsigned long)
+	??0TDmaTransferArgs@@QAE@XZ @ 6 NONAME ; public: __thiscall TDmaTransferArgs::TDmaTransferArgs(void)
+	??0TDmaTransferConfig@@QAE@KIIIHHIIW4TDmaBurstSize@@IIH@Z @ 7 NONAME ; public: __thiscall TDmaTransferConfig::TDmaTransferConfig(unsigned long,unsigned int,unsigned int,unsigned int,int,int,unsigned int,unsigned int,enum TDmaBurstSize,unsigned int,unsigned int,int)
+	??0TDmaTransferConfig@@QAE@KIW4TDmaAddrMode@@IW4TDmaBurstSize@@IIIH@Z @ 8 NONAME ; public: __thiscall TDmaTransferConfig::TDmaTransferConfig(unsigned long,unsigned int,enum TDmaAddrMode,unsigned int,enum TDmaBurstSize,unsigned int,unsigned int,unsigned int,int)
+	??0TDmaTransferConfig@@QAE@XZ @ 9 NONAME ; public: __thiscall TDmaTransferConfig::TDmaTransferConfig(void)
+	??1DDmaRequest@@UAE@XZ @ 10 NONAME ; public: virtual __thiscall DDmaRequest::~DDmaRequest(void)
+	?AddressAlignMask@TDmaChannel@@QAEIIIK@Z @ 11 NONAME ; public: unsigned int __thiscall TDmaChannel::AddressAlignMask(unsigned int,unsigned int,unsigned long)
+	?CancelAll@TDmaChannel@@QAEXXZ @ 12 NONAME ; public: void __thiscall TDmaChannel::CancelAll(void)
+	?Close@TDmaChannel@@QAEXXZ @ 13 NONAME ; public: void __thiscall TDmaChannel::Close(void)
+	?DisableDstElementCounting@DDmaRequest@@QAEXXZ @ 14 NONAME ; public: void __thiscall DDmaRequest::DisableDstElementCounting(void)
+	?DisableSrcElementCounting@DDmaRequest@@QAEXXZ @ 15 NONAME ; public: void __thiscall DDmaRequest::DisableSrcElementCounting(void)
+	?DmaTestInfo@@YAABUTDmaTestInfo@@XZ @ 16 NONAME ; struct TDmaTestInfo const & __cdecl DmaTestInfo(void)
+	?DmaTestInfoV2@@YAABUTDmaV2TestInfo@@XZ @ 17 NONAME ; struct TDmaV2TestInfo const & __cdecl DmaTestInfoV2(void)
+	?DmacCaps@TDmaChannel@@QAEABUSDmacCaps@@XZ @ 18 NONAME ; public: struct SDmacCaps const & __thiscall TDmaChannel::DmacCaps(void)
+	?DstFragmentCount@DDmaRequest@@QAEHXZ @ 19 NONAME ; public: int __thiscall DDmaRequest::DstFragmentCount(void)
+	?EnableDstElementCounting@DDmaRequest@@QAEXH@Z @ 20 NONAME ; public: void __thiscall DDmaRequest::EnableDstElementCounting(int)
+	?EnableSrcElementCounting@DDmaRequest@@QAEXH@Z @ 21 NONAME ; public: void __thiscall DDmaRequest::EnableSrcElementCounting(int)
+	?ExpandDesList@DDmaRequest@@QAEHH@Z @ 22 NONAME ; public: int __thiscall DDmaRequest::ExpandDesList(int)
+	?ExpandDstDesList@DDmaRequest@@QAEHH@Z @ 23 NONAME ; public: int __thiscall DDmaRequest::ExpandDstDesList(int)
+	?ExpandSrcDesList@DDmaRequest@@QAEHH@Z @ 24 NONAME ; public: int __thiscall DDmaRequest::ExpandSrcDesList(int)
+	?Extension@TDmaChannel@@QAEHHPAX@Z @ 25 NONAME ; public: int __thiscall TDmaChannel::Extension(int,void *)
+	?FailNext@TDmaChannel@@QAEHH@Z @ 26 NONAME ; public: int __thiscall TDmaChannel::FailNext(int)
+	?Fragment@DDmaRequest@@QAEHABUTDmaTransferArgs@@@Z @ 27 NONAME ; public: int __thiscall DDmaRequest::Fragment(struct TDmaTransferArgs const &)
+	?Fragment@DDmaRequest@@QAEHKKHIK@Z @ 28 NONAME ; public: int __thiscall DDmaRequest::Fragment(unsigned long,unsigned long,int,unsigned int,unsigned long)
+	?FragmentCount@DDmaRequest@@QAEHXZ @ 29 NONAME ; public: int __thiscall DDmaRequest::FragmentCount(void)
+	?FreeDesList@DDmaRequest@@QAEXXZ @ 30 NONAME ; public: void __thiscall DDmaRequest::FreeDesList(void)
+	?FreeDstDesList@DDmaRequest@@QAEXXZ @ 31 NONAME ; public: void __thiscall DDmaRequest::FreeDstDesList(void)
+	?FreeSrcDesList@DDmaRequest@@QAEXXZ @ 32 NONAME ; public: void __thiscall DDmaRequest::FreeSrcDesList(void)
+	?IsrRedoRequest@TDmaChannel@@QAEHKKIKH@Z @ 33 NONAME ; public: int __thiscall TDmaChannel::IsrRedoRequest(unsigned long,unsigned long,unsigned int,unsigned long,int)
+	?LinkToChannel@TDmaChannel@@QAEHPAV1@@Z @ 34 NONAME ; public: int __thiscall TDmaChannel::LinkToChannel(class TDmaChannel *)
+	?MaxTransferLength@TDmaChannel@@QAEIIIK@Z @ 35 NONAME ; public: unsigned int __thiscall TDmaChannel::MaxTransferLength(unsigned int,unsigned int,unsigned long)
+	?MissNextInterrupts@TDmaChannel@@QAEHH@Z @ 36 NONAME ; public: int __thiscall TDmaChannel::MissNextInterrupts(int)
+	?Open@TDmaChannel@@SAHABUSCreateInfo@1@AAPAV1@@Z @ 37 NONAME ; public: static int __cdecl TDmaChannel::Open(struct TDmaChannel::SCreateInfo const &,class TDmaChannel * &)
+	?Pause@TDmaChannel@@QAEHXZ @ 38 NONAME ; public: int __thiscall TDmaChannel::Pause(void)
+	?Queue@DDmaRequest@@QAEHXZ @ 39 NONAME ; public: int __thiscall DDmaRequest::Queue(void)
+	?Resume@TDmaChannel@@QAEHXZ @ 40 NONAME ; public: int __thiscall TDmaChannel::Resume(void)
+	?SrcFragmentCount@DDmaRequest@@QAEHXZ @ 41 NONAME ; public: int __thiscall DDmaRequest::SrcFragmentCount(void)
+	?StaticExtension@TDmaChannel@@QAEHHPAX@Z @ 42 NONAME ; public: int __thiscall TDmaChannel::StaticExtension(int,void *)
+	?TotalNumDstElementsTransferred@DDmaRequest@@QAEKXZ @ 43 NONAME ; public: unsigned long __thiscall DDmaRequest::TotalNumDstElementsTransferred(void)
+	?TotalNumSrcElementsTransferred@DDmaRequest@@QAEKXZ @ 44 NONAME ; public: unsigned long __thiscall DDmaRequest::TotalNumSrcElementsTransferred(void)
+
--- a/kerneltest/e32test/defrag/t_ramdefrag.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/defrag/t_ramdefrag.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -543,7 +543,20 @@
 	Ldd.ResetDriver();
 	
 	Ldd.CallDefrag(DEFRAG_TYPE_GEN, DEFRAG_VER_SYNC);
-	if (VerifyMovDisAlloc() != KErrNone)
+	TInt r;
+	r = VerifyMovDisAlloc();
+	if (r == KErrGeneral)
+		{
+		// A rare set of circumstances may cause some of the movable pages to be in
+		// use during the defrag and thus not be moved to the correct RAM zone. Run
+		// the defrag once more to give it a chance to move these pages. We ensure
+		// that there is no pending asynchronous clean up operation before doing so.
+		UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
+		Ldd.CallDefrag(DEFRAG_TYPE_GEN, DEFRAG_VER_SYNC);
+		r = VerifyMovDisAlloc();
+		}
+
+	if (r != KErrNone)
 		{
 		CLEANUP(;);
 		TEST_FAIL;
--- a/kerneltest/e32test/demandpaging/t_pagetable_limit.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/demandpaging/t_pagetable_limit.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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/dll/t_xxver2.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dll/t_xxver2.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -578,8 +578,13 @@
 		test(((SSecurityInfo&)info.iSecurityInfo).iCaps[0]==0x0002aaab);
 		test(((SSecurityInfo&)info.iSecurityInfo).iCaps[1]==0);
 		if(formHeader)
+		{
+		#if defined(__ARMCC__) && __ARMCC_VERSION >= 400000
+			test(info.iHardwareFloatingPoint == EFpTypeVFPv2);
+		#else
 			test(info.iHardwareFloatingPoint == EFpTypeNone);
-
+		#endif
+		}
 		if(formHeader)
 			break;
 		formHeader = ETrue;
--- a/kerneltest/e32test/dma/d_dma.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dma/d_dma.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -260,6 +260,19 @@
 		r = TDmaChannel::Open(info, iChannel);
 		if (r!= KErrNone)
 			return r;
+
+		// ---> Code coverage of rarely called functions
+		const TDmac* const c = iChannel->Controller();
+		if (!c)
+			return KErrGeneral;
+		const TInt mts = iChannel->MaxTransferSize(0, iCookie);
+		if (mts == 0)
+			return KErrGeneral;
+		const TUint mam = iChannel->MemAlignMask(0, iCookie);
+		if (~mam == 0)
+			return KErrGeneral;
+		// <--- Code coverage of rarely called functions
+
 		iClient = &Kern::CurrentThread();
 		for (TInt i=0; i<KMaxRequests; ++i)
 			{
--- a/kerneltest/e32test/dmav2/cap_reqs.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dmav2/cap_reqs.h	Wed Aug 18 11:08:29 2010 +0300
@@ -127,4 +127,5 @@
 
 const TDmaCapability capAboveV1(EPilVersion, EGTE, 2, EFalse);
 const TDmaCapability capBelowV2(EPilVersion, ELTE, 1, EFalse);
+const TDmaCapability LinkingNotWanted(EChannelLinking, EEqual, EFalse, ETrue);
 #endif // #ifdef __CAP_REQS_H__
--- a/kerneltest/e32test/dmav2/d_dma2.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dmav2/d_dma2.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -101,6 +101,8 @@
 
 	TInt OpenDmaChannel(TUint aPslCookie, TUint& aDriverCookie);
 	TInt OpenDmaChannel(TUint& aDriverCookie, TDmaChannel::SCreateInfo& aInfo);
+	TInt LinkDmaChannelByCookie(TUint aDriverCookie);	
+	TInt UnlinkDmaChannelByCookie(TUint aDriverCookie);
 	TInt CloseDmaChannelByCookie(TUint aDriverCookie);
 	TInt PauseDmaChannelByCookie(TUint aDriverCookie);
 	TInt ResumeDmaChannelByCookie(TUint aDriverCookie);
@@ -109,12 +111,26 @@
 	TInt CancelAllByCookie(TUint aDriverCookie);
 	TInt IsrRedoRequestByCookie(TUint aDriverCookie,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb);
 	TInt IsQueueEmptyByCookie(TUint aDriverCookie, TBool& aQueueEmpty);		
-	TInt ChannelIsOpenedByCookie(TUint aDriverCookie, TBool& aChannelOpen);		
+	TInt ChannelIsOpenedByCookie(TUint aDriverCookie, TBool& aChannelOpen);	
+	TInt EnableDstElementCountingByCookie(TUint aDriverCookie);
+	TInt EnableSrcElementCountingByCookie(TUint aDriverCookie);
+	TInt DisableDstElementCountingByCookie(TUint aDriverCookie);
+	TInt DisableSrcElementCountingByCookie(TUint aDriverCookie);
+	TInt TotalNumDstElementsTransferredByCookie(TUint aDriverCookie);
+	TInt TotalNumSrcElementsTransferredByCookie(TUint aDriverCookie);
 	void CloseDmaChannelByIndex(TInt aIndex);
 	void CancelAllByIndex(TInt aIndex);
+	TInt LinkDmaChannelByIndex(TInt aIndex);
+	TInt UnlinkDmaChannelByIndex(TInt aIndex);
 	TInt PauseDmaChannelByIndex(TInt aIndex);
 	TInt ResumeDmaChannelByIndex(TInt aIndex);		
 	TInt IsrRedoRequestByIndex(TInt aIndex,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb);
+	void EnableDstElementCountingByIndex(TInt aIndex);
+	void EnableSrcElementCountingByIndex(TInt aIndex);
+	void DisableDstElementCountingByIndex(TInt aIndex);
+	void DisableSrcElementCountingByIndex(TInt aIndex);
+	TInt TotalNumDstElementsTransferredByIndex(TInt aIndex);
+	TInt TotalNumSrcElementsTransferredByIndex(TInt aIndex);
 	TInt CreateSharedChunk();
 	TUint OpenSharedChunkHandle();
 
@@ -145,13 +161,12 @@
 	TInt QueueRequest(TUint aRequestCookie, TRequestStatus* aStatus, TCallbackRecord* aRecord, TUint64* aDurationMicroSecs);
 	DClientDmaRequest* RequestFromCookie(TUint aRequestCookie) const;
 	TInt RequestFragmentCount(TUint aRequestCookie);
-
 	TDmaV2TestInfo ConvertTestInfo(const TDmaTestInfo& aOldInfo) const;
 private:
 	DThread* iClient;
 	TDynamicDfcQue* iDfcQ;
 	TDynamicDfcQue* iIsrCallbackDfcQ; // Will be used by requests which complete with an ISR callback
-	static const TInt KMaxChunkSize = 8 * KMega;
+	static const TInt KMaxChunkSize;
 	TLinAddr iChunkBase;
 	DChunk* iChunk;
 
@@ -377,7 +392,7 @@
 The new style callback called by the DMA framework
 may be called in either thread or ISR context
 */
-void DClientDmaRequest::Callback(TUint aCallbackType, TDmaResult aResult, TAny* aArg, SDmaDesHdr* aHdr)
+void DClientDmaRequest::Callback(TUint aCallbackType, TDmaResult aResult, TAny* aArg, SDmaDesHdr* /*aHdr*/)
 	{
 	const TInt context = NKern::CurrentContext();
 	__KTRACE_OPT(KDMA, Kern::Printf(">DClientDmaRequest::CallBack: TDmaResult result = %d, NKern::TContext context = %d", aResult, context));
@@ -503,7 +518,7 @@
 	Kern::QueueRequestComplete(self.iClient, self.iClientDataRequest, KErrNone);
 	}
 
-const TInt DDmaTestSession::KMaxChunkSize;
+const TInt DDmaTestSession::KMaxChunkSize = 8 * KMega;
 
 TInt DDmaTestSession::RequestUserHandle(DThread* aThread, TOwnerType aType)
 	{
@@ -517,24 +532,31 @@
 	{}
 
 // called in thread critical section
-TInt DDmaTestSession::DoCreate(TInt /*aUnit*/, const TDesC8* aInfo, const TVersion& /*aVer*/)
+TInt DDmaTestSession::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
 	{
 	__NK_ASSERT_ALWAYS(iDfcQ == NULL);
 	__NK_ASSERT_ALWAYS(iIsrCallbackDfcQ == NULL);
 
 	TInt r = Kern::DynamicDfcQCreate(iDfcQ, KDFCThreadPriority, KDFCThreadName);
 	if (r != KErrNone)
+		{
+		Kern::Printf("DDmaTestSession::DoCreate D_DMA_DFC_THREAD returned (%d)\n", r);
 		return r;
+		}
 	NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny);
 
 	r = Kern::DynamicDfcQCreate(iIsrCallbackDfcQ, KDFCThreadPriority, KIsrCbDfcThreadName);
 	if (r != KErrNone)
+		{
+		Kern::Printf("DDmaTestSession::DoCreate D_DMA_IsrCb_thread returned (%d)\n", r);
 		return r;
+		}
 	NKern::ThreadSetCpuAffinity((NThread*)(iIsrCallbackDfcQ->iThread), KCpuAffinityAny);
 
 	iClient = &Kern::CurrentThread();
 
 	r = CreateSharedChunk();
+	Kern::Printf("DDmaTestSession::DoCreate CreateSharedChunk returned (%d)\n", r);
 	return r;
 	}
 
@@ -636,12 +658,60 @@
 			TInt r = ResumeDmaChannelByCookie(driverCookie);
 			return r;
 			}
+	case RDmaSession::ELinkChannel:
+			{
+			TUint driverCookie = reinterpret_cast<TUint>(a1);
+			TInt r = LinkDmaChannelByCookie(driverCookie);
+			return r;
+			}
+	case RDmaSession::EUnlinkChannel:
+			{
+			TUint driverCookie = reinterpret_cast<TUint>(a1);
+			TInt r = UnlinkDmaChannelByCookie(driverCookie);
+			return r;
+			}
 	case RDmaSession::EFragmentCount:
 			{
 			TUint requestCookie = reinterpret_cast<TUint>(a1);
 			TInt r = RequestFragmentCount(requestCookie);
 			return r;
 			}
+	case RDmaSession::EEnableDstElementCounting:
+			{		
+			TUint requestCookie = reinterpret_cast<TUint>(a1);
+			TInt r = EnableDstElementCountingByCookie(requestCookie);
+			return r;
+			}
+	case RDmaSession::EEnableSrcElementCounting:
+			{
+			TUint requestCookie = reinterpret_cast<TUint>(a1);		
+			TInt r = EnableSrcElementCountingByCookie(requestCookie);
+			return r;
+			}
+	case RDmaSession::EDisableDstElementCounting:
+			{
+			TUint requestCookie = reinterpret_cast<TUint>(a1);
+			TInt r = DisableDstElementCountingByCookie(requestCookie);
+			return r;
+			}
+	case RDmaSession::EDisableSrcElementCounting:
+			{
+			TUint requestCookie = reinterpret_cast<TUint>(a1);
+			TInt r = DisableSrcElementCountingByCookie(requestCookie);
+			return r;
+			}
+	case RDmaSession::ETotalNumDstElementsTransferred:
+			{
+			TUint requestCookie = reinterpret_cast<TUint>(a1);
+			TInt r = TotalNumDstElementsTransferredByCookie(requestCookie);
+			return r;
+			}
+	case RDmaSession::ETotalNumSrcElementsTransferred:
+			{
+			TUint requestCookie = reinterpret_cast<TUint>(a1);
+			TInt r = TotalNumSrcElementsTransferredByCookie(requestCookie);
+			return r;
+			}
 	case RDmaSession::ERequestOpen:
 			{
 			RDmaSession::TRequestCreateArgs createArgs(0, EFalse, 0);
@@ -915,6 +985,64 @@
 	channel->CancelAll();
 	}
 
+TInt DDmaTestSession::LinkDmaChannelByIndex(TInt aIndex)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("LinkDmaChannelByIndex: %d", aIndex)); 
+	__NK_ASSERT_DEBUG(aIndex < iChannels.Count()); 
+
+#ifdef DMA_APIV2
+	TDmaChannel* channel = iChannels[aIndex];
+	return channel->LinkToChannel(channel);
+#else
+	return KErrNotSupported;
+#endif	
+	}
+
+TInt DDmaTestSession::LinkDmaChannelByCookie(TUint aDriverCookie)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("LinkDmaChannelByCookie: 0x%08x", aDriverCookie)); 
+	const TInt index = CookieToChannelIndex(aDriverCookie);
+	
+	if(index >= 0)
+		{
+		TInt r = LinkDmaChannelByIndex(index);
+		return r;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+TInt DDmaTestSession::UnlinkDmaChannelByIndex(TInt aIndex)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("UnlinkDmaChannelByIndex: %d", aIndex)); 
+	__NK_ASSERT_DEBUG(aIndex < iChannels.Count()); 
+
+#ifdef DMA_APIV2
+	TDmaChannel* channel = iChannels[aIndex];
+	return channel->LinkToChannel(NULL);
+#else
+	return KErrNotSupported;
+#endif	
+	}
+
+TInt DDmaTestSession::UnlinkDmaChannelByCookie(TUint aDriverCookie)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("UnlinkDmaChannelByCookie: 0x%08x", aDriverCookie)); 
+	const TInt index = CookieToChannelIndex(aDriverCookie);
+	
+	if(index >= 0)
+		{
+		TInt r = UnlinkDmaChannelByIndex(index);
+		return r;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
 TInt DDmaTestSession::PauseDmaChannelByIndex(TInt aIndex)
 	{
 	__KTRACE_OPT(KDMA, Kern::Printf("PauseDmaChannelByIndex: %d", aIndex)); 
@@ -973,6 +1101,164 @@
 		}
 	}
 
+TInt DDmaTestSession::EnableDstElementCountingByCookie(TUint aDriverCookie)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("EnableDstElementCountingByCookie: 0x%08x", aDriverCookie)); 
+	const TInt index = CookieToRequestIndex(aDriverCookie);
+	
+	if(index >= 0)
+		{
+		EnableDstElementCountingByIndex(index);
+		return KErrNone;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+void DDmaTestSession::EnableDstElementCountingByIndex(TInt aIndex)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("EnableDstElementCountingByIndex: %d", aIndex)); 		
+	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
+#ifdef DMA_APIV2	
+	iClientDmaReqs[aIndex]->EnableDstElementCounting();
+#endif
+	}
+
+TInt DDmaTestSession::EnableSrcElementCountingByCookie(TUint aDriverCookie)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("EnableSrcElementCountingByCookie: 0x%08x", aDriverCookie)); 
+	const TInt index = CookieToRequestIndex(aDriverCookie);
+	
+	if(index >= 0)
+		{
+		EnableSrcElementCountingByIndex(index);
+		return KErrNone;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+void DDmaTestSession::EnableSrcElementCountingByIndex(TInt aIndex)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("EnableSrcElementCountingByIndex: %d", aIndex)); 		
+	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
+	
+#ifdef DMA_APIV2
+	iClientDmaReqs[aIndex]->EnableSrcElementCounting();
+#endif
+	}
+
+TInt DDmaTestSession::DisableDstElementCountingByCookie(TUint aDriverCookie)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("DisableDstElementCountingByCookie: 0x%08x", aDriverCookie)); 
+	const TInt index = CookieToRequestIndex(aDriverCookie);
+	
+	if(index >= 0)
+		{
+		DisableDstElementCountingByIndex(index);
+		return KErrNone;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+void DDmaTestSession::DisableDstElementCountingByIndex(TInt aIndex)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("DisableDstElementCountingByIndex: %d", aIndex)); 		
+	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
+#ifdef DMA_APIV2
+	iClientDmaReqs[aIndex]->DisableDstElementCounting();
+#endif
+	}
+
+TInt DDmaTestSession::DisableSrcElementCountingByCookie(TUint aDriverCookie)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("DisableSrcElementCountingByCookie: 0x%08x", aDriverCookie)); 
+	const TInt index = CookieToRequestIndex(aDriverCookie);
+	
+	if(index >= 0)
+		{
+		DisableSrcElementCountingByIndex(index);
+		return KErrNone;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+void DDmaTestSession::DisableSrcElementCountingByIndex(TInt aIndex)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("DisableSrcElementCountingByIndex: %d", aIndex)); 		
+	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
+#ifdef DMA_APIV2
+	iClientDmaReqs[aIndex]->DisableSrcElementCounting();
+#endif
+	}
+
+TInt DDmaTestSession::TotalNumDstElementsTransferredByCookie(TUint aDriverCookie)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("TotalNumDstElementsTransferredByCookie: 0x%08x", aDriverCookie)); 
+	const TInt index = CookieToRequestIndex(aDriverCookie);
+	
+	if(index >= 0)
+		{
+		TInt r = TotalNumDstElementsTransferredByIndex(index);
+		return r;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+TInt DDmaTestSession::TotalNumDstElementsTransferredByIndex(TInt aIndex)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("TotalNumDstElementsTransferredByIndex: %d", aIndex)); 		
+	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
+	
+#ifdef DMA_APIV2
+	TInt r = iClientDmaReqs[aIndex]->TotalNumDstElementsTransferred();
+	return r;
+#else
+	return KErrNotSupported;
+#endif
+	}
+
+TInt DDmaTestSession::TotalNumSrcElementsTransferredByCookie(TUint aDriverCookie)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("TotalNumSrcElementsTransferredByCookie: 0x%08x", aDriverCookie)); 
+	const TInt index = CookieToRequestIndex(aDriverCookie);
+	
+	if(index >= 0)
+		{
+		TInt r = TotalNumSrcElementsTransferredByIndex(index);
+		return r;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+TInt DDmaTestSession::TotalNumSrcElementsTransferredByIndex(TInt aIndex)
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf("TotalNumSrcElementsTransferredByIndex: %d", aIndex)); 		
+	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
+	
+#ifdef DMA_APIV2
+	TInt r = iClientDmaReqs[aIndex]->TotalNumSrcElementsTransferred();
+	return r;
+#else
+	return KErrNotSupported;
+#endif
+	}
 TInt DDmaTestSession::IsrRedoRequestByCookie(TUint aDriverCookie,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb)
 {
 	__KTRACE_OPT(KDMA, Kern::Printf("IsrRedoRequestByCookie: 0x%08x", aDriverCookie)); 
@@ -1152,7 +1438,10 @@
     TChunkCreateInfo info;
     info.iType         = TChunkCreateInfo::ESharedKernelSingle;
     info.iMaxSize      = KMaxChunkSize;
+#ifndef __WINS__
     info.iMapAttr      = EMapAttrFullyBlocking | EMapAttrUserRw;
+#endif
+
     info.iOwnsMemory   = ETrue;
     info.iDestroyedDfc = NULL;
 
@@ -1299,16 +1588,28 @@
 	newInfo.iMemMemPslInfo = aOldInfo.iMemMemPslInfo;
 
 	newInfo.iMaxSbChannels = aOldInfo.iMaxSbChannels;
-	for(TInt i=0; i<aOldInfo.iMaxSbChannels; i++)
-		newInfo.iSbChannels[i] = aOldInfo.iSbChannels[i];
+		{
+		for(TInt i=0; i<aOldInfo.iMaxSbChannels; i++)
+			{
+			newInfo.iSbChannels[i] = aOldInfo.iSbChannels[i];
+			}
+		}
 
 	newInfo.iMaxDbChannels = aOldInfo.iMaxDbChannels;
-	for(TInt i=0; i<aOldInfo.iMaxDbChannels; i++)
-		newInfo.iDbChannels[i] = aOldInfo.iDbChannels[i];
+		{
+		for(TInt i=0; i<aOldInfo.iMaxDbChannels; i++)
+			{
+			newInfo.iDbChannels[i] = aOldInfo.iDbChannels[i];
+			}
+		}
 
 	newInfo.iMaxSgChannels = aOldInfo.iMaxSgChannels;
-	for(TInt i=0; i<aOldInfo.iMaxSgChannels; i++)
-		newInfo.iSgChannels[i] = aOldInfo.iSgChannels[i];
+		{
+		for(TInt i=0; i<aOldInfo.iMaxSgChannels; i++)
+			{
+			newInfo.iSgChannels[i] = aOldInfo.iSgChannels[i];
+			}
+		}
 
 	return newInfo;
 	}
@@ -1339,13 +1640,16 @@
 TInt DDmaTestFactory::Create(DLogicalChannelBase*& aChannel)
     {
 	aChannel=new DDmaTestSession;
+	Kern::Printf("DDmaTestFactory::Create %d\n", aChannel?KErrNone : KErrNoMemory);
 	return aChannel ? KErrNone : KErrNoMemory;
     }
 
 
 TInt DDmaTestFactory::Install()
     {
-    return SetName(&KTestDmaLddName);
+    TInt r = SetName(&KTestDmaLddName);
+	Kern::Printf("DDmaTestFactory::Install %d\n",r);
+	return r;
     }
 
 
--- a/kerneltest/e32test/dmav2/d_dma2.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dmav2/d_dma2.h	Wed Aug 18 11:08:29 2010 +0300
@@ -62,7 +62,13 @@
 	}
 #endif
 
-_LIT(KTestDmaLddName, "TestDmaV2");
+_LIT(KTestDmaLddNameSim, "TestDmaV2Sim");
+_LIT(KTestDmaLddNameHw, "TestDmaV2");
+#ifdef __DMASIM__
+const TPtrC KTestDmaLddName = KTestDmaLddNameSim();
+#else
+const TPtrC KTestDmaLddName = KTestDmaLddNameHw();
+#endif
 
 inline TVersion TestDmaLddVersion() { return TVersion(1, 0, 1); }
 
@@ -444,6 +450,16 @@
 		return DoControl(EResumeChannel, reinterpret_cast<TAny*>(aDriverCookie));
 		}
 
+	TInt ChannelLinking(TUint aDriverCookie)
+		{	
+		return DoControl(ELinkChannel, reinterpret_cast<TAny*>(aDriverCookie));
+		}
+
+	TInt ChannelUnLinking(TUint aDriverCookie)
+		{	
+		return DoControl(EUnlinkChannel, reinterpret_cast<TAny*>(aDriverCookie));
+		}
+
 	TInt ChannelCaps(TUint aDriverCookie, SDmacCaps& aChannelCaps)
 		{
 		TDmacTestCaps caps;
@@ -460,9 +476,16 @@
 	
 	TInt Open()
 		{
-		return DoCreate(KTestDmaLddName,TestDmaLddVersion(), 0, NULL, NULL, EOwnerThread);
+		TInt r = KErrNone;
+		r = DoCreate(KTestDmaLddNameHw,TestDmaLddVersion(), 0, NULL, NULL, EOwnerThread);
+		RDebug::Printf("RDmaSession::Open returned %d", r);
+		return r;
 		}
 
+	TInt OpenSim()
+		{
+		return DoCreate(KTestDmaLddNameSim,TestDmaLddVersion(), 0, NULL, NULL, EOwnerThread);
+		}
 
 	TInt RequestCreateOld(TUint aChannelCookie, TUint& aRequestCookie, TUint aMaxTransferSize=0)
 		{	
@@ -485,6 +508,36 @@
 		return DoControl(EFragmentCount, reinterpret_cast<TAny*>(aRequestCookie));
 		}
 
+	TInt RequestEnableDstElementCounting(TUint aRequestCookie)
+		{					
+		return DoControl(EEnableDstElementCounting, reinterpret_cast<TAny*>(aRequestCookie));		
+		}
+
+	TInt RequestEnableSrcElementCounting(TUint aRequestCookie)
+		{		
+		return DoControl(EEnableSrcElementCounting, reinterpret_cast<TAny*>(aRequestCookie));
+		}
+
+	TInt RequestDisableDstElementCounting(TUint aRequestCookie)
+		{	
+		return DoControl(EDisableDstElementCounting, reinterpret_cast<TAny*>(aRequestCookie));
+		}
+
+	TInt RequestDisableSrcElementCounting(TUint aRequestCookie)
+		{	
+		return DoControl(EDisableSrcElementCounting, reinterpret_cast<TAny*>(aRequestCookie));
+		}
+
+	TInt RequestTotalNumDstElementsTransferred(TUint aRequestCookie)
+		{	
+		return DoControl(ETotalNumDstElementsTransferred, reinterpret_cast<TAny*>(aRequestCookie));
+		}
+
+	TInt RequestTotalNumSrcElementsTransferred(TUint aRequestCookie)
+		{	
+		return DoControl(ETotalNumSrcElementsTransferred, reinterpret_cast<TAny*>(aRequestCookie));
+		}
+
 	/**
 	Will fragment a DMA request using the legacy API
 	*/
@@ -571,15 +624,15 @@
 		TUint chunkHandle = DoControl(EOpenSharedChunk);
 		return aChunk.SetReturnedHandle(chunkHandle);
 		}
-	
+
 	TInt GetTestInfo(TDmaV2TestInfo& aInfo)
 		{
 		TPckg<TDmaV2TestInfo> package(aInfo);
 		return DoControl(EGetTestInfo, &package);
 		}
 
-	static void SelfTest();
-	
+	static void SelfTest(TBool aSimulatedDmac);
+
 	static void ApiTest();
 #endif // __KERNEL_MODE__
 
@@ -591,8 +644,7 @@
 		TPckgC<TRequestCreateArgs> package(args);
 		return DoControl(ERequestOpen, &package, &aRequestCookie);
 		}
-
-
+	
 	struct TRequestCreateArgs
 		{
 		TRequestCreateArgs(TUint aChannelCookie, TBool aNewStyle, TUint aMaxFragmentSize)
@@ -664,7 +716,15 @@
 		EIsOpened,
 		EIsrRedoRequest,
 		ECancelAllChannel,
-		EQueueRequestWithReque
+		EQueueRequestWithReque,
+		ELinkChannel,
+		EUnlinkChannel,
+		EEnableDstElementCounting,
+		EEnableSrcElementCounting,
+		EDisableDstElementCounting,
+		EDisableSrcElementCounting,
+		ETotalNumDstElementsTransferred,
+		ETotalNumSrcElementsTransferred,
 		};
 	};
 #endif // __D_DMA2_H__
--- a/kerneltest/e32test/dmav2/d_dma2_cmn.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dmav2/d_dma2_cmn.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -17,10 +17,20 @@
 */
 #ifdef __KERNEL_MODE__
 #include <platform.h>
+
+#ifdef __DMASIM__
+#ifdef __WINS__
+typedef TLinAddr TPhysAddr;
+#endif
+static inline TPhysAddr LinToPhys(TLinAddr aLin) {return aLin;}
+#else
+static inline TPhysAddr LinToPhys(TLinAddr aLin) {return Epoc::LinearToPhysical(aLin);}
+#endif
 #endif
 
 #include "d_dma2.h"
 
+
 TInt Log2(TInt aNum)
 	{
 	TInt res = -1;
@@ -240,7 +250,7 @@
 		iSrcAddr += aChunkBase;
 
 #ifdef __KERNEL_MODE__
-		iSrcAddr = Epoc::LinearToPhysical(iSrcAddr);
+		iSrcAddr = LinToPhys(iSrcAddr);
 		TEST_ASSERT(iSrcAddr != KPhysAddrInvalid);
 #endif
 		}
@@ -258,7 +268,7 @@
 		iDstAddr += aChunkBase;
 
 #ifdef __KERNEL_MODE__
-		iDstAddr = Epoc::LinearToPhysical(iDstAddr);
+		iDstAddr = LinToPhys(iDstAddr);
 		TEST_ASSERT(iDstAddr != KPhysAddrInvalid);
 #endif
 		}
@@ -321,9 +331,9 @@
 void TAddressParms::MakePhysical()
 	{
 #ifdef __KERNEL_MODE__
-	iSrcAddr = Epoc::LinearToPhysical(iSrcAddr);
+	iSrcAddr = LinToPhys(iSrcAddr);
 	TEST_ASSERT(iSrcAddr != KPhysAddrInvalid);
-	iDstAddr = Epoc::LinearToPhysical(iDstAddr);
+	iDstAddr = LinToPhys(iDstAddr);
 	TEST_ASSERT(iDstAddr != KPhysAddrInvalid);
 #else
 	TEST_FAULT;
@@ -385,7 +395,7 @@
 	{
 	TUint chunkStart = 0;
 #ifdef __KERNEL_MODE__
-	chunkStart = Epoc::LinearToPhysical(aStart);
+	chunkStart = LinToPhys(aStart);
 	TEST_ASSERT(chunkStart != KPhysAddrInvalid);
 #else
 	chunkStart = aStart;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/dmav2/dma2_sim.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,760 @@
+// 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:
+// os/kernelhwsrv/kerneltest/e32test/dmav2/dma2_sim.cpp
+// Partial simulation of DMA2 PSL
+//
+//
+
+
+#include <kernel/kern_priv.h>
+
+#include <drivers/dma.h>
+#include <drivers/dma_hai.h>
+
+#include "d_dma2.h"
+
+// Debug support
+static const char KDmaPanicCat[] = "DMA PSL - " __FILE__;
+
+static const TInt KMaxTransferLen = 0x1000;	// max transfer length for this DMAC
+static const TInt KMemAlignMask = 0; // memory addresses passed to DMAC must be multiple of 8
+static const TInt KDesCount = 160;				// Initial DMA descriptor count
+
+#define TEST_RETURN(X) if (!(X))\
+	{\
+	__KTRACE_OPT(KPANIC, Kern::Printf("Simulated Dma test failure: " __FILE__ " line %d", __LINE__));\
+	return KErrAbort;\
+	}
+
+class TDmaDesc
+//
+// Hardware DMA descriptor
+//
+	{
+public:
+	enum {KStopBitMask = 1};
+public:
+	TPhysAddr iDescAddr;
+	TPhysAddr iSrcAddr;
+	TPhysAddr iDestAddr;
+	TUint32 iCmd;
+	};
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Test Support
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+TO DO: Fill in to provide information to the V1 test harness (t_dma.exe)
+*/
+TDmaTestInfo TestInfo =
+	{
+	0,
+	0,
+	0,
+	0,
+	NULL,
+	0,
+	NULL,
+	0,
+	NULL
+	};
+
+
+EXPORT_C const TDmaTestInfo& DmaTestInfo()
+//
+//
+//
+	{
+	return TestInfo;
+	}
+
+/**
+TO DO: Fill in to provide information to the V2 test harness (t_dma2.exe)
+*/
+TDmaV2TestInfo TestInfov2 =
+	{
+	0,
+	0,
+	0,
+	0,
+	{0},
+	0,
+	{0},
+	1,
+	{0}
+	};
+
+EXPORT_C const TDmaV2TestInfo& DmaTestInfoV2()
+	{
+	return TestInfov2;
+	}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Simulated channel
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+An interface class to add simulation specific functionallity to any DMA channel
+*/
+class MSimChannel
+	{
+public:
+	virtual TInt PreOpen() =0;
+	virtual TDmaChannel& Channel() =0;
+	};
+
+//////////////////////////////////////////////////////////////////////////////
+// Derived Channel (Scatter/Gather)
+//////////////////////////////////////////////////////////////////////////////
+
+const SDmacCaps KSimSgChanCaps =
+	{0,										// TInt iChannelPriorities;
+	 EFalse,								// TBool iChannelPauseAndResume;
+	 EFalse,								// TBool iAddrAlignedToElementSize;
+	 EFalse,								// TBool i1DIndexAddressing;
+	 EFalse,								// TBool i2DIndexAddressing;
+	 KDmaSyncAuto,						   // TUint iSynchronizationTypes;
+	 KDmaBurstSizeAny,					   // TUint iBurstTransactions;
+	 EFalse,							   // TBool iDescriptorInterrupt;
+	 EFalse,							   // TBool iFrameInterrupt;
+	 EFalse,							   // TBool iLinkedListPausedInterrupt;
+	 EFalse,							   // TBool iEndiannessConversion;
+	 KDmaGraphicsOpNone,				   // TUint iGraphicsOps;
+	 EFalse,							   // TBool iRepeatingTransfers;
+	 EFalse,							   // TBool iChannelLinking;
+	 ETrue,								   // TBool iHwDescriptors;
+	 EFalse,							   // TBool iSrcDstAsymmetry;
+	 EFalse,							   // TBool iAsymHwDescriptors;
+	 EFalse,							   // TBool iBalancedAsymSegments;
+	 EFalse,							   // TBool iAsymCompletionInterrupt;
+	 EFalse,							   // TBool iAsymDescriptorInterrupt;
+	 EFalse,							   // TBool iAsymFrameInterrupt;
+	 {0, 0, 0, 0, 0}					   // TUint32 iReserved[5];
+	};
+
+const SDmacCaps KSimSwChanCaps =
+	{0,										// TInt iChannelPriorities;
+	 EFalse,								// TBool iChannelPauseAndResume;
+	 EFalse,								// TBool iAddrAlignedToElementSize;
+	 EFalse,								// TBool i1DIndexAddressing;
+	 EFalse,								// TBool i2DIndexAddressing;
+	 KDmaSyncAuto,						   // TUint iSynchronizationTypes;
+	 KDmaBurstSizeAny,					   // TUint iBurstTransactions;
+	 EFalse,							   // TBool iDescriptorInterrupt;
+	 EFalse,							   // TBool iFrameInterrupt;
+	 EFalse,							   // TBool iLinkedListPausedInterrupt;
+	 EFalse,							   // TBool iEndiannessConversion;
+	 KDmaGraphicsOpNone,				   // TUint iGraphicsOps;
+	 EFalse,							   // TBool iRepeatingTransfers;
+	 EFalse,							   // TBool iChannelLinking;
+	 EFalse,							   // TBool iHwDescriptors;
+	 EFalse,							   // TBool iSrcDstAsymmetry;
+	 EFalse,							   // TBool iAsymHwDescriptors;
+	 EFalse,							   // TBool iBalancedAsymSegments;
+	 EFalse,							   // TBool iAsymCompletionInterrupt;
+	 EFalse,							   // TBool iAsymDescriptorInterrupt;
+	 EFalse,							   // TBool iAsymFrameInterrupt;
+	 {0, 0, 0, 0, 0}					   // TUint32 iReserved[5];
+	};
+
+class TEmptyChannel : public TDmaChannel, public MSimChannel
+	{
+public:
+	// Virtual from TDmaChannel
+	void DoCancelAll();
+
+	void CallDefaultVirtuals();
+	TInt CheckExtensionStubs();
+
+	// From MSimChannel
+	TInt PreOpen();
+	TDmaChannel& Channel() {return *this;}
+	};
+
+void TEmptyChannel::DoCancelAll()
+	{
+	__DMA_CANT_HAPPEN();
+	}
+
+void TEmptyChannel::CallDefaultVirtuals()
+	{
+	DMA_PSL_TRACE("Calling default virtual TDmaChannel functions");
+
+	const DDmaRequest* req = NULL;
+	SDmaDesHdr* hdr = NULL;
+
+	DoQueue(*req);
+	DoDfc(*req, hdr);
+	DoDfc(*req, hdr, hdr);
+
+	QueuedRequestCountChanged();
+	}
+
+TInt TEmptyChannel::CheckExtensionStubs()
+	{
+	DMA_PSL_TRACE("Calling extension stubs");
+
+	TInt r = Extension(0, NULL);
+	TEST_RETURN(r == KErrNotSupported)
+
+	r = StaticExtension(0, NULL);
+	TEST_RETURN(r == KErrNotSupported)
+
+	return KErrNone;
+	}
+
+TInt TEmptyChannel::PreOpen()
+	{
+	CallDefaultVirtuals();
+	return CheckExtensionStubs();
+	}
+
+//////////////////////////////////////////////////////////////////////////////
+// Derived SkelControllerSw Class
+//////////////////////////////////////////////////////////////////////////////
+
+class TSkelDmac : public TDmac
+	{
+public:
+	TSkelDmac(const SCreateInfo& aInfo);
+	TInt Create(const SCreateInfo& aInfo);
+private:
+	// from TDmac (PIL pure virtual)
+	virtual void StopTransfer(const TDmaChannel& aChannel);
+	virtual TBool IsIdle(const TDmaChannel& aChannel);
+	virtual TUint MaxTransferLength(TDmaChannel& aChannel, TUint aSrcFlags,
+									TUint aDstFlags, TUint32 aPslInfo);
+	virtual TUint AddressAlignMask(TDmaChannel& aChannel, TUint aSrcFlags,
+								   TUint aDstFlags, TUint32 aPslInfo);
+
+	inline TDmaDesc* HdrToHwDes(const SDmaDesHdr& aHdr);
+
+	void CallDefaultVirtuals();
+	TInt TestPool();
+
+public:
+	static const SCreateInfo KDmacInfoHw;
+	static const SCreateInfo KDmacInfoSw;
+
+	TEmptyChannel iChannel;
+	};
+
+
+const TDmac::SCreateInfo TSkelDmac::KDmacInfoHw =
+	{
+	ETrue,													// iCapsHwDes
+	KDesCount,												// iDesCount
+	sizeof(TDmaDesc),										// iDesSize
+#ifndef __WINS__
+	EMapAttrSupRw | EMapAttrFullyBlocking					// iDesChunkAttribs
+#endif
+	};
+
+const TDmac::SCreateInfo TSkelDmac::KDmacInfoSw =
+	{
+	EFalse,													// iCapsHwDes
+	KDesCount,												// iDesCount
+	sizeof(TDmaTransferArgs),										// iDesSize
+#ifndef __WINS__
+	EMapAttrSupRw | EMapAttrFullyBlocking					// iDesChunkAttribs
+#endif
+	};
+
+static TSkelDmac SkelControllerSw(TSkelDmac::KDmacInfoSw);
+static TSkelDmac SkelControllerHw(TSkelDmac::KDmacInfoHw);
+
+
+TSkelDmac::TSkelDmac(const SCreateInfo& aInfo)
+//
+// Constructor.
+//
+	: TDmac(aInfo)
+	{
+	TInt r = Create(aInfo);
+	__NK_ASSERT_ALWAYS(r == KErrNone);
+
+	CallDefaultVirtuals();
+	r = TestPool();
+	__NK_ASSERT_ALWAYS(r == KErrNone);
+	}
+
+
+TInt TSkelDmac::Create(const SCreateInfo& aInfo)
+//
+// Second phase construction.
+//
+	{
+	TInt r = TDmac::Create(aInfo);							// Base class Create()
+	if (r == KErrNone)
+		{
+		__DMA_ASSERTA(ReserveSetOfDes(1) == KErrNone);
+		}
+	return r;
+	}
+
+
+void TSkelDmac::StopTransfer(const TDmaChannel& aChannel)
+//
+// Stops a running channel.
+//
+	{
+	const TUint8 i = static_cast<TUint8>(aChannel.PslId());
+
+	__KTRACE_OPT(KDMA, Kern::Printf(">TSkelDmac::StopTransfer channel=%d (unsupported)", i));
+
+	(void) i;
+
+	}
+
+
+TBool TSkelDmac::IsIdle(const TDmaChannel& aChannel)
+//
+// Returns the state of a given channel.
+//
+	{
+	const TUint8 i = static_cast<TUint8>(aChannel.PslId());
+
+	__KTRACE_OPT(KDMA, Kern::Printf(">TSkelDmac::IsIdle channel=%d (unsupported)", i));
+
+	// TO DO (for instance): Return the state of the RUN bit of the channel.
+	// The return value should reflect the actual state.
+	(void) i;
+
+	return ETrue;
+	}
+
+
+TUint TSkelDmac::MaxTransferLength(TDmaChannel& /*aChannel*/, TUint /*aSrcFlags*/,
+									   TUint /*aDstFlags*/, TUint32 /*aPslInfo*/)
+//
+// Returns the maximum transfer length in bytes for a given transfer.
+//
+	{
+	// TO DO: Determine the proper return value, based on the arguments.
+
+	// For instance:
+	return KMaxTransferLen;
+	}
+
+
+TUint TSkelDmac::AddressAlignMask(TDmaChannel& /*aChannel*/, TUint /*aSrcFlags*/,
+									  TUint /*aDstFlags*/, TUint32 /*aPslInfo*/)
+//
+// Returns the memory buffer alignment restrictions mask for a given transfer.
+//
+	{
+	// TO DO: Determine the proper return value, based on the arguments.
+
+	// For instance:
+	return KMemAlignMask;
+	}
+
+
+inline TDmaDesc* TSkelDmac::HdrToHwDes(const SDmaDesHdr& aHdr)
+//
+// Changes return type of base class call.
+//
+	{
+	return static_cast<TDmaDesc*>(TDmac::HdrToHwDes(aHdr));
+	}
+
+/**
+Call the default virtual functions on the TDmac,
+that would never otherwise be called
+
+*/
+void TSkelDmac::CallDefaultVirtuals()
+	{
+	DMA_PSL_TRACE("Calling default virtual TDmac functions");
+
+	TDmaChannel* channel = NULL;
+	SDmaDesHdr* hdr = NULL;
+
+	Transfer(*channel, *hdr);
+	Transfer(*channel, *hdr, *hdr);
+
+	const TDmaTransferArgs args;
+	TInt r = KErrNone;
+
+	r = InitHwDes(*hdr, args);
+	__NK_ASSERT_ALWAYS(r == KErrGeneral);
+
+	r = InitSrcHwDes(*hdr, args);
+	__NK_ASSERT_ALWAYS(r == KErrGeneral);
+
+	r = InitDstHwDes(*hdr, args);
+	__NK_ASSERT_ALWAYS(r == KErrGeneral);
+
+	r = UpdateHwDes(*hdr, KPhysAddrInvalid, KPhysAddrInvalid, 0, 0);
+	__NK_ASSERT_ALWAYS(r == KErrGeneral);
+
+	r = UpdateSrcHwDes(*hdr, KPhysAddrInvalid, 0, 0);
+	__NK_ASSERT_ALWAYS(r == KErrGeneral);
+
+	r = UpdateDstHwDes(*hdr, KPhysAddrInvalid, 0, 0);
+	__NK_ASSERT_ALWAYS(r == KErrGeneral);
+
+	ChainHwDes(*hdr, *hdr);
+	AppendHwDes(*channel, *hdr, *hdr);
+	AppendHwDes(*channel, *hdr, *hdr, *hdr, *hdr);
+	UnlinkHwDes(*channel, *hdr);
+
+	TUint32 count = 0;
+
+	count = HwDesNumDstElementsTransferred(*hdr);
+	__NK_ASSERT_ALWAYS(count == 0);
+
+	count = HwDesNumSrcElementsTransferred(*hdr);
+	__NK_ASSERT_ALWAYS(count == 0);
+	}
+
+TInt TSkelDmac::TestPool()
+	{
+	DMA_PSL_TRACE("TSkelDmac::TestPool()");
+	TInt count = 0;
+	SDmaDesHdr* hdr = iFreeHdr;
+	TAny* des = iDesPool;
+
+	TInt r = KErrNone;
+	while(hdr->iNext)
+		{
+		TAny* receivedDes = NULL;
+		if(iCapsHwDes)
+			{
+			receivedDes = HdrToHwDes(*hdr);
+			}
+		else
+			{
+			TDmaTransferArgs& args = HdrToDes(*hdr);
+			receivedDes = &args;
+			}
+
+		if(receivedDes != des)
+			{
+			DMA_PSL_TRACE1("TSkelDmac::TestPool() failure: count=%d", count);
+			r = KErrGeneral;
+			break;
+			}
+
+		hdr = hdr->iNext;
+		des = (TAny*)((TUint)des + iDesSize);
+		count++;
+		}
+
+	if(count != (KDesCount - 1))
+		{
+		DMA_PSL_TRACE2("TSkelDmac::TestPool() failure: count = %d != (iMaxDesCount -1) = %d", count, KDesCount-1);
+		r = KErrUnknown;
+		}
+	return r;
+	}
+
+//////////////////////////////////////////////////////////////////////////////
+// Simulated Fragmentation Dmac
+//////////////////////////////////////////////////////////////////////////////
+
+
+const SDmacCaps KSimAsymmChanCaps =
+	{0,										// TInt iChannelPriorities;
+	 EFalse,								// TBool iChannelPauseAndResume;
+	 EFalse,								// TBool iAddrAlignedToElementSize;
+	 EFalse,								// TBool i1DIndexAddressing;
+	 EFalse,								// TBool i2DIndexAddressing;
+	 KDmaSyncAuto,						   // TUint iSynchronizationTypes;
+	 KDmaBurstSizeAny,					   // TUint iBurstTransactions;
+	 EFalse,							   // TBool iDescriptorInterrupt;
+	 EFalse,							   // TBool iFrameInterrupt;
+	 EFalse,							   // TBool iLinkedListPausedInterrupt;
+	 EFalse,							   // TBool iEndiannessConversion;
+	 KDmaGraphicsOpNone,				   // TUint iGraphicsOps;
+	 EFalse,							   // TBool iRepeatingTransfers;
+	 EFalse,							   // TBool iChannelLinking;
+	 ETrue,								   // TBool iHwDescriptors;
+	 EFalse,							   // TBool iSrcDstAsymmetry;
+	 ETrue,								   // TBool iAsymHwDescriptors;
+	 EFalse,							   // TBool iBalancedAsymSegments;
+	 EFalse,							   // TBool iAsymCompletionInterrupt;
+	 EFalse,							   // TBool iAsymDescriptorInterrupt;
+	 EFalse,							   // TBool iAsymFrameInterrupt;
+	 {0, 0, 0, 0, 0}					   // TUint32 iReserved[5];
+	};
+
+const SDmacCaps KSimAsymmBalancedChanCaps =
+	{0,										// TInt iChannelPriorities;
+	 EFalse,								// TBool iChannelPauseAndResume;
+	 EFalse,								// TBool iAddrAlignedToElementSize;
+	 EFalse,								// TBool i1DIndexAddressing;
+	 EFalse,								// TBool i2DIndexAddressing;
+	 KDmaSyncAuto,						   // TUint iSynchronizationTypes;
+	 KDmaBurstSizeAny,					   // TUint iBurstTransactions;
+	 EFalse,							   // TBool iDescriptorInterrupt;
+	 EFalse,							   // TBool iFrameInterrupt;
+	 EFalse,							   // TBool iLinkedListPausedInterrupt;
+	 EFalse,							   // TBool iEndiannessConversion;
+	 KDmaGraphicsOpNone,				   // TUint iGraphicsOps;
+	 EFalse,							   // TBool iRepeatingTransfers;
+	 EFalse,							   // TBool iChannelLinking;
+	 ETrue,								   // TBool iHwDescriptors;
+	 EFalse,							   // TBool iSrcDstAsymmetry;
+	 ETrue,								   // TBool iAsymHwDescriptors;
+	 ETrue,								   // TBool iBalancedAsymSegments;
+	 EFalse,							   // TBool iAsymCompletionInterrupt;
+	 EFalse,							   // TBool iAsymDescriptorInterrupt;
+	 EFalse,							   // TBool iAsymFrameInterrupt;
+	 {0, 0, 0, 0, 0}					   // TUint32 iReserved[5];
+	};
+
+
+class TAsymmDmac : public TDmac
+	{
+	struct THwDes
+		{
+		TUint iAddr;
+		TUint iLength;
+		TUint iCookie;
+		};
+public:
+	TAsymmDmac();
+	TInt Create();
+private:
+	// Work around for compiler which forbids this
+	// class from accessing the protected, nested TDmac::SCreateInfo
+	using TDmac::SCreateInfo;
+
+	// from TDmac (PIL pure virtual)
+	virtual void StopTransfer(const TDmaChannel& aChannel);
+	virtual TBool IsIdle(const TDmaChannel& aChannel);
+	virtual TUint MaxTransferLength(TDmaChannel& aChannel, TUint aSrcFlags,
+									TUint aDstFlags, TUint32 aPslInfo);
+	virtual TUint AddressAlignMask(TDmaChannel& aChannel, TUint aSrcFlags,
+								   TUint aDstFlags, TUint32 aPslInfo);
+	// from TDmac (PIL virtual)
+	TInt InitSrcHwDes(const SDmaDesHdr& /*aHdr*/, const TDmaTransferArgs& /*aTransferArgs*/);
+	TInt InitDstHwDes(const SDmaDesHdr& /*aHdr*/, const TDmaTransferArgs& /*aTransferArgs*/);
+
+	void ChainHwDes(const SDmaDesHdr& aHdr, const SDmaDesHdr& aNextHdr);
+	void UnlinkHwDes(const TDmaChannel& aChannel, SDmaDesHdr& aHdr);
+
+	inline THwDes* HdrToHwDes(const SDmaDesHdr& aHdr);
+
+private:
+	static const SCreateInfo KInfo;
+public:
+	static const TInt iChannelCount;
+	TEmptyChannel iChannel;
+	};
+
+const TAsymmDmac::SCreateInfo TAsymmDmac::KInfo =
+	{
+	ETrue,													// iCapsHwDes
+	KDesCount,												// iDesCount
+	sizeof(THwDes),											// iDesSize
+#ifndef __WINS__
+	EMapAttrSupRw | EMapAttrFullyBlocking					// iDesChunkAttribs
+#endif
+	};
+
+const TInt TAsymmDmac::iChannelCount = 1;
+
+static TAsymmDmac AsymController;
+
+TAsymmDmac::TAsymmDmac()
+//
+// Constructor.
+//
+	: TDmac(KInfo)
+	{
+	TInt r = Create();
+	__NK_ASSERT_ALWAYS(r == KErrNone);
+	}
+
+
+TInt TAsymmDmac::Create()
+//
+// Second phase construction.
+//
+	{
+	TInt r = TDmac::Create(KInfo);							// Base class Create()
+	if (r == KErrNone)
+		{
+		__DMA_ASSERTA(ReserveSetOfDes(iChannelCount) == KErrNone);
+		}
+	return r;
+	}
+
+
+void TAsymmDmac::StopTransfer(const TDmaChannel& /*aChannel*/)
+//
+// Stops a running channel.
+//
+	{
+	__DMA_CANT_HAPPEN();
+	}
+
+
+TBool TAsymmDmac::IsIdle(const TDmaChannel& /*aChannel*/)
+//
+// Returns the state of a given channel.
+//
+	{
+	__DMA_CANT_HAPPEN();
+	return ETrue;
+	}
+
+
+TUint TAsymmDmac::MaxTransferLength(TDmaChannel& /*aChannel*/, TUint /*aSrcFlags*/,
+									   TUint /*aDstFlags*/, TUint32 /*aPslInfo*/)
+//
+// Returns the maximum transfer length in bytes for a given transfer.
+//
+	{
+	// TO DO: Determine the proper return value, based on the arguments.
+
+	// For instance:
+	return KMaxTransferLen;
+	}
+
+
+TUint TAsymmDmac::AddressAlignMask(TDmaChannel& /*aChannel*/, TUint /*aSrcFlags*/,
+									  TUint /*aDstFlags*/, TUint32 /*aPslInfo*/)
+//
+// Returns the memory buffer alignment restrictions mask for a given transfer.
+//
+	{
+	// TO DO: Determine the proper return value, based on the arguments.
+
+	// For instance:
+	return KMemAlignMask;
+	}
+
+
+inline TAsymmDmac::THwDes* TAsymmDmac::HdrToHwDes(const SDmaDesHdr& aHdr)
+//
+// Changes return type of base class call.
+//
+	{
+	return static_cast<THwDes*>(TDmac::HdrToHwDes(aHdr));
+	}
+
+TInt TAsymmDmac::InitSrcHwDes(const SDmaDesHdr& /*aHdr*/, const TDmaTransferArgs& /*aTransferArgs*/)
+	{
+	return KErrNone;
+	}
+
+TInt TAsymmDmac::InitDstHwDes(const SDmaDesHdr& /*aHdr*/, const TDmaTransferArgs& /*aTransferArgs*/)
+	{
+	return KErrNone;
+	}
+
+void TAsymmDmac::ChainHwDes(const SDmaDesHdr& /*aHdr*/, const SDmaDesHdr& /*aNextHdr*/)
+	{
+	}
+
+void TAsymmDmac::UnlinkHwDes(const TDmaChannel& /*aChannel*/, SDmaDesHdr& /*aHdr*/)
+	{
+	}
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Channel Opening/Closing (Channel Allocator)
+//////////////////////////////////////////////////////////////////////////////
+
+struct TChanEntry
+	{
+	TChanEntry(TDmac& aController, MSimChannel& aChannel, const SDmacCaps& aCaps)
+		:
+			iController(aController),
+			iSimChannel(aChannel),
+			iCaps(aCaps)
+	{}
+
+	TDmac& iController;
+	MSimChannel& iSimChannel;
+	const SDmacCaps& iCaps;
+	};
+
+const TChanEntry ChannelTable[] =
+	{
+		TChanEntry(SkelControllerSw, SkelControllerSw.iChannel, KSimSwChanCaps),
+		TChanEntry(SkelControllerHw, SkelControllerHw.iChannel, KSimSgChanCaps),
+		TChanEntry(AsymController, AsymController.iChannel, KSimAsymmChanCaps),
+		TChanEntry(AsymController, AsymController.iChannel, KSimAsymmBalancedChanCaps)
+	};
+
+static const TInt KChannelCount = ARRAY_LENGTH(ChannelTable);
+
+TDmaChannel* DmaChannelMgr::Open(TUint32 aOpenId, TBool /*aDynChannel*/, TUint /*aPriority*/)
+//
+//
+//
+	{
+	__KTRACE_OPT(KDMA, Kern::Printf(">DmaChannelMgr::Open aOpenId=%d", aOpenId));
+
+	__DMA_ASSERTA(aOpenId < static_cast<TUint32>(KChannelCount));
+
+	const TChanEntry& entry = ChannelTable[aOpenId];
+	TDmaChannel* pC = &entry.iSimChannel.Channel();
+	if (pC->IsOpened())
+		{
+		pC = NULL;
+		}
+	else
+		{
+		pC->iController = &entry.iController;
+		pC->iPslId = aOpenId;
+		pC->iDmacCaps = &entry.iCaps;
+
+		// It is safe to signal here,
+		// setting iController marks the channel
+		// as taken
+		Signal();
+
+		TInt r = entry.iSimChannel.PreOpen();
+
+		Wait();
+
+		// If there was an error
+		// Close channel after retaking mutex
+		if(r != KErrNone)
+			{
+			pC->iController = NULL;
+			pC = NULL;
+			}
+
+
+		}
+	return pC;
+	}
+
+
+void DmaChannelMgr::Close(TDmaChannel* /*aChannel*/)
+//
+//
+//
+	{
+	// NOP
+	}
+
+
+TInt DmaChannelMgr::StaticExtension(TInt /*aCmd*/, TAny* /*aArg*/)
+//
+//
+//
+	{
+	return KErrNotSupported;
+	}
--- a/kerneltest/e32test/dmav2/self_test.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dmav2/self_test.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -31,12 +31,23 @@
 
 static RTest test(_L("t_dma2 test framework tests"));
 
-void RDmaSession::SelfTest()
+void RDmaSession::SelfTest(TBool aSimulatedDmac)
 	{
 	test.Start(_L("Simple transfer test"));
-	test.Next(_L("Open session"));
+
 	RDmaSession session;
-	TInt r = session.Open();
+	TInt r = KErrUnknown;
+	if (aSimulatedDmac)
+		{
+		test.Next(_L("Open session (simulated DMA)"));
+		r = session.OpenSim();
+		}
+	else
+		{
+		test.Next(_L("Open session"));
+		r = session.Open();
+		}
+
 	test_KErrNone(r);
 
 	test.Next(_L("Get test info"));
@@ -134,16 +145,19 @@
 		test.Printf(_L("cookie recived = 0x%08x\n"), reqCookieNewStyle );
 		test_KErrNone(r);
 
-		test.Next(_L("Fragment for ISR callback"));
-		const TInt size = 128 * KKilo;
-		TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr, KDmaSyncAuto, KDmaRequestCallbackFromIsr);
-		r = session.FragmentRequest(reqCookieNewStyle, transferArgs);
-		test_KErrNone(r);
+		if(!aSimulatedDmac)
+			{
+			test.Next(_L("Fragment for ISR callback"));
+			const TInt size = 128 * KKilo;
+			TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr, KDmaSyncAuto, KDmaRequestCallbackFromIsr);
+			r = session.FragmentRequest(reqCookieNewStyle, transferArgs);
+			test_KErrNone(r);
 
-		TIsrRequeArgs reque;
-		test.Next(_L("Queue ISR callback - with default re-queue"));
-		r = session.QueueRequestWithRequeue(reqCookieNewStyle, &reque, 1);
-		test_KErrNone(r);
+			TIsrRequeArgs reque;
+			test.Next(_L("Queue ISR callback - with default re-queue"));
+			r = session.QueueRequestWithRequeue(reqCookieNewStyle, &reque, 1);
+			test_KErrNone(r);
+			}
 
 		test.Next(_L("Destroy new-style Dma request"));
 		r = session.RequestDestroy(reqCookieNewStyle);
@@ -166,78 +180,81 @@
 	test(chunk.IsWritable());
 	test(chunk.IsReadable());
 
-	test.Next(_L("Fragment(old style)"));
-	const TInt size = 128 * KKilo;
-	TInt i;
-	for(i = 0; i<10; i++)
-		{
-		TUint64 time = 0;
-		TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr);
-		r = session.FragmentRequestOld(reqCookie, transferArgs, &time);
-		test_KErrNone(r);
-		if(gVerboseOutput)
-			{
-			test.Printf(_L("%lu us\n"), time);
-			}
-	}
-
-	test.Next(_L("Queue"));
-	TRequestStatus status;
-
-	for(i = 0; i<10; i++)
+	if(!aSimulatedDmac)
 		{
-		TUint64 time = 0;
-		r = session.QueueRequest(reqCookie, status, 0, &time);
-		User::WaitForRequest(status);
-		test_KErrNone(r);
-		if(gVerboseOutput)
+		test.Next(_L("Fragment(old style)"));
+		const TInt size = 128 * KKilo;
+		TInt i;
+		for(i = 0; i<10; i++)
 			{
-			test.Printf(_L("%lu us\n"), time);
+			TUint64 time = 0;
+			TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr);
+			r = session.FragmentRequestOld(reqCookie, transferArgs, &time);
+			test_KErrNone(r);
+			if(gVerboseOutput)
+				{
+				test.Printf(_L("%lu us\n"), time);
+				}
 			}
-		}
 
-	if(newPil)
-		{
-		test.Next(_L("Fragment(new style)"));
-		TDmaTransferArgs transferArgs;
-		transferArgs.iSrcConfig.iAddr = 0;
-		transferArgs.iDstConfig.iAddr = size;
-		transferArgs.iSrcConfig.iFlags = KDmaMemAddr;
-		transferArgs.iDstConfig.iFlags = KDmaMemAddr;
-		transferArgs.iTransferCount = size;
+		test.Next(_L("Queue"));
+		TRequestStatus status;
 
 		for(i = 0; i<10; i++)
 			{
 			TUint64 time = 0;
-			r = session.FragmentRequest(reqCookie, transferArgs, &time);
+			r = session.QueueRequest(reqCookie, status, 0, &time);
+			User::WaitForRequest(status);
 			test_KErrNone(r);
 			if(gVerboseOutput)
 				{
 				test.Printf(_L("%lu us\n"), time);
 				}
 			}
-		}
 
-	test.Next(_L("Queue"));
-	TCallbackRecord record;
-	r = session.QueueRequest(reqCookie, &record);
-	test_KErrNone(r);
+		if(newPil)
+			{
+			test.Next(_L("Fragment(new style)"));
+			TDmaTransferArgs transferArgs;
+			transferArgs.iSrcConfig.iAddr = 0;
+			transferArgs.iDstConfig.iAddr = size;
+			transferArgs.iSrcConfig.iFlags = KDmaMemAddr;
+			transferArgs.iDstConfig.iFlags = KDmaMemAddr;
+			transferArgs.iTransferCount = size;
 
-	test.Next(_L("check TCallbackRecord record"));
-	if(gVerboseOutput)
-	{
-	record.Print();
-	}
-	const TCallbackRecord expected(TCallbackRecord::EThread, 1);
-	if(!(record == expected))
+			for(i = 0; i<10; i++)
+				{
+				TUint64 time = 0;
+				r = session.FragmentRequest(reqCookie, transferArgs, &time);
+				test_KErrNone(r);
+				if(gVerboseOutput)
+					{
+					test.Printf(_L("%lu us\n"), time);
+					}
+				}
+			}
+
+		test.Next(_L("Queue"));
+		TCallbackRecord record;
+		r = session.QueueRequest(reqCookie, &record);
+		test_KErrNone(r);
+
+		test.Next(_L("check TCallbackRecord record"));
+		if(gVerboseOutput)
 		{
-		test.Printf(_L("TCallbackRecords did not match"));
-		if(gVerboseOutput)
+		record.Print();
+		}
+		const TCallbackRecord expected(TCallbackRecord::EThread, 1);
+		if(!(record == expected))
 			{
-			test.Printf(_L("expected:"));
-			expected.Print();
+			test.Printf(_L("TCallbackRecords did not match"));
+			if(gVerboseOutput)
+				{
+				test.Printf(_L("expected:"));
+				expected.Print();
+				}
+			TEST_FAULT;
 			}
-		TEST_FAULT;
 		}
 
 	test.Next(_L("Destroy Dma request"));
@@ -259,7 +276,6 @@
 	RTest::CloseHandleAndWaitForDestruction(session);
 
 	test.End();
-
 	}
 
 const SDmacCaps KTestCapSet =
@@ -815,7 +831,12 @@
 void SelfTests()
 	{
 	test.Next(_L("Running framework unit tests"));
-	RDmaSession::SelfTest();
+#ifndef __WINS__
+	// Cannot connect real driver on Emulator - only
+	// simulator
+	RDmaSession::SelfTest(EFalse);
+#endif
+	RDmaSession::SelfTest(ETrue);
 	TDmaCapability::SelfTest();
 	TTestCase::SelfTest();
 	TTransferIter::SelfTest();
--- a/kerneltest/e32test/dmav2/t_dma2.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dmav2/t_dma2.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -131,6 +131,10 @@
 	if(iDmaSession.Handle() == KNullHandle)
 		{
 		TInt r = iDmaSession.Open();
+		if(KErrNone != r)
+			{
+			RDebug::Printf("CDmaTest::OpenDmaSession = %d\n", r);
+			}
 		TEST_ASSERT(r == KErrNone);
 		r = iDmaSession.OpenSharedChunk(iChunk);
 		TEST_ASSERT(r == KErrNone);
@@ -700,6 +704,159 @@
 	}
 
 //////////////////////////////////////////////////////////////////////
+//	CPauseResumeNegTest
+//
+//	-Open DMA Channel
+//	-Pause and Resume DMA channel
+//	-Check that KErrNotSupported is returned
+//	-Close DMA Channel
+//////////////////////////////////////////////////////////////////////
+CPauseResumeNegTest::~CPauseResumeNegTest()
+	{
+	}
+
+void CPauseResumeNegTest::RunTest()
+	{
+	OpenDmaSession();
+
+	//Open a single DMA channel for a transfer
+	OpenChannel();
+
+	RDebug::Printf("Resume unpaused idle channel");
+	TInt r = iDmaSession.ChannelResume(iChannelSessionCookie);
+	TEST_ASSERT(KErrNotSupported == r);
+
+	RDebug::Printf("Pause idle channel");
+	r = iDmaSession.ChannelPause(iChannelSessionCookie);
+	TEST_ASSERT(KErrNotSupported == r);
+
+	RDebug::Printf("Pause paused idle Channel");
+	r = iDmaSession.ChannelPause(iChannelSessionCookie);
+	TEST_ASSERT(KErrNotSupported == r);
+
+	RDebug::Printf("Resume paused idle channel");
+	r = iDmaSession.ChannelResume(iChannelSessionCookie);
+	TEST_ASSERT(KErrNotSupported == r);
+
+	CloseChannel();
+	CloseDmaSession();
+	}
+
+void CPauseResumeNegTest::PrintTestType() const
+	{
+	RDebug::RawPrint(_L("Pause and Resume API Test - Negative Test"));
+	}
+
+//////////////////////////////////////////////////////////////////////
+//	CLinkChannelTest
+//
+//	-Open DMA Channel
+//	-Link and Unlink DMA channel
+//	-Check that KErrNotSupported is returned
+//	-Close DMA Channel
+//
+//////////////////////////////////////////////////////////////////////
+CLinkChannelTest::~CLinkChannelTest()
+	{
+	}
+
+void CLinkChannelTest::RunTest()
+	{
+	OpenDmaSession();
+
+	//Open a single DMA channel for a transfer
+	OpenChannel();
+
+	RDebug::Printf("Linking DMA channels");
+	TInt r = iDmaSession.ChannelLinking(iChannelSessionCookie);
+	TEST_ASSERT(KErrNotSupported == r);
+
+	RDebug::Printf("Unlinking DMA channels");
+	r = iDmaSession.ChannelUnLinking(iChannelSessionCookie);
+	TEST_ASSERT(KErrNotSupported == r);
+
+	CloseChannel();
+	CloseDmaSession();
+	}
+
+void CLinkChannelTest::PrintTestType() const
+	{
+	RDebug::RawPrint(_L("Channel Linking API Test - Negative Test"));
+	}
+
+//////////////////////////////////////////////////////////////////////
+//	CElementCountingTest
+//
+//	-Open DMA Channel
+//	-Create Request
+//	-Fragment and Make calls to Element Counting APIs
+//  -Check that TotalNumDstElementsTransferred() and TotalNumSrcElementsTransferred()
+//	 return non zero values
+//  -Check that KErrNone(from test driver) returned for other API calls
+//	-Queue Request 
+//	-Close DMA Channel
+//////////////////////////////////////////////////////////////////////
+CElementCountingTest::~CElementCountingTest()
+	{
+	}
+
+void CElementCountingTest::RunTest()
+	{
+	OpenDmaSession();
+	PreTransferSetup();
+
+	//Open a single DMA channel for a transfer
+	OpenChannel();
+	
+	//Setup a DMA request and Fragment the request.
+	RDebug::Printf("Create and Fragment DMA Request");
+	CreateDmaRequest();
+	Fragment();
+
+	//Enable src/dst counting
+	RDebug::Printf("Enable DstElementCounting");
+	TInt r = iDmaSession.RequestEnableDstElementCounting(iRequestSessionCookie);
+	TEST_ASSERT(KErrNone == r);
+
+	RDebug::Printf("Enable SrcElementCounting");
+	r = iDmaSession.RequestEnableSrcElementCounting(iRequestSessionCookie);
+	TEST_ASSERT(KErrNone == r);
+
+	//Queue request
+	RDebug::Printf("Queue DMA Request");
+	Queue();
+
+	//Disable src/dst counting
+	RDebug::Printf("Disable DstElementCounting");
+	r = iDmaSession.RequestDisableDstElementCounting(iRequestSessionCookie);
+	TEST_ASSERT(KErrNone == r);
+
+	RDebug::Printf("Disable SrcElementCounting");
+	r = iDmaSession.RequestDisableSrcElementCounting(iRequestSessionCookie);
+	TEST_ASSERT(KErrNone == r);
+
+	//check total src/dst elements transferred
+	RDebug::Printf("Get Total Number of DstElementsTransferred");
+	r = iDmaSession.RequestTotalNumDstElementsTransferred(iRequestSessionCookie);
+	TEST_ASSERT(r >= 0);
+
+	RDebug::Printf("Get Total Number of SrcElementsTransferred");
+	r = iDmaSession.RequestTotalNumSrcElementsTransferred(iRequestSessionCookie);
+	TEST_ASSERT(r >= 0);
+
+	FreeRequest();
+	CloseChannel();
+
+	PostTransferCheck();
+	CloseDmaSession();
+	}
+
+void CElementCountingTest::PrintTestType() const
+	{
+	RDebug::RawPrint(_L("Element Counting Tests"));
+	}
+
+//////////////////////////////////////////////////////////////////////
 // COpenCloseTest
 //////////////////////////////////////////////////////////////////////
 COpenCloseTest::~COpenCloseTest()
@@ -1999,8 +2156,8 @@
 	case EEndiannessConversion:
 	case EGraphicsOps:
 	case ERepeatingTransfers:
-	case EChannelLinking:
-		TEST_FAULT;
+	case EChannelLinking:	
+		return aChannelCaps.iChannelLinking == (TBool)iValue;
 	case EHwDescriptors:
 		return aChannelCaps.iHwDescriptors == (TBool)iValue;
 	case ESrcDstAsymmetry:
@@ -2502,13 +2659,81 @@
 		testRunner.AddTestCases(TestArray);//Add all test cases
 	}
 
-	
 	test.Next(_L("call TTestRunner::RunTests()\n"));
 	testRunner.RunTests();
 
 	test.End();
 	}
 
+
+struct TSimTest
+	{
+	TUint iPslId;
+	TBool iFragment;
+	};
+
+const TSimTest KSimTests[] =
+	{
+		{0, EFalse},
+		{1, EFalse},
+		{2, ETrue},
+		{3, ETrue},
+	};
+
+const TInt KSimTestsCount = ARRAY_LENGTH(KSimTests);
+
+void RunSimDMATests()
+	{
+	test.Start(_L("Run simulated DMAC tests\n"));
+
+	test.Next(_L("Open session"));
+	RDmaSession session;
+	TInt r = session.OpenSim();
+	test_KErrNone(r);
+
+	for(TInt i=0; i<KSimTestsCount; i++)
+		{
+		TUint pslId = KSimTests[i].iPslId;
+		TBool doFrag = KSimTests[i].iFragment;
+
+		test.Start(_L("Open channel"));
+		TUint channelCookie=0;
+		r = session.ChannelOpen(pslId, channelCookie);
+		test.Printf(_L("Open channel %d, cookie recived = 0x%08x\n"), pslId, channelCookie);
+		test_KErrNone(r);
+
+		test.Next(_L("Create Dma request"));
+
+		TUint reqCookie=0;
+		r = session.RequestCreate(channelCookie, reqCookie);
+		test.Printf(_L("cookie recived = 0x%08x\n"), reqCookie );
+		test_KErrNone(r);
+
+		if(doFrag)
+			{
+			test.Next(_L("Fragment request"));
+			const TInt size = 128 * KKilo;
+			TDmaTransferArgs transferArgs(0, size, size, KDmaMemAddr);
+			r = session.FragmentRequest(reqCookie, transferArgs);
+			test_KErrNone(r);
+			}
+
+		test.Next(_L("Destroy Dma request"));
+		r = session.RequestDestroy(reqCookie);
+		test_KErrNone(r);
+
+		test.Next(_L("Channel close"));
+		r = session.ChannelClose(channelCookie);
+		test_KErrNone(r);
+		test.End();
+		}
+
+	test.Next(_L("Close session"));
+	RTest::CloseHandleAndWaitForDestruction(session);
+
+	test.End();
+	}
+
 TInt E32Main()
 	{
 	__UHEAP_MARK;
@@ -2531,7 +2756,7 @@
 		{
 		User::Panic(_L("DMA test run memory failure"), KErrNoMemory);
 		}
-	
+
 	if (gHelpRequested)
 		{
 		PrintUsage();
@@ -2551,8 +2776,7 @@
 
 	if (!(dma2Loaded || dma2CompatLoaded))
 		{
-		test.Printf(_L("DMA test driver not found - test skipped\n"));
-		return 0;
+		test.Printf(_L("Hardware DMA test driver not found - will run tests on simulated DMAC only\n"));
 		}
 	else if (dma2Loaded && !dma2CompatLoaded)
 		{
@@ -2567,6 +2791,23 @@
 		test.Printf(_L("The ROM contains %S and %S - only one should be present\n"), &KDma, &KDma2Compat);
 		TEST_FAULT;
 		}
+
+	const TBool dmaHwPresent = (dma2Loaded || dma2CompatLoaded);
+
+	_LIT(KDma2Sim, "D_DMA2_SIM.LDD");
+
+	r = User::LoadLogicalDevice(KDma2Sim);
+	const TBool dma2SimLoaded = ((r == KErrNone) || (r == KErrAlreadyExists));
+	if (dma2SimLoaded)
+		{
+		test.Printf(_L("Loaded %S\n"), &KDma2Sim);
+		}
+	else
+		{
+		test.Printf(_L("Failed to load %S, r=%d\n"), &KDma2Sim, r);
+		test(EFalse);
+		}
+
 	// Turn off evil lazy dll unloading
 	RLoader l;
 	test(l.Connect()==KErrNone);
@@ -2576,11 +2817,15 @@
 	__KHEAP_MARK;
 
 	if (gSelfTest) //Run self tests if specified on command line
-	{
-	SelfTests(); 	
-	}
-
-	RunDMATests();
+		{
+		SelfTests();
+		}
+
+	RunSimDMATests();
+	if (dmaHwPresent)
+		{
+		RunDMATests();
+		}
 
 	// Wait for the supervisor thread to run and perform asynchronous
 	// cleanup, so that kernel heap space will be freed
@@ -2588,8 +2833,14 @@
 	test_KErrNone(r);
 	__KHEAP_MARKEND;
 
-	r = User::FreeLogicalDevice(KTestDmaLddName);
+	if(dmaHwPresent)
+		{
+		r = User::FreeLogicalDevice(KTestDmaLddNameHw);
+		test_KErrNone(r);
+		}
+	r = User::FreeLogicalDevice(KTestDmaLddNameSim);
 	test_KErrNone(r);
+
 	test.End();
 	test.Close();
 
--- a/kerneltest/e32test/dmav2/t_dma2.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dmav2/t_dma2.h	Wed Aug 18 11:08:29 2010 +0300
@@ -597,6 +597,84 @@
 	};
 
 /**
+Used for testing Pause and Resume ( Negative Testing)
+
+Extends CSingle transfer by adding the capability to test
+Pause  & Resume() API. Expects that Pause and Resume is not supported
+*/
+class CPauseResumeNegTest : public CSingleTransferTest
+	{
+public:
+	 CPauseResumeNegTest(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aArgs, const TResultSet& aExpected)
+		:CSingleTransferTest(aName, aIterations, aArgs, aExpected)
+	 {}
+
+	~CPauseResumeNegTest();
+
+	virtual void RunTest();
+	virtual void PrintTestType() const;
+
+	virtual CTest* Clone() const {return new  CPauseResumeNegTest(*this);}
+
+	// The methods below is a setters ie. The Named Parameter Idiom
+	// @see http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.18
+	inline CPauseResumeNegTest& UseNewDmaApi(TBool aFlag) {CSingleTransferTest::UseNewDmaApi(aFlag); return *this;}
+	};
+
+
+/**
+Used for testing element counting 
+
+Extends CSingle transfer by adding the capability to test
+Element Counting APIs
+*/
+class CElementCountingTest : public CSingleTransferTest
+	{
+public:
+	 CElementCountingTest(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aArgs, const TResultSet& aExpected)
+		:CSingleTransferTest(aName, aIterations, aArgs, aExpected)
+	 {}
+
+	~CElementCountingTest();
+
+	virtual void RunTest();
+	virtual void PrintTestType() const;
+
+	virtual CTest* Clone() const {return new CElementCountingTest(*this);}
+
+	// The methods below is a setters ie. The Named Parameter Idiom
+	// @see http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.18
+	inline CElementCountingTest& UseNewDmaApi(TBool aFlag) {CSingleTransferTest::UseNewDmaApi(aFlag); return *this;}
+	};
+
+
+/**
+Used for testing Linking of DMA Channels ( Negative Testing)
+
+Extends CSingle transfer by adding the capability to test DMA channel linking
+Expects that channel linking is not supported
+*/
+class CLinkChannelTest : public CSingleTransferTest
+	{
+public:
+	 CLinkChannelTest(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aArgs, const TResultSet& aExpected)
+		:CSingleTransferTest(aName, aIterations, aArgs, aExpected)
+	 {}
+
+	~CLinkChannelTest();
+
+	virtual void RunTest();
+	virtual void PrintTestType() const;
+
+	virtual CTest* Clone() const {return new  CLinkChannelTest(*this);}
+
+	// The methods below is a setters ie. The Named Parameter Idiom
+	// @see http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.18
+	inline CLinkChannelTest& UseNewDmaApi(TBool aFlag) {CSingleTransferTest::UseNewDmaApi(aFlag); return *this;}
+	};
+
+
+/**
 This class will be used for tests which benchmark certain DMA operations
 */
 class CDmaBenchmark : public CSingleTransferTest
--- a/kerneltest/e32test/dmav2/test_cases.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/dmav2/test_cases.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -119,7 +119,42 @@
 	CPauseResumeTest testPauseResume = CPauseResumeTest(_L("Pause and Resume Test"), 1, transferArgs, expectedResults); 
 	TTestCase testCasePauseResume(&testPauseResume, EFalse, capAboveV1,pauseRequired_skip);	
 	}
+//--------------------------------------------------------------------------------------------
+//! TestCaseID      KBASE-DMA-2572
+//! TestType        CIT
+//! PREQ            REQ
+//! TestCaseDesc    This test verifies the correct behavior of Pause and Resume API in the new DMA 
+//!					framework 
+//!
+//! TestActions     
+//!						1.	Open a DMA channel for a transfer.
+//!						2.  Pause and Resume DMA channel.
+//!						3.  Close DMA channel.
+//!					
+//! 
+//!	TestExpectedResults 1.  DMA channel opens and KErrNone returned.
+//!						2.  KErrNotSupported returned when Pause and Resume API are called.
+//!						3.	DMA channel closes and KErrNone returned.
+//!
+//! TestPriority        High
+//! TestStatus          Implemented
+//----------------------------------------------------------------------------------------------
+namespace PauseResumeApiNegTest
+	{
+	const TInt srcAddr		= 0;
+	const TInt desAddr		= 2 * KMega;	
+	const TInt transferSize = 1 * KMega;	
 
+	TDmaTransferArgs transferArgs(srcAddr, desAddr, transferSize, KDmaMemAddr);	
+
+	TResultSet noTransferExpected = TResultSet().
+		RequestResult(TRequestResults().CreationResult(KErrUnknown).FragmentationResult(KErrUnknown).QueueResult(KErrUnknown)).
+		CallbackRecord(TCallbackRecord::Empty()).
+		PostTransferResult(KErrUnknown);
+
+	CPauseResumeNegTest testPauseResumeNeg = CPauseResumeNegTest(_L("Pause and Resume Negative Test"), 1, transferArgs, noTransferExpected); 
+	TTestCase testCasePauseResumeNeg(&testPauseResumeNeg , EFalse, capAboveV1,pauseNotWanted);	
+	}
 //--------------------------------------------------------------------------------------------
 //! TestCaseID      KBASE-DMA-2560
 //! TestType        CIT
@@ -1111,6 +1146,76 @@
 	TTestCase testCase(&isQueueEmpty,EFalse,capAboveV1,pauseRequired_skip);
 	}
 
+//--------------------------------------------------------------------------------------------
+//! TestCaseID      KBASE-DMA-2573
+//! TestType        CIT
+//! PREQ            REQ
+//! TestCaseDesc    This test verifies the correct behavior of the DMA Channel Linking API 
+//!					in the new DMA framework 
+//!
+//! TestActions     
+//!						1.	Open a DMA channel for a transfer.
+//!						2.  Link and Unlink DMA channel.
+//!						3.  Close DMA channel.
+//!					
+//! 
+//!	TestExpectedResults 1.  DMA channel opens and KErrNone returned.
+//!						2.  KErrNotSupported returned when DMA Linking and Unlinking API are called.
+//!						3.	DMA channel closes and KErrNone returned.
+//!
+//! TestPriority        High
+//! TestStatus          Implemented
+//----------------------------------------------------------------------------------------------
+namespace ChannelLinkingTest
+	{
+	const TInt srcAddr		= 0;
+	const TInt desAddr		= 2 * KMega;	
+	const TInt transferSize = 1 * KMega;	
+
+	TDmaTransferArgs transferArgs(srcAddr, desAddr, transferSize, KDmaMemAddr);	
+
+	TResultSet noTransferExpected = TResultSet().
+		RequestResult(TRequestResults().CreationResult(KErrUnknown).FragmentationResult(KErrUnknown).QueueResult(KErrUnknown)).
+		CallbackRecord(TCallbackRecord::Empty()).
+		PostTransferResult(KErrUnknown);
+
+	CLinkChannelTest testChannelLinking = CLinkChannelTest(_L("DMA Channel Linking and Unlinking Negative Test"), 1, transferArgs, noTransferExpected); 
+	TTestCase testCaseChannelLinking(&testChannelLinking , EFalse, capAboveV1,LinkingNotWanted);	
+	}
+
+//--------------------------------------------------------------------------------------------
+//! TestCaseID      KBASE-DMA-2574
+//! TestType        CIT
+//! PREQ            REQ
+//! TestCaseDesc    This test verifies that the DMA Element Counting APIs can be called. The calls 
+//!					to these functions are meant to be used to meet a code coverage requirement.These APIs
+//!					are not yet supported so the functionality of the APIs are not currently tested.
+//!
+//! TestActions     
+//!						1.	Open a DMA channel for a transfer.
+//!						2.  Make calls to Element Counting APIs
+//!						3.  Close DMA channel.
+//!					
+//! 
+//!	TestExpectedResults 1.  DMA channel opens and KErrNone returned.
+//!						2.  Element Counting APIs are called without crashing the framework
+//!						3.	DMA channel closes and KErrNone returned.
+//!
+//! TestPriority        High
+//! TestStatus          Implemented
+//----------------------------------------------------------------------------------------------
+namespace ElementCountingTest
+	{
+	const TInt srcAddr		= 0;
+	const TInt desAddr		= 2 * KMega;	
+	const TInt transferSize = 1 * KMega;	
+
+	TDmaTransferArgs transferArgs(srcAddr, desAddr, transferSize, KDmaMemAddr);	
+
+	const TResultSet expectedResults(threadCallback);
+	CElementCountingTest testElementCounting(_L("DMA Element Counting Test"), 1, transferArgs, expectedResults);
+	TTestCase testCaseElementCounting(&testElementCounting, EFalse, capAboveV1);
+	}
 
 static TTestCase* StaticSimpleTestArray[] = {
 	&Simple_1::testCase,
@@ -1198,6 +1303,7 @@
 
 static TTestCase* StaticSuspendTestArray[] = {
 	&PauseResumeApiTest::testCasePauseResume,  
+	&PauseResumeApiNegTest::testCasePauseResumeNeg,
 };
 
 static TTestCase* StaticQueueTestArray[] = {
@@ -1265,8 +1371,11 @@
 	&CloseApiTest::testCaseCloseApi,
 	&OpenApiTest::testCaseOpenApi,
 	&PauseResumeApiTest::testCasePauseResume,  
+	&PauseResumeApiNegTest::testCasePauseResumeNeg,	
 	&CancelAllTest::testCase,
-	&IsQueueEmptyTest::testCase,	
+	&IsQueueEmptyTest::testCase,
+	&ChannelLinkingTest::testCaseChannelLinking,
+	&ElementCountingTest::testCaseElementCounting,
 };
 
 RPointerArray<TTestCase> TestArray(StaticTestArray, ARRAY_LENGTH(StaticTestArray));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/eabi/d_dma2_simu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,56 @@
+EXPORTS
+	_Z19CreateLogicalDevicev @ 1 NONAME
+	_Z11DmaTestInfov @ 2 NONAME
+	_Z13DmaTestInfoV2v @ 3 NONAME
+	_ZN11DDmaRequest11FreeDesListEv @ 4 NONAME
+	_ZN11DDmaRequest13ExpandDesListEi @ 5 NONAME
+	_ZN11DDmaRequest13FragmentCountEv @ 6 NONAME
+	_ZN11DDmaRequest14FreeDstDesListEv @ 7 NONAME
+	_ZN11DDmaRequest14FreeSrcDesListEv @ 8 NONAME
+	_ZN11DDmaRequest16DstFragmentCountEv @ 9 NONAME
+	_ZN11DDmaRequest16ExpandDstDesListEi @ 10 NONAME
+	_ZN11DDmaRequest16ExpandSrcDesListEi @ 11 NONAME
+	_ZN11DDmaRequest16SrcFragmentCountEv @ 12 NONAME
+	_ZN11DDmaRequest24EnableDstElementCountingEi @ 13 NONAME
+	_ZN11DDmaRequest24EnableSrcElementCountingEi @ 14 NONAME
+	_ZN11DDmaRequest25DisableDstElementCountingEv @ 15 NONAME
+	_ZN11DDmaRequest25DisableSrcElementCountingEv @ 16 NONAME
+	_ZN11DDmaRequest30TotalNumDstElementsTransferredEv @ 17 NONAME
+	_ZN11DDmaRequest30TotalNumSrcElementsTransferredEv @ 18 NONAME
+	_ZN11DDmaRequest5QueueEv @ 19 NONAME
+	_ZN11DDmaRequest8FragmentERK16TDmaTransferArgs @ 20 NONAME
+	_ZN11DDmaRequest8FragmentEmmijm @ 21 NONAME
+	_ZN11DDmaRequestC1ER11TDmaChannelPFvNS_7TResultEPvES3_i @ 22 NONAME
+	_ZN11DDmaRequestC1ER11TDmaChannelPFvj10TDmaResultPvP10SDmaDesHdrES3_j @ 23 NONAME
+	_ZN11DDmaRequestC2ER11TDmaChannelPFvNS_7TResultEPvES3_i @ 24 NONAME
+	_ZN11DDmaRequestC2ER11TDmaChannelPFvj10TDmaResultPvP10SDmaDesHdrES3_j @ 25 NONAME
+	_ZN11DDmaRequestD0Ev @ 26 NONAME
+	_ZN11DDmaRequestD1Ev @ 27 NONAME
+	_ZN11DDmaRequestD2Ev @ 28 NONAME
+	_ZN11TDmaChannel13LinkToChannelEPS_ @ 29 NONAME
+	_ZN11TDmaChannel14IsrRedoRequestEmmjmi @ 30 NONAME
+	_ZN11TDmaChannel15StaticExtensionEiPv @ 31 NONAME
+	_ZN11TDmaChannel16AddressAlignMaskEjjm @ 32 NONAME
+	_ZN11TDmaChannel17MaxTransferLengthEjjm @ 33 NONAME
+	_ZN11TDmaChannel18MissNextInterruptsEi @ 34 NONAME
+	_ZN11TDmaChannel4OpenERKNS_11SCreateInfoERPS_ @ 35 NONAME
+	_ZN11TDmaChannel5CloseEv @ 36 NONAME
+	_ZN11TDmaChannel5PauseEv @ 37 NONAME
+	_ZN11TDmaChannel6ResumeEv @ 38 NONAME
+	_ZN11TDmaChannel8DmacCapsEv @ 39 NONAME
+	_ZN11TDmaChannel8FailNextEi @ 40 NONAME
+	_ZN11TDmaChannel9CancelAllEv @ 41 NONAME
+	_ZN11TDmaChannel9ExtensionEiPv @ 42 NONAME
+	_ZN16TDmaTransferArgsC1ERK18TDmaTransferConfigS2_mjj15TDmaGraphicsOpsm @ 43 NONAME
+	_ZN16TDmaTransferArgsC1Ejjjjjj12TDmaAddrModejj13TDmaBurstSizej15TDmaGraphicsOpsm @ 44 NONAME
+	_ZN16TDmaTransferArgsC1Ev @ 45 NONAME
+	_ZN16TDmaTransferArgsC2ERK18TDmaTransferConfigS2_mjj15TDmaGraphicsOpsm @ 46 NONAME
+	_ZN16TDmaTransferArgsC2Ejjjjjj12TDmaAddrModejj13TDmaBurstSizej15TDmaGraphicsOpsm @ 47 NONAME
+	_ZN16TDmaTransferArgsC2Ev @ 48 NONAME
+	_ZN18TDmaTransferConfigC1Emj12TDmaAddrModej13TDmaBurstSizejjji @ 49 NONAME
+	_ZN18TDmaTransferConfigC1Emjjjiijj13TDmaBurstSizejji @ 50 NONAME
+	_ZN18TDmaTransferConfigC1Ev @ 51 NONAME
+	_ZN18TDmaTransferConfigC2Emj12TDmaAddrModej13TDmaBurstSizejjji @ 52 NONAME
+	_ZN18TDmaTransferConfigC2Emjjjiijj13TDmaBurstSizejji @ 53 NONAME
+	_ZN18TDmaTransferConfigC2Ev @ 54 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/eabi/i2c_masterstubs_ctrlessu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,24 @@
+EXPORTS
+	_Z20CreatePhysicalDevicev @ 1 NONAME
+	_ZN20TIicBusSlaveCallback7DfcFuncEPv @ 2 NONAME
+	_ZN25DIicBusChannelMasterSlaveC1EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexEP20DIicBusChannelMasterP19DIicBusChannelSlave @ 3 NONAME
+	_ZN25DIicBusChannelMasterSlaveC2EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexEP20DIicBusChannelMasterP19DIicBusChannelSlave @ 4 NONAME
+	_ZN31DSimulatedIicBusChannelSlaveI2cC1EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexE @ 5 NONAME
+	_ZN31DSimulatedIicBusChannelSlaveI2cC2EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexE @ 6 NONAME
+	_ZN32DSimulatedIicBusChannelMasterI2cC1EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexE @ 7 NONAME
+	_ZN32DSimulatedIicBusChannelMasterI2cC2EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexE @ 8 NONAME
+	_ZN37DSimulatedIicBusChannelMasterSlaveI2cC1EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexEP32DSimulatedIicBusChannelMasterI2cP31DSimulatedIicBusChannelSlaveI2c @ 9 NONAME
+	_ZN37DSimulatedIicBusChannelMasterSlaveI2cC2EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexEP32DSimulatedIicBusChannelMasterI2cP31DSimulatedIicBusChannelSlaveI2c @ 10 NONAME
+	_ZTI19DIicBusChannelSlave @ 11 NONAME
+	_ZTI20DIicBusChannelMaster @ 12 NONAME
+	_ZTI25DIicBusChannelMasterSlave @ 13 NONAME
+	_ZTI31DSimulatedIicBusChannelSlaveI2c @ 14 NONAME
+	_ZTI32DSimulatedIicBusChannelMasterI2c @ 15 NONAME
+	_ZTI37DSimulatedIicBusChannelMasterSlaveI2c @ 16 NONAME
+	_ZTV19DIicBusChannelSlave @ 17 NONAME
+	_ZTV20DIicBusChannelMaster @ 18 NONAME
+	_ZTV25DIicBusChannelMasterSlave @ 19 NONAME
+	_ZTV31DSimulatedIicBusChannelSlaveI2c @ 20 NONAME
+	_ZTV32DSimulatedIicBusChannelMasterI2c @ 21 NONAME
+	_ZTV37DSimulatedIicBusChannelMasterSlaveI2c @ 22 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/eabi/i2c_slavestubs_ctrlessu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,24 @@
+EXPORTS
+	_Z20CreatePhysicalDevicev @ 1 NONAME
+	_ZN20TIicBusSlaveCallback7DfcFuncEPv @ 2 NONAME
+	_ZN25DIicBusChannelMasterSlaveC1EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexEP20DIicBusChannelMasterP19DIicBusChannelSlave @ 3 NONAME
+	_ZN25DIicBusChannelMasterSlaveC2EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexEP20DIicBusChannelMasterP19DIicBusChannelSlave @ 4 NONAME
+	_ZN31DSimulatedIicBusChannelSlaveI2cC1EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexE @ 5 NONAME
+	_ZN31DSimulatedIicBusChannelSlaveI2cC2EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexE @ 6 NONAME
+	_ZN32DSimulatedIicBusChannelMasterI2cC1EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexE @ 7 NONAME
+	_ZN32DSimulatedIicBusChannelMasterI2cC2EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexE @ 8 NONAME
+	_ZN37DSimulatedIicBusChannelMasterSlaveI2cC1EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexEP32DSimulatedIicBusChannelMasterI2cP31DSimulatedIicBusChannelSlaveI2c @ 9 NONAME
+	_ZN37DSimulatedIicBusChannelMasterSlaveI2cC2EN14DIicBusChannel8TBusTypeENS0_14TChannelDuplexEP32DSimulatedIicBusChannelMasterI2cP31DSimulatedIicBusChannelSlaveI2c @ 10 NONAME
+	_ZTI19DIicBusChannelSlave @ 11 NONAME
+	_ZTI20DIicBusChannelMaster @ 12 NONAME
+	_ZTI25DIicBusChannelMasterSlave @ 13 NONAME
+	_ZTI31DSimulatedIicBusChannelSlaveI2c @ 14 NONAME
+	_ZTI32DSimulatedIicBusChannelMasterI2c @ 15 NONAME
+	_ZTI37DSimulatedIicBusChannelMasterSlaveI2c @ 16 NONAME
+	_ZTV19DIicBusChannelSlave @ 17 NONAME
+	_ZTV20DIicBusChannelMaster @ 18 NONAME
+	_ZTV25DIicBusChannelMasterSlave @ 19 NONAME
+	_ZTV31DSimulatedIicBusChannelSlaveI2c @ 20 NONAME
+	_ZTV32DSimulatedIicBusChannelMasterI2c @ 21 NONAME
+	_ZTV37DSimulatedIicBusChannelMasterSlaveI2c @ 22 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/eabi/t_usb_tranhandlesrvu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,9 @@
+EXPORTS
+	_ZN14RTranHandleSrv14TransferHandleER11RHandleBaseS1_ @ 1 NONAME
+	_ZN14RTranHandleSrv7ConnectEv @ 2 NONAME
+	_ZN14RTranHandleSrvC1Ev @ 3 NONAME
+	_ZN14RTranHandleSrvC2Ev @ 4 NONAME
+	_ZN14RTranHandleSrvD1Ev @ 5 NONAME
+	_ZN14RTranHandleSrvD2Ev @ 6 NONAME
+	_ZNK14RTranHandleSrv7VersionEv @ 7 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/eabi/t_usb_transfersrvu.def	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,9 @@
+EXPORTS
+	_ZN12RTransferSrv17SetConfigFileNameER6TDes16 @ 1 NONAME
+	_ZN12RTransferSrv7ConnectEv @ 2 NONAME
+	_ZN12RTransferSrvC1Ev @ 3 NONAME
+	_ZN12RTransferSrvC2Ev @ 4 NONAME
+	_ZN12RTransferSrvD1Ev @ 5 NONAME
+	_ZN12RTransferSrvD2Ev @ 6 NONAME
+	_ZNK12RTransferSrv7VersionEv @ 7 NONAME
+
--- a/kerneltest/e32test/group/bld.inf	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/group/bld.inf	Wed Aug 18 11:08:29 2010 +0300
@@ -121,6 +121,7 @@
 d_shbuf_own					support
 d_asid						support
 d_entropysources			support
+d_khal						support
 
 #ifdef GENERIC_MARM
 d_schedhook					support
@@ -136,16 +137,19 @@
 rescontrol_psl				support
 rescontrol_extended_psl		support
 d_rescontrolcli				support
+d_rescontrolclisync			support
 d_extendedrescontrolcli		support
 d_prmacctstsim				support
 ../resmanus/resourcecontrol	support
 ../resmanus/resourcecontrollerextended	support
+../resmanus/d_resmanusbtrace		support
 #endif
 
 // DMA kernel-side test harness for software-simulated DMA framework
 // software-simulated DMA framework
 d_dmasim					support
 dmasim						support
+d_dma2_sim					support
 
 // Examples for demand paging device driver migration
 d_pagingexample_1_pre  support
@@ -191,15 +195,20 @@
 
 #if !defined(X86)
 ../iic/iic_psl/iic_testpsl			support
-../iic/iic_psl/spi					support
-../iic/iic_psl/i2c					support
+../iic/iic_psl/spi				support
+../iic/iic_psl/i2c				support
 ../iic/iic_psl/d_iic_client			support
-../iic/iic_psl/d_iic_slaveclient	support
+../iic/iic_psl/d_iic_slaveclient		support
 
 ../iic/iic_psl/spi_ctrless			support
 ../iic/iic_psl/i2c_ctrless			support
 ../iic/iic_psl/d_iic_client_ctrless		support
 ../iic/iic_psl/d_iic_slaveclient_ctrless	support
+
+../iic/iic_psl/i2c_masterstubs_ctrless		support
+../iic/iic_psl/i2c_slavestubs_ctrless		support
+../iic/iic_psl/d_iic_client_stubs		support
+../iic/iic_psl/d_iic_slaveclient_stubs		support
 #endif
 
 #if !defined(WINS) && !defined(X86)
@@ -302,6 +311,9 @@
 t_userasmbm manual
 #endif
 
+// /E32TEST/TIMESTAMP test
+t_timestamp
+
 // /e32test/benchmark
 #ifndef X86
 bm_suite    MANUAL_ON_WINS
@@ -381,6 +393,9 @@
 #endif
 #ifdef MARM_ARMV5
 t_usb_device	manual
+t_usb_tranhandleclient	support
+t_usb_transfersrvclient	support
+t_usb_transfersrv	manual
 t_usb_scdevice	manual
 #endif
 
@@ -498,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
@@ -621,7 +634,7 @@
 t_loadsim	support
 
 #if !defined(WINS)
-t_zip       manual
+t_zip       
 #endif
 
 #ifdef EPOC32
@@ -713,8 +726,6 @@
 domainPolicyTest support
 t_switchoff
 t_frqchg
-// /E32TEST/TIMESTAMP test
-t_timestamp
 
 // /E32TEST/PRIME tests
 t_kern      support
@@ -744,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
@@ -779,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
@@ -826,7 +840,8 @@
 t_wwins     manual
 t_mmcpw     manual
 
-t_keys      support
+refkeymap   support //Reference template keyboard look-up tables for T_KEYS test 
+t_keys
 
 // /E32TEST/Y2K tests
 t_y2k
@@ -982,11 +997,13 @@
 ../resmanus/t_resmanus
 ../resmanus/t_resmanuskern
 ../resmanus/t_resmanusextended
+../resmanus/t_resmanusbtrace
 #endif
 
 // /E32TEST/RESOURCEMAN tests
 #if !defined X86 
 t_rescontrolcli
+t_rescontrolclisync
 t_extendedrescontrolcli
 t_prmacctstsim
 #endif
@@ -1057,9 +1074,6 @@
 t_destruct_dll3		support
 
 #include "../examples/examples.inf"
-// Shared chunk camera driver tests.
-t_camera_api		manual
-t_camera_gen		manual
 d_mmcsc			support
 
 t_kerncorestats		support
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/d_dma2_sim.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,52 @@
+// 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 "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:
+//
+
+#include "kernel/kern_ext.mmh"
+
+target		d_dma2_sim.ldd
+targettype	ldd
+
+// It is not actually necessary to export DMA API functions
+// from this simulated binary
+noexportlibrary
+
+deffile		../~/d_dma2_sim.def
+
+sourcepath	../../../../kernelhwsrv/kernel/eka/drivers/dma
+source		dma2_pil.cpp dma2_shared.cpp
+
+sourcepath	../dmav2
+source		d_dma2.cpp d_dma2_cmn.cpp dma2_sim.cpp
+
+
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+epocallowdlldata
+
+start wins
+win32_headers
+end
+
+capability	all
+VENDORID 0x70000001
+
+#ifdef SMP
+MACRO CPU_AFFINITY_ANY
+#endif
+
+SMPSAFE
+
+MACRO DMA_APIV2
+MACRO __DMASIM__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/d_khal.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -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/d_rescontrolclisync.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,40 @@
+// 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_rescontrolcli.mmp
+// 
+//
+
+#include "kernel/kern_ext.mmh"
+
+target         d_rescontrolclisync.ldd
+targettype     ldd
+sourcepath     ../resourceman/
+source         d_rescontrolclisync.cpp
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+library        resourcecontroller.lib
+
+uid		0x100000af
+vendorid 0x70000001
+
+capability		all
+epocallowdlldata
+
+start wins
+win32_headers
+end
+
+macro CPU_AFFINITY_ANY
+SMPSAFE
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/refkeymap.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,46 @@
+// 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/refkeymap.mmp
+// refekdata.dll Reference template keyboard look-up tables for T_KEYS test 
+// 
+//
+
+/**
+ @file
+*/
+#define __USING_ASSP_REGISTER_API__
+#define __USING_ASSP_INTERRUPT_API__
+
+target				refkdata.dll
+targettype		dll
+
+
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+sourcepath		../../../bsptemplate/asspandvariant/template_variant/specific
+source				keymap.cpp
+
+library				euser.lib
+
+deffile				../../../kernel/eka/~/ekdata.def
+
+nostrictdef
+
+capability			all
+
+uid					0x1000008d 0x100039e0
+vendorid			 0x70000001
+
+SMPSAFE
+unpagedcode
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_atomicu.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -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
--- a/kerneltest/e32test/group/t_camera_api.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-// Copyright (c) 2005-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/group/t_camera_api.mmp
-// 
-//
-
-target			t_camera_api.exe
-targettype		exe
-sourcepath		../multimedia
-source			t_camera_api.cpp
-source			t_camera_display.cpp
-source			t_camera_bitmap.cpp
-library			euser.lib hal.lib efsrv.lib
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-
-capability		ALL -TCB
-vendorid		0x70000001
-epocheapsize		1048576 16777216
-
-SMPSAFE
--- a/kerneltest/e32test/group/t_camera_gen.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-// Copyright (c) 2005-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/group/t_camera_gen.mmp
-// 
-//
-
-target			t_camera_gen.exe        
-targettype		exe
-sourcepath		../multimedia
-source			t_camera_gen.cpp
-source			t_camera_display.cpp
-library			euser.lib hal.lib
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-
-capability		ALL -TCB
-vendorid		0x70000001
-
-
-SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_khal.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Wed Aug 18 11:08:29 2010 +0300
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_rescontrolclisync.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,35 @@
+// 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_rescontrolcli.mmp
+// 
+//
+
+target         t_rescontrolclisync.exe
+targettype     exe
+sourcepath	   ../resourceman/
+source         t_rescontrolclisync.cpp
+library        euser.lib
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+
+capability		all
+
+vendorid 0x70000001
+
+start wins
+win32_headers
+end
+
+
+SMPSAFE
--- a/kerneltest/e32test/group/t_usb_scdevice.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/group/t_usb_scdevice.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -40,11 +40,13 @@
 SOURCE    	config.cpp
 SOURCE		apitests.cpp
 SOURCE		usbms.cpp
+SOURCE		tranhandleserver.cpp
+SOURCE		tranhandlesession.cpp
 
 
 LIBRARY     EUSER.LIB HAL.LIB
 LIBRARY		usbcsc_bil.lib
-LIBRARY     EFSRV.LIB
+LIBRARY     EFSRV.LIB t_usb_transfersrv.lib
 
 CAPABILITY    ALL
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_usb_tranhandleclient.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* 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 "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:
+*
+*/
+
+
+
+TARGET      t_usb_tranhandlesrv.dll
+TARGETTYPE  DLL
+
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE	  ../usb/t_usb_device/include
+
+// Source file paths
+
+SOURCEPATH	  ../usb/t_usb_device/src
+
+
+deffile			../~/t_usb_tranhandlesrv.def 
+
+CAPABILITY    ALL
+
+VENDORID      0x70000001
+
+// Larger user heap than default: maximum = 16MB
+EPOCHEAPSIZE  0x1000 0x01000000
+
+SMPSAFE
+
+
+SOURCE        tranhandlesrv.cpp
+
+LIBRARY       euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_usb_transfersrv.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,52 @@
+// Copyright (c) 2008-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_usb_transfersrv.mmp
+// 
+//
+
+TARGET        t_usb_transfersrv.exe
+TARGETTYPE    EXE
+uid 0x0 0x101fe1db
+
+MACRO		USB_SC
+
+// Header file paths
+
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE	  ../usb/t_usb_device/include
+
+// Source file paths
+
+SOURCEPATH	  ../usb/t_usb_device/src
+
+
+SOURCE     	transfersrvmain.cpp
+SOURCE		transfersession.cpp
+SOURCE		transferserver.cpp
+SOURCE		config.cpp
+SOURCE		transferhandle.cpp
+
+LIBRARY     EUSER.LIB HAL.LIB
+LIBRARY		usbcsc_bil.lib
+LIBRARY     EFSRV.LIB t_usb_tranhandlesrv.lib
+
+CAPABILITY    ALL
+
+VENDORID      0x70000001
+
+// Larger user heap than default: maximum = 16MB
+EPOCHEAPSIZE  0x1000 0x01000000
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/group/t_usb_transfersrvclient.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,49 @@
+// Copyright (c) 2008-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_usb_transfersrv.mmp
+// 
+//
+
+TARGET        t_usb_transfersrv.dll
+TARGETTYPE    DLL
+
+MACRO		USB_SC
+
+// Header file paths
+
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE	  ../usb/t_usb_device/include
+
+// Source file paths
+
+SOURCEPATH	  ../usb/t_usb_device/src
+
+
+SOURCE		transfersrv.cpp
+
+deffile			../~/t_usb_transfersrv.def 
+
+LIBRARY     EUSER.LIB HAL.LIB
+LIBRARY		usbcsc_bil.lib
+LIBRARY     EFSRV.LIB
+
+CAPABILITY    ALL
+
+VENDORID      0x70000001
+
+// Larger user heap than default: maximum = 16MB
+EPOCHEAPSIZE  0x1000 0x01000000
+
+SMPSAFE
--- a/kerneltest/e32test/heap/t_kheap.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/heap/t_kheap.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -181,6 +181,7 @@
 	{
 	const TDesC* fileName = NULL;
 	const TDesC* objName = &KTestLddName();
+	User::FreeLogicalDevice(*objName);
 	switch (aDevice)
 		{
 		case 0:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/iic/iic_psl/d_iic_client_stubs.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,54 @@
+// Copyright (c) 2008-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/group/d_iic_client_stubs.mmp
+// Created for code coverage tests.
+
+
+#include "kernel/kern_ext.mmh"
+
+target         iic_client_stubs.ldd
+targettype     ldd
+
+//Both macros are only used for channel creation. It will create 
+//all 3 types of channels(Master, Slave, MasterSlave) when both 
+//macros are defined. For our code coverage improving tests, 
+//we need all these 3 types of channels, so we enable both macros here.
+macro MASTER_MODE
+macro SLAVE_MODE
+
+macro IIC_SIMULATED_PSL
+macro STANDALONE_CHANNEL
+macro IIC_STUBS
+
+sourcepath     .
+source         iic_client.cpp
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+// un-comment the following if debug printing is required
+//macro LOG_CLIENT
+
+library spi_ctrless.lib
+library i2c_masterstubs_ctrless.lib
+
+uid			0x100000af 0x10286b4d
+VENDORID 0x70000001
+
+capability		all
+epocallowdlldata
+
+start wins
+win32_headers
+end
+
+SMPSAFE
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/iic/iic_psl/d_iic_slaveclient_stubs.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,53 @@
+// Copyright (c) 2008-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/group/d_iic_slaveclient_stubs.mmp
+// created for code coverage tests
+
+#include "kernel/kern_ext.mmh"
+
+target         iic_slaveclient_stubs.ldd
+targettype     ldd
+
+//These macros are only used for channel creation
+//In the code coverage tests, we need all three types of channels
+//(Master, Slave, MasterSlave) to be tested, so enable both macros here.
+macro MASTER_MODE
+macro SLAVE_MODE
+
+macro IIC_SIMULATED_PSL
+
+macro STANDALONE_CHANNEL
+macro IIC_STUBS
+
+sourcepath     .
+source         iic_slaveclient.cpp
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+// un-comment the following if debug printing is required
+//macro LOG_SLAVECLIENT
+
+library spi_ctrless.lib
+library i2c_slavestubs_ctrless.lib
+
+uid			0x100000af 0x10286b4e
+VENDORID 0x70000001
+
+capability		all
+epocallowdlldata
+
+start wins
+win32_headers
+end
+
+SMPSAFE
--- a/kerneltest/e32test/iic/iic_psl/i2c.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/iic/iic_psl/i2c.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -47,14 +47,15 @@
 	}
 #endif/*STANDALONE_CHANNEL*/
 
-#ifdef SLAVE_MODE
+//Macros MASTER_MODE and SLAVE_MODE are intentionally omitted from this file
+//This is for master and slave stubs to exercise the channel class,
+//and we need these stubs for code coverage tests.
 LOCAL_C TInt16 AssignSlaveChanId()
 	{
 	static TInt16 iBaseSlaveChanId = KI2cSlaveChannelIdBase;
 	I2C_PRINT(("I2C AssignSlaveChanId - on entry, iBaseSlaveChanId = 0x%x\n",iBaseSlaveChanId));
 	return iBaseSlaveChanId++; // Arbitrary, for illustration
 	}
-#endif/*SLAVE_MODE*/
 
 NONSHARABLE_CLASS(DSimulatedI2cDevice) : public DPhysicalDevice
 	{
@@ -230,8 +231,6 @@
 	return new DSimulatedI2cDevice;
 	}
 
-
-#ifdef MASTER_MODE
 #ifdef STANDALONE_CHANNEL
 EXPORT_C
 #endif
@@ -253,6 +252,8 @@
 	if(r == KErrNone)
 		SetDfcQ((TDfcQue*)iDynamicDfcQ);
 	DSimulatedIicBusChannelMasterI2c::SetRequestDelayed(this,EFalse);
+	//Call to base class DoCreate(not strictly necessary)
+	DIicBusChannelMaster::DoCreate();
 	return r;
 	}
 
@@ -423,7 +424,8 @@
 		default:
 			{
 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
-			r=KErrNotSupported;
+			//For default case call the base class method for consistent handling
+            r=DIicBusChannelMaster::StaticExtension(aFunction,NULL,NULL);
 			}
 		}
 		
@@ -433,11 +435,6 @@
 	return r;
 	}
 
-//#ifdef MASTER_MODE
-#endif
-
-#ifdef SLAVE_MODE
-
 void DSimulatedIicBusChannelSlaveI2c::SlaveAsyncSimCallback(TAny* aPtr)
 	{
 	// To support simulating an asynchronous capture operation
@@ -1042,7 +1039,8 @@
 		default:
 			{
 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
-			r=KErrNotSupported;
+			//For default case call the base class method for consistent handling
+            r=DIicBusChannelSlave::StaticExtension(aFunction,NULL,NULL);
 			}
 		}
 #ifdef IIC_INSTRUMENTATION_MACRO
@@ -1051,12 +1049,6 @@
 	return r;
 	}
 
-
-
-//#ifdef MASTER_MODE
-#endif
-
-#if defined(MASTER_MODE) && defined(SLAVE_MODE)
 #ifdef STANDALONE_CHANNEL
 EXPORT_C
 #endif
@@ -1107,15 +1099,13 @@
 		default:
 			{
 			Kern::Printf("aFunction %d is not recognised \n",aFunction);
-			r=KErrNotSupported;
+			//For default case call the base class method for consistent handling
+			r=DIicBusChannelMasterSlave::StaticExtension(aFunction,NULL,NULL);
 			}
 		}
 	return r;
 	}
 
 
-//#if defined(MASTER_MODE) && defined(SLAVE_MODE)
-#endif
 
 
-
--- a/kerneltest/e32test/iic/iic_psl/i2c.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/iic/iic_psl/i2c.h	Wed Aug 18 11:08:29 2010 +0300
@@ -42,15 +42,15 @@
 #endif/*STANDALONE_CHANNEL*/
 
 
-#if defined(MASTER_MODE)
 const TInt KI2cThreadPriority = 5; // Arbitrary, can be 0-7, 7 highest
-#endif
 
 const TInt16 KI2cSlaveChannelIdBase = 0x1D00;	// Arbitrary
 
 const TInt KI2cSlaveAsyncDelaySim = 20;	// Arbitrary delay, for timer to simulate asynchronous processing
 
-#ifdef MASTER_MODE
+//Macros MASTER_MODE and SLAVE_MODE are intentionally omitted from this file
+//This is for master and slave stubs to exercise the channel class,
+//and we need these stubs for code coverage tests.
 class DSimulatedIicBusChannelMasterI2c : public DIicBusChannelMaster
 	{
 	// platform specific implementation
@@ -87,9 +87,7 @@
 #ifndef STANDALONE_CHANNEL
 TInt8 DSimulatedIicBusChannelMasterI2c::iCurrentChanNum = KI2cChannelNumBase; // Initialise static member of DSimulatedIicBusChannelMasterI2c
 #endif
-#endif/*MASTER_MODE*/
 
-#ifdef SLAVE_MODE
 class DSimulatedIicBusChannelSlaveI2c : public DIicBusChannelSlave
 	{
 public:
@@ -150,9 +148,7 @@
 		NTimer iSlaveTimer; // Used to simulate an asynchronous capture operation
 		TSpinLock iEventSpinLock; // To serialise simulated bus events - Rx, Tx or Rx+Tx
 		};
-#endif/*SLAVE_MODE*/
 
-#if defined(MASTER_MODE) && defined(SLAVE_MODE)
 class DSimulatedIicBusChannelMasterSlaveI2c : public DIicBusChannelMasterSlave
 	{
 public:
@@ -163,6 +159,5 @@
 				
 	TInt StaticExtension(TUint aFunction, TAny* aParam1, TAny* aParam2);	
 	};
-#endif/*(MASTER_MODE) && (SLAVE_MODE)*/
 
 #endif /*I2C_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/iic/iic_psl/i2c_masterstubs_ctrless.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,63 @@
+// Copyright (c) 2008-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/iic/iic_psl/i2c_masterstubs_ctrless.mmp
+//
+
+macro STANDALONE_CHANNEL
+#define STANDALONE_CHANNEL /*Only for iic_channel.mmh to pick up the needed source files*/
+
+#include "../../../../kernel/eka/drivers/iic/iic_channel.mmh"
+
+//enable the SLAVE_MODE so all the functions defined in SLAVE_MODE can be tested.
+macro SLAVE_MODE
+
+
+target          i2c_masterstubs_ctrless.pdd
+targettype      pdd
+
+sourcepath	../../../../kernel/eka/drivers/iic
+source		IIC_PIL_SOURCE
+
+sourcepath		.
+source          i2c.cpp
+
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+macro IIC_SIMULATED_PSL
+macro BUS_TYPE=(DIicBusChannel::EI2c)
+
+// un-comment the following if debug printing is required
+//macro LOG_I2C
+
+// un-comment the following if BTRACE output is required
+macro IIC_INSTRUMENTATION_MACRO
+
+deffile				../../~/i2c_masterstubs_ctrless.def
+
+uid			0x100039d0 0x10286b50
+VENDORID 0x70000001
+
+//library				ecust.lib
+#ifdef WINS
+library				emulator.lib
+#endif 
+
+start wins
+win32_library			kernel32.lib
+#if defined(VC32)
+win32_library			msvcrt.lib
+#endif
+end
+
+SMPSAFE
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/iic/iic_psl/i2c_slavestubs_ctrless.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,62 @@
+// Copyright (c) 2008-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/iic/iic_psl/i2c_slave_stubs_ctrless.mmp
+//
+
+macro STANDALONE_CHANNEL
+#define STANDALONE_CHANNEL /*Only for iic_channel.mmh to pick up the needed source files*/
+
+#include "../../../../kernel/eka/drivers/iic/iic_channel.mmh"
+
+macro MASTER_MODE
+
+target          i2c_slavestubs_ctrless.pdd
+targettype      pdd
+
+sourcepath	../../../../kernel/eka/drivers/iic
+source		IIC_PIL_SOURCE
+
+sourcepath		.
+source          i2c.cpp
+
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+macro IIC_SIMULATED_PSL
+macro BUS_TYPE=(DIicBusChannel::EI2c)
+
+// un-comment the following if debug printing is required
+//macro LOG_I2C
+
+// un-comment the following if BTRACE output is required
+macro IIC_INSTRUMENTATION_MACRO
+
+deffile				../../~/i2c_slavestubs_ctrless.def
+
+uid			0x100039d0 0x10286b50
+VENDORID 0x70000001
+
+//library				ecust.lib
+#ifdef WINS
+library				emulator.lib
+#endif 
+
+start wins
+win32_library			kernel32.lib
+#if defined(VC32)
+win32_library			msvcrt.lib
+#endif
+end
+
+SMPSAFE
+
--- a/kerneltest/e32test/iic/iic_psl/iic_client.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/iic/iic_psl/iic_client.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -112,8 +112,13 @@
 
 
 #ifdef STANDALONE_CHANNEL
+#ifdef IIC_STUBS
+_LIT(KLddRootName,"iic_client_stubs");
+#else
 _LIT(KLddRootName,"iic_client_ctrless");
-#else
+#endif/*IIC_STUBS*/
+
+#else/*STANDALONE_CHANNEL*/
 _LIT(KLddRootName,"iic_client");
 #endif
 _LIT(KIicClientThreadName,"IicClientLddThread");
@@ -403,6 +408,7 @@
 	TInt StaticExtension(TUint aId, TUint aFunction, TAny* aParam1, TAny* aParam2);
 	TInt CaptureChannel(TInt aBusId, TDes8* aConfigHdr, TIicBusSlaveCallback* aCallback, TInt& aChannelId, TBool aAsynch=NULL);
 	TInt ReleaseChannel(TInt aChannelId);
+	TInt Spare1(TInt aBusId);
 	public:
 	inline void Lock() {Kern::MutexWait(*iArrayMutex);}
 	inline void Unlock() {Kern::MutexSignal(*iArrayMutex);}
@@ -1324,6 +1330,56 @@
     return r;
 	}
 
+//this function is added for improving the code coverage of IIC.
+//Spare1 is a placeholder for future expansion, and so returns KErrNotSupported.
+#ifdef STANDALONE_CHANNEL
+TInt DChannelIicClient::Spare1(TInt aBusId)
+    {
+    TInt r = KErrNone;
+
+    TInt chanIndex = 0;
+    DIicClientChan* chanPtr = NULL;
+    if(r == KErrNone)
+        {
+        r = GetChanPtr(aBusId, chanIndex, chanPtr);
+        if(r == KErrNone)
+            {
+            if(!chanPtr)
+                {
+                r = KErrArgument;
+                }
+            else
+                {
+                switch(chanPtr->GetChanType())
+                    {
+                    case DIicBusChannel::EMaster:
+                        {
+                        r = ((DIicBusChannelMaster*)(chanPtr->GetChannelPtr()))->Spare1(0,NULL,NULL);
+                        break;
+                        }
+                    case DIicBusChannel::EMasterSlave:
+                        {
+                        r = KErrNotSupported;
+                        break;
+                        }
+                    case DIicBusChannel::ESlave:
+                        {
+                        r = ((DIicBusChannelSlave*)(chanPtr->GetChannelPtr()))->Spare1(0,NULL,NULL);
+                        break;
+                        }
+                    default:
+                        {
+                        r = KErrArgument;
+                        }
+                    }
+                }
+            }
+        }
+    return r;
+    }
+#endif
+
+#ifndef IIC_STUBS
 void DChannelIicClient::DoCancel(TInt aMask)
 	{
 // Cancel an outstanding request.
@@ -1406,7 +1462,68 @@
 
 	return;
 	}
+#else/*IIC_STUBS*/
+//should only be called in IIC_STUBS mode
+//DoCancel is used to cancel an asynchronous request which is still waiting in the queue and
+//has not yet been handled by IIC.
+//In the stub test, QueueTransaction should always return a KErrNotSupported error code
+//So we pretend there is an request waiting in the queue that can be cancelled by calling DoCancel.
+void DChannelIicClient::DoCancel(TInt aMask)
+    {
+    // Cancel an outstanding request.
+    CLIENT_PRINT(("DChannelIicClient::DoCancel invoked with aMask=0x%x\n", aMask));
 
+    // inline void CancelAsyncOperation(TRequestStatus* aStatus, TInt aBusId)   {TInt* parms[2]; parms[0]=(TInt*)aStatus; parms[1]=(TInt*)aBusId;DoCancel((TInt)&parms[0]);}
+    // aMask has the address on TInt* parms[2]
+    // parms[0] = TRequestStatus pointer
+    // parms[1] = Bus Identifier
+    TInt* parms[2];
+    TInt r=Kern::ThreadRawRead(iClient,(TAny*)aMask,&(parms[0]),2*sizeof(TInt*));
+    if(r!=KErrNone)
+        {
+        CLIENT_PRINT(("DChannelIicClient::DoCancel ERROR - Can't read parms[]\n"));
+        return; // Can't proceed if can't access request parameters
+        }
+    CLIENT_PRINT(("DChannelIicClient::DoCancel - TRequestStatus 0x%x, BusID = 0x%x\n",parms[0],parms[1]));
+    TRequestStatus* status= (TRequestStatus*)(parms[0]);
+    
+    //A valid transaction object is required here in order to exercise the API
+    TInt busIdI2c = (TInt)(parms[1]);
+    TConfigI2cBufV01* i2cBuf=NULL;
+    SET_BUS_TYPE(busIdI2c,EI2c);
+    SET_CHAN_NUM(busIdI2c,10);
+    // aDeviceId=1 ... 100kHz ... aTimeoutPeriod=100 ... aTransactionWaitCycles=10 - arbitrary paarmeters.
+    r=CreateI2cBuf(i2cBuf, EI2cAddr7Bit, 36, ELittleEndian, 100);
+    if(r!=KErrNone)
+        {
+        CLIENT_PRINT(("DChannelIicClient::DoCancel ERROR - Can't allocate memory for I2c buffer\n"));
+        return; // Can't proceed if can't access request parameters
+        }
+
+    TIicBusTransfer* tfer = new TIicBusTransfer(TIicBusTransfer::EMasterWrite,8,i2cBuf);
+    if(tfer == NULL) 
+        {
+        CLIENT_PRINT(("DChannelIicClient::DoCancel ERROR - Can't allocate memory for the transfer\n"));
+        delete i2cBuf; 
+        return;
+        }
+
+    TIicBusTransaction* transac = new TIicBusTransaction((TDes8*)i2cBuf, tfer);
+    if(transac == NULL) 
+        {
+        CLIENT_PRINT(("DChannelIicClient::DoCancel ERROR - Can't allocate memory for the transaction\n"));
+        delete i2cBuf; 
+        delete tfer; 
+        return;
+        }
+
+    r = CancelTransaction(busIdI2c, transac);
+    Kern::RequestComplete(iClient, status, r);
+    delete i2cBuf;
+    delete tfer;
+    delete transac;
+    }
+#endif/*IIC_STUBS*/
 
 // Function to support preamble testing
 void PreambleCallbackFunc(TIicBusTransaction* /*aTrans*/, TAny* aParam)
@@ -2395,8 +2512,17 @@
             r = channelInterface.TestInterface();
             break;         
             }
+        case(RBusDevIicClient::ETestSpare1):
+            {
+            r = Spare1((TInt)a1);
+            break;
+            }
+        case(RBusDevIicClient::ETestStaticEx):
+            {
+            r = StaticExtension((TUint32)a1, (TUint)RBusDevIicClient::ECtlIoNone, NULL, NULL);
+            break;
+            }
 #endif
-        
         default:
 			{
 			CLIENT_PRINT(("DChannelIicClient::DoControl - unrecognised value for aId=0x%x\n",aId));
--- a/kerneltest/e32test/iic/iic_psl/iic_slaveclient.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/iic/iic_psl/iic_slaveclient.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -93,7 +93,11 @@
 const TInt KMaxNumChannels = 2;	// 1 "true" slave, one "dummy"
 
 #ifdef STANDALONE_CHANNEL
+#ifdef IIC_STUBS
+_LIT(KLddRootName,"iic_slaveclient_stubs");
+#else
 _LIT(KLddRootName,"iic_slaveclient_ctrless");
+#endif/*IIC_STUBS*/
 #else
 _LIT(KLddRootName,"iic_slaveclient");
 #endif
@@ -164,6 +168,9 @@
 	TInt RegisterTxBuffer(TInt aChannelId, TPtr8 aTxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset);
 	TInt CaptureChannel(TInt aBusId, TDes8* aConfigHdr, TIicBusSlaveCallback* aCallback, TInt& aChannelId, TBool aAsynch=NULL);
 	TInt ReleaseChannel(TInt aChannelId);
+#ifdef STANDALONE_CHANNEL
+	TInt Spare1(TInt aBusId);
+#endif
 	private:
 	TDynamicDfcQue* iDfcQue;
 	TIicBusSlaveCallback* iNotif;
@@ -471,6 +478,13 @@
 	DIicSlaveClientChan* aChanPtr = NULL;
 	if(iCapturedChan.iChannelId == aChannelId)
 		aChanPtr = iCapturedChan.iChannel;
+#ifdef IIC_STUBS
+	//in the code coverage tests, a slave channel will not be captured before other slave
+	//operations get called, e.g. calling DIicBusChannelSlave::CaptureChannel in MASTER_MODE
+	//should return a KErrNotSupported. In controller-less mode, the client creates and manages its own channels.
+	//So in here, we pretend a slave channel has been captured and can be used for the current operation.
+	aChanPtr=iCapturedChan.iChannel;
+#endif/*IIC_STUBS*/
 	if(!aChanPtr)
 		return KErrArgument;
 	if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave)
@@ -490,6 +504,13 @@
 	DIicSlaveClientChan* aChanPtr = NULL;
 	if(iCapturedChan.iChannelId == aChannelId)
 		aChanPtr = iCapturedChan.iChannel;
+#ifdef IIC_STUBS
+    //in the code coverage tests, a slave channel will not be captured before other slave
+	//operations get called, e.g. calling DIicBusChannelSlave::CaptureChannel in MASTER_MODE
+	//should return a KErrNotSupported. In controller-less mode, the client creates and manages its own channels.
+	//So in here, we pretend a slave channel has been captured and can be used for the current operation.
+    aChanPtr=iCapturedChan.iChannel;
+#endif/*IIC_STUBS*/
 	if(!aChanPtr)
 		return KErrArgument;
 	if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave)
@@ -529,6 +550,13 @@
 	DIicSlaveClientChan* aChanPtr = NULL;
 	if(iCapturedChan.iChannelId == aChannelId)
 		aChanPtr = iCapturedChan.iChannel;
+#ifdef IIC_STUBS
+    //in the code coverage tests, a slave channel will not be captured before other slave
+	//operations get called, e.g. calling DIicBusChannelSlave::CaptureChannel in MASTER_MODE
+	//should return a KErrNotSupported. In controller-less mode, the client creates and manages its own channels.
+	//So in here, we pretend a slave channel has been captured and can be used for the current operation.
+    aChanPtr=iCapturedChan.iChannel;
+#endif/*IIC_STUBS*/
 	if(!aChanPtr)
 		return KErrArgument;
 	if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave)
@@ -589,6 +617,13 @@
 						r = KErrArgument;
 						}
 					}
+#ifdef IIC_STUBS
+				//if we try to capture a slave channel in MASTER_MODE, the capture should fail with KErrNotSupported.
+				//However, we need a slave channel to be captured before running most of slave operation 
+				//tests,e.g. RegisterRxBuf. So in here, we pretend the channel is captured, and save
+				//the channel pointer in iCapturedChan, so it can be used for other slave operation tests. 
+				iCapturedChan.iChannel = chanPtr;
+#endif/*IIC_STUBS*/
 				// For synchronous capture, if successful then install the channel
 				if(r == KErrNone)
 					{
@@ -630,6 +665,54 @@
 #endif
 	return r;
 	}
+
+//this function is added for improving the code coverage of IIC.
+//Spare1 is a placeholder for future expansion, so returns KErrNotSupported.
+#ifdef STANDALONE_CHANNEL
+TInt DChannelIicSlaveClient::Spare1(TInt aBusId)
+    {
+    TInt r = KErrNone;
+    DIicSlaveClientChan* chanPtr = NULL;
+    if(r == KErrNone)
+        {
+        r = GetChanPtr(aBusId, chanPtr);
+        if(r == KErrNone)
+            {
+            if(!chanPtr)
+                {
+                r = KErrArgument;
+                }
+            else
+                {
+                switch(chanPtr->GetChanType())
+                    {
+                    case DIicBusChannel::EMaster:
+                        {
+                        r = ((DIicBusChannelMaster*)(chanPtr->GetChannelPtr()))->Spare1(0,NULL,NULL);
+                        break;
+                        }
+                    case DIicBusChannel::EMasterSlave:
+                        {
+                        r = KErrNotSupported;
+                        break;
+                        }
+                    case DIicBusChannel::ESlave:
+                        {
+                        r = ((DIicBusChannelSlave*)(chanPtr->GetChannelPtr()))->Spare1(0,NULL,NULL);
+                        break;
+                        }
+                    default:
+                        {
+                        r = KErrArgument;
+                        }
+                    }
+                }
+            }
+        }
+    return r;
+    }
+#endif
+
 TInt DChannelIicSlaveClient::CbProcessOverUnderRunRxTx()
 	{
 	CLIENT_PRINT(("> DChannelIicSlaveClient::CbProcessOverUnderRunRxTx(), iTestOverUnderState=%d\n",iTestOverUnderState));
@@ -1335,7 +1418,13 @@
 				iFullDuplexReq |= (ERxAllBytes|ETxAllBytes);
 			r = SetNotificationTrigger(parms[0],parms[1]);
 			if(r == KErrTimedOut)
+			    {
+                //the TRequestStatus is being completed with the error code to indicate 
+                //that the timeout was detected, but KErrNone is returned because 
+                //the requested notification settings were accepted.
+                Kern::RequestComplete(iClient, iStatus, r);
 				r=KErrNone;	// KErrTimedOut is returned if the Client has not interacted with IIC for a while
+			    }			
 			break;
 			}
 
@@ -1532,7 +1621,23 @@
 			r = StaticExtension((TUint)a1, (TUint)ctrlIoVal, NULL, NULL);
 			break;
 			}
-
+#ifdef STANDALONE_CHANNEL
+		 case(RBusDevIicClient::ETestSpare1):
+            {
+            //a1 represents a BusId passed from the user.
+			//Spare1 is a placeholder for future expansion.
+            r = Spare1((TInt)a1);
+            break;
+            }
+		 case(RBusDevIicClient::ETestStaticEx):
+            {
+		    //Passing a1, which represents a BusId, and the value of a function to StaticExtension.
+			//Using ECtlIoNone here, so StaticExtension will be called to execute the default case,
+			// but since this is only called when using stubs KErrNotSupported will be expected.
+            r = StaticExtension((TUint32)a1, (TUint)RBusDevIicClient::ECtlIoNone, NULL, NULL);
+            break;
+            }
+#endif
 		default:
 			{
 			CLIENT_PRINT(("DChannelIicSlaveClient::DoControl - unrecognised value for aId=0x%x\n",aId));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/iic/iic_psl/iic_testpsl.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,106 @@
+// Copyright (c) 2008-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/iic/iic_psl/iic_testpsl.cpp
+//
+
+#include <drivers/iic.h>
+#include "iic_testpsl.h"
+
+// Global Controller pointer
+extern DIicBusController*& gTheController;
+
+#ifndef IIC_SIMULATED_PSL
+
+#error iic_testpsl.cpp being built when IIC_SIMULATED_PSL is not defined
+
+#else
+
+TVersion DIicPdd::VersionRequired()
+	{
+	const TInt KIicMajorVersionNumber=1;
+	const TInt KIicMinorVersionNumber=0;
+	const TInt KIicBuildVersionNumber=KE32BuildVersionNumber;
+	return TVersion(KIicMajorVersionNumber,KIicMinorVersionNumber,KIicBuildVersionNumber);
+	}
+
+/** Factory class constructor */
+DIicPdd::DIicPdd()
+	{
+    iVersion = DIicPdd::VersionRequired();
+	}
+
+DIicPdd::~DIicPdd()
+	{
+	delete gTheController;
+	}
+
+TInt DIicPdd::Install()
+    {
+    return(SetName(&KPddName));
+    }
+
+/**  Called by the kernel's device driver framework to create a Physical Channel. */
+TInt DIicPdd::Create(DBase*& /*aChannel*/, TInt /*aUint*/, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/)
+    {
+    return KErrNone;
+    }
+
+/**  Called by the kernel's device driver framework to check if this PDD is suitable for use with a Logical Channel.*/
+TInt DIicPdd::Validate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer)
+    {
+   	if (!Kern::QueryVersionSupported(DIicPdd::VersionRequired(),aVer))
+		return(KErrNotSupported);
+    return KErrNone;
+    }
+
+/** Return the driver capabilities */
+void DIicPdd::GetCaps(TDes8& aDes) const
+    {
+	// Create a capabilities object
+	TCaps caps;
+	caps.iVersion = iVersion;
+	// Zero the buffer
+	TInt maxLen = aDes.MaxLength();
+	aDes.FillZ(maxLen);
+	// Copy cpabilities
+	TInt size=sizeof(caps);
+	if(size>maxLen)
+	   size=maxLen;
+	aDes.Copy((TUint8*)&caps,size);
+    }
+
+static DIicPdd* TheIicPdd;
+
+DECLARE_STANDARD_PDD()
+	{
+	gTheController = new DIicBusController;
+	if(!gTheController)
+		return NULL;
+	TInt r = gTheController->Create();
+	if(r == KErrNone)
+		{
+		TheIicPdd = new DIicPdd;
+		if(TheIicPdd)
+			return TheIicPdd;
+		}
+	
+	delete gTheController; 
+	return NULL;
+	}
+
+#endif/*IIC_SIMULATED_PSL*/
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/iic/iic_psl/iic_testpsl.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,41 @@
+// Copyright (c) 2008-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/iic/iic_psl/iic_testpsl.h
+//
+
+#ifndef IIC_TEST_PSL_H_
+#define IIC_TEST_PSL_H_
+
+_LIT(KPddName,"iic.pdd");
+
+NONSHARABLE_CLASS(DIicPdd) : public DPhysicalDevice
+	{
+// Class to faciliate loading of the IIC classes
+public:
+	class TCaps
+		{
+	public:
+		TVersion iVersion;
+		};
+public:
+	DIicPdd();
+	~DIicPdd();
+	virtual TInt Install();
+	virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	virtual TInt Validate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	virtual void GetCaps(TDes8& aDes) const;
+	inline static TVersion VersionRequired();
+	};
+
+#endif
--- a/kerneltest/e32test/iic/iic_psl/iic_testpsl.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/iic/iic_psl/iic_testpsl.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -28,9 +28,11 @@
 
 sourcepath			../../../../kernel/eka/drivers/iic
 source				iic.cpp iic_transaction.cpp
+sourcepath			.
+source				iic_testpsl.cpp
 
 OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-USERINCLUDE		../../../../kernel/eka/drivers/iic
+USERINCLUDE		. ../../../../kernel/eka/drivers/iic
 
 // un-comment the following if BTRACE output is required
 macro IIC_INSTRUMENTATION_MACRO
--- a/kerneltest/e32test/iic/t_iic.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/iic/t_iic.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -37,13 +37,28 @@
 _LIT(KIicProxyFileNameRoot, "iic_client");
 _LIT(KIicProxySlaveFileName, "iic_slaveclient.ldd");	// Kernel-side proxy LDD acting as a slave client of the IIC
 _LIT(KIicProxySlaveFileNameRoot, "iic_slaveclient");
+//These are used to exercise stub functions.
+_LIT(KIicProxyFileNameStubs, "iic_client_stubs.ldd");
+_LIT(KIicProxyFileNameRootStubs, "iic_client_stubs");
+_LIT(KIicProxySlaveFileNameStubs, "iic_slaveclient_stubs.ldd");
+_LIT(KIicProxySlaveFileNameRootStubs, "iic_slaveclient_stubs");
+
 
 #ifdef IIC_SIMULATED_PSL
 _LIT(KSpiFileNameCtrlLess, "spi_ctrless.pdd");	// Simulated PSL bus implementation
-_LIT(KI2cFileNameCtrlLess, "i2c_ctrless.pdd");	// Simulated PSL bus implementation
+_LIT(KI2cFileNameCtrlLess, "i2c_ctrless.pdd");  // Simulated PSL bus implementation
 _LIT(KIicPslFileName, "iic_testpsl.pdd");	// Simulated PSL implementation
 _LIT(KSpiFileName, "spi.pdd");	// Simulated PSL bus implementation
-_LIT(KI2cFileName, "i2c.pdd");	// Simulated PSL bus implementation
+_LIT(KI2cFileName, "i2c.pdd");  // Simulated PSL bus implementation
+//These are used to exercise stubs. The I2C pdd to use for stub tests will depend on
+//whether Master, Slave mode has been selected. 
+#if defined(MASTER_MODE)&&!defined(SLAVE_MODE)
+_LIT(KI2cFileNameStubs, "i2c_slavestubs_ctrless.pdd");
+#elif !defined(MASTER_MODE)&& defined(SLAVE_MODE)
+_LIT(KI2cFileNameStubs, "i2c_masterstubs_ctrless.pdd");
+#else
+_LIT(KI2cFileNameStubs, "i2c_ctrless.pdd");
+#endif
 #endif
 
 _LIT(KIicPslFileNameRoot, "iic.pdd");
@@ -730,6 +745,9 @@
 //!						    of words. Wait for the TRequestStatus to be completed (with KErrNone). Specify a notification trigger for Tx and
 //!							Tx Overrun, then use controlIO to instruct the simulated bus to unblock Master responses.Wait for the TRequestStatus
 //!							to be completed.
+//!         
+//!                     12) Test the PIL behavior for a client timeout: request notification of an event but deliberately delay the client response.  
+//!                         The PIL should return KErrTimedOut when a subsequent request for a notification is made.
 //!
 //! @SYMTestExpectedResults 0) Kernel-side proxy client should return with KErrNone, exits otherwise.
 //!						1) Kernel-side proxy client should return with KErrNone, exits otherwise.
@@ -750,6 +768,9 @@
 //!						   TRequestStatus should be set to KErrNone, exits otherwise.
 //!						11) Kernel-side proxy client should return with KErrNone for each API call, exits otherwise. The associated
 //!						   TRequestStatus should be set to KErrNone in both cases, exits otherwise.
+//!                     12) Kernel-side proxy client should return with KErrNone for each API call, exits otherwise. The associated
+//!                        TRequestStatus should be set to KErrNone in both cases, exits otherwise, except for when the client response
+//!                        exceeds the timeout period, and the next request for a notification expects KErrTimedOut.
 //!
 //! @SYMTestPriority        High
 //! @SYMTestStatus          Implemented
@@ -1189,6 +1210,50 @@
 	r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status);
 	gTest(r==KErrNone);
 
+	//Test the PIL behavior for a client timeout: request notification of an event
+	//but deliberately delay the client response. The PIL should return KErrTimedOut 
+	//when a subsequent request for a notification is made.
+	gTest.Printf(_L("Starting test for SendBusErrorAndReturn.\n"));
+	
+	// For Rx, specify buffer granularity=4 (32-bit words), 8 words to receive, offset of 16 bytes
+	// 64 bytes as 16 words: words 0-3 offset, words 4-11 data, words 12-15 unused
+	gTest.Printf(_L("Starting RegisterRxBuffer\n"));
+	r=gChanSlaveI2c.RegisterRxBuffer(chanId, 4, 8, 16);
+	gTest(r==KErrNone);
+
+	// Now set the notification trigger
+	//TRequestStatus status;
+	triggerMask=ERxAllBytes;
+	
+    gTest.Printf(_L("Starting SetNotificationTrigger with ERxAllBytes\n"));
+    r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status);
+    gTest(r==KErrNone);
+    // Now instruct the bus implementation to represent receipt of the required number of words from the bus master.
+    gTest.Printf(_L("Starting SimulateRxNWords\n"));
+    r=gChanSlaveI2c.SimulateRxNWords(busIdI2c, chanId, 8);
+    gTest(r==KErrNone);
+    //
+    // Wait for the notification
+    User::WaitForRequest(status);
+    r=status.Int();
+    if(r != KErrNone)
+        {
+        gTest.Printf(_L("TRequestStatus value after receiving data = %d\n"),r);
+        gTest(r==KErrNone);
+        }
+    //Delay the client response to exceed the timeout period, and check that the next
+    //request for a notification encounters the expected error code.
+    User::After(1000 * 1000);
+    r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status);
+    gTest(r==KErrNone);
+    User::WaitForRequest(status);
+	r = status.Int();
+    if(r!=KErrTimedOut)
+        {
+        gTest.Printf(_L("TRequestStatus value = %d\n"),status.Int());
+        gTest(r==KErrTimedOut);
+        } 
+    gTest.Printf(_L("The test for SendBusErrorAndReturn is completed OK\n"));
 	// Release the channel
 	r = gChanSlaveI2c.ReleaseChannel( chanId );
 	gTest(r==KErrNone);
@@ -1403,6 +1468,125 @@
         }
     }
 
+//Only get called in stand alone mode
+LOCAL_C TInt IicTestStubs()
+    {
+    //Function to call the stub methods for Master and slave channels
+    //when Master and Slave functionality has not been built. The stubs
+    //return KErrNotSupported.
+    TInt r=KErrNone;
+    
+    TUint32 busIdI2c = 0;
+    TConfigI2cBufV01* i2cBuf=NULL;
+    TRequestStatus status;
+
+    //Starting master channel stubs test.
+    //a valid transaction is required when calling the Master QueueTransaction stub.
+    //Use I2C channel here. In MASTER_MODE, channelId starting from 10, 
+    //and 10 is a master channel
+    SET_BUS_TYPE(busIdI2c,EI2c);
+    SET_CHAN_NUM(busIdI2c,10);
+    // aDeviceId=1 ... 100kHz ... aTimeoutPeriod=100 ... aTransactionWaitCycles=10 - arbitrary paarmeters.
+    r=CreateI2cBuf(i2cBuf, EI2cAddr7Bit, 36, ELittleEndian, 100);
+    gTest(r==KErrNone);
+
+    // Use a single transfer
+    _LIT(halfDuplexText,"Half Duplex Text");
+    TBuf8<17> halfDuplexBuf_8;
+    halfDuplexBuf_8.Copy(halfDuplexText);
+    TUsideTferDesc* tfer = NULL;
+    r = CreateSingleUserSideTransfer(tfer, EMasterWrite, 8, &halfDuplexBuf_8, NULL);
+    gTest(r==KErrNone);
+
+    // Create the transaction object
+    TUsideTracnDesc* tracn = NULL;
+    r = CreateSingleUserSideTransaction(tracn, EI2c, i2cBuf, tfer, NULL, 0, NULL, NULL);
+    gTest(r==KErrNone);
+
+    // queue a synchronous transaction
+    gTest.Printf(_L("\n\nStarting synchronous QueueTransaction \n"));
+    r = gChanMasterI2c.QueueTransaction(busIdI2c, tracn);
+    gTest.Printf(_L("Synchronous QueueTransaction returned = %d\n"),r);
+    //Queueing a transaction in SLAVE_MODE should return KErrNotSupported 
+    gTest(r==KErrNotSupported); 
+    
+    // queue an asynchronous transaction and cancel the trasnaction
+    // QueueTransaction actually completes before CancelAsyncOperation with KErrNotSupported
+    // In test driver, we pretend the request is still in the queue and then cancel it.
+    gChanMasterI2c.QueueTransaction(status, busIdI2c, tracn);
+    gChanMasterI2c.CancelAsyncOperation(&status, busIdI2c);
+    User::WaitForRequest(status);
+    if(status != KErrNotSupported)
+        {
+        gTest.Printf(_L("TRequestStatus value after queue = %d\n"),status.Int());
+        gTest(r==KErrNotSupported);
+        }
+    //spare1 is an unused method that is present to provide for future extension,
+    //which just returns KErrNotSupported. 
+    r = gChanMasterI2c.TestSpare1(busIdI2c);
+    gTest(r == KErrNotSupported);
+    //StaticExtension is present for PSL implementations to override, the default
+    //implementation just returns KErrNotSupported
+    r = gChanMasterI2c.TestStaticExtension(busIdI2c);
+    gTest(r == KErrNotSupported);
+    //free the memory
+    delete i2cBuf;
+    delete tfer;
+    delete tracn;
+
+    //Start to test slave channel operations
+    SET_BUS_TYPE(busIdI2c,EI2c);
+    SET_CHAN_NUM(busIdI2c,11); // 11 is the Slave channel number
+    //
+    // clock speed=36Hz, aTimeoutPeriod=100 - arbitrary parameter
+    r=CreateI2cBuf(i2cBuf, EI2cAddr7Bit, 36, ELittleEndian, 100);
+    gTest(r==KErrNone);
+
+    // Synchronous capture of a Slave channel.
+    TInt chanId = 0; // Initialise to zero to silence compiler ...
+    gTest.Printf(_L("\n\nStarting synchronous CaptureChannel \n"));
+    r = gChanSlaveI2c.CaptureChannel(busIdI2c, i2cBuf, chanId );
+    gTest.Printf(_L("Synchronous CaptureChannel returned = %d, aChanId=0x%x\n"),r,chanId);
+    gTest(r==KErrNotSupported);
+    
+    gTest.Printf(_L("Starting RegisterRxBuffer\n"));
+    r=gChanSlaveI2c.RegisterRxBuffer(chanId, 4, 8, 16);
+    gTest(r==KErrNotSupported);
+    
+    gTest.Printf(_L("\nStarting RegisterTxBuffer\n"));
+    r=gChanSlaveI2c.RegisterTxBuffer(chanId, 4, 12, 8);
+    gTest(r==KErrNotSupported);
+    //
+    // Now set the notification trigger
+    TInt triggerMask=ERxAllBytes;
+
+    gTest.Printf(_L("Starting SetNotificationTrigger with ERxAllBytes\n"));
+    r=gChanSlaveI2c.SetNotificationTrigger(chanId,triggerMask,&status);
+    gTest(r==KErrNotSupported);
+    
+    r = gChanSlaveI2c.TestSpare1(busIdI2c);
+    gTest(r == KErrNotSupported);
+    r = gChanSlaveI2c.TestStaticExtension(busIdI2c);
+    gTest(r == KErrNotSupported);
+    delete i2cBuf;
+
+    //Start to test MasterSlave channel operations
+    //Create a Master-Slave channel
+    RBusDevIicClient chanMasterSlaveI2c;
+    TBufC<18> proxyName;
+    proxyName = KIicProxyFileNameRootStubs;
+    r = chanMasterSlaveI2c.Open(proxyName);
+    gTest(r==KErrNone);
+    
+    SET_BUS_TYPE(busIdI2c,EI2c);
+    SET_CHAN_NUM(busIdI2c,12); // 12 is the MasterSlave channel number
+    r = chanMasterSlaveI2c.TestStaticExtension(busIdI2c);
+    gTest(r==KErrNotSupported);
+    chanMasterSlaveI2c.Close();
+
+    return KErrNone;
+    }
+
 LOCAL_C TInt RunTests()
 //
 //	Utility method to invoke the separate tests
@@ -1619,6 +1803,63 @@
 	gTest.Next(_L("Free Simulated PSL SPI bus driver"));
 	err = User::FreePhysicalDevice(KSpiFileNameCtrlLess);
 	gTest(err==KErrNone);
+	
+    //For simplicity, the code coverage tests are executed in STANDALONE_CHANNEL mode
+	//All the changes are made in test code, and not affect PIL.
+	gTest.Next(_L("Start the code coverage tests"));
+
+    gTest.Next(_L("Load Simulated PSL I2C bus driver"));
+    r = User::LoadPhysicalDevice(KI2cFileNameStubs);
+    gTest.Printf(_L("return value r=%d"),r);
+    gTest(r==KErrNone || r==KErrAlreadyExists);
+
+    gTest.Next(_L("Load kernel-side proxy IIC client"));
+    r = User::LoadLogicalDevice(KIicProxyFileNameStubs);
+    gTest(r==KErrNone || r==KErrAlreadyExists);
+
+    gTest.Next(_L("Load kernel-side proxy IIC slave client"));
+    r = User::LoadLogicalDevice(KIicProxySlaveFileNameStubs);
+    gTest(r==KErrNone || r==KErrAlreadyExists);
+
+    __KHEAP_MARK;
+    TBufC<30> proxyNameStubs(KIicProxyFileNameRootStubs);
+    // Open a Master I2C channel to the kernel side proxy
+    r = gChanMasterI2c.Open(proxyNameStubs);
+
+    gTest(r==KErrNone);
+    TBufC<35> proxySlaveNameStubs(KIicProxySlaveFileNameRootStubs);
+
+    r = gChanSlaveI2c.Open(proxySlaveNameStubs);
+    gTest(r==KErrNone);
+    r = gChanSlaveI2c.InitSlaveClient();
+    gTest(r==KErrNone);
+
+    // Instigate tests
+    r = IicTestStubs();
+    gTest(r==KErrNone);
+
+    gTest.Printf(_L("Tests completed OK, about to close channel\n"));
+    gChanMasterI2c.Close();
+    gChanSlaveI2c.Close();
+
+    UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
+    // Not safe to assume that heap clean-up has completed for the channels just closed, so insert a delay.(DEF145202)
+    User::After(20 * 1000);
+    __KHEAP_MARKEND;
+
+    gTest.Next(_L("Free kernel-side proxy IIC client"));
+
+    err = User::FreeLogicalDevice(KIicProxyFileNameRootStubs);
+    gTest(err==KErrNone || err==KErrAlreadyExists);
+    gTest.Next(_L("Free kernel-side proxy IIC slave client"));
+    err = User::FreeLogicalDevice(KIicProxySlaveFileNameRootStubs);
+    gTest(err==KErrNone || err==KErrAlreadyExists);
+
+    gTest.Next(_L("Free Simulated PSL I2C bus driver"));
+    err = User::FreePhysicalDevice(KI2cFileNameStubs);
+    gTest(err==KErrNone);
+
+	gTest.Next(_L("End the code coverage tests"));
 #else
 	gTest.Printf(_L("Don't do the test if it is not IIC_SIMULATED_PSL"));
 #endif
--- a/kerneltest/e32test/iic/t_iic.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/iic/t_iic.h	Wed Aug 18 11:08:29 2010 +0300
@@ -301,7 +301,9 @@
 		EReleaseChan,						/**< ReleaseChannel												*/
 		ERegisterRxBuffer,					/**< Register a buffer for receiving data						*/
 		ERegisterTxBuffer,					/**< Register a buffer for transmitting data					*/
-		ESetNotifTrigger					/**< Set the notification triggers                               */									
+		ESetNotifTrigger,					/**< Set the notification triggers                               */
+		ETestSpare1,
+		ETestStaticEx
 		};
 
 	enum TStaticExt
@@ -405,7 +407,9 @@
 	inline TInt SetNotifNoTrigger(TInt aChannelId, TInt aTrigger){return(DoControl(ECtrlIoNotifNoTrigger,(TAny*)aChannelId,(TAny*)aTrigger));};
 
 	inline void TestOverrunUnderrun(TInt aBusId, TInt aChannelId, TRequestStatus& aStatus) {DoRequest(ECtrlIoOvUndRunRxTx,aStatus,(TAny*)aBusId,(TAny*)aChannelId);}
-
+	
+	inline TInt TestSpare1(TInt aBusId) {return (DoControl(ETestSpare1, (TAny*)aBusId));}
+	inline TInt TestStaticExtension(TInt aBusId) {return (DoControl(ETestStaticEx, (TAny*)aBusId));}
 #endif
 	};
 
--- a/kerneltest/e32test/misc/t_zip.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/misc/t_zip.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/mmu/freeram.h	Wed Aug 18 11:08:29 2010 +0300
@@ -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/mmu/t_alias_remove.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/mmu/t_alias_remove.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -207,7 +207,7 @@
 		if ((fillValue & 0xf) == 1)
 			test.Printf(_L("."));
 
-		PRINTF(T_PRINTF(_L("Process ID %d start slave fill value %d\n"), aProcessId, fillValue));
+		test.Printf(_L("Process ID %d start slave fill value %d\n"), aProcessId, fillValue);
 		RServer2 masterServer;
 		r = masterServer.CreateGlobal(MasterServerName);
 		test_KErrNone(r);
@@ -269,7 +269,7 @@
 				}
 			}
 		
-		PRINTF(T_PRINTF(_L("Process ID %d Wait for alias to complete\n"), aProcessId));
+		test.Printf(_L("Process ID %d Wait for alias to complete\n"), aProcessId);
 		masterMessage.Complete(KErrNone);
 		User::WaitForRequest(threadStatus);
 		TInt statusInt = threadStatus.Int();
@@ -280,7 +280,7 @@
 		test_Equal(EExitKill, readThread.ExitType());
 		readThread.Close();
 
-		PRINTF(T_PRINTF(_L("Process ID %d Wait for slave to complete\n"), aProcessId));
+		test.Printf(_L("Process ID %d Wait for slave to complete\n"), aProcessId);
 		User::WaitForRequest(slaveStatus);
 		test_Equal(EExitKill, slaveProcess.ExitType());
 		test_Equal(KErrNone, slaveProcess.ExitReason());
--- a/kerneltest/e32test/multimedia/t_camera_api.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1487 +0,0 @@
-// Copyright (c) 2006-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\multimedia\t_camera_api.cpp
-// 
-//
-
-#include <e32test.h>
-#include <d32camerasc.h>
-#include <e32def.h>
-#include <e32def_private.h>
-#include "t_camera_display.h"
-#include "t_camera_bitmap.h"
-#include "d_mmcsc.h"
-
-_LIT(KTstLddFileName,"D_MMCSC.LDD");
-_LIT(KCamLddFileName,"ECAMERASC.LDD");
-
-#ifdef __WINSCW__
-_LIT(KCamPddFileName,"_TEMPLATE_CAMERASC.PDD");
-#else
-_LIT(KCamPddFileName,"CAMERASC.PDD");
-#endif
-
-
-_LIT(KCamFreePddExtension,".*");
-
-_LIT(KFrameSize, "%dx%d");
-_LIT(KSensor, "d:\\Sensor_");
-_LIT(KUnderscore, "_");
-_LIT(KBmp, ".bmp");
-_LIT(KJpeg, ".jpg");
-_LIT(KSpeedTaggedJpeg, ".stj");
-
-LOCAL_D TCameraCapsV02* CameraCaps;
-LOCAL_D TInt CapsSize;
-LOCAL_D TAny* CapsBufPtr;
-RTest Test(_L("T_CAMERA_API"));
-
-const TInt KNumVideoFramesToAllocate=6;
-const TInt KNumVideoFramesToCapture=(KNumVideoFramesToAllocate-2);
-const TInt KHeapSize=0x4000;
-const TInt KUnit0=0;
-
-enum TSecThreadTestId
-	{
-	ESecThreadTestOpen,
-	ESecThreadTestDuplicateHandle,
-	ESecThreadReuseHandle
-	};
-
-struct SSecondaryThreadInfo
-	{
-	TSecThreadTestId iTestId;
-	TInt iExpectedRetVal;
-	TThreadId iThreadId;
-	TInt iDrvHandle;
-	TInt iCameraModuleIndex;
-	};
-
-LOCAL_C TInt secondaryThread(TAny* aTestInfo)
-	{
-	RTest stest(_L("Secondary test camera thread"));
-	stest.Title();
-
-	stest.Start(_L("Check which test to perform"));
-	SSecondaryThreadInfo sti =*((SSecondaryThreadInfo*)aTestInfo);
-	
-	TInt r;
-	switch(sti.iTestId)
-		{
-		case ESecThreadTestOpen:
-			{
-			stest.Next(_L("Open channel test"));
-			RDevCameraSc cam;
-			r=cam.Open(sti.iCameraModuleIndex);
-			stest(r==sti.iExpectedRetVal);
-			cam.Close();
-			break;
-			}
-		case ESecThreadTestDuplicateHandle:
-			{
-			stest.Next(_L("Duplicate channel handle test"));
-
-			// Get a reference to the main thread - which created the handle
-			RThread thread;
-			r=thread.Open(sti.iThreadId);
-			stest(r==KErrNone);
-
-			// Duplicate the driver handle passed from the other thread - for this thread
-			RDevCameraSc cam;
-			cam.SetHandle(sti.iDrvHandle);
-			r=cam.Duplicate(thread);
-			stest(r==sti.iExpectedRetVal);
-			cam.Close();
-			thread.Close();
-			break;
-			}
-		case ESecThreadReuseHandle:
-			{
-			stest.Next(_L("Re-use channel test"));
-			RDevCameraSc* camPtr=(RDevCameraSc*)sti.iDrvHandle;
-			TCameraConfigV02Buf camConfBuf;
-			camPtr->GetCamConfig(ECamCaptureModeImage, camConfBuf);	// This should cause a panic.
-			break;
-			}
-		default:
-			break;
-		}
-
-	stest.End();
-	return(KErrNone);
-	}
-
-/** Test for defect DEF135950. */
-LOCAL_C void DoCamDynamicSettingsTests(RDevCameraSc& aCam, RTest& aTest)
-	{
-	aTest.Next(_L("DYNAMIC SETTINGS TESTS"));
-	
-	aTest.Next(_L("Get the Caps size. Should be non-zero"));
-	TInt capsSize = aCam.CapsSize();
-	aTest(capsSize>0);
-
-	aTest.Next(_L("Get the Capabilities (driver owned copy)."));
-	TPtrC8 driverCopy = aCam.Caps();
-	aTest(driverCopy.Ptr() != NULL);
-	aTest(driverCopy.Length()>0);
-
-	aTest.Next(_L("Test failure (buffer too small)."));
-	TAny* capsBufPtr = User::Alloc(capsSize-1);
-	aTest(capsBufPtr != NULL);
-	TPtr8 smallBuf((TUint8*) capsBufPtr, capsSize-1, capsSize-1);
-	aTest(KErrArgument==aCam.Caps(smallBuf));
-	User::Free(capsBufPtr);
-
-	aTest.Next(_L("Get the Capabilities (client owned copy)."));
-	capsBufPtr = User::Alloc(capsSize);
-	aTest(capsBufPtr != NULL);
-	TPtr8 clientCopy((TUint8*) capsBufPtr, capsSize, capsSize);
-	aTest(KErrNone==aCam.Caps(clientCopy));
-	aTest(clientCopy.Ptr() != NULL);
-	aTest(clientCopy.Length()>0);
-
-	aTest.Next(_L("Obtain the range for Dynamic Settings from both copies (should be the same)."));
-	
-	TDynamicRange &driverRangeBrightness = ((TCameraCapsV02*)(driverCopy.Ptr()))->iDynamicRange[ECamAttributeBrightness];
-	TDynamicRange &clientRangeBrightness = ((TCameraCapsV02*)(clientCopy.Ptr()))->iDynamicRange[ECamAttributeBrightness];
-	
-	aTest(driverRangeBrightness.iMin == 0);
-	aTest(driverRangeBrightness.iMax == 6);
-	aTest(driverRangeBrightness.iMin == clientRangeBrightness.iMin);
-	aTest(driverRangeBrightness.iMax == clientRangeBrightness.iMax);
-
-	TDynamicRange &driverRangeContrast = ((TCameraCapsV02*)(driverCopy.Ptr()))->iDynamicRange[ECamAttributeContrast];
-	TDynamicRange &clientRangeContrast = ((TCameraCapsV02*)(clientCopy.Ptr()))->iDynamicRange[ECamAttributeContrast];
-
-	aTest(driverRangeContrast.iMin == 0);
-	aTest(driverRangeContrast.iMax == 6);
-	aTest(driverRangeContrast.iMin == clientRangeContrast.iMin);
-	aTest(driverRangeContrast.iMax == clientRangeContrast.iMax);
-	
-	TDynamicRange &driverRangeColorEffect = ((TCameraCapsV02*)(driverCopy.Ptr()))->iDynamicRange[ECamAttributeColorEffect];
-	TDynamicRange &clientRangeColorEffect = ((TCameraCapsV02*)(clientCopy.Ptr()))->iDynamicRange[ECamAttributeColorEffect];
-
-	aTest(driverRangeColorEffect.iMin == 0);
-	aTest(driverRangeColorEffect.iMax == 7); // TBC::OV3640 set to 7, template driver set to 0x0040 (enum)
-	aTest(driverRangeColorEffect.iMin == clientRangeColorEffect.iMin);
-	aTest(driverRangeColorEffect.iMax == clientRangeColorEffect.iMax);
-
-	aTest.Next(_L("Test for invalid Min range."));
-	aTest(aCam.SetDynamicAttribute(ECamAttributeBrightness, driverRangeBrightness.iMin-1)==KErrArgument);
-	aTest(aCam.SetDynamicAttribute(ECamAttributeContrast, driverRangeContrast.iMin-1)==KErrArgument);
-	aTest(aCam.SetDynamicAttribute(ECamAttributeColorEffect, driverRangeColorEffect.iMin-1)==KErrArgument);
-
-	aTest.Next(_L("Test for invalid Max range."));
-	aTest(aCam.SetDynamicAttribute(ECamAttributeBrightness, driverRangeBrightness.iMax+1)==KErrArgument);
-	aTest(aCam.SetDynamicAttribute(ECamAttributeContrast, driverRangeContrast.iMax+1)==KErrArgument);
-	aTest(aCam.SetDynamicAttribute(ECamAttributeColorEffect, driverRangeColorEffect.iMax+1)==KErrArgument);
-
-	aTest.Next(_L("Test all valid settings as reported by range - Brightness"));
-	for (TUint i=driverRangeBrightness.iMin; i <= driverRangeBrightness.iMax; ++i)
-		{
-		aTest(aCam.SetDynamicAttribute(ECamAttributeBrightness, i)==KErrNone);
-		}
-
-	aTest.Next(_L("Test all valid settings as reported by range - Contrast"));
-	for (TUint j=driverRangeContrast.iMin; j <= driverRangeContrast.iMax; ++j)
-		{
-		aTest(aCam.SetDynamicAttribute(ECamAttributeContrast, j)==KErrNone);
-		}
-
-	aTest.Next(_L("Test all valid settings as reported by range - ColorEffect"));
-	for (TUint k=driverRangeColorEffect.iMin; k <= driverRangeColorEffect.iMax; ++k)
-		{
-		aTest(aCam.SetDynamicAttribute(ECamAttributeColorEffect, k)==KErrNone);
-		}
-
-	User::Free(capsBufPtr);
-	}
-
-/** Test for defect DEF135949. */
-LOCAL_C void DoCamBufferOffsetTests(RDevCameraSc& aCam, RTest& aTest, const SDevCamPixelFormat& aPixelFormat, const SDevCamFrameSize& aFrameSize, TUint aFrameRate)
-	{
-	TInt r;
-
-	aTest.Next(_L("BUFFER ID OFFSET TESTS"));
-	aTest.Printf(_L("PixelFormat = %d, FrameSize = %d x %d\n"),aPixelFormat.iPixelFormat,aFrameSize.iWidth,aFrameSize.iHeight);
-
-	// Configure Image Capture
-	aTest.Next(_L("Get the camera config of Image mode"));
-	TCameraConfigV02Buf camConfBuf;
-	aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
-	TCameraConfigV02 &camConf=camConfBuf();
-
-	camConf.iFrameSize=aFrameSize;
-	camConf.iPixelFormat=aPixelFormat;
-	camConf.iFrameRate=aFrameRate;
-
-	// Set the Image configuration.
-	aTest.Next(_L("Set the Get the camera config of Image mode"));
-	r=aCam.SetCamConfig(ECamCaptureModeImage,camConfBuf);
-	aTest(r==KErrNone);
-	aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
-	PrintCamConf(camConf,aTest);
-
-	// Create an Image chunk handle.
-	aTest.Next(_L("Create the Image chunk"));
-	RChunk imgChunkImage;
-	TInt numBuffers=KNumVideoFramesToAllocate;
-	r=aCam.SetBufConfigChunkCreate(ECamCaptureModeImage,numBuffers,imgChunkImage);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Read and display the Image buffer config"));
-	TMmSharedChunkBufConfig bufferConfig;
-	TPckg<TMmSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
-	aCam.GetBufferConfig(ECamCaptureModeImage, bufferConfigBuf);
-	PrintBufferConf(bufferConfig,aTest);
-
-	// Configure Video Capture
-	aTest.Next(_L("Get the camera config of Video mode"));
-	aCam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
-	camConf=camConfBuf();
-
-	camConf.iFrameSize=aFrameSize;
-	camConf.iPixelFormat=aPixelFormat;
-	camConf.iFrameRate=aFrameRate;
-
-	// Set the video configuration.
-	aTest.Next(_L("Set the Get the camera config of Video mode"));
-	r=aCam.SetCamConfig(ECamCaptureModeVideo,camConfBuf);
-	aTest(r==KErrNone);
-	aCam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
-	PrintCamConf(camConf,aTest);
-
-	// Create an Video chunk handle.
-	aTest.Next(_L("Create the Video chunk"));
-	RChunk chunkVideo;
-	numBuffers=KNumVideoFramesToAllocate;
-	r=aCam.SetBufConfigChunkCreate(ECamCaptureModeVideo,numBuffers,chunkVideo);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Read and display the Video buffer config"));
-	aCam.GetBufferConfig(ECamCaptureModeVideo, bufferConfigBuf);
-	PrintBufferConf(bufferConfig,aTest);
-
-	// Test that stop still returns an error.
-	r=aCam.Stop();
-	aTest(r==KErrGeneral);
-
-	// Set the current capture mode to image
-	aTest.Next(_L("Set the camera in Image mode and capture a buffer, then requesting the buffer offset."));
-	r=aCam.SetCaptureMode(ECamCaptureModeImage);
-	aTest(r==KErrNone);
-
-	// Start the camera
-	r=aCam.Start();
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Issue a capture request"));
-	TRequestStatus rs1;
-	aCam.NotifyNewImage(rs1);
-	User::WaitForRequest(rs1);
-	TInt retId=rs1.Int();
-	TInt retOffset=-1;
-	aTest(retId>=0);
-	aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
-	aTest.Printf(_L("Buffer offset: %d(%xH)\r\n"),retId,retOffset);
-	aTest(retOffset>=0);
-
-	// Change capture mode
-	aTest.Next(_L("Set the capture mode to Video."));
-	r=aCam.SetCaptureMode(ECamCaptureModeVideo);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Request again the offset for the buffer in Image mode."));
-	aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
-	aTest.Printf(_L("Buffer offset: %d(%xH)\r\n"),retId,retOffset);
-	aTest(retOffset>=0);
-
-	// Stop the camera.
-	r=aCam.Stop();
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Close the chunk"));
-	r=aCam.ChunkClose(ECamCaptureModeImage);
-	aTest(r==KErrNone);
-	r=aCam.ChunkClose(ECamCaptureModeVideo);
-	aTest(r==KErrNone);
-	}
-
-
-LOCAL_C void DoCamOpenCapTests(RTest& aTest,TInt aCameraSensorIndex)
-	{
-	TInt r;
-
-	// Open the camera driver to obtain the basic capabilities for use throughout the tests and
-	// then close it again so that it may be confirmed that opening multiple times is ok
-	aTest.Next(_L("CHANNEL OPEN AND CAPABILITIES TESTS"));
-	RDevCameraSc cam;
-	aTest.Next(_L("Open a channel on the camera driver"));
-	r=cam.Open(aCameraSensorIndex);
-	aTest(r==KErrNone);
-
-	// Make sure that the driver can handle attempts to start it before it has been configured
-	aTest.Next(_L("Try to start/stop camera before its configured"));
-	r=cam.Start();
-	aTest(r==KErrNotReady);
-	r=cam.Stop();
-	aTest(r==KErrGeneral);
-
-	aTest.Next(_L("Read the capabilities structure size of this device"));
-	CapsSize=cam.CapsSize();
-	aTest.Next(_L("Read and display the capabilities of this device"));
-	CapsBufPtr = User::Alloc(CapsSize);
-	TPtr8 capsPtr( (TUint8*)CapsBufPtr, CapsSize, CapsSize );
-	r=cam.Caps(capsPtr);
-	aTest(r==KErrNone);
-	CameraCaps = (TCameraCapsV02*) capsPtr.Ptr();
-	PrintCamModes(CameraCaps,aTest);
-
-	TAny* frameSizeCapsBuf;
-	SDevCamPixelFormat* pixelFormat;
-	TBuf<80> buf;
-	SDevCamFrameSize* frameSize;
-	TPtr8 frameSizeCapsPtr(0,0,0);
-	TUint fsCount, pfCount, theCount = 0;
-
-	/* IMAGE */
-	/* Use pixel formats from 0 to CapsBuf->iNumImagePixelFormats */
-	buf.Zero();
-	buf.Append(KCaptureModeImage);
-	buf.Append(_L("\r\n"));
-	aTest.Printf(buf);
-	pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
-	for (pfCount = theCount; pfCount < CameraCaps->iNumImagePixelFormats; pfCount++)
-		{
-		buf.Zero();
-		AppendPixelFormat(buf, pixelFormat->iPixelFormat);
-		aTest.Printf(buf);
-		frameSizeCapsBuf = User::Alloc(pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		new (&frameSizeCapsPtr) TPtr8((TUint8*)frameSizeCapsBuf, pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize), pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		r=cam.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizeCapsPtr);
-		aTest(r==KErrNone);
-		frameSize = (SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
-		for (fsCount = 0; fsCount < pixelFormat->iNumFrameSizes; fsCount++)
-			{
-			aTest.Printf(_L("%dx%d "),frameSize->iWidth,frameSize->iHeight);
-			frameSize++;
-			}
-		aTest.Printf(_L("\n"));
-		User::Free(frameSizeCapsBuf);
-		pixelFormat++;
-		}
-
-	/* VIDEO */
-	buf.Zero();
-	buf.Append(KCaptureModeVideo);
-	buf.Append(_L("\r\n"));
-	aTest.Printf(buf);
-	pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
-	pixelFormat += CameraCaps->iNumImagePixelFormats;
-	theCount = CameraCaps->iNumImagePixelFormats + CameraCaps->iNumVideoPixelFormats;
-	for (pfCount = CameraCaps->iNumImagePixelFormats; pfCount < theCount; pfCount++)
-		{
-		buf.Zero();
-		AppendPixelFormat(buf, pixelFormat->iPixelFormat);
-		aTest.Printf(buf);
-		frameSizeCapsBuf = User::Alloc(pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		new (&frameSizeCapsPtr) TPtr8((TUint8*)frameSizeCapsBuf, pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize), pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		r=cam.FrameSizeCaps(ECamCaptureModeVideo, pixelFormat->iPixelFormat, frameSizeCapsPtr);
-		aTest(r==KErrNone);
-		frameSize = (SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
-		for (fsCount = 0; fsCount < pixelFormat->iNumFrameSizes; fsCount++)
-			{
-			aTest.Printf(_L("%dx%d "),frameSize->iWidth,frameSize->iHeight);
-			frameSize++;
-			}
-		aTest.Printf(_L("\n"));
-		User::Free(frameSizeCapsBuf);
-		pixelFormat++;
-		}
-
-	/* VIEW FINDER */
-	buf.Zero();
-	buf.Append(KCaptureModeViewFinder);
-	buf.Append(_L("\r\n"));
-	aTest.Printf(buf);
-	pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
-	pixelFormat += (CameraCaps->iNumImagePixelFormats + CameraCaps->iNumVideoPixelFormats);
-	theCount = CameraCaps->iNumImagePixelFormats + CameraCaps->iNumVideoPixelFormats + CameraCaps->iNumViewFinderPixelFormats;
-	for (pfCount = CameraCaps->iNumImagePixelFormats + CameraCaps->iNumVideoPixelFormats; pfCount < theCount; pfCount++)
-		{
-		buf.Zero();
-		AppendPixelFormat(buf, pixelFormat->iPixelFormat);
-		aTest.Printf(buf);
-		frameSizeCapsBuf = User::Alloc(pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		new (&frameSizeCapsPtr) TPtr8((TUint8*)frameSizeCapsBuf, pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize), pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		r=cam.FrameSizeCaps(ECamCaptureModeViewFinder, pixelFormat->iPixelFormat, frameSizeCapsPtr);
-		aTest(r==KErrNone);
-		frameSize = (SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
-		for (fsCount = 0; fsCount < pixelFormat->iNumFrameSizes; fsCount++)
-			{
-			aTest.Printf(_L("%dx%d "),frameSize->iWidth,frameSize->iHeight);
-			frameSize++;
-			}
-		aTest.Printf(_L("\n"));
-		User::Free(frameSizeCapsBuf);
-		pixelFormat++;
-		}
-
-	aTest.Next(_L("Try opening the same unit a second time."));
-	RDevCameraSc cam2;
-	r=cam2.Open(aCameraSensorIndex);
-	aTest(r==KErrInUse);
-
-	aTest.Next(_L("Open a channel from the 2nd thread without closing the 1st"));
-	RThread thread;
-	TRequestStatus stat;
-	SSecondaryThreadInfo sti;
-
-	// Setup the 2nd thread to open a channel on the same unit
-	sti.iTestId=ESecThreadTestOpen;
-	sti.iExpectedRetVal=KErrInUse;
-	sti.iCameraModuleIndex=aCameraSensorIndex;
-	r=thread.Create(_L("Thread"),secondaryThread,KDefaultStackSize,KHeapSize,KHeapSize,&sti);
-	Test(r==KErrNone);
-	thread.Logon(stat);
-	thread.Resume();
-	User::WaitForRequest(stat);
-	Test(stat.Int()==KErrNone);
-	Test(thread.ExitType()==EExitKill);
-	thread.Close();
-	User::After(10000);	// Wait 10ms
-
-	aTest.Next(_L("Open a channel from the 2nd thread having closed the 1st"));
-	cam.Close();		// Close the 1st channel
-	sti.iTestId=ESecThreadTestOpen;
-	sti.iExpectedRetVal=KErrNone;
-	r=thread.Create(_L("Thread02"),secondaryThread,KDefaultStackSize,KHeapSize,KHeapSize,&sti);
-	Test(r==KErrNone);
-	thread.Logon(stat);
-	thread.Resume();
-	User::WaitForRequest(stat);
-	Test(stat.Int()==KErrNone);
-	Test(thread.ExitType()==EExitKill);
-	thread.Close();
-	User::After(10000);	// Wait 10ms
-
-	aTest.Next(_L("Re-open channel and duplicate it from 2nd thread"));
-	r=cam.Open(aCameraSensorIndex);		// Re-open the channel
-	aTest(r==KErrNone);
-	sti.iTestId=ESecThreadTestDuplicateHandle;
-	sti.iExpectedRetVal=KErrAccessDenied;
-	sti.iThreadId=RThread().Id();	// Get the ID of this thread
-	sti.iDrvHandle=cam.Handle();	// Pass the channel handle
-
-	r=thread.Create(_L("Thread03"),secondaryThread,KDefaultStackSize,KHeapSize,KHeapSize,&sti); // Create secondary thread
-	Test(r==KErrNone);
-	thread.Logon(stat);
-	thread.Resume();
-	User::WaitForRequest(stat);
-	Test(stat.Int()==KErrNone);
-	Test(thread.ExitType()==EExitKill);
-	thread.Close();
-	User::After(10000);	// Wait 10ms
-
-	aTest.Next(_L("Re-use the same channel from 2nd thread"));
-	sti.iTestId=ESecThreadReuseHandle;
-	sti.iDrvHandle=(TInt)&cam;	// Pass a pointer to the channel
-	r=thread.Create(_L("Thread04"),secondaryThread,KDefaultStackSize,KHeapSize,KHeapSize,&sti); // Create secondary thread
-	Test(r==KErrNone);
-	thread.Logon(stat);
-	thread.Resume();
-	User::WaitForRequest(stat);
-	TExitCategoryName exitCategoryName = thread.ExitCategory();
-	Test.Printf(_L("Thread exit info: Cat:%S, Reason:%x, Type:%d\r\n"),&exitCategoryName,thread.ExitReason(),thread.ExitType());
-	Test(thread.ExitType()==EExitPanic);	// Secondary thread is expected to panic
-	Test(stat.Int()==KErrNone);
-	thread.Close();
-	User::After(10000);	// Wait 10ms
-
-	cam.Close();
-	}
-
-LOCAL_C void DoCamConfigTests(RDevCameraSc& aCam, RTest& aTest, TDevCamCaptureMode aCaptureMode, const SDevCamPixelFormat& aPixelFormat, const SDevCamFrameSize& aFrameSize)
-	{
-	TInt r;
-
-	aTest.Next(_L("GETTING & SETTING CONFIG TESTS"));
-	aTest.Printf(_L("CaptureMode = %d, PixelFormat = %x, FrameSize = %d x %d\n"),aCaptureMode,aPixelFormat.iPixelFormat,aFrameSize.iWidth,aFrameSize.iHeight);
-
-	aTest.Next(_L("Read and display the default camera config for requested capture mode"));
-	TCameraConfigV02Buf camConfBuf;
-	aCam.GetCamConfig(aCaptureMode, camConfBuf);
-	TCameraConfigV02 &camConf=camConfBuf();
-	PrintCamConf(camConf,aTest);
-
-	aTest.Next(_L("Read and display the default buffer config for requested capture mode"));
-	TMmSharedChunkBufConfig bufferConfig;
-	TPckg<TMmSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
-	aCam.GetBufferConfig(aCaptureMode, bufferConfigBuf);
-	PrintBufferConf(bufferConfig,aTest);
-
-	aTest.Next(_L("Setup the config - creating a chunk"));
-	camConf.iFrameSize=aFrameSize;
-	camConf.iPixelFormat=aPixelFormat;
-	camConf.iFrameRate=aFrameSize.iMaxFrameRate;
-	r=aCam.SetCamConfig(aCaptureMode, camConfBuf);
-	aTest(r==KErrNone);
-	RChunk chunk;
-	r=aCam.SetBufConfigChunkCreate(aCaptureMode, KNumVideoFramesToAllocate, chunk);
-	aTest(r==KErrNone);
-	aCam.GetCamConfig(aCaptureMode, camConfBuf);
-	PrintCamConf(camConf,aTest);
-
-	aTest.Next(_L("Read and display the resulting buffer config"));
-	aCam.GetBufferConfig(aCaptureMode, bufferConfigBuf);
-	PrintBufferConf(bufferConfig,aTest);
-
-	aTest.Next(_L("Close the chunk created"));
-	chunk.Close();
-
-	aTest.Next(_L("Open a channel on the test driver"));
-	RMmCreateSc tstDrv;
-	r=tstDrv.Open();		// Opening the channel results in the creation of a shared chunk.
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Get a handle on its shared chunk"));
-	r=tstDrv.GetChunkHandle(chunk);	// Get a handle on the shared chunk created by the test driver
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Read and display the buffer config"));
-	TMmSharedChunkBufConfig bufferConfigTest;
-	TPckg<TMmSharedChunkBufConfig> bufferConfigBufTest(bufferConfigTest);
-
-	// Get info on the buffers within the shared chunk
-	aTest.Next(_L("Get info. on the shared chunk"));
-	r=tstDrv.GetBufInfo(bufferConfigBufTest);
-	aTest(r==KErrNone);
-
-	PrintBufferConf(bufferConfigTest,aTest);
-	aTest.Next(_L("Setup the config - supplying a chunk"));
-	r=aCam.SetBufConfigChunkOpen(aCaptureMode, bufferConfigBufTest, chunk);
-	aTest(r==KErrNone);
-	aCam.GetCamConfig(aCaptureMode, camConfBuf);
-	PrintCamConf(camConf,aTest);
-	aCam.GetBufferConfig(aCaptureMode, bufferConfigBufTest);
-	PrintBufferConf(bufferConfigTest,aTest);
-
-	aTest.Next(_L("Close the chunk driver and the 2nd chunk"));
-	tstDrv.Close();
-	chunk.Close();
-	}
-
-LOCAL_C void DoCamVideoCaptureTests(RDevCameraSc& aCam, RTest& aTest, TDevCamCaptureMode aCaptureMode, const SDevCamPixelFormat& aPixelFormat, const SDevCamFrameSize& aFrameSize, TUint aFrameRate)
-	{
-	TInt r;
-
-	aTest.Next(_L("VIDEO CAPTURE TESTS"));
-	aTest.Printf(_L("CaptureMode = %d, PixelFormat = %x, FrameSize = %d x %d\n"),aCaptureMode,aPixelFormat.iPixelFormat,aFrameSize.iWidth,aFrameSize.iHeight);
-
-	// Configure Video or Viewfinder Capture
-	TCameraConfigV02Buf camConfBuf;
-	aCam.GetCamConfig(aCaptureMode, camConfBuf);
-	TCameraConfigV02 &camConf=camConfBuf();
-
-	camConf.iFrameSize=aFrameSize;
-	camConf.iPixelFormat=aPixelFormat;
-	camConf.iFrameRate=aFrameRate;
-
-	// Set the camera configuration.
-	r=aCam.SetCamConfig(aCaptureMode,camConfBuf);
-	aTest(r==KErrNone);
-	aCam.GetCamConfig(aCaptureMode, camConfBuf);
-	PrintCamConf(camConf,aTest);
-
-	// Create a chunk handle and trigger the buffer creation.
-	aTest.Next(_L("Setup the config - creating a chunk"));
-	RChunk chunkVideo;
-	TInt numBuffers=KNumVideoFramesToAllocate;
-	r=aCam.SetBufConfigChunkCreate(aCaptureMode,numBuffers,chunkVideo);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Read and display the resulting buffer config"));
-	TMmSharedChunkBufConfig bufferConfig;
-	TPckg<TMmSharedChunkBufConfig> bufferConfigBufVideo(bufferConfig);
-	aCam.GetBufferConfig(aCaptureMode, bufferConfigBufVideo);
-	PrintBufferConf(bufferConfig,aTest);
-
-	// Request and print the camera and buffer configurations for all three capture modes
-	aTest.Next(_L("Read and display the camera configs"));
-	aCam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
-	PrintCamConf(camConf,aTest);
-	aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
-	PrintCamConf(camConf,aTest);
-	aCam.GetCamConfig(ECamCaptureModeViewFinder, camConfBuf);
-	PrintCamConf(camConf,aTest);
-
-	// Create and configure a display handler
-	TCamDisplayHandler dispHand;
-	r=dispHand.Init();
-	aTest(r==KErrNone);
-
-	if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-		{
-		r=dispHand.SetConfig(aFrameSize,aPixelFormat);
-		aTest(r==KErrNone);
-		}
-
-	// Test that stop still returns an error.
-	r=aCam.Stop();
-	aTest(r==KErrGeneral);
-
-	// Set the current capture mode
-	r=aCam.SetCaptureMode(aCaptureMode);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Start the camera in video mode"));
-	r=aCam.Start();
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Issue capture requests"));
-	aTest.Printf(_L("Request %d frames\r\n"),KNumVideoFramesToCapture);
-	// Issue new image requests immediately. We'll have to wait while the
-	// camera captures the images.
-	TRequestStatus rs[KNumVideoFramesToCapture];
-	TInt i;
-	for (i=0 ; i<KNumVideoFramesToCapture; i++)
-		{
-		aTest.Printf(_L("Requesting new image... %d\n"), i);
-		aCam.NotifyNewImage(rs[i]);
-		aTest.Printf(_L("Requested new image... %d\n"), i);
-		}
-
-	TInt retId=-1;
-	TInt retOffset=-1;
-	for (i=0 ; i<KNumVideoFramesToCapture; i++)
-		{
-		aTest.Printf(_L("Waiting for... %d\n"), i);
-		User::WaitForRequest(rs[i]);
-		retId=rs[i].Int();
-		aTest(retId>=0);
-		aTest.Printf(_L("Getting buffer offset for... %d\n"), i);
-		aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
-		aTest.Printf(_L("Buffer%d(id:%d) offset: %d(%xH)\r\n"),i,retId,retOffset,retOffset);
-		aTest(retOffset>=0);
-		}
-
-	TUint8* imgBase;
-
-	// Display each image received for 333ms
-	for (i=0 ; i<KNumVideoFramesToCapture; i++)
-		{
-		if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-			{
-			retId=rs[i].Int();
-			aTest(retId>=0);
-			aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
-			aTest(retOffset>=0);
-			imgBase=chunkVideo.Base()+retOffset;
-			r=dispHand.Process(imgBase);
-			
-#ifdef __WINSCW__
-			aTest(r==KErrNotSupported);
-#else
-			aTest(r==KErrNone);
-#endif
-
-			User::After(333000);	// 0.33sec
-			}
-		}
-
-	aTest.Next(_L("Free the buffers"));
-	for (i=0 ; i<KNumVideoFramesToCapture; i++)
-		{
-		aTest.Printf(_L("Releasing %d(i:%d) "),rs[i].Int(), i);
-		r=aCam.ReleaseBuffer(rs[i].Int());
-		aTest.Printf(_L("buffer(%d), r=%d\n"),rs[i].Int(),r);
-		aTest(r==KErrNone);
-		}
-
-	aTest.Next(_L("Issue more capture requests"));
-	// Wait a bit more so camera has images ready as soon as we issue the requests
-	User::After(500000);	// 0.5sec
-
-	aTest.Printf(_L("Request %d frames\r\n"),KNumVideoFramesToCapture);
-	for (i=0 ; i<KNumVideoFramesToCapture; i++)
-		aCam.NotifyNewImage(rs[i]);
-
-	for (i=0 ; i<KNumVideoFramesToCapture; i++)
-		{
-		User::WaitForRequest(rs[i]);
-		retId=rs[i].Int();
-		aTest(retId>=0);
-		aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
-		aTest.Printf(_L("Buffer%d(id:%d) offset: %d(%xH)\r\n"),i,retId,retOffset,retOffset);
-		aTest(retOffset>=0);
-		}
-
-	aTest.Next(_L("Stop the camera."));
-	r=aCam.Stop();
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Start it again."));
-	r=aCam.Start();
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Continuously display for 10 secs"));
-	RTimer tim;
-	tim.CreateLocal();
-	TRequestStatus timStatus;
-	const TUint KTimeOut=10000000;	// 10 seconds
-	tim.After(timStatus,KTimeOut);
-	aTest(timStatus==KRequestPending);
-	aCam.NotifyNewImage(rs[0]);
-	aCam.NotifyNewImage(rs[1]);
-	FOREVER
-		{
-		User::WaitForAnyRequest();
-		if (timStatus!=KRequestPending)
-			{
-			aCam.NotifyNewImageCancel();
-			User::WaitForRequest(rs[0]);
-			User::WaitForRequest(rs[1]);
-			break;
-			}
-		else if (rs[0]!=KRequestPending)
-			{
-			retId=rs[0].Int();
-			aTest(retId>=0);
-			aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
-			aTest(retOffset>=0);
-			imgBase=chunkVideo.Base()+retOffset;
-			if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-				{
-				r=dispHand.Process(imgBase);
-				
-#ifdef __WINSCW__
-				aTest(r==KErrNotSupported);
-#else
-				aTest(r==KErrNone);
-#endif
-				
-				}
-			r=aCam.ReleaseBuffer(retId);
-			aTest(r==KErrNone);
-			aCam.NotifyNewImage(rs[0]);
-			}
-		else if (rs[1]!=KRequestPending)
-			{
-			retId=rs[1].Int();
-			aTest(retId>=0);
-			aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
-			aTest(retOffset>=0);
-			imgBase=chunkVideo.Base()+retOffset;
-			if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-				{
-				r=dispHand.Process(imgBase);
-				
-#ifdef __WINSCW__
-				aTest(r==KErrNotSupported);
-#else
-				aTest(r==KErrNone);
-#endif
-				
-				}
-			r=aCam.ReleaseBuffer(retId);
-			aTest(r==KErrNone);
-			aCam.NotifyNewImage(rs[1]);
-			}
-		else
-			aTest(0);
-		}
-
-	tim.Close();
-
-	aTest.Next(_L("Stop the camera."));
-	r=aCam.Stop();
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Close the chunk"));
-	r=aCam.ChunkClose(aCaptureMode);
-	}
-
-LOCAL_C void DoCamImageCaptureTests(RDevCameraSc& aCam, RTest& aTest, TInt aCameraSensorIndex, const SDevCamPixelFormat& aPixelFormat, const SDevCamFrameSize& aFrameSize, TUint aFrameRate)
-	{
-	TInt r;
-
-	aTest.Next(_L("IMAGE CAPTURE TESTS"));
-	aTest.Printf(_L("PixelFormat = %d, FrameSize = %d x %d\n"),aPixelFormat.iPixelFormat,aFrameSize.iWidth,aFrameSize.iHeight);
-
-	// Configure Image Capture
-	TCameraConfigV02Buf camConfBuf;
-	aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
-	TCameraConfigV02 &camConf=camConfBuf();
-
-	camConf.iFrameSize=aFrameSize;
-	camConf.iPixelFormat=aPixelFormat;
-	camConf.iFrameRate=aFrameRate;
-
-	// Set the camera configuration.
-	r=aCam.SetCamConfig(ECamCaptureModeImage,camConfBuf);
-	aTest(r==KErrNone);
-	aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
-	PrintCamConf(camConf,aTest);
-
-	// Create a chunk handle and trigger the buffer creation.
-	aTest.Next(_L("Setup the config - creating a chunk"));
-	RChunk chunkImage;
-	TInt numBuffers=KNumVideoFramesToAllocate;
-	r=aCam.SetBufConfigChunkCreate(ECamCaptureModeImage,numBuffers,chunkImage);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Read and display the resulting buffer config"));
-	TMmSharedChunkBufConfig bufferConfig;
-	TPckg<TMmSharedChunkBufConfig> bufferConfigBufImage(bufferConfig);
-	aCam.GetBufferConfig(ECamCaptureModeImage, bufferConfigBufImage);
-	PrintBufferConf(bufferConfig,aTest);
-
-	// Create and configure a display handler
-	TCamDisplayHandler dispHand;
-	r=dispHand.Init();
-	aTest(r==KErrNone);
-
-	if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-		{
-		r=dispHand.SetConfig(aFrameSize,aPixelFormat);
-		aTest(r==KErrNone);
-		}
-
-	// Test that stop still returns an error.
-	r=aCam.Stop();
-	aTest(r==KErrGeneral);
-
-	// Set the current capture mode
-	r=aCam.SetCaptureMode(ECamCaptureModeImage);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Start the camera in image capture mode"));
-	r=aCam.Start();
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Issue a capture request"));
-	TRequestStatus rs1;
-	aCam.NotifyNewImage(rs1);
-	User::WaitForRequest(rs1);
-	TInt retId=rs1.Int();
-	TInt retOffset=-1;
-	aTest(retId>=0);
-	aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
-	aTest.Printf(_L("Buffer offset: %d(%xH)\r\n"),retId,retOffset);
-	aTest(retOffset>=0);
-
-	TUint8* imgBase;
-	imgBase=chunkImage.Base()+retOffset;
-
-	if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-		{
-		// Display the image received for 1s
-		r=dispHand.Process(imgBase);
-		
-#ifdef __WINSCW__
-        aTest(r==KErrNotSupported);
-#else
-        aTest(r==KErrNone);
-#endif
-        
-		User::After(1000000);	// 1 sec
-		}
-
-	// Save the to do MMC card with a filename to indicate its size.  If no MMC card is present
-	// then we will just display a warning rather than fail as this is an optional manual step
-	TBuf<100> fileName(KSensor);
-	fileName.AppendNum(aCameraSensorIndex);
-	fileName.Append(KUnderscore);
-	fileName.AppendFormat(KFrameSize, aFrameSize.iWidth, aFrameSize.iHeight);
-	fileName.Append(KUnderscore);
-	AppendPixelFormat(fileName, aPixelFormat.iPixelFormat);
-
-	TBool wrote = ETrue;
-	RBitmap bitmap;
-
-	if ((aPixelFormat.iPixelFormat == EUidPixelFormatJPEG) || (aPixelFormat.iPixelFormat == EUidPixelFormatSpeedTaggedJPEG))
-		{
-		fileName.Append((aPixelFormat.iPixelFormat == EUidPixelFormatJPEG) ? KJpeg : KSpeedTaggedJpeg);
-		r=bitmap.WriteBuffer(fileName, imgBase, (aFrameSize.iWidth * aFrameSize.iHeight * aPixelFormat.iPixelWidthInBytes));
-		}
-	else if ((aPixelFormat.iPixelFormat == EUidPixelFormatYUV_422Interleaved) || (aPixelFormat.iPixelFormat == EUidPixelFormatRGB_565))
-		{
-		fileName.Append(KBmp);
-		r=bitmap.WriteBMP(fileName, imgBase, aPixelFormat, aFrameSize.iWidth, aFrameSize.iHeight);
-		}
-	else
-		{
-		wrote = EFalse;
-		}
-
-	if (wrote)
-		{
-		if (r==KErrNone)
-			{
-			aTest.Printf(_L("Wrote image to %S\n"),&fileName);
-			}
-		else
-			{
-			aTest.Printf(_L("Warning: Unable to write %S (error = %d)\r\n"),&fileName,r);
-			}
-		}
-
-	aTest.Next(_L("Free the buffer"));
-	r=aCam.ReleaseBuffer(retId);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Issue two consecutive capture requests"));
-	TRequestStatus rs2;
-	aCam.NotifyNewImage(rs1);
-	aCam.NotifyNewImage(rs2);
-
-	User::WaitForRequest(rs1);
-	retId=rs1.Int();
-	aTest(retId>=0);
-	aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
-	aTest.Printf(_L("Buffer0 offset: %d(%xH)\r\n"),retOffset,retOffset);
-	aTest(retOffset>=0);
-
-	if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-		{
-		// Display the image received for 1s
-		imgBase=chunkImage.Base()+retOffset;
-		r=dispHand.Process(imgBase);
-		
-#ifdef __WINSCW__
-        aTest(r==KErrNotSupported);
-#else
-        aTest(r==KErrNone);
-#endif
-        
-		User::After(1000000);	// 1 sec
-		}
-
-	r=aCam.ReleaseBuffer(retId);
-	aTest(r==KErrNone);
-
-	User::WaitForRequest(rs2);
-	retId=rs2.Int();
-	aTest(retId>=0);
-	aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
-	aTest.Printf(_L("Buffer1 offset: %d(%xH)\r\n"),retOffset,retOffset);
-	aTest(retOffset>=0);
-
-	if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-		{
-		// Display the image received for 1s
-		imgBase=chunkImage.Base()+retOffset;
-		r=dispHand.Process(imgBase);
-		
-#ifdef __WINSCW__
-        aTest(r==KErrNotSupported);
-#else
-        aTest(r==KErrNone);
-#endif
-        
-		User::After(1000000);	// 1 sec
-		}
-
-	r=aCam.ReleaseBuffer(retId);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Issue four more separate capture requests"));
-	for (TInt i=0 ; i<4 ; i++)
-		{
-		aCam.NotifyNewImage(rs1);
-		User::WaitForRequest(rs1);
-		retId=rs1.Int();
-		aTest(retId>=0);
-		aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
-		aTest.Printf(_L("Buffer%d offset: %d(%xH)\r\n"),i,retOffset,retOffset);
-		aTest(retOffset>=0);
-
-		if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
-			{
-			// Display the image received for 1s
-			imgBase=chunkImage.Base()+retOffset;
-			r=dispHand.Process(imgBase);
-			
-#ifdef __WINSCW__
-            aTest(r==KErrNotSupported);
-#else
-            aTest(r==KErrNone);
-#endif
-            
-			User::After(1000000);	// 1 sec
-			}
-		}
-
-	r=aCam.ReleaseBuffer(retId);
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Stop the camera."));
-	r=aCam.Stop();
-	aTest(r==KErrNone);
-
-	aTest.Next(_L("Close the chunk"));
-	r=aCam.ChunkClose(ECamCaptureModeImage);
-	aTest(r==KErrNone);
-	}
-
-LOCAL_C void DoCamCancelTests(RTest& aTest, TInt aCameraSensorIndex)
-	{
-	TInt bufferSize, r;
-	SDevCamFrameSize* frameSizes;
-	TCameraConfigV02Buf camConfBuf;
-
-	aTest.Next(_L("CAPTURE CANCEL TESTS"));
-
-	RDevCameraSc cam;
-	aTest.Next(_L("Open a channel on the camera driver"));
-	r=cam.Open(aCameraSensorIndex);
-	aTest(r==KErrNone);
-
-	TInt numBuffers=KNumVideoFramesToAllocate;
-	SDevCamPixelFormat* pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
-
-	// Test Image Capture, if supported
-	if (CameraCaps->iNumImagePixelFormats)
-		{
-		// If iNumImagePixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
-		Test(pixelFormat->iNumFrameSizes > 0);
-		frameSizes = new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
-		Test(frameSizes != NULL);
-		bufferSize = (sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
-		TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
-		r = cam.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizesBuf);
-		Test(r == KErrNone);
-
-		cam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
-
-		camConfBuf().iFrameSize=frameSizes[0];
-		camConfBuf().iPixelFormat=*pixelFormat;
-		camConfBuf().iFrameRate=frameSizes[0].iMaxFrameRate;
-
-		// Set the camera configuration.
-		r=cam.SetCamConfig(ECamCaptureModeImage, camConfBuf);
-		aTest(r==KErrNone);
-		cam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
-		PrintCamConf(camConfBuf(), aTest);
-
-		// Create a chunk handle and trigger the buffer creation.
-		RChunk chunkImage;
-		aTest.Next(_L("Setup the config - creating a chunk for image capture"));
-		r=cam.SetBufConfigChunkCreate(ECamCaptureModeImage,numBuffers,chunkImage);
-		aTest(r==KErrNone);
-
-		aTest.Next(_L("Read and display the resulting buffer config"));
-		TMmSharedChunkBufConfig bufferConfig;
-		TPckg<TMmSharedChunkBufConfig> bufferConfigBufImage(bufferConfig);
-		cam.GetBufferConfig(ECamCaptureModeImage, bufferConfigBufImage);
-		PrintBufferConf(bufferConfig,aTest);
-
-		// Set the current capture mode
-		r=cam.SetCaptureMode(ECamCaptureModeImage);
-		aTest(r==KErrNone);
-
-		aTest.Next(_L("Start the camera in image capture mode."));
-		r=cam.Start();
-		aTest(r==KErrNone);
-
-		TRequestStatus rs[KNumVideoFramesToCapture];
-		TInt retId, retOffset;
-
-		aTest.Next(_L("Issue a request and then cancel it"));
-		cam.NotifyNewImage(rs[0]);
-		cam.NotifyNewImageCancel();
-		User::WaitForRequest(rs[0]);
-		retId=rs[0].Int();
-		aTest(retId==KErrCancel || retId>=0);
-		if (retId>=0)
-			{
-			cam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
-			aTest.Printf(_L("Buffer%d : %d\r\n"),retId,retOffset);
-			aTest(retOffset>=0);
-			cam.ReleaseBuffer(retId);
-			}
-
-		aTest.Next(_L("Stop the camera."));
-		r=cam.Stop();
-		aTest(r==KErrNone);
-
-		aTest.Next(_L("Close the Image chunk"));
-		chunkImage.Close();
-
-		delete [] frameSizes;
-		}
-
-	// Skip past the image pixel formats
-	pixelFormat += CameraCaps->iNumImagePixelFormats;
-
-	// Test Video Capture, if supported
-	if (CameraCaps->iNumVideoPixelFormats)
-		{
-		// If iNumVideoPixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
-		Test(pixelFormat->iNumFrameSizes > 0);
-		frameSizes = new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
-		Test(frameSizes != NULL);
-		bufferSize = (sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
-		TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
-		r = cam.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizesBuf);
-		Test(r == KErrNone);
-
-		cam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
-
-		camConfBuf().iFrameSize=frameSizes[0];
-		camConfBuf().iPixelFormat=*pixelFormat;
-		camConfBuf().iFrameRate=frameSizes[0].iMaxFrameRate;
-
-		// Set the camera configuration.
-		r=cam.SetCamConfig(ECamCaptureModeVideo, camConfBuf);
-		aTest(r==KErrNone);
-		cam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
-		PrintCamConf(camConfBuf(), aTest);
-
-		// Create a chunk handle and trigger the buffer creation.
-		RChunk chunkVideo;
-		aTest.Next(_L("Setup the config - creating a chunk for video capture"));
-		r=cam.SetBufConfigChunkCreate(ECamCaptureModeVideo,numBuffers,chunkVideo);
-		aTest(r==KErrNone);
-
-		aTest.Next(_L("Read and display the resulting buffer config"));
-		TMmSharedChunkBufConfig bufferConfig;
-		TPckg<TMmSharedChunkBufConfig> bufferConfigBufVideo(bufferConfig);
-		cam.GetBufferConfig(ECamCaptureModeVideo, bufferConfigBufVideo);
-		PrintBufferConf(bufferConfig,aTest);
-
-		// Set the current capture mode
-		r=cam.SetCaptureMode(ECamCaptureModeVideo);
-		aTest(r==KErrNone);
-
-		aTest.Next(_L("Start the camera in video mode"));
-		r=cam.Start();
-		aTest(r==KErrNone);
-
-		aTest.Next(_L("Issue capture requests and globally cancel them all"));
-		aTest.Printf(_L("Request %d frames\r\n"),KNumVideoFramesToCapture);
-		TRequestStatus rs[KNumVideoFramesToCapture];
-		TInt i;
-		for (i=0 ; i<KNumVideoFramesToCapture; i++)
-			cam.NotifyNewImage(rs[i]);
-
-		cam.NotifyNewImageCancel();
-
-		TInt retOffset = -2;
-		TInt retId = -2;
-		for (i=0 ; i<KNumVideoFramesToCapture; i++)
-			{
-			User::WaitForRequest(rs[i]);
-			retId=rs[i].Int();
-			aTest(retId==KErrCancel || retId>=0);
-			if (retId>=0)
-				{
-				cam.BufferIdToOffset(ECamCaptureModeVideo,retId,retOffset);
-				aTest.Printf(_L("Buffer%d : %d\r\n"),retId,retOffset);
-				aTest(retOffset>=0);
-				cam.ReleaseBuffer(retId);
-				}
-			}
-
-		aTest.Next(_L("Issue capture requests and individually cancel them all"));
-		aTest.Printf(_L("Request %d frames\r\n"),KNumVideoFramesToCapture);
-
-		for (i=0 ; i<KNumVideoFramesToCapture; i++)
-			cam.NotifyNewImage(rs[i]);
-
-		for (i=0 ; i<KNumVideoFramesToCapture; i++)
-			cam.NotifyNewImageCancel(rs[i]);
-
-		for (i=0 ; i<KNumVideoFramesToCapture; i++)
-			{
-			User::WaitForRequest(rs[i]);
-			retId=rs[i].Int();
-			aTest(retId==KErrCancel || retId>=0);
-			if (retId>=0)
-				{
-				cam.BufferIdToOffset(ECamCaptureModeVideo,retId,retOffset);
-				aTest.Printf(_L("Buffer%d : %d\r\n"),retId,retOffset);
-				aTest(retOffset>=0);
-				cam.ReleaseBuffer(retId);
-				}
-			}
-
-		aTest.Next(_L("Stop the camera."));
-		r=cam.Stop();
-		aTest(r==KErrNone);
-
-		aTest.Next(_L("Close the Video chunk"));
-		chunkVideo.Close();
-
-		delete [] frameSizes;
-		}
-
-	// Skip past the video pixel formats
-	pixelFormat += CameraCaps->iNumVideoPixelFormats;
-
-	// Test Viewfinder Capture, if supported
-	if (CameraCaps->iNumViewFinderPixelFormats)
-		{
-		// If iNumViewFinderPixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
-		Test(pixelFormat->iNumFrameSizes > 0);
-		frameSizes = new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
-		Test(frameSizes != NULL);
-		bufferSize = (sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
-		TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
-		r = cam.FrameSizeCaps(ECamCaptureModeViewFinder, pixelFormat->iPixelFormat, frameSizesBuf);
-		Test(r == KErrNone);
-
-		cam.GetCamConfig(ECamCaptureModeViewFinder, camConfBuf);
-
-		camConfBuf().iFrameSize=frameSizes[0];
-		camConfBuf().iPixelFormat=*pixelFormat;
-		camConfBuf().iFrameRate=frameSizes[0].iMaxFrameRate;
-
-		// Set the camera configuration.
-		r=cam.SetCamConfig(ECamCaptureModeViewFinder, camConfBuf);
-		aTest(r==KErrNone);
-		cam.GetCamConfig(ECamCaptureModeViewFinder, camConfBuf);
-		PrintCamConf(camConfBuf(), aTest);
-
-		// Create a chunk handle and trigger the buffer creation.
-		RChunk chunkViewFinder;
-		aTest.Next(_L("Setup the config - creating a chunk for viewfinder capture"));
-		r=cam.SetBufConfigChunkCreate(ECamCaptureModeViewFinder,numBuffers,chunkViewFinder);
-		aTest(r==KErrNone);
-
-		aTest.Next(_L("Read and display the resulting buffer config"));
-		TMmSharedChunkBufConfig bufferConfig;
-		TPckg<TMmSharedChunkBufConfig> bufferConfigBufViewFinder(bufferConfig);
-		cam.GetBufferConfig(ECamCaptureModeViewFinder, bufferConfigBufViewFinder);
-		PrintBufferConf(bufferConfig,aTest);
-
-		aTest.Next(_L("Close the Viewfinder chunk"));
-		chunkViewFinder.Close();
-
-		delete [] frameSizes;
-		}
-
-	aTest.Next(_L("Close the drivers"));
-	cam.Close();
-	}
-
-void CameraTests(TInt aCameraSensorIndex)
-	{
-	TUint index, size;
-	Test.Printf(_L("Testing unit number: %d\r\n"),aCameraSensorIndex);
-
-	// Perform some basic opening and multithreaded tests.  We don't want just in time debugging during
-	// these tests
-	TBool justInTime=User::JustInTime();
-	User::SetJustInTime(EFalse);
-	DoCamOpenCapTests(Test,aCameraSensorIndex);
-	User::SetJustInTime(justInTime);
-
-	// Test request handling
-	DoCamCancelTests(Test, aCameraSensorIndex);
-
-	// Re-open the camera driver for use below and to ensure that it can deal with being re-opened (it
-	// has already been opened and closed by DoCamOpenCapTests())
-	RDevCameraSc cam;
-	Test.Next(_L("Open a channel on the camera driver"));
-	TInt r=cam.Open(aCameraSensorIndex);
-	Test(r==KErrNone);
-
-	// Test Dynamic Settings, e.g. Brightness, Contrast, etc.
-	DoCamDynamicSettingsTests(cam, Test);
-	
-	// Go through all supported image, video and viewfinder pixel formats and perform configuration
-	// and capture tests on them all, for all supported frame sizes and frame rates
-	TInt bufferSize;
-	SDevCamFrameSize* frameSizes;
-	TBool imageConfigTestsDone=EFalse, videoConfigTestsDone=EFalse, viewFinderConfigTestsDone=EFalse;
-	SDevCamPixelFormat* pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
-
-	for (index = 0; index < CameraCaps->iNumImagePixelFormats; ++index)
-		{
-		// If iNumImagePixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
-		Test(pixelFormat->iNumFrameSizes > 0);
-		Test.Printf(_L("Image pixel format %x, number of frame sizes = %d\n"), pixelFormat->iPixelFormat, pixelFormat->iNumFrameSizes);
-		frameSizes=new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
-		Test(frameSizes!=NULL);
-		bufferSize=(sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
-		TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
-		r = cam.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizesBuf);
-		Test(r == KErrNone);
-
-		// Test camera configuration for image capture.  This is only done once for the sake of
-		// test expediency
-		if (!imageConfigTestsDone)
-			{
-			imageConfigTestsDone = ETrue;
-			DoCamConfigTests(cam, Test, ECamCaptureModeImage, *pixelFormat, frameSizes[0]);
-			}
-
-		// Test image capture mode
-		for (size = 0; size < pixelFormat->iNumFrameSizes; ++size)
-			{
-			DoCamImageCaptureTests(cam, Test, aCameraSensorIndex, *pixelFormat, frameSizes[size], frameSizes[size].iMaxFrameRate);
-			}
-
-		// Test buffer offset
-		for (size = 0; size < pixelFormat->iNumFrameSizes; ++size)
-			{
-			DoCamBufferOffsetTests(cam, Test, *pixelFormat, frameSizes[size], frameSizes[size].iMaxFrameRate);
-			}
-
-		delete [] frameSizes;
-		++pixelFormat;
-		}
-
-	for (index = 0; index < CameraCaps->iNumVideoPixelFormats; ++index)
-		{
-		// If iNumVideoPixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
-		Test(pixelFormat->iNumFrameSizes > 0);
-		Test.Printf(_L("Video pixel format %x, number of frame sizes = %d\n"), pixelFormat->iPixelFormat, pixelFormat->iNumFrameSizes);
-		frameSizes=new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
-		Test(frameSizes!=NULL);
-		bufferSize=(sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
-		TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
-		r = cam.FrameSizeCaps(ECamCaptureModeVideo, pixelFormat->iPixelFormat, frameSizesBuf);
-		Test(r == KErrNone);
-
-		// Test camera configuration for video capture.  This is only done once for the sake of
-		// test expediency
-		if (!videoConfigTestsDone)
-			{
-			videoConfigTestsDone=ETrue;
-			DoCamConfigTests(cam, Test, ECamCaptureModeVideo, *pixelFormat, frameSizes[0]);
-			}
-
-		// Test video capture mode
-		for (size = 0; size < pixelFormat->iNumFrameSizes; ++size)
-			{
-			DoCamVideoCaptureTests(cam, Test, ECamCaptureModeVideo, *pixelFormat,frameSizes[size], frameSizes[size].iMaxFrameRate);
-			}
-		delete [] frameSizes;
-		++pixelFormat;
-		}
-
-	for (index = 0; index < CameraCaps->iNumViewFinderPixelFormats; ++index)
-		{
-		// If iNumViewFinderPixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
-		Test(pixelFormat->iNumFrameSizes > 0);
-		Test.Printf(_L("Viewfinder pixel format %x, number of frame sizes = %d\n"), pixelFormat->iPixelFormat, pixelFormat->iNumFrameSizes);
-		frameSizes=new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
-		Test(frameSizes!=NULL);
-		bufferSize=(sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
-		TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
-		r = cam.FrameSizeCaps(ECamCaptureModeViewFinder, pixelFormat->iPixelFormat, frameSizesBuf);
-		Test(r == KErrNone);
-
-		// Test camera configuration for view finder capture.  This is only done once for the sake of
-		// test expediency
-		if (!viewFinderConfigTestsDone)
-			{
-			viewFinderConfigTestsDone=ETrue;
-			DoCamConfigTests(cam, Test, ECamCaptureModeViewFinder, *pixelFormat, frameSizes[0]);
-			}
-
-		// Test view finder capture mode
-		for (size = 0; size < pixelFormat->iNumFrameSizes; ++size)
-			{
-			DoCamVideoCaptureTests(cam, Test, ECamCaptureModeViewFinder, *pixelFormat, frameSizes[size], frameSizes[size].iMaxFrameRate);
-			}
-		delete [] frameSizes;
-		++pixelFormat;
-		}
-	cam.Close();
-
-	// And free the global capabilities buffer that was allocated in DoCamOpenCapTests()
-	User::Free(CapsBufPtr);
-	}
-
-GLDEF_C TInt E32Main()
-	{
-	__UHEAP_MARK;
-
-	Test.Title();
-	Test.Start(_L("Camera module API test"));
-
-	Test.Next(_L("Loading CAMERA PDD"));
-	TInt r=User::LoadPhysicalDevice(KCamPddFileName);
-	Test.Printf(_L("Returned %d\r\n"),r);
-
-	if (r==KErrNotFound)
-		{
-		Test.Printf(_L("Shared chunk camera driver not supported - test skipped\r\n"));
-		Test.End();
-		Test.Close();
-		__UHEAP_MARKEND;
-		return(KErrNone);
-		}
-
-	Test(r==KErrNone || r==KErrAlreadyExists);
-
-	Test.Next(_L("Loading CAMERA LDD"));
-	r=User::LoadLogicalDevice(KCamLddFileName);
-	Test.Printf(_L("Returned %d\r\n"),r);
-	Test(r==KErrNone || r==KErrAlreadyExists);
-
-	Test.Next(_L("Loading D_MMCSC LDD"));
-	r=User::LoadLogicalDevice(KTstLddFileName);
-	Test.Printf(_L("Returned %d\r\n"),r);
-	Test(r==KErrNone||r==KErrAlreadyExists);
-
-	__KHEAP_MARK;
-
-	if (User::CommandLineLength()>0)
-		{
-		TBuf<0x100> cmd;
-		TInt moduleIndex = KUnit0;
-		User::CommandLine(cmd);
-		Test(cmd.Length()>0);
-		if (cmd[0]>='0' && cmd[0]<='9')
-			moduleIndex=(TInt)(cmd[0]-'0');
-		CameraTests(moduleIndex);
-		}
-	else // If no command line arguments are passed we perform tests on the module 0 and 1
-		{
-		CameraTests(0);
-		}
-
-	__KHEAP_MARKEND;
-
-	// Free the PDDs and LDDs
-	Test.Next(_L("Freeing ECAMERASC LDD"));
-	r=User::FreeLogicalDevice(KDevCameraScName);
-	Test(r==KErrNone);
-
-	Test.Next(_L("Freeing CAMERASC PDD"));
-	TFindPhysicalDevice fDr;
-	TFullName drivName;
-	TName searchName;
-	searchName.Append(KDevCameraScName);
-	searchName.Append(KCamFreePddExtension);
-	fDr.Find(searchName);
-	r=fDr.Next(drivName);
-	Test(r==KErrNone);
-	r=User::FreePhysicalDevice(drivName);
-	Test(r==KErrNone);
-
-	Test.Next(_L("Freeing D_MMCSC LDD"));
-	r=User::FreeLogicalDevice(KDevMmCScName);
-	Test(r==KErrNone);
-
-	Test.End();
-	Test.Close();
-
-	__UHEAP_MARKEND;
-	return(KErrNone);
-	}
--- a/kerneltest/e32test/multimedia/t_camera_bitmap.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,291 +0,0 @@
-// Copyright (c) 2008-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/multimedia/t_camera_bitmap.cpp
-// This is a basic Windows bitmap file writer, that can be used for converting YUV422 data into
-// RGB format and dumping it to a Windows .bmp file, for manual examination.
-// 
-//
-
-#include <e32test.h>
-#include <f32file.h>
-#include "t_camera_bitmap.h"
-
-#define CLIP(a) if (a < 0) a = 0; else if (a > 255) a = 255;
-
-/**
-Converts a RGB565 buffer into 24 bit RGB format in a second buffer.
-@param	aDest		Pointer to the buffer into which to place the 24 bit RGB data
-@param	aSource		Pointer to the buffer containing the RGB565 data to be converted
-@param	aWidth		The width of the data in the buffer in pixels
-@param	aHeight		The height of the data in the buffer in pixels
-*/
-void RBitmap::RGBToRGB(TUint8* aDest, TUint8* aSource, TInt aWidth, TInt aHeight)
-	{
-	TUint16* source = (TUint16*) aSource;
-	TUint16 pixel;
-
-	for (TInt y = 0; y < aHeight; ++y)
-		{
-		for (TInt x = 0; x < aWidth; ++x)
-			{
-			pixel = *source++;
-			*aDest++ = (TUint8) ((pixel & 0xf800) >> 8);
-			*aDest++ = (TUint8) ((pixel & 0x07e0) >> 3);
-			*aDest++ = (TUint8) ((pixel & 0x001f) << 3);
-			}
-		}
-	}
-
-/**
-Converts a YUV422 buffer into 24 bit RGB format in a second buffer.
-@param	aDest		Pointer to the buffer into which to place the 24 bit RGB data
-@param	aSource		Pointer to the buffer containing the YUV422 data to be converted
-@param	aWidth		The width of the data in the buffer in pixels
-@param	aHeight		The height of the data in the buffer in pixels
-*/
-void RBitmap::YUVToRGB(TUint8* aDest, TUint8* aSource, TInt aWidth, TInt aHeight)
-	{
-	TInt y, u, v, r, g, b;
-
-	aDest += ((aWidth * 3) * (aHeight - 1));
-
-	for (TInt l = 0; l < aHeight; ++l)
-		{
-		for (TInt x = 0; x < (aWidth / 2); ++x)
-			{
-			u = (aSource[0] - 128);
-			v = (aSource[2] - 128);
-			y = (aSource[3] - 16);
-
-			r = ((298 * y + 409 * u) / 256);
-			g = ((298 * y - 100 * v - 208 * u) / 256);
-			b = ((298 * y + 516 * v) / 256);
-
-			CLIP(r);
-			CLIP(g);
-			CLIP(b);
-
-			*aDest++ = (TUint8) r;
-			*aDest++ = (TUint8) g;
-			*aDest++ = (TUint8) b;
-
-			y = (aSource[1] - 16);
-
-			r = ((298 * y + 409 * u) / 256);
-			g = ((298 * y - 100 * v - 208 * u) / 256);
-			b = ((298 * y + 516 * v) / 256);
-
-			CLIP(r);
-			CLIP(g);
-			CLIP(b);
-
-			*aDest++ = (TUint8) r;
-			*aDest++ = (TUint8) g;
-			*aDest++ = (TUint8) b;
-			aSource += 4;
-			}
-
-		aDest -= (aWidth * 3 * 2);
-		}
-	}
-
-/**
-Converts a 32 bit long from whatever the host format is into little endian format in a user supplied buffer.
-@param	aBuffer		Pointer to the buffer into which to write the value
-@param	aLong		The value to be written
-*/
-void RBitmap::PutLong(TUint8* aBuffer, TInt aLong)
-	{
-	*aBuffer++ = (TUint8) (aLong & 0xff);
-	*aBuffer++ = (TUint8) ((aLong >> 8) & 0xff);
-	*aBuffer++ = (TUint8) ((aLong >> 16) & 0xff);
-	*aBuffer++ = (TUint8) ((aLong >> 24) & 0xff);
-	}
-
-/**
-Converts a 16 bit short from whatever the host format is into little endian format in a user supplied buffer.
-@param	aBuffer		Pointer to the buffer into which to write the value
-@param	aShort		The value to be written
-*/
-void RBitmap::PutShort(TUint8* aBuffer, TInt16 aShort)
-	{
-	*aBuffer++ = (TUint8) (aShort & 0xff);
-	*aBuffer++ = (TUint8) ((aShort >> 8) & 0xff);
-	}
-
-/**
-Writes a standard Windows .bmp header to a file, including the standard .bmp file header, followed
-by a V3 DIB header.
-@param	aFile		A reference to the file to which to write the header
-@param	aWidth		The width of the bitmap in pixels
-@param	aHeight		The height of the bitmap in pixels
-@return	KErrNone if write was successful, otherwise one of the other system wide error codes
-*/
-TInt RBitmap::WriteHeader(RFile& aFile, TInt aWidth, TInt aHeight)
-	{
-	TBuf8<14> header(14);
-	TUint8* buffer = (TUint8*) header.Ptr();
-
-	header.Fill(0);
-
-	header[0] = 'B';
-	header[1] = 'M';
-	PutLong((buffer + 2), (14 + 40 + (aWidth * aHeight * 3)));
-	PutLong((buffer + 10), (14 + 40));
-
-	TInt r = aFile.Write(header);
-
-	if (r == KErrNone)
-		{
-		TBuf8<40> bitmapInfoHeader(40);
-		TUint8* buffer = (TUint8*) bitmapInfoHeader.Ptr();
-
-		bitmapInfoHeader.Fill(0);
-
-		PutLong(buffer, 40);
-		PutLong((buffer + 4), aWidth);
-		PutLong((buffer + 8), aHeight);
-		PutShort((buffer + 12), 1);
-		PutShort((buffer + 14), 24);
-		PutLong((buffer + 20), (aWidth * aHeight * 3));
-
-		r = aFile.Write(bitmapInfoHeader);
-		}
-
-	return r;
-	}
-
-/**
-Converts a YUV422 or RGB565 buffer into 24 bit RGB format and writes it to a file.
-@param	aFile			A reference to the file to which to write the data
-@param	aBuffer			A pointer to the buffer containing the data to be converted and written
-@param	aPixelFormat	UID specifying the format of the source data
-@param	aWidth			The width of the data in the buffer in pixels
-@param	aHeight			The height of the data in the buffer in pixels
-@return	KErrNone if write was successful, otherwise one of the other system wide error codes
-*/
-TInt RBitmap::WriteBitmapData(RFile& aFile, TUint8* aBuffer, SDevCamPixelFormat aPixelFormat, TInt aWidth, TInt aHeight)
-	{
-	TInt length = (aWidth * aHeight * 3);
-	TUint8* rgbBuffer = new TUint8[length];
-
-	TInt r = KErrNone;
-
-	if (rgbBuffer)
-		{
-		if (aPixelFormat.iPixelFormat == EUidPixelFormatYUV_422Interleaved)
-			{
-			YUVToRGB(rgbBuffer, aBuffer, aWidth, aHeight);
-			}
-		else if (aPixelFormat.iPixelFormat == EUidPixelFormatRGB_565)
-			{
-			RGBToRGB(rgbBuffer, aBuffer, aWidth, aHeight);
-			}
-		else
-			{
-			r = KErrNotSupported;
-			}
-
-		if (r == KErrNone)
-			{
-			TPtr8 buffer(rgbBuffer, length, length);
-			r = aFile.Write(buffer);
-			}
-
-		delete [] rgbBuffer;
-		}
-	else
-		{
-		r = KErrNoMemory;
-		}
-
-	return r;
-	}
-
-/**
-Converts a YUV422 or RGB565 buffer into 24 bit RGB format and writes it to a Windows .bmp file.
-@param	aFileName		A reference to the fully qualified name of the file to write the .bmp file to
-@param	aBuffer			A pointer to the buffer containing the data to be converted and written
-@param	aPixelFormat	UID specifying the format of the source data
-@param	aWidth			The width of the data in the buffer in pixels
-@param	aHeight			The height of the data in the buffer in pixels
-@return	KErrNone if write was successful, otherwise one of the other system wide error codes
-*/
-TInt RBitmap::WriteBMP(const TDesC& aFileName, TUint8* aBuffer, SDevCamPixelFormat aPixelFormat, TInt aWidth, TInt aHeight)
-	{
-	TInt r;
-	RFile file;
-	RFs fs;
-
-	if ((r = fs.Connect()) == KErrNone)
-		{
-		if ((r = file.Replace(fs, aFileName, EFileWrite)) == KErrNone)
-			{
-			if ((r = WriteHeader(file, aWidth, aHeight)) == KErrNone)
-				{
-				r = WriteBitmapData(file, aBuffer, aPixelFormat, aWidth, aHeight);
-				}
-
-			file.Close();
-
-			// If anything went wrong, delete the file so that we do not leave partial files that
-			// might cause confusion
-			if (r != KErrNone)
-				{
-				fs.Delete(aFileName);
-				}
-			}
-
-		fs.Close();
-		}
-
-	return r;
-	}
-
-/**
-Dumps a buffer straight to disk, without any kind of processing.
-@param	aFileName		A reference to the fully qualified name of the file to write the file to
-@param	aBuffer			A pointer to the buffer containing the data to be converted written
-@param	aSize			The size of the buffer to be written, in bytes
-@return	KErrNone if write was successful, otherwise one of the other system wide error codes
-*/
-TInt RBitmap::WriteBuffer(const TDesC& aFileName, TUint8* aBuffer, TInt aSize)
-	{
-	TInt r;
-	RFile file;
-	RFs fs;
-
-	if ((r = fs.Connect()) == KErrNone)
-		{
-		if ((r = file.Replace(fs, aFileName, EFileWrite)) == KErrNone)
-			{
-			TPtrC8 buffer(aBuffer, aSize);
-
-			r = file.Write(buffer);
-
-			file.Close();
-
-			// If anything went wrong, delete the file so that we do not leave partial files that
-			// might cause confusion
-			if (r != KErrNone)
-				{
-				fs.Delete(aFileName);
-				}
-			}
-
-		fs.Close();
-		}
-
-	return r;
-	}
--- a/kerneltest/e32test/multimedia/t_camera_bitmap.h	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-// Copyright (c) 2008-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/multimedia/t_camera_bitmap.h
-// This is a basic Windows bitmap file writer, that can be used for converting YUV422 data into
-// RGB format and dumping it to a Windows .bmp file, for manual examination.
-// 
-//
-
-#if !defined(__T_CAMERA_BITMAP_H__)
-#define __T_CAMERA_BITMAP_H__
-
-#include <d32camerasc.h>
-#include <f32file.h>
-
-class RBitmap
-	{
-public:
-
-	TInt WriteBMP(const TDesC& aFileName, TUint8* aBuffer, SDevCamPixelFormat aPixelFormat, TInt aWidth, TInt aHeight);
-	TInt WriteBuffer(const TDesC& aFileName, TUint8* aBuffer, TInt aSize);
-
-private:
-
-	void RGBToRGB(TUint8* aDest, TUint8* aSource, TInt aWidth, TInt aHeight);
-	void YUVToRGB(TUint8* aDest, TUint8* aSource, TInt aWidth, TInt aHeight);
-	void PutLong(TUint8* aBuffer, TInt aLong);
-	void PutShort(TUint8* aBuffer, TInt16 aShort);
-	TInt WriteHeader(RFile& aFile, TInt aWidth, TInt aHeight);
-	TInt WriteBitmapData(RFile& aFile, TUint8* aBuffer, SDevCamPixelFormat aPixelFormat, TInt aWidth, TInt aHeight);
-	};
-
-#endif // ! __T_CAMERA_BITMAP_H__
--- a/kerneltest/e32test/multimedia/t_camera_display.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,388 +0,0 @@
-// Copyright (c) 2006-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\multimedia\t_camera_display.cpp
-// 
-//
-
-#include <e32test.h>
-#include <e32svr.h>
-#include <u32hal.h>
-#include <videodriver.h>
-#include "t_camera_display.h"
-
-_LIT(KFrameSizeConfTitle,"Current frame size  :");
-_LIT(KFrameSize, " %d x %d");
-
-#define CLIP(a) if (a < 0) a = 0; else if (a > 255) a = 255;
-
-/**
-Constructor
-*/
-TCamDisplayHandler::TCamDisplayHandler()
-	{}
-
-/**
-Initialise the display handler.
-@return KErrNone if write was successful, otherwise one of the other system wide error codes.
-*/
-TInt TCamDisplayHandler::Init()
-	{
-	TScreenInfoV01 screenInfo;
-	TPckg<TScreenInfoV01> screenInfoBuf(screenInfo);
-	UserSvr::ScreenInfo(screenInfoBuf);
-	iVideoAddress = (TUint8*) screenInfo.iScreenAddress;
-	iScreenWidth = screenInfo.iScreenSize.iWidth;
-	iScreenHeight = screenInfo.iScreenSize.iHeight;
-
-	TPckgBuf<TVideoInfoV01> videoInfoBuf;
-	UserSvr::HalFunction(EHalGroupDisplay, EDisplayHalCurrentModeInfo, &videoInfoBuf, NULL);
-	iBitsPerPixel = videoInfoBuf().iBitsPerPixel;
-
-	return(KErrNone);
-	}
-
-TInt TCamDisplayHandler::Min(TInt aA, TInt aB)
-	{
-	return (aA < aB) ? aA : aB;
-	}
-
-TInt TCamDisplayHandler::SetConfig(const SDevCamFrameSize& aSize,const SDevCamPixelFormat& aPixelFormat)
-	{
-	if (aPixelFormat.iPixelFormat==EUidPixelFormatYUV_422Interleaved || aPixelFormat.iPixelFormat==EUidPixelFormatRGB_565)
-		iPixelFormat=aPixelFormat;
-	else
-		return(KErrArgument);
-
-	iWidth = aSize.iWidth;
-	iHeight = aSize.iHeight;
-
-	return(KErrNone);
-	}
-
-/**
-Post process a received image.
-@return KErrNone if write was successful, otherwise one of the other system wide error codes.
-*/
-TInt TCamDisplayHandler::Process(TUint8* aImageBaseAddress)
-	{
-	switch (iPixelFormat.iPixelFormat)
-		{
-		case EUidPixelFormatYUV_422Interleaved:
-			return(ProcessYUV422(aImageBaseAddress));
-		case EUidPixelFormatRGB_565:
-			return(ProcessRGB565(aImageBaseAddress));
-		default:
-			return(KErrNotSupported);
-		}
-	}
-
-/**
-Post process a received RGB565 image.
-@return KErrNone if write was successful, otherwise one of the other system wide error codes.
-*/
-TInt TCamDisplayHandler::ProcessRGB565(TUint8* aImageBaseAddress)
-	{
-	TUint16* source = (TUint16*) aImageBaseAddress;
-	TUint16 pixel;
-	TInt sourceModulo, destModulo, width, height;
-	TInt r = KErrNone;
-
-	// Determine whether the screen or the picture to display is the widest, and calculate modulos
-	// and clipping sizes appropriately
-	if (iWidth < iScreenWidth)
-		{
-		width = iWidth;
-		sourceModulo = 0;
-		destModulo = (iScreenWidth - iWidth);
-		}
-	else
-		{
-		width = iScreenWidth;
-		sourceModulo = (iWidth - iScreenWidth);
-		destModulo = 0;
-		}
-
-	// Determine whether the screen or the picture to display is the highest
-	height = (iHeight < iScreenHeight) ? iHeight : iScreenHeight;
-
-	if (iBitsPerPixel == 16)
-		{
-		TUint16* dest = (TUint16*) iVideoAddress;
-
-		// Loop around and copy the data directly onto the screen
-		for (TInt line = 0; line < height; ++line)
-			{
-			for (TInt x = 0; x < width; ++x)
-				{
-				*dest++ = *source++;
-				}
-
-			source += sourceModulo;
-			dest += destModulo;
-			}
-		}
-	else if (iBitsPerPixel == 32)
-		{
-		TUint8* dest = iVideoAddress;
-
-		destModulo *= 4;
-
-		// Loop around and convert whatever part of the picture will fit onto the screen into BGRA,
-		// writing it directly onto the screen
-		for (TInt line = 0; line < height; ++line)
-			{
-			for (TInt x = 0; x < width; ++x)
-				{
-				pixel = *source++;
-				*dest++= (TUint8) ((pixel & 0x001f) << 3);
-				*dest++= (TUint8) ((pixel & 0x07e0) >> 3);
-				*dest++= (TUint8) ((pixel & 0xf800) >> 8);
-				*dest++ = 0xff;
-				}
-
-			source += sourceModulo;
-			dest += destModulo;
-			}
-		}
-	else
-		{
-		r = KErrNotSupported;
-		}
-
-	return r;
-	}
-
-/**
-Post process a received YUV422 image.
-@return KErrNone if write was successful, otherwise one of the other system wide error codes.
-*/
-TInt TCamDisplayHandler::ProcessYUV422(TUint8* aImageBaseAddress)
-	{
-	TUint16* dest16 = (TUint16*) iVideoAddress;
-	TUint32* dest32 = (TUint32*) iVideoAddress;
-	TUint8* source = aImageBaseAddress;
-	TInt y, u, v, r, g, b, sourceModulo, destModulo, width, height;
-	TInt retVal = KErrNone;
-
-	// Determine whether the screen or the picture to display is the widest, and calculate modulos
-	// and clipping sizes appropriately
-	if (iWidth < iScreenWidth)
-		{
-		width = (iWidth / 2);
-		sourceModulo = 0;
-		destModulo = (iScreenWidth - iWidth);
-		}
-	else
-		{
-		width = (iScreenWidth / 2);
-		sourceModulo = ((iWidth - iScreenWidth) * 2);
-		destModulo = 0;
-		}
-
-	// Determine whether the screen or the picture to display is the highest
-	height = (iHeight < iScreenHeight) ? iHeight : iScreenHeight;
-
-	// Only 16 and 32 bits per pixel are supported.  It is also assumed that 16 bit will be RGB565 and
-	// 32 bit will be BGRA.  You will need to add support for new formats if required
-	if ((iBitsPerPixel == 16) || (iBitsPerPixel == 32))
-		{
-		// Loop around and convert whatever part of the picture will fit onto the screen into RGB565 or BGRA,
-		// writing it directly onto the screen
-		for (TInt line = 0; line < height; ++line)
-			{
-			for (TInt x = 0; x < width; ++x)
-				{
-				u = (source[0] - 128);
-				v = (source[2] - 128);
-				y = (source[3] - 16);
-
-				r = ((298 * y + 409 * u) / 256);
-				g = ((298 * y - 100 * v - 208 * u) / 256);
-				b = ((298 * y + 516 * v) / 256);
-
-				CLIP(r);
-				CLIP(g);
-				CLIP(b);
-
-				if (iBitsPerPixel == 16)
-					{
-					*dest16++ = (TUint16) (((b & 0xf8) << 8) | ((g & 0xfc) << 3) | ((r & 0xf8) >> 3));
-					}
-				else
-					{
-					*dest32++ = (0xff000000 | (r << 16) | (g << 8) | b);
-					}
-
-				y = (source[1] - 16);
-
-				r = ((298 * y + 409 * u) / 256);
-				g = ((298 * y - 100 * v - 208 * u) / 256);
-				b = ((298 * y + 516 * v) / 256);
-
-				CLIP(r);
-				CLIP(g);
-				CLIP(b);
-
-				if (iBitsPerPixel == 16)
-					{
-					*dest16++ = (TUint16) (((b & 0xf8) << 8) | ((g & 0xfc) << 3) | ((r & 0xf8) >> 3));
-					}
-				else
-					{
-					*dest32++ = (0xff000000 | (r << 16) | (g << 8) | b);
-					}
-
-				source += 4;
-				}
-
-			source += sourceModulo;
-			dest16 += destModulo;
-			dest32 += destModulo;
-			}
-		}
-	else
-		{
-		retVal = KErrNotSupported;
-		}
-
-	return retVal;
-	}
-
-/**
-Appends a string representing a pixel format UID onto a descriptor.
-@param aBuffer		Reference to the descriptor into which to append the string.  It is up to the
-					caller to ensure that this is large enough.
-@param aPixelFormat	UID of the pixel format to be converted into a string.
-*/
-void AppendPixelFormat(TDes& aBuffer, TUidPixelFormat aPixelFormat)
-	{
-	if (aPixelFormat == EUidPixelFormatRGB_565)
-		aBuffer.Append(KPixelFormatRGB_565);
-	else if (aPixelFormat == EUidPixelFormatYUV_422Interleaved)
-		aBuffer.Append(KPixelFormatYUV_422Interleaved);
-	else if (aPixelFormat == EUidPixelFormatSpeedTaggedJPEG)
-		aBuffer.Append(KPixelFormatSpeedTaggedJPEG);
-	else if (aPixelFormat == EUidPixelFormatJPEG)
-		aBuffer.Append(KPixelFormatJPEG);
-	else
-		aBuffer.Append(KPixelFormatUnknown);
-	}
-
-void PrintCamModes(TCameraCapsV02* aCaps,RTest& aTest)
-	{
-	TBuf<80> buf;
-
-	// Display the supported capture modes
-	buf.Zero();
-	buf.Append(KCaptureModeCapsTitle);
-	if (aCaps->iNumImagePixelFormats)
-		buf.Append(KCaptureModeImage);
-	if (aCaps->iNumVideoPixelFormats)
-		buf.Append(KCaptureModeVideo);
-	if (aCaps->iNumViewFinderPixelFormats)
-		buf.Append(KCaptureModeViewFinder);
-	buf.Append(_L("\r\n"));
-	aTest.Printf(buf);
-
-	// Display the supported video pixel formats
-	TUint i;
-	SDevCamPixelFormat* pixelFormat;
-	if (aCaps->iNumImagePixelFormats)
-		{
-		buf.Zero();
-		buf.Append(KPixelFormatCapsTitle);
-		buf.Append(KCaptureModeImage);
-		pixelFormat = (SDevCamPixelFormat*) (aCaps + 1);
-		for (i = 0; i < aCaps->iNumImagePixelFormats; i++)
-			{
-			AppendPixelFormat(buf, pixelFormat->iPixelFormat);
-			pixelFormat++;
-			}
-		buf.Append(_L("\r\n"));
-		aTest.Printf(buf);
-		}
-
-	if (aCaps->iNumVideoPixelFormats)
-		{
-		buf.Zero();
-		buf.Append(KPixelFormatCapsTitle);
-		buf.Append(KCaptureModeVideo);
-		pixelFormat = (SDevCamPixelFormat*) (aCaps + 1);
-		for (i = aCaps->iNumImagePixelFormats; i < (aCaps->iNumImagePixelFormats + aCaps->iNumVideoPixelFormats); i++)
-			{
-			AppendPixelFormat(buf, pixelFormat->iPixelFormat);
-			pixelFormat++;
-			}
-		buf.Append(_L("\r\n"));
-		aTest.Printf(buf);
-		}
-
-	if (aCaps->iNumViewFinderPixelFormats)
-		{
-		buf.Zero();
-		buf.Append(KPixelFormatCapsTitle);
-		buf.Append(KCaptureModeViewFinder);
-		pixelFormat = (SDevCamPixelFormat*) (aCaps + 1);
-		i = aCaps->iNumImagePixelFormats + aCaps->iNumImagePixelFormats + 1;
-		for (i = aCaps->iNumImagePixelFormats + aCaps->iNumVideoPixelFormats; i < (aCaps->iNumImagePixelFormats + aCaps->iNumVideoPixelFormats + aCaps->iNumViewFinderPixelFormats); i++)
-			{
-			AppendPixelFormat(buf, pixelFormat->iPixelFormat);
-			pixelFormat++;
-			}
-		buf.Append(_L("\r\n"));
-		aTest.Printf(buf);
-		}
-	}
-
-void PrintCamConf(TCameraConfigV02& aConf,RTest& aTest)
-	{
-	TBuf<80> buf;
-
-	// Display the current frame size
-	buf.Zero();
-	buf.Append(KFrameSizeConfTitle);
-	buf.AppendFormat(KFrameSize, aConf.iFrameSize.iWidth, aConf.iFrameSize.iHeight);
-	buf.Append(_L("\r\n"));
-	aTest.Printf(buf);
-
-	// Display the current pixel format
-	buf.Zero();
-	buf.Append(KPixelFormatConfTitle);
-	AppendPixelFormat(buf, aConf.iPixelFormat.iPixelFormat);
-	buf.Append(_L("\r\n"));
-	aTest.Printf(buf);
-
-	// Display the current frame rate
-	buf.Zero();
-	buf.Format(_L("Current frame rate  : %d fps\r\n"),aConf.iFrameRate);
-	aTest.Printf(buf);
-	}
-
-void PrintBufferConf(TMmSharedChunkBufConfig& aBufConf,RTest& aTest)
-	{
-	TBuf<80> buf(0);
-
-	SBufSpecList* tempSpec = aBufConf.iSpec;
-
-	// Display the buffer configuration
-	buf.Format(_L("Buffer Config       : NumBufs:%d Size:%xH\r\n"),aBufConf.iNumBuffers,aBufConf.iBufferSizeInBytes);
-	aTest.Printf(buf);
-	if (aBufConf.iFlags & KScFlagBufOffsetListInUse)
-		{
-		buf.Format(_L(" Offsets[%08xH,%08xH,%08xH,%08xH]\r\n"),tempSpec[0].iBufferOffset,tempSpec[1].iBufferOffset,tempSpec[2].iBufferOffset,tempSpec[3].iBufferOffset);
-		aTest.Printf(buf);
-		buf.Format(_L(" Offsets[%08xH,%08xH,%08xH,%08xH]\r\n"),tempSpec[4].iBufferOffset,tempSpec[5].iBufferOffset,tempSpec[6].iBufferOffset,tempSpec[7].iBufferOffset);
-		aTest.Printf(buf);
-		}
-	}
--- a/kerneltest/e32test/multimedia/t_camera_display.h	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-// Copyright (c) 2006-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\multimedia\t_camera_display.h
-// 
-//
-
-#if !defined(__T_CAMERA_DISPLAY_H__)
-#define __T_CAMERA_DISPLAY_H__
-
-#include <e32test.h>
-#include <d32camerasc.h>
-#include <pixelformats.h>
-#include "d_mmcsc.h"
-
-_LIT(KCaptureModeCapsTitle, "Capture modes: ");
-_LIT(KCaptureModeImage, "Image ");
-_LIT(KCaptureModeVideo, "Video ");
-_LIT(KCaptureModeViewFinder, "ViewFinder ");
-
-_LIT(KPixelFormatCapsTitle, "Pixel formats: ");
-_LIT(KPixelFormatConfTitle, "Current pixel format: ");
-_LIT(KPixelFormatUnknown, "Pixel Format Unknown (Other) ");
-_LIT(KPixelFormatRGB_565, "RGB565 ");
-_LIT(KPixelFormatYUV_422Interleaved, "YUV422 Interleaved ");
-_LIT(KPixelFormatSpeedTaggedJPEG, "Speed Tagged JPEG ");
-_LIT(KPixelFormatJPEG, "JPEG ");
-
-class TCamDisplayHandler
-	{
-public:
-	TCamDisplayHandler();
-	TInt Init();
-	TInt SetConfig(const SDevCamFrameSize& aSize,const SDevCamPixelFormat& aPixelFormat);
-	TInt Process(TUint8* aImageBaseAddress);
-private:
-	TInt Min(TInt aA, TInt aB);
-	TInt ProcessRGB565(TUint8* aImageBaseAddress);
-	TInt ProcessYUV422(TUint8* aImageBaseAddress);
-private:
-	/** Pixel format of the data to be converted and displayed */
-	SDevCamPixelFormat iPixelFormat;
-	/** Address of the top left hand corner of screen memory */
-	TUint8* iVideoAddress;
-	/** Width of the frame to be displayed, in pixels */
-	TUint iWidth;
-	/** Height of the frame to be displayed, in pixels */
-	TUint iHeight;
-	/** Width of the screen, in pixels */
-	TUint iScreenWidth;
-	/** Height of the screen, in pixels */
-	TUint iScreenHeight;
-	/** Number of bits per pixel */
-	TInt iBitsPerPixel;
-	};
-
-void AppendPixelFormat(TDes& aBuffer, TUidPixelFormat aPixelFormat);
-void PrintCamModes(TCameraCapsV02* aCaps,RTest& aTest);
-void PrintCamConf(TCameraConfigV02& aConf,RTest& aTest);
-void PrintBufferConf(TMmSharedChunkBufConfig& aBufConf,RTest& aTest);
-
-#endif // __T_CAMERA_DISPLAY_H__
--- a/kerneltest/e32test/multimedia/t_camera_gen.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,494 +0,0 @@
-// Copyright (c) 2004-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\multimedia\t_camera_gen.cpp
-// 
-//
-
-#include <e32test.h>
-#include <d32camerasc.h>
-#include <e32def.h>
-#include <e32def_private.h>
-#include "t_camera_display.h"
-#include "d_mmcsc.h"
-
-_LIT(KTstLddFileName,"D_MMCSC.LDD");
-_LIT(KCamLddFileName,"ECAMERASC.LDD");
-
-#ifdef __WINSCW__
-_LIT(KCamPddFileName,"_TEMPLATE_CAMERASC.PDD");
-#else
-_LIT(KCamPddFileName,"CAMERASC.PDD");
-#endif
-
-_LIT(KCamFreePddExtension,".*");
-
-const TInt KUnit0=0;
-const TInt KFrameRate=30;		// Run the test at 30fps
-
-class CCameraHandler;
-
-RTest test(_L("T_CAMERA_GEN"));
-CCameraHandler* camera;
-
-/**
-Wait for a key press, but timeout so automated tests
-are unaffected
-*/
-void util_getch_withtimeout(TUint aSecs)
-	{
-	TRequestStatus keyStat;
-	test.Console()->Read(keyStat);
-	RTimer timer;
-	test(timer.CreateLocal()==KErrNone);
-	TRequestStatus timerStat;
-	timer.After(timerStat,aSecs*1000000);
-	User::WaitForRequest(timerStat,keyStat);
-	if(keyStat!=KRequestPending)
-		(void)test.Console()->KeyCode();
-	timer.Cancel();
-	timer.Close();
-	test.Console()->ReadCancel();
-	User::WaitForAnyRequest();
-	}
-
-// Define the frame number to capture
-// For image capture this should be zero.
-const TInt64 KFrameNumberToCapture= 50;
-
-/// Defines camera handler
-class CCameraHandler : public CActive
-	{
-public:
-	static CCameraHandler* NewL();
-	~CCameraHandler();
-	TInt SetConfig(TDevCamCaptureMode aCaptureMode, SDevCamFrameSize aSize,SDevCamPixelFormat aPixelFormat,TBool aCreateChunk,TInt aNumBuffers);
-	void GetConfig(TDevCamCaptureMode aCaptureMode);
-	TInt GetCaps();
-	TInt SetFirstConfig(TUint aOffset);
-	TInt Start(TDevCamCaptureMode aCaptureMode);
-	TInt Stop();
-	void SetCaptureMode(TDevCamCaptureMode aCaptureMode);
-private:
-	CCameraHandler();
-	virtual void RunL();
-	virtual void DoCancel();
-	TInt Init();
-private:
-	TCamDisplayHandler iDispHandler[ECamCaptureModeMax];
-	RDevCameraSc iCamera;
-	RChunk iChunk[ECamCaptureModeMax];
-	TInt iFrameCount;
-	TDevCamCaptureMode iCaptureMode;
-	TInt iCapsSize;
-	TAny* iCapsBufPtr;
-	TCameraCapsV02* iCameraCaps;
-	};
-
-CCameraHandler::CCameraHandler() : CActive(EPriorityStandard)
-//
-// Constructor for the camera handler
-//
-	{
-	// Active object priority is set to normal
-	}
-
-CCameraHandler::~CCameraHandler()
-//
-// Destructor for the camera handler
-//
-	{
-	for (TInt captureMode=0; captureMode < ECamCaptureModeMax; captureMode++)
-		iChunk[captureMode].Close();
-	if(iCapsBufPtr)
-		User::Free(iCapsBufPtr);
-	iCamera.Close();
-	// Cancel any active request
-	CActive::Cancel();
-	}
-
-void CCameraHandler::DoCancel()
-	{
-
-	}
-
-CCameraHandler* CCameraHandler::NewL()
-//
-// Create active camera
-//
-	{
-	test.Printf(_L("NewL\r\n"));
-	CCameraHandler *cc = new (ELeave) CCameraHandler;
-	TInt r=cc->Init();
-	if (r!=KErrNone)
-		User::Leave(r);
-	CActiveScheduler::Add(cc);
-	return(cc);
-	}
-
-TInt CCameraHandler::Init()
-//
-// Initialise hardware
-//
-	{
-	test.Printf(_L("Init\r\n"));
-	TInt r;
-	for (TInt captureMode=0; captureMode < ECamCaptureModeMax; captureMode++)
-		{
-		r=iDispHandler[captureMode].Init();
-		if (r!=KErrNone)
-			return(r);
-		}
-
-	// Open camera driver channel
-	r=iCamera.Open(KUnit0);
-	return(r);
-	}
-
-void CCameraHandler::SetCaptureMode(TDevCamCaptureMode aCaptureMode)
-	{
-	iCaptureMode=aCaptureMode;
-	}
-
-TInt CCameraHandler::GetCaps()
-	{
-	test.Printf(_L("GetCaps\r\n"));
-	iCapsSize=iCamera.CapsSize();
-	iCapsBufPtr = User::Alloc(iCapsSize);
-	TPtr8 capsPtr( (TUint8*)iCapsBufPtr, iCapsSize, iCapsSize );
-	TInt r = iCamera.Caps(capsPtr);
-	if(r!=KErrNone)
-		return r;
-	iCameraCaps = (TCameraCapsV02*) capsPtr.Ptr();
-
-	test.Printf(_L("Number of supported pixel formats:%d\r\n"),iCameraCaps->iNumVideoPixelFormats);
-	return r;
-	}
-
-void CCameraHandler::GetConfig(TDevCamCaptureMode aCaptureMode)
-	{
-	test.Printf(_L("GetConfig\r\n"));
-	// Config camera
-	TCameraConfigV02Buf configBuf;
-	TCameraConfigV02 &config=configBuf();
-
-	iCamera.GetCamConfig(aCaptureMode, configBuf);
-
-	test.Printf(_L("Pixel Format:%d\r\n"),config.iPixelFormat);
-	test.Printf(_L("Frame Size  :%d\r\n"),config.iFrameSize);
-	test.Printf(_L("Frame rate  :%dfps\r\n"),config.iFrameRate);
-	}
-
-TInt CCameraHandler::SetFirstConfig(TUint aOffset)
-	{
-	test.Printf(_L("SetFirstConfig\r\n"));
-	TInt ret;
-	TAny* frameSizeCapsBuf=0;
-	SDevCamPixelFormat* pixelFormat;
-	SDevCamFrameSize* frameSize;
-	TPtr8 frameSizeCapsPtr(0,0,0);
-	pixelFormat = (SDevCamPixelFormat*) (iCameraCaps + 1);
-
-	if(camera->iCameraCaps->iNumVideoPixelFormats)
-		{
-		pixelFormat = pixelFormat + iCameraCaps->iNumImagePixelFormats + iCameraCaps->iNumVideoPixelFormats;
-		frameSizeCapsBuf = User::Alloc(pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		new (&frameSizeCapsPtr) TPtr8((TUint8*)frameSizeCapsBuf, pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize), pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
-		ret=iCamera.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizeCapsPtr);
-		test(ret==KErrNone);
-		frameSize = (SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
-		if((pixelFormat->iNumFrameSizes>aOffset) && aOffset)
-			frameSize += aOffset;
-		ret=camera->SetConfig(ECamCaptureModeVideo,*frameSize,*pixelFormat,ETrue,3);
-		test(ret==KErrNone);
-		User::Free(frameSizeCapsBuf);
-		return(KErrNone);
-		}
-	else
-		return(KErrNotSupported);
-	}
-
-TInt CCameraHandler::SetConfig(TDevCamCaptureMode aCaptureMode, SDevCamFrameSize aSize,SDevCamPixelFormat aPixelFormat,TBool aCreateChunk,TInt aNumBuffers)
-	{
-	test.Printf(_L("SetConfig\r\n"));
-	TInt r=iDispHandler[aCaptureMode].SetConfig(aSize,aPixelFormat);
-	if (r!=KErrNone)
-		return(r);
-
-	// Config camera
-	TCameraConfigV02Buf configBuf;
-	TCameraConfigV02 &config=configBuf();
-	iCamera.GetCamConfig(aCaptureMode, configBuf);		// Load defaults
-
-	config.iFrameSize=aSize;
-	config.iPixelFormat=aPixelFormat;
-	config.iFrameRate=KFrameRate;
-
-	TMmSharedChunkBufConfig bufferConfig;
-	TPckg<TMmSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
-
-	r=iCamera.SetCamConfig(aCaptureMode,configBuf);
-	if (r!=KErrNone)
-		return(r);
-
-	if (aCreateChunk)
-		{
-		r=iCamera.SetBufConfigChunkCreate(aCaptureMode,aNumBuffers,iChunk[aCaptureMode]);
-		if (r!=KErrNone)
-			return(r);
-		}
-	else
-		{
-		// 'aNumBuffers' is ignored here, D_MMCSC.LDD currently uses 2 buffers
-
-		RMmCreateSc tstDrv;
-		r=tstDrv.Open();
-		if (r!=KErrNone)
-			return(r);
-		r=tstDrv.GetChunkHandle(iChunk[aCaptureMode]);	// Get a handle on the shared chunk created by the test driver
-		if (r!=KErrNone)
-			return(r);
-		r=tstDrv.GetBufInfo(bufferConfigBuf);
-		if (r!=KErrNone)
-			return(r);
-		r=iCamera.SetBufConfigChunkOpen(aCaptureMode,bufferConfigBuf,iChunk[aCaptureMode]);
-		if (r!=KErrNone)
-			return(r);
-
-		tstDrv.Close();
-		}
-
-	iCamera.GetBufferConfig(aCaptureMode, bufferConfigBuf);
-	PrintBufferConf(bufferConfig,test);
-
-	return(r);
-	}
-
-TInt CCameraHandler::Start(TDevCamCaptureMode aCaptureMode)
-//
-// Set object active, start getting images from the camera
-//
-	{
-	test.Printf(_L("Start\r\n"));
-	// Set object active
-	iFrameCount=0;
-	SetActive();
-	iCamera.SetCaptureMode(aCaptureMode);
-	// Add request for a new image
-	TInt r=iCamera.Start();
-	if (r==KErrNone)
-		iCamera.NotifyNewImage(iStatus);
-	return(r);
-	}
-
-void CCameraHandler::RunL()
-//
-// Handles a new request
-//
-	{
-	TInt retId=iStatus.Int();
-	TInt retOffset=-1;
-	iCamera.BufferIdToOffset(iCaptureMode,retId,retOffset);
-	if (retId>=0)
-		{
-		TUint8* imgBase=iChunk[iCaptureMode].Base()+retOffset;
-		TInt r=iDispHandler[iCaptureMode].Process(imgBase);
-		
-#ifdef __WINSCW__
-		test(r==KErrNotSupported);
-#else
-		test(r==KErrNone);
-#endif
-		
-		// Release the buffer
-		test(iCamera.ReleaseBuffer(retId)==KErrNone);
-		iFrameCount++;
-		}
-	else
-		test.Printf(_L("Capture error (%d)\r\n"),retId);
-
-	if (iFrameCount<KFrameNumberToCapture)
-		{
-		// Add request for a new image
-		iCamera.NotifyNewImage(iStatus);
-		// re-set active
-		SetActive();
-		}
-
-	else
-		{
-		CActiveScheduler::Stop();
-		}
-	}
-
-TInt CCameraHandler::Stop()
-//
-// Stops camera
-//
-	{
-	test.Printf(_L("Stop\r\n"));
-	CActive::Cancel();
-	TInt r=iCamera.Stop();
-	return(r);
-	}
-
-//
-// Test for recording a certain number of frames in a particular configuration and displaying
-// the results.
-//
-void TestRecording()
-	{
-	TInt ret;
-
-	camera->GetConfig(ECamCaptureModeVideo);
-	camera->SetCaptureMode(ECamCaptureModeVideo);
-	test.Next(_L("Starting camera"));
-	ret=camera->Start(ECamCaptureModeVideo);
-	test.Printf(_L("Start returned %d\r\n"),ret);
-	test(ret==KErrNone);
-
-	// Calculate frame rate.
-	// We store cuurent time before receiving data from the camera and
-	// after to have received KFrameNumberToCapture pictures, we calculate
-	// time elapsed during the reception.
-	TTimeIntervalMicroSeconds microseconds ;
-	TTime now;
-	TTime iTime;
-	now.HomeTime();
-
-	test.Next(_L("Starting active scheduler"));
-	// Start active scheduler
-	CActiveScheduler::Start();
-
-	// We have received all pictures, so we store the new current time
-	iTime.HomeTime();
-
-	// We keep this time in microseconds to be more precise
-	microseconds = iTime.MicroSecondsFrom(now) ;
-
-	TInt64 timeElapsed = microseconds.Int64();
-
-	// We store in this variable, integer value of the frame rate
-	TInt64 intFrameRate = (TInt64)((KFrameNumberToCapture *1000000)/timeElapsed);
-
-	// We store in this variable, decimal value of the frame rate
-	TInt64 milliFrameRate = (TInt64)((KFrameNumberToCapture *1000000)%timeElapsed);
-	milliFrameRate = (milliFrameRate*1000) / timeElapsed;
-
-	test.Printf(_L("   Frame rate for frames received : %d.%03d frames per second\r\n"), static_cast<TInt>(intFrameRate), static_cast<TInt>(milliFrameRate));
-	test.Printf(_L("   Frame rate expected            : %d.000 frames per second\r\n"),KFrameRate);
-	test.Next(_L("Stopping camera"));
-	// Stop Camera
-	ret=camera->Stop();
-	test(ret==KErrNone);
-	}
-
-//
-// Test program main part
-//
-TInt E32Main()
-	{
-	__UHEAP_MARK;
-
-	test.Title();
-	test.Start(_L("Camera module GEN test"));
-
-	test.Next(_L("Loading CAMERA PDD"));
-	TInt ret=User::LoadPhysicalDevice(KCamPddFileName);
-	test.Printf(_L("Returned %d\r\n"),ret);
-
-	if (ret==KErrNotFound)
-		{
-		test.Printf(_L("Shared chunk camera driver not supported - test skipped\r\n"));
-		test.End();
-		test.Close();
-		__UHEAP_MARKEND;
-		return(KErrNone);
-		}
-
-	test(ret==KErrNone || ret==KErrAlreadyExists);
-
-	test.Next(_L("Loading CAMERA LDD"));
-	ret=User::LoadLogicalDevice(KCamLddFileName);
-	test.Printf(_L("Returned %d\r\n"),ret);
-	test(ret==KErrNone || ret==KErrAlreadyExists);
-
-	test.Next(_L("Loading D_MMCSC LDD"));
-	ret=User::LoadLogicalDevice(KTstLddFileName);
-	test.Printf(_L("Returned %d\r\n"),ret);
-	test(ret==KErrNone||ret==KErrAlreadyExists);
-
-	__KHEAP_MARK;
-
-	// Construct and install the active scheduler
-	test.Next(_L("Initialising active scheduler"));
-	CActiveScheduler *exampleScheduler = new (ELeave) CActiveScheduler();
-	// Install as the active scheduler
-	CActiveScheduler::Install(exampleScheduler);
-
-	// Create camera handler
-	test.Next(_L("Creating camera handler"));
-	camera = CCameraHandler::NewL();
-
-	test.Next(_L("+ Getting Camera Capabilities"));
-	ret=camera->GetCaps();
-	test(ret==KErrNone);
-
-	// SetConfig
-	test.Next(_L("Setting Camera Configuration"));
-	ret=camera->SetFirstConfig(0);
-	test(ret==KErrNone);
-	TestRecording();
-
-	// Repeat with a different configuration
-	test.Next(_L("Resetting Camera Configuration"));
-	ret=camera->SetFirstConfig(1);
-	test(ret==KErrNone);
-	TestRecording();
-
-	delete camera;
-	delete exampleScheduler;
-
-	__KHEAP_MARKEND;
-
-	// Free the PDDs and LDDs
-	test.Next(_L("Freeing ECAMERASC LDD"));
-	ret=User::FreeLogicalDevice(KDevCameraScName);
-	test(ret==KErrNone);
-
-	test.Next(_L("Freeing CAMERASC PDD")) ;
-	TFindPhysicalDevice fDr;
-	TFullName drivName;
-	TName searchName;
-	searchName.Append(KDevCameraScName);
-	searchName.Append(KCamFreePddExtension);
-	fDr.Find(searchName);
-	ret=fDr.Next(drivName);
-	test(ret==KErrNone);
-	ret=User::FreePhysicalDevice(drivName);
-	test(ret==KErrNone);
-
-	test.Next(_L("Freeing D_MMCSC LDD"));
-	ret=User::FreeLogicalDevice(KDevMmCScName);
-	test(ret==KErrNone);
-
-	test.Printf(_L("Hit any key to continue\r\n"));
-	util_getch_withtimeout(5);
-
-	test.End();
-	test.Close();
-
-	__UHEAP_MARKEND;
-
-	return KErrNone;
-	}
--- a/kerneltest/e32test/pccd/t_medch.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/pccd/t_medch.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -220,6 +220,10 @@
 					break;
 					}
 				}
+			else
+				{
+				break;
+				}
 			}
 		}
 
--- a/kerneltest/e32test/power/t_domain.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/power/t_domain.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2002-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"
@@ -806,7 +806,9 @@
 	void Perform();
 	void Release();
 	TInt TransitionNotification(MDmDomainMember& aDomainMember);
-	void TransitionRequestComplete();
+	void TransitionRequestComplete();	
+	void RunTestOnGetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailure);
+	
 	CDmTest5(TDmDomainId aPowerId, TDmDomainId aTestId, TDmDomainState aPowerState, TDmDomainState aTestState) : 
 		CActive(CActive::EPriorityStandard), 
 		iPowerDomainId(aPowerId), iTestDomainId(aTestId), iPowerState(aPowerState), iTestState(aTestState) {}
@@ -846,7 +848,28 @@
 	TInt				iTransitionsExpected;
 	};
 
-
+void CDmTest5::RunTestOnGetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailure)
+	{
+	//*************************************************
+	// Test - OOM Testing on GetTransitionFailures()
+	// Simulates heap failure in GetTransitionFailures()
+	//*************************************************
+	TInt error = 0;
+	TInt count = 0;	
+	do
+		{		
+		__UHEAP_SETFAIL(RHeap::EFailNext, ++count);
+		error = iTestDomainManager.GetTransitionFailures(aTransitionFailure);						
+		test.Printf( _L( "CDmTest5::RunTestOnGetTransitionFailures, simulating heap failure on GetTransitionFailures(), Error=%d, Run=%d\n" ), error, count );
+		}while(error == KErrNoMemory);		
+		
+	__UHEAP_RESET;
+	
+	//Actual count of heap failure as the final iteration which terminates the loop would not return KErrNoMemory 
+	--count;
+	test(count > 0);
+	test.Printf( _L( "Out of memory tests on GetTransitionFailures() succeeded at heap failure rate of %i\n" ), count );
+	}
 
 //! @SYMTestCaseID PBASE-T_DOMAIN-5
 //! @SYMTestType CT
@@ -1106,6 +1129,18 @@
 	testFailureCount = iTestDomainManager.GetTransitionFailureCount();
 	test (testFailureCount == 1);
 
+#ifdef _DEBUG
+	//***************************************************************
+	// OOM Testing: Simulates heap failure in GetTransitionFailures()
+	//***************************************************************
+	__UHEAP_MARK;
+	RArray<const TTransitionFailure> oomTestFailures;
+	RunTestOnGetTransitionFailures(oomTestFailures);
+	test(oomTestFailures.Count()==1);
+	oomTestFailures.Close();
+	__UHEAP_MARKEND;
+#endif
+	
 	r = iTestDomainManager.GetTransitionFailures(testFailures);
 	test(r == KErrNone);
 	test(testFailureCount == testFailures.Count());
@@ -2210,7 +2245,6 @@
 		{
 		MDmTest* tests[] = 
 			{
-
 			new CDmTest1(KDmIdRoot, EPwStandby),
 			new CDmTest1(KDmIdRoot, EPwOff),
 			new CDmTest1(KDmIdRoot, EPwActive),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resmanus/d_resmanusbtrace.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,351 @@
+// 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\resmanus\d_resmanusbtrace.cpp
+// 
+//
+
+#include <kernel/kernel.h>
+#include <drivers/resource.h>
+#include <drivers/resourcecontrol.h>
+#include <drivers/resmanus_trace.h>
+#include <drivers/resourcecontrol_trace.h>
+#include "d_resmanusbtraceconst.h"
+#include "d_resmanusbtrace.h"
+
+class DTestFactory : public DLogicalDevice
+//
+// Test LDD factory
+//
+	{
+public:
+	DTestFactory();
+	virtual TInt Install(); 					//overriding pure virtual
+	virtual void GetCaps(TDes8& aDes) const;	//overriding pure virtual
+	virtual TInt Create(DLogicalChannelBase*& aChannel); 	//overriding pure virtual
+	};
+
+class DTest1 : public DLogicalChannelBase
+//
+// Test logical channel
+//
+	{
+public:
+	virtual ~DTest1();
+protected:
+	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
+
+private:
+	TInt DoSendLog(TLogInfo* aInfo);
+	TInt ClientHandle() { return KClientHandle; }
+	};
+
+
+
+DECLARE_STANDARD_LDD()
+	{
+	return new DTestFactory;
+	}
+
+//
+// Constructor
+//
+DTestFactory::DTestFactory()
+	{
+
+	}
+
+TInt DTestFactory::Create(DLogicalChannelBase*& aChannel)
+	{
+//
+// Create new channel
+//
+	aChannel=new DTest1;
+	return aChannel?KErrNone:KErrNoMemory;
+	}
+
+TInt DTestFactory::Install()
+//
+// Install the LDD - overriding pure virtual
+//
+	{
+	return SetName(&KLddName);
+	}
+
+void DTestFactory::GetCaps(TDes8& /*aDes*/) const
+//
+// Get capabilities - overriding pure virtual
+//
+	{
+	}
+
+TInt DTest1::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
+//
+// Create channel
+//
+	{
+	return KErrNone;
+	}
+
+DTest1::~DTest1()
+//
+// Destructor
+//
+	{
+	}
+
+TInt DTest1::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/)
+	{
+
+	// 'Control' functions...
+	switch(aReqNo)
+		{
+		// DoControl
+		case RLddTest1::ECONTROL_SENDLOG:
+		    TLogInfo info;
+			DoSendLog(&info);
+			Kern::ThreadRawWrite(&Kern::CurrentThread(), a1, &info, sizeof(info));
+			break;
+		}
+
+	return KErrNone;
+	}
+	
+class TestResource 
+    {
+public:
+    TestResource(const TDesC8& aName, TInt aDefaultLevel)
+        {
+        iName = (HBuf8*)&aName;
+        iDefaultLevel = aDefaultLevel;
+        }
+    HBuf* iName;
+    TInt iDefaultLevel;
+    TInt iResourceId;
+    };
+
+struct TestClient
+    {
+    TDes8* iName;
+    TInt iClientId;
+    };
+
+struct TestCallback
+    {
+    TInt iResourceId;
+    TInt iClientId;
+    };
+
+struct TestNotification
+    {
+    TestCallback iCallback;
+    };
+
+class TestRequest
+    {
+public:
+    TInt ResourceId() {return iResourceId;}
+    TInt ClientId() {return iClientId;}
+    TInt Level() {return iLevel;}
+    TInt iResourceId;
+    TInt iClientId;
+    TInt iLevel;
+    };
+
+TInt DTest1::DoSendLog(TLogInfo* aInfo)
+	{
+	TInt r = KErrNoMemory;
+	
+	TInt iClient = (TInt) KClient;
+	TBuf<80> Buffer;
+	TDes8* iUserNameUsed = &Buffer;
+	Buffer.Append(KCLIENTNAME);
+	Kern::Printf("PRM_US_OPEN_CHANNEL_START_TRACE");
+	PRM_US_OPEN_CHANNEL_START_TRACE
+	
+	Kern::Printf("PRM_US_OPEN_CHANNEL_END_TRACE %x", (TInt)ClientHandle());
+	PRM_US_OPEN_CHANNEL_END_TRACE
+	
+	TUint8 stateRes[3] = {KStatsRes1, KStatsRes2, KStatsRes3};
+	Kern::Printf("PRM_US_REGISTER_CLIENT_START_TRACE");
+	PRM_US_REGISTER_CLIENT_START_TRACE
+
+	Kern::Printf("PRM_US_REGISTER_CLIENT_END_TRACE");
+	PRM_US_REGISTER_CLIENT_END_TRACE
+	
+	Kern::Printf("PRM_US_DEREGISTER_CLIENT_START_TRACE");
+	PRM_US_DEREGISTER_CLIENT_START_TRACE
+	
+    Kern::Printf("PRM_US_DEREGISTER_CLIENT_END_TRACE");
+	PRM_US_DEREGISTER_CLIENT_END_TRACE	
+	
+	TUint resourceId = KResourceId;
+    Kern::Printf("PRM_US_GET_RESOURCE_STATE_START_TRACE");
+	PRM_US_GET_RESOURCE_STATE_START_TRACE
+	
+	TUint aResourceId = KResourceId;
+	TUint aLevel = KLevel;
+	TUint aClient = KClient;
+	TUint aResult = KResult;
+    Kern::Printf("PRM_US_GET_RESOURCE_STATE_END_TRACE");
+	PRM_US_GET_RESOURCE_STATE_END_TRACE
+	
+	TUint newState = KLevel;
+    Kern::Printf("PRM_US_SET_RESOURCE_STATE_START_TRACE");
+	PRM_US_SET_RESOURCE_STATE_START_TRACE
+	
+    Kern::Printf("PRM_US_SET_RESOURCE_STATE_END_TRACE");
+	PRM_US_SET_RESOURCE_STATE_END_TRACE
+	
+	Kern::Printf("PRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE");
+	PRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE
+	
+	Kern::Printf("PRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE");
+	PRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE
+	
+	Kern::Printf("PRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE");
+	PRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE
+	
+	Kern::Printf("PRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE");
+	PRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE
+	
+	TPowerResourceInfoV01 ResourceInfo;
+	TPowerResourceInfoV01* pResInfo = &ResourceInfo;
+	TestResource Resource(KRESOURCENAME, KDefaultLevel);
+	TestResource* pR = &Resource;
+	pResInfo->iMinLevel = KMinLevel;
+	pResInfo->iMaxLevel = KMaxLevel;
+	pResInfo->iDefaultLevel = KDefaultLevel;
+	TUint resCount = KResCount;
+    Kern::Printf("PRM_REGISTER_RESOURCE_TRACE");
+	PRM_REGISTER_RESOURCE_TRACE
+	
+	TUint aClientId = KClientId;
+	TBuf8<80> ClientName(KCLIENTNAME);
+	SPowerResourceClient ResourceClient;
+	SPowerResourceClient* pC = &ResourceClient;
+	pC->iName = &ClientName;
+    Kern::Printf("PRM_CLIENT_REGISTER_TRACE");
+	PRM_CLIENT_REGISTER_TRACE
+	
+    Kern::Printf("PRM_CLIENT_DEREGISTER_TRACE");
+	PRM_CLIENT_DEREGISTER_TRACE
+	
+	TInt aNewState = KLevel;
+	pC->iClientId = KClientId;
+	Kern::Printf("PRM_CLIENT_CHANGE_STATE_START_TRACE");
+	PRM_CLIENT_CHANGE_STATE_START_TRACE
+
+	pC->iClientId = KClientId;
+	Kern::Printf("PRM_CLIENT_CHANGE_STATE_END_TRACE");
+	PRM_CLIENT_CHANGE_STATE_END_TRACE
+	
+	TestNotification aN;
+	TestNotification* pN = &aN;
+	pN->iCallback.iResourceId = KResourceId;
+	
+    Kern::Printf("PRM_POSTNOTIFICATION_REGISTER_TRACE");
+	PRM_POSTNOTIFICATION_REGISTER_TRACE
+
+    Kern::Printf("PRM_POSTNOTIFICATION_DEREGISTER_TRACE");
+	PRM_POSTNOTIFICATION_DEREGISTER_TRACE
+	
+    Kern::Printf("PRM_POSTNOTIFICATION_SENT_TRACE");
+	PRM_POSTNOTIFICATION_SENT_TRACE
+	
+	TestCallback* pCb = &(pN->iCallback);
+	pCb->iClientId = KClientId;
+    Kern::Printf("PRM_CALLBACK_COMPLETION_TRACE");
+	PRM_CALLBACK_COMPLETION_TRACE
+	
+	TInt size = KSize;
+	PRM_MEMORY_USAGE_TRACE
+	
+	TestRequest aRequest;
+	aRequest.iClientId = KClientId;
+	aRequest.iResourceId = KResourceId;
+	
+	TDesC8* iName = iUserNameUsed;
+    Kern::Printf("PRM_PSL_RESOURCE_GET_STATE_START_TRACE");
+	PRM_PSL_RESOURCE_GET_STATE_START_TRACE
+	
+    Kern::Printf("PRM_RESOURCE_GET_STATE_START_TRACE");
+	PRM_RESOURCE_GET_STATE_START_TRACE
+	
+	TInt retVal = KRetVal;
+	TInt iCurLevel = KLevel;
+	TInt aState = KLevel;
+    Kern::Printf("PRM_PSL_RESOURCE_GET_STATE_END_TRACE");
+	PRM_PSL_RESOURCE_GET_STATE_END_TRACE
+	
+    Kern::Printf("PRM_RESOURCE_GET_STATE_END_TRACE");
+	PRM_RESOURCE_GET_STATE_END_TRACE
+	
+    Kern::Printf("PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE");
+	PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE
+	
+	aRequest.iLevel = KLevel;
+    Kern::Printf("PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE");
+	PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE
+	
+    Kern::Printf("PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE");
+	PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE
+	
+	TInt iDefaultLevel = KDefaultLevel;
+	TInt iFlags = KFlags;
+	TInt iMinLevel = KMinLevel;
+	TInt iMaxLevel = KMaxLevel;
+	TInt aReason = KErrNoMemory;
+    Kern::Printf("PRM_PSL_RESOURCE_CREATE_TRACE");
+	PRM_PSL_RESOURCE_CREATE_TRACE
+	
+    Kern::Printf("PRM_BOOTING_TRACE");
+	PRM_BOOTING_TRACE
+	
+	TestResource* aPDRes = &Resource;
+	aPDRes->iResourceId = KResourceId;
+	TestClient Client;
+	TestClient* aClientPtr = &Client;
+	aClientPtr->iName = &ClientName;
+	aClientPtr->iClientId = KClientId;
+    Kern::Printf("PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE");
+	PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE
+
+	TestResource* pDR = &Resource;
+	TInt level = KLevel;
+    Kern::Printf("PRM_REGISTER_DYNAMIC_RESOURCE_TRACE");
+	PRM_REGISTER_DYNAMIC_RESOURCE_TRACE
+	
+    Kern::Printf("PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE");
+	PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE
+	
+	TestResource* pR1 = &Resource;
+	TestResource* pR2 = &Resource;
+    Kern::Printf("PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE");
+	PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE
+	
+	TestResource* pDR1 = &Resource;
+	TestResource* pDR2 = &Resource;
+    Kern::Printf("PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE");
+	PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE
+	
+	aInfo->iPR = &Resource;
+	aInfo->iPC = &ResourceClient;
+	aInfo->iPN = pN;
+	aInfo->iPCb = pCb;
+	aInfo->iPClient = &Client;
+	aInfo->iPCallback = &(pN->iCallback);
+	
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resmanus/d_resmanusbtrace.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,46 @@
+// 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\resmanus\d_resmanusbtrace.h
+// 
+//
+
+#if !defined(__D_RESMANUSBTRACE_H__)
+#define __D_RESMANUSBTRACE_H__
+
+#include <e32cmn.h>
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
+
+_LIT(KLddName,"D_RESMANUSBTRACE.LDD");
+
+class RLddTest1 : public RBusLogicalChannel
+	{
+public:
+	enum TControl
+		{
+		ECONTROL_SENDLOG
+		};
+
+public:
+#ifndef __KERNEL_MODE__
+
+	inline TInt Open()
+		{ return DoCreate(KLddName,TVersion(0,1,1),KNullUnit,NULL,NULL); }
+	inline TInt SendLog(TLogInfo* aInfo)
+		{ return DoControl(ECONTROL_SENDLOG, aInfo); }
+
+#endif 
+	};
+#endif   //__D_RESMANUSBTRACE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resmanus/d_resmanusbtrace.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,39 @@
+// 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/resmanus/d_resmanusbtrace.mmp
+// 
+//
+
+#include "kernel/kern_ext.mmh"
+
+TARGET         d_resmanusbtrace.ldd
+TARGETTYPE     LDD
+SOURCEPATH     .
+SOURCE         d_resmanusbtrace.cpp
+
+
+EPOCALLOWDLLDATA
+
+UID		0x100000af
+VENDORID 0x70000001
+
+macro BTRACE_RESMANUS
+macro BTRACE_RESOURCE_MANAGER
+macro PRM_ENABLE_EXTENDED_VERSION
+capability		all
+
+start wins
+win32_headers
+end
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resmanus/d_resmanusbtraceconst.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,54 @@
+// 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\resmanus\d_resmanusbtraceconst.h
+// 
+//
+
+#ifndef D_RESMANUSBTRACECONST_H_
+#define D_RESMANUSBTRACECONST_H_
+
+
+const TUint KClientId = 0x12345678;
+const TInt KClientHandle = 0x10;
+const TUint8 KStatsRes1 = 0x20;
+const TUint8 KStatsRes2 = 0x21;
+const TUint8 KStatsRes3 = 0x22;
+const TUint KResourceId = 0x80;
+const TUint KLevel = 0x90;
+const TUint KClient = 0xC800FFFF;
+const TUint KResult = 0x100;
+const TInt KMinLevel = -99;
+const TInt KMaxLevel = 99;
+const TInt KDefaultLevel = 50;
+const TInt KResCount = 20;
+const TInt KSize = 999;
+const TInt KRetVal = KErrNoMemory;
+const TUint KFlags = 0xAAAAAAAA;
+
+_LIT8(KRESOURCENAME, "ResourceName");
+_LIT8(KCLIENTNAME, "ClientName");
+
+struct TLogInfo
+    {
+    TAny* iPR;
+    TAny* iPC;
+    TAny* iPN;
+    TAny* iPCb;
+    TAny* iPClient;
+    TAny* iPCallback;
+    };
+
+
+
+#endif /* D_RESMANUSBTRACECONST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resmanus/t_resmanusbtrace.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,754 @@
+// 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\resmanus\t_resmanusbtrace.cpp
+// 
+//
+
+#include <e32test.h>
+#include <e32hal.h>
+#include <d32btrace.h>
+#include <e32btrace.h>
+#include <e32svr.h>
+#include <hal.h>
+#include <u32hal.h>
+#include "d_resmanusbtraceconst.h"
+#include "d_resmanusbtrace.h"
+
+_LIT(KLddFileName, "D_RESMANUSBTRACE.LDD");
+
+RLddTest1 ldd;
+GLDEF_D RTest test(_L("T_RESMANUSBTRACE"));
+
+TInt BTraceHeaderSize = 0;
+
+RBTrace Trace;
+TUint8* BufferPtr;
+TInt Count;
+TLogInfo LogInfo;
+
+CConsoleBase* console;
+
+class CTestTraceBase
+    {
+public:    
+    CTestTraceBase(TUint8** aBufferPtrAddr, TInt aHeaderSize) : 
+            iBufferPtrAddr(aBufferPtrAddr), iHeaderSize(aHeaderSize)
+        {
+        iBuffer.Zero();
+        }
+    void SkipHeader()
+        {
+        *iBufferPtrAddr += iHeaderSize;
+        }
+    TInt Compare()
+        {
+	TInt i = 0;
+        TPtrC8 ptr2(*iBufferPtrAddr, iBuffer.Length());
+        TUint length = iBuffer.Length();
+        length = (length + 0x3) & (~0x3);
+
+        for(i = 0; i < ptr2.Length(); i++)
+            {
+            test.Printf(_L("%02x "), ptr2.Ptr()[i]);
+            }
+        test.Printf(_L("\n"));
+        for(i = 0; i < iBuffer.Length(); i++)
+            {
+            test.Printf(_L("%02x "), iBuffer.Ptr()[i]);
+            }
+        test.Printf(_L("\n"));
+
+        *iBufferPtrAddr += length;
+        return (iBuffer.Compare(ptr2)==0)?KErrNone:KErrCorrupt;
+        }
+    void AppendUInt(TUint aVal)
+        {
+        iBuffer.Append((TUint8*)&aVal, sizeof(TUint));
+        }
+    void AppendInt(TInt aVal)
+        {
+        iBuffer.Append((TUint8*)&aVal, sizeof(TInt));
+        }    
+    void AppendDes(const TDesC8& aDesPtr)
+        {
+        iBuffer.Append(aDesPtr);
+        }
+    TUint8** iBufferPtrAddr;
+    TBuf8<80> iBuffer;
+    TInt iHeaderSize;
+    };
+
+class Test_PRM_US_OPEN_CHANNEL_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_OPEN_CHANNEL_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClient);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_OPEN_CHANNEL_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_OPEN_CHANNEL_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt((TUint)KClientHandle);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_REGISTER_CLIENT_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_REGISTER_CLIENT_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientHandle);
+        TUint32 stateRes32 = ((KStatsRes1&0xFF) << 16) | ((KStatsRes2&0xFF) << 8) | ((KStatsRes3&0xFF));
+        AppendUInt(stateRes32);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_REGISTER_CLIENT_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_REGISTER_CLIENT_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientHandle);
+        AppendInt(KRetVal);
+        }
+    };
+
+class Test_PRM_US_DEREGISTER_CLIENT_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_DEREGISTER_CLIENT_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientHandle);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_DEREGISTER_CLIENT_END_TRACE   : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_DEREGISTER_CLIENT_END_TRACE()  : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientHandle);
+        }
+    };
+    
+class Test_PRM_US_GET_RESOURCE_STATE_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_GET_RESOURCE_STATE_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt(KClientHandle);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_GET_RESOURCE_STATE_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_GET_RESOURCE_STATE_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt(KLevel);
+        AppendUInt(KClient);
+        AppendUInt(KResult);
+        }
+    };
+
+class Test_PRM_US_SET_RESOURCE_STATE_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_SET_RESOURCE_STATE_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt(KLevel);
+        AppendUInt(KClientHandle);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_SET_RESOURCE_STATE_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_SET_RESOURCE_STATE_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt(KLevel);
+        AppendUInt(KClient);
+        AppendUInt(KResult);
+        }
+    };
+
+class Test_PRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt(KClientHandle);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt(KClientHandle);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt(KClientHandle);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt(KClientHandle);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_REGISTER_RESOURCE_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_REGISTER_RESOURCE_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResCount+1);
+        AppendUInt((TUint)(LogInfo.iPR));
+        AppendInt(KMinLevel);
+        AppendUInt(KMaxLevel);
+        AppendUInt(KDefaultLevel);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);
+        }
+    };
+
+class Test_PRM_CLIENT_REGISTER_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_CLIENT_REGISTER_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt((TUint)LogInfo.iPC);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+class Test_PRM_CLIENT_DEREGISTER_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_CLIENT_DEREGISTER_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt((TUint)LogInfo.iPC);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_CLIENT_CHANGE_STATE_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_CLIENT_CHANGE_STATE_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KLevel);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);        
+        }
+    };
+
+class Test_PRM_CLIENT_CHANGE_STATE_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_CLIENT_CHANGE_STATE_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendInt(KRetVal);
+        AppendUInt(KLevel);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);         
+        }
+    };
+
+class Test_PRM_POSTNOTIFICATION_REGISTER_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_POSTNOTIFICATION_REGISTER_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt((TUint)(LogInfo.iPCallback));
+        AppendInt(KRetVal);
+        }
+    };
+
+class Test_PRM_POSTNOTIFICATION_DEREGISTER_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_POSTNOTIFICATION_DEREGISTER_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt((TUint)(LogInfo.iPCallback));
+        AppendInt(KRetVal);
+        }
+    };
+
+class Test_PRM_POSTNOTIFICATION_SENT_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_POSTNOTIFICATION_SENT_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        }
+    };
+
+class Test_PRM_CALLBACK_COMPLETION_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_CALLBACK_COMPLETION_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        }
+    };
+
+class Test_PRM_MEMORY_USAGE_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_MEMORY_USAGE_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KSize);
+        }
+    };
+
+class Test_PRM_PSL_RESOURCE_GET_STATE_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_PSL_RESOURCE_GET_STATE_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_RESOURCE_GET_STATE_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_RESOURCE_GET_STATE_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);
+        }
+    };
+
+class Test_PRM_PSL_RESOURCE_GET_STATE_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_PSL_RESOURCE_GET_STATE_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KLevel);
+        AppendInt(KRetVal);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_RESOURCE_GET_STATE_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_RESOURCE_GET_STATE_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KLevel);
+        AppendInt(KRetVal);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);        
+        }
+    };
+
+class Test_PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendInt(KRetVal);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);     
+        }
+    };
+
+class Test_PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KLevel);
+        AppendUInt(KLevel);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KLevel);
+        AppendUInt(KLevel);
+        AppendInt(KRetVal);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);    
+        }
+    };
+
+class Test_PRM_PSL_RESOURCE_CREATE_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_PSL_RESOURCE_CREATE_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendInt(KMinLevel);
+        AppendInt(KMaxLevel);
+        AppendInt(KDefaultLevel);
+        AppendUInt(KFlags);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        }
+    };
+
+class Test_PRM_BOOTING_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_BOOTING_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendInt(KErrNoMemory);
+        }
+    };
+
+class Test_PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KResourceId);
+        AppendUInt((TUint)(LogInfo.iPR));
+        AppendInt(KMinLevel);
+        AppendInt(KMaxLevel);
+        AppendInt(KDefaultLevel);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);        
+        }
+    };
+
+class Test_PRM_REGISTER_DYNAMIC_RESOURCE_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_REGISTER_DYNAMIC_RESOURCE_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt((TUint)(LogInfo.iPR));
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);
+        }
+    };
+
+class Test_PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt((TUint)(LogInfo.iPR));
+        AppendUInt(KLevel);
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);
+        }
+    };
+
+class Test_PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KResourceId);
+        AppendUInt((TUint)(LogInfo.iPR));
+        AppendUInt((TUint)(LogInfo.iPR));
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);        
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);  
+        }
+    };
+
+class Test_PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE : public CTestTraceBase
+    {
+public:
+    Test_PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE() : CTestTraceBase(&BufferPtr, BTraceHeaderSize)
+        {
+        AppendUInt(KClientId);
+        AppendUInt(KResourceId);
+        AppendUInt(KResourceId);
+        AppendUInt((TUint)(LogInfo.iPR));
+        AppendUInt((TUint)(LogInfo.iPR));
+        AppendUInt(KCLIENTNAME.iTypeLength);
+        AppendDes(KCLIENTNAME);
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);        
+        AppendUInt(KRESOURCENAME.iTypeLength);
+        AppendDes(KRESOURCENAME);      
+        }
+    };
+
+void TestMacro()
+    {
+    const TInt numCpus = UserSvr::HalFunction(EHalGroupKernel, EKernelHalNumLogicalCpus, 0, 0);
+    if(numCpus>1)
+    	{
+	BTraceHeaderSize = 20;
+	}
+    else
+        {
+	BTraceHeaderSize = 12;
+	}
+
+    Test_PRM_US_OPEN_CHANNEL_START_TRACE testPRM_US_OPEN_CHANNEL_START_TRACE; //0
+    Test_PRM_US_OPEN_CHANNEL_END_TRACE testPRM_US_OPEN_CHANNEL_END_TRACE; //1
+    Test_PRM_US_REGISTER_CLIENT_START_TRACE testPRM_US_REGISTER_CLIENT_START_TRACE; //2
+    Test_PRM_US_REGISTER_CLIENT_END_TRACE testPRM_US_REGISTER_CLIENT_END_TRACE; //3
+    Test_PRM_US_DEREGISTER_CLIENT_START_TRACE testPRM_US_DEREGISTER_CLIENT_START_TRACE; //4
+    Test_PRM_US_DEREGISTER_CLIENT_END_TRACE   testPRM_US_DEREGISTER_CLIENT_END_TRACE; //5
+    Test_PRM_US_GET_RESOURCE_STATE_START_TRACE testPRM_US_GET_RESOURCE_STATE_START_TRACE; //6
+    Test_PRM_US_GET_RESOURCE_STATE_END_TRACE testPRM_US_GET_RESOURCE_STATE_END_TRACE; //7
+    Test_PRM_US_SET_RESOURCE_STATE_START_TRACE testPRM_US_SET_RESOURCE_STATE_START_TRACE; //8
+    Test_PRM_US_SET_RESOURCE_STATE_END_TRACE testPRM_US_SET_RESOURCE_STATE_END_TRACE; //9
+    Test_PRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE testPRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE; //10
+    Test_PRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE testPRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE; //11
+    Test_PRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE testPRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE; //12
+    Test_PRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE testPRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE; //13
+    Test_PRM_REGISTER_RESOURCE_TRACE testPRM_REGISTER_RESOURCE_TRACE; //14
+    Test_PRM_CLIENT_REGISTER_TRACE testPRM_CLIENT_REGISTER_TRACE; //15
+    Test_PRM_CLIENT_DEREGISTER_TRACE testPRM_CLIENT_DEREGISTER_TRACE; //16
+    Test_PRM_CLIENT_CHANGE_STATE_START_TRACE testPRM_CLIENT_CHANGE_STATE_START_TRACE; //17
+    Test_PRM_CLIENT_CHANGE_STATE_END_TRACE testPRM_CLIENT_CHANGE_STATE_END_TRACE; //18
+    Test_PRM_POSTNOTIFICATION_REGISTER_TRACE testPRM_POSTNOTIFICATION_REGISTER_TRACE; //19
+    Test_PRM_POSTNOTIFICATION_DEREGISTER_TRACE testPRM_POSTNOTIFICATION_DEREGISTER_TRACE; //20
+    Test_PRM_POSTNOTIFICATION_SENT_TRACE testPRM_POSTNOTIFICATION_SENT_TRACE; //21
+    Test_PRM_CALLBACK_COMPLETION_TRACE testPRM_CALLBACK_COMPLETION_TRACE; //22
+    Test_PRM_MEMORY_USAGE_TRACE testPRM_MEMORY_USAGE_TRACE; //23
+    Test_PRM_PSL_RESOURCE_GET_STATE_START_TRACE testPRM_PSL_RESOURCE_GET_STATE_START_TRACE; //24
+    Test_PRM_RESOURCE_GET_STATE_START_TRACE testPRM_RESOURCE_GET_STATE_START_TRACE; //25
+    Test_PRM_PSL_RESOURCE_GET_STATE_END_TRACE testPRM_PSL_RESOURCE_GET_STATE_END_TRACE; //26
+    Test_PRM_RESOURCE_GET_STATE_END_TRACE testPRM_RESOURCE_GET_STATE_END_TRACE; //27
+    Test_PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE testPRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE; //28
+    Test_PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE testPRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE; //29
+    Test_PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE testPRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE; //30
+    Test_PRM_PSL_RESOURCE_CREATE_TRACE testPRM_PSL_RESOURCE_CREATE_TRACE; //31
+    Test_PRM_BOOTING_TRACE testPRM_BOOTING_TRACE; //32
+    Test_PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE testPRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE; //33
+    Test_PRM_REGISTER_DYNAMIC_RESOURCE_TRACE testPRM_REGISTER_DYNAMIC_RESOURCE_TRACE; //34
+    Test_PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE testPRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE; //35
+    Test_PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE testPRM_REGISTER_RESOURCE_DEPENDENCY_TRACE; //36
+    Test_PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE testPRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE; //37
+    
+//    const TInt KNumTest = 38;
+    CTestTraceBase* TestArray[] = 
+            {
+            &testPRM_US_OPEN_CHANNEL_START_TRACE,
+            &testPRM_US_OPEN_CHANNEL_END_TRACE,
+            &testPRM_US_REGISTER_CLIENT_START_TRACE,
+            &testPRM_US_REGISTER_CLIENT_END_TRACE,
+            &testPRM_US_DEREGISTER_CLIENT_START_TRACE,
+            &testPRM_US_DEREGISTER_CLIENT_END_TRACE,
+            &testPRM_US_GET_RESOURCE_STATE_START_TRACE,
+            &testPRM_US_GET_RESOURCE_STATE_END_TRACE,
+            &testPRM_US_SET_RESOURCE_STATE_START_TRACE,
+            &testPRM_US_SET_RESOURCE_STATE_END_TRACE,
+            &testPRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE,
+            &testPRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE,
+            &testPRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE,
+            &testPRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE,
+            &testPRM_REGISTER_RESOURCE_TRACE,
+            &testPRM_CLIENT_REGISTER_TRACE,
+            &testPRM_CLIENT_DEREGISTER_TRACE,
+            &testPRM_CLIENT_CHANGE_STATE_START_TRACE,
+            &testPRM_CLIENT_CHANGE_STATE_END_TRACE,
+            &testPRM_POSTNOTIFICATION_REGISTER_TRACE,
+            &testPRM_POSTNOTIFICATION_DEREGISTER_TRACE,
+            &testPRM_POSTNOTIFICATION_SENT_TRACE,
+            &testPRM_CALLBACK_COMPLETION_TRACE,
+            &testPRM_MEMORY_USAGE_TRACE,
+            &testPRM_PSL_RESOURCE_GET_STATE_START_TRACE,
+            &testPRM_RESOURCE_GET_STATE_START_TRACE,
+            &testPRM_PSL_RESOURCE_GET_STATE_END_TRACE,
+            &testPRM_RESOURCE_GET_STATE_END_TRACE,
+            &testPRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE,
+            &testPRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE,
+            &testPRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE,
+            &testPRM_PSL_RESOURCE_CREATE_TRACE,
+            &testPRM_BOOTING_TRACE,
+            &testPRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE,
+            &testPRM_REGISTER_DYNAMIC_RESOURCE_TRACE,
+            &testPRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE,
+            &testPRM_REGISTER_RESOURCE_DEPENDENCY_TRACE,
+            &testPRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE
+            };
+    
+    TInt r = KErrNone;
+    
+    for(TUint i = 0; i < sizeof(TestArray)/sizeof(CTestTraceBase*); i++)
+        {
+        TestArray[i]->SkipHeader();
+        test.Printf(_L("\n\nTest number %d\n\n"), i);
+        r = TestArray[i]->Compare();
+        test(r==KErrNone);
+        }
+    
+    }
+
+void DoTests()
+	{
+	TInt r = KErrNone;
+
+	test.Printf(_L("Loading logical device \n"));
+	r=User::LoadLogicalDevice(KLddFileName);
+	test(r == KErrNone);
+
+	test.Printf(_L("Opening of logical device\n"));
+	r = ldd.Open();
+	test(r == KErrNone);
+
+	Trace.Open();
+	TInt OrgBufSize = Trace.BufferSize();
+	if(OrgBufSize<1024)
+	    Trace.ResizeBuffer(1024);
+	
+    Trace.Empty();
+    Trace.SetMode(RBTrace::EEnable);
+	
+	Trace.SetFilter(BTrace::EResourceManagerUs, ETrue);
+	Trace.SetFilter(BTrace::EResourceManager, ETrue);	
+
+    test.Printf(_L("Test Cat 19 is enabled"));
+	test(Trace.Filter(19));
+    test.Printf(_L("Test Cat 20 is enabled"));
+	test(Trace.Filter(20));
+    
+	test.Printf(_L("Send log\n"));
+	r = ldd.SendLog(&LogInfo);
+	test(r == KErrNone);
+
+	Trace.GetData(BufferPtr);
+    
+	TestMacro();
+	
+	Trace.DataUsed();
+	
+	Trace.SetFilter(BTrace::EResourceManagerUs, EFalse);
+	Trace.SetFilter(BTrace::EResourceManager, EFalse);	
+	
+	if(OrgBufSize<1024)
+	    Trace.ResizeBuffer(1024);
+	
+	Trace.Close();
+	
+	test.Printf(_L("\nClosing the channel\n"));
+	ldd.Close();
+
+	test.Printf(_L("Freeing logical device\n"));
+	r = User::FreeLogicalDevice(KLddFileName);;
+	test(r==KErrNone);
+
+
+	}
+
+GLDEF_C TInt E32Main()
+    {
+	test.Start(_L("T_RESMANUSBTRACE"));
+	console = test.Console();
+	DoTests();
+	test.End();
+	test.Close();
+		
+ 	return(KErrNone);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resmanus/t_resmanusbtrace.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -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/t_resmanusbtrace.mmp
+// 
+//
+
+TARGET         t_resmanusbtrace.exe
+TARGETTYPE     EXE
+SOURCEPATH     .
+SOURCE         t_resmanusbtrace.cpp
+LIBRARY        euser.lib
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE  .
+
+library btracec.lib
+capability		all
+
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resourceman/d_rescontrolclisync.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,419 @@
+// 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\resourceman\d_rescontrolclisync.cpp
+// 
+//
+
+#include <kernel/kern_priv.h>
+#include <drivers/resource_extend.h>
+#include <drivers/resourceman.h>
+#include "d_rescontrolclisync.h"
+
+#include "resourceman_psl/rescontrol_psl.h"
+
+_LIT(KTestPowerRCName, "D_RESCONTROLCLISYNC.LDD");
+
+
+const TInt KTestResManLddThreadPriority  = 0x5;
+const TUint KResourceId = 16; // DMLSHLGLSPResource
+const TInt KResourceMax = 65;
+const TInt KResourceMin = 10;
+
+_LIT(KTestResManLddThread, "TestResManLddThread");
+_LIT(KTestResManLddHelperThread, "TestResManLddHelperThread");
+_LIT(KTestResManLddCallbackThread, "TestResManLddCallbackThread");
+_LIT(KResClientName1, "ResTestClient1");
+_LIT(KResClientName2, "ResTestClient2");
+
+class DTestResManLdd;
+/**
+The logical device (factory class) for the resource manager client side test.
+*/
+class DTestResManLddFactory : public DLogicalDevice
+	{
+public:
+    enum {
+        ESignallerCallback,
+        EWaiterCallback
+    };
+	DTestResManLddFactory();
+	~DTestResManLddFactory();
+	virtual TInt Install();
+	virtual void GetCaps(TDes8 &aDes) const;
+	virtual TInt Create(DLogicalChannelBase*& aChannel);
+	
+    NFastSemaphore iSemaphore1; // fast semaphore for helper queue
+    NFastSemaphore iSemaphore2; // fast semaphore for call back thread
+
+	TInt iResourceClientRegisterCount;
+	TDynamicDfcQue* iLddQue;   // dfc que for logical channel (also running the primary ChangeResourceState
+	TDynamicDfcQue* iLddHelperQue; // helper dfc que to execute the secondary ChangeResourceState
+    TDynamicDfcQue* iCallbackQue;  // dfc que for call back 
+ 
+    DTestResManLdd* iChannel1;
+    DTestResManLdd* iChannel2;
+    TInt iCallbackState;
+    TPowerResourceCb* iAsyncResourceCallback; 
+	};
+
+/** Logical channel class for Resource manager test LDD */
+class DTestResManLdd : public DLogicalChannel
+	{
+public:
+	DTestResManLdd();
+	virtual ~DTestResManLdd();
+	// Inherited from DLogicalChannel
+	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	virtual void HandleMsg(TMessageBase* aMsg);
+
+    DThread* iClientThreadPtr;	
+    TRequestStatus* iStatus;
+    TUint iResClientId;
+    TDfc* iWaitAndChangeResourceDfc;
+    
+private:
+	TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
+	TInt DoRequest(TInt aFunction, TRequestStatus* aStatus, TAny* a1, TAny* a2);
+	TInt DoCancel(TUint aMask);
+	};
+
+void AsyncResourceCallbackFn(TUint /*aClientId*/, TUint /*aResourceId*/, TInt /*aLevel*/, TInt /*aLevelOwnerId*/, TInt aResult, TAny* aParam)
+    {
+    // call back function, always run on call back dfc queue
+    Kern::Printf(">AsyncResourceCallbackFn 0x%x", &(Kern::CurrentThread().iNThread));
+    DTestResManLddFactory* pLddFactory = (DTestResManLddFactory*)aParam;
+    DTestResManLdd* pLdd = NULL;
+
+    if(pLddFactory->iCallbackState == DTestResManLddFactory::ESignallerCallback)
+        {
+        pLdd = pLddFactory->iChannel1;
+        Kern::Printf("AsyncResourceCallbackFn cond 1 signal [#3.1]"); 
+        NKern::FSSignal(&(pLddFactory->iSemaphore1));
+        
+        Kern::Printf("AsyncResourceCallbackFn cond 1 wait [#3.2]");
+        NKern::FSWait(&(pLddFactory->iSemaphore2));
+        
+        Kern::Printf("AsyncResourceCallbackFn cond 1 wake up [#3.3]");
+        }
+    else if(pLddFactory->iCallbackState == DTestResManLddFactory::EWaiterCallback)
+        {
+        pLdd = pLddFactory->iChannel2;
+        // aResult should be equal to KErrNone (not KErrCompletion)
+        Kern::Printf("AsyncResourceCallbackFn cond 2 r = %d [#2.5]", aResult);
+        }
+    else
+        {
+        Kern::Fault("AsyncResourceCallbackFn", __LINE__);
+        }
+    
+    Kern::RequestComplete(pLdd->iClientThreadPtr, pLdd->iStatus, aResult);
+    pLdd->iStatus = NULL;    
+    Kern::Printf("<AsyncResourceCallbackFn");
+    }
+
+void WaitAndChangeResourceDfcFn(TAny* aLdd)
+    {
+    // helper function to call ChangeResourceState, always run on ldd helper dfc queue
+    Kern::Printf(">WaitAndChangeResourceDfcFn 0x%x [#2.1]", &(Kern::CurrentThread().iNThread));
+    DTestResManLdd* pLdd = (DTestResManLdd*)aLdd;
+    DTestResManLddFactory* pLddFactory = (DTestResManLddFactory*)(pLdd->iDevice);
+    
+    Kern::Printf(" WaitAndChangeResourceDfcFn - Wait for Semaphore [#2.2]");
+    NKern::FSWait(&(pLddFactory->iSemaphore1));
+    
+    Kern::Printf(" WaitAndChangeResourceDfcFn - ChangeResourceState [#2.3]");
+    pLddFactory->iCallbackState = DTestResManLddFactory::EWaiterCallback;
+    PowerResourceManager::ChangeResourceState(pLdd->iResClientId, KResourceId, KResourceMax, pLddFactory->iAsyncResourceCallback);
+    
+    Kern::Printf(" WaitAndChangeResourceDfcFn - signal [#2.4]");
+    NKern::FSSignal(&(pLddFactory->iSemaphore2));
+    
+    delete pLdd->iWaitAndChangeResourceDfc;
+    Kern::Printf("<WaitAndChangeResourceDfcFn");
+    }
+
+DTestResManLddFactory::DTestResManLddFactory()
+	{
+	iParseMask=0; // Allow info and pdd, but not units
+	iUnitsMask=0;
+	// Set version number for this device
+	iVersion=RTestResMan::VersionRequired();
+	}
+
+DTestResManLddFactory::~DTestResManLddFactory()
+	{
+    if(iLddQue)
+        iLddQue->Destroy();       
+    if(iLddHelperQue)
+      iLddHelperQue->Destroy(); 
+    if(iCallbackQue)
+      iCallbackQue->Destroy(); 
+    
+    if(iAsyncResourceCallback)
+      delete iAsyncResourceCallback;
+	}
+
+/** Entry point for this driver */
+DECLARE_STANDARD_LDD()
+	{
+	DTestResManLddFactory* p = new DTestResManLddFactory;
+	if(!p)
+		return NULL;
+
+	TInt r = KErrNone;
+	
+    r = Kern::DynamicDfcQCreate(p->iLddQue, KTestResManLddThreadPriority, KTestResManLddThread);
+    if(r != KErrNone)
+        {
+        return NULL;
+        }
+    Kern::Printf("iLddQue 0x%x", p->iLddQue->iThread);
+    
+    r = Kern::DynamicDfcQCreate(p->iLddHelperQue, KTestResManLddThreadPriority, KTestResManLddHelperThread);
+    if(r != KErrNone)
+        {
+        p->iLddQue->Destroy();  
+        return NULL;
+        }
+    p->iSemaphore1.iOwningThread = (NThreadBase*)(p->iLddHelperQue->iThread);
+    Kern::Printf("iSemaphore1 owning thread 0x%x", p->iSemaphore1.iOwningThread);
+
+    r = Kern::DynamicDfcQCreate(p->iCallbackQue, KTestResManLddThreadPriority, KTestResManLddCallbackThread);
+    if(r != KErrNone)
+        {
+        p->iLddQue->Destroy();  
+        p->iLddHelperQue->Destroy();          
+        return NULL;
+        }
+    p->iSemaphore2.iOwningThread = (NThreadBase*)(p->iCallbackQue->iThread);
+    Kern::Printf("iSemaphore2 owning thread 0x%x", p->iSemaphore2.iOwningThread);
+
+    p->iAsyncResourceCallback = new TPowerResourceCb(AsyncResourceCallbackFn, p, 
+            p->iCallbackQue, 5);    
+    
+#ifdef __SMP__      
+    NKern::ThreadSetCpuAffinity((NThread*)(p->iLddQue->iThread), 0);
+    NKern::ThreadSetCpuAffinity((NThread*)(p->iLddHelperQue->iThread), 0);
+    NKern::ThreadSetCpuAffinity((NThread*)(p->iCallbackQue->iThread), 1);
+#endif      
+    
+	r = DSimulatedPowerResourceController::CompleteResourceControllerInitialisation();
+	if(r != KErrNone)
+		Kern::Fault("PRM INIT FAILED", __LINE__);
+	return p;
+	}
+
+/** Second stage constuctor */
+TInt DTestResManLddFactory::Install()
+	{
+   	return(SetName(&KTestPowerRCName));
+	}
+
+/** Device capabilities */
+void DTestResManLddFactory::GetCaps(TDes8& aDes)const
+	{
+	// Create a capabilities object
+	RTestResMan::TCaps caps;
+	caps.iVersion = iVersion;
+	// Write it back to user memory
+	Kern::InfoCopy(aDes,(TUint8*)&caps,sizeof(caps));
+	}
+
+
+TInt DTestResManLddFactory::Create(DLogicalChannelBase*& aChannel)
+	{
+	aChannel = new DTestResManLdd();
+	if(!aChannel)
+		return KErrNoMemory;
+	if(!iChannel1)
+	    iChannel1 = (DTestResManLdd*)aChannel;
+	else if(!iChannel2)
+	    iChannel2 = (DTestResManLdd*)aChannel;
+	else
+	    {
+        delete aChannel;
+	    return KErrInUse;
+	    }
+	return KErrNone;
+	}
+
+/** Constructor */
+DTestResManLdd::DTestResManLdd()
+	{
+	iClientThreadPtr=&Kern::CurrentThread();
+	iResClientId = 0;
+
+	// Increase the DThread's ref count so that it does not close without us
+	((DObject*)iClientThreadPtr)->Open();
+	}
+
+/** Destructor */
+DTestResManLdd::~DTestResManLdd()
+	{
+	Kern::SafeClose((DObject*&)iClientThreadPtr,NULL);
+	}
+
+/** Second stage constructor. */
+TInt DTestResManLdd::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
+	{
+   	// Check version
+	if (!Kern::QueryVersionSupported(RTestResMan::VersionRequired(),aVer))
+		return KErrNotSupported;
+
+	SetDfcQ(((DTestResManLddFactory*)iDevice)->iLddQue);
+ 	iMsgQ.Receive();
+	return KErrNone;
+	}
+
+/** Process a message for this logical channel */
+void DTestResManLdd::HandleMsg(TMessageBase* aMsg)
+	{
+	TThreadMessage& m=*(TThreadMessage*)aMsg;
+	TInt id=m.iValue;
+
+	if (id==(TInt)ECloseMsg)
+		{
+		// Channel close.
+		m.Complete(KErrNone,EFalse);
+		return;
+		}
+	else if (id==KMaxTInt)
+		{
+		// DoCancel
+		m.Complete(KErrNone,ETrue);
+		return;
+		}
+	else if (id<0)
+		{
+		// DoRequest
+		TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
+		TInt r=DoRequest(~id,pS,m.Ptr1(),m.Ptr2());
+		if (r!=KErrNone)
+			Kern::RequestComplete(iClientThreadPtr,pS,r);
+		m.Complete(KErrNone,ETrue);
+		}
+	else
+		{
+		// DoControl
+		TInt r=DoControl(id,m.Ptr0(),m.Ptr1());
+		m.Complete(r,ETrue);
+		}
+	}
+
+/**
+  Process synchronous 'control' requests
+*/
+TInt DTestResManLdd::DoControl(TInt aFunction, TAny* /*a1*/, TAny* /*a2*/)
+	{
+	TInt r = KErrNone;
+
+	switch(aFunction)
+		{
+		case RTestResMan::ERegisterClient:
+		    {
+            Kern::Printf("RTestResMan::ERegisterClient");		    
+			if(iResClientId!=0)
+				{
+				r = KErrInUse;
+				break;
+				}
+			if(((DTestResManLddFactory*)iDevice)->iResourceClientRegisterCount==0)
+			    {
+			    r = PowerResourceManager::RegisterClient(iResClientId, KResClientName1);
+			    }
+			else if(((DTestResManLddFactory*)iDevice)->iResourceClientRegisterCount==1)
+			    {
+                r = PowerResourceManager::RegisterClient(iResClientId, KResClientName2);
+                }                
+			else
+			    r = KErrInUse;
+			
+			(((DTestResManLddFactory*)iDevice)->iResourceClientRegisterCount)++;
+			
+			break;
+		    }
+	    case RTestResMan::EDeRegisterClient:
+	        {
+            Kern::Printf("RTestResMan::EDeRegisterClient");          
+            if(iResClientId==0)
+                {
+                r = KErrArgument;
+                break;
+                }
+            r = PowerResourceManager::DeRegisterClient(iResClientId);
+            break;
+	        }    
+        case RTestResMan::EPrintResourceInfo:
+            {
+            Kern::Printf("RTestResMan::EPrintResourceInfo");          
+            TPowerResourceInfoBuf01 info;
+            info.SetLength(0);
+            Kern::Printf("EPrintResourceInfo");
+            r = PowerResourceManager::GetResourceInfo(iResClientId,KResourceId,&info);
+            Kern::Printf("EPrintResourceInfo:%S", info().iResourceName);
+            break;
+            }
+		default:
+		    {
+			r = KErrNotSupported;
+			break;
+		    }
+		}
+	return r;
+
+	}
+
+
+TInt DTestResManLdd::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* /*a1*/, TAny* /*a2*/)
+	{
+	TInt r = KErrNone;
+
+	if(r != KErrNone)
+		Kern::RequestComplete(iClientThreadPtr, aStatus, r);
+	switch(aReqNo)
+		{
+        case RTestResMan::EWaitAndChangeResource:
+            // Queue a dfc which wait for the semaphore and then call ChangeResourceState
+            Kern::Printf("RTestResMan::EWaitAndChangeResource 0x%x [#1.1]", &(Kern::CurrentThread().iNThread));            
+            if(iStatus)
+                {
+                r = KErrInUse;
+                break;
+                }
+            iStatus = aStatus;
+
+            iWaitAndChangeResourceDfc = new TDfc(WaitAndChangeResourceDfcFn, this, 
+                    ((DTestResManLddFactory*)iDevice)->iLddHelperQue, 5);
+            iWaitAndChangeResourceDfc->Enque();
+
+            break;
+        case RTestResMan::EChangeResourceAndSignal:	
+            // call ChangeResourceState and signal the semaphore
+            Kern::Printf("RTestResMan::EChangeResourceAndSignal 0x%x [#1.2]", &(Kern::CurrentThread().iNThread));             
+            if(iStatus)
+                {
+                r = KErrInUse;
+                break;
+                }
+            iStatus = aStatus;
+            PowerResourceManager::ChangeResourceState(iResClientId, KResourceId, KResourceMin, 
+                    ((DTestResManLddFactory*)iDevice)->iAsyncResourceCallback);
+            ((DTestResManLddFactory*)iDevice)->iCallbackState = DTestResManLddFactory::ESignallerCallback;
+
+            break;            
+	    default:
+	        break;
+		}
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resourceman/d_rescontrolclisync.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,101 @@
+// 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\resourceman\d_rescontrolclisync.h
+// 
+//
+
+#ifndef __D_RESCONTROLCLISYNC_H__
+#define __D_RESCONTROLCLISYNC_H__
+
+#include <e32cmn.h>
+#include <e32ver.h>
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif   
+
+_LIT(KLddFileName, "D_RESCONTROLCLISYNC.LDD");
+_LIT(KLddName, "D_RESCONTROLCLISYNC.LDD");
+_LIT(KPddFileName, "resourcecontroller.pdd");
+_LIT(KPddName, "resourcecontroller.pdd");
+
+
+/** User side logical channel */
+class RTestResMan : public RBusLogicalChannel
+	{
+public:
+	// Structure for holding driver capabilities information
+	class TCaps
+		{
+	public:
+		TVersion iVersion;
+		};
+
+private:
+	enum TControl //Request types for synchronous operation.
+		{ 
+		ERegisterClient,
+        EDeRegisterClient,	
+        EPrintResourceInfo,
+        ERegisterNotification,
+        EDeRegisterNotification,
+		EMaxControl,
+		
+		};
+	enum TRequest //Request types for asynchronous operation
+		{
+        EWaitAndChangeResource = EMaxControl + 1,
+        EChangeResourceAndSignal, 
+	    EMaxRequest, 
+		};
+	friend class DTestResManLdd;
+public:
+   	TInt Open();
+   	TInt PrintResourceInfo()
+   	    {return DoControl(EPrintResourceInfo);}
+   	TInt RegisterClient()
+   	    {return DoControl(ERegisterClient);}
+    TInt DeRegisterClient()
+        {return DoControl(EDeRegisterClient);}
+    TInt RegisterNotification()
+        {return DoControl(ERegisterNotification);}
+    TInt DeRegisterNotification()
+        {return DoControl(EDeRegisterNotification);}
+    void WaitAndChangeResource(TRequestStatus& aStatus)
+        {DoRequest(EWaitAndChangeResource, aStatus);}    
+    void ChangeResourceAndSignal(TRequestStatus& aStatus)
+        {DoRequest(EChangeResourceAndSignal, aStatus);}    
+
+    inline static TVersion VersionRequired();
+    
+    };
+
+inline TVersion RTestResMan::VersionRequired()
+	{
+	const TInt KMajorVersionNumber=1;
+	const TInt KMinorVersionNumber=0;
+	const TInt KBuildVersionNumber=KE32BuildVersionNumber;
+	return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
+	}
+
+#ifndef __KERNEL_MODE__
+
+/** Open a channel for the driver.*/ 
+TInt RTestResMan::Open()
+	{
+    return DoCreate(KLddName, VersionRequired(), KNullUnit, &KPddName, NULL, EOwnerProcess, EFalse);
+	}
+
+
+#endif //__KERNEL_MODE__
+#endif //__D_RESCONTROLCLISYNC_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/resourceman/t_rescontrolclisync.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,120 @@
+// 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\resourceman\t_rescontrolclisync.cpp
+// TestCase Description:
+// This test harness is to test the unsafe setup of power request call back object
+// inside resourcecontrol.cpp. The memeber variable of TPowerRequestCb should not 
+// be corrupted when a second ChangeResourceState is execute during the call back
+// function is running.
+// 
+//
+
+#include <e32test.h>
+#include <e32hal.h>
+#include <e32math.h>
+#include <e32def.h>
+#include <e32def_private.h>
+#include "d_rescontrolclisync.h"
+
+
+
+LOCAL_D RTest test(_L("T_RESCONTROLCLISYNC"));
+RTestResMan lddChan;
+RTestResMan lddChan2;
+
+#define TESTANDCLEAN(x) TestAndClean(x,__LINE__)
+
+void TestAndClean(TBool aTestValid, TInt aLine)
+    {
+    if(!aTestValid)
+        {
+        lddChan.DeRegisterClient();
+        lddChan2.DeRegisterClient();
+        lddChan.Close();
+        lddChan2.Close();
+        User::FreeLogicalDevice(KLddFileName);
+        User::FreePhysicalDevice(KPddFileName);
+        RDebug::Printf("Test fail at line %d", aLine);
+        test.HandleError(EFalse, aLine, (TText *)__FILE__);
+        }
+    }
+
+GLDEF_C TInt E32Main()
+	{
+	test.Title();
+	test.Start(_L("Testing Resource Manager...\n"));
+
+	test.Next(_L("Load Physical device"));
+	TInt r = User::LoadPhysicalDevice(KPddFileName);
+	test(r==KErrNone || r==KErrAlreadyExists);
+	test.Next(_L("Load Logical Device"));
+	r=User::LoadLogicalDevice(KLddFileName);
+	test(r==KErrNone || r==KErrAlreadyExists);
+    test.Next(_L("Open Logical Channel 1"));	
+	r = lddChan.Open();
+    test(r==KErrNone);	
+    test.Next(_L("Open Logical Channel 2"));        
+	r = lddChan2.Open();
+	test(r==KErrNone);
+
+    test.Next(_L("Register client 1"));    
+	r = lddChan.RegisterClient();
+    RDebug::Printf("Register client 1 return r = %d", r);
+    TESTANDCLEAN(r==KErrNone);
+
+	test.Next(_L("Register client 2"));    
+	r = lddChan2.RegisterClient();
+    RDebug::Printf("Register client 2 return r = %d", r);
+    TESTANDCLEAN(r==KErrNone);
+    
+    test.Next(_L("Print resource info"));    
+    r = lddChan.PrintResourceInfo();
+    RDebug::Printf("Print resource info return r = %d", r);
+    TESTANDCLEAN(r==KErrNone);
+
+    TRequestStatus RequestStatus;
+    TRequestStatus RequestStatus2;
+    
+    test.Next(_L("WaitAndChangeResource"));    
+    lddChan.WaitAndChangeResource(RequestStatus);
+
+    test.Next(_L("ChangeResourceAndSignal"));    
+    lddChan2.ChangeResourceAndSignal(RequestStatus2);
+
+    User::WaitForRequest(RequestStatus);
+    TESTANDCLEAN(RequestStatus.Int()==KErrNone);
+    User::WaitForRequest(RequestStatus2);
+    TESTANDCLEAN(RequestStatus2.Int()==KErrNone);
+
+    test.Next(_L("De-register client 1")); 
+	r = lddChan.DeRegisterClient();
+    test(r==KErrNone);
+    
+    test.Next(_L("De-register client 2")); 	
+    r = lddChan2.DeRegisterClient();
+    test(r==KErrNone);
+    
+	test.Printf(_L("Closing the channel\n"));
+	lddChan.Close();
+	lddChan2.Close();
+	test.Printf(_L("Freeing logical device\n"));
+	r = User::FreeLogicalDevice(KLddFileName);
+	test(r==KErrNone);
+	r = User::FreePhysicalDevice(KPddFileName);
+	test(r==KErrNone);
+	test.End();
+	test.Close();
+	return KErrNone;
+	}
+
--- a/kerneltest/e32test/rm_debug/debug_targets/t_rmdebug_app.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/rm_debug/debug_targets/t_rmdebug_app.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/rm_debug/multi_agent_tests/t_multi_agent.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/system/t_cobj.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/system/t_ctrap.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/system/t_inf.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Wed Aug 18 11:08:29 2010 +0300
@@ -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	Wed Aug 18 11:08:29 2010 +0300
@@ -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;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/configs/scvascobm.xml	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,41 @@
+<LDD name="eusbcsc">
+<ENDPOINTS>30</ENDPOINTS>
+<SOFTCONNECT>Y</SOFTCONNECT>
+<SELFPOWER>N</SELFPOWER>
+<REMOTEWAKEUP>N</REMOTEWAKEUP>
+<HIGHSPEED>Y</HIGHSPEED>
+<FEATURES>1</FEATURES>
+<MAXPOWER>50</MAXPOWER>
+<EPSTALL>Y</EPSTALL>
+<SPEC>0x200</SPEC>
+<VID>0xE22</VID>
+<PID>0x1110</PID>
+<RELEASE>0x305</RELEASE>
+<PRODUCT>VascoDevice</PRODUCT>
+<INTERFACE>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 0 (Default Setting 0)"</DESCRIPTOR>
+<ENDPOINT type="BULK" direction="IN">
+<BUFFERSIZE>300000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>300000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="IN">
+<BUFFERSIZE>300000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>300000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+</INTERFACE>
+</LDD>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/configs/scvascoif0.xml	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,31 @@
+<LDD name="eusbcsc">
+<ENDPOINTS>30</ENDPOINTS>
+<SOFTCONNECT>Y</SOFTCONNECT>
+<SELFPOWER>N</SELFPOWER>
+<REMOTEWAKEUP>N</REMOTEWAKEUP>
+<HIGHSPEED>Y</HIGHSPEED>
+<FEATURES>1</FEATURES>
+<MAXPOWER>50</MAXPOWER>
+<EPSTALL>Y</EPSTALL>
+<SPEC>0x200</SPEC>
+<VID>0xE22</VID>
+<PID>0x1110</PID>
+<RELEASE>0x305</RELEASE>
+<PRODUCT>VascoDevice</PRODUCT>
+<INTERFACE>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 0 (Default Setting 0)"</DESCRIPTOR>
+<ENDPOINT type="BULK" direction="IN">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+</INTERFACE>
+</LDD>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/configs/scvascoif0a3.xml	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,112 @@
+<LDD name="eusbcsc">
+<ENDPOINTS>30</ENDPOINTS>
+<SOFTCONNECT>Y</SOFTCONNECT>
+<SELFPOWER>N</SELFPOWER>
+<REMOTEWAKEUP>N</REMOTEWAKEUP>
+<HIGHSPEED>Y</HIGHSPEED>
+<FEATURES>1</FEATURES>
+<MAXPOWER>50</MAXPOWER>
+<EPSTALL>Y</EPSTALL>
+<SPEC>0x200</SPEC>
+<VID>0xE22</VID>
+<PID>0x1110</PID>
+<RELEASE>0x305</RELEASE>
+<PRODUCT>VascoDevice</PRODUCT>
+<INTERFACE>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 0 (Default Setting 0)"</DESCRIPTOR>
+<ENDPOINT type="BULK" direction="IN">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="IN">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="IN">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+</INTERFACE>
+<ALT_SETTING>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 0 (Alternate Setting 1)"</DESCRIPTOR>
+<ENDPOINT type="INTERRUPT" direction="IN">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="IN">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+</ALT_SETTING>
+<ALT_SETTING>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 0 (Alternate Setting 2)"</DESCRIPTOR>
+<ENDPOINT type="BULK" direction="IN">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="IN">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>64</SIZE>
+<INTERVAL>1</INTERVAL>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<BUFFERSIZE>128000</BUFFERSIZE>
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+</ALT_SETTING>
+</LDD>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/configs/scvascoif0a3if1a2if2.xml	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,142 @@
+<LDD name="eusbcsc">
+<ENDPOINTS>30</ENDPOINTS>
+<SOFTCONNECT>Y</SOFTCONNECT>
+<SELFPOWER>N</SELFPOWER>
+<REMOTEWAKEUP>N</REMOTEWAKEUP>
+<HIGHSPEED>Y</HIGHSPEED>
+<FEATURES>1</FEATURES>
+<MAXPOWER>50</MAXPOWER>
+<EPSTALL>Y</EPSTALL>
+<SPEC>0x200</SPEC>
+<VID>0xE22</VID>
+<PID>0x1110</PID>
+<RELEASE>0x305</RELEASE>
+<PRODUCT>VascoDevice</PRODUCT>
+<INTERFACE>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 0 (Default Setting 0)"</DESCRIPTOR>
+<ENDPOINT type="BULK" direction="IN">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="IN">
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="OUT">
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="IN">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+</INTERFACE>
+<ALT_SETTING>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 0 (Alternate Setting 1)"</DESCRIPTOR>
+<ENDPOINT type="INTERRUPT" direction="IN">
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="OUT">
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="IN">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+</ALT_SETTING>
+<ALT_SETTING>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 0 (Alternate Setting 2)"</DESCRIPTOR>
+<ENDPOINT type="BULK" direction="IN">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="IN">
+<SIZE>64</SIZE>
+<INTERVAL>1</INTERVAL>
+<DMA>N</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>N</DMA>
+</ENDPOINT>
+</ALT_SETTING>
+<INTERFACE>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 1 (Default Setting 0)"</DESCRIPTOR>
+<ENDPOINT type="BULK" direction="IN">
+<SIZE>512</SIZE>
+<DMA>Y</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>Y</DMA>
+</ENDPOINT>
+</INTERFACE>
+<ALT_SETTING>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 1 (Alternate Setting 1)"</DESCRIPTOR>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>Y</DMA>
+</ENDPOINT>
+<ENDPOINT type="INTERRUPT" direction="IN">
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>Y</DMA>
+</ENDPOINT>
+</ALT_SETTING>
+<INTERFACE>
+<CLASS>255</CLASS>
+<SUBCLASS>255</SUBCLASS>
+<PROTOCOL>255</PROTOCOL>
+<DESCRIPTOR>"T_USB Test Interface 2 (Default Setting 0)"</DESCRIPTOR>
+<ENDPOINT type="INTERRUPT" direction="IN">
+<INTERVAL>1</INTERVAL>
+<SIZE>64</SIZE>
+<DMA>Y</DMA>
+</ENDPOINT>
+<ENDPOINT type="BULK" direction="OUT">
+<SIZE>512</SIZE>
+<DMA>Y</DMA>
+</ENDPOINT>
+</INTERFACE>
+</LDD>
\ No newline at end of file
--- a/kerneltest/e32test/usb/t_usb_device/include/activecontrol.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/include/activecontrol.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -20,6 +20,8 @@
 
 #include "activestallnotifier.h"
 #include "activedevicestatenotifier.h"
+#include "transfersrv.h"
+#include "config.h"
 
 static const TInt KSetupPacketSize = 8;
 static const TInt KMaxControlBufferSize = 256;
@@ -51,6 +53,8 @@
 
 class CActiveRW;
 
+class CTranHandleServer;
+
 class CActiveControl : public CActive
 	{
 public:
@@ -64,6 +68,9 @@
 	void AllocateDoubleBuffering(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
 	void DeAllocateEndpointDMA(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
 	void DeAllocateDoubleBuffering(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
+#ifdef USB_SC	
+	void ConstructLOnSharedLdd(const RMessagePtr2& aMsg);
+#endif
 
 private:
 	CActiveControl(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile);
@@ -83,6 +90,9 @@
 	
 	void FillEndpointsResourceAllocation(IFConfigPtr aIfCfg);
 	void PopulateInterfaceResourceAllocation(IFConfigPtr aFirstIfCfg, TInt aPortNumber);
+#ifdef USB_SC	
+	void SetupTransferedInterface(IFConfigPtr* aIfPtr, TInt aPortNumber);
+#endif
 	
 private:
 	CConsoleBase* iConsole;											// a console to read from
@@ -113,6 +123,9 @@
 	RThread iIdleCounterThread;
 	RChunk iIdleCounterChunk;
 	struct TTestIdleCounter* iIdleCounter;
+#ifdef USB_SC	
+	CTranHandleServer*        iTranHandleServer;
+#endif
 	};
 
 #endif	// __ACTIVECONTROL_H__
--- a/kerneltest/e32test/usb/t_usb_device/include/activedevicestatenotifier.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/include/activedevicestatenotifier.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -18,6 +18,8 @@
 #ifndef __ACTIVEDEVICESTATENOTIFIER_H__
 #define __ACTIVEDEVICESTATENOTIFIER_H__
 
+#include "general.h"
+
 class CActiveDeviceStateNotifier : public CActive
 	{
 public:
--- a/kerneltest/e32test/usb/t_usb_device/include/activerw.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/include/activerw.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -39,6 +39,7 @@
 	void ResumeAltSetting(TUint aAltSetting);
 	void SendWaitSetting();
 	void StartOrSuspend();
+	inline RDEVCLIENT* Ldd();
 			
 private:
 	CActiveRW(CConsoleBase* aConsole, RDEVCLIENT* aPort, RFs aFs, TUint16 aIndex, TBool aLastSetting);
@@ -86,4 +87,9 @@
 	TBool iLastSetting;
 	};
 
+inline RDEVCLIENT* CActiveRW::Ldd()
+	{
+	return iPort;
+	}
+
 #endif	// __ACTIVERW_H__
--- a/kerneltest/e32test/usb/t_usb_device/include/activestallnotifier.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/include/activestallnotifier.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -18,6 +18,7 @@
 #ifndef __ACTIVESTALLNOTIFIER_H__
 #define __ACTIVESTALLNOTIFIER_H__
 
+#include "general.h"
 
 class CActiveStallNotifier : public CActive
 	{
--- a/kerneltest/e32test/usb/t_usb_device/include/general.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/include/general.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-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"
@@ -143,50 +143,71 @@
 
 #define TUSB_PRINT(string) \
 		do { \
-		iConsole->Printf(_L(string)); \
-		iConsole->Printf(_L("\n")); \
+			if (iConsole) \
+			{			\
+		    iConsole->Printf(_L(string)); \
+		    iConsole->Printf(_L("\n")); \
+			} \
 		RDebug::Print(_L(string)); \
 		} while (0)
 
 #define TUSB_PRINT1(string, a) \
 		do { \
-		iConsole->Printf(_L(string), (a)); \
-		iConsole->Printf(_L("\n")); \
+		if (iConsole) \
+			{			\
+			iConsole->Printf(_L(string), (a)); \
+			iConsole->Printf(_L("\n")); \
+			}	\
 		RDebug::Print(_L(string), (a)); \
 		} while (0)
 
 #define TUSB_PRINT2(string, a, b) \
 		do { \
-		iConsole->Printf(_L(string), (a), (b)); \
-		iConsole->Printf(_L("\n")); \
+			if (iConsole) \
+			{			\
+			iConsole->Printf(_L(string), (a), (b)); \
+			iConsole->Printf(_L("\n")); \
+			}	\
 		RDebug::Print(_L(string), (a), (b)); \
 		} while (0)
 
 #define TUSB_PRINT3(string, a, b, c) \
 		do { \
-		iConsole->Printf(_L(string), (a), (b), (c)); \
-		iConsole->Printf(_L("\n")); \
+			if (iConsole) \
+			{			\
+			iConsole->Printf(_L(string), (a), (b), (c)); \
+			iConsole->Printf(_L("\n")); \
+			}	\
 		RDebug::Print(_L(string), (a), (b), (c)); \
 		} while (0)
 
 #define TUSB_PRINT4(string, a, b, c, d) \
 		do { \
-		iConsole->Printf(_L(string), (a), (b), (c), (d)); \
-		iConsole->Printf(_L("\n")); \
+			if (iConsole) \
+			{			\
+			iConsole->Printf(_L(string), (a), (b), (c), (d)); \
+			iConsole->Printf(_L("\n")); \
+			}	\
 		RDebug::Print(_L(string), (a), (b), (c), (d)); \
 		} while (0)
 
 #define TUSB_PRINT5(string, a, b, c, d, e) \
 		do { \
-		iConsole->Printf(_L(string), (a), (b), (c), (d), (e)); \
-		iConsole->Printf(_L("\n")); \
+			if (iConsole) \
+			{			\
+			iConsole->Printf(_L(string), (a), (b), (c), (d), (e)); \
+			iConsole->Printf(_L("\n")); \
+			}	\
 		RDebug::Print(_L(string), (a), (b), (c), (d), (e)); \
 		} while (0)
 
 #define TUSB_PRINT6(string, a, b, c, d, e, f) \
 		do { \
-		iConsole->Printf(_L(string), (a), (b), (c), (d), (e), (f)); \
-		iConsole->Printf(_L("\n")); \
+			if (iConsole) \
+			{			\
+			iConsole->Printf(_L(string), (a), (b), (c), (d), (e), (f)); \
+			iConsole->Printf(_L("\n")); \
+			}	\
 		RDebug::Print(_L(string), (a), (b), (c), (d), (e), (f)); \
 		} while (0)
 
@@ -242,8 +263,11 @@
 		do { \
 		if (gVerbose) \
 			{ \
-			aConsole->Printf(_L(string)); \
-			aConsole->Printf(_L("\n")); \
+				if (iConsole) \
+				{			\
+				aConsole->Printf(_L(string)); \
+				aConsole->Printf(_L("\n")); \
+				}	\
 			RDebug::Print(_L(string)); \
 			} \
 		} while (0)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/tranhandleserver.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TRANHANDLESERVER_H
+#define TRANHANDLESERVER_H
+
+#include <e32base.h>
+
+class CActiveControl;
+
+NONSHARABLE_CLASS(CTranHandleServer) : public CPolicyServer
+    {
+public:
+    static CTranHandleServer* NewL(CActiveControl& aControl);
+    ~CTranHandleServer();
+
+private:
+    CTranHandleServer(CActiveControl& aControl);
+    
+private:
+    // from CPolicyServer
+    CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMessage) const;
+    
+private:
+    // unowned
+    CActiveControl& iActiveControl;
+    };
+
+#endif // TRANHANDLESERVER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/tranhandleserverconsts.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TRANHANDLESERVERCONSTS_H
+#define TRANHANDLESERVERCONSTS_H
+
+#include <e32base.h>
+
+_LIT(KTranHandleServerName, "!TranHandleSrv");
+
+/** Version numbers. */
+const TInt8 KTranHandleSrvMajorVersionNumber = 1;
+const TInt8 KTranHandleSrvMinorVersionNumber = 1;
+const TInt16 KTranHandleSrvBuildNumber = 0;
+
+/** IPC messages supported by the server. */
+enum TNcmIpc
+    {
+    ETransferHandle              = 0,
+    ENotSupport
+    };
+    
+
+#endif // TRANHANDLESERVERCONSTS_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/tranhandleserversecuritypolicy.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,63 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+ @file 
+ @internalComponent
+*/
+ 
+#ifndef TRANHANDLESERVERSECURITYPOLICY_H
+#define TRANHANDLESERVERSECURITYPOLICY_H
+
+#include <e32base.h>
+#include "tranhandleserverconsts.h"
+
+const TInt KTranHanleServerRanges[] = 
+    {
+    ETransferHandle,             /** pass */
+    ENotSupport,        /** fail (to KMaxTInt) */
+    };
+
+const TUint KTranHanleServerRangeCount = sizeof(KTranHanleServerRanges) / sizeof(KTranHanleServerRanges[0]);
+
+const TInt KPolicyPass = 0;
+
+const TUint8 KTranHanleServerElementsIndex[KTranHanleServerRangeCount] = 
+    {
+    KPolicyPass,                  /** All (valid) APIs */
+    CPolicyServer::ENotSupported,   /** remainder of possible IPCs */
+    };
+
+
+const CPolicyServer::TPolicyElement KTranHanleServerElements[] = 
+    {
+        { 
+        _INIT_SECURITY_POLICY_PASS
+        },
+    };
+
+/** Main policy */
+const CPolicyServer::TPolicy KTranHandleServerPolicy = 
+    {
+    CPolicyServer::EAlwaysPass, /** Specifies all connect attempts should pass */
+    KTranHanleServerRangeCount,
+    KTranHanleServerRanges,
+    KTranHanleServerElementsIndex,
+    KTranHanleServerElements,
+    };
+    
+#endif // TRANHANDLESERVERSECURITYPOLICY_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/tranhandlesession.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TRANHANDLESESSION_H
+#define TRANHANDLESESSION_H
+
+#include <e32base.h>
+
+
+class CActiveControl;
+
+NONSHARABLE_CLASS(CTranHandleSession) : public CSession2
+    {
+public:
+    static CTranHandleSession* NewL(CActiveControl& aControl);
+    ~CTranHandleSession();
+
+private:
+    CTranHandleSession(CActiveControl& aControl);
+
+private: // from CSession2
+
+    void ServiceL(const RMessage2& aMessage);
+
+private:
+    // unowned
+    CActiveControl& iActiveControl;
+    };
+
+#endif // TRANHANDLESESSION_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/tranhandlesrv.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,44 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef TRANHANDLESRV_H
+#define TRANHANDLESRV_H
+
+#include <e32base.h>
+
+NONSHARABLE_CLASS(RTranHandleSrv) : public RSessionBase
+    {
+public:
+    IMPORT_C RTranHandleSrv();
+    IMPORT_C ~RTranHandleSrv();
+
+public:
+
+    IMPORT_C TInt Connect();
+    IMPORT_C TVersion Version() const;
+
+public:
+    IMPORT_C TInt TransferHandle(RHandleBase& aHandle, RHandleBase& aChunk);
+private:
+    };
+
+#endif // TRANHANDLESRV_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/tranhandlsession.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TRANHANDLESERVERCONSTS_H
+#define TRANHANDLESERVERCONSTS_H
+
+#include <e32base.h>
+
+_LIT(KTranHandleServerName, "!TranHandleSrv");
+
+/** Version numbers. */
+const TInt8 KNcmSrvMajorVersionNumber = 1;
+const TInt8 KNcmSrvMinorVersionNumber = 1;
+const TInt16 KNcmSrvBuildNumber = 0;
+
+/** IPC messages supported by the server. */
+enum TNcmIpc
+    {
+    ENcmTransferHandle              = 0,
+    ENcmSetIapId,
+    ENcmSetDhcpResult,
+    ENcmDhcpProvisionNotify,
+    ENcmDhcpProvisionNotifyCancel,
+    ENcmTransferBufferSize,
+    ENcmNotSupport
+    };
+    
+/** Panic category with which the ACM server panics the client. */
+_LIT(KNcmSrvPanic,"NCMServer");
+
+/** Panic codes with which the ACM server panics the client. */
+enum TNcmSvrPanic
+    {
+    /** The client has sent a bad IPC message number. */
+    ENcmBadNcmMessage        = 0
+    };
+    
+/** Set value to server. the value is defined by type.*/
+enum TNcmSetType
+    {
+    ENcmSetTypeIapId,
+    ENcmSetTypeDhcpReturn
+    };
+
+#endif // ACMSERVERCONSTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/transferhandle.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* 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 "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:
+* Header file NTB build policy base class
+*
+*/
+
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef TRANSFERHANDLE_H
+#define TRANSFERHANDLE_H
+
+
+#include <e32base.h>
+
+class CTransferServer;
+
+NONSHARABLE_CLASS(CTransferHandle) : public CActive
+    {
+public:
+    static CTransferHandle* NewL(CTransferServer& aServer);
+    ~CTransferHandle();
+	void StartTimer();
+	
+private:
+	CTransferHandle(CTransferServer& aServer);
+	CTransferServer& iServer;
+	void RunL();
+    void DoCancel();
+    void ConstructL();
+    RTimer iTimer;
+};
+
+
+
+
+#endif //TRANSFERHANDLE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/transferserver.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,84 @@
+/**
+* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+* Implements a Symbian OS server that exposes the RUsb API
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __CTRANSFERSERVER_H__
+#define __CTRANSFERSERVER_H__
+
+#include "general.h"
+#include "config.h"
+
+
+class CTransferHandle;
+
+ NONSHARABLE_CLASS(CTransferServer) : public CPolicyServer
+	{
+public:
+	static CTransferServer* NewLC();
+	virtual ~CTransferServer();
+
+	virtual CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMessage) const;
+	void Error(TInt aError);
+
+	void IncrementSessionCount();
+	void DecrementSessionCount();
+	inline TInt SessionCount() const;
+	void LaunchShutdownTimerIfNoSessions();
+	TInt SetupLdds(TDes& aFileName);
+	void TransferHandleL();
+
+protected:
+	CTransferServer();
+	void ConstructL();
+	
+private:	
+	TInt iSessionCount;
+	enum {KShutdownDelay = 2 * 1000 * 1000};	// 2 seconds
+	class CShutdownTimer : public CTimer
+		{
+	public:
+		CShutdownTimer();
+		void ConstructL();
+		virtual void RunL();
+		};
+	CShutdownTimer* iShutdownTimer;
+	
+	void SetupInterface(IFConfigPtr* aIfPtr, TInt aPortNumber);
+	void FillEndpointsResourceAllocation(IFConfigPtr aIfCfg);
+	void PopulateInterfaceResourceAllocation(IFConfigPtr aFirstIfCfg, TInt aPortNumber);
+	void QueryUsbClientL(LDDConfigPtr aLddPtr, RDEVCLIENT* aPort);	
+
+	TInt iTotalChannels;
+	RFs iFs;
+	RFile iConfigFile;
+	LDDConfigPtr iLddPtr;
+	RDEVCLIENT iPort[KMaxInterfaces];
+	TBool iSupportResourceAllocationV2;
+	TBool iSoftwareConnect;
+	CConsoleBase* iConsole;
+
+	CTransferHandle* iTransferHandle;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/transferserversecuritypolicy.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+* USBMAN Server Security Policy definitions for Platform security.
+*
+*/
+
+/**
+ @file 
+ @internalComponent
+*/
+ 
+#if !defined(__TRANSFERSERVERSECURITYPOLICY_H__)
+#define __TRANSFERSERVERSECURITYPOLICY_H__
+
+
+const TInt KTransferServerRanges[] = 
+	{
+	ESetConfigFileName,                 			/** pass 		*/
+	ETransferNotSupport					 				/** fail (to KMaxTInt) 	*/
+	};
+
+const TUint KTransferServerRangeCount = sizeof(KTransferServerRanges) / sizeof(KTransferServerRanges[0]);
+
+/** Index numbers into KAcmServerElements[] */
+const TInt KPolicyPass = 0;
+
+/** Mapping IPCs to policy element */
+const TUint8 KTransferServerElementsIndex[KTransferServerRangeCount] = 
+    {
+    KPolicyPass,                  /** All (valid) APIs */
+    CPolicyServer::ENotSupported,   /** remainder of possible IPCs */
+    };
+
+/** Individual policy elements */
+const CPolicyServer::TPolicyElement KTransferServerElements[] = 
+	{
+  		{ _INIT_SECURITY_POLICY_PASS },
+	};
+
+/** Main policy */
+const CPolicyServer::TPolicy KTransferServerPolicy = 
+	{
+	CPolicyServer::EAlwaysPass, /** Specifies all connect attempts should pass */
+	KTransferServerRangeCount,
+	KTransferServerRanges,
+	KTransferServerElementsIndex,
+	KTransferServerElements,
+	};
+#endif //__TRANSFERSERVERSECURITYPOLICY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/transfersession.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,57 @@
+/**
+* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+* Implements a Session of a Symbian OS server for the RUsb API
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __CTRANSFERSESSION_H__
+#define __CTRANSFERSESSION_H__
+
+#include <e32std.h>
+#include "general.h"
+
+class CTransferServer;
+class CTransferHandle;
+
+NONSHARABLE_CLASS(CTransferSession) : public CSession2
+	{
+public:
+	static CTransferSession* NewL(CTransferServer* aServer);
+	virtual ~CTransferSession();
+
+	// CSession2
+	virtual void ServiceL(const RMessage2& aMessage);
+	virtual void CreateL();
+	void TransferHandleL();
+
+protected:
+	CTransferSession(CTransferServer* aServer);
+
+	void DispatchMessageL(const RMessage2& aMessage);
+
+private:
+	CTransferServer* iTransferServer;
+	CConsoleBase* iConsole;
+		
+	};
+
+#endif //__CTRANSFERSESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/include/transfersrv.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* 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 "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:
+* Definitions required for RUsb
+*
+*/
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __TRANSFER_H__
+#define __TRANSFER_H__
+
+#include <e32std.h>
+#include <e32base.h>
+
+
+_LIT(KTransferServerName, "!transferserver");
+
+const TInt KTransferSrvMajorVersionNumber = 1;
+const TInt KTransferSrvMinorVersionNumber = 1;
+const TInt KTransferSrvBuildVersionNumber = 0;
+
+const TUid KTransferSvrUid = {0x101FE1DB};
+
+
+enum TTransferMessages
+	{
+	ESetConfigFileName,
+	ETransferNotSupport
+	};
+
+NONSHARABLE_CLASS(RTransferSrv) : public RSessionBase
+    {
+public:
+    IMPORT_C RTransferSrv();
+    IMPORT_C ~RTransferSrv();
+
+public:
+    IMPORT_C TInt Connect();
+    IMPORT_C TVersion Version() const;
+	IMPORT_C TInt SetConfigFileName(TDes& aString);
+
+    };
+
+#endif //__TRANSFER_H__
+
--- a/kerneltest/e32test/usb/t_usb_device/src/activecontrol.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/src/activecontrol.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2000-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"
@@ -24,6 +24,9 @@
 #include "activecontrol.h"
 #include "apitests.h"
 #include "activerw.h"
+#ifdef USB_SC
+#include "tranhandleserver.h"
+#endif
 
 void StartMassStorage(RDEVCLIENT* aPort);
 void StopMassStorage(RDEVCLIENT* aPort);
@@ -42,6 +45,9 @@
 	};
 
 extern RTest test;
+#ifdef USB_SC	
+extern TBool gShareHandle;
+#endif
 extern TBool gVerbose;
 extern TBool gSkip;
 extern TBool gTempTest;
@@ -151,10 +157,25 @@
 	return self;
 	}
 
-
 void CActiveControl::ConstructL()
 	{
 	CActiveScheduler::Add(this);
+#ifdef USB_SC	
+	if (gShareHandle)
+		{
+		iTranHandleServer = CTranHandleServer::NewL(*this);
+		RTransferSrv aSrv;
+		test.Next (_L("ConstructL"));
+		User::LeaveIfError(aSrv.Connect());
+		CleanupClosePushL(aSrv);	
+		test.Next (_L("ConstructL1"));
+		User::LeaveIfError(aSrv.SetConfigFileName(*iConfigFileName));
+		test.Next (_L("ConstructL2"));
+		CleanupStack::Pop();
+		aSrv.Close();
+		return;
+		}
+#endif
 	TInt r;
 	
 	User::LeaveIfError(iFs.Connect());
@@ -680,7 +701,10 @@
 		delete (*lddPtrPtr);
 		* lddPtrPtr = NULL;
 		}
-
+#ifdef USB_SC
+	delete iTranHandleServer;
+	TUSB_PRINT("CActiveControl::delete iTranHandleServer");
+#endif
 	iFs.Close();
 	}
 
@@ -918,6 +942,12 @@
 								}	
 							}
 						TUSB_VERBOSE_PRINT1 ("Closing USB channel number %d",portNumber);
+#ifdef USB_SC
+						RChunk* commChunk;
+						User::LeaveIfError(iPort[portNumber].GetDataTransferChunk(commChunk));
+						commChunk->Close(); 
+#endif
+						
 						iPort[portNumber].Close();											// close USB channel
 						}
 					TUSB_VERBOSE_PRINT("Closing Idle Counter Thread");
@@ -1209,6 +1239,12 @@
 								}	
 							}
 						TUSB_VERBOSE_PRINT1 ("Closing USB channel number %d",portNumber);
+#ifdef USB_SC
+						RChunk* commChunk;
+						User::LeaveIfError(iPort[portNumber].GetDataTransferChunk(commChunk));
+						commChunk->Close();	
+						TUSB_PRINT("commChunk->Close");
+#endif
 						iPort[portNumber].Close();											// close USB channel
 						}
 		
@@ -1714,4 +1750,354 @@
 	return KErrNone;
 	}
 
+
+#ifdef USB_SC	
+
+void CActiveControl::SetupTransferedInterface(IFConfigPtr* aIfPtr, TInt aPortNumber)
+	{
+	TInt r;
+	TUSB_VERBOSE_PRINT1("SetupTransferedInterface %d", aPortNumber);
+	test.Start (_L("Setup Transfered Interface "));
+
+	#ifdef USB_SC
+	TUsbcScInterfaceInfoBuf ifc = *((*aIfPtr)->iInfoPtr);
+	#else
+	TUsbcInterfaceInfoBuf ifc = *((*aIfPtr)->iInfoPtr);
+	#endif
+	
+	TBuf8<KUsbDescSize_Interface> ifDescriptor;
+	r = iPort[aPortNumber].GetInterfaceDescriptor(0, ifDescriptor);
+	test_KErrNone(r);
+
+	// Check the interface descriptor
+	test(ifDescriptor[KIfcDesc_SettingOffset] == 0 && ifDescriptor[KIfcDesc_NumEndpointsOffset] == (*aIfPtr)->iInfoPtr->iTotalEndpointsUsed &&
+	    ifDescriptor[KIfcDesc_ClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iClassNum &&
+	    ifDescriptor[KIfcDesc_SubClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iSubClassNum &&
+	    ifDescriptor[KIfcDesc_ProtocolOffset] == (*aIfPtr)->iInfoPtr->iClass.iProtocolNum);
+
+	if ((*aIfPtr)->iNumber != 0 && ifDescriptor[KIfcDesc_NumberOffset] != (*aIfPtr)->iNumber)
+		{
+		ifDescriptor[KIfcDesc_NumberOffset] = (*aIfPtr)->iNumber;
+		r = iPort[aPortNumber].SetInterfaceDescriptor(0, ifDescriptor);	
+		test_KErrNone(r);
+		}
+	else
+		{
+		(*aIfPtr)->iNumber = ifDescriptor[KIfcDesc_NumberOffset];	
+		}
+	TUint8 interfaceNumber = (*aIfPtr)->iNumber;
+	TUSB_PRINT1 ("Interface Number %d",interfaceNumber);
+		
+	// Check all endpoint descriptors
+	TBuf8<KUsbDescSize_AudioEndpoint> epDescriptor;
+	for (TUint i = 0; i < (*aIfPtr)->iInfoPtr->iTotalEndpointsUsed; i++)
+		{
+		if (!gSkip)
+			{
+			TestEndpointDescriptor (&iPort[aPortNumber],0,i+1,(*aIfPtr)->iInfoPtr->iEndpointData[i]);	
+
+			}
+
+		if (firstBulkOutEndpoint < 0 && ((*aIfPtr)->iInfoPtr->iEndpointData[i].iDir & KUsbEpDirOut) &&
+			(*aIfPtr)->iInfoPtr->iEndpointData[i].iType == KUsbEpTypeBulk)
+			{
+			firstBulkOutEndpoint = i+1;	
+			}
+		}
+
+	TUSB_PRINT1 ("Interface number is %d",interfaceNumber);
+	(*aIfPtr)->iPortNumber = aPortNumber;
+	gInterfaceConfig [interfaceNumber] [0] = *aIfPtr;
+
+	TInt alternateNumber = 1;
+	// check for any alternatate interfaces and set any that are found
+	* aIfPtr = (*aIfPtr)->iPtrNext;
+	if (* aIfPtr != NULL)
+		{
+		test(SupportsAlternateInterfaces());
+
+		IFConfigPtr ifPtr = *aIfPtr;
+		while (ifPtr != NULL)
+			{
+			if (ifPtr->iAlternateSetting)
+				{
+				ifc = *(ifPtr->iInfoPtr);
+					
+				r = iPort[aPortNumber].GetInterfaceDescriptor(alternateNumber, ifDescriptor);
+				test_KErrNone(r);
+
+				// Check the interface descriptor
+				test(ifDescriptor[KIfcDesc_SettingOffset] == alternateNumber && ifDescriptor[KIfcDesc_NumEndpointsOffset] == (*aIfPtr)->iInfoPtr->iTotalEndpointsUsed &&
+				    ifDescriptor[KIfcDesc_ClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iClassNum &&
+				    ifDescriptor[KIfcDesc_SubClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iSubClassNum &&
+				    ifDescriptor[KIfcDesc_ProtocolOffset] == (*aIfPtr)->iInfoPtr->iClass.iProtocolNum);
+
+				// Check all endpoint descriptors
+				for (TUint i = 0; i < ifPtr->iInfoPtr->iTotalEndpointsUsed; i++)
+					{
+					TInt desc_size;
+					r = iPort[aPortNumber].GetEndpointDescriptorSize(alternateNumber, i+1, desc_size);
+					test_KErrNone(r);
+					test_Equal(KUsbDescSize_Endpoint + (*aIfPtr)->iInfoPtr->iEndpointData[i].iExtra,static_cast<TUint>(desc_size));
+
+					r = iPort[aPortNumber].GetEndpointDescriptor(alternateNumber, i+1, epDescriptor);
+					test_KErrNone(r);
+					
+					test((((*aIfPtr)->iInfoPtr->iEndpointData[i].iDir & KUsbEpDirIn) && (epDescriptor[KEpDesc_AddressOffset] & 0x80) ||
+						!((*aIfPtr)->iInfoPtr->iEndpointData[i].iDir & KUsbEpDirIn) && !(epDescriptor[KEpDesc_AddressOffset] & 0x80)) &&
+						EpTypeMask2Value((*aIfPtr)->iInfoPtr->iEndpointData[i].iType) == (TUint)(epDescriptor[KEpDesc_AttributesOffset] & 0x03) &&
+						(*aIfPtr)->iInfoPtr->iEndpointData[i].iInterval == epDescriptor[KEpDesc_IntervalOffset]);
+
+
+					if (!gSkip && (*aIfPtr)->iInfoPtr->iEndpointData[i].iExtra)
+						{
+						test.Next(_L("Extended Endpoint Descriptor Manipulation"));
+						TUint8 addr = 0x85;										// bogus address
+						if (epDescriptor[KEpDesc_SynchAddressOffset] == addr)
+							addr++;
+						epDescriptor[KEpDesc_SynchAddressOffset] = addr;
+						r = iPort[aPortNumber].SetEndpointDescriptor(alternateNumber, i+1, epDescriptor);
+						test_KErrNone(r);
+
+						TBuf8<KUsbDescSize_AudioEndpoint> descriptor2;
+						r = iPort[aPortNumber].GetEndpointDescriptor(alternateNumber, i+1, descriptor2);
+						test_KErrNone(r);
+
+						test.Next(_L("Compare endpoint descriptor with value set"));
+						r = descriptor2.Compare(epDescriptor);
+						test_KErrNone(r);						
+						}
+					}
+				
+					
+				// if no error move on to the next interface
+				ifPtr->iPortNumber = aPortNumber;
+				ifPtr->iNumber = interfaceNumber;
+				gInterfaceConfig [interfaceNumber] [alternateNumber] = ifPtr;
+
+				alternateNumber++;
+				ifPtr = ifPtr->iPtrNext;
+				* aIfPtr = ifPtr;
+				}
+			else
+				{
+				ifPtr = NULL;
+				}
+			}
+		}
+	iNumInterfaceSettings[aPortNumber] = alternateNumber;
+	if (!gSkip)
+		{
+		TestInvalidSetInterface (&iPort[aPortNumber],iNumInterfaceSettings[aPortNumber]);			
+		TestInvalidReleaseInterface (&iPort[aPortNumber],iNumInterfaceSettings[aPortNumber]);
+
+		//TestDescriptorManipulation(iLddPtr->iHighSpeed,&iPort[aPortNumber],alternateNumber);
+		TestOtgExtensions(&iPort[aPortNumber]);
+		TestEndpoint0MaxPacketSizes(&iPort[aPortNumber]);
+		}
+		
+	test.End();
+	}
+
+
+void CActiveControl::ConstructLOnSharedLdd(const RMessagePtr2& aMsg)
+	{
+// currently only support one interface with one alternate settings	
+	test.Start (_L("ConstructLOnSharedLdd Configuration"));
+
+	User::LeaveIfError(iPort[0].Open(aMsg, 0, EOwnerProcess));
+	CleanupClosePushL(iPort[0]);
+
+	RChunk* chunk;
+	//Get the Ldd's RChunk, but don't own it.
+	User::LeaveIfError(iPort[0].GetDataTransferChunk(chunk));
+	User::LeaveIfError(chunk->Open(aMsg, 1, FALSE, EOwnerProcess));
+	CleanupStack::Pop();
+	
+
+	TInt r;
+
+	User::LeaveIfError(iFs.Connect());
+
+	test_Compare(iConfigFileName->Length(),!=,0);
+		
+	iTimer.CreateLocal();
+	iPending = EPendingNone;
+	
+	test.Next (_L("Open configuration file"));
+	// set the session path to use the ROM if no drive specified
+	r=iFs.SetSessionPath(_L("Z:\\test\\"));
+	test_KErrNone(r);
+
+	r = iConfigFile.Open(iFs, * iConfigFileName, EFileShareReadersOnly | EFileStreamText | EFileRead);
+	test_KErrNone(r);
+	TUSB_VERBOSE_PRINT1("Configuration file %s Opened successfully", iConfigFileName->PtrZ());
+
+	test.Next (_L("Process configuration file"));
+	test(ProcessConfigFile (iConfigFile,iConsole,&iLddPtr));
+	
+	iConfigFile.Close();
+
+	test.Next (_L("LDD in configuration file"));
+	test_NotNull(iLddPtr);
+		
+	LDDConfigPtr lddPtr = iLddPtr;
+	TInt nextPort = 0;
+	while (lddPtr != NULL)
+		{
+		// Load logical driver (LDD)
+		// (There's no physical driver (PDD) with USB: it's a kernel extension DLL which
+		//  was already loaded at boot time.)
+		test.Next (_L("Loading USB LDD"));
+		TUSB_VERBOSE_PRINT1("Loading USB LDD ",lddPtr->iName.PtrZ());
+		r = User::LoadLogicalDevice(lddPtr->iName);
+		test(r == KErrNone || r == KErrAlreadyExists);
+	
+		IFConfigPtr ifPtr = lddPtr->iIFPtr;
+		
+		test.Next (_L("Opening Channels"));
+		TUSB_VERBOSE_PRINT1("Successfully opened USB port %d", lddPtr->iNumChannels);
+		for (TInt portNumber = nextPort; portNumber < nextPort+lddPtr->iNumChannels; portNumber++)
+			{
+			test_Compare(lddPtr->iNumChannels,>,0);
+
+			// Open USB channel
+			
+			TUSB_VERBOSE_PRINT("Successfully opened USB port");
+
+			// Query the USB device/Setup the USB interface
+			if (portNumber == nextPort)
+				{
+				// Change some descriptors to contain suitable values
+				SetupDescriptors(lddPtr, &iPort[portNumber]);
+				}
+				
+			if (portNumber == 0)
+				{
+				QueryUsbClientL(lddPtr, &iPort[portNumber]);
+				}
+
+			test_NotNull(ifPtr);
+			
+			if (iSupportResourceAllocationV2)
+				{
+				PopulateInterfaceResourceAllocation(ifPtr, portNumber);
+				}
+				
+			IFConfigPtr defaultIfPtr = ifPtr;
+			SetupTransferedInterface(&ifPtr,portNumber);
+					
+
+			if (!iSupportResourceAllocationV2)
+				{
+				// 	allocate endpoint DMA and double buffering for all endpoints on default interface when using resource allocation v1 api
+				for (TUint8 i = 1; i <= defaultIfPtr->iInfoPtr->iTotalEndpointsUsed; i++)
+					{
+					defaultIfPtr->iEpDMA[i-1] ? AllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i);
+					#ifndef USB_SC
+					defaultIfPtr->iEpDoubleBuff[i-1] ? AllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i);
+					#endif
+					}				
+				}
+			}
+	
+		iTotalChannels += lddPtr->iNumChannels;
+		nextPort += lddPtr->iNumChannels;	
+		lddPtr = lddPtr->iPtrNext;	
+		}
+		
+	TUSB_VERBOSE_PRINT("All Interfaces and Alternate Settings successfully set up");
+	
+	test.Next (_L("Start Idle Counter Thread"));
+	r = iIdleCounterThread.Create(_L("IdleCounter"), IdleCounterThread, KDefaultStackSize, KMinHeapSize, KMinHeapSize, NULL);
+	test_KErrNone(r);
+	iIdleCounterThread.Resume();
+	// Allow some time for low-priority counter process
+	User::After(100000); // 0.1 second
+	r = iIdleCounterChunk.OpenGlobal(KTestIdleCounterChunkName, EFalse);
+	test_KErrNone(r);
+	iIdleCounter = (struct TTestIdleCounter*) iIdleCounterChunk.Base();
+	test_NotNull(iIdleCounter);
+	// Allow some time for low-priority counter process
+	User::After(100000); // 0.1 second
+	TInt64 val1 = iIdleCounter->iCounter;
+	User::After(1000000); // 1 second
+	TInt64 val2 = iIdleCounter->iCounter;
+	TUSB_PRINT1("Idle Counter when test inactive: %Ldinc/ms", (val2 - val1) / 1000);
+
+	test.Next (_L("Enumeration..."));
+	r = ReEnumerate();
+	test_KErrNone(r);
+		
+	TUSB_VERBOSE_PRINT("Device successfully re-enumerated\n");
+
+
+	if (iLddPtr->iHighSpeed && !gSkip)
+		{
+		test.Next (_L("High Speed"));
+		test(iHighSpeed);	
+		}
+			
+	test.Next (_L("Create Notifiers"));
+	for (TInt portNumber = 0; portNumber < iTotalChannels; portNumber++)
+		{
+
+		// Create device state active object
+		iDeviceStateNotifier[portNumber] = CActiveDeviceStateNotifier::NewL(iConsole, &iPort[portNumber], portNumber);
+		test_NotNull(iDeviceStateNotifier[portNumber]);
+		iDeviceStateNotifier[portNumber]->Activate();
+		TUSB_VERBOSE_PRINT("Created device state notifier");
+
+		// Create endpoint stall status active object
+		iStallNotifier[portNumber] = CActiveStallNotifier::NewL(iConsole, &iPort[portNumber]);
+		test_NotNull(iStallNotifier[portNumber]);
+		iStallNotifier[portNumber]->Activate();
+		TUSB_VERBOSE_PRINT("Created stall notifier");
+			
+		TestInvalidSetInterface (&iPort[portNumber],iNumInterfaceSettings[portNumber]);			
+		TestInvalidReleaseInterface (&iPort[portNumber],iNumInterfaceSettings[portNumber]);
+			
+		}
+		
+	test.Next (_L("Endpoint Zero Max Packet Sizes"));
+	TUint ep0Size = iPort[0].EndpointZeroMaxPacketSizes();
+	switch (ep0Size)
+		{
+		case KUsbEpSize8 :
+			iEp0PacketSize = 8;
+			break;
+					
+		case KUsbEpSize16 :
+			iEp0PacketSize = 16;
+			break;
+
+		case KUsbEpSize32 :
+			iEp0PacketSize = 32;
+			break;
+
+		case KUsbEpSize64 :
+			iEp0PacketSize = 64;
+			break;
+					
+		default:
+			iEp0PacketSize = 0;
+			break;		
+		}
+	test_Compare(iEp0PacketSize,>,0);
+
+	test.Next (_L("Set Device Control"));
+	r = iPort[0].SetDeviceControl();
+	test_KErrNone(r);
+
+	#ifdef USB_SC
+	r = iPort[0].OpenEndpoint(iEp0Buf,0);
+	test_KErrNone(r);
+	#endif
+	
+	test.End();
+	//iSrv.Close();
+	RequestEp0ControlPacket();
+	}
+
+#endif
 // -eof-
--- a/kerneltest/e32test/usb/t_usb_device/src/activedevicestatenotifier.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/src/activedevicestatenotifier.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2000-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"
@@ -85,6 +85,17 @@
 		switch (iDeviceState)
 			{
 		case EUsbcDeviceStateUndefined:
+#ifdef	USB_SC
+			TUSB_PRINT("Device State notifier: Undefined0");
+			for (TUint16 i =0; i < KMaxConcurrentTests; i++)
+				{
+				if (gRW[i])
+					{
+					TUSB_VERBOSE_PRINT2("ResetAltSetting index %d, LDD %x",i, gRW[i]->Ldd());
+					gRW[i]->Ldd()->ResetAltSetting();						
+					}
+				}
+#endif
 			TUSB_PRINT("Device State notifier: Undefined");
 			break;
 		case EUsbcDeviceStateAttached:
--- a/kerneltest/e32test/usb/t_usb_device/src/activerw.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/src/activerw.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2000-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"
@@ -71,7 +71,6 @@
 
 CActiveRW* CActiveRW::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort, RFs aFs, TUint16 aIndex, TBool aLastSetting)
 	{
-	TUSB_VERBOSE_APRINT("CActiveRW::NewL()");
 
 	CActiveRW* self = new (ELeave) CActiveRW(aConsole, aPort, aFs, aIndex, aLastSetting);
 	CleanupStack::PushL(self);
--- a/kerneltest/e32test/usb/t_usb_device/src/main.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/usb/t_usb_device/src/main.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2002-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"
@@ -20,7 +20,7 @@
 #include "general.h"
 #include "config.h"
 #include "activecontrol.h"
-#include "activeRW.h"
+#include "activerw.h"
 
 // --- Global Top Level Variables
 
@@ -30,6 +30,10 @@
 #else
 RTest test(_L("T_USB_DEVICE"));
 #endif
+
+#ifdef USB_SC	
+TBool gShareHandle = EFalse;
+#endif
 TBool gVerbose = EFalse;
 TBool gSkip = EFalse;
 TBool gTempTest = EFalse;
@@ -81,8 +85,12 @@
 
 	
 		// Call request function
+#ifdef USB_SC		
+		if (!gShareHandle)
+			gActiveControl->RequestEp0ControlPacket();
+#else
 		gActiveControl->RequestEp0ControlPacket();
-
+#endif
 		CActiveScheduler::Start();
 		
 		test.Printf (_L("Test Run Completed\n"));
@@ -147,6 +155,13 @@
 				RDebug::Print(_L("Not Stopping on Test Fail\n"));
 				gStopOnFail = EFalse;
 				}
+#ifdef USB_SC	
+			else if (token == _L("/a"))
+				{				
+				RDebug::Print(_L("share handle test\n"));
+				gShareHandle = ETrue;
+				}
+#endif
 			else if (token.Left(5) == _L("/soak"))
 				{
 				TInt equalPos;
@@ -205,7 +220,6 @@
 	__UHEAP_MARKEND;
 
 	RDebug::Print(_L("Program exit: done.\n"));
-
 	return 0;												// and return
 	}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/tranhandleserver.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#include "tranhandleserver.h"
+#include "tranhandlesession.h"
+#include "tranhandleserversecuritypolicy.h"
+#include "tranhandleserverconsts.h"
+#include "general.h"
+
+
+
+CTranHandleServer* CTranHandleServer::NewL(CActiveControl& aControl)
+    {
+    RDebug::Printf("CTranHandleServer::NewL");
+    CTranHandleServer* self = new(ELeave) CTranHandleServer(aControl);
+    CleanupStack::PushL(self);
+    TInt err = self->Start(KTranHandleServerName);
+
+    if ( err != KErrAlreadyExists )
+        {
+        User::LeaveIfError(err);
+        }
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CTranHandleServer::~CTranHandleServer()
+    {
+    RDebug::Printf("CTranHandleServer::~CTranHandleServer");
+    }
+
+CTranHandleServer::CTranHandleServer(CActiveControl& aControl)
+ :  CPolicyServer(CActive::EPriorityStandard, KTranHandleServerPolicy, ESharableSessions),
+    iActiveControl(aControl)
+    {
+    }
+
+CSession2* CTranHandleServer::NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const
+    {
+    //Validate session as coming from UsbSvr
+	RDebug::Printf("CTranHandleServer::NewSessionL");
+    CTranHandleSession* sess = CTranHandleSession::NewL(iActiveControl);
+    return sess;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/tranhandlesession.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <e32base.h>
+
+#include "tranhandleserverconsts.h"
+#include "tranhandlesession.h"
+#include "activecontrol.h"
+
+
+
+CTranHandleSession* CTranHandleSession::NewL(CActiveControl& aControl)
+    {
+    CTranHandleSession* self = new(ELeave) CTranHandleSession(aControl);
+    return self;
+    }
+
+CTranHandleSession::CTranHandleSession(CActiveControl& aControl)
+    : iActiveControl(aControl)
+    {
+    }
+
+CTranHandleSession::~CTranHandleSession()
+    {
+    RDebug::Printf("CTranHandleSession::~CTranHandleSession");
+    }
+
+void CTranHandleSession::ServiceL(const RMessage2& aMessage)
+    {
+	RDebug::Printf("CTranHandleSession::ServiceL");
+	TInt r;
+    switch ( aMessage.Function() )
+        {
+    case ETransferHandle:
+        {
+        RMessagePtr2 messagePtr(aMessage);
+        TRAP(r, iActiveControl.ConstructLOnSharedLdd(messagePtr));
+
+        aMessage.Complete(r);
+        break;
+        }
+
+    default:
+        aMessage.Complete(KErrNotSupported);
+        break;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/tranhandlesrv.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+@file
+@internalTechnology
+*/
+
+#include <e32base.h>
+#include "tranhandlesrv.h"
+#include "tranhandleserverconsts.h"
+
+
+/** Constructor */
+EXPORT_C RTranHandleSrv::RTranHandleSrv()
+    {
+    }
+
+/** Destructor */
+EXPORT_C RTranHandleSrv::~RTranHandleSrv()
+    {
+    }
+
+EXPORT_C TVersion RTranHandleSrv::Version() const
+    {
+    return TVersion(    KTranHandleSrvMajorVersionNumber,
+                        KTranHandleSrvMinorVersionNumber,
+                        KTranHandleSrvBuildNumber
+                    );
+    }
+
+EXPORT_C TInt RTranHandleSrv::Connect()
+    {
+    return CreateSession(KTranHandleServerName, Version(), 1);
+    }
+
+EXPORT_C TInt RTranHandleSrv::TransferHandle(RHandleBase& aHandle, RHandleBase& aChunk)
+    {
+    return SendReceive(ETransferHandle, TIpcArgs(aHandle, aChunk));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/transferhandle.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* 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 "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:
+* Header file NTB build policy base class
+*
+*/
+
+
+/**
+@file
+@internalComponent
+*/
+
+#include "transferhandle.h"
+#include "transferserver.h"
+
+CTransferHandle* CTransferHandle::NewL(CTransferServer& aServer)
+    {
+    CTransferHandle *self=new (ELeave) CTransferHandle(aServer);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;    
+    }
+
+CTransferHandle::CTransferHandle(CTransferServer& aServer)
+    : CActive(CActive::EPriorityStandard), iServer(aServer)
+    {
+    }
+
+CTransferHandle::~CTransferHandle()
+    {
+    RDebug::Printf("CTransferHandle::~CTransferHandle");
+    Cancel();
+    iTimer.Close();
+    }
+
+void CTransferHandle::DoCancel()
+    {
+    RDebug::Printf("CTransferHandle::DoCancel");
+    iTimer.Cancel();
+    }
+
+void CTransferHandle::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    User::LeaveIfError(iTimer.CreateLocal());
+    }
+
+_LIT(KPanic, "CTransferHandle");
+const TInt KTimerError = 1;
+
+
+void CTransferHandle::RunL()
+	{
+	if(iStatus.Int() != KErrNone)
+		{		
+		RDebug::Printf("CTransferHandle::RunL");
+		User::Panic(KPanic, KTimerError);
+		return;
+		}
+	iServer.TransferHandleL();
+	}
+
+void CTransferHandle::StartTimer()
+	{
+	iStatus = KRequestPending;
+    iTimer.After(iStatus, 10000);
+    SetActive();
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/transferserver.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,486 @@
+/*
+* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*
+*/
+
+/**
+ @file
+*/
+
+#include <e32svr.h>
+#include "transferserver.h"
+#include "transfersession.h"
+#include "transfersrv.h"
+#include "transferserversecuritypolicy.h"
+#include "transferhandle.h"
+#include "tranhandlesrv.h"
+
+
+
+TBool gVerbose = ETrue;
+extern RTest test;
+
+
+CTransferServer* CTransferServer::NewLC()
+	{
+	RDebug::Printf("CTransferServer::NewLC");
+	CTransferServer* self = new(ELeave) CTransferServer;
+	CleanupStack::PushL(self);
+	self->StartL(KTransferServerName);
+	self->ConstructL();
+	return self;
+	}
+
+CTransferServer::~CTransferServer()
+	{
+	RDebug::Printf("CTransferServer::~CTransferServer");
+	while (iLddPtr->iIFPtr)
+	{
+	IFConfigPtr* ifPtrPtr = & iLddPtr->iIFPtr;
+	while ((*ifPtrPtr)->iPtrNext)
+		{
+		ifPtrPtr = &(*ifPtrPtr)->iPtrNext;
+		}
+	delete (*ifPtrPtr)->iInfoPtr->iString;
+	delete (*ifPtrPtr)->iInfoPtr;
+	delete (*ifPtrPtr);
+	* ifPtrPtr = NULL;
+	}
+
+	while (iLddPtr)
+		{
+		LDDConfigPtr* lddPtrPtr = &iLddPtr;	
+		while ((*lddPtrPtr)->iPtrNext)
+			{
+			lddPtrPtr = &(*lddPtrPtr)->iPtrNext;
+			}
+		delete (*lddPtrPtr)->iManufacturer;
+		delete (*lddPtrPtr)->iProduct;
+		delete (*lddPtrPtr)->iSerialNumber;
+		delete (*lddPtrPtr);
+		* lddPtrPtr = NULL;
+		}
+
+	delete iShutdownTimer;	
+	delete iTransferHandle;	
+	RDebug::Printf("<<<CTransferServer::~CTransferServer");
+	}
+
+
+CTransferServer::CTransferServer()
+     : CPolicyServer(EPriorityHigh,KTransferServerPolicy)
+	{
+	}
+
+void CTransferServer::ConstructL()
+	{
+	iShutdownTimer = new(ELeave) CShutdownTimer;
+	iShutdownTimer->ConstructL(); 
+	
+	iTransferHandle = CTransferHandle::NewL(*this);
+	RDebug::Printf("CTransferServer::ConstructL");
+	}
+
+
+CSession2* CTransferServer::NewSessionL(const TVersion &aVersion, const RMessage2& aMessage) const
+	{
+	(void)aMessage;//Remove compiler warning
+	(void)aVersion;//Remove compiler warning
+	
+	CTransferServer* ncThis = const_cast<CTransferServer*>(this);
+	
+	CTransferSession* sess = CTransferSession::NewL(ncThis);
+		
+	return sess;
+	}
+
+
+void CTransferServer::Error(TInt aError)
+	{
+	RDebug::Printf("CTransferServer::Error");
+	Message().Complete(aError);
+	ReStart();
+	}
+
+void CTransferServer::IncrementSessionCount()
+	{
+	RDebug::Printf("CTransferServer::IncrementSessionCount");
+	
+	++iSessionCount;
+	iShutdownTimer->Cancel();
+
+	}
+
+void CTransferServer::DecrementSessionCount()
+	{
+	--iSessionCount;	
+	RDebug::Printf("CTransferServer::DecrementSessionCount");	
+	if (iSessionCount == 0)
+		{
+		iShutdownTimer->After(KShutdownDelay);
+		RDebug::Printf("CTransferServer::DecrementSessionCount1");
+		}
+	}
+
+void CTransferServer::LaunchShutdownTimerIfNoSessions()
+	{
+	if (iSessionCount == 0)
+		iShutdownTimer->After(KShutdownDelay);
+	}
+
+CTransferServer::CShutdownTimer::CShutdownTimer()
+:	CTimer(EPriorityStandard)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+
+void CTransferServer::CShutdownTimer::ConstructL()
+	{
+	RDebug::Printf("CTransferServer::CShutdownTimer::ConstructL");
+	CTimer::ConstructL();
+	}
+
+
+void CTransferServer::CShutdownTimer::RunL()
+	{
+	RDebug::Printf("CShutdownTimer::RunL");
+	CActiveScheduler::Stop();
+	}
+
+
+void CTransferServer::TransferHandleL()
+	{
+	RTranHandleSrv aServer;
+	RChunk* commChunk = NULL;
+	User::LeaveIfError(aServer.Connect());
+	User::LeaveIfError(iPort[0].GetDataTransferChunk(commChunk));
+	User::LeaveIfError(aServer.TransferHandle(iPort[0], *commChunk));	
+	aServer.Close();
+	commChunk->Close();
+	iPort[0].Close();
+	}
+
+void CTransferServer::FillEndpointsResourceAllocation(IFConfigPtr aIfCfg)
+	{
+	
+#ifdef USB_SC
+		TUsbcScInterfaceInfo* iInfoPtr = aIfCfg->iInfoPtr;
+#else
+		TUsbcInterfaceInfo* iInfoPtr = aIfCfg->iInfoPtr;
+#endif
+	
+	//	fill resource allocation info in the endpoint info with resource allocation v2
+	for (TUint8 i = 1; i <= iInfoPtr->iTotalEndpointsUsed; i++)
+		{
+		if (aIfCfg->iEpDMA[i-1])
+			{
+			iInfoPtr->iEndpointData[i-1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA;
+			}
+		else
+			{
+			iInfoPtr->iEndpointData[i-1].iFeatureWord1 &= (~KUsbcEndpointInfoFeatureWord1_DMA);
+			}
+	#ifndef USB_SC
+		if (aIfCfg->iEpDoubleBuff[i-1])
+			{
+			iInfoPtr->iEndpointData[i-1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
+			}
+		else
+			{
+			iInfoPtr->iEndpointData[i-1].iFeatureWord1 &= (~KUsbcEndpointInfoFeatureWord1_DoubleBuffering);
+			}
+	#endif
+		}	
+	}
+
+
+void CTransferServer::PopulateInterfaceResourceAllocation(IFConfigPtr aFirstIfCfg, TInt aPortNumber)
+	{
+	FillEndpointsResourceAllocation(aFirstIfCfg);
+	
+	IFConfigPtr ifCfgPtr = aFirstIfCfg->iPtrNext;
+	while (ifCfgPtr != NULL)
+		{
+		if (ifCfgPtr->iAlternateSetting)
+			{
+			FillEndpointsResourceAllocation(ifCfgPtr);
+			ifCfgPtr = ifCfgPtr->iPtrNext;
+			}
+		else
+			{
+			ifCfgPtr = NULL;
+			}
+		}
+	}
+
+void CTransferServer::SetupInterface(IFConfigPtr* aIfPtr, TInt aPortNumber)
+	{
+	test.Start (_L("Setup Interface"));
+	
+	// first of all set the default interface	
+	TUSB_PRINT2 ("Set Default Interface with %d endpoints bandwidth 0x%x",(*aIfPtr)->iInfoPtr->iTotalEndpointsUsed,(*aIfPtr)->iBandwidthIn | (*aIfPtr)->iBandwidthOut);
+#ifdef USB_SC
+	TUsbcScInterfaceInfoBuf ifc = *((*aIfPtr)->iInfoPtr);
+	TInt r = iPort[aPortNumber].SetInterface(0, ifc);
+#else
+	TUsbcInterfaceInfoBuf ifc = *((*aIfPtr)->iInfoPtr);
+	TInt r = iPort[aPortNumber].SetInterface(0, ifc, (*aIfPtr)->iBandwidthIn | (*aIfPtr)->iBandwidthOut);
+#endif
+	test_KErrNone(r);
+
+	TBuf8<KUsbDescSize_Interface> ifDescriptor;
+	r = iPort[aPortNumber].GetInterfaceDescriptor(0, ifDescriptor);
+	test_KErrNone(r);
+
+	// Check the interface descriptor
+	test(ifDescriptor[KIfcDesc_SettingOffset] == 0 && ifDescriptor[KIfcDesc_NumEndpointsOffset] == (*aIfPtr)->iInfoPtr->iTotalEndpointsUsed &&
+		ifDescriptor[KIfcDesc_ClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iClassNum &&
+		ifDescriptor[KIfcDesc_SubClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iSubClassNum &&
+		ifDescriptor[KIfcDesc_ProtocolOffset] == (*aIfPtr)->iInfoPtr->iClass.iProtocolNum);
+
+	if ((*aIfPtr)->iNumber != 0 && ifDescriptor[KIfcDesc_NumberOffset] != (*aIfPtr)->iNumber)
+		{
+		ifDescriptor[KIfcDesc_NumberOffset] = (*aIfPtr)->iNumber;
+		r = iPort[aPortNumber].SetInterfaceDescriptor(0, ifDescriptor); 
+		test_KErrNone(r);
+		}
+	else
+		{
+		(*aIfPtr)->iNumber = ifDescriptor[KIfcDesc_NumberOffset];	
+		}
+	TUint8 interfaceNumber = (*aIfPtr)->iNumber;
+	TUSB_PRINT1 ("Interface Number %d",interfaceNumber);
+	test.End();
+	}
+
+
+TInt CTransferServer::SetupLdds(TDes& aFileName)
+	{
+	TInt r;
+	User::LeaveIfError(iFs.Connect());
+
+	RDebug::Printf ("Configuration");
+	
+	RDebug::Printf ("Open configuration file");
+	// set the session path to use the ROM if no drive specified
+	r=iFs.SetSessionPath(_L("Z:\\test\\"));
+	test_KErrNone(r);
+
+	r = iConfigFile.Open(iFs, aFileName, EFileShareReadersOnly | EFileStreamText | EFileRead);
+	test_KErrNone(r);
+	RDebug::Printf("Configuration file %s Opened successfully", aFileName.PtrZ());
+
+	RDebug::Printf ("Process configuration file");
+	test(ProcessConfigFile (iConfigFile,NULL,&iLddPtr));
+	
+	iConfigFile.Close();
+	iFs.Close();
+
+	RDebug::Printf ("LDD in configuration file");
+	test_NotNull(iLddPtr);
+		
+	LDDConfigPtr lddPtr = iLddPtr;
+	TInt nextPort = 0;
+	while (lddPtr != NULL)
+		{
+		// Load logical driver (LDD)
+		// (There's no physical driver (PDD) with USB: it's a kernel extension DLL which
+		//	was already loaded at boot time.)
+		RDebug::Printf ("Loading USB LDD");
+		TUSB_PRINT1("Loading USB LDD ",lddPtr->iName.PtrZ());
+		r = User::LoadLogicalDevice(lddPtr->iName);
+		test(r == KErrNone || r == KErrAlreadyExists);
+	
+		IFConfigPtr ifPtr = lddPtr->iIFPtr;
+		
+		RDebug::Printf ("Opening Channels");
+		for (TInt portNumber = nextPort; portNumber < nextPort+lddPtr->iNumChannels; portNumber++)
+			{
+			test_Compare(lddPtr->iNumChannels,>,0);
+			test_Compare(lddPtr->iNumChannels,==,1);
+
+			// Open USB channel
+			r = iPort[portNumber].Open(0);
+			test_KErrNone(r);
+			TUSB_PRINT("Successfully opened USB port");
+
+			// Query the USB device/Setup the USB interface
+			if (portNumber == nextPort)
+				{
+				// Change some descriptors to contain suitable values
+				//SetupDescriptors(lddPtr, &iPort[portNumber]);
+				}
+				
+
+			test_NotNull(ifPtr);
+			
+			if (iSupportResourceAllocationV2)
+				{
+				PopulateInterfaceResourceAllocation(ifPtr, portNumber);
+				}
+				
+			SetupInterface(&ifPtr,portNumber);
+					
+	#ifdef USB_SC
+//			RChunk *tChunk = &gChunk;
+			test_KErrNone(iPort[portNumber].FinalizeInterface());
+	#endif
+
+			}
+	
+		iTotalChannels += lddPtr->iNumChannels;
+		nextPort += lddPtr->iNumChannels;	
+		lddPtr = lddPtr->iPtrNext;	
+		}
+		
+	TUSB_PRINT("All Interfaces and Alternate Settings successfully set up");
+	
+	iTransferHandle->StartTimer();
+
+	return KErrNone;
+	}
+
+void CTransferServer::QueryUsbClientL(LDDConfigPtr aLddPtr, RDEVCLIENT* aPort)
+	{
+	test.Start(_L("Query device and Endpoint Capabilities"));
+
+
+	TUsbDeviceCaps d_caps;
+	TInt r = aPort->DeviceCaps(d_caps);
+	test_KErrNone(r);
+
+	const TInt n = d_caps().iTotalEndpoints;
+
+	TUSB_PRINT("###  USB device capabilities:");
+	TUSB_PRINT1("Number of endpoints:				 %d", n);
+	TUSB_PRINT1("Supports Software-Connect: 		 %s",
+				d_caps().iConnect ? _S("yes") : _S("no"));
+	TUSB_PRINT1("Device is Self-Powered:			 %s",
+				d_caps().iSelfPowered ? _S("yes") : _S("no"));
+	TUSB_PRINT1("Supports Remote-Wakeup:			 %s",
+				d_caps().iRemoteWakeup ? _S("yes") : _S("no"));
+	TUSB_PRINT1("Supports High-speed:				 %s",
+				d_caps().iHighSpeed ? _S("yes") : _S("no"));
+	TUSB_PRINT1("Supports unpowered cable detection: %s\n",
+				(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ?
+				_S("yes") : _S("no"));
+	TUSB_PRINT1("Supports endpoint resource allocation v2 scheme: %s\n",
+				(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) ?
+				_S("yes") : _S("no"));					
+	TUSB_PRINT("");
+
+	iSoftwareConnect = d_caps().iConnect;					// we need to remember this
+	test_Equal(aLddPtr->iSoftConnect,iSoftwareConnect);
+
+	iSupportResourceAllocationV2 = ((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0);
+	
+	// only check capabilities if set; therefore allowing them to be disabled
+	if (aLddPtr->iSelfPower)
+		{
+		test(d_caps().iSelfPowered);	
+		}
+	
+	// only check capabilities if set; therefore allowing them to be disabled
+	if (aLddPtr->iRemoteWakeup)
+		{
+		test(d_caps().iRemoteWakeup);		
+		}
+
+	test_Equal(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower,aLddPtr->iFeatures);
+
+	// only check capability if set; therefore allowing it to be disabled
+	if (aLddPtr->iHighSpeed)
+		{
+		test(d_caps().iHighSpeed);		
+		}
+	
+	test_Equal(aLddPtr->iNumEndpoints,n);
+
+	// Endpoints
+	TUsbcEndpointData data[KUsbcMaxEndpoints];
+	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
+	r = aPort->EndpointCaps(dataptr);
+	test_KErrNone(r);
+
+	TUSB_PRINT("### USB device endpoint capabilities:");
+	for (TInt i = 0; i < n; i++)
+		{
+		const TUsbcEndpointCaps* caps = &data[i].iCaps;
+		
+		
+		TBuf<40> sizeStr(_S("unknown"));
+		if (caps->iSizes == KUsbEpNotAvailable)
+			{
+			sizeStr = _S("Not Available");	
+			}		
+		else
+			{
+			sizeStr.SetLength(0);
+			if (caps->iSizes & KUsbEpSizeCont)
+				sizeStr.Append(_S(" Continuous"),11);
+			if (caps->iSizes & KUsbEpSize8)
+				sizeStr.Append(_S(" 8"),2);
+			if (caps->iSizes & KUsbEpSize16)
+				sizeStr.Append(_S(" 16"),3);
+			if (caps->iSizes & KUsbEpSize32)
+				sizeStr.Append(_S(" 32"),3);
+			if (caps->iSizes & KUsbEpSize64)
+				sizeStr.Append(_S(" 64"),3);
+			if (caps->iSizes & KUsbEpSize128)
+				sizeStr.Append(_S(" 128"),4);
+			if (caps->iSizes & KUsbEpSize256)
+				sizeStr.Append(_S(" 256"),4);
+			if (caps->iSizes & KUsbEpSize512)
+				sizeStr.Append(_S(" 512"),4);
+			if (caps->iSizes & KUsbEpSize1023)
+				sizeStr.Append(_S(" 1023"),5);
+			if (caps->iSizes & KUsbEpSize1024)
+				sizeStr.Append(_S(" 1024"),5);
+			}
+
+		TBuf<40> typeStr(_S("unknown"));
+		if (caps->iTypesAndDir == KUsbEpNotAvailable)
+			typeStr = _S("Not Available");
+		if (caps->iTypesAndDir & (KUsbEpTypeControl | KUsbEpTypeBulk | KUsbEpTypeInterrupt | KUsbEpTypeIsochronous))
+			{
+			typeStr.SetLength(0);
+			if (caps->iTypesAndDir & KUsbEpTypeBulk)
+				typeStr.Append(_S("Control "),8);
+			if (caps->iTypesAndDir & KUsbEpTypeBulk)
+				typeStr.Append(_S("Bulk "),5);
+			if (caps->iTypesAndDir & KUsbEpTypeInterrupt)
+				typeStr.Append(_S("Interrupt "),10);
+			if (caps->iTypesAndDir & KUsbEpTypeIsochronous)
+				typeStr.Append(_S("Isochronous"),11);			
+			}
+			
+		TBuf<20> directionStr(_S("unknown"));
+		
+		if (caps->iTypesAndDir & KUsbEpDirIn)
+			directionStr = _S("In");
+		if (caps->iTypesAndDir & KUsbEpDirOut)
+			directionStr = _S("Out");
+		if (caps->iTypesAndDir & KUsbEpDirBidirect)
+			directionStr = _S("Both");
+				
+		TUSB_PRINT4("Endpoint:%d Sizes =%s Type = %s - %s",
+					i+1,sizeStr.PtrZ(), typeStr.PtrZ(), directionStr.PtrZ());
+		}
+	TUSB_PRINT("");
+
+	test.End();
+			
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/transfersession.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+* Implements a Session of a Symbian OS server for the RUsb API
+*
+*/
+
+/**
+ @file
+*/
+
+#define __E32TEST_EXTENSION__
+
+#include <e32test.h>
+#include <usb.h>
+#include "transfersession.h"
+#include "transferserver.h"
+#include "transfersrv.h"
+#include "tranhandlesrv.h"
+
+
+
+CTransferSession* CTransferSession::NewL(CTransferServer* aServer)
+	{
+	return (new (ELeave) CTransferSession(aServer));
+	}
+
+
+CTransferSession::CTransferSession(CTransferServer* aServer)
+	: iTransferServer(aServer)
+	{
+	iTransferServer->IncrementSessionCount();
+	}
+
+
+CTransferSession::~CTransferSession()
+	{
+	TUSB_PRINT("CTransferSession::~CTransferSession");
+	iTransferServer->DecrementSessionCount();
+	TUSB_PRINT("<<CTransferSession::~CTransferSession");
+	}
+
+
+void CTransferSession::ServiceL(const RMessage2& aMessage)
+	{
+	DispatchMessageL(aMessage);
+	}
+
+void CTransferSession::CreateL()
+	{
+	}
+
+void CTransferSession::DispatchMessageL(const RMessage2& aMessage)
+	{
+	TInt ret = KErrNone;
+	TName string;
+
+	switch (aMessage.Function())
+		{
+	case ESetConfigFileName:
+		ret = aMessage.Read(0, string);
+		if (ret != KErrNone)
+			break;
+		ret = iTransferServer->SetupLdds(string);
+		break;
+
+	default:
+		ret = KErrNotSupported;
+		break;
+		}
+
+	aMessage.Complete(ret);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/transfersrv.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,132 @@
+/*
+* 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 "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:
+*
+*/
+
+/**
+@file
+@internalTechnology
+*/
+
+#include <e32base.h>
+#include <e32test.h>
+#include <usb.h>
+#include "transfersrv.h"
+
+_LIT(KUsbmanImg, "z:\\system\\programs\\t_usb_transfersrv.exe");
+
+
+static TInt StartServer()
+//
+// Start the server process or thread
+//
+	{
+	const TUidType serverUid(KNullUid, KNullUid, KTransferSvrUid);
+	RDebug::Printf("StartServer1");
+
+	RProcess server;
+	TInt err = server.Create(KUsbmanImg, KNullDesC, serverUid);
+	RDebug::Printf("StartServer2 %d", err);
+	
+	if (err != KErrNone)
+		{
+		return err;
+		}
+	RDebug::Printf("StartServer3");
+
+	TRequestStatus stat;
+	server.Rendezvous(stat);
+	
+	if (stat!=KRequestPending)
+		server.Kill(0);		// abort startup
+	else
+		server.Resume();	// logon OK - start the server
+	RDebug::Printf("StartServer4");
+
+	User::WaitForRequest(stat);		// wait for start or death
+
+	// we can't use the 'exit reason' if the server panicked as this
+	// is the panic 'reason' and may be '0' which cannot be distinguished
+	// from KErrNone
+	err = (server.ExitType() == EExitPanic) ? KErrServerTerminated : stat.Int();
+	RDebug::Printf("StartServer5");
+
+	//server.Close();
+	
+	RDebug::Printf("transfer server started successfully: \n");
+
+	return err;
+	}
+
+
+
+/** Constructor */
+EXPORT_C RTransferSrv::RTransferSrv()
+    {
+    }
+
+/** Destructor */
+EXPORT_C RTransferSrv::~RTransferSrv()
+    {
+    }
+
+EXPORT_C TVersion RTransferSrv::Version() const
+    {
+    return TVersion(    KTransferSrvMajorVersionNumber,
+                        KTransferSrvMinorVersionNumber,
+                        KTransferSrvBuildVersionNumber
+                    );
+    }
+
+EXPORT_C TInt RTransferSrv::Connect()
+    {
+	TInt retry = 2;
+	
+	RDebug::Printf("Connect1");
+	FOREVER
+		{
+		TInt err = CreateSession(KTransferServerName, Version(), 10);
+		RDebug::Printf("Connect2");
+
+		if ((err != KErrNotFound) && (err != KErrServerTerminated))
+			{
+			return err;
+			}
+		RDebug::Printf("Connect3");
+
+		if (--retry == 0)
+			{
+			return err;
+			}
+		RDebug::Printf("Connect4");
+
+		err = StartServer();
+
+		if ((err != KErrNone) && (err != KErrAlreadyExists))
+			{
+			return err;
+			}
+		
+		RDebug::Printf("Connect5");
+		}
+    }
+
+EXPORT_C TInt RTransferSrv::SetConfigFileName(TDes& aString)
+	{
+	
+	RDebug::Printf("SetConfigFileName");
+	return SendReceive(ESetConfigFileName, TIpcArgs(&aString));
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/usb/t_usb_device/src/transfersrvmain.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* 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 "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:
+*
+*/
+
+#include <e32base.h>
+#include <e32test.h>
+#include "transfersrv.h"
+#include "transferserver.h"
+
+static void RunServerL();
+
+
+RTest test(_L("T_USB_TRANSFER"));
+
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+
+	TInt ret = KErrNoMemory;
+
+	if (cleanup)
+		{
+		TRAP(ret, RunServerL());
+		delete cleanup;
+		}
+
+	__UHEAP_MARKEND;
+
+	return ret;
+	}
+
+static void RunServerL()
+//
+// Perform all server initialisation, in particular creation of the
+// scheduler and server and then run the scheduler
+//
+	{
+	test.Start(_L("transfer handle"));
+
+	// naming the server thread after the server helps to debug panics
+	User::LeaveIfError(User::RenameThread(KTransferServerName));
+	//
+	// create and install the active scheduler we need
+	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+	//
+	// create the server (leave it on the cleanup stack)
+	CTransferServer* server = CTransferServer::NewLC();
+	//
+	RProcess::Rendezvous(KErrNone);
+
+	//
+	// Ready to run
+	RDebug::Printf(">>>CActiveScheduler::Start");
+	CActiveScheduler::Start();
+	RDebug::Printf("<<<CActiveScheduler::Start");
+	test.End();
+	test.Close();
+
+	//
+	// Cleanup the server and scheduler
+	RDebug::Printf("tranfermain exit 1");
+	CleanupStack::PopAndDestroy(2, scheduler);
+	RDebug::Printf("tranfermain exit 2");
+	}
+
+//
+// End of file
--- a/kerneltest/e32test/window/t_keys.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/e32test/window/t_keys.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1996-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"
@@ -14,10 +14,11 @@
 // e32test\window\t_keys.cpp
 // 
 //
-
+#define __E32TEST_EXTENSION__
 #include <e32test.h>
 #include <e32hal.h>
 #include <e32twin.h>
+#include <e32keys.h>
 #include <e32svr.h>
 
 const TBool KEY_UP=ETrue;
@@ -25,6 +26,8 @@
 const TBool EXPECT_NO_KEY_PRESS=EFalse;
 const TBool EXPECT_KEY_PRESS=ETrue;
 
+_LIT(REFKDATA, "REFKDATA");
+
 LOCAL_D RTest test(_L("T_KEYS"));
 LOCAL_D CKeyTranslator *KeyTranslator;
 LOCAL_D CCaptureKeys *CaptureKeys;
@@ -135,7 +138,73 @@
 
 	CaptureKeys->Construct();
 
+
+	test.Printf(_L("Load template EKData dll \n"));       // Test with rfkdata.dll	 
+	TInt res=KeyTranslator->ChangeKeyData(REFKDATA);
+	test_KErrNone(res);
+	
+	/* Test the AddCapture failure case */
+	TCaptureKey ck;
+	ck.iModifiers.iMask = 11;
+	ck.iModifiers.iValue = 100;
+	ck.iKeyCodePattern.iKeyCode = EKeyNull;
+	ck.iKeyCodePattern.iPattern = EAnyKey;
+	ck.iApp = 111;
+	ck.iHandle = 123;
+
+	TInt r = KErrNone;
+	TRAP(r, CaptureKeys->AddCaptureKeyL(ck));
+	test_Equal(r, KErrArgument);
+
+	/* Test the AddCapture success case */
+	ck.iModifiers.iMask = 11;
+	ck.iModifiers.iValue = 1;
+
+	TRAP(r, CaptureKeys->AddCaptureKeyL(ck));
+	test_KErrNone(r);
+
+	/* Test the SetCapture case */
+	TCaptureKey replaceck;
+	replaceck.iModifiers.iMask = 0;
+	replaceck.iModifiers.iValue = 0;
+	replaceck.iKeyCodePattern.iKeyCode = EKeyNull;
+	replaceck.iKeyCodePattern.iPattern = EAnyKey;
+	replaceck.iApp = 222;
+	replaceck.iHandle = 456;
+
+	/* Test the SetCapture failure case */
+	CaptureKeys->SetCaptureKey(replaceck.iHandle, ck);
+
+	/* Test the SetCapture success case */
+	CaptureKeys->SetCaptureKey(ck.iHandle, replaceck, 0x80);
+
+	/* Test the Cancelcapture failure case */
+	CaptureKeys->CancelCaptureKey(ck.iHandle);
+
+	/* Let us add one more with a different set of mask to test ProcessCaptureKeys */
+	ck.iModifiers.iMask = 11;
+	ck.iModifiers.iValue = 1;
+	ck.iKeyCodePattern.iKeyCode = EKeyNull;
+	ck.iKeyCodePattern.iPattern = EMatchLeftOrRight+1;
+	ck.iApp = 111;
+	ck.iHandle = 123;
+
+	TRAP(r, CaptureKeys->AddCaptureKeyL(ck));
+	test_KErrNone(r);
+
+	/* Let us add one more with a different set of mask to test ProcessCaptureKeys */
+	ck.iModifiers.iMask = 11;
+	ck.iModifiers.iValue = 1;
+	ck.iKeyCodePattern.iKeyCode = EKeyNull;
+	ck.iKeyCodePattern.iPattern = EAnyKey;
+	ck.iApp = 333;
+	ck.iHandle = 789;
+
+	TRAP(r, CaptureKeys->AddCaptureKeyL(ck));
+	test_KErrNone(r);
+
     TUint scancode=EStdKeyLeftArrow;
+
 //
 // Test that the special keys pass through and anything after
 // or before raises an error
@@ -259,6 +328,29 @@
 	testAccents('6','E',0xea);
 
 */
+
+	/* Test the CancelAllCaptureKeys failure case */
+	CaptureKeys->CancelAllCaptureKeys(ck.iApp);
+
+	/* Test the CancelCaptureKey success case */
+	CaptureKeys->CancelCaptureKey(replaceck.iHandle);
+
+	/* Now add a CaptureKey to test CancelAllCaptureKeys success case */
+	ck.iModifiers.iMask = 11;
+	ck.iModifiers.iValue = 1;
+	ck.iKeyCodePattern.iKeyCode = EKeyNull;
+	ck.iKeyCodePattern.iPattern = EAnyKey;
+	ck.iApp = 111;
+	ck.iHandle = 123;
+
+	TRAP(r, CaptureKeys->AddCaptureKeyL(ck));
+	test_KErrNone(r);
+
+	/* Test CancelAllCaptureKeys success case */
+	CaptureKeys->CancelAllCaptureKeys(ck.iApp);
+
+	delete CaptureKeys;
+
 	test.End();
 	return(KErrNone);
     }
--- a/kerneltest/f32test/filesystem/fat/t_mount.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/filesystem/fat/t_mount.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -629,12 +629,12 @@
     bDriveFinalised = DoCheckVolumeFinalised(gDriveNum);
     test(!bDriveFinalised); //-- the volume has become "unfinalised"
 
-    //-- 2.1 open a file, try to finalise; Shall dail with KErrInUse
+    //-- 2.1 open a file, try to finalise; This should be OK
     nRes = file.Replace(TheFs, KFileName, EFileWrite | EFileRead);
     test_KErrNone(nRes);
 
     nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
-    test(nRes==KErrInUse); //-- can't finalise drives with opened objects
+    test_KErrNone(nRes);
 
     file.Close();
 
@@ -1274,7 +1274,6 @@
     PrintDrvInfo(TheFs, gDriveNum);
     InitGlobals();
 
-
     TestNotifyDiskSpace();
 
     //-------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/f32test/fileutils/inc/tf32testtimer.h	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,154 @@
+// 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:
+// @file
+// 
+// 
+//
+
+
+class TF32TestTimer
+{
+public:
+    TF32TestTimer();
+
+    void Start();
+    void Stop();
+
+    TInt64 TimeTaken() const;
+    TTimeIntervalMicroSeconds Time() const;
+    TTimeIntervalMicroSeconds32 Time32() const;
+    int TimeInMicroSeconds() const;
+    int TimeInMilliSeconds() const;
+
+    static TInt TimeInMilliSeconds(TTimeIntervalMicroSeconds aTime);
+    static TInt TimeInMilliSeconds(TTimeIntervalMicroSeconds32 aTime);
+
+protected:
+    TInt64 Diff(TUint32 aTicks) const;
+
+protected:
+    TInt iFastCounterFreq;
+    TUint32 startTicks;
+    TUint32 endTicks;
+};
+
+
+class TF32TestTimer2: public TF32TestTimer
+{
+public:
+    void Stop2();
+
+    TInt64 TimeTaken2() const;
+    TTimeIntervalMicroSeconds32 Time2() const;
+    int Time2InMicroSeconds() const;
+
+private:
+    TUint32 endTicks2;
+};
+
+inline TF32TestTimer::TF32TestTimer()
+{   
+    TInt r = HAL::Get(HAL::EFastCounterFrequency, iFastCounterFreq);
+    test_KErrNone(r);
+}
+
+inline void TF32TestTimer::Start()
+{
+    startTicks = User::FastCounter();
+}
+
+inline void TF32TestTimer::Stop()
+{
+    endTicks = User::FastCounter();;
+}
+
+inline void TF32TestTimer2::Stop2()
+{
+    endTicks2 = User::FastCounter();;
+}
+
+inline TInt64 TF32TestTimer::Diff(TUint32 aTicks) const
+{
+    if (aTicks == startTicks)
+        {
+        test.Printf(_L("Warning: tick not advanced"));
+        }
+
+    TInt64 diff;
+    if (aTicks > startTicks)
+        {
+        diff = static_cast<TInt64>(aTicks) - static_cast<TInt64>(startTicks);
+        }
+    else
+        {
+        // handle counter rollover
+        diff = ((static_cast<TInt64>(KMaxTUint32) + 1 + aTicks) - static_cast<TInt64>(startTicks));
+        }
+    //RDebug::Printf("%x %x %ld", aTicks, startTicks, diff);
+    diff *= TInt64(1000000);
+    diff /= TInt64(iFastCounterFreq);
+    
+    return diff;
+}
+
+inline TInt64 TF32TestTimer::TimeTaken() const
+{
+    return Diff(endTicks);
+}
+
+inline TInt64 TF32TestTimer2::TimeTaken2() const
+{
+    return Diff(endTicks2);
+}
+
+inline int TF32TestTimer::TimeInMicroSeconds() const
+{
+    return static_cast <int>(TimeTaken());
+}
+
+inline int TF32TestTimer2::Time2InMicroSeconds() const
+{
+    return static_cast <int>(TimeTaken2());
+}
+
+inline TTimeIntervalMicroSeconds TF32TestTimer::Time() const
+{
+    return TimeTaken();
+}
+
+inline TTimeIntervalMicroSeconds32 TF32TestTimer2::Time2() const
+{    
+    return static_cast <int>(TimeTaken2());
+}
+
+inline TTimeIntervalMicroSeconds32 TF32TestTimer::Time32() const
+{
+    return static_cast <int>(TimeTaken());
+}
+
+inline int TF32TestTimer::TimeInMilliSeconds() const
+{
+    return static_cast <int>(TimeTaken() / 1000);
+}
+
+TInt TF32TestTimer::TimeInMilliSeconds(TTimeIntervalMicroSeconds aTime)
+{
+    return static_cast <int>(aTime.Int64()/static_cast<TInt64>(1000));
+}
+
+TInt TF32TestTimer::TimeInMilliSeconds(TTimeIntervalMicroSeconds32 aTime)
+{
+    return static_cast <int>(aTime.Int()/1000);
+}
+
--- a/kerneltest/f32test/group/t_wcache.mmp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/group/t_wcache.mmp	Wed Aug 18 11:08:29 2010 +0300
@@ -23,6 +23,7 @@
 
 LIBRARY		euser.lib efsrv.lib hal.lib 
 OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE		../fileutils/inc
 EPOCSTACKSIZE	0x10000
 
 CAPABILITY		TCB DISKADMIN ALLFILES
--- a/kerneltest/f32test/server/t_bigfile.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/server/t_bigfile.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -115,6 +115,7 @@
 
 MFileManObserver::TControl CFileManObserver::NotifyFileManStarted()
 	{
+    (void)MFileManObserver::NotifyFileManStarted();
 	TInt lastError = iFileMan->GetLastError();
 	TFileName fileName = iFileMan->CurrentEntry().iName;
 	test.Printf(_L("NotifyFileManStarted(): Error %d File %S\n"),lastError, &fileName);
@@ -123,6 +124,7 @@
 
 MFileManObserver::TControl CFileManObserver::NotifyFileManOperation()
 	{
+    (void)MFileManObserver::NotifyFileManOperation();
 	TInt lastError = iFileMan->GetLastError();
 	TFileName fileName = iFileMan->CurrentEntry().iName;
 	test.Printf(_L("NotifyFileManOperation(): Error %d File %S\n"),lastError, &fileName);
--- a/kerneltest/f32test/server/t_dspace.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/server/t_dspace.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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_fman.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/server/t_fman.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -53,6 +53,7 @@
 // Called back after each FMan tick
 //
 	{
+    (void) MFileManObserver::NotifyFileManEnded();
 	TInt lastError=iFileMan->GetLastError();
 	if (lastError!=KErrNone && lastError!=KErrBadName)
 		{
@@ -3108,7 +3109,6 @@
 	CFileMan* iFileMan;
 	};
 
-
 CFileManObserverOverWrite::CFileManObserverOverWrite(CFileMan* aFileMan)
 //
 // Constructor
@@ -3137,6 +3137,59 @@
 	return(MFileManObserver::EContinue);
 	}
 
+class CFileManObserverBytesCopied : public CBase, public MFileManObserver
+    {
+public:
+    CFileManObserverBytesCopied(CFileMan* aFileMan);
+    TControl NotifyFileManEnded();
+    TControl NotifyFileManOperation();
+    TInt iBytesToBeCopied;
+private:
+    CFileMan* iFileMan;
+    TInt iBytesCopied;
+    };
+
+CFileManObserverBytesCopied::CFileManObserverBytesCopied(CFileMan* aFileMan)
+//
+// Constructor
+//
+    {
+    __DECLARE_NAME(_S("CFileManObserverBytesCopied"));
+    iFileMan=aFileMan;
+    iBytesCopied=0;
+    }
+
+MFileManObserver::TControl CFileManObserverBytesCopied::NotifyFileManOperation()
+//
+// Observer for testBytesCopied tests
+//
+    {
+    TFileName target;
+    iFileMan->GetCurrentTarget(target);
+    TInt match = target.MatchF(_L("?:\\bytesTransferred"));
+    if(match != 0)
+        {
+        RDebug::Print(_L("CFileManObserverBytesCopied::NotifyFileManOperation - target %s, match %d"),target.PtrZ(),match);
+        return MFileManObserver::EAbort;
+        }
+    
+    iBytesCopied += iFileMan->BytesTransferredByCopyStep();
+    return(MFileManObserver::EContinue);
+    }
+
+MFileManObserver::TControl CFileManObserverBytesCopied::NotifyFileManEnded()
+//
+// Observer for testBytesCopied  tests
+//
+    {
+    if(iBytesCopied!=iBytesToBeCopied)
+        return (MFileManObserver::EAbort);
+    
+    return(MFileManObserver::EContinue);
+    }
+
+
+
 LOCAL_C void TestOverWrite()
 //
 // Test overwrite for copy and rename
@@ -4306,6 +4359,79 @@
 	RmDir(_L("C:\\TestDEF130678\\"));	
 	}
 
+void TestBytesTransferredByCopyStep()
+    {
+    //
+    // Test BytesCopied
+    //
+    test.Next(_L("TestBytesTransferredByCopyStep"));
+    (void)gFileMan->Delete(_L("\\bytesTransferred"));
+    
+    RFile tempFile;
+    TFileName tempname;
+    TInt r = tempFile.Temp(TheFs,_L("\\"),tempname,EFileWrite);
+    test_KErrNone(r);
+    r = tempFile.SetSize(50);
+    test_KErrNone(r);
+    tempFile.Flush();
+    tempFile.Close();
+
+    CFileManObserverBytesCopied* fManObserver=new(ELeave) CFileManObserverBytesCopied(gFileMan);
+    CleanupStack::PushL(fManObserver);
+    gFileMan->SetObserver(fManObserver);
+    fManObserver->iBytesToBeCopied=50;
+    
+    if (!gAsynch)
+        {
+        r=gFileMan->Copy(tempname,_L("\\bytesTransferred"),CFileMan::EOverWrite);
+        test_KErrNone(r);
+        }
+    else
+        {
+        TInt r=gFileMan->Copy(tempname,_L("\\bytesTransferred"),CFileMan::EOverWrite,gStat);
+        test_KErrNone(r);
+        WaitForSuccess();
+        }
+    
+    (void)gFileMan->Delete(_L("\\bytesTransferred"));
+    (void)TheFs.Delete(tempname);
+    CleanupStack::PopAndDestroy();
+    }
+
+void TestGetMoreErrorInfo()
+    {
+    //
+     // Test GetMoreErrorInfo
+     //
+     test.Next(_L("TestGetMoreErrorInfo"));
+
+     CFileManObserver* fManObserver=new(ELeave) CFileManObserver(gFileMan);
+     CleanupStack::PushL(fManObserver);
+     gFileMan->SetObserver(fManObserver);
+     
+     if (!gAsynch)
+         {
+         TInt r=gFileMan->Copy(_L("\\SRC"),_L("\\TRG"),0);
+         if(r!=KErrNone) //correct behaviour
+             {
+             TFileManError error = gFileMan->GetMoreInfoAboutError();
+             test_Equal(error,(TFileManError)ENoFilesProcessed);
+             }
+         else { test_Equal(r,!KErrNone); }
+         }
+     else
+         {
+         TInt r=gFileMan->Copy(_L("\\SRC"),_L("\\TRG"),0,gStat);
+         if(r!=KErrNone) //correct behaviour
+             {
+             TFileManError error = gFileMan->GetMoreInfoAboutError();
+             test_Equal(error,(TFileManError)ENoFilesProcessed);
+             }
+         else { test_Equal(r,!KErrNone); }
+         }
+    CleanupStack::PopAndDestroy();
+    }
+
 GLDEF_C void CallTestsL()
 //
 // Do tests
@@ -4401,6 +4527,8 @@
 	TestCopyAllCancel();
 	
 	TestDEF130678(); // Test CFileMan::Move does not leak any memory
+	TestBytesTransferredByCopyStep();
+	TestGetMoreErrorInfo();
 #ifndef __WINS__
 	RThread t;
 	TThreadStackInfo stack;
@@ -4408,6 +4536,7 @@
 	TestStackUsage(0, stack);
 #endif
 
+	
 	Cleanup();
 	DeleteTestDirectory();
 	test_KErrNone(TheFs.RmDir(_L("\\F32-TST\\")));
--- a/kerneltest/f32test/server/t_fsched.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/server/t_fsched.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -29,9 +29,11 @@
 #include "t_server.h"
 #include <e32twin.h>
 #include <e32cmn.h>
+#include <hal.h>
+#include "tf32testtimer.h"
 #include "f32_test_utils.h"
+using namespace F32_Test_Utils;
 
-using namespace F32_Test_Utils;
 
 //----------------------------------------------------------------------------------------------
 //! @SYMTestCaseID      PBASE-T_FSCHED-0191
@@ -117,7 +119,6 @@
 HBufC8* gBufSec = NULL;
 TPtr8 gBufWritePtr(NULL, 0);	
 
-const TInt KuStomS = 1000;
 const TInt KOneK = 1024;
 const TInt KOneMeg = KOneK * 1024;
 const TInt KBigBlockSize = KOneMeg ; 
@@ -134,8 +135,8 @@
 TTimeIntervalMicroSeconds32 gTimeTakenBigBlock(0);
 TBuf16<45> gSmallFile, gBigFile;
 TInt gNextFile=0;
-TTime gTime1;
-TTime gTime2;
+
+TF32TestTimer gTestTimer;
 
 RSemaphore gSync;
 
@@ -154,6 +155,9 @@
 	ENoThreads	
 	};
 
+
+
+
 /** Generates a file name of the form FFFFF*<aPos>.TXT (aLong.3)
 
 	@param aBuffer The filename will be returned here
@@ -613,32 +617,30 @@
 	}
 
 
-
 /** Measure the time taken for a big block to be written synchronously
 */
 void TimeTakenToWriteBigBlock() 
 {
-	TTime startTime;
-	TTime endTime;
 	RFile fileWrite;
 	
 	TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO);
 	TESTERROR(r);
 
 	// Calculate how long it takes to write a big block to be able to issue at the right time the concurrent writes
-	startTime.HomeTime();
+    TF32TestTimer timer;
+	timer.Start();
 	
 	r = fileWrite.Write(gBufWritePtr, KBigBlockSize); 
-	
-	endTime.HomeTime();
-	
+
+    timer.Stop();
+
 	fileWrite.Close();
 
 	TESTERROR(r);
 	
-	gTimeTakenBigBlock = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()/3);
-
-	test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), gTimeTakenBigBlock.Int() / KuStomS);
+	gTimeTakenBigBlock = timer.TimeInMicroSeconds()/3;
+        
+	test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigBlock));
 }
 	
 
@@ -646,51 +648,44 @@
 */
 void TimeTakenToWriteBigFile(TInt aPos) 
 {
-	TTime startTime;
-	TTime endTime;
-	
 	test((aPos >= 0) && (aPos <= 1));
-	startTime.HomeTime();
-	
+    TF32TestTimer timer;
+    timer.Start();
+
 	WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads);
 	
-	endTime.HomeTime();
+	timer.Stop();
 
-	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
+	gTimeTakenBigFile = timer.Time32();
+		
+	test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile));
 	
-	
-	test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), gTimeTakenBigFile.Int() / KuStomS);
-	
-	gTotalTimeSync[aPos] = Max((gTimeTakenBigFile.Int()/KuStomS), gTotalTimeSync[aPos]) ;
+	gTotalTimeSync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeSync[aPos]) ;
 }
 
 /** Measure the time taken for this file to be written asynchronously
 */
 void TimeTakenToWriteBigFileAsync(TInt aPos) 
 {
-	TTime startTime;
-	TTime endTime;
-	TTime endTime2;
 	TRequestStatus status[KWaitRequestsTableSize];
 	RFile bigFile;
 	
 	test((aPos >= 0) && (aPos <= 1));
-	
-	startTime.HomeTime();
+
+    TF32TestTimer2 timer;
+	timer.Start();
 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); 
-	endTime.HomeTime();
-
+	timer.Stop();
 	
 	WaitForAll(status, gBigFileSize, KBigBlockSize);	
+	timer.Stop2();
 	
-	endTime2.HomeTime();
-	
-	gTimeTakenBigFile=I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
+	gTimeTakenBigFile = timer.Time32();        
 	bigFile.Close();
-	test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), gTimeTakenBigFile.Int() / KuStomS);
-	gTimeTakenBigFile=I64LOW(endTime2.MicroSecondsFrom(startTime).Int64());
-	test.Printf(_L("to actually write it: %d ms\n"),gTimeTakenBigFile.Int() / KuStomS);
-	gTotalTimeAsync[aPos] = Max((gTimeTakenBigFile.Int() / KuStomS), gTotalTimeAsync[aPos]) ; 
+	test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), timer.TimeInMilliSeconds());
+	gTimeTakenBigFile = timer.Time2();
+	test.Printf(_L("to actually write it: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile));
+	gTotalTimeAsync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeAsync[aPos]) ; 
 }
 
 /**  Delete content of directory
@@ -728,7 +723,7 @@
 	TESTERROR(r);
 	
 	ReadFile(fs,gSmallFile,KBlockSize, EThreadWait);
-	gTime2.HomeTime();
+	gTestTimer.Start();
 	
 	client.Signal();
 	
@@ -753,7 +748,7 @@
 	TESTERROR(r);
 	
 	ReadFile(fs,gBigFile,KBlockSize, EThreadWait);
-	gTime2.HomeTime();
+	gTestTimer.Stop();
 	
 	client.Signal();
 		
@@ -778,7 +773,7 @@
 	TESTERROR(r);
 	
 	WriteFile(fs,gSmallFile,gSmallFileSize, KBlockSize, EThreadWait);
-	gTime2.HomeTime();
+	gTestTimer.Start();
 	
 	client.Signal();
 	
@@ -803,7 +798,7 @@
 	TESTERROR(r);
 	
 	WriteFile(fs, gBigFile, gBigFileSize, KBigBlockSize, EThreadSignal); 
-	gTime1.HomeTime();
+	gTestTimer.Stop();
 	
 	client.Signal();
 	
@@ -828,7 +823,7 @@
 	TESTERROR(r);
 	
 	WriteFile(fs, gSmallFile, gBigFileSize, KBigBlockSize, EThreadWait); 
-	gTime2.HomeTime();
+	gTestTimer.Stop();
 	
 	client.Signal();
 	
@@ -900,19 +895,13 @@
 
 */
 void TestReadingWhileWriting() 
-{
-	TInt r = 0;
-	TTime time1;
-	TTime time2;
-
-	time1.HomeTime();
-	
+{	
 	// Write the small file and take the appropriate measures
 	WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads);
 
 	// Sync test
 	TBuf<20> buf=_L("Big Write");
-	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
+	TInt r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
 	TEST(r == KErrNone);
 
 	buf = _L("Small Read");
@@ -928,15 +917,13 @@
 	gBig.Close();
 	gSmall.Close();
 	
-	
-	TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2);
-	test.Printf(_L("\nSync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
-	TReal time=I64LOW(timeTaken.Int64() / KuStomS); 
+	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
+	test.Printf(_L("\nSync read done %d ms before the write ended\n"), TF32TestTimer::TimeInMilliSeconds(timeTaken));
 	#if !defined(__WINS__)
-		// If this condition fails, it means that writing the sync file while fairscheduling a small sync read takes too long
-		test.Printf(_L("time: %f\n"), time);
-		// test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) );  
-		test(time > 0);
+		// If this condition fails, it means that writing the sync file while 
+        // fairscheduling a small sync read takes too long. Reading small file
+        // should complete first.
+		test(timeTaken > 0);
 	#endif 
 	
 	// Async test 
@@ -948,27 +935,26 @@
 	ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 );
 
 	WaitForAll(status2,KBlockSize , KBlockSize );
-	time1.HomeTime(); 
+
+    TF32TestTimer timer;
+	timer.Start();
 
 	WaitForAll(status,gBigFileSize, KBigBlockSize);
 
-	time2.HomeTime();
+	timer.Stop();
 	bigFile.Close();
 	smallFile.Close();
 	
-	timeTaken = time2.MicroSecondsFrom(time1);
+	timeTaken = timer.Time();
 	
-	test.Printf(_L("\nAsync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
-	time = I64LOW(timeTaken.Int64() / KuStomS); 
+	test.Printf(_L("\nAsync read done %d ms before the write ended\n"), timer.TimeInMilliSeconds());
 
 	#if !defined(__WINS__)
 	if (!Is_HVFS(TheFs, gDrive))
 		{
 		// If this condition fails, it means that writing the async file while fairscheduling a small async read takes too long
-		test.Printf(_L("time: %f\n"), time);
 		test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] );
-		// test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) );
-		test(time > 0);
+		test(timeTaken > 0);
 		}
 	#endif
 }
@@ -979,8 +965,6 @@
 void TestWritingWhileWriting() 
 {
 	TInt r = 0;
-	TTime time1;
-	TTime time2;
 
 	// Sync test
 	TBuf<20> buf = _L("Big Write II");
@@ -1000,14 +984,12 @@
 	gBig.Close();
 	gSmall.Close();
 	
-	TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2);
-	test.Printf(_L("\nSync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
-	TReal time=I64LOW(timeTaken.Int64() / KuStomS); 
+	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
+	test.Printf(_L("\nSync write done %d ms before the big write ended\n"), gTestTimer.TimeInMilliSeconds());
 	#if !defined(__WINS__)
-		// If this condition fails, it means that writing the sync file while fairscheduling a small sync write takes too long
-		test.Printf(_L("time: %f\n"), time);
-		// test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); 
-		test(time > 0);
+		// If this condition fails, it means that writing the sync file while 
+        // fairscheduling a small sync write takes too long		
+		test(timeTaken > 0);
 	#endif 
 
 	// Async test 
@@ -1018,21 +1000,19 @@
 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
 	WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2);
 	WaitForAll(status2,gSmallFileSize, KBlockSize);
-	time1.HomeTime();
+    TF32TestTimer timer;
+	timer.Start();
 	WaitForAll(status, gBigFileSize, KBigBlockSize);
-	time2.HomeTime();
+	timer.Stop();
 	
-	timeTaken = time2.MicroSecondsFrom(time1);
-	test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
-	time=I64LOW(timeTaken.Int64() / KuStomS);
+	timeTaken = timer.Time();
+	test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),timer.TimeInMilliSeconds());
 	#if !defined(__WINS__)
 	if (!Is_HVFS(TheFs, gDrive))
 		{
 		// If this condition fails, it means that writing the async file while fairscheduling a small async write takes too long
-		test.Printf(_L("time: %f\n"), time);
 		test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] );
-		// test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) );
-		test(time > 0);
+		test(timeTaken > 0);
 		}
 	#endif
 	bigFile.Close();
@@ -1045,8 +1025,6 @@
 void TestTwoBigOnes()
 {
 	TInt r = 0;
-	TTime time1;
-	TTime time2;
 
 	// Sync test
 	TBuf<20> buf = _L("Big Write IIII");
@@ -1066,8 +1044,8 @@
 	gBig.Close();
 	gSmall.Close();
 	
-	TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1);
-	test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS));
+	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
+	test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken));
 
 	// Async test 
 	TRequestStatus status[KWaitRequestsTableSize];
@@ -1077,12 +1055,13 @@
 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
 	WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2);
 	WaitForAll(status, gBigFileSize, KBigBlockSize);
-	time1.HomeTime();
+    TF32TestTimer timer;
+	timer.Start();
 	WaitForAll(status2, gBigFileSize, KBigBlockSize);
-	time2.HomeTime();
+	timer.Stop();
 	
-	timeTaken = time2.MicroSecondsFrom(time1);
-	test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS));
+	timeTaken = timer.Time();
+	test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken));
 	bigFile.Close();
 	bigFile2.Close();	
 }
@@ -1093,9 +1072,9 @@
 void TestReadingWhileWritingSameFile() 
 {
 	TInt r = 0;
-	TTime time1;
+	TF32TestTimer timer;
 	
-	time1.HomeTime();
+	timer.Start();
 	
 	// Sync test
 	TBuf<20> buf = _L("Big Write IV");
@@ -1115,8 +1094,8 @@
 	CLOSE_AND_WAIT(gBig);
 	CLOSE_AND_WAIT(gSmall);
 	
-	TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1);
-	test.Printf(_L("\nSync write finished %d ms before the read ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
+	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
+	test.Printf(_L("\nSync write finished %d ms before the read ended\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken));
 	
 }
 
--- a/kerneltest/f32test/server/t_misc.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/server/t_misc.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -20,6 +20,10 @@
 #include <e32test.h>
 #include "t_server.h"
 
+#include "f32_test_utils.h"
+using namespace F32_Test_Utils;
+
+
 // If there is an NFE media driver present, then because of the way EDeleteNotify requests work,
 // the data retrieved from a deleted file will not be a buffer full of zero's, but instead a buffer
 // full of decrypted zero's
@@ -30,11 +34,13 @@
     #pragma setlocale("english")
 #endif
 
-GLDEF_D RTest test(_L("T_MISC"));
+RTest test(_L("T_MISC"));
 
+
+TInt gDriveNum = -1;
 const TUint KBufLength = 0x100;
 
-LOCAL_C void Test1()
+static void Test1()
 //
 // Open, write to and read from a file
 //
@@ -59,7 +65,7 @@
 	file.Close();
 	}
 
-LOCAL_C void Test2()
+static void Test2()
 //
 // Open and read from a file
 //
@@ -80,7 +86,7 @@
 	test_KErrNone(r);
 	}
 
-LOCAL_C void Test3()
+static void Test3()
 //
 // Create nested directories
 //
@@ -109,7 +115,7 @@
 	test_Value(r, r == KErrNone || r==KErrAlreadyExists);
 	}
 
-LOCAL_C void Test4()
+static void Test4()
 //
 // Test returned error values
 //
@@ -172,7 +178,7 @@
 	dir.Close();
 	}
 
-LOCAL_C void Test5()
+static void Test5()
 //
 // Read files directly from the rom
 //
@@ -270,7 +276,7 @@
 		}
 	}
 
-LOCAL_C void Test6()
+static void Test6()
 //
 // Test rom return values
 //
@@ -289,7 +295,7 @@
 	test_Value(r, r == KErrAccessDenied);
 	}
 
-LOCAL_C void Test7()
+static void Test7()
 //
 // Test cache
 //
@@ -327,7 +333,7 @@
 	test(entry.iType==uid2);
 	}
 
-LOCAL_C void Test8()
+static void Test8()
 //
 // Test IsValidName
 //
@@ -536,7 +542,7 @@
         }
 	}
 
-LOCAL_C void Test9()
+static void Test9()
 //
 // Test IsFileInRom
 //
@@ -563,7 +569,7 @@
 		}
 	}
 
-LOCAL_C void Test10()
+static void Test10()
 //
 // Test drive names
 //
@@ -660,7 +666,7 @@
 
 	}
 
-LOCAL_C void Test11()
+static void Test11()
 //
 // Miscellaneous tests
 //
@@ -677,7 +683,7 @@
 	test_Value(r, r == KErrBadName);
 	}
 
-LOCAL_C void Test12()
+static void Test12()
 //
 // Test SetNotifyUser and GetNotifyUser
 //
@@ -696,7 +702,7 @@
 	test(notifyState);
 	}
 
-LOCAL_C void Test13()
+static void Test13()
 //
 // Test return values from RFs::Volume on cf-cards
 //
@@ -728,84 +734,37 @@
 
 void    DoTest14(TInt aDrvNum);
 TInt    CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize);
-TInt    CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize);
 TBool   CheckFileContents(RFs& aFs, const TDesC& aFileName);
 #ifndef __NFE_MEDIA_DRIVER_PRESENT__
 TBool   CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr=0);
 #endif
 
 /**
-Testing unallocated data initialization vulnerability in RFile
-This test is performed on RAM drives and non-removable media that supports DeleteNotify (KMediaAttDeleteNotify flag)
-e.g. XSR NAND
+    Testing unallocated data initialization vulnerability in RFile
+    This test is performed on RAM drives and non-removable media that supports DeleteNotify (KMediaAttDeleteNotify flag)
+    e.g. XSR NAND
 */
-LOCAL_C void Test14()
+static void Test14()
 {
-	TInt nRes;
 
 	test.Next(_L("Testing unallocated data initialization vulnerability in RFile"));
 
-	TDriveList driveList;
-	TDriveInfo driveInfo;
-
-	//-- 1. get drives list
-	nRes=TheFs.DriveList(driveList);
-    test_KErrNone(nRes);
-
-	//-- 2. walk through all drives, performing the test only on suitable ones
-	for (TInt drvNum=0; drvNum<KMaxDrives; ++drvNum)
-    {
-	    if(!driveList[drvNum])
-	        continue;   //-- skip unexisting drive
-
-	    //-- get drive info
-	    test(TheFs.Drive(driveInfo, drvNum) == KErrNone);
-
-	    //-- select a suitable drive for the testing. It shall be RAM drive, of FLASH but not removable
-	    //-- and not read only, if it is FLASH, it shall support "Delete Notify" facility
-        switch(driveInfo.iType)
-        {
-        //-- RAM drive, OK
-        case EMediaRam:
-        break;
-
-        //-- FLASH drive, OK
-        case EMediaFlash:
-        case EMediaNANDFlash:
-            if(driveInfo.iMediaAtt & KMediaAttDeleteNotify)
-                break; //-- this type of media shall support DeleteNotify flag, otherwise this test is inconsistent
-            else continue;
+    TDriveInfo driveInfo;
+	
+    //-- get drive info
+	test(TheFs.Drive(driveInfo, gDriveNum) == KErrNone);
 
-        //break; //unreacable
-
-        default:
-            continue;
-        }//switch(driveInfo.iType)
-
-		if (driveInfo.iDriveAtt	& KDriveAttSubsted)
-			{
-			// skip subst drives.
-			continue;
-			}
-
-        TBool readOnly = driveInfo.iMediaAtt & KMediaAttWriteProtected;
-        if(readOnly)
-            continue; //-- nothing to do, can't create any file etc.
-
-        //-- skip test on the emulator's C: drive, doesn't make any sense because
-        //-- in this case we deal with WIN32 API and filesystem.
-        #ifdef __WINS__
-        if(drvNum == 2)
-        {
-             test.Printf(_L("Skipping test on emulator's C: drive\n"));
-             continue;
-        }
-        #endif
-
-        DoTest14(drvNum);
-
-    }// for (TInt drvNum=0; ...
-
+    const TBool bMediaSuitable = (driveInfo.iType == EMediaRam)     || //-- RAM drives should be tested
+                                 (driveInfo.iType == EMediaFlash)   || //-- NOR FLASH drives should be tested
+                                 (driveInfo.iType == EMediaNANDFlash && driveInfo.iMediaAtt & KMediaAttDeleteNotify); //-- NAND media with DeleteNotify support
+    
+    if(!bMediaSuitable)
+    {
+        test.Printf(_L("This test can't be performed on this type of the media! Skipping.\n"));
+        return;
+    }
+    
+    DoTest14(gDriveNum);
 }
 
 //--------------------------------------------------------
@@ -877,7 +836,7 @@
 
 }
 
-LOCAL_C void Test15()
+static void Test15()
 //
 // Test IsValidName
 //
@@ -1210,32 +1169,6 @@
 
 //--------------------------------------------------------
 
-/**
-    Create an empty file of specified size.
-    @param  aFs		    ref. to the FS
-    @param  aFileName   name of the file
-    @param  aFileSize   size of the file to be created
-    @return    KErrNone on success, system-wide error code otherwise
-*/
-TInt CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize)
-{
-    RFile   file;
-	TInt    nRes;
-
-	nRes = file.Create(aFs, aFileName, EFileRead|EFileWrite);
-    if(nRes != KErrNone)
-        return nRes;
-
-	nRes = file.SetSize(aFileSize);
-    if(nRes != KErrNone)
-        return nRes;
-
-    file.Close();
-
-    return KErrNone;
-}
-
-//--------------------------------------------------------
 
 /**
     Create a file of specified size filled with some data pattern.
@@ -1364,11 +1297,11 @@
 
     //-- check if the buffer filled with allowable data (RAM page initialisation data or something similar)
     //-- but not something meaningful.
-    //-- allowable bytes: 0x00, 0x03, 0xff, 0xcc
+    //-- Actually, the buffer should be filled with uniformed bytes (most probably, 0x00)
     for(TInt i=0; i<aBuffer.Size(); ++i)
     {
         TUint8 byte = aBuffer[i];
-        if(byte != 0x00 && byte != 0x03 && byte != 0xff && byte != 0xcc )
+        if(byte != aBuffer[0])
         {
             bRes = EFalse;
             break;
@@ -1395,13 +1328,368 @@
     return bRes;
 }
 
+//--------------------------------------------------------
+/**
+    Check if the drive aDriveNo is finalised or not.
+    The "CleanShutDown" is obtained by QueryVolumeInfoExt API which is FS-agnostic.
 
-GLDEF_C void CallTestsL()
-//
-// Call tests that may leave
-//
+    @param  aDriveNo drive number to query.
+    @return ETrue if the drive if finalised
+*/
+static TBool IsVolumeFinalised(TInt aDriveNo)
+{
+    TInt nRes;
+    TPckgBuf<TBool> boolPckg;
+
+    //-- 1. get "Finalised" state by using the API
+    nRes = TheFs.QueryVolumeInfoExt(aDriveNo, EIsDriveFinalised, boolPckg);
+    test_KErrNone(nRes);
+    
+    return boolPckg();
+}
+
+
+//--------------------------------------------------------
+/**
+    This is a file system - agnostic test that verifies RFs::FinaliseDrive() API
+    There are also file system - specific tests that check similar functionallity (see t_mount for example)
+
+*/
+void TestDriveFinalisation()
+{
+    test.Next(_L("TestDriveFinalisation(). Testing RFs::FinaliseDrives() API\n"));    
+    
+
+    if((!Is_Fat(TheFs, gDriveNum) && !Is_ExFat(TheFs, gDriveNum)) || Is_Fat12(TheFs, gDriveNum) )
+    {
+        test.Printf(_L("This test can't be performed on current file system, skipping.\n"));
+        return;
+    }
+
+    TVolumeInfo v;
+    TInt  nRes;
+
+    nRes = TheFs.Volume(v);
+    test(nRes==KErrNone);
+
+    if(v.iDrive.iMediaAtt & KMediaAttVariableSize)
+        {
+        test.Printf(_L("Skipping. RAM drive not tested.\n"));
+        return;
+        }
+
+
+    TBool bDriveFinalised;
+
+    //============= 1. finalise the drive (RW mode) and check the result
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    //-- 1.1 finalise the drive second time EFinal_RW -> EFinal_RW shall work
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    //============= 2. create a file. Shall succeed (EFinal_RW), the volume shall become unfinalised
+
+    RFile file;
+    _LIT(KFileName, "\\my_file1.dat");
+    _LIT8(KSomeData, "this is some data");
+
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(!bDriveFinalised); //-- the volume has become "unfinalised"
+
+    //----------------------------------------------------------------------------------
+    //-- test volume finalisation with opened objects
+
+    //-- 2.1 having opened files should be OK for volume finalisation
+    
+    //-- 2.1.1 RW finalisation; after the volume finalised it should be possible to write to the opened file
+    nRes = file.Open(TheFs, KFileName, EFileWrite | EFileWriteDirectIO);
+    test_KErrNone(nRes);
+
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    nRes = file.Write(0, KSomeData);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(!bDriveFinalised); //-- the volume should become "unfinalised"
+
+    //-- 2.1.2 RO finalisation; after the volume finalised it shouldn't be possible to write to the opened file
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    nRes = file.Write(0, KSomeData);
+    test(nRes == KErrAccessDenied);  //-- no write access to the volume
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised); //-- the volume should become "unfinalised"
+
+    file.Close();
+    
+    //-- remount FS, the drive shall become RW
+    nRes = RemountFS(TheFs, gDriveNum);
+    test_KErrNone(nRes);
+    
+    
+    //-- 2.2 having opened directories should be OK for volume finalisation
+    _LIT(KDirName,  "\\Dir11235tt\\");
+    MakeDir(KDirName);
+    RDir dir;
+
+    //-- 2.2.1 RW finalisation; after the volume finalised it should be possible to have write access to it
+    nRes = dir.Open(TheFs, KDirName, KEntryAttNormal);
+    test_KErrNone(nRes);
+
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(!bDriveFinalised);
+
+    //-- 2.1.2 RO finalisation; after the volume finalised it shouldn't be possible to write to it
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test(nRes == KErrAccessDenied);  //-- no write access to the volume
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised); //-- the volume should become "unfinalised"
+
+    dir.Close();
+
+    //-- remount FS, the drive shall become RW
+    nRes = RemountFS(TheFs, gDriveNum);
+    test_KErrNone(nRes);
+    
+    //-- 2.3 having opened disk access objects, like formats or raw disks makes finalisation impossible
+    RFormat  format;
+    RRawDisk rawDisk;
+    TInt     fmtCnt;
+
+    //-- 2.3.1 format
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test_KErrNone(nRes);
+
+    nRes = format.Open(TheFs, gSessionPath, EFullFormat, fmtCnt);
+    test_KErrNone(nRes);
+
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test(nRes == KErrInUse);  
+
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
+    test(nRes == KErrInUse);  
+
+    format.Close();
+
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test_KErrNone(nRes);
+
+    //-- 2.3.2 raw disk
+    nRes = rawDisk.Open(TheFs, gDriveNum);
+    test_KErrNone(nRes);
+
+
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test(nRes == KErrInUse);  
+
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
+    test(nRes == KErrInUse);  
+    
+    rawDisk.Close();
+
+    //-- 2.4 Volume finalisation and file system dismounting
+
+    //-- 2.4.1 "graceful" dismounting should finalise the drive correctly
+
+    //-- "unfinalise the volume"
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(!bDriveFinalised);
+
+    TFSDescriptor fsDesc;
+    nRes = GetFileSystemDescriptor(TheFs, gDriveNum, fsDesc);
+    test_KErrNone(nRes);
+
+    //-- gracefully dismount the file system
+    nRes = TheFs.DismountFileSystem(fsDesc.iFsName, gDriveNum);
+    test_KErrNone(nRes);
+
+    //-- mount it back
+    nRes = MountFileSystem(TheFs, gDriveNum, fsDesc);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    //-- 2.4.2 "forced" dismounting, usually happens when "graceful doesn't work, because there are files opened on the volume.
+    //-- Should also finalise the drive correctly
+
+    //-- "unfinalise the volume"
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(!bDriveFinalised);
+
+    //-- open a file on the volume, this will prevent graceful dismounting
+    nRes = file.Open(TheFs, KFileName, EFileWrite | EFileWriteDirectIO);
+    test_KErrNone(nRes);
+
+    nRes = GetFileSystemDescriptor(TheFs, gDriveNum, fsDesc);
+    test_KErrNone(nRes);
+
+    //-- try gracefully dismount the file system
+    nRes = TheFs.DismountFileSystem(fsDesc.iFsName, gDriveNum);
+    test(nRes == KErrInUse); //-- no luck, as expected
+
+    //-- now do dismounting by force
+    TRequestStatus  rqStat;
+    TheFs.NotifyDismount(gDriveNum, rqStat, EFsDismountForceDismount);
+    User::WaitForRequest(rqStat);
+    test_KErrNone(rqStat.Int());
+
+    nRes = file.Write(0, KSomeData);
+    test(nRes == KErrNotReady);    
+
+    file.Close();
+
+    //-- mount it back
+    nRes = MountFileSystem(TheFs, gDriveNum, fsDesc);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    //============= 3. test "unfinalise API"
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EForceUnfinalise);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(!bDriveFinalised); //-- the volume has become "unfinalised"
+
+    //============= 4. test finalisation into RO mode
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO); //-- the volume becomes RO
+    test_KErrNone(nRes);
+
+    //-- try to write a file on RO volume; it shall fail with KErrAccessDenied
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test(nRes == KErrAccessDenied);
+    file.Close();
+
+    //-- 4.1 try to finalise into EFinal_RW mode, shall fail with KErrAccessDenied
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test(nRes == KErrAccessDenied);
+
+    //-- 4.2 "unfinalise" the volume, it still shall remain RO
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EForceUnfinalise);
+    test_KErrNone(nRes);
+
+    //-- try to write a file on RO volume; it shall fail with KErrAccessDenied
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test(nRes == KErrAccessDenied);
+    file.Close();
+
+    //-- remount FS, the drive shall become RW
+    nRes = RemountFS(TheFs, gDriveNum);
+    test_KErrNone(nRes);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    //-- try to write a file on RW volume, shall be OK
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test(nRes == KErrNone);
+    file.Close();
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(!bDriveFinalised);
+
+    //============= 5. test various finalisation modes
+
+    //-- 5.1  Not finalised -> EFinal_RW (KErrNone)
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test(nRes == KErrNone);
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    //-- 5.2  EFinal_RW -> EFinal_RO (KErrNone)
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
+    test(nRes == KErrNone);
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    //-- 5.2  EFinal_RO -> EFinal_RW  (KErrAccessDenied)
+    nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
+    test(nRes == KErrAccessDenied);
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    //-- 5.3 restore
+    nRes = RemountFS(TheFs, gDriveNum);
+    test_KErrNone(nRes);
+
+
+    //============= 6. test old RFs::FinaliseDrives API
+
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test(nRes == KErrNone);
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(!bDriveFinalised);
+
+    TheFs.FinaliseDrives(); //-- shall work as TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW) but for ALL drives
+
+    bDriveFinalised = IsVolumeFinalised(gDriveNum);
+    test(bDriveFinalised);
+
+    nRes = CreateEmptyFile(TheFs, KFileName, 128000);
+    test(nRes == KErrNone);
+
+
+
+}
+
+
+void CallTestsL()
 	{
+    //-- set up console output
+    F32_Test_Utils::SetConsole(test.Console());
 
+    TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
+    test_KErrNone(nRes);
+    
+    PrintDrvInfo(TheFs, gDriveNum);
+
+    TestDriveFinalisation();
 	Test1();
 	Test2();
 	Test3();
@@ -1418,4 +1706,5 @@
 	Test14();
 	Test15();
     TestGetMediaSerialNumber();
+
 	}
--- a/kerneltest/f32test/server/t_nmbs.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/server/t_nmbs.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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"));
--- a/kerneltest/f32test/server/t_proxydrive1.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/server/t_proxydrive1.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -24,7 +24,7 @@
 using namespace F32_Test_Utils;
 
 
-GLDEF_D RTest test(_L("T_PROXYDRIVE1"));
+RTest test(_L("T_PROXYDRIVE1"));
 
 
 TInt GetRemovableDrive(TInt aDriveNumber)
@@ -81,7 +81,7 @@
 
 
 
-GLDEF_C void CallTestsL()
+void CallTestsL()
 	{
     TInt drive;
 	TInt err=RFs::CharToDrive(gDriveToTest,drive);
@@ -96,7 +96,7 @@
 
 	TInt r;
 
-	TInt localDriveNumber = GetRemovableDrive(drive);
+	TInt localDriveNumber = GetRemovableDrive(drive); //-- local _physical_ drive number
 	if (localDriveNumber < 0)
 		{
 		test.Printf(_L("Not a removable drive, skipping test\n"));
@@ -113,16 +113,25 @@
 	TBuf<1> p2;
 	TInt driveNumber = EDriveM;
 
+    //-- this is a hack - mount the proxy drive to the existing one with alive file system just to check
+    //-- that it works.
+
 	r = TheFs.MountProxyDrive(driveNumber, KBitProxyDrive, &p1, &p2);
 	test.Printf(_L("MountProxyDrive(%d, %S) r %d\n"), driveNumber, &KBitProxyDrive, r);
 	test (r >= 0);
 
-	_LIT(KFileSystem, "FAT");
-	r = TheFs.MountFileSystem(KFileSystem, driveNumber);
-	test.Printf(_L("MountFileSystem(%S) r %d\n"), &KFileSystem, r);
+    //-- query existing file system name on the drive that we are be parasiting on.
+    TFSName fsName;
+    r = TheFs.FileSystemName(fsName, drive);
+    test(r == KErrNone);
+
+
+	r = TheFs.MountFileSystem(fsName, driveNumber);
+	test.Printf(_L("MountFileSystem(%S) r %d\n"), &fsName, r);
 	test(r == KErrNone);
 
 
+
 	RFs fs;
 	r = fs.Connect();
 	test(r == KErrNone);
@@ -135,8 +144,8 @@
 	test.Printf(_L("RDir::Open(%S) r %d\n"), &dirPath, r);
 
 
-	r = TheFs.DismountFileSystem(KFileSystem, driveNumber);
-	test.Printf(_L("DismountFileSystem(%S) r %d\n"), &KFileSystem, r);
+	r = TheFs.DismountFileSystem(fsName, driveNumber);
+	test.Printf(_L("DismountFileSystem(%S) r %d\n"), &fsName, r);
 	test (r == KErrInUse);
 
 	// dismount failed - attempt a forced dismount
@@ -144,7 +153,7 @@
 	TheFs.NotifyDismount(driveNumber, stat, EFsDismountForceDismount);
 	User::WaitForRequest(stat);
 	r = stat.Int();
-	test.Printf(_L("DismountFileSystem(%S, EFsDismountForceDismount) r %d\n"), &KFileSystem, r);
+	test.Printf(_L("DismountFileSystem(%S, EFsDismountForceDismount) r %d\n"), &fsName, r);
 	test (r == KErrNone);
 
 	r = TheFs.DismountProxyDrive(driveNumber);
--- a/kerneltest/f32test/server/t_wcache.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/kerneltest/f32test/server/t_wcache.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -28,6 +28,8 @@
 #include <f32dbg.h>
 #include "t_server.h"
 #include <e32twin.h>
+#include <hal.h>
+#include "tf32testtimer.h"
 
 const TInt KTotalCacheSize = 32 * 1024 * 1024;
 const TInt KDefaultCacheSize = (128 + 12) * 1024; 	// This size is the default configuration size
@@ -89,7 +91,6 @@
 const TInt KOneMeg = KOneK * 1024;
 const TInt KBlockSize = KOneK;
 const TInt KWaitRequestsTableSize = 256;
-const TInt KMs = 1000; 
 
 TInt gSecondFileSize = 0; 
 TInt gFirstFileSize = 0;
@@ -102,9 +103,6 @@
 TBuf16<25> gCurrentFile;
 
 TInt gNextFile = 0;
-TTime gTime1;
-TTime gTime2;
-
 
 // Concurrent Threads
 RThread gThread1;
@@ -513,25 +511,22 @@
 	
 	@return time taken to perform the operation in uS
 */
-TInt WriteTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) 
+TTimeIntervalMicroSeconds WriteTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) 
 	{
 	RTest test(_L("T_WCACHE"));
 
-	TTime startTime;
-	TTime endTime;
 	TInt r = 0;
-	
-	startTime.HomeTime();
+
+    TF32TestTimer timer;
+	timer.Start();
 	
 	r = WriteFile(gTheFs,aFile, aFileName , aSize * KOneK, aBlockSize, gBufWritePtr, aMode);
 	test_KErrNone(r);
-	
-	endTime.HomeTime();
-	
-	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
-	
+
+	timer.Stop();	
+	gTimeTakenBigFile = timer.Time();
 	test.Close();
-	return I64LOW(gTimeTakenBigFile.Int64());
+	return timer.Time();        
 	}
 
 /** Measure the time taken for this file to be read synchronously
@@ -545,18 +540,16 @@
 	@return time taken to perform the operation in uS
 
 */
-TInt ReadTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) 
+TTimeIntervalMicroSeconds ReadTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aBlockSize, TInt aMode) 
 	{
-	TTime startTime;
-	TTime endTime;
+    TF32TestTimer timer;
+	timer.Start();
+	ReadFile(gTheFs,aFile, aFileName, aSize * KOneK, aBlockSize, aMode);
+	timer.Stop();
 	
-	startTime.HomeTime();
-	ReadFile(gTheFs,aFile, aFileName, aSize * KOneK, aBlockSize, aMode);
-	endTime.HomeTime();
-	
-	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
-	
-	return I64LOW(gTimeTakenBigFile.Int64()) ;
+	gTimeTakenBigFile = timer.Time();
+        	
+	return timer.Time();
 	}
 
 /** Read asynchronously the test file from the disc
@@ -569,22 +562,19 @@
 
 	@return time taken to perform the operation in uS
 */
-TInt ReadAsyncTestFile(RFile& file, TDes16& aFile, TInt aSize, TInt aBlockSize, TInt aMode) 
+TTimeIntervalMicroSeconds ReadAsyncTestFile(RFile& file, TDes16& aFile, TInt aSize, TInt aBlockSize, TInt aMode) 
 	{
-	TTime startTime;
-	TTime endTime;
 	TRequestStatus status[KWaitRequestsTableSize];
-	
-	startTime.HomeTime();
+    TF32TestTimer timer;
+	timer.Start();
 	
 	ReadFileAsync(gTheFs, file, aFile, aSize * KOneK, aBlockSize, status, aMode);
 	WaitForAll(status,  (aSize * KOneK)/KBlockSize);
-	
-	endTime.HomeTime();
+	timer.Stop();	
+		
+	gTimeTakenBigFile = timer.Time();
 	
-	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
-	
-	return I64LOW(gTimeTakenBigFile.Int64());
+	return timer.Time();
 	}
 
 /** Read asynchronously the test file from the disc
@@ -596,22 +586,19 @@
 
 	@return time taken to perform the operation in uS
 */
-TInt WriteAsyncTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aMode) 
+TTimeIntervalMicroSeconds WriteAsyncTestFile(RFile& aFile, TDes16& aFileName, TInt aSize, TInt aMode) 
 	{
-	TTime startTime;
-	TTime endTime;
 	TRequestStatus status[KWaitRequestsTableSize];
-	
-	startTime.HomeTime();
+    TF32TestTimer timer;
+    timer.Start();
 	
 	WriteFileAsync(gTheFs, aFile, aFileName, aSize * KOneK, aMode, status );
 	WaitForAll(status, (aSize * KOneK)/KBlockSize);
-	
-	endTime.HomeTime();
+	timer.Stop();	
 	
-	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
+	gTimeTakenBigFile = timer.Time();
 	
-	return I64LOW(gTimeTakenBigFile.Int64());
+	return timer.Time();
 	}
 
 /**  Test Boundaries
@@ -621,9 +608,9 @@
 void TestBoundaries()
 	{
 	TInt r = 0;
-	TInt time = 0;
-	TInt rtime = 0;
-	TInt tcreate = 0;
+	TTimeIntervalMicroSeconds time = 0;
+	TTimeIntervalMicroSeconds rtime = 0;
+	TTimeIntervalMicroSeconds tcreate = 0;
 	RFile fileWriter;
 	RFile fileWriter2;
 	RFile fileReader;
@@ -641,21 +628,22 @@
 		test.Printf(_L("\nSync: Write from 1 K to %d K \n"), i); 
 
 		tcreate = WriteTestFile(fileWriter, gSecondFile, i, KBlockSize, EFileShareAny|EFileWrite|EFileWriteDirectIO);
-		test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, tcreate/KMs);	
+		test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(tcreate));	
 		fileWriter.Close();
 
 		time =  WriteTestFile(fileWriter2, gFirstFile, i, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered);
-		test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, time/KMs);
+		test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(time));
 
 		rtime = ReadTestFile(fileReader, gFirstFile, i, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered);
-		test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, rtime/KMs);
-
+		test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(rtime));
 
 		fileReader.Close();	
 		fileWriter2.Close();
 		
 		#if !defined(__WINS__)
-			test((tcreate > time) || (tcreate > rtime)); 
+            test(tcreate > TTimeIntervalMicroSeconds(0));  // test measured time is correct
+			test(tcreate > time);
+            test(tcreate > rtime); 
 		#endif
 
 		r = gTheFs.Delete(gFirstFile);
@@ -676,21 +664,23 @@
 		test.Printf(_L("\nAsync: Write from 1 K to %d K \n"), i); 
 
 		tcreate = WriteAsyncTestFile(fileWriter, gSecondFile, i, EFileShareAny|EFileWrite|EFileWriteDirectIO);
-		test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, tcreate/KMs);	
+		test.Printf(_L("Time to write %d K without caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(tcreate));
 		fileWriter.Close();
 
 		time =  WriteAsyncTestFile(fileWriter2, gFirstFile, i,EFileShareAny|EFileWrite|EFileWriteBuffered);
-		test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, time/KMs);
+		test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(time));
 
 
 		rtime = ReadAsyncTestFile(fileReader, gFirstFile, i, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered);
-		test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, rtime/KMs);
+		test.Printf(_L("Time to read %d K from the cache: %d mS\n"), i, TF32TestTimer::TimeInMilliSeconds(rtime));
 
 		fileReader.Close();	
 		fileWriter2.Close();
 		
 		#if !defined(__WINS__)
-			test((tcreate > time) || (tcreate > rtime));  
+            test(tcreate > TTimeIntervalMicroSeconds(0));  // test measured time is correct
+			test(tcreate > time);
+            test(tcreate > rtime);
 		#endif
 
 		r = gTheFs.Delete(gFirstFile);
@@ -749,17 +739,16 @@
 	
 	@return returns the time that took to do the verification in mS, fails if the file is not corrupted/modified
 */
-TInt ReadTestFileVerif(TDes16& aFile)
+TTimeIntervalMicroSeconds ReadTestFileVerif(TDes16& aFile)
 	{
-	TTime startTime;
-	TTime endTime;
 	TInt r = 0;
 	TInt size = 0;
 	RFile fileRead;
 	TInt corrupt = 0;
 	TBool isFat=IsFSFAT(gTheFs,gDrive);
-	
-	startTime.HomeTime();
+
+    TF32TestTimer timer;
+	timer.Start();
 	
 	r = fileRead.Open(gTheFs,aFile,EFileShareAny|EFileRead|EFileReadBuffered|EFileReadAheadOff);
 	test_KErrNone(r);
@@ -791,12 +780,11 @@
 	fileRead.Close();
 	
 	test(corrupt>0); // Ensure the cache returns the changed content 
-	
-	endTime.HomeTime();
+	timer.Stop();	
 	
-	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
+	gTimeTakenBigFile = timer.Time();
 	
-	return I64LOW(gTimeTakenBigFile.Int64()) / KMs;
+	return timer.Time();
 	}
 
 /**  Modifies the second file
@@ -840,8 +828,8 @@
 LOCAL_C void TestIntegrity()
 	{
 	TInt r = 0;
-	TInt time;
-	TInt tcreate = 0;
+	TTimeIntervalMicroSeconds time;
+	TTimeIntervalMicroSeconds tcreate = 0;
 	RFile file;
 	
 	// Modify file in some position 
@@ -850,14 +838,14 @@
 	test.Printf(_L("\nSync: Write from 1 K to %d K \n"), 255); 
 
 	tcreate = WriteTestFile(file, gSecondFile, 255, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered);
-	test.Printf(_L("Time to write %d K with caching: %d mS\n"), 255, tcreate/KMs);	
+	test.Printf(_L("Time to write %d K with caching: %d mS\n"), 255, TF32TestTimer::TimeInMilliSeconds(tcreate));	
 	file.Close();
 
 	test.Printf(_L("Mess the content that is still in the cache\n"));
 	CorruptSecondFile(); 
 	
 	time = ReadTestFileVerif(gSecondFile);	
-	test.Printf(_L("Time taken to verify: %d\n"),time);
+	test.Printf(_L("Time taken to verify: %ld\n"),time.Int64());
 	
 	test.Printf(_L("Integrity verified\n"));
 
@@ -1178,7 +1166,7 @@
 */
 void TestRemoval()
 	{	
-	TInt time = 0, rtime = 0;
+	TTimeIntervalMicroSeconds time = 0, rtime = 0;
 	RFile file1, file2;
 	
 		 	
@@ -1227,7 +1215,7 @@
 	test.Printf(_L("\nSync: Write from 1 K to 254 K \n")); 
 
 	time =  WriteTestFile(file1, gSecondFile, KMinSize, KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered);
-	test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize, time/KMs);
+	test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize, TF32TestTimer::TimeInMilliSeconds(time));
 	test.Printf(_L("Remove MMC card,! and then press a key\n"));
 	test.Getch();
 
@@ -1235,7 +1223,7 @@
 	test.Getch();
 
 	rtime = ReadTestFile(file2, gSecondFile, KMinSize, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered);
-	test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize, rtime/KMs);
+	test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize, TF32TestTimer::TimeInMilliSeconds(rtime));
 
 	test.Printf(_L("Remove MMC card! and then press a key\n"));
 	test.Getch();
@@ -1247,7 +1235,7 @@
 	test.Printf(_L("\nSync: Write from 1 K to 255 K \n")); 
 
 	time =  WriteTestFile(file1, gFirstFile, KMinSize + 1 , KBlockSize, EFileShareAny|EFileWrite|EFileWriteBuffered);
-	test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize + 1, time/KMs);
+	test.Printf(_L("Time to write %d K WITH caching: %d mS\n"), KMinSize + 1, TF32TestTimer::TimeInMilliSeconds(time));
 	test.Printf(_L("Remove MMC card and delete the file //F32-TST//FFFFFFF0.TXT and then press a key\n"));
 	test.Getch();
 
@@ -1255,7 +1243,7 @@
 	test.Getch();
 
 	rtime = ReadTestFile(file2, gFirstFile, KMinSize + 1, KBlockSize, EFileShareAny|EFileRead|EFileReadBuffered);
-	test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize + 1, rtime/KMs);
+	test.Printf(_L("Time to read %d K from the cache: %d mS\n"), KMinSize + 1, TF32TestTimer::TimeInMilliSeconds(rtime));
 
 	test.Printf(_L("Remove MMC card! and then press a key\n"));
 	test.Getch();
--- a/package_definition.xml	Tue Jul 06 15:50:07 2010 +0300
+++ b/package_definition.xml	Wed Aug 18 11:08:29 2010 +0300
@@ -50,9 +50,6 @@
       <component id="btrace" name="Kernel Trace Tool" purpose="mandatory">
         <unit bldFile="kernel/eka/drivers/trace" mrp="kernel/eka/drivers/trace/base_e32_drivers_trace.mrp"/>
       </component>
-      <component id="cameraldd" name="Camera Drivers" introduced="^3" purpose="optional">
-        <unit bldFile="kernel/eka/drivers/camerasc" mrp="kernel/eka/drivers/camerasc/base_drivers_camerasc.mrp"/>
-      </component>
       <component id="displayldd" name="Display Drivers" introduced="^3" purpose="optional">
         <!-- owned and maintained by graphics package. To be moved there as soon as technical limitations are resolved -->
         <unit bldFile="kernel/eka/drivers/display" mrp="kernel/eka/drivers/display/base_e32_drivers_display.mrp"/>
@@ -89,6 +86,9 @@
       <component id="fileserver" name="File Server" filter="gt" purpose="mandatory">
         <unit bldFile="userlibandfileserver/fileserver/group" mrp="userlibandfileserver/fileserver/group/base_f32.mrp"/>
       </component>
+      <component id="automounter" name="Automounter" filter="gt" purpose="mandatory">
+        <unit bldFile="userlibandfileserver/fileserver/automounter" mrp="userlibandfileserver/fileserver/automounter/base_f32_automounter.mrp"/>
+      </component>
       <component id="estart" name="Base Starter" filter="gt" purpose="optional">
         <unit bldFile="userlibandfileserver/fileserver/estart" mrp="userlibandfileserver/fileserver/estart/base_f32_estart.mrp"/>
       </component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_map.xml	Wed Aug 18 11:08:29 2010 +0300
@@ -0,0 +1,1 @@
+<PackageMap root="sf" layer="os"/>
--- a/userlibandfileserver/domainmgr/src/domaincli.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/domainmgr/src/domaincli.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2002-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"
@@ -19,6 +19,7 @@
 #include <e32base_private.h>
 #include <e32property.h>
 
+
 #include <domainmember.h>
 #include <domainmanager.h>
 #include "domainobserver.h"
@@ -380,26 +381,43 @@
 	{
 	__DM_ASSERT(Handle() != KNullHandle);
 
+	
 	aTransitionFailures.Reset();
 
 	TInt err = KErrNone;
-
+		
 	TInt failureCount = GetTransitionFailureCount();
 	if (failureCount <= 0)
 		return failureCount;
-
+	
+	// Pre-allocate array with a known size which for this case is the value in failureCount 
+	// in order to guarantee that future append operations to the array aTransitionFailures would
+	// not fail. This is assuming that the pre-allocated size is not exceeded.
+	err=aTransitionFailures.Reserve(failureCount); 
+	if (err != KErrNone)
+		return err;
+		
 	TTransitionFailure* failures = new TTransitionFailure[failureCount];
 	if(failures == NULL)
+		{		
+		aTransitionFailures.Reset();
 		return(KErrNoMemory);
+		}
+	
 	TPtr8 dataPtr(reinterpret_cast<TUint8*>(failures), failureCount * sizeof(TTransitionFailure));
 
 	TIpcArgs a(&dataPtr);
 	err = RSessionBase::SendReceive(EDmGetTransitionFailures, a);
-	
+
 	if (err == KErrNone)
 		{
-		for (TInt i=0; i<failureCount; i++)
-			aTransitionFailures.Append(failures[i]);
+		for (TInt i=0; i<failureCount; i++)	
+			{
+			err = aTransitionFailures.Append(failures[i]);		
+			//The pre-allocation made above for the array aTransitionFailures should guarantee
+			//that append operations complete succesfully.			
+			__DM_ASSERT(err == KErrNone);	
+			}
 		}
 
 	delete [] failures;
@@ -439,19 +457,34 @@
 	if (count <= 0)
 		return KErrGeneral;
 
+	// Pre-allocate array with a known size which for this case is the value in count 
+	// in order to guarantee that future append operations to the array aTransitionFailures 
+	// would not fail. This is assuming that the pre-allocated size is not exceeded.
+	TInt ret=aTransitions.Reserve(count); 
+	if (ret != KErrNone)
+		return ret;
+
 	TTransInfo* trans = new TTransInfo[count];
 	if(trans == NULL)
+		{
+		aTransitions.Reset();
 		return(KErrNoMemory);
+		}
 	
 	TPtr8 dataPtr(reinterpret_cast<TUint8*>(trans), count * sizeof(TTransInfo));
 
 	TIpcArgs a(&dataPtr);
-	TInt ret=RSessionBase::SendReceive(EDmObserverGetEvent, a);
+	ret=RSessionBase::SendReceive(EDmObserverGetEvent, a);
 	
 	if(ret==KErrNone)
 		{
 		for (TInt i=0; i<count; i++)
-			aTransitions.Append(trans[i]);
+			{
+			ret = aTransitions.Append(trans[i]);					
+			//The pre-allocation made above for the array aTransitions should guarantee
+			//that append operations complete succesfully.
+			__DM_ASSERT(ret == KErrNone);					
+			}
 		}
 	
 	delete [] trans;
--- a/userlibandfileserver/fileserver/etshell/ts_com.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/etshell/ts_com.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -84,10 +84,9 @@
 LOCAL_C TInt pswd_DrvNbr(TDes &aPath, TInt &aDN);
 LOCAL_C TInt pswd_Password(TDes &aPath, TInt aPWNbr, TMediaPassword &aPW);
 
-_LIT(KLitNewLine,"\n");
 void CShell::NewLine()
 	{
-	TheConsole->Printf(KLitNewLine());
+	Printf(KNl);
 	}
 
 //
@@ -371,7 +370,7 @@
 	    switch(nRes)
 		    {
 	    case 0:
-		    CShell::TheConsole->Printf(_L("Complete - no errors\n"));
+		    CShell::TheConsole->Printf(_L("Completed - no errors found\n"));
 		    break;
 	    case 1:
 		    CShell::TheConsole->Printf(_L("Error - File cluster chain contains a bad value (<2 or >maxCluster)\n"));
@@ -1195,9 +1194,9 @@
                 if(nRes == KErrNone)
                 {
                     if(boolPckg() >0)
-                        Buf.Copy(_L("Volume: Finalised"));
+                        Buf.Copy(_L("Vol:Finalised "));
                     else
-                        Buf.Copy(_L("Volume: Not finalised"));
+                        Buf.Copy(_L("Vol:Not finalised "));
                 }
 
                 //-- print out cluster size that FS reported
@@ -1437,16 +1436,16 @@
     {//-- gaceful attempt to dismount the FS
     nRes = aFs.DismountFileSystem(fsName, aDrvNum);
     if(nRes != KErrNone)
-    {
+        {
         CShell::TheConsole->Printf(_L("Can't dismount FS!\n"));
         return nRes;
-    }
+        }
     else
-    {
-    CShell::TheConsole->Printf(_L("'%S' filesystem dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum);
-    return KErrNone;
+        {
+        CShell::TheConsole->Printf(_L("'%S' filesystem dismounted from drive %c:\n"), &fsName, 'A'+aDrvNum);
+        return KErrNone;
+        }
     }
-}
     else
     {//-- dismount by force
         TRequestStatus rqStat;
--- a/userlibandfileserver/fileserver/group/bld.inf	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/group/bld.inf	Wed Aug 18 11:08:29 2010 +0300
@@ -43,7 +43,7 @@
 ../inc/rofs.h									SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(rofs.h)
 ../inc/ftlcontrolio.h							SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(ftlcontrolio.h)
 ../inc/f32pluginUtils.h							SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(f32pluginutils.h)
-../inc/F32plugin.h								SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(f32plugin.h)
+../inc/f32plugin.h								SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(f32plugin.h)
 ../inc/f32plugin.inl							SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(f32plugin.inl)
 
 ../rom/f32.iby	 		/epoc32/rom/f32/f32.iby
--- a/userlibandfileserver/fileserver/group/release.txt	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/group/release.txt	Wed Aug 18 11:08:29 2010 +0300
@@ -1,3 +1,64 @@
+Version 2.00.3055
+=================
+(Made by fadhliM 23/07/2010)
+
+1.	michcox
+	1.	ou1cimx1#488769 Race condition in file server plugins
+	2.	ou1cimx1#502970 [ENV] Fileserver Coverity Defects
+
+2.	niccox
+	1.	ou1cimx1#486762 ENV T_FSCHED.EXE failure: line 936, after "Sync read done 0 ms before the write ended"
+
+
+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)
+
+1.	dlyokhin
+	1.	ou1cimx1#424702 FAT, exFAT should allow volume finalisation even if it has opened files or directories
+
+
+Version 2.00.3051
+=================
+(Made by vfebvre 21/06/2010)
+
+1.	michcox
+	1.	ou1cimx1#439295 [DEV] MCL Improve Code Coverage in MFS Code - Improve CFileMan observer
+
+
+Version 2.00.3050
+=================
+(Made by vfebvre 18/06/2010)
+
+1.	shubmurt
+	1.	ou1cimx1#428765 Case and Slash fix for Linux Build
+
+2.	dlyokhin
+	1.	ou1cimx1#423737 FAT FS can report incorrect volume size
+
+
 Version 2.00.3049
 =================
 (Made by vfebvre 15/06/2010)
--- a/userlibandfileserver/fileserver/inc/F32plugin.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/inc/F32plugin.h	Wed Aug 18 11:08:29 2010 +0300
@@ -448,7 +448,7 @@
 	//Overloaded function - checks all types of TInterceptAtts
 	TBool IsRegistered(TInt aMessage);
 	TBool IsRegistered(TInt aMessage, TInterceptAtts aInterceptAtts);
-	TBool IsPluginThread(CFsRequest& aMessage);
+	TBool OriginatedFromPlugin(CFsRequest& aMessage);
 	TBool IsMounted(TInt aDrive);
 
 private:
--- a/userlibandfileserver/fileserver/inc/f32file.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/inc/f32file.h	Wed Aug 18 11:08:29 2010 +0300
@@ -2942,7 +2942,6 @@
 	IMPORT_C TInt Copy(const RFile& anOld,const TDesC& aNew,TUint aSwitches,TRequestStatus& aStatus);
 protected:
 	CFileMan(RFs& aFs);
-	TInt RenameInvalidEntry(const TDesC& anOld,const TDesC& aNew,TUint aSwitch=EOverWrite);
 private:
 	/**
 	This is an internal enumeration for CFileMan implementation. 
--- a/userlibandfileserver/fileserver/inc/f32fsys.inl	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/inc/f32fsys.inl	Wed Aug 18 11:08:29 2010 +0300
@@ -270,53 +270,48 @@
 	__IS_DRIVETHREAD();
 	iDriveFlags |= ENotifyOff;
 	}
+
 /**
-
 Locks the drive.This function acquires iLock mutex.
-
 */
 inline void TDrive::Lock()
 	{iLock.Wait();}
+
 /**
-
 UnLocks the drive.This function signals the iLock mutex.
-
 */
-
 inline void TDrive::UnLock()
 	{iLock.Signal();}
 
 
 /**
-
-Gets the reserved space of a drive
-
 @return	Amount of space reserved in bytes.
-
 */
-
 inline TInt TDrive::ReservedSpace() const
-	{return iReservedSpace;}
+	{
+    return iReservedSpace;
+    }
 
 /**
-
-Reserves a space of a drive.
+    Reserves space on a drive. The amount of 'reserved space' is subtracted  
+    from the amount of available free space on the volume reported by file system, when the user 
+    queries it.
 
-@param	aReservedSpace	Amount of space to reserve in bytes.
-
+    @param	aReservedSpace	Amount of space to reserve in bytes.
 */
 inline void TDrive::SetReservedSpace(const TInt aReservedSpace)
-	{iReservedSpace=aReservedSpace; }
+	{
+    iReservedSpace=aReservedSpace; 
+    }
 
 /**
-
-Sets the rugged flag in the drive object.
+    Sets the 'rugged mode' flag in the drive object. The file system associated with this TDrive object 
+    can use this flag for changing its behaviour.
+    For example, FAT file system if this flag is set, operates in 'Rugged FAT' mode, when the performance is 
+    sacrificed for the sake of reliability. 
 
-@param Flag to set or clear the rugged flag.
-@see	IsRugged()
-
+    @param aIsRugged  the 'rugged mode' flag.
 */
-
 inline void TDrive::SetRugged(TBool aIsRugged)
 	{
 	if (!aIsRugged)
@@ -326,17 +321,13 @@
 	}
 
 /**
-
-Returns whether the current drive is running as rugged Fat
-or not.If IsRugged flag is set then in the event of power 
-failure fat/metadata will be in a valid state if the scandrive 
-utility is run immediately after.
-
-@return Is rugged fat flag.
+    @return 'Is rugged' flag.
+    See TDrive::SetRugged()
 */
-
 inline TBool TDrive::IsRugged() const
-	{return !(iDriveFlags & ENotRugged); }
+	{
+    return !(iDriveFlags & ENotRugged); 
+    }
 
 
 /**
@@ -451,64 +442,69 @@
 	{Drive().SetNotifyOff();}
 
 
+//---------------------------------------------------------------------------------------------------------------------------------
 
+/**
+
+    Increment mount's lock counter. This happens on following events:
+        - RemoveResource() call, when file (share) or directory is closed
+        - AddDiskAccess() call,  when disk access object (like Format or RawDisk access) is opened on the mount.
+
+    See also: CMountCB::LockStatus()   
+*/
+inline void CMountCB::IncLock()
+	{
+    iLockMount++;
+    }
+
+
+//---------------------------------------------------------------------------------------------------------------------------------
 
 /**
-Locks the mount by incrementing the internal lock counter.
+    Decrement mount's lock counter. This happens on following events:
+
+    AddResource()       call when file (share) or directory is opened on the mount 
+    RemoveDiskAccess()  call when disk access object (like Format or RawDisk access) is closed.
+
+    See also: CMountCB::LockStatus()   
+*/
+inline void CMountCB::DecLock()
+	{
+    iLockMount--;
+    }
 
-The mount becomes locked on formatting or on the opening of a resource
-(a file or a directory) or raw disk subsession.
-A format, resource or raw disk subsession can only be opened if the mount
-is not locked.
+//---------------------------------------------------------------------------------------------------------------------------------
+
+/**
+    @return value of the Mount's lock counter value.
+    
+    The meaning of 'iLockMount' is overloaded a bit, it's value is:
+        0   when there are no files, directories, formats and any other objects opened on the mount
+        >0  when there are disk access objects opened (raw disk access or format)
+        <0  when there are files or directories opened on the mount, and the value reflects their total number 
 */
-inline void CMountCB::IncLock()
-	{iLockMount++;}
-
+inline TInt CMountCB::LockStatus() const
+	{
+    return iLockMount;
+    }
 
 
 
-/**
-Unlocks the mount by decrementing the internal lock counter.
-
-The mount becomes locked on formatting or on the opening of a resource
-(a file or a directory) or raw disk subsession.
-A format, resource or raw disk subsession can only be opened if the mount
-is not locked.
-*/
-inline void CMountCB::DecLock()
-	{iLockMount--;}
-
-
-
-
-/**
-Gets the current lock status.
-
-It delivers the current lock status by returning the internal lock counter.
-
-@return The current lock status.
-*/
-inline TInt CMountCB::LockStatus() const
-	{return(iLockMount);}
-
-
-
-
+//---------------------------------------------------------------------------------------------------------------------------------
 /**
 Tests whether the mount is currently locked. 
 
 A mount is locked when the internal lock counter is greater than zero.
-On creation, the lock counter is set to zero.
+    This happens when a format, resource or raw disk subsession is opened on the mount.
 
-The mount becomes locked on formatting or on the opening of a resource
-(a file or a directory) or raw disk subsession.
-A format, resource or raw disk subsession can only be opened if the mount
-is not locked.
+    See also: CMountCB::LockStatus()   
 
-@return True if the mount is locked, false, otherwise.
+    @return True if the mount is locked by having disk access objects opened
 */
 inline TBool CMountCB::Locked() const
-	{return iLockMount>0; }
+	{
+    return iLockMount > 0; 
+    }
 
 
 
@@ -537,7 +533,9 @@
 /**
 */
 inline TInt64 CMountCB::Size() const
-	{return(iSize);}
+	{
+    return iSize;
+    }
 
 
 
@@ -547,14 +545,19 @@
 @param aMountNumber - The unique mount number
 */
 const TInt KMountDismounted = 0x80000000;
+
 inline void CMountCB::SetMountNumber(TInt aMountNumber)
-	{ iMountNumber = (aMountNumber &~ KMountDismounted); }
+	{ 
+    iMountNumber = (aMountNumber & ~KMountDismounted); 
+    }
 
 
 
 
 /**
-Set the mount to be dismounted
+    Set the mount flag indicating that it is in 'dismounted' state.
+    The CMountCB object in this case is still alive, but any attempts to access resources on this 
+    mount result in KErrDismounted.
 */
 inline void CMountCB::SetDismounted(TBool aDismounted)
 	{
@@ -568,21 +571,23 @@
 
 
 /**
-Returns the unique mount number
 @return The unique mount number
 */
 inline TInt CMountCB::MountNumber() const
-	{ return(iMountNumber &~ KMountDismounted); }
+	{ 
+    return(iMountNumber &~ KMountDismounted); 
+    }
 
 
 
 
 /**
-Returns ETrue if the mount is flagged as dismounted.
 @return ETrue if the mount is flagged as dismounted
 */
 inline TBool CMountCB::IsDismounted() const
-	{ return(iMountNumber & KMountDismounted); }
+	{ 
+    return(iMountNumber & KMountDismounted); 
+    }
 
 
 
--- a/userlibandfileserver/fileserver/inc/f32ver.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/inc/f32ver.h	Wed Aug 18 11:08:29 2010 +0300
@@ -58,6 +58,6 @@
 
 @see TVersion
 */
-const TInt KF32BuildVersionNumber=3049;
+const TInt KF32BuildVersionNumber=3055;
 //
 #endif
--- a/userlibandfileserver/fileserver/sfat32/fat_table32.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfat32/fat_table32.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -692,7 +692,7 @@
 CAtaFatTable::CAtaFatTable(CFatMountCB& aOwner)
              :CFatTable(aOwner), iDriveInteface(aOwner.DriveInterface())
     {
-        iState = ENotInitialised;
+    iState = ENotInitialised;
     }
 
 
@@ -1044,10 +1044,16 @@
             //-- create helper thread object and start the thread
             ipHelperThread = CFat32BitCachePopulator::NewL(*this);
 
-            ipHelperThread->Launch(); 
-            //-- background FAT bit cache populating thread is running now.
-            //-- the result of thread start up and completion isn't very interesting: If it fails to 
-            //-- properly populate the cache, nothing fatal will happen.
+            if(ipHelperThread->Launch() != KErrNone)
+                {//-- failed for some reason
+                DestroyHelperThread();
+                }
+                else
+                {
+                //-- background FAT bit cache populating thread is running now.
+                //-- the result of thread start up and completion isn't very interesting: If it fails to 
+                //-- properly populate the cache, nothing fatal will happen.
+                }
             }
 
         //-- CFat32BitCachePopulator doesn't affect FAT table state. 
@@ -1544,7 +1550,8 @@
     
     SetState(EFreeClustersScan);
     
-    ipHelperThread->Launch(); 
+    User::LeaveIfError(ipHelperThread->Launch()); 
+    
     //-- background FAT scanning thread is running now
     }
 
@@ -1964,8 +1971,8 @@
         return nRes;
         }
 
-   //-- Helper FAT thread is running now
-   return KErrNone; 
+    //-- Helper FAT thread is running now
+    return KErrNone; 
     }
 
 
@@ -1983,7 +1990,8 @@
 
 /**
     Launches the FAT32_ScanThread scaner thread.
-    @return  standard error code
+    @return  KErrNone if the thread launched OK
+             standard error code otherwise
 */
 TInt CFat32ScanThread::Launch()
     {
--- a/userlibandfileserver/fileserver/sfat32/inc/sl_std.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfat32/inc/sl_std.h	Wed Aug 18 11:08:29 2010 +0300
@@ -750,6 +750,7 @@
     void    DoReMountL();
     void    SetFatType(TFatType aFatType);
 
+    TUint64 VolumeSizeInBytes() const;
 
 private:
 	
@@ -767,10 +768,10 @@
     TBool iRamDrive         : 1;///< true if this is a RAM drive    
     TBool iMainBootSecValid : 1;///< true if the main boot sector is valid, if false, a backup boot sector may be in use. 
 
-    TFatMntState iState;        ///< this mounnt internal state
+    TFatMntState iState;            ///< this mounnt internal state
 
-    TFatType iFatType;          ///< FAT type, FAT12,16 or 32
-    TUint32  iFatEocCode;       ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 
+    TFatType iFatType;              ///< FAT type, FAT12,16 or 32
+    TUint32  iFatEocCode;           ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 
 
     CLeafDirCache* iLeafDirCache;	///< A cache for most recently visited directories, only valid when limit is set bigger than 1
 
@@ -782,7 +783,7 @@
     CFatTable* iFatTable;           ///< Pointer to the volume Fat 
 	CRawDisk*  iRawDisk;            ///< Pointer to the raw data interface class
 	
-    CAsyncNotifier* iNotifier;  ///< Async notifier for notifying user of Fat error conditions 
+    CAsyncNotifier* iNotifier;      ///< Async notifier for notifying user of Fat error conditions 
 
     XDriveInterface iDriverInterface; ///< the object representing interface to the drive, provides read/write access and notifiers
 	TFatConfig      iFatConfig;       ///< FAT parametrers from estart.txt
@@ -862,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	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfat32/sl_file.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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/sfat32/sl_mnt.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -551,10 +551,8 @@
         return;
         }
 
-    if(LockStatus() != 0)
-        {//-- can't finalise the volume if it has opened objects and not in the consistent state.
-         //-- Theoretically, we can finalise the mount if we have files opened only for read, but at present,
-         //-- it's impossible to detect such situation.
+    if(Locked())
+        {//-- can't finalise the volume if it has opened disk access objects, like Format or RawAccess
         User::Leave(KErrInUse);
         }
 
@@ -613,10 +611,23 @@
 */
 TBool CFatMountCB::VolCleanFlagSupported() const
     {
-        const TFatType fatType=FatType();
-
-        ASSERT(fatType == EFat12 || fatType == EFat16 || fatType == EFat32);
-        return (fatType != EFat12);
+    const TFatType fatType=FatType();
+
+    ASSERT(fatType == EFat12 || fatType == EFat16 || fatType == EFat32);
+    return (fatType != EFat12);
+    }
+
+
+//-----------------------------------------------------------------------------------------
+/**
+    @return Volume size in bytes according to the number of usable clusters.
+    This approach is not applicable to RAM drive, because its size isn't fixed and can be adjusted by the system.
+*/
+TUint64 CFatMountCB::VolumeSizeInBytes() const
+    {
+    ASSERT(ConsistentState());
+    ASSERT(!iRamDrive);
+    return ((TUint64)UsableClusters()) << ClusterSizeLog2();
     }
 
 //-----------------------------------------------------------------------------------------
@@ -681,16 +692,21 @@
 
 
     const TUint32 freeClusters = FAT().NumberOfFreeClusters(bSyncOp);
-
+    aVolume.iFree = (TInt64)freeClusters << ClusterSizeLog2();
     __PRINT1(_L("CFatMountCB::VolumeL() free clusters:%d"), freeClusters);
 
-    aVolume.iFree = (TInt64)freeClusters << ClusterSizeLog2();
-
-    if (drvInfo.iType==EMediaRam)
+
+    if(drvInfo.iType==EMediaRam)
+        {//-- a special case. RAM drive size is variable and adjustable. It should be calculated from aVolume.iFree and CMountCB::iFree
+        ASSERT(iRamDrive);
         aVolume.iSize=aVolume.iFree+iSize;
-
-    aVolume.iSize-=ClusterBasePosition(); // Allow for bytes used by FAT etc
-    aVolume.iSize=(aVolume.iSize >> ClusterSizeLog2()) << ClusterSizeLog2();  //-- round down to cluster size
+        aVolume.iSize-=ClusterBasePosition(); // Allow for bytes used by FAT etc
+        aVolume.iSize=(aVolume.iSize >> ClusterSizeLog2()) << ClusterSizeLog2();  //-- round down to cluster size
+        }
+    else
+        {//-- normal case; the volume size is determined by amount of usable clusters
+        aVolume.iSize = VolumeSizeInBytes();
+        }
 
     }
 
@@ -4277,7 +4293,7 @@
     TInt nRes;
 
     if(LockStatus()!=0)
-        {
+        {//-- can't run if the volume has opened objects, like files, directories, formats etc.
 		__PRINT(_L("CFatMountCB::ScanDrive() locked!\n"));
         return KErrInUse;
         }
--- a/userlibandfileserver/fileserver/sfat32/sl_mnt32.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfat32/sl_mnt32.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -218,8 +218,8 @@
 void CFatMountCB::SetVolumeCleanL(TBool aClean) 
     {
 
-	//-- The volume can't be set clean if there are objects opened on it. This precondition must be checked before calling this function
-    if(aClean && LockStatus()!=0)
+	//-- The volume can't be set clean if there are disk access objects opened on it. This precondition must be checked before calling this function
+    if(aClean && Locked())
         {
         __PRINT1(_L("#- CFatMountCB::SetVolumeCleanL drive:%d isn't free!"),DriveNumber());
         ASSERT(0);
@@ -935,12 +935,7 @@
             case ESQ_MountedVolumeSize:
                 {
                 TUint64* pVal = (TUint64*)aParam; 
-		*pVal = iSize; //-- physical drive size
-
-                //-- take into account space occupied by FAT table, etc.
-                *pVal -= ClusterBasePosition(); 
-                *pVal=(*pVal >> ClusterSizeLog2()) << ClusterSizeLog2();  //-- round down to cluster size
-
+                *pVal = VolumeSizeInBytes();
                 __PRINT1(_L("MountControl() MountedVolumeSize:%LU"), *pVal);
                 return KErrNone;
                 }
--- a/userlibandfileserver/fileserver/sfile/sf_debug.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_debug.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -18,7 +18,7 @@
 #include "sf_std.h"
 #include <f32dbg.h>
 #include "f32image.h"
-#include <F32plugin.h>
+#include <f32plugin.h>
 #include <filesystem_fat.h>
 #include "sf_file_cache.h"
 #include "sf_memory_man.h"
--- a/userlibandfileserver/fileserver/sfile/sf_dir.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_dir.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -116,7 +116,8 @@
 	CFsPlugin* plugin = NULL;
 	//Get the next plugin which is mounted on this drive (IsMounted called in NextPlugin)
 	//Do not check whether we're registered for current operation (in case not registered for EFsDirOpen)
-	while(FsPluginManager::NextPlugin(plugin,(CFsMessageRequest*)aRequest,(TBool)ETrue,(TBool)EFalse)==KErrNone && plugin)
+	FsPluginManager::ReadLockChain();                                      //!Check operation
+	while(FsPluginManager::NextPlugin(plugin,(CFsMessageRequest*)aRequest,(TBool)EFalse)==KErrNone && plugin)
 		{
 		if(plugin->IsRegistered(EFsDirReadOne) ||
 			plugin->IsRegistered(EFsDirReadPacked) ||
@@ -129,6 +130,7 @@
 			break;
 			}
 		}
+	FsPluginManager::UnlockChain();
 	
 	TPtrC8 pH((TUint8*)&h,sizeof(TInt));
 	TRAP(r,aRequest->WriteL(KMsgPtr3,pH))
--- a/userlibandfileserver/fileserver/sfile/sf_drv.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_drv.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -2173,8 +2173,9 @@
 
 
 /**
-Dismounts the current mount. This is method is called from outside, so do some finalisation work on mount.
+    Gracefully dismounts the current mount. This is method is called from outside, so do some finalisation work on mount.
 After calling this function there is no current mount on the drive.
+
 */
 EXPORT_C void TDrive::Dismount()
 	{
@@ -2184,10 +2185,12 @@
 	if (!iCurrentMount)
 		return;
 
+    //-- try to do the best flushing file caches
     TRAP_IGNORE(FlushCachedFileInfoL());
 
     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
-    TRAP_IGNORE(iCurrentMount->FinaliseMountL());
+    //-- finalise the mount in RO mode, we are dismounting the FS anyway
+    TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RO));
     
     DoDismount();
 	}
@@ -2196,8 +2199,7 @@
 
 
 /**
-Forcibly dismounts the current mount and prevents it being remounted.
-After calling this function there is no current mount on the drive.
+    Dismounts the current mount by force.
 */
 void TDrive::ForceDismount()
 	{
@@ -2209,7 +2211,15 @@
 		return;
   
 	TRAP_IGNORE(FlushCachedFileInfoL());
-	iCurrentMount->SetDismounted(); //! this affects TDrive::ReMount()
+
+    //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
+    //-- finalise the mount in RO mode, we are dismounting the FS anyway
+    TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RO));
+
+    //-- mark the mount as 'Dismounted'; this invalidates all object handles until the mount is successfully "remounted". 
+    //-- if there are still some objects opened on this mount, CMountCB::Close() won't destroy it until all objects are closed.
+    iCurrentMount->SetDismounted(); 
+    
     DoDismount();
 	}
 
--- a/userlibandfileserver/fileserver/sfile/sf_file.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_file.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -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_ops.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_ops.h	Wed Aug 18 11:08:29 2010 +0300
@@ -135,7 +135,7 @@
 		{	EFsAddPlugin,				ESync,					&TFsAddPlugin::Initialise,					NULL,								&TFsAddPlugin::DoRequestL					},
 		{	EFsRemovePlugin,			ESync,					&TFsRemovePlugin::Initialise,				NULL,								&TFsRemovePlugin::DoRequestL				},
 		{	EFsMountPlugin,				ESync,					&TFsMountPlugin::Initialise,				NULL,								&TFsMountPlugin::DoRequestL					},
-		{	EFsDismountPlugin,			0,						&TFsDismountPlugin::Initialise,				NULL,								&TFsDismountPlugin::DoRequestL				},
+		{	EFsDismountPlugin,			0, /*PluginThrdContxt*/	&TFsDismountPlugin::Initialise,				NULL,								&TFsDismountPlugin::DoRequestL				},
 		{	EFsPluginName,				ESync,					&TFsPluginName::Initialise,					NULL,								&TFsPluginName::DoRequestL					},
 		{	EFsPluginOpen,				ESync | EParseSrc,		&TFsPluginOpen::Initialise,					NULL,								&TFsPluginOpen::DoRequestL					},
 		{	EFsPluginSubClose,			ESync,					&TFsSubClose::Initialise,					NULL,								&TFsSubClose::DoRequestL					},
--- a/userlibandfileserver/fileserver/sfile/sf_plugin.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_plugin.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -247,9 +247,9 @@
 	}
 
 /**
-   Return ETrue if the calling thread is the plugin thread
+   Return ETrue if the request originated from this plugin
 */
-TBool CFsPlugin::IsPluginThread(CFsRequest& aRequest)
+TBool CFsPlugin::OriginatedFromPlugin(CFsRequest& aRequest)
 	{
 	if(aRequest.iOwnerPlugin == this)
 		return ETrue;
@@ -361,9 +361,11 @@
 
 
 	CFsPlugin* plugin = this;
-	FsPluginManager::NextPlugin(plugin, &msgRequest,(TBool)ETrue);
+	FsPluginManager::ReadLockChain();
+	FsPluginManager::NextPlugin(plugin, &msgRequest);
 	msgRequest.iCurrentPlugin = plugin;
 	msgRequest.Dispatch();
+	FsPluginManager::UnlockChain();
 	iThreadP->OperationLockWait();
 
 	aDes.SetLength(len);
--- a/userlibandfileserver/fileserver/sfile/sf_plugin.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_plugin.h	Wed Aug 18 11:08:29 2010 +0300
@@ -21,7 +21,7 @@
 
 #include "message.h"
 #include <f32fsys.h>
-#include <F32plugin.h>
+#include <f32plugin.h>
 
 class CFsSyncMessageScheduler;
 class CFsInternalRequest;
@@ -60,8 +60,8 @@
 	static TInt InstallPluginFactory(CFsPluginFactory* aFactory,RLibrary aLib);
 	static CFsPluginFactory* GetPluginFactory(const TDesC& aName);
 
-	static TInt NextPlugin(CFsPlugin*& aPlugin, CFsMessageRequest* aMsgRequest, TBool aLock, TBool aCheckCurrentOperation=ETrue);
-	static TInt PrevPlugin(CFsPlugin*& aPlugin, CFsMessageRequest* aMsgRequest, TBool aLock);
+	static TInt NextPlugin(CFsPlugin*& aPlugin, CFsMessageRequest* aMsgRequest, TBool aCheckCurrentOperation=ETrue);
+	static TInt PrevPlugin(CFsPlugin*& aPlugin, CFsMessageRequest* aMsgRequest);
 	static TInt InsertInPluginStack(CFsPlugin*& aPlugin,TInt aPos);
 	static TInt IsInChain(TInt aUPos, TInt aPos,TInt aDrive, CFsPluginFactory* aPluginFactory);
 	static CFsPlugin* FindByUniquePosition(TInt aPos);
@@ -72,7 +72,8 @@
 	static TInt ChainCount();
 	static TInt Plugin(CFsPlugin*& aPlugin, TInt aPos);
 
-	static void LockChain();
+	static void ReadLockChain();
+	static void WriteLockChain();
 	static void UnlockChain();
 
 	static CFsPluginConn* CreatePluginConnL(TInt aUniquePosition, TUint aClientId);
@@ -91,7 +92,7 @@
 	static CFsObjectCon* iPluginConns;
 
 	static RPointerArray<CFsPlugin> iPluginChain;
-	static RFastLock iChainLock;
+	static RReadWriteLock iChainLock;
 
 	static CFsSyncMessageScheduler* iScheduler;
 
--- a/userlibandfileserver/fileserver/sfile/sf_plugin_man.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_plugin_man.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -21,7 +21,7 @@
 
 CFsObjectCon* FsPluginManager::iPluginFactories = NULL;
 CFsObjectCon* FsPluginManager::iPluginConns     = NULL;
-RFastLock FsPluginManager::iChainLock;
+RReadWriteLock FsPluginManager::iChainLock;
 RPointerArray<CFsPlugin> FsPluginManager::iPluginChain;
 CFsSyncMessageScheduler* FsPluginManager::iScheduler = NULL;
 
@@ -153,7 +153,7 @@
 		return err;
 		}
 
-	LockChain();
+	WriteLockChain();
 	err = InsertInPluginStack(pP,aPos);
 	UnlockChain();
 	if(err != KErrNone)
@@ -235,7 +235,7 @@
 Transfer any outstanding requests to next/previous plugin depending on
 if it is post filter or not
 
-Must be called with the plugin chain locked.
+Must be called with the plugin chain write-locked.
 Attains plugin-thread's listlock.
 */
 void FsPluginManager::TransferRequests(CPluginThread* aPluginThread)
@@ -315,12 +315,12 @@
 	        if(pR->IsPostOperation())
 	            {
 	            //[set the plugin to] pass the request backwards in the chain
-	            PrevPlugin(pR->iCurrentPlugin, &mR, EFalse);
+	            PrevPlugin(pR->iCurrentPlugin, &mR);
 	            }
 	        else //IsPreOperations
 	            {
 	            //[set the plugin to] pass the request forwards in the chain
-	            NextPlugin(pR->iCurrentPlugin, &mR, EFalse);
+	            NextPlugin(pR->iCurrentPlugin, &mR);
 	            }
 
 	        if(pR->iCurrentPlugin)
@@ -386,19 +386,18 @@
 /**
 Find the next plugin that supports the operation
 
+Must be called with the plugin chain (at least read-) locked.
+
 @param aPlugin - On calling the function this may contain either NULL or the current plugin.
                  If it is called with NULL, then we start to look for plugins from the beginning of the chain.
                  If is is called with a plugin then we start to look after that plugin for the next one.
                  On return, aPlugin shall contain either a plugin or NULL.
                  
-@param aLock - If this is set to ETRUE, then the function shall lock the plugin chain.
-               If this is set to EFALSE, then the caller of the function MUST already hold the lock.
-
 @param aCheckCurrentOperation - Optional, if false, will return the next plugin,
  								whether the plugin is currently registered
 								for the current function or not. (so long as mounted on the current drive)
 */
-TInt FsPluginManager::NextPlugin(CFsPlugin*& aPlugin, CFsMessageRequest* aMsgRequest,TBool aLock, TBool aCheckCurrentOperation)
+TInt FsPluginManager::NextPlugin(CFsPlugin*& aPlugin, CFsMessageRequest* aMsgRequest, TBool aCheckCurrentOperation)
 	{
 	if(aMsgRequest->DirectToDrive())
 		{
@@ -410,9 +409,6 @@
 	TInt function = aMsgRequest->Operation()->Function();
 	TInt drive = aMsgRequest->DriveNumber();
 
-	if(aLock)
-	    LockChain();
-	
 	//the plugin chain lock must be held by this point.
 	TInt count = iPluginChain.Count();
 
@@ -431,25 +427,22 @@
 					{
 
 					aPlugin = iPluginChain[i];
-					if(aLock)
-					    UnlockChain();
 					return KErrNone;
 					}
 				}
 			}
 		}
 	aPlugin = NULL;
-	if(aLock)
-	    UnlockChain();
 	return KErrNotFound;
 	}
 
 /**
 Find the next plugin that supports the operation
+Must be called with the plugin chain (at least read-) locked.
 
 @see FsPluginManager::NextPlugin
 */
-TInt FsPluginManager::PrevPlugin(CFsPlugin*& aPlugin, CFsMessageRequest* aMsgRequest, TBool aLock)
+TInt FsPluginManager::PrevPlugin(CFsPlugin*& aPlugin, CFsMessageRequest* aMsgRequest)
 	{
 	if(aMsgRequest->DirectToDrive() && (aMsgRequest->CurrentOperationPtr() != NULL))
 		{
@@ -460,9 +453,6 @@
 	TInt start;
 	TInt function = aMsgRequest->Operation()->Function();
 	TInt drive = aMsgRequest->DriveNumber();
-
-	if(aLock)
-	    LockChain();
 	
 	//the plugin chain lock must be held by this point.
 	TInt count= iPluginChain.Count();
@@ -486,16 +476,12 @@
 					{
 
 					aPlugin = iPluginChain[i];
-					if(aLock)
-					    UnlockChain();
 					return KErrNone;
 					}
 				}
 			}
 		}
 	aPlugin = NULL;
-	if(aLock)
-	    UnlockChain();
 	return KErrNotFound;
 	}
 /**
@@ -584,7 +570,7 @@
 */
 CFsPlugin* FsPluginManager::FindByUniquePosition(TInt aUniquePosition)
 	{
-	LockChain();
+	ReadLockChain();
 	CFsPlugin* plugin = NULL;
 	TInt count= iPluginChain.Count();
 	for(TInt i=0;i<count;i++)
@@ -671,19 +657,27 @@
 	}
 
 /**
-Locks the chain
+Locks the chain for reading
 */
-void FsPluginManager::LockChain()
+void FsPluginManager::ReadLockChain()
 	{
-	iChainLock.Wait();
+    iChainLock.ReadLock();
 	}
 
 /**
+Locks the chain for writing
+*/
+void FsPluginManager::WriteLockChain()
+    {
+    iChainLock.WriteLock();
+    }
+
+/**
 Unlocks the chain
 */
 void FsPluginManager::UnlockChain()
 	{
-	iChainLock.Signal();
+    iChainLock.Unlock();
 	}
 
 /**
@@ -743,7 +737,7 @@
 	// Iterate through all plugins, cancelling outstanding session requests
 	aRequest->Set(CancelPluginOp, aSession);
 
-	FsPluginManager::LockChain();
+	FsPluginManager::ReadLockChain();
 	TInt count = FsPluginManager::ChainCount();
 	TInt oldCount = count;
 	TInt i;
@@ -759,7 +753,7 @@
 	    //so hopefully this wont take too long.
 	    FsPluginManager::UnlockChain();
 	    User::WaitForRequest(aRequest->Status());
-	    FsPluginManager::LockChain();
+	    FsPluginManager::ReadLockChain();
 	    __ASSERT_ALWAYS(aRequest->Status().Int()==KErrNone||aRequest->Status().Int()==KErrCancel,Fault(ESessionDisconnectThread2));
 	    count = FsPluginManager::ChainCount();
 	    //If a plugin was removed whilst the chain was unlocked we need to make sure we don't skip any plugins
--- a/userlibandfileserver/fileserver/sfile/sf_plugin_ops.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_plugin_ops.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -153,7 +153,7 @@
 	if(pF->IsDriveSupported(drive) == EFalse)
 		return KErrNotSupported;
 
-	FsPluginManager::LockChain();
+	FsPluginManager::ReadLockChain();
 	err = FsPluginManager::IsInChain(pF->UniquePosition(),aRequest->Message().Int2(),aRequest->Message().Int1(), pF);
 
 	// plugin might have been mounted in different pos and drive. Find the right one
@@ -209,7 +209,7 @@
 
 	TInt drive = aRequest->Message().Int1();
 
-	FsPluginManager::LockChain();
+	FsPluginManager::WriteLockChain();
 
 	TInt err = FsPluginManager::IsInChain(pF->UniquePosition(),aRequest->Message().Int2(),drive, pF);
 	if(err >= 0)
@@ -219,11 +219,8 @@
 		err = FsPluginManager::Plugin(plugin, pos);
 		if(err == KErrNone)
 			{
-			if(aRequest->iCurrentPlugin == plugin)
-				{
-				FsPluginManager::DismountPlugin(*pF,pos);
-				aRequest->SetScratchValue(0);
-				}
+			FsPluginManager::DismountPlugin(*pF,pos);
+			aRequest->SetScratchValue(0);
 			}
 		}
 	FsPluginManager::UnlockChain();
@@ -250,7 +247,7 @@
 TInt TFsPluginName::DoRequestL(CFsRequest* aRequest)
 	{
 	CFsPlugin* plugin=NULL;
-	FsPluginManager::LockChain();
+	FsPluginManager::ReadLockChain();
 	TInt err = FsPluginManager::Plugin(plugin, aRequest->Message().Int2());
 	if(err != KErrNone) //should be ok but just in case
 	    {
--- a/userlibandfileserver/fileserver/sfile/sf_request.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_request.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -974,7 +974,7 @@
 //
 	{
 	TInt err = KErrNone;
-	if(!iCurrentPlugin->IsPluginThread(*this))
+	if(!iCurrentPlugin->OriginatedFromPlugin(*this))
 		{
 		// The request hasn't come from this plugin so it's safe to dispatch		
 		TFsPluginRequest request(this);
@@ -997,14 +997,17 @@
 	
 	// Find the previous plugin in the chain and dispatch
 	//  - If no more plugins are interested in this message, then complete
-	FsPluginManager::PrevPlugin(iCurrentPlugin, this, ETrue);
+	FsPluginManager::ReadLockChain();
+	FsPluginManager::PrevPlugin(iCurrentPlugin, this);
 	if(iCurrentPlugin == NULL)
 		{
+	    FsPluginManager::UnlockChain();
 		Complete(GetError());
 		return;
 		}
 
 	Dispatch();
+	FsPluginManager::UnlockChain();
 	return;
 	}
 	
@@ -1015,7 +1018,7 @@
 //
 	{
 	TInt err = KErrNone;
-	if(!iCurrentPlugin->IsPluginThread(*this))
+	if(!iCurrentPlugin->OriginatedFromPlugin(*this))
 		{
 		// The request hasn't come from this plugin so it's safe to dispatch		
 		TFsPluginRequest request(this);		
@@ -1024,7 +1027,7 @@
 
 		if((iOperation->Function() == EFsDismountPlugin) && (err !=  KErrPermissionDenied))
 			{
-			TRAP(leaveValue, err = iOperation->DoRequestL(this));
+		    err = KErrNone;
 			}
 
 		if(leaveValue != KErrNone)
@@ -1042,10 +1045,12 @@
 		// Find the next plugin in the chain and dispatch
 		//  - If no more plugins are interested in this message, 
 		//	  then Dispatch() will process the request in drive/main thread context.
-		FsPluginManager::NextPlugin(iCurrentPlugin, this,(TBool)ETrue);
+	    FsPluginManager::ReadLockChain();
+		FsPluginManager::NextPlugin(iCurrentPlugin, this);
 		if(iCurrentPlugin && IsPostOperation())
 			SetPostOperation(EFalse);
 		Dispatch();
+		FsPluginManager::UnlockChain();
 		return;
 		}
 	// KErrCompletion may be returned by the plugin to 
@@ -1054,18 +1059,21 @@
 		{
 		// Find the previous plugin in the chain and dispatch
 		//  - If no more plugins are interested in this message, then complete
-		FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue);
+	    FsPluginManager::ReadLockChain();
+		FsPluginManager::PrevPlugin(iCurrentPlugin, this);
 		if(iCurrentPlugin != NULL)
 			{
 			SetPostOperation(ETrue);
 			err = KErrNone;
 			Dispatch();
+			FsPluginManager::UnlockChain();
 			return;
 			}
 		else
 			{
 			err = KErrNone;	
 			}
+		FsPluginManager::UnlockChain();
 		}
 		
 	Complete(err);
@@ -1116,19 +1124,26 @@
 		}
 
 	SetError(err);
-
+	
+    if (IsExpectedResult(err) && !IsPluginSpecific() && !IsNotifierSpecific())
+        DoNotifyDiskSpace(KErrNone);
 
 	// Start issuing the post-operation requests starting from the bottom of the chain
 	iCurrentPlugin = NULL;
 	if (PostInterceptEnabled())
 		{
-		FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue);
-		if(iCurrentPlugin && !iCurrentPlugin->IsPluginThread(*this))
+	    FsPluginManager::ReadLockChain();
+		FsPluginManager::PrevPlugin(iCurrentPlugin, this);
+		if(iCurrentPlugin && !iCurrentPlugin->OriginatedFromPlugin(*this))
 			{
 			SetPostOperation(ETrue);
 			if (DispatchToPlugin())
+			    {
+		        FsPluginManager::UnlockChain();  
 				return;
+			    }
 			}
+		FsPluginManager::UnlockChain();		
 		}		
 
 	Complete(GetError());
@@ -1142,16 +1157,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 +1303,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 +1340,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()
 //
@@ -1409,13 +1422,16 @@
 		iCurrentPlugin = NULL;
 		if (PostInterceptEnabled())
 			{
-			FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue);
-			if(iCurrentPlugin && !iCurrentPlugin->IsPluginThread(*this))
+		    FsPluginManager::ReadLockChain();
+			FsPluginManager::PrevPlugin(iCurrentPlugin, this);
+			if(iCurrentPlugin && !iCurrentPlugin->OriginatedFromPlugin(*this))
 				{
 				SetPostOperation(ETrue);
 				Dispatch();
+				FsPluginManager::UnlockChain();
 				return r;	// EReqActionComplete
 				}
+			FsPluginManager::UnlockChain();
 			}		
 
 		Complete(KErrNone);
@@ -1443,6 +1459,7 @@
 	__THRD_PRINT1(_L("CFsMessageRequest::Dispatch() req %08x"), this);
 
 	TInt r = KErrNone;
+	TBool pluginChainLocked = EFalse;
 
 	if (iReqState == EReqStateInitialise && aInitialise)
 		{
@@ -1462,16 +1479,18 @@
 			}
 		if(!IsPluginSpecific() && (iOwnerPlugin == NULL))
 			{
+		    FsPluginManager::ReadLockChain(); // Unlocked in DispatchToPlugin
+		    pluginChainLocked = ETrue;
 			iCurrentPlugin = NULL;
 			iClientThreadId = 0;
-			FsPluginManager::NextPlugin(iCurrentPlugin, this, (TBool)ETrue);
+			FsPluginManager::NextPlugin(iCurrentPlugin, this);
 
 			// find out whether there is a plugin registered to post intercept this message
 			CFsPlugin* postInterceptPlugin = NULL;
 			if (iCurrentPlugin == NULL)
-				FsPluginManager::PrevPlugin(postInterceptPlugin, this, (TBool)ETrue);
+				FsPluginManager::PrevPlugin(postInterceptPlugin, this);
 
-			// Save the client's thread Id for subsequent testing by CFsPlugin::IsPluginThread() - doing so on the fly 
+			// Save the client's thread Id for subsequent testing by CFsPlugin::OriginatedFromPlugin() - doing so on the fly 
 			// is risky because some messages are completed early in which case Message().Client() will result in a panic
 			if ((iCurrentPlugin || postInterceptPlugin) && Message().Handle() != NULL && Message().Handle() != KLocalMessageHandle)
 				{
@@ -1490,16 +1509,23 @@
 		__PLUGIN_PRINT1(_L("PLUGIN: CFsMessageRequest %x dispatched to plugin (async)"), this);
 		// The request has been delivered to the plugin thread
 		//  - leave the main thread now and await asynchronous completion
+		if(pluginChainLocked)
+		    FsPluginManager::UnlockChain();
 		return;
 		}
 
+	//DispatchToPlugin didn't (deliver then unlock) so make sure we unlock here.
+    if(pluginChainLocked)
+        FsPluginManager::UnlockChain();
 
 	// Is there a PostInitialise function ?
 	if (iReqState ==  EReqStatePostInitialise && aInitialise && r == KErrNone)
 		{
 		TInt r = PostInitialise();
 		if (r == EReqActionComplete)
+		    {
 			return;
+		    }
 		else if (r == EReqActionBusy)				// request postponed ?
 			SetState(EReqStatePostInitialise);		// reinitialize when request is next processed
 		}
@@ -1559,6 +1585,7 @@
 //
 // Common route: Receive -> Process -> Dispatch -> DispatchToPlugin
 //
+// (Is called with FsPluginManager ReadLocked)
 	{
 	TInt drivenumber = DriveNumber();
 	if(iCurrentPlugin)
@@ -1572,16 +1599,16 @@
 				iCurrentPlugin = NULL;
 				}
 
-			while(iCurrentPlugin && iCurrentPlugin->IsPluginThread(*this))
+			while(iCurrentPlugin && iCurrentPlugin->OriginatedFromPlugin(*this))
 				{
 				// Skip the current plugin if the request originated from the plugin
 				if(IsPostOperation())
 					{
-					FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue);
+					FsPluginManager::PrevPlugin(iCurrentPlugin, this);
 					}
 				else
 					{
-					FsPluginManager::NextPlugin(iCurrentPlugin, this,(TBool)ETrue);
+					FsPluginManager::NextPlugin(iCurrentPlugin, this);
 					}
 				}
 				
@@ -1611,7 +1638,7 @@
 					//  - Pass the message on to the next plugin
 					if(FsFunction() != EFsPluginOpen)
 					    {
-	                    FsPluginManager::NextPlugin(iCurrentPlugin, this,(TBool)ETrue);
+	                    FsPluginManager::NextPlugin(iCurrentPlugin, this);
 	                    continue;
 					    }
 					else // FsFunction == EFsPluginOpen
@@ -1619,7 +1646,6 @@
 					    /* 
 					     * PluginOpen requests should not be passed down the plugin stack.
 					     * 
-
 					     */
 					    iCurrentPlugin = NULL;
 					    continue;
@@ -1630,7 +1656,7 @@
 					// The plugin has processed synchronously (case 2)
 					//  - Pass the message back up the stack
 					SetPostOperation(ETrue);
-					FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue);
+					FsPluginManager::PrevPlugin(iCurrentPlugin, this);
 					continue;
 					}
 				_LIT(KPanic,"Panic: F32-BAD-PLUGIN-ERROR");
@@ -1652,13 +1678,17 @@
 			}			
 		}
 
+	/*
+	 * Special case- DismountPlugin runs in the context of the plugin thread
+	 */
 	if(iOperation->Function() == EFsDismountPlugin)
 		{
 		// Don't pass plugin dismounts to the drive thread
+	    FsPluginManager::UnlockChain();
 		Process();
+		FsPluginManager::ReadLockChain(); //inverted unlock/lock to get around dismount plugin being a special case
 		return(ETrue);
 		}
-		
 	return EFalse;
 	}
 
--- a/userlibandfileserver/fileserver/sfile/sf_std.h	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_std.h	Wed Aug 18 11:08:29 2010 +0300
@@ -1320,6 +1320,7 @@
    // TUid iUID;
 private:
 	void DoNotify(TInt aError);
+	void DoNotifyDiskSpace(TInt aError);
 	TInt DoInitialise();
 	TInt PostInitialise();
 	TBool DispatchToPlugin();
--- a/userlibandfileserver/fileserver/sfile/sf_utl.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_utl.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -613,9 +613,11 @@
 	}
 
 
-//
-// Returns ETrue if aDes only contains spaces or is zero length
-//
+
+/**
+    @return ETrue if aDes only contains spaces or is zero length
+    Note that _all_ UNICODE space characters are treated as usual spaces
+*/
 static TBool IsSpace(const TDesC& aDes)
 	{
 
@@ -890,38 +892,43 @@
 	return powerGood;
 	}
 
+//---------------------------------------------------------------------------------------------------------------------------------
+/**
+    Decrement mount's lock counter when the mount resource, like a file or directory is opened. 
+    See also: CMountCB::LockStatus()   
+*/
 void AddResource(CMountCB& aMount)
-//
-// Decrement resource counters
-//
 	{
 	__CHECK_DRIVETHREAD(aMount.Drive().DriveNumber());
 	__ASSERT_DEBUG(aMount.LockStatus()<=0,Fault(ERawDiskBadAccessCount2));
 	aMount.DecLock();
 	}
 
+/**
+    Increment mount's lock counter when the mount resource, like a file or directory is closed. 
+    See also: CMountCB::LockStatus()   
+*/
 void RemoveResource(CMountCB& aMount)
-//
-// Increment resource counters
-//
 	{
 	__ASSERT_DEBUG(aMount.LockStatus()<0,Fault(ERawDiskBadAccessCount1));
 	aMount.IncLock();
 	}
 
 
+/**
+    Increment mount's lock counter when the disk access (Format, Raw disk) is opened on the mount
+    See also: CMountCB::LockStatus()   
+*/
 void AddDiskAccess(CMountCB& aMount)
-//
-// Increment resource counters
-//
 	{
 	aMount.IncLock();
 	}
 
+/**
+    Decrement mount's lock counter when the disk access (Format, Raw disk) is closed on the mount
+    See also: CMountCB::LockStatus()   
+*/
 void RemoveDiskAccess(CMountCB& aMount)
-//
-// Decrement resource counters
-//
 	{
 	aMount.DecLock();
 	}
--- a/userlibandfileserver/fileserver/sfsrv/cl_cli.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfsrv/cl_cli.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -3259,7 +3259,7 @@
 
     @return KErrNone on success,
             KErrArgument if the function arguments are invalid
-            KErrInUse    if the drive has opened objects (files, directories etc.) and therefore can not be finalised
+            KErrInUse    if the drive has opened disk access objects (format, raw disk access, etc) and therefore can not be finalised
             KErrCorrupt  if the drive is corrupt.
             System wide error codes otherwise.
 
--- a/userlibandfileserver/fileserver/sfsrv/cl_fman.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfsrv/cl_fman.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -1926,15 +1926,6 @@
 	return(KErrNone);
 	}
 
-TInt CFileMan::RenameInvalidEntry(const TDesC& /*aName*/,const TDesC& /*aNewName*/,TUint /*aSwitches*/)
-//
-// Start rename operation
-//
-	{
-	return KErrNotSupported;
-	}
-
-
 
 
 EXPORT_C TInt CFileMan::Rename(const TDesC& aName,const TDesC& aNewName,TUint aSwitches,TRequestStatus& aStatus)
--- a/userlibandfileserver/fileserver/sfsrv/cl_scan.cpp	Tue Jul 06 15:50:07 2010 +0300
+++ b/userlibandfileserver/fileserver/sfsrv/cl_scan.cpp	Wed Aug 18 11:08:29 2010 +0300
@@ -411,7 +411,7 @@
 	TInt r;
 	aDirEntries=NULL;
 	
-	if(iStack && iStack->IsEmpty())
+	if(iStack->IsEmpty())
 	    return;
 	
 	CDirList* list=iStack->Peek();