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