| 0 |      1 | // Copyright (c) 2008-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 | // e32\e32test\demandpaging\d_pagingexample.h
 | 
|  |     15 | // Examples for demand paging device driver migration
 | 
|  |     16 | // This header defines the interface to four drivers:
 | 
|  |     17 | // d_pagingexample_1_pre		DLogicalChannel-dervied driver, pre-migration
 | 
|  |     18 | // d_pagingexample_1_post		DLogicalChannel-dervied driver, post-migration
 | 
|  |     19 | // d_pagingexample_2_pre		DLogicalChannelBase-dervied driver, pre-migration
 | 
|  |     20 | // d_pagingexample_2_post		DLogicalChannelBase-dervied driver, post-migration
 | 
|  |     21 | // 
 | 
|  |     22 | //
 | 
|  |     23 | 
 | 
|  |     24 | #ifndef __D_PAGINGEXAMPLE_H__
 | 
|  |     25 | #define __D_PAGINGEXAMPLE_H__
 | 
|  |     26 | 
 | 
|  |     27 | #include <e32cmn.h>
 | 
|  |     28 | 
 | 
|  |     29 | #ifndef __KERNEL_MODE__
 | 
|  |     30 | #include <e32std.h>
 | 
|  |     31 | #endif
 | 
|  |     32 | 
 | 
|  |     33 | _LIT(KPagingExample1PreLdd,"D_PAGINGEXAMPLE_1_PRE");
 | 
|  |     34 | _LIT(KPagingExample1PostLdd,"D_PAGINGEXAMPLE_1_POST");
 | 
|  |     35 | _LIT(KPagingExample2PreLdd,"D_PAGINGEXAMPLE_2_PRE");
 | 
|  |     36 | _LIT(KPagingExample2PostLdd,"D_PAGINGEXAMPLE_2_POST");
 | 
|  |     37 | 
 | 
|  |     38 | const TInt KMaxTransferSize = 256;
 | 
|  |     39 | const TInt KAsyncDelay = 100;   // simulated async operations take 100ms
 | 
|  |     40 | 
 | 
|  |     41 | // Common interface to all versions of the example driver
 | 
|  |     42 | class RPagingExample : public RBusLogicalChannel
 | 
|  |     43 | 	{
 | 
|  |     44 | public:
 | 
|  |     45 | 	enum TControl
 | 
|  |     46 | 		{
 | 
|  |     47 | 		ESetRealtimeState,
 | 
|  |     48 | 		EGetConfig,
 | 
|  |     49 | 		ESetConfig,
 | 
|  |     50 | 		};
 | 
|  |     51 | 	
 | 
|  |     52 | 	enum TRequest
 | 
|  |     53 | 		{
 | 
|  |     54 | 		ERequestRead,
 | 
|  |     55 | 		ERequestReadDes,
 | 
|  |     56 | 		ERequestWrite,
 | 
|  |     57 | 		ERequestWriteDes,
 | 
|  |     58 | 		ERequestNotify,
 | 
|  |     59 | 		ERequestAsyncGetValue,
 | 
|  |     60 | 		ERequestAsyncGetValue2,
 | 
|  |     61 | 		ERequestCancel,
 | 
|  |     62 | 		};
 | 
|  |     63 | 
 | 
|  |     64 | 	struct TConfigData
 | 
|  |     65 | 		{
 | 
|  |     66 | 		TInt iParam1;
 | 
|  |     67 | 		TInt iParam2;
 | 
|  |     68 | 		TInt iParam3;
 | 
|  |     69 | 		TInt iParam4;
 | 
|  |     70 | 		};
 | 
|  |     71 | 
 | 
|  |     72 | 	struct TValueStruct
 | 
|  |     73 | 		{
 | 
|  |     74 | 		TInt     iValue1;
 | 
|  |     75 | 		TBuf8<4> iValue2;
 | 
|  |     76 | 		};
 | 
|  |     77 | 	
 | 
|  |     78 | #ifndef __KERNEL_MODE__
 | 
|  |     79 | public:
 | 
|  |     80 | 	inline TInt Open(const TDesC& aLddName)
 | 
|  |     81 | 		{ return DoCreate(aLddName, TVersion(), KNullUnit, NULL, NULL, EOwnerThread, EFalse); }
 | 
|  |     82 | 	inline TInt SetDfcThreadRealtimeState(TBool aRealtime)  // only supported on "1_pre" driver
 | 
|  |     83 | 		{ return DoControl(ESetRealtimeState, (TAny*)aRealtime); }
 | 
|  |     84 | 	inline TInt GetConfig(TConfigData& aConfigOut)
 | 
|  |     85 | 		{ return DoControl(EGetConfig, (TAny*)&aConfigOut); }
 | 
|  |     86 | 	inline TInt SetConfig(const TConfigData& aConfigIn)
 | 
|  |     87 | 		{ return DoControl(ESetConfig, (TAny*)&aConfigIn); }
 | 
|  |     88 | 	inline void Notify(TRequestStatus& aStatus)
 | 
|  |     89 | 		{ DoRequest(ERequestNotify, aStatus); }
 | 
|  |     90 | 	inline void AsyncGetValue(TRequestStatus& aStatus, TValueStruct& aValueOut)
 | 
|  |     91 | 		{ DoRequest(ERequestAsyncGetValue, aStatus, (TAny*)&aValueOut); }
 | 
|  |     92 | 	inline void AsyncGetValue2(TRequestStatus& aStatus, TInt& aValueOut1, TInt& aValueOut2)
 | 
|  |     93 | 		{ DoRequest(ERequestAsyncGetValue2, aStatus, (TAny*)&aValueOut1, (TAny*)&aValueOut2); }
 | 
|  |     94 | 	inline void Read(TRequestStatus& aStatus, TUint8* aBuffer, TInt aLength)
 | 
|  |     95 | 		{ DoRequest(ERequestRead, aStatus, aBuffer, (TAny*)aLength); }
 | 
|  |     96 | 	inline void ReadDes(TRequestStatus& aStatus, TDes8& aDesOut)
 | 
|  |     97 | 		{ DoRequest(ERequestReadDes, aStatus, &aDesOut); }
 | 
|  |     98 | 	inline void Write(TRequestStatus& aStatus, const TUint8* aBuffer, TInt aLength)
 | 
|  |     99 | 		{ DoRequest(ERequestWrite, aStatus, (TAny*)aBuffer, (TAny*)aLength); }
 | 
|  |    100 | 	inline void WriteDes(TRequestStatus& aStatus, const TDesC8& aDesIn)
 | 
|  |    101 | 		{ DoRequest(ERequestWriteDes, aStatus, (TAny*)&aDesIn); }
 | 
|  |    102 | 	inline void Cancel()
 | 
|  |    103 | 		{ DoCancel(ERequestCancel); }
 | 
|  |    104 | #endif
 | 
|  |    105 | 	};
 | 
|  |    106 | 
 | 
|  |    107 | #endif
 |