2 Implementation of PcdLib class library for PEI phase.
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
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.
14 Module Name: PeiPcdLib.c
21 The constructor function retrieve the PCD_PPI pointer.
25 @retval PCD_PPI * The pointer to the PCD_PPI.
35 EFI_PEI_SERVICES
**PeiServices
;
38 PeiServices
= GetPeiServicesTablePointer ();
40 Status
= (**PeiServices
).LocatePpi (
48 ASSERT_EFI_ERROR (Status
);
56 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
58 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
59 set values associated with a PCD token.
61 @retval UINTN Return the SKU ID that just be set.
73 PcdPpi
= GetPcdPpiPtr ();
76 Status
= PcdPpi
->SetSku (SkuId
);
77 ASSERT_EFI_ERROR (Status
);
85 Returns the 8-bit value for the token specified by TokenNumber.
87 @param[in] The PCD token number to retrieve a current value for.
89 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
100 PcdPpi
= GetPcdPpiPtr ();
102 return PcdPpi
->Get8 (TokenNumber
);
108 Returns the 16-bit value for the token specified by TokenNumber.
110 @param[in] The PCD token number to retrieve a current value for.
112 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
123 PcdPpi
= GetPcdPpiPtr ();
125 return PcdPpi
->Get16 (TokenNumber
);
131 Returns the 32-bit value for the token specified by TokenNumber.
133 @param[in] TokenNumber The PCD token number to retrieve a current value for.
135 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
146 PcdPpi
= GetPcdPpiPtr ();
148 return PcdPpi
->Get32 (TokenNumber
);
154 Returns the 64-bit value for the token specified by TokenNumber.
156 @param[in] TokenNumber The PCD token number to retrieve a current value for.
158 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
169 PcdPpi
= GetPcdPpiPtr ();
171 return PcdPpi
->Get64 (TokenNumber
);
177 Returns the pointer to the buffer of the token specified by TokenNumber.
179 @param[in] TokenNumber The PCD token number to retrieve a current value for.
181 @retval VOID* Returns the pointer to the token specified by TokenNumber.
192 PcdPpi
= GetPcdPpiPtr ();
194 return PcdPpi
->GetPtr (TokenNumber
);
200 Returns the Boolean value of the token specified by TokenNumber.
202 @param[in] TokenNumber The PCD token number to retrieve a current value for.
204 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
215 PcdPpi
= GetPcdPpiPtr ();
217 return PcdPpi
->GetBool (TokenNumber
);
223 Returns the size of the token specified by TokenNumber.
225 @param[in] TokenNumber The PCD token number to retrieve a current value for.
227 @retval UINTN Returns the size of the token specified by TokenNumber.
238 PcdPpi
= GetPcdPpiPtr ();
240 return PcdPpi
->GetSize (TokenNumber
);
246 Returns the 8-bit value for the token specified by TokenNumber and Guid.
247 If Guid is NULL, then ASSERT().
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.
253 @retval UINT8 Return the UINT8.
265 PcdPpi
= GetPcdPpiPtr ();
267 return PcdPpi
->Get8Ex (Guid
, TokenNumber
);
273 Returns the 16-bit value for the token specified by TokenNumber and Guid.
274 If Guid is NULL, then ASSERT().
276 @param[in] Guid Pointer to a 128-bit unique value that designates
277 which namespace to retrieve a value from.
278 @param[in] TokenNumber The PCD token number to retrieve a current value for.
280 @retval UINT16 Return the UINT16.
292 PcdPpi
= GetPcdPpiPtr ();
294 return PcdPpi
->Get16Ex (Guid
, TokenNumber
);
300 Returns the 32-bit value for the token specified by TokenNumber and Guid.
301 If Guid is NULL, then ASSERT().
303 @param[in] Guid Pointer to a 128-bit unique value that designates
304 which namespace to retrieve a value from.
305 @param[in] TokenNumber The PCD token number to retrieve a current value for.
307 @retval UINT32 Return the UINT32.
319 PcdPpi
= GetPcdPpiPtr ();
321 return PcdPpi
->Get32Ex (Guid
, TokenNumber
);
328 Returns the 64-bit value for the token specified by TokenNumber and Guid.
329 If Guid is NULL, then ASSERT().
331 @param[in] Guid Pointer to a 128-bit unique value that designates
332 which namespace to retrieve a value from.
333 @param[in] TokenNumber The PCD token number to retrieve a current value for.
335 @retval UINT64 Return the UINT64.
347 PcdPpi
= GetPcdPpiPtr ();
349 return PcdPpi
->Get64Ex (Guid
, TokenNumber
);
355 Returns the pointer to the token specified by TokenNumber and Guid.
356 If Guid is NULL, then ASSERT().
358 @param[in] Guid Pointer to a 128-bit unique value that designates
359 which namespace to retrieve a value from.
360 @param[in] TokenNumber The PCD token number to retrieve a current value for.
362 @retval VOID* Return the VOID* pointer.
374 PcdPpi
= GetPcdPpiPtr ();
376 return PcdPpi
->GetPtrEx (Guid
, TokenNumber
);
382 Returns the Boolean value of the token specified by TokenNumber and Guid.
383 If Guid is NULL, then ASSERT().
385 @param[in] Guid Pointer to a 128-bit unique value that designates
386 which namespace to retrieve a value from.
387 @param[in] TokenNumber The PCD token number to retrieve a current value for.
389 @retval BOOLEAN Return the BOOLEAN.
401 PcdPpi
= GetPcdPpiPtr ();
403 return PcdPpi
->GetBoolEx (Guid
, TokenNumber
);
409 Returns the size of the token specified by TokenNumber and Guid.
410 If Guid is NULL, then ASSERT().
412 @param[in] Guid Pointer to a 128-bit unique value that designates
413 which namespace to retrieve a value from.
414 @param[in] TokenNumber The PCD token number to retrieve a current value for.
416 @retval UINTN Return the size.
428 PcdPpi
= GetPcdPpiPtr ();
430 return PcdPpi
->GetSizeEx (Guid
, TokenNumber
);
436 Sets the 8-bit value for the token specified by TokenNumber
437 to the value specified by Value. Value is returned.
439 @param[in] TokenNumber The PCD token number to set a current value for.
440 @param[in] Value The 8-bit value to set.
442 @retval UINT8 Return the value been set.
448 IN UINTN TokenNumber
,
455 PcdPpi
= GetPcdPpiPtr ();
458 Status
= PcdPpi
->Set8 (TokenNumber
, Value
);
460 ASSERT_EFI_ERROR (Status
);
468 Sets the 16-bit value for the token specified by TokenNumber
469 to the value specified by Value. Value is returned.
471 @param[in] TokenNumber The PCD token number to set a current value for.
472 @param[in] Value The 16-bit value to set.
474 @retval UINT16 Return the value been set.
480 IN UINTN TokenNumber
,
487 PcdPpi
= GetPcdPpiPtr ();
490 Status
= PcdPpi
->Set16 (TokenNumber
, Value
);
492 ASSERT_EFI_ERROR (Status
);
500 Sets the 32-bit value for the token specified by TokenNumber
501 to the value specified by Value. Value is returned.
503 @param[in] TokenNumber The PCD token number to set a current value for.
504 @param[in] Value The 32-bit value to set.
506 @retval UINT32 Return the value been set.
512 IN UINTN TokenNumber
,
519 PcdPpi
= GetPcdPpiPtr ();
521 Status
= PcdPpi
->Set32 (TokenNumber
, Value
);
523 ASSERT_EFI_ERROR (Status
);
531 Sets the 64-bit value for the token specified by TokenNumber
532 to the value specified by Value. Value is returned.
534 @param[in] TokenNumber The PCD token number to set a current value for.
535 @param[in] Value The 64-bit value to set.
537 @retval UINT64 Return the value been set.
543 IN UINTN TokenNumber
,
550 PcdPpi
= GetPcdPpiPtr ();
553 Status
= PcdPpi
->Set64 (TokenNumber
, Value
);
555 ASSERT_EFI_ERROR (Status
);
563 Sets a buffer for the token specified by TokenNumber to
564 the value specified by Value. Value is returned.
565 If Value is NULL, then ASSERT().
567 @param[in] TokenNumber The PCD token number to set a current value for.
568 @param[in] Value A pointer to the buffer to set.
570 @retval VOID* Return the pointer for the buffer been set.
576 IN UINTN TokenNumber
,
583 PcdPpi
= GetPcdPpiPtr ();
586 Status
= PcdPpi
->SetPtr (TokenNumber
, Value
);
588 ASSERT_EFI_ERROR (Status
);
590 return (VOID
*)Value
;
596 Sets the Boolean value for the token specified by TokenNumber
597 to the value specified by Value. Value is returned.
599 @param[in] TokenNumber The PCD token number to set a current value for.
600 @param[in] Value The boolean value to set.
602 @retval BOOLEAN Return the value been set.
608 IN UINTN TokenNumber
,
615 PcdPpi
= GetPcdPpiPtr ();
618 Status
= PcdPpi
->SetBool (TokenNumber
, Value
);
620 ASSERT_EFI_ERROR (Status
);
628 Sets the 8-bit value for the token specified by TokenNumber and
629 Guid to the value specified by Value. Value is returned.
630 If Guid is NULL, then ASSERT().
632 @param[in] Guid Pointer to a 128-bit unique value that
633 designates which namespace to set a value from.
634 @param[in] TokenNumber The PCD token number to set a current value for.
635 @param[in] Value The 8-bit value to set.
637 @retval UINT8 Return the value been set.
644 IN UINTN TokenNumber
,
651 PcdPpi
= GetPcdPpiPtr ();
654 Status
= PcdPpi
->Set8Ex (Guid
, TokenNumber
, Value
);
656 ASSERT_EFI_ERROR (Status
);
664 Sets the 16-bit value for the token specified by TokenNumber and
665 Guid to the value specified by Value. Value is returned.
666 If Guid is NULL, then ASSERT().
668 @param[in] Guid Pointer to a 128-bit unique value that
669 designates which namespace to set a value from.
670 @param[in] TokenNumber The PCD token number to set a current value for.
671 @param[in] Value The 16-bit value to set.
673 @retval UINT8 Return the value been set.
680 IN UINTN TokenNumber
,
687 PcdPpi
= GetPcdPpiPtr ();
690 Status
= PcdPpi
->Set16Ex (Guid
, TokenNumber
, Value
);
692 ASSERT_EFI_ERROR (Status
);
700 Sets the 32-bit value for the token specified by TokenNumber and
701 Guid to the value specified by Value. Value is returned.
702 If Guid is NULL, then ASSERT().
704 @param[in] Guid Pointer to a 128-bit unique value that
705 designates which namespace to set a value from.
706 @param[in] TokenNumber The PCD token number to set a current value for.
707 @param[in] Value The 32-bit value to set.
709 @retval UINT32 Return the value been set.
716 IN UINTN TokenNumber
,
723 PcdPpi
= GetPcdPpiPtr ();
726 Status
= PcdPpi
->Set32Ex (Guid
, TokenNumber
, Value
);
728 ASSERT_EFI_ERROR (Status
);
736 Sets the 64-bit value for the token specified by TokenNumber and
737 Guid to the value specified by Value. Value is returned.
738 If Guid is NULL, then ASSERT().
740 @param[in] Guid Pointer to a 128-bit unique value that
741 designates which namespace to set a value from.
742 @param[in] TokenNumber The PCD token number to set a current value for.
743 @param[in] Value The 64-bit value to set.
745 @retval UINT64 Return the value been set.
752 IN UINTN TokenNumber
,
759 PcdPpi
= GetPcdPpiPtr ();
762 Status
= PcdPpi
->Set64Ex (Guid
, TokenNumber
, Value
);
764 ASSERT_EFI_ERROR (Status
);
772 Sets a buffer for the token specified by TokenNumber and
773 Guid to the value specified by Value. Value is returned.
774 If Guid is NULL, then ASSERT().
775 If Value is NULL, then ASSERT().
777 @param[in] Guid Pointer to a 128-bit unique value that
778 designates which namespace to set a value from.
779 @param[in] TokenNumber The PCD token number to set a current value for.
780 @param[in] Value The 8-bit value to set.
782 @retval VOID * Return the value been set.
789 IN UINTN TokenNumber
,
796 PcdPpi
= GetPcdPpiPtr ();
799 Status
= PcdPpi
->SetPtrEx (Guid
, TokenNumber
, Value
);
801 ASSERT_EFI_ERROR (Status
);
803 return (VOID
*)Value
;
809 Sets the Boolean value for the token specified by TokenNumber and
810 Guid to the value specified by Value. Value is returned.
811 If Guid is NULL, then ASSERT().
813 @param[in] Guid Pointer to a 128-bit unique value that
814 designates which namespace to set a value from.
815 @param[in] TokenNumber The PCD token number to set a current value for.
816 @param[in] Value The Boolean value to set.
818 @retval Boolean Return the value been set.
825 IN UINTN TokenNumber
,
832 PcdPpi
= GetPcdPpiPtr ();
835 Status
= PcdPpi
->SetBoolEx (Guid
, TokenNumber
, Value
);
837 ASSERT_EFI_ERROR (Status
);
845 When the token specified by TokenNumber and Guid is set,
846 then notification function specified by NotificationFunction is called.
847 If Guid is NULL, then the default token space is used.
848 If NotificationFunction is NULL, then ASSERT().
850 @param[in] Guid Pointer to a 128-bit unique value that designates which
851 namespace to set a value from. If NULL, then the default
853 @param[in] TokenNumber The PCD token number to monitor.
854 @param[in] NotificationFunction The function to call when the token
855 specified by Guid and TokenNumber is set.
862 LibPcdCallbackOnSet (
863 IN CONST GUID
*Guid
, OPTIONAL
864 IN UINTN TokenNumber
,
865 IN PCD_CALLBACK NotificationFunction
871 PcdPpi
= GetPcdPpiPtr ();
874 Status
= PcdPpi
->CallbackOnSet (TokenNumber
, Guid
, NotificationFunction
);
876 ASSERT_EFI_ERROR (Status
);
884 Disable a notification function that was established with LibPcdCallbackonSet().
885 If NotificationFunction is NULL, then ASSERT().
887 @param[in] Guid Specify the GUID token space.
888 @param[in] TokenNumber Specify the token number.
889 @param[in] NotificationFunction The callback function to be unregistered.
896 LibPcdCancelCallback (
897 IN CONST GUID
*Guid
, OPTIONAL
898 IN UINTN TokenNumber
,
899 IN PCD_CALLBACK NotificationFunction
905 PcdPpi
= GetPcdPpiPtr ();
908 Status
= PcdPpi
->CancelCallback (TokenNumber
, Guid
, NotificationFunction
);
910 ASSERT_EFI_ERROR (Status
);
918 Retrieves the next PCD token number from the token space specified by Guid.
919 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
920 then the first token number is returned. Otherwise, the token number that
921 follows TokenNumber in the token space is returned. If TokenNumber is the last
922 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
923 is not in the token space specified by Guid, then ASSERT().
925 @param[in] Pointer to a 128-bit unique value that designates which namespace
926 to set a value from. If NULL, then the default token space is used.
927 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
930 @retval UINTN The next valid token number.
936 IN CONST GUID
*Guid
, OPTIONAL
937 IN OUT UINTN
*TokenNumber
943 PcdPpi
= GetPcdPpiPtr ();
946 Status
= PcdPpi
->GetNextToken (Guid
, TokenNumber
);
948 ASSERT_EFI_ERROR (Status
);
950 return (*TokenNumber
);