The LDD Entry Point and Factory

This document describes how LDDs are created.

An LDD must define an entry point function using the macro DECLARE_STANDARD_LDD, or DECLARE_EXTENSION_LDD in the case of kernel extensions. This must create an LDD factory object derived from DLogicalDevice:

    return new DerivedLogicalDevice;

This factory object is created on the kernel heap. Its purpose is to create the logical channel, the object through which all client interaction with the driver will occur.

DLogicalDevice is derived from DObject, and is, therefore a reference-counting object. It also means that DLogicalDevice objects are given a name, as these objects are always subsequently found by name. The user-side specifies the name of the logical device through the first parameter in the user-side call to RBusLogicalChannel::DoCreate().

The file extension of a LDD DLL can be any permitted Symbian Platform name but, by convention, the LDD DLL has the extension .LDD. Device driver DLLs are polymorphic interface DLLs. When building LDDs, specify a target type of ldd in the .mmp file.

An LDD is loaded by calling User::LoadLogicalDevice(). This static function:

  • loads the DLL into RAM, if necessary

  • calls the exported function at ordinal 1 to create the factory object, the DLogicalDevice derived object

  • places the factory object into the appropriate object container.

Note: This only needs to be done once, not every time the driver is used.

If an LDD needs to perform initialisation at boot time (before the driver is loaded by User::LoadLogicalDevice()) then specify the entry point macros DECLARE_STANDARD_EXTENSION and DECLARE_EXTENSION_LDD.

    // initialise code here

    return new DMyLogicalFactory;

In order for the kernel to initialise the LDD extension at boot time then the .oby file must specify the extension keyword. Also note that initialisation of the extension will not load the LDD: this still has to be done through a call to User::LoadLogicalDevice().