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