How 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:
attach a DFC queue, if the underlying media driver supports asynchronous creation
register the media driver with the local media system.
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.
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.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.