1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/examples/convert1/convert1_dev.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,133 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Shared Chunks in its implementation.
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file Kernel side interfaces to example data converter device driver which uses
1.23 + @publishedPartner
1.24 + @prototype 9.1
1.25 +*/
1.26 +
1.27 +#ifndef __CONVERT1_DEV_H__
1.28 +#define __CONVERT1_DEV_H__
1.29 +
1.30 +/**
1.31 + Logical Device (factory class) for 'Convert1'
1.32 +*/
1.33 +class DConvert1Factory : public DLogicalDevice
1.34 + {
1.35 +public:
1.36 + DConvert1Factory();
1.37 + ~DConvert1Factory();
1.38 + // Inherited from DLogicalDevice
1.39 + virtual TInt Install();
1.40 + virtual void GetCaps(TDes8& aDes) const;
1.41 + virtual TInt Create(DLogicalChannelBase*& aChannel);
1.42 + // Resource handling methods
1.43 + TInt ClaimResource(TInt& aResourceId);
1.44 + void ReleaseResource(TInt aResourceId);
1.45 +private:
1.46 + NFastMutex iResourceMutex; /**< Mutex to protect access to iResourceFlags */
1.47 + TUint iResourceFlags; /**< Bitfield of flags representing device resources available for use.
1.48 + I.e. iResourceFlags&(1<<resourceId) is true if resource 'resourceId' is free. */
1.49 + };
1.50 +
1.51 +/**
1.52 + Class representing a buffer of data
1.53 +*/
1.54 +class DChunkBuffer
1.55 + {
1.56 +public:
1.57 + DChunkBuffer();
1.58 + ~DChunkBuffer();
1.59 + TInt Create(TInt aSize);
1.60 + void Destroy();
1.61 + TInt SetMaxSize(TInt aMaxSize);
1.62 + TInt Open(TAny* aAddress, TInt aSize, TBool aWrite=EFalse);
1.63 + TInt Open(TInt aChunkHandle, TInt aOffset, TInt aSize, TBool aWrite=EFalse);
1.64 + void Close();
1.65 + TInt Copy(TAny* aAddress, TInt aSize);
1.66 +private:
1.67 + TInt SetPhysicalAddresses(TInt aSize);
1.68 +public:
1.69 + DChunk* iChunk; /**< The chunk which contains the buffer */
1.70 + TInt iChunkOffset; /**< Offset, in bytes, of buffer start within the chunk */
1.71 + TInt iMaxSize; /**< Maximum size of buffer n bytes */
1.72 + TLinAddr iChunkBase; /**< Linear address in kernel process for the start of the chunk */
1.73 + TUint32 iChunkMapAttr; /**< MMU mapping attributes for chunk */
1.74 + TPhysAddr iPhysicalAddress; /**< Physical address of buffer. KPhysAddrInvalid if buffer not physically contiguous */
1.75 + TPhysAddr* iPhysicalPages; /**< List of physical addresses for buffer pages. 0 if buffer is physically contiguous */
1.76 + };
1.77 +
1.78 +/**
1.79 + Logical Channel class for 'Convert1'
1.80 +*/
1.81 +class DConvert1Channel : public DLogicalChannelBase
1.82 + {
1.83 +public:
1.84 + DConvert1Channel(DConvert1Factory* aFactory);
1.85 + virtual ~DConvert1Channel();
1.86 + // Inherited from DObject
1.87 + virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
1.88 + // Inherited from DLogicalChannelBase
1.89 + virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
1.90 + virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
1.91 +private:
1.92 + // Panic reasons
1.93 + enum TPanic
1.94 + {
1.95 + ERequestFromWrongThread=1,
1.96 + ERequestAlreadyPending
1.97 + };
1.98 + // Implementation for the differnt kinds of messages sent through RBusLogicalChannel
1.99 + TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
1.100 + TInt DoRequest(TInt aNotReqNo, TAny* a1, TAny* a2);
1.101 + TInt DoCancel(TUint aMask);
1.102 + // Methods for configuration
1.103 + TInt GetConfig(TDes8* aConfigBuf);
1.104 + TInt SetConfig(const TDesC8* aConfigBuf,RConvert1::TBufferInfo* aBufferInfo);
1.105 + // Methods for capturing images
1.106 + void ConvertDes(const TDesC8* aSrc,TRequestStatus* aRequestStatus);
1.107 + void ConvertChunk(const RConvert1::TConvertArgs* aSrcArgs,TRequestStatus* aRequestStatus);
1.108 + void ConvertInChunk(TInt aSize,TRequestStatus* aRequestStatus);
1.109 + void ConvertCancel();
1.110 + void ConvertComplete(TInt aResult);
1.111 + static void ConvertDfcTrampoline(TAny* aSelf);
1.112 + void ConvertDfc();
1.113 + // Methods which program the convert hardware
1.114 + void DoConvertStart(TInt aOffset,TInt aSize);
1.115 + void DoConvertCancel();
1.116 +private:
1.117 + DConvert1Factory* iFactory; /**< Pointer to device driver factory object */
1.118 + TInt iResourceId; /**< The id of the device hardware resource owned by this channel */
1.119 +
1.120 + NFastMutex iConvertMutex; /**< Mutex to protect access to driver state */
1.121 +
1.122 + DChunkBuffer* iSource; /**< Buffer containing the converter's input data */
1.123 + DChunkBuffer iInBuffer; /**< Buffer into which client supplied data can be copied */
1.124 + DChunkBuffer iOutBuffer; /**< Buffer containing the converter's output data */
1.125 + DChunkBuffer iClientBuffer; /**< Buffer representing client supplied chunk data */
1.126 +
1.127 + DThread* iClient; /**< The single client thread for this channel */
1.128 + TRequestStatus* iConvertRequestStatus; /**< The request status for client ConvertImage request */
1.129 +
1.130 + RConvert1::TConfig iConfig; /**< The driver configuration information */
1.131 +
1.132 + NTimer iConvertTimer; /**< Timer used to emulate image capture hardware */
1.133 + };
1.134 +
1.135 +#endif
1.136 +