sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test/mmu/d_shbuf.h sl@0: // sl@0: // sl@0: sl@0: #ifndef D_SHBUF_H sl@0: #define D_SHBUF_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class TShPoolInfo; sl@0: class TShPoolCreateInfo; sl@0: sl@0: // Device driver names sl@0: _LIT(KTestShBufClient, "d_shbuf_client"); // Driver 0 sl@0: _LIT(KTestShBufOwn, "d_shbuf_own"); // Driver 1 sl@0: sl@0: // Some test data sl@0: _LIT8(KTestData1, "QTWHEIRSTTYEUSITOAPPAPSIDSFAGFHUJCKKLIZNXGCPVIBLNEMOQFWCERRATPEA"); sl@0: _LIT8(KTestData2, "8297382917319823712893719824737644563284328746372468732643287463"); sl@0: sl@0: const TInt KTestMinimumAlignmentLog2 = 5; sl@0: const TInt KTestPoolSizeInBufs = 10; sl@0: const TInt KDefaultPoolHandleFlags = EShPoolWriteable | EShPoolAllocate; sl@0: sl@0: class RShBufTestChannel : public RBusLogicalChannel sl@0: { sl@0: public: sl@0: enum TTestControl sl@0: { sl@0: ETestOpenUserPool, sl@0: ETestOpenKernelPool, sl@0: ETestCloseUserPool, sl@0: ETestCloseKernelPool, sl@0: ETestManipulateUserBuffer, sl@0: ETestAllocateKernelBuffer, sl@0: ETestCreatePoolPhysAddrCont, sl@0: ETestCreatePoolPhysAddrNonCont, sl@0: ETestAllocateMax, sl@0: ETestBufferAlignmentKernel, sl@0: ETestNegativeTestsKernel, sl@0: ETestCreatePoolContiguousPool, sl@0: ETestPinBuffer, sl@0: // Performance tests sl@0: EFromRShBufProcessAndReturn = 100, sl@0: EFromRShBufProcessAndRelease, sl@0: EFromTPtr8ProcessAndReturn, sl@0: EFromTPtr8ProcessAndRelease sl@0: }; sl@0: sl@0: enum { EClientThread = 0, EOwnThread = 1 }; sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline TInt Open(TInt aDriverNo); // driver 0 executes in client thread, driver 1 has its own thread sl@0: inline TInt OpenUserPool(TInt aHandle, const TShPoolInfo& aPoolInfo); sl@0: inline TInt OpenKernelPool(TShPoolCreateInfo& aInfo, TInt& aHandle); sl@0: inline TInt CloseUserPool(); sl@0: inline TInt CloseKernelPool(); sl@0: inline TInt ManipulateUserBuffer(TInt aHandle); sl@0: inline TInt AllocateKernelBuffer(TInt aPoolIndex, TInt& aHandle); sl@0: inline TInt CreatePoolPhysAddrCont(TInt aBufSize); sl@0: inline TInt CreatePoolPhysAddrNonCont(TInt aBufSize); sl@0: inline TInt AllocateMax(TInt aPoolIndex, TInt& aAllocated); sl@0: inline TInt BufferAlignmentKernel(TInt aBufSize, TInt aAlignment); sl@0: inline TInt NegativeTestsKernel(); sl@0: inline TInt ContiguousPoolKernel(TShPoolCreateInfo& aInfo); sl@0: inline TInt PinBuffer(TInt aPoolHandle, TInt aBufferHandle); sl@0: // Performance tests sl@0: inline TInt FromRShBufProcessAndReturn(TUint aBufSize); sl@0: inline TInt FromRShBufProcessAndRelease(TInt aHandle); sl@0: inline TInt FromTPtr8ProcessAndReturn(TDes8& aBuf, TUint bufferSize); sl@0: inline TInt FromTPtr8ProcessAndRelease(TDes8& aBuf); sl@0: #endif // __KERNEL_MODE__ sl@0: }; sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline TInt RShBufTestChannel::Open(TInt aDriverNo) sl@0: { sl@0: if (aDriverNo!=0&&aDriverNo!=1) sl@0: { sl@0: return KErrArgument; sl@0: } sl@0: return (DoCreate((aDriverNo)?(KTestShBufOwn()):(KTestShBufClient()),TVersion(1,0,KE32BuildVersionNumber),KNullUnit,NULL,NULL,EOwnerThread)); sl@0: } sl@0: inline TInt RShBufTestChannel::OpenUserPool(TInt aHandle, const TShPoolInfo& aPoolInfo) sl@0: {return DoControl(ETestOpenUserPool, (TAny*) aHandle, (TAny*) &aPoolInfo);} sl@0: inline TInt RShBufTestChannel::OpenKernelPool(TShPoolCreateInfo& aInfo, TInt& aHandle) sl@0: {return DoControl(ETestOpenKernelPool, (TAny*) &aInfo, (TAny*) &aHandle);} sl@0: inline TInt RShBufTestChannel::CloseUserPool() sl@0: {return DoControl(ETestCloseUserPool);} sl@0: inline TInt RShBufTestChannel::CloseKernelPool() sl@0: {return DoControl(ETestCloseKernelPool);} sl@0: inline TInt RShBufTestChannel::ManipulateUserBuffer(TInt aHandle) sl@0: {return DoControl(ETestManipulateUserBuffer, (TAny*) aHandle);} sl@0: inline TInt RShBufTestChannel::AllocateKernelBuffer(TInt aPoolIndex, TInt& aHandle) sl@0: {return DoControl(ETestAllocateKernelBuffer, (TAny*) aPoolIndex, (TAny*) &aHandle);} sl@0: inline TInt RShBufTestChannel::CreatePoolPhysAddrCont(TInt aBufSize) sl@0: {return DoControl(ETestCreatePoolPhysAddrCont, (TAny*) aBufSize);} sl@0: inline TInt RShBufTestChannel::CreatePoolPhysAddrNonCont(TInt aBufSize) sl@0: {return DoControl(ETestCreatePoolPhysAddrNonCont, (TAny*) aBufSize);} sl@0: inline TInt RShBufTestChannel::AllocateMax(TInt aPoolIndex, TInt& aAllocated) sl@0: {return DoControl(ETestAllocateMax, (TAny*) aPoolIndex, (TAny*) &aAllocated);} sl@0: inline TInt RShBufTestChannel::BufferAlignmentKernel(TInt aBufSize, TInt aAlignment) sl@0: {return DoControl(ETestBufferAlignmentKernel, (TAny*) aBufSize, (TAny*) aAlignment);} sl@0: inline TInt RShBufTestChannel::NegativeTestsKernel() sl@0: {return DoControl(ETestNegativeTestsKernel);} sl@0: inline TInt RShBufTestChannel::ContiguousPoolKernel(TShPoolCreateInfo& aInfo) sl@0: {return DoControl(ETestCreatePoolContiguousPool, (TAny*)&aInfo);} sl@0: inline TInt RShBufTestChannel::PinBuffer(TInt aPoolHandle, TInt aBufferHandle) sl@0: {return DoControl(ETestPinBuffer, (TAny*) aPoolHandle, (TAny*) aBufferHandle);} sl@0: // Performance tests sl@0: inline TInt RShBufTestChannel::FromRShBufProcessAndReturn(TUint aBufSize) sl@0: {return DoControl(EFromRShBufProcessAndReturn, (TAny*) aBufSize);} sl@0: inline TInt RShBufTestChannel::FromRShBufProcessAndRelease(TInt aHandle) sl@0: {return DoControl(EFromRShBufProcessAndRelease,(TAny*)aHandle);} sl@0: inline TInt RShBufTestChannel::FromTPtr8ProcessAndReturn(TDes8& aBuf, TUint aBufSize) sl@0: {return DoControl(EFromTPtr8ProcessAndReturn,(TAny*)&aBuf, (TAny*) aBufSize);} sl@0: inline TInt RShBufTestChannel::FromTPtr8ProcessAndRelease(TDes8& aBuf) sl@0: {return DoControl(EFromTPtr8ProcessAndRelease,(TAny*)&aBuf);} sl@0: #endif // __KERNEL_MODE__ sl@0: #endif // D_SHBUF_H