diff -r 000000000000 -r 96e5fb8b040d kerneltest/e32test/mmu/d_memorytest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/e32test/mmu/d_memorytest.cpp Thu Dec 17 09:24:54 2009 +0200 @@ -0,0 +1,582 @@ +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32test\mmu\d_memorytest.cpp +// +// + +#include +#include +#include "d_memorytest.h" + +// +// Class definitions +// + +class DMemoryTestFactory : public DLogicalDevice + { +public: + ~DMemoryTestFactory(); + virtual TInt Install(); + virtual void GetCaps(TDes8& aDes) const; + virtual TInt Create(DLogicalChannelBase*& aChannel); + }; + +class DMemoryTestChannel : public DLogicalChannelBase + { +public: + DMemoryTestChannel(); + ~DMemoryTestChannel(); + virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); + virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); +private: + TInt TestAllocZerosMemory(); + TInt TestReAllocZerosMemory(); + TInt AllocTest1(); + TInt ReAllocTest1(); + TInt ReAllocTest2(TUint8*& mem1, TUint8*& mem2, TUint8*& mem3); + TInt AllocPhysTest(TUint32 aIters, TUint32 aSize); + TInt AllocPhysTest1(TUint32 aIters, TUint32 aSize); +public: + DMemoryTestFactory* iFactory; + TVirtualPinObject* iVirtualPinObject; + + struct{ + TPhysicalPinObject* iObject; + TPhysAddr iPhysAddr; + TPhysAddr iPhysPageList[UCPageCount]; + TUint iColour; + TUint32 iActualMapAttr; + }iPhysicalPinning; + TUint32 iPageSize; + }; + +// +// DMemoryTestFactory +// + +TInt DMemoryTestFactory::Install() + { + return SetName(&KMemoryTestLddName); + } + +DMemoryTestFactory::~DMemoryTestFactory() + { + } + +void DMemoryTestFactory::GetCaps(TDes8& /*aDes*/) const + { + // Not used but required as DLogicalDevice::GetCaps is pure virtual + } + +TInt DMemoryTestFactory::Create(DLogicalChannelBase*& aChannel) + { + aChannel = NULL; + DMemoryTestChannel* channel=new DMemoryTestChannel; + if(!channel) + return KErrNoMemory; + channel->iFactory = this; + aChannel = channel; + return KErrNone; + } + +DECLARE_STANDARD_LDD() + { + return new DMemoryTestFactory; + } + +// +// DMemoryTestChannel +// + +TInt DMemoryTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) + { + return KErrNone; + } + +DMemoryTestChannel::DMemoryTestChannel() + { + iPageSize = Kern::RoundToPageSize(1); + } + +DMemoryTestChannel::~DMemoryTestChannel() + { + Kern::DestroyVirtualPinObject(iVirtualPinObject); + } + + +TInt DMemoryTestChannel::Request(TInt aFunction, TAny* a1, TAny* a2) + { + TInt r=KErrNotSupported; + + switch(aFunction) + { + case RMemoryTestLdd::EReadWriteMemory: + case RMemoryTestLdd::EReadMemory: + case RMemoryTestLdd::EWriteMemory: + { + TUint32 value=(TUint32)a2; +#ifdef _DEBUG + TInt debugMask = Kern::CurrentThread().iDebugMask; + Kern::CurrentThread().iDebugMask = debugMask&~(1<