kerneltest/e32test/mmu/d_shbuf.h
changeset 9 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test/mmu/d_shbuf.h
       
    15 //
       
    16 //
       
    17 
       
    18 #ifndef D_SHBUF_H
       
    19 #define D_SHBUF_H
       
    20 
       
    21 #include <e32cmn.h>
       
    22 #include <e32ver.h>
       
    23 #include <e32shbufcmn.h>
       
    24 
       
    25 class TShPoolInfo;
       
    26 class TShPoolCreateInfo;
       
    27 
       
    28 // Device driver names
       
    29 _LIT(KTestShBufClient, "d_shbuf_client"); // Driver 0
       
    30 _LIT(KTestShBufOwn, "d_shbuf_own"); // Driver 1
       
    31 
       
    32 // Some test data
       
    33 _LIT8(KTestData1, "QTWHEIRSTTYEUSITOAPPAPSIDSFAGFHUJCKKLIZNXGCPVIBLNEMOQFWCERRATPEA");
       
    34 _LIT8(KTestData2, "8297382917319823712893719824737644563284328746372468732643287463");
       
    35 
       
    36 const TInt KTestMinimumAlignmentLog2 = 5;
       
    37 const TInt KTestPoolSizeInBufs = 10;
       
    38 const TInt KDefaultPoolHandleFlags = EShPoolWriteable | EShPoolAllocate;
       
    39 
       
    40 class RShBufTestChannel : public RBusLogicalChannel
       
    41 	{
       
    42 public:
       
    43 	enum TTestControl
       
    44 		{
       
    45 		ETestOpenUserPool,
       
    46 		ETestOpenKernelPool,
       
    47 		ETestCloseUserPool,
       
    48 		ETestCloseKernelPool,
       
    49 		ETestManipulateUserBuffer,
       
    50 		ETestAllocateKernelBuffer,
       
    51 		ETestCreatePoolPhysAddrCont,
       
    52 		ETestCreatePoolPhysAddrNonCont,
       
    53 		ETestAllocateMax,
       
    54 		ETestBufferAlignmentKernel,
       
    55 		ETestNegativeTestsKernel,
       
    56 		ETestCreatePoolContiguousPool,
       
    57 		ETestPinBuffer,
       
    58 		// Performance tests
       
    59 		EFromRShBufProcessAndReturn = 100,
       
    60 		EFromRShBufProcessAndRelease,
       
    61 		EFromTPtr8ProcessAndReturn,
       
    62 		EFromTPtr8ProcessAndRelease
       
    63 		};
       
    64 
       
    65 	enum { EClientThread = 0, EOwnThread = 1 };
       
    66 
       
    67 #ifndef __KERNEL_MODE__
       
    68 	inline TInt Open(TInt aDriverNo);	// driver 0 executes in client thread, driver 1 has its own thread
       
    69 	inline TInt OpenUserPool(TInt aHandle, const TShPoolInfo& aPoolInfo);
       
    70 	inline TInt OpenKernelPool(TShPoolCreateInfo& aInfo, TInt& aHandle);
       
    71 	inline TInt CloseUserPool();
       
    72 	inline TInt CloseKernelPool();
       
    73 	inline TInt ManipulateUserBuffer(TInt aHandle);
       
    74 	inline TInt AllocateKernelBuffer(TInt aPoolIndex, TInt& aHandle);
       
    75 	inline TInt CreatePoolPhysAddrCont(TInt aBufSize);
       
    76 	inline TInt CreatePoolPhysAddrNonCont(TInt aBufSize);
       
    77 	inline TInt AllocateMax(TInt aPoolIndex, TInt& aAllocated);
       
    78 	inline TInt BufferAlignmentKernel(TInt aBufSize, TInt aAlignment);
       
    79 	inline TInt NegativeTestsKernel();
       
    80 	inline TInt ContiguousPoolKernel(TShPoolCreateInfo& aInfo);
       
    81 	inline TInt PinBuffer(TInt aPoolHandle, TInt aBufferHandle);
       
    82 	// Performance tests
       
    83 	inline TInt FromRShBufProcessAndReturn(TUint aBufSize);
       
    84 	inline TInt FromRShBufProcessAndRelease(TInt aHandle);
       
    85 	inline TInt FromTPtr8ProcessAndReturn(TDes8& aBuf, TUint bufferSize);
       
    86 	inline TInt FromTPtr8ProcessAndRelease(TDes8& aBuf);
       
    87 #endif // __KERNEL_MODE__
       
    88 	};
       
    89 
       
    90 #ifndef __KERNEL_MODE__
       
    91 inline TInt RShBufTestChannel::Open(TInt aDriverNo)
       
    92 	{
       
    93 	if (aDriverNo!=0&&aDriverNo!=1)
       
    94 		{
       
    95 		return KErrArgument;
       
    96 		}
       
    97 	return (DoCreate((aDriverNo)?(KTestShBufOwn()):(KTestShBufClient()),TVersion(1,0,KE32BuildVersionNumber),KNullUnit,NULL,NULL,EOwnerThread));
       
    98 	}
       
    99 inline TInt RShBufTestChannel::OpenUserPool(TInt aHandle, const TShPoolInfo& aPoolInfo)
       
   100 	{return DoControl(ETestOpenUserPool, (TAny*) aHandle, (TAny*) &aPoolInfo);}
       
   101 inline TInt RShBufTestChannel::OpenKernelPool(TShPoolCreateInfo& aInfo, TInt& aHandle)
       
   102 	{return DoControl(ETestOpenKernelPool, (TAny*) &aInfo, (TAny*) &aHandle);}
       
   103 inline TInt RShBufTestChannel::CloseUserPool()
       
   104 	{return DoControl(ETestCloseUserPool);}
       
   105 inline TInt RShBufTestChannel::CloseKernelPool()
       
   106 	{return DoControl(ETestCloseKernelPool);}
       
   107 inline TInt RShBufTestChannel::ManipulateUserBuffer(TInt aHandle)
       
   108 	{return DoControl(ETestManipulateUserBuffer, (TAny*) aHandle);}
       
   109 inline TInt RShBufTestChannel::AllocateKernelBuffer(TInt aPoolIndex, TInt& aHandle)
       
   110 	{return DoControl(ETestAllocateKernelBuffer, (TAny*) aPoolIndex, (TAny*) &aHandle);}
       
   111 inline TInt RShBufTestChannel::CreatePoolPhysAddrCont(TInt aBufSize)
       
   112 	{return DoControl(ETestCreatePoolPhysAddrCont, (TAny*) aBufSize);}
       
   113 inline TInt RShBufTestChannel::CreatePoolPhysAddrNonCont(TInt aBufSize)
       
   114 	{return DoControl(ETestCreatePoolPhysAddrNonCont, (TAny*) aBufSize);}
       
   115 inline TInt RShBufTestChannel::AllocateMax(TInt aPoolIndex, TInt& aAllocated)
       
   116 	{return DoControl(ETestAllocateMax, (TAny*) aPoolIndex, (TAny*) &aAllocated);}
       
   117 inline TInt RShBufTestChannel::BufferAlignmentKernel(TInt aBufSize, TInt aAlignment)
       
   118 	{return DoControl(ETestBufferAlignmentKernel, (TAny*) aBufSize, (TAny*) aAlignment);}
       
   119 inline TInt RShBufTestChannel::NegativeTestsKernel()
       
   120 	{return DoControl(ETestNegativeTestsKernel);}
       
   121 inline TInt RShBufTestChannel::ContiguousPoolKernel(TShPoolCreateInfo& aInfo)
       
   122 	{return DoControl(ETestCreatePoolContiguousPool, (TAny*)&aInfo);}
       
   123 inline TInt RShBufTestChannel::PinBuffer(TInt aPoolHandle, TInt aBufferHandle)
       
   124 	{return DoControl(ETestPinBuffer, (TAny*) aPoolHandle, (TAny*) aBufferHandle);}
       
   125 // Performance tests
       
   126 inline TInt RShBufTestChannel::FromRShBufProcessAndReturn(TUint aBufSize)
       
   127 	{return DoControl(EFromRShBufProcessAndReturn, (TAny*) aBufSize);}
       
   128 inline TInt RShBufTestChannel::FromRShBufProcessAndRelease(TInt aHandle)
       
   129 	{return DoControl(EFromRShBufProcessAndRelease,(TAny*)aHandle);}
       
   130 inline TInt RShBufTestChannel::FromTPtr8ProcessAndReturn(TDes8& aBuf, TUint aBufSize)
       
   131 	{return DoControl(EFromTPtr8ProcessAndReturn,(TAny*)&aBuf, (TAny*) aBufSize);}
       
   132 inline TInt RShBufTestChannel::FromTPtr8ProcessAndRelease(TDes8& aBuf)
       
   133 	{return DoControl(EFromTPtr8ProcessAndRelease,(TAny*)&aBuf);}
       
   134 #endif // __KERNEL_MODE__
       
   135 #endif // D_SHBUF_H