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