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