]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
b8a53185bd8d59b4c94571321e814a5941359bca
[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 PcdPpi = GetPcdPpiPtr ();
262
263 return PcdPpi->Get8Ex (Guid, TokenNumber);
264 }
265
266
267
268 /**
269 Returns the 16-bit value for the token specified by TokenNumber and Guid.
270 If Guid is NULL, then ASSERT().
271
272 @param[in] Guid Pointer to a 128-bit unique value that designates
273 which namespace to retrieve a value from.
274 @param[in] TokenNumber The PCD token number to retrieve a current value for.
275
276 @retval UINT16 Return the UINT16.
277
278 **/
279 UINT16
280 EFIAPI
281 LibPcdGetEx16 (
282 IN CONST GUID *Guid,
283 IN UINTN TokenNumber
284 )
285 {
286 PCD_PPI * PcdPpi;
287
288 PcdPpi = GetPcdPpiPtr ();
289
290 return PcdPpi->Get16Ex (Guid, TokenNumber);
291 }
292
293
294
295 /**
296 Returns the 32-bit value for the token specified by TokenNumber and Guid.
297 If Guid is NULL, then ASSERT().
298
299 @param[in] Guid Pointer to a 128-bit unique value that designates
300 which namespace to retrieve a value from.
301 @param[in] TokenNumber The PCD token number to retrieve a current value for.
302
303 @retval UINT32 Return the UINT32.
304
305 **/
306 UINT32
307 EFIAPI
308 LibPcdGetEx32 (
309 IN CONST GUID *Guid,
310 IN UINTN TokenNumber
311 )
312 {
313 PCD_PPI * PcdPpi;
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 PcdPpi = GetPcdPpiPtr ();
344
345 return PcdPpi->Get64Ex (Guid, TokenNumber);
346 }
347
348
349
350 /**
351 Returns the pointer to the token specified by TokenNumber and Guid.
352 If Guid is NULL, then ASSERT().
353
354 @param[in] Guid Pointer to a 128-bit unique value that designates
355 which namespace to retrieve a value from.
356 @param[in] TokenNumber The PCD token number to retrieve a current value for.
357
358 @retval VOID* Return the VOID* pointer.
359
360 **/
361 VOID *
362 EFIAPI
363 LibPcdGetExPtr (
364 IN CONST GUID *Guid,
365 IN UINTN TokenNumber
366 )
367 {
368 PCD_PPI * PcdPpi;
369
370 PcdPpi = GetPcdPpiPtr ();
371
372 return PcdPpi->GetPtrEx (Guid, TokenNumber);
373 }
374
375
376
377 /**
378 Returns the Boolean value of the token specified by TokenNumber and Guid.
379 If Guid is NULL, then ASSERT().
380
381 @param[in] Guid Pointer to a 128-bit unique value that designates
382 which namespace to retrieve a value from.
383 @param[in] TokenNumber The PCD token number to retrieve a current value for.
384
385 @retval BOOLEAN Return the BOOLEAN.
386
387 **/
388 BOOLEAN
389 EFIAPI
390 LibPcdGetExBool (
391 IN CONST GUID *Guid,
392 IN UINTN TokenNumber
393 )
394 {
395 PCD_PPI * PcdPpi;
396
397 PcdPpi = GetPcdPpiPtr ();
398
399 return PcdPpi->GetBoolEx (Guid, TokenNumber);
400 }
401
402
403
404 /**
405 Returns the size of the token specified by TokenNumber and Guid.
406 If Guid is NULL, then ASSERT().
407
408 @param[in] Guid Pointer to a 128-bit unique value that designates
409 which namespace to retrieve a value from.
410 @param[in] TokenNumber The PCD token number to retrieve a current value for.
411
412 @retval UINTN Return the size.
413
414 **/
415 UINTN
416 EFIAPI
417 LibPcdGetExSize (
418 IN CONST GUID *Guid,
419 IN UINTN TokenNumber
420 )
421 {
422 PCD_PPI * PcdPpi;
423
424 PcdPpi = GetPcdPpiPtr ();
425
426 return PcdPpi->GetSizeEx (Guid, TokenNumber);
427 }
428
429
430
431 /**
432 Sets the 8-bit value for the token specified by TokenNumber
433 to the value specified by Value. Value is returned.
434
435 @param[in] TokenNumber The PCD token number to set a current value for.
436 @param[in] Value The 8-bit value to set.
437
438 @retval UINT8 Return the value been set.
439
440 **/
441 UINT8
442 EFIAPI
443 LibPcdSet8 (
444 IN UINTN TokenNumber,
445 IN UINT8 Value
446 )
447 {
448 EFI_STATUS Status;
449 PCD_PPI * PcdPpi;
450
451 PcdPpi = GetPcdPpiPtr ();
452
453
454 Status = PcdPpi->Set8 (TokenNumber, Value);
455
456 ASSERT_EFI_ERROR (Status);
457
458 return Value;
459 }
460
461
462
463 /**
464 Sets the 16-bit value for the token specified by TokenNumber
465 to the value specified by Value. Value is returned.
466
467 @param[in] TokenNumber The PCD token number to set a current value for.
468 @param[in] Value The 16-bit value to set.
469
470 @retval UINT16 Return the value been set.
471
472 **/
473 UINT16
474 EFIAPI
475 LibPcdSet16 (
476 IN UINTN TokenNumber,
477 IN UINT16 Value
478 )
479 {
480 EFI_STATUS Status;
481 PCD_PPI * PcdPpi;
482
483 PcdPpi = GetPcdPpiPtr ();
484
485
486 Status = PcdPpi->Set16 (TokenNumber, Value);
487
488 ASSERT_EFI_ERROR (Status);
489
490 return Value;
491 }
492
493
494
495 /**
496 Sets the 32-bit value for the token specified by TokenNumber
497 to the value specified by Value. Value is returned.
498
499 @param[in] TokenNumber The PCD token number to set a current value for.
500 @param[in] Value The 32-bit value to set.
501
502 @retval UINT32 Return the value been set.
503
504 **/
505 UINT32
506 EFIAPI
507 LibPcdSet32 (
508 IN UINTN TokenNumber,
509 IN UINT32 Value
510 )
511 {
512 EFI_STATUS Status;
513 PCD_PPI * PcdPpi;
514
515 PcdPpi = GetPcdPpiPtr ();
516
517 Status = PcdPpi->Set32 (TokenNumber, Value);
518
519 ASSERT_EFI_ERROR (Status);
520
521 return Value;
522 }
523
524
525
526 /**
527 Sets the 64-bit value for the token specified by TokenNumber
528 to the value specified by Value. Value is returned.
529
530 @param[in] TokenNumber The PCD token number to set a current value for.
531 @param[in] Value The 64-bit value to set.
532
533 @retval UINT64 Return the value been set.
534
535 **/
536 UINT64
537 EFIAPI
538 LibPcdSet64 (
539 IN UINTN TokenNumber,
540 IN UINT64 Value
541 )
542 {
543 EFI_STATUS Status;
544 PCD_PPI * PcdPpi;
545
546 PcdPpi = GetPcdPpiPtr ();
547
548
549 Status = PcdPpi->Set64 (TokenNumber, Value);
550
551 ASSERT_EFI_ERROR (Status);
552
553 return Value;
554 }
555
556
557
558 /**
559 Sets a buffer for the token specified by TokenNumber to
560 the value specified by Buffer and SizeOfValue. Buffer to
561 be set is returned. The content of the buffer could be
562 overwritten if a Callback on SET is registered with this
563 TokenNumber.
564
565 If SizeOfValue is greater than the maximum
566 size support by TokenNumber, then set SizeOfValue to the
567 maximum size supported by TokenNumber and return NULL to
568 indicate that the set operation was not actually performed.
569
570 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
571
572 @param[in] TokenNumber The PCD token number to set a current value for.
573 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.
574 @param[in] Value A pointer to the buffer to set.
575
576 @retval VOID* Return the pointer for the buffer been set.
577
578 **/
579 VOID *
580 EFIAPI
581 LibPcdSetPtr (
582 IN UINTN TokenNumber,
583 IN OUT UINTN *SizeOfBuffer,
584 IN VOID *Buffer
585 )
586 {
587 EFI_STATUS Status;
588 PCD_PPI *PcdPpi;
589
590 ASSERT (SizeOfBuffer != NULL);
591
592 if (*SizeOfBuffer > 0) {
593 ASSERT (Buffer != NULL);
594 }
595
596 PcdPpi = GetPcdPpiPtr ();
597
598 Status = PcdPpi->SetPtr (TokenNumber, SizeOfBuffer, Buffer);
599
600 if (EFI_ERROR (Status)) {
601 return NULL;
602 }
603
604 return Buffer;
605 }
606
607
608
609 /**
610 Sets the Boolean value for the token specified by TokenNumber
611 to the value specified by Value. Value is returned.
612
613 @param[in] TokenNumber The PCD token number to set a current value for.
614 @param[in] Value The boolean value to set.
615
616 @retval BOOLEAN Return the value been set.
617
618 **/
619 BOOLEAN
620 EFIAPI
621 LibPcdSetBool (
622 IN UINTN TokenNumber,
623 IN BOOLEAN Value
624 )
625 {
626 EFI_STATUS Status;
627 PCD_PPI * PcdPpi;
628
629 PcdPpi = GetPcdPpiPtr ();
630
631
632 Status = PcdPpi->SetBool (TokenNumber, Value);
633
634 ASSERT_EFI_ERROR (Status);
635
636 return Value;
637 }
638
639
640
641 /**
642 Sets the 8-bit value for the token specified by TokenNumber and
643 Guid to the value specified by Value. Value is returned.
644 If Guid is NULL, then ASSERT().
645
646 @param[in] Guid Pointer to a 128-bit unique value that
647 designates which namespace to set a value from.
648 @param[in] TokenNumber The PCD token number to set a current value for.
649 @param[in] Value The 8-bit value to set.
650
651 @retval UINT8 Return the value been set.
652
653 **/
654 UINT8
655 EFIAPI
656 LibPcdSetEx8 (
657 IN CONST GUID *Guid,
658 IN UINTN TokenNumber,
659 IN UINT8 Value
660 )
661 {
662 EFI_STATUS Status;
663 PCD_PPI * PcdPpi;
664
665 PcdPpi = GetPcdPpiPtr ();
666
667
668 Status = PcdPpi->Set8Ex (Guid, TokenNumber, Value);
669
670 ASSERT_EFI_ERROR (Status);
671
672 return Value;
673 }
674
675
676
677 /**
678 Sets the 16-bit value for the token specified by TokenNumber and
679 Guid to the value specified by Value. Value is returned.
680 If Guid is NULL, then ASSERT().
681
682 @param[in] Guid Pointer to a 128-bit unique value that
683 designates which namespace to set a value from.
684 @param[in] TokenNumber The PCD token number to set a current value for.
685 @param[in] Value The 16-bit value to set.
686
687 @retval UINT8 Return the value been set.
688
689 **/
690 UINT16
691 EFIAPI
692 LibPcdSetEx16 (
693 IN CONST GUID *Guid,
694 IN UINTN TokenNumber,
695 IN UINT16 Value
696 )
697 {
698 EFI_STATUS Status;
699 PCD_PPI * PcdPpi;
700
701 PcdPpi = GetPcdPpiPtr ();
702
703
704 Status = PcdPpi->Set16Ex (Guid, TokenNumber, Value);
705
706 ASSERT_EFI_ERROR (Status);
707
708 return Value;
709 }
710
711
712
713 /**
714 Sets the 32-bit value for the token specified by TokenNumber and
715 Guid to the value specified by Value. Value is returned.
716 If Guid is NULL, then ASSERT().
717
718 @param[in] Guid Pointer to a 128-bit unique value that
719 designates which namespace to set a value from.
720 @param[in] TokenNumber The PCD token number to set a current value for.
721 @param[in] Value The 32-bit value to set.
722
723 @retval UINT32 Return the value been set.
724
725 **/
726 UINT32
727 EFIAPI
728 LibPcdSetEx32 (
729 IN CONST GUID *Guid,
730 IN UINTN TokenNumber,
731 IN UINT32 Value
732 )
733 {
734 EFI_STATUS Status;
735 PCD_PPI * PcdPpi;
736
737 PcdPpi = GetPcdPpiPtr ();
738
739
740 Status = PcdPpi->Set32Ex (Guid, TokenNumber, Value);
741
742 ASSERT_EFI_ERROR (Status);
743
744 return Value;
745 }
746
747
748
749 /**
750 Sets the 64-bit value for the token specified by TokenNumber and
751 Guid to the value specified by Value. Value is returned.
752 If Guid is NULL, then ASSERT().
753
754 @param[in] Guid Pointer to a 128-bit unique value that
755 designates which namespace to set a value from.
756 @param[in] TokenNumber The PCD token number to set a current value for.
757 @param[in] Value The 64-bit value to set.
758
759 @retval UINT64 Return the value been set.
760
761 **/
762 UINT64
763 EFIAPI
764 LibPcdSetEx64 (
765 IN CONST GUID *Guid,
766 IN UINTN TokenNumber,
767 IN UINT64 Value
768 )
769 {
770 EFI_STATUS Status;
771 PCD_PPI * PcdPpi;
772
773 PcdPpi = GetPcdPpiPtr ();
774
775
776 Status = PcdPpi->Set64Ex (Guid, TokenNumber, Value);
777
778 ASSERT_EFI_ERROR (Status);
779
780 return Value;
781 }
782
783
784
785 /**
786 Sets a buffer for the token specified by TokenNumber to the value specified by
787 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
788 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
789 supported by TokenNumber and return NULL to indicate that the set operation
790 was not actually performed.
791
792 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
793
794 @param[in] Guid Pointer to a 128-bit unique value that
795 designates which namespace to set a value from.
796 @param[in] TokenNumber The PCD token number to set a current value for.
797 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
798 @param[in] Buffer A pointer to the buffer to set.
799
800 @retval VOID * Return the pinter to the buffer been set.
801
802 **/
803 VOID *
804 EFIAPI
805 LibPcdSetExPtr (
806 IN CONST GUID *Guid,
807 IN UINTN TokenNumber,
808 IN OUT UINTN *SizeOfBuffer,
809 IN VOID *Buffer
810 )
811 {
812 EFI_STATUS Status;
813 PCD_PPI *PcdPpi;
814
815 if (*SizeOfBuffer > 0) {
816 ASSERT (Buffer != NULL);
817 }
818
819 PcdPpi = GetPcdPpiPtr ();
820
821 Status = PcdPpi->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);
822
823 if (EFI_ERROR (Status)) {
824 return NULL;
825 }
826
827 return Buffer;
828 }
829
830
831
832 /**
833 Sets the Boolean value for the token specified by TokenNumber and
834 Guid to the value specified by Value. Value is returned.
835 If Guid is NULL, then ASSERT().
836
837 @param[in] Guid Pointer to a 128-bit unique value that
838 designates which namespace to set a value from.
839 @param[in] TokenNumber The PCD token number to set a current value for.
840 @param[in] Value The Boolean value to set.
841
842 @retval Boolean Return the value been set.
843
844 **/
845 BOOLEAN
846 EFIAPI
847 LibPcdSetExBool (
848 IN CONST GUID *Guid,
849 IN UINTN TokenNumber,
850 IN BOOLEAN Value
851 )
852 {
853 EFI_STATUS Status;
854 PCD_PPI * PcdPpi;
855
856 PcdPpi = GetPcdPpiPtr ();
857
858
859 Status = PcdPpi->SetBoolEx (Guid, TokenNumber, Value);
860
861 ASSERT_EFI_ERROR (Status);
862
863 return Value;
864 }
865
866
867
868 /**
869 When the token specified by TokenNumber and Guid is set,
870 then notification function specified by NotificationFunction is called.
871 If Guid is NULL, then the default token space is used.
872 If NotificationFunction is NULL, then ASSERT().
873
874 @param[in] Guid Pointer to a 128-bit unique value that designates which
875 namespace to set a value from. If NULL, then the default
876 token space is used.
877 @param[in] TokenNumber The PCD token number to monitor.
878 @param[in] NotificationFunction The function to call when the token
879 specified by Guid and TokenNumber is set.
880
881 @retval VOID
882
883 **/
884 VOID
885 EFIAPI
886 LibPcdCallbackOnSet (
887 IN CONST GUID *Guid, OPTIONAL
888 IN UINTN TokenNumber,
889 IN PCD_CALLBACK NotificationFunction
890 )
891 {
892 EFI_STATUS Status;
893 PCD_PPI * PcdPpi;
894
895 PcdPpi = GetPcdPpiPtr ();
896
897
898 Status = PcdPpi->CallbackOnSet (TokenNumber, Guid, NotificationFunction);
899
900 ASSERT_EFI_ERROR (Status);
901
902 return;
903 }
904
905
906
907 /**
908 Disable a notification function that was established with LibPcdCallbackonSet().
909 If NotificationFunction is NULL, then ASSERT().
910
911 @param[in] Guid Specify the GUID token space.
912 @param[in] TokenNumber Specify the token number.
913 @param[in] NotificationFunction The callback function to be unregistered.
914
915 @retval VOID
916
917 **/
918 VOID
919 EFIAPI
920 LibPcdCancelCallback (
921 IN CONST GUID *Guid, OPTIONAL
922 IN UINTN TokenNumber,
923 IN PCD_CALLBACK NotificationFunction
924 )
925 {
926 EFI_STATUS Status;
927 PCD_PPI * PcdPpi;
928
929 PcdPpi = GetPcdPpiPtr ();
930
931
932 Status = PcdPpi->CancelCallback (TokenNumber, Guid, NotificationFunction);
933
934 ASSERT_EFI_ERROR (Status);
935
936 return;
937 }
938
939
940
941 /**
942 Retrieves the next PCD token number from the token space specified by Guid.
943 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
944 then the first token number is returned. Otherwise, the token number that
945 follows TokenNumber in the token space is returned. If TokenNumber is the last
946 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
947 is not in the token space specified by Guid, then ASSERT().
948
949 @param[in] Pointer to a 128-bit unique value that designates which namespace
950 to set a value from. If NULL, then the default token space is used.
951 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
952 token number.
953
954 @retval UINTN The next valid token number.
955
956 **/
957 UINTN
958 EFIAPI
959 LibPcdGetNextToken (
960 IN CONST GUID *Guid, OPTIONAL
961 IN UINTN TokenNumber
962 )
963 {
964 EFI_STATUS Status;
965 PCD_PPI * PcdPpi;
966
967 PcdPpi = GetPcdPpiPtr ();
968
969
970 Status = PcdPpi->GetNextToken (Guid, &TokenNumber);
971
972 ASSERT_EFI_ERROR (Status);
973
974 return TokenNumber;
975 }
976
977
978 /**
979 Retrieves the next PCD token space from a token space specified by Guid.
980 Guid of NULL is reserved to mark the default local token namespace on the current
981 platform. If Guid is NULL, then the GUID of the first non-local token space of the
982 current platform is returned. If Guid is the last non-local token space,
983 then NULL is returned.
984
985 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
986
987
988
989 @param[in] Pointer to a 128-bit unique value that designates from which namespace
990 to start the search.
991
992 @retval CONST GUID * The next valid token namespace.
993
994 **/
995 GUID *
996 EFIAPI
997 LibPcdGetNextTokenSpace (
998 IN CONST GUID *Guid
999 )
1000 {
1001 EFI_STATUS Status;
1002 PCD_PPI * PcdPpi;
1003
1004 PcdPpi = GetPcdPpiPtr ();
1005
1006
1007 Status = PcdPpi->GetNextTokenSpace (&Guid);
1008
1009 ASSERT_EFI_ERROR (Status);
1010
1011 return (GUID *)Guid;
1012 }
1013
1014
1015
1016 /**
1017 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1018 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
1019 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
1020 NULL to indicate that the set operation was not actually performed.
1021 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
1022 MaximumDatumSize and NULL must be returned.
1023
1024 If PatchVariable is NULL, then ASSERT().
1025 If SizeOfValue is NULL, then ASSERT().
1026 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
1027
1028 @param[in] PatchVariable A pointer to the global variable in a module that is
1029 the target of the set operation.
1030 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1031 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1032 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1033
1034 **/
1035 VOID *
1036 EFIAPI
1037 LibPatchPcdSetPtr (
1038 IN VOID *PatchVariable,
1039 IN UINTN MaximumDatumSize,
1040 IN OUT UINTN *SizeOfBuffer,
1041 IN CONST VOID *Buffer
1042 )
1043 {
1044 ASSERT (PatchVariable != NULL);
1045 ASSERT (SizeOfBuffer != NULL);
1046
1047 if (*SizeOfBuffer > 0) {
1048 ASSERT (Buffer != NULL);
1049 }
1050
1051 if ((*SizeOfBuffer > MaximumDatumSize) ||
1052 (*SizeOfBuffer == MAX_ADDRESS)) {
1053 *SizeOfBuffer = MaximumDatumSize;
1054 return NULL;
1055 }
1056
1057 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1058
1059 return (VOID *) Buffer;
1060 }
1061
1062