2 Implementation of PcdLib class library for DXE 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: DxePcdLib.c
18 static PCD_PROTOCOL
*mPcd
;
21 The constructor function caches the PCD_PROTOCOL pointer.
23 @param[in] ImageHandle The firmware allocated handle for the EFI image.
24 @param[in] SystemTable A pointer to the EFI System Table.
26 @retval EFI_SUCCESS The constructor always return EFI_SUCCESS.
32 IN EFI_HANDLE ImageHandle
,
33 IN EFI_SYSTEM_TABLE
*SystemTable
38 Status
= gBS
->LocateProtocol (&gPcdProtocolGuid
, NULL
, (VOID
**)&mPcd
);
39 ASSERT_EFI_ERROR (Status
);
46 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
48 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
49 set values associated with a PCD token.
51 @retval SKU_ID Return the SKU ID that just be set.
68 Returns the 8-bit value for the token specified by TokenNumber.
70 @param[in] The PCD token number to retrieve a current value for.
72 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
81 return mPcd
->Get8 (TokenNumber
);
87 Returns the 16-bit value for the token specified by TokenNumber.
89 @param[in] The PCD token number to retrieve a current value for.
91 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
100 return mPcd
->Get16 (TokenNumber
);
106 Returns the 32-bit value for the token specified by TokenNumber.
108 @param[in] TokenNumber The PCD token number to retrieve a current value for.
110 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
119 return mPcd
->Get32 (TokenNumber
);
125 Returns the 64-bit value for the token specified by TokenNumber.
127 @param[in] TokenNumber The PCD token number to retrieve a current value for.
129 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
138 return mPcd
->Get64 (TokenNumber
);
144 Returns the pointer to the buffer of the token specified by TokenNumber.
146 @param[in] TokenNumber The PCD token number to retrieve a current value for.
148 @retval VOID* Returns the pointer to the token specified by TokenNumber.
157 return mPcd
->GetPtr (TokenNumber
);
163 Returns the Boolean value of the token specified by TokenNumber.
165 @param[in] TokenNumber The PCD token number to retrieve a current value for.
167 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
176 return mPcd
->GetBool (TokenNumber
);
182 Returns the size of the token specified by TokenNumber.
184 @param[in] TokenNumber The PCD token number to retrieve a current value for.
186 @retval UINTN Returns the size of the token specified by TokenNumber.
195 return mPcd
->GetSize (TokenNumber
);
201 Returns the 8-bit value for the token specified by TokenNumber and Guid.
202 If Guid is NULL, then ASSERT().
204 @param[in] Guid Pointer to a 128-bit unique value that designates
205 which namespace to retrieve a value from.
206 @param[in] TokenNumber The PCD token number to retrieve a current value for.
208 @retval UINT8 Return the UINT8.
218 ASSERT (Guid
!= NULL
);
220 return mPcd
->Get8Ex (Guid
, TokenNumber
);
225 Returns the 16-bit value for the token specified by TokenNumber and Guid.
226 If Guid is NULL, then ASSERT().
228 @param[in] Guid Pointer to a 128-bit unique value that designates
229 which namespace to retrieve a value from.
230 @param[in] TokenNumber The PCD token number to retrieve a current value for.
232 @retval UINT16 Return the UINT16.
242 ASSERT (Guid
!= NULL
);
244 return mPcd
->Get16Ex (Guid
, TokenNumber
);
249 Returns the 32-bit value for the token specified by TokenNumber and Guid.
250 If Guid is NULL, then ASSERT().
252 @param[in] Guid Pointer to a 128-bit unique value that designates
253 which namespace to retrieve a value from.
254 @param[in] TokenNumber The PCD token number to retrieve a current value for.
256 @retval UINT32 Return the UINT32.
266 ASSERT (Guid
!= NULL
);
268 return mPcd
->Get32Ex (Guid
, TokenNumber
);
274 Returns the 64-bit value for the token specified by TokenNumber and Guid.
275 If Guid is NULL, then ASSERT().
277 @param[in] Guid Pointer to a 128-bit unique value that designates
278 which namespace to retrieve a value from.
279 @param[in] TokenNumber The PCD token number to retrieve a current value for.
281 @retval UINT64 Return the UINT64.
291 ASSERT (Guid
!= NULL
);
293 return mPcd
->Get64Ex (Guid
, TokenNumber
);
299 Returns the pointer to the token specified by TokenNumber and Guid.
300 If Guid is NULL, then ASSERT().
302 @param[in] Guid Pointer to a 128-bit unique value that designates
303 which namespace to retrieve a value from.
304 @param[in] TokenNumber The PCD token number to retrieve a current value for.
306 @retval VOID* Return the VOID* pointer.
316 ASSERT (Guid
!= NULL
);
318 return mPcd
->GetPtrEx (Guid
, TokenNumber
);
324 Returns the Boolean value of the token specified by TokenNumber and Guid.
325 If Guid is NULL, then ASSERT().
327 @param[in] Guid Pointer to a 128-bit unique value that designates
328 which namespace to retrieve a value from.
329 @param[in] TokenNumber The PCD token number to retrieve a current value for.
331 @retval BOOLEAN Return the BOOLEAN.
341 ASSERT (Guid
!= NULL
);
343 return mPcd
->GetBoolEx (Guid
, TokenNumber
);
349 Returns the size of 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 UINTN Return the size.
366 ASSERT (Guid
!= NULL
);
368 return mPcd
->GetSizeEx (Guid
, TokenNumber
);
374 Sets the 8-bit value for the token specified by TokenNumber
375 to the value specified by Value. Value is returned.
377 @param[in] TokenNumber The PCD token number to set a current value for.
378 @param[in] Value The 8-bit value to set.
380 @retval UINT8 Return the value been set.
386 IN UINTN TokenNumber
,
392 Status
= mPcd
->Set8 (TokenNumber
, Value
);
394 ASSERT_EFI_ERROR (Status
);
402 Sets the 16-bit value for the token specified by TokenNumber
403 to the value specified by Value. Value is returned.
405 @param[in] TokenNumber The PCD token number to set a current value for.
406 @param[in] Value The 16-bit value to set.
408 @retval UINT16 Return the value been set.
414 IN UINTN TokenNumber
,
420 Status
= mPcd
->Set16 (TokenNumber
, Value
);
422 ASSERT_EFI_ERROR (Status
);
430 Sets the 32-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 32-bit value to set.
436 @retval UINT32 Return the value been set.
442 IN UINTN TokenNumber
,
447 Status
= mPcd
->Set32 (TokenNumber
, Value
);
449 ASSERT_EFI_ERROR (Status
);
457 Sets the 64-bit value for the token specified by TokenNumber
458 to the value specified by Value. Value is returned.
460 @param[in] TokenNumber The PCD token number to set a current value for.
461 @param[in] Value The 64-bit value to set.
463 @retval UINT64 Return the value been set.
469 IN UINTN TokenNumber
,
475 Status
= mPcd
->Set64 (TokenNumber
, Value
);
477 ASSERT_EFI_ERROR (Status
);
485 Sets a buffer for the token specified by TokenNumber to
486 the value specified by Value. Value is returned.
487 If Value is NULL, then ASSERT().
489 @param[in] TokenNumber The PCD token number to set a current value for.
490 @param[in] Value A pointer to the buffer to set.
492 @retval VOID* Return the pointer for the buffer been set.
498 IN UINTN TokenNumber
,
499 IN UINTN SizeOfBuffer
,
505 ASSERT (Buffer
!= NULL
);
507 Status
= mPcd
->SetPtr (TokenNumber
, SizeOfBuffer
, Buffer
);
509 ASSERT_EFI_ERROR (Status
);
517 Sets the Boolean value for the token specified by TokenNumber
518 to the value specified by Value. Value is returned.
520 @param[in] TokenNumber The PCD token number to set a current value for.
521 @param[in] Value The boolean value to set.
523 @retval BOOLEAN Return the value been set.
529 IN UINTN TokenNumber
,
535 Status
= mPcd
->SetBool (TokenNumber
, Value
);
537 ASSERT_EFI_ERROR (Status
);
545 Sets the 8-bit value for the token specified by TokenNumber and
546 Guid to the value specified by Value. Value is returned.
547 If Guid is NULL, then ASSERT().
549 @param[in] Guid Pointer to a 128-bit unique value that
550 designates which namespace to set a value from.
551 @param[in] TokenNumber The PCD token number to set a current value for.
552 @param[in] Value The 8-bit value to set.
554 @retval UINT8 Return the value been set.
561 IN UINTN TokenNumber
,
567 ASSERT (Guid
!= NULL
);
569 Status
= mPcd
->Set8Ex (Guid
, TokenNumber
, Value
);
571 ASSERT_EFI_ERROR (Status
);
579 Sets the 16-bit value for the token specified by TokenNumber and
580 Guid to the value specified by Value. Value is returned.
581 If Guid is NULL, then ASSERT().
583 @param[in] Guid Pointer to a 128-bit unique value that
584 designates which namespace to set a value from.
585 @param[in] TokenNumber The PCD token number to set a current value for.
586 @param[in] Value The 16-bit value to set.
588 @retval UINT8 Return the value been set.
595 IN UINTN TokenNumber
,
601 ASSERT (Guid
!= NULL
);
603 Status
= mPcd
->Set16Ex (Guid
, TokenNumber
, Value
);
605 ASSERT_EFI_ERROR (Status
);
613 Sets the 32-bit value for the token specified by TokenNumber and
614 Guid to the value specified by Value. Value is returned.
615 If Guid is NULL, then ASSERT().
617 @param[in] Guid Pointer to a 128-bit unique value that
618 designates which namespace to set a value from.
619 @param[in] TokenNumber The PCD token number to set a current value for.
620 @param[in] Value The 32-bit value to set.
622 @retval UINT32 Return the value been set.
629 IN UINTN TokenNumber
,
635 ASSERT (Guid
!= NULL
);
637 Status
= mPcd
->Set32Ex (Guid
, TokenNumber
, Value
);
639 ASSERT_EFI_ERROR (Status
);
647 Sets the 64-bit value for the token specified by TokenNumber and
648 Guid to the value specified by Value. Value is returned.
649 If Guid is NULL, then ASSERT().
651 @param[in] Guid Pointer to a 128-bit unique value that
652 designates which namespace to set a value from.
653 @param[in] TokenNumber The PCD token number to set a current value for.
654 @param[in] Value The 64-bit value to set.
656 @retval UINT64 Return the value been set.
663 IN UINTN TokenNumber
,
669 ASSERT (Guid
!= NULL
);
671 Status
= mPcd
->Set64Ex (Guid
, TokenNumber
, Value
);
673 ASSERT_EFI_ERROR (Status
);
681 Sets a buffer for the token specified by TokenNumber and
682 Guid to the value specified by Value. Value is returned.
683 If Guid is NULL, then ASSERT().
684 If Value is NULL, then ASSERT().
686 @param[in] Guid Pointer to a 128-bit unique value that
687 designates which namespace to set a value from.
688 @param[in] TokenNumber The PCD token number to set a current value for.
689 @param[in] Value The 8-bit value to set.
691 @retval VOID * Return the value been set.
698 IN UINTN TokenNumber
,
699 IN UINTN SizeOfBuffer
,
705 ASSERT (Guid
!= NULL
);
706 ASSERT (Buffer
!= NULL
);
708 Status
= mPcd
->SetPtrEx (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
710 ASSERT_EFI_ERROR (Status
);
718 Sets the Boolean value for the token specified by TokenNumber and
719 Guid to the value specified by Value. Value is returned.
720 If Guid is NULL, then ASSERT().
722 @param[in] Guid Pointer to a 128-bit unique value that
723 designates which namespace to set a value from.
724 @param[in] TokenNumber The PCD token number to set a current value for.
725 @param[in] Value The Boolean value to set.
727 @retval Boolean Return the value been set.
734 IN UINTN TokenNumber
,
740 ASSERT (Guid
!= NULL
);
742 Status
= mPcd
->SetBoolEx (Guid
, TokenNumber
, Value
);
744 ASSERT_EFI_ERROR (Status
);
752 When the token specified by TokenNumber and Guid is set,
753 then notification function specified by NotificationFunction is called.
754 If Guid is NULL, then the default token space is used.
755 If NotificationFunction is NULL, then ASSERT().
757 @param[in] Guid Pointer to a 128-bit unique value that designates which
758 namespace to set a value from. If NULL, then the default
760 @param[in] TokenNumber The PCD token number to monitor.
761 @param[in] NotificationFunction The function to call when the token
762 specified by Guid and TokenNumber is set.
769 LibPcdCallbackOnSet (
770 IN CONST GUID
*Guid
, OPTIONAL
771 IN UINTN TokenNumber
,
772 IN PCD_CALLBACK NotificationFunction
777 ASSERT (NotificationFunction
!= NULL
);
779 Status
= mPcd
->CallbackOnSet (TokenNumber
, Guid
, NotificationFunction
);
781 ASSERT_EFI_ERROR (Status
);
789 Disable a notification function that was established with LibPcdCallbackonSet().
790 If NotificationFunction is NULL, then ASSERT().
792 @param[in] Guid Specify the GUID token space.
793 @param[in] TokenNumber Specify the token number.
794 @param[in] NotificationFunction The callback function to be unregistered.
801 LibPcdCancelCallback (
802 IN CONST GUID
*Guid
, OPTIONAL
803 IN UINTN TokenNumber
,
804 IN PCD_CALLBACK NotificationFunction
809 ASSERT (NotificationFunction
!= NULL
);
811 Status
= mPcd
->CancelCallback (TokenNumber
, Guid
, NotificationFunction
);
813 ASSERT_EFI_ERROR (Status
);
821 Retrieves the next PCD token number from the token space specified by Guid.
822 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
823 then the first token number is returned. Otherwise, the token number that
824 follows TokenNumber in the token space is returned. If TokenNumber is the last
825 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
826 is not in the token space specified by Guid, then ASSERT().
828 @param[in] Pointer to a 128-bit unique value that designates which namespace
829 to set a value from. If NULL, then the default token space is used.
830 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
833 @retval UINTN The next valid token number.
839 IN CONST GUID
*Guid
, OPTIONAL
845 Status
= mPcd
->GetNextToken (Guid
, &TokenNumber
);
847 ASSERT_EFI_ERROR (Status
);