os/kernelhwsrv/kerneltest/e32test/mmu/t_shbuf_perfserver.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test/mmu/t_shbuf_perfserver.h
sl@0
    15
//
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef _T_SHBUF_PERFSERVER_H_
sl@0
    19
#define _T_SHBUF_PERFSERVER_H_
sl@0
    20
sl@0
    21
/**
sl@0
    22
 *  @file
sl@0
    23
 * 
sl@0
    24
 *  Test server used for Performance Testing of shared buffers.
sl@0
    25
 */
sl@0
    26
sl@0
    27
#include <e32base.h>
sl@0
    28
#include <e32shbuf.h>
sl@0
    29
sl@0
    30
#include "d_shbuf.h"
sl@0
    31
sl@0
    32
class RShBuf;
sl@0
    33
sl@0
    34
/**
sl@0
    35
 *  Name of the server. The '!' means it is a protected server.
sl@0
    36
 */
sl@0
    37
_LIT(KRShBufTestServerName, "!RShBufServer");
sl@0
    38
sl@0
    39
sl@0
    40
/**
sl@0
    41
 *  Server IPC requests.
sl@0
    42
 */
sl@0
    43
enum TShBufServerRequest
sl@0
    44
	{
sl@0
    45
	EShBufServerSendBuffer,
sl@0
    46
	EShBufServerReceiveBuffer,
sl@0
    47
	EShBufServerSendAndReceiveBuffer,
sl@0
    48
	EShBufServerSendSharedBuffer,
sl@0
    49
	EShBufServerReceiveSharedBuffer,
sl@0
    50
	EShBufServerSendAndReceiveSharedBuffer,
sl@0
    51
	EShBufServerShutdownServer,
sl@0
    52
	EShBufServerFromTPtr8ProcessAndReturn,
sl@0
    53
	EShBufServerFromTPtr8ProcessAndRelease,
sl@0
    54
	EShBufServerOpenRShBufPool,
sl@0
    55
	EShBufServerCloseRShBufPool,
sl@0
    56
	EShBufServerFromRShBufProcessAndReturn,
sl@0
    57
	EShBufServerFromRShBufProcessAndRelease,
sl@0
    58
	EShBufServerDbgMarkHeap,
sl@0
    59
	EShBufServerDbgCheckHeap,
sl@0
    60
	EShBufServerDbgMarkEnd,
sl@0
    61
	EShBufServerDbgFailNext
sl@0
    62
	};
sl@0
    63
sl@0
    64
sl@0
    65
class CShBufTestServerSession;
sl@0
    66
sl@0
    67
sl@0
    68
/**
sl@0
    69
 *  The RShBuf test server class.
sl@0
    70
 *
sl@0
    71
 *  The class provides all the services required by class CShBufTestServerSession.
sl@0
    72
 */
sl@0
    73
class CShBufTestServer : public CServer2
sl@0
    74
	{
sl@0
    75
public:
sl@0
    76
	static CShBufTestServer* NewL();
sl@0
    77
sl@0
    78
	void AddSessionL(CShBufTestServerSession* aSession);
sl@0
    79
	void DropSession(CShBufTestServerSession* aSession);
sl@0
    80
sl@0
    81
	TInt FromTPtr8ProcessAndReturn(TDes8& aBuf, TUint aBufSize);
sl@0
    82
	TInt FromTPtr8ProcessAndRelease(TDes8& aBuf);
sl@0
    83
sl@0
    84
	TInt OpenRShBufPool(TInt aHandle, const TShPoolInfo& aPoolInfo);
sl@0
    85
	TInt CloseRShBufPool();
sl@0
    86
	TInt FromRShBufProcessAndReturn(RShBuf& aShBuf, TUint aBufSize);
sl@0
    87
	TInt FromRShBufProcessAndRelease(RShBuf& aShBuf);
sl@0
    88
sl@0
    89
	TInt DbgMarkHeap() const;
sl@0
    90
	TInt DbgCheckHeap(TInt aCount) const;
sl@0
    91
	TInt DbgMarkEnd(TInt aCount) const;
sl@0
    92
	TInt DbgFailNext(TInt aCount) const;
sl@0
    93
sl@0
    94
	TInt ShutdownServer();
sl@0
    95
sl@0
    96
private:
sl@0
    97
	CShBufTestServer();
sl@0
    98
	~CShBufTestServer();
sl@0
    99
sl@0
   100
	void ConstructL();
sl@0
   101
sl@0
   102
	CSession2* NewSessionL(const TVersion& aVersion,const RMessage2&/*aMessage*/) const;
sl@0
   103
	TInt RunError(TInt aError);
sl@0
   104
sl@0
   105
	RPointerArray<CShBufTestServerSession>  iSessionArray;
sl@0
   106
sl@0
   107
	//
sl@0
   108
	// Variables to control shutdown of the server...
sl@0
   109
	//
sl@0
   110
	TBool  iShouldShutdownServer;
sl@0
   111
sl@0
   112
	//
sl@0
   113
	// Handle to the driver...
sl@0
   114
	//
sl@0
   115
	RShBufTestChannel  iShBufLdd;
sl@0
   116
	TUint8  iClearCache[32768];
sl@0
   117
	};
sl@0
   118
sl@0
   119
sl@0
   120
/**
sl@0
   121
 *  This is the Phonebook Sync Server side session class and is responsible
sl@0
   122
 *  for handling the client (RPhoneBookSession) requests, encoding/decoding
sl@0
   123
 *  the parameters and Contacts Item phonebook data across the API.
sl@0
   124
 *  Once the parameters are decoded the request is sent to the server where
sl@0
   125
 *  it will either be handled directly or forwarded to the Background Sync
sl@0
   126
 *  Engine. Once the request is completed, any return parameters are written
sl@0
   127
 *  back to the client if neccessary.
sl@0
   128
 */
sl@0
   129
class CShBufTestServerSession : public CSession2
sl@0
   130
	{
sl@0
   131
public:
sl@0
   132
	void CreateL();
sl@0
   133
	void CompleteRequest(const RMessage2& aMessage, TInt aResult) const;
sl@0
   134
sl@0
   135
	inline CShBufTestServer& Server();
sl@0
   136
sl@0
   137
private:
sl@0
   138
	~CShBufTestServerSession();
sl@0
   139
sl@0
   140
	void ServiceL(const RMessage2& aMessage);
sl@0
   141
sl@0
   142
	void ShutdownServerL(const RMessage2& aMessage);
sl@0
   143
sl@0
   144
	void FromTPtr8ProcessAndReturnL(const RMessage2& aMessage);
sl@0
   145
	void FromTPtr8ProcessAndReleaseL(const RMessage2& aMessage);
sl@0
   146
sl@0
   147
	void OpenRShBufPoolL(const RMessage2& aMessage);
sl@0
   148
	void CloseRShBufPoolL(const RMessage2& aMessage);
sl@0
   149
	void FromRShBufProcessAndReturnL(const RMessage2& aMessage);
sl@0
   150
	void FromRShBufProcessAndReleaseL(const RMessage2& aMessage);
sl@0
   151
sl@0
   152
	void DbgMarkHeapL(const RMessage2& aMessage);
sl@0
   153
	void DbgCheckHeapL(const RMessage2& aMessage);
sl@0
   154
	void DbgMarkEndL(const RMessage2& aMessage);
sl@0
   155
	void DbgFailNextL(const RMessage2& aMessage);
sl@0
   156
sl@0
   157
private:
sl@0
   158
	TUint8  iSessionTempBuffer[8192];
sl@0
   159
	};
sl@0
   160
sl@0
   161
sl@0
   162
/**
sl@0
   163
 *  Returns a reference to the CPhoneBookServer class.
sl@0
   164
 */
sl@0
   165
inline CShBufTestServer& CShBufTestServerSession::Server()
sl@0
   166
	{
sl@0
   167
	return *static_cast<CShBufTestServer*>(const_cast<CServer2*>(CSession2::Server()));
sl@0
   168
	} // CShBufTestServerSession::Server
sl@0
   169
sl@0
   170
sl@0
   171
#ifndef CAN_TRANSFER_SHBUF_TO_ANOTHER_PROCESS
sl@0
   172
TInt RShBufTestServerThread(TAny* aPtr);
sl@0
   173
#endif
sl@0
   174
sl@0
   175
sl@0
   176
#endif // _T_SHBUF_PERFSERVER_H_
sl@0
   177