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