]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/DxePcdLib/DxePcdLib.c
3062df4fcd1876c43d40b09c679a53e179097fa7
[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 VOID *
528 EFIAPI
529 LibPcdSetPtr (
530 IN UINTN TokenNumber,
531 IN OUT UINTN *SizeOfBuffer,
532 IN VOID *Buffer
533 )
534 {
535 EFI_STATUS Status;
536
537 ASSERT (SizeOfBuffer != NULL);
538
539 if (*SizeOfBuffer > 0) {
540 ASSERT (Buffer != NULL);
541 }
542
543 Status = (GetPcdProtocol ())->SetPtr (TokenNumber, SizeOfBuffer, Buffer);
544
545 if (EFI_ERROR (Status)) {
546 return NULL;
547 }
548
549 return Buffer;
550 }
551
552
553
554 /**
555 Sets the Boolean value for the token specified by TokenNumber
556 to the value specified by Value. Value is returned.
557
558 @param[in] TokenNumber The PCD token number to set a current value for.
559 @param[in] Value The boolean value to set.
560
561 @retval BOOLEAN Return the value been set.
562
563 **/
564 BOOLEAN
565 EFIAPI
566 LibPcdSetBool (
567 IN UINTN TokenNumber,
568 IN BOOLEAN Value
569 )
570 {
571 EFI_STATUS Status;
572
573 Status = (GetPcdProtocol ())->SetBool (TokenNumber, Value);
574
575 ASSERT_EFI_ERROR (Status);
576
577 return Value;
578 }
579
580
581
582 /**
583 Sets the 8-bit value for the token specified by TokenNumber and
584 Guid to the value specified by Value. Value is returned.
585 If Guid is NULL, then ASSERT().
586
587 @param[in] Guid Pointer to a 128-bit unique value that
588 designates which namespace to set a value from.
589 @param[in] TokenNumber The PCD token number to set a current value for.
590 @param[in] Value The 8-bit value to set.
591
592 @retval UINT8 Return the value been set.
593
594 **/
595 UINT8
596 EFIAPI
597 LibPcdSetEx8 (
598 IN CONST GUID *Guid,
599 IN UINTN TokenNumber,
600 IN UINT8 Value
601 )
602 {
603 EFI_STATUS Status;
604
605 ASSERT (Guid != NULL);
606
607 Status = (GetPcdProtocol ())->Set8Ex (Guid, TokenNumber, Value);
608
609 ASSERT_EFI_ERROR (Status);
610
611 return Value;
612 }
613
614
615
616 /**
617 Sets the 16-bit value for the token specified by TokenNumber and
618 Guid to the value specified by Value. Value is returned.
619 If Guid is NULL, then ASSERT().
620
621 @param[in] Guid Pointer to a 128-bit unique value that
622 designates which namespace to set a value from.
623 @param[in] TokenNumber The PCD token number to set a current value for.
624 @param[in] Value The 16-bit value to set.
625
626 @retval UINT8 Return the value been set.
627
628 **/
629 UINT16
630 EFIAPI
631 LibPcdSetEx16 (
632 IN CONST GUID *Guid,
633 IN UINTN TokenNumber,
634 IN UINT16 Value
635 )
636 {
637 EFI_STATUS Status;
638
639 ASSERT (Guid != NULL);
640
641 Status = (GetPcdProtocol ())->Set16Ex (Guid, TokenNumber, Value);
642
643 ASSERT_EFI_ERROR (Status);
644
645 return Value;
646 }
647
648
649
650 /**
651 Sets the 32-bit value for the token specified by TokenNumber and
652 Guid to the value specified by Value. Value is returned.
653 If Guid is NULL, then ASSERT().
654
655 @param[in] Guid Pointer to a 128-bit unique value that
656 designates which namespace to set a value from.
657 @param[in] TokenNumber The PCD token number to set a current value for.
658 @param[in] Value The 32-bit value to set.
659
660 @retval UINT32 Return the value been set.
661
662 **/
663 UINT32
664 EFIAPI
665 LibPcdSetEx32 (
666 IN CONST GUID *Guid,
667 IN UINTN TokenNumber,
668 IN UINT32 Value
669 )
670 {
671 EFI_STATUS Status;
672
673 ASSERT (Guid != NULL);
674
675 Status = (GetPcdProtocol ())->Set32Ex (Guid, TokenNumber, Value);
676
677 ASSERT_EFI_ERROR (Status);
678
679 return Value;
680 }
681
682
683
684 /**
685 Sets the 64-bit value for the token specified by TokenNumber and
686 Guid to the value specified by Value. Value is returned.
687 If Guid is NULL, then ASSERT().
688
689 @param[in] Guid Pointer to a 128-bit unique value that
690 designates which namespace to set a value from.
691 @param[in] TokenNumber The PCD token number to set a current value for.
692 @param[in] Value The 64-bit value to set.
693
694 @retval UINT64 Return the value been set.
695
696 **/
697 UINT64
698 EFIAPI
699 LibPcdSetEx64 (
700 IN CONST GUID *Guid,
701 IN UINTN TokenNumber,
702 IN UINT64 Value
703 )
704 {
705 EFI_STATUS Status;
706
707 ASSERT (Guid != NULL);
708
709 Status = (GetPcdProtocol ())->Set64Ex (Guid, TokenNumber, Value);
710
711 ASSERT_EFI_ERROR (Status);
712
713 return Value;
714 }
715
716
717
718 /**
719 Sets a buffer for the token specified by TokenNumber to the value specified by
720 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
721 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
722 supported by TokenNumber and return NULL to indicate that the set operation
723 was not actually performed.
724
725 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
726
727 @param[in] Guid Pointer to a 128-bit unique value that
728 designates which namespace to set a value from.
729 @param[in] TokenNumber The PCD token number to set a current value for.
730 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
731 @param[in] Buffer A pointer to the buffer to set.
732
733 @retval VOID * Return the pinter to the buffer been set.
734
735 **/
736 VOID *
737 EFIAPI
738 LibPcdSetExPtr (
739 IN CONST GUID *Guid,
740 IN UINTN TokenNumber,
741 IN OUT UINTN *SizeOfBuffer,
742 IN VOID *Buffer
743 )
744 {
745 EFI_STATUS Status;
746
747 ASSERT (Guid != NULL);
748
749 ASSERT (SizeOfBuffer != NULL);
750
751 if (*SizeOfBuffer > 0) {
752 ASSERT (Buffer != NULL);
753 }
754
755 Status = (GetPcdProtocol ())->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);
756
757 if (EFI_ERROR (Status)) {
758 return NULL;
759 }
760
761 return Buffer;
762 }
763
764
765
766 /**
767 Sets the Boolean value for the token specified by TokenNumber and
768 Guid to the value specified by Value. Value is returned.
769 If Guid is NULL, then ASSERT().
770
771 @param[in] Guid Pointer to a 128-bit unique value that
772 designates which namespace to set a value from.
773 @param[in] TokenNumber The PCD token number to set a current value for.
774 @param[in] Value The Boolean value to set.
775
776 @retval Boolean Return the value been set.
777
778 **/
779 BOOLEAN
780 EFIAPI
781 LibPcdSetExBool (
782 IN CONST GUID *Guid,
783 IN UINTN TokenNumber,
784 IN BOOLEAN Value
785 )
786 {
787 EFI_STATUS Status;
788
789 ASSERT (Guid != NULL);
790
791 Status = (GetPcdProtocol ())->SetBoolEx (Guid, TokenNumber, Value);
792
793 ASSERT_EFI_ERROR (Status);
794
795 return Value;
796 }
797
798
799
800 /**
801 When the token specified by TokenNumber and Guid is set,
802 then notification function specified by NotificationFunction is called.
803 If Guid is NULL, then the default token space is used.
804 If NotificationFunction is NULL, then ASSERT().
805
806 @param[in] Guid Pointer to a 128-bit unique value that designates which
807 namespace to set a value from. If NULL, then the default
808 token space is used.
809 @param[in] TokenNumber The PCD token number to monitor.
810 @param[in] NotificationFunction The function to call when the token
811 specified by Guid and TokenNumber is set.
812
813 @retval VOID
814
815 **/
816 VOID
817 EFIAPI
818 LibPcdCallbackOnSet (
819 IN CONST GUID *Guid, OPTIONAL
820 IN UINTN TokenNumber,
821 IN PCD_CALLBACK NotificationFunction
822 )
823 {
824 EFI_STATUS Status;
825
826 ASSERT (NotificationFunction != NULL);
827
828 Status = (GetPcdProtocol ())->CallbackOnSet (Guid, TokenNumber, NotificationFunction);
829
830 ASSERT_EFI_ERROR (Status);
831
832 return;
833 }
834
835
836
837 /**
838 Disable a notification function that was established with LibPcdCallbackonSet().
839 If NotificationFunction is NULL, then ASSERT().
840
841 @param[in] Guid Specify the GUID token space.
842 @param[in] TokenNumber Specify the token number.
843 @param[in] NotificationFunction The callback function to be unregistered.
844
845 @retval VOID
846
847 **/
848 VOID
849 EFIAPI
850 LibPcdCancelCallback (
851 IN CONST GUID *Guid, OPTIONAL
852 IN UINTN TokenNumber,
853 IN PCD_CALLBACK NotificationFunction
854 )
855 {
856 EFI_STATUS Status;
857
858 ASSERT (NotificationFunction != NULL);
859
860 Status = (GetPcdProtocol ())->CancelCallback (Guid, TokenNumber, NotificationFunction);
861
862 ASSERT_EFI_ERROR (Status);
863
864 return;
865 }
866
867
868
869 /**
870 Retrieves the next PCD token number from the token space specified by Guid.
871 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
872 then the first token number is returned. Otherwise, the token number that
873 follows TokenNumber in the token space is returned. If TokenNumber is the last
874 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
875 is not in the token space specified by Guid, then ASSERT().
876
877 @param[in] Guid Pointer to a 128-bit unique value that designates which namespace
878 to set a value from. If NULL, then the default token space is used.
879 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
880 token number.
881
882 @retval UINTN The next valid token number.
883
884 **/
885 UINTN
886 EFIAPI
887 LibPcdGetNextToken (
888 IN CONST GUID *Guid, OPTIONAL
889 IN UINTN TokenNumber
890 )
891 {
892 EFI_STATUS Status;
893
894 Status = (GetPcdProtocol ())->GetNextToken (Guid, &TokenNumber);
895
896 ASSERT_EFI_ERROR (Status);
897
898 return TokenNumber;
899 }
900
901
902
903 /**
904 Retrieves the next PCD token space from a token space specified by Guid.
905 Guid of NULL is reserved to mark the default local token namespace on the current
906 platform. If Guid is NULL, then the GUID of the first non-local token space of the
907 current platform is returned. If Guid is the last non-local token space,
908 then NULL is returned.
909
910 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
911
912
913
914 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace
915 to start the search.
916
917 @retval CONST GUID * The next valid token namespace.
918
919 **/
920 GUID *
921 EFIAPI
922 LibPcdGetNextTokenSpace (
923 IN CONST GUID *Guid
924 )
925 {
926 EFI_STATUS Status;
927
928 Status = (GetPcdProtocol ())->GetNextTokenSpace (&Guid);
929
930 ASSERT_EFI_ERROR (Status);
931
932 return (GUID *) Guid;
933 }
934
935
936 /**
937 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
938 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
939 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
940 NULL to indicate that the set operation was not actually performed.
941 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
942 MaximumDatumSize and NULL must be returned.
943
944 If PatchVariable is NULL, then ASSERT().
945 If SizeOfValue is NULL, then ASSERT().
946 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
947
948 @param[in] PatchVariable A pointer to the global variable in a module that is
949 the target of the set operation.
950 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
951 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
952 @param[in] Buffer A pointer to the buffer to used to set the target variable.
953
954 **/
955 VOID *
956 EFIAPI
957 LibPatchPcdSetPtr (
958 IN VOID *PatchVariable,
959 IN UINTN MaximumDatumSize,
960 IN OUT UINTN *SizeOfBuffer,
961 IN CONST VOID *Buffer
962 )
963 {
964 ASSERT (PatchVariable != NULL);
965 ASSERT (SizeOfBuffer != NULL);
966
967 if (*SizeOfBuffer > 0) {
968 ASSERT (Buffer != NULL);
969 }
970
971 if ((*SizeOfBuffer > MaximumDatumSize) ||
972 (*SizeOfBuffer == MAX_ADDRESS)) {
973 *SizeOfBuffer = MaximumDatumSize;
974 return NULL;
975 }
976
977 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
978
979 return (VOID *) Buffer;
980 }
981
982
983