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