Adaptation/GUID-A70A01D2-467E-5BA8-A01D-6182558F3F52.dita
changeset 15 307f4279f433
equal deleted inserted replaced
14:578be2adaf3e 15:307f4279f433
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-A70A01D2-467E-5BA8-A01D-6182558F3F52" xml:lang="en"><title>Boot
       
    13 Time Initialisation Implementation</title><shortdesc>How to write an initialisation function, implemented by the Media
       
    14 driver and called by the kernel at boot time. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>You use the <xref href="GUID-7964FC46-4641-3BDD-92C9-50FA22C3321A.dita"><apiname>DECLARE_STANDARD_EXTENSION()</apiname></xref> macro as a
       
    16 wrapper around the code that does this. There are at two important things
       
    17 to do at this stage: </p>
       
    18 <ul>
       
    19 <li id="GUID-21EA5C7E-7147-596E-A340-1D6FED0328CE"><p>attach a DFC queue,
       
    20 if the underlying media driver supports asynchronous creation </p> </li>
       
    21 <li id="GUID-4E9CD255-B954-5B75-B639-2AC494296AA4"><p>register the media driver
       
    22 with the local media system. </p> </li>
       
    23 </ul>
       
    24 <section id="GUID-43EB0EC7-AAA3-5FFC-8724-E938F6BFB158"><title>Asynchronous
       
    25 creation of the media driver</title> <p>If the underlying media driver supports
       
    26 asynchronous creation, then a DFC queue <i>must</i> be attached at this stage.
       
    27 However, media drivers that interface to the Peripheral Bus Controller should
       
    28 create a new <xref href="GUID-B4E66372-2654-3434-AFB7-844B0B8D2FC9.dita"><apiname>DPBusPrimaryMedia</apiname></xref> object, as shown in the
       
    29 code above, but should not allocate a DFC for asynchronous creation; this
       
    30 is handled by the Peripheral Bus Controller. </p> <p>See also <xref href="GUID-A6D14A03-ADBF-570D-8AC7-E8BC2700F930.dita#GUID-A6D14A03-ADBF-570D-8AC7-E8BC2700F930/GUID-32B157E9-0F71-5C1B-A0FA-08D5B1ACA700">Create() - create the media driver object</xref>. </p> </section>
       
    31 <section id="GUID-4A8DEEAB-32C4-5431-8226-5623E2BD9098"><title>Register the
       
    32 media driver with the local media system</title> <p>The media driver must
       
    33 be registered with the Local Media Subsystem; this provides information such
       
    34 as the number of supported drives, partitions, names and drive numbers. This
       
    35 is done by calling <xref href="GUID-9E60E8D9-619E-3A76-BAC8-93A60D62C7DF.dita#GUID-9E60E8D9-619E-3A76-BAC8-93A60D62C7DF/GUID-647D0858-FE04-3A4F-99CE-81CD0B34CE7B"><apiname>LocDrv::RegisterMediaDevice()</apiname></xref>, and passing
       
    36 appropriate values. </p> <p>The media device type can be any of the <xref href="GUID-0FE5A5FE-5D38-3620-8674-2B770CB9D049.dita"><apiname>TMediaDevice</apiname></xref> enumerated
       
    37 values provide that a given value is only used once. This value may sometimes
       
    38 be referred to as the media ID. </p> <p>The values passed to this function
       
    39 are highly dependent on the target hardware platform, and it is common practice
       
    40 to define them in a file contained within the Variant directory, instead of
       
    41 hard-coding them into generic Symbian platform code. For example, Variant
       
    42 A may provide two PC Card slots, while Variant B may provide 4. </p> <p>The
       
    43 port for the template reference board has the header file <filepath>...\template_variant\inc\variantmediadef.h</filepath>,
       
    44 which defines constants that are used when registering a media driver for
       
    45 that specific hardware. </p> <p>Your code may find it convenient to use the
       
    46 struct <xref href="GUID-FC0F974E-9ABB-348B-9AE9-778B3A1F413A.dita"><apiname>SMediaDeviceInfo</apiname></xref> to capture this information. </p> </section>
       
    47 <example><p>The following code is used: </p> <codeblock id="GUID-2A3ADFBB-C2D4-51DD-AE3E-21C5C34554D9" xml:space="preserve">DECLARE_STANDARD_EXTENSION()
       
    48     {
       
    49     TInt r=KErrNoMemory;
       
    50     DPrimaryMediaBase* pM=new DPrimaryMediaBase;
       
    51     if (pM)
       
    52         {
       
    53         //…Required here for Asynchronous creation (if supported)
       
    54         pM-&gt;iDfcQ = &amp;MyDfcQ;
       
    55  
       
    56         //…Perform registration here
       
    57         r = LocDrv::RegisterMediaDevice(MEDIA_DEVICE_TYPE,
       
    58                                         MEDIA_DRIVECOUNT,
       
    59                                         &amp;IMediaDriveNumbers[0],
       
    60                                         pM,MEDIA_NUMMEDIA,KMediaDriveName
       
    61                                        );
       
    62         }
       
    63     return(r);
       
    64     }
       
    65       </codeblock> <p>You can also do any further initialisation that is appropriate
       
    66 to your driver. </p></example>
       
    67 </conbody></concept>