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