Adaptation/GUID-C244D421-8BD0-4212-A5C5-47A8B1E0C1E2.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-C244D421-8BD0-4212-A5C5-47A8B1E0C1E2" xml:lang="en"><title>Kernel
       
    13 Extension</title><shortdesc>This document describes how to implement a device driver as a kernel
       
    14 extension.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <section id="GUID-D3EEB917-368E-45A3-866E-C63490994C59">             <p>Device
       
    16 drivers can also be kernel extensions, which means that they are loaded by
       
    17 the Kernel when it boots. They are used for extending the Kernel, as the name
       
    18 suggests. Generally, kernel extensions provide early initialisation of devices
       
    19 that must be permanently available, such as LCD, DMA, and I2C and other peripheral
       
    20 bus controllers. Because kernel extensions are loaded by the Kernel, they
       
    21 are never unloaded and so their destructors are never called. </p> <p>The <codeph>DECLARE_STANDARD_EXTENSION</codeph> macro
       
    22 is used to provide an entry point for a kernel extension (see <xref href="GUID-B94FFCA4-1EB3-46A7-9FF9-54C55D67FFE8.dita">Entry
       
    23 Points</xref>). </p> <p>Extensions are built into the ROM image, by specifying
       
    24 the <codeph>extension</codeph> keyword in the <filepath>.iby</filepath> file.
       
    25 This enables the ROM build tool to build the ROM header. The extensions are
       
    26 loaded in the order specified in the <filepath>kernel.iby</filepath> file. </p> <codeblock id="GUID-1AABD1B3-BF5A-50FC-9B1F-86E657F9890D" xml:space="preserve">extension[VARID]=\Epoc32\Release\&lt;assp&gt;\urel\KDEBUG.DLL \System\Bin\kdebug.dll</codeblock> <p>A
       
    27 kernel extension's interface to other Kernel side components is usually exported
       
    28 using a static interface. Clients can access this interface by using the global
       
    29 instance of the object created and initialised in the <codeph>DECLARE_STANDARD_EXTENSION</codeph> entry
       
    30 point. They then use this object to call the exported API. </p> <p>Kernel
       
    31 extensions can also be implemented that let user code open channels on them
       
    32 to use the interface. This model is used for devices where initialisation
       
    33 has to be done at system boot up, but which can then be used by the clients,
       
    34 for example, the media driver <filepath>elocd.ldd</filepath>. </p> <p>To do
       
    35 this, drivers have to declare <xref href="GUID-38771B51-195D-3148-A462-277DA3696117.dita"><apiname>DECLARE_EXTENSION_LDD</apiname></xref> in
       
    36 addition to the <xref href="GUID-8B6DF6D7-4995-3564-9303-272500D7E747.dita"><apiname>DECLARE_STANDARD_EXTENSION</apiname></xref> macro. In this
       
    37 model, extensions generally call <xref href="GUID-671F731F-428F-379D-8260-D9F18CAC25CF.dita#GUID-671F731F-428F-379D-8260-D9F18CAC25CF/GUID-ADB60188-13D4-3245-96D0-4D44CB983551"><apiname>Kernel::InstallLogicalDevice()</apiname></xref> /<xref href="GUID-671F731F-428F-379D-8260-D9F18CAC25CF.dita#GUID-671F731F-428F-379D-8260-D9F18CAC25CF/GUID-703E2FAD-A71C-377B-86F0-D19643D4CDA9"><apiname>Kernel::InstallPhysicalDevice()</apiname></xref> to
       
    38 install the logical device. Later clients can open channels on this driver
       
    39 and use the interface in the same way as a standard driver. </p> <codeblock id="GUID-29B10898-2CCA-5D03-B14A-CAD3C56EB73F" xml:space="preserve">DECLARE_STANDARD_EXTENSION()
       
    40     {
       
    41     ...
       
    42     // Create factory object
       
    43     DExDriverLogicalDevice* device = new DExDriverLogicalDevice;
       
    44     if (device==NULL)
       
    45         r=KErrNoMemory;
       
    46     else
       
    47         {
       
    48         // Installs the logical device by calling the second
       
    49         // phase constructor
       
    50         r=Kern::InstallLogicalDevice(device);
       
    51         }
       
    52     return r;
       
    53     }
       
    54 
       
    55 DECLARE_EXTENSION_LDD()
       
    56     {
       
    57     return new DExDriverLogicalDevice;
       
    58     }</codeblock>     </section>
       
    59 </conbody></concept>