201031_08
authorhgs
Thu, 12 Aug 2010 11:55:14 +0100
changeset 244 a77889bee936
parent 243 c7a0ce20c48c
child 245 647ab20fee2e
201031_08
kernel/eka/drivers/locmedia/locmedia.cpp
kernel/eka/drivers/medmmc/medmmc.cpp
kernel/eka/drivers/pbus/mmc/sdcard/bmarm/sdcard3c/epbusmu.def
kernel/eka/drivers/pbus/mmc/sdcard/bmarm/sdcard3c/sdio/epbusmu.def
kernel/eka/drivers/pbus/mmc/sdcard/bwins/sdcard3c/epbusmu.def
kernel/eka/drivers/pbus/mmc/sdcard/bwins/sdcard3c/sdio/epbusmu.def
kernel/eka/drivers/pbus/mmc/sdcard/bx86/sdcard3c/epbusmu.def
kernel/eka/drivers/pbus/mmc/sdcard/bx86/sdcard3c/sdio/epbusmu.def
kernel/eka/drivers/pbus/mmc/sdcard/eabi/sdcard3c/epbusmu.def
kernel/eka/drivers/pbus/mmc/sdcard/eabi/sdcard3c/sdio/epbusmu.def
kernel/eka/drivers/pbus/mmc/sdcard/sdcard3c/sdcard.cpp
kernel/eka/drivers/pbus/mmc/sdcard/sdcard3c/sdio/sdiostack.cpp
kernel/eka/drivers/pbus/mmc/session.cpp
kernel/eka/drivers/pbus/mmc/stack.cpp
kernel/eka/drivers/resmanus/d_resmanus.cpp
kernel/eka/drivers/resourceman/rescontrol_export.cpp
kernel/eka/drivers/resourceman/resourcecontrol.cpp
kernel/eka/drivers/resourceman/resourcecontrol_extended.cpp
kernel/eka/include/drivers/mmc.h
kernel/eka/include/drivers/mmc.inl
kernel/eka/include/drivers/resmanus.h
kernel/eka/include/drivers/resource.h
kernel/eka/include/drivers/resourcecontrol.h
kernel/eka/include/drivers/resourcecontrol.inl
kernel/eka/include/drivers/sdcard.h
kernel/eka/include/kernel/kpower.h
kernel/eka/kernel/power.cpp
kernel/eka/release.txt
kerneltest/e32test/group/bld.inf
kerneltest/e32test/group/rescontrol_extended_psl.mmp
kerneltest/e32test/group/rescontrol_psl.mmp
kerneltest/e32test/mediaext/d_nfe.cpp
kerneltest/e32test/mediaext/t_nfe.cpp
kerneltest/e32test/mmu/t_shadow.cpp
kerneltest/e32test/resmanus/resourcecontrol.mmp
kerneltest/e32test/resmanus/resourcecontrollerextended.mmp
kerneltest/e32test/resmanus/t_resmanus.cpp
kerneltest/e32test/resmanus/t_resmanus.mmp
kerneltest/e32test/resmanus/t_resmanusextended.mmp
kerneltest/e32test/resmanus/t_resmanuskern.mmp
kerneltest/e32test/resourceman/d_rescontrolcli.cpp
kerneltest/e32test/resourceman/resourceman_psl/rescontrol_extended_psl.cpp
kerneltest/e32test/resourceman/resourceman_psl/rescontrol_psl.cpp
kerneltest/e32test/resourceman/resourceman_psl/rescontrol_psl.h
kerneltest/e32test/resourceman/t_rescontrolcli.cpp
kerneltest/f32test/fileutils/inc/f32_test_utils.h
kerneltest/f32test/fileutils/src/f32_test_utils.cpp
kerneltest/f32test/group/bld.inf
kerneltest/f32test/server/t_file.cpp
kerneltest/f32test/server/t_fman.cpp
kerneltest/f32test/server/t_pwstr.cpp
kerneltest/f32test/server/t_sysbin.cpp
userlibandfileserver/fileserver/group/release.txt
userlibandfileserver/fileserver/sfat32/sl_mnt.cpp
userlibandfileserver/fileserver/sfile/sf_drv.cpp
userlibandfileserver/fileserver/sfile/sf_file.cpp
userlibandfileserver/fileserver/sfile/sf_std.h
userlibandfileserver/fileserver/swins/elocal.cpp
--- a/kernel/eka/drivers/locmedia/locmedia.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/locmedia/locmedia.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -2654,7 +2654,7 @@
 		}
 
 	__KTRACE_OPT(KFAIL,Kern::Printf("mdrq %d",m.Id()));
-	__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::HandleMsg state %d req %d",iMediaId,iState,m.Id()));
+	__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::HandleMsg(%08X) state %d req %d",iMediaId,&m,iState,m.Id()));
 
 	OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_HANDLEMSG2, "iMediaId=%d; iState=%d; req Id=%d", iMediaId, iState, m.Id());
 	
@@ -2754,7 +2754,7 @@
 */
 	{
 	OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DOREQUEST_ENTRY, this );
-	__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DPrimaryMediaBase::DoRequest %d",m.Id()));
+	__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DPrimaryMediaBase(%d)::DoRequest(%08X) req %d", iMediaId, &m, m.Id()));
 	TLocDrv* pL=m.Drive();
 	DMedia* media=pL->iMedia;
 	TInt r=KErrNone;
@@ -3138,11 +3138,16 @@
 #ifdef __DEMAND_PAGING__
 			if (DataPagingMedia(this))
 				{
-				__KTRACE_OPT(KLOCDRV,Kern::Printf("DoPartitionInfoComplete(%d) Close Media Driver aborted for data paging media %08X", this));
+				__KTRACE_OPT(KLOCDRV,Kern::Printf("DoPartitionInfoComplete() Close Media Driver aborted for data paging media %08X", this));
 				OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE2, "Close Media Driver for data paging media 0x%08x", this);
 				}
 			else
 #endif
+			if (iBody->iMediaExtension)
+				{
+				__KTRACE_OPT(KLOCDRV,Kern::Printf("DoPartitionInfoComplete() Close Media Driver aborted for extension media %08X", this));
+				}
+			else
 				{
 				pM->iDriver->Close();
 				pM->iDriver=NULL;
@@ -3299,6 +3304,10 @@
 	{
 	OstTraceFunctionEntry1( DPRIMARYMEDIABASE_COMPLETEREQUEST_ENTRY, this );
 	OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_COMPLETEREQUEST1, "TLocDrvRequest Object=0x%x; aResult=%d", (TUint) &aMsg, aResult);
+
+
+	__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::CompleteRequest(%08x) r %d",iMediaId,&aMsg, aResult));
+
 	aMsg.Complete(aResult,EFalse);
 	OstTraceFunctionExit1( DPRIMARYMEDIABASE_COMPLETEREQUEST_EXIT, this );
 	}
--- a/kernel/eka/drivers/medmmc/medmmc.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/medmmc/medmmc.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -2726,6 +2726,9 @@
 	iMedReq = aRequest;
 	SetCurrentConsumption(aCurrent);
 
+	// Reset the card pointer just in case the stack has changed it.
+	iSession->SetCard(iCard);
+
 	TInt r = InCritical();
 	if (r == KErrNone)
 		{
--- a/kernel/eka/drivers/pbus/mmc/sdcard/bmarm/sdcard3c/epbusmu.def	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/bmarm/sdcard3c/epbusmu.def	Thu Aug 12 11:55:14 2010 +0100
@@ -106,7 +106,7 @@
 	DeclareCardAsGone__12TSDCardArrayUi @ 105 NONAME R3UNUSED ; TSDCardArray::DeclareCardAsGone(unsigned int)
 	Dummy1__8DSDStack @ 106 NONAME R3UNUSED ; DSDStack::Dummy1(void)
 	Dummy2__8DSDStack @ 107 NONAME R3UNUSED ; DSDStack::Dummy2(void)
-	Dummy3__8DSDStack @ 108 NONAME R3UNUSED ; DSDStack::Dummy3(void)
+	GetInterface__8DSDStackQ29DMMCStack12TInterfaceIdRPQ29DMMCStack10MInterface @ 108  NONAME R3UNUSED ; DSDStack::GetInterface(DMMCStack::TInterfaceId, DMMCStack::MInterface *&)
 	CardType__8DSDStackii @ 109 NONAME R3UNUSED ; DSDStack::CardType(int, int)
 	InitStackAfterUnlockSM__8DSDStack @ 110 NONAME R3UNUSED ; DSDStack::InitStackAfterUnlockSM(void)
 	Init__8DSDStack @ 111 NONAME R3UNUSED ; DSDStack::Init(void)
--- a/kernel/eka/drivers/pbus/mmc/sdcard/bmarm/sdcard3c/sdio/epbusmu.def	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/bmarm/sdcard3c/sdio/epbusmu.def	Thu Aug 12 11:55:14 2010 +0100
@@ -106,7 +106,7 @@
 	DeclareCardAsGone__12TSDCardArrayUi @ 105 NONAME R3UNUSED ; TSDCardArray::DeclareCardAsGone(unsigned int)
 	Dummy1__8DSDStack @ 106 NONAME R3UNUSED ; DSDStack::Dummy1(void)
 	Dummy2__8DSDStack @ 107 NONAME R3UNUSED ; DSDStack::Dummy2(void)
-	Dummy3__8DSDStack @ 108 NONAME R3UNUSED ; DSDStack::Dummy3(void)
+	GetInterface__8DSDStackQ29DMMCStack12TInterfaceIdRPQ29DMMCStack10MInterface @ 108  NONAME R3UNUSED ; DSDStack::GetInterface(DMMCStack::TInterfaceId, DMMCStack::MInterface *&)
 	CardType__8DSDStackii @ 109 NONAME R3UNUSED ; DSDStack::CardType(int, int)
 	InitStackAfterUnlockSM__8DSDStack @ 110 NONAME R3UNUSED ; DSDStack::InitStackAfterUnlockSM(void)
 	Init__8DSDStack @ 111 NONAME R3UNUSED ; DSDStack::Init(void)
--- a/kernel/eka/drivers/pbus/mmc/sdcard/bwins/sdcard3c/epbusmu.def	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/bwins/sdcard3c/epbusmu.def	Thu Aug 12 11:55:14 2010 +0100
@@ -107,7 +107,7 @@
 	?DeclareCardAsGone@TSDCardArray@@UAEXI@Z @ 106 NONAME ; public: virtual void __thiscall TSDCardArray::DeclareCardAsGone(unsigned int)
 	?Dummy1@DSDStack@@EAEXXZ @ 107 NONAME ; private: virtual void __thiscall DSDStack::Dummy1(void)
 	?Dummy2@DSDStack@@EAEXXZ @ 108 NONAME ; private: virtual void __thiscall DSDStack::Dummy2(void)
-	?Dummy3@DSDStack@@EAEXXZ @ 109 NONAME ; private: virtual void __thiscall DSDStack::Dummy3(void)
+	?GetInterface@DSDStack@@MAEXW4TInterfaceId@DMMCStack@@AAPAVMInterface@3@@Z @ 109  NONAME ; protected: virtual void __thiscall DSDStack::GetInterface(enum DMMCStack::TInterfaceId,class DMMCStack::MInterface * &)
 	?CardType@DSDStack@@UAE?AW4TSDCardType@1@HH@Z @ 110 NONAME ; public: virtual enum DSDStack::TSDCardType __thiscall DSDStack::CardType(int,int)
 	?Init@DSDStack@@UAEHXZ @ 111 NONAME ; public: virtual int __thiscall DSDStack::Init(void)
 	?InitStackAfterUnlockSM@DSDStack@@MAEKXZ @ 112 NONAME ; protected: virtual unsigned long __thiscall DSDStack::InitStackAfterUnlockSM(void)
--- a/kernel/eka/drivers/pbus/mmc/sdcard/bwins/sdcard3c/sdio/epbusmu.def	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/bwins/sdcard3c/sdio/epbusmu.def	Thu Aug 12 11:55:14 2010 +0100
@@ -107,7 +107,7 @@
 	?DeclareCardAsGone@TSDCardArray@@UAEXI@Z @ 106 NONAME ; public: virtual void __thiscall TSDCardArray::DeclareCardAsGone(unsigned int)
 	?Dummy1@DSDStack@@EAEXXZ @ 107 NONAME ; private: virtual void __thiscall DSDStack::Dummy1(void)
 	?Dummy2@DSDStack@@EAEXXZ @ 108 NONAME ; private: virtual void __thiscall DSDStack::Dummy2(void)
-	?Dummy3@DSDStack@@EAEXXZ @ 109 NONAME ; private: virtual void __thiscall DSDStack::Dummy3(void)
+	?GetInterface@DSDStack@@MAEXW4TInterfaceId@DMMCStack@@AAPAVMInterface@3@@Z @ 109  NONAME ; protected: virtual void __thiscall DSDStack::GetInterface(enum DMMCStack::TInterfaceId,class DMMCStack::MInterface * &)
 	?CardType@DSDStack@@UAE?AW4TSDCardType@1@HH@Z @ 110 NONAME ; public: virtual enum DSDStack::TSDCardType __thiscall DSDStack::CardType(int,int)
 	?Init@DSDStack@@UAEHXZ @ 111 NONAME ; public: virtual int __thiscall DSDStack::Init(void)
 	?InitStackAfterUnlockSM@DSDStack@@MAEKXZ @ 112 NONAME ; protected: virtual unsigned long __thiscall DSDStack::InitStackAfterUnlockSM(void)
--- a/kernel/eka/drivers/pbus/mmc/sdcard/bx86/sdcard3c/epbusmu.def	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/bx86/sdcard3c/epbusmu.def	Thu Aug 12 11:55:14 2010 +0100
@@ -107,7 +107,7 @@
 	?DeclareCardAsGone@TSDCardArray@@UAEXI@Z @ 106 NONAME ; public: virtual void __thiscall TSDCardArray::DeclareCardAsGone(unsigned int)
 	?Dummy1@DSDStack@@EAEXXZ @ 107 NONAME ; private: virtual void __thiscall DSDStack::Dummy1(void)
 	?Dummy2@DSDStack@@EAEXXZ @ 108 NONAME ; private: virtual void __thiscall DSDStack::Dummy2(void)
-	?Dummy3@DSDStack@@EAEXXZ @ 109 NONAME ; private: virtual void __thiscall DSDStack::Dummy3(void)
+	?GetInterface@DSDStack@@MAEXW4TInterfaceId@DMMCStack@@AAPAVMInterface@3@@Z @ 109  NONAME ; protected: virtual void __thiscall DSDStack::GetInterface(enum DMMCStack::TInterfaceId,class DMMCStack::MInterface * &)
 	?CardType@DSDStack@@UAE?AW4TSDCardType@1@HH@Z @ 110 NONAME ; public: virtual enum DSDStack::TSDCardType __thiscall DSDStack::CardType(int,int)
 	?Init@DSDStack@@UAEHXZ @ 111 NONAME ; public: virtual int __thiscall DSDStack::Init(void)
 	?InitStackAfterUnlockSM@DSDStack@@MAEKXZ @ 112 NONAME ; protected: virtual unsigned long __thiscall DSDStack::InitStackAfterUnlockSM(void)
--- a/kernel/eka/drivers/pbus/mmc/sdcard/bx86/sdcard3c/sdio/epbusmu.def	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/bx86/sdcard3c/sdio/epbusmu.def	Thu Aug 12 11:55:14 2010 +0100
@@ -107,7 +107,7 @@
 	?DeclareCardAsGone@TSDCardArray@@UAEXI@Z @ 106 NONAME ; public: virtual void __thiscall TSDCardArray::DeclareCardAsGone(unsigned int)
 	?Dummy1@DSDStack@@EAEXXZ @ 107 NONAME ; private: virtual void __thiscall DSDStack::Dummy1(void)
 	?Dummy2@DSDStack@@EAEXXZ @ 108 NONAME ; private: virtual void __thiscall DSDStack::Dummy2(void)
-	?Dummy3@DSDStack@@EAEXXZ @ 109 NONAME ; private: virtual void __thiscall DSDStack::Dummy3(void)
+	?GetInterface@DSDStack@@MAEXW4TInterfaceId@DMMCStack@@AAPAVMInterface@3@@Z @ 109  NONAME ; protected: virtual void __thiscall DSDStack::GetInterface(enum DMMCStack::TInterfaceId,class DMMCStack::MInterface * &)
 	?CardType@DSDStack@@UAE?AW4TSDCardType@1@HH@Z @ 110 NONAME ; public: virtual enum DSDStack::TSDCardType __thiscall DSDStack::CardType(int,int)
 	?Init@DSDStack@@UAEHXZ @ 111 NONAME ; public: virtual int __thiscall DSDStack::Init(void)
 	?InitStackAfterUnlockSM@DSDStack@@MAEKXZ @ 112 NONAME ; protected: virtual unsigned long __thiscall DSDStack::InitStackAfterUnlockSM(void)
--- a/kernel/eka/drivers/pbus/mmc/sdcard/eabi/sdcard3c/epbusmu.def	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/eabi/sdcard3c/epbusmu.def	Thu Aug 12 11:55:14 2010 +0100
@@ -134,7 +134,7 @@
 	_ZN8DSDStack4InitEv @ 133 NONAME
 	_ZN8DSDStack6Dummy1Ev @ 134 NONAME
 	_ZN8DSDStack6Dummy2Ev @ 135 NONAME
-	_ZN8DSDStack6Dummy3Ev @ 136 NONAME
+	_ZN8DSDStack12GetInterfaceEN9DMMCStack12TInterfaceIdERPNS0_10MInterfaceE @ 136 NONAME
 	_ZN8DSDStack8CardTypeEii @ 137 NONAME
 	_ZNK8DSDStack12AllocSessionERK12TMMCCallBack @ 138 NONAME
 	_ZTI12TSDCardArray @ 139 NONAME ; #<TI>#
--- a/kernel/eka/drivers/pbus/mmc/sdcard/eabi/sdcard3c/sdio/epbusmu.def	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/eabi/sdcard3c/sdio/epbusmu.def	Thu Aug 12 11:55:14 2010 +0100
@@ -134,7 +134,7 @@
 	_ZN8DSDStack4InitEv @ 133 NONAME
 	_ZN8DSDStack6Dummy1Ev @ 134 NONAME
 	_ZN8DSDStack6Dummy2Ev @ 135 NONAME
-	_ZN8DSDStack6Dummy3Ev @ 136 NONAME
+	_ZN8DSDStack12GetInterfaceEN9DMMCStack12TInterfaceIdERPNS0_10MInterfaceE @ 136 NONAME
 	_ZN8DSDStack8CardTypeEii @ 137 NONAME
 	_ZNK8DSDStack12AllocSessionERK12TMMCCallBack @ 138 NONAME
 	_ZTI12TSDCardArray @ 139 NONAME ; #<TI>#
--- a/kernel/eka/drivers/pbus/mmc/sdcard/sdcard3c/sdcard.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/sdcard3c/sdcard.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -424,6 +424,10 @@
 EXPORT_C TInt DSDStack::Init()
 	{
 	OstTraceFunctionEntry1( DSDSTACK_INIT_ENTRY, this );
+
+	if((iAddressCard = new DAddressCard(*this)) == NULL)
+        return KErrNoMemory;
+	
 	TInt ret = DMMCStack::Init();
 	OstTraceFunctionExitExt( DSDSTACK_INIT_EXIT, this, ret );
 	return ret;
@@ -1136,7 +1140,7 @@
 		    {
 			AddressCard(KBroadcastToAllCards);
 			__KTRACE_OPT(KPBUS1, Kern::Printf("<DSDStack::InitStackAfterUnlockSM()"));
-		    }
+ 		    }
 
 	SMF_END
 	
@@ -1654,6 +1658,31 @@
     }
 
 
+DAddressCard::DAddressCard(DSDStack& aStack) :iStack(aStack)
+	{
+	}
+
+void DAddressCard::AddressCard(TInt aCardNumber)
+	{
+	iStack.AddressCard(aCardNumber);
+	}
+
+/**
+Gets an interface from a derived class
+
+N.B the derived class should call this function if it does not support the specified interface
+*/
+EXPORT_C void DSDStack::GetInterface(TInterfaceId aInterfaceId, MInterface*& aInterfacePtr)
+	{
+	if (aInterfaceId == KInterfaceAddressCard)
+		{
+		aInterfacePtr = (DMMCStack::MInterface*) iAddressCard;
+		}
+	else
+		{
+		DMMCStack::GetInterface(aInterfaceId, aInterfacePtr);
+		}
+	}
+
 EXPORT_C void DSDStack::Dummy1() {}
 EXPORT_C void DSDStack::Dummy2() {}
-EXPORT_C void DSDStack::Dummy3() {}
--- a/kernel/eka/drivers/pbus/mmc/sdcard/sdcard3c/sdio/sdiostack.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/sdcard/sdcard3c/sdio/sdiostack.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -2823,3 +2823,6 @@
 EXPORT_C void DSDIOStack::Dummy2() {}
 EXPORT_C void DSDIOStack::Dummy3() {}
 EXPORT_C void DSDIOStack::Dummy4() {}
+#if defined(__WINS__) || defined (__X86__)
+EXPORT_C void Dummy1() {}
+#endif
--- a/kernel/eka/drivers/pbus/mmc/session.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/session.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -464,6 +464,10 @@
 		return KErrNotReady;
 	    }
 
+	// Save the callers card pointer as some state machines 
+	// (e.g. ECIMLockUnlock, ECIMInitStackAfterUnlock) can change it
+	SaveCard();
+
 	SetupCIMControl(iSessionID);
 
 	iStackP->Add(this);
--- a/kernel/eka/drivers/pbus/mmc/stack.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/stack.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -1804,9 +1804,11 @@
 	if( sessP->iCardP != NULL && sessP->iCardP->iUsingSessionP == sessP )
 		sessP->iCardP->iUsingSessionP = NULL;
 
-	// iAutoUnlockSession may attach to more than once card, so need to iterate 
+	// Some sessions may attach to more than once card, so need to iterate 
 	// through all cards and clear their session pointers if they match sessP
-	if (sessP == &iAutoUnlockSession)
+	if (sessP == &iAutoUnlockSession || 
+		sessP->iSessionID == ECIMLockUnlock || 
+		sessP->iSessionID == ECIMInitStackAfterUnlock)
 		{
 		for (TUint i = 0; i < iMaxCardsInStack; i++)
 			{
@@ -1942,6 +1944,11 @@
 
 			if(doCallback)
 				{
+				// Restore the callers card pointer as some state machines 
+				// (e.g. ECIMLockUnlock, ECIMInitStackAfterUnlock) can change it
+				sessP->RestoreCard();
+
+
 				// call media driver completion routine or StackSessionCBST().
 				sessP->iCallBack.CallBack();
 				}
@@ -6063,6 +6070,8 @@
 			return KMMCErrNotSupported;
 		    }
 
+		DoAddressCard(s.iCardP->iIndex-1);
+
 		s.iState |= KMMCSessStateInProgress;
 		m.SetTraps( KMMCErrInitContext );
 
@@ -6474,30 +6483,31 @@
 		// Upon completion, test the next card before performing further initialisation.
 		//
 		
-		SMF_STATE(EStSendStatus)
+		DoAddressCard(iAutoUnlockIndex); 	// Address the card
+		TMMCard* cd = iCardArray->CardP(iAutoUnlockIndex);
+		s.SetCard(cd);
+
+	SMF_STATE(EStSendStatus)
 		        
 		s.FillCommandDesc(ECmdSendStatus, 0);
 		                        
 		SMF_INVOKES(ExecCommandSMST,EStGetStatus)
 		                        
-		SMF_STATE(EStGetStatus)
+	SMF_STATE(EStGetStatus)
 		                        
 		const TMMCStatus st = s.LastStatus();
 		if((st & KMMCStatCardIsLocked) == 0)
 			{
-		    SMF_RETURN(err)
+			SMF_GOTOS(EStNextIndex);
 		    }
 		                        
-		SMF_STATE(EStUnlock)
+	SMF_STATE(EStUnlock)
 		                        
 		const TMapping *mp = NULL;
 		mp = iSocket->iPasswordStore->FindMappingInStore(iCardArray->CardP(iAutoUnlockIndex)->CID());
 
-		TMMCard &cd = *(iCardArray->CardP(iAutoUnlockIndex++));
-		OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMAUTOUNLOCKSM4, "Attempting to unlock card %d", cd.Number() );
+		OstTrace1( TRACE_INTERNALS, DMMCSTACK_CIMAUTOUNLOCKSM4, "Attempting to unlock card %d", iCardArray->CardP(iAutoUnlockIndex)->Number() );
 		
-		s.SetCard(&cd);
-
 		const TInt kPWD_LEN = mp->iPWD.Length();
 		iPSLBuf[0] = 0;				// LOCK_UNLOCK = 0; unlock
 		iPSLBuf[1] = static_cast<TUint8>(kPWD_LEN);
@@ -6774,6 +6784,21 @@
 	return busWidth;
 	}
 
+void DMMCStack::DoAddressCard(TInt aCardNumber)
+	{
+	MAddressCard* addressCardInterface = NULL;
+	GetInterface(KInterfaceAddressCard, (MInterface*&) addressCardInterface);
+	if (addressCardInterface)
+		addressCardInterface->AddressCard(aCardNumber);
+	else
+		{
+		// if the interface isn't supported on a multiplexed bus, then panic if the card number > 0 - 
+		// one cause of this panic is if the PSL 's implementation of GetInterface() does not call the 
+		// base class's implementation of GetInterface()
+		__ASSERT_ALWAYS((!iMultiplexedBus) || (aCardNumber <= 0), DMMCSocket::Panic(DMMCSocket::EMMCAddressCardNotSupported));
+		}
+	}
+
 /**
  * class DMMCSocket 
  */
--- a/kernel/eka/drivers/resmanus/d_resmanus.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/resmanus/d_resmanus.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -482,8 +482,7 @@
 			{
 			__ASSERT_ALWAYS(m.Ptr2() != NULL, RESMANUS_FAULT());
 #ifdef _DUMP_TRACKERS
-			if((r=DumpTracker(iSetStateTracker))!=KErrNone)
-				break;
+			DumpTracker(iSetStateTracker);
 #endif
 			r = GetAndInitTrackingBuffer(iSetStateTracker, trackBuf, (TUint)m.Ptr1(), pS);
 			if( r != KErrNone)
@@ -500,8 +499,7 @@
 			__ASSERT_ALWAYS(m.Ptr2() != NULL, RESMANUS_FAULT());
 			umemget32(&(parms[0]), m.Ptr2(), 3*sizeof(TInt));
 #ifdef _DUMP_TRACKERS
-			if((r=DumpTracker(iGetStateTracker))!=KErrNone)
-				break;
+			DumpTracker(iGetStateTracker);
 #endif
 			r = GetStateBuffer(iGetStateTracker, trackBuf, (TUint)m.Ptr1(), (TInt*)parms[1], (TInt*)parms[2], callBack, pS);
 			if(r != KErrNone)
@@ -1269,10 +1267,8 @@
 				if((r==KErrNone) && (stateRes[2]>0))
 					r=InitTrackingControl(iListenableTracker,ENotify,stateRes[2]);
 #ifdef _DUMP_TRACKERS
-			if((r=DumpTracker(iGetStateTracker))!=KErrNone)
-				break;
-			if((r=DumpTracker(iSetStateTracker))!=KErrNone)
-				break;
+				DumpTracker(iGetStateTracker);
+				DumpTracker(iSetStateTracker);
 #endif
 				}
 			break;
@@ -2014,14 +2010,16 @@
 	return r;
 	}
 
-
 #ifdef _DUMP_TRACKERS
-TInt DChannelResManUs::DumpTracker(TTrackingControl* aTracker)
+void DChannelResManUs::DumpTracker(TTrackingControl* aTracker)
 	{
 	Kern::Printf("\nDChannelResManUs::DumpTracker");
 	Kern::Printf("Tracker at 0x%x\n",aTracker);
-	if(NULL==aTracker)
-		return KErrGeneral;
+	if(!aTracker)
+		{
+		Kern::Printf("Nothing to dump..");
+		return;
+		}
 	Kern::Printf("iType=%d",aTracker->iType);
 	switch(aTracker->iType)
 		{
@@ -2043,14 +2041,14 @@
 		buf=aTracker->iFreeQue->First();
 		while(buf!=aTracker->iFreeQue->Last())
 			{
-			Kern::Printf("iFreeQue buffer at 0x%x\n",buf);
+			Kern::Printf("iFreeQue first buffer at 0x%x\n",buf);
 			TAny* intermediatePtr = (TAny*)buf;
 			if((aTracker->iType == EGetState)||(aTracker->iType == ESetState))
 				{
-				TTrackStateBuf* tempBuf =(TTrackStateBuf*)intermediatePtr;
-				Kern::Printf("buffer control block at 0x%x\n",tempBuf->iCtrlBlock);
+				TTrackSetStateBuf* tempBuf =(TTrackSetStateBuf*)intermediatePtr;
+				Kern::Printf("buffer control block at 0x%x\n",(TInt)&tempBuf->iCtrlBlock);
 				}
-			buf= buf->iNext;
+			buf = buf->iNext;
 			};
 		}
 	Kern::Printf("iBusyQue at 0x%x\n",aTracker->iBusyQue);
@@ -2063,14 +2061,12 @@
 			TAny* intermediatePtr = (TAny*)buf;
 			if((aTracker->iType == EGetState)||(aTracker->iType == ESetState))
 				{
-				TTrackStateBuf* tempBuf =(TTrackStateBuf*)intermediatePtr;
-				Kern::Printf("buffer control block at 0x%x\n",tempBuf->iCtrlBlock);
+				TTrackSetStateBuf* tempBuf =(TTrackSetStateBuf*)intermediatePtr;
+				Kern::Printf("buffer control block at 0x%x\n", (TInt)&tempBuf->iCtrlBlock);
 				}
 			buf= buf->iNext;
 			};
 		}
-
-	return KErrNone;
 	}
 #endif
 
--- a/kernel/eka/drivers/resourceman/rescontrol_export.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/resourceman/rescontrol_export.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -12,7 +12,7 @@
 //
 // Description:
 // e32\drivers\resourceman\rescontrol_export.cpp
-// 
+//
 //
 
 #include <drivers/resourcecontrol.h>
@@ -55,7 +55,7 @@
 	if(!pRC)
 		return KErrNotFound;
 	pRC->Lock();
-    CHECK_CONTEXT(thread)
+    CHECK_CONTEXT(thread);
 	//Accept the postboot level only if issued before controller is fully initialised.
 	if(pRC->iInitialised == EResConStartupCompleted)
 		{
@@ -66,15 +66,15 @@
 #ifndef PRM_ENABLE_EXTENDED_VERSION
     // coverity[deref_ptr]
     // aResId is checked to be more than the array entries before dereferencing pRC->iStaticResourceArray
-	if((!aResId) || (aResId > pRC->iStaticResourceArrayEntries) || (!pRC->iStaticResourceArray[aResId-1]))
+	if((!aResId) || (aResId > (TUint)pRC->iStaticResourceArray.Count()) || (!pRC->iStaticResourceArray[aResId-1]))
 		{
 		pRC->UnLock();
 		LOCK_AND_CRITICAL_SECTION_COUNT_CHECK(thread)
 		return KErrNotFound;
 		}
 #else
-	if(!aResId || ((aResId & KIdMaskResourceWithDependencies) && ((aResId & ID_INDEX_BIT_MASK) > pRC->iStaticResDependencyCount)) 
-				|| (!(aResId & KIdMaskResourceWithDependencies) && ((aResId > pRC->iStaticResourceArrayEntries)
+	if(!aResId || ((aResId & KIdMaskResourceWithDependencies) && ((aResId & ID_INDEX_BIT_MASK) > (TUint)pRC->iStaticResDependencyArray.Count())) 
+				|| (!(aResId & KIdMaskResourceWithDependencies) && ((aResId > (TUint)pRC->iStaticResourceArray.Count())
 				|| (!pRC->iStaticResourceArray[aResId-1]))))
 		{
 		pRC->UnLock();
@@ -90,7 +90,7 @@
 		}
 	else
 #endif
-    if(pRC->iStaticResourceArray) 
+    if((TUint)pRC->iStaticResourceArray.Count() > aResId - 1)
 		{
 		DStaticPowerResource* pR=pRC->iStaticResourceArray[--aResId];
 		pR->iPostBootLevel=aLevel;
@@ -107,7 +107,9 @@
 	Kernel extensions or variants can call this API to register the static resources before resource controller
 	is fully initialised.
 	@Param aClientId             ID of the client that is requesting resource registration
-	@Param aStaticResourceArray  Static resources to register with RC. 
+	@Param aStaticResourceArray  Static resources to register with RC.
+	                             Note, that in the special case, when aResCount equals to one, this parameter is treated as a pointer to the
+	                             DStaticPowerResource (DStaticPowerResource*). Otherwise - is the pointer to array of such pointers (DStaticPowerResource*).
 	@Param aResCount             Number of static resources to register with RC. This equals the size of the passed array.
 	@return KErrNone, if operation is success
 	        KErrAccessDenied if clientId could not be found in the current list of registered clients or if this
@@ -127,7 +129,7 @@
 
 	if(!aStaticResourceArray || (aResCount == 0))
 		return KErrArgument;
-    CHECK_CONTEXT(thread)
+	CHECK_CONTEXT(thread);
 	//Accept the registration of static resource only if issued before controller is fully initialised.
 	if(pRC->iInitialised == EResConStartupCompleted)
 		{
@@ -139,10 +141,10 @@
 		return KErrNotSupported;
 		}
 #ifdef PRM_ENABLE_EXTENDED_VERSION
+	// if aResCount equals to 1 aStaticResourceArray contains not an array, but simply a pointer to the resource.
 	if(aResCount == 1)
 		{
-		if((((DStaticPowerResource*)aStaticResourceArray)->iResourceId & KIdMaskResourceWithDependencies) ||
-										(((DStaticPowerResource*)aStaticResourceArray)->iResourceId & KIdMaskDynamic))
+		if(((DStaticPowerResource*)aStaticResourceArray)->iResourceId & (KIdMaskResourceWithDependencies | KIdMaskDynamic))
 			{
 			return KErrNotSupported;
 			}
@@ -151,56 +153,60 @@
 		{
 		for(TUint rescount = 0; rescount < aResCount; rescount++)
 			{
-			if(aStaticResourceArray[rescount] && ((aStaticResourceArray[rescount]->iResourceId & KIdMaskResourceWithDependencies) || 
-				                          (aStaticResourceArray[rescount]->iResourceId & KIdMaskDynamic)))
+			if(aStaticResourceArray[rescount] &&
+			  (aStaticResourceArray[rescount]->iResourceId & (KIdMaskResourceWithDependencies | KIdMaskDynamic)))
 				{
 				return KErrNotSupported;
 				}
 			}
 		}
 #endif
-	SPowerResourceClient* pC = pRC->iClientList[(TUint16)(aClientId & ID_INDEX_BIT_MASK)];								
-	if(!pC)																										
-		{																										
-		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Client ID not Found"));											
-		return KErrAccessDenied;																		
-		}																										
-	if(pC->iClientId != aClientId)				
-		{																										
-		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Client ID instance count does not match"));						
-		return KErrAccessDenied;																		
-		}																										
-	if(pC->iClientId & CLIENT_THREAD_RELATIVE_BIT_MASK)															
-		{																										
-		if(pC->iThreadId != thread.iId)																				
-			{																									
-			__KTRACE_OPT(KRESMANAGER, Kern::Printf("Client not called from thread context(Thread Relative)"));	
-			return KErrAccessDenied;																	
-			}																									
+	SPowerResourceClient* pC = pRC->iClientList[(TUint16)(aClientId & ID_INDEX_BIT_MASK)];
+	if(!pC)
+		{
+		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Client ID not Found"));
+		return KErrAccessDenied;
+		}
+	if(pC->iClientId != aClientId)
+		{
+		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Client ID instance count does not match"));
+		return KErrAccessDenied;
 		}
- 
-    TInt r = Kern::SafeReAlloc((TAny*&)pRC->iStaticResourceArray, pRC->iStaticResourceArrayEntries*sizeof(DStaticPowerResource*), 
-		                                         (pRC->iStaticResourceArrayEntries + aResCount)*sizeof(DStaticPowerResource*));
-    if(r != KErrNone)
+	if(pC->iClientId & CLIENT_THREAD_RELATIVE_BIT_MASK)
 		{
-        return r;
+		if(pC->iThreadId != thread.iId)
+			{
+			__KTRACE_OPT(KRESMANAGER, Kern::Printf("Client not called from thread context(Thread Relative)"));
+			return KErrAccessDenied;
+			}
 		}
+
+    TInt r = KErrNone;
 	if(aResCount == 1)
 		{
-		pRC->iStaticResourceArray[pRC->iStaticResourceArrayEntries++] = (DStaticPowerResource*)aStaticResourceArray;
-		if((DStaticPowerResource*)aStaticResourceArray)
+		// if aResCount equals to one, threat the pointer as a pointer to resource
+		r = pRC->iStaticResourceArray.Append((DStaticPowerResource*)aStaticResourceArray);
+		// increment count of valid resources
+		if(r == KErrNone && aStaticResourceArray)
 			pRC->iStaticResourceCount++;
 		}
 	else
 		{
 		for(TUint count = 0; count < aResCount; count++)
 			{
-			pRC->iStaticResourceArray[pRC->iStaticResourceArrayEntries++] = aStaticResourceArray[count];
+			r = pRC->iStaticResourceArray.Append(aStaticResourceArray[count]);
+			if(r != KErrNone)
+				{
+				__KTRACE_OPT(KRESMANAGER, Kern::Printf("Could not add new static resources, r = %d", r));
+				break;
+				}
+			// increment count of valid resources
 			if(aStaticResourceArray[count])
 				pRC->iStaticResourceCount++;
 			}
 		}
-    return KErrNone;
+
+	return r;
 	}
 
 /**
@@ -229,6 +235,10 @@
 	This function initialises the controller. 
 	@return KErrNone, if operation is success or one of the system wide errors.
 	*/
+RPointerArray <DStaticPowerResource> *StaticResourceArrayPtr;
+#ifdef PRM_ENABLE_EXTENDED_VERSION
+RPointerArray <DStaticPowerResourceD> *StaticResourceDependencyArrayPtr;
+#endif
 EXPORT_C TInt DPowerResourceController::InitController()
 	{
     __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::InitController()"));
@@ -252,13 +262,31 @@
 	if(!pRC->iMsgQDependency)
 		return KErrNoMemory;
 #endif
-	// Call PSL to create all static resources and populate the iStaticResourceArray with pointers to resources and
-	// update static resource count
-    r=pRC->DoRegisterStaticResources(pRC->iStaticResourceArray, pRC->iStaticResourceArrayEntries);
-    if(r!=KErrNone)
+	// This method can be called in two situations - before the constructor of DPowerResourceController was called 
+	// for the second time (placement new in the extension psl entry macro) e.g. as a result of the call to InitResources() 
+	// from the variant::Init3() method) or after that.
+
+	// In order not to make any assumption on number of constructor invocations, a copy (binary) of the iStaticResourceArray object 
+	// is created below, so that it could be used to later restore the original iStaticResoureceArray object if the constructor
+	// was called after this method. The reason for that is, that in this destructor calls the default RPointerArrayBase()
+	// which resets the array, i.e. it looses the information, but allocated area and pointers still exist in the memory. 
+	// It is then valid to restore the object directly (which will copy all members, including iSize and iEntries pointers). 
+	// This temporary object will be deleted in DPowerResourceController::InitResources() at the last stage of initialization.
+	// (see also comments in DPowerResourceController::DPowerResourceController()) 
+
+	StaticResourceArrayPtr = new RPointerArray <DStaticPowerResource>;
+	if(!StaticResourceArrayPtr)
+		return KErrNoMemory;
+
+	r = pRC->DoRegisterStaticResources(pRC->iStaticResourceArray);
+	if(r != KErrNone)
 		return r;
-	//Get the actual number of static resource registered count
-	for(TInt resCnt = 0; resCnt < pRC->iStaticResourceArrayEntries; resCnt++)
+
+	// make a copy (see above comment)
+	*StaticResourceArrayPtr = pRC->iStaticResourceArray; 
+
+	// Get the actual number of static resource registered count
+	for(TInt resCnt = 0; resCnt < pRC->iStaticResourceArray.Count(); resCnt++)
 		{
 		if(pRC->iStaticResourceArray[resCnt])
 			pRC->iStaticResourceCount++;
@@ -269,7 +297,7 @@
 	DStaticPowerResource* pR = NULL;
 	TPowerResourceInfoBuf01 resInfo;
 	TPowerResourceInfoV01 *pResInfo;
-	for(TInt resCount = 0; resCount < pRC->iStaticResourceArrayEntries; resCount++)
+	for(TInt resCount = 0; resCount < pRC->iStaticResourceArray.Count(); resCount++)
 		{
 		pR = pRC->iStaticResourceArray[resCount];
 		if(!pR)
@@ -281,16 +309,25 @@
 #endif
 
 #ifdef PRM_ENABLE_EXTENDED_VERSION
-	//Call PSL to register static resources with dependency if any exists
-	r = pRC->DoRegisterStaticResourcesDependency(pRC->iStaticResDependencyArray, pRC->iStaticResDependencyCount);
+	StaticResourceDependencyArrayPtr = new RPointerArray <DStaticPowerResourceD>;
+	if(!StaticResourceDependencyArrayPtr)
+		return KErrNoMemory;
+
+	// Call PSL to register static resources with dependency if any exists
+	r = pRC->DoRegisterStaticResourcesDependency(pRC->iStaticResDependencyArray);
+
 	if(r != KErrNone)
 		return r;
-	if(pRC->iStaticResDependencyCount)
+
+	// make a copy (see above comments for StaticResourceArrayPtr)
+	*StaticResourceDependencyArrayPtr = pRC->iStaticResDependencyArray;
+
+	if(pRC->iStaticResDependencyArray.Count())
 		{
 		DStaticPowerResourceD* pRD = NULL;
 		TUint count;
 		//Assign resource index in resource id
-		for(count = 0; count < pRC->iStaticResDependencyCount; count++)
+		for(count = 0; count < (TUint)pRC->iStaticResDependencyArray.Count(); count++)
 			{
 			pRD = pRC->iStaticResDependencyArray[count];
 			if(!pRD)
@@ -298,7 +335,7 @@
 			pRD->iResourceId |= ((count + 1) & ID_INDEX_BIT_MASK);
 			}
 		//Check for dependency closed loops
-		for(count = 0; count < pRC->iStaticResDependencyCount; count++)
+		for(count = 0; count < (TUint)pRC->iStaticResDependencyArray.Count(); count++)
 			{
 			pRD = pRC->iStaticResDependencyArray[count];
 			if(!(pRD->iResourceId & KIdMaskStaticWithDependencies))
@@ -309,7 +346,7 @@
 			pRC->CheckForDependencyLoop(pRD, pRD->iResourceId, pRD->iResourceId);
 			}
 #ifdef PRM_INSTRUMENTATION_MACRO
-		for(count = 0; count < pRC->iStaticResDependencyCount; count++)
+		for(count = 0; count < (TUint)pRC->iStaticResDependencyArray.Count(); count++)
 			{
 			pR = pRC->iStaticResDependencyArray[count];
 			pR->GetInfo((TDes8*)resInfo.Ptr());
--- a/kernel/eka/drivers/resourceman/resourcecontrol.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/resourceman/resourcecontrol.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -12,7 +12,7 @@
 //
 // Description:
 // e32\drivers\resourceman\resourcecontrol.cpp
-// 
+//
 //
 
 #include <drivers/resourcecontrol.h>
@@ -313,19 +313,44 @@
     return PowerResourceController->GetInterface(aClientId, aFunction, aParam1, aParam2, aParam3);
     }
 
-/** Resouce controller panic */
+/** Resource controller panic */
 void DPowerResourceController::Panic(TUint8 aPanic)
 	{
 	Kern::Fault("Power Resource Controller", aPanic);
 	}
 
 /** Constructor for power controller. Creates message queue and generates ID for power controller to use. */
+extern RPointerArray <DStaticPowerResource> *StaticResourceArrayPtr;
+#ifdef PRM_ENABLE_EXTENDED_VERSION
+extern RPointerArray <DStaticPowerResourceD> *StaticResourceDependencyArrayPtr;
+#endif
 DPowerResourceController::DPowerResourceController()
 	{
-    __KTRACE_OPT(KRESMANAGER, Kern::Printf("DPowerResourceController::DPowerResouceController()"));
-	//Constructor is expected to invoke multiple times (during creation, variant init 0 and extension init 1)
-	if(PowerResourceController) 
+	__KTRACE_OPT(KRESMANAGER, Kern::Printf("DPowerResourceController::DPowerResouceController()"));
+	// Constructor is expected to invoke multiple times, i.e.: 
+	// during creation: variant init 0(KModuleEntryReasonVariantInit0) and later extension init 1 (KModuleEntryReasonExtensionInit1)
+	if(PowerResourceController)
+		{
+		// If InitController() was called in the Init3() static resource arrays were populated already and invocation of this 
+		// constructor has zeroed the dynamic pointer arrays (calling their default constructors). In such case we need to 
+		// restore these arrays from their temporary shadow copies (i.e. copies of RPointerArray objects, not their content)
+		// (See comments in RegisterStaticResources())
+		if(StaticResourceArrayPtr)
+			{
+			// by making a (binary) copy of RPointerArray object (compiler's auto-generated code)
+			// we are taking the ownership of content (pointers stored/owned by that array) of this temporary array
+			iStaticResourceArray = *StaticResourceArrayPtr;
+			}
+#ifdef PRM_ENABLE_EXTENDED_VERSION
+		// the same applies to static resources with dependencies for extended version.
+		// Temporary object are de-allocated in InitResources()
+		if(StaticResourceDependencyArrayPtr)
+			{
+			iStaticResDependencyArray = *StaticResourceDependencyArrayPtr;
+			}
+#endif
 		return;
+		}
     PowerResourceController = this;
 	iClientList.Initialise(0);
 	iUserSideClientList.Initialise(0);
@@ -336,58 +361,6 @@
 #endif
 	}
 
-/** Destructor for power controller. Frees the memory allocated in kernel heap. */
-DPowerResourceController::~DPowerResourceController()
-	{
-	__KTRACE_OPT(KRESMANAGER, Kern::Printf("DPowerResourceController::~DPowerResourceController()"));
-#ifdef RESOURCE_MANAGER_SIMULATED_PSL
-	iCleanList.ResetAndDestroy();
-#endif
-	iClientList.Delete();
-	iUserSideClientList.Delete();
-
-
-		
-#ifdef PRM_ENABLE_EXTENDED_VERSION
-	iDynamicResourceList.Delete();
-	iDynamicResDependencyList.Delete();
-#endif
-
-	SPowerResourceClientLevel *pCL = iClientLevelPool;
-	while(iClientLevelPool) //Find the starting position of array to delete
-		{
-		if(iClientLevelPool < pCL)
-			pCL = iClientLevelPool;
-		iClientLevelPool = iClientLevelPool->iNextInList;
-		}
-	//delete pCL;
-	delete []pCL;
-	SPowerRequest *pReq = iRequestPool;
-	while(iRequestPool) //Find the starting position of array to delete
-		{
-		if(iRequestPool < pReq)
-			pReq = iRequestPool;
-		iRequestPool = iRequestPool->iNext;
-		}
-	//delete pR
-	delete []pReq;
-#ifdef PRM_ENABLE_EXTENDED_VERSION
-	pCL = iResourceLevelPool;
-	while(iResourceLevelPool)
-		{
-		if(iResourceLevelPool < pCL)
-			pCL = iResourceLevelPool;
-		iResourceLevelPool = iResourceLevelPool->iNextInList;
-		}
-	//delete resource pool
-	delete []pCL;
-	//delete Message Queue dependency
-	delete iMsgQDependency;
-#endif
-	//delete Message Queue
-	delete iMsgQ;
-	}
-
 /** Send notificatins to clients registered for it for the specified resource. */
 void DPowerResourceController::CompleteNotifications(TInt aClientId, DStaticPowerResource* aResource, TInt aState, 
 													      TInt aReturnCode, TInt aLevelOwnerId, TBool aLock)
@@ -712,7 +685,7 @@
 		PRM_CLIENT_CHANGE_STATE_END_TRACE
 		}
 #endif
-	//Check whether callback is cancelled and if not queue the DFC.
+	//Check whether callback is canceled and if not queue the DFC.
     TPowerResourceCb* pCb = aReq->ResourceCb();
     if(pCb)
 		{
@@ -758,7 +731,7 @@
 		pC->iClientId = aReq->ClientId();
 		DDynamicPowerResourceD* pDRes;
 		if(aReq->ClientId() & KIdMaskDynamic)
-			pDRes = pRC->iDynamicResDependencyList[(TUint16)(aReq->ClientId() & ID_INDEX_BIT_MASK)];	
+			pDRes = pRC->iDynamicResDependencyList[(aReq->ClientId() & ID_INDEX_BIT_MASK)];	
 		else
 			pDRes = (DDynamicPowerResourceD*)pRC->iStaticResDependencyArray[(aReq->ClientId() & ID_INDEX_BIT_MASK) - 1];
 		pC->iName = pDRes->iName;
@@ -787,7 +760,7 @@
 		PRM_CLIENT_CHANGE_STATE_END_TRACE
 		}
 #endif
-	//Check whether callback is cancelled and if not queue the DFC.
+	//Check whether callback is canceled and if not queue the DFC.
     TPowerResourceCb* pCb = aReq->ResourceCb();
     if(pCb)
 		{
@@ -856,13 +829,13 @@
 TInt DPowerResourceController::InitResources()
 	{
     __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DPowerResourceController::InitResources()"));
-	TUint16 count;
+	TInt count;
 	//Create a Kernel client object for Power Controller
 	Lock();
 	SPowerResourceClient * pC = NULL;
 	// By now client pool should be created
 	LIST_POP(iClientPool, pC, iNextInList);
-	TUint16 growBy = iClientList.GrowBy();
+	TInt growBy = iClientList.GrowBy();
 	if(!pC)
 		{
 		UnLock();
@@ -900,7 +873,15 @@
 	iPowerControllerId = pC->iClientId;
     iClientCount++;
     if(TPowerController::PowerController())
-       TPowerController::PowerController()->RegisterResourceController(this, iPowerControllerId);
+		{
+		if(TPowerController::PowerController()->RegisterResourceController(this, iPowerControllerId))
+			{
+#ifndef RESOURCE_MANAGER_SIMULATED_PSL
+			Panic(EControllerAlreadyExists);	//	Panic with this error for any error returned by RegisterResourceController
+#endif
+			}
+		}
+
 	iInitialised =EResConStartupCompleted;
 	UnLock();
 	//Check the resource for postboot level and send notifications to clients registered for it.
@@ -908,7 +889,7 @@
 	TInt r;
 	TPowerRequest req = TPowerRequest::Get();
 	//For Static resource with no dependencies
-    for(count = 0; count< iStaticResourceArrayEntries; count++)
+    for(count = 0; count < iStaticResourceArray.Count(); count++)
 		{
 		pR = iStaticResourceArray[count];
 		if(pR && (pR->iFlags & SET_VALID_POST_BOOT_LEVEL))
@@ -931,7 +912,7 @@
 		}
 #ifdef PRM_ENABLE_EXTENDED_VERSION
 	//For Static resource with dependencies 
-	for(count = 0; count < iStaticResDependencyCount; count++)
+	for(count = 0; count < iStaticResDependencyArray.Count(); count++)
 		{
 		pR = iStaticResDependencyArray[count];
 		if(pR->iFlags & SET_VALID_POST_BOOT_LEVEL)
@@ -948,6 +929,21 @@
 			}
 		}
 #endif
+	
+	// delete the temporary copy of static resource array used during initialization.
+	if(StaticResourceArrayPtr)
+		{
+		delete StaticResourceArrayPtr;
+		StaticResourceArrayPtr = NULL;
+		}
+#ifdef PRM_ENABLE_EXTENDED_VERSION
+	// the same applies to dependency resources array for extended version.
+	if(StaticResourceDependencyArrayPtr)
+		{
+		delete StaticResourceDependencyArrayPtr;
+		StaticResourceDependencyArrayPtr = NULL;
+		}
+#endif
 	__KTRACE_OPT(KRESMANAGER, Kern::Printf("<DPowerResourceController::InitResources()"));
     return KErrNone;
 	}
@@ -1261,9 +1257,9 @@
 		}
 #ifdef PRM_ENABLE_EXTENDED_VERSION
 	SPowerResourceClientLevel* pRL = NULL;
-	if(iStaticResDependencyCount)
+	if(iStaticResDependencyArray.Count())
 		{
-		pRL = new SPowerResourceClientLevel[iStaticResDependencyCount];
+		pRL = new SPowerResourceClientLevel[iStaticResDependencyArray.Count()];
 		if(!pRL)
 			{
 			__KTRACE_OPT(KRESMANAGER, Kern::Printf("Resource level Pool Allocation Failed"));
@@ -1279,12 +1275,12 @@
 	iCleanList.Append(pC);
 #endif
 	Lock();
-	TUint16 c;
-	for(c = 0; c < iStaticResDependencyCount; c++)
+	TInt c;
+	for(c = 0; c < iStaticResDependencyArray.Count(); c++)
 		{
 		LIST_PUSH(iResourceLevelPool, &pRL[c], iNextInList);
 		}
-	iResourceLevelPoolCount = iStaticResDependencyCount;
+	iResourceLevelPoolCount = (TUint16)iStaticResDependencyArray.Count();
 #else
 #ifdef RESOURCE_MANAGER_SIMULATED_PSL
     iCleanList.Append(pC);
@@ -1293,7 +1289,7 @@
     TUint16 c;
 #endif
     // Create Client pool list
-    for(c = 0; c< (aKClients + aUClients); c++)
+    for(c = 0; c < TUint16(aKClients + aUClients); c++)
 		{
         LIST_PUSH(iClientPool, &pC[c], iNextInList);
 		}
@@ -1379,7 +1375,7 @@
 	req->SendReceive(iMsgQ);
 	if(req->ReturnCode() == KErrNone)
 		{
-		pC = iClientList[(TUint16)(req->ClientId() & ID_INDEX_BIT_MASK)];
+		pC = iClientList[(req->ClientId() & ID_INDEX_BIT_MASK)];
 		if(aType == EOwnerThread)
 			{
 			pC->iClientId |= CLIENT_THREAD_RELATIVE_BIT_MASK; //Set 31st bit;
@@ -1428,7 +1424,7 @@
 		//Get Next client from FreePool
 		LIST_POP(iClientPool, pC, iNextInList);
 
-		TUint16 growBy = iClientList.GrowBy();
+		TInt growBy = iClientList.GrowBy();
 		if(!pC)
 			{
 			//Free Pool is empty, so try to grow the pool.
@@ -1473,7 +1469,7 @@
 		{
 		//Get Next client from FreePool
 		LIST_POP(iClientPool, pC, iNextInList);
-		TUint16 growBy = iUserSideClientList.GrowBy();
+		TInt growBy = iUserSideClientList.GrowBy();
 		if(!pC)
 			{
 			//Free Pool is empty, so try to grow the pool.
@@ -1486,7 +1482,7 @@
 			iCleanList.Append(pCL);
 #endif
 			Lock();
-			TUint16 count;
+			TInt count;
 			for(count = 0; count < growBy - 1; count++)
 				LIST_PUSH(iClientPool, &pCL[count], iNextInList);
 			UnLock();
@@ -1552,23 +1548,23 @@
 		{
         __KTRACE_OPT(KRESMANAGER, Kern::Printf("Client 0x%x has requirement on resource %d", pCL->iClientId, pCL->iResourceId));
 #ifdef PRM_ENABLE_EXTENDED_VERSION
-		switch((pCL->iResourceId >>RESOURCE_BIT_IN_ID_CHECK) & 0x3)													
-		{																		
-		case PRM_STATIC_RESOURCE:												
-			pR = iStaticResourceArray[pCL->iResourceId - 1];								
-			break;																
-		case PRM_DYNAMIC_RESOURCE:												
-			pR = (iDynamicResourceList[(TUint16)(pCL->iResourceId & ID_INDEX_BIT_MASK)]);			
-			break;																
-		case PRM_STATIC_DEPENDENCY_RESOURCE:									
-			pR = (iStaticResDependencyArray[(TUint16)(pCL->iResourceId & ID_INDEX_BIT_MASK) - 1]);						
-			break;																
-		case PRM_DYNAMIC_DEPENDENCY_RESOURCE:									
-			pR = (iDynamicResDependencyList[(TUint16)(pCL->iResourceId & ID_INDEX_BIT_MASK)]);		
-			break;																
-		}
+		switch((pCL->iResourceId >>RESOURCE_BIT_IN_ID_CHECK) & 0x3)
+			{
+			case PRM_STATIC_RESOURCE:
+			pR = iStaticResourceArray[pCL->iResourceId - 1];
+				break;
+			case PRM_DYNAMIC_RESOURCE:
+			pR = (iDynamicResourceList[(pCL->iResourceId & ID_INDEX_BIT_MASK)]);
+				break;
+			case PRM_STATIC_DEPENDENCY_RESOURCE:
+			pR = (iStaticResDependencyArray[(pCL->iResourceId & ID_INDEX_BIT_MASK) - 1]);
+				break;
+			case PRM_DYNAMIC_DEPENDENCY_RESOURCE:
+			pR = (iDynamicResDependencyList[(pCL->iResourceId & ID_INDEX_BIT_MASK)]);
+				break;
+			}
 #else
-		pR = iStaticResourceArray[pCL->iResourceId -1];
+		pR = iStaticResourceArray[pCL->iResourceId - 1];
 #endif
 #ifdef PRM_ENABLE_EXTENDED_VERSION
 		if(((pR->Sense() == DStaticPowerResource::ECustom) || ((TInt)pCL->iClientId == pR->iLevelOwnerId)) && (!(pCL->iResourceId & KIdMaskDynamic) ||
@@ -1693,7 +1689,7 @@
 		return KErrArgument;
 	//Get the index from client ID
 	Lock();
-	SPowerResourceClient* pC = iClientList[(TUint16)(aClientId & ID_INDEX_BIT_MASK)];
+	SPowerResourceClient* pC = iClientList[(aClientId & ID_INDEX_BIT_MASK)];
     if(!pC)
 	    {
         __KTRACE_OPT(KRESMANAGER, Kern::Printf("Client ID not Found"));
@@ -1737,7 +1733,7 @@
 	iRequestPoolCount = (TUint16)(iRequestPoolCount + (TUint16)pC->iReservedRm);
 	PRM_CLIENT_DEREGISTER_TRACE
 	//Increment the free pool count for client level and request level.
-	iClientList.Remove(pC, (TUint16)(pC->iClientId & ID_INDEX_BIT_MASK));
+	iClientList.Remove(pC, (pC->iClientId & ID_INDEX_BIT_MASK));
 	pC->iName = NULL;
 	iClientCount--; //Decrement client count
 	LIST_PUSH(iClientPool, pC, iNextInList);
@@ -1874,9 +1870,9 @@
 		return KErrTooBig;
 	Lock();
 	VALIDATE_CLIENT(thread);
-	TUint count = 0;
+	TInt count = 0;
 	//Search in static resource with no dependencies array for specified resource name.
-	for(count = 0; count < iStaticResourceArrayEntries; count++)
+	for(count = 0; count < iStaticResourceArray.Count(); count++)
 		{
 		if((iStaticResourceArray[count]) && (!(aResourceName.Compare(*(const TDesC8*)iStaticResourceArray[count]->iName))))
 			{
@@ -1896,7 +1892,7 @@
 		UNLOCK_RETURN(KErrNone);
 		}
 	//Search in static resource with dependencies (if exists) for specified resource name
-	for(count = 0; count < iStaticResDependencyCount; count++)
+	for(count = 0; count < iStaticResDependencyArray.Count(); count++)
 		{
 		if(!(aResourceName.Compare(*(const TDesC8*)iStaticResDependencyArray[count]->iName)))
 			{
@@ -1965,7 +1961,7 @@
 	   UNLOCK_RETURN(KErrArgument);
 
 #ifndef PRM_ENABLE_EXTENDED_VERSION
-	if((!aResourceId) || (aResourceId > iStaticResourceArrayEntries))
+	if((!aResourceId) || (aResourceId > (TUint)iStaticResourceArray.Count()))
 		UNLOCK_RETURN(KErrNotFound);
 	//Get resource from static resource array. 0(1) operation.
 	pR = iStaticResourceArray[aResourceId-1];
@@ -2036,7 +2032,7 @@
 	if(!aTargetClientId)
 		{
 #ifdef PRM_ENABLE_EXTENDED_VERSION
-		aNumResource = iStaticResourceCount + iDynamicResourceCount + iStaticResDependencyCount + 
+		aNumResource = iStaticResourceCount + iDynamicResourceCount + iStaticResDependencyArray.Count() + 
 			                                                          iDynamicResDependencyCount; 
 #else
 		aNumResource = iStaticResourceCount;
@@ -2115,22 +2111,22 @@
          UNLOCK_RETURN(KErrArgument);
     TPowerResourceInfoBuf01 buf;
 
-	TUint16 count = 0;
+	TInt count = 0;
 	TInt r = KErrNone;
 	//Special case, if aTargetClientId is 0 fill with all the resource
 	if(!aTargetClientId)
 		{
-		TUint numResources = aNumResources;
+		TInt numResources = aNumResources;
 #ifndef PRM_ENABLE_EXTENDED_VERSION
 		aNumResources = iStaticResourceCount;
 #else
-		aNumResources = iStaticResourceCount + iDynamicResourceCount + iStaticResDependencyCount + 
+		aNumResources = iStaticResourceCount + iDynamicResourceCount + iStaticResDependencyArray.Count() + 
 			                                                           iDynamicResDependencyCount;
 #endif
 		UnLock();
-		while(count < iStaticResourceArrayEntries)
+		while(count < iStaticResourceArray.Count())
 			{
-			if(numResources <=0)
+			if(numResources == 0)
 				return KErrNone;
 			pR = iStaticResourceArray[count++];
 			if(!pR)
@@ -2145,7 +2141,7 @@
 			}	
 #ifdef PRM_ENABLE_EXTENDED_VERSION
 		count = 0;
-		while(count < iStaticResDependencyCount)
+		while(count < iStaticResDependencyArray.Count())
 			{
 			if(count >= numResources)
 				return KErrNone;
@@ -2157,11 +2153,11 @@
 				return r;
 			pInfo->Append(buf);
 			}
-		numResources -= iStaticResDependencyCount;
+		numResources -= iStaticResDependencyArray.Count();
 		if((!numResources) || (!iDynamicResourceCount && !iDynamicResDependencyCount))
 			return r;
 		Lock();
-		TUint resCount = 0;
+		TInt resCount = 0;
 		for(count = 0; count < iDynamicResourceList.Allocd(); count++)
 			{
 			pR = iDynamicResourceList[count];
@@ -2178,7 +2174,7 @@
 			}
 		numResources -= resCount;
 		resCount = 0;
-		for(count = 0; count < iDynamicResDependencyList.Allocd(); count++) 
+		for(count = 0; count < (TInt)iDynamicResDependencyList.Allocd(); count++) 
 			{
 			pR = iDynamicResDependencyList[count];
 			if(!pR)
@@ -2200,7 +2196,7 @@
 	SPowerResourceClientLevel* pCL = pC->iLevelList;
 	for (count= 0; pCL; count++, pCL = pCL->iNextInList)
 		{
-		if(count >= aNumResources)
+		if(count >= (TInt)aNumResources)
 			continue;
 #ifndef PRM_ENABLE_EXTENDED_VERSION
 		pR = iStaticResourceArray[pCL->iResourceId-1];
@@ -2267,7 +2263,7 @@
 	DStaticPowerResource* pR = NULL;
 	GET_RESOURCE_FROM_LIST(aResourceId, pR) 
 #else
-	if(aResourceId > iStaticResourceArrayEntries)
+	if(aResourceId > (TUint)iStaticResourceArray.Count())
 		UNLOCK_RETURN(KErrNotFound);
 	DStaticPowerResource* pR = iStaticResourceArray[aResourceId-1];
 	if(!pR)
@@ -2371,7 +2367,7 @@
 	DStaticPowerResource* pR = NULL;
 	GET_RESOURCE_FROM_LIST(aResourceId, pR) 
 #else
-	if(aResourceId > iStaticResourceArrayEntries)
+	if(aResourceId > (TUint)iStaticResourceArray.Count())
 		UNLOCK_RETURN(KErrNotFound);
 	DStaticPowerResource* pR = iStaticResourceArray[aResourceId-1];
 	if(!pR)
@@ -2385,9 +2381,9 @@
 			continue;
 		pCL = (SPowerResourceClientLevel*)pRC;
 		if(pCL->iClientId & USER_SIDE_CLIENT_BIT_MASK)
-			pC = iUserSideClientList[(TUint16)(pCL->iClientId & ID_INDEX_BIT_MASK)];
+			pC = iUserSideClientList[(pCL->iClientId & ID_INDEX_BIT_MASK)];
 		else
-			pC = iClientList[(TUint16)(pCL->iClientId & ID_INDEX_BIT_MASK)];
+			pC = iClientList[(pCL->iClientId & ID_INDEX_BIT_MASK)];
 		info.iClientId = pC->iClientId;
 		info.iClientName =  (TDesC8*)pC->iName;
         pInfo->Append(TPckgC<TPowerClientInfoV01>(info));
@@ -2405,7 +2401,7 @@
 NOTE: If a resource callback is specified for instantaneous resource, then callback
       will be called after resource change and will be executed in the context of the
       client thread.
-      If a resource callback is specified for long latency reosurces, then it will be
+      If a resource callback is specified for long latency resources, then it will be
       executed asynchronously.When the request is accepted the API returns immediately
 	  and the calling thread is unblocked: the callback (called in the client's context) 
 	  will be invoked when the resource change finally takes place.
@@ -2424,7 +2420,7 @@
 @param aCb         For Long latency resource
                        A pointer to a resource callback object which encapsulates a
                        callback function to be called whenever the resource state change
-                       happens (if left NULL the API will execute synchrounously).
+                       happens (if left NULL the API will execute synchronously).
                    For Instantaneous resource
                        A pointer to a resource callback object which encapsulates a callback
                        function to be called after resource change. This executes in the
@@ -2479,7 +2475,7 @@
 	DStaticPowerResource *pR = NULL;
 	GET_RESOURCE_FROM_LIST(aResourceId, pR) 
 #else
-	if(aResourceId > iStaticResourceArrayEntries)
+	if(aResourceId > (TUint)iStaticResourceArray.Count())
 		UNLOCK_RETURN(KErrNotFound);
 	DStaticPowerResource* pR = iStaticResourceArray[aResourceId-1];
 	if(!pR)
@@ -2563,8 +2559,8 @@
 	SPowerRequest* pS=NULL;
 	if(pR->LatencySet() && aCb)
 		{
-		// Get request object from free pool, as it is long latency reosurce as client
-		// will be unblocked once message is sent to controller, so cant use thread message.
+		// Get request object from free pool, as it is long latency resource as client
+		// will be unblocked once message is sent to controller, so can't use thread message.
 		if(pC->iReservedRm ==0 && !iRequestPoolCount)
 			{
             r = KErrUnderflow;
@@ -2617,7 +2613,7 @@
 			else
 #endif
 				{
-				req->Send(iMsgQ); // Send the request to Resource Controler thread.
+				req->Send(iMsgQ); // Send the request to Resource Controller thread.
 				return KErrNone;
 				}
 			}
@@ -2768,7 +2764,7 @@
                    state is read from resource.
 @param aState      Returns the resource state if operation was successful. This
                    could be a binary value for a binary resource, an integer level
-                   for a multilevel resource or some platform specific tolen for a
+                   for a multilevel resource or some platform specific token for a
                    multi-property resource.
 @param aLevelOwnerId Returns the Id of the client that is currently holding the resource.
 					 -1	is returned when no client is holding the resource.
@@ -2815,7 +2811,7 @@
 			UNLOCK_RETURN(KErrNotFound);
 		}
 #else
-	if(aResourceId > iStaticResourceArrayEntries)
+	if(aResourceId > (TUint)iStaticResourceArray.Count())
 		UNLOCK_RETURN(KErrNotFound);
 	DStaticPowerResource *pR = iStaticResourceArray[aResourceId-1];
 	if(!pR)
@@ -2899,7 +2895,7 @@
 @publishedPartner
 @prototype 9.5
 
-Request the state of the resource asynchrounously for long latency resource and
+Request the state of the resource asynchronously for long latency resource and
 synchronously for instantaneous resource
 
 @param aClientId  ID of the client which is requesting the resource state.
@@ -2961,7 +2957,7 @@
 			UNLOCK_RETURN(KErrNotFound);
 		}
 #else
-	if(aResourceId > iStaticResourceArrayEntries)
+	if(aResourceId > (TUint)iStaticResourceArray.Count())
 		UNLOCK_RETURN(KErrNotFound);
 	DStaticPowerResource *pR = iStaticResourceArray[aResourceId-1];
 	if(!pR)
@@ -3098,19 +3094,19 @@
 Cancel an asynchronous request(or its callback).
 
 @param aClientId       ID of the client which is requesting the cancellation of the request.
-@param aResourceId     ID for the resource which the request that is being cancelled operates
+@param aResourceId     ID for the resource which the request that is being canceled operates
                        upon.
 @param aCb             A reference to the resource callback object specified with the request
-                       that is being cancelled.
+                       that is being canceled.
 
-@return KErrCancel if the request was cancelled.
+@return KErrCancel if the request was canceled.
         KErrNotFound if this resource ID could not be found in the current list of controllable
                      resources.
         KErrCompletion if request is no longer pending.
         KErrAccessDenied if the client ID could not be found in the current list of registered
 		clients or if the client was registered to be thread relative and this API is not called
 		from the same thread or if client is not the same that requested the resource state change.
-		KErrInUse if the request cannot be cancelled as processing of the request already started 
+		KErrInUse if the request cannot be canceled as processing of the request already started 
 		and will run to completion. 
 
 @pre Interrupts must be enabled
@@ -3230,7 +3226,7 @@
 NOTE: This API should return immediately; however the notification will
 only happen when a resource change occurs.Notification request is idempotent, 
 if the same notification has already been requested for this resource ID, 
-the API returns with no further action.Notifications remain queued until they are cancelled.
+the API returns with no further action.Notifications remain queued until they are canceled.
 
 @pre Interrupts must be enabled
 @pre Kernel must be unlocked
@@ -3258,7 +3254,7 @@
 	DStaticPowerResource *pR = NULL;
 	GET_RESOURCE_FROM_LIST(aResourceId, pR)
 #else
-	if(aResourceId > iStaticResourceArrayEntries)
+	if(aResourceId > (TUint)iStaticResourceArray.Count())
 		{
         r = KErrNotFound;
 		PRM_POSTNOTIFICATION_REGISTER_TRACE
@@ -3322,7 +3318,7 @@
 
 @return KErrNone if the operation of requesting a notification was successful.
         KErrNotFound if this resource ID could not be found in the current list
-                     of controllable reosurces.
+                     of controllable resources.
         KErrAccessDenied if the client ID could not be found in the list of
                          registered clients or if the client was registered to be thread
 						 relative and this API is not called from the same thread. 
@@ -3331,7 +3327,7 @@
 NOTE: This API should return immediately; however the notification will only
 happen when a resource change occurs. Notification request is idempotent, 
 if the same notification has already been requested for this resource ID, 
-the API returns with no further action. Notification remain queued until they are cancelled.
+the API returns with no further action. Notification remain queued until they are canceled.
 
 @pre Interrupts must be enabled
 @pre Kernel must be unlocked
@@ -3361,7 +3357,7 @@
 	DStaticPowerResource *pR = NULL;
 	GET_RESOURCE_FROM_LIST(aResourceId, pR)
 #else
-	if(aResourceId > iStaticResourceArrayEntries)
+	if(aResourceId > (TUint)iStaticResourceArray.Count())
 		{
         r = KErrNotFound;
         PRM_POSTNOTIFICATION_REGISTER_TRACE
@@ -3425,12 +3421,12 @@
 
 @param aClientId ID of the client which is requesting to cancel the notification
 @param aResourceId for the resource whose pending notification of state changes
-                   is being cancelled.
+                   is being canceled.
 @param aN          A reference to the notification object that was associated with
-                   the notification request that is being cancelled. This will be
-                   used to identify the notification that is being cancelled.
+                   the notification request that is being canceled. This will be
+                   used to identify the notification that is being canceled.
 
-@return KErrCancel if the notification request was successfully cancelled.
+@return KErrCancel if the notification request was successfully canceled.
         KErrNotFound if the specified notification object is 
 					 not found in the current list of notification objects for the 
 					 specified resource.
@@ -3584,9 +3580,9 @@
 	TInt requestPoolCount = iRequestPoolCount;
 	SPowerResourceClient* pC;
 	if(aRequest.ClientId() & USER_SIDE_CLIENT_BIT_MASK)
-		pC = iUserSideClientList[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)];
+		pC = iUserSideClientList[(aRequest.ClientId() & ID_INDEX_BIT_MASK)];
 	else																				
-		pC = iClientList[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)];
+		pC = iClientList[(aRequest.ClientId() & ID_INDEX_BIT_MASK)];
 	UnLock();
 
 	if(clientPoolCount < aRequest.ClientLevelCount())
@@ -3685,7 +3681,7 @@
 	req->SendReceive(iMsgQ);
 	if(req->ReturnCode() == KErrNone)
 		{
-		pC = iUserSideClientList[(TUint16)(req->ClientId() & ID_INDEX_BIT_MASK)];
+		pC = iUserSideClientList[(req->ClientId() & ID_INDEX_BIT_MASK)];
 		pC->iName=&aName;
 		//Store the current thread Id;
 		pC->iThreadId = t.iId;
@@ -3710,7 +3706,7 @@
 	if(!(aClientId & USER_SIDE_CLIENT_BIT_MASK))
 		return KErrArgument;
 	Lock();
-	SPowerResourceClient* pC = iUserSideClientList[(TUint16)(aClientId & ID_INDEX_BIT_MASK)];
+	SPowerResourceClient* pC = iUserSideClientList[(aClientId & ID_INDEX_BIT_MASK)];
 	if(!pC)
 		{
 		UnLock();
@@ -3758,7 +3754,7 @@
 	iRequestPoolCount = (TUint16)(iRequestPoolCount + pC->iReservedRm);
 	PRM_CLIENT_DEREGISTER_TRACE
 	//Increment the free pool count for client level and request level.
-	iUserSideClientList.Remove(pC, (TUint16)(pC->iClientId & ID_INDEX_BIT_MASK));
+	iUserSideClientList.Remove(pC, (pC->iClientId & ID_INDEX_BIT_MASK));
 	pC->iName = NULL;
 	iUserSideClientCount--; //Decrement client count
 	LIST_PUSH(iClientPool, pC, iNextInList);
@@ -3795,7 +3791,7 @@
 	for(count=0;count<aNumResources;count++) //Check for valid resource ID.
 		{
 #ifndef PRM_ENABLE_EXTENDED_VERSION
-		if((!pS->iResourceId) || (pS->iResourceId > iStaticResourceArrayEntries) || (!iStaticResourceArray[pS->iResourceId-1]))
+		if((!pS->iResourceId) || (pS->iResourceId > (TUint)iStaticResourceArray.Count()) || (!iStaticResourceArray[pS->iResourceId-1]))
 			{
 			UnLock();
 			LOCK_AND_CRITICAL_SECTION_COUNT_CHECK
@@ -3809,8 +3805,8 @@
 			return KErrNotSupported;
 			}
 		if((!pS->iResourceId) || ((pS->iResourceId & KIdMaskResourceWithDependencies) && 
-			     (pS->iResourceId > iStaticResDependencyCount)) || (!(pS->iResourceId & KIdMaskResourceWithDependencies) && 
-					((pS->iResourceId > iStaticResourceArrayEntries) || (!iStaticResourceArray[pS->iResourceId-1]))))
+			     (pS->iResourceId > (TUint)iStaticResDependencyArray.Count())) || (!(pS->iResourceId & KIdMaskResourceWithDependencies) && 
+					((pS->iResourceId > (TUint)iStaticResourceArray.Count()) || (!iStaticResourceArray[pS->iResourceId-1]))))
 			{
 			UnLock();
 			LOCK_AND_CRITICAL_SECTION_COUNT_CHECK
@@ -3885,7 +3881,7 @@
 	if(aResourceId & KIdMaskDynamic)
 		((DDynamicPowerResource*)pR)->Lock();
 #else
-	if(aResourceId > iStaticResourceArrayEntries)
+	if(aResourceId > (TUint)iStaticResourceArray.Count())
 		{
 		UNLOCK_RETURN(KErrNotFound);
 		}
--- a/kernel/eka/drivers/resourceman/resourcecontrol_extended.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/drivers/resourceman/resourcecontrol_extended.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -35,14 +35,14 @@
 		iResourceLevelPoolCount = (TUint16)(iResourceLevelPoolCount - aCount);
 	else
 		{
-		TUint allocCount = (iStaticResDependencyCount / 2) + aCount;
+		TUint allocCount = (iStaticResDependencyArray.Count() / 2) + aCount;
 		// coverity[alloc_fn]
 		SPowerResourceClientLevel* pCL = new SPowerResourceClientLevel[allocCount];
 		if(!pCL)
 			return KErrNoMemory;
 		for(TUint count = 0;count<(TUint)(allocCount);count++)
 			LIST_PUSH(iResourceLevelPool, &pCL[count], iNextInList);
-		iResourceLevelPoolCount= (TUint16)(iResourceLevelPoolCount + (iStaticResDependencyCount / 2));
+		iResourceLevelPoolCount= (TUint16)(iResourceLevelPoolCount + (iStaticResDependencyArray.Count() / 2));
 #ifdef PRM_INSTRUMENTATION_MACRO
 		TUint size = allocCount * sizeof(SPowerResourceClientLevel);
 		PRM_MEMORY_USAGE_TRACE
@@ -79,16 +79,16 @@
 	SNode* pN;
 	if(aResourceId & KIdMaskDynamic)
 		{
-		DDynamicPowerResourceD* pDR = iDynamicResDependencyList[(TUint16)(aResourceId & ID_INDEX_BIT_MASK)];		
+		DDynamicPowerResourceD* pDR = iDynamicResDependencyList[(aResourceId & ID_INDEX_BIT_MASK)];		
 		if(!pDR)														
 			return KErrNotFound;
 		pN = pDR->iDependencyList;
 		}
 	else
 		{
-		if((aResourceId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount)
+		if((aResourceId & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count())
 			return KErrNotFound;
-		DStaticPowerResourceD* pDR = iStaticResDependencyArray[(TUint16)(aResourceId & ID_INDEX_BIT_MASK) - 1];
+		DStaticPowerResourceD* pDR = iStaticResDependencyArray[(aResourceId & ID_INDEX_BIT_MASK) - 1];
 		pN = pDR->iDependencyList;
 		}
 	*aNumResources = 0;
@@ -123,16 +123,16 @@
 	SNode* pN;
 	if(aResourceId & KIdMaskDynamic)
 		{
-		DDynamicPowerResourceD* pDR = iDynamicResDependencyList[(TUint16)(aResourceId & ID_INDEX_BIT_MASK)];
+		DDynamicPowerResourceD* pDR = iDynamicResDependencyList[(aResourceId & ID_INDEX_BIT_MASK)];
 		if(!pDR)
 			return KErrNotFound;
 		pN = pDR->iDependencyList;
 		}
 	else
 		{
-		if((aResourceId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount)
+		if((aResourceId & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count())
 			return KErrNotFound;
-		DStaticPowerResourceD* pDR = iStaticResDependencyArray[(TUint16)(aResourceId & ID_INDEX_BIT_MASK) -1];
+		DStaticPowerResourceD* pDR = iStaticResDependencyArray[(aResourceId & ID_INDEX_BIT_MASK) -1];
 		pN = pDR->iDependencyList;
 		}
 	TUint count = 0;
@@ -184,31 +184,31 @@
 	//Retrieve resource1 from the corresponding list.
 	if(aInfo1->iResourceId & KIdMaskDynamic)
 		{
-		pR1 = iDynamicResDependencyList[(TUint16)(aInfo1->iResourceId & ID_INDEX_BIT_MASK)];
+		pR1 = iDynamicResDependencyList[(aInfo1->iResourceId & ID_INDEX_BIT_MASK)];
 		if(!pR1)
 			return KErrNotFound;
 		pN1 = pR1->iDependencyList;
 		}
 	else 
 		{
-		if((aInfo1->iResourceId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount)
+		if((aInfo1->iResourceId & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count())
 			return KErrNotFound;
-		pR1 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(TUint16)(aInfo1->iResourceId & ID_INDEX_BIT_MASK) - 1];
+		pR1 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aInfo1->iResourceId & ID_INDEX_BIT_MASK) - 1];
 		pN1 = ((DStaticPowerResourceD*)pR1)->iDependencyList;
 		}
 	//Retrieve resource2 from the corresponding list.
 	if(aInfo2->iResourceId & KIdMaskDynamic)
 		{
-		pR2 = iDynamicResDependencyList[(TUint16)(aInfo2->iResourceId & ID_INDEX_BIT_MASK)];
+		pR2 = iDynamicResDependencyList[(aInfo2->iResourceId & ID_INDEX_BIT_MASK)];
 		if(!pR2)
 			return KErrNotFound;
 		pN2 = pR2->iDependencyList;
 		}
 	else
 		{
-		if((aInfo2->iResourceId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount)
+		if((aInfo2->iResourceId & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count())
 			return KErrNotFound;
-		pR2 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(TUint16)(aInfo2->iResourceId & ID_INDEX_BIT_MASK) - 1];
+		pR2 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aInfo2->iResourceId & ID_INDEX_BIT_MASK) - 1];
 		pN2 = ((DStaticPowerResourceD*)pR2)->iDependencyList;
 		}
 
@@ -325,13 +325,13 @@
 	//Get the resource from appropriate container
 	if(aResourceId & KIdMaskResourceWithDependencies)
 		{
-		pDR = iDynamicResDependencyList[(TUint16)(aResourceId & ID_INDEX_BIT_MASK)];		
+		pDR = iDynamicResDependencyList[(aResourceId & ID_INDEX_BIT_MASK)];		
 		if(!pDR)														
 			return KErrNotFound;
 		}
 	else
 		{
-		pDR = iDynamicResourceList[(TUint16)(aResourceId & ID_INDEX_BIT_MASK)];		
+		pDR = iDynamicResourceList[(aResourceId & ID_INDEX_BIT_MASK)];		
 		if(!pDR)														
 			return KErrNotFound;
 		}
@@ -460,9 +460,9 @@
 		{
 		pCL = (SPowerResourceClientLevel*)pRC;
 		if(pCL->iClientId & USER_SIDE_CLIENT_BIT_MASK)
-			pC = iUserSideClientList[(TUint16)(pCL->iClientId & ID_INDEX_BIT_MASK)];								
+			pC = iUserSideClientList[(pCL->iClientId & ID_INDEX_BIT_MASK)];								
 		else																										
-			pC = iClientList[(TUint16)(pCL->iClientId & ID_INDEX_BIT_MASK)];										
+			pC = iClientList[(pCL->iClientId & ID_INDEX_BIT_MASK)];										
 		LIST_REMOVE(pC->iLevelList, pCL, iNextInList, SPowerResourceClientLevel);
 		LIST_PUSH(iClientLevelPool, pCL, iNextInList);
 		if(pC->iUnderFlowClCount > 0)
@@ -477,12 +477,12 @@
 	aClientPtr->iDynamicResCount--;
 	if(aResourceId & KIdMaskResourceWithDependencies)
 		{
-		iDynamicResDependencyList.Remove((DDynamicPowerResourceD*)pDR, (TUint16)(pDR->iResourceId & ID_INDEX_BIT_MASK));
+		iDynamicResDependencyList.Remove((DDynamicPowerResourceD*)pDR, (pDR->iResourceId & ID_INDEX_BIT_MASK));
 		iDynamicResDependencyCount--;
 		}
 	else
 		{
-		iDynamicResourceList.Remove(pDR, (TUint16)(pDR->iResourceId & ID_INDEX_BIT_MASK));
+		iDynamicResourceList.Remove(pDR, (pDR->iResourceId & ID_INDEX_BIT_MASK));
 		iDynamicResourceCount--;
 		}
 	__KTRACE_OPT(KRESMANAGER, Kern::Printf("<DExtendedResourceController::DeregisterDynamicResource"));
@@ -498,12 +498,10 @@
 @prototype 9.6
 Default implementation, PSL re-implements this if features supported.
 */
-TInt DPowerResourceController::DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, 
-																    TUint16& aStaticResourceDCount)
+TInt DPowerResourceController::DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray)
 	{
 	__KTRACE_OPT(KRESMANAGER, Kern::Printf("DExtendedResourceController::DoRegisterStaticResourcesDependency default implementation"));
-	aStaticResourceDArray = NULL;
-	aStaticResourceDCount = 0;
+	aStaticResourceDArray.Reset();
 	return KErrNone;
 	}
 
@@ -708,18 +706,18 @@
 			{																							
 			DStaticPowerResourceD* pResource;												
 			if(aRequest.ClientId() & KIdMaskDynamic)										
-				pResource = (DStaticPowerResourceD*)iDynamicResDependencyList[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)];
+				pResource = (DStaticPowerResourceD*)iDynamicResDependencyList[(aRequest.ClientId() & ID_INDEX_BIT_MASK)];
 			else																						
-				pResource = iStaticResDependencyArray[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)  - 1];	
+				pResource = iStaticResDependencyArray[(aRequest.ClientId() & ID_INDEX_BIT_MASK)  - 1];	
 			name = pResource->iName;																	
 			}																							
 		else																							
 			{																							
 			SPowerResourceClient* pClient;																
 			if(aRequest.ClientId() & USER_SIDE_CLIENT_BIT_MASK)										
-				pClient = iUserSideClientList[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)];	
+				pClient = iUserSideClientList[(aRequest.ClientId() & ID_INDEX_BIT_MASK)];	
 			else // coverity[returned_null]
-				pClient = iClientList[(TUint16)(aRequest.ClientId() & ID_INDEX_BIT_MASK)];			
+				pClient = iClientList[(aRequest.ClientId() & ID_INDEX_BIT_MASK)];			
 			name = pClient->iName;				
 			}
 		}
@@ -762,7 +760,7 @@
 
 	if(aResId1 & KIdMaskDynamic)
 		{
-		pDR1 = iDynamicResDependencyList[(TUint16)(aResId1 & ID_INDEX_BIT_MASK)];	
+		pDR1 = iDynamicResDependencyList[(aResId1 & ID_INDEX_BIT_MASK)];	
 		if(!pDR1)															
 			UNLOCK_RETURN(KErrNotFound);
 		pN1 = pDR1->iDependencyList;
@@ -770,7 +768,7 @@
 		}
 	else
 		{
-		if((aResId1 & ID_INDEX_BIT_MASK) > iStaticResDependencyCount)			
+		if((aResId1 & ID_INDEX_BIT_MASK) > (TUint)iStaticResDependencyArray.Count())			
 			UNLOCK_RETURN(KErrNotFound);			
 		pDR1 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aResId1 & ID_INDEX_BIT_MASK) - 1];
 		pN1 = ((DStaticPowerResourceD*)pDR1)->iDependencyList;
@@ -780,7 +778,7 @@
 	//Get second resource from list
 	if(aResId2 & KIdMaskDynamic)
 		{
-		pDR2 = iDynamicResDependencyList[(TUint16)(aResId2 & ID_INDEX_BIT_MASK)];	
+		pDR2 = iDynamicResDependencyList[(aResId2 & ID_INDEX_BIT_MASK)];	
 		if(!pDR2)															
 			UNLOCK_RETURN(KErrNotFound);
 		pN2 = pDR2->iDependencyList;
@@ -788,9 +786,9 @@
 		}
 	else
 		{
-		if((aResId2 & ID_INDEX_BIT_MASK)> iStaticResDependencyCount)			
+		if((aResId2 & ID_INDEX_BIT_MASK)> (TUint)iStaticResDependencyArray.Count())			
 				UNLOCK_RETURN(KErrNotFound);			
-		pDR2 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(TUint16)(aResId2 & ID_INDEX_BIT_MASK) - 1];
+		pDR2 = (DDynamicPowerResourceD*)iStaticResDependencyArray[(aResId2 & ID_INDEX_BIT_MASK) - 1];
 		pN2 = ((DStaticPowerResourceD*)pDR2)->iDependencyList;
 		pCL2 = ((DStaticPowerResourceD*)pDR2)->iResourceClientList;
 		}
--- a/kernel/eka/include/drivers/mmc.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/include/drivers/mmc.h	Thu Aug 12 11:55:14 2010 +0100
@@ -3014,6 +3014,10 @@
 	inline void EnableDoubleBuffering(TUint32 aNumBlocks);							  /**< @internalTechnology */
 	inline void SetDataTransferCallback(TMMCCallBack& aCallback);					  /**< @internalTechnology */
 	inline void MoreDataAvailable(TUint32 aNumBlocks, TUint8* aMemoryP, TInt aError); /**< @internalTechnology */
+
+	inline void SaveCard();			/**< @internalTechnology */
+	inline void RestoreCard();		/**< @internalTechnology */
+
 public:
 	/**
     The last R1 response.
@@ -3057,7 +3061,9 @@
 	
 	TMMCCallBack iDataTransferCallback;	// A callback function, used to request more data when performing double-buffering
 
-	TUint32 iSpare[22];				// Spare data (stolen from iCommand)
+	TUint32 iSpare[21];				// Spare data (stolen from iCommand)
+
+	TMMCard* iSavedCardP;			// Saved copy of iCardP
 
 	TMMCStateMachine iMachine;		// State Machine context
 #ifdef __EPOC32__
@@ -3091,7 +3097,8 @@
 		KInterfaceSetBusWidth,
 		KInterfaceDemandPagingInfo,
 		KInterfaceCancelSession,
-		KInterfaceDoWakeUpSM
+		KInterfaceDoWakeUpSM,
+		KInterfaceAddressCard,
 		};
 
 	/** generic interface */
@@ -3137,6 +3144,17 @@
 		virtual TMMCErr DoWakeUpSM()=0;
 		};
 
+	/**
+	 * An optional interface implemented by the derived class. Used when the stack supports more than one 
+	 * card and the cards are individually selectable, i.e. iMultiplexedBus is true
+	 * @see KInterfaceAddressCard
+	 */
+	class MAddressCard
+		{
+	public:
+		virtual void AddressCard(TInt aCardNumber)=0;
+		};
+
 
 public:
 	IMPORT_C DMMCStack(TInt aBus, DMMCSocket* aSocket);
@@ -3526,6 +3544,8 @@
 
 	void DetermineBusWidthAndClock(const TMMCard& aCard, TBool aLowVoltage, TUint& aPowerClass, TBusWidthAndClock& aBusWidthAndClock);
 	TUint GetPowerClass(const TMMCard& aCard, TBusWidthAndClock aWidthAndClock, TBool aLowVoltage);
+	
+	void DoAddressCard(TInt aCardNumber);
 
 
     //	----------- Data Members -------------
@@ -3604,6 +3624,8 @@
 protected:
 	/** 
 	Gets an interface from a derived class
+	N.B the derived class should call the base class's default implementation of this function
+	if it does not support the specified interface
 	replaces reserved virtual Dummy4()
 	*/
 	IMPORT_C virtual void GetInterface(TInterfaceId aInterfaceId, MInterface*& aInterfacePtr);
@@ -4107,6 +4129,7 @@
 		EMMCUnblockingInWrongContext	=18,
 		EMMCInvalidCardNumber			=19,
 		EMMCNotInDfcContext				=20,
+		EMMCAddressCardNotSupported		=21,
 		};
     IMPORT_C static void Panic(TMMCPanic aPanic);
 	friend class DMMCStack;
--- a/kernel/eka/include/drivers/mmc.inl	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/include/drivers/mmc.inl	Thu Aug 12 11:55:14 2010 +0100
@@ -1127,6 +1127,18 @@
 	return(EFalse);
 	}
 
+inline void DMMCSession::SaveCard()
+	{
+	if (iCardP)
+		iSavedCardP = iCardP;
+	}
+
+inline void DMMCSession::RestoreCard()
+	{
+	if (iSavedCardP)
+		iCardP = iSavedCardP;
+	iSavedCardP = NULL;
+	}
 
 //	--------  class DMMCSocket  --------
 
--- a/kernel/eka/include/drivers/resmanus.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/include/drivers/resmanus.h	Thu Aug 12 11:55:14 2010 +0100
@@ -270,7 +270,7 @@
 	TInt ExtractResourceInfo(const TPowerResourceInfoV01* aPwrResInfo, TResourceInfoBuf& aInfo);
 #ifdef _DUMP_TRACKERS
 	TInt DumpResource(const TPowerResourceInfoV01* aResource);
-	TInt DumpTracker(TTrackingControl* aTracker);
+	void DumpTracker(TTrackingControl* aTracker);
 #endif
 #ifdef RESOURCE_MANAGER_SIMULATED_PSL
 	void CheckForCandidateAsyncResource(TPowerResourceInfoV01* aResource);
--- a/kernel/eka/include/drivers/resource.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/include/drivers/resource.h	Thu Aug 12 11:55:14 2010 +0100
@@ -12,7 +12,7 @@
 //
 // Description:
 // e32\include\drivers\resource.h
-// 
+//
 // WARNING: This file contains some APIs which are internal and are subject
 //          to change without notice. Such APIs should therefore not be used
 //          outside the Kernel and Hardware Services package.
@@ -26,18 +26,18 @@
 #include <drivers/resource_category.h>
 
 //Definition for resource flag setting. Used by PSL.
-static const TUint KTypeMask= 0x3;
-static const TUint KUsageOffset=0x1F;
-static const TUint KLongLatencySetOffset=0x1E;
-static const TUint KLongLatencyGetOffset=0x1D;
-static const TUint KClassOffset=0x1C;
-static const TUint KSenseOffset=0x1A;
-static const TUint KShared=0x1U<<KUsageOffset;
-static const TUint KLongLatencySet=0x1<<KLongLatencySetOffset;
-static const TUint KLongLatencyGet=0x1<<KLongLatencyGetOffset;
-static const TUint KLogical=0x1<<KClassOffset;
-static const TUint KSenseNegative=0x01<<KSenseOffset;
-static const TUint KSenseCustom=0x2<<KSenseOffset;
+const TUint KTypeMask             = 0x3;
+const TUint KUsageOffset          = 0x1F;
+const TUint KLongLatencySetOffset = 0x1E;
+const TUint KLongLatencyGetOffset = 0x1D;
+const TUint KClassOffset          = 0x1C;
+const TUint KSenseOffset          = 0x1A;
+const TUint KShared               = 0x1u << KUsageOffset;
+const TUint KLongLatencySet       = 0x1u << KLongLatencySetOffset;
+const TUint KLongLatencyGet       = 0x1u << KLongLatencyGetOffset;
+const TUint KLogical              = 0x1u << KClassOffset;
+const TUint KSenseNegative        = 0x1u << KSenseOffset;
+const TUint KSenseCustom          = 0x2u << KSenseOffset;
 
 struct TPowerRequest;
 struct SIdleResourceInfo;
@@ -149,7 +149,7 @@
 /**
 @publishedPartner
 @prototype 9.5
-An object of this type prepresents a customised Dfc
+An object of this type represents a customized Dfc
 used to signal completion of the resource manager's asynchronous APIs
 and completion of notifications
 @see TPowerResourceManager
@@ -191,16 +191,18 @@
 private:
     void Lock()
         {
+		__ASSERT_DEBUG(iMutex, Kern::Fault("TPowerResourceCb::Lock", __LINE__));
         NKern::ThreadEnterCS();
         Kern::MutexWait(*iMutex);
         }
     void UnLock()
         {
+		__ASSERT_DEBUG(iMutex, Kern::Fault("TPowerResourceCb::UnLock", __LINE__));
         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 iResult; //Used to store the result as well as binary usage count for the callback
     TInt iLevel; // Level of the resource
 	TInt iLevelOwnerId; // Stores owner of the resource for asynchronous get operation
     TUint iResourceId; //Stores the ID of the resource whose state is changed/read asynchronously
--- a/kernel/eka/include/drivers/resourcecontrol.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/include/drivers/resourcecontrol.h	Thu Aug 12 11:55:14 2010 +0100
@@ -12,7 +12,7 @@
 //
 // Description:
 // e32\include\drivers\resourcecontrol.h
-// 
+//
 // WARNING: This file contains some APIs which are internal and are subject
 //          to change without notice. Such APIs should therefore not be used
 //          outside the Kernel and Hardware Services package.
@@ -133,9 +133,9 @@
 /* Macro to add dynamic resource to appropriate containers. Used only in extended version */
 #define ADD_TO_RESOURCE_CONTAINER(list, res, resId, resIdCount)				\
 	{																		\
-	TUint16 growBy = (list).GrowBy();										\
+	TInt growBy = (list).GrowBy();										\
 	if(!growBy)																\
-		(list).Initialise((TUint16)PRM_DYNAMIC_RESOURCE_INITIAL_SIZE);		\
+		(list).Initialise(PRM_DYNAMIC_RESOURCE_INITIAL_SIZE);		\
 	if((list).Add(res, resId) == KErrNoMemory)								\
 		{																	\
 		TInt r = (list).ReSize(growBy);										\
@@ -154,24 +154,24 @@
 	switch((resId >> RESOURCE_BIT_IN_ID_CHECK) & 0x3)											\
 		{																						\
 		case PRM_STATIC_RESOURCE:																\
-			if(resId > iStaticResourceArrayEntries)												\
+			if((TInt)resId > iStaticResourceArray.Count())										\
 				UNLOCK_RETURN(KErrNotFound);													\
 			res = iStaticResourceArray[resId - 1];												\
 			if(!res)																			\
 				UNLOCK_RETURN(KErrNotFound);													\
 			break;																				\
 		case PRM_STATIC_DEPENDENCY_RESOURCE:													\
-			if((TUint16)(resId & ID_INDEX_BIT_MASK) > iStaticResDependencyCount)				\
+			if((TInt)(resId & ID_INDEX_BIT_MASK) > iStaticResDependencyArray.Count())	\
 				UNLOCK_RETURN(KErrNotFound);													\
-			res = iStaticResDependencyArray[(TUint16)(resId & ID_INDEX_BIT_MASK)  - 1];			\
+			res = iStaticResDependencyArray[(resId & ID_INDEX_BIT_MASK)  - 1];			\
 			break;																				\
 		case PRM_DYNAMIC_RESOURCE:																\
-			res = iDynamicResourceList[(TUint16)(resId & ID_INDEX_BIT_MASK)];					\
+			res = iDynamicResourceList[(resId & ID_INDEX_BIT_MASK)];					\
 			if(!res)																			\
 				UNLOCK_RETURN(KErrNotFound);													\
 			break;																				\
 		case PRM_DYNAMIC_DEPENDENCY_RESOURCE:													\
-			res = iDynamicResDependencyList[(TUint16)(resId & ID_INDEX_BIT_MASK)];				\
+			res = iDynamicResDependencyList[(resId & ID_INDEX_BIT_MASK)];				\
 			if(!res)																			\
 				UNLOCK_RETURN(KErrNotFound);													\
 			break;																				\
@@ -185,9 +185,9 @@
    it is called from the same thread. */
 #define VALIDATE_CLIENT(t)																						\
 	if(aClientId & USER_SIDE_CLIENT_BIT_MASK)																	\
-		pC = iUserSideClientList[(TUint16)(aClientId & ID_INDEX_BIT_MASK)];										\
+		pC = iUserSideClientList[(aClientId & ID_INDEX_BIT_MASK)];										\
 	else																										\
-		pC = iClientList[(TUint16)(aClientId & ID_INDEX_BIT_MASK)];												\
+		pC = iClientList[(aClientId & ID_INDEX_BIT_MASK)];												\
 	if(!pC)																										\
 		{																										\
 		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Client ID not Found"));											\
@@ -210,9 +210,9 @@
 /** Macro to get the target client from appropriate client list based on bit 14 of client ID. */
 #define GET_TARGET_CLIENT()																				\
 	if(aTargetClientId & USER_SIDE_CLIENT_BIT_MASK) 													\
-		pC = iUserSideClientList[(TUint16)(aTargetClientId & ID_INDEX_BIT_MASK)];	    				\
+		pC = iUserSideClientList[(aTargetClientId & ID_INDEX_BIT_MASK)];	    				\
 	else																								\
-		pC = iClientList[(TUint16)(aTargetClientId & ID_INDEX_BIT_MASK)];								\
+		pC = iClientList[(aTargetClientId & ID_INDEX_BIT_MASK)];								\
 	if(!pC)																								\
 		{																								\
 		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Target Client ID not found"));							\
@@ -318,16 +318,16 @@
 class DResourceCon : public DBase
 	{
 public:
-    inline TInt Initialise(TUint16 aInitialSize);
+    inline TInt Initialise(TInt aInitialSize);
     inline void Delete();
-    inline T*  operator[](TUint16 aIndex);
-    inline TInt Remove(T* aObj, TUint16 aIndex);
+    inline T*  operator[](TInt aIndex);
+    inline TInt Remove(T* aObj, TInt aIndex);
     inline TInt Add(T* aObj, TUint &aId);
     inline TInt Find(T*& anEntry, TDesC& aName);
-    inline TInt ReSize(TUint16 aGrowBy);
-    inline TUint16 Count() {return iCount;}
-    inline TUint16 Allocd() {return iAllocated;}
-	inline TUint16 GrowBy() {return iGrowBy;}
+    inline TInt ReSize(TInt aGrowBy);
+    inline TInt Count() {return iCount;}
+    inline TInt Allocd() {return iAllocated;}
+	inline TInt GrowBy() {return iGrowBy;}
 private:
     TUint16 iGrowBy; //Size to grow the size of the array.
     TUint16 iAllocated;  //Size of the array
@@ -454,7 +454,6 @@
     virtual TInt RegisterResourcesForIdle(TInt aPowerControllerId, TUint aNumResources, TPtr* aBuf);
     static void Panic(TUint8 aPanic);
     virtual TInt GetInterface(TUint aClientId, TUint aInterfaceId, TAny* aParam1, TAny* aParam2, TAny* aParam3);
-	virtual ~DPowerResourceController();
 	/**@internalComponent*/
 	void CompleteNotifications(TInt aClientId, DStaticPowerResource* aResource, TInt aState, TInt aReturnCode, TInt aLevelOwnerId, TBool aLock = ETrue);
 #ifdef PRM_ENABLE_EXTENDED_VERSION
@@ -481,12 +480,12 @@
 							  NKern::ThreadLeaveCS();}
 #ifdef PRM_ENABLE_EXTENDED_VERSION
 	//Default implementation, PSL re-implements these if features supported
-	virtual TInt DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount);
+	virtual TInt DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray);
 #endif
 private:
     // pure virtual implemented by PSL - to be called by PIL
     virtual TInt DoInitController()=0;
-    virtual TInt DoRegisterStaticResources(DStaticPowerResource**& aStaticResourceArray, TUint16& aStaticResourceCount)=0;
+    virtual TInt DoRegisterStaticResources(RPointerArray <DStaticPowerResource> & aStaticResourceArray)=0;
     /**@internalComponent*/
     TInt CheckLevelAndAddClient(SPowerResourceClient* pC, TPowerRequest* Request);
     static void MsgQFunc(TAny* aPtr);
@@ -523,18 +522,16 @@
 	TInt GetDependentsIdForResource(TUint aResourceId, TAny* aInfo, TUint* aNumDepResources);
 	TInt HandleResourceRegistration(TPowerRequest& aReq);
 #endif
-public:
+protected:
 	DMutex* iResourceMutex;
-protected:
-    TDfcQue* iDfcQ;
+	TDfcQue* iDfcQ;
     TMessageQue *iMsgQ;
 #ifdef PRM_ENABLE_EXTENDED_VERSION
 	TDfcQue* iDfcQDependency;
 	TMessageQue* iMsgQDependency;
 	TBool iDfcQDependencyLock;
 #endif
-private:
-    DStaticPowerResource** iStaticResourceArray;
+	RPointerArray <DStaticPowerResource> iStaticResourceArray;
     DResourceCon<SPowerResourceClient> iClientList;
     DResourceCon<SPowerResourceClient> iUserSideClientList;
 #ifdef RESOURCE_MANAGER_SIMULATED_PSL
@@ -552,19 +549,18 @@
     TUint16 iClientLevelPoolGrowBy;
     TUint16 iRequestPoolCount;
     TUint16 iRequestPoolGrowBy;
-    TUint16 iStaticResourceArrayEntries; //Number of entries in the array including holes if any.
 	TUint16 iStaticResourceCount;  //Actual number of static resources registered (valid entries).
 	TUint	iReserved2; //Reserved for future use
 #ifdef PRM_ENABLE_EXTENDED_VERSION
-	DResourceCon<DDynamicPowerResource> iDynamicResourceList;
-	DResourceCon<DDynamicPowerResourceD> iDynamicResDependencyList;
-	DStaticPowerResourceD** iStaticResDependencyArray;
+	DResourceCon<DDynamicPowerResource>   iDynamicResourceList;
+	DResourceCon<DDynamicPowerResourceD>  iDynamicResDependencyList;
+	RPointerArray <DStaticPowerResourceD> iStaticResDependencyArray;
 	SPowerResourceClientLevel* iResourceLevelPool;
 	TUint16 iResourceLevelPoolCount;
-	TUint16 iStaticResDependencyCount;
 	TUint16 iDynamicResourceCount;
-	TUint8 iDynamicResDependencyCount;
-	TUint8 iSpare2;
+	TUint8  iDynamicResDependencyCount;
+	TUint8  iSpare1;
+	TUint16 iSpare2;
 	TUint  iReserved3; //Reserved for future use.
 #endif
 	};
--- a/kernel/eka/include/drivers/resourcecontrol.inl	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/include/drivers/resourcecontrol.inl	Thu Aug 12 11:55:14 2010 +0100
@@ -30,7 +30,7 @@
 /** Second stage constructor
  Allocates the specified size in kernel heap and creates a virtual link */
 template <class T>
-inline TInt DResourceCon<T>::Initialise(TUint16 aInitialSize)
+inline TInt DResourceCon<T>::Initialise(TInt aInitialSize)
 	{
     __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DResourceCon<T>::Initialise"));
     __KTRACE_OPT(KRESMANAGER, Kern::Printf("aInitialSize %d", aInitialSize));
@@ -47,8 +47,8 @@
 		for(TInt c = 0; c < aInitialSize; c++)
 			iArray[c] = (T*)(c+1);
 		}
-    iAllocated = aInitialSize;
-    iGrowBy = aInitialSize < 2 ? aInitialSize : TUint16(aInitialSize/2);
+    iAllocated = (TUint16)aInitialSize;
+    iGrowBy = (TUint16) (aInitialSize < 2 ? aInitialSize : aInitialSize/2);
     iCount = 0;
     iInstanceCount = 0;
     iFreeLoc = 0;
@@ -65,7 +65,7 @@
 
 /** Resize the array */
 template <class T>
-inline TInt DResourceCon<T>::ReSize(TUint16 aGrowBy)
+inline TInt DResourceCon<T>::ReSize(TInt aGrowBy)
 	{
     __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DResourceCon<T>::ReSize"));
     __KTRACE_OPT(KRESMANAGER, Kern::Printf("aGrowBy %d\n", aGrowBy));
@@ -73,7 +73,7 @@
 	TInt r = Kern::SafeReAlloc((TAny*&)iArray, iAllocated * sizeof(T*), (iAllocated+aGrowBy)*sizeof(T*));
 	if(r != KErrNone)
 		return r;
-    TUint16 c = iAllocated;
+    TInt c = iAllocated;
     //Virtually link the free ones
     while(c<(iAllocated+aGrowBy))
 		{
@@ -94,11 +94,12 @@
 inline void DResourceCon<T>::Delete()
 	{
     delete []iArray;
+    iArray = NULL;
 	}
 
 /** Find the object at the specified location */
 template <class T>
-inline T* DResourceCon<T>::operator[](TUint16 anIndex)
+inline T* DResourceCon<T>::operator[](TInt anIndex)
 	{
     __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DResourceCon<T>::operator[], anIndex = %d", anIndex));
 	// Check if passed index is inside allocated range and is not free.
@@ -109,17 +110,17 @@
 
 /** Remove the specified object from the container */
 template <class T>
-inline TInt DResourceCon<T>::Remove(T* /*aObj */, TUint16 aIndex)
+inline TInt DResourceCon<T>::Remove(T* /*aObj */, TInt aIndex)
 	{
     __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DResourceCon<T>::Remove"));
-    if(aIndex>=iAllocated)
+    if(aIndex>=(TInt)iAllocated)
 		{
 		__KTRACE_OPT(KRESMANAGER, Kern::Printf("Object not found, iAllocated = %d, index = %d", iAllocated, aIndex));
 		DPowerResourceController::Panic(DPowerResourceController::EObjectNotFoundInList);
 		}
 	// Add the entry to the free location
 	iArray[aIndex] = (T*)iFreeLoc;
-	iFreeLoc = aIndex;
+	iFreeLoc = (TUint16)aIndex;
     iCount--; //Decrement valid client count
 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">DResourceCon<T>::Remove"));
     return KErrNone;
@@ -136,9 +137,9 @@
     //Update in the array in the free location
 	aId = ((++iInstanceCount & INSTANCE_COUNT_BIT_MASK) << INSTANCE_COUNT_POS); //Instance count
 	aId |= (iFreeLoc & ID_INDEX_BIT_MASK); //Array index
-    TUint16 nextFreeLoc = (TUint16)(TUint)iArray[iFreeLoc];
+    TUint nextFreeLoc = (TUint)iArray[iFreeLoc];
     iArray[iFreeLoc] = aObj;
-    iFreeLoc = nextFreeLoc;
+    iFreeLoc = (TUint16)nextFreeLoc;
     __KTRACE_OPT(KRESMANAGER, Kern::Printf("iFreeLoc %d", iFreeLoc));
     iCount++;  //Increment the valid client count
     return KErrNone;
@@ -151,7 +152,7 @@
     __KTRACE_OPT(KRESMANAGER, Kern::Printf(">DResourceCon<T>::Find, aName %S", &aName));
     anEntry = NULL;
     T* pC=anEntry;
-    for(TUint count = 0; count<iAllocated; count++)
+    for(TInt count = 0; count < (TInt)iAllocated; count++)
 		{
         /* Check whether the location is free */
         if(((TUint)iArray[count]) <= iAllocated)
--- a/kernel/eka/include/drivers/sdcard.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/include/drivers/sdcard.h	Thu Aug 12 11:55:14 2010 +0100
@@ -147,6 +147,17 @@
 
 const TInt KSDMaxMBWRetries = 1;
 const TUint32 KSDACMD22BlockLen = 4;
+
+NONSHARABLE_CLASS(DAddressCard) : public DMMCStack::MAddressCard
+	{
+public:
+	DAddressCard(DSDStack& aStack);
+	virtual void AddressCard(TInt aCardNumber);
+private:
+	DSDStack& iStack;
+	};
+
+
 class DSDStack : public DMMCStack
 	{
 public:
@@ -191,15 +202,19 @@
     // Dummy functions to maintain binary compatibility
     IMPORT_C virtual void Dummy1();
     IMPORT_C virtual void Dummy2();
-    IMPORT_C virtual void Dummy3();
+
+protected:
+	IMPORT_C virtual void GetInterface(TInterfaceId aInterfaceId, MInterface*& aInterfacePtr);
 
 public: 
     IMPORT_C virtual DSDStack::TSDCardType CardType(TInt aSocket, TInt aCardNumber);
 
 private:    
+	DAddressCard* iAddressCard;
     //
     // Reserved members to maintain binary compatibility
-    TInt iReserved[68];
+
+    TInt iReserved[67];
 	};
 
 #include <drivers/sdcard.inl>
--- a/kernel/eka/include/kernel/kpower.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/include/kernel/kpower.h	Thu Aug 12 11:55:14 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1998-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"
@@ -155,6 +155,16 @@
     @see TPowerState
 	*/
 	virtual void PowerDown(TTimeK aWakeupTime) = 0;
+
+	/**
+	Registers resources of interest for Idle with Resource Manager
+
+	Function also provided for power controller to perform other operations if required.
+	*/
+	virtual TInt DoRegisterResourceController()
+		{
+		return KErrNone;
+		}
 	};
 
 #ifndef __X86__
--- a/kernel/eka/kernel/power.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/kernel/power.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1998-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"
@@ -666,7 +666,9 @@
     iResourceControllerData.iResourceController = aController;
     //Store the client Id generated by Resource controller for Power controller to use.
     iResourceControllerData.iClientId = aClientId;
-    return KErrNone;
+	
+	// Perform variant specific operations e.g. trigger registration of resources for idle with Resource Manager
+    return DoRegisterResourceController();
 	}
 
 /**
--- a/kernel/eka/release.txt	Fri Aug 06 16:34:38 2010 +0100
+++ b/kernel/eka/release.txt	Thu Aug 12 11:55:14 2010 +0100
@@ -1,3 +1,29 @@
+Version 2.00.3111
+=================
+(Made by fadhliM 26/07/2010)
+
+1.	lforynsk
+	1.	ou1cimx1#500491 Resource Manager PIL reallocates an array that it doesn't create or delete (kernelhwsrv)
+	2.	ou1cimx1#500836 Resource manager does not response to an asynchronous request if the resource level owner send a request with the same level
+
+2.	gayarama
+	1.	ou1cimx1#473162 DEV Registration of resources for idle is not complete
+	2.	ou1cimx1#493520 DEV Allow simulated resource controller to register with power controller
+
+3.	cnotton
+	1.	ou1cimx1#493455 Test bld.inf files are exporting headers without proper macro
+	2.	MINOR_CHANGE Moved T_TIMESTAMP up above T_LAT2.
+
+4.	erifung
+	1.	ou1cimx1#493519 t_rescontrolcli.exe crash
+
+5.	vfebvre
+	1.	ou1cimx1#483102 H6 baseport bld.inf changes
+
+6.	jcoppear
+	1.	ou1cimx1#428875 MCL NaviEngine baseport bld.inf changes
+
+
 Version 2.00.3110
 =================
 (Made by fadhliM 22/07/2010)
--- a/kerneltest/e32test/group/bld.inf	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/group/bld.inf	Thu Aug 12 11:55:14 2010 +0100
@@ -31,21 +31,21 @@
 
 PRJ_TESTEXPORTS
 
-../../../kernel/eka/include/kernel/dobject.h						/epoc32/include/kernel/			
+../../../kernel/eka/include/kernel/dobject.h						OS_LAYER_PLATFORM_EXPORT_PATH(kernel/dobject.h)			
 
-../../../userlibandfileserver/domainmgr/inc/domainobserver.h				/epoc32/include/
+../../../userlibandfileserver/domainmgr/inc/domainobserver.h				OS_LAYER_PLATFORM_EXPORT_PATH(domainobserver.h)
 
-../dll/d_ldrtst.h					/epoc32/include/
+../dll/d_ldrtst.h					OS_LAYER_PLATFORM_EXPORT_PATH(d_ldrtst.h)
 
-../nkernsa/interrupts.h				SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(nktest/interrupts.h)	//
-../nkernsa/nkutils.h				SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(nktest/nkutils.h)	//
-../nkernsa/utils.h					SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(nktest/utils.h)	//
-../nkernsa/diag.h					SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(nktest/diag.h)	//
+../nkernsa/interrupts.h				OS_LAYER_PLATFORM_EXPORT_PATH(nktest/interrupts.h)	//
+../nkernsa/nkutils.h				OS_LAYER_PLATFORM_EXPORT_PATH(nktest/nkutils.h)	//
+../nkernsa/utils.h					OS_LAYER_PLATFORM_EXPORT_PATH(nktest/utils.h)	//
+../nkernsa/diag.h					OS_LAYER_PLATFORM_EXPORT_PATH(nktest/diag.h)	//
 
-../../../kernel/eka/include/e32huffman.h				/epoc32/include/
+../../../kernel/eka/include/e32huffman.h				OS_LAYER_PLATFORM_EXPORT_PATH(e32huffman.h)
 
 platsec.settings        /epoc32/data/defaulttest.ini
-../mmu/d_memorytest.h   /epoc32/include/e32test/d_memorytest.h
+../mmu/d_memorytest.h   OS_LAYER_PLATFORM_EXPORT_PATH(e32test/d_memorytest.h)
 
 ../buffer/UnicodeData.txt    /epoc32/data/z/test/unicodedata.txt
 ../buffer/UnicodeData.txt    /epoc32/release/wins/udeb/z/test/unicodedata.txt
@@ -68,11 +68,11 @@
 ../dll/oe/eabi/urel/t_oeexport.exe      /epoc32/release/armv5/urel/t_oeexport.exe
 ../dll/oe/eabi/urel/t_oeexport1.exe     /epoc32/release/armv5/urel/t_oeexport1.exe
 
-../demandpaging/d_pagestress.h		/epoc32/include/
-../pci/t_pci.h						/epoc32/include/e32test/t_pci.h
+../demandpaging/d_pagestress.h		OS_LAYER_PLATFORM_EXPORT_PATH(d_pagestress.h)
+../pci/t_pci.h						OS_LAYER_PLATFORM_EXPORT_PATH(e32test/t_pci.h)
 
-../iic/iic_psl/i2c.h			/epoc32/include/e32test/
-../iic/iic_psl/spi.h			/epoc32/include/e32test/
+../iic/iic_psl/i2c.h			OS_LAYER_PLATFORM_EXPORT_PATH(e32test/i2c.h)
+../iic/iic_psl/spi.h			OS_LAYER_PLATFORM_EXPORT_PATH(e32test/spi.h)
 
 PRJ_TESTMMPFILES
 
@@ -257,6 +257,9 @@
 t_ramdefrag
 #endif
 
+// /E32TEST/TIMESTAMP test must also come before t_lat2 as it goes into Low Power Mode.
+t_timestamp
+
 #ifdef EPOC32
 // Start the latency measurement
 t_lat2
@@ -311,9 +314,6 @@
 t_userasmbm manual
 #endif
 
-// /E32TEST/TIMESTAMP test
-t_timestamp
-
 // /e32test/benchmark
 #ifndef X86
 bm_suite    MANUAL_ON_WINS
--- a/kerneltest/e32test/group/rescontrol_extended_psl.mmp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/group/rescontrol_extended_psl.mmp	Thu Aug 12 11:55:14 2010 +0100
@@ -24,6 +24,7 @@
 
 macro		BTRACE_RESOURCE_MANAGER
 macro		RESOURCE_MANAGER_SIMULATED_PSL
+macro		_DUMP_TRACKERS
 macro		PRM_INSTRUMENTATION_MACRO
 macro		PRM_ENABLE_EXTENDED_VERSION
 //macro		DEBUG_VERSION //Enable if wanted to check for Lock and critical section count checker
--- a/kerneltest/e32test/group/rescontrol_psl.mmp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/group/rescontrol_psl.mmp	Thu Aug 12 11:55:14 2010 +0100
@@ -24,6 +24,7 @@
 
 macro		BTRACE_RESOURCE_MANAGER
 macro		RESOURCE_MANAGER_SIMULATED_PSL
+macro		_DUMP_TRACKERS
 macro		PRM_INSTRUMENTATION_MACRO
 //macro		DEBUG_VERSION //Enable if wanted to check for Lock and critical section count checker
 
--- a/kerneltest/e32test/mediaext/d_nfe.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/mediaext/d_nfe.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -1051,6 +1051,9 @@
 
 //	__KTRACE_PRINT(Kern::Printf("NFE%d: HandleRead pos %lx len %lx status %d", iInstance, currentPos, remainingLength, di->Status()));
 
+	if (di->iEntry.iPartitionLen == 0)
+		return KErrNotReady;
+
 
 	di->iReadRequestCount++;
 
@@ -1212,40 +1215,30 @@
 
 TInt DMediaDriverNFE::HandleFormat(TLocDrvRequest& aReq)
 	{
-	TInt r = KErrNone;
 	TInt64 currentPos =  aReq.Pos();
-	TInt64 remainingLength = aReq.Length();
 	TNfeDriveInfo* di = &iInfo.iDrives[DriveIndex(aReq.Drive()->iDriveNumber)];
 
-//	__KTRACE_PRINT(Kern::Printf("NFE%d: HandleFormat pos %lx len %lx status %d", iInstance, currentPos, remainingLength, di->Status()));
+	__KTRACE_PRINT(Kern::Printf("NFE%d: HandleFormat pos %lx len %lx status %d", iInstance, currentPos, aReq.Length(), di->Status()));
+
+	if (di->Status() == ENfeEncrypting)
+		{
+		di->iEncryptEndPos = di->iEntry.iPartitionBaseAddr + di->iEntry.iPartitionLen;
+		SetStatus(*di,  ENfeEncrypted);
+		__KTRACE_PRINT(Kern::Printf("NFE%d: HandleFormat() , Setting status to %s", iInstance, DriveStatus(di->Status())));
+		}
+
+	if (currentPos >= di->iEntry.iPartitionBaseAddr && 
+		currentPos < di->iEntry.iPartitionBaseAddr + KSectorSize && 
+		di->IsUDADrive() &&
+		di->Status() == ENfeEncrypted)
+		{
+		__KTRACE_PRINT(Kern::Printf("NFE%d: Write to sector #0 detected", iInstance));
+		di->iUniqueID = 0;	// undefined
+		__KTRACE_PRINT(Kern::Printf("NFE%d: Setting Volume ID to %08X", iInstance, di->iUniqueID ));
+		}
 
 
-	// just forward the request if the drive is not encrypted
-	if (di->Status() == ENfeDecrypted)
-		return ForwardRequest(aReq);
-
-	// otherwise create a buffer containing NULLs, encrypt it and write that to the attached drive
-	while(remainingLength && r == KErrNone)
-		{
-		TInt64 currentLength = (remainingLength <= KBufSize ? remainingLength : KBufSize);
-
-		TBool encryptBuffer = AdjustRequest(di, currentPos, currentLength);
-
-		memclr(iBuffer, KBufSize);
-		TPtr8 des(iBuffer,KBufSize,KBufSize);
-
-		if (encryptBuffer)
-			EncryptBuffer(des);
-		
-		r = Write(di->iLocalDriveNum, currentPos, (TLinAddr) iBuffer, I64LOW(currentLength));
-		if(r != KErrNone)
-			break;
-
-		remainingLength-= currentLength;
-		currentPos+= currentLength;
-		}
-
-	return r == KErrNone ? KErrCompletion : r;
+	return ForwardRequest(aReq);
 	}
 
 
@@ -1362,9 +1355,13 @@
 TBool DMediaDriverNFE::ValidBootSector(TUint8* aBuffer)
 	{
 	if (aBuffer[0] == 0xEB || aBuffer[0] == 0xE9)
+		{
 		return ETrue;
+		}
 	else
+		{
 		return EFalse;
+		}
 	}
 
 
@@ -1409,7 +1406,7 @@
 
 	// Find out whether the volume has changed
 	TUint32 uniqueID = VolumeId(iBuffer);   
-	TBool volumeChanged = uniqueID != aDi.iUniqueID;
+	TBool volumeChanged = (aDi.iUniqueID != 0) && (uniqueID != aDi.iUniqueID);
 	__KTRACE_PRINT(Kern::Printf("NFE%d: Old Volume ID %08X", iInstance, aDi.iUniqueID));
 	__KTRACE_PRINT(Kern::Printf("NFE%d: New Volume ID %08X", iInstance, uniqueID));
 	__KTRACE_PRINT(Kern::Printf("NFE%d: volumeChanged %d", iInstance, volumeChanged));
@@ -1537,9 +1534,6 @@
 		return KErrNone;
 		}
 
-//	TInt KBackgroundPriority = 7;						//*test*
-//	Kern::SetThreadPriority(KBackgroundPriority);		//*test*
-
 	TInt r = KErrNone;
 	for (;;)
 		{
@@ -1626,8 +1620,6 @@
 	if (r != KErrCompletion)
 		iIdleTimer.OneShot(NKern::TimerTicks(KNotBusyInterval));
 
-//	Kern::SetThreadPriority(KNfeThreadPriority);	//*test*
-	
 	return r;
 	}
 
--- a/kerneltest/e32test/mediaext/t_nfe.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/mediaext/t_nfe.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -130,9 +130,9 @@
 	return r;
 	}
 
-void DisplayNfeDeviceInfo(TInt aNfeDrive, TNfeDeviceInfo& aDeviceInfo)
+void DisplayNfeDeviceInfo(TInt aNfeDrive, TNfeDeviceInfo& aDeviceInfo, TBool (&aNfeDrives)[KMaxLocalDrives])
 	{
-	test.Printf(_L("Stats: \n"));
+//	test.Printf(_L("Stats: \n"));
 
 	RLocalDrive	d;
 	TBool change = EFalse;
@@ -153,6 +153,13 @@
 		{
 		TNfeDriveInfo& di = aDeviceInfo.iDrives[i];
 
+		TInt localDriveNum = di.iLocalDriveNum;
+		test_Value(localDriveNum, di.iLocalDriveNum < KMaxLocalDrives);
+		
+		if (aNfeDrives[localDriveNum])
+			continue;
+		aNfeDrives[localDriveNum] = 1;
+
 		test.Printf(_L("*** drive index %d ***\n"), i);
 		test.Printf(_L("iLocalDriveNum %x\n"), di.iLocalDriveNum);
 		test.Printf(_L("iDriveLetter %c\n"), di.iDriveLetter >= 0 && di.iDriveLetter <= 25 ? di.iDriveLetter +'A' : '?');
@@ -389,10 +396,13 @@
 		}
 
 
+	TBool nfeDrives[KMaxLocalDrives];
+	memclr(nfeDrives, sizeof(nfeDrives));
+	
 	for(TInt nfeDrive = FindNfeDrive(0); nfeDrive != KErrNotFound; nfeDrive = FindNfeDrive(++nfeDrive))
 		{
 		TNfeDeviceInfo deviceInfo;
-		DisplayNfeDeviceInfo(nfeDrive, deviceInfo);
+		DisplayNfeDeviceInfo(nfeDrive, deviceInfo, nfeDrives);
 		}
 
 	fs.Close();
--- a/kerneltest/e32test/mmu/t_shadow.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/mmu/t_shadow.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -464,6 +464,11 @@
 #ifdef __WINS__
 	test.Printf(_L("Test not valid in WINS\n"));
 #else
+	// Turn off lazy dll unloading
+	RLoader l;
+	test_KErrNone(l.Connect());
+	test_KErrNone(l.CancelLazyDllUnload());
+	l.Close();
 
 	test.Start(_L("Testing ROM shadowing"));
 	Initialise();
--- a/kerneltest/e32test/resmanus/resourcecontrol.mmp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resmanus/resourcecontrol.mmp	Thu Aug 12 11:55:14 2010 +0100
@@ -30,6 +30,7 @@
 #endif
 
 macro RESOURCE_MANAGER_SIMULATED_PSL
+macro _DUMP_TRACKERS
 macro BTRACE_RESMANUS
 macro PRM_US_INSTRUMENTATION_MACRO
 
--- a/kerneltest/e32test/resmanus/resourcecontrollerextended.mmp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resmanus/resourcecontrollerextended.mmp	Thu Aug 12 11:55:14 2010 +0100
@@ -31,6 +31,7 @@
 
 macro RESOURCE_MANAGER_SIMULATED_PSL
 macro BTRACE_RESMANUS
+macro _DUMP_TRACKERS
 macro PRM_US_INSTRUMENTATION_MACRO
 macro PRM_ENABLE_EXTENDED_VERSION
 
--- a/kerneltest/e32test/resmanus/t_resmanus.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resmanus/t_resmanus.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -43,7 +43,6 @@
 
 TBuf<16> gTestName(testName);
 
-GLDEF_D RTest gTest(testName);
 GLDEF_D RBusDevResManUs gChannel;
 
 TUint8 KNoOfGetStateRequests = 5;
@@ -75,6 +74,116 @@
 
 TBool gUseCached = EFalse;
 
+class RTestSafe: public RTest
+	{
+public:
+	RTestSafe(const TDesC &aTitle) :
+		RTest(aTitle), iCleanUpLevelMask (0), iFailHdnFunc(NULL)
+		{
+		}
+	RTestSafe(const TDesC &aTitle, void(*func)(RTestSafe &aTest)) :
+		RTest(aTitle), iFailHdnFunc(func)
+		{
+		}
+
+	// new version of operator(int), which calls our cleanup handler if check has failed
+	void operator()(TInt aResult)
+		{
+		if(!aResult && iFailHdnFunc)
+			iFailHdnFunc(*this);
+		RTest::operator ()(aResult);
+		}
+
+	void operator()(TInt aResult, TInt aLineNum)
+		{
+		if(!aResult && iFailHdnFunc)
+			iFailHdnFunc(*this);
+		RTest::operator ()(aResult, aLineNum);
+		}
+
+	void operator()(TInt aResult, TInt aLineNum, const TText* aFileName)
+		{
+		if(!aResult && iFailHdnFunc)
+			iFailHdnFunc(*this);
+		RTest::operator ()(aResult, aLineNum, aFileName);
+		}
+
+	// new version of End, which calls handler before exit..
+	void End()
+		{
+		if(iFailHdnFunc)
+			iFailHdnFunc(*this);
+		RTest::End();
+		}
+
+	void SetCleanupFlag(TUint aFlag)
+		{
+		iCleanUpLevelMask |= 1 << aFlag;
+		}
+
+	TBool CleanupNeeded(TUint aFlag)
+		{
+		return (iCleanUpLevelMask & (1 << aFlag)) >> aFlag;
+		}
+
+	TUint iCleanUpLevelMask;
+	void (*iFailHdnFunc)(RTestSafe &aTest);
+	};
+
+// cleanup handler
+enum TCleanupLevels
+	{
+	EPddLoaded = 0,
+	ELddLoaded,
+	EChannelOpened
+	};
+
+
+void TestCleanup(RTestSafe &aTest)
+	{
+	// cleanup for all 3 levels..
+	if(aTest.CleanupNeeded(EChannelOpened))
+		{
+		gChannel.Close();
+		}
+
+	if(aTest.CleanupNeeded(ELddLoaded))
+		{
+		User::FreeLogicalDevice(KLddRootName);
+		}
+
+	if(aTest.CleanupNeeded(EPddLoaded))
+		{
+		User::FreePhysicalDevice(PDD_NAME);
+		}
+	}
+
+// global gTest object..
+RTestSafe gTest(testName, &TestCleanup);
+
+LOCAL_C TInt CheckCaps()
+	{
+	TInt r = KErrNone;
+	RDevice d;
+	TPckgBuf<TCapsDevResManUs> caps;
+	r = d.Open(KLddRootName);
+	if(r == KErrNone)
+		{
+		d.GetCaps(caps);
+		d.Close();
+
+		TVersion ver = caps().version;
+		if(ver.iMajor != 1 || ver.iMinor != 0 || ver.iBuild != KE32BuildVersionNumber)
+			{
+			gTest.Printf(_L("Capabilities returned wrong version"));
+			gTest.Printf(_L("Expected(1, 0, %d), got (%d , %d, %d)"),
+			                KE32BuildVersionNumber, ver.iMajor, ver.iMinor, ver.iBuild);
+			r = KErrGeneral;
+			}
+		}
+	return r;
+	}
+
 LOCAL_C TInt OpenChannel(TDesC16& aName, RBusDevResManUs& aChannel)
 	{
 	TInt r = KErrNone;
@@ -1139,7 +1248,7 @@
 		}
 
 
-	// Fourth invocation - examine effect of orignal client requesting a level for 
+	// Fourth invocation - examine effect of oryginal client requesting a level for 
 	// the Shared resource
 	if(gHaveSharedRes)
 		{
@@ -1185,7 +1294,6 @@
 			}
 		}
 
-
 	// Close the temporary channels
 	channelTwo.Close();
 	channelThree.Close();
@@ -1343,8 +1451,10 @@
 	TInt r = KErrNone;
 
 	TRequestStatus status;
+	TRequestStatus status2;
 	TBool cached = gUseCached;
 	TInt readValue = 0;
+	TInt readValue2 = 0;
 	TInt levelOwnerId = 0;
 	TInt testNo = 0;
 
@@ -1524,10 +1634,20 @@
 
 	// 8) Call API to get the state of a long latency resource then call API without operation-type qualifier to cancel the request.
 	gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
+	
+	// NOTE: Cancel operation can only remove request which is still inside the resource controller
+	// message queue. If the queue is empty, the resource controller may process the request very quickly
+	// after it is sent. It may cause the test fail. To solve this, two get long latency resource state 
+	// requests are submitted. So that the second one must be inside the resource controller. 
+	// And we will always test the second request
+	
 	gChannel.GetResourceState(status,gLongLatencyResource,cached,&readValue,&levelOwnerId);
+	gChannel.GetResourceState(status2,gLongLatencyResource,cached,&readValue2,&levelOwnerId);
 	gChannel.CancelAsyncOperation(&status);
+	gChannel.CancelAsyncOperation(&status2);
 	User::WaitForRequest(status);
-	if(status.Int() != KErrCancel)
+	User::WaitForRequest(status2);
+	if(status2.Int() != KErrCancel)
 		{
 		gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status = %d\n"),r);
 		return r;
@@ -1535,11 +1655,21 @@
 
 	// 9) Call API to modify the state of the long latency resource then call API without operation-type qualifier to cancel the request.
 	gTest.Printf(_L("TestGetSetResourceStateOps, starting test %d\n"),testNo++);
+	
+	// NOTE: Cancel operation can only remove request which is still inside the resource controller
+	// message queue. If the queue is empty, the resource controller may process the request very quickly
+	// after it is sent. It may cause the test fail. To solve this, two get long latency resource state 
+	// requests are submitted. So that the second one must be inside the resource controller. 
+	// And we will always test the second request
+		
 	newLevel = (TUint)(readValue + gAsyncResStateDelta);
 	gChannel.ChangeResourceState(status,gLongLatencyResource,newLevel);
+	gChannel.ChangeResourceState(status2,gLongLatencyResource,newLevel);
 	gChannel.CancelAsyncOperation(&status);
+	gChannel.CancelAsyncOperation(&status2);
 	User::WaitForRequest(status);
-	if(status.Int() != KErrCancel)
+	User::WaitForRequest(status2);
+	if(status2.Int() != KErrCancel)
 		{
 		gTest.Printf(_L("TestGetSetResourceStateOps, cancelled change state status = %d\n"),r);
 		return r;
@@ -1597,7 +1727,12 @@
 	for(i=0;i<KLoopVarN;i++)
 		{
 		User::WaitForRequest(getReqStatus[i]);
-		if((r=getReqStatus[i].Int()) != KErrCancel)
+
+	// NOTE: Cancel operation can only remove request which is still inside the resource controller
+	// message queue. If the queue is empty, the resource controller may process the request very quickly
+	// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
+			
+		if(i>0 && ((r=getReqStatus[i].Int()) != KErrCancel))
 			{
 			gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status[%d] = %d\n"),i,r);
 			return r;
@@ -1615,7 +1750,12 @@
 	for(i=0;i<KLoopVarM;i++)
 		{
 		User::WaitForRequest(setReqStatus[i]);
-		if((r=setReqStatus[i].Int()) != KErrCancel)
+		
+	// NOTE: Cancel operation can only remove request which is still inside the resource controller
+	// message queue. If the queue is empty, the resource controller may process the request very quickly 
+	// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
+		
+		if(i>0 && ((r=setReqStatus[i].Int()) != KErrCancel))
 			{
 			gTest.Printf(_L("TestGetSetResourceStateOps, cancelled change state status[%d] = %d\n"),i,r);
 			return r;
@@ -1691,7 +1831,12 @@
 	for(i=0;i<KLoopVarN;i++)
 		{
 		User::WaitForRequest(getReqStatus[i]);
-		if((r=getReqStatus[i].Int()) != KErrCancel)
+
+	// NOTE: Cancel operation can only remove request which is still inside the resource controller
+	// message queue. If the queue is empty, the resource controller may process the request very quickly 
+	// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
+		
+		if(i>0 && ((r=getReqStatus[i].Int()) != KErrCancel))
 			{
 			gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status[%d] = %d\n"),i,r);
 			return r;
@@ -1844,8 +1989,16 @@
 		r=gChannel.CancelGetResourceState(getReqStatus[i]);
 		if(r!=KErrNone)
 			{
-			gTest.Printf(_L("TestGetSetResourceStateOps, CancelGetResourceState for index %d returned %d\n"),i,r);
-			return r;
+
+	// NOTE: Cancel operation can only remove request which is still inside the resource controller
+	// message queue. If the queue is empty, the resource controller may process the request very quickly 
+	// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
+			
+			if(i!=0)
+				{
+				gTest.Printf(_L("TestGetSetResourceStateOps, CancelGetResourceState for index %d returned %d\n"),i,r);
+				return r;
+				}
 			}
 		}
 	for(i=0;i<KLoopVarM;i++)
@@ -1868,7 +2021,12 @@
 	for(i=0;i<KLoopVarN;i++)
 		{
 		User::WaitForRequest(getReqStatus[i]);
-		if((r=getReqStatus[i].Int()) != KErrCancel)
+
+	// NOTE: Cancel operation can only remove request which is still inside the resource controller
+	// message queue. If the queue is empty, the resource controller may process the request very quickly 
+	// after it is sent. It may cause the test fail. To solve this, we skip the test for request 0.
+		
+		if(i>0 && ((r=getReqStatus[i].Int()) != KErrCancel))
 			{
 			gTest.Printf(_L("TestGetSetResourceStateOps, cancelled get state status[%d] = %d\n"),i,r);
 			return r;
@@ -2873,7 +3031,7 @@
 		gTest.Printf(_L("TestThreadExclusiveAccess: Duplicate with EOwnerProcess returned %d\n"),r);
 		if(r==KErrNone)
 			r=KErrGeneral;
-		return r;
+		return r; // return error which is neither KErrNone nor KErrAccessDenied
 		}
 	pirateChannel = gChannel;
 	if((r=pirateChannel.Duplicate(RThread(),EOwnerThread))!=KErrNone)
@@ -2997,7 +3155,7 @@
 		{
 		if(r==KErrNone)
 			r=KErrGeneral;
-		return r;
+		return r; // return error which is neither KErrPermissionDenied nor KErrGeneral
 		}
 	else
 		r=KErrNone; // Ensure misleading result is not propagated
@@ -3077,7 +3235,7 @@
 			{
 			if(r==KErrNone)
 				r=KErrGeneral;
-			return r;
+			return r; // return error which is neither KErrPermissionDenied nor KErrGeneral
 			}
 		else
 			r=KErrNone; // Ensure misleading result is not propagated
@@ -3771,7 +3929,7 @@
 		if((r=gChannel.GetInfoOnClientsUsingResource(gSharedResource, numClients, &infoPtrs, EFalse))!=KErrNotReady)
 			{
 			gTest.Printf(_L("TestTransientHandling: GetInfoOnClientsUsingResource (for gSharedResource) returned %d\n"),r);
-			return r;
+			return KErrGeneral;
 			}
 		infoPtrs.Close();
 		}
@@ -4080,104 +4238,82 @@
 //
 // Main
 //
-    {
+	{
+	gTest.Title();
 	gTest.Start(_L("Test Power Resource Manager user side API\n"));
-  
-	TInt r = KErrNone;
 
 	// Test attempted load of PDD
-    gTest.Next(_L("**Load PDD\n"));
-    r=User::LoadPhysicalDevice(PDD_NAME);
-    if((r!=KErrNone)&&(r!=KErrAlreadyExists))
-		{
-		gTest.Printf(_L("User::LoadPhysicalDevice error %d\n"),r);
-		}
-	else
-		{
-		// Test attempted load of LDD
-		gTest.Next(_L("**Load LDD\n"));
-		r=User::LoadLogicalDevice(LDD_NAME);
-		if((r!=KErrNone)&&(r!=KErrAlreadyExists))
-			gTest.Printf(_L("User::LoadLogicalDevice error - expected %d, got %d\n"),KErrAlreadyExists,r);
-		}
-    if((r==KErrNone)||(r==KErrAlreadyExists))
-		{
-		r = KErrNone; // Re-initialise in case set to KErrAlreadyExists
-		//
-		// Need a channel open for the following tests
-		gTest.Next(_L("**OpenAndRegisterChannel\n"));
-		r=OpenAndRegisterChannel();
-		if (r==KErrNone)
-			{
-			// Get the version of the ResourceController
-			TUint version;
-			if((r=gChannel.GetResourceControllerVersion(version))!=KErrNone)
-				{
-				gTest.Printf(_L("TestTransientHandling: GetResourceControllerVersion returned %d\n"),r);
-				return r;
-				}
-			gTest.Printf(_L("TestTransientHandling: ResourceController version =0x%x\n"),version);
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestThreadExclusiveAccess\n"));
-			r=TestThreadExclusiveAccess();
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestGetClientGetResourceInfo - initial state\n"));
-			r=TestGetClientGetResourceInfo();
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestGetSetResourceStateOps\n"));
-			r=TestGetSetResourceStateOps();
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestGetClientGetResourceInfo - after changing stateof Async resource\n"));
-			r=TestGetClientGetResourceInfo();
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestGetSetResourceStateQuota\n"));
-			r=TestGetSetResourceStateQuota();
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestNotificationOps\n"));
-			r=TestNotificationOps();
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestNotificationQuota\n"));
-			r=TestNotificationQuota();
-			}
-		if (r==KErrNone)
-			{
-			// Should be no change since last invocation (assuming that
-			// no clients other than those in this test)
-			gTest.Next(_L("**TestGetClientGetResourceInfo - last invocation\n"));
-			r=TestGetClientGetResourceInfo();
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestAdditionalThread\n"));
-			r=TestAdditionalThread();
-			}
-		if (r==KErrNone)
-			{
-			gTest.Next(_L("**TestTransientHandling\n"));
-			r=TestTransientHandling();
-			}
-		}
-	gChannel.Close();
-
-    User::FreeLogicalDevice(KLddRootName);
-    User::FreePhysicalDevice(PDD_NAME);	
-	User::After(100000);	// Allow idle thread to run for driver unloading
+	gTest.Next(_L("**Load PDD\n"));
+	TInt r = User::LoadPhysicalDevice(PDD_NAME);
+	gTest((r == KErrNone) || (r == KErrAlreadyExists));
+	gTest.SetCleanupFlag(EPddLoaded);
+
+	// Test attempted load of LDD
+	gTest.Next(_L("**Load LDD\n"));
+	r = User::LoadLogicalDevice(LDD_NAME);
+	gTest((r == KErrNone) || (r == KErrAlreadyExists));
+	r = KErrNone; // Re-initialise in case set to KErrAlreadyExists
+	gTest.SetCleanupFlag(ELddLoaded);
+
+	// test caps
+	gTest(CheckCaps() == KErrNone);
+
+	// Need a channel open for the following tests
+	gTest.Next(_L("**OpenAndRegisterChannel\n"));
+	r = OpenAndRegisterChannel();
+	gTest(r == KErrNone);
+	gTest.SetCleanupFlag(EChannelOpened);
+
+	// Get the version of the ResourceController
+	TUint version;
+	r = gChannel.GetResourceControllerVersion(version);
+	gTest.Printf(_L("TestTransientHandling: ResourceController version =0x%x\n"), version);
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestThreadExclusiveAccess\n"));
+	r = TestThreadExclusiveAccess();
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestGetClientGetResourceInfo - initial state\n"));
+	r = TestGetClientGetResourceInfo();
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestGetSetResourceStateOps\n"));
+	r = TestGetSetResourceStateOps();
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestGetClientGetResourceInfo - after changing stateof Async resource\n"));
+	r = TestGetClientGetResourceInfo();
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestGetSetResourceStateQuota\n"));
+	r = TestGetSetResourceStateQuota();
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestNotificationOps\n"));
+	r = TestNotificationOps();
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestNotificationQuota\n"));
+	r = TestNotificationQuota();
+	gTest(r == KErrNone);
+
+	// Should be no change since last invocation (assuming that
+	// no clients other than those in this test)
+	gTest.Next(_L("**TestGetClientGetResourceInfo - last invocation\n"));
+	r = TestGetClientGetResourceInfo();
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestAdditionalThread\n"));
+	r = TestAdditionalThread();
+	gTest(r == KErrNone);
+
+	gTest.Next(_L("**TestTransientHandling\n"));
+	r = TestTransientHandling();
+	gTest(r == KErrNone);
 
 	gTest.End();
-	return r;
-    }
-
+	return KErrNone;
+	}
+
+
--- a/kerneltest/e32test/resmanus/t_resmanus.mmp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resmanus/t_resmanus.mmp	Thu Aug 12 11:55:14 2010 +0100
@@ -18,6 +18,7 @@
 
 // Need simulated PSL to support this test
 macro RESOURCE_MANAGER_SIMULATED_PSL
+macro _DUMP_TRACKERS
 
 sourcepath      ../resmanus
 source  	t_resmanus.cpp
@@ -26,7 +27,7 @@
 
 library 	euser.lib hal.lib
 
-capability		PowerMgmt
+capability		PowerMgmt 
 
 vendorid 0x70000001
 SMPSAFE
--- a/kerneltest/e32test/resmanus/t_resmanusextended.mmp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resmanus/t_resmanusextended.mmp	Thu Aug 12 11:55:14 2010 +0100
@@ -18,6 +18,7 @@
 
 // Need simulated PSL to support this test
 macro RESOURCE_MANAGER_SIMULATED_PSL
+macro _DUMP_TRACKERS
 macro PRM_ENABLE_EXTENDED_VERSION
 
 sourcepath      ../resmanus
@@ -27,7 +28,7 @@
 
 library 	euser.lib hal.lib
 
-capability		PowerMgmt
+capability		PowerMgmt 
 
 vendorid 0x70000001
 SMPSAFE
--- a/kerneltest/e32test/resmanus/t_resmanuskern.mmp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resmanus/t_resmanuskern.mmp	Thu Aug 12 11:55:14 2010 +0100
@@ -17,7 +17,8 @@
 targettype      exe
 
 // Need simulated PSL to support this test
-macro RESOURCE_MANAGER_SIMULATED_PSL 
+macro RESOURCE_MANAGER_SIMULATED_PSL
+macro _DUMP_TRACKERS
 macro PRM_ENABLE_EXTENDED_VERSION
 macro RESMANUS_KERN
 
--- a/kerneltest/e32test/resourceman/d_rescontrolcli.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resourceman/d_rescontrolcli.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -283,12 +283,6 @@
 	{
 	if(iDfcQ)
 	  iDfcQ->Destroy();
-	if(iStaticRes)
-		delete iStaticRes;
-	if(iStaticResArray[0])
-		delete iStaticResArray[0];
-	if(iStaticResArray[2])
-		delete iStaticResArray[2];
 	}
 
 /** Entry point for this driver */
@@ -319,7 +313,7 @@
 		return NULL;
 		}
 	//Allocating memory earlier so that during failure conditions can cleanup easily
-	p->iStaticRes = new DLaterRegisterStaticResource();
+	p->iStaticRes = new DLaterRegisterStaticResource(); // it will be registered, and later destroyed by the ResourceManager
 	if(!p->iStaticRes)
 		{
 		delete p->iClient.pName;
@@ -327,7 +321,7 @@
 		p->AsyncDelete();
 		return NULL;
 		}
-	p->iStaticResArray[0] = new DLaterRegisterStaticResource1();
+	p->iStaticResArray[0] = new DLaterRegisterStaticResource1(); // it will be registered, and later destroyed by the ResourceManager
 	if(!p->iStaticResArray[0])
 		{
 		delete p->iStaticRes;
@@ -1337,7 +1331,7 @@
 	TInt r = PowerResourceManager::CancelNotification(iClient.iClientId, aResId, *ptr);
 	if(r == KErrCancel)
 		{
-		delete ptr;
+		ptr->AsyncDelete();
 		if(iPostBootNotiCount == EXPECTED_POST_NOTI_COUNT)
 			{
 			r = PowerResourceManager::DeRegisterClient(DTestResManLddFactory::iClient.iClientId);
--- a/kerneltest/e32test/resourceman/resourceman_psl/rescontrol_extended_psl.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resourceman/resourceman_psl/rescontrol_extended_psl.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -31,56 +31,65 @@
 									|						  |
 								ResourceF				   ResourceG	
 	*/
-TInt DSimulatedPowerResourceController::DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount)
+
+TInt DSimulatedPowerResourceController::DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray)
 	{
 	Kern::Printf(">DSimulatedPowerResourceController::DoRegisterStaticResourcesDependency");
-	aStaticResourceDArray = (DStaticPowerResourceD**)new(DStaticPowerResourceD*[MAX_DEPENDENT_RESOURCE_COUNT]);
-	if(!aStaticResourceDArray)
-		return KErrNoMemory;
+
+	// this is just for testing purposes - try to call base-class implementation, which by default resets the values and returns KErrNone
+	TInt r = DPowerResourceController::DoRegisterStaticResourcesDependency(aStaticResourceDArray);
+	if(r != KErrNone || aStaticResourceDArray.Count())
+		{
+		Kern::Printf("DPowerResourceController::DoRegisterStaticResourcesDependency() default base class implementation has failed?");
+		return KErrGeneral;
+		}
+
 	DStaticPowerResourceD* pR = NULL;
+	TBool error_occured = EFalse;
+
 	pR = new DMLSLGLSPDependResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory)
-	aStaticResourceDArray[iStaticResDependencyCount++] = pR;
+	if(!SafeAppend(aStaticResourceDArray, pR))
+		error_occured = ETrue;
 
 	pR = new DMLSIGLSNDependResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory)
-	aStaticResourceDArray[iStaticResDependencyCount++] = pR;
-	
+	if(!SafeAppend(aStaticResourceDArray, pR))
+		error_occured = ETrue;
+
 	pR = new DBSIGLSPDependResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory)
-	aStaticResourceDArray[iStaticResDependencyCount++] = pR;
-
+	if(!SafeAppend(aStaticResourceDArray, pR))
+		error_occured = ETrue;
+	
 	pR = new DMLSHIGLSPDependResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory)
-	aStaticResourceDArray[iStaticResDependencyCount++] = pR;
+	if(!SafeAppend(aStaticResourceDArray, pR))
+		error_occured = ETrue;
 
 	pR = new DBSHLGLSNDependResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory)
-	aStaticResourceDArray[iStaticResDependencyCount++] = pR;
+	if(!SafeAppend(aStaticResourceDArray, pR))
+		error_occured = ETrue;
 
 	pR = new DMLSHLGLSNDependResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory)
-	aStaticResourceDArray[iStaticResDependencyCount++] = pR;
+	if(!SafeAppend(aStaticResourceDArray, pR))
+		error_occured = ETrue;
 
 	//Establish resource dependencies
-	if(CreateResourceDependency(aStaticResourceDArray))
-		CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory)
+	r = CreateResourceDependency(aStaticResourceDArray);
+	if(r != KErrNone)
+		error_occured = ETrue;
 
-	iDependencyResources = aStaticResourceDArray;
+	// the only error that could occur here is KErrNoMemory (also from calling CreateResourceDependency)
+	// clean-up if the error did occur
+	if(error_occured)
+		{
+		aStaticResourceDArray.ResetAndDestroy();
+		r = KErrNoMemory;
+		}
 
-	aStaticResourceDCount = iStaticResDependencyCount;
-	return KErrNone;
+	return r;
 	}
 
 
 // This function establishes above dependency between static dependent resource
-TInt DSimulatedPowerResourceController::CreateResourceDependency(DStaticPowerResourceD** pResArray)
+TInt DSimulatedPowerResourceController::CreateResourceDependency(RPointerArray <DStaticPowerResourceD> & pResArray)
 	{
 	iNodeArray = new SNode[10];
 	SNode* pN1;
--- a/kerneltest/e32test/resourceman/resourceman_psl/rescontrol_psl.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resourceman/resourceman_psl/rescontrol_psl.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -49,7 +49,8 @@
 	}
 
 /** Constructor for simulated resource controller. */
-DSimulatedPowerResourceController::DSimulatedPowerResourceController():DPowerResourceController(),iStaticResourceCount(0), iEventDfc(EventDfcFunc, this)
+DSimulatedPowerResourceController::DSimulatedPowerResourceController()
+	: iEventDfc(EventDfcFunc, this)
 	{
 	Kern::Printf(">DSimulatedPowerResourceController");
 	}
@@ -57,26 +58,51 @@
 /** Destructor for simulated resource controller. */
 DSimulatedPowerResourceController::~DSimulatedPowerResourceController()
 	{
-	Kern::Printf("DSimulatedPowerResourceController::~DSimulatedPowerResourceController()\n");
+	Kern::Printf(">~DSimulatedPowerResourceController()\n");
 	((TDynamicDfcQue*)iDfcQ)->Destroy();
-	DStaticPowerResource *pR;
-	TUint c;
-	for(c = 0; c < iStaticResourceCount; c++)
+	delete iMsgQ;
+
+	SPowerResourceClientLevel *pCL = iClientLevelPool;
+	while(iClientLevelPool) //Find the starting position of array to delete
 		{
-		pR = iResources[c];
-		delete pR;
+		if(iClientLevelPool < pCL)
+			pCL = iClientLevelPool;
+		iClientLevelPool = iClientLevelPool->iNextInList;
+		}
+
+	delete [] pCL;
+	SPowerRequest *pReq = iRequestPool;
+	while(iRequestPool) //Find the starting position of array to delete
+		{
+		if(iRequestPool < pReq)
+			pReq = iRequestPool;
+		iRequestPool = iRequestPool->iNext;
 		}
-	delete []iResources;
+	delete [] pReq;
+
 #ifdef PRM_ENABLE_EXTENDED_VERSION
-	DStaticPowerResourceD* pDR;
-	
-	delete []iNodeArray; //Delete dependency nodes
-	for(c = 0; c < iStaticResDependencyCount; c++) 
+	pCL = iResourceLevelPool;
+	while(iResourceLevelPool)
 		{
-		pDR = iDependencyResources[c];
-		delete pDR;
+		if(iResourceLevelPool < pCL)
+			pCL = iResourceLevelPool;
+		iResourceLevelPool = iResourceLevelPool->iNextInList;
 		}
-	delete []iDependencyResources;
+	//delete resource pool
+	delete [] pCL;
+	delete iMsgQDependency;
+#endif
+
+	iClientList.Delete();
+	iUserSideClientList.Delete();
+	iStaticResourceArray.ResetAndDestroy();
+
+#ifdef PRM_ENABLE_EXTENDED_VERSION
+	iCleanList.ResetAndDestroy();
+	iDynamicResourceList.Delete();
+	iDynamicResDependencyList.Delete();
+	delete [] iNodeArray; //Delete dependency nodes
+	iStaticResDependencyArray.ResetAndDestroy();
 #endif
 	}
 
@@ -274,147 +300,133 @@
 	}
 
 //This registers all static resource with resource controller. This function is called by PIL
-TInt DSimulatedPowerResourceController::DoRegisterStaticResources(DStaticPowerResource**& aStaticResourceArray, TUint16& aStaticResourceCount)
+TInt DSimulatedPowerResourceController::DoRegisterStaticResources(RPointerArray <DStaticPowerResource> & aStaticResourceArray)
 	{
 	Kern::Printf(">DSimulatedPowerResourceController::DoRegisterStaticResources");
-	aStaticResourceArray = (DStaticPowerResource**)new(DStaticPowerResource*[MAX_RESOURCE_COUNT]);
-	if(!aStaticResourceArray)
-		return KErrNoMemory;
-	DStaticPowerResource* pR = NULL;
+
+	TBool error_occured = EFalse;
+	TInt r = KErrNone;
 
 	//Create Binary Single Instantaneous Positive Resource
-	pR = new DBSIGISPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	DStaticPowerResource* pR = new DBSIGISPResource();
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
 	//Create Multilevel Single Instantaneous Positive Resource
 	pR = new DMLSIGISPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
 	//Create Binary Single Instantaneous Negative Resource
 	pR = new DBSIGISNResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
 	//Create Multilevel Single Instantaneous Negative Resource
 	pR = new DMLSIGISNResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Binary Single Longlatency Positive Resource
+	//Create Binary Single Long latency Positive Resource
 	pR = new DBSLGLSPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Multilevel Single Longlatency  Positive Resource
+	//Create Multilevel Single Long latency  Positive Resource
 	pR = new DMLSLGLSPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Binary Single Longlatency Get & Instantaneous Set Negative Resource
+	//Create Binary Single Long latency Get & Instantaneous Set Negative Resource
 	pR = new DBSLGISNResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Multilevel Single Longlatency Get & Instantaneous Set Negative Resource
+	//Create Multilevel Single Long latency Get & Instantaneous Set Negative Resource
 	pR = new DMLSLGISNResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Binary Single Instantaneous Get & Longlatency Set Positive Resource
+	//Create Binary Single Instantaneous Get & Long latency Set Positive Resource
 	pR = new DBSIGLSPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Multilevel Single Instantaneous Get & Longlatency Set Positive Resource
+	//Create Multilevel Single Instantaneous Get & Long latency Set Positive Resource
 	pR = new DMLSIGLSPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
 	//Create Binary SHared Instantaneous Positive Resource
 	pR = new DBSHIGISPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
 	//Create Multilevel SHared Instantaneous Positive Resource
 	pR = new DMLSHIGISPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
 	//Create Binary SHared Instantaneous Negative Resource
 	pR = new DBSHIGISNResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
 	//Create Multilevel SHared Instantaneous Negative Resource
 	pR = new DMLSHIGISNResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Binary SHared Longlatency Positive Resource
+	//Create Binary SHared Long latency Positive Resource
 	pR = new DBSHLGLSPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Multilevel SHared Longlatency  Positive Resource
+	//Create Multilevel SHared Long latency  Positive Resource
 	pR = new DMLSHLGLSPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Binary SHared Longlatency Get & Instantaneous Set Negative Resource
+	//Create Binary SHared Long latency Get & Instantaneous Set Negative Resource
 	pR = new DBSHLGISNResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Multilevel SHared Longlatency Get & Instantaneous Set Negative Resource
+	//Create Multilevel SHared Long latency Get & Instantaneous Set Negative Resource
 	pR = new DMLSHLGISNResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
 	//Create holes in resource array
-	aStaticResourceArray[iStaticResourceCount++] = NULL;
-	aStaticResourceArray[iStaticResourceCount++] = NULL;
-	//Create Binary SHared Instantaneous Get & Longlatency Set Positive Resource
+	if(aStaticResourceArray.Append(NULL) != KErrNone)
+		error_occured = ETrue;
+
+	if(aStaticResourceArray.Append(NULL) != KErrNone)
+		error_occured = ETrue;
+
+	//Create Binary SHared Instantaneous Get & Long latency Set Positive Resource
 	pR = new DBSHIGLSPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	//Create Multilevel SHared Instantaneous Get & Longlatency Set Positive Resource
+	//Create Multilevel SHared Instantaneous Get & Long latency Set Positive Resource
 	pR = new DMLSHIGLSPResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
-	 
-	//Create Binary shared Longlatency get and set Custom Resource
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
+
+	//Create Binary shared Long latency get and set Custom Resource
 	pR = new DBSHLGLSCResource();
-	if(!pR)
-		CLEAN_AND_RETURN(iStaticResourceCount, aStaticResourceArray, KErrNoMemory)
-	aStaticResourceArray[iStaticResourceCount++] = pR;
+	if(!SafeAppend(aStaticResourceArray, pR))
+		error_occured = ETrue;
 
-	iResources = aStaticResourceArray;
-
-	aStaticResourceCount = iStaticResourceCount;
-	return KErrNone;
+	// the only error that could occur here is KErrNoMemory
+	// clean-up if the error did occur
+	if(error_occured)
+		{
+		aStaticResourceArray.ResetAndDestroy();
+		r = KErrNoMemory;
+		}
+	return r;
 	}
 
 //Constructors of all resources
--- a/kerneltest/e32test/resourceman/resourceman_psl/rescontrol_psl.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resourceman/resourceman_psl/rescontrol_psl.h	Thu Aug 12 11:55:14 2010 +0100
@@ -32,15 +32,20 @@
 #define MAX_RESOURCE_COUNT 30
 #define MAX_DEPENDENT_RESOURCE_COUNT 10
 
-#define MAX_BLOCK_TIME 200 //Maximum block time
-#define MIN_BLOCK_TIME 50 //Guaranteed minimum block
+#define MAX_BLOCK_TIME 400 //Maximum block time
+#define MIN_BLOCK_TIME 200 //Guaranteed minimum block
 
-#define CLEAN_AND_RETURN(resCount, resArray, error)				\
-	{															\
-	for(TUint count = 0; count < resCount; count++)				\
-		delete resArray[count];									\
-	delete resArray;											\
-	return error;												\
+template <class T>
+inline TBool SafeAppend(RPointerArray <T> & aStaticResourceArray, T* pR)
+	{
+	if(pR)
+		{
+		if(aStaticResourceArray.Append(pR) == KErrNone)
+			return ETrue;
+		else
+			delete pR;
+		}
+	return EFalse;
 	}
 
 const TUint KBinary = 0x0;
@@ -55,10 +60,10 @@
 	~DSimulatedPowerResourceController();
     TInt DoInitController();
     TInt DoInitResources();
-    TInt DoRegisterStaticResources(DStaticPowerResource**& aStaticResourceArray, TUint16& aStaticResourceCount);
+    TInt DoRegisterStaticResources(RPointerArray <DStaticPowerResource> & aStaticResourceArray);
 	// Function to process instantaneous resources
     TInt ProcessInstantaneousResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel);
-	// Function to procces polled resources
+	// Function to process polled resources
     TInt ProcessPolledResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0);
 	// Function to change the state of the resource
     TInt ChangeResource(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel);
@@ -67,19 +72,15 @@
     IMPORT_C static TInt CaptureIdleResourcesInfo(TUint aControllerId, TUint aNumResources, TPtr* aPtr);
 	IMPORT_C static TInt CompleteResourceControllerInitialisation();
 #ifdef PRM_ENABLE_EXTENDED_VERSION
-	TInt DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount);
-	TInt CreateResourceDependency(DStaticPowerResourceD** pResArray);
+	TInt DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray);
+	TInt CreateResourceDependency(RPointerArray <DStaticPowerResourceD> & pResArray);
 #endif
 private:
-    static void TimerIsrFunc(TAny* ptr); //ISR Function called when specfied timer expires. This is for even driven resources
-    static void EventDfcFunc(TAny* ptr); //Function to wakeup the fast semphore. This is called from timer ISR.
-    DStaticPowerResource** iResources;
-    TUint16 iStaticResourceCount;
-    NFastSemaphore iEventFastSem; //Semphore to block the PIL of resource controller for event driven resource operations.
+    static void TimerIsrFunc(TAny* ptr); //ISR Function called when specified timer expires. This is for even driven resources
+    static void EventDfcFunc(TAny* ptr); //Function to wake up the fast semaphore. This is called from timer ISR.
+    NFastSemaphore iEventFastSem; //Semaphore to block the PIL of resource controller for event driven resource operations.
     TDfc iEventDfc; //Dfc to run to signal the event semaphore when the timer expires. Queued from timer ISR
 #ifdef PRM_ENABLE_EXTENDED_VERSION
-	DStaticPowerResourceD** iDependencyResources;
-	TUint16 iStaticResDependencyCount;
 	SNode* iNodeArray;
 	TUint16 iNodeCount;
 #endif
--- a/kerneltest/e32test/resourceman/t_rescontrolcli.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/e32test/resourceman/t_rescontrolcli.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -4321,10 +4321,6 @@
 	test.Start(_L("Testing Resource Manager...\n"));
 	test.Printf(_L("Testing HCR client setting Macro's for Resource Manager \n"));
 	TestClientHCRSettingMacros();
-	//
-	test.Printf(_L("TEST SKIPPED UNTIL FIX FOR DEF145087 IS AVAILABLE TO PREVENT CRASHING\n"));
-	test(0);
-	//
 	test.Next(_L("Load Physical device"));
 #ifndef PRM_ENABLE_EXTENDED_VERSION
 	r = User::LoadPhysicalDevice(KPddFileName);
@@ -4340,8 +4336,22 @@
 	r=User::LoadLogicalDevice(KExtLddFileName);
 	test(r==KErrNone || r==KErrAlreadyExists);
 #endif
+
+	RDevice d;
+	TPckgBuf<RTestResMan::TCaps> caps;
+	r = d.Open(KLddName);
+	test(r == KErrNone);
+	d.GetCaps(caps);
+	d.Close();
+
+	TVersion ver = caps().iVersion;
+	test(ver.iMajor == 1);
+	test(ver.iMinor == 0);
+	test(ver.iBuild == KE32BuildVersionNumber);
+
 	r = lddChan.Open();
 	test(r==KErrNone || r==KErrAlreadyExists);
+
 	//Check whether the notifications recieved as a result of postboot level setting is as expected.
 	r = lddChan.CheckPostBootLevelNotifications();
 	test(r == KErrNone);
--- a/kerneltest/f32test/fileutils/inc/f32_test_utils.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/f32test/fileutils/inc/f32_test_utils.h	Thu Aug 12 11:55:14 2010 +0100
@@ -59,6 +59,13 @@
 
 TInt FormatDrive(RFs &aFs, TInt aDrive, TBool aQuickFormat); 
 
+//-----------------------------------------------------------------------------
+
+TBool CompareBuffers(const TDesC8& aBuf1, const TDesC8& aBuf2);
+TBool CompareBuffers(const TAny* apBuf1, TUint aBuf1Len, const TAny* apBuf2, TUint aBuf2Len);
+
+void  HexDump(const TDesC8& aBuf);
+void  HexDump(const TAny* apBuf, TUint aBufLen);
 
 //-----------------------------------------------------------------------------
 /** 
@@ -155,6 +162,8 @@
 
 
 
+
+
 //#############################################################################
 //#  some  private helper functions  
 //#############################################################################
--- a/kerneltest/f32test/fileutils/src/f32_test_utils.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/f32test/fileutils/src/f32_test_utils.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -36,6 +36,196 @@
 static CConsoleBase* pConsole = NULL;   //-- pointer to the text console for printing out data
 static TBool  bPrintOutEnabled = ETrue; //-- global flag, if EFalse, all printing out is disabled
 
+
+
+//-------------------------------------------------------------------------------------------------------------------
+
+/**
+    Prints out a hex dump of a descriptor contents
+    @param  aBuf data descriptor to dump
+*/
+void  F32_Test_Utils::HexDump(const TDesC8& aBuf)
+{
+    HexDump(aBuf.Ptr(), aBuf.Size());
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+/**
+    Prints out a hex dump of a buffer
+    @param  apBuf   pointer to the data to dump
+    @param  aBufLen buffer length
+*/
+void  F32_Test_Utils::HexDump(const TAny* apBuf, TUint aBufLen)
+{
+    DoPrintf(_L("~ F32_Test_Utils::HexDump() size:%u\n"), aBufLen);
+  
+    ASSERT(apBuf);
+    
+    if(!aBufLen)
+        return;
+
+    const TUint colDmpWidth = 16;
+    const TUint8* pBuf = (const TUint8*)apBuf;
+    TBuf<256> buf1;
+    TBuf<64>  buf2;
+
+    TUint dumpPos;
+    
+    for(dumpPos=0; dumpPos < aBufLen-1; )
+    {
+        buf1.Format(_L("%06X: "), dumpPos);
+        buf2.Zero();
+
+        for(TUint i=0; i<colDmpWidth; ++i)
+        {
+            buf1.AppendFormat(_L("%02x "), pBuf[dumpPos+i]);
+        
+            const TChar ch = pBuf[dumpPos+i];
+            if(ch.IsPrint())
+                buf2.Append(ch);
+            else    
+                buf2.Append(_L("."));
+            
+
+            if(++dumpPos >= aBufLen)
+            {    
+                while(++i < colDmpWidth)
+                {
+                    buf1.Append(_L("   "));
+                    buf2.Append(_L(" "));
+                }
+
+                break;
+            }
+        }
+
+        buf1.Append(buf2);
+        DoPrintf(buf1);
+    
+    }
+
+    DoPrintf(_L("\n"));
+
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+/**
+    Compare 2 buffers and print out the difference if there is any.
+    Buffer sizes must be the same and non-0
+
+    @param  aBuf1   buffer 1 descriptor
+    @param  aBuf2   buffer 2 descriptor
+    
+    @return ETrue if buffers are the same, EFalse otherwise
+*/
+TBool F32_Test_Utils::CompareBuffers(const TDesC8& aBuf1, const TDesC8& aBuf2)
+{
+    return CompareBuffers(aBuf1.Ptr(), aBuf1.Size(), aBuf2.Ptr(), aBuf2.Size());
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+/**
+    Compare 2 buffers and print out the difference if there is any.
+    Buffer sizes must be the same and non-0
+
+    @param  apBuf1   pointer to the buffer 1 
+    @param  aBuf1Len buffer1 length
+    @param  apBuf2   pointer to the buffer 2 
+    @param  aBuf2Len buffer2 length
+
+    @return ETrue if buffers are the same, EFalse otherwise
+*/
+TBool F32_Test_Utils::CompareBuffers(const TAny* apBuf1, TUint aBuf1Len, const TAny* apBuf2, TUint aBuf2Len)
+{
+    ASSERT(apBuf1 && apBuf2);
+    
+    if(aBuf1Len != aBuf2Len)
+    {
+        DoPrintf(_L("~ F32_Test_Utils::CompareBuffers() different sizes! %u:%u\n"), aBuf1Len, aBuf2Len);
+        ASSERT(0);
+        return EFalse;
+    }
+
+    if(!aBuf1Len)
+    {//-- empty buffers to compare
+        return ETrue;
+    }
+
+
+    const TUint8* pBuf1 = (const TUint8*)apBuf1;
+    const TUint8* pBuf2 = (const TUint8*)apBuf2;   
+        
+    if(!Mem::Compare(pBuf1, aBuf1Len, pBuf2, aBuf2Len))
+        return ETrue; //-- buffers are the same. 
+
+
+    //-- the buffers' contents are different
+    TUint diffpos;
+    TBuf<256> buf1;
+    TBuf<100> buf2;
+
+    const TUint colDmpWidth = 16;
+    TBool bBannerPrinted = EFalse;
+
+    //-- dump chunks of the buffer with differences only
+    for(diffpos=0; diffpos<aBuf1Len-1; )
+    {
+        if(pBuf1[diffpos] == pBuf2[diffpos])
+            {
+            ++diffpos;
+            continue;
+            }
+
+        if(!bBannerPrinted)
+        {
+            bBannerPrinted = ETrue;
+            DoPrintf(_L("~ F32_Test_Utils::CompareBuffers() buffers' contents are different starting at pos:%u (0x%x). Hexdump:\n"), diffpos, diffpos);
+
+        }
+
+        //-- difference found, dump chunks of the buffer with differences only
+        TUint dumpPos = (diffpos >> 4) << 4; //-- round down to 16
+
+        buf1.Format(_L("%06X: "), dumpPos);
+        buf2.Format(_L("|"));
+        
+        for(TUint i=0; i<colDmpWidth; ++i)
+        {
+            buf1.AppendFormat(_L("%02x"), pBuf1[dumpPos+i]);
+            buf2.AppendFormat(_L("%02x"), pBuf2[dumpPos+i]);
+
+            if(i < colDmpWidth-1)
+            {
+                buf1.Append(_L(" "));
+                buf2.Append(_L(" "));
+            }
+
+        
+            if(++diffpos >= aBuf1Len)
+            {//-- pad the dump with spaces
+                while(++i < colDmpWidth)
+                {
+                    buf1.Append(_L("   "));
+                    buf2.Append(_L("   "));
+                }
+            
+                break;
+            }
+
+        }
+
+        buf1.Append(buf2);
+        DoPrintf(buf1);
+    }
+    
+    DoPrintf(_L("\n"));
+
+    return EFalse;
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
 /**
     Set the console where the ouput will go.
     @param  apConsole pointer to the console. if NULL, the print out will be debug port only.
--- a/kerneltest/f32test/group/bld.inf	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/f32test/group/bld.inf	Thu Aug 12 11:55:14 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1998-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,9 +26,9 @@
 
 PRJ_TESTEXPORTS
 
-../../../userlibandfileserver/fileserver/shostmassstorage/client/rusbhostmslogicalunit.h        /epoc32/include/
+../../../userlibandfileserver/fileserver/shostmassstorage/client/rusbhostmslogicalunit.h        OS_LAYER_PLATFORM_EXPORT_PATH(rusbhostmslogicalunit.h)
 
-../../../userlibandfileserver/fileserver/inc/runtests.h                         /epoc32/include/
+../../../userlibandfileserver/fileserver/inc/runtests.h                         OS_LAYER_PLATFORM_EXPORT_PATH(runtests.h)
 
 PRJ_TESTMMPFILES
 ../../e32test/mediaext/t_nfe
@@ -156,7 +156,7 @@
 //t_scndr1    manual //-- obsolte; replaced by t_scn32dr1
 //t_scndr2    manual //-- obsolte; replaced by t_scn32dr2
 //T_MMC     manual
-t_pwstr manual
+t_pwstr
 
 
 t_fsys
--- a/kerneltest/f32test/server/t_file.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/f32test/server/t_file.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -190,25 +190,40 @@
 
 	test.Start(_L("Test read file"));
 	RFile f,ZFile;
-	TInt r=f.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText);
+	
+    TInt r=f.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText);
 	test_KErrNone(r);
-	TFileName fn = _L("Z:\\TEST\\T_FILE.CPP");
+	
+    TFileName fn = _L("Z:\\TEST\\T_FILE.CPP");
 	fn[0] = gExeFileName[0];
-	r=ZFile.Open(TheFs,fn,EFileStreamText);
+	
+    r=ZFile.Open(TheFs,fn,EFileStreamText);
 	test_KErrNone(r);
 
+	// check the file on the Z: drive his read-only
+	TEntry fileAtt;
+	r=TheFs.Entry(fn,fileAtt);
+	test_KErrNone(r);
+	test((fileAtt.iAtt & KEntryAttReadOnly) == KEntryAttReadOnly);
+
+
 	test.Next(_L("Read file"));
 	TBuf8<0x100> a,b;
-	FOREVER
+	
+    for(;;)
 		{
 		r=f.Read(b);
 		test_KErrNone(r);
-		r=ZFile.Read(a);
+		
+        r=ZFile.Read(a);
 		test_KErrNone(r);
-		test(a==b);
-		if (b.Length()<b.MaxLength())
+		
+        test(CompareBuffers(a, b));
+		
+        if (b.Length()<b.MaxLength())
 			break;
 		}
+
 	b.SetLength(10);
 	r=f.Read(b);
 	test_KErrNone(r);
@@ -240,23 +255,30 @@
 	{
 
 	test.Start(_L("Test multiple read file"));
-	RFile f1;
+	
+    RFile f1;
 	TInt r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
 	test_KErrNone(r);
-	RFile f2;
+	
+    RFile f2;
 	r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
 	test_KErrNone(r);
 
 	test.Next(_L("Read file"));
-	FOREVER
+	
+    TBuf8<0x100> b1;
+    TBuf8<0x100> b2;
+    
+    for(;;)
 		{
-		TBuf8<0x100> b1;
-		r=f1.Read(b1);
+        r=f1.Read(b1);
 		test_KErrNone(r);
-		TBuf8<0x100> b2;
+        
 		r=f2.Read(b2);
 		test_KErrNone(r);
-		test(b1==b2);
+		
+        test(CompareBuffers(b1, b2));
+
 		if (b1.Length()<b1.MaxLength())
 			break;
 		}
@@ -953,6 +975,44 @@
 	test_KErrNone(r);
 	f.Close();
 
+
+	test.Next(_L("Internal attribute can't be read"));
+
+	r=TheFs.SetAtt(fname,0,KEntryAttReadOnly);
+	test_KErrNone(r);
+
+	r=f.Open(TheFs,fname,EFileWrite);
+	test_KErrNone(r);
+
+	r=f.SetAtt(KEntryAttReadOnly, 0);	// this will set internal attribut KEntryAttModified
+	test_KErrNone(r);
+
+	// copied \sf\os\kernelhwsrv\userlibandfileserver\fileserver\inc\common.h
+	const TUint KEntryAttModified=0x20000000;	
+
+	TUint att;
+	r = f.Att(att);
+	test_KErrNone(r);
+    test.Printf(_L("att %x"), att);
+	test_Value(att & KEntryAttModified, (att & KEntryAttModified) == 0);
+
+	r=f.SetAtt(att | KEntryAttModified, 0);
+	test_KErrNone(r);
+
+	r = f.Att(att);
+	test_KErrNone(r);
+    test.Printf(_L("att %x"), att);
+	test_Value(att & KEntryAttModified, (att & KEntryAttModified) == 0);
+
+	test.Next(_L("file time is set"));
+	r = f.Modified(time);
+	test(time.Int64() != 0);
+
+    r = f.Flush(); //-- this will flush attributes to the media
+    test_KErrNone(r);
+	f.Close();
+
+
 	// Tidy up
 	r=TheFs.SetAtt(fname,0,KEntryAttReadOnly);
 	test_KErrNone(r);
@@ -2888,8 +2948,6 @@
 {
     test.Next(_L("test maximal file size on FAT32\n"));
 
-#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-
     if(!Is_Fat32(TheFs, gDriveNum))
     {
         test.Printf(_L("This test requires FAT32! skipping.\n"));
@@ -3009,11 +3067,8 @@
     nRes = TheFs.Delete(KFileName);
     test_KErrNone(nRes);
 
-#else
-
     test.Printf(_L("RFile64 is not supported! Skipping.\n"));
 
-#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
 
 }
 
--- a/kerneltest/f32test/server/t_fman.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/f32test/server/t_fman.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -601,7 +601,7 @@
 	test_KErrNone(r);
 	test(entry.iName.MatchF(_L("T_FSRV.CPP"))!=KErrNotFound);
 #if defined (__WINS__)
-	test_Equal(KEntryAttArchive, entry.iAtt);
+	test_Equal(KEntryAttArchive | KEntryAttReadOnly, entry.iAtt);
 #else
 	if (!IsTestingLFFS())
 		{
@@ -4415,9 +4415,9 @@
          if(r!=KErrNone) //correct behaviour
              {
              TFileManError error = gFileMan->GetMoreInfoAboutError();
-             test_Equal(error,(TFileManError)ENoFilesProcessed);
+             test_Equal((TFileManError)ENoFilesProcessed,error);
              }
-         else { test_Equal(r,!KErrNone); }
+         else { test_Equal(!KErrNone,r); }
          }
      else
          {
@@ -4425,9 +4425,9 @@
          if(r!=KErrNone) //correct behaviour
              {
              TFileManError error = gFileMan->GetMoreInfoAboutError();
-             test_Equal(error,(TFileManError)ENoFilesProcessed);
+             test_Equal((TFileManError)ENoFilesProcessed,error);
              }
-         else { test_Equal(r,!KErrNone); }
+         else { test_Equal(!KErrNone,r); }
          }
     CleanupStack::PopAndDestroy();
     }
--- a/kerneltest/f32test/server/t_pwstr.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/f32test/server/t_pwstr.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1998-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"
@@ -101,6 +101,7 @@
 							// integrator, TBLDNum should be set to 3.
 
 LOCAL_D TInt RFsDNum = -1;	// File Server Drive number
+LOCAL_D TBool gManual = EFalse; // Manual Tests enabled
 
 struct TTestMapping
 	{
@@ -1231,25 +1232,41 @@
 	test.Next(_L("open connection"));
 	RFs theFs;
 	test(theFs.Connect() == KErrNone);
-
 	
+	// So that we are in a consistant state lets
+	// Remove the password file first. i.e. could be passwords left over from previous test failures
+    test.Next(_L("tidy up"));
+    TEntry theEntry;
+    TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
+    mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
+    test.Printf(_L("password file : %S\n"),&mediaPWrdFile);
+    error = theFs.Delete(mediaPWrdFile);
+    // Should be either KErrNone, KErrPathNotFound or KErrNotFound
+    test.Printf(_L("password file deleted: %d\n"),error);
 	
 	// Now set the first password that we will use
 	test.Next(_L("lock the media card"));	
 	TMediaPassword& nulPWrd = *PWDs[0];
 	TMediaPassword& oldPWrd = *PWDs[1];
 	error = theFs.LockDrive(KDriveNum, nulPWrd, oldPWrd, ETrue);
-	test(KErrNone == error);
 
+	if (KErrNotSupported == error)
+	    {
+        // Appears that passwords aren't supported on this drive config (i.e. NFE)
+        theFs.Close();
+        test.End();
+        return;
+	    }
+	test_KErrNone(error);
 
 	// Verify that the password file does exist and is in the correct place
 	test.Next(_L("check password file exists"));
-	TEntry theEntry;
-	TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
-	mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
 	error = theFs.Entry(mediaPWrdFile, theEntry);
-	test (KErrNone == error);
-
+	test.Printf(_L("password file exists: %d\n"),error);
+	if (error != KErrNone && error != KErrNotFound)
+	    {
+        test(0);
+	    }	
 	
 	// Attempt to set a new password without specifying the current one
 	test.Next(_L("change password failure"));	
@@ -1261,27 +1278,44 @@
 	// Change the password for a new one...
 	test.Next(_L("change password success"));	
 	error = theFs.LockDrive(KDriveNum, oldPWrd, newPWrd, ETrue);
-	test(KErrNone == error);
+	test_KErrNone(error);
 
 	
 	// Clear the password
+	// NB The file server uses a separate thread to write to the password file,
+	// so we may need to wait a short while to see any change...
 	test.Next(_L("clear the password"));	
 	error = theFs.ClearPassword(KDriveNum, newPWrd);
-	test(KErrNone == error);
+	test_KErrNone(error);
 
 
 	// Check that the password has been removed from the file
 	// (KMediaPWrdFile should now be zero bytes in size)
 	test.Next(_L("check password removal"));
-	error = theFs.Entry(mediaPWrdFile, theEntry);
-	test (KErrNone == error);
-	test (0 == theEntry.iSize);
+	theEntry.iSize = KMaxTInt;
+	TInt n;
+	for (n=0; theEntry.iSize > 0 && n<10; n++)
+		{
+		error = theFs.Entry(mediaPWrdFile, theEntry);
+	test_KErrNone(error);
+		test.Printf(_L("Password file size is %d\n"), theEntry.iSize);
+		if (theEntry.iSize > 0)
+			User::After(1000000);
+		}
+	test (theEntry.iSize == 0);
 
 	
 	// Remove the password file
 	test.Next(_L("tidy up"));
-	error = theFs.Delete(mediaPWrdFile);
-	test (KErrNone == error);
+	error = KErrInUse;
+	for (n=0; error == KErrInUse && n<10; n++)
+		{
+		error = theFs.Delete(mediaPWrdFile);
+		test.Printf(_L("Deleting %S, Iter %d, r %d\n"), &mediaPWrdFile, n, error);
+		if (error == KErrInUse)
+			User::After(1000000);
+		}
+	test_KErrNone(error);
 
 
 	theFs.Close();
@@ -1466,15 +1500,18 @@
 	UserHal::DriveInfo(diBuf);
 	TDriveInfoV1 &di=diBuf();
 
-	test.Printf(_L(" iRegisteredDriveBitmask 0x%08X"), di.iRegisteredDriveBitmask);
+	test.Printf(_L(" iRegisteredDriveBitmask 0x%08X\n"), di.iRegisteredDriveBitmask);
 
 	aDrive  = -1;
 	
 	TLocalDriveCapsV5Buf capsBuf;
 	TBusLocalDrive TBLD;
 	TLocalDriveCapsV5& caps = capsBuf();
+	
 	TPtrC8 localSerialNum;
 	TInt registeredDriveNum = 0;
+		
+	// Find a Drive that has Password support.
 	for(aDrive=0; aDrive < KMaxLocalDrives; aDrive++)
 		{
 		TInt driveNumberMask = 1 << aDrive;
@@ -1483,27 +1520,29 @@
 
 		test.Printf(_L(" Drive %d -  %S\r\n"), aDrive, &di.iDriveName[registeredDriveNum]);
 
-		// check that the card is readable (so we can ignore for empty card slots)
-		if ((di.iDriveName[registeredDriveNum].MatchF(_L("MultiMediaCard0")) == KErrNone) ||
-		    (di.iDriveName[registeredDriveNum].MatchF(_L("SDIOCard0")) == KErrNone))
-			{
-			
-			TBool TBLDChangedFlag;
-			TInt r = TBLD.Connect(aDrive, TBLDChangedFlag);
+        TBool TBLDChangedFlag;
+        TInt r = TBLD.Connect(aDrive, TBLDChangedFlag);
 //test.Printf(_L(" Connect returned %d\n"), r);
-			if (r == KErrNone)
-				{
-				r = TBLD.Caps(capsBuf);
-				localSerialNum.Set(caps.iSerialNum, caps.iSerialNumLength);
-				const TInt KSectSize = 512;
-				TBuf8<KSectSize> sect;
-				r = TBLD.Read(0, KSectSize, sect);
+        if (r == KErrNone)
+            {
+            r = TBLD.Caps(capsBuf);
+            
+            //Check media is lockable if not carry on			
+            if (caps.iMediaAtt & KMediaAttLockable)
+                {
+                test.Printf(_L("Drive %d is Lockable\n"),aDrive);
+                localSerialNum.Set(caps.iSerialNum, caps.iSerialNumLength);
+                const TInt KSectSize = 512;
+                TBuf8<KSectSize> sect;
+                r = TBLD.Read(0, KSectSize, sect);
 //test.Printf(_L(" Read returned %d\n"), r);
 				
 				TBLD.Disconnect();
 				if (r == KErrNone)
 					break;
 				}
+
+			TBLD.Disconnect();				
 			}
 		registeredDriveNum++;
 		}
@@ -1625,7 +1664,9 @@
 	for (n=0; n<30 && !TestLocked(aFs, aTheMemoryCardDrive); n++)
 		{
 		User::After(1000000);
+		test.Printf(_L("."));
 		}
+	test.Printf(_L("\n"));
 	test(n < 30);
 	test(TestLocked(aFs, aTheMemoryCardDrive));	// should now be locked
 	}
@@ -1941,7 +1982,6 @@
 	fs.Close();
 	}
 
-
 LOCAL_C void RunTests()
 //
 // Main test routine.  Calls other test functions.
@@ -1964,34 +2004,47 @@
 	test.Next(_L("Allocating test data"));
 	AllocateTestData();
 
-	test.Next(_L("Testing locking / unlocking using file server APIs"));
-	TestFsLockUnlock();
+    if (gManual)
+        {
+		test.Next(_L("Testing locking / unlocking using file server APIs"));
+		TestFsLockUnlock();
 	
-	test.Next(_L("Testing Power Down Status Reporting using file server APIs"));
-	TestPowerDownStatus();
+		test.Next(_L("Testing Power Down Status Reporting using file server APIs"));
+		TestPowerDownStatus();
 
-    test.Next(_L("Testing RFs::NotifyChange() with RFs::UnlockDrive()"));
-	TestUnlockDriveNotifyChange();
+	    test.Next(_L("Testing RFs::NotifyChange() with RFs::UnlockDrive()"));
+		TestUnlockDriveNotifyChange();
 
-	test.Next(_L("Forced Erase"));
-	TestFormatErase();
+		test.Next(_L("Forced Erase"));
+		TestFormatErase();
+		}
+		
 	test.Next(_L("Testing store management"));
 	TestStaticStore();
-	test.Next(_L("Testing locking functions"));
-	TestLockUnlock();
-	test.Next(_L("Testing Elide Passwords"));
-	TestElidePasswords();
-	test.Next(_L("Testing Null Passwords"));
-	TestNullPasswords();
-	test.Next(_L("Testing controller store"));
-	TestControllerStore();
-	test.Next(_L("Testing auto unlock"));
-	TestAutoUnlock();
+
+    if (gManual)
+        {		
+		test.Next(_L("Testing locking functions"));
+		TestLockUnlock();
+		test.Next(_L("Testing Elide Passwords"));
+		TestElidePasswords();		
+		test.Next(_L("Testing Null Passwords"));
+		TestNullPasswords();
+		test.Next(_L("Testing controller store"));
+		TestControllerStore();
+		test.Next(_L("Testing auto unlock"));
+		TestAutoUnlock();
+		}
+		
 	test.Next(_L("Testing password file"));
 	TestPasswordFile();
-	test.Next(_L("Testing writing a valid password to store unlocks card"));
-	TestWriteToPasswordStoreUnlocksCard();
-
+	
+    if (gManual)
+        {		
+		test.Next(_L("Testing writing a valid password to store unlocks card"));
+		TestWriteToPasswordStoreUnlocksCard();
+		}
+    
 	test.Next(_L("Disconnecting TBLD"));
 	TBLD.Disconnect();
 
@@ -2001,15 +2054,43 @@
 	__UHEAP_MARKEND;
 	}
 
+LOCAL_D void ParseCommandLineArgs()
+    {
+    
+    TBuf<0x100> cmd;
+    User::CommandLine(cmd);
+    TLex lex(cmd);
+
+    for (TPtrC token=lex.NextToken(); token.Length() != 0;token.Set(lex.NextToken()))
+        {
+        if (token.CompareF(_L("-m"))== 0)
+            {
+            gManual = ETrue;
+            continue;
+            }
+        }
+    }
 
 TInt E32Main()
 	{
 	
 	test.Title();
-	test.Start(_L("E32Main"));
+	test.Start(_L("T_PWSTR"));
+
+#if defined(__WINS__)
+	if (!gManual)
+	    {
+        test.Printf(_L("Automated T_PWSTR not supported on emulated devices\n"));
+	    }
+	else
+#endif
+	    {
+        ParseCommandLineArgs();	
+        
+        RunTests();
+	    }
+
 	
-	RunTests();
-
 	test.End();
 	test.Close();
 
--- a/kerneltest/f32test/server/t_sysbin.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/kerneltest/f32test/server/t_sysbin.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -344,6 +344,14 @@
 
 		test.End();
 
+	// All files on the emulator's Z: drive have the KEntryAttReadOnly flag set
+	// This flag will have been copied to the C: drive, so we need to remove this before calling CFileMan::RmDir()
+#ifdef __WINS__
+	r = TheFs.SetAtt(KDllCInCTest, 0, KEntryAttReadOnly);
+	test_KErrNone(r);
+#endif
+
+
 	_LIT(KCTestPath,"c:\\sysbin_test\\");
 	r = TheFileMan->RmDir(KCTestPath);
 	test_KErrNone(r);
@@ -381,6 +389,14 @@
 
 		test.End();
 
+	// All files on the emulator's Z: drive have the KEntryAttReadOnly flag set
+	// This flag will have been copied to the C: drive, so we need to remove this before calling CFileMan::RmDir()
+#ifdef __WINS__
+	r = TheFs.SetAtt(KDllDInCSysBinTest, 0, KEntryAttReadOnly);
+	test_KErrNone(r);
+#endif
+
+
 	_LIT(KCTestPath2,"c:\\sys\\bin\\test\\");
 	r = TheFileMan->RmDir(KCTestPath2);
 	test_KErrNone(r);
--- a/userlibandfileserver/fileserver/group/release.txt	Fri Aug 06 16:34:38 2010 +0100
+++ b/userlibandfileserver/fileserver/group/release.txt	Thu Aug 12 11:55:14 2010 +0100
@@ -1,3 +1,27 @@
+Version 2.00.3056
+=================
+(Made by fadhliM 26/07/2010)
+
+1.	dlyokhin
+	1.	ou1cimx1#481268 ENV: F32TEST T_FILE Fails during testMultipleReadFile()
+
+2.	necliffo
+	1.	ou1cimx1#456106 [DEV] Improve MedMMC and PBus Coverage
+
+3.	martai
+	1.	ou1cimx1#493927 ENV : E32TEST T_SHADOW Fails during testMultipleReadFile()
+
+4.	migubarr
+	1.	ou1cimx1#469293 t_pwstr failures
+	2.	ou1cimx1#488785 SD stack: formatting a card on a multiple-card stack can fail with KErrNotReady
+	3.	ou1cimx1#485015 Internal file server attribute (KEntryAttModified) can be returned to the client
+	4.	ou1cimx1#459805 Querying the attributes of an open file on the emulator's Z: drive returns incorrect attributes
+
+5.	michcox
+	1.	ou1cimx1#455757 MINOR_CHANGE - t_fman test fail error code print out
+	2.	MINOR_CHANGE MCL change includes from <F32Plugin.h> to <f32plugin.h> (i.e. case correction)
+
+
 Version 2.00.3055
 =================
 (Made by fadhliM 23/07/2010)
--- a/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -4213,7 +4213,7 @@
     if(bProblemsFound && chkDskRes == CScanDrive::ENoErrors)
         {//-- ScanDrive in this mode can leave unexpectedly without setting an error code that is returned by ProblemsDiscovered();
          //-- leave itself means a problem
-        chkDskRes = CScanDrive::EUnknownError;
+        chkDskRes = nScnDrvRes == KErrNone ? CScanDrive::EUnknownError : (CScanDrive::TGenericError) nScnDrvRes;
         }
 
     delete pScnDrv;
--- a/userlibandfileserver/fileserver/sfile/sf_drv.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_drv.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -90,17 +90,13 @@
 // Do not allow the entry type to be changed
 //
 	{
-	const TUint KReadOnlySetAtts = KEntryAttVolume | 
-								   KEntryAttDir    | 
-								   KEntryAttRemote;
+	const TUint KReadOnlyAtts = KEntryAttVolume	| 
+								KEntryAttDir	| 
+								KEntryAttRemote	|
+								KEntryAttModified;
 
-	const TUint KReadOnlyClrAtts = KEntryAttVolume | 
-								   KEntryAttDir    | 
-								   KEntryAttRemote | 
-								   KEntryAttModified;
-
-	aSetAttMask   &= ~KReadOnlySetAtts;
-	aClearAttMask &= ~KReadOnlyClrAtts;
+	aSetAttMask   &= ~KReadOnlyAtts;
+	aClearAttMask &= ~KReadOnlyAtts;
 	}
 
 void CheckForLeaveAfterOpenL(TInt leaveError, CFsRequest* aRequest, TInt aHandle)
@@ -1235,6 +1231,33 @@
 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSETENTRYL_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
 	TRAP(r,CurrentMount().SetEntryL(entryName,aTime,aSetAttMask,aClearAttMask))
 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSETENTRYLRET, "r %d", r);
+
+	// If the file is already open then write the file attributes directly to the file
+	TFileName foldedName;
+	TUint32 nameHash=0;
+	foldedName.CopyF(aName);
+	nameHash=CalcNameHash(foldedName);
+
+	__CHECK_DRIVETHREAD(iDriveNumber);
+	TDblQueIter<CFileCB> q(CurrentMount().iMountQ);
+	CMountCB* currentMount = &CurrentMount();
+	CFileCB* file;
+	while ((file=q++)!=NULL)
+		{
+		if ((&file->Drive()==this) && 
+			&file->Mount() == currentMount &&
+			nameHash == file->NameHash() && 
+			file->FileNameF().Match(foldedName)==KErrNone)
+			{
+			TUint att = file->Att();
+			att |= aSetAttMask;
+			att &= ~aClearAttMask;
+			file->SetAtt(att | KEntryAttModified);
+			file->SetModified(aTime);
+			break;
+			}
+		}
+
 	return(r);
 	}
 
--- a/userlibandfileserver/fileserver/sfile/sf_file.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_file.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -1641,6 +1641,7 @@
 	CFileShare* share=(CFileShare*)aRequest->ScratchValue();
 //	TInt att=(TInt)aRequest->FileShare()->File().Att()&KEntryAttMaskSupported;
 	TInt att=(TInt)share->File().Att();	// DRM: let ROM XIP attribute through
+	att&= ~KEntryAttModified;	// this is an internal attribute and should not be returned to the client
 	TPtrC8 pA((TUint8*)&att,sizeof(TInt));
 	aRequest->WriteL(KMsgPtr0,pA);
 	
@@ -1679,7 +1680,7 @@
 	TUint clearAttMask=(TUint)aRequest->Message().Int1();
 	ValidateAtts(setAttMask,clearAttMask);
 	OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL1, "this %x aSetAttMask %x aClearAttMask %x", (TUint) &share->File(), (TUint) setAttMask, (TUint) clearAttMask);
-	TRAP(r,share->File().SetEntryL(TTime(0),setAttMask,clearAttMask))
+	TRAP(r,share->File().SetEntryL(share->File().Modified(),setAttMask,clearAttMask))
 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL1RET, "r %d", r);
 	return(r);
 	}
@@ -1785,12 +1786,12 @@
     TTime time;
 	TPtr8 t((TUint8*)&time,sizeof(TTime));
 	aRequest->ReadL(KMsgPtr0,t);
-	TUint setAttMask=(TUint)(aRequest->Message().Int1()|KEntryAttModified);
+	TUint setAttMask=(TUint)(aRequest->Message().Int1());
 	TUint clearAttMask=(TUint)aRequest->Message().Int2();
 	ValidateAtts(setAttMask,clearAttMask);//	Validate attributes
 
 	OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL3, "this %x aSetAttMask %x aClearAttMask %x", (TUint) &share->File(), (TUint) setAttMask, (TUint) clearAttMask);
-	TRAP(r,share->File().SetEntryL(time,setAttMask,clearAttMask))
+	TRAP(r,share->File().SetEntryL(time,setAttMask|KEntryAttModified,clearAttMask))
 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL3RET, "r %d", r);
 	return(r);
 	}
--- a/userlibandfileserver/fileserver/sfile/sf_std.h	Fri Aug 06 16:34:38 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_std.h	Thu Aug 12 11:55:14 2010 +0100
@@ -32,7 +32,7 @@
 #include <e32const_private.h>
 #include "sf_plugin.h"
 #include "sf_func.h"
-#include <F32plugin.h>
+#include <f32plugin.h>
 #include "f32trace.h"
 
 #define __PRINT1TEMP_ALWAYS(t,a) {{TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}}
--- a/userlibandfileserver/fileserver/swins/elocal.cpp	Fri Aug 06 16:34:38 2010 +0100
+++ b/userlibandfileserver/fileserver/swins/elocal.cpp	Thu Aug 12 11:55:14 2010 +0100
@@ -855,8 +855,8 @@
     file.SetSize64(fileSize, EFalse);
 	file.SetAtt(info.dwFileAttributes&KEntryAttMaskSupported);
 
-//	if (IsRomDrive())
-//		file.iAtt|=KEntryAttReadOnly;
+	if (IsRomDrive())
+		file.SetAtt(file.Att() | KEntryAttReadOnly);
 	TTime tempTime=file.Modified();
 	fileTimeToTime(&info.ftLastWriteTime,tempTime);
 	file.SetModified(tempTime);