]>
Commit | Line | Data |
---|---|---|
6bfbb5f0 | 1 | ## @file\r |
68dbca6c | 2 | # PCD PEIM produces PCD database to manage all dynamic PCD in PEI phase and install Pcd Ppi service.\r |
80408db0 | 3 | #\r |
d1102dba | 4 | # This version PCD PEIM depends on the external PCD database binary file, not built in PCD data base.\r |
6c74c538 | 5 | # There are two PCD PPIs as follows:\r |
d1102dba | 6 | # 1) PCD_PPI\r |
6c74c538 | 7 | # It is EDKII implementation which support Dynamic/DynamicEx Pcds.\r |
8 | # 2) EFI_PEI_PCD_PPI\r | |
d1102dba | 9 | # It is defined by PI specification 1.2, Vol 3 which only support dynamicEx\r |
6c74c538 | 10 | # type Pcd.\r |
11 | # For dynamicEx type PCD, it is compatible between PCD_PPI and EFI_PEI_PCD_PPI.\r | |
419db80b BF |
12 | # PCD PEIM driver will produce above two PPIs at same time.\r |
13 | #\r | |
d1102dba LG |
14 | # PCD database is generated as the separate binary image at build time. The binary image\r |
15 | # will be intergrated into Firmware volume together with PCD driver.\r | |
6c74c538 | 16 | #\r |
b6b3dc44 | 17 | # ////////////////////////////////////////////////////////////////////////////////\r |
18 | # // //\r | |
19 | # // Introduction of PCD database //\r | |
20 | # // //\r | |
21 | # ////////////////////////////////////////////////////////////////////////////////\r | |
22 | #\r | |
23 | # 1, Introduction\r | |
d1102dba LG |
24 | # PCD database hold all dynamic type PCD information. The structure of PEI PCD\r |
25 | # database is generated by build tools according to dynamic PCD usage for\r | |
b6b3dc44 | 26 | # specified platform.\r |
d1102dba | 27 | #\r |
b6b3dc44 | 28 | # 2, Dynamic Type PCD\r |
29 | # Dynamic type PCD is used for the configuration/setting which value is determined\r | |
d1102dba LG |
30 | # dynamic. In contrast, the value of static type PCD (FeatureFlag, FixedPcd,\r |
31 | # PatchablePcd) is fixed in final generated FD image in build time.\r | |
32 | #\r | |
b6b3dc44 | 33 | # 2.1 The "dynamic" determination means one of below cases:\r |
d1102dba | 34 | # a) The PCD setting value is produced by someone driver and consumed by\r |
b6b3dc44 | 35 | # other driver in execution time.\r |
36 | # b) The PCD setting value is set/get by user from FrontPage.\r | |
37 | # c) The PCD setting value is produced by platform OEM vendor in specified area.\r | |
d1102dba | 38 | #\r |
b6b3dc44 | 39 | # 2.2 According to module distribution way, dynamic PCD could be classfied as:\r |
40 | # a) Dynamic:\r | |
d1102dba | 41 | # If module is released in source code and will be built with platform\r |
b6b3dc44 | 42 | # DSC, the dynamic PCD used by this module can be accessed as:\r |
d1102dba | 43 | # PcdGetxx(PcdSampleDynamicPcd);\r |
b6b3dc44 | 44 | # In building platform, build tools will translate PcdSampleDynamicPcd to\r |
d1102dba | 45 | # pair of {Token Space Guid: Token Number} for this PCD.\r |
b6b3dc44 | 46 | # b) DynamicEx:\r |
47 | # If module is release as binary and will not pariticpate platform building,\r | |
48 | # the dynamic PCD used by this module need be accessed as:\r | |
49 | # PcdGetxxEx(gEfiMyTokenspaceGuid, PcdSampleDynamicPcd)\r | |
50 | # Developer need explicity gives {Token Space Guid:Token Number} as parameter\r | |
51 | # in writting source code.\r | |
d1102dba | 52 | #\r |
b6b3dc44 | 53 | # 2.3 According to PCD value's storage method, dynamic PCD could be classfied as:\r |
d1102dba LG |
54 | # a) Default Storage:\r |
55 | # - The PCD value is stored in PCD database maintained by PCD driver in boot\r | |
b6b3dc44 | 56 | # time memory.\r |
d1102dba LG |
57 | # - This type is used for communication between PEIM/DXE driver, DXE/DXE\r |
58 | # driver. But all set/get value will be losted after boot-time memory\r | |
b6b3dc44 | 59 | # is turn off.\r |
d1102dba | 60 | # - [PcdsDynamicDefault] is used as section name for this type PCD in\r |
b6b3dc44 | 61 | # platform DSC file. [PcdsDynamicExDefault] is used for dynamicEx type PCD.\r |
d1102dba LG |
62 | #\r |
63 | # b) Variable Storage:\r | |
64 | # - The PCD value is stored in variable area.\r | |
b6b3dc44 | 65 | # - As default storage type, this type PCD could be used for PEI/DXE driver\r |
d1102dba | 66 | # communication. But beside it, this type PCD could also be used to store\r |
b6b3dc44 | 67 | # the value associate with a HII setting via variable interface.\r |
d1102dba | 68 | # - In PEI phase, the PCD value could only be got but can not be set due\r |
b6b3dc44 | 69 | # to variable area is readonly.\r |
d1102dba | 70 | # - [PcdsDynamicHii] is used as section name for this type PCD in platform\r |
b6b3dc44 | 71 | # DSC file. [PcdsDynamicExHii] is for dynamicEx type PCD.\r |
d1102dba | 72 | #\r |
b6b3dc44 | 73 | # c) OEM specificed storage area:\r |
d1102dba | 74 | # - The PCD value is stored in OEM specified area which base address is\r |
534efca0 | 75 | # specified by PCD setting - PcdVpdBaseAddress64 or PcdVpdBaseAddress.\r |
b6b3dc44 | 76 | # - The area is read only for PEI and DXE phase.\r |
d1102dba | 77 | # - [PcdsDynamicVpd] is used as section name for this type PCD in platform\r |
b6b3dc44 | 78 | # DSC file. [PcdsDynamicExVpd] is for dynamicex type PCD.\r |
d1102dba | 79 | #\r |
b6b3dc44 | 80 | # 2.4 When and how to use dynamic PCD\r |
81 | # Module developer do not care the used PCD is dynamic or static when writting\r | |
d1102dba | 82 | # source code/INF. Dynamic PCD and dynamic type is pointed by platform integrator\r |
b6b3dc44 | 83 | # in platform DSC file. Please ref section 2.3 to get matching between dynamic\r |
84 | # PCD type and section name in DSC file.\r | |
d1102dba | 85 | #\r |
b6b3dc44 | 86 | # 3, PCD database:\r |
d1102dba | 87 | # Although dynamic PCD could be in different storage type as above description,\r |
b6b3dc44 | 88 | # but the basic information and default value for all dynamic PCD is hold\r |
89 | # by PCD database maintained by PEI/DXE driver.\r | |
d1102dba | 90 | #\r |
b6b3dc44 | 91 | # As the whole EFI BIOS boot path is divided into PEI/DXE phase, the PCD database\r |
92 | # also is divided into Pei/Dxe database maintaied by PcdPeim/PcdDxe driver separatly.\r | |
93 | # To make PcdPeim's driver image smaller, PEI PCD database only hold all dynamic\r | |
94 | # PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD\r | |
95 | # database contains all PCDs used in PEI/DXE phase in memory.\r | |
d1102dba LG |
96 | #\r |
97 | # Build tool will generate PCD database into the separate binary file for\r | |
98 | # PEI/DXE PCD driver according to dynamic PCD section in platform DSC file.\r | |
99 | #\r | |
b6b3dc44 | 100 | # 3.1 PcdPeim and PcdDxe\r |
101 | # PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver\r | |
d1102dba LG |
102 | # build guid hob in temporary memory and copy the binary data base from flash\r |
103 | # to temporary memory for PEI PCD database.\r | |
b6b3dc44 | 104 | # DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,\r |
105 | # a new PCD database is allocated in boot-time memory which including all\r | |
106 | # PEI PCD and DXE PCD entry.\r | |
d1102dba | 107 | #\r |
b6b3dc44 | 108 | # Pcd driver should run as early as possible before any other driver access\r |
109 | # dynamic PCD's value. PEI/DXE "Apriori File" mechanism make it possible by\r | |
110 | # making PcdPeim/PcdDxe as first dispatching driver in PEI/DXE phase.\r | |
d1102dba | 111 | #\r |
b6b3dc44 | 112 | # 3.2 Token space Guid/Token number, Platform token, Local token number\r |
113 | # Dynamic PCD\r | |
114 | # +-----------+ +---------+\r | |
115 | # |TokenSpace | |Platform |\r | |
116 | # | Guid | build tool | Token |\r | |
117 | # | + +-------------->| Number |\r | |
118 | # | Token | +---------+`._\r | |
119 | # | Number | `.\r | |
120 | # +-----------+ `. +------+\r | |
121 | # `-|Local |\r | |
122 | # |Token |\r | |
123 | # DynamicEx PCD ,-|Number|\r | |
124 | # +-----------+ ,-' +------+\r | |
125 | # |TokenSpace | ,-'\r | |
126 | # | Guid | _,-'\r | |
127 | # | + +.'\r | |
128 | # | Token |\r | |
129 | # | Number |\r | |
130 | # +-----------+\r | |
d1102dba LG |
131 | #\r |
132 | #\r | |
b6b3dc44 | 133 | # 3.2.1 Pair of Token space guid + Token number\r |
134 | # Any type PCD is identified by pair of "TokenSpaceGuid + TokeNumber". But it\r | |
d1102dba LG |
135 | # is not easy maintained by PCD driver, and hashed token number will make\r |
136 | # searching slowly.\r | |
b6b3dc44 | 137 | #\r |
138 | # 3.2.2 Platform Token Number\r | |
d1102dba LG |
139 | # "Platform token number" concept is introduced for mapping to a pair of\r |
140 | # "TokenSpaceGuid + TokenNumber". The platform token number is generated by\r | |
141 | # build tool in autogen.h and all of them are continual in a platform scope\r | |
b6b3dc44 | 142 | # started from 1.(0 meaning invalid internal token number)\r |
143 | # With auto-generated "platform token number", PcdGet(PcdSampleDynamicPcd)\r | |
d1102dba | 144 | # in source code is translated to LibPcdGet(_PCD_TOKEN_PcdSampleDynamicPcd)\r |
b6b3dc44 | 145 | # in autogen.h.\r |
146 | # Notes: The mapping between pair of "tokenspace guid + token number" and\r | |
147 | # "internal token number" need build tool establish, so "platform token number"\r | |
148 | # mechanism is not suitable for binary module which use DynamicEx type PCD.\r | |
149 | # To access a dynamicEx type PCD, pair of "token space guid/token number" all need\r | |
150 | # to be specificed for PcdSet/PcdGet accessing macro.\r | |
d1102dba LG |
151 | #\r |
152 | # Platform Token Number is started from 1, and inceased continuous. From whole\r | |
b6b3dc44 | 153 | # platform scope, there are two zones: PEI Zone and DXE Zone\r |
154 | # | Platform Token Number\r | |
155 | # ----------|----------------------------------------------------------------\r | |
156 | # PEI Zone: | 1 ~ PEI_LOCAL_TOKEN_NUMBER\r | |
157 | # DXE Zone: | (PEI_LOCAL_TOKEN_NUMBER + 1) ~ (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)\r | |
d1102dba | 158 | #\r |
b6b3dc44 | 159 | # 3.2.3 Local Token Number\r |
d1102dba | 160 | # To fast searching a PCD entry in PCD database, PCD driver translate\r |
b6b3dc44 | 161 | # platform token number to local token number via a mapping table.\r |
162 | # For binary DynamicEx type PCD, there is a another mapping table to translate\r | |
163 | # "token space guid + token number" to local token number directly.\r | |
164 | # Local token number is identifier for all internal interface in PCD PEI/DXE\r | |
165 | # driver.\r | |
d1102dba | 166 | #\r |
b6b3dc44 | 167 | # A local token number is a 32-bit value in following meaning:\r |
168 | # 32 ------------- 28 ---------- 24 -------- 0\r | |
169 | # | PCD type mask | Datum Type | Offset |\r | |
170 | # +-----------------------------------------+\r | |
171 | # where:\r | |
172 | # PCd type mask: indicate Pcd type from following macro:\r | |
173 | # PCD_TYPE_DATA\r | |
174 | # PCD_TYPE_HII\r | |
175 | # PCD_TYPE_VPD\r | |
b6b3dc44 | 176 | # PCD_TYPE_STRING\r |
177 | # Datum Type : indicate PCD vaue type from following macro:\r | |
178 | # PCD_DATUM_TYPE_POINTER\r | |
179 | # PCD_DATUM_TYPE_UINT8\r | |
180 | # PCD_DATUM_TYPE_UINT16\r | |
181 | # PCD_DATUM_TYPE_UINT32\r | |
182 | # PCD_DATUM_TYPE_UINT64\r | |
183 | # Offset : indicate the related offset of PCD value in PCD database array.\r | |
184 | # Based on local token number, PCD driver could fast determine PCD type, value\r | |
185 | # type and get PCD entry from PCD database.\r | |
d1102dba | 186 | #\r |
419db80b | 187 | # 3.3 PCD Database binary file\r |
d1102dba LG |
188 | # PCD Database binary file will be created at build time as the standalone binary image.\r |
189 | # To understand the binary image layout, PCD Database C structure is still generated\r | |
419db80b | 190 | # as comments by build tools in PCD driver's autogen.h/\r |
b6b3dc44 | 191 | # autogen.c file. In generated C structure, following information is stored:\r |
d1102dba | 192 | # - ExMapTable: This table is used translate a binary dynamicex type PCD's\r |
b6b3dc44 | 193 | # "tokenguid + token" to local token number.\r |
194 | # - LocalTokenNumberTable:\r | |
195 | # This table stores all local token number in array, use "Internal\r | |
196 | # token number" as array index to get PCD entry's offset fastly.\r | |
197 | # - SizeTable: This table stores the size information for all PCD entry.\r | |
198 | # - GuidTable: This table stores guid value for DynamicEx's token space,\r | |
419db80b | 199 | # HII type PCD's variable GUID.\r |
b6b3dc44 | 200 | # - SkuIdTable: TBD\r |
201 | # - SystemSkuId: TBD\r | |
d1102dba | 202 | # - PCD value structure:\r |
b6b3dc44 | 203 | # Every PCD has a value record in PCD database. For different\r |
d1102dba | 204 | # datum type PCD has different record structure which will be\r |
b6b3dc44 | 205 | # introduced in 3.3.1\r |
d1102dba LG |
206 | #\r |
207 | # In a PCD database structure, there are two major area: Init and UnInit.\r | |
208 | # Init area is use stored above PCD internal structure such as ExMapTable,\r | |
209 | # LocalTokenNumberTable etc and the (default) value of PCD which has default\r | |
b6b3dc44 | 210 | # value specified in platform DSC file.\r |
211 | # Unint area is used stored the value of PCD which has no default value in\r | |
212 | # platform DSC file, the value of NULL, 0 specified in platform DSC file can\r | |
213 | # be seemed as "no default value".\r | |
d1102dba | 214 | #\r |
b6b3dc44 | 215 | # 3.3.1 Simple Sample PCD Database C Structure\r |
216 | # A general sample of PCD database structue is as follows:\r | |
217 | # typedef struct _PCD_DATABASE {\r | |
218 | # typedef struct _PCD_DATABASE_INIT {\r | |
219 | # //===== Following is PCD database internal maintain structures\r | |
220 | # DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];\r | |
221 | # UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r | |
222 | # GUID GuidTable[PEI_GUID_TABLE_SIZE];\r | |
223 | # SIZE_INFO SizeTable[PEI_SIZE_TABLE_SIZE];\r | |
224 | # UINT8 SkuIdTable[PEI_SKUID_TABLE_SIZE];\r | |
225 | # SKU_ID SystemSkuId;\r | |
d1102dba | 226 | #\r |
b6b3dc44 | 227 | # //===== Following is value structure for PCD with default value\r |
228 | # ....\r | |
229 | # ....\r | |
230 | # ....\r | |
231 | # } Init;\r | |
232 | # typedef struct _PCD_DATABSE_UNINIT {\r | |
233 | # //==== Following is value structure for PCD without default value\r | |
234 | # ....\r | |
235 | # ....\r | |
236 | # } UnInit;\r | |
237 | # }\r | |
d1102dba | 238 | #\r |
b6b3dc44 | 239 | # 3.3.2 PCD value structure in PCD database C structure\r |
240 | # The value's structure is generated by build tool in PCD database C structure.\r | |
241 | # The PCDs in different datum type has different value structure.\r | |
d1102dba | 242 | #\r |
b6b3dc44 | 243 | # 3.3.2.1 UINT8/UINT16/UINT32/UINT64 datum type PCD\r |
244 | # The C structure for these datum type PCD is just a UINT8/UINT16/UINT32/UINT64\r | |
245 | # data member in PCD database, For example:\r | |
246 | # UINT16 PcdHardwareErrorRecordLevel_d3705011_bc19_4af7_be16_f68030378c15_VariableDefault_0;\r | |
247 | # Above structure is generated by build tool, the member name is "PcdCName_Guidvalue"\r | |
248 | # Member type is UINT16 according to PcdHardwareErrorRecordLevel declaration\r | |
249 | # in DEC file.\r | |
d1102dba | 250 | #\r |
b6b3dc44 | 251 | # 3.3.2.2 VOID* datum type PCD\r |
252 | # The value of VOID* datum type PCD is a UINT8/UINT16 array in PCD database.\r | |
d1102dba | 253 | #\r |
b6b3dc44 | 254 | # 3.3.2.2.1 VOID* - string type\r |
d1102dba LG |
255 | # If the default value for VOID* datum type PCD like L"xxx", the PCD is\r |
256 | # used for unicode string, and C structure of this datum type PCD is\r | |
b6b3dc44 | 257 | # UINT16 string array in PCD database, for example:\r |
258 | # UINT16 StringTable[29];\r | |
259 | # The number of 29 in above sample is max size of a unicode string.\r | |
d1102dba | 260 | #\r |
b6b3dc44 | 261 | # If the default value for VOID* datum type PCD like "xxx", the PCD is\r |
d1102dba | 262 | # used for ascii string, and C structure of this datum type PCD is\r |
b6b3dc44 | 263 | # UINT8 string array in PCD database, for example:\r |
264 | # UINT8 StringTable[20];\r | |
265 | # The number of 20 in above sample is max size of a ascii string.\r | |
d1102dba | 266 | #\r |
b6b3dc44 | 267 | # 3.3.2.2.2 VOID* - byte array\r |
268 | # If the default value of VOID* datum type PCD like {'0x29', '0x01', '0xf2'}\r | |
d1102dba | 269 | # the PCD is used for byte array. The generated structrue is same as\r |
b6b3dc44 | 270 | # above ascii string table,\r |
271 | # UINT8 StringTable[13];\r | |
272 | # The number of 13 in above sample is max size of byte array.\r | |
d1102dba | 273 | #\r |
b6b3dc44 | 274 | # 3.3.3 Some utility structures in PCD Database\r |
275 | # 3.3.3.1 GuidTable\r | |
276 | # GuidTable array is used to store all related GUID value in PCD database:\r | |
277 | # - Variable GUID for HII type PCD\r | |
d1102dba LG |
278 | # - Token space GUID for dynamicex type PCD\r |
279 | #\r | |
e8d2a980 | 280 | # Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
80408db0 | 281 | #\r |
9d510e61 | 282 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
80408db0 | 283 | #\r |
284 | #\r | |
6bfbb5f0 | 285 | ##\r |
80408db0 | 286 | \r |
80408db0 | 287 | [Defines]\r |
288 | INF_VERSION = 0x00010005\r | |
289 | BASE_NAME = PcdPeim\r | |
6036e94d | 290 | MODULE_UNI_FILE = PcdPeim.uni\r |
80408db0 | 291 | FILE_GUID = 9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50\r |
292 | MODULE_TYPE = PEIM\r | |
419db80b | 293 | VERSION_STRING = 4.0\r |
be82f9ff | 294 | PCD_IS_DRIVER = PEI_PCD_DRIVER\r |
80408db0 | 295 | ENTRY_POINT = PcdPeimInit\r |
296 | \r | |
297 | #\r | |
298 | # The following information is for reference only and not required by the build tools.\r | |
299 | #\r | |
de005223 | 300 | # VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)\r |
80408db0 | 301 | #\r |
302 | \r | |
188e4e84 | 303 | [Sources]\r |
80408db0 | 304 | Service.c\r |
305 | Service.h\r | |
306 | Pcd.c\r | |
80408db0 | 307 | \r |
80408db0 | 308 | [Packages]\r |
309 | MdePkg/MdePkg.dec\r | |
e75fe0eb | 310 | MdeModulePkg/MdeModulePkg.dec\r |
80408db0 | 311 | \r |
312 | [LibraryClasses]\r | |
313 | BaseMemoryLib\r | |
80408db0 | 314 | PcdLib\r |
315 | PeiServicesLib\r | |
316 | HobLib\r | |
317 | BaseLib\r | |
318 | PeimEntryPoint\r | |
319 | DebugLib\r | |
96d6d004 | 320 | MemoryAllocationLib\r |
80408db0 | 321 | \r |
80408db0 | 322 | [Guids]\r |
419db80b BF |
323 | ## PRODUCES ## HOB\r |
324 | ## SOMETIMES_CONSUMES ## HOB\r | |
d1102dba | 325 | gPcdDataBaseHobGuid\r |
6036e94d | 326 | gPcdDataBaseSignatureGuid ## CONSUMES ## GUID # PCD database signature GUID.\r |
219247e1 | 327 | gEfiMdeModulePkgTokenSpaceGuid ## SOMETIMES_CONSUMES ## GUID\r |
80408db0 | 328 | \r |
80408db0 | 329 | [Ppis]\r |
419db80b | 330 | gEfiPeiReadOnlyVariable2PpiGuid ## SOMETIMES_CONSUMES\r |
b9982883 | 331 | gPcdPpiGuid ## PRODUCES\r |
c896d682 | 332 | gEfiPeiPcdPpiGuid ## PRODUCES\r |
96d6d004 SZ |
333 | gGetPcdInfoPpiGuid ## SOMETIMES_PRODUCES\r |
334 | gEfiGetPcdInfoPpiGuid ## SOMETIMES_PRODUCES\r | |
7c736265 | 335 | gEfiEndOfPeiSignalPpiGuid ## NOTIFY\r |
96d6d004 | 336 | \r |
4941d881 | 337 | [FeaturePcd]\r |
419db80b | 338 | gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## CONSUMES\r |
80408db0 | 339 | \r |
188e4e84 | 340 | [Pcd]\r |
419db80b | 341 | gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES\r |
534efca0 | 342 | gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## SOMETIMES_CONSUMES\r |
307a19a7 | 343 | gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry ## SOMETIMES_CONSUMES\r |
219247e1 LG |
344 | gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer ## SOMETIMES_CONSUMES\r |
345 | gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## CONSUMES\r | |
80408db0 | 346 | \r |
80408db0 | 347 | [Depex]\r |
348 | TRUE\r | |
349 | \r | |
6036e94d SZ |
350 | [UserExtensions.TianoCore."ExtraFiles"]\r |
351 | PcdPeimExtra.uni\r |