Symbian3/PDK/Source/GUID-C376486D-B9BF-5D00-8B1A-1527FC1F83AD.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     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-C376486D-B9BF-5D00-8B1A-1527FC1F83AD" xml:lang="en"><title>RAM
       
    13 Zone Tutorial</title><shortdesc>This topic describes how to design the use of RAM zones on a phone,
       
    14 and how to specify the RAM zones in the set up functions in the ASSP/Variant. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>A base port can improve the power performance of a phone through the use
       
    16 of <xref href="GUID-C13DFF33-7C54-5113-9277-CAD96215F075.dita">RAM Zones</xref>. </p>
       
    17 <section id="GUID-7A1812EA-F693-4521-A72D-A7AF95B61C66"><title> Specifying RAM zones</title> <p>RAM zones are specified only
       
    18 once during the boot process by the base port. This takes place within the
       
    19 overridden pure virtual method <xref href="GUID-A83A7C3C-7DC0-3B9C-842F-70FCC751365D.dita#GUID-A83A7C3C-7DC0-3B9C-842F-70FCC751365D/GUID-63F2135B-4264-3B3B-9B68-656A89BF7EE9"><apiname>Asic::Init1()</apiname></xref> by <xref href="GUID-3DC7B5F2-512E-3FF3-BC08-945DDE2AE680.dita#GUID-3DC7B5F2-512E-3FF3-BC08-945DDE2AE680/GUID-F4765A82-01D0-3F97-A216-99327F14D53A"><apiname>Epoc::SetRamZoneConfig()</apiname></xref>. <xref href="GUID-3DC7B5F2-512E-3FF3-BC08-945DDE2AE680.dita#GUID-3DC7B5F2-512E-3FF3-BC08-945DDE2AE680/GUID-F4765A82-01D0-3F97-A216-99327F14D53A"><apiname>Epoc::SetRamZoneConfig()</apiname></xref> takes an array of <xref href="GUID-9C26C2ED-922E-3E61-9A7D-779165940BB9.dita"><apiname>SRamZone</apiname></xref> objects and an optional pointer
       
    20 to the base port implementation of the <xref href="GUID-ACA7BAC8-9DC3-356A-92C2-F33A99D8604B.dita"><apiname>TRamZoneCallback</apiname></xref> function.
       
    21 This is described in detail in <xref href="GUID-C376486D-B9BF-5D00-8B1A-1527FC1F83AD.dita#GUID-C376486D-B9BF-5D00-8B1A-1527FC1F83AD/GUID-A0273264-8876-523D-B1F0-F6D430FFAECA">RAM
       
    22 zone call back function</xref>. </p> <p>Each <xref href="GUID-9C26C2ED-922E-3E61-9A7D-779165940BB9.dita"><apiname>SRamZone</apiname></xref> object
       
    23 contains the physical base address, size in bytes, unique ID, preference value
       
    24 and a set of flags for each RAM zone. </p> <p><b>Restrictions on RAM zone
       
    25 properties </b> </p> <p>There are some restrictions on how the base port can
       
    26 specify the RAM zones: </p> <ul>
       
    27 <li id="GUID-CD39AC9D-D625-548E-8AFC-DCF567AE5D90"><p>each RAM zone's address
       
    28 space must be distinct and not overlap with any other RAM zone's address space </p> </li>
       
    29 <li id="GUID-9A43168A-D350-5A83-A201-683C0DEC5D51"><p>the value of <xref href="GUID-F17B80B9-82E2-32FB-8AE0-10FE8094910F.dita"><apiname>SRamZone.iBase</apiname></xref> must
       
    30 be aligned to the ASIC's MMU small page size </p> </li>
       
    31 <li id="GUID-D7F43ADD-22DC-504E-BAB1-BAFB5B10D59C"><p>the value of <xref href="GUID-369C0E92-AE5D-3939-9D41-8269CA1842B0.dita"><apiname>SRamZone.iSize</apiname></xref> must
       
    32 be a multiple of the ASIC's MMU small page size, usually 4KB on an ARM MMU </p> </li>
       
    33 <li id="GUID-6CA82A2B-1812-5F01-8BDD-458EEF0012AE"><p>when added together
       
    34 all of the RAM zones must cover the whole of the physical RAM address space
       
    35 as specified by the bootstrap in the <xref href="GUID-84750794-1480-349B-8E93-442A98FCA2E9.dita"><apiname>SuperPage</apiname></xref> member <xref href="GUID-0D646171-1989-39F0-A254-5B6D060D8C25.dita#GUID-0D646171-1989-39F0-A254-5B6D060D8C25/GUID-10EBE3FB-68EE-3367-9244-65E555032F57"><apiname>SSuperPageBase::iTotalRamSize</apiname></xref>  </p> </li>
       
    36 <li id="GUID-B8C7068C-33DC-5524-8A1D-CE36CF188487"><p>the value of each RAM
       
    37 zone’s <xref href="GUID-5C496D97-236F-3EEA-850E-C34F8460CBE4.dita"><apiname>SRamZone.iId</apiname></xref> must be unique for that RAM zone </p> </li>
       
    38 <li id="GUID-C0840320-5F65-5D11-981F-04BED75E3E60"><p>there can be no more
       
    39 RAM zones than specified by <xref href="GUID-F7BFCBAF-3E13-3F2F-B89F-F4F7DE40E204.dita"><apiname>KMaxRamZones</apiname></xref>. </p> </li>
       
    40 </ul> <p><b>Restriction on RAM zone preference ordering </b> </p> <p>The bootstrap
       
    41 always allocates the RAM it requires from the lowest RAM address upwards.
       
    42 This is during the system boot process and before the variant has specified
       
    43 the RAM zone properties. This means that the RAM zone(s) located at the lowest
       
    44 RAM addresses, used by the bootstrap, are never empty. Therefore, these RAM
       
    45 zone(s) should always be assigned to be the most preferable. A low preference
       
    46 value maps to a high logical preference, therefore the most preferable RAM
       
    47 zones have a preference value that is lower than the preference value of all
       
    48 the other RAM zones in the device. </p> </section>
       
    49 <section id="GUID-68EA70F2-91DD-5919-97D5-7A5678E16FC8"><title>Designing RAM
       
    50 zones to reduce power consumption</title> <p><b>Partitioning RAM into zones </b> </p> <p>For
       
    51 power saving purposes, each RAM zone should represent the lowest division
       
    52 of the device’s RAM IC(s) that can be either powered down or refreshed independently
       
    53 of other divisions of the RAM IC(s). For example, it should not be possible
       
    54 for less than an entire RAM zone to be powered or refreshed. This allows the
       
    55 system to achieve lower power consumption when the level of RAM usage is reduced. </p> <p>For
       
    56 example, if a device contains two RAM ICs and each IC is further divided into
       
    57 4 banks that can be refreshed independently, then the device’s RAM should
       
    58 be divided into 8 RAM zones with each zone being mapped to one of the 8 individually
       
    59 refreshable RAM IC banks. </p> <p><b>Assigning preferences to zones </b> </p> <p>To
       
    60 save power, the RAM zone preferences should be implemented in such a way that
       
    61 the minimum number of RAM ICs or RAM IC refresh banks are used. </p> <p>For
       
    62 example, suppose a device has 2 RAM ICs, the RAM zones in the lowest addressed
       
    63 RAM IC (IC0) should be more preferable than the RAM zones located in the second
       
    64 RAM IC (IC1). For all RAM zones in IC0 the preference should be less than
       
    65 the preference of the RAM zones in IC1. A zone with a lower preference being
       
    66 the preferred RAM zone. This results in RAM IC1 only being powered on once
       
    67 RAM IC0 is too full. This is determined by the RAM zone thresholds. </p> <p><b>RAM
       
    68 zone power state on system boot </b> </p> <p>When the system boots, all the
       
    69 RAM specified by the bootstrap must be enabled and ready to use. Devices that
       
    70 wish to reduce power consumption must only adjust the power modes(s) of the
       
    71 RAM IC(s) after the RAM zone call back function has been invoked with aOp=<xref href="GUID-1DB1634C-F3D6-382B-B742-CB61FD5383C6.dita"><apiname>ERamZoneOp_Init</apiname></xref>. </p> </section>
       
    72 <section id="GUID-5EBF1D4D-A86C-5FBF-ADA8-8551284DF665"><title>Designing RAM
       
    73 zones for physically contiguous allocation</title> <p>Some devices have particular
       
    74 applications or hardware peripherals that require a block of physically contiguous
       
    75 RAM. In such cases, a RAM zone should be defined that is the size of the physically
       
    76 contiguous block required, aligned to the nearest ASIC’s MMU small page size.
       
    77 The device then attempts to use this RAM zone whenever the particular application
       
    78 or hardware peripheral is activated. </p> <p>For example, a device may contain
       
    79 a camera that requires a buffer of 4MB of physically contiguous memory to
       
    80 operate. A RAM zone with a size of 4MB must be defined and this RAM zone should
       
    81 have a greater preference value than other RAM zones in the device. This results
       
    82 in the camera RAM zone: </p> <ul>
       
    83 <li id="GUID-F573D85A-0207-5BB4-8089-717A8B07AF2A"><p>only being used for
       
    84 non-camera purposes once all of the other RAM zones in the device become too
       
    85 full. </p> </li>
       
    86 <li id="GUID-1EFFD42D-F1EF-5B7D-B34D-C5D185CDD23E"><p>having a greater chance
       
    87 of being emptied of any pages allocated for non-camera purposes when required
       
    88 by the camera. </p> </li>
       
    89 </ul> <p><b>KRamZoneDiscardOnly </b> </p> <p>On devices that use <xref href="GUID-469EC7BB-8697-57FE-A487-016882A0BEA8.dita">demand
       
    90 paging</xref>, an additional way to increase the chances of a RAM zone being
       
    91 available is to set the <xref href="GUID-A0A5E53C-C454-37C4-9314-941B8A9F64E5.dita"><apiname>KRamZoneDiscardOnly</apiname></xref> bit of <xref href="GUID-9C26C2ED-922E-3E61-9A7D-779165940BB9.dita"><apiname>SRamZone</apiname></xref> s' <xref href="GUID-61FE6994-3FBE-3512-A2C4-08AE33B3B41D.dita"><apiname>iFlags</apiname></xref> member.
       
    92 This stops the system allocating pages that are not discardable in that zone.
       
    93 However, setting <xref href="GUID-A0A5E53C-C454-37C4-9314-941B8A9F64E5.dita"><apiname>KRamZoneDiscardOnly</apiname></xref> also has the effect
       
    94 of reducing the amount of RAM available to the device for general purpose
       
    95 (non-demand paging) use. </p> <p> <xref href="GUID-C926F405-1AC2-33E7-9031-A4A22F19D5F7.dita"><apiname>KRamZoneFlagDiscardOnly</apiname></xref> only
       
    96 increases the chances of a RAM zone’s availability if the minimum buffer size
       
    97 used by demand paging and/or file caching, is small enough that the RAM zone
       
    98 may be cleared without reducing the paging or caching buffer beyond their
       
    99 specified minimum size. </p> </section>
       
   100 <section id="GUID-A0273264-8876-523D-B1F0-F6D430FFAECA"><title>RAM zone call
       
   101 back function</title> <p>If <xref href="GUID-ACA7BAC8-9DC3-356A-92C2-F33A99D8604B.dita"><apiname>TRamZoneCallback</apiname></xref> has been initialised
       
   102 by <xref href="GUID-3DC7B5F2-512E-3FF3-BC08-945DDE2AE680.dita#GUID-3DC7B5F2-512E-3FF3-BC08-945DDE2AE680/GUID-F4765A82-01D0-3F97-A216-99327F14D53A"><apiname>Epoc::SetRamZoneConfig()</apiname></xref>, then it is invoked each time
       
   103 the system requires the base port to perform an operation on a RAM zone. When
       
   104 the call back function is invoked the calling thread is: </p> <ul>
       
   105 <li id="GUID-46E21179-B438-5C2F-9CAD-E6388A1E08D8"><p>in a critical section </p> </li>
       
   106 <li id="GUID-6731F7EF-3407-5DEE-8886-B44B042570A1"><p>holding the Symbian
       
   107 platform RAM allocator mutex </p> </li>
       
   108 <li id="GUID-217193FE-008E-57BC-A9BC-B6D68C88F521"><p>not holding any fast
       
   109 mutex </p> </li>
       
   110 <li id="GUID-D193EE0B-7E8C-5E18-9998-735BE7E36BBD"><p>interrupt enabled and
       
   111 the kernel is unlocked. </p> </li>
       
   112 </ul> <p>This means that the base port’s implementation of the call back function
       
   113 is: </p> <ul>
       
   114 <li id="GUID-28CC9F46-A680-503C-B222-E857D9806818"><p>not able to be suspended
       
   115 or killed by another thread </p> </li>
       
   116 <li id="GUID-210F0AA9-E1D4-5801-A4A9-8A901D213C00"><p>not able to acquire
       
   117 a Symbian platform mutex of an order greater than or equal to the RAM allocator
       
   118 mutex this is all other Symbian platform mutexes. This is a deadlock prevention
       
   119 mechanism. </p> </li>
       
   120 <li id="GUID-FCADE0F8-5B71-54C9-85B3-BA963B942572"><p>able to acquire a fast
       
   121 mutex. The call back must release it before returning. </p> </li>
       
   122 <li id="GUID-4181E193-B030-55E0-AAD5-4687B6B9547D"><p>able to be pre-empted
       
   123 by other threads/processes. </p> </li>
       
   124 </ul> <p><b>Parameters </b> </p> <p>A choice of three RAM zone operations
       
   125 can be requested with <xref href="GUID-ACA7BAC8-9DC3-356A-92C2-F33A99D8604B.dita"><apiname>TRamZoneCallback</apiname></xref>, as defined by <xref href="GUID-445BC66E-44AF-3F56-8E8B-CD3C22C0FF8B.dita"><apiname>TRamZoneOp</apiname></xref>: </p> <ul>
       
   126 <li id="GUID-39D99FE2-CB23-5D41-A9DD-9353684C7B3F"><p> <xref href="GUID-3B839FD3-BA8B-38A0-A850-62491C71D3E3.dita"><apiname>ERamZoneOp_PowerUp</apiname></xref> is
       
   127 used each time a RAM zone transitions from being empty to having pages allocated
       
   128 into it. When this operation is invoked, all RAM zones that have their bit
       
   129 position set in the mask pointed to by <codeph>aParam2</codeph>  <i>MUST</i> be
       
   130 fully enabled and ready for use before returning from the call back function.
       
   131 Failure to fully enable any of these RAM zones results in the device becoming
       
   132 unstable and its behaviour unpredictable. </p> <p>For example, a device could
       
   133 have two RAM ICs, where IC1 is mapped to RAM zones 1 - 4 and IC2 is mapped
       
   134 to RAM zones 5 - 8. </p> <p>If while the second RAM IC is powered down, RAM
       
   135 zone 5 is required, a <xref href="GUID-3B839FD3-BA8B-38A0-A850-62491C71D3E3.dita"><apiname>ERamZoneOp_PowerUp</apiname></xref> operation is requested.
       
   136 The IC2 must be fully enabled before returning from the call back function.
       
   137 On return from the call back function, the memory in IC2 is used by the system. </p> </li>
       
   138 <li id="GUID-25B72080-8E39-5739-9545-8D17AE8EA669"><p> <xref href="GUID-74DA7B02-CB90-325D-8A84-454004AEB5C8.dita"><apiname>ERamZoneOp_PowerDown</apiname></xref> is
       
   139 used each time a RAM zone transitions from having pages allocated in it to
       
   140 being empty. Devices that wish to reduce power consumption can adjust a RAM
       
   141 IC’s partial array self refresh mode or power down a RAM IC if all of the
       
   142 other RAM zones in that RAM IC are also empty. </p> <p>For example, an <xref href="GUID-74DA7B02-CB90-325D-8A84-454004AEB5C8.dita"><apiname>ERamZoneOp_PowerDown</apiname></xref> operation
       
   143 is requested when all the RAM zones mapped to the top half of the RAM IC Partial
       
   144 Array Self Refresh (PASR) regions are empty. The RAM IC can be set to use
       
   145 half array PASR when it next enters PASR mode, assuming the RAM IC has the
       
   146 option of using half array PASR mode. </p> </li>
       
   147 <li id="GUID-FC3EBDE2-64E5-5AA1-938F-858C62D18A56"><p> <xref href="GUID-2A00ADB4-778F-3981-A9DC-5C7E23F95CE6.dita"><apiname>ERAMZoneOp_Init</apiname></xref> is
       
   148 used only once during the initial stages of the system boot process. When
       
   149 this operation is invoked all the RAM zones that have their bit positions
       
   150 cleared in the mask pointed to by <codeph>aParam2</codeph> are not currently
       
   151 in use. The system assumes that during boot all of RAM is enabled and ready
       
   152 to use. Devices that wish to reduce power consumption can then adjust each
       
   153 of the RAM IC's partial array self refresh modes or power down modes, appropriately. </p> <p>For
       
   154 example, if a device has two RAM IC's, IC1 is mapped to zones1-4 and IC2 is
       
   155 mapped to RAM zones 5-8. Then if the <xref href="GUID-2A00ADB4-778F-3981-A9DC-5C7E23F95CE6.dita"><apiname>ERAMZoneOp_Init</apiname></xref> operation
       
   156 is requested and all of the RAM zones in RAM IC2 are currently not in use,
       
   157 then IC2 could be placed into power down mode by the base port at the next
       
   158 appropriate moment. </p> </li>
       
   159 </ul> <p>The two parameters, <codeph>aParam1</codeph> =TAny* and <codeph>aParam2</codeph> =const
       
   160 TAny* allows the call back function to perform multiple operations with the
       
   161 same interface. When <xref href="GUID-ACA7BAC8-9DC3-356A-92C2-F33A99D8604B.dita"><apiname>TRamZoneCallback</apiname></xref> is called with <xref href="GUID-445BC66E-44AF-3F56-8E8B-CD3C22C0FF8B.dita"><apiname>TRamZoneOp</apiname></xref> defined
       
   162 as either <xref href="GUID-74DA7B02-CB90-325D-8A84-454004AEB5C8.dita"><apiname>ERamZoneOp_PowerDown</apiname></xref> or <xref href="GUID-3B839FD3-BA8B-38A0-A850-62491C71D3E3.dita"><apiname>ERamZoneOp_PowerUp</apiname></xref>,
       
   163 the last two parameters are defined as: </p> <ul>
       
   164 <li id="GUID-19A0CBAC-E630-50E3-9201-6599BAE047E8"><p> <xref href="GUID-037E37E5-B5A1-35B4-B3A8-C36A7C017DE9.dita"><apiname>aParam1</apiname></xref> is
       
   165 the ID of the RAM zone that changed state </p> </li>
       
   166 <li id="GUID-DA614AA8-5CCF-59D8-AF81-966FB465A4A3"><p> <xref href="GUID-D07C02D2-C5B2-3D01-B3C5-F24B0D7A9298.dita"><apiname>aParam2</apiname></xref> points
       
   167 to an array of bit masks that represent the new power state of the RAM zones.
       
   168 The bit mask is organised in ascending RAM zone address order with the LSB
       
   169 of the bit mask representing the power state of the lowest addressed zone.
       
   170 A zone’s bit is set if the RAM zone is in use and cleared if the RAM zone
       
   171 is not in use. The value of the bit mask <i>MUST</i> not be modified by the
       
   172 call back function. </p> </li>
       
   173 </ul> <p>See also: </p> </section>
       
   174 <section id="GUID-4D506D2E-771F-573F-B5EB-8EA25FAC7C7B"><title>When to reduce
       
   175 power consumption of the RAM</title> <p>Depending on the RAM IC configuration
       
   176 for the device, entering and exiting Partial Array Self Refresh (PASR) or
       
   177 power down modes may introduce a decrease in a device’s overall performance.
       
   178 The overhead incurred when transitioning a RAM IC from power off to power
       
   179 on mode may have significant latency due to the amount of initialisation required.
       
   180 It is recommended that a delay is used between a <xref href="GUID-74DA7B02-CB90-325D-8A84-454004AEB5C8.dita"><apiname>ERamZoneOp_PowerDown</apiname></xref> operation
       
   181 being invoked and a RAM IC either entering PASR mode or being powered down.
       
   182 One approach to achieving this is to only enter PASR mode or power down a
       
   183 RAM IC in the device’s implementation of the <xref href="GUID-B3D1C422-6A82-3C6E-9123-1E4F598F0366.dita#GUID-B3D1C422-6A82-3C6E-9123-1E4F598F0366/GUID-473874CA-FC35-3EB2-BC23-A97D7176B833"><apiname>DPowerController::CpuIdle()</apiname></xref> and <xref href="GUID-B3D1C422-6A82-3C6E-9123-1E4F598F0366.dita#GUID-B3D1C422-6A82-3C6E-9123-1E4F598F0366/GUID-8AE99718-6B82-3920-9029-28C2041A3B10"><apiname>DPowerController::PowerDown()</apiname></xref> methods.
       
   184 This way while the device is active its performance is not affected by the
       
   185 RAM zone operations. </p> </section>
       
   186 </conbody><related-links>
       
   187 <link href="GUID-E0DCBDCF-C056-53E5-A375-778327F848E4.dita#GUID-E0DCBDCF-C056-53E5-A375-778327F848E4/GUID-7F5D4AD6-0881-5942-9A86-A95C02125A28">
       
   188 <linktext>Asic::Init1()</linktext></link>
       
   189 <link href="GUID-0C435514-EEC6-5660-BB5F-535790349632.dita"><linktext>Power Management</linktext>
       
   190 </link>
       
   191 <link href="GUID-C13DFF33-7C54-5113-9277-CAD96215F075.dita"><linktext>RAM Zones</linktext>
       
   192 </link>
       
   193 </related-links></concept>