MdePkg PcdLib: Follow the comment of LibPcdGetNextToken to ASSERT when an invalid...
[mirror_edk2.git] / MdePkg / Library / PeiPcdLib / PeiPcdLib.c
CommitLineData
e386b444 1/** @file\r
2Implementation of PcdLib class library for PEI phase.\r
3\r
419db80b 4Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
19388d29 5This program and the accompanying materials \r
e386b444 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
13\r
e386b444 14**/\r
15\r
16\r
17\r
c892d846 18\r
c7d265a9 19#include <PiPei.h>\r
c892d846 20\r
c7d265a9 21#include <Ppi/Pcd.h>\r
ec735bb2 22#include <Ppi/PiPcd.h>\r
96d6d004
SZ
23#include <Ppi/PcdInfo.h>\r
24#include <Ppi/PiPcdInfo.h>\r
c892d846 25\r
1c280088 26#include <Library/PeiServicesLib.h>\r
c7d265a9 27#include <Library/PcdLib.h>\r
28#include <Library/DebugLib.h>\r
c7d265a9 29#include <Library/BaseMemoryLib.h>\r
e386b444 30\r
31/**\r
a72bd1ec 32 Retrieve the PCD_PPI pointer.\r
e386b444 33\r
a72bd1ec 34 This function is to locate PCD_PPI PPI via PeiService. \r
35 If fail to locate PCD_PPI, then ASSERT_EFI_ERROR().\r
36 \r
e386b444 37 @retval PCD_PPI * The pointer to the PCD_PPI.\r
38\r
39**/\r
e386b444 40PCD_PPI *\r
a72bd1ec 41GetPcdPpiPointer (\r
e386b444 42 VOID\r
43 ) \r
44{\r
45 EFI_STATUS Status;\r
46 PCD_PPI *PcdPpi;\r
1c280088 47 \r
48 Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);\r
e386b444 49 ASSERT_EFI_ERROR (Status);\r
50\r
51 return PcdPpi;\r
52}\r
53\r
ec735bb2 54/**\r
55 Retrieve the pointer of EFI_PEI_PCD_PPI defined in PI 1.2 Vol 3.\r
56\r
57 This function is to locate EFI_PEI_PCD_PPI PPI via PeiService. \r
58 If fail to locate EFI_PEI_PCD_PPI, then ASSERT_EFI_ERROR().\r
59 \r
60 @retval EFI_PEI_PCD_PPI * The pointer to the EFI_PEI_PCD_PPI.\r
61\r
62**/\r
63EFI_PEI_PCD_PPI *\r
64GetPiPcdPpiPointer (\r
65 VOID\r
66 )\r
67{\r
68 EFI_STATUS Status;\r
69 EFI_PEI_PCD_PPI *PiPcdPpi;\r
70 \r
71 Status = PeiServicesLocatePpi (&gEfiPeiPcdPpiGuid, 0, NULL, (VOID **)&PiPcdPpi);\r
72 ASSERT_EFI_ERROR (Status);\r
73 \r
74 return PiPcdPpi;\r
75} \r
96d6d004
SZ
76\r
77/**\r
78 Retrieve the GET_PCD_INFO_PPI pointer.\r
79\r
80 This function is to locate GET_PCD_INFO_PPI PPI via PeiService. \r
81 If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().\r
82\r
83 @retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI.\r
84\r
85**/\r
86GET_PCD_INFO_PPI *\r
87GetPcdInfoPpiPointer (\r
88 VOID\r
89 ) \r
90{\r
91 EFI_STATUS Status;\r
92 GET_PCD_INFO_PPI *PcdInfoPpi;\r
93 \r
94 Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);\r
95 ASSERT_EFI_ERROR (Status);\r
96\r
97 return PcdInfoPpi;\r
98}\r
99\r
100/**\r
101 Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3.\r
102\r
103 This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService. \r
104 If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().\r
105\r
106 @retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI.\r
107\r
108**/\r
109EFI_GET_PCD_INFO_PPI *\r
110GetPiPcdInfoPpiPointer (\r
111 VOID\r
112 )\r
113{\r
114 EFI_STATUS Status;\r
115 EFI_GET_PCD_INFO_PPI *PiPcdInfoPpi;\r
ec735bb2 116 \r
96d6d004
SZ
117 Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);\r
118 ASSERT_EFI_ERROR (Status);\r
119 \r
120 return PiPcdInfoPpi;\r
121} \r
122\r
e386b444 123/**\r
0c3437e0 124 This function provides a means by which SKU support can be established in the PCD infrastructure.\r
125\r
e386b444 126 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
c00bdbb1 127 If SkuId >= PCD_MAX_SKU_ID, then ASSERT(). \r
0c3437e0 128\r
58380e9c 129 @param SkuId The SKU value that will be used when the PCD service retrieves \r
130 and sets values associated with a PCD token.\r
e386b444 131\r
c00bdbb1 132 @return Return the SKU ID that just be set.\r
e386b444 133\r
134**/\r
135UINTN\r
136EFIAPI\r
137LibPcdSetSku (\r
0c3437e0 138 IN UINTN SkuId\r
e386b444 139 )\r
140{\r
141\r
a72bd1ec 142 ASSERT (SkuId < PCD_MAX_SKU_ID);\r
e386b444 143\r
ec735bb2 144 GetPiPcdPpiPointer()->SetSku (SkuId);\r
145 \r
e386b444 146 return SkuId;\r
147}\r
148\r
149\r
150\r
151/**\r
0c3437e0 152 This function provides a means by which to retrieve a value for a given PCD token.\r
153 \r
e386b444 154 Returns the 8-bit value for the token specified by TokenNumber. \r
155\r
63e4dba9 156 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 157\r
f73e0ad2 158 @return Returns the 8-bit value for the token specified by TokenNumber. \r
e386b444 159\r
160**/\r
161UINT8\r
162EFIAPI\r
163LibPcdGet8 (\r
0c3437e0 164 IN UINTN TokenNumber\r
e386b444 165 )\r
166{\r
a72bd1ec 167 return (GetPcdPpiPointer ())->Get8 (TokenNumber);\r
e386b444 168}\r
169\r
170\r
171\r
172/**\r
0c3437e0 173 This function provides a means by which to retrieve a value for a given PCD token.\r
174 \r
e386b444 175 Returns the 16-bit value for the token specified by TokenNumber. \r
176\r
0c3437e0 177 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 178\r
f73e0ad2 179 @return Returns the 16-bit value for the token specified by TokenNumber. \r
e386b444 180\r
181**/\r
182UINT16\r
183EFIAPI\r
184LibPcdGet16 (\r
0c3437e0 185 IN UINTN TokenNumber\r
e386b444 186 )\r
187{\r
a72bd1ec 188 return (GetPcdPpiPointer ())->Get16 (TokenNumber);\r
e386b444 189}\r
190\r
191\r
192\r
193/**\r
0c3437e0 194 This function provides a means by which to retrieve a value for a given PCD token.\r
195 \r
e386b444 196 Returns the 32-bit value for the token specified by TokenNumber. \r
197\r
198 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
199\r
f73e0ad2 200 @return Returns the 32-bit value for the token specified by TokenNumber.\r
e386b444 201\r
202**/\r
203UINT32\r
204EFIAPI\r
205LibPcdGet32 (\r
0c3437e0 206 IN UINTN TokenNumber\r
e386b444 207 )\r
208{\r
a72bd1ec 209 return (GetPcdPpiPointer ())->Get32 (TokenNumber);\r
e386b444 210}\r
211\r
212\r
213\r
214/**\r
0c3437e0 215 This function provides a means by which to retrieve a value for a given PCD token.\r
216 \r
e386b444 217 Returns the 64-bit value for the token specified by TokenNumber.\r
218\r
219 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
220\r
f73e0ad2 221 @return Returns the 64-bit value for the token specified by TokenNumber.\r
e386b444 222\r
223**/\r
224UINT64\r
225EFIAPI\r
226LibPcdGet64 (\r
0c3437e0 227 IN UINTN TokenNumber\r
e386b444 228 )\r
229{\r
a72bd1ec 230 return (GetPcdPpiPointer ())->Get64 (TokenNumber);\r
e386b444 231}\r
232\r
233\r
234\r
235/**\r
0c3437e0 236 This function provides a means by which to retrieve a value for a given PCD token.\r
237 \r
e386b444 238 Returns the pointer to the buffer of the token specified by TokenNumber.\r
239\r
240 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
241\r
f73e0ad2 242 @return Returns the pointer to the token specified by TokenNumber.\r
e386b444 243\r
244**/\r
245VOID *\r
246EFIAPI\r
247LibPcdGetPtr (\r
0c3437e0 248 IN UINTN TokenNumber\r
e386b444 249 )\r
250{\r
a72bd1ec 251 return (GetPcdPpiPointer ())->GetPtr (TokenNumber);\r
e386b444 252}\r
253\r
254\r
255\r
256/**\r
0c3437e0 257 This function provides a means by which to retrieve a value for a given PCD token.\r
258 \r
e386b444 259 Returns the Boolean value of the token specified by TokenNumber. \r
260\r
261 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
262\r
f73e0ad2 263 @return Returns the Boolean value of the token specified by TokenNumber. \r
e386b444 264\r
265**/\r
266BOOLEAN \r
267EFIAPI\r
268LibPcdGetBool (\r
0c3437e0 269 IN UINTN TokenNumber\r
e386b444 270 )\r
271{\r
a72bd1ec 272 return (GetPcdPpiPointer ())->GetBool (TokenNumber);\r
e386b444 273}\r
274\r
275\r
276\r
277/**\r
0c3437e0 278 This function provides a means by which to retrieve the size of a given PCD token.\r
e386b444 279\r
280 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
281\r
f73e0ad2 282 @return Returns the size of the token specified by TokenNumber. \r
e386b444 283\r
284**/\r
285UINTN\r
286EFIAPI\r
287LibPcdGetSize (\r
0c3437e0 288 IN UINTN TokenNumber\r
e386b444 289 )\r
290{\r
a72bd1ec 291 return (GetPcdPpiPointer ())->GetSize (TokenNumber);\r
e386b444 292}\r
293\r
294\r
295\r
296/**\r
0c3437e0 297 This function provides a means by which to retrieve a value for a given PCD token.\r
298 \r
e386b444 299 Returns the 8-bit value for the token specified by TokenNumber and Guid.\r
0c3437e0 300 \r
e386b444 301 If Guid is NULL, then ASSERT(). \r
302\r
2fc59a00 303 @param[in] Guid The pointer to a 128-bit unique value that designates \r
c00bdbb1 304 which namespace to retrieve a value from.\r
305 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 306\r
f73e0ad2 307 @return Return the UINT8.\r
e386b444 308\r
309**/\r
310UINT8\r
311EFIAPI\r
312LibPcdGetEx8 (\r
313 IN CONST GUID *Guid,\r
314 IN UINTN TokenNumber\r
315 )\r
316{\r
e386b444 317 ASSERT (Guid != NULL);\r
318\r
9dbad162 319 return (GetPiPcdPpiPointer ())->Get8 (Guid, TokenNumber);\r
e386b444 320}\r
321\r
322\r
323\r
324/**\r
0c3437e0 325 This function provides a means by which to retrieve a value for a given PCD token.\r
326\r
e386b444 327 Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
0c3437e0 328 \r
e386b444 329 If Guid is NULL, then ASSERT(). \r
330\r
2fc59a00 331 @param[in] Guid The pointer to a 128-bit unique value that designates \r
c00bdbb1 332 which namespace to retrieve a value from.\r
333 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 334\r
f73e0ad2 335 @return Return the UINT16.\r
e386b444 336\r
337**/\r
338UINT16\r
339EFIAPI\r
340LibPcdGetEx16 (\r
341 IN CONST GUID *Guid,\r
342 IN UINTN TokenNumber\r
343 )\r
344{\r
e386b444 345\r
346 ASSERT (Guid != NULL);\r
347\r
9dbad162 348 return (GetPiPcdPpiPointer ())->Get16 (Guid, TokenNumber);\r
e386b444 349}\r
350\r
351\r
352\r
353/**\r
354 Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
355 If Guid is NULL, then ASSERT(). \r
356\r
2fc59a00 357 @param[in] Guid The pointer to a 128-bit unique value that designates \r
c00bdbb1 358 which namespace to retrieve a value from.\r
359 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 360\r
f73e0ad2 361 @return Return the UINT32.\r
e386b444 362\r
363**/\r
364UINT32\r
365EFIAPI\r
366LibPcdGetEx32 (\r
367 IN CONST GUID *Guid,\r
368 IN UINTN TokenNumber\r
369 )\r
370{\r
e386b444 371 ASSERT (Guid != NULL);\r
372\r
9dbad162 373 return (GetPiPcdPpiPointer ())->Get32 (Guid, TokenNumber);\r
e386b444 374}\r
375\r
376\r
377\r
378\r
379/**\r
0c3437e0 380 This function provides a means by which to retrieve a value for a given PCD token.\r
381 \r
e386b444 382 Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
0c3437e0 383 \r
e386b444 384 If Guid is NULL, then ASSERT(). \r
385\r
2fc59a00 386 @param[in] Guid The pointer to a 128-bit unique value that designates \r
0c3437e0 387 which namespace to retrieve a value from.\r
388 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 389\r
f73e0ad2 390 @return Return the UINT64.\r
e386b444 391\r
392**/\r
393UINT64\r
394EFIAPI\r
395LibPcdGetEx64 (\r
396 IN CONST GUID *Guid,\r
397 IN UINTN TokenNumber\r
398 )\r
399{\r
e386b444 400 ASSERT (Guid != NULL);\r
9dbad162 401 return (GetPiPcdPpiPointer ())->Get64 (Guid, TokenNumber);\r
e386b444 402}\r
403\r
404\r
405\r
406/**\r
0c3437e0 407 This function provides a means by which to retrieve a value for a given PCD token.\r
408 \r
409 Returns the pointer to the buffer of token specified by TokenNumber and Guid.\r
410 \r
e386b444 411 If Guid is NULL, then ASSERT(). \r
412\r
2fc59a00 413 @param[in] Guid The pointer to a 128-bit unique value that designates \r
0c3437e0 414 which namespace to retrieve a value from.\r
415 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 416\r
f73e0ad2 417 @return Return the VOID* pointer.\r
e386b444 418\r
419**/\r
420VOID *\r
421EFIAPI\r
422LibPcdGetExPtr (\r
423 IN CONST GUID *Guid,\r
424 IN UINTN TokenNumber\r
425 )\r
426{\r
e386b444 427 ASSERT (Guid != NULL);\r
428\r
9dbad162 429 return (GetPiPcdPpiPointer ())->GetPtr (Guid, TokenNumber);\r
e386b444 430}\r
431\r
432\r
433\r
434/**\r
0c3437e0 435 This function provides a means by which to retrieve a value for a given PCD token.\r
436 \r
e386b444 437 Returns the Boolean value of the token specified by TokenNumber and Guid. \r
0c3437e0 438 \r
e386b444 439 If Guid is NULL, then ASSERT(). \r
440\r
2fc59a00 441 @param[in] Guid The pointer to a 128-bit unique value that designates \r
0c3437e0 442 which namespace to retrieve a value from.\r
443 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 444\r
f73e0ad2 445 @return Return the BOOLEAN.\r
e386b444 446\r
447**/\r
448BOOLEAN\r
449EFIAPI\r
450LibPcdGetExBool (\r
451 IN CONST GUID *Guid,\r
452 IN UINTN TokenNumber\r
453 )\r
454{\r
e386b444 455 ASSERT (Guid != NULL);\r
9dbad162 456 return (GetPiPcdPpiPointer ())->GetBool (Guid, TokenNumber);\r
e386b444 457}\r
458\r
459\r
460\r
461/**\r
0c3437e0 462 This function provides a means by which to retrieve the size of a given PCD token.\r
463 \r
e386b444 464 Returns the size of the token specified by TokenNumber and Guid. \r
0c3437e0 465 \r
e386b444 466 If Guid is NULL, then ASSERT(). \r
467\r
2fc59a00 468 @param[in] Guid The pointer to a 128-bit unique value that designates \r
0c3437e0 469 which namespace to retrieve a value from.\r
470 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 471\r
f73e0ad2 472 @return Return the size.\r
e386b444 473\r
474**/\r
475UINTN\r
476EFIAPI\r
477LibPcdGetExSize (\r
478 IN CONST GUID *Guid,\r
479 IN UINTN TokenNumber\r
480 )\r
481{\r
e386b444 482 ASSERT (Guid != NULL);\r
9dbad162 483 return (GetPiPcdPpiPointer ())->GetSize (Guid, TokenNumber);\r
e386b444 484}\r
485\r
486\r
487\r
488/**\r
0c3437e0 489 This function provides a means by which to set a value for a given PCD token.\r
490 \r
e386b444 491 Sets the 8-bit value for the token specified by TokenNumber \r
492 to the value specified by Value. Value is returned.\r
493 \r
0c3437e0 494 @param[in] TokenNumber The PCD token number to set a current value for.\r
495 @param[in] Value The 8-bit value to set.\r
e386b444 496\r
58380e9c 497 @return Return the value that was set.\r
e386b444 498\r
499**/\r
500UINT8\r
501EFIAPI\r
502LibPcdSet8 (\r
503 IN UINTN TokenNumber,\r
504 IN UINT8 Value\r
505 )\r
506{\r
507 EFI_STATUS Status;\r
e386b444 508\r
a72bd1ec 509 Status = (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);\r
e386b444 510\r
511 ASSERT_EFI_ERROR (Status);\r
512 \r
513 return Value;\r
514}\r
515\r
516\r
517\r
518/**\r
0c3437e0 519 This function provides a means by which to set a value for a given PCD token.\r
520 \r
e386b444 521 Sets the 16-bit value for the token specified by TokenNumber \r
522 to the value specified by Value. Value is returned.\r
523 \r
0c3437e0 524 @param[in] TokenNumber The PCD token number to set a current value for.\r
525 @param[in] Value The 16-bit value to set.\r
e386b444 526\r
58380e9c 527 @return Return the value that was set.\r
e386b444 528\r
529**/\r
530UINT16\r
531EFIAPI\r
532LibPcdSet16 (\r
533 IN UINTN TokenNumber,\r
534 IN UINT16 Value\r
535 )\r
536{\r
537 EFI_STATUS Status;\r
e386b444 538\r
a72bd1ec 539 Status = (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);\r
e386b444 540\r
541 ASSERT_EFI_ERROR (Status);\r
542 \r
543 return Value;\r
544}\r
545\r
546\r
547\r
548/**\r
0c3437e0 549 This function provides a means by which to set a value for a given PCD token.\r
550 \r
e386b444 551 Sets the 32-bit value for the token specified by TokenNumber \r
552 to the value specified by Value. Value is returned.\r
553 \r
0c3437e0 554 @param[in] TokenNumber The PCD token number to set a current value for.\r
555 @param[in] Value The 32-bit value to set.\r
e386b444 556\r
58380e9c 557 @return Return the value that was set.\r
e386b444 558\r
559**/\r
560UINT32\r
561EFIAPI\r
562LibPcdSet32 (\r
563 IN UINTN TokenNumber,\r
0c3437e0 564 IN UINT32 Value\r
e386b444 565 )\r
566{\r
567 EFI_STATUS Status;\r
e386b444 568\r
a72bd1ec 569 Status = (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);\r
e386b444 570\r
571 ASSERT_EFI_ERROR (Status);\r
572\r
573 return Value;\r
574}\r
575\r
576\r
577\r
578/**\r
0c3437e0 579 This function provides a means by which to set a value for a given PCD token.\r
580 \r
e386b444 581 Sets the 64-bit value for the token specified by TokenNumber \r
582 to the value specified by Value. Value is returned.\r
583 \r
0c3437e0 584 @param[in] TokenNumber The PCD token number to set a current value for.\r
585 @param[in] Value The 64-bit value to set.\r
e386b444 586\r
58380e9c 587 @return Return the value that was set.\r
e386b444 588\r
589**/\r
590UINT64\r
591EFIAPI\r
592LibPcdSet64 (\r
593 IN UINTN TokenNumber,\r
0c3437e0 594 IN UINT64 Value\r
e386b444 595 )\r
596{\r
597 EFI_STATUS Status;\r
e386b444 598\r
a72bd1ec 599 Status = (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);\r
e386b444 600\r
601 ASSERT_EFI_ERROR (Status);\r
602\r
603 return Value;\r
604}\r
605\r
606\r
607\r
608/**\r
0c3437e0 609 This function provides a means by which to set a value for a given PCD token.\r
e386b444 610 \r
0c3437e0 611 Sets a buffer for the token specified by TokenNumber to the value \r
612 specified by Buffer and SizeOfBuffer. Buffer is returned. \r
613 If SizeOfBuffer is greater than the maximum size support by TokenNumber, \r
614 then set SizeOfBuffer to the maximum size supported by TokenNumber and \r
615 return NULL to indicate that the set operation was not actually performed. \r
616\r
617 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the \r
618 maximum size supported by TokenName and NULL must be returned.\r
e386b444 619 \r
0c3437e0 620 If SizeOfBuffer is NULL, then ASSERT().\r
a72bd1ec 621 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 622 \r
0c3437e0 623 @param[in] TokenNumber The PCD token number to set a current value for.\r
624 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
625 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 626\r
f73e0ad2 627 @return Return the pointer for the buffer been set.\r
e386b444 628\r
629**/\r
630VOID *\r
631EFIAPI\r
632LibPcdSetPtr (\r
0c3437e0 633 IN UINTN TokenNumber,\r
634 IN OUT UINTN *SizeOfBuffer,\r
635 IN CONST VOID *Buffer\r
e386b444 636 )\r
637{\r
638 EFI_STATUS Status;\r
e386b444 639\r
640 ASSERT (SizeOfBuffer != NULL);\r
641\r
642 if (*SizeOfBuffer > 0) {\r
643 ASSERT (Buffer != NULL);\r
644 }\r
e386b444 645 \r
b52f6a1a 646 Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
e386b444 647\r
648 if (EFI_ERROR (Status)) {\r
649 return NULL;\r
650 }\r
651\r
b52f6a1a 652 return (VOID *) Buffer;\r
e386b444 653}\r
654\r
655\r
656\r
657/**\r
0c3437e0 658 This function provides a means by which to set a value for a given PCD token.\r
659 \r
e386b444 660 Sets the Boolean value for the token specified by TokenNumber \r
661 to the value specified by Value. Value is returned.\r
662 \r
0c3437e0 663 @param[in] TokenNumber The PCD token number to set a current value for.\r
664 @param[in] Value The boolean value to set.\r
e386b444 665\r
58380e9c 666 @return Return the value that was set.\r
e386b444 667\r
668**/\r
669BOOLEAN\r
670EFIAPI\r
671LibPcdSetBool (\r
672 IN UINTN TokenNumber,\r
673 IN BOOLEAN Value\r
674 )\r
675{\r
676 EFI_STATUS Status;\r
e386b444 677\r
a72bd1ec 678 Status = (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);\r
e386b444 679\r
680 ASSERT_EFI_ERROR (Status);\r
681\r
682 return Value;\r
683}\r
684\r
685\r
686\r
687/**\r
0c3437e0 688 This function provides a means by which to set a value for a given PCD token.\r
689 \r
e386b444 690 Sets the 8-bit value for the token specified by TokenNumber and \r
691 Guid to the value specified by Value. Value is returned.\r
0c3437e0 692 \r
e386b444 693 If Guid is NULL, then ASSERT().\r
694 \r
2fc59a00 695 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 696 designates which namespace to set a value from.\r
697 @param[in] TokenNumber The PCD token number to set a current value for.\r
698 @param[in] Value The 8-bit value to set.\r
e386b444 699\r
58380e9c 700 @return Return the value that was set.\r
e386b444 701\r
702**/\r
703UINT8\r
704EFIAPI\r
705LibPcdSetEx8 (\r
706 IN CONST GUID *Guid,\r
707 IN UINTN TokenNumber,\r
708 IN UINT8 Value\r
709 )\r
710{\r
711 EFI_STATUS Status;\r
e386b444 712\r
713 ASSERT (Guid != NULL);\r
714\r
9dbad162 715 Status = (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);\r
e386b444 716\r
717 ASSERT_EFI_ERROR (Status);\r
718\r
719 return Value;\r
720}\r
721\r
722\r
723\r
724/**\r
0c3437e0 725 This function provides a means by which to set a value for a given PCD token.\r
726 \r
e386b444 727 Sets the 16-bit value for the token specified by TokenNumber and \r
728 Guid to the value specified by Value. Value is returned.\r
0c3437e0 729 \r
e386b444 730 If Guid is NULL, then ASSERT().\r
731 \r
2fc59a00 732 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 733 designates which namespace to set a value from.\r
734 @param[in] TokenNumber The PCD token number to set a current value for.\r
735 @param[in] Value The 16-bit value to set.\r
e386b444 736\r
58380e9c 737 @return Return the value that was set.\r
e386b444 738\r
739**/\r
740UINT16\r
741EFIAPI\r
742LibPcdSetEx16 (\r
743 IN CONST GUID *Guid,\r
744 IN UINTN TokenNumber,\r
745 IN UINT16 Value\r
746 )\r
747{\r
748 EFI_STATUS Status;\r
e386b444 749 ASSERT (Guid != NULL);\r
9dbad162 750 Status = (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);\r
e386b444 751\r
752 ASSERT_EFI_ERROR (Status);\r
753\r
754 return Value;\r
755}\r
756\r
757\r
758\r
759/**\r
0c3437e0 760 This function provides a means by which to set a value for a given PCD token.\r
761 \r
e386b444 762 Sets the 32-bit value for the token specified by TokenNumber and \r
763 Guid to the value specified by Value. Value is returned.\r
0c3437e0 764 \r
e386b444 765 If Guid is NULL, then ASSERT().\r
766 \r
2fc59a00 767 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 768 designates which namespace to set a value from.\r
769 @param[in] TokenNumber The PCD token number to set a current value for.\r
770 @param[in] Value The 32-bit value to set.\r
e386b444 771\r
58380e9c 772 @return Return the value that was set.\r
e386b444 773\r
774**/\r
775UINT32\r
776EFIAPI\r
777LibPcdSetEx32 (\r
778 IN CONST GUID *Guid,\r
779 IN UINTN TokenNumber,\r
0c3437e0 780 IN UINT32 Value\r
e386b444 781 )\r
782{\r
783 EFI_STATUS Status;\r
e386b444 784\r
a72bd1ec 785 ASSERT (Guid != NULL);\r
e386b444 786\r
9dbad162 787 Status = (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);\r
e386b444 788\r
789 ASSERT_EFI_ERROR (Status);\r
790\r
791 return Value;\r
792}\r
793\r
794\r
795\r
796/**\r
0c3437e0 797 This function provides a means by which to set a value for a given PCD token.\r
798 \r
e386b444 799 Sets the 64-bit value for the token specified by TokenNumber and \r
800 Guid to the value specified by Value. Value is returned.\r
801 If Guid is NULL, then ASSERT().\r
802 \r
2fc59a00 803 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 804 designates which namespace to set a value from.\r
805 @param[in] TokenNumber The PCD token number to set a current value for.\r
806 @param[in] Value The 64-bit value to set.\r
e386b444 807\r
58380e9c 808 @return Return the value that was set.\r
e386b444 809\r
810**/\r
811UINT64\r
812EFIAPI\r
813LibPcdSetEx64 (\r
814 IN CONST GUID *Guid,\r
815 IN UINTN TokenNumber,\r
816 IN UINT64 Value\r
817 )\r
818{\r
819 EFI_STATUS Status;\r
e386b444 820 ASSERT (Guid != NULL);\r
e386b444 821\r
9dbad162 822 Status = (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);\r
e386b444 823\r
824 ASSERT_EFI_ERROR (Status);\r
825\r
826 return Value;\r
827}\r
828\r
829\r
830\r
831/**\r
0c3437e0 832 This function provides a means by which to set a value for a given PCD token.\r
833 \r
e386b444 834 Sets a buffer for the token specified by TokenNumber to the value specified by \r
a72bd1ec 835 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than \r
836 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size \r
e386b444 837 supported by TokenNumber and return NULL to indicate that the set operation \r
838 was not actually performed. \r
839 \r
0c3437e0 840 If Guid is NULL, then ASSERT().\r
841 If SizeOfBuffer is NULL, then ASSERT().\r
a72bd1ec 842 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 843 \r
2fc59a00 844 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 845 designates which namespace to set a value from.\r
846 @param[in] TokenNumber The PCD token number to set a current value for.\r
847 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
848 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 849\r
f73e0ad2 850 @return Return the pinter to the buffer been set.\r
e386b444 851\r
852**/\r
853VOID *\r
854EFIAPI\r
855LibPcdSetExPtr (\r
856 IN CONST GUID *Guid,\r
857 IN UINTN TokenNumber,\r
858 IN OUT UINTN *SizeOfBuffer,\r
859 IN VOID *Buffer\r
860 )\r
861{\r
862 EFI_STATUS Status;\r
a72bd1ec 863 ASSERT (SizeOfBuffer != NULL);\r
e386b444 864 if (*SizeOfBuffer > 0) {\r
865 ASSERT (Buffer != NULL);\r
866 }\r
867 ASSERT (Guid != NULL);\r
e386b444 868\r
9dbad162 869 Status = (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
e386b444 870\r
871 if (EFI_ERROR (Status)) {\r
872 return NULL;\r
873 }\r
874\r
875 return Buffer;\r
876}\r
877\r
878\r
879\r
880/**\r
0c3437e0 881 This function provides a means by which to set a value for a given PCD token.\r
882 \r
e386b444 883 Sets the Boolean value for the token specified by TokenNumber and \r
884 Guid to the value specified by Value. Value is returned.\r
0c3437e0 885 \r
e386b444 886 If Guid is NULL, then ASSERT().\r
887 \r
2fc59a00 888 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 889 designates which namespace to set a value from.\r
890 @param[in] TokenNumber The PCD token number to set a current value for.\r
891 @param[in] Value The Boolean value to set.\r
e386b444 892\r
58380e9c 893 @return Return the value that was set.\r
e386b444 894\r
895**/\r
896BOOLEAN\r
897EFIAPI\r
898LibPcdSetExBool (\r
899 IN CONST GUID *Guid,\r
900 IN UINTN TokenNumber,\r
901 IN BOOLEAN Value\r
902 )\r
903{\r
904 EFI_STATUS Status;\r
e386b444 905\r
906 ASSERT (Guid != NULL);\r
9dbad162 907 Status = (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);\r
e386b444 908\r
909 ASSERT_EFI_ERROR (Status);\r
910\r
911 return Value;\r
912}\r
913\r
914\r
915\r
916/**\r
0c3437e0 917 Set up a notification function that is called when a specified token is set.\r
918 \r
e386b444 919 When the token specified by TokenNumber and Guid is set, \r
920 then notification function specified by NotificationFunction is called. \r
c00bdbb1 921 If Guid is NULL, then the default token space is used.\r
e386b444 922 If NotificationFunction is NULL, then ASSERT().\r
0c3437e0 923\r
58380e9c 924 @param[in] Guid The pointer to a 128-bit unique value that \r
925 designates which namespace to set a value from. \r
926 If NULL, then the default token space is used.\r
c00bdbb1 927 @param[in] TokenNumber The PCD token number to monitor.\r
0c3437e0 928 @param[in] NotificationFunction The function to call when the token \r
929 specified by Guid and TokenNumber is set.\r
e386b444 930\r
e386b444 931**/\r
932VOID\r
933EFIAPI\r
934LibPcdCallbackOnSet (\r
935 IN CONST GUID *Guid, OPTIONAL\r
936 IN UINTN TokenNumber,\r
937 IN PCD_CALLBACK NotificationFunction\r
938 )\r
939{\r
940 EFI_STATUS Status;\r
e386b444 941\r
fc153004 942 ASSERT (NotificationFunction != NULL);\r
943\r
d6b58d32 944 Status = (GetPiPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);\r
e386b444 945\r
946 ASSERT_EFI_ERROR (Status);\r
947\r
948 return;\r
949}\r
950\r
951\r
952\r
953/**\r
954 Disable a notification function that was established with LibPcdCallbackonSet().\r
0c3437e0 955 \r
c00bdbb1 956 Disable a notification function that was previously established with LibPcdCallbackOnSet().\r
e386b444 957 If NotificationFunction is NULL, then ASSERT().\r
0c3437e0 958 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber, \r
959 and NotificationFunction, then ASSERT().\r
a72bd1ec 960 \r
c00bdbb1 961 @param[in] Guid Specify the GUID token space.\r
962 @param[in] TokenNumber Specify the token number.\r
e386b444 963 @param[in] NotificationFunction The callback function to be unregistered.\r
964\r
e386b444 965**/\r
966VOID\r
967EFIAPI\r
968LibPcdCancelCallback (\r
969 IN CONST GUID *Guid, OPTIONAL\r
970 IN UINTN TokenNumber,\r
971 IN PCD_CALLBACK NotificationFunction\r
972 )\r
973{\r
974 EFI_STATUS Status;\r
e386b444 975\r
fc153004 976 ASSERT (NotificationFunction != NULL);\r
977\r
d6b58d32 978 Status = (GetPiPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);\r
e386b444 979\r
980 ASSERT_EFI_ERROR (Status);\r
981\r
982 return;\r
983}\r
984\r
985\r
986\r
987/**\r
0c3437e0 988 Retrieves the next token in a token space.\r
989 \r
e386b444 990 Retrieves the next PCD token number from the token space specified by Guid. \r
991 If Guid is NULL, then the default token space is used. If TokenNumber is 0, \r
992 then the first token number is returned. Otherwise, the token number that \r
993 follows TokenNumber in the token space is returned. If TokenNumber is the last \r
0c3437e0 994 token number in the token space, then 0 is returned. \r
a72bd1ec 995 \r
0c3437e0 996 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().\r
997\r
2fc59a00 998 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace \r
0c3437e0 999 to set a value from. If NULL, then the default token space is used.\r
1000 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD \r
1001 token number.\r
e386b444 1002\r
f73e0ad2 1003 @return The next valid token number.\r
e386b444 1004\r
1005**/\r
0c3437e0 1006UINTN \r
e386b444 1007EFIAPI\r
1008LibPcdGetNextToken (\r
0c3437e0 1009 IN CONST GUID *Guid, OPTIONAL\r
1010 IN UINTN TokenNumber\r
e386b444 1011 )\r
1012{\r
da660118
SZ
1013 EFI_STATUS Status;\r
1014\r
1015 Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);\r
1016 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);\r
e386b444 1017\r
1018 return TokenNumber;\r
1019}\r
1020\r
1021\r
1022/**\r
64735d24 1023 Used to retrieve the list of available PCD token space GUIDs.\r
1024 \r
8f0dd97e 1025 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces\r
1026 in the platform.\r
1027 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.\r
1028 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.\r
e386b444 1029 \r
2fc59a00 1030 @param TokenSpaceGuid The pointer to the a PCD token space GUID\r
e386b444 1031\r
f73e0ad2 1032 @return The next valid token namespace.\r
e386b444 1033\r
1034**/\r
c00bdbb1 1035GUID *\r
e386b444 1036EFIAPI\r
1037LibPcdGetNextTokenSpace (\r
64735d24 1038 IN CONST GUID *TokenSpaceGuid\r
e386b444 1039 )\r
1040{\r
419db80b 1041 (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);\r
e386b444 1042\r
64735d24 1043 return (GUID *) TokenSpaceGuid;\r
e386b444 1044}\r
1045\r
1046\r
1047\r
1048/**\r
9638ba6d 1049 Sets a value of a patchable PCD entry that is type pointer.\r
1050 \r
e386b444 1051 Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
a72bd1ec 1052 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than \r
1053 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return \r
e386b444 1054 NULL to indicate that the set operation was not actually performed. \r
a72bd1ec 1055 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to \r
e386b444 1056 MaximumDatumSize and NULL must be returned.\r
1057 \r
1058 If PatchVariable is NULL, then ASSERT().\r
a72bd1ec 1059 If SizeOfBuffer is NULL, then ASSERT().\r
1060 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 1061\r
1062 @param[in] PatchVariable A pointer to the global variable in a module that is \r
1063 the target of the set operation.\r
1064 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1065 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1066 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
f73e0ad2 1067 \r
9638ba6d 1068 @return Return the pointer to the buffer been set.\r
e386b444 1069\r
1070**/\r
1071VOID *\r
1072EFIAPI\r
1073LibPatchPcdSetPtr (\r
1074 IN VOID *PatchVariable,\r
1075 IN UINTN MaximumDatumSize,\r
1076 IN OUT UINTN *SizeOfBuffer,\r
1077 IN CONST VOID *Buffer\r
1078 )\r
1079{\r
1080 ASSERT (PatchVariable != NULL);\r
1081 ASSERT (SizeOfBuffer != NULL);\r
1082 \r
1083 if (*SizeOfBuffer > 0) {\r
1084 ASSERT (Buffer != NULL);\r
1085 }\r
1086\r
1087 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1088 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1089 *SizeOfBuffer = MaximumDatumSize;\r
1090 return NULL;\r
1091 }\r
1092 \r
1093 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1094 \r
1095 return (VOID *) Buffer;\r
1096}\r
1097\r
96d6d004
SZ
1098/**\r
1099 Retrieve additional information associated with a PCD token.\r
1100\r
1101 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1102 human readable name that is associated with the token.\r
e386b444 1103\r
96d6d004
SZ
1104 If TokenNumber is not in the default token space specified, then ASSERT().\r
1105\r
1106 @param[in] TokenNumber The PCD token number.\r
1107 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1108 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1109**/\r
1110VOID\r
1111EFIAPI\r
1112LibPcdGetInfo (\r
1113 IN UINTN TokenNumber,\r
1114 OUT PCD_INFO *PcdInfo\r
1115 )\r
1116{\r
1117 EFI_STATUS Status;\r
1118\r
1119 Status = GetPcdInfoPpiPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1120 ASSERT_EFI_ERROR (Status);\r
1121}\r
1122\r
1123/**\r
1124 Retrieve additional information associated with a PCD token.\r
1125\r
1126 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1127 human readable name that is associated with the token.\r
1128\r
1129 If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
1130\r
1131 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
1132 @param[in] TokenNumber The PCD token number.\r
1133 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1134 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1135**/\r
1136VOID\r
1137EFIAPI\r
1138LibPcdGetInfoEx (\r
1139 IN CONST GUID *Guid,\r
1140 IN UINTN TokenNumber,\r
1141 OUT PCD_INFO *PcdInfo\r
1142 )\r
1143{\r
1144 EFI_STATUS Status;\r
1145\r
1146 Status = GetPiPcdInfoPpiPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1147 ASSERT_EFI_ERROR (Status);\r
1148}\r
1149\r
1150/**\r
1151 Retrieve the currently set SKU Id.\r
1152\r
1153 If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().\r
1154\r
1155 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
1156 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
1157 Id is returned.\r
1158**/\r
1159UINTN\r
1160EFIAPI\r
1161LibPcdGetSku (\r
1162 VOID\r
1163 )\r
1164{\r
1165 UINTN SkuId;\r
1166\r
1167 SkuId = GetPiPcdInfoPpiPointer()->GetSku ();\r
1168 ASSERT (SkuId < PCD_MAX_SKU_ID);\r
1169\r
1170 return SkuId;\r
1171}\r