]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/DxePcdLib/DxePcdLib.c
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Library / DxePcdLib / DxePcdLib.c
1 /** @file
2 Implementation of PcdLib class library for DXE phase.
3
4 Copyright (c) 2006 - 2018, 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 #include <Protocol/PcdInfo.h>
22 #include <Protocol/PiPcdInfo.h>
23
24 #include <Library/PcdLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/UefiBootServicesTableLib.h>
27 #include <Library/BaseMemoryLib.h>
28
29 PCD_PROTOCOL *mPcd = NULL;
30 EFI_PCD_PROTOCOL *mPiPcd = NULL;
31 GET_PCD_INFO_PROTOCOL *mPcdInfo = NULL;
32 EFI_GET_PCD_INFO_PROTOCOL *mPiPcdInfo = NULL;
33
34 /**
35 Retrieves the PI PCD protocol from the handle database.
36
37 @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.
38 **/
39 EFI_PCD_PROTOCOL *
40 EFIAPI
41 GetPiPcdProtocol (
42 VOID
43 )
44 {
45 EFI_STATUS Status;
46
47 if (mPiPcd == NULL) {
48 //
49 // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module
50 // access DynamicEx type PCD.
51 //
52 Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd);
53 ASSERT_EFI_ERROR (Status);
54 ASSERT (mPiPcd != NULL);
55 }
56 return mPiPcd;
57 }
58
59 /**
60 Retrieves the PCD protocol from the handle database.
61
62 @retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL.
63 **/
64 PCD_PROTOCOL *
65 EFIAPI
66 GetPcdProtocol (
67 VOID
68 )
69 {
70 EFI_STATUS Status;
71
72 if (mPcd == NULL) {
73 //
74 // PCD protocol need to be installed before the module access Dynamic type PCD.
75 // But dynamic type PCD is not required in PI 1.2 specification.
76 //
77 Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd);
78 ASSERT_EFI_ERROR (Status);
79 ASSERT (mPcd != NULL);
80 }
81 return mPcd;
82 }
83
84 /**
85 Retrieves the PI PCD info protocol from the handle database.
86
87 @retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3.
88 **/
89 EFI_GET_PCD_INFO_PROTOCOL *
90 GetPiPcdInfoProtocolPointer (
91 VOID
92 )
93 {
94 EFI_STATUS Status;
95
96 if (mPiPcdInfo == NULL) {
97 Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo);
98 ASSERT_EFI_ERROR (Status);
99 ASSERT (mPiPcdInfo != NULL);
100 }
101 return mPiPcdInfo;
102 }
103
104 /**
105 Retrieves the PCD info protocol from the handle database.
106
107 @retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL.
108 **/
109 GET_PCD_INFO_PROTOCOL *
110 GetPcdInfoProtocolPointer (
111 VOID
112 )
113 {
114 EFI_STATUS Status;
115
116 if (mPcdInfo == NULL) {
117 Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo);
118 ASSERT_EFI_ERROR (Status);
119 ASSERT (mPcdInfo != NULL);
120 }
121 return mPcdInfo;
122 }
123
124 /**
125 This function provides a means by which SKU support can be established in the PCD infrastructure.
126
127 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
128
129 @param SkuId The SKU value that will be used when the PCD service retrieves and sets values
130 associated with a PCD token.
131
132 @return Return the SKU ID that just be set.
133
134 **/
135 UINTN
136 EFIAPI
137 LibPcdSetSku (
138 IN UINTN SkuId
139 )
140 {
141 GetPcdProtocol()->SetSku (SkuId);
142
143 return SkuId;
144 }
145
146
147
148 /**
149 This function provides a means by which to retrieve a value for a given PCD token.
150
151 Returns the 8-bit value for the token specified by TokenNumber.
152
153 @param[in] TokenNumber The PCD token number to retrieve a current value for.
154
155 @return Returns the 8-bit value for the token specified by TokenNumber.
156
157 **/
158 UINT8
159 EFIAPI
160 LibPcdGet8 (
161 IN UINTN TokenNumber
162 )
163 {
164 return GetPcdProtocol()->Get8 (TokenNumber);
165 }
166
167
168
169 /**
170 This function provides a means by which to retrieve a value for a given PCD token.
171
172 Returns the 16-bit value for the token specified by TokenNumber.
173
174 @param[in] TokenNumber The PCD token number to retrieve a current value for.
175
176 @return Returns the 16-bit value for the token specified by TokenNumber.
177
178 **/
179 UINT16
180 EFIAPI
181 LibPcdGet16 (
182 IN UINTN TokenNumber
183 )
184 {
185 return GetPcdProtocol()->Get16 (TokenNumber);
186 }
187
188
189
190 /**
191 This function provides a means by which to retrieve a value for a given PCD token.
192
193 Returns the 32-bit value for the token specified by TokenNumber.
194
195 @param[in] TokenNumber The PCD token number to retrieve a current value for.
196
197 @return Returns the 32-bit value for the token specified by TokenNumber.
198
199 **/
200 UINT32
201 EFIAPI
202 LibPcdGet32 (
203 IN UINTN TokenNumber
204 )
205 {
206 return GetPcdProtocol()->Get32 (TokenNumber);
207 }
208
209
210
211 /**
212 This function provides a means by which to retrieve a value for a given PCD token.
213
214 Returns the 64-bit value for the token specified by TokenNumber.
215
216 @param[in] TokenNumber The PCD token number to retrieve a current value for.
217
218 @return Returns the 64-bit value for the token specified by TokenNumber.
219
220 **/
221 UINT64
222 EFIAPI
223 LibPcdGet64 (
224 IN UINTN TokenNumber
225 )
226 {
227 return GetPcdProtocol()->Get64 (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 pointer to the buffer of the token specified by TokenNumber.
236
237 @param[in] TokenNumber The PCD token number to retrieve a current value for.
238
239 @return Returns the pointer to the token specified by TokenNumber.
240
241 **/
242 VOID *
243 EFIAPI
244 LibPcdGetPtr (
245 IN UINTN TokenNumber
246 )
247 {
248 return GetPcdProtocol()->GetPtr (TokenNumber);
249 }
250
251
252
253 /**
254 This function provides a means by which to retrieve a value for a given PCD token.
255
256 Returns the Boolean value of the token specified by TokenNumber.
257
258 @param[in] TokenNumber The PCD token number to retrieve a current value for.
259
260 @return Returns the Boolean value of the token specified by TokenNumber.
261
262 **/
263 BOOLEAN
264 EFIAPI
265 LibPcdGetBool (
266 IN UINTN TokenNumber
267 )
268 {
269 return GetPcdProtocol()->GetBool (TokenNumber);
270 }
271
272
273
274 /**
275 This function provides a means by which to retrieve the size of a given PCD token.
276
277 @param[in] TokenNumber The PCD token number to retrieve a current value for.
278
279 @return Returns the size of the token specified by TokenNumber.
280
281 **/
282 UINTN
283 EFIAPI
284 LibPcdGetSize (
285 IN UINTN TokenNumber
286 )
287 {
288 return GetPcdProtocol()->GetSize (TokenNumber);
289 }
290
291
292
293 /**
294 This function provides a means by which to retrieve a value for a given PCD token.
295
296 Returns the 8-bit value for the token specified by TokenNumber and Guid.
297
298 If Guid is NULL, then ASSERT().
299
300 @param[in] Guid The pointer to a 128-bit unique value that designates
301 which namespace to retrieve a value from.
302 @param[in] TokenNumber The PCD token number to retrieve a current value for.
303
304 @return Return the UINT8.
305
306 **/
307 UINT8
308 EFIAPI
309 LibPcdGetEx8 (
310 IN CONST GUID *Guid,
311 IN UINTN TokenNumber
312 )
313 {
314 ASSERT (Guid != NULL);
315
316 return GetPiPcdProtocol()->Get8 (Guid, TokenNumber);
317 }
318
319
320 /**
321 This function provides a means by which to retrieve a value for a given PCD token.
322
323 Returns the 16-bit value for the token specified by TokenNumber and Guid.
324
325 If Guid is NULL, then ASSERT().
326
327 @param[in] Guid The pointer to a 128-bit unique value that designates
328 which namespace to retrieve a value from.
329 @param[in] TokenNumber The PCD token number to retrieve a current value for.
330
331 @return Return the UINT16.
332
333 **/
334 UINT16
335 EFIAPI
336 LibPcdGetEx16 (
337 IN CONST GUID *Guid,
338 IN UINTN TokenNumber
339 )
340 {
341 ASSERT (Guid != NULL);
342
343 return GetPiPcdProtocol()->Get16 (Guid, TokenNumber);
344 }
345
346
347 /**
348 Returns the 32-bit value for the token specified by TokenNumber and Guid.
349 If Guid is NULL, then ASSERT().
350
351 @param[in] Guid The pointer to a 128-bit unique value that designates
352 which namespace to retrieve a value from.
353 @param[in] TokenNumber The PCD token number to retrieve a current value for.
354
355 @return Return the UINT32.
356
357 **/
358 UINT32
359 EFIAPI
360 LibPcdGetEx32 (
361 IN CONST GUID *Guid,
362 IN UINTN TokenNumber
363 )
364 {
365 ASSERT (Guid != NULL);
366
367 return GetPiPcdProtocol()->Get32 (Guid, TokenNumber);
368 }
369
370
371
372 /**
373 This function provides a means by which to retrieve a value for a given PCD token.
374
375 Returns the 64-bit value for the token specified by TokenNumber and Guid.
376
377 If Guid is NULL, then ASSERT().
378
379 @param[in] Guid The pointer to a 128-bit unique value that designates
380 which namespace to retrieve a value from.
381 @param[in] TokenNumber The PCD token number to retrieve a current value for.
382
383 @return Return the UINT64.
384
385 **/
386 UINT64
387 EFIAPI
388 LibPcdGetEx64 (
389 IN CONST GUID *Guid,
390 IN UINTN TokenNumber
391 )
392 {
393 ASSERT (Guid != NULL);
394
395 return GetPiPcdProtocol()->Get64 (Guid, TokenNumber);
396 }
397
398
399
400 /**
401 This function provides a means by which to retrieve a value for a given PCD token.
402
403 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
404
405 If Guid is NULL, then ASSERT().
406
407 @param[in] Guid The pointer to a 128-bit unique value that designates
408 which namespace to retrieve a value from.
409 @param[in] TokenNumber The PCD token number to retrieve a current value for.
410
411 @return Return the VOID* pointer.
412
413 **/
414 VOID *
415 EFIAPI
416 LibPcdGetExPtr (
417 IN CONST GUID *Guid,
418 IN UINTN TokenNumber
419 )
420 {
421 ASSERT (Guid != NULL);
422
423 return GetPiPcdProtocol()->GetPtr (Guid, TokenNumber);
424 }
425
426
427
428 /**
429 This function provides a means by which to retrieve a value for a given PCD token.
430
431 Returns the Boolean value of the token specified by TokenNumber and Guid.
432
433 If Guid is NULL, then ASSERT().
434
435 @param[in] Guid The pointer to a 128-bit unique value that designates
436 which namespace to retrieve a value from.
437 @param[in] TokenNumber The PCD token number to retrieve a current value for.
438
439 @return Return the BOOLEAN.
440
441 **/
442 BOOLEAN
443 EFIAPI
444 LibPcdGetExBool (
445 IN CONST GUID *Guid,
446 IN UINTN TokenNumber
447 )
448 {
449 ASSERT (Guid != NULL);
450
451 return GetPiPcdProtocol()->GetBool (Guid, TokenNumber);
452 }
453
454
455
456 /**
457 This function provides a means by which to retrieve the size of a given PCD token.
458
459 Returns the size of the token specified by TokenNumber and Guid.
460
461 If Guid is NULL, then ASSERT().
462
463 @param[in] Guid The pointer to a 128-bit unique value that designates
464 which namespace to retrieve a value from.
465 @param[in] TokenNumber The PCD token number to retrieve a current value for.
466
467 @return Return the size.
468
469 **/
470 UINTN
471 EFIAPI
472 LibPcdGetExSize (
473 IN CONST GUID *Guid,
474 IN UINTN TokenNumber
475 )
476 {
477 ASSERT (Guid != NULL);
478
479 return GetPiPcdProtocol()->GetSize (Guid, TokenNumber);
480 }
481
482
483
484 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
485 /**
486 This function provides a means by which to set a value for a given PCD token.
487
488 Sets the 8-bit value for the token specified by TokenNumber
489 to the value specified by Value. Value is returned.
490
491 @param[in] TokenNumber The PCD token number to set a current value for.
492 @param[in] Value The 8-bit value to set.
493
494 @return Return the value that was set.
495
496 **/
497 UINT8
498 EFIAPI
499 LibPcdSet8 (
500 IN UINTN TokenNumber,
501 IN UINT8 Value
502 )
503 {
504 GetPcdProtocol()->Set8 (TokenNumber, Value);
505
506 return Value;
507 }
508
509
510
511 /**
512 This function provides a means by which to set a value for a given PCD token.
513
514 Sets the 16-bit value for the token specified by TokenNumber
515 to the value specified by Value. Value is returned.
516
517 @param[in] TokenNumber The PCD token number to set a current value for.
518 @param[in] Value The 16-bit value to set.
519
520 @return Return the value that was set.
521
522 **/
523 UINT16
524 EFIAPI
525 LibPcdSet16 (
526 IN UINTN TokenNumber,
527 IN UINT16 Value
528 )
529 {
530 GetPcdProtocol()->Set16 (TokenNumber, Value);
531
532 return Value;
533 }
534
535
536
537 /**
538 This function provides a means by which to set a value for a given PCD token.
539
540 Sets the 32-bit value for the token specified by TokenNumber
541 to the value specified by Value. Value is returned.
542
543 @param[in] TokenNumber The PCD token number to set a current value for.
544 @param[in] Value The 32-bit value to set.
545
546 @return Return the value that was set.
547
548 **/
549 UINT32
550 EFIAPI
551 LibPcdSet32 (
552 IN UINTN TokenNumber,
553 IN UINT32 Value
554 )
555 {
556 GetPcdProtocol()->Set32 (TokenNumber, Value);
557
558 return Value;
559 }
560
561
562
563 /**
564 This function provides a means by which to set a value for a given PCD token.
565
566 Sets the 64-bit value for the token specified by TokenNumber
567 to the value specified by Value. Value is returned.
568
569 @param[in] TokenNumber The PCD token number to set a current value for.
570 @param[in] Value The 64-bit value to set.
571
572 @return Return the value that was set.
573
574 **/
575 UINT64
576 EFIAPI
577 LibPcdSet64 (
578 IN UINTN TokenNumber,
579 IN UINT64 Value
580 )
581 {
582 GetPcdProtocol()->Set64 (TokenNumber, Value);
583
584 return Value;
585 }
586
587
588
589 /**
590 This function provides a means by which to set a value for a given PCD token.
591
592 Sets a buffer for the token specified by TokenNumber to the value
593 specified by Buffer and SizeOfBuffer. Buffer is returned.
594 If SizeOfBuffer is greater than the maximum size support by TokenNumber,
595 then set SizeOfBuffer to the maximum size supported by TokenNumber and
596 return NULL to indicate that the set operation was not actually performed.
597
598 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
599 maximum size supported by TokenName and NULL must be returned.
600
601 If SizeOfBuffer is NULL, then ASSERT().
602 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
603
604 @param[in] TokenNumber The PCD token number to set a current value for.
605 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
606 @param[in] Buffer A pointer to the buffer to set.
607
608 @return Return the pointer for the buffer been set.
609
610 **/
611 VOID *
612 EFIAPI
613 LibPcdSetPtr (
614 IN UINTN TokenNumber,
615 IN OUT UINTN *SizeOfBuffer,
616 IN CONST VOID *Buffer
617 )
618 {
619 EFI_STATUS Status;
620 UINTN InputSizeOfBuffer;
621
622 ASSERT (SizeOfBuffer != NULL);
623
624 if (*SizeOfBuffer > 0) {
625 ASSERT (Buffer != NULL);
626 }
627
628 InputSizeOfBuffer = *SizeOfBuffer;
629 Status = GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
630 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
631 return NULL;
632 }
633
634 return (VOID *)Buffer;
635 }
636
637
638
639 /**
640 This function provides a means by which to set a value for a given PCD token.
641
642 Sets the Boolean value for the token specified by TokenNumber
643 to the value specified by Value. Value is returned.
644
645 @param[in] TokenNumber The PCD token number to set a current value for.
646 @param[in] Value The boolean value to set.
647
648 @return Return the value that was set.
649
650 **/
651 BOOLEAN
652 EFIAPI
653 LibPcdSetBool (
654 IN UINTN TokenNumber,
655 IN BOOLEAN Value
656 )
657 {
658 GetPcdProtocol()->SetBool (TokenNumber, Value);
659
660 return Value;
661 }
662
663
664
665 /**
666 This function provides a means by which to set a value for a given PCD token.
667
668 Sets the 8-bit value for the token specified by TokenNumber and
669 Guid to the value specified by Value. Value is returned.
670
671 If Guid is NULL, then ASSERT().
672
673 @param[in] Guid The pointer to a 128-bit unique value that
674 designates which namespace to set a value from.
675 @param[in] TokenNumber The PCD token number to set a current value for.
676 @param[in] Value The 8-bit value to set.
677
678 @return Return the value that was set.
679
680 **/
681 UINT8
682 EFIAPI
683 LibPcdSetEx8 (
684 IN CONST GUID *Guid,
685 IN UINTN TokenNumber,
686 IN UINT8 Value
687 )
688 {
689 ASSERT (Guid != NULL);
690
691 GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);
692
693 return Value;
694 }
695
696
697
698 /**
699 This function provides a means by which to set a value for a given PCD token.
700
701 Sets the 16-bit value for the token specified by TokenNumber and
702 Guid to the value specified by Value. Value is returned.
703
704 If Guid is NULL, then ASSERT().
705
706 @param[in] Guid The pointer to a 128-bit unique value that
707 designates which namespace to set a value from.
708 @param[in] TokenNumber The PCD token number to set a current value for.
709 @param[in] Value The 16-bit value to set.
710
711 @return Return the value that was set.
712
713 **/
714 UINT16
715 EFIAPI
716 LibPcdSetEx16 (
717 IN CONST GUID *Guid,
718 IN UINTN TokenNumber,
719 IN UINT16 Value
720 )
721 {
722 ASSERT (Guid != NULL);
723
724 GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);
725
726 return Value;
727 }
728
729
730
731 /**
732 This function provides a means by which to set a value for a given PCD token.
733
734 Sets the 32-bit value for the token specified by TokenNumber and
735 Guid to the value specified by Value. Value is returned.
736
737 If Guid is NULL, then ASSERT().
738
739 @param[in] Guid The 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 32-bit value to set.
743
744 @return Return the value that was set.
745
746 **/
747 UINT32
748 EFIAPI
749 LibPcdSetEx32 (
750 IN CONST GUID *Guid,
751 IN UINTN TokenNumber,
752 IN UINT32 Value
753 )
754 {
755 ASSERT (Guid != NULL);
756
757 GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);
758
759 return Value;
760 }
761
762
763
764 /**
765 This function provides a means by which to set a value for a given PCD token.
766
767 Sets the 64-bit value for the token specified by TokenNumber and
768 Guid to the value specified by Value. Value is returned.
769
770 If Guid is NULL, then ASSERT().
771
772 @param[in] Guid The 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] Value The 64-bit value to set.
776
777 @return Return the value that was set.
778
779 **/
780 UINT64
781 EFIAPI
782 LibPcdSetEx64 (
783 IN CONST GUID *Guid,
784 IN UINTN TokenNumber,
785 IN UINT64 Value
786 )
787 {
788 ASSERT (Guid != NULL);
789
790 GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);
791
792 return Value;
793 }
794
795
796
797 /**
798 This function provides a means by which to set a value for a given PCD token.
799
800 Sets a buffer for the token specified by TokenNumber to the value specified by
801 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
802 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
803 supported by TokenNumber and return NULL to indicate that the set operation
804 was not actually performed.
805
806 If Guid is NULL, then ASSERT().
807 If SizeOfBuffer is NULL, then ASSERT().
808 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
809
810 @param[in] Guid The pointer to a 128-bit unique value that
811 designates which namespace to set a value from.
812 @param[in] TokenNumber The PCD token number to set a current value for.
813 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
814 @param[in] Buffer A pointer to the buffer to set.
815
816 @return Return the pointer to the buffer been set.
817
818 **/
819 VOID *
820 EFIAPI
821 LibPcdSetExPtr (
822 IN CONST GUID *Guid,
823 IN UINTN TokenNumber,
824 IN OUT UINTN *SizeOfBuffer,
825 IN VOID *Buffer
826 )
827 {
828 EFI_STATUS Status;
829 UINTN InputSizeOfBuffer;
830
831 ASSERT (Guid != NULL);
832
833 ASSERT (SizeOfBuffer != NULL);
834
835 if (*SizeOfBuffer > 0) {
836 ASSERT (Buffer != NULL);
837 }
838
839 InputSizeOfBuffer = *SizeOfBuffer;
840 Status = GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
841 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
842 return NULL;
843 }
844
845 return Buffer;
846 }
847
848
849
850 /**
851 This function provides a means by which to set a value for a given PCD token.
852
853 Sets the Boolean value for the token specified by TokenNumber and
854 Guid to the value specified by Value. Value is returned.
855
856 If Guid is NULL, then ASSERT().
857
858 @param[in] Guid The pointer to a 128-bit unique value that
859 designates which namespace to set a value from.
860 @param[in] TokenNumber The PCD token number to set a current value for.
861 @param[in] Value The Boolean value to set.
862
863 @return Return the value that was set.
864
865 **/
866 BOOLEAN
867 EFIAPI
868 LibPcdSetExBool (
869 IN CONST GUID *Guid,
870 IN UINTN TokenNumber,
871 IN BOOLEAN Value
872 )
873 {
874 ASSERT (Guid != NULL);
875
876 GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);
877
878 return Value;
879 }
880 #endif
881
882 /**
883 This function provides a means by which to set a value for a given PCD token.
884
885 Sets the 8-bit value for the token specified by TokenNumber
886 to the value specified by Value.
887
888 @param[in] TokenNumber The PCD token number to set a current value for.
889 @param[in] Value The 8-bit value to set.
890
891 @return The status of the set operation.
892
893 **/
894 RETURN_STATUS
895 EFIAPI
896 LibPcdSet8S (
897 IN UINTN TokenNumber,
898 IN UINT8 Value
899 )
900 {
901 return GetPcdProtocol()->Set8 (TokenNumber, Value);
902 }
903
904 /**
905 This function provides a means by which to set a value for a given PCD token.
906
907 Sets the 16-bit value for the token specified by TokenNumber
908 to the value specified by Value.
909
910 @param[in] TokenNumber The PCD token number to set a current value for.
911 @param[in] Value The 16-bit value to set.
912
913 @return The status of the set operation.
914
915 **/
916 RETURN_STATUS
917 EFIAPI
918 LibPcdSet16S (
919 IN UINTN TokenNumber,
920 IN UINT16 Value
921 )
922 {
923 return GetPcdProtocol()->Set16 (TokenNumber, Value);
924 }
925
926 /**
927 This function provides a means by which to set a value for a given PCD token.
928
929 Sets the 32-bit value for the token specified by TokenNumber
930 to the value specified by Value.
931
932 @param[in] TokenNumber The PCD token number to set a current value for.
933 @param[in] Value The 32-bit value to set.
934
935 @return The status of the set operation.
936
937 **/
938 RETURN_STATUS
939 EFIAPI
940 LibPcdSet32S (
941 IN UINTN TokenNumber,
942 IN UINT32 Value
943 )
944 {
945 return GetPcdProtocol()->Set32 (TokenNumber, Value);
946 }
947
948 /**
949 This function provides a means by which to set a value for a given PCD token.
950
951 Sets the 64-bit value for the token specified by TokenNumber
952 to the value specified by Value.
953
954 @param[in] TokenNumber The PCD token number to set a current value for.
955 @param[in] Value The 64-bit value to set.
956
957 @return The status of the set operation.
958
959 **/
960 RETURN_STATUS
961 EFIAPI
962 LibPcdSet64S (
963 IN UINTN TokenNumber,
964 IN UINT64 Value
965 )
966 {
967 return GetPcdProtocol()->Set64 (TokenNumber, Value);
968 }
969
970 /**
971 This function provides a means by which to set a value for a given PCD token.
972
973 Sets a buffer for the token specified by TokenNumber to the value specified
974 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
975 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
976 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
977 was not actually performed.
978
979 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
980 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
981
982 If SizeOfBuffer is NULL, then ASSERT().
983 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
984
985 @param[in] TokenNumber The PCD token number to set a current value for.
986 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
987 @param[in] Buffer A pointer to the buffer to set.
988
989 @return The status of the set operation.
990
991 **/
992 RETURN_STATUS
993 EFIAPI
994 LibPcdSetPtrS (
995 IN UINTN TokenNumber,
996 IN OUT UINTN *SizeOfBuffer,
997 IN CONST VOID *Buffer
998 )
999 {
1000 ASSERT (SizeOfBuffer != NULL);
1001
1002 if (*SizeOfBuffer > 0) {
1003 ASSERT (Buffer != NULL);
1004 }
1005
1006 return GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
1007 }
1008
1009 /**
1010 This function provides a means by which to set a value for a given PCD token.
1011
1012 Sets the boolean value for the token specified by TokenNumber
1013 to the value specified by Value.
1014
1015 @param[in] TokenNumber The PCD token number to set a current value for.
1016 @param[in] Value The boolean value to set.
1017
1018 @return The status of the set operation.
1019
1020 **/
1021 RETURN_STATUS
1022 EFIAPI
1023 LibPcdSetBoolS (
1024 IN UINTN TokenNumber,
1025 IN BOOLEAN Value
1026 )
1027 {
1028 return GetPcdProtocol()->SetBool (TokenNumber, Value);
1029 }
1030
1031 /**
1032 This function provides a means by which to set a value for a given PCD token.
1033
1034 Sets the 8-bit value for the token specified by TokenNumber
1035 to the value specified by Value.
1036
1037 If Guid is NULL, then ASSERT().
1038
1039 @param[in] Guid The pointer to a 128-bit unique value that
1040 designates which namespace to set a value from.
1041 @param[in] TokenNumber The PCD token number to set a current value for.
1042 @param[in] Value The 8-bit value to set.
1043
1044 @return The status of the set operation.
1045
1046 **/
1047 RETURN_STATUS
1048 EFIAPI
1049 LibPcdSetEx8S (
1050 IN CONST GUID *Guid,
1051 IN UINTN TokenNumber,
1052 IN UINT8 Value
1053 )
1054 {
1055 ASSERT (Guid != NULL);
1056
1057 return GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);
1058 }
1059
1060 /**
1061 This function provides a means by which to set a value for a given PCD token.
1062
1063 Sets the 16-bit value for the token specified by TokenNumber
1064 to the value specified by Value.
1065
1066 If Guid is NULL, then ASSERT().
1067
1068 @param[in] Guid The pointer to a 128-bit unique value that
1069 designates which namespace to set a value from.
1070 @param[in] TokenNumber The PCD token number to set a current value for.
1071 @param[in] Value The 16-bit value to set.
1072
1073 @return The status of the set operation.
1074
1075 **/
1076 RETURN_STATUS
1077 EFIAPI
1078 LibPcdSetEx16S (
1079 IN CONST GUID *Guid,
1080 IN UINTN TokenNumber,
1081 IN UINT16 Value
1082 )
1083 {
1084 ASSERT (Guid != NULL);
1085
1086 return GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);
1087 }
1088
1089 /**
1090 This function provides a means by which to set a value for a given PCD token.
1091
1092 Sets the 32-bit value for the token specified by TokenNumber
1093 to the value specified by Value.
1094
1095 If Guid is NULL, then ASSERT().
1096
1097 @param[in] Guid The pointer to a 128-bit unique value that
1098 designates which namespace to set a value from.
1099 @param[in] TokenNumber The PCD token number to set a current value for.
1100 @param[in] Value The 32-bit value to set.
1101
1102 @return The status of the set operation.
1103
1104 **/
1105 RETURN_STATUS
1106 EFIAPI
1107 LibPcdSetEx32S (
1108 IN CONST GUID *Guid,
1109 IN UINTN TokenNumber,
1110 IN UINT32 Value
1111 )
1112 {
1113 ASSERT (Guid != NULL);
1114
1115 return GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);
1116 }
1117
1118 /**
1119 This function provides a means by which to set a value for a given PCD token.
1120
1121 Sets the 64-bit value for the token specified by TokenNumber
1122 to the value specified by Value.
1123
1124 If Guid is NULL, then ASSERT().
1125
1126 @param[in] Guid The pointer to a 128-bit unique value that
1127 designates which namespace to set a value from.
1128 @param[in] TokenNumber The PCD token number to set a current value for.
1129 @param[in] Value The 64-bit value to set.
1130
1131 @return The status of the set operation.
1132
1133 **/
1134 RETURN_STATUS
1135 EFIAPI
1136 LibPcdSetEx64S (
1137 IN CONST GUID *Guid,
1138 IN UINTN TokenNumber,
1139 IN UINT64 Value
1140 )
1141 {
1142 ASSERT (Guid != NULL);
1143
1144 return GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);
1145 }
1146
1147 /**
1148 This function provides a means by which to set a value for a given PCD token.
1149
1150 Sets a buffer for the token specified by TokenNumber to the value specified by
1151 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
1152 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
1153 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
1154 was not actually performed.
1155
1156 If Guid is NULL, then ASSERT().
1157 If SizeOfBuffer is NULL, then ASSERT().
1158 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1159
1160 @param[in] Guid Pointer to a 128-bit unique value that
1161 designates which namespace to set a value from.
1162 @param[in] TokenNumber The PCD token number to set a current value for.
1163 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
1164 @param[in] Buffer A pointer to the buffer to set.
1165
1166 @return The status of the set operation.
1167
1168 **/
1169 RETURN_STATUS
1170 EFIAPI
1171 LibPcdSetExPtrS (
1172 IN CONST GUID *Guid,
1173 IN UINTN TokenNumber,
1174 IN OUT UINTN *SizeOfBuffer,
1175 IN VOID *Buffer
1176 )
1177 {
1178 ASSERT (Guid != NULL);
1179
1180 ASSERT (SizeOfBuffer != NULL);
1181
1182 if (*SizeOfBuffer > 0) {
1183 ASSERT (Buffer != NULL);
1184 }
1185
1186 return GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
1187 }
1188
1189 /**
1190 This function provides a means by which to set a value for a given PCD token.
1191
1192 Sets the boolean value for the token specified by TokenNumber
1193 to the value specified by Value.
1194
1195 If Guid is NULL, then ASSERT().
1196
1197 @param[in] Guid The pointer to a 128-bit unique value that
1198 designates which namespace to set a value from.
1199 @param[in] TokenNumber The PCD token number to set a current value for.
1200 @param[in] Value The boolean value to set.
1201
1202 @return The status of the set operation.
1203
1204 **/
1205 RETURN_STATUS
1206 EFIAPI
1207 LibPcdSetExBoolS (
1208 IN CONST GUID *Guid,
1209 IN UINTN TokenNumber,
1210 IN BOOLEAN Value
1211 )
1212 {
1213 ASSERT (Guid != NULL);
1214
1215 return GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);
1216 }
1217
1218 /**
1219 Set up a notification function that is called when a specified token is set.
1220
1221 When the token specified by TokenNumber and Guid is set,
1222 then notification function specified by NotificationFunction is called.
1223 If Guid is NULL, then the default token space is used.
1224 If NotificationFunction is NULL, then ASSERT().
1225
1226 @param[in] Guid The pointer to a 128-bit unique value that designates which
1227 namespace to set a value from. If NULL, then the default
1228 token space is used.
1229 @param[in] TokenNumber The PCD token number to monitor.
1230 @param[in] NotificationFunction The function to call when the token
1231 specified by Guid and TokenNumber is set.
1232
1233 **/
1234 VOID
1235 EFIAPI
1236 LibPcdCallbackOnSet (
1237 IN CONST GUID *Guid, OPTIONAL
1238 IN UINTN TokenNumber,
1239 IN PCD_CALLBACK NotificationFunction
1240 )
1241 {
1242 EFI_STATUS Status;
1243
1244 ASSERT (NotificationFunction != NULL);
1245
1246 Status = GetPiPcdProtocol()->CallbackOnSet (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);
1247 ASSERT_EFI_ERROR (Status);
1248
1249 return;
1250 }
1251
1252
1253
1254 /**
1255 Disable a notification function that was established with LibPcdCallbackonSet().
1256
1257 Disable a notification function that was previously established with LibPcdCallbackOnSet().
1258 If NotificationFunction is NULL, then ASSERT().
1259 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
1260 and NotificationFunction, then ASSERT().
1261
1262 @param[in] Guid Specify the GUID token space.
1263 @param[in] TokenNumber Specify the token number.
1264 @param[in] NotificationFunction The callback function to be unregistered.
1265
1266 **/
1267 VOID
1268 EFIAPI
1269 LibPcdCancelCallback (
1270 IN CONST GUID *Guid, OPTIONAL
1271 IN UINTN TokenNumber,
1272 IN PCD_CALLBACK NotificationFunction
1273 )
1274 {
1275 EFI_STATUS Status;
1276
1277 ASSERT (NotificationFunction != NULL);
1278
1279 Status = GetPiPcdProtocol()->CancelCallback (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);
1280 ASSERT_EFI_ERROR (Status);
1281
1282 return;
1283 }
1284
1285
1286
1287 /**
1288 Retrieves the next token in a token space.
1289
1290 Retrieves the next PCD token number from the token space specified by Guid.
1291 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
1292 then the first token number is returned. Otherwise, the token number that
1293 follows TokenNumber in the token space is returned. If TokenNumber is the last
1294 token number in the token space, then 0 is returned.
1295
1296 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
1297
1298 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
1299 to set a value from. If NULL, then the default token space is used.
1300 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
1301 token number.
1302
1303 @return The next valid token number.
1304
1305 **/
1306 UINTN
1307 EFIAPI
1308 LibPcdGetNextToken (
1309 IN CONST GUID *Guid, OPTIONAL
1310 IN UINTN TokenNumber
1311 )
1312 {
1313 EFI_STATUS Status;
1314
1315 Status = GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);
1316 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
1317
1318 return TokenNumber;
1319 }
1320
1321
1322
1323 /**
1324 Used to retrieve the list of available PCD token space GUIDs.
1325
1326 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
1327 in the platform.
1328 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
1329 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
1330
1331 @param TokenSpaceGuid The pointer to the a PCD token space GUID.
1332
1333 @return The next valid token namespace.
1334
1335 **/
1336 GUID *
1337 EFIAPI
1338 LibPcdGetNextTokenSpace (
1339 IN CONST GUID *TokenSpaceGuid
1340 )
1341 {
1342 GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid);
1343
1344 return (GUID *)TokenSpaceGuid;
1345 }
1346
1347
1348 /**
1349 Sets a value of a patchable PCD entry that is type pointer.
1350
1351 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1352 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1353 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1354 NULL to indicate that the set operation was not actually performed.
1355 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1356 MaximumDatumSize and NULL must be returned.
1357
1358 If PatchVariable is NULL, then ASSERT().
1359 If SizeOfBuffer is NULL, then ASSERT().
1360 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1361
1362 @param[out] PatchVariable A pointer to the global variable in a module that is
1363 the target of the set operation.
1364 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1365 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1366 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1367
1368 @return Return the pointer to the buffer been set.
1369
1370 **/
1371 VOID *
1372 EFIAPI
1373 LibPatchPcdSetPtr (
1374 OUT VOID *PatchVariable,
1375 IN UINTN MaximumDatumSize,
1376 IN OUT UINTN *SizeOfBuffer,
1377 IN CONST VOID *Buffer
1378 )
1379 {
1380 ASSERT (PatchVariable != NULL);
1381 ASSERT (SizeOfBuffer != NULL);
1382
1383 if (*SizeOfBuffer > 0) {
1384 ASSERT (Buffer != NULL);
1385 }
1386
1387 if ((*SizeOfBuffer > MaximumDatumSize) ||
1388 (*SizeOfBuffer == MAX_ADDRESS)) {
1389 *SizeOfBuffer = MaximumDatumSize;
1390 return NULL;
1391 }
1392
1393 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1394
1395 return (VOID *) Buffer;
1396 }
1397
1398 /**
1399 Sets a value of a patchable PCD entry that is type pointer.
1400
1401 Sets the PCD entry specified by PatchVariable to the value specified
1402 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1403 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1404 to indicate that the set operation was not actually performed.
1405 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1406 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1407
1408 If PatchVariable is NULL, then ASSERT().
1409 If SizeOfBuffer is NULL, then ASSERT().
1410 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1411
1412 @param[out] PatchVariable A pointer to the global variable in a module that is
1413 the target of the set operation.
1414 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1415 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1416 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1417
1418 @return The status of the set operation.
1419
1420 **/
1421 RETURN_STATUS
1422 EFIAPI
1423 LibPatchPcdSetPtrS (
1424 OUT VOID *PatchVariable,
1425 IN UINTN MaximumDatumSize,
1426 IN OUT UINTN *SizeOfBuffer,
1427 IN CONST VOID *Buffer
1428 )
1429 {
1430 ASSERT (PatchVariable != NULL);
1431 ASSERT (SizeOfBuffer != NULL);
1432
1433 if (*SizeOfBuffer > 0) {
1434 ASSERT (Buffer != NULL);
1435 }
1436
1437 if ((*SizeOfBuffer > MaximumDatumSize) ||
1438 (*SizeOfBuffer == MAX_ADDRESS)) {
1439 *SizeOfBuffer = MaximumDatumSize;
1440 return RETURN_INVALID_PARAMETER;
1441 }
1442
1443 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1444
1445 return RETURN_SUCCESS;
1446 }
1447
1448
1449 /**
1450 Sets a value and size of a patchable PCD entry that is type pointer.
1451
1452 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1453 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1454 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1455 NULL to indicate that the set operation was not actually performed.
1456 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1457 MaximumDatumSize and NULL must be returned.
1458
1459 If PatchVariable is NULL, then ASSERT().
1460 If SizeOfPatchVariable is NULL, then ASSERT().
1461 If SizeOfBuffer is NULL, then ASSERT().
1462 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1463
1464 @param[out] PatchVariable A pointer to the global variable in a module that is
1465 the target of the set operation.
1466 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1467 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1468 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1469 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1470
1471 @return Return the pointer to the buffer been set.
1472
1473 **/
1474 VOID *
1475 EFIAPI
1476 LibPatchPcdSetPtrAndSize (
1477 OUT VOID *PatchVariable,
1478 OUT UINTN *SizeOfPatchVariable,
1479 IN UINTN MaximumDatumSize,
1480 IN OUT UINTN *SizeOfBuffer,
1481 IN CONST VOID *Buffer
1482 )
1483 {
1484 ASSERT (PatchVariable != NULL);
1485 ASSERT (SizeOfPatchVariable != NULL);
1486 ASSERT (SizeOfBuffer != NULL);
1487
1488 if (*SizeOfBuffer > 0) {
1489 ASSERT (Buffer != NULL);
1490 }
1491
1492 if ((*SizeOfBuffer > MaximumDatumSize) ||
1493 (*SizeOfBuffer == MAX_ADDRESS)) {
1494 *SizeOfBuffer = MaximumDatumSize;
1495 return NULL;
1496 }
1497
1498 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1499 *SizeOfPatchVariable = *SizeOfBuffer;
1500
1501 return (VOID *) Buffer;
1502 }
1503
1504 /**
1505 Sets a value and size of a patchable PCD entry that is type pointer.
1506
1507 Sets the PCD entry specified by PatchVariable to the value specified
1508 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1509 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1510 to indicate that the set operation was not actually performed.
1511 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1512 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1513
1514 If PatchVariable is NULL, then ASSERT().
1515 If SizeOfPatchVariable is NULL, then ASSERT().
1516 If SizeOfBuffer is NULL, then ASSERT().
1517 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1518
1519 @param[out] PatchVariable A pointer to the global variable in a module that is
1520 the target of the set operation.
1521 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1522 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1523 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1524 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1525
1526 @return The status of the set operation.
1527
1528 **/
1529 RETURN_STATUS
1530 EFIAPI
1531 LibPatchPcdSetPtrAndSizeS (
1532 OUT VOID *PatchVariable,
1533 OUT UINTN *SizeOfPatchVariable,
1534 IN UINTN MaximumDatumSize,
1535 IN OUT UINTN *SizeOfBuffer,
1536 IN CONST VOID *Buffer
1537 )
1538 {
1539 ASSERT (PatchVariable != NULL);
1540 ASSERT (SizeOfPatchVariable != NULL);
1541 ASSERT (SizeOfBuffer != NULL);
1542
1543 if (*SizeOfBuffer > 0) {
1544 ASSERT (Buffer != NULL);
1545 }
1546
1547 if ((*SizeOfBuffer > MaximumDatumSize) ||
1548 (*SizeOfBuffer == MAX_ADDRESS)) {
1549 *SizeOfBuffer = MaximumDatumSize;
1550 return RETURN_INVALID_PARAMETER;
1551 }
1552
1553 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1554 *SizeOfPatchVariable = *SizeOfBuffer;
1555
1556 return RETURN_SUCCESS;
1557 }
1558
1559 /**
1560 Retrieve additional information associated with a PCD token.
1561
1562 This includes information such as the type of value the TokenNumber is associated with as well as possible
1563 human readable name that is associated with the token.
1564
1565 If TokenNumber is not in the default token space specified, then ASSERT().
1566
1567 @param[in] TokenNumber The PCD token number.
1568 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1569 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1570 **/
1571 VOID
1572 EFIAPI
1573 LibPcdGetInfo (
1574 IN UINTN TokenNumber,
1575 OUT PCD_INFO *PcdInfo
1576 )
1577 {
1578 EFI_STATUS Status;
1579
1580 Status = GetPcdInfoProtocolPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);
1581 ASSERT_EFI_ERROR (Status);
1582 }
1583
1584 /**
1585 Retrieve additional information associated with a PCD token.
1586
1587 This includes information such as the type of value the TokenNumber is associated with as well as possible
1588 human readable name that is associated with the token.
1589
1590 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1591
1592 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1593 @param[in] TokenNumber The PCD token number.
1594 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1595 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1596 **/
1597 VOID
1598 EFIAPI
1599 LibPcdGetInfoEx (
1600 IN CONST GUID *Guid,
1601 IN UINTN TokenNumber,
1602 OUT PCD_INFO *PcdInfo
1603 )
1604 {
1605 EFI_STATUS Status;
1606
1607 Status = GetPiPcdInfoProtocolPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);
1608 ASSERT_EFI_ERROR (Status);
1609 }
1610
1611 /**
1612 Retrieve the currently set SKU Id.
1613
1614 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1615 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
1616 Id is returned.
1617 **/
1618 UINTN
1619 EFIAPI
1620 LibPcdGetSku (
1621 VOID
1622 )
1623 {
1624 return GetPiPcdInfoProtocolPointer()->GetSku ();
1625 }
1626