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