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