]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
Function headers in .h and .c files synchronized with spec
[mirror_edk2.git] / MdePkg / Library / PeiPcdLib / PeiPcdLib.c
... / ...
CommitLineData
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
14**/\r
15\r
16\r
17\r
18\r
19#include <PiPei.h>\r
20\r
21#include <Ppi/Pcd.h>\r
22\r
23#include <Library/PeiServicesLib.h>\r
24#include <Library/PcdLib.h>\r
25#include <Library/DebugLib.h>\r
26#include <Library/BaseMemoryLib.h>\r
27\r
28/**\r
29 Retrieve the PCD_PPI pointer.\r
30\r
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
34 @retval PCD_PPI * The pointer to the PCD_PPI.\r
35\r
36**/\r
37PCD_PPI *\r
38GetPcdPpiPointer (\r
39 VOID\r
40 ) \r
41{\r
42 EFI_STATUS Status;\r
43 PCD_PPI *PcdPpi;\r
44 \r
45 Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);\r
46 ASSERT_EFI_ERROR (Status);\r
47\r
48 return PcdPpi;\r
49}\r
50\r
51/**\r
52 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
53 If SkuId not less than PCD_MAX_SKU_ID, then ASSERT().\r
54 \r
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
57\r
58 @return Return the SKU ID that just be set.\r
59\r
60**/\r
61UINTN\r
62EFIAPI\r
63LibPcdSetSku (\r
64 IN UINTN SkuId\r
65 )\r
66{\r
67\r
68 ASSERT (SkuId < PCD_MAX_SKU_ID);\r
69\r
70 GetPcdPpiPointer()->SetSku (SkuId);\r
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
80 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
81\r
82 @return Returns the 8-bit value for the token specified by TokenNumber. \r
83\r
84**/\r
85UINT8\r
86EFIAPI\r
87LibPcdGet8 (\r
88 IN UINTN TokenNumber\r
89 )\r
90{\r
91 return (GetPcdPpiPointer ())->Get8 (TokenNumber);\r
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
99 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
100\r
101 @return Returns the 16-bit value for the token specified by TokenNumber. \r
102\r
103**/\r
104UINT16\r
105EFIAPI\r
106LibPcdGet16 (\r
107 IN UINTN TokenNumber\r
108 )\r
109{\r
110 return (GetPcdPpiPointer ())->Get16 (TokenNumber);\r
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
120 @return Returns the 32-bit value for the token specified by TokenNumber.\r
121\r
122**/\r
123UINT32\r
124EFIAPI\r
125LibPcdGet32 (\r
126 IN UINTN TokenNumber\r
127 )\r
128{\r
129 return (GetPcdPpiPointer ())->Get32 (TokenNumber);\r
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
139 @return Returns the 64-bit value for the token specified by TokenNumber.\r
140\r
141**/\r
142UINT64\r
143EFIAPI\r
144LibPcdGet64 (\r
145 IN UINTN TokenNumber\r
146 )\r
147{\r
148 return (GetPcdPpiPointer ())->Get64 (TokenNumber);\r
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
158 @return Returns the pointer to the token specified by TokenNumber.\r
159\r
160**/\r
161VOID *\r
162EFIAPI\r
163LibPcdGetPtr (\r
164 IN UINTN TokenNumber\r
165 )\r
166{\r
167 return (GetPcdPpiPointer ())->GetPtr (TokenNumber);\r
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
177 @return Returns the Boolean value of the token specified by TokenNumber. \r
178\r
179**/\r
180BOOLEAN \r
181EFIAPI\r
182LibPcdGetBool (\r
183 IN UINTN TokenNumber\r
184 )\r
185{\r
186 return (GetPcdPpiPointer ())->GetBool (TokenNumber);\r
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
196 @return Returns the size of the token specified by TokenNumber. \r
197\r
198**/\r
199UINTN\r
200EFIAPI\r
201LibPcdGetSize (\r
202 IN UINTN TokenNumber\r
203 )\r
204{\r
205 return (GetPcdPpiPointer ())->GetSize (TokenNumber);\r
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
218 @return Return the UINT8.\r
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
228 ASSERT (Guid != NULL);\r
229\r
230 return (GetPcdPpiPointer ())->Get8Ex (Guid, TokenNumber);\r
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
243 @return Return the UINT16.\r
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
253\r
254 ASSERT (Guid != NULL);\r
255\r
256 return (GetPcdPpiPointer ())->Get16Ex (Guid, TokenNumber);\r
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
269 @return Return the UINT32.\r
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
279 ASSERT (Guid != NULL);\r
280\r
281 return (GetPcdPpiPointer ())->Get32Ex (Guid, TokenNumber);\r
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
295 @return Return the UINT64.\r
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
305 ASSERT (Guid != NULL);\r
306 return (GetPcdPpiPointer ())->Get64Ex (Guid, TokenNumber);\r
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
319 @return Return the VOID* pointer.\r
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
329 ASSERT (Guid != NULL);\r
330\r
331 return (GetPcdPpiPointer ())->GetPtrEx (Guid, TokenNumber);\r
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
344 @return Return the BOOLEAN.\r
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
354 ASSERT (Guid != NULL);\r
355 return (GetPcdPpiPointer ())->GetBoolEx (Guid, TokenNumber);\r
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
368 @return Return the size.\r
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
378 ASSERT (Guid != NULL);\r
379 return (GetPcdPpiPointer ())->GetSizeEx (Guid, TokenNumber);\r
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
387 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
392 @return Return the value been set.\r
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
403\r
404 Status = (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);\r
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
416 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
421 @return Return the value been set.\r
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
432\r
433 Status = (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);\r
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
445 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
450 @return Return the value been set.\r
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
461\r
462 Status = (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);\r
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
474 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
479 @return Return the value been set.\r
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
490\r
491 Status = (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);\r
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
502 the value specified by Buffer and SizeOfBuffer. Buffer to\r
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
507 If SizeOfBuffer is greater than the maximum \r
508 size support by TokenNumber, then set SizeOfBuffer to the \r
509 maximum size supported by TokenNumber and return NULL to \r
510 indicate that the set operation was not actually performed. \r
511 \r
512 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
513 \r
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
516 In out, returns actual size of buffer is set.\r
517 @param[in] Buffer A pointer to the buffer to set.\r
518\r
519 @return Return the pointer for the buffer been set.\r
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
531\r
532 ASSERT (SizeOfBuffer != NULL);\r
533\r
534 if (*SizeOfBuffer > 0) {\r
535 ASSERT (Buffer != NULL);\r
536 }\r
537 \r
538 Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, Buffer);\r
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
552 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
557 @return Return the value been set.\r
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
568\r
569 Status = (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);\r
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
582 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
589 @return Return the value been set.\r
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
601\r
602 ASSERT (Guid != NULL);\r
603\r
604 Status = (GetPcdPpiPointer ())->Set8Ex (Guid, TokenNumber, Value);\r
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
617 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
624 @return Return the value been set.\r
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
636 ASSERT (Guid != NULL);\r
637 Status = (GetPcdPpiPointer ())->Set16Ex (Guid, TokenNumber, Value);\r
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
650 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
657 @return Return the value been set.\r
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
669\r
670 ASSERT (Guid != NULL);\r
671\r
672 Status = (GetPcdPpiPointer ())->Set32Ex (Guid, TokenNumber, Value);\r
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
685 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
692 @return Return the value been set.\r
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
704 ASSERT (Guid != NULL);\r
705\r
706 Status = (GetPcdPpiPointer ())->Set64Ex (Guid, TokenNumber, Value);\r
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
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
719 supported by TokenNumber and return NULL to indicate that the set operation \r
720 was not actually performed. \r
721 \r
722 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
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
728 In out, returns actual size of buffer is set.\r
729 @param[in] Buffer A pointer to the buffer to set.\r
730\r
731 @return Return the pinter to the buffer been set.\r
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
744 ASSERT (SizeOfBuffer != NULL);\r
745 if (*SizeOfBuffer > 0) {\r
746 ASSERT (Buffer != NULL);\r
747 }\r
748 ASSERT (Guid != NULL);\r
749\r
750 Status = (GetPcdPpiPointer ())->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
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
765 If fail to set pcd value, then ASSERT_EFI_ERROR().\r
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
772 @return Return the value been set.\r
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
784\r
785 ASSERT (Guid != NULL);\r
786 Status = (GetPcdPpiPointer ())->SetBoolEx (Guid, TokenNumber, Value);\r
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
800 If fail to set callback, then ASSERT_EFI_ERROR().\r
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
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
818\r
819 Status = (GetPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, NotificationFunction);\r
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
831 If fail to cancel callback, then ASSERT_EFI_ERROR().\r
832 \r
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
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
847\r
848 Status = (GetPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, NotificationFunction);\r
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
864 If fail to get token in given token space, then ASSERT_EFI_ERROR().\r
865 \r
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
870\r
871 @return The next valid token number.\r
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
882\r
883 Status = (GetPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);\r
884\r
885 ASSERT_EFI_ERROR (Status);\r
886\r
887 return TokenNumber;\r
888}\r
889\r
890\r
891/**\r
892 Used to retrieve the list of available PCD token space GUIDs.\r
893 \r
894 Retrieves the next PCD token space from a token space specified by Guid.\r
895 Guid of NULL is reserved to mark the default local token namespace on the current\r
896 platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
897 current platform is returned. If Guid is the last non-local token space, \r
898 then NULL is returned. \r
899 If fail to get next token space, then ASSERT_EFI_ERROR().\r
900 \r
901 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
902\r
903\r
904 \r
905 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace \r
906 to start the search.\r
907\r
908 @return The next valid token namespace.\r
909\r
910**/\r
911GUID * \r
912EFIAPI\r
913LibPcdGetNextTokenSpace (\r
914 IN CONST GUID *TokenSpaceGuid\r
915 )\r
916{\r
917 EFI_STATUS Status;\r
918\r
919 Status = (GetPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);\r
920\r
921 ASSERT_EFI_ERROR (Status);\r
922\r
923 return (GUID *) TokenSpaceGuid;\r
924}\r
925\r
926\r
927\r
928/**\r
929 Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
930 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than \r
931 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return \r
932 NULL to indicate that the set operation was not actually performed. \r
933 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to \r
934 MaximumDatumSize and NULL must be returned.\r
935 \r
936 If PatchVariable is NULL, then ASSERT().\r
937 If SizeOfBuffer is NULL, then ASSERT().\r
938 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
939\r
940 @param[in] PatchVariable A pointer to the global variable in a module that is \r
941 the target of the set operation.\r
942 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
943 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
944 In out, returns actual size of buffer is set.\r
945 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
946 \r
947 @return Return the pinter to the buffer been set.\r
948\r
949**/\r
950VOID *\r
951EFIAPI\r
952LibPatchPcdSetPtr (\r
953 IN VOID *PatchVariable,\r
954 IN UINTN MaximumDatumSize,\r
955 IN OUT UINTN *SizeOfBuffer,\r
956 IN CONST VOID *Buffer\r
957 )\r
958{\r
959 ASSERT (PatchVariable != NULL);\r
960 ASSERT (SizeOfBuffer != NULL);\r
961 \r
962 if (*SizeOfBuffer > 0) {\r
963 ASSERT (Buffer != NULL);\r
964 }\r
965\r
966 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
967 (*SizeOfBuffer == MAX_ADDRESS)) {\r
968 *SizeOfBuffer = MaximumDatumSize;\r
969 return NULL;\r
970 }\r
971 \r
972 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
973 \r
974 return (VOID *) Buffer;\r
975}\r
976\r
977\r