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