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