]>
Commit | Line | Data |
---|---|---|
fc547e08 | 1 | /** @file \r |
5944a83b | 2 | All Pcd Ppi services are implemented here.\r |
fc547e08 | 3 | \r |
c896d682 | 4 | Copyright (c) 2006 - 2009, Intel Corporation \r |
80408db0 | 5 | All rights reserved. This program and the accompanying materials \r |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
80408db0 | 13 | **/\r |
14 | \r | |
80408db0 | 15 | #include "Service.h"\r |
16 | \r | |
8a541f0a | 17 | //\r |
18 | // Instance of PCD_PPI protocol is native implementation by MdePkg.\r | |
19 | // This protocol instance support dynamic and dynamicEx type PCDs.\r | |
20 | //\r | |
80408db0 | 21 | PCD_PPI mPcdPpiInstance = {\r |
22 | PeiPcdSetSku,\r | |
23 | \r | |
24 | PeiPcdGet8,\r | |
25 | PeiPcdGet16, \r | |
26 | PeiPcdGet32, \r | |
27 | PeiPcdGet64, \r | |
28 | PeiPcdGetPtr, \r | |
29 | PeiPcdGetBool, \r | |
30 | PeiPcdGetSize,\r | |
31 | \r | |
32 | PeiPcdGet8Ex,\r | |
33 | PeiPcdGet16Ex, \r | |
34 | PeiPcdGet32Ex, \r | |
35 | PeiPcdGet64Ex, \r | |
36 | PeiPcdGetPtrEx, \r | |
37 | PeiPcdGetBoolEx, \r | |
38 | PeiPcdGetSizeEx,\r | |
39 | \r | |
40 | PeiPcdSet8,\r | |
41 | PeiPcdSet16, \r | |
42 | PeiPcdSet32, \r | |
43 | PeiPcdSet64, \r | |
44 | PeiPcdSetPtr, \r | |
45 | PeiPcdSetBool, \r | |
46 | \r | |
47 | PeiPcdSet8Ex,\r | |
48 | PeiPcdSet16Ex, \r | |
49 | PeiPcdSet32Ex, \r | |
50 | PeiPcdSet64Ex, \r | |
51 | PeiPcdSetPtrEx, \r | |
52 | PeiPcdSetBoolEx,\r | |
53 | \r | |
54 | PeiRegisterCallBackOnSet,\r | |
55 | PcdUnRegisterCallBackOnSet,\r | |
56 | PeiPcdGetNextToken,\r | |
57 | PeiPcdGetNextTokenSpace\r | |
58 | };\r | |
59 | \r | |
8a541f0a | 60 | //\r |
61 | // Instance of EFI_PEI_PCD_PPI which is defined in PI 1.2 Vol 3.\r | |
62 | // This PPI instance only support dyanmicEx type PCD.\r | |
63 | //\r | |
c896d682 | 64 | EFI_PEI_PCD_PPI mEfiPcdPpiInstance = {\r |
65 | PeiPcdSetSku,\r | |
66 | \r | |
67 | PeiPcdGet8Ex,\r | |
68 | PeiPcdGet16Ex,\r | |
69 | PeiPcdGet32Ex,\r | |
70 | PeiPcdGet64Ex,\r | |
71 | PeiPcdGetPtrEx,\r | |
72 | PeiPcdGetBoolEx,\r | |
73 | PeiPcdGetSizeEx,\r | |
74 | PeiPcdSet8Ex,\r | |
75 | PeiPcdSet16Ex,\r | |
76 | PeiPcdSet32Ex,\r | |
77 | PeiPcdSet64Ex,\r | |
78 | PeiPcdSetPtrEx,\r | |
79 | PeiPcdSetBoolEx,\r | |
80 | (EFI_PEI_PCD_PPI_CALLBACK_ON_SET) PeiRegisterCallBackOnSet,\r | |
81 | (EFI_PEI_PCD_PPI_CANCEL_CALLBACK) PcdUnRegisterCallBackOnSet,\r | |
82 | PeiPcdGetNextToken,\r | |
83 | PeiPcdGetNextTokenSpace\r | |
84 | };\r | |
85 | \r | |
fe1e36e5 | 86 | EFI_PEI_PPI_DESCRIPTOR mPpiPCD = {\r |
80408db0 | 87 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r |
88 | &gPcdPpiGuid,\r | |
89 | &mPcdPpiInstance\r | |
90 | };\r | |
91 | \r | |
c896d682 | 92 | EFI_PEI_PPI_DESCRIPTOR mEfiPpiPCD = {\r |
93 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r | |
94 | &gEfiPeiPcdPpiGuid,\r | |
95 | &mEfiPcdPpiInstance\r | |
96 | };\r | |
97 | \r | |
fc547e08 | 98 | /**\r |
99 | Main entry for PCD PEIM driver.\r | |
100 | \r | |
8a541f0a | 101 | This routine initialize the PCD database for PEI phase and install PCD_PPI/EFI_PEI_PCD_PPI.\r |
80408db0 | 102 | \r |
8bd22b8a LG |
103 | @param FileHandle Handle of the file being invoked.\r |
104 | @param PeiServices Describes the list of possible PEI Services.\r | |
80408db0 | 105 | \r |
fc547e08 | 106 | @return Status of install PCD_PPI\r |
107 | \r | |
108 | **/\r | |
80408db0 | 109 | EFI_STATUS\r |
110 | EFIAPI\r | |
111 | PcdPeimInit (\r | |
8bd22b8a LG |
112 | IN EFI_PEI_FILE_HANDLE FileHandle,\r |
113 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
80408db0 | 114 | )\r |
115 | {\r | |
8a541f0a | 116 | EFI_STATUS Status;\r |
117 | \r | |
80408db0 | 118 | BuildPcdDatabase ();\r |
80408db0 | 119 | \r |
8a541f0a | 120 | //\r |
121 | // Install PCD_PPI which produce support for dynamic and dynamicEx PCD\r | |
122 | //\r | |
123 | Status = PeiServicesInstallPpi (&mPpiPCD);\r | |
124 | ASSERT_EFI_ERROR (Status);\r | |
125 | \r | |
126 | //\r | |
127 | // Install EFI_PCD_PPI which produce support for dynamicEx PCD which is defined\r | |
128 | // in PI 1.2 Vol 3 specification.\r | |
129 | //\r | |
130 | Status = PeiServicesInstallPpi (&mEfiPpiPCD);\r | |
131 | ASSERT_EFI_ERROR (Status);\r | |
132 | \r | |
133 | return Status;\r | |
80408db0 | 134 | }\r |
135 | \r | |
fc547e08 | 136 | /**\r |
137 | Sets the SKU value for subsequent calls to set or get PCD token values.\r | |
138 | \r | |
139 | SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. \r | |
140 | SetSku() is normally called only once by the system.\r | |
141 | \r | |
142 | For each item (token), the database can hold a single value that applies to all SKUs, \r | |
143 | or multiple values, where each value is associated with a specific SKU Id. Items with multiple, \r | |
144 | SKU-specific values are called SKU enabled. \r | |
145 | \r | |
146 | The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255. \r | |
147 | For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the \r | |
148 | single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the \r | |
149 | last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token, \r | |
150 | the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been \r | |
151 | set for that Id, the results are unpredictable.\r | |
152 | \r | |
153 | @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r | |
154 | set values associated with a PCD token.\r | |
155 | \r | |
fc547e08 | 156 | **/\r |
80408db0 | 157 | VOID\r |
158 | EFIAPI\r | |
159 | PeiPcdSetSku (\r | |
160 | IN UINTN SkuId\r | |
161 | )\r | |
162 | {\r | |
163 | \r | |
164 | GetPcdDatabase()->Init.SystemSkuId = (SKU_ID) SkuId;\r | |
165 | \r | |
166 | return;\r | |
167 | }\r | |
168 | \r | |
fc547e08 | 169 | /**\r |
170 | Retrieves an 8-bit value for a given PCD token.\r | |
80408db0 | 171 | \r |
fc547e08 | 172 | Retrieves the current byte-sized value for a PCD token number. \r |
173 | If the TokenNumber is invalid, the results are unpredictable.\r | |
174 | \r | |
175 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 176 | \r |
fc547e08 | 177 | @return The UINT8 value.\r |
178 | \r | |
179 | **/\r | |
80408db0 | 180 | UINT8\r |
181 | EFIAPI\r | |
182 | PeiPcdGet8 (\r | |
183 | IN UINTN TokenNumber\r | |
184 | )\r | |
185 | {\r | |
186 | return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r | |
187 | }\r | |
188 | \r | |
fc547e08 | 189 | /**\r |
190 | Retrieves an 16-bit value for a given PCD token.\r | |
80408db0 | 191 | \r |
fc547e08 | 192 | Retrieves the current 16-bits value for a PCD token number. \r |
193 | If the TokenNumber is invalid, the results are unpredictable.\r | |
194 | \r | |
195 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 196 | \r |
fc547e08 | 197 | @return The UINT16 value.\r |
198 | \r | |
199 | **/\r | |
80408db0 | 200 | UINT16\r |
201 | EFIAPI\r | |
202 | PeiPcdGet16 (\r | |
203 | IN UINTN TokenNumber\r | |
204 | )\r | |
205 | {\r | |
206 | return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r | |
207 | }\r | |
208 | \r | |
fc547e08 | 209 | /**\r |
210 | Retrieves an 32-bit value for a given PCD token.\r | |
80408db0 | 211 | \r |
fc547e08 | 212 | Retrieves the current 32-bits value for a PCD token number. \r |
213 | If the TokenNumber is invalid, the results are unpredictable.\r | |
214 | \r | |
215 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 216 | \r |
fc547e08 | 217 | @return The UINT32 value.\r |
218 | \r | |
219 | **/\r | |
80408db0 | 220 | UINT32\r |
221 | EFIAPI\r | |
222 | PeiPcdGet32 (\r | |
223 | IN UINTN TokenNumber\r | |
224 | )\r | |
225 | {\r | |
226 | return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r | |
227 | }\r | |
228 | \r | |
fc547e08 | 229 | /**\r |
230 | Retrieves an 64-bit value for a given PCD token.\r | |
80408db0 | 231 | \r |
fc547e08 | 232 | Retrieves the current 64-bits value for a PCD token number. \r |
233 | If the TokenNumber is invalid, the results are unpredictable.\r | |
234 | \r | |
235 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 236 | \r |
fc547e08 | 237 | @return The UINT64 value.\r |
238 | \r | |
239 | **/\r | |
80408db0 | 240 | UINT64\r |
241 | EFIAPI\r | |
242 | PeiPcdGet64 (\r | |
243 | IN UINTN TokenNumber\r | |
244 | )\r | |
245 | {\r | |
246 | return ReadUnaligned64 (GetWorker (TokenNumber, sizeof (UINT64)));\r | |
247 | }\r | |
248 | \r | |
fc547e08 | 249 | /**\r |
250 | Retrieves a pointer to a value for a given PCD token.\r | |
251 | \r | |
252 | Retrieves the current pointer to the buffer for a PCD token number. \r | |
253 | Do not make any assumptions about the alignment of the pointer that \r | |
254 | is returned by this function call. If the TokenNumber is invalid, \r | |
255 | the results are unpredictable.\r | |
80408db0 | 256 | \r |
fc547e08 | 257 | @param[in] TokenNumber The PCD token number. \r |
80408db0 | 258 | \r |
3fd8027e | 259 | @return The pointer to the buffer to be retrieved.\r |
fc547e08 | 260 | \r |
261 | **/\r | |
80408db0 | 262 | VOID *\r |
263 | EFIAPI\r | |
264 | PeiPcdGetPtr (\r | |
265 | IN UINTN TokenNumber\r | |
266 | )\r | |
267 | {\r | |
268 | return GetWorker (TokenNumber, 0);\r | |
269 | }\r | |
270 | \r | |
fc547e08 | 271 | /**\r |
272 | Retrieves a Boolean value for a given PCD token.\r | |
80408db0 | 273 | \r |
fc547e08 | 274 | Retrieves the current boolean value for a PCD token number. \r |
275 | Do not make any assumptions about the alignment of the pointer that \r | |
276 | is returned by this function call. If the TokenNumber is invalid, \r | |
277 | the results are unpredictable.\r | |
80408db0 | 278 | \r |
fc547e08 | 279 | @param[in] TokenNumber The PCD token number. \r |
280 | \r | |
281 | @return The Boolean value.\r | |
282 | \r | |
283 | **/\r | |
80408db0 | 284 | BOOLEAN\r |
285 | EFIAPI\r | |
286 | PeiPcdGetBool (\r | |
287 | IN UINTN TokenNumber\r | |
288 | )\r | |
289 | {\r | |
290 | return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));\r | |
291 | }\r | |
292 | \r | |
fc547e08 | 293 | /**\r |
294 | Retrieves the size of the value for a given PCD token.\r | |
295 | \r | |
296 | Retrieves the current size of a particular PCD token. \r | |
297 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 298 | \r |
fc547e08 | 299 | @param[in] TokenNumber The PCD token number. \r |
80408db0 | 300 | \r |
fc547e08 | 301 | @return The size of the value for the PCD token.\r |
302 | \r | |
303 | **/\r | |
80408db0 | 304 | UINTN\r |
305 | EFIAPI\r | |
306 | PeiPcdGetSize (\r | |
307 | IN UINTN TokenNumber\r | |
308 | )\r | |
309 | {\r | |
310 | PEI_PCD_DATABASE *PeiPcdDb;\r | |
311 | UINTN Size;\r | |
312 | UINTN MaxSize;\r | |
313 | \r | |
80408db0 | 314 | PeiPcdDb = GetPcdDatabase ();\r |
315 | //\r | |
316 | // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r | |
317 | // We have to decrement TokenNumber by 1 to make it usable\r | |
318 | // as the array index.\r | |
319 | //\r | |
320 | TokenNumber--;\r | |
321 | \r | |
322 | // EBC compiler is very choosy. It may report warning about comparison\r | |
323 | // between UINTN and 0 . So we add 1 in each size of the \r | |
324 | // comparison.\r | |
325 | ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r | |
326 | \r | |
327 | Size = (PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r | |
328 | \r | |
329 | if (Size == 0) {\r | |
330 | //\r | |
331 | // For pointer type, we need to scan the SIZE_TABLE to get the current size.\r | |
332 | //\r | |
333 | return GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);\r | |
334 | } else {\r | |
335 | return Size;\r | |
336 | }\r | |
337 | \r | |
338 | }\r | |
339 | \r | |
fc547e08 | 340 | /**\r |
341 | Retrieves an 8-bit value for a given PCD token.\r | |
80408db0 | 342 | \r |
fc547e08 | 343 | Retrieves the 8-bit value of a particular PCD token. \r |
344 | If the TokenNumber is invalid or the token space\r | |
345 | specified by Guid does not exist, the results are \r | |
346 | unpredictable.\r | |
80408db0 | 347 | \r |
fc547e08 | 348 | @param[in] Guid The token space for the token number.\r |
349 | @param[in] ExTokenNumber The PCD token number. \r | |
350 | \r | |
351 | @return The size 8-bit value for the PCD token.\r | |
352 | \r | |
353 | **/\r | |
80408db0 | 354 | UINT8\r |
355 | EFIAPI\r | |
356 | PeiPcdGet8Ex (\r | |
357 | IN CONST EFI_GUID *Guid,\r | |
358 | IN UINTN ExTokenNumber\r | |
359 | )\r | |
360 | {\r | |
361 | return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));\r | |
362 | }\r | |
363 | \r | |
fc547e08 | 364 | /**\r |
365 | Retrieves an 16-bit value for a given PCD token.\r | |
80408db0 | 366 | \r |
fc547e08 | 367 | Retrieves the 16-bit value of a particular PCD token. \r |
368 | If the TokenNumber is invalid or the token space\r | |
369 | specified by Guid does not exist, the results are \r | |
370 | unpredictable.\r | |
80408db0 | 371 | \r |
fc547e08 | 372 | @param[in] Guid The token space for the token number.\r |
373 | @param[in] ExTokenNumber The PCD token number. \r | |
374 | \r | |
375 | @return The size 16-bit value for the PCD token.\r | |
376 | \r | |
377 | **/\r | |
80408db0 | 378 | UINT16\r |
379 | EFIAPI\r | |
380 | PeiPcdGet16Ex (\r | |
381 | IN CONST EFI_GUID *Guid,\r | |
382 | IN UINTN ExTokenNumber\r | |
383 | )\r | |
384 | {\r | |
385 | return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT16)));\r | |
386 | }\r | |
387 | \r | |
fc547e08 | 388 | /**\r |
389 | Retrieves an 32-bit value for a given PCD token.\r | |
390 | \r | |
391 | Retrieves the 32-bit value of a particular PCD token. \r | |
392 | If the TokenNumber is invalid or the token space\r | |
393 | specified by Guid does not exist, the results are \r | |
394 | unpredictable.\r | |
80408db0 | 395 | \r |
fc547e08 | 396 | @param[in] Guid The token space for the token number.\r |
397 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 398 | \r |
fc547e08 | 399 | @return The size 32-bit value for the PCD token.\r |
400 | \r | |
401 | **/\r | |
80408db0 | 402 | UINT32\r |
403 | EFIAPI\r | |
404 | PeiPcdGet32Ex (\r | |
405 | IN CONST EFI_GUID *Guid,\r | |
406 | IN UINTN ExTokenNumber\r | |
407 | )\r | |
408 | {\r | |
409 | return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT32)));\r | |
410 | }\r | |
411 | \r | |
fc547e08 | 412 | /**\r |
413 | Retrieves an 64-bit value for a given PCD token.\r | |
414 | \r | |
415 | Retrieves the 64-bit value of a particular PCD token. \r | |
416 | If the TokenNumber is invalid or the token space\r | |
417 | specified by Guid does not exist, the results are \r | |
418 | unpredictable.\r | |
80408db0 | 419 | \r |
fc547e08 | 420 | @param[in] Guid The token space for the token number.\r |
421 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 422 | \r |
fc547e08 | 423 | @return The size 64-bit value for the PCD token.\r |
424 | \r | |
425 | **/\r | |
80408db0 | 426 | UINT64\r |
427 | EFIAPI\r | |
428 | PeiPcdGet64Ex (\r | |
429 | IN CONST EFI_GUID *Guid,\r | |
430 | IN UINTN ExTokenNumber\r | |
431 | )\r | |
432 | {\r | |
433 | return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));\r | |
434 | }\r | |
435 | \r | |
fc547e08 | 436 | /**\r |
437 | Retrieves a pointer to a value for a given PCD token.\r | |
80408db0 | 438 | \r |
fc547e08 | 439 | Retrieves the current pointer to the buffer for a PCD token number. \r |
440 | Do not make any assumptions about the alignment of the pointer that \r | |
441 | is returned by this function call. If the TokenNumber is invalid, \r | |
442 | the results are unpredictable.\r | |
80408db0 | 443 | \r |
fc547e08 | 444 | @param[in] Guid The token space for the token number.\r |
445 | @param[in] ExTokenNumber The PCD token number. \r | |
446 | \r | |
3fd8027e | 447 | @return The pointer to the buffer to be retrieved.\r |
fc547e08 | 448 | \r |
449 | **/\r | |
80408db0 | 450 | VOID *\r |
451 | EFIAPI\r | |
452 | PeiPcdGetPtrEx (\r | |
453 | IN CONST EFI_GUID *Guid,\r | |
454 | IN UINTN ExTokenNumber\r | |
455 | )\r | |
456 | {\r | |
457 | return ExGetWorker (Guid, ExTokenNumber, 0);\r | |
458 | }\r | |
459 | \r | |
fc547e08 | 460 | /**\r |
461 | Retrieves an Boolean value for a given PCD token.\r | |
462 | \r | |
463 | Retrieves the Boolean value of a particular PCD token. \r | |
464 | If the TokenNumber is invalid or the token space\r | |
465 | specified by Guid does not exist, the results are \r | |
466 | unpredictable.\r | |
80408db0 | 467 | \r |
fc547e08 | 468 | @param[in] Guid The token space for the token number.\r |
469 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 470 | \r |
fc547e08 | 471 | @return The size Boolean value for the PCD token.\r |
472 | \r | |
473 | **/\r | |
80408db0 | 474 | BOOLEAN\r |
475 | EFIAPI\r | |
476 | PeiPcdGetBoolEx (\r | |
477 | IN CONST EFI_GUID *Guid,\r | |
478 | IN UINTN ExTokenNumber\r | |
479 | )\r | |
480 | {\r | |
481 | return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof (BOOLEAN)));\r | |
482 | }\r | |
483 | \r | |
fc547e08 | 484 | /**\r |
485 | Retrieves the size of the value for a given PCD token.\r | |
486 | \r | |
487 | Retrieves the current size of a particular PCD token. \r | |
488 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 489 | \r |
fc547e08 | 490 | @param[in] Guid The token space for the token number.\r |
491 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 492 | \r |
fc547e08 | 493 | @return The size of the value for the PCD token.\r |
494 | \r | |
495 | **/\r | |
80408db0 | 496 | UINTN\r |
497 | EFIAPI\r | |
498 | PeiPcdGetSizeEx (\r | |
499 | IN CONST EFI_GUID *Guid,\r | |
500 | IN UINTN ExTokenNumber\r | |
501 | )\r | |
502 | {\r | |
80408db0 | 503 | return PeiPcdGetSize (GetExPcdTokenNumber (Guid, ExTokenNumber));\r |
504 | }\r | |
505 | \r | |
fc547e08 | 506 | /**\r |
507 | Sets an 8-bit value for a given PCD token.\r | |
80408db0 | 508 | \r |
fc547e08 | 509 | When the PCD service sets a value, it will check to ensure that the \r |
510 | size of the value being set is compatible with the Token's existing definition. \r | |
511 | If it is not, an error will be returned.\r | |
80408db0 | 512 | \r |
fc547e08 | 513 | @param[in] TokenNumber The PCD token number. \r |
514 | @param[in] Value The value to set for the PCD token.\r | |
515 | \r | |
516 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
517 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
518 | being set was incompatible with a call to this function. \r | |
519 | Use GetSize() to retrieve the size of the target data.\r | |
520 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
521 | \r | |
522 | **/\r | |
80408db0 | 523 | EFI_STATUS\r |
524 | EFIAPI\r | |
525 | PeiPcdSet8 (\r | |
526 | IN UINTN TokenNumber,\r | |
527 | IN UINT8 Value\r | |
528 | )\r | |
529 | {\r | |
530 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
531 | }\r | |
532 | \r | |
fc547e08 | 533 | /**\r |
534 | Sets an 16-bit value for a given PCD token.\r | |
535 | \r | |
536 | When the PCD service sets a value, it will check to ensure that the \r | |
537 | size of the value being set is compatible with the Token's existing definition. \r | |
538 | If it is not, an error will be returned.\r | |
80408db0 | 539 | \r |
fc547e08 | 540 | @param[in] TokenNumber The PCD token number. \r |
541 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 542 | \r |
fc547e08 | 543 | @retval EFI_SUCCESS Procedure returned successfully.\r |
544 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
545 | being set was incompatible with a call to this function. \r | |
546 | Use GetSize() to retrieve the size of the target data.\r | |
547 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
548 | \r | |
549 | **/\r | |
80408db0 | 550 | EFI_STATUS\r |
551 | EFIAPI\r | |
552 | PeiPcdSet16 (\r | |
553 | IN UINTN TokenNumber,\r | |
554 | IN UINT16 Value\r | |
555 | )\r | |
556 | {\r | |
557 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
558 | }\r | |
559 | \r | |
fc547e08 | 560 | /**\r |
561 | Sets an 32-bit value for a given PCD token.\r | |
80408db0 | 562 | \r |
fc547e08 | 563 | When the PCD service sets a value, it will check to ensure that the \r |
564 | size of the value being set is compatible with the Token's existing definition. \r | |
565 | If it is not, an error will be returned.\r | |
80408db0 | 566 | \r |
fc547e08 | 567 | @param[in] TokenNumber The PCD token number. \r |
568 | @param[in] Value The value to set for the PCD token.\r | |
569 | \r | |
570 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
571 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
572 | being set was incompatible with a call to this function. \r | |
573 | Use GetSize() to retrieve the size of the target data.\r | |
574 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
575 | \r | |
576 | **/\r | |
80408db0 | 577 | EFI_STATUS\r |
578 | EFIAPI\r | |
579 | PeiPcdSet32 (\r | |
580 | IN UINTN TokenNumber,\r | |
581 | IN UINT32 Value\r | |
582 | )\r | |
583 | {\r | |
584 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
585 | }\r | |
586 | \r | |
fc547e08 | 587 | /**\r |
588 | Sets an 64-bit value for a given PCD token.\r | |
589 | \r | |
590 | When the PCD service sets a value, it will check to ensure that the \r | |
591 | size of the value being set is compatible with the Token's existing definition. \r | |
592 | If it is not, an error will be returned.\r | |
80408db0 | 593 | \r |
fc547e08 | 594 | @param[in] TokenNumber The PCD token number. \r |
595 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 596 | \r |
fc547e08 | 597 | @retval EFI_SUCCESS Procedure returned successfully.\r |
598 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
599 | being set was incompatible with a call to this function. \r | |
600 | Use GetSize() to retrieve the size of the target data.\r | |
601 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
602 | \r | |
603 | **/\r | |
80408db0 | 604 | EFI_STATUS\r |
605 | EFIAPI\r | |
606 | PeiPcdSet64 (\r | |
607 | IN UINTN TokenNumber,\r | |
608 | IN UINT64 Value\r | |
609 | )\r | |
610 | {\r | |
611 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
612 | }\r | |
613 | \r | |
fc547e08 | 614 | /**\r |
615 | Sets a value of a specified size for a given PCD token.\r | |
616 | \r | |
617 | When the PCD service sets a value, it will check to ensure that the \r | |
618 | size of the value being set is compatible with the Token's existing definition. \r | |
619 | If it is not, an error will be returned.\r | |
620 | \r | |
621 | @param[in] TokenNumber The PCD token number. \r | |
622 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
623 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
624 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
625 | the maximum size supported for this TokenNumber.\r | |
626 | @param[in] Buffer The buffer to set for the PCD token.\r | |
627 | \r | |
628 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
629 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
630 | being set was incompatible with a call to this function. \r | |
631 | Use GetSize() to retrieve the size of the target data.\r | |
632 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
633 | \r | |
634 | **/\r | |
80408db0 | 635 | EFI_STATUS\r |
636 | EFIAPI\r | |
637 | PeiPcdSetPtr (\r | |
638 | IN UINTN TokenNumber,\r | |
639 | IN OUT UINTN *SizeOfBuffer,\r | |
640 | IN VOID *Buffer\r | |
641 | )\r | |
642 | {\r | |
643 | return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r | |
644 | }\r | |
645 | \r | |
fc547e08 | 646 | /**\r |
647 | Sets an Boolean value for a given PCD token.\r | |
80408db0 | 648 | \r |
fc547e08 | 649 | When the PCD service sets a value, it will check to ensure that the \r |
650 | size of the value being set is compatible with the Token's existing definition. \r | |
651 | If it is not, an error will be returned.\r | |
80408db0 | 652 | \r |
fc547e08 | 653 | @param[in] TokenNumber The PCD token number. \r |
654 | @param[in] Value The value to set for the PCD token.\r | |
655 | \r | |
656 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
657 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
658 | being set was incompatible with a call to this function. \r | |
659 | Use GetSize() to retrieve the size of the target data.\r | |
660 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
661 | \r | |
662 | **/\r | |
80408db0 | 663 | EFI_STATUS\r |
664 | EFIAPI\r | |
665 | PeiPcdSetBool (\r | |
666 | IN UINTN TokenNumber,\r | |
667 | IN BOOLEAN Value\r | |
668 | )\r | |
669 | {\r | |
670 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
671 | }\r | |
672 | \r | |
fc547e08 | 673 | /**\r |
674 | Sets an 8-bit value for a given PCD token.\r | |
80408db0 | 675 | \r |
fc547e08 | 676 | When the PCD service sets a value, it will check to ensure that the \r |
677 | size of the value being set is compatible with the Token's existing definition. \r | |
678 | If it is not, an error will be returned.\r | |
80408db0 | 679 | \r |
fc547e08 | 680 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
681 | @param[in] ExTokenNumber The PCD token number. \r | |
682 | @param[in] Value The value to set for the PCD token.\r | |
683 | \r | |
684 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
685 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
686 | being set was incompatible with a call to this function. \r | |
687 | Use GetSize() to retrieve the size of the target data.\r | |
688 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
689 | \r | |
690 | **/\r | |
80408db0 | 691 | EFI_STATUS\r |
692 | EFIAPI\r | |
693 | PeiPcdSet8Ex (\r | |
694 | IN CONST EFI_GUID *Guid,\r | |
695 | IN UINTN ExTokenNumber,\r | |
696 | IN UINT8 Value\r | |
697 | )\r | |
698 | {\r | |
699 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
700 | }\r | |
701 | \r | |
fc547e08 | 702 | /**\r |
703 | Sets an 16-bit value for a given PCD token.\r | |
704 | \r | |
705 | When the PCD service sets a value, it will check to ensure that the \r | |
706 | size of the value being set is compatible with the Token's existing definition. \r | |
707 | If it is not, an error will be returned.\r | |
80408db0 | 708 | \r |
fc547e08 | 709 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
710 | @param[in] ExTokenNumber The PCD token number. \r | |
711 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 712 | \r |
fc547e08 | 713 | @retval EFI_SUCCESS Procedure returned successfully.\r |
714 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
715 | being set was incompatible with a call to this function. \r | |
716 | Use GetSize() to retrieve the size of the target data.\r | |
717 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
718 | \r | |
719 | **/\r | |
80408db0 | 720 | EFI_STATUS\r |
721 | EFIAPI\r | |
722 | PeiPcdSet16Ex (\r | |
723 | IN CONST EFI_GUID *Guid,\r | |
724 | IN UINTN ExTokenNumber,\r | |
725 | IN UINT16 Value\r | |
726 | )\r | |
727 | {\r | |
728 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
729 | }\r | |
730 | \r | |
fc547e08 | 731 | /**\r |
732 | Sets an 32-bit value for a given PCD token.\r | |
733 | \r | |
734 | When the PCD service sets a value, it will check to ensure that the \r | |
735 | size of the value being set is compatible with the Token's existing definition. \r | |
736 | If it is not, an error will be returned.\r | |
80408db0 | 737 | \r |
fc547e08 | 738 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
739 | @param[in] ExTokenNumber The PCD token number. \r | |
740 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 741 | \r |
fc547e08 | 742 | @retval EFI_SUCCESS Procedure returned successfully.\r |
743 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
744 | being set was incompatible with a call to this function. \r | |
745 | Use GetSize() to retrieve the size of the target data.\r | |
746 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
747 | \r | |
748 | **/\r | |
80408db0 | 749 | EFI_STATUS\r |
750 | EFIAPI\r | |
751 | PeiPcdSet32Ex (\r | |
752 | IN CONST EFI_GUID *Guid,\r | |
753 | IN UINTN ExTokenNumber,\r | |
754 | IN UINT32 Value\r | |
755 | )\r | |
756 | {\r | |
757 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
758 | }\r | |
759 | \r | |
fc547e08 | 760 | /**\r |
761 | Sets an 64-bit value for a given PCD token.\r | |
80408db0 | 762 | \r |
fc547e08 | 763 | When the PCD service sets a value, it will check to ensure that the \r |
764 | size of the value being set is compatible with the Token's existing definition. \r | |
765 | If it is not, an error will be returned.\r | |
80408db0 | 766 | \r |
fc547e08 | 767 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
768 | @param[in] ExTokenNumber The PCD token number. \r | |
769 | @param[in] Value The value to set for the PCD token.\r | |
770 | \r | |
771 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
772 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
773 | being set was incompatible with a call to this function. \r | |
774 | Use GetSize() to retrieve the size of the target data.\r | |
775 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
776 | \r | |
777 | **/\r | |
80408db0 | 778 | EFI_STATUS\r |
779 | EFIAPI\r | |
780 | PeiPcdSet64Ex (\r | |
781 | IN CONST EFI_GUID *Guid,\r | |
782 | IN UINTN ExTokenNumber,\r | |
783 | IN UINT64 Value\r | |
784 | )\r | |
785 | {\r | |
786 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
787 | }\r | |
788 | \r | |
fc547e08 | 789 | /**\r |
790 | Sets a value of a specified size for a given PCD token.\r | |
791 | \r | |
792 | When the PCD service sets a value, it will check to ensure that the \r | |
793 | size of the value being set is compatible with the Token's existing definition. \r | |
794 | If it is not, an error will be returned.\r | |
795 | \r | |
796 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
797 | @param[in] ExTokenNumber The PCD token number. \r | |
798 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
799 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
800 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
801 | the maximum size supported for this TokenNumber.\r | |
802 | @param[in] Value The buffer to set for the PCD token.\r | |
803 | \r | |
804 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
805 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
806 | being set was incompatible with a call to this function. \r | |
807 | Use GetSize() to retrieve the size of the target data.\r | |
808 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
809 | \r | |
810 | **/\r | |
80408db0 | 811 | EFI_STATUS\r |
812 | EFIAPI\r | |
813 | PeiPcdSetPtrEx (\r | |
fc547e08 | 814 | IN CONST EFI_GUID *Guid,\r |
815 | IN UINTN ExTokenNumber,\r | |
816 | IN OUT UINTN *SizeOfBuffer,\r | |
817 | IN VOID *Value\r | |
80408db0 | 818 | )\r |
819 | {\r | |
820 | return ExSetWorker (ExTokenNumber, Guid, Value, SizeOfBuffer, TRUE);\r | |
821 | }\r | |
822 | \r | |
fc547e08 | 823 | /**\r |
824 | Sets an Boolean value for a given PCD token.\r | |
825 | \r | |
826 | When the PCD service sets a value, it will check to ensure that the \r | |
827 | size of the value being set is compatible with the Token's existing definition. \r | |
828 | If it is not, an error will be returned.\r | |
80408db0 | 829 | \r |
fc547e08 | 830 | @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
831 | @param [in] ExTokenNumber The PCD token number. \r | |
832 | @param [in] Value The value to set for the PCD token.\r | |
80408db0 | 833 | \r |
fc547e08 | 834 | @retval EFI_SUCCESS Procedure returned successfully.\r |
835 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
836 | being set was incompatible with a call to this function. \r | |
837 | Use GetSize() to retrieve the size of the target data.\r | |
838 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
839 | \r | |
840 | **/\r | |
80408db0 | 841 | EFI_STATUS\r |
842 | EFIAPI\r | |
843 | PeiPcdSetBoolEx (\r | |
844 | IN CONST EFI_GUID *Guid,\r | |
845 | IN UINTN ExTokenNumber,\r | |
846 | IN BOOLEAN Value\r | |
847 | )\r | |
848 | {\r | |
849 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
850 | }\r | |
851 | \r | |
fc547e08 | 852 | /**\r |
853 | Specifies a function to be called anytime the value of a designated token is changed.\r | |
80408db0 | 854 | \r |
fc547e08 | 855 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
856 | @param[in] ExTokenNumber The PCD token number. \r | |
857 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 858 | \r |
fc547e08 | 859 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
860 | for the CallBackToken requested.\r | |
861 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
80408db0 | 862 | \r |
fc547e08 | 863 | **/\r |
80408db0 | 864 | EFI_STATUS\r |
865 | EFIAPI\r | |
866 | PeiRegisterCallBackOnSet (\r | |
867 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
868 | IN UINTN ExTokenNumber,\r | |
869 | IN PCD_PPI_CALLBACK CallBackFunction\r | |
870 | )\r | |
871 | {\r | |
f806dd27 | 872 | if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable)) {\r |
80408db0 | 873 | return EFI_UNSUPPORTED;\r |
874 | }\r | |
875 | \r | |
e4a3922f | 876 | if (CallBackFunction == NULL) {\r |
877 | return EFI_INVALID_PARAMETER;\r | |
878 | }\r | |
879 | \r | |
80408db0 | 880 | return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);\r |
881 | }\r | |
882 | \r | |
fc547e08 | 883 | /**\r |
884 | Cancels a previously set callback function for a particular PCD token number.\r | |
80408db0 | 885 | \r |
fc547e08 | 886 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
887 | @param[in] ExTokenNumber The PCD token number. \r | |
888 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 889 | \r |
fc547e08 | 890 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
891 | for the CallBackToken requested.\r | |
892 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
893 | \r | |
894 | **/\r | |
80408db0 | 895 | EFI_STATUS\r |
896 | EFIAPI\r | |
897 | PcdUnRegisterCallBackOnSet (\r | |
898 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
899 | IN UINTN ExTokenNumber,\r | |
900 | IN PCD_PPI_CALLBACK CallBackFunction\r | |
901 | )\r | |
902 | {\r | |
f806dd27 | 903 | if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable)) {\r |
80408db0 | 904 | return EFI_UNSUPPORTED;\r |
905 | }\r | |
906 | \r | |
e4a3922f | 907 | if (CallBackFunction == NULL) {\r |
908 | return EFI_INVALID_PARAMETER;\r | |
909 | }\r | |
910 | \r | |
80408db0 | 911 | return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);\r |
912 | }\r | |
913 | \r | |
fc547e08 | 914 | /**\r |
90e06556 | 915 | Retrieves the next valid token number in a given namespace. \r |
916 | \r | |
917 | This is useful since the PCD infrastructure contains a sparse list of token numbers, \r | |
918 | and one cannot a priori know what token numbers are valid in the database. \r | |
919 | \r | |
920 | If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned. \r | |
921 | If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned. \r | |
922 | If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned. \r | |
923 | If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned. \r | |
924 | The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid. \r | |
925 | If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned. \r | |
926 | If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned. \r | |
927 | If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.\r | |
928 | \r | |
929 | \r | |
930 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value. \r | |
931 | This is an optional parameter that may be NULL. If this parameter is NULL, then a request \r | |
932 | is being made to retrieve tokens from the default token space.\r | |
933 | @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.\r | |
934 | \r | |
935 | @retval EFI_SUCCESS The PCD service has retrieved the next valid token number. \r | |
936 | Or the input token number is already the last valid token number in the PCD database. \r | |
fc547e08 | 937 | In the later case, *TokenNumber is updated with the value of 0.\r |
938 | @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r | |
939 | \r | |
940 | **/\r | |
80408db0 | 941 | EFI_STATUS\r |
942 | EFIAPI\r | |
943 | PeiPcdGetNextToken (\r | |
944 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
945 | IN OUT UINTN *TokenNumber\r | |
946 | )\r | |
947 | {\r | |
948 | UINTN GuidTableIdx;\r | |
949 | PEI_PCD_DATABASE *PeiPcdDb;\r | |
950 | EFI_GUID *MatchGuid;\r | |
951 | DYNAMICEX_MAPPING *ExMapTable;\r | |
fc547e08 | 952 | UINTN Index;\r |
80408db0 | 953 | BOOLEAN Found;\r |
954 | BOOLEAN PeiExMapTableEmpty;\r | |
955 | \r | |
f806dd27 | 956 | if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {\r |
80408db0 | 957 | return EFI_UNSUPPORTED;\r |
958 | }\r | |
959 | \r | |
960 | PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r | |
961 | \r | |
962 | if (Guid == NULL) {\r | |
963 | if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {\r | |
964 | return EFI_NOT_FOUND;\r | |
965 | }\r | |
966 | (*TokenNumber)++;\r | |
967 | if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {\r | |
968 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
969 | }\r | |
970 | return EFI_SUCCESS;\r | |
971 | } else {\r | |
972 | if (PeiExMapTableEmpty) {\r | |
973 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
974 | return EFI_SUCCESS;\r | |
975 | }\r | |
976 | \r | |
977 | //\r | |
978 | // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r | |
979 | // 1) ExGuid\r | |
980 | // 2) ExTokenNumber\r | |
981 | //\r | |
982 | PeiPcdDb = GetPcdDatabase ();\r | |
983 | \r | |
984 | MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);\r | |
985 | \r | |
986 | if (MatchGuid == NULL) {\r | |
987 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
988 | return EFI_NOT_FOUND;\r | |
989 | }\r | |
990 | \r | |
991 | GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r | |
992 | \r | |
993 | ExMapTable = PeiPcdDb->Init.ExMapTable;\r | |
994 | \r | |
995 | Found = FALSE;\r | |
996 | //\r | |
997 | // Locate the GUID in ExMapTable first.\r | |
998 | //\r | |
fc547e08 | 999 | for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r |
1000 | if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r | |
80408db0 | 1001 | Found = TRUE;\r |
1002 | break;\r | |
1003 | }\r | |
1004 | }\r | |
1005 | \r | |
1006 | if (Found) {\r | |
1007 | if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r | |
fc547e08 | 1008 | *TokenNumber = ExMapTable[Index].ExTokenNumber;\r |
80408db0 | 1009 | return EFI_SUCCESS;\r |
1010 | }\r | |
1011 | \r | |
fc547e08 | 1012 | for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r |
1013 | if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {\r | |
1014 | Index++;\r | |
1015 | if (Index == PEI_EXMAPPING_TABLE_SIZE) {\r | |
80408db0 | 1016 | //\r |
1017 | // Exceed the length of ExMap Table\r | |
1018 | //\r | |
1019 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
1020 | return EFI_SUCCESS;\r | |
1021 | }\r | |
fc547e08 | 1022 | if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r |
1023 | *TokenNumber = ExMapTable[Index].ExTokenNumber;\r | |
80408db0 | 1024 | return EFI_SUCCESS;\r |
1025 | } else {\r | |
1026 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
1027 | return EFI_SUCCESS;\r | |
1028 | }\r | |
1029 | }\r | |
1030 | }\r | |
1031 | return EFI_NOT_FOUND;\r | |
1032 | }\r | |
1033 | }\r | |
1034 | \r | |
1035 | return EFI_NOT_FOUND;\r | |
1036 | }\r | |
1037 | \r | |
fc547e08 | 1038 | /**\r |
1039 | Retrieves the next valid PCD token namespace for a given namespace.\r | |
1040 | \r | |
1041 | @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates \r | |
1042 | a known token namespace from which the search will start. On output, \r | |
1043 | it designates the next valid token namespace on the platform. If the input \r | |
1044 | token namespace does not exist on the platform, an error is returned and \r | |
1045 | the value of *Guid is undefined. If *Guid is NULL, then the GUID of the \r | |
1046 | first token space of the current platform is assigned to *Guid the function \r | |
1047 | return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in \r | |
1048 | the platform other than the default (NULL) tokennamespace, *Guid is unchanged \r | |
1049 | and the function return EFI_SUCCESS. If this input token namespace is the last \r | |
1050 | namespace on the platform, *Guid will be assigned to NULL and the function return \r | |
1051 | EFI_SUCCESS. \r | |
1052 | \r | |
1053 | @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid. \r | |
1054 | Or the input token space Guid is already the last valid token space Guid \r | |
1055 | in the PCD database. In the later case, *Guid is updated with the value of NULL.\r | |
1056 | @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.\r | |
80408db0 | 1057 | \r |
fc547e08 | 1058 | **/\r |
80408db0 | 1059 | EFI_STATUS\r |
1060 | EFIAPI\r | |
1061 | PeiPcdGetNextTokenSpace (\r | |
1062 | IN OUT CONST EFI_GUID **Guid\r | |
1063 | )\r | |
1064 | {\r | |
1065 | UINTN GuidTableIdx;\r | |
1066 | EFI_GUID *MatchGuid;\r | |
1067 | PEI_PCD_DATABASE *PeiPcdDb;\r | |
1068 | DYNAMICEX_MAPPING *ExMapTable;\r | |
fc547e08 | 1069 | UINTN Index;\r |
80408db0 | 1070 | BOOLEAN Found;\r |
1071 | BOOLEAN PeiExMapTableEmpty;\r | |
1072 | \r | |
f806dd27 | 1073 | if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {\r |
80408db0 | 1074 | return EFI_UNSUPPORTED;\r |
1075 | }\r | |
1076 | \r | |
1077 | ASSERT (Guid != NULL);\r | |
1078 | \r | |
1079 | PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r | |
1080 | \r | |
1081 | if (PeiExMapTableEmpty) {\r | |
1082 | if (*Guid != NULL) {\r | |
1083 | return EFI_NOT_FOUND;\r | |
1084 | } else {\r | |
1085 | return EFI_SUCCESS;\r | |
1086 | }\r | |
1087 | }\r | |
1088 | \r | |
1089 | //\r | |
1090 | // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r | |
1091 | // 1) ExGuid\r | |
1092 | // 2) ExTokenNumber\r | |
1093 | //\r | |
1094 | PeiPcdDb = GetPcdDatabase ();\r | |
1095 | \r | |
1096 | ExMapTable = PeiPcdDb->Init.ExMapTable;\r | |
1097 | \r | |
1098 | if (*Guid == NULL) {\r | |
1099 | //\r | |
1100 | // return the first Token Space Guid.\r | |
1101 | //\r | |
1102 | *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[0].ExGuidIndex];\r | |
1103 | return EFI_SUCCESS;\r | |
1104 | }\r | |
1105 | \r | |
1106 | MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), *Guid);\r | |
1107 | \r | |
1108 | if (MatchGuid == NULL) {\r | |
1109 | return EFI_NOT_FOUND;\r | |
1110 | }\r | |
1111 | \r | |
1112 | GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r | |
1113 | \r | |
1114 | Found = FALSE;\r | |
fc547e08 | 1115 | for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r |
1116 | if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r | |
80408db0 | 1117 | Found = TRUE;\r |
1118 | break;\r | |
1119 | }\r | |
1120 | }\r | |
1121 | \r | |
1122 | if (Found) {\r | |
fc547e08 | 1123 | Index++;\r |
1124 | for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++ ) {\r | |
1125 | if (ExMapTable[Index].ExGuidIndex != GuidTableIdx ) {\r | |
1126 | *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[Index].ExGuidIndex];\r | |
80408db0 | 1127 | return EFI_SUCCESS;\r |
1128 | }\r | |
1129 | }\r | |
1130 | *Guid = NULL;\r | |
1131 | return EFI_SUCCESS;\r | |
1132 | }\r | |
1133 | \r | |
1134 | return EFI_NOT_FOUND;\r | |
1135 | \r | |
1136 | }\r | |
1137 | \r | |
fc547e08 | 1138 | /**\r |
1139 | Get PCD value's size for POINTER type PCD.\r | |
1140 | \r | |
1141 | The POINTER type PCD's value will be stored into a buffer in specificed size.\r | |
1142 | The max size of this PCD's value is described in PCD's definition in DEC file.\r | |
1143 | \r | |
1144 | @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r | |
3fd8027e | 1145 | @param MaxSize Maximum size of PCD's value\r |
fc547e08 | 1146 | @param Database Pcd database in PEI phase.\r |
1147 | \r | |
1148 | @return PCD value's size for POINTER type PCD.\r | |
1149 | \r | |
1150 | **/\r | |
80408db0 | 1151 | UINTN\r |
1152 | GetPtrTypeSize (\r | |
1153 | IN UINTN LocalTokenNumberTableIdx,\r | |
1154 | OUT UINTN *MaxSize,\r | |
1155 | IN PEI_PCD_DATABASE *Database\r | |
1156 | )\r | |
1157 | {\r | |
1158 | INTN SizeTableIdx;\r | |
1159 | UINTN LocalTokenNumber;\r | |
1160 | SKU_ID *SkuIdTable;\r | |
1161 | SIZE_INFO *SizeTable;\r | |
fc547e08 | 1162 | UINTN Index;\r |
80408db0 | 1163 | \r |
1164 | SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r | |
1165 | \r | |
1166 | LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];\r | |
1167 | \r | |
1168 | ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);\r | |
1169 | \r | |
1170 | SizeTable = Database->Init.SizeTable;\r | |
1171 | \r | |
1172 | *MaxSize = SizeTable[SizeTableIdx];\r | |
1173 | //\r | |
1174 | // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type \r | |
1175 | // PCD entry.\r | |
1176 | //\r | |
fc547e08 | 1177 | if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r |
80408db0 | 1178 | //\r |
1179 | // We have only one entry for VPD enabled PCD entry:\r | |
1180 | // 1) MAX Size.\r | |
1181 | // We consider current size is equal to MAX size.\r | |
1182 | //\r | |
1183 | return *MaxSize;\r | |
1184 | } else {\r | |
1185 | if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {\r | |
1186 | //\r | |
1187 | // We have only two entry for Non-Sku enabled PCD entry:\r | |
1188 | // 1) MAX SIZE\r | |
1189 | // 2) Current Size\r | |
1190 | //\r | |
1191 | return SizeTable[SizeTableIdx + 1];\r | |
1192 | } else {\r | |
1193 | //\r | |
1194 | // We have these entry for SKU enabled PCD entry\r | |
1195 | // 1) MAX SIZE\r | |
1196 | // 2) Current Size for each SKU_ID (It is equal to MaxSku).\r | |
1197 | //\r | |
1198 | SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r | |
fc547e08 | 1199 | for (Index = 0; Index < SkuIdTable[0]; Index++) {\r |
1200 | if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {\r | |
1201 | return SizeTable[SizeTableIdx + 1 + Index];\r | |
80408db0 | 1202 | }\r |
1203 | }\r | |
1204 | return SizeTable[SizeTableIdx + 1];\r | |
1205 | }\r | |
1206 | }\r | |
1207 | }\r | |
1208 | \r | |
fc547e08 | 1209 | /**\r |
1210 | Set PCD value's size for POINTER type PCD.\r | |
1211 | \r | |
1212 | The POINTER type PCD's value will be stored into a buffer in specificed size.\r | |
1213 | The max size of this PCD's value is described in PCD's definition in DEC file.\r | |
1214 | \r | |
1215 | @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r | |
3fd8027e | 1216 | @param CurrentSize Maximum size of PCD's value\r |
fc547e08 | 1217 | @param Database Pcd database in PEI phase.\r |
80408db0 | 1218 | \r |
3fd8027e | 1219 | @retval TRUE Success to set PCD's value size, which is not exceed maximum size\r |
1220 | @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size\r | |
80408db0 | 1221 | \r |
fc547e08 | 1222 | **/\r |
80408db0 | 1223 | BOOLEAN\r |
1224 | SetPtrTypeSize (\r | |
1225 | IN UINTN LocalTokenNumberTableIdx,\r | |
1226 | IN OUT UINTN *CurrentSize,\r | |
1227 | IN PEI_PCD_DATABASE *Database\r | |
1228 | )\r | |
1229 | {\r | |
1230 | INTN SizeTableIdx;\r | |
1231 | UINTN LocalTokenNumber;\r | |
1232 | SKU_ID *SkuIdTable;\r | |
1233 | SIZE_INFO *SizeTable;\r | |
fc547e08 | 1234 | UINTN Index;\r |
80408db0 | 1235 | UINTN MaxSize;\r |
1236 | \r | |
1237 | SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r | |
1238 | \r | |
1239 | LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];\r | |
1240 | \r | |
1241 | ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);\r | |
1242 | \r | |
1243 | SizeTable = Database->Init.SizeTable;\r | |
1244 | \r | |
1245 | MaxSize = SizeTable[SizeTableIdx];\r | |
1246 | //\r | |
1247 | // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type \r | |
1248 | // PCD entry.\r | |
1249 | //\r | |
fc547e08 | 1250 | if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r |
80408db0 | 1251 | //\r |
1252 | // We shouldn't come here as we don't support SET for VPD\r | |
1253 | //\r | |
1254 | ASSERT (FALSE);\r | |
1255 | return FALSE;\r | |
1256 | } else {\r | |
1257 | if ((*CurrentSize > MaxSize) ||\r | |
1258 | (*CurrentSize == MAX_ADDRESS)) {\r | |
1259 | *CurrentSize = MaxSize;\r | |
1260 | return FALSE;\r | |
5944a83b | 1261 | }\r |
80408db0 | 1262 | \r |
1263 | if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {\r | |
1264 | //\r | |
1265 | // We have only two entry for Non-Sku enabled PCD entry:\r | |
1266 | // 1) MAX SIZE\r | |
1267 | // 2) Current Size\r | |
1268 | //\r | |
1269 | SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;\r | |
1270 | return TRUE;\r | |
1271 | } else {\r | |
1272 | //\r | |
1273 | // We have these entry for SKU enabled PCD entry\r | |
1274 | // 1) MAX SIZE\r | |
1275 | // 2) Current Size for each SKU_ID (It is equal to MaxSku).\r | |
1276 | //\r | |
1277 | SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r | |
fc547e08 | 1278 | for (Index = 0; Index < SkuIdTable[0]; Index++) {\r |
1279 | if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {\r | |
1280 | SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;\r | |
80408db0 | 1281 | return TRUE;\r |
1282 | }\r | |
1283 | }\r | |
1284 | SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;\r | |
1285 | return TRUE;\r | |
1286 | }\r | |
1287 | }\r | |
1288 | \r | |
1289 | }\r |