]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / PeiPcdLib / PeiPcdLib.c
CommitLineData
e386b444 1/** @file\r
2Implementation of PcdLib class library for PEI phase.\r
3\r
9095d37b 4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
e386b444 6\r
7\r
e386b444 8**/\r
9\r
10\r
11\r
c892d846 12\r
c7d265a9 13#include <PiPei.h>\r
c892d846 14\r
c7d265a9 15#include <Ppi/Pcd.h>\r
ec735bb2 16#include <Ppi/PiPcd.h>\r
96d6d004
SZ
17#include <Ppi/PcdInfo.h>\r
18#include <Ppi/PiPcdInfo.h>\r
c892d846 19\r
1c280088 20#include <Library/PeiServicesLib.h>\r
c7d265a9 21#include <Library/PcdLib.h>\r
22#include <Library/DebugLib.h>\r
c7d265a9 23#include <Library/BaseMemoryLib.h>\r
e386b444 24\r
25/**\r
a72bd1ec 26 Retrieve the PCD_PPI pointer.\r
e386b444 27\r
9095d37b 28 This function is to locate PCD_PPI PPI via PeiService.\r
a72bd1ec 29 If fail to locate PCD_PPI, then ASSERT_EFI_ERROR().\r
9095d37b 30\r
e386b444 31 @retval PCD_PPI * The pointer to the PCD_PPI.\r
32\r
33**/\r
e386b444 34PCD_PPI *\r
a72bd1ec 35GetPcdPpiPointer (\r
e386b444 36 VOID\r
9095d37b 37 )\r
e386b444 38{\r
39 EFI_STATUS Status;\r
40 PCD_PPI *PcdPpi;\r
9095d37b 41\r
1c280088 42 Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);\r
e386b444 43 ASSERT_EFI_ERROR (Status);\r
44\r
45 return PcdPpi;\r
46}\r
47\r
ec735bb2 48/**\r
49 Retrieve the pointer of EFI_PEI_PCD_PPI defined in PI 1.2 Vol 3.\r
50\r
9095d37b 51 This function is to locate EFI_PEI_PCD_PPI PPI via PeiService.\r
ec735bb2 52 If fail to locate EFI_PEI_PCD_PPI, then ASSERT_EFI_ERROR().\r
9095d37b 53\r
ec735bb2 54 @retval EFI_PEI_PCD_PPI * The pointer to the EFI_PEI_PCD_PPI.\r
55\r
56**/\r
57EFI_PEI_PCD_PPI *\r
58GetPiPcdPpiPointer (\r
59 VOID\r
60 )\r
61{\r
62 EFI_STATUS Status;\r
63 EFI_PEI_PCD_PPI *PiPcdPpi;\r
9095d37b 64\r
ec735bb2 65 Status = PeiServicesLocatePpi (&gEfiPeiPcdPpiGuid, 0, NULL, (VOID **)&PiPcdPpi);\r
66 ASSERT_EFI_ERROR (Status);\r
9095d37b 67\r
ec735bb2 68 return PiPcdPpi;\r
9095d37b 69}\r
96d6d004
SZ
70\r
71/**\r
72 Retrieve the GET_PCD_INFO_PPI pointer.\r
73\r
9095d37b 74 This function is to locate GET_PCD_INFO_PPI PPI via PeiService.\r
96d6d004
SZ
75 If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().\r
76\r
77 @retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI.\r
78\r
79**/\r
80GET_PCD_INFO_PPI *\r
81GetPcdInfoPpiPointer (\r
82 VOID\r
9095d37b 83 )\r
96d6d004
SZ
84{\r
85 EFI_STATUS Status;\r
86 GET_PCD_INFO_PPI *PcdInfoPpi;\r
9095d37b 87\r
96d6d004
SZ
88 Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);\r
89 ASSERT_EFI_ERROR (Status);\r
90\r
91 return PcdInfoPpi;\r
92}\r
93\r
94/**\r
95 Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3.\r
96\r
9095d37b 97 This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService.\r
96d6d004
SZ
98 If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().\r
99\r
100 @retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI.\r
101\r
102**/\r
103EFI_GET_PCD_INFO_PPI *\r
104GetPiPcdInfoPpiPointer (\r
105 VOID\r
106 )\r
107{\r
108 EFI_STATUS Status;\r
109 EFI_GET_PCD_INFO_PPI *PiPcdInfoPpi;\r
9095d37b 110\r
96d6d004
SZ
111 Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);\r
112 ASSERT_EFI_ERROR (Status);\r
9095d37b 113\r
96d6d004 114 return PiPcdInfoPpi;\r
9095d37b 115}\r
96d6d004 116\r
e386b444 117/**\r
0c3437e0 118 This function provides a means by which SKU support can be established in the PCD infrastructure.\r
119\r
e386b444 120 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
0c3437e0 121\r
9095d37b 122 @param SkuId The SKU value that will be used when the PCD service retrieves\r
58380e9c 123 and sets values associated with a PCD token.\r
e386b444 124\r
c00bdbb1 125 @return Return the SKU ID that just be set.\r
e386b444 126\r
127**/\r
128UINTN\r
129EFIAPI\r
130LibPcdSetSku (\r
0c3437e0 131 IN UINTN SkuId\r
e386b444 132 )\r
133{\r
ec735bb2 134 GetPiPcdPpiPointer()->SetSku (SkuId);\r
9095d37b 135\r
e386b444 136 return SkuId;\r
137}\r
138\r
139\r
140\r
141/**\r
0c3437e0 142 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b
LG
143\r
144 Returns the 8-bit value for the token specified by TokenNumber.\r
e386b444 145\r
63e4dba9 146 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 147\r
9095d37b 148 @return Returns the 8-bit value for the token specified by TokenNumber.\r
e386b444 149\r
150**/\r
151UINT8\r
152EFIAPI\r
153LibPcdGet8 (\r
0c3437e0 154 IN UINTN TokenNumber\r
e386b444 155 )\r
156{\r
a72bd1ec 157 return (GetPcdPpiPointer ())->Get8 (TokenNumber);\r
e386b444 158}\r
159\r
160\r
161\r
162/**\r
0c3437e0 163 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b
LG
164\r
165 Returns the 16-bit value for the token specified by TokenNumber.\r
e386b444 166\r
0c3437e0 167 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 168\r
9095d37b 169 @return Returns the 16-bit value for the token specified by TokenNumber.\r
e386b444 170\r
171**/\r
172UINT16\r
173EFIAPI\r
174LibPcdGet16 (\r
0c3437e0 175 IN UINTN TokenNumber\r
e386b444 176 )\r
177{\r
a72bd1ec 178 return (GetPcdPpiPointer ())->Get16 (TokenNumber);\r
e386b444 179}\r
180\r
181\r
182\r
183/**\r
0c3437e0 184 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b
LG
185\r
186 Returns the 32-bit value for the token specified by TokenNumber.\r
e386b444 187\r
188 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
189\r
f73e0ad2 190 @return Returns the 32-bit value for the token specified by TokenNumber.\r
e386b444 191\r
192**/\r
193UINT32\r
194EFIAPI\r
195LibPcdGet32 (\r
0c3437e0 196 IN UINTN TokenNumber\r
e386b444 197 )\r
198{\r
a72bd1ec 199 return (GetPcdPpiPointer ())->Get32 (TokenNumber);\r
e386b444 200}\r
201\r
202\r
203\r
204/**\r
0c3437e0 205 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 206\r
e386b444 207 Returns the 64-bit value for the token specified by TokenNumber.\r
208\r
209 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
210\r
f73e0ad2 211 @return Returns the 64-bit value for the token specified by TokenNumber.\r
e386b444 212\r
213**/\r
214UINT64\r
215EFIAPI\r
216LibPcdGet64 (\r
0c3437e0 217 IN UINTN TokenNumber\r
e386b444 218 )\r
219{\r
a72bd1ec 220 return (GetPcdPpiPointer ())->Get64 (TokenNumber);\r
e386b444 221}\r
222\r
223\r
224\r
225/**\r
0c3437e0 226 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 227\r
e386b444 228 Returns the pointer to the buffer of the token specified by TokenNumber.\r
229\r
230 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
231\r
f73e0ad2 232 @return Returns the pointer to the token specified by TokenNumber.\r
e386b444 233\r
234**/\r
235VOID *\r
236EFIAPI\r
237LibPcdGetPtr (\r
0c3437e0 238 IN UINTN TokenNumber\r
e386b444 239 )\r
240{\r
a72bd1ec 241 return (GetPcdPpiPointer ())->GetPtr (TokenNumber);\r
e386b444 242}\r
243\r
244\r
245\r
246/**\r
0c3437e0 247 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b
LG
248\r
249 Returns the Boolean value of the token specified by TokenNumber.\r
e386b444 250\r
251 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
252\r
9095d37b 253 @return Returns the Boolean value of the token specified by TokenNumber.\r
e386b444 254\r
255**/\r
9095d37b 256BOOLEAN\r
e386b444 257EFIAPI\r
258LibPcdGetBool (\r
0c3437e0 259 IN UINTN TokenNumber\r
e386b444 260 )\r
261{\r
a72bd1ec 262 return (GetPcdPpiPointer ())->GetBool (TokenNumber);\r
e386b444 263}\r
264\r
265\r
266\r
267/**\r
0c3437e0 268 This function provides a means by which to retrieve the size of a given PCD token.\r
e386b444 269\r
270 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
271\r
9095d37b 272 @return Returns the size of the token specified by TokenNumber.\r
e386b444 273\r
274**/\r
275UINTN\r
276EFIAPI\r
277LibPcdGetSize (\r
0c3437e0 278 IN UINTN TokenNumber\r
e386b444 279 )\r
280{\r
a72bd1ec 281 return (GetPcdPpiPointer ())->GetSize (TokenNumber);\r
e386b444 282}\r
283\r
284\r
285\r
286/**\r
0c3437e0 287 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 288\r
e386b444 289 Returns the 8-bit value for the token specified by TokenNumber and Guid.\r
e386b444 290\r
9095d37b
LG
291 If Guid is NULL, then ASSERT().\r
292\r
293 @param[in] Guid The pointer to a 128-bit unique value that designates\r
c00bdbb1 294 which namespace to retrieve a value from.\r
295 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 296\r
f73e0ad2 297 @return Return the UINT8.\r
e386b444 298\r
299**/\r
300UINT8\r
301EFIAPI\r
302LibPcdGetEx8 (\r
303 IN CONST GUID *Guid,\r
304 IN UINTN TokenNumber\r
305 )\r
306{\r
e386b444 307 ASSERT (Guid != NULL);\r
308\r
9dbad162 309 return (GetPiPcdPpiPointer ())->Get8 (Guid, TokenNumber);\r
e386b444 310}\r
311\r
312\r
313\r
314/**\r
0c3437e0 315 This function provides a means by which to retrieve a value for a given PCD token.\r
316\r
e386b444 317 Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
e386b444 318\r
9095d37b
LG
319 If Guid is NULL, then ASSERT().\r
320\r
321 @param[in] Guid The pointer to a 128-bit unique value that designates\r
c00bdbb1 322 which namespace to retrieve a value from.\r
323 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 324\r
f73e0ad2 325 @return Return the UINT16.\r
e386b444 326\r
327**/\r
328UINT16\r
329EFIAPI\r
330LibPcdGetEx16 (\r
331 IN CONST GUID *Guid,\r
332 IN UINTN TokenNumber\r
333 )\r
334{\r
e386b444 335\r
336 ASSERT (Guid != NULL);\r
337\r
9dbad162 338 return (GetPiPcdPpiPointer ())->Get16 (Guid, TokenNumber);\r
e386b444 339}\r
340\r
341\r
342\r
343/**\r
344 Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
9095d37b 345 If Guid is NULL, then ASSERT().\r
e386b444 346\r
9095d37b 347 @param[in] Guid The pointer to a 128-bit unique value that designates\r
c00bdbb1 348 which namespace to retrieve a value from.\r
349 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 350\r
f73e0ad2 351 @return Return the UINT32.\r
e386b444 352\r
353**/\r
354UINT32\r
355EFIAPI\r
356LibPcdGetEx32 (\r
357 IN CONST GUID *Guid,\r
358 IN UINTN TokenNumber\r
359 )\r
360{\r
e386b444 361 ASSERT (Guid != NULL);\r
362\r
9dbad162 363 return (GetPiPcdPpiPointer ())->Get32 (Guid, TokenNumber);\r
e386b444 364}\r
365\r
366\r
367\r
368\r
369/**\r
0c3437e0 370 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 371\r
e386b444 372 Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
e386b444 373\r
9095d37b
LG
374 If Guid is NULL, then ASSERT().\r
375\r
376 @param[in] Guid The pointer to a 128-bit unique value that designates\r
0c3437e0 377 which namespace to retrieve a value from.\r
378 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 379\r
f73e0ad2 380 @return Return the UINT64.\r
e386b444 381\r
382**/\r
383UINT64\r
384EFIAPI\r
385LibPcdGetEx64 (\r
386 IN CONST GUID *Guid,\r
387 IN UINTN TokenNumber\r
388 )\r
389{\r
e386b444 390 ASSERT (Guid != NULL);\r
9dbad162 391 return (GetPiPcdPpiPointer ())->Get64 (Guid, TokenNumber);\r
e386b444 392}\r
393\r
394\r
395\r
396/**\r
0c3437e0 397 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 398\r
0c3437e0 399 Returns the pointer to the buffer of token specified by TokenNumber and Guid.\r
e386b444 400\r
9095d37b
LG
401 If Guid is NULL, then ASSERT().\r
402\r
403 @param[in] Guid The pointer to a 128-bit unique value that designates\r
0c3437e0 404 which namespace to retrieve a value from.\r
405 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 406\r
f73e0ad2 407 @return Return the VOID* pointer.\r
e386b444 408\r
409**/\r
410VOID *\r
411EFIAPI\r
412LibPcdGetExPtr (\r
413 IN CONST GUID *Guid,\r
414 IN UINTN TokenNumber\r
415 )\r
416{\r
e386b444 417 ASSERT (Guid != NULL);\r
418\r
9dbad162 419 return (GetPiPcdPpiPointer ())->GetPtr (Guid, TokenNumber);\r
e386b444 420}\r
421\r
422\r
423\r
424/**\r
0c3437e0 425 This function provides a means by which to retrieve a value for a given PCD token.\r
e386b444 426\r
9095d37b
LG
427 Returns the Boolean value of the token specified by TokenNumber and Guid.\r
428\r
429 If Guid is NULL, then ASSERT().\r
430\r
431 @param[in] Guid The pointer to a 128-bit unique value that designates\r
0c3437e0 432 which namespace to retrieve a value from.\r
433 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 434\r
f73e0ad2 435 @return Return the BOOLEAN.\r
e386b444 436\r
437**/\r
438BOOLEAN\r
439EFIAPI\r
440LibPcdGetExBool (\r
441 IN CONST GUID *Guid,\r
442 IN UINTN TokenNumber\r
443 )\r
444{\r
e386b444 445 ASSERT (Guid != NULL);\r
9dbad162 446 return (GetPiPcdPpiPointer ())->GetBool (Guid, TokenNumber);\r
e386b444 447}\r
448\r
449\r
450\r
451/**\r
0c3437e0 452 This function provides a means by which to retrieve the size of a given PCD token.\r
e386b444 453\r
9095d37b
LG
454 Returns the size of the token specified by TokenNumber and Guid.\r
455\r
456 If Guid is NULL, then ASSERT().\r
457\r
458 @param[in] Guid The pointer to a 128-bit unique value that designates\r
0c3437e0 459 which namespace to retrieve a value from.\r
460 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 461\r
f73e0ad2 462 @return Return the size.\r
e386b444 463\r
464**/\r
465UINTN\r
466EFIAPI\r
467LibPcdGetExSize (\r
468 IN CONST GUID *Guid,\r
469 IN UINTN TokenNumber\r
470 )\r
471{\r
e386b444 472 ASSERT (Guid != NULL);\r
9dbad162 473 return (GetPiPcdPpiPointer ())->GetSize (Guid, TokenNumber);\r
e386b444 474}\r
475\r
476\r
477\r
9a355841 478#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
e386b444 479/**\r
0c3437e0 480 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
481\r
482 Sets the 8-bit value for the token specified by TokenNumber\r
e386b444 483 to the value specified by Value. Value is returned.\r
0befb08d 484\r
0c3437e0 485 @param[in] TokenNumber The PCD token number to set a current value for.\r
486 @param[in] Value The 8-bit value to set.\r
e386b444 487\r
58380e9c 488 @return Return the value that was set.\r
e386b444 489\r
490**/\r
491UINT8\r
492EFIAPI\r
493LibPcdSet8 (\r
494 IN UINTN TokenNumber,\r
495 IN UINT8 Value\r
496 )\r
497{\r
9a355841 498 (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);\r
9095d37b 499\r
e386b444 500 return Value;\r
501}\r
502\r
503\r
504\r
505/**\r
0c3437e0 506 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
507\r
508 Sets the 16-bit value for the token specified by TokenNumber\r
e386b444 509 to the value specified by Value. Value is returned.\r
0befb08d 510\r
0c3437e0 511 @param[in] TokenNumber The PCD token number to set a current value for.\r
512 @param[in] Value The 16-bit value to set.\r
e386b444 513\r
58380e9c 514 @return Return the value that was set.\r
e386b444 515\r
516**/\r
517UINT16\r
518EFIAPI\r
519LibPcdSet16 (\r
520 IN UINTN TokenNumber,\r
521 IN UINT16 Value\r
522 )\r
523{\r
9a355841 524 (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);\r
9095d37b 525\r
e386b444 526 return Value;\r
527}\r
528\r
529\r
530\r
531/**\r
0c3437e0 532 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
533\r
534 Sets the 32-bit value for the token specified by TokenNumber\r
e386b444 535 to the value specified by Value. Value is returned.\r
0befb08d 536\r
0c3437e0 537 @param[in] TokenNumber The PCD token number to set a current value for.\r
538 @param[in] Value The 32-bit value to set.\r
e386b444 539\r
58380e9c 540 @return Return the value that was set.\r
e386b444 541\r
542**/\r
543UINT32\r
544EFIAPI\r
545LibPcdSet32 (\r
546 IN UINTN TokenNumber,\r
0c3437e0 547 IN UINT32 Value\r
e386b444 548 )\r
549{\r
9a355841 550 (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);\r
e386b444 551\r
552 return Value;\r
553}\r
554\r
555\r
556\r
557/**\r
0c3437e0 558 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
559\r
560 Sets the 64-bit value for the token specified by TokenNumber\r
e386b444 561 to the value specified by Value. Value is returned.\r
0befb08d 562\r
0c3437e0 563 @param[in] TokenNumber The PCD token number to set a current value for.\r
564 @param[in] Value The 64-bit value to set.\r
e386b444 565\r
58380e9c 566 @return Return the value that was set.\r
e386b444 567\r
568**/\r
569UINT64\r
570EFIAPI\r
571LibPcdSet64 (\r
572 IN UINTN TokenNumber,\r
0c3437e0 573 IN UINT64 Value\r
e386b444 574 )\r
575{\r
9a355841 576 (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);\r
e386b444 577\r
578 return Value;\r
579}\r
580\r
581\r
582\r
583/**\r
0c3437e0 584 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
585\r
586 Sets a buffer for the token specified by TokenNumber to the value\r
587 specified by Buffer and SizeOfBuffer. Buffer is returned.\r
588 If SizeOfBuffer is greater than the maximum size support by TokenNumber,\r
589 then set SizeOfBuffer to the maximum size supported by TokenNumber and\r
9a355841 590 return NULL to indicate that the set operation was not actually performed.\r
0c3437e0 591\r
9095d37b 592 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the\r
0c3437e0 593 maximum size supported by TokenName and NULL must be returned.\r
9095d37b 594\r
0c3437e0 595 If SizeOfBuffer is NULL, then ASSERT().\r
a72bd1ec 596 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
9095d37b 597\r
0c3437e0 598 @param[in] TokenNumber The PCD token number to set a current value for.\r
599 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
600 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 601\r
f73e0ad2 602 @return Return the pointer for the buffer been set.\r
e386b444 603\r
604**/\r
605VOID *\r
606EFIAPI\r
607LibPcdSetPtr (\r
0c3437e0 608 IN UINTN TokenNumber,\r
609 IN OUT UINTN *SizeOfBuffer,\r
610 IN CONST VOID *Buffer\r
e386b444 611 )\r
612{\r
613 EFI_STATUS Status;\r
0befb08d 614 UINTN InputSizeOfBuffer;\r
e386b444 615\r
616 ASSERT (SizeOfBuffer != NULL);\r
617\r
618 if (*SizeOfBuffer > 0) {\r
619 ASSERT (Buffer != NULL);\r
620 }\r
e386b444 621\r
0befb08d
SZ
622 InputSizeOfBuffer = *SizeOfBuffer;\r
623 Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
624 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
e386b444 625 return NULL;\r
626 }\r
627\r
b52f6a1a 628 return (VOID *) Buffer;\r
e386b444 629}\r
630\r
631\r
632\r
633/**\r
0c3437e0 634 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
635\r
636 Sets the Boolean value for the token specified by TokenNumber\r
e386b444 637 to the value specified by Value. Value is returned.\r
0befb08d 638\r
0c3437e0 639 @param[in] TokenNumber The PCD token number to set a current value for.\r
640 @param[in] Value The boolean value to set.\r
e386b444 641\r
58380e9c 642 @return Return the value that was set.\r
e386b444 643\r
644**/\r
645BOOLEAN\r
646EFIAPI\r
647LibPcdSetBool (\r
648 IN UINTN TokenNumber,\r
649 IN BOOLEAN Value\r
650 )\r
651{\r
9a355841 652 (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);\r
e386b444 653\r
654 return Value;\r
655}\r
656\r
657\r
658\r
659/**\r
0c3437e0 660 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
661\r
662 Sets the 8-bit value for the token specified by TokenNumber and\r
e386b444 663 Guid to the value specified by Value. Value is returned.\r
0befb08d 664\r
e386b444 665 If Guid is NULL, then ASSERT().\r
0befb08d 666\r
9095d37b 667 @param[in] Guid The pointer to a 128-bit unique value that\r
0c3437e0 668 designates which namespace to set a value from.\r
669 @param[in] TokenNumber The PCD token number to set a current value for.\r
670 @param[in] Value The 8-bit value to set.\r
e386b444 671\r
58380e9c 672 @return Return the value that was set.\r
e386b444 673\r
674**/\r
675UINT8\r
676EFIAPI\r
677LibPcdSetEx8 (\r
678 IN CONST GUID *Guid,\r
679 IN UINTN TokenNumber,\r
680 IN UINT8 Value\r
681 )\r
682{\r
e386b444 683 ASSERT (Guid != NULL);\r
684\r
9a355841 685 (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);\r
e386b444 686\r
687 return Value;\r
688}\r
689\r
690\r
691\r
692/**\r
0c3437e0 693 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
694\r
695 Sets the 16-bit value for the token specified by TokenNumber and\r
e386b444 696 Guid to the value specified by Value. Value is returned.\r
0befb08d 697\r
e386b444 698 If Guid is NULL, then ASSERT().\r
0befb08d 699\r
9095d37b 700 @param[in] Guid The pointer to a 128-bit unique value that\r
0c3437e0 701 designates which namespace to set a value from.\r
702 @param[in] TokenNumber The PCD token number to set a current value for.\r
703 @param[in] Value The 16-bit value to set.\r
e386b444 704\r
58380e9c 705 @return Return the value that was set.\r
e386b444 706\r
707**/\r
708UINT16\r
709EFIAPI\r
710LibPcdSetEx16 (\r
711 IN CONST GUID *Guid,\r
712 IN UINTN TokenNumber,\r
713 IN UINT16 Value\r
714 )\r
715{\r
e386b444 716 ASSERT (Guid != NULL);\r
e386b444 717\r
9a355841 718 (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);\r
e386b444 719\r
720 return Value;\r
721}\r
722\r
723\r
724\r
725/**\r
0c3437e0 726 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
727\r
728 Sets the 32-bit value for the token specified by TokenNumber and\r
e386b444 729 Guid to the value specified by Value. Value is returned.\r
0befb08d 730\r
e386b444 731 If Guid is NULL, then ASSERT().\r
0befb08d 732\r
9095d37b 733 @param[in] Guid The pointer to a 128-bit unique value that\r
0c3437e0 734 designates which namespace to set a value from.\r
735 @param[in] TokenNumber The PCD token number to set a current value for.\r
736 @param[in] Value The 32-bit value to set.\r
e386b444 737\r
58380e9c 738 @return Return the value that was set.\r
e386b444 739\r
740**/\r
741UINT32\r
742EFIAPI\r
743LibPcdSetEx32 (\r
744 IN CONST GUID *Guid,\r
745 IN UINTN TokenNumber,\r
0c3437e0 746 IN UINT32 Value\r
e386b444 747 )\r
748{\r
a72bd1ec 749 ASSERT (Guid != NULL);\r
e386b444 750\r
9a355841 751 (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);\r
e386b444 752\r
753 return Value;\r
754}\r
755\r
756\r
757\r
758/**\r
0c3437e0 759 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
760\r
761 Sets the 64-bit value for the token specified by TokenNumber and\r
e386b444 762 Guid to the value specified by Value. Value is returned.\r
0befb08d 763\r
e386b444 764 If Guid is NULL, then ASSERT().\r
0befb08d 765\r
9095d37b 766 @param[in] Guid The pointer to a 128-bit unique value that\r
0c3437e0 767 designates which namespace to set a value from.\r
768 @param[in] TokenNumber The PCD token number to set a current value for.\r
769 @param[in] Value The 64-bit value to set.\r
e386b444 770\r
58380e9c 771 @return Return the value that was set.\r
e386b444 772\r
773**/\r
774UINT64\r
775EFIAPI\r
776LibPcdSetEx64 (\r
777 IN CONST GUID *Guid,\r
778 IN UINTN TokenNumber,\r
779 IN UINT64 Value\r
780 )\r
781{\r
e386b444 782 ASSERT (Guid != NULL);\r
e386b444 783\r
9a355841 784 (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);\r
e386b444 785\r
786 return Value;\r
787}\r
788\r
789\r
790\r
791/**\r
0c3437e0 792 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
793\r
794 Sets a buffer for the token specified by TokenNumber to the value specified by\r
795 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than\r
796 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size\r
797 supported by TokenNumber and return NULL to indicate that the set operation\r
9a355841 798 was not actually performed.\r
9095d37b 799\r
0c3437e0 800 If Guid is NULL, then ASSERT().\r
801 If SizeOfBuffer is NULL, then ASSERT().\r
a72bd1ec 802 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
9095d37b
LG
803\r
804 @param[in] Guid The pointer to a 128-bit unique value that\r
0c3437e0 805 designates which namespace to set a value from.\r
806 @param[in] TokenNumber The PCD token number to set a current value for.\r
807 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
808 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 809\r
f73e0ad2 810 @return Return the pinter to the buffer been set.\r
e386b444 811\r
812**/\r
813VOID *\r
814EFIAPI\r
815LibPcdSetExPtr (\r
816 IN CONST GUID *Guid,\r
817 IN UINTN TokenNumber,\r
818 IN OUT UINTN *SizeOfBuffer,\r
819 IN VOID *Buffer\r
820 )\r
821{\r
822 EFI_STATUS Status;\r
0befb08d
SZ
823 UINTN InputSizeOfBuffer;\r
824\r
a72bd1ec 825 ASSERT (SizeOfBuffer != NULL);\r
e386b444 826 if (*SizeOfBuffer > 0) {\r
827 ASSERT (Buffer != NULL);\r
828 }\r
829 ASSERT (Guid != NULL);\r
e386b444 830\r
0befb08d 831 InputSizeOfBuffer = *SizeOfBuffer;\r
9dbad162 832 Status = (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
0befb08d 833 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
e386b444 834 return NULL;\r
835 }\r
836\r
837 return Buffer;\r
838}\r
839\r
840\r
841\r
842/**\r
0c3437e0 843 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
844\r
845 Sets the Boolean value for the token specified by TokenNumber and\r
e386b444 846 Guid to the value specified by Value. Value is returned.\r
0befb08d 847\r
e386b444 848 If Guid is NULL, then ASSERT().\r
0befb08d 849\r
9095d37b 850 @param[in] Guid The pointer to a 128-bit unique value that\r
0c3437e0 851 designates which namespace to set a value from.\r
852 @param[in] TokenNumber The PCD token number to set a current value for.\r
853 @param[in] Value The Boolean value to set.\r
e386b444 854\r
58380e9c 855 @return Return the value that was set.\r
e386b444 856\r
857**/\r
858BOOLEAN\r
859EFIAPI\r
860LibPcdSetExBool (\r
861 IN CONST GUID *Guid,\r
862 IN UINTN TokenNumber,\r
863 IN BOOLEAN Value\r
864 )\r
865{\r
e386b444 866 ASSERT (Guid != NULL);\r
e386b444 867\r
9a355841 868 (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);\r
e386b444 869\r
870 return Value;\r
871}\r
9a355841
SZ
872#endif\r
873\r
874/**\r
875 This function provides a means by which to set a value for a given PCD token.\r
876\r
877 Sets the 8-bit value for the token specified by TokenNumber\r
878 to the value specified by Value.\r
879\r
880 @param[in] TokenNumber The PCD token number to set a current value for.\r
881 @param[in] Value The 8-bit value to set.\r
882\r
883 @return The status of the set operation.\r
884\r
885**/\r
886RETURN_STATUS\r
887EFIAPI\r
888LibPcdSet8S (\r
889 IN UINTN TokenNumber,\r
890 IN UINT8 Value\r
891 )\r
892{\r
893 return (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);\r
894}\r
895\r
896/**\r
897 This function provides a means by which to set a value for a given PCD token.\r
898\r
899 Sets the 16-bit value for the token specified by TokenNumber\r
900 to the value specified by Value.\r
901\r
902 @param[in] TokenNumber The PCD token number to set a current value for.\r
903 @param[in] Value The 16-bit value to set.\r
904\r
905 @return The status of the set operation.\r
906\r
907**/\r
908RETURN_STATUS\r
909EFIAPI\r
910LibPcdSet16S (\r
911 IN UINTN TokenNumber,\r
912 IN UINT16 Value\r
913 )\r
914{\r
915 return (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);\r
916}\r
917\r
918/**\r
919 This function provides a means by which to set a value for a given PCD token.\r
920\r
921 Sets the 32-bit value for the token specified by TokenNumber\r
922 to the value specified by Value.\r
923\r
924 @param[in] TokenNumber The PCD token number to set a current value for.\r
925 @param[in] Value The 32-bit value to set.\r
926\r
927 @return The status of the set operation.\r
928\r
929**/\r
930RETURN_STATUS\r
931EFIAPI\r
932LibPcdSet32S (\r
933 IN UINTN TokenNumber,\r
934 IN UINT32 Value\r
935 )\r
936{\r
937 return (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);\r
938}\r
939\r
940/**\r
941 This function provides a means by which to set a value for a given PCD token.\r
942\r
943 Sets the 64-bit value for the token specified by TokenNumber\r
944 to the value specified by Value.\r
945\r
946 @param[in] TokenNumber The PCD token number to set a current value for.\r
947 @param[in] Value The 64-bit value to set.\r
948\r
949 @return The status of the set operation.\r
950\r
951**/\r
952RETURN_STATUS\r
953EFIAPI\r
954LibPcdSet64S (\r
955 IN UINTN TokenNumber,\r
956 IN UINT64 Value\r
957 )\r
958{\r
959 return (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);\r
960}\r
961\r
962/**\r
963 This function provides a means by which to set a value for a given PCD token.\r
964\r
965 Sets a buffer for the token specified by TokenNumber to the value specified\r
966 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
967 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
968 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
969 was not actually performed.\r
970\r
971 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the\r
972 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.\r
973\r
974 If SizeOfBuffer is NULL, then ASSERT().\r
975 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
976\r
977 @param[in] TokenNumber The PCD token number to set a current value for.\r
978 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
979 @param[in] Buffer A pointer to the buffer to set.\r
980\r
981 @return The status of the set operation.\r
982\r
983**/\r
984RETURN_STATUS\r
985EFIAPI\r
986LibPcdSetPtrS (\r
987 IN UINTN TokenNumber,\r
988 IN OUT UINTN *SizeOfBuffer,\r
989 IN CONST VOID *Buffer\r
990 )\r
991{\r
992 ASSERT (SizeOfBuffer != NULL);\r
993\r
994 if (*SizeOfBuffer > 0) {\r
995 ASSERT (Buffer != NULL);\r
996 }\r
997\r
998 return (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
999}\r
1000\r
1001/**\r
1002 This function provides a means by which to set a value for a given PCD token.\r
1003\r
1004 Sets the boolean value for the token specified by TokenNumber\r
1005 to the value specified by Value.\r
1006\r
1007 @param[in] TokenNumber The PCD token number to set a current value for.\r
1008 @param[in] Value The boolean value to set.\r
1009\r
1010 @return The status of the set operation.\r
1011\r
1012**/\r
1013RETURN_STATUS\r
1014EFIAPI\r
1015LibPcdSetBoolS (\r
1016 IN UINTN TokenNumber,\r
1017 IN BOOLEAN Value\r
1018 )\r
1019{\r
1020 return (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);\r
1021}\r
1022\r
1023/**\r
1024 This function provides a means by which to set a value for a given PCD token.\r
1025\r
1026 Sets the 8-bit value for the token specified by TokenNumber\r
1027 to the value specified by Value.\r
1028\r
1029 If Guid is NULL, then ASSERT().\r
1030\r
1031 @param[in] Guid The pointer to a 128-bit unique value that\r
1032 designates which namespace to set a value from.\r
1033 @param[in] TokenNumber The PCD token number to set a current value for.\r
1034 @param[in] Value The 8-bit value to set.\r
1035\r
1036 @return The status of the set operation.\r
1037\r
1038**/\r
1039RETURN_STATUS\r
1040EFIAPI\r
1041LibPcdSetEx8S (\r
1042 IN CONST GUID *Guid,\r
1043 IN UINTN TokenNumber,\r
1044 IN UINT8 Value\r
1045 )\r
1046{\r
1047 ASSERT (Guid != NULL);\r
1048\r
1049 return (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);\r
1050}\r
e386b444 1051\r
9a355841
SZ
1052/**\r
1053 This function provides a means by which to set a value for a given PCD token.\r
e386b444 1054\r
9a355841
SZ
1055 Sets the 16-bit value for the token specified by TokenNumber\r
1056 to the value specified by Value.\r
1057\r
1058 If Guid is NULL, then ASSERT().\r
1059\r
1060 @param[in] Guid The pointer to a 128-bit unique value that\r
1061 designates which namespace to set a value from.\r
1062 @param[in] TokenNumber The PCD token number to set a current value for.\r
1063 @param[in] Value The 16-bit value to set.\r
1064\r
1065 @return The status of the set operation.\r
1066\r
1067**/\r
1068RETURN_STATUS\r
1069EFIAPI\r
1070LibPcdSetEx16S (\r
1071 IN CONST GUID *Guid,\r
1072 IN UINTN TokenNumber,\r
1073 IN UINT16 Value\r
1074 )\r
1075{\r
1076 ASSERT (Guid != NULL);\r
1077\r
1078 return (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);\r
1079}\r
1080\r
1081/**\r
1082 This function provides a means by which to set a value for a given PCD token.\r
1083\r
1084 Sets the 32-bit value for the token specified by TokenNumber\r
1085 to the value specified by Value.\r
1086\r
1087 If Guid is NULL, then ASSERT().\r
1088\r
1089 @param[in] Guid The pointer to a 128-bit unique value that\r
1090 designates which namespace to set a value from.\r
1091 @param[in] TokenNumber The PCD token number to set a current value for.\r
1092 @param[in] Value The 32-bit value to set.\r
1093\r
1094 @return The status of the set operation.\r
1095\r
1096**/\r
1097RETURN_STATUS\r
1098EFIAPI\r
1099LibPcdSetEx32S (\r
1100 IN CONST GUID *Guid,\r
1101 IN UINTN TokenNumber,\r
1102 IN UINT32 Value\r
1103 )\r
1104{\r
1105 ASSERT (Guid != NULL);\r
1106\r
1107 return (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);\r
1108}\r
1109\r
1110/**\r
1111 This function provides a means by which to set a value for a given PCD token.\r
1112\r
1113 Sets the 64-bit value for the token specified by TokenNumber\r
1114 to the value specified by Value.\r
1115\r
1116 If Guid is NULL, then ASSERT().\r
1117\r
1118 @param[in] Guid The pointer to a 128-bit unique value that\r
1119 designates which namespace to set a value from.\r
1120 @param[in] TokenNumber The PCD token number to set a current value for.\r
1121 @param[in] Value The 64-bit value to set.\r
1122\r
1123 @return The status of the set operation.\r
1124\r
1125**/\r
1126RETURN_STATUS\r
1127EFIAPI\r
1128LibPcdSetEx64S (\r
1129 IN CONST GUID *Guid,\r
1130 IN UINTN TokenNumber,\r
1131 IN UINT64 Value\r
1132 )\r
1133{\r
1134 ASSERT (Guid != NULL);\r
1135\r
1136 return (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);\r
1137}\r
1138\r
1139/**\r
1140 This function provides a means by which to set a value for a given PCD token.\r
1141\r
1142 Sets a buffer for the token specified by TokenNumber to the value specified by\r
1143 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
1144 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
1145 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
1146 was not actually performed.\r
1147\r
1148 If Guid is NULL, then ASSERT().\r
1149 If SizeOfBuffer is NULL, then ASSERT().\r
1150 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1151\r
1152 @param[in] Guid Pointer to a 128-bit unique value that\r
1153 designates which namespace to set a value from.\r
1154 @param[in] TokenNumber The PCD token number to set a current value for.\r
1155 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
1156 @param[in] Buffer A pointer to the buffer to set.\r
1157\r
1158 @return The status of the set operation.\r
1159\r
1160**/\r
1161RETURN_STATUS\r
1162EFIAPI\r
1163LibPcdSetExPtrS (\r
1164 IN CONST GUID *Guid,\r
1165 IN UINTN TokenNumber,\r
1166 IN OUT UINTN *SizeOfBuffer,\r
1167 IN VOID *Buffer\r
1168 )\r
1169{\r
1170 ASSERT (Guid != NULL);\r
1171\r
1172 ASSERT (SizeOfBuffer != NULL);\r
1173\r
1174 if (*SizeOfBuffer > 0) {\r
1175 ASSERT (Buffer != NULL);\r
1176 }\r
1177\r
1178 return (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
1179}\r
1180\r
1181/**\r
1182 This function provides a means by which to set a value for a given PCD token.\r
1183\r
1184 Sets the boolean value for the token specified by TokenNumber\r
1185 to the value specified by Value.\r
1186\r
1187 If Guid is NULL, then ASSERT().\r
1188\r
1189 @param[in] Guid The pointer to a 128-bit unique value that\r
1190 designates which namespace to set a value from.\r
1191 @param[in] TokenNumber The PCD token number to set a current value for.\r
1192 @param[in] Value The boolean value to set.\r
1193\r
1194 @return The status of the set operation.\r
1195\r
1196**/\r
1197RETURN_STATUS\r
1198EFIAPI\r
1199LibPcdSetExBoolS (\r
1200 IN CONST GUID *Guid,\r
1201 IN UINTN TokenNumber,\r
1202 IN BOOLEAN Value\r
1203 )\r
1204{\r
1205 ASSERT (Guid != NULL);\r
1206\r
1207 return (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);\r
1208}\r
e386b444 1209\r
1210/**\r
0c3437e0 1211 Set up a notification function that is called when a specified token is set.\r
9095d37b
LG
1212\r
1213 When the token specified by TokenNumber and Guid is set,\r
1214 then notification function specified by NotificationFunction is called.\r
c00bdbb1 1215 If Guid is NULL, then the default token space is used.\r
e386b444 1216 If NotificationFunction is NULL, then ASSERT().\r
0c3437e0 1217\r
9095d37b
LG
1218 @param[in] Guid The pointer to a 128-bit unique value that\r
1219 designates which namespace to set a value from.\r
58380e9c 1220 If NULL, then the default token space is used.\r
c00bdbb1 1221 @param[in] TokenNumber The PCD token number to monitor.\r
9095d37b 1222 @param[in] NotificationFunction The function to call when the token\r
0c3437e0 1223 specified by Guid and TokenNumber is set.\r
e386b444 1224\r
e386b444 1225**/\r
1226VOID\r
1227EFIAPI\r
1228LibPcdCallbackOnSet (\r
1229 IN CONST GUID *Guid, OPTIONAL\r
1230 IN UINTN TokenNumber,\r
1231 IN PCD_CALLBACK NotificationFunction\r
1232 )\r
1233{\r
1234 EFI_STATUS Status;\r
e386b444 1235\r
fc153004 1236 ASSERT (NotificationFunction != NULL);\r
1237\r
d6b58d32 1238 Status = (GetPiPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);\r
e386b444 1239\r
1240 ASSERT_EFI_ERROR (Status);\r
1241\r
1242 return;\r
1243}\r
1244\r
1245\r
1246\r
1247/**\r
1248 Disable a notification function that was established with LibPcdCallbackonSet().\r
9095d37b 1249\r
c00bdbb1 1250 Disable a notification function that was previously established with LibPcdCallbackOnSet().\r
e386b444 1251 If NotificationFunction is NULL, then ASSERT().\r
9095d37b 1252 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,\r
0c3437e0 1253 and NotificationFunction, then ASSERT().\r
9095d37b 1254\r
c00bdbb1 1255 @param[in] Guid Specify the GUID token space.\r
1256 @param[in] TokenNumber Specify the token number.\r
e386b444 1257 @param[in] NotificationFunction The callback function to be unregistered.\r
1258\r
e386b444 1259**/\r
1260VOID\r
1261EFIAPI\r
1262LibPcdCancelCallback (\r
1263 IN CONST GUID *Guid, OPTIONAL\r
1264 IN UINTN TokenNumber,\r
1265 IN PCD_CALLBACK NotificationFunction\r
1266 )\r
1267{\r
1268 EFI_STATUS Status;\r
e386b444 1269\r
fc153004 1270 ASSERT (NotificationFunction != NULL);\r
1271\r
d6b58d32 1272 Status = (GetPiPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);\r
e386b444 1273\r
1274 ASSERT_EFI_ERROR (Status);\r
1275\r
1276 return;\r
1277}\r
1278\r
1279\r
1280\r
1281/**\r
0c3437e0 1282 Retrieves the next token in a token space.\r
9095d37b
LG
1283\r
1284 Retrieves the next PCD token number from the token space specified by Guid.\r
1285 If Guid is NULL, then the default token space is used. If TokenNumber is 0,\r
1286 then the first token number is returned. Otherwise, the token number that\r
1287 follows TokenNumber in the token space is returned. If TokenNumber is the last\r
1288 token number in the token space, then 0 is returned.\r
1289\r
0c3437e0 1290 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().\r
1291\r
9095d37b 1292 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace\r
0c3437e0 1293 to set a value from. If NULL, then the default token space is used.\r
9095d37b 1294 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD\r
0c3437e0 1295 token number.\r
e386b444 1296\r
f73e0ad2 1297 @return The next valid token number.\r
e386b444 1298\r
1299**/\r
9095d37b 1300UINTN\r
e386b444 1301EFIAPI\r
1302LibPcdGetNextToken (\r
0c3437e0 1303 IN CONST GUID *Guid, OPTIONAL\r
1304 IN UINTN TokenNumber\r
e386b444 1305 )\r
1306{\r
da660118
SZ
1307 EFI_STATUS Status;\r
1308\r
1309 Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);\r
1310 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);\r
e386b444 1311\r
1312 return TokenNumber;\r
1313}\r
1314\r
1315\r
1316/**\r
64735d24 1317 Used to retrieve the list of available PCD token space GUIDs.\r
9095d37b 1318\r
8f0dd97e 1319 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces\r
1320 in the platform.\r
1321 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.\r
1322 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.\r
9095d37b 1323\r
2fc59a00 1324 @param TokenSpaceGuid The pointer to the a PCD token space GUID\r
e386b444 1325\r
f73e0ad2 1326 @return The next valid token namespace.\r
e386b444 1327\r
1328**/\r
c00bdbb1 1329GUID *\r
e386b444 1330EFIAPI\r
1331LibPcdGetNextTokenSpace (\r
64735d24 1332 IN CONST GUID *TokenSpaceGuid\r
e386b444 1333 )\r
1334{\r
419db80b 1335 (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);\r
e386b444 1336\r
64735d24 1337 return (GUID *) TokenSpaceGuid;\r
e386b444 1338}\r
1339\r
1340\r
1341\r
1342/**\r
9638ba6d 1343 Sets a value of a patchable PCD entry that is type pointer.\r
9095d37b
LG
1344\r
1345 Sets the PCD entry specified by PatchVariable to the value specified by Buffer\r
1346 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than\r
1347 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return\r
1348 NULL to indicate that the set operation was not actually performed.\r
1349 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
e386b444 1350 MaximumDatumSize and NULL must be returned.\r
9095d37b 1351\r
e386b444 1352 If PatchVariable is NULL, then ASSERT().\r
a72bd1ec 1353 If SizeOfBuffer is NULL, then ASSERT().\r
1354 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 1355\r
9095d37b 1356 @param[out] PatchVariable A pointer to the global variable in a module that is\r
e386b444 1357 the target of the set operation.\r
1358 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1359 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1360 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
9095d37b 1361\r
9638ba6d 1362 @return Return the pointer to the buffer been set.\r
e386b444 1363\r
1364**/\r
1365VOID *\r
1366EFIAPI\r
1367LibPatchPcdSetPtr (\r
f8308f0a 1368 OUT VOID *PatchVariable,\r
e386b444 1369 IN UINTN MaximumDatumSize,\r
1370 IN OUT UINTN *SizeOfBuffer,\r
1371 IN CONST VOID *Buffer\r
1372 )\r
1373{\r
1374 ASSERT (PatchVariable != NULL);\r
1375 ASSERT (SizeOfBuffer != NULL);\r
9095d37b 1376\r
e386b444 1377 if (*SizeOfBuffer > 0) {\r
1378 ASSERT (Buffer != NULL);\r
1379 }\r
1380\r
1381 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1382 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1383 *SizeOfBuffer = MaximumDatumSize;\r
1384 return NULL;\r
1385 }\r
9095d37b 1386\r
e386b444 1387 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
9095d37b 1388\r
e386b444 1389 return (VOID *) Buffer;\r
1390}\r
1391\r
9a355841
SZ
1392/**\r
1393 Sets a value of a patchable PCD entry that is type pointer.\r
1394\r
1395 Sets the PCD entry specified by PatchVariable to the value specified\r
1396 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
1397 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
1398 to indicate that the set operation was not actually performed.\r
1399 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
1400 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
1401\r
1402 If PatchVariable is NULL, then ASSERT().\r
1403 If SizeOfBuffer is NULL, then ASSERT().\r
1404 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1405\r
f8308f0a 1406 @param[out] PatchVariable A pointer to the global variable in a module that is\r
9a355841
SZ
1407 the target of the set operation.\r
1408 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1409 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1410 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
9095d37b 1411\r
9a355841
SZ
1412 @return The status of the set operation.\r
1413\r
1414**/\r
1415RETURN_STATUS\r
1416EFIAPI\r
1417LibPatchPcdSetPtrS (\r
f8308f0a 1418 OUT VOID *PatchVariable,\r
9a355841
SZ
1419 IN UINTN MaximumDatumSize,\r
1420 IN OUT UINTN *SizeOfBuffer,\r
1421 IN CONST VOID *Buffer\r
1422 )\r
1423{\r
1424 ASSERT (PatchVariable != NULL);\r
1425 ASSERT (SizeOfBuffer != NULL);\r
9095d37b 1426\r
9a355841
SZ
1427 if (*SizeOfBuffer > 0) {\r
1428 ASSERT (Buffer != NULL);\r
1429 }\r
1430\r
1431 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1432 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1433 *SizeOfBuffer = MaximumDatumSize;\r
1434 return RETURN_INVALID_PARAMETER;\r
1435 }\r
1436\r
1437 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1438\r
1439 return RETURN_SUCCESS;\r
1440}\r
1441\r
f8308f0a
LG
1442\r
1443/**\r
1444 Sets a value and size of a patchable PCD entry that is type pointer.\r
9095d37b
LG
1445\r
1446 Sets the PCD entry specified by PatchVariable to the value specified by Buffer\r
1447 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than\r
1448 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return\r
1449 NULL to indicate that the set operation was not actually performed.\r
1450 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
f8308f0a 1451 MaximumDatumSize and NULL must be returned.\r
9095d37b 1452\r
f8308f0a
LG
1453 If PatchVariable is NULL, then ASSERT().\r
1454 If SizeOfPatchVariable is NULL, then ASSERT().\r
1455 If SizeOfBuffer is NULL, then ASSERT().\r
1456 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1457\r
9095d37b 1458 @param[out] PatchVariable A pointer to the global variable in a module that is\r
f8308f0a
LG
1459 the target of the set operation.\r
1460 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
1461 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1462 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1463 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
9095d37b 1464\r
f8308f0a
LG
1465 @return Return the pointer to the buffer been set.\r
1466\r
1467**/\r
1468VOID *\r
1469EFIAPI\r
1470LibPatchPcdSetPtrAndSize (\r
1471 OUT VOID *PatchVariable,\r
1472 OUT UINTN *SizeOfPatchVariable,\r
1473 IN UINTN MaximumDatumSize,\r
1474 IN OUT UINTN *SizeOfBuffer,\r
1475 IN CONST VOID *Buffer\r
1476 )\r
1477{\r
1478 ASSERT (PatchVariable != NULL);\r
1479 ASSERT (SizeOfPatchVariable != NULL);\r
1480 ASSERT (SizeOfBuffer != NULL);\r
9095d37b 1481\r
f8308f0a
LG
1482 if (*SizeOfBuffer > 0) {\r
1483 ASSERT (Buffer != NULL);\r
1484 }\r
1485\r
1486 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1487 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1488 *SizeOfBuffer = MaximumDatumSize;\r
1489 return NULL;\r
1490 }\r
9095d37b 1491\r
f8308f0a
LG
1492 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1493 *SizeOfPatchVariable = *SizeOfBuffer;\r
9095d37b 1494\r
f8308f0a
LG
1495 return (VOID *) Buffer;\r
1496}\r
1497\r
1498/**\r
1499 Sets a value and size of a patchable PCD entry that is type pointer.\r
1500\r
1501 Sets the PCD entry specified by PatchVariable to the value specified\r
1502 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
1503 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
1504 to indicate that the set operation was not actually performed.\r
1505 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
1506 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
1507\r
1508 If PatchVariable is NULL, then ASSERT().\r
1509 If SizeOfPatchVariable is NULL, then ASSERT().\r
1510 If SizeOfBuffer is NULL, then ASSERT().\r
1511 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1512\r
1513 @param[out] PatchVariable A pointer to the global variable in a module that is\r
1514 the target of the set operation.\r
1515 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
1516 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1517 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1518 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
9095d37b 1519\r
f8308f0a
LG
1520 @return The status of the set operation.\r
1521\r
1522**/\r
1523RETURN_STATUS\r
1524EFIAPI\r
1525LibPatchPcdSetPtrAndSizeS (\r
1526 OUT VOID *PatchVariable,\r
1527 OUT UINTN *SizeOfPatchVariable,\r
1528 IN UINTN MaximumDatumSize,\r
1529 IN OUT UINTN *SizeOfBuffer,\r
1530 IN CONST VOID *Buffer\r
1531 )\r
1532{\r
1533 ASSERT (PatchVariable != NULL);\r
1534 ASSERT (SizeOfPatchVariable != NULL);\r
1535 ASSERT (SizeOfBuffer != NULL);\r
9095d37b 1536\r
f8308f0a
LG
1537 if (*SizeOfBuffer > 0) {\r
1538 ASSERT (Buffer != NULL);\r
1539 }\r
1540\r
1541 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1542 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1543 *SizeOfBuffer = MaximumDatumSize;\r
1544 return RETURN_INVALID_PARAMETER;\r
1545 }\r
1546\r
1547 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1548 *SizeOfPatchVariable = *SizeOfBuffer;\r
1549\r
1550 return RETURN_SUCCESS;\r
1551}\r
1552\r
96d6d004
SZ
1553/**\r
1554 Retrieve additional information associated with a PCD token.\r
1555\r
1556 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1557 human readable name that is associated with the token.\r
e386b444 1558\r
96d6d004
SZ
1559 If TokenNumber is not in the default token space specified, then ASSERT().\r
1560\r
1561 @param[in] TokenNumber The PCD token number.\r
1562 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1563 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1564**/\r
1565VOID\r
1566EFIAPI\r
1567LibPcdGetInfo (\r
1568 IN UINTN TokenNumber,\r
1569 OUT PCD_INFO *PcdInfo\r
1570 )\r
1571{\r
1572 EFI_STATUS Status;\r
1573\r
1574 Status = GetPcdInfoPpiPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1575 ASSERT_EFI_ERROR (Status);\r
1576}\r
1577\r
1578/**\r
1579 Retrieve additional information associated with a PCD token.\r
1580\r
1581 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1582 human readable name that is associated with the token.\r
1583\r
1584 If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
1585\r
1586 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
1587 @param[in] TokenNumber The PCD token number.\r
1588 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1589 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1590**/\r
1591VOID\r
1592EFIAPI\r
1593LibPcdGetInfoEx (\r
1594 IN CONST GUID *Guid,\r
1595 IN UINTN TokenNumber,\r
1596 OUT PCD_INFO *PcdInfo\r
1597 )\r
1598{\r
1599 EFI_STATUS Status;\r
1600\r
1601 Status = GetPiPcdInfoPpiPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1602 ASSERT_EFI_ERROR (Status);\r
1603}\r
1604\r
1605/**\r
1606 Retrieve the currently set SKU Id.\r
1607\r
96d6d004
SZ
1608 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
1609 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
1610 Id is returned.\r
1611**/\r
1612UINTN\r
1613EFIAPI\r
1614LibPcdGetSku (\r
1615 VOID\r
1616 )\r
1617{\r
c7451444 1618 return GetPiPcdInfoPpiPointer()->GetSku ();\r
96d6d004 1619}\r