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