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