Symbian3/PDK/Source/GUID-0CFC2113-37F9-58B5-AF27-125C23C3087F.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 11 Mar 2010 18:02:22 +0000
changeset 3 46218c8b8afa
parent 1 25a17d01db0c
permissions -rw-r--r--
week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 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: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-0CFC2113-37F9-58B5-AF27-125C23C3087F"><title>driver1_dev.h</title><prolog><metadata><keywords/></metadata></prolog><conbody><codeblock id="GUID-56EACFFA-3694-5DEE-8EC1-0DD3BC665F76" xml:space="preserve">// driver1_dev.h
//
// Copyright (c) 2009 Nokia Ltd. All rights reserved.
//

/**
Kernel side interfaces to example Logical and Physical Device Drivers
*/

#ifndef __DRIVER1_DEV_H__
#define __DRIVER1_DEV_H__

/**
  Physical Device (factory class) for 'Driver1'
*/
class DDevice1PddFactory : public DPhysicalDevice
    {
public:
    DDevice1PddFactory();
    ~DDevice1PddFactory();
    // Inherited from DPhysicalDevice
    virtual TInt Install();
    virtual void GetCaps(TDes8&amp; aDes) const;
    virtual TInt Create(DBase*&amp; aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion&amp; aVer);
    virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion&amp; aVer);
public:
    TInt iHardwareInUse;
private:
    enum TMinimumLDDVersion
        {
        EMinimumLddMajorVersion=1,
        EMinimumLddMinorVersion=0,
        EMinimumLddBuild=0 //Not used
        };
public:
    TDynamicDfcQue* iDfcQ;
    };


/**
  Logical Device (factory class) for 'Driver1'
*/
class DDriver1Factory : public DLogicalDevice
    {
public:    
    DDriver1Factory();
    ~DDriver1Factory();
    //    Inherited from DLogicalDevice
    virtual TInt Install();
    virtual void GetCaps(TDes8&amp; aDes) const;
    virtual TInt Create(DLogicalChannelBase*&amp; aChannel);
    };

class DDriver1;

/**
  Logical Channel class for 'Driver1'
*/
class DDriver1Channel : public DLogicalChannel
    {
public:
    DDriver1Channel();
    virtual ~DDriver1Channel();
    // Inherited from DObject
    virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
    // Inherited from DLogicalChannelBase
    virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion&amp; aVer);
    // Inherited from DLogicalChannel
    virtual void HandleMsg(TMessageBase* aMsg);
private:
    // Panic reasons
    enum TPanic
        {
        ERequestAlreadyPending = 1
        };
    // Implementation for the differnt kinds of requests send through RBusLogicalChannel
    TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
    TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
    void DoCancel(TUint aMask);
    // Accessor for the PDD
    inline DDriver1* Pdd();
    // Methods for configuration
    TInt GetConfig(TDes8* aConfigBuf);
    TInt SetConfig(const TDesC8* aConfigBuf);
    void CurrentConfig(RDriver1::TConfig&amp; aConfig);
    // Methods for processing a SendData request
    TInt SendData(TRequestStatus* aStatus,const TDesC8* aData);
    void SendDataCancel();
    void DoSendDataComplete();
    static void SendDataDfc(TAny* aPtr);
    // Methods for processing a ReceiveData request
    TInt ReceiveData(TRequestStatus* aStatus,TDes8* aBuffer);
    void ReceiveDataCancel();
    void DoReceiveDataComplete();
    static void ReceiveDataDfc(TAny* aPtr);
public:
    // Interface methods for use by PDD
    virtual void SendDataComplete(TInt aResult);
    virtual void ReceiveDataComplete(TInt aResult);
private:
    DThread* iClient;
    // Members used for processing a SendData request
    TRequestStatus* iSendDataStatus;
    TDfc iSendDataDfc;
    TInt iSendDataResult;
    TBuf8&lt;256&gt; iSendDataBuffer;
    // Members used for processing a ReceiveData request
    TDes8* iReceiveDataDescriptor;
    TRequestStatus* iReceiveDataStatus;
    TDfc iReceiveDataDfc;
    TInt iReceiveDataResult;
    TBuf8&lt;256&gt; iReceiveDataBuffer;
    };

inline DDriver1* DDriver1Channel::Pdd()
    { return (DDriver1*)iPdd; }

/**
  Interface to 'Driver1' physical device
*/
class DDriver1 : public DBase
    {
public:
    /**
    Structure for holding PDD capabilities information
    */
    class TCaps
        {
    public:
        TVersion iVersion;
        };
public:
    virtual TInt BufferSize() const =0;
    virtual TInt Speed() const =0;
    virtual TInt SetSpeed(TInt aSpeed) =0;
    virtual TInt SendData(const TDesC8&amp; aData) =0;
    virtual void SendDataCancel() =0;
    virtual TInt ReceiveData(TDes8&amp; aBuffer) =0;
    virtual void ReceiveDataCancel() =0;
public:
    DDriver1Channel* iLdd;
    };

#endif
</codeblock> </conbody></concept>