]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
84edb9befd1265bd8093f5f7bd626cd3b5dc6d4f
[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 This function provides a means by which to set a value for a given PCD token.
479
480 Sets the 8-bit value for the token specified by TokenNumber
481 to the value specified by Value.
482
483 @param[in] TokenNumber The PCD token number to set a current value for.
484 @param[in] Value The 8-bit value to set.
485
486 @return The status of the set operation.
487
488 **/
489 RETURN_STATUS
490 EFIAPI
491 LibPcdSet8S (
492 IN UINTN TokenNumber,
493 IN UINT8 Value
494 )
495 {
496 return (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);
497 }
498
499 /**
500 This function provides a means by which to set a value for a given PCD token.
501
502 Sets the 16-bit value for the token specified by TokenNumber
503 to the value specified by Value.
504
505 @param[in] TokenNumber The PCD token number to set a current value for.
506 @param[in] Value The 16-bit value to set.
507
508 @return The status of the set operation.
509
510 **/
511 RETURN_STATUS
512 EFIAPI
513 LibPcdSet16S (
514 IN UINTN TokenNumber,
515 IN UINT16 Value
516 )
517 {
518 return (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);
519 }
520
521 /**
522 This function provides a means by which to set a value for a given PCD token.
523
524 Sets the 32-bit value for the token specified by TokenNumber
525 to the value specified by Value.
526
527 @param[in] TokenNumber The PCD token number to set a current value for.
528 @param[in] Value The 32-bit value to set.
529
530 @return The status of the set operation.
531
532 **/
533 RETURN_STATUS
534 EFIAPI
535 LibPcdSet32S (
536 IN UINTN TokenNumber,
537 IN UINT32 Value
538 )
539 {
540 return (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);
541 }
542
543 /**
544 This function provides a means by which to set a value for a given PCD token.
545
546 Sets the 64-bit value for the token specified by TokenNumber
547 to the value specified by Value.
548
549 @param[in] TokenNumber The PCD token number to set a current value for.
550 @param[in] Value The 64-bit value to set.
551
552 @return The status of the set operation.
553
554 **/
555 RETURN_STATUS
556 EFIAPI
557 LibPcdSet64S (
558 IN UINTN TokenNumber,
559 IN UINT64 Value
560 )
561 {
562 return (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);
563 }
564
565 /**
566 This function provides a means by which to set a value for a given PCD token.
567
568 Sets a buffer for the token specified by TokenNumber to the value specified
569 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
570 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
571 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
572 was not actually performed.
573
574 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
575 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
576
577 If SizeOfBuffer is NULL, then ASSERT().
578 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
579
580 @param[in] TokenNumber The PCD token number to set a current value for.
581 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
582 @param[in] Buffer A pointer to the buffer to set.
583
584 @return The status of the set operation.
585
586 **/
587 RETURN_STATUS
588 EFIAPI
589 LibPcdSetPtrS (
590 IN UINTN TokenNumber,
591 IN OUT UINTN *SizeOfBuffer,
592 IN CONST VOID *Buffer
593 )
594 {
595 ASSERT (SizeOfBuffer != NULL);
596
597 if (*SizeOfBuffer > 0) {
598 ASSERT (Buffer != NULL);
599 }
600
601 return (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
602 }
603
604 /**
605 This function provides a means by which to set a value for a given PCD token.
606
607 Sets the boolean value for the token specified by TokenNumber
608 to the value specified by Value.
609
610 @param[in] TokenNumber The PCD token number to set a current value for.
611 @param[in] Value The boolean value to set.
612
613 @return The status of the set operation.
614
615 **/
616 RETURN_STATUS
617 EFIAPI
618 LibPcdSetBoolS (
619 IN UINTN TokenNumber,
620 IN BOOLEAN Value
621 )
622 {
623 return (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);
624 }
625
626 /**
627 This function provides a means by which to set a value for a given PCD token.
628
629 Sets the 8-bit value for the token specified by TokenNumber
630 to the value specified by Value.
631
632 If Guid is NULL, then ASSERT().
633
634 @param[in] Guid The pointer to a 128-bit unique value that
635 designates which namespace to set a value from.
636 @param[in] TokenNumber The PCD token number to set a current value for.
637 @param[in] Value The 8-bit value to set.
638
639 @return The status of the set operation.
640
641 **/
642 RETURN_STATUS
643 EFIAPI
644 LibPcdSetEx8S (
645 IN CONST GUID *Guid,
646 IN UINTN TokenNumber,
647 IN UINT8 Value
648 )
649 {
650 ASSERT (Guid != NULL);
651
652 return (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);
653 }
654
655 /**
656 This function provides a means by which to set a value for a given PCD token.
657
658 Sets the 16-bit value for the token specified by TokenNumber
659 to the value specified by Value.
660
661 If Guid is NULL, then ASSERT().
662
663 @param[in] Guid The pointer to a 128-bit unique value that
664 designates which namespace to set a value from.
665 @param[in] TokenNumber The PCD token number to set a current value for.
666 @param[in] Value The 16-bit value to set.
667
668 @return The status of the set operation.
669
670 **/
671 RETURN_STATUS
672 EFIAPI
673 LibPcdSetEx16S (
674 IN CONST GUID *Guid,
675 IN UINTN TokenNumber,
676 IN UINT16 Value
677 )
678 {
679 ASSERT (Guid != NULL);
680
681 return (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);
682 }
683
684 /**
685 This function provides a means by which to set a value for a given PCD token.
686
687 Sets the 32-bit value for the token specified by TokenNumber
688 to the value specified by Value.
689
690 If Guid is NULL, then ASSERT().
691
692 @param[in] Guid The pointer to a 128-bit unique value that
693 designates which namespace to set a value from.
694 @param[in] TokenNumber The PCD token number to set a current value for.
695 @param[in] Value The 32-bit value to set.
696
697 @return The status of the set operation.
698
699 **/
700 RETURN_STATUS
701 EFIAPI
702 LibPcdSetEx32S (
703 IN CONST GUID *Guid,
704 IN UINTN TokenNumber,
705 IN UINT32 Value
706 )
707 {
708 ASSERT (Guid != NULL);
709
710 return (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);
711 }
712
713 /**
714 This function provides a means by which to set a value for a given PCD token.
715
716 Sets the 64-bit value for the token specified by TokenNumber
717 to the value specified by Value.
718
719 If Guid is NULL, then ASSERT().
720
721 @param[in] Guid The 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] Value The 64-bit value to set.
725
726 @return The status of the set operation.
727
728 **/
729 RETURN_STATUS
730 EFIAPI
731 LibPcdSetEx64S (
732 IN CONST GUID *Guid,
733 IN UINTN TokenNumber,
734 IN UINT64 Value
735 )
736 {
737 ASSERT (Guid != NULL);
738
739 return (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);
740 }
741
742 /**
743 This function provides a means by which to set a value for a given PCD token.
744
745 Sets a buffer for the token specified by TokenNumber to the value specified by
746 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
747 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
748 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
749 was not actually performed.
750
751 If Guid is NULL, then ASSERT().
752 If SizeOfBuffer is NULL, then ASSERT().
753 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
754
755 @param[in] Guid Pointer to a 128-bit unique value that
756 designates which namespace to set a value from.
757 @param[in] TokenNumber The PCD token number to set a current value for.
758 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
759 @param[in] Buffer A pointer to the buffer to set.
760
761 @return The status of the set operation.
762
763 **/
764 RETURN_STATUS
765 EFIAPI
766 LibPcdSetExPtrS (
767 IN CONST GUID *Guid,
768 IN UINTN TokenNumber,
769 IN OUT UINTN *SizeOfBuffer,
770 IN VOID *Buffer
771 )
772 {
773 ASSERT (Guid != NULL);
774
775 ASSERT (SizeOfBuffer != NULL);
776
777 if (*SizeOfBuffer > 0) {
778 ASSERT (Buffer != NULL);
779 }
780
781 return (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
782 }
783
784 /**
785 This function provides a means by which to set a value for a given PCD token.
786
787 Sets the boolean value for the token specified by TokenNumber
788 to the value specified by Value.
789
790 If Guid is NULL, then ASSERT().
791
792 @param[in] Guid The pointer to a 128-bit unique value that
793 designates which namespace to set a value from.
794 @param[in] TokenNumber The PCD token number to set a current value for.
795 @param[in] Value The boolean value to set.
796
797 @return The status of the set operation.
798
799 **/
800 RETURN_STATUS
801 EFIAPI
802 LibPcdSetExBoolS (
803 IN CONST GUID *Guid,
804 IN UINTN TokenNumber,
805 IN BOOLEAN Value
806 )
807 {
808 ASSERT (Guid != NULL);
809
810 return (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);
811 }
812
813 /**
814 Set up a notification function that is called when a specified token is set.
815
816 When the token specified by TokenNumber and Guid is set,
817 then notification function specified by NotificationFunction is called.
818 If Guid is NULL, then the default token space is used.
819 If NotificationFunction is NULL, then ASSERT().
820
821 @param[in] Guid The pointer to a 128-bit unique value that
822 designates which namespace to set a value from.
823 If NULL, then the default token space is used.
824 @param[in] TokenNumber The PCD token number to monitor.
825 @param[in] NotificationFunction The function to call when the token
826 specified by Guid and TokenNumber is set.
827
828 **/
829 VOID
830 EFIAPI
831 LibPcdCallbackOnSet (
832 IN CONST GUID *Guid OPTIONAL,
833 IN UINTN TokenNumber,
834 IN PCD_CALLBACK NotificationFunction
835 )
836 {
837 EFI_STATUS Status;
838
839 ASSERT (NotificationFunction != NULL);
840
841 Status = (GetPiPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);
842
843 ASSERT_EFI_ERROR (Status);
844
845 return;
846 }
847
848
849
850 /**
851 Disable a notification function that was established with LibPcdCallbackonSet().
852
853 Disable a notification function that was previously established with LibPcdCallbackOnSet().
854 If NotificationFunction is NULL, then ASSERT().
855 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
856 and NotificationFunction, then ASSERT().
857
858 @param[in] Guid Specify the GUID token space.
859 @param[in] TokenNumber Specify the token number.
860 @param[in] NotificationFunction The callback function to be unregistered.
861
862 **/
863 VOID
864 EFIAPI
865 LibPcdCancelCallback (
866 IN CONST GUID *Guid OPTIONAL,
867 IN UINTN TokenNumber,
868 IN PCD_CALLBACK NotificationFunction
869 )
870 {
871 EFI_STATUS Status;
872
873 ASSERT (NotificationFunction != NULL);
874
875 Status = (GetPiPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);
876
877 ASSERT_EFI_ERROR (Status);
878
879 return;
880 }
881
882
883
884 /**
885 Retrieves the next token in a token space.
886
887 Retrieves the next PCD token number from the token space specified by Guid.
888 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
889 then the first token number is returned. Otherwise, the token number that
890 follows TokenNumber in the token space is returned. If TokenNumber is the last
891 token number in the token space, then 0 is returned.
892
893 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
894
895 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
896 to set a value from. If NULL, then the default token space is used.
897 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
898 token number.
899
900 @return The next valid token number.
901
902 **/
903 UINTN
904 EFIAPI
905 LibPcdGetNextToken (
906 IN CONST GUID *Guid OPTIONAL,
907 IN UINTN TokenNumber
908 )
909 {
910 EFI_STATUS Status;
911
912 Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);
913 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
914
915 return TokenNumber;
916 }
917
918
919 /**
920 Used to retrieve the list of available PCD token space GUIDs.
921
922 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
923 in the platform.
924 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
925 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
926
927 @param TokenSpaceGuid The pointer to the a PCD token space GUID
928
929 @return The next valid token namespace.
930
931 **/
932 GUID *
933 EFIAPI
934 LibPcdGetNextTokenSpace (
935 IN CONST GUID *TokenSpaceGuid
936 )
937 {
938 (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);
939
940 return (GUID *) TokenSpaceGuid;
941 }
942
943
944
945 /**
946 Sets a value of a patchable PCD entry that is type pointer.
947
948 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
949 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
950 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
951 NULL to indicate that the set operation was not actually performed.
952 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
953 MaximumDatumSize and NULL must be returned.
954
955 If PatchVariable is NULL, then ASSERT().
956 If SizeOfBuffer is NULL, then ASSERT().
957 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
958
959 @param[out] PatchVariable A pointer to the global variable in a module that is
960 the target of the set operation.
961 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
962 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
963 @param[in] Buffer A pointer to the buffer to used to set the target variable.
964
965 @return Return the pointer to the buffer been set.
966
967 **/
968 VOID *
969 EFIAPI
970 LibPatchPcdSetPtr (
971 OUT VOID *PatchVariable,
972 IN UINTN MaximumDatumSize,
973 IN OUT UINTN *SizeOfBuffer,
974 IN CONST VOID *Buffer
975 )
976 {
977 ASSERT (PatchVariable != NULL);
978 ASSERT (SizeOfBuffer != NULL);
979
980 if (*SizeOfBuffer > 0) {
981 ASSERT (Buffer != NULL);
982 }
983
984 if ((*SizeOfBuffer > MaximumDatumSize) ||
985 (*SizeOfBuffer == MAX_ADDRESS)) {
986 *SizeOfBuffer = MaximumDatumSize;
987 return NULL;
988 }
989
990 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
991
992 return (VOID *) Buffer;
993 }
994
995 /**
996 Sets a value of a patchable PCD entry that is type pointer.
997
998 Sets the PCD entry specified by PatchVariable to the value specified
999 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1000 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1001 to indicate that the set operation was not actually performed.
1002 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1003 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1004
1005 If PatchVariable is NULL, then ASSERT().
1006 If SizeOfBuffer is NULL, then ASSERT().
1007 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1008
1009 @param[out] PatchVariable A pointer to the global variable in a module that is
1010 the target of the set operation.
1011 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1012 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1013 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1014
1015 @return The status of the set operation.
1016
1017 **/
1018 RETURN_STATUS
1019 EFIAPI
1020 LibPatchPcdSetPtrS (
1021 OUT VOID *PatchVariable,
1022 IN UINTN MaximumDatumSize,
1023 IN OUT UINTN *SizeOfBuffer,
1024 IN CONST VOID *Buffer
1025 )
1026 {
1027 ASSERT (PatchVariable != NULL);
1028 ASSERT (SizeOfBuffer != NULL);
1029
1030 if (*SizeOfBuffer > 0) {
1031 ASSERT (Buffer != NULL);
1032 }
1033
1034 if ((*SizeOfBuffer > MaximumDatumSize) ||
1035 (*SizeOfBuffer == MAX_ADDRESS)) {
1036 *SizeOfBuffer = MaximumDatumSize;
1037 return RETURN_INVALID_PARAMETER;
1038 }
1039
1040 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1041
1042 return RETURN_SUCCESS;
1043 }
1044
1045
1046 /**
1047 Sets a value and size of a patchable PCD entry that is type pointer.
1048
1049 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1050 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1051 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1052 NULL to indicate that the set operation was not actually performed.
1053 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1054 MaximumDatumSize and NULL must be returned.
1055
1056 If PatchVariable is NULL, then ASSERT().
1057 If SizeOfPatchVariable is NULL, then ASSERT().
1058 If SizeOfBuffer is NULL, then ASSERT().
1059 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1060
1061 @param[out] PatchVariable A pointer to the global variable in a module that is
1062 the target of the set operation.
1063 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1064 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1065 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1066 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1067
1068 @return Return the pointer to the buffer been set.
1069
1070 **/
1071 VOID *
1072 EFIAPI
1073 LibPatchPcdSetPtrAndSize (
1074 OUT VOID *PatchVariable,
1075 OUT UINTN *SizeOfPatchVariable,
1076 IN UINTN MaximumDatumSize,
1077 IN OUT UINTN *SizeOfBuffer,
1078 IN CONST VOID *Buffer
1079 )
1080 {
1081 ASSERT (PatchVariable != NULL);
1082 ASSERT (SizeOfPatchVariable != NULL);
1083 ASSERT (SizeOfBuffer != NULL);
1084
1085 if (*SizeOfBuffer > 0) {
1086 ASSERT (Buffer != NULL);
1087 }
1088
1089 if ((*SizeOfBuffer > MaximumDatumSize) ||
1090 (*SizeOfBuffer == MAX_ADDRESS)) {
1091 *SizeOfBuffer = MaximumDatumSize;
1092 return NULL;
1093 }
1094
1095 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1096 *SizeOfPatchVariable = *SizeOfBuffer;
1097
1098 return (VOID *) Buffer;
1099 }
1100
1101 /**
1102 Sets a value and size of a patchable PCD entry that is type pointer.
1103
1104 Sets the PCD entry specified by PatchVariable to the value specified
1105 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1106 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1107 to indicate that the set operation was not actually performed.
1108 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1109 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1110
1111 If PatchVariable is NULL, then ASSERT().
1112 If SizeOfPatchVariable is NULL, then ASSERT().
1113 If SizeOfBuffer is NULL, then ASSERT().
1114 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1115
1116 @param[out] PatchVariable A pointer to the global variable in a module that is
1117 the target of the set operation.
1118 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1119 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1120 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1121 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1122
1123 @return The status of the set operation.
1124
1125 **/
1126 RETURN_STATUS
1127 EFIAPI
1128 LibPatchPcdSetPtrAndSizeS (
1129 OUT VOID *PatchVariable,
1130 OUT UINTN *SizeOfPatchVariable,
1131 IN UINTN MaximumDatumSize,
1132 IN OUT UINTN *SizeOfBuffer,
1133 IN CONST VOID *Buffer
1134 )
1135 {
1136 ASSERT (PatchVariable != NULL);
1137 ASSERT (SizeOfPatchVariable != NULL);
1138 ASSERT (SizeOfBuffer != NULL);
1139
1140 if (*SizeOfBuffer > 0) {
1141 ASSERT (Buffer != NULL);
1142 }
1143
1144 if ((*SizeOfBuffer > MaximumDatumSize) ||
1145 (*SizeOfBuffer == MAX_ADDRESS)) {
1146 *SizeOfBuffer = MaximumDatumSize;
1147 return RETURN_INVALID_PARAMETER;
1148 }
1149
1150 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1151 *SizeOfPatchVariable = *SizeOfBuffer;
1152
1153 return RETURN_SUCCESS;
1154 }
1155
1156 /**
1157 Retrieve additional information associated with a PCD token.
1158
1159 This includes information such as the type of value the TokenNumber is associated with as well as possible
1160 human readable name that is associated with the token.
1161
1162 If TokenNumber is not in the default token space specified, then ASSERT().
1163
1164 @param[in] TokenNumber The PCD token number.
1165 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1166 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1167 **/
1168 VOID
1169 EFIAPI
1170 LibPcdGetInfo (
1171 IN UINTN TokenNumber,
1172 OUT PCD_INFO *PcdInfo
1173 )
1174 {
1175 EFI_STATUS Status;
1176
1177 Status = GetPcdInfoPpiPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);
1178 ASSERT_EFI_ERROR (Status);
1179 }
1180
1181 /**
1182 Retrieve additional information associated with a PCD token.
1183
1184 This includes information such as the type of value the TokenNumber is associated with as well as possible
1185 human readable name that is associated with the token.
1186
1187 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1188
1189 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1190 @param[in] TokenNumber The PCD token number.
1191 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1192 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1193 **/
1194 VOID
1195 EFIAPI
1196 LibPcdGetInfoEx (
1197 IN CONST GUID *Guid,
1198 IN UINTN TokenNumber,
1199 OUT PCD_INFO *PcdInfo
1200 )
1201 {
1202 EFI_STATUS Status;
1203
1204 Status = GetPiPcdInfoPpiPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);
1205 ASSERT_EFI_ERROR (Status);
1206 }
1207
1208 /**
1209 Retrieve the currently set SKU Id.
1210
1211 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1212 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
1213 Id is returned.
1214 **/
1215 UINTN
1216 EFIAPI
1217 LibPcdGetSku (
1218 VOID
1219 )
1220 {
1221 return GetPiPcdInfoPpiPointer()->GetSku ();
1222 }