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