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