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 SKU_ID Return the SKU ID that just be set.
71 GetPcdPpiPtr()->SetSku (SkuId
);;
79 Returns the 8-bit value for the token specified by TokenNumber.
81 @param[in] The PCD token number to retrieve a current value for.
83 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
94 PcdPpi
= GetPcdPpiPtr ();
96 return PcdPpi
->Get8 (TokenNumber
);
102 Returns the 16-bit value for the token specified by TokenNumber.
104 @param[in] The PCD token number to retrieve a current value for.
106 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
117 PcdPpi
= GetPcdPpiPtr ();
119 return PcdPpi
->Get16 (TokenNumber
);
125 Returns the 32-bit value for the token specified by TokenNumber.
127 @param[in] TokenNumber The PCD token number to retrieve a current value for.
129 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
140 PcdPpi
= GetPcdPpiPtr ();
142 return PcdPpi
->Get32 (TokenNumber
);
148 Returns the 64-bit value for the token specified by TokenNumber.
150 @param[in] TokenNumber The PCD token number to retrieve a current value for.
152 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
163 PcdPpi
= GetPcdPpiPtr ();
165 return PcdPpi
->Get64 (TokenNumber
);
171 Returns the pointer to the buffer of the token specified by TokenNumber.
173 @param[in] TokenNumber The PCD token number to retrieve a current value for.
175 @retval VOID* Returns the pointer to the token specified by TokenNumber.
186 PcdPpi
= GetPcdPpiPtr ();
188 return PcdPpi
->GetPtr (TokenNumber
);
194 Returns the Boolean value of the token specified by TokenNumber.
196 @param[in] TokenNumber The PCD token number to retrieve a current value for.
198 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
209 PcdPpi
= GetPcdPpiPtr ();
211 return PcdPpi
->GetBool (TokenNumber
);
217 Returns the size of the token specified by TokenNumber.
219 @param[in] TokenNumber The PCD token number to retrieve a current value for.
221 @retval UINTN Returns the size of the token specified by TokenNumber.
232 PcdPpi
= GetPcdPpiPtr ();
234 return PcdPpi
->GetSize (TokenNumber
);
240 Returns the 8-bit value for the token specified by TokenNumber and Guid.
241 If Guid is NULL, then ASSERT().
243 @param[in] Guid Pointer to a 128-bit unique value that designates
244 which namespace to retrieve a value from.
245 @param[in] TokenNumber The PCD token number to retrieve a current value for.
247 @retval UINT8 Return the UINT8.
259 PcdPpi
= GetPcdPpiPtr ();
261 return PcdPpi
->Get8Ex (Guid
, TokenNumber
);
267 Returns the 16-bit value for the token specified by TokenNumber and Guid.
268 If Guid is NULL, then ASSERT().
270 @param[in] Guid Pointer to a 128-bit unique value that designates
271 which namespace to retrieve a value from.
272 @param[in] TokenNumber The PCD token number to retrieve a current value for.
274 @retval UINT16 Return the UINT16.
286 PcdPpi
= GetPcdPpiPtr ();
288 return PcdPpi
->Get16Ex (Guid
, TokenNumber
);
294 Returns the 32-bit value for the token specified by TokenNumber and Guid.
295 If Guid is NULL, then ASSERT().
297 @param[in] Guid Pointer to a 128-bit unique value that designates
298 which namespace to retrieve a value from.
299 @param[in] TokenNumber The PCD token number to retrieve a current value for.
301 @retval UINT32 Return the UINT32.
313 PcdPpi
= GetPcdPpiPtr ();
315 return PcdPpi
->Get32Ex (Guid
, TokenNumber
);
322 Returns the 64-bit value for the token specified by TokenNumber and Guid.
323 If Guid is NULL, then ASSERT().
325 @param[in] Guid Pointer to a 128-bit unique value that designates
326 which namespace to retrieve a value from.
327 @param[in] TokenNumber The PCD token number to retrieve a current value for.
329 @retval UINT64 Return the UINT64.
341 PcdPpi
= GetPcdPpiPtr ();
343 return PcdPpi
->Get64Ex (Guid
, TokenNumber
);
349 Returns the pointer to the token specified by TokenNumber and Guid.
350 If Guid is NULL, then ASSERT().
352 @param[in] Guid Pointer to a 128-bit unique value that designates
353 which namespace to retrieve a value from.
354 @param[in] TokenNumber The PCD token number to retrieve a current value for.
356 @retval VOID* Return the VOID* pointer.
368 PcdPpi
= GetPcdPpiPtr ();
370 return PcdPpi
->GetPtrEx (Guid
, TokenNumber
);
376 Returns the Boolean value of the token specified by TokenNumber and Guid.
377 If Guid is NULL, then ASSERT().
379 @param[in] Guid Pointer to a 128-bit unique value that designates
380 which namespace to retrieve a value from.
381 @param[in] TokenNumber The PCD token number to retrieve a current value for.
383 @retval BOOLEAN Return the BOOLEAN.
395 PcdPpi
= GetPcdPpiPtr ();
397 return PcdPpi
->GetBoolEx (Guid
, TokenNumber
);
403 Returns the size of the token specified by TokenNumber and Guid.
404 If Guid is NULL, then ASSERT().
406 @param[in] Guid Pointer to a 128-bit unique value that designates
407 which namespace to retrieve a value from.
408 @param[in] TokenNumber The PCD token number to retrieve a current value for.
410 @retval UINTN Return the size.
422 PcdPpi
= GetPcdPpiPtr ();
424 return PcdPpi
->GetSizeEx (Guid
, TokenNumber
);
430 Sets the 8-bit value for the token specified by TokenNumber
431 to the value specified by Value. Value is returned.
433 @param[in] TokenNumber The PCD token number to set a current value for.
434 @param[in] Value The 8-bit value to set.
436 @retval UINT8 Return the value been set.
442 IN UINTN TokenNumber
,
449 PcdPpi
= GetPcdPpiPtr ();
452 Status
= PcdPpi
->Set8 (TokenNumber
, Value
);
454 ASSERT_EFI_ERROR (Status
);
462 Sets the 16-bit value for the token specified by TokenNumber
463 to the value specified by Value. Value is returned.
465 @param[in] TokenNumber The PCD token number to set a current value for.
466 @param[in] Value The 16-bit value to set.
468 @retval UINT16 Return the value been set.
474 IN UINTN TokenNumber
,
481 PcdPpi
= GetPcdPpiPtr ();
484 Status
= PcdPpi
->Set16 (TokenNumber
, Value
);
486 ASSERT_EFI_ERROR (Status
);
494 Sets the 32-bit value for the token specified by TokenNumber
495 to the value specified by Value. Value is returned.
497 @param[in] TokenNumber The PCD token number to set a current value for.
498 @param[in] Value The 32-bit value to set.
500 @retval UINT32 Return the value been set.
506 IN UINTN TokenNumber
,
513 PcdPpi
= GetPcdPpiPtr ();
515 Status
= PcdPpi
->Set32 (TokenNumber
, Value
);
517 ASSERT_EFI_ERROR (Status
);
525 Sets the 64-bit value for the token specified by TokenNumber
526 to the value specified by Value. Value is returned.
528 @param[in] TokenNumber The PCD token number to set a current value for.
529 @param[in] Value The 64-bit value to set.
531 @retval UINT64 Return the value been set.
537 IN UINTN TokenNumber
,
544 PcdPpi
= GetPcdPpiPtr ();
547 Status
= PcdPpi
->Set64 (TokenNumber
, Value
);
549 ASSERT_EFI_ERROR (Status
);
557 Sets a buffer for the token specified by TokenNumber to
558 the value specified by Buffer and SizeOfValue. Buffer to
559 be set is returned. The content of the buffer could be
560 overwritten if a Callback on SET is registered with this
563 If SizeOfValue is greater than the maximum
564 size support by TokenNumber, then set SizeOfValue to the
565 maximum size supported by TokenNumber and return NULL to
566 indicate that the set operation was not actually performed.
568 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
570 @param[in] TokenNumber The PCD token number to set a current value for.
571 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.
572 @param[in] Value A pointer to the buffer to set.
574 @retval VOID* Return the pointer for the buffer been set.
580 IN UINTN TokenNumber
,
581 IN OUT UINTN
*SizeOfBuffer
,
589 PcdPpi
= GetPcdPpiPtr ();
591 ASSERT ((*SizeOfBuffer
> 0) && Buffer
== NULL
);
593 Size
= LibPcdGetSize (TokenNumber
);
595 if (*SizeOfBuffer
> Size
) {
596 *SizeOfBuffer
= Size
;
600 Status
= PcdPpi
->SetPtr (TokenNumber
, *SizeOfBuffer
, Buffer
);
602 ASSERT_EFI_ERROR (Status
);
610 Sets the Boolean value for the token specified by TokenNumber
611 to the value specified by Value. Value is returned.
613 @param[in] TokenNumber The PCD token number to set a current value for.
614 @param[in] Value The boolean value to set.
616 @retval BOOLEAN Return the value been set.
622 IN UINTN TokenNumber
,
629 PcdPpi
= GetPcdPpiPtr ();
632 Status
= PcdPpi
->SetBool (TokenNumber
, Value
);
634 ASSERT_EFI_ERROR (Status
);
642 Sets the 8-bit value for the token specified by TokenNumber and
643 Guid to the value specified by Value. Value is returned.
644 If Guid is NULL, then ASSERT().
646 @param[in] Guid Pointer to a 128-bit unique value that
647 designates which namespace to set a value from.
648 @param[in] TokenNumber The PCD token number to set a current value for.
649 @param[in] Value The 8-bit value to set.
651 @retval UINT8 Return the value been set.
658 IN UINTN TokenNumber
,
665 PcdPpi
= GetPcdPpiPtr ();
668 Status
= PcdPpi
->Set8Ex (Guid
, TokenNumber
, Value
);
670 ASSERT_EFI_ERROR (Status
);
678 Sets the 16-bit value for the token specified by TokenNumber and
679 Guid to the value specified by Value. Value is returned.
680 If Guid is NULL, then ASSERT().
682 @param[in] Guid Pointer to a 128-bit unique value that
683 designates which namespace to set a value from.
684 @param[in] TokenNumber The PCD token number to set a current value for.
685 @param[in] Value The 16-bit value to set.
687 @retval UINT8 Return the value been set.
694 IN UINTN TokenNumber
,
701 PcdPpi
= GetPcdPpiPtr ();
704 Status
= PcdPpi
->Set16Ex (Guid
, TokenNumber
, Value
);
706 ASSERT_EFI_ERROR (Status
);
714 Sets the 32-bit value for the token specified by TokenNumber and
715 Guid to the value specified by Value. Value is returned.
716 If Guid is NULL, then ASSERT().
718 @param[in] Guid Pointer to a 128-bit unique value that
719 designates which namespace to set a value from.
720 @param[in] TokenNumber The PCD token number to set a current value for.
721 @param[in] Value The 32-bit value to set.
723 @retval UINT32 Return the value been set.
730 IN UINTN TokenNumber
,
737 PcdPpi
= GetPcdPpiPtr ();
740 Status
= PcdPpi
->Set32Ex (Guid
, TokenNumber
, Value
);
742 ASSERT_EFI_ERROR (Status
);
750 Sets the 64-bit value for the token specified by TokenNumber and
751 Guid to the value specified by Value. Value is returned.
752 If Guid is NULL, then ASSERT().
754 @param[in] Guid Pointer to a 128-bit unique value that
755 designates which namespace to set a value from.
756 @param[in] TokenNumber The PCD token number to set a current value for.
757 @param[in] Value The 64-bit value to set.
759 @retval UINT64 Return the value been set.
766 IN UINTN TokenNumber
,
773 PcdPpi
= GetPcdPpiPtr ();
776 Status
= PcdPpi
->Set64Ex (Guid
, TokenNumber
, Value
);
778 ASSERT_EFI_ERROR (Status
);
786 Sets a buffer for the token specified by TokenNumber to the value specified by
787 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
788 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
789 supported by TokenNumber and return NULL to indicate that the set operation
790 was not actually performed.
792 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
794 @param[in] Guid Pointer to a 128-bit unique value that
795 designates which namespace to set a value from.
796 @param[in] TokenNumber The PCD token number to set a current value for.
797 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
798 @param[in] Buffer A pointer to the buffer to set.
800 @retval VOID * Return the pinter to the buffer been set.
807 IN UINTN TokenNumber
,
808 IN OUT UINTN
*SizeOfBuffer
,
816 PcdPpi
= GetPcdPpiPtr ();
818 Size
= LibPcdGetExSize (Guid
, TokenNumber
);
819 if (*SizeOfBuffer
> Size
) {
820 *SizeOfBuffer
= Size
;
824 Status
= PcdPpi
->SetPtrEx (Guid
, TokenNumber
, *SizeOfBuffer
, Buffer
);
826 ASSERT_EFI_ERROR (Status
);
834 Sets the Boolean value for the token specified by TokenNumber and
835 Guid to the value specified by Value. Value is returned.
836 If Guid is NULL, then ASSERT().
838 @param[in] Guid Pointer to a 128-bit unique value that
839 designates which namespace to set a value from.
840 @param[in] TokenNumber The PCD token number to set a current value for.
841 @param[in] Value The Boolean value to set.
843 @retval Boolean Return the value been set.
850 IN UINTN TokenNumber
,
857 PcdPpi
= GetPcdPpiPtr ();
860 Status
= PcdPpi
->SetBoolEx (Guid
, TokenNumber
, Value
);
862 ASSERT_EFI_ERROR (Status
);
870 When the token specified by TokenNumber and Guid is set,
871 then notification function specified by NotificationFunction is called.
872 If Guid is NULL, then the default token space is used.
873 If NotificationFunction is NULL, then ASSERT().
875 @param[in] Guid Pointer to a 128-bit unique value that designates which
876 namespace to set a value from. If NULL, then the default
878 @param[in] TokenNumber The PCD token number to monitor.
879 @param[in] NotificationFunction The function to call when the token
880 specified by Guid and TokenNumber is set.
887 LibPcdCallbackOnSet (
888 IN CONST GUID
*Guid
, OPTIONAL
889 IN UINTN TokenNumber
,
890 IN PCD_CALLBACK NotificationFunction
896 PcdPpi
= GetPcdPpiPtr ();
899 Status
= PcdPpi
->CallbackOnSet (TokenNumber
, Guid
, NotificationFunction
);
901 ASSERT_EFI_ERROR (Status
);
909 Disable a notification function that was established with LibPcdCallbackonSet().
910 If NotificationFunction is NULL, then ASSERT().
912 @param[in] Guid Specify the GUID token space.
913 @param[in] TokenNumber Specify the token number.
914 @param[in] NotificationFunction The callback function to be unregistered.
921 LibPcdCancelCallback (
922 IN CONST GUID
*Guid
, OPTIONAL
923 IN UINTN TokenNumber
,
924 IN PCD_CALLBACK NotificationFunction
930 PcdPpi
= GetPcdPpiPtr ();
933 Status
= PcdPpi
->CancelCallback (TokenNumber
, Guid
, NotificationFunction
);
935 ASSERT_EFI_ERROR (Status
);
943 Retrieves the next PCD token number from the token space specified by Guid.
944 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
945 then the first token number is returned. Otherwise, the token number that
946 follows TokenNumber in the token space is returned. If TokenNumber is the last
947 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
948 is not in the token space specified by Guid, then ASSERT().
950 @param[in] Pointer to a 128-bit unique value that designates which namespace
951 to set a value from. If NULL, then the default token space is used.
952 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
955 @retval UINTN The next valid token number.
961 IN CONST GUID
*Guid
, OPTIONAL
968 PcdPpi
= GetPcdPpiPtr ();
971 Status
= PcdPpi
->GetNextToken (Guid
, &TokenNumber
);
973 ASSERT_EFI_ERROR (Status
);
980 Retrieves the next PCD token space from a token space specified by Guid.
981 Guid of NULL is reserved to mark the default local token namespace on the current
982 platform. If Guid is NULL, then the GUID of the first non-local token space of the
983 current platform is returned. If Guid is the last non-local token space,
984 then NULL is returned.
986 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
990 @param[in] Pointer to a 128-bit unique value that designates from which namespace
993 @retval CONST GUID * The next valid token namespace.
998 LibPcdGetNextTokenSpace (
1005 PcdPpi
= GetPcdPpiPtr ();
1008 Status
= PcdPpi
->GetNextTokenSpace (&Guid
);
1010 ASSERT_EFI_ERROR (Status
);