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