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