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