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