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