]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 #include <PiPei.h>
11
12 #include <Ppi/Pcd.h>
13 #include <Ppi/PiPcd.h>
14 #include <Ppi/PcdInfo.h>
15 #include <Ppi/PiPcdInfo.h>
16
17 #include <Library/PeiServicesLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/BaseMemoryLib.h>
21
22 /**
23 Retrieve the PCD_PPI pointer.
24
25 This function is to locate PCD_PPI PPI via PeiService.
26 If fail to locate PCD_PPI, then ASSERT_EFI_ERROR().
27
28 @retval PCD_PPI * The pointer to the PCD_PPI.
29
30 **/
31 PCD_PPI *
32 GetPcdPpiPointer (
33 VOID
34 )
35 {
36 EFI_STATUS Status;
37 PCD_PPI *PcdPpi;
38
39 Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);
40 ASSERT_EFI_ERROR (Status);
41
42 return PcdPpi;
43 }
44
45 /**
46 Retrieve the pointer of EFI_PEI_PCD_PPI defined in PI 1.2 Vol 3.
47
48 This function is to locate EFI_PEI_PCD_PPI PPI via PeiService.
49 If fail to locate EFI_PEI_PCD_PPI, then ASSERT_EFI_ERROR().
50
51 @retval EFI_PEI_PCD_PPI * The pointer to the EFI_PEI_PCD_PPI.
52
53 **/
54 EFI_PEI_PCD_PPI *
55 GetPiPcdPpiPointer (
56 VOID
57 )
58 {
59 EFI_STATUS Status;
60 EFI_PEI_PCD_PPI *PiPcdPpi;
61
62 Status = PeiServicesLocatePpi (&gEfiPeiPcdPpiGuid, 0, NULL, (VOID **)&PiPcdPpi);
63 ASSERT_EFI_ERROR (Status);
64
65 return PiPcdPpi;
66 }
67
68 /**
69 Retrieve the GET_PCD_INFO_PPI pointer.
70
71 This function is to locate GET_PCD_INFO_PPI PPI via PeiService.
72 If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().
73
74 @retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI.
75
76 **/
77 GET_PCD_INFO_PPI *
78 GetPcdInfoPpiPointer (
79 VOID
80 )
81 {
82 EFI_STATUS Status;
83 GET_PCD_INFO_PPI *PcdInfoPpi;
84
85 Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);
86 ASSERT_EFI_ERROR (Status);
87
88 return PcdInfoPpi;
89 }
90
91 /**
92 Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3.
93
94 This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService.
95 If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().
96
97 @retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI.
98
99 **/
100 EFI_GET_PCD_INFO_PPI *
101 GetPiPcdInfoPpiPointer (
102 VOID
103 )
104 {
105 EFI_STATUS Status;
106 EFI_GET_PCD_INFO_PPI *PiPcdInfoPpi;
107
108 Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);
109 ASSERT_EFI_ERROR (Status);
110
111 return PiPcdInfoPpi;
112 }
113
114 /**
115 This function provides a means by which SKU support can be established in the PCD infrastructure.
116
117 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
118
119 @param SkuId The SKU value that will be used when the PCD service retrieves
120 and sets values associated with a PCD token.
121
122 @return Return the SKU ID that just be set.
123
124 **/
125 UINTN
126 EFIAPI
127 LibPcdSetSku (
128 IN UINTN SkuId
129 )
130 {
131 GetPiPcdPpiPointer ()->SetSku (SkuId);
132
133 return SkuId;
134 }
135
136 /**
137 This function provides a means by which to retrieve a value for a given PCD token.
138
139 Returns the 8-bit value for the token specified by TokenNumber.
140
141 @param[in] TokenNumber The PCD token number to retrieve a current value for.
142
143 @return Returns the 8-bit value for the token specified by TokenNumber.
144
145 **/
146 UINT8
147 EFIAPI
148 LibPcdGet8 (
149 IN UINTN TokenNumber
150 )
151 {
152 return (GetPcdPpiPointer ())->Get8 (TokenNumber);
153 }
154
155 /**
156 This function provides a means by which to retrieve a value for a given PCD token.
157
158 Returns the 16-bit value for the token specified by TokenNumber.
159
160 @param[in] TokenNumber The PCD token number to retrieve a current value for.
161
162 @return Returns the 16-bit value for the token specified by TokenNumber.
163
164 **/
165 UINT16
166 EFIAPI
167 LibPcdGet16 (
168 IN UINTN TokenNumber
169 )
170 {
171 return (GetPcdPpiPointer ())->Get16 (TokenNumber);
172 }
173
174 /**
175 This function provides a means by which to retrieve a value for a given PCD token.
176
177 Returns the 32-bit value for the token specified by TokenNumber.
178
179 @param[in] TokenNumber The PCD token number to retrieve a current value for.
180
181 @return Returns the 32-bit value for the token specified by TokenNumber.
182
183 **/
184 UINT32
185 EFIAPI
186 LibPcdGet32 (
187 IN UINTN TokenNumber
188 )
189 {
190 return (GetPcdPpiPointer ())->Get32 (TokenNumber);
191 }
192
193 /**
194 This function provides a means by which to retrieve a value for a given PCD token.
195
196 Returns the 64-bit value for the token specified by TokenNumber.
197
198 @param[in] TokenNumber The PCD token number to retrieve a current value for.
199
200 @return Returns the 64-bit value for the token specified by TokenNumber.
201
202 **/
203 UINT64
204 EFIAPI
205 LibPcdGet64 (
206 IN UINTN TokenNumber
207 )
208 {
209 return (GetPcdPpiPointer ())->Get64 (TokenNumber);
210 }
211
212 /**
213 This function provides a means by which to retrieve a value for a given PCD token.
214
215 Returns the pointer to the buffer of the token specified by TokenNumber.
216
217 @param[in] TokenNumber The PCD token number to retrieve a current value for.
218
219 @return Returns the pointer to the token specified by TokenNumber.
220
221 **/
222 VOID *
223 EFIAPI
224 LibPcdGetPtr (
225 IN UINTN TokenNumber
226 )
227 {
228 return (GetPcdPpiPointer ())->GetPtr (TokenNumber);
229 }
230
231 /**
232 This function provides a means by which to retrieve a value for a given PCD token.
233
234 Returns the Boolean value of the token specified by TokenNumber.
235
236 @param[in] TokenNumber The PCD token number to retrieve a current value for.
237
238 @return Returns the Boolean value of the token specified by TokenNumber.
239
240 **/
241 BOOLEAN
242 EFIAPI
243 LibPcdGetBool (
244 IN UINTN TokenNumber
245 )
246 {
247 return (GetPcdPpiPointer ())->GetBool (TokenNumber);
248 }
249
250 /**
251 This function provides a means by which to retrieve the size of a given PCD token.
252
253 @param[in] TokenNumber The PCD token number to retrieve a current value for.
254
255 @return Returns the size of the token specified by TokenNumber.
256
257 **/
258 UINTN
259 EFIAPI
260 LibPcdGetSize (
261 IN UINTN TokenNumber
262 )
263 {
264 return (GetPcdPpiPointer ())->GetSize (TokenNumber);
265 }
266
267 /**
268 This function provides a means by which to retrieve a value for a given PCD token.
269
270 Returns the 8-bit value for the token specified by TokenNumber and Guid.
271
272 If Guid is NULL, then ASSERT().
273
274 @param[in] Guid The pointer to a 128-bit unique value that designates
275 which namespace to retrieve a value from.
276 @param[in] TokenNumber The PCD token number to retrieve a current value for.
277
278 @return Return the UINT8.
279
280 **/
281 UINT8
282 EFIAPI
283 LibPcdGetEx8 (
284 IN CONST GUID *Guid,
285 IN UINTN TokenNumber
286 )
287 {
288 ASSERT (Guid != NULL);
289
290 return (GetPiPcdPpiPointer ())->Get8 (Guid, TokenNumber);
291 }
292
293 /**
294 This function provides a means by which to retrieve a value for a given PCD token.
295
296 Returns the 16-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 UINT16.
305
306 **/
307 UINT16
308 EFIAPI
309 LibPcdGetEx16 (
310 IN CONST GUID *Guid,
311 IN UINTN TokenNumber
312 )
313 {
314 ASSERT (Guid != NULL);
315
316 return (GetPiPcdPpiPointer ())->Get16 (Guid, TokenNumber);
317 }
318
319 /**
320 Returns the 32-bit value for the token specified by TokenNumber and Guid.
321 If Guid is NULL, then ASSERT().
322
323 @param[in] Guid The pointer to a 128-bit unique value that designates
324 which namespace to retrieve a value from.
325 @param[in] TokenNumber The PCD token number to retrieve a current value for.
326
327 @return Return the UINT32.
328
329 **/
330 UINT32
331 EFIAPI
332 LibPcdGetEx32 (
333 IN CONST GUID *Guid,
334 IN UINTN TokenNumber
335 )
336 {
337 ASSERT (Guid != NULL);
338
339 return (GetPiPcdPpiPointer ())->Get32 (Guid, TokenNumber);
340 }
341
342 /**
343 This function provides a means by which to retrieve a value for a given PCD token.
344
345 Returns the 64-bit value for the token specified by TokenNumber and Guid.
346
347 If Guid is NULL, then ASSERT().
348
349 @param[in] Guid The pointer to a 128-bit unique value that designates
350 which namespace to retrieve a value from.
351 @param[in] TokenNumber The PCD token number to retrieve a current value for.
352
353 @return Return the UINT64.
354
355 **/
356 UINT64
357 EFIAPI
358 LibPcdGetEx64 (
359 IN CONST GUID *Guid,
360 IN UINTN TokenNumber
361 )
362 {
363 ASSERT (Guid != NULL);
364 return (GetPiPcdPpiPointer ())->Get64 (Guid, TokenNumber);
365 }
366
367 /**
368 This function provides a means by which to retrieve a value for a given PCD token.
369
370 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
371
372 If Guid is NULL, then ASSERT().
373
374 @param[in] Guid The pointer to a 128-bit unique value that designates
375 which namespace to retrieve a value from.
376 @param[in] TokenNumber The PCD token number to retrieve a current value for.
377
378 @return Return the VOID* pointer.
379
380 **/
381 VOID *
382 EFIAPI
383 LibPcdGetExPtr (
384 IN CONST GUID *Guid,
385 IN UINTN TokenNumber
386 )
387 {
388 ASSERT (Guid != NULL);
389
390 return (GetPiPcdPpiPointer ())->GetPtr (Guid, TokenNumber);
391 }
392
393 /**
394 This function provides a means by which to retrieve a value for a given PCD token.
395
396 Returns the Boolean value of the token specified by TokenNumber and Guid.
397
398 If Guid is NULL, then ASSERT().
399
400 @param[in] Guid The pointer to a 128-bit unique value that designates
401 which namespace to retrieve a value from.
402 @param[in] TokenNumber The PCD token number to retrieve a current value for.
403
404 @return Return the BOOLEAN.
405
406 **/
407 BOOLEAN
408 EFIAPI
409 LibPcdGetExBool (
410 IN CONST GUID *Guid,
411 IN UINTN TokenNumber
412 )
413 {
414 ASSERT (Guid != NULL);
415 return (GetPiPcdPpiPointer ())->GetBool (Guid, TokenNumber);
416 }
417
418 /**
419 This function provides a means by which to retrieve the size of a given PCD token.
420
421 Returns the size of the token specified by TokenNumber and Guid.
422
423 If Guid is NULL, then ASSERT().
424
425 @param[in] Guid The pointer to a 128-bit unique value that designates
426 which namespace to retrieve a value from.
427 @param[in] TokenNumber The PCD token number to retrieve a current value for.
428
429 @return Return the size.
430
431 **/
432 UINTN
433 EFIAPI
434 LibPcdGetExSize (
435 IN CONST GUID *Guid,
436 IN UINTN TokenNumber
437 )
438 {
439 ASSERT (Guid != NULL);
440 return (GetPiPcdPpiPointer ())->GetSize (Guid, TokenNumber);
441 }
442
443 /**
444 This function provides a means by which to set a value for a given PCD token.
445
446 Sets the 8-bit value for the token specified by TokenNumber
447 to the value specified by Value.
448
449 @param[in] TokenNumber The PCD token number to set a current value for.
450 @param[in] Value The 8-bit value to set.
451
452 @return The status of the set operation.
453
454 **/
455 RETURN_STATUS
456 EFIAPI
457 LibPcdSet8S (
458 IN UINTN TokenNumber,
459 IN UINT8 Value
460 )
461 {
462 return (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);
463 }
464
465 /**
466 This function provides a means by which to set a value for a given PCD token.
467
468 Sets the 16-bit value for the token specified by TokenNumber
469 to the value specified by Value.
470
471 @param[in] TokenNumber The PCD token number to set a current value for.
472 @param[in] Value The 16-bit value to set.
473
474 @return The status of the set operation.
475
476 **/
477 RETURN_STATUS
478 EFIAPI
479 LibPcdSet16S (
480 IN UINTN TokenNumber,
481 IN UINT16 Value
482 )
483 {
484 return (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);
485 }
486
487 /**
488 This function provides a means by which to set a value for a given PCD token.
489
490 Sets the 32-bit value for the token specified by TokenNumber
491 to the value specified by Value.
492
493 @param[in] TokenNumber The PCD token number to set a current value for.
494 @param[in] Value The 32-bit value to set.
495
496 @return The status of the set operation.
497
498 **/
499 RETURN_STATUS
500 EFIAPI
501 LibPcdSet32S (
502 IN UINTN TokenNumber,
503 IN UINT32 Value
504 )
505 {
506 return (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);
507 }
508
509 /**
510 This function provides a means by which to set a value for a given PCD token.
511
512 Sets the 64-bit value for the token specified by TokenNumber
513 to the value specified by Value.
514
515 @param[in] TokenNumber The PCD token number to set a current value for.
516 @param[in] Value The 64-bit value to set.
517
518 @return The status of the set operation.
519
520 **/
521 RETURN_STATUS
522 EFIAPI
523 LibPcdSet64S (
524 IN UINTN TokenNumber,
525 IN UINT64 Value
526 )
527 {
528 return (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);
529 }
530
531 /**
532 This function provides a means by which to set a value for a given PCD token.
533
534 Sets a buffer for the token specified by TokenNumber to the value specified
535 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
536 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
537 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
538 was not actually performed.
539
540 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
541 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
542
543 If SizeOfBuffer is NULL, then ASSERT().
544 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
545
546 @param[in] TokenNumber The PCD token number to set a current value for.
547 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
548 @param[in] Buffer A pointer to the buffer to set.
549
550 @return The status of the set operation.
551
552 **/
553 RETURN_STATUS
554 EFIAPI
555 LibPcdSetPtrS (
556 IN UINTN TokenNumber,
557 IN OUT UINTN *SizeOfBuffer,
558 IN CONST VOID *Buffer
559 )
560 {
561 ASSERT (SizeOfBuffer != NULL);
562
563 if (*SizeOfBuffer > 0) {
564 ASSERT (Buffer != NULL);
565 }
566
567 return (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *)Buffer);
568 }
569
570 /**
571 This function provides a means by which to set a value for a given PCD token.
572
573 Sets the boolean value for the token specified by TokenNumber
574 to the value specified by Value.
575
576 @param[in] TokenNumber The PCD token number to set a current value for.
577 @param[in] Value The boolean value to set.
578
579 @return The status of the set operation.
580
581 **/
582 RETURN_STATUS
583 EFIAPI
584 LibPcdSetBoolS (
585 IN UINTN TokenNumber,
586 IN BOOLEAN Value
587 )
588 {
589 return (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);
590 }
591
592 /**
593 This function provides a means by which to set a value for a given PCD token.
594
595 Sets the 8-bit value for the token specified by TokenNumber
596 to the value specified by Value.
597
598 If Guid is NULL, then ASSERT().
599
600 @param[in] Guid The pointer to a 128-bit unique value that
601 designates which namespace to set a value from.
602 @param[in] TokenNumber The PCD token number to set a current value for.
603 @param[in] Value The 8-bit value to set.
604
605 @return The status of the set operation.
606
607 **/
608 RETURN_STATUS
609 EFIAPI
610 LibPcdSetEx8S (
611 IN CONST GUID *Guid,
612 IN UINTN TokenNumber,
613 IN UINT8 Value
614 )
615 {
616 ASSERT (Guid != NULL);
617
618 return (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);
619 }
620
621 /**
622 This function provides a means by which to set a value for a given PCD token.
623
624 Sets the 16-bit value for the token specified by TokenNumber
625 to the value specified by Value.
626
627 If Guid is NULL, then ASSERT().
628
629 @param[in] Guid The pointer to a 128-bit unique value that
630 designates which namespace to set a value from.
631 @param[in] TokenNumber The PCD token number to set a current value for.
632 @param[in] Value The 16-bit value to set.
633
634 @return The status of the set operation.
635
636 **/
637 RETURN_STATUS
638 EFIAPI
639 LibPcdSetEx16S (
640 IN CONST GUID *Guid,
641 IN UINTN TokenNumber,
642 IN UINT16 Value
643 )
644 {
645 ASSERT (Guid != NULL);
646
647 return (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);
648 }
649
650 /**
651 This function provides a means by which to set a value for a given PCD token.
652
653 Sets the 32-bit value for the token specified by TokenNumber
654 to the value specified by Value.
655
656 If Guid is NULL, then ASSERT().
657
658 @param[in] Guid The pointer to a 128-bit unique value that
659 designates which namespace to set a value from.
660 @param[in] TokenNumber The PCD token number to set a current value for.
661 @param[in] Value The 32-bit value to set.
662
663 @return The status of the set operation.
664
665 **/
666 RETURN_STATUS
667 EFIAPI
668 LibPcdSetEx32S (
669 IN CONST GUID *Guid,
670 IN UINTN TokenNumber,
671 IN UINT32 Value
672 )
673 {
674 ASSERT (Guid != NULL);
675
676 return (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);
677 }
678
679 /**
680 This function provides a means by which to set a value for a given PCD token.
681
682 Sets the 64-bit value for the token specified by TokenNumber
683 to the value specified by Value.
684
685 If Guid is NULL, then ASSERT().
686
687 @param[in] Guid The pointer to a 128-bit unique value that
688 designates which namespace to set a value from.
689 @param[in] TokenNumber The PCD token number to set a current value for.
690 @param[in] Value The 64-bit value to set.
691
692 @return The status of the set operation.
693
694 **/
695 RETURN_STATUS
696 EFIAPI
697 LibPcdSetEx64S (
698 IN CONST GUID *Guid,
699 IN UINTN TokenNumber,
700 IN UINT64 Value
701 )
702 {
703 ASSERT (Guid != NULL);
704
705 return (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);
706 }
707
708 /**
709 This function provides a means by which to set a value for a given PCD token.
710
711 Sets a buffer for the token specified by TokenNumber to the value specified by
712 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
713 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
714 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
715 was not actually performed.
716
717 If Guid is NULL, then ASSERT().
718 If SizeOfBuffer is NULL, then ASSERT().
719 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
720
721 @param[in] Guid Pointer to a 128-bit unique value that
722 designates which namespace to set a value from.
723 @param[in] TokenNumber The PCD token number to set a current value for.
724 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
725 @param[in] Buffer A pointer to the buffer to set.
726
727 @return The status of the set operation.
728
729 **/
730 RETURN_STATUS
731 EFIAPI
732 LibPcdSetExPtrS (
733 IN CONST GUID *Guid,
734 IN UINTN TokenNumber,
735 IN OUT UINTN *SizeOfBuffer,
736 IN VOID *Buffer
737 )
738 {
739 ASSERT (Guid != NULL);
740
741 ASSERT (SizeOfBuffer != NULL);
742
743 if (*SizeOfBuffer > 0) {
744 ASSERT (Buffer != NULL);
745 }
746
747 return (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
748 }
749
750 /**
751 This function provides a means by which to set a value for a given PCD token.
752
753 Sets the boolean value for the token specified by TokenNumber
754 to the value specified by Value.
755
756 If Guid is NULL, then ASSERT().
757
758 @param[in] Guid The pointer to a 128-bit unique value that
759 designates which namespace to set a value from.
760 @param[in] TokenNumber The PCD token number to set a current value for.
761 @param[in] Value The boolean value to set.
762
763 @return The status of the set operation.
764
765 **/
766 RETURN_STATUS
767 EFIAPI
768 LibPcdSetExBoolS (
769 IN CONST GUID *Guid,
770 IN UINTN TokenNumber,
771 IN BOOLEAN Value
772 )
773 {
774 ASSERT (Guid != NULL);
775
776 return (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);
777 }
778
779 /**
780 Set up a notification function that is called when a specified token is set.
781
782 When the token specified by TokenNumber and Guid is set,
783 then notification function specified by NotificationFunction is called.
784 If Guid is NULL, then the default token space is used.
785 If NotificationFunction is NULL, then ASSERT().
786
787 @param[in] Guid The pointer to a 128-bit unique value that
788 designates which namespace to set a value from.
789 If NULL, then the default token space is used.
790 @param[in] TokenNumber The PCD token number to monitor.
791 @param[in] NotificationFunction The function to call when the token
792 specified by Guid and TokenNumber is set.
793
794 **/
795 VOID
796 EFIAPI
797 LibPcdCallbackOnSet (
798 IN CONST GUID *Guid OPTIONAL,
799 IN UINTN TokenNumber,
800 IN PCD_CALLBACK NotificationFunction
801 )
802 {
803 EFI_STATUS Status;
804
805 ASSERT (NotificationFunction != NULL);
806
807 Status = (GetPiPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK)NotificationFunction);
808
809 ASSERT_EFI_ERROR (Status);
810
811 return;
812 }
813
814 /**
815 Disable a notification function that was established with LibPcdCallbackonSet().
816
817 Disable a notification function that was previously established with LibPcdCallbackOnSet().
818 If NotificationFunction is NULL, then ASSERT().
819 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
820 and NotificationFunction, then ASSERT().
821
822 @param[in] Guid Specify the GUID token space.
823 @param[in] TokenNumber Specify the token number.
824 @param[in] NotificationFunction The callback function to be unregistered.
825
826 **/
827 VOID
828 EFIAPI
829 LibPcdCancelCallback (
830 IN CONST GUID *Guid OPTIONAL,
831 IN UINTN TokenNumber,
832 IN PCD_CALLBACK NotificationFunction
833 )
834 {
835 EFI_STATUS Status;
836
837 ASSERT (NotificationFunction != NULL);
838
839 Status = (GetPiPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK)NotificationFunction);
840
841 ASSERT_EFI_ERROR (Status);
842
843 return;
844 }
845
846 /**
847 Retrieves the next token in a token space.
848
849 Retrieves the next PCD token number from the token space specified by Guid.
850 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
851 then the first token number is returned. Otherwise, the token number that
852 follows TokenNumber in the token space is returned. If TokenNumber is the last
853 token number in the token space, then 0 is returned.
854
855 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
856
857 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
858 to set a value from. If NULL, then the default token space is used.
859 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
860 token number.
861
862 @return The next valid token number.
863
864 **/
865 UINTN
866 EFIAPI
867 LibPcdGetNextToken (
868 IN CONST GUID *Guid OPTIONAL,
869 IN UINTN TokenNumber
870 )
871 {
872 EFI_STATUS Status;
873
874 Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);
875 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
876
877 return TokenNumber;
878 }
879
880 /**
881 Used to retrieve the list of available PCD token space GUIDs.
882
883 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
884 in the platform.
885 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
886 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
887
888 @param TokenSpaceGuid The pointer to the a PCD token space GUID
889
890 @return The next valid token namespace.
891
892 **/
893 GUID *
894 EFIAPI
895 LibPcdGetNextTokenSpace (
896 IN CONST GUID *TokenSpaceGuid
897 )
898 {
899 (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);
900
901 return (GUID *)TokenSpaceGuid;
902 }
903
904 /**
905 Sets a value of a patchable PCD entry that is type pointer.
906
907 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
908 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
909 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
910 NULL to indicate that the set operation was not actually performed.
911 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
912 MaximumDatumSize and NULL must be returned.
913
914 If PatchVariable is NULL, then ASSERT().
915 If SizeOfBuffer is NULL, then ASSERT().
916 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
917
918 @param[out] PatchVariable A pointer to the global variable in a module that is
919 the target of the set operation.
920 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
921 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
922 @param[in] Buffer A pointer to the buffer to used to set the target variable.
923
924 @return Return the pointer to the buffer been set.
925
926 **/
927 VOID *
928 EFIAPI
929 LibPatchPcdSetPtr (
930 OUT VOID *PatchVariable,
931 IN UINTN MaximumDatumSize,
932 IN OUT UINTN *SizeOfBuffer,
933 IN CONST VOID *Buffer
934 )
935 {
936 ASSERT (PatchVariable != NULL);
937 ASSERT (SizeOfBuffer != NULL);
938
939 if (*SizeOfBuffer > 0) {
940 ASSERT (Buffer != NULL);
941 }
942
943 if ((*SizeOfBuffer > MaximumDatumSize) ||
944 (*SizeOfBuffer == MAX_ADDRESS))
945 {
946 *SizeOfBuffer = MaximumDatumSize;
947 return NULL;
948 }
949
950 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
951
952 return (VOID *)Buffer;
953 }
954
955 /**
956 Sets a value of a patchable PCD entry that is type pointer.
957
958 Sets the PCD entry specified by PatchVariable to the value specified
959 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
960 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
961 to indicate that the set operation was not actually performed.
962 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
963 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
964
965 If PatchVariable is NULL, then ASSERT().
966 If SizeOfBuffer is NULL, then ASSERT().
967 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
968
969 @param[out] PatchVariable A pointer to the global variable in a module that is
970 the target of the set operation.
971 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
972 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
973 @param[in] Buffer A pointer to the buffer to used to set the target variable.
974
975 @return The status of the set operation.
976
977 **/
978 RETURN_STATUS
979 EFIAPI
980 LibPatchPcdSetPtrS (
981 OUT VOID *PatchVariable,
982 IN UINTN MaximumDatumSize,
983 IN OUT UINTN *SizeOfBuffer,
984 IN CONST VOID *Buffer
985 )
986 {
987 ASSERT (PatchVariable != NULL);
988 ASSERT (SizeOfBuffer != NULL);
989
990 if (*SizeOfBuffer > 0) {
991 ASSERT (Buffer != NULL);
992 }
993
994 if ((*SizeOfBuffer > MaximumDatumSize) ||
995 (*SizeOfBuffer == MAX_ADDRESS))
996 {
997 *SizeOfBuffer = MaximumDatumSize;
998 return RETURN_INVALID_PARAMETER;
999 }
1000
1001 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1002
1003 return RETURN_SUCCESS;
1004 }
1005
1006 /**
1007 Sets a value and size of a patchable PCD entry that is type pointer.
1008
1009 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1010 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1011 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1012 NULL to indicate that the set operation was not actually performed.
1013 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1014 MaximumDatumSize and NULL must be returned.
1015
1016 If PatchVariable is NULL, then ASSERT().
1017 If SizeOfPatchVariable is NULL, then ASSERT().
1018 If SizeOfBuffer is NULL, then ASSERT().
1019 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1020
1021 @param[out] PatchVariable A pointer to the global variable in a module that is
1022 the target of the set operation.
1023 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1024 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1025 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1026 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1027
1028 @return Return the pointer to the buffer been set.
1029
1030 **/
1031 VOID *
1032 EFIAPI
1033 LibPatchPcdSetPtrAndSize (
1034 OUT VOID *PatchVariable,
1035 OUT UINTN *SizeOfPatchVariable,
1036 IN UINTN MaximumDatumSize,
1037 IN OUT UINTN *SizeOfBuffer,
1038 IN CONST VOID *Buffer
1039 )
1040 {
1041 ASSERT (PatchVariable != NULL);
1042 ASSERT (SizeOfPatchVariable != NULL);
1043 ASSERT (SizeOfBuffer != NULL);
1044
1045 if (*SizeOfBuffer > 0) {
1046 ASSERT (Buffer != NULL);
1047 }
1048
1049 if ((*SizeOfBuffer > MaximumDatumSize) ||
1050 (*SizeOfBuffer == MAX_ADDRESS))
1051 {
1052 *SizeOfBuffer = MaximumDatumSize;
1053 return NULL;
1054 }
1055
1056 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1057 *SizeOfPatchVariable = *SizeOfBuffer;
1058
1059 return (VOID *)Buffer;
1060 }
1061
1062 /**
1063 Sets a value and size of a patchable PCD entry that is type pointer.
1064
1065 Sets the PCD entry specified by PatchVariable to the value specified
1066 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1067 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1068 to indicate that the set operation was not actually performed.
1069 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1070 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1071
1072 If PatchVariable is NULL, then ASSERT().
1073 If SizeOfPatchVariable is NULL, then ASSERT().
1074 If SizeOfBuffer is NULL, then ASSERT().
1075 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1076
1077 @param[out] PatchVariable A pointer to the global variable in a module that is
1078 the target of the set operation.
1079 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1080 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1081 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1082 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1083
1084 @return The status of the set operation.
1085
1086 **/
1087 RETURN_STATUS
1088 EFIAPI
1089 LibPatchPcdSetPtrAndSizeS (
1090 OUT VOID *PatchVariable,
1091 OUT UINTN *SizeOfPatchVariable,
1092 IN UINTN MaximumDatumSize,
1093 IN OUT UINTN *SizeOfBuffer,
1094 IN CONST VOID *Buffer
1095 )
1096 {
1097 ASSERT (PatchVariable != NULL);
1098 ASSERT (SizeOfPatchVariable != NULL);
1099 ASSERT (SizeOfBuffer != NULL);
1100
1101 if (*SizeOfBuffer > 0) {
1102 ASSERT (Buffer != NULL);
1103 }
1104
1105 if ((*SizeOfBuffer > MaximumDatumSize) ||
1106 (*SizeOfBuffer == MAX_ADDRESS))
1107 {
1108 *SizeOfBuffer = MaximumDatumSize;
1109 return RETURN_INVALID_PARAMETER;
1110 }
1111
1112 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1113 *SizeOfPatchVariable = *SizeOfBuffer;
1114
1115 return RETURN_SUCCESS;
1116 }
1117
1118 /**
1119 Retrieve additional information associated with a PCD token.
1120
1121 This includes information such as the type of value the TokenNumber is associated with as well as possible
1122 human readable name that is associated with the token.
1123
1124 If TokenNumber is not in the default token space specified, then ASSERT().
1125
1126 @param[in] TokenNumber The PCD token number.
1127 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1128 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1129 **/
1130 VOID
1131 EFIAPI
1132 LibPcdGetInfo (
1133 IN UINTN TokenNumber,
1134 OUT PCD_INFO *PcdInfo
1135 )
1136 {
1137 EFI_STATUS Status;
1138
1139 Status = GetPcdInfoPpiPointer ()->GetInfo (TokenNumber, (EFI_PCD_INFO *)PcdInfo);
1140 ASSERT_EFI_ERROR (Status);
1141 }
1142
1143 /**
1144 Retrieve additional information associated with a PCD token.
1145
1146 This includes information such as the type of value the TokenNumber is associated with as well as possible
1147 human readable name that is associated with the token.
1148
1149 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1150
1151 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1152 @param[in] TokenNumber The PCD token number.
1153 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1154 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1155 **/
1156 VOID
1157 EFIAPI
1158 LibPcdGetInfoEx (
1159 IN CONST GUID *Guid,
1160 IN UINTN TokenNumber,
1161 OUT PCD_INFO *PcdInfo
1162 )
1163 {
1164 EFI_STATUS Status;
1165
1166 Status = GetPiPcdInfoPpiPointer ()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *)PcdInfo);
1167 ASSERT_EFI_ERROR (Status);
1168 }
1169
1170 /**
1171 Retrieve the currently set SKU Id.
1172
1173 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1174 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
1175 Id is returned.
1176 **/
1177 UINTN
1178 EFIAPI
1179 LibPcdGetSku (
1180 VOID
1181 )
1182 {
1183 return GetPiPcdInfoPpiPointer ()->GetSku ();
1184 }