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