kerneltest/e32test/demandpaging/d_pagingexample.h
author Tom Cosgrove <tom.cosgrove@nokia.com>
Fri, 28 May 2010 16:29:07 +0100
changeset 30 8aab599e3476
parent 0 a41df078684a
permissions -rw-r--r--
Fix for bug 2283 (RVCT 4.0 support is missing from PDK 3.0.h) Have multiple extension sections in the bld.inf, one for each version of the compiler. The RVCT version building the tools will build the runtime libraries for its version, but make sure we extract all the other versions from zip archives. Also add the archive for RVCT4.

// Copyright (c) 2008-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:
// e32\e32test\demandpaging\d_pagingexample.h
// Examples for demand paging device driver migration
// This header defines the interface to four drivers:
// d_pagingexample_1_pre		DLogicalChannel-dervied driver, pre-migration
// d_pagingexample_1_post		DLogicalChannel-dervied driver, post-migration
// d_pagingexample_2_pre		DLogicalChannelBase-dervied driver, pre-migration
// d_pagingexample_2_post		DLogicalChannelBase-dervied driver, post-migration
// 
//

#ifndef __D_PAGINGEXAMPLE_H__
#define __D_PAGINGEXAMPLE_H__

#include <e32cmn.h>

#ifndef __KERNEL_MODE__
#include <e32std.h>
#endif

_LIT(KPagingExample1PreLdd,"D_PAGINGEXAMPLE_1_PRE");
_LIT(KPagingExample1PostLdd,"D_PAGINGEXAMPLE_1_POST");
_LIT(KPagingExample2PreLdd,"D_PAGINGEXAMPLE_2_PRE");
_LIT(KPagingExample2PostLdd,"D_PAGINGEXAMPLE_2_POST");

const TInt KMaxTransferSize = 256;
const TInt KAsyncDelay = 100;   // simulated async operations take 100ms

// Common interface to all versions of the example driver
class RPagingExample : public RBusLogicalChannel
	{
public:
	enum TControl
		{
		ESetRealtimeState,
		EGetConfig,
		ESetConfig,
		};
	
	enum TRequest
		{
		ERequestRead,
		ERequestReadDes,
		ERequestWrite,
		ERequestWriteDes,
		ERequestNotify,
		ERequestAsyncGetValue,
		ERequestAsyncGetValue2,
		ERequestCancel,
		};

	struct TConfigData
		{
		TInt iParam1;
		TInt iParam2;
		TInt iParam3;
		TInt iParam4;
		};

	struct TValueStruct
		{
		TInt     iValue1;
		TBuf8<4> iValue2;
		};
	
#ifndef __KERNEL_MODE__
public:
	inline TInt Open(const TDesC& aLddName)
		{ return DoCreate(aLddName, TVersion(), KNullUnit, NULL, NULL, EOwnerThread, EFalse); }
	inline TInt SetDfcThreadRealtimeState(TBool aRealtime)  // only supported on "1_pre" driver
		{ return DoControl(ESetRealtimeState, (TAny*)aRealtime); }
	inline TInt GetConfig(TConfigData& aConfigOut)
		{ return DoControl(EGetConfig, (TAny*)&aConfigOut); }
	inline TInt SetConfig(const TConfigData& aConfigIn)
		{ return DoControl(ESetConfig, (TAny*)&aConfigIn); }
	inline void Notify(TRequestStatus& aStatus)
		{ DoRequest(ERequestNotify, aStatus); }
	inline void AsyncGetValue(TRequestStatus& aStatus, TValueStruct& aValueOut)
		{ DoRequest(ERequestAsyncGetValue, aStatus, (TAny*)&aValueOut); }
	inline void AsyncGetValue2(TRequestStatus& aStatus, TInt& aValueOut1, TInt& aValueOut2)
		{ DoRequest(ERequestAsyncGetValue2, aStatus, (TAny*)&aValueOut1, (TAny*)&aValueOut2); }
	inline void Read(TRequestStatus& aStatus, TUint8* aBuffer, TInt aLength)
		{ DoRequest(ERequestRead, aStatus, aBuffer, (TAny*)aLength); }
	inline void ReadDes(TRequestStatus& aStatus, TDes8& aDesOut)
		{ DoRequest(ERequestReadDes, aStatus, &aDesOut); }
	inline void Write(TRequestStatus& aStatus, const TUint8* aBuffer, TInt aLength)
		{ DoRequest(ERequestWrite, aStatus, (TAny*)aBuffer, (TAny*)aLength); }
	inline void WriteDes(TRequestStatus& aStatus, const TDesC8& aDesIn)
		{ DoRequest(ERequestWriteDes, aStatus, (TAny*)&aDesIn); }
	inline void Cancel()
		{ DoCancel(ERequestCancel); }
#endif
	};

#endif