diff -r 578be2adaf3e -r 307f4279f433 Adaptation/GUID-65F012C2-19BA-474E-8E94-D0E89DADF7B8.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adaptation/GUID-65F012C2-19BA-474E-8E94-D0E89DADF7B8.dita Fri Oct 15 14:32:18 2010 +0100 @@ -0,0 +1,56 @@ + + + + + +Multiple +Unit SupportThis document describes how to support multiple units of hardware +with a single device driver. +
Supporting +multiple units

An LDD can support more than one device by +providing a separate channel to each device.

There can be more than +one PDD associated with a given LDD, where each PDD supports a different variation +of a similar device.

Alternatively, a single PDD can be designed to +support multiple instances of an identical device by supporting more than +one channel. For example, a platform that contains two identical UARTS could +support these by providing a PDD that can open a channel on either (or both) +UARTs.

Where a driver supports multiple devices on a platform, then +it uses a unit number to distinguish between each instance of the device. +Clients open a channel to the driver for a particular unit. The following +shows an example of this, and the example driver function that creates the +channel:

// User application opens the driver for unit1 +RExDriverChannel ldd; +r = ldd.Open(KUnit1); +test(r==KErrNone); // User side wrapper function to driver API +inline TInt RExDriverChannel::Open(TInt aUnit) + { + return DoCreate(KDriverName,VersionRequired(), + aUnit,NULL,NULL,EOwnerThread); + }
+
System information

The +driver must inform the framework that it supports the use of unit numbers. +A driver can use unit numbers to ensure that it only opens on one unit. This +is done by setting the DLogicalDevice::iParseMask bitmask +with the KDeviceAllowUnit flag.

// Logical Channel Second stage constructor +DExDriverLogicalDevice:: DExDriverLogicalDevice () + { + iParseMask = KDeviceAllowPhysicalDevice | KDeviceAllowUnit; + ... + }
+
Unit number +validation

The device driver framework validates if the driver +supports unit numbers. In the following example, the PDD checks if the unit +number passed is valid.

TInt DExH4PhysicalDevice::Validate(TInt aUnit, const TDesC8* +/*aInfo*/, const TVersion& aVer) + { + ... + if (aUnit<0 || aUnit>=KNumUarts) + return KErrNotSupported; + }
+
\ No newline at end of file