diff -r 578be2adaf3e -r 307f4279f433 Adaptation/GUID-A70A01D2-467E-5BA8-A01D-6182558F3F52.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adaptation/GUID-A70A01D2-467E-5BA8-A01D-6182558F3F52.dita Fri Oct 15 14:32:18 2010 +0100 @@ -0,0 +1,67 @@ + + + + + +Boot +Time Initialisation ImplementationHow to write an initialisation function, implemented by the Media +driver and called by the kernel at boot time. +

You use the DECLARE_STANDARD_EXTENSION() macro as a +wrapper around the code that does this. There are at two important things +to do at this stage:

+ +
Asynchronous +creation of the media driver

If the underlying media driver supports +asynchronous creation, then a DFC queue must be attached at this stage. +However, media drivers that interface to the Peripheral Bus Controller should +create a new DPBusPrimaryMedia object, as shown in the +code above, but should not allocate a DFC for asynchronous creation; this +is handled by the Peripheral Bus Controller.

See also Create() - create the media driver object.

+
Register the +media driver with the local media system

The media driver must +be registered with the Local Media Subsystem; this provides information such +as the number of supported drives, partitions, names and drive numbers. This +is done by calling LocDrv::RegisterMediaDevice(), and passing +appropriate values.

The media device type can be any of the TMediaDevice enumerated +values provide that a given value is only used once. This value may sometimes +be referred to as the media ID.

The values passed to this function +are highly dependent on the target hardware platform, and it is common practice +to define them in a file contained within the Variant directory, instead of +hard-coding them into generic Symbian platform code. For example, Variant +A may provide two PC Card slots, while Variant B may provide 4.

The +port for the template reference board has the header file ...\template_variant\inc\variantmediadef.h, +which defines constants that are used when registering a media driver for +that specific hardware.

Your code may find it convenient to use the +struct SMediaDeviceInfo to capture this information.

+

The following code is used:

DECLARE_STANDARD_EXTENSION() + { + TInt r=KErrNoMemory; + DPrimaryMediaBase* pM=new DPrimaryMediaBase; + if (pM) + { + //…Required here for Asynchronous creation (if supported) + pM->iDfcQ = &MyDfcQ; + + //…Perform registration here + r = LocDrv::RegisterMediaDevice(MEDIA_DEVICE_TYPE, + MEDIA_DRIVECOUNT, + &IMediaDriveNumbers[0], + pM,MEDIA_NUMMEDIA,KMediaDriveName + ); + } + return(r); + } +

You can also do any further initialisation that is appropriate +to your driver.

+
\ No newline at end of file