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