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