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