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.
89 IN PCD_TOKEN_NUMBER 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.
112 IN PCD_TOKEN_NUMBER 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.
135 IN PCD_TOKEN_NUMBER 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.
158 IN PCD_TOKEN_NUMBER 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.
181 IN PCD_TOKEN_NUMBER 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.
204 IN PCD_TOKEN_NUMBER 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.
227 IN PCD_TOKEN_NUMBER 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.
254 IN PCD_TOKEN_NUMBER TokenNumber
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.
281 IN PCD_TOKEN_NUMBER TokenNumber
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.
308 IN PCD_TOKEN_NUMBER TokenNumber
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.
336 IN PCD_TOKEN_NUMBER TokenNumber
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.
363 IN PCD_TOKEN_NUMBER TokenNumber
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.
390 IN PCD_TOKEN_NUMBER TokenNumber
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.
417 IN PCD_TOKEN_NUMBER TokenNumber
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 PCD_TOKEN_NUMBER 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 PCD_TOKEN_NUMBER 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 PCD_TOKEN_NUMBER 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 PCD_TOKEN_NUMBER 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 Value. Value is returned.
559 If Value is NULL, then ASSERT().
561 @param[in] TokenNumber The PCD token number to set a current value for.
562 @param[in] Value A pointer to the buffer to set.
564 @retval VOID* Return the pointer for the buffer been set.
570 IN PCD_TOKEN_NUMBER TokenNumber
,
571 IN UINTN SizeOfBuffer
,
578 PcdPpi
= GetPcdPpiPtr ();
581 Status
= PcdPpi
->SetPtr (TokenNumber
, SizeOfBuffer
, Buffer
);
583 ASSERT_EFI_ERROR (Status
);
591 Sets the Boolean value for the token specified by TokenNumber
592 to the value specified by Value. Value is returned.
594 @param[in] TokenNumber The PCD token number to set a current value for.
595 @param[in] Value The boolean value to set.
597 @retval BOOLEAN Return the value been set.
603 IN PCD_TOKEN_NUMBER TokenNumber
,
610 PcdPpi
= GetPcdPpiPtr ();
613 Status
= PcdPpi
->SetBool (TokenNumber
, Value
);
615 ASSERT_EFI_ERROR (Status
);
623 Sets the 8-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().
627 @param[in] Guid Pointer to a 128-bit unique value that
628 designates which namespace to set a value from.
629 @param[in] TokenNumber The PCD token number to set a current value for.
630 @param[in] Value The 8-bit value to set.
632 @retval UINT8 Return the value been set.
639 IN PCD_TOKEN_NUMBER TokenNumber
,
646 PcdPpi
= GetPcdPpiPtr ();
649 Status
= PcdPpi
->Set8Ex (Guid
, TokenNumber
, Value
);
651 ASSERT_EFI_ERROR (Status
);
659 Sets the 16-bit value for the token specified by TokenNumber and
660 Guid to the value specified by Value. Value is returned.
661 If Guid is NULL, then ASSERT().
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 16-bit value to set.
668 @retval UINT8 Return the value been set.
675 IN PCD_TOKEN_NUMBER TokenNumber
,
682 PcdPpi
= GetPcdPpiPtr ();
685 Status
= PcdPpi
->Set16Ex (Guid
, TokenNumber
, Value
);
687 ASSERT_EFI_ERROR (Status
);
695 Sets the 32-bit value for the token specified by TokenNumber and
696 Guid to the value specified by Value. Value is returned.
697 If Guid is NULL, then ASSERT().
699 @param[in] Guid Pointer to a 128-bit unique value that
700 designates which namespace to set a value from.
701 @param[in] TokenNumber The PCD token number to set a current value for.
702 @param[in] Value The 32-bit value to set.
704 @retval UINT32 Return the value been set.
711 IN PCD_TOKEN_NUMBER TokenNumber
,
718 PcdPpi
= GetPcdPpiPtr ();
721 Status
= PcdPpi
->Set32Ex (Guid
, TokenNumber
, Value
);
723 ASSERT_EFI_ERROR (Status
);
731 Sets the 64-bit value for the token specified by TokenNumber and
732 Guid to the value specified by Value. Value is returned.
733 If Guid is NULL, then ASSERT().
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] Value The 64-bit value to set.
740 @retval UINT64 Return the value been set.
747 IN PCD_TOKEN_NUMBER TokenNumber
,
754 PcdPpi
= GetPcdPpiPtr ();
757 Status
= PcdPpi
->Set64Ex (Guid
, TokenNumber
, Value
);
759 ASSERT_EFI_ERROR (Status
);
767 Sets a buffer for the token specified by TokenNumber and
768 Guid to the value specified by Value. Value is returned.
769 If Guid is NULL, then ASSERT().
770 If Value is NULL, then ASSERT().
772 @param[in] Guid Pointer to a 128-bit unique value that
773 designates which namespace to set a value from.
774 @param[in] TokenNumber The PCD token number to set a current value for.
775 @param[in] Value The 8-bit value to set.
777 @retval VOID * Return the value been set.
784 IN PCD_TOKEN_NUMBER TokenNumber
,
785 IN UINTN SizeOfBuffer
,
792 PcdPpi
= GetPcdPpiPtr ();
794 Status
= PcdPpi
->SetPtrEx (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
796 ASSERT_EFI_ERROR (Status
);
804 Sets the Boolean value for the token specified by TokenNumber and
805 Guid to the value specified by Value. Value is returned.
806 If Guid is NULL, then ASSERT().
808 @param[in] Guid Pointer to a 128-bit unique value that
809 designates which namespace to set a value from.
810 @param[in] TokenNumber The PCD token number to set a current value for.
811 @param[in] Value The Boolean value to set.
813 @retval Boolean Return the value been set.
820 IN PCD_TOKEN_NUMBER TokenNumber
,
827 PcdPpi
= GetPcdPpiPtr ();
830 Status
= PcdPpi
->SetBoolEx (Guid
, TokenNumber
, Value
);
832 ASSERT_EFI_ERROR (Status
);
840 When the token specified by TokenNumber and Guid is set,
841 then notification function specified by NotificationFunction is called.
842 If Guid is NULL, then the default token space is used.
843 If NotificationFunction is NULL, then ASSERT().
845 @param[in] Guid Pointer to a 128-bit unique value that designates which
846 namespace to set a value from. If NULL, then the default
848 @param[in] TokenNumber The PCD token number to monitor.
849 @param[in] NotificationFunction The function to call when the token
850 specified by Guid and TokenNumber is set.
857 LibPcdCallbackOnSet (
858 IN CONST GUID
*Guid
, OPTIONAL
859 IN PCD_TOKEN_NUMBER TokenNumber
,
860 IN PCD_CALLBACK NotificationFunction
866 PcdPpi
= GetPcdPpiPtr ();
869 Status
= PcdPpi
->CallbackOnSet (TokenNumber
, Guid
, NotificationFunction
);
871 ASSERT_EFI_ERROR (Status
);
879 Disable a notification function that was established with LibPcdCallbackonSet().
880 If NotificationFunction is NULL, then ASSERT().
882 @param[in] Guid Specify the GUID token space.
883 @param[in] TokenNumber Specify the token number.
884 @param[in] NotificationFunction The callback function to be unregistered.
891 LibPcdCancelCallback (
892 IN CONST GUID
*Guid
, OPTIONAL
893 IN PCD_TOKEN_NUMBER TokenNumber
,
894 IN PCD_CALLBACK NotificationFunction
900 PcdPpi
= GetPcdPpiPtr ();
903 Status
= PcdPpi
->CancelCallback (TokenNumber
, Guid
, NotificationFunction
);
905 ASSERT_EFI_ERROR (Status
);
913 Retrieves the next PCD token number from the token space specified by Guid.
914 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
915 then the first token number is returned. Otherwise, the token number that
916 follows TokenNumber in the token space is returned. If TokenNumber is the last
917 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
918 is not in the token space specified by Guid, then ASSERT().
920 @param[in] Pointer to a 128-bit unique value that designates which namespace
921 to set a value from. If NULL, then the default token space is used.
922 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
925 @retval PCD_TOKEN_NUMBER The next valid token number.
931 IN CONST GUID
*Guid
, OPTIONAL
932 IN OUT PCD_TOKEN_NUMBER TokenNumber
938 PcdPpi
= GetPcdPpiPtr ();
941 Status
= PcdPpi
->GetNextToken (Guid
, &TokenNumber
);
943 ASSERT_EFI_ERROR (Status
);