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