]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / PeiPcdLib / PeiPcdLib.c
1 /** @file
2 Implementation of PcdLib class library for PEI 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
12
13 #include <PiPei.h>
14
15 #include <Ppi/Pcd.h>
16 #include <Ppi/PiPcd.h>
17 #include <Ppi/PcdInfo.h>
18 #include <Ppi/PiPcdInfo.h>
19
20 #include <Library/PeiServicesLib.h>
21 #include <Library/PcdLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/BaseMemoryLib.h>
24
25 /**
26 Retrieve the PCD_PPI pointer.
27
28 This function is to locate PCD_PPI PPI via PeiService.
29 If fail to locate PCD_PPI, then ASSERT_EFI_ERROR().
30
31 @retval PCD_PPI * The pointer to the PCD_PPI.
32
33 **/
34 PCD_PPI *
35 GetPcdPpiPointer (
36 VOID
37 )
38 {
39 EFI_STATUS Status;
40 PCD_PPI *PcdPpi;
41
42 Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);
43 ASSERT_EFI_ERROR (Status);
44
45 return PcdPpi;
46 }
47
48 /**
49 Retrieve the pointer of EFI_PEI_PCD_PPI defined in PI 1.2 Vol 3.
50
51 This function is to locate EFI_PEI_PCD_PPI PPI via PeiService.
52 If fail to locate EFI_PEI_PCD_PPI, then ASSERT_EFI_ERROR().
53
54 @retval EFI_PEI_PCD_PPI * The pointer to the EFI_PEI_PCD_PPI.
55
56 **/
57 EFI_PEI_PCD_PPI *
58 GetPiPcdPpiPointer (
59 VOID
60 )
61 {
62 EFI_STATUS Status;
63 EFI_PEI_PCD_PPI *PiPcdPpi;
64
65 Status = PeiServicesLocatePpi (&gEfiPeiPcdPpiGuid, 0, NULL, (VOID **)&PiPcdPpi);
66 ASSERT_EFI_ERROR (Status);
67
68 return PiPcdPpi;
69 }
70
71 /**
72 Retrieve the GET_PCD_INFO_PPI pointer.
73
74 This function is to locate GET_PCD_INFO_PPI PPI via PeiService.
75 If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().
76
77 @retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI.
78
79 **/
80 GET_PCD_INFO_PPI *
81 GetPcdInfoPpiPointer (
82 VOID
83 )
84 {
85 EFI_STATUS Status;
86 GET_PCD_INFO_PPI *PcdInfoPpi;
87
88 Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);
89 ASSERT_EFI_ERROR (Status);
90
91 return PcdInfoPpi;
92 }
93
94 /**
95 Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3.
96
97 This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService.
98 If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().
99
100 @retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI.
101
102 **/
103 EFI_GET_PCD_INFO_PPI *
104 GetPiPcdInfoPpiPointer (
105 VOID
106 )
107 {
108 EFI_STATUS Status;
109 EFI_GET_PCD_INFO_PPI *PiPcdInfoPpi;
110
111 Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);
112 ASSERT_EFI_ERROR (Status);
113
114 return PiPcdInfoPpi;
115 }
116
117 /**
118 This function provides a means by which SKU support can be established in the PCD infrastructure.
119
120 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
121
122 @param SkuId The SKU value that will be used when the PCD service retrieves
123 and sets values associated with a PCD token.
124
125 @return Return the SKU ID that just be set.
126
127 **/
128 UINTN
129 EFIAPI
130 LibPcdSetSku (
131 IN UINTN SkuId
132 )
133 {
134 GetPiPcdPpiPointer()->SetSku (SkuId);
135
136 return SkuId;
137 }
138
139
140
141 /**
142 This function provides a means by which to retrieve a value for a given PCD token.
143
144 Returns the 8-bit value for the token specified by TokenNumber.
145
146 @param[in] TokenNumber The PCD token number to retrieve a current value for.
147
148 @return Returns the 8-bit value for the token specified by TokenNumber.
149
150 **/
151 UINT8
152 EFIAPI
153 LibPcdGet8 (
154 IN UINTN TokenNumber
155 )
156 {
157 return (GetPcdPpiPointer ())->Get8 (TokenNumber);
158 }
159
160
161
162 /**
163 This function provides a means by which to retrieve a value for a given PCD token.
164
165 Returns the 16-bit value for the token specified by TokenNumber.
166
167 @param[in] TokenNumber The PCD token number to retrieve a current value for.
168
169 @return Returns the 16-bit value for the token specified by TokenNumber.
170
171 **/
172 UINT16
173 EFIAPI
174 LibPcdGet16 (
175 IN UINTN TokenNumber
176 )
177 {
178 return (GetPcdPpiPointer ())->Get16 (TokenNumber);
179 }
180
181
182
183 /**
184 This function provides a means by which to retrieve a value for a given PCD token.
185
186 Returns the 32-bit value for the token specified by TokenNumber.
187
188 @param[in] TokenNumber The PCD token number to retrieve a current value for.
189
190 @return Returns the 32-bit value for the token specified by TokenNumber.
191
192 **/
193 UINT32
194 EFIAPI
195 LibPcdGet32 (
196 IN UINTN TokenNumber
197 )
198 {
199 return (GetPcdPpiPointer ())->Get32 (TokenNumber);
200 }
201
202
203
204 /**
205 This function provides a means by which to retrieve a value for a given PCD token.
206
207 Returns the 64-bit value for the token specified by TokenNumber.
208
209 @param[in] TokenNumber The PCD token number to retrieve a current value for.
210
211 @return Returns the 64-bit value for the token specified by TokenNumber.
212
213 **/
214 UINT64
215 EFIAPI
216 LibPcdGet64 (
217 IN UINTN TokenNumber
218 )
219 {
220 return (GetPcdPpiPointer ())->Get64 (TokenNumber);
221 }
222
223
224
225 /**
226 This function provides a means by which to retrieve a value for a given PCD token.
227
228 Returns the pointer to the buffer of the token specified by TokenNumber.
229
230 @param[in] TokenNumber The PCD token number to retrieve a current value for.
231
232 @return Returns the pointer to the token specified by TokenNumber.
233
234 **/
235 VOID *
236 EFIAPI
237 LibPcdGetPtr (
238 IN UINTN TokenNumber
239 )
240 {
241 return (GetPcdPpiPointer ())->GetPtr (TokenNumber);
242 }
243
244
245
246 /**
247 This function provides a means by which to retrieve a value for a given PCD token.
248
249 Returns the Boolean value of the token specified by TokenNumber.
250
251 @param[in] TokenNumber The PCD token number to retrieve a current value for.
252
253 @return Returns the Boolean value of the token specified by TokenNumber.
254
255 **/
256 BOOLEAN
257 EFIAPI
258 LibPcdGetBool (
259 IN UINTN TokenNumber
260 )
261 {
262 return (GetPcdPpiPointer ())->GetBool (TokenNumber);
263 }
264
265
266
267 /**
268 This function provides a means by which to retrieve the size of a given PCD token.
269
270 @param[in] TokenNumber The PCD token number to retrieve a current value for.
271
272 @return Returns the size of the token specified by TokenNumber.
273
274 **/
275 UINTN
276 EFIAPI
277 LibPcdGetSize (
278 IN UINTN TokenNumber
279 )
280 {
281 return (GetPcdPpiPointer ())->GetSize (TokenNumber);
282 }
283
284
285
286 /**
287 This function provides a means by which to retrieve a value for a given PCD token.
288
289 Returns the 8-bit value for the token specified by TokenNumber and Guid.
290
291 If Guid is NULL, then ASSERT().
292
293 @param[in] Guid The pointer to a 128-bit unique value that designates
294 which namespace to retrieve a value from.
295 @param[in] TokenNumber The PCD token number to retrieve a current value for.
296
297 @return Return the UINT8.
298
299 **/
300 UINT8
301 EFIAPI
302 LibPcdGetEx8 (
303 IN CONST GUID *Guid,
304 IN UINTN TokenNumber
305 )
306 {
307 ASSERT (Guid != NULL);
308
309 return (GetPiPcdPpiPointer ())->Get8 (Guid, TokenNumber);
310 }
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
336 ASSERT (Guid != NULL);
337
338 return (GetPiPcdPpiPointer ())->Get16 (Guid, TokenNumber);
339 }
340
341
342
343 /**
344 Returns the 32-bit value for the token specified by TokenNumber and Guid.
345 If Guid is NULL, then ASSERT().
346
347 @param[in] Guid The pointer to a 128-bit unique value that designates
348 which namespace to retrieve a value from.
349 @param[in] TokenNumber The PCD token number to retrieve a current value for.
350
351 @return Return the UINT32.
352
353 **/
354 UINT32
355 EFIAPI
356 LibPcdGetEx32 (
357 IN CONST GUID *Guid,
358 IN UINTN TokenNumber
359 )
360 {
361 ASSERT (Guid != NULL);
362
363 return (GetPiPcdPpiPointer ())->Get32 (Guid, TokenNumber);
364 }
365
366
367
368
369 /**
370 This function provides a means by which to retrieve a value for a given PCD token.
371
372 Returns the 64-bit value for the token specified by TokenNumber and Guid.
373
374 If Guid is NULL, then ASSERT().
375
376 @param[in] Guid The pointer to a 128-bit unique value that designates
377 which namespace to retrieve a value from.
378 @param[in] TokenNumber The PCD token number to retrieve a current value for.
379
380 @return Return the UINT64.
381
382 **/
383 UINT64
384 EFIAPI
385 LibPcdGetEx64 (
386 IN CONST GUID *Guid,
387 IN UINTN TokenNumber
388 )
389 {
390 ASSERT (Guid != NULL);
391 return (GetPiPcdPpiPointer ())->Get64 (Guid, TokenNumber);
392 }
393
394
395
396 /**
397 This function provides a means by which to retrieve a value for a given PCD token.
398
399 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
400
401 If Guid is NULL, then ASSERT().
402
403 @param[in] Guid The pointer to a 128-bit unique value that designates
404 which namespace to retrieve a value from.
405 @param[in] TokenNumber The PCD token number to retrieve a current value for.
406
407 @return Return the VOID* pointer.
408
409 **/
410 VOID *
411 EFIAPI
412 LibPcdGetExPtr (
413 IN CONST GUID *Guid,
414 IN UINTN TokenNumber
415 )
416 {
417 ASSERT (Guid != NULL);
418
419 return (GetPiPcdPpiPointer ())->GetPtr (Guid, TokenNumber);
420 }
421
422
423
424 /**
425 This function provides a means by which to retrieve a value for a given PCD token.
426
427 Returns the Boolean value of the token specified by TokenNumber and Guid.
428
429 If Guid is NULL, then ASSERT().
430
431 @param[in] Guid The pointer to a 128-bit unique value that designates
432 which namespace to retrieve a value from.
433 @param[in] TokenNumber The PCD token number to retrieve a current value for.
434
435 @return Return the BOOLEAN.
436
437 **/
438 BOOLEAN
439 EFIAPI
440 LibPcdGetExBool (
441 IN CONST GUID *Guid,
442 IN UINTN TokenNumber
443 )
444 {
445 ASSERT (Guid != NULL);
446 return (GetPiPcdPpiPointer ())->GetBool (Guid, TokenNumber);
447 }
448
449
450
451 /**
452 This function provides a means by which to retrieve the size of a given PCD token.
453
454 Returns the size of the token specified by TokenNumber and Guid.
455
456 If Guid is NULL, then ASSERT().
457
458 @param[in] Guid The pointer to a 128-bit unique value that designates
459 which namespace to retrieve a value from.
460 @param[in] TokenNumber The PCD token number to retrieve a current value for.
461
462 @return Return the size.
463
464 **/
465 UINTN
466 EFIAPI
467 LibPcdGetExSize (
468 IN CONST GUID *Guid,
469 IN UINTN TokenNumber
470 )
471 {
472 ASSERT (Guid != NULL);
473 return (GetPiPcdPpiPointer ())->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 (GetPcdPpiPointer ())->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 (GetPcdPpiPointer ())->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 (GetPcdPpiPointer ())->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 (GetPcdPpiPointer ())->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 = (GetPcdPpiPointer ())->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 (GetPcdPpiPointer ())->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 (GetPiPcdPpiPointer ())->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 (GetPiPcdPpiPointer ())->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 (GetPiPcdPpiPointer ())->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 (GetPiPcdPpiPointer ())->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 pinter 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 (SizeOfBuffer != NULL);
826 if (*SizeOfBuffer > 0) {
827 ASSERT (Buffer != NULL);
828 }
829 ASSERT (Guid != NULL);
830
831 InputSizeOfBuffer = *SizeOfBuffer;
832 Status = (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
833 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
834 return NULL;
835 }
836
837 return Buffer;
838 }
839
840
841
842 /**
843 This function provides a means by which to set a value for a given PCD token.
844
845 Sets the Boolean value for the token specified by TokenNumber and
846 Guid to the value specified by Value. Value is returned.
847
848 If Guid is NULL, then ASSERT().
849
850 @param[in] Guid The pointer to a 128-bit unique value that
851 designates which namespace to set a value from.
852 @param[in] TokenNumber The PCD token number to set a current value for.
853 @param[in] Value The Boolean value to set.
854
855 @return Return the value that was set.
856
857 **/
858 BOOLEAN
859 EFIAPI
860 LibPcdSetExBool (
861 IN CONST GUID *Guid,
862 IN UINTN TokenNumber,
863 IN BOOLEAN Value
864 )
865 {
866 ASSERT (Guid != NULL);
867
868 (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);
869
870 return Value;
871 }
872 #endif
873
874 /**
875 This function provides a means by which to set a value for a given PCD token.
876
877 Sets the 8-bit value for the token specified by TokenNumber
878 to the value specified by Value.
879
880 @param[in] TokenNumber The PCD token number to set a current value for.
881 @param[in] Value The 8-bit value to set.
882
883 @return The status of the set operation.
884
885 **/
886 RETURN_STATUS
887 EFIAPI
888 LibPcdSet8S (
889 IN UINTN TokenNumber,
890 IN UINT8 Value
891 )
892 {
893 return (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);
894 }
895
896 /**
897 This function provides a means by which to set a value for a given PCD token.
898
899 Sets the 16-bit value for the token specified by TokenNumber
900 to the value specified by Value.
901
902 @param[in] TokenNumber The PCD token number to set a current value for.
903 @param[in] Value The 16-bit value to set.
904
905 @return The status of the set operation.
906
907 **/
908 RETURN_STATUS
909 EFIAPI
910 LibPcdSet16S (
911 IN UINTN TokenNumber,
912 IN UINT16 Value
913 )
914 {
915 return (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);
916 }
917
918 /**
919 This function provides a means by which to set a value for a given PCD token.
920
921 Sets the 32-bit value for the token specified by TokenNumber
922 to the value specified by Value.
923
924 @param[in] TokenNumber The PCD token number to set a current value for.
925 @param[in] Value The 32-bit value to set.
926
927 @return The status of the set operation.
928
929 **/
930 RETURN_STATUS
931 EFIAPI
932 LibPcdSet32S (
933 IN UINTN TokenNumber,
934 IN UINT32 Value
935 )
936 {
937 return (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);
938 }
939
940 /**
941 This function provides a means by which to set a value for a given PCD token.
942
943 Sets the 64-bit value for the token specified by TokenNumber
944 to the value specified by Value.
945
946 @param[in] TokenNumber The PCD token number to set a current value for.
947 @param[in] Value The 64-bit value to set.
948
949 @return The status of the set operation.
950
951 **/
952 RETURN_STATUS
953 EFIAPI
954 LibPcdSet64S (
955 IN UINTN TokenNumber,
956 IN UINT64 Value
957 )
958 {
959 return (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);
960 }
961
962 /**
963 This function provides a means by which to set a value for a given PCD token.
964
965 Sets a buffer for the token specified by TokenNumber to the value specified
966 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
967 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
968 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
969 was not actually performed.
970
971 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
972 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
973
974 If SizeOfBuffer is NULL, then ASSERT().
975 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
976
977 @param[in] TokenNumber The PCD token number to set a current value for.
978 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
979 @param[in] Buffer A pointer to the buffer to set.
980
981 @return The status of the set operation.
982
983 **/
984 RETURN_STATUS
985 EFIAPI
986 LibPcdSetPtrS (
987 IN UINTN TokenNumber,
988 IN OUT UINTN *SizeOfBuffer,
989 IN CONST VOID *Buffer
990 )
991 {
992 ASSERT (SizeOfBuffer != NULL);
993
994 if (*SizeOfBuffer > 0) {
995 ASSERT (Buffer != NULL);
996 }
997
998 return (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
999 }
1000
1001 /**
1002 This function provides a means by which to set a value for a given PCD token.
1003
1004 Sets the boolean value for the token specified by TokenNumber
1005 to the value specified by Value.
1006
1007 @param[in] TokenNumber The PCD token number to set a current value for.
1008 @param[in] Value The boolean value to set.
1009
1010 @return The status of the set operation.
1011
1012 **/
1013 RETURN_STATUS
1014 EFIAPI
1015 LibPcdSetBoolS (
1016 IN UINTN TokenNumber,
1017 IN BOOLEAN Value
1018 )
1019 {
1020 return (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);
1021 }
1022
1023 /**
1024 This function provides a means by which to set a value for a given PCD token.
1025
1026 Sets the 8-bit value for the token specified by TokenNumber
1027 to the value specified by Value.
1028
1029 If Guid is NULL, then ASSERT().
1030
1031 @param[in] Guid The pointer to a 128-bit unique value that
1032 designates which namespace to set a value from.
1033 @param[in] TokenNumber The PCD token number to set a current value for.
1034 @param[in] Value The 8-bit value to set.
1035
1036 @return The status of the set operation.
1037
1038 **/
1039 RETURN_STATUS
1040 EFIAPI
1041 LibPcdSetEx8S (
1042 IN CONST GUID *Guid,
1043 IN UINTN TokenNumber,
1044 IN UINT8 Value
1045 )
1046 {
1047 ASSERT (Guid != NULL);
1048
1049 return (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);
1050 }
1051
1052 /**
1053 This function provides a means by which to set a value for a given PCD token.
1054
1055 Sets the 16-bit value for the token specified by TokenNumber
1056 to the value specified by Value.
1057
1058 If Guid is NULL, then ASSERT().
1059
1060 @param[in] Guid The pointer to a 128-bit unique value that
1061 designates which namespace to set a value from.
1062 @param[in] TokenNumber The PCD token number to set a current value for.
1063 @param[in] Value The 16-bit value to set.
1064
1065 @return The status of the set operation.
1066
1067 **/
1068 RETURN_STATUS
1069 EFIAPI
1070 LibPcdSetEx16S (
1071 IN CONST GUID *Guid,
1072 IN UINTN TokenNumber,
1073 IN UINT16 Value
1074 )
1075 {
1076 ASSERT (Guid != NULL);
1077
1078 return (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);
1079 }
1080
1081 /**
1082 This function provides a means by which to set a value for a given PCD token.
1083
1084 Sets the 32-bit value for the token specified by TokenNumber
1085 to the value specified by Value.
1086
1087 If Guid is NULL, then ASSERT().
1088
1089 @param[in] Guid The pointer to a 128-bit unique value that
1090 designates which namespace to set a value from.
1091 @param[in] TokenNumber The PCD token number to set a current value for.
1092 @param[in] Value The 32-bit value to set.
1093
1094 @return The status of the set operation.
1095
1096 **/
1097 RETURN_STATUS
1098 EFIAPI
1099 LibPcdSetEx32S (
1100 IN CONST GUID *Guid,
1101 IN UINTN TokenNumber,
1102 IN UINT32 Value
1103 )
1104 {
1105 ASSERT (Guid != NULL);
1106
1107 return (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);
1108 }
1109
1110 /**
1111 This function provides a means by which to set a value for a given PCD token.
1112
1113 Sets the 64-bit value for the token specified by TokenNumber
1114 to the value specified by Value.
1115
1116 If Guid is NULL, then ASSERT().
1117
1118 @param[in] Guid The pointer to a 128-bit unique value that
1119 designates which namespace to set a value from.
1120 @param[in] TokenNumber The PCD token number to set a current value for.
1121 @param[in] Value The 64-bit value to set.
1122
1123 @return The status of the set operation.
1124
1125 **/
1126 RETURN_STATUS
1127 EFIAPI
1128 LibPcdSetEx64S (
1129 IN CONST GUID *Guid,
1130 IN UINTN TokenNumber,
1131 IN UINT64 Value
1132 )
1133 {
1134 ASSERT (Guid != NULL);
1135
1136 return (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);
1137 }
1138
1139 /**
1140 This function provides a means by which to set a value for a given PCD token.
1141
1142 Sets a buffer for the token specified by TokenNumber to the value specified by
1143 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
1144 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
1145 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
1146 was not actually performed.
1147
1148 If Guid is NULL, then ASSERT().
1149 If SizeOfBuffer is NULL, then ASSERT().
1150 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1151
1152 @param[in] Guid Pointer to a 128-bit unique value that
1153 designates which namespace to set a value from.
1154 @param[in] TokenNumber The PCD token number to set a current value for.
1155 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
1156 @param[in] Buffer A pointer to the buffer to set.
1157
1158 @return The status of the set operation.
1159
1160 **/
1161 RETURN_STATUS
1162 EFIAPI
1163 LibPcdSetExPtrS (
1164 IN CONST GUID *Guid,
1165 IN UINTN TokenNumber,
1166 IN OUT UINTN *SizeOfBuffer,
1167 IN VOID *Buffer
1168 )
1169 {
1170 ASSERT (Guid != NULL);
1171
1172 ASSERT (SizeOfBuffer != NULL);
1173
1174 if (*SizeOfBuffer > 0) {
1175 ASSERT (Buffer != NULL);
1176 }
1177
1178 return (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
1179 }
1180
1181 /**
1182 This function provides a means by which to set a value for a given PCD token.
1183
1184 Sets the boolean value for the token specified by TokenNumber
1185 to the value specified by Value.
1186
1187 If Guid is NULL, then ASSERT().
1188
1189 @param[in] Guid The pointer to a 128-bit unique value that
1190 designates which namespace to set a value from.
1191 @param[in] TokenNumber The PCD token number to set a current value for.
1192 @param[in] Value The boolean value to set.
1193
1194 @return The status of the set operation.
1195
1196 **/
1197 RETURN_STATUS
1198 EFIAPI
1199 LibPcdSetExBoolS (
1200 IN CONST GUID *Guid,
1201 IN UINTN TokenNumber,
1202 IN BOOLEAN Value
1203 )
1204 {
1205 ASSERT (Guid != NULL);
1206
1207 return (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);
1208 }
1209
1210 /**
1211 Set up a notification function that is called when a specified token is set.
1212
1213 When the token specified by TokenNumber and Guid is set,
1214 then notification function specified by NotificationFunction is called.
1215 If Guid is NULL, then the default token space is used.
1216 If NotificationFunction is NULL, then ASSERT().
1217
1218 @param[in] Guid The pointer to a 128-bit unique value that
1219 designates which namespace to set a value from.
1220 If NULL, then the default token space is used.
1221 @param[in] TokenNumber The PCD token number to monitor.
1222 @param[in] NotificationFunction The function to call when the token
1223 specified by Guid and TokenNumber is set.
1224
1225 **/
1226 VOID
1227 EFIAPI
1228 LibPcdCallbackOnSet (
1229 IN CONST GUID *Guid, OPTIONAL
1230 IN UINTN TokenNumber,
1231 IN PCD_CALLBACK NotificationFunction
1232 )
1233 {
1234 EFI_STATUS Status;
1235
1236 ASSERT (NotificationFunction != NULL);
1237
1238 Status = (GetPiPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);
1239
1240 ASSERT_EFI_ERROR (Status);
1241
1242 return;
1243 }
1244
1245
1246
1247 /**
1248 Disable a notification function that was established with LibPcdCallbackonSet().
1249
1250 Disable a notification function that was previously established with LibPcdCallbackOnSet().
1251 If NotificationFunction is NULL, then ASSERT().
1252 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
1253 and NotificationFunction, then ASSERT().
1254
1255 @param[in] Guid Specify the GUID token space.
1256 @param[in] TokenNumber Specify the token number.
1257 @param[in] NotificationFunction The callback function to be unregistered.
1258
1259 **/
1260 VOID
1261 EFIAPI
1262 LibPcdCancelCallback (
1263 IN CONST GUID *Guid, OPTIONAL
1264 IN UINTN TokenNumber,
1265 IN PCD_CALLBACK NotificationFunction
1266 )
1267 {
1268 EFI_STATUS Status;
1269
1270 ASSERT (NotificationFunction != NULL);
1271
1272 Status = (GetPiPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);
1273
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 = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);
1310 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
1311
1312 return TokenNumber;
1313 }
1314
1315
1316 /**
1317 Used to retrieve the list of available PCD token space GUIDs.
1318
1319 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
1320 in the platform.
1321 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
1322 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
1323
1324 @param TokenSpaceGuid The pointer to the a PCD token space GUID
1325
1326 @return The next valid token namespace.
1327
1328 **/
1329 GUID *
1330 EFIAPI
1331 LibPcdGetNextTokenSpace (
1332 IN CONST GUID *TokenSpaceGuid
1333 )
1334 {
1335 (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);
1336
1337 return (GUID *) TokenSpaceGuid;
1338 }
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 = GetPcdInfoPpiPointer()->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 = GetPiPcdInfoPpiPointer()->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 GetPiPcdInfoPpiPointer()->GetSku ();
1619 }