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