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