Symbian
 Developer Library

DEVELOPER LIBRARY

[Index] [Glossary] [Previous] [Next]



Location: k32std.h
Link against: ekern.lib

Class DPhysicalDevice

DPhysicalDevice

Support

Supported from 5.0

Description

The abstract base class for the PDD factory object.

This is also referred to as the physical device.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CObjectImplements reference counting to track concurrent references to itself
DPhysicalDeviceThe abstract base class for the PDD factory object

Defined in DPhysicalDevice:
CheckForSlowOpening(), CheckForSlowOpening(), CreateL(), DPhysicalDevice(), GetCaps(), Install(), IsAvailable(), Library(), QueryVersionSupported(), Remove(), iLibrary, iUnitsMask, iVersion, ~DPhysicalDevice()

Inherited from CBase:
operator new()

Inherited from CObject:
AccessCount(), Close(), Dec(), FullName(), Inc(), Name(), Open(), Owner(), SetName(), SetNameL(), SetOwner(), UniqueID()


Construction and destruction


DPhysicalDevice()

protected : DPhysicalDevice();

Description

Default constructor.

The constructor is protected to prevent objects of this class from being constructed. This class is intended only as an abstract base for other classes.

Typically, a derived class constructor sets up the data members: iVersion and iUnitsMask.

See also:


~DPhysicalDevice()

protected : ~DPhysicalDevice();

Description

Destructor.

This implementation is empty.

[Top]


Functions that need an implementation


Install()

virtual TInt Install() = 0;

Description

Completes the installation of this physical device.

The function is called by the Kernel after this factory object has been successfully constructed on the Kernel heap as a result of a call to User::LoadPhysicalDevice().

As a minimum, the function must define the name of the physical device; this is the way the physical device is identified. The name should be the same as the LDD name but followed by a dot and then a short string to represent the physical device; for example, ecomm.pccd for the comms PDD for the pc-card serial port. For example:

_LIT(KName,"Myname.xxxx");
return(SetName(&KName));

where CObject::SetName() is a member of the base class, and the format of any name obeys the standard rules.

Return value

TInt

KErrNone, if successful; otherwise, one of the other system wide error codes.

See also:


GetCaps()

virtual void GetCaps(TDes8& aDes) const = 0;

Description

Gets the capabilities of this physical device.

This function is not called by the device driver framework but is available to be called.

Symbian OS does not define how a device's capabilities are encoded. Any encoding scheme must be understood by the user side.

A common convention is simply to return the version of the PDD on the grounds that capabilities correlate with the version.

Parameters

TDes8& aDes

On return, contains information describing the capabilities of the physical device.


CreateL()

virtual CBase* CreateL(TInt aUnit,const TDesC* anInfo,const TVersion& aVer) = 0;

Description

Creates a physical channel.

The function is called by the Kernel during the creation of a logical channel as a consequence of a user side call to RBusLogicalChannel::DoCreate() . This, in turn, is called by an 'open' type member function of a class derived from RBusLogicalChannel supplied by the developer of the device driver.

The physical channel is only created if the logical device needs a physical device, i.e. if the KDeviceAllowPhysicalDevice bit is set in the iParseMask data member of DLogicalDevice.

The constructed object is always an instance of a class derived from CBase. The device driver framework makes no particular recommendation on the structure of this derived class.

For drivers which implement unit numbers, the implementation should check that the device supports the specified unit number, either directly in this function or in a delegated function which might be prototyped as DoCreate(TInt aUnit), defined on the CBase derived class. This function should also check the requested version number against the version number with which this PDD is built.

A typical implementation might be:

{
    if (!User::QueryVersionSupported(iVersion,aVer))
        {
        User::Leave(KErrNotSupported);
        }
    CBase* pD = new(ELeave) DSomePhysicalChannel();
    TInt ret = pD->DoCreate(aUnit); // should also verify that this
                                    // is valid for this device
    if (ret != KErrNone)
        {
        delete pD;
        User::Leave(ret);
        }
    return pD;
    }

where DSomePhysicalChannel is a class is wholly designed by the device driver writer.

Parameters

TInt aUnit

The unit for which the channel is being created.

const TDesC* anInfo

A pointer to a descriptor containing additional information; this may be NULL.

const TVersion& aVer

The requested version.

Return value

CBase*

A pointer to the physical channel, a Kernel side object.

Notes:

See also:

[Top]


Functions with default implementation


Remove()

virtual TInt Remove();

Description

Performs final processing before removing this physical device.

This function is called by the Kernel as a result of a call to User::FreePhysicalDevice(). It is called before:

The function is also called by the Kernel if a call to User::LoadPhysicalDevice() fails. Specifically, the function is called if the attempt to add this DPhysicalDevice object to the Kernel's list of physical devices fails. In this event, Remove() is called before Close() is called on this object.

The function gives the logical device the opportunity to do any further final processing before it is closed; it should return KErrNone.

The default implementation just returns KErrNone.

Return value

TInt

KErrNone.

Notes:

See also:


QueryVersionSupported()

virtual TBool QueryVersionSupported(const TVersion& aVer) const;

Description

Tests whether the specified version is supported by this physical device.

The function is not called by device driver framework but is available to be called.

An implementation supplied by a derived class should decide whether the specified version is supported by this logical device and return true or false.

The default implementation returns the result of a call to User::QueryVersionSupported() taking the version with which this DPhysicalDevice object is built as the reference version and the specified version as the test version; i.e. the default implementation returns true if one of the following two conditions is true and returns false if neither are true:

Parameters

const TVersion& aVer

The version to be compared against the version with which this DPhysicalDevice is built.

Return value

TBool

True, if the specified version is supported by this physical device; false, otherwise.

See also:


IsAvailable()

virtual TBool IsAvailable(TInt aUnit,const TDesC* anInfo) const;

Description

Tests whether a unit is supported.

The function is not called by device driver framework but is available to be called.

An implementation supplied by a derived class should decide whether the specified unit and the additional information specified by the const TDesC* anInfo argument is supported, and return true if it is or false if not.

The default implementation always returns true.

Parameters

TInt aUnit

The unit.

const TDesC* anInfo

A pointer to a descriptor containing additional information; this pointer can be NULL.

Return value

TBool

True, if the unit is supported; false, otherwise.

Notes:


CheckForSlowOpening()

virtual TUint CheckForSlowOpening(TInt* aUnit);

Support

Withdrawn in 6.1

Description

Tests whether the device requires an asynchronous operation before and/or after opening a channel.

The function is called by the Kernel as part of the response to the user side RBusLogicalChannel::DoCreate().

Such a function allows the power handling needs of the device to be addressed.

An implementation should decide whether the device needs an asynchronous operation and, if it does, whether it should be performed:

The function must also put the unit number in *aUnit and, if asynchronous operations are needed.

The default implementation returns zero which means that the device needs no asynchronous operations.

Parameters

TInt* aUnit

A pointer to a TInt supplied by the Kernel into which the function must put the unit number.

Return value

TUint

The peripheral bus socket number plus KBusDevPhase1Start, if an asynchronous operation is needed before opening the channel, or KBusDevPhase2Start, if an asynchronous operation is needed after opening the channel, or both KBusDevPhase1Start and KBusDevPhase2Start, if an asynchronous operation is needed both before and after opening the channel. This return value is zero, if the device needs no asynchronous operations.

Notes:


CheckForSlowOpening()

virtual TUint CheckForSlowOpening(TInt aUnit);

Support

Supported from 6.1

Description

Tests whether the device requires an asynchronous operation before and/or after opening a channel.

The function is called by the Kernel as part of the response to the user side RBusLogicalChannel::DoCreate().

Such a function allows the power handling needs of the device to be addressed.

An implementation should decide whether the device needs an asynchronous operation and, if it does, whether it should be performed:

The default implementation returns zero which means that the device needs no asynchronous operations.

Parameters

TInt aUnit

The unit number.

Return value

TUint

The peripheral bus socket number plus KBusDevPhase1Start, if an asynchronous operation is needed before opening the channel, or KBusDevPhase2Start, if an asynchronous operation is needed after opening the channel, or both KBusDevPhase1Start and KBusDevPhase2Start, if an asynchronous operation is needed both before and after opening the channel. This return value is zero, if the device needs no asynchronous operations.

Notes:

[Top]


Accessors


Library()

DLibrary* Library();

Description

Gets a pointer to the PDD library.

Return value

DLibrary*

A pointer to the PDD library.

[Top]


Data members


iVersion

protected : TVersion iVersion;

Description

The version of this physical device.

This is used to check that an LDD and PDD are compatible. Typically, this is set by the constructor of a derived class.


iUnitsMask

protected : TUint iUnitsMask;

Description

Indicates which units are valid.

If units are allowed, i.e. DLogicalDevice::iParseMask&KDeviceAllowMask returns true, then this mask indicates which of the units (from 0 to 31) are valid.

The DLogicalDevice object associated with the LDD has a similar mask, and both masks are used to indicate which units the LDD-PDD pair can handle.

Typically, this is set by the constructor of a derived class.

See also:

[Top]


Internal members


iLibrary

private : DLibrary *iLibrary;

Description

This is internal and is not intended for use.

It is a pointer to the PDD library.