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