Home | History | Annotate | Download | only in Dxe
      1 // /** @file
      2 // PCD DXE driver manage database contains all dynamic PCD entries and produce the implementation of PCD protocol.
      3 //
      4 // This version PCD DXE depends on the external PCD database binary file, not built in PCD data base.
      5 // There are two PCD Protocols as follows:
      6 // 1) PCD_PROTOCOL
      7 // It is EDKII implementation which support Dynamic/DynamicEx type Pcds.
      8 // 2) EFI_PCD_PROTOCOL
      9 // It is defined by PI specification 1.2, Vol 3 which only support dynamicEx
     10 // type Pcd.
     11 // 
     12 // For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL.
     13 // PCD DXE driver will produce above two protocols at same time.
     14 // 
     15 // PCD database is generated as the separate binary image at build time. The binary image
     16 // will be intergrated into Firmware volume together with PCD driver.
     17 // 
     18 // ////////////////////////////////////////////////////////////////////////////////
     19 // //                                                                            //
     20 // //                      Introduction of PCD database                          //
     21 // //                                                                            //
     22 // ////////////////////////////////////////////////////////////////////////////////
     23 // 
     24 // 1, Introduction
     25 // PCD database hold all dynamic type PCD information. The structure of PEI PCD
     26 // database is generated by build tools according to dynamic PCD usage for
     27 // specified platform.
     28 // 
     29 // 2, Dynamic Type PCD
     30 // Dynamic type PCD is used for the configuration/setting which value is determined
     31 // dynamic. In contrast, the value of static type PCD (FeatureFlag, FixedPcd,
     32 // PatchablePcd) is fixed in final generated FD image in build time.
     33 // 
     34 // 2.1 The "dynamic" determination means one of below cases:
     35 // a) The PCD setting value is produced by someone driver and consumed by
     36 // other driver in execution time.
     37 // b) The PCD setting value is set/get by user from FrontPage.
     38 // c) The PCD setting value is produced by platform OEM vendor in specified area.
     39 // 
     40 // 2.2 According to module distribution way, dynamic PCD could be classfied as:
     41 // a) Dynamic:
     42 // If module is released in source code and will be built with platform
     43 // DSC, the dynamic PCD used by this module can be accessed as:
     44 // PcdGetxx(PcdSampleDynamicPcd);
     45 // In building platform, build tools will translate PcdSampleDynamicPcd to
     46 // pair of {Token Space Guid: Token Number} for this PCD.
     47 // b) DynamicEx:
     48 // If module is release as binary and will not pariticpate platform building,
     49 // the dynamic PCD used by this module need be accessed as:
     50 // PcdGetxxEx(gEfiMyTokenspaceGuid, PcdSampleDynamicPcd)
     51 // Developer need explicity gives {Token Space Guid:Token Number} as parameter
     52 // in writting source code.
     53 // 
     54 // 2.3 According to PCD value's storage method, dynamic PCD could be classfied as:
     55 // a) Default Storage:
     56 // - The PCD value is stored in PCD database maintained by PCD driver in boot
     57 // time memory.
     58 // - This type is used for communication between PEIM/DXE driver, DXE/DXE
     59 // driver. But all set/get value will be losted after boot-time memory
     60 // is turn off.
     61 // - [PcdsDynamicDefault] is used as section name for this type PCD in
     62 // platform DSC file. [PcdsDynamicExDefault] is used for dynamicEx type PCD.
     63 // 
     64 // b) Variable Storage:
     65 // - The PCD value is stored in variable area.
     66 // - As default storage type, this type PCD could be used for PEI/DXE driver
     67 // communication. But beside it, this type PCD could also be used to store
     68 // the value associate with a HII setting via variable interface.
     69 // - In PEI phase, the PCD value could only be got but can not be set due
     70 // to variable area is readonly.
     71 // - [PcdsDynamicHii] is used as section name for this type PCD in platform
     72 // DSC file. [PcdsDynamicExHii] is for dynamicEx type PCD.
     73 // 
     74 // c) OEM specificed storage area:
     75 // - The PCD value is stored in OEM specified area which base address is
     76 // specified by a FixedAtBuild PCD setting - PcdVpdBaseAddress.
     77 // - The area is read only for PEI and DXE phase.
     78 // - [PcdsDynamicVpd] is used as section name for this type PCD in platform
     79 // DSC file. [PcdsDynamicExVpd] is for dynamicex type PCD.
     80 // 
     81 // 2.4 When and how to use dynamic PCD
     82 // Module developer do not care the used PCD is dynamic or static when writting
     83 // source code/INF. Dynamic PCD and dynamic type is pointed by platform integrator
     84 // in platform DSC file. Please ref section 2.3 to get matching between dynamic
     85 // PCD type and section name in DSC file.
     86 // 
     87 // 3, PCD database:
     88 // Although dynamic PCD could be in different storage type as above description,
     89 // but the basic information and default value for all dynamic PCD is hold
     90 // by PCD database maintained by PEI/DXE driver.
     91 // 
     92 // As the whole EFI BIOS boot path is divided into PEI/DXE phase, the PCD database
     93 // also is divided into Pei/Dxe database maintaied by PcdPeim/PcdDxe driver separatly.
     94 // To make PcdPeim's driver image smaller, PEI PCD database only hold all dynamic
     95 // PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD
     96 // database contains all PCDs used in PEI/DXE phase in memory.
     97 // 
     98 // Build tool will generate PCD database into the separate binary file for
     99 // PEI/DXE PCD driver according to dynamic PCD section in platform DSC file.
    100 // 
    101 // 3.1 PcdPeim and PcdDxe
    102 // PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver
    103 // build guid hob in temporary memory and copy the binary data base from flash
    104 // to temporary memory for PEI PCD database.
    105 // DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,
    106 // a new PCD database is allocated in boot-time memory which including all
    107 // PEI PCD and DXE PCD entry.
    108 // 
    109 // Pcd driver should run as early as possible before any other driver access
    110 // dynamic PCD's value. PEI/DXE "Apriori File" mechanism make it possible by
    111 // making PcdPeim/PcdDxe as first dispatching driver in PEI/DXE phase.
    112 // 
    113 // 3.2 Token space Guid/Token number, Platform token, Local token number
    114 // Dynamic PCD
    115 // +-----------+               +---------+
    116 // |TokenSpace |               |Platform |
    117 // |   Guid    |  build tool   | Token   |
    118 // |    +      +-------------->| Number  |
    119 // |  Token    |               +---------+`._
    120 // |  Number   |                             `.
    121 // +-----------+                               `.  +------+
    122 // `-|Local |
    123 // |Token |
    124 // DynamicEx PCD            ,-|Number|
    125 // +-----------+         ,-'  +------+
    126 // |TokenSpace |      ,-'
    127 // |   Guid    |  _,-'
    128 // |    +      +.'
    129 // |  Token    |
    130 // |  Number   |
    131 // +-----------+
    132 // 
    133 // 
    134 // 3.2.1 Pair of Token space guid + Token number
    135 // Any type PCD is identified by pair of "TokenSpaceGuid + TokeNumber". But it
    136 // is not easy maintained by PCD driver, and hashed token number will make
    137 // searching slowly.
    138 // 
    139 // 3.2.2 Platform Token Number
    140 // "Platform token number" concept is introduced for mapping to a pair of
    141 // "TokenSpaceGuid + TokenNumber". The platform token number is generated by
    142 // build tool in autogen.h and all of them are continual in a platform scope
    143 // started from 1.(0 meaning invalid internal token number)
    144 // With auto-generated "platform token number", PcdGet(PcdSampleDynamicPcd)
    145 // in source code is translated to LibPcdGet(_PCD_TOKEN_PcdSampleDynamicPcd)
    146 // in autogen.h.
    147 // Notes: The mapping between pair of "tokenspace guid + token number" and
    148 // "internal token number" need build tool establish, so "platform token number"
    149 // mechanism is not suitable for binary module which use DynamicEx type PCD.
    150 // To access a dynamicEx type PCD, pair of "token space guid/token number" all need
    151 // to be specificed for PcdSet/PcdGet accessing macro.
    152 // 
    153 // Platform Token Number is started from 1, and inceased continuous. From whole
    154 // platform scope, there are two zones: PEI Zone and DXE Zone
    155 // |                      Platform Token Number
    156 // ----------|----------------------------------------------------------------
    157 // PEI Zone: |            1                 ~  PEI_LOCAL_TOKEN_NUMBER
    158 // DXE Zone: | (PEI_LOCAL_TOKEN_NUMBER + 1) ~ (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)
    159 // 
    160 // 3.2.3 Local Token Number
    161 // To fast searching a PCD entry in PCD database, PCD driver translate
    162 // platform token number to local token number via a mapping table.
    163 // For binary DynamicEx type PCD, there is a another mapping table to translate
    164 // "token space guid + token number" to local token number directly.
    165 // Local token number is identifier for all internal interface in PCD PEI/DXE
    166 // driver.
    167 // 
    168 // A local token number is a 32-bit value in following meaning:
    169 // 32 ------------- 28 ---------- 24 -------- 0
    170 // | PCD type mask  | Datum Type  |  Offset  |
    171 // +-----------------------------------------+
    172 // where:
    173 // PCd type mask: indicate Pcd type from following macro:
    174 // PCD_TYPE_DATA
    175 // PCD_TYPE_HII
    176 // PCD_TYPE_VPD
    177 // PCD_TYPE_SKU_ENABLED
    178 // PCD_TYPE_STRING
    179 // Datum Type   : indicate PCD vaue type from following macro:
    180 // PCD_DATUM_TYPE_POINTER
    181 // PCD_DATUM_TYPE_UINT8
    182 // PCD_DATUM_TYPE_UINT16
    183 // PCD_DATUM_TYPE_UINT32
    184 // PCD_DATUM_TYPE_UINT64
    185 // Offset      : indicate the related offset of PCD value in PCD database array.
    186 // Based on local token number, PCD driver could fast determine PCD type, value
    187 // type and get PCD entry from PCD database.
    188 // 
    189 // 3.3 PCD Database binary file
    190 // PCD Database binary file will be created at build time as the standalone binary image.
    191 // To understand the binary image layout, PCD Database C structure is still generated
    192 // as comments by build tools in PCD driver's autogen.h/
    193 // autogen.c file. In generated C structure, following information is stored:
    194 // - ExMapTable: This table is used translate a binary dynamicex type PCD's
    195 // "tokenguid + token" to local token number.
    196 // - LocalTokenNumberTable:
    197 // This table stores all local token number in array, use "Internal
    198 // token number" as array index to get PCD entry's offset fastly.
    199 // - SizeTable:  This table stores the size information for all PCD entry.
    200 // - GuidTable:  This table stores guid value for DynamicEx's token space,
    201 // HII type PCD's variable GUID.
    202 // - SkuIdTable: TBD
    203 // - SystemSkuId: TBD
    204 // - PCD value structure:
    205 // Every PCD has a value record in PCD database. For different
    206 // datum type PCD has different record structure which will be
    207 // introduced in 3.3.1
    208 // 
    209 // In a PCD database structure, there are two major area: Init and UnInit.
    210 // Init area is use stored above PCD internal structure such as ExMapTable,
    211 // LocalTokenNumberTable etc and the (default) value of PCD which has default
    212 // value specified in platform DSC file.
    213 // Unint area is used stored the value of PCD which has no default value in
    214 // platform DSC file, the value of NULL, 0 specified in platform DSC file can
    215 // be seemed as "no default value".
    216 // 
    217 // 3.3.1 Simple Sample PCD Database C Structure
    218 // A general sample of PCD database structue is as follows:
    219 // typedef struct _PCD_DATABASE {
    220 // typedef struct _PCD_DATABASE_INIT {
    221 // //===== Following is PCD database internal maintain structures
    222 // DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];
    223 // UINT32            LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER_TABLE_SIZE];
    224 // GUID              GuidTable[PEI_GUID_TABLE_SIZE];
    225 // SIZE_INFO         SizeTable[PEI_SIZE_TABLE_SIZE];
    226 // UINT8             SkuIdTable[PEI_SKUID_TABLE_SIZE];
    227 // SKU_ID            SystemSkuId;
    228 // 
    229 // //===== Following is value structure for PCD with default value
    230 // ....
    231 // ....
    232 // ....
    233 // } Init;
    234 // typedef struct _PCD_DATABSE_UNINIT {
    235 // //==== Following is value structure for PCD without default value
    236 // ....
    237 // ....
    238 // } UnInit;
    239 // }
    240 // 
    241 // 3.3.2 PCD value structure in PCD database C structure
    242 // The value's structure is generated by build tool in PCD database C structure.
    243 // The PCDs in different datum type has different value structure.
    244 // 
    245 // 3.3.2.1 UINT8/UINT16/UINT32/UINT64 datum type PCD
    246 // The C structure for these datum type PCD is just a UINT8/UINT16/UINT32/UINT64
    247 // data member in PCD database, For example:
    248 // UINT16  PcdHardwareErrorRecordLevel_d3705011_bc19_4af7_be16_f68030378c15_VariableDefault_0;
    249 // Above structure is generated by build tool, the member name is "PcdCName_Guidvalue"
    250 // Member type is UINT16 according to PcdHardwareErrorRecordLevel declaration
    251 // in DEC file.
    252 // 
    253 // 3.3.2.2 VOID* datum type PCD
    254 // The value of VOID* datum type PCD is a UINT8/UINT16 array in PCD database.
    255 // 
    256 // 3.3.2.2.1 VOID* - string type
    257 // If the default value for VOID* datum type PCD like L"xxx", the PCD is
    258 // used for unicode string, and C structure of this datum type PCD is
    259 // UINT16 string array in PCD database, for example:
    260 // UINT16 StringTable[29];
    261 // The number of 29 in above sample is max size of a unicode string.
    262 // 
    263 // If the default value for VOID* datum type PCD like "xxx", the PCD is
    264 // used for ascii string, and C structure of this datum type PCD is
    265 // UINT8 string array in PCD database, for example:
    266 // UINT8 StringTable[20];
    267 // The number of 20 in above sample is max size of a ascii string.
    268 // 
    269 // 3.3.2.2.2 VOID* - byte array
    270 // If the default value of VOID* datum type PCD like {'0x29', '0x01', '0xf2'}
    271 // the PCD is used for byte array. The generated structrue is same as
    272 // above ascii string table,
    273 // UINT8 StringTable[13];
    274 // The number of 13 in above sample is max size of byte array.
    275 // 
    276 // 3.3.3 Some utility structures in PCD Database
    277 // 3.3.3.1 GuidTable
    278 // GuidTable array is used to store all related GUID value in PCD database:
    279 // - Variable GUID for HII type PCD
    280 // - Token space GUID for dynamicex type PCD
    281 //
    282 // Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    283 //
    284 // This program and the accompanying materials
    285 // are licensed and made available under the terms and conditions of the BSD License
    286 // which accompanies this distribution. The full text of the license may be found at
    287 // http://opensource.org/licenses/bsd-license.php
    288 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    289 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
    290 //
    291 // **/
    292 
    293 
    294 #string STR_MODULE_ABSTRACT             #language en-US "PCD DXE driver manages the database that contains all dynamic PCD entries and produce the implementation of PCD protocol"
    295 
    296 #string STR_MODULE_DESCRIPTION          #language en-US "PCD DXE driver manages the database that contains all dynamic PCD entries and produces the implementation of PCD protocol."
    297 
    298