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 if (*SizeOfBuffer
> 0) {
590 ASSERT (Buffer
!= NULL
);
593 PcdPpi
= GetPcdPpiPtr ();
595 Size
= LibPcdGetSize (TokenNumber
);
597 if (*SizeOfBuffer
> Size
) {
598 *SizeOfBuffer
= Size
;
602 Status
= PcdPpi
->SetPtr (TokenNumber
, *SizeOfBuffer
, Buffer
);
604 ASSERT_EFI_ERROR (Status
);
612 Sets the Boolean value for the token specified by TokenNumber
613 to the value specified by Value. Value is returned.
615 @param[in] TokenNumber The PCD token number to set a current value for.
616 @param[in] Value The boolean value to set.
618 @retval BOOLEAN Return the value been set.
624 IN UINTN TokenNumber
,
631 PcdPpi
= GetPcdPpiPtr ();
634 Status
= PcdPpi
->SetBool (TokenNumber
, Value
);
636 ASSERT_EFI_ERROR (Status
);
644 Sets the 8-bit value for the token specified by TokenNumber and
645 Guid to the value specified by Value. Value is returned.
646 If Guid is NULL, then ASSERT().
648 @param[in] Guid Pointer to a 128-bit unique value that
649 designates which namespace to set a value from.
650 @param[in] TokenNumber The PCD token number to set a current value for.
651 @param[in] Value The 8-bit value to set.
653 @retval UINT8 Return the value been set.
660 IN UINTN TokenNumber
,
667 PcdPpi
= GetPcdPpiPtr ();
670 Status
= PcdPpi
->Set8Ex (Guid
, TokenNumber
, Value
);
672 ASSERT_EFI_ERROR (Status
);
680 Sets the 16-bit value for the token specified by TokenNumber and
681 Guid to the value specified by Value. Value is returned.
682 If Guid is NULL, then ASSERT().
684 @param[in] Guid Pointer to a 128-bit unique value that
685 designates which namespace to set a value from.
686 @param[in] TokenNumber The PCD token number to set a current value for.
687 @param[in] Value The 16-bit value to set.
689 @retval UINT8 Return the value been set.
696 IN UINTN TokenNumber
,
703 PcdPpi
= GetPcdPpiPtr ();
706 Status
= PcdPpi
->Set16Ex (Guid
, TokenNumber
, Value
);
708 ASSERT_EFI_ERROR (Status
);
716 Sets the 32-bit value for the token specified by TokenNumber and
717 Guid to the value specified by Value. Value is returned.
718 If Guid is NULL, then ASSERT().
720 @param[in] Guid Pointer to a 128-bit unique value that
721 designates which namespace to set a value from.
722 @param[in] TokenNumber The PCD token number to set a current value for.
723 @param[in] Value The 32-bit value to set.
725 @retval UINT32 Return the value been set.
732 IN UINTN TokenNumber
,
739 PcdPpi
= GetPcdPpiPtr ();
742 Status
= PcdPpi
->Set32Ex (Guid
, TokenNumber
, Value
);
744 ASSERT_EFI_ERROR (Status
);
752 Sets the 64-bit value for the token specified by TokenNumber and
753 Guid to the value specified by Value. Value is returned.
754 If Guid is NULL, then ASSERT().
756 @param[in] Guid Pointer to a 128-bit unique value that
757 designates which namespace to set a value from.
758 @param[in] TokenNumber The PCD token number to set a current value for.
759 @param[in] Value The 64-bit value to set.
761 @retval UINT64 Return the value been set.
768 IN UINTN TokenNumber
,
775 PcdPpi
= GetPcdPpiPtr ();
778 Status
= PcdPpi
->Set64Ex (Guid
, TokenNumber
, Value
);
780 ASSERT_EFI_ERROR (Status
);
788 Sets a buffer for the token specified by TokenNumber to the value specified by
789 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
790 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
791 supported by TokenNumber and return NULL to indicate that the set operation
792 was not actually performed.
794 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
796 @param[in] Guid Pointer to a 128-bit unique value that
797 designates which namespace to set a value from.
798 @param[in] TokenNumber The PCD token number to set a current value for.
799 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
800 @param[in] Buffer A pointer to the buffer to set.
802 @retval VOID * Return the pinter to the buffer been set.
809 IN UINTN TokenNumber
,
810 IN OUT UINTN
*SizeOfBuffer
,
818 if (*SizeOfBuffer
> 0) {
819 ASSERT (Buffer
!= NULL
);
822 PcdPpi
= GetPcdPpiPtr ();
824 Size
= LibPcdGetExSize (Guid
, TokenNumber
);
825 if (*SizeOfBuffer
> Size
) {
826 *SizeOfBuffer
= Size
;
830 Status
= PcdPpi
->SetPtrEx (Guid
, TokenNumber
, *SizeOfBuffer
, Buffer
);
832 ASSERT_EFI_ERROR (Status
);
840 Sets the Boolean value for the token specified by TokenNumber and
841 Guid to the value specified by Value. Value is returned.
842 If Guid is NULL, then ASSERT().
844 @param[in] Guid Pointer to a 128-bit unique value that
845 designates which namespace to set a value from.
846 @param[in] TokenNumber The PCD token number to set a current value for.
847 @param[in] Value The Boolean value to set.
849 @retval Boolean Return the value been set.
856 IN UINTN TokenNumber
,
863 PcdPpi
= GetPcdPpiPtr ();
866 Status
= PcdPpi
->SetBoolEx (Guid
, TokenNumber
, Value
);
868 ASSERT_EFI_ERROR (Status
);
876 When the token specified by TokenNumber and Guid is set,
877 then notification function specified by NotificationFunction is called.
878 If Guid is NULL, then the default token space is used.
879 If NotificationFunction is NULL, then ASSERT().
881 @param[in] Guid Pointer to a 128-bit unique value that designates which
882 namespace to set a value from. If NULL, then the default
884 @param[in] TokenNumber The PCD token number to monitor.
885 @param[in] NotificationFunction The function to call when the token
886 specified by Guid and TokenNumber is set.
893 LibPcdCallbackOnSet (
894 IN CONST GUID
*Guid
, OPTIONAL
895 IN UINTN TokenNumber
,
896 IN PCD_CALLBACK NotificationFunction
902 PcdPpi
= GetPcdPpiPtr ();
905 Status
= PcdPpi
->CallbackOnSet (TokenNumber
, Guid
, NotificationFunction
);
907 ASSERT_EFI_ERROR (Status
);
915 Disable a notification function that was established with LibPcdCallbackonSet().
916 If NotificationFunction is NULL, then ASSERT().
918 @param[in] Guid Specify the GUID token space.
919 @param[in] TokenNumber Specify the token number.
920 @param[in] NotificationFunction The callback function to be unregistered.
927 LibPcdCancelCallback (
928 IN CONST GUID
*Guid
, OPTIONAL
929 IN UINTN TokenNumber
,
930 IN PCD_CALLBACK NotificationFunction
936 PcdPpi
= GetPcdPpiPtr ();
939 Status
= PcdPpi
->CancelCallback (TokenNumber
, Guid
, NotificationFunction
);
941 ASSERT_EFI_ERROR (Status
);
949 Retrieves the next PCD token number from the token space specified by Guid.
950 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
951 then the first token number is returned. Otherwise, the token number that
952 follows TokenNumber in the token space is returned. If TokenNumber is the last
953 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
954 is not in the token space specified by Guid, then ASSERT().
956 @param[in] Pointer to a 128-bit unique value that designates which namespace
957 to set a value from. If NULL, then the default token space is used.
958 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
961 @retval UINTN The next valid token number.
967 IN CONST GUID
*Guid
, OPTIONAL
974 PcdPpi
= GetPcdPpiPtr ();
977 Status
= PcdPpi
->GetNextToken (Guid
, &TokenNumber
);
979 ASSERT_EFI_ERROR (Status
);
986 Retrieves the next PCD token space from a token space specified by Guid.
987 Guid of NULL is reserved to mark the default local token namespace on the current
988 platform. If Guid is NULL, then the GUID of the first non-local token space of the
989 current platform is returned. If Guid is the last non-local token space,
990 then NULL is returned.
992 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
996 @param[in] Pointer to a 128-bit unique value that designates from which namespace
999 @retval CONST GUID * The next valid token namespace.
1004 LibPcdGetNextTokenSpace (
1011 PcdPpi
= GetPcdPpiPtr ();
1014 Status
= PcdPpi
->GetNextTokenSpace (&Guid
);
1016 ASSERT_EFI_ERROR (Status
);