Home | History | Annotate | Download | only in PeiPcdLib
      1 /** @file
      2 Implementation of PcdLib class library for PEI phase.
      3 
      4 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
      5 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
      9 
     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.
     12 
     13 
     14 **/
     15 
     16 
     17 
     18 
     19 #include <PiPei.h>
     20 
     21 #include <Ppi/Pcd.h>
     22 #include <Ppi/PiPcd.h>
     23 #include <Ppi/PcdInfo.h>
     24 #include <Ppi/PiPcdInfo.h>
     25 
     26 #include <Library/PeiServicesLib.h>
     27 #include <Library/PcdLib.h>
     28 #include <Library/DebugLib.h>
     29 #include <Library/BaseMemoryLib.h>
     30 
     31 /**
     32   Retrieve the PCD_PPI pointer.
     33 
     34   This function is to locate PCD_PPI PPI via PeiService.
     35   If fail to locate PCD_PPI, then ASSERT_EFI_ERROR().
     36 
     37   @retval PCD_PPI * The pointer to the PCD_PPI.
     38 
     39 **/
     40 PCD_PPI  *
     41 GetPcdPpiPointer (
     42   VOID
     43   )
     44 {
     45   EFI_STATUS        Status;
     46   PCD_PPI           *PcdPpi;
     47 
     48   Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);
     49   ASSERT_EFI_ERROR (Status);
     50 
     51   return PcdPpi;
     52 }
     53 
     54 /**
     55   Retrieve the pointer of EFI_PEI_PCD_PPI defined in PI 1.2 Vol 3.
     56 
     57   This function is to locate EFI_PEI_PCD_PPI PPI via PeiService.
     58   If fail to locate EFI_PEI_PCD_PPI, then ASSERT_EFI_ERROR().
     59 
     60   @retval EFI_PEI_PCD_PPI * The pointer to the EFI_PEI_PCD_PPI.
     61 
     62 **/
     63 EFI_PEI_PCD_PPI *
     64 GetPiPcdPpiPointer (
     65   VOID
     66   )
     67 {
     68   EFI_STATUS        Status;
     69   EFI_PEI_PCD_PPI   *PiPcdPpi;
     70 
     71   Status = PeiServicesLocatePpi (&gEfiPeiPcdPpiGuid, 0, NULL, (VOID **)&PiPcdPpi);
     72   ASSERT_EFI_ERROR (Status);
     73 
     74   return PiPcdPpi;
     75 }
     76 
     77 /**
     78   Retrieve the GET_PCD_INFO_PPI pointer.
     79 
     80   This function is to locate GET_PCD_INFO_PPI PPI via PeiService.
     81   If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().
     82 
     83   @retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI.
     84 
     85 **/
     86 GET_PCD_INFO_PPI *
     87 GetPcdInfoPpiPointer (
     88   VOID
     89   )
     90 {
     91   EFI_STATUS            Status;
     92   GET_PCD_INFO_PPI      *PcdInfoPpi;
     93 
     94   Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);
     95   ASSERT_EFI_ERROR (Status);
     96 
     97   return PcdInfoPpi;
     98 }
     99 
    100 /**
    101   Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3.
    102 
    103   This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService.
    104   If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().
    105 
    106   @retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI.
    107 
    108 **/
    109 EFI_GET_PCD_INFO_PPI *
    110 GetPiPcdInfoPpiPointer (
    111   VOID
    112   )
    113 {
    114   EFI_STATUS            Status;
    115   EFI_GET_PCD_INFO_PPI  *PiPcdInfoPpi;
    116 
    117   Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);
    118   ASSERT_EFI_ERROR (Status);
    119 
    120   return PiPcdInfoPpi;
    121 }
    122 
    123 /**
    124   This function provides a means by which SKU support can be established in the PCD infrastructure.
    125 
    126   Sets the current SKU in the PCD database to the value specified by SkuId.  SkuId is returned.
    127   If SkuId >= PCD_MAX_SKU_ID, then ASSERT().
    128 
    129   @param  SkuId   The SKU value that will be used when the PCD service retrieves
    130                   and sets values associated with a PCD token.
    131 
    132   @return  Return the SKU ID that just be set.
    133 
    134 **/
    135 UINTN
    136 EFIAPI
    137 LibPcdSetSku (
    138   IN UINTN   SkuId
    139   )
    140 {
    141 
    142   ASSERT (SkuId < PCD_MAX_SKU_ID);
    143 
    144   GetPiPcdPpiPointer()->SetSku (SkuId);
    145 
    146   return SkuId;
    147 }
    148 
    149 
    150 
    151 /**
    152   This function provides a means by which to retrieve a value for a given PCD token.
    153 
    154   Returns the 8-bit value for the token specified by TokenNumber.
    155 
    156   @param[in]  TokenNumber The PCD token number to retrieve a current value for.
    157 
    158   @return Returns the 8-bit value for the token specified by TokenNumber.
    159 
    160 **/
    161 UINT8
    162 EFIAPI
    163 LibPcdGet8 (
    164   IN UINTN             TokenNumber
    165   )
    166 {
    167   return (GetPcdPpiPointer ())->Get8 (TokenNumber);
    168 }
    169 
    170 
    171 
    172 /**
    173   This function provides a means by which to retrieve a value for a given PCD token.
    174 
    175   Returns the 16-bit value for the token specified by TokenNumber.
    176 
    177   @param[in]  TokenNumber The PCD token number to retrieve a current value for.
    178 
    179   @return Returns the 16-bit value for the token specified by TokenNumber.
    180 
    181 **/
    182 UINT16
    183 EFIAPI
    184 LibPcdGet16 (
    185   IN UINTN             TokenNumber
    186   )
    187 {
    188   return (GetPcdPpiPointer ())->Get16 (TokenNumber);
    189 }
    190 
    191 
    192 
    193 /**
    194   This function provides a means by which to retrieve a value for a given PCD token.
    195 
    196   Returns the 32-bit value for the token specified by TokenNumber.
    197 
    198   @param[in]  TokenNumber The PCD token number to retrieve a current value for.
    199 
    200   @return Returns the 32-bit value for the token specified by TokenNumber.
    201 
    202 **/
    203 UINT32
    204 EFIAPI
    205 LibPcdGet32 (
    206   IN UINTN             TokenNumber
    207   )
    208 {
    209   return (GetPcdPpiPointer ())->Get32 (TokenNumber);
    210 }
    211 
    212 
    213 
    214 /**
    215   This function provides a means by which to retrieve a value for a given PCD token.
    216 
    217   Returns the 64-bit value for the token specified by TokenNumber.
    218 
    219   @param[in]  TokenNumber The PCD token number to retrieve a current value for.
    220 
    221   @return Returns the 64-bit value for the token specified by TokenNumber.
    222 
    223 **/
    224 UINT64
    225 EFIAPI
    226 LibPcdGet64 (
    227   IN UINTN             TokenNumber
    228   )
    229 {
    230   return (GetPcdPpiPointer ())->Get64 (TokenNumber);
    231 }
    232 
    233 
    234 
    235 /**
    236   This function provides a means by which to retrieve a value for a given PCD token.
    237 
    238   Returns the pointer to the buffer of the token specified by TokenNumber.
    239 
    240   @param[in]  TokenNumber The PCD token number to retrieve a current value for.
    241 
    242   @return Returns the pointer to the token specified by TokenNumber.
    243 
    244 **/
    245 VOID *
    246 EFIAPI
    247 LibPcdGetPtr (
    248   IN UINTN             TokenNumber
    249   )
    250 {
    251   return (GetPcdPpiPointer ())->GetPtr (TokenNumber);
    252 }
    253 
    254 
    255 
    256 /**
    257   This function provides a means by which to retrieve a value for a given PCD token.
    258 
    259   Returns the Boolean value of the token specified by TokenNumber.
    260 
    261   @param[in]  TokenNumber The PCD token number to retrieve a current value for.
    262 
    263   @return Returns the Boolean value of the token specified by TokenNumber.
    264 
    265 **/
    266 BOOLEAN
    267 EFIAPI
    268 LibPcdGetBool (
    269   IN UINTN             TokenNumber
    270   )
    271 {
    272   return (GetPcdPpiPointer ())->GetBool (TokenNumber);
    273 }
    274 
    275 
    276 
    277 /**
    278   This function provides a means by which to retrieve the size of a given PCD token.
    279 
    280   @param[in]  TokenNumber The PCD token number to retrieve a current value for.
    281 
    282   @return Returns the size of the token specified by TokenNumber.
    283 
    284 **/
    285 UINTN
    286 EFIAPI
    287 LibPcdGetSize (
    288   IN UINTN             TokenNumber
    289   )
    290 {
    291   return (GetPcdPpiPointer ())->GetSize (TokenNumber);
    292 }
    293 
    294 
    295 
    296 /**
    297   This function provides a means by which to retrieve a value for a given PCD token.
    298 
    299   Returns the 8-bit value for the token specified by TokenNumber and Guid.
    300 
    301   If Guid is NULL, then ASSERT().
    302 
    303   @param[in]  Guid         The 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.
    306 
    307   @return Return the UINT8.
    308 
    309 **/
    310 UINT8
    311 EFIAPI
    312 LibPcdGetEx8 (
    313   IN CONST GUID        *Guid,
    314   IN UINTN             TokenNumber
    315   )
    316 {
    317   ASSERT (Guid != NULL);
    318 
    319   return (GetPiPcdPpiPointer ())->Get8 (Guid, TokenNumber);
    320 }
    321 
    322 
    323 
    324 /**
    325   This function provides a means by which to retrieve a value for a given PCD token.
    326 
    327   Returns the 16-bit value for the token specified by TokenNumber and Guid.
    328 
    329   If Guid is NULL, then ASSERT().
    330 
    331   @param[in]  Guid         The 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.
    334 
    335   @return Return the UINT16.
    336 
    337 **/
    338 UINT16
    339 EFIAPI
    340 LibPcdGetEx16 (
    341   IN CONST GUID        *Guid,
    342   IN UINTN             TokenNumber
    343   )
    344 {
    345 
    346   ASSERT (Guid != NULL);
    347 
    348   return (GetPiPcdPpiPointer ())->Get16 (Guid, TokenNumber);
    349 }
    350 
    351 
    352 
    353 /**
    354   Returns the 32-bit value for the token specified by TokenNumber and Guid.
    355   If Guid is NULL, then ASSERT().
    356 
    357   @param[in]  Guid         The pointer to a 128-bit unique value that designates
    358                            which namespace to retrieve a value from.
    359   @param[in]  TokenNumber  The PCD token number to retrieve a current value for.
    360 
    361   @return Return the UINT32.
    362 
    363 **/
    364 UINT32
    365 EFIAPI
    366 LibPcdGetEx32 (
    367   IN CONST GUID        *Guid,
    368   IN UINTN             TokenNumber
    369   )
    370 {
    371   ASSERT (Guid != NULL);
    372 
    373   return (GetPiPcdPpiPointer ())->Get32 (Guid, TokenNumber);
    374 }
    375 
    376 
    377 
    378 
    379 /**
    380   This function provides a means by which to retrieve a value for a given PCD token.
    381 
    382   Returns the 64-bit value for the token specified by TokenNumber and Guid.
    383 
    384   If Guid is NULL, then ASSERT().
    385 
    386   @param[in]  Guid          The pointer to a 128-bit unique value that designates
    387                             which namespace to retrieve a value from.
    388   @param[in]  TokenNumber   The PCD token number to retrieve a current value for.
    389 
    390   @return Return the UINT64.
    391 
    392 **/
    393 UINT64
    394 EFIAPI
    395 LibPcdGetEx64 (
    396   IN CONST GUID        *Guid,
    397   IN UINTN             TokenNumber
    398   )
    399 {
    400   ASSERT (Guid != NULL);
    401   return (GetPiPcdPpiPointer ())->Get64 (Guid, TokenNumber);
    402 }
    403 
    404 
    405 
    406 /**
    407   This function provides a means by which to retrieve a value for a given PCD token.
    408 
    409   Returns the pointer to the buffer of token specified by TokenNumber and Guid.
    410 
    411   If Guid is NULL, then ASSERT().
    412 
    413   @param[in]  Guid          The pointer to a 128-bit unique value that designates
    414                             which namespace to retrieve a value from.
    415   @param[in]  TokenNumber   The PCD token number to retrieve a current value for.
    416 
    417   @return Return the VOID* pointer.
    418 
    419 **/
    420 VOID *
    421 EFIAPI
    422 LibPcdGetExPtr (
    423   IN CONST GUID        *Guid,
    424   IN UINTN             TokenNumber
    425   )
    426 {
    427   ASSERT (Guid != NULL);
    428 
    429   return (GetPiPcdPpiPointer ())->GetPtr (Guid, TokenNumber);
    430 }
    431 
    432 
    433 
    434 /**
    435   This function provides a means by which to retrieve a value for a given PCD token.
    436 
    437   Returns the Boolean value of the token specified by TokenNumber and Guid.
    438 
    439   If Guid is NULL, then ASSERT().
    440 
    441   @param[in]  Guid          The pointer to a 128-bit unique value that designates
    442                             which namespace to retrieve a value from.
    443   @param[in]  TokenNumber   The PCD token number to retrieve a current value for.
    444 
    445   @return Return the BOOLEAN.
    446 
    447 **/
    448 BOOLEAN
    449 EFIAPI
    450 LibPcdGetExBool (
    451   IN CONST GUID        *Guid,
    452   IN UINTN             TokenNumber
    453   )
    454 {
    455   ASSERT (Guid != NULL);
    456   return (GetPiPcdPpiPointer ())->GetBool (Guid, TokenNumber);
    457 }
    458 
    459 
    460 
    461 /**
    462   This function provides a means by which to retrieve the size of a given PCD token.
    463 
    464   Returns the size of the token specified by TokenNumber and Guid.
    465 
    466   If Guid is NULL, then ASSERT().
    467 
    468   @param[in]  Guid          The pointer to a 128-bit unique value that designates
    469                             which namespace to retrieve a value from.
    470   @param[in]  TokenNumber   The PCD token number to retrieve a current value for.
    471 
    472   @return Return the size.
    473 
    474 **/
    475 UINTN
    476 EFIAPI
    477 LibPcdGetExSize (
    478   IN CONST GUID        *Guid,
    479   IN UINTN             TokenNumber
    480   )
    481 {
    482   ASSERT (Guid != NULL);
    483   return (GetPiPcdPpiPointer ())->GetSize (Guid, TokenNumber);
    484 }
    485 
    486 
    487 
    488 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
    489 /**
    490   This function provides a means by which to set a value for a given PCD token.
    491 
    492   Sets the 8-bit value for the token specified by TokenNumber
    493   to the value specified by Value.  Value is returned.
    494 
    495   @param[in]  TokenNumber   The PCD token number to set a current value for.
    496   @param[in]  Value         The 8-bit value to set.
    497 
    498   @return Return the value that was set.
    499 
    500 **/
    501 UINT8
    502 EFIAPI
    503 LibPcdSet8 (
    504   IN UINTN             TokenNumber,
    505   IN UINT8             Value
    506   )
    507 {
    508   (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);
    509 
    510   return Value;
    511 }
    512 
    513 
    514 
    515 /**
    516   This function provides a means by which to set a value for a given PCD token.
    517 
    518   Sets the 16-bit value for the token specified by TokenNumber
    519   to the value specified by Value.  Value is returned.
    520 
    521   @param[in]  TokenNumber   The PCD token number to set a current value for.
    522   @param[in]  Value         The 16-bit value to set.
    523 
    524   @return Return the value that was set.
    525 
    526 **/
    527 UINT16
    528 EFIAPI
    529 LibPcdSet16 (
    530   IN UINTN             TokenNumber,
    531   IN UINT16            Value
    532   )
    533 {
    534   (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);
    535 
    536   return Value;
    537 }
    538 
    539 
    540 
    541 /**
    542   This function provides a means by which to set a value for a given PCD token.
    543 
    544   Sets the 32-bit value for the token specified by TokenNumber
    545   to the value specified by Value.  Value is returned.
    546 
    547   @param[in]  TokenNumber   The PCD token number to set a current value for.
    548   @param[in]  Value         The 32-bit value to set.
    549 
    550   @return Return the value that was set.
    551 
    552 **/
    553 UINT32
    554 EFIAPI
    555 LibPcdSet32 (
    556   IN UINTN             TokenNumber,
    557   IN UINT32            Value
    558   )
    559 {
    560   (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);
    561 
    562   return Value;
    563 }
    564 
    565 
    566 
    567 /**
    568   This function provides a means by which to set a value for a given PCD token.
    569 
    570   Sets the 64-bit value for the token specified by TokenNumber
    571   to the value specified by Value.  Value is returned.
    572 
    573   @param[in]  TokenNumber   The PCD token number to set a current value for.
    574   @param[in]  Value         The 64-bit value to set.
    575 
    576   @return Return the value that was set.
    577 
    578 **/
    579 UINT64
    580 EFIAPI
    581 LibPcdSet64 (
    582   IN UINTN             TokenNumber,
    583   IN UINT64            Value
    584   )
    585 {
    586   (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);
    587 
    588   return Value;
    589 }
    590 
    591 
    592 
    593 /**
    594   This function provides a means by which to set a value for a given PCD token.
    595 
    596   Sets a buffer for the token specified by TokenNumber to the value
    597   specified by Buffer and SizeOfBuffer.  Buffer is returned.
    598   If SizeOfBuffer is greater than the maximum size support by TokenNumber,
    599   then set SizeOfBuffer to the maximum size supported by TokenNumber and
    600   return NULL to indicate that the set operation was not actually performed.
    601 
    602   If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
    603   maximum size supported by TokenName and NULL must be returned.
    604 
    605   If SizeOfBuffer is NULL, then ASSERT().
    606   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
    607 
    608   @param[in]      TokenNumber   The PCD token number to set a current value for.
    609   @param[in, out] SizeOfBuffer  The size, in bytes, of Buffer.
    610   @param[in]      Buffer        A pointer to the buffer to set.
    611 
    612   @return Return the pointer for the buffer been set.
    613 
    614 **/
    615 VOID *
    616 EFIAPI
    617 LibPcdSetPtr (
    618   IN        UINTN             TokenNumber,
    619   IN OUT    UINTN             *SizeOfBuffer,
    620   IN CONST  VOID              *Buffer
    621   )
    622 {
    623   EFI_STATUS Status;
    624   UINTN      InputSizeOfBuffer;
    625 
    626   ASSERT (SizeOfBuffer != NULL);
    627 
    628   if (*SizeOfBuffer > 0) {
    629     ASSERT (Buffer != NULL);
    630   }
    631 
    632   InputSizeOfBuffer = *SizeOfBuffer;
    633   Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
    634   if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
    635     return NULL;
    636   }
    637 
    638   return (VOID *) Buffer;
    639 }
    640 
    641 
    642 
    643 /**
    644   This function provides a means by which to set a value for a given PCD token.
    645 
    646   Sets the Boolean value for the token specified by TokenNumber
    647   to the value specified by Value.  Value is returned.
    648 
    649   @param[in]  TokenNumber   The PCD token number to set a current value for.
    650   @param[in]  Value         The boolean value to set.
    651 
    652   @return Return the value that was set.
    653 
    654 **/
    655 BOOLEAN
    656 EFIAPI
    657 LibPcdSetBool (
    658   IN UINTN             TokenNumber,
    659   IN BOOLEAN           Value
    660   )
    661 {
    662   (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);
    663 
    664   return Value;
    665 }
    666 
    667 
    668 
    669 /**
    670   This function provides a means by which to set a value for a given PCD token.
    671 
    672   Sets the 8-bit value for the token specified by TokenNumber and
    673   Guid to the value specified by Value. Value is returned.
    674 
    675   If Guid is NULL, then ASSERT().
    676 
    677   @param[in]  Guid          The pointer to a 128-bit unique value that
    678                             designates which namespace to set a value from.
    679   @param[in]  TokenNumber   The PCD token number to set a current value for.
    680   @param[in]  Value         The 8-bit value to set.
    681 
    682   @return Return the value that was set.
    683 
    684 **/
    685 UINT8
    686 EFIAPI
    687 LibPcdSetEx8 (
    688   IN CONST GUID        *Guid,
    689   IN UINTN             TokenNumber,
    690   IN UINT8             Value
    691   )
    692 {
    693   ASSERT (Guid != NULL);
    694 
    695   (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);
    696 
    697   return Value;
    698 }
    699 
    700 
    701 
    702 /**
    703   This function provides a means by which to set a value for a given PCD token.
    704 
    705   Sets the 16-bit value for the token specified by TokenNumber and
    706   Guid to the value specified by Value. Value is returned.
    707 
    708   If Guid is NULL, then ASSERT().
    709 
    710   @param[in]  Guid          The pointer to a 128-bit unique value that
    711                             designates which namespace to set a value from.
    712   @param[in]  TokenNumber   The PCD token number to set a current value for.
    713   @param[in]  Value         The 16-bit value to set.
    714 
    715   @return Return the value that was set.
    716 
    717 **/
    718 UINT16
    719 EFIAPI
    720 LibPcdSetEx16 (
    721   IN CONST GUID        *Guid,
    722   IN UINTN             TokenNumber,
    723   IN UINT16            Value
    724   )
    725 {
    726   ASSERT (Guid != NULL);
    727 
    728   (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);
    729 
    730   return Value;
    731 }
    732 
    733 
    734 
    735 /**
    736   This function provides a means by which to set a value for a given PCD token.
    737 
    738   Sets the 32-bit value for the token specified by TokenNumber and
    739   Guid to the value specified by Value. Value is returned.
    740 
    741   If Guid is NULL, then ASSERT().
    742 
    743   @param[in]  Guid          The pointer to a 128-bit unique value that
    744                             designates which namespace to set a value from.
    745   @param[in]  TokenNumber   The PCD token number to set a current value for.
    746   @param[in]  Value         The 32-bit value to set.
    747 
    748   @return Return the value that was set.
    749 
    750 **/
    751 UINT32
    752 EFIAPI
    753 LibPcdSetEx32 (
    754   IN CONST GUID        *Guid,
    755   IN UINTN             TokenNumber,
    756   IN UINT32            Value
    757   )
    758 {
    759   ASSERT (Guid != NULL);
    760 
    761   (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);
    762 
    763   return Value;
    764 }
    765 
    766 
    767 
    768 /**
    769   This function provides a means by which to set a value for a given PCD token.
    770 
    771   Sets the 64-bit value for the token specified by TokenNumber and
    772   Guid to the value specified by Value. Value is returned.
    773 
    774   If Guid is NULL, then ASSERT().
    775 
    776   @param[in]  Guid          The pointer to a 128-bit unique value that
    777                             designates which namespace to set a value from.
    778   @param[in]  TokenNumber   The PCD token number to set a current value for.
    779   @param[in]  Value         The 64-bit value to set.
    780 
    781   @return Return the value that was set.
    782 
    783 **/
    784 UINT64
    785 EFIAPI
    786 LibPcdSetEx64 (
    787   IN CONST GUID        *Guid,
    788   IN UINTN             TokenNumber,
    789   IN UINT64            Value
    790   )
    791 {
    792   ASSERT (Guid != NULL);
    793 
    794   (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);
    795 
    796   return Value;
    797 }
    798 
    799 
    800 
    801 /**
    802   This function provides a means by which to set a value for a given PCD token.
    803 
    804   Sets a buffer for the token specified by TokenNumber to the value specified by
    805   Buffer and SizeOfBuffer.  Buffer is returned.  If SizeOfBuffer is greater than
    806   the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
    807   supported by TokenNumber and return NULL to indicate that the set operation
    808   was not actually performed.
    809 
    810   If Guid is NULL, then ASSERT().
    811   If SizeOfBuffer is NULL, then ASSERT().
    812   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
    813 
    814   @param[in]  Guid              The pointer to a 128-bit unique value that
    815                                 designates which namespace to set a value from.
    816   @param[in]  TokenNumber       The PCD token number to set a current value for.
    817   @param[in, out] SizeOfBuffer  The size, in bytes, of Buffer.
    818   @param[in]  Buffer            A pointer to the buffer to set.
    819 
    820   @return Return the pinter to the buffer been set.
    821 
    822 **/
    823 VOID *
    824 EFIAPI
    825 LibPcdSetExPtr (
    826   IN      CONST GUID        *Guid,
    827   IN      UINTN             TokenNumber,
    828   IN OUT  UINTN             *SizeOfBuffer,
    829   IN      VOID              *Buffer
    830   )
    831 {
    832   EFI_STATUS      Status;
    833   UINTN           InputSizeOfBuffer;
    834 
    835   ASSERT (SizeOfBuffer != NULL);
    836   if (*SizeOfBuffer > 0) {
    837     ASSERT (Buffer != NULL);
    838   }
    839   ASSERT (Guid != NULL);
    840 
    841   InputSizeOfBuffer = *SizeOfBuffer;
    842   Status = (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
    843   if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
    844     return NULL;
    845   }
    846 
    847   return Buffer;
    848 }
    849 
    850 
    851 
    852 /**
    853   This function provides a means by which to set a value for a given PCD token.
    854 
    855   Sets the Boolean value for the token specified by TokenNumber and
    856   Guid to the value specified by Value. Value is returned.
    857 
    858   If Guid is NULL, then ASSERT().
    859 
    860   @param[in]  Guid          The pointer to a 128-bit unique value that
    861                             designates which namespace to set a value from.
    862   @param[in]  TokenNumber   The PCD token number to set a current value for.
    863   @param[in]  Value         The Boolean value to set.
    864 
    865   @return Return the value that was set.
    866 
    867 **/
    868 BOOLEAN
    869 EFIAPI
    870 LibPcdSetExBool (
    871   IN CONST GUID        *Guid,
    872   IN UINTN             TokenNumber,
    873   IN BOOLEAN           Value
    874   )
    875 {
    876   ASSERT (Guid != NULL);
    877 
    878   (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);
    879 
    880   return Value;
    881 }
    882 #endif
    883 
    884 /**
    885   This function provides a means by which to set a value for a given PCD token.
    886 
    887   Sets the 8-bit value for the token specified by TokenNumber
    888   to the value specified by Value.
    889 
    890   @param[in] TokenNumber    The PCD token number to set a current value for.
    891   @param[in] Value          The 8-bit value to set.
    892 
    893   @return The status of the set operation.
    894 
    895 **/
    896 RETURN_STATUS
    897 EFIAPI
    898 LibPcdSet8S (
    899   IN UINTN          TokenNumber,
    900   IN UINT8          Value
    901   )
    902 {
    903   return (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);
    904 }
    905 
    906 /**
    907   This function provides a means by which to set a value for a given PCD token.
    908 
    909   Sets the 16-bit value for the token specified by TokenNumber
    910   to the value specified by Value.
    911 
    912   @param[in] TokenNumber    The PCD token number to set a current value for.
    913   @param[in] Value          The 16-bit value to set.
    914 
    915   @return The status of the set operation.
    916 
    917 **/
    918 RETURN_STATUS
    919 EFIAPI
    920 LibPcdSet16S (
    921   IN UINTN          TokenNumber,
    922   IN UINT16         Value
    923   )
    924 {
    925   return (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);
    926 }
    927 
    928 /**
    929   This function provides a means by which to set a value for a given PCD token.
    930 
    931   Sets the 32-bit value for the token specified by TokenNumber
    932   to the value specified by Value.
    933 
    934   @param[in] TokenNumber    The PCD token number to set a current value for.
    935   @param[in] Value          The 32-bit value to set.
    936 
    937   @return The status of the set operation.
    938 
    939 **/
    940 RETURN_STATUS
    941 EFIAPI
    942 LibPcdSet32S (
    943   IN UINTN          TokenNumber,
    944   IN UINT32         Value
    945   )
    946 {
    947   return (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);
    948 }
    949 
    950 /**
    951   This function provides a means by which to set a value for a given PCD token.
    952 
    953   Sets the 64-bit value for the token specified by TokenNumber
    954   to the value specified by Value.
    955 
    956   @param[in] TokenNumber    The PCD token number to set a current value for.
    957   @param[in] Value          The 64-bit value to set.
    958 
    959   @return The status of the set operation.
    960 
    961 **/
    962 RETURN_STATUS
    963 EFIAPI
    964 LibPcdSet64S (
    965   IN UINTN          TokenNumber,
    966   IN UINT64         Value
    967   )
    968 {
    969   return (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);
    970 }
    971 
    972 /**
    973   This function provides a means by which to set a value for a given PCD token.
    974 
    975   Sets a buffer for the token specified by TokenNumber to the value specified
    976   by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
    977   support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
    978   TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
    979   was not actually performed.
    980 
    981   If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
    982   maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
    983 
    984   If SizeOfBuffer is NULL, then ASSERT().
    985   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
    986 
    987   @param[in]      TokenNumber   The PCD token number to set a current value for.
    988   @param[in, out] SizeOfBuffer  The size, in bytes, of Buffer.
    989   @param[in]      Buffer        A pointer to the buffer to set.
    990 
    991   @return The status of the set operation.
    992 
    993 **/
    994 RETURN_STATUS
    995 EFIAPI
    996 LibPcdSetPtrS (
    997   IN       UINTN    TokenNumber,
    998   IN OUT   UINTN    *SizeOfBuffer,
    999   IN CONST VOID     *Buffer
   1000   )
   1001 {
   1002   ASSERT (SizeOfBuffer != NULL);
   1003 
   1004   if (*SizeOfBuffer > 0) {
   1005     ASSERT (Buffer != NULL);
   1006   }
   1007 
   1008   return (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
   1009 }
   1010 
   1011 /**
   1012   This function provides a means by which to set a value for a given PCD token.
   1013 
   1014   Sets the boolean value for the token specified by TokenNumber
   1015   to the value specified by Value.
   1016 
   1017   @param[in] TokenNumber    The PCD token number to set a current value for.
   1018   @param[in] Value          The boolean value to set.
   1019 
   1020   @return The status of the set operation.
   1021 
   1022 **/
   1023 RETURN_STATUS
   1024 EFIAPI
   1025 LibPcdSetBoolS (
   1026   IN UINTN          TokenNumber,
   1027   IN BOOLEAN        Value
   1028   )
   1029 {
   1030   return (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);
   1031 }
   1032 
   1033 /**
   1034   This function provides a means by which to set a value for a given PCD token.
   1035 
   1036   Sets the 8-bit value for the token specified by TokenNumber
   1037   to the value specified by Value.
   1038 
   1039   If Guid is NULL, then ASSERT().
   1040 
   1041   @param[in] Guid           The pointer to a 128-bit unique value that
   1042                             designates which namespace to set a value from.
   1043   @param[in] TokenNumber    The PCD token number to set a current value for.
   1044   @param[in] Value          The 8-bit value to set.
   1045 
   1046   @return The status of the set operation.
   1047 
   1048 **/
   1049 RETURN_STATUS
   1050 EFIAPI
   1051 LibPcdSetEx8S (
   1052   IN CONST GUID     *Guid,
   1053   IN UINTN          TokenNumber,
   1054   IN UINT8          Value
   1055   )
   1056 {
   1057   ASSERT (Guid != NULL);
   1058 
   1059   return (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);
   1060 }
   1061 
   1062 /**
   1063   This function provides a means by which to set a value for a given PCD token.
   1064 
   1065   Sets the 16-bit value for the token specified by TokenNumber
   1066   to the value specified by Value.
   1067 
   1068   If Guid is NULL, then ASSERT().
   1069 
   1070   @param[in] Guid           The pointer to a 128-bit unique value that
   1071                             designates which namespace to set a value from.
   1072   @param[in] TokenNumber    The PCD token number to set a current value for.
   1073   @param[in] Value          The 16-bit value to set.
   1074 
   1075   @return The status of the set operation.
   1076 
   1077 **/
   1078 RETURN_STATUS
   1079 EFIAPI
   1080 LibPcdSetEx16S (
   1081   IN CONST GUID     *Guid,
   1082   IN UINTN          TokenNumber,
   1083   IN UINT16         Value
   1084   )
   1085 {
   1086   ASSERT (Guid != NULL);
   1087 
   1088   return (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);
   1089 }
   1090 
   1091 /**
   1092   This function provides a means by which to set a value for a given PCD token.
   1093 
   1094   Sets the 32-bit value for the token specified by TokenNumber
   1095   to the value specified by Value.
   1096 
   1097   If Guid is NULL, then ASSERT().
   1098 
   1099   @param[in] Guid           The pointer to a 128-bit unique value that
   1100                             designates which namespace to set a value from.
   1101   @param[in] TokenNumber    The PCD token number to set a current value for.
   1102   @param[in] Value          The 32-bit value to set.
   1103 
   1104   @return The status of the set operation.
   1105 
   1106 **/
   1107 RETURN_STATUS
   1108 EFIAPI
   1109 LibPcdSetEx32S (
   1110   IN CONST GUID     *Guid,
   1111   IN UINTN          TokenNumber,
   1112   IN UINT32         Value
   1113   )
   1114 {
   1115   ASSERT (Guid != NULL);
   1116 
   1117   return (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);
   1118 }
   1119 
   1120 /**
   1121   This function provides a means by which to set a value for a given PCD token.
   1122 
   1123   Sets the 64-bit value for the token specified by TokenNumber
   1124   to the value specified by Value.
   1125 
   1126   If Guid is NULL, then ASSERT().
   1127 
   1128   @param[in] Guid           The pointer to a 128-bit unique value that
   1129                             designates which namespace to set a value from.
   1130   @param[in] TokenNumber    The PCD token number to set a current value for.
   1131   @param[in] Value          The 64-bit value to set.
   1132 
   1133   @return The status of the set operation.
   1134 
   1135 **/
   1136 RETURN_STATUS
   1137 EFIAPI
   1138 LibPcdSetEx64S (
   1139   IN CONST GUID     *Guid,
   1140   IN UINTN          TokenNumber,
   1141   IN UINT64         Value
   1142   )
   1143 {
   1144   ASSERT (Guid != NULL);
   1145 
   1146   return (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);
   1147 }
   1148 
   1149 /**
   1150   This function provides a means by which to set a value for a given PCD token.
   1151 
   1152   Sets a buffer for the token specified by TokenNumber to the value specified by
   1153   Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
   1154   support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
   1155   TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
   1156   was not actually performed.
   1157 
   1158   If Guid is NULL, then ASSERT().
   1159   If SizeOfBuffer is NULL, then ASSERT().
   1160   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
   1161 
   1162   @param[in]      Guid          Pointer to a 128-bit unique value that
   1163                                 designates which namespace to set a value from.
   1164   @param[in]      TokenNumber   The PCD token number to set a current value for.
   1165   @param[in, out] SizeOfBuffer  The size, in bytes, of Buffer.
   1166   @param[in]      Buffer        A pointer to the buffer to set.
   1167 
   1168   @return The status of the set operation.
   1169 
   1170 **/
   1171 RETURN_STATUS
   1172 EFIAPI
   1173 LibPcdSetExPtrS (
   1174   IN CONST GUID     *Guid,
   1175   IN       UINTN    TokenNumber,
   1176   IN OUT   UINTN    *SizeOfBuffer,
   1177   IN       VOID     *Buffer
   1178   )
   1179 {
   1180   ASSERT (Guid != NULL);
   1181 
   1182   ASSERT (SizeOfBuffer != NULL);
   1183 
   1184   if (*SizeOfBuffer > 0) {
   1185     ASSERT (Buffer != NULL);
   1186   }
   1187 
   1188   return (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
   1189 }
   1190 
   1191 /**
   1192   This function provides a means by which to set a value for a given PCD token.
   1193 
   1194   Sets the boolean value for the token specified by TokenNumber
   1195   to the value specified by Value.
   1196 
   1197   If Guid is NULL, then ASSERT().
   1198 
   1199   @param[in] Guid           The pointer to a 128-bit unique value that
   1200                             designates which namespace to set a value from.
   1201   @param[in] TokenNumber    The PCD token number to set a current value for.
   1202   @param[in] Value          The boolean value to set.
   1203 
   1204   @return The status of the set operation.
   1205 
   1206 **/
   1207 RETURN_STATUS
   1208 EFIAPI
   1209 LibPcdSetExBoolS (
   1210   IN CONST GUID     *Guid,
   1211   IN UINTN          TokenNumber,
   1212   IN BOOLEAN        Value
   1213   )
   1214 {
   1215   ASSERT (Guid != NULL);
   1216 
   1217   return (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);
   1218 }
   1219 
   1220 /**
   1221   Set up a notification function that is called when a specified token is set.
   1222 
   1223   When the token specified by TokenNumber and Guid is set,
   1224   then notification function specified by NotificationFunction is called.
   1225   If Guid is NULL, then the default token space is used.
   1226   If NotificationFunction is NULL, then ASSERT().
   1227 
   1228   @param[in]  Guid                  The pointer to a 128-bit unique value that
   1229                                     designates which namespace to set a value from.
   1230                                     If NULL, then the default token space is used.
   1231   @param[in]  TokenNumber           The PCD token number to monitor.
   1232   @param[in]  NotificationFunction  The function to call when the token
   1233                                     specified by Guid and TokenNumber is set.
   1234 
   1235 **/
   1236 VOID
   1237 EFIAPI
   1238 LibPcdCallbackOnSet (
   1239   IN CONST GUID               *Guid,       OPTIONAL
   1240   IN UINTN                    TokenNumber,
   1241   IN PCD_CALLBACK             NotificationFunction
   1242   )
   1243 {
   1244   EFI_STATUS Status;
   1245 
   1246   ASSERT (NotificationFunction != NULL);
   1247 
   1248   Status = (GetPiPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);
   1249 
   1250   ASSERT_EFI_ERROR (Status);
   1251 
   1252   return;
   1253 }
   1254 
   1255 
   1256 
   1257 /**
   1258   Disable a notification function that was established with LibPcdCallbackonSet().
   1259 
   1260   Disable a notification function that was previously established with LibPcdCallbackOnSet().
   1261   If NotificationFunction is NULL, then ASSERT().
   1262   If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
   1263   and NotificationFunction, then ASSERT().
   1264 
   1265   @param[in]  Guid                 Specify the GUID token space.
   1266   @param[in]  TokenNumber          Specify the token number.
   1267   @param[in]  NotificationFunction The callback function to be unregistered.
   1268 
   1269 **/
   1270 VOID
   1271 EFIAPI
   1272 LibPcdCancelCallback (
   1273   IN CONST GUID               *Guid,       OPTIONAL
   1274   IN UINTN                    TokenNumber,
   1275   IN PCD_CALLBACK             NotificationFunction
   1276   )
   1277 {
   1278   EFI_STATUS Status;
   1279 
   1280   ASSERT (NotificationFunction != NULL);
   1281 
   1282   Status = (GetPiPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);
   1283 
   1284   ASSERT_EFI_ERROR (Status);
   1285 
   1286   return;
   1287 }
   1288 
   1289 
   1290 
   1291 /**
   1292   Retrieves the next token in a token space.
   1293 
   1294   Retrieves the next PCD token number from the token space specified by Guid.
   1295   If Guid is NULL, then the default token space is used.  If TokenNumber is 0,
   1296   then the first token number is returned.  Otherwise, the token number that
   1297   follows TokenNumber in the token space is returned.  If TokenNumber is the last
   1298   token number in the token space, then 0 is returned.
   1299 
   1300   If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
   1301 
   1302   @param[in]  Guid        The pointer to a 128-bit unique value that designates which namespace
   1303                           to set a value from.  If NULL, then the default token space is used.
   1304   @param[in]  TokenNumber The previous PCD token number.  If 0, then retrieves the first PCD
   1305                           token number.
   1306 
   1307   @return The next valid token number.
   1308 
   1309 **/
   1310 UINTN
   1311 EFIAPI
   1312 LibPcdGetNextToken (
   1313   IN CONST GUID               *Guid,       OPTIONAL
   1314   IN UINTN                    TokenNumber
   1315   )
   1316 {
   1317   EFI_STATUS    Status;
   1318 
   1319   Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);
   1320   ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
   1321 
   1322   return TokenNumber;
   1323 }
   1324 
   1325 
   1326 /**
   1327   Used to retrieve the list of available PCD token space GUIDs.
   1328 
   1329   Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
   1330   in the platform.
   1331   If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
   1332   If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
   1333 
   1334   @param  TokenSpaceGuid  The pointer to the a PCD token space GUID
   1335 
   1336   @return The next valid token namespace.
   1337 
   1338 **/
   1339 GUID *
   1340 EFIAPI
   1341 LibPcdGetNextTokenSpace (
   1342   IN CONST GUID  *TokenSpaceGuid
   1343   )
   1344 {
   1345   (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);
   1346 
   1347   return (GUID *) TokenSpaceGuid;
   1348 }
   1349 
   1350 
   1351 
   1352 /**
   1353   Sets a value of a patchable PCD entry that is type pointer.
   1354 
   1355   Sets the PCD entry specified by PatchVariable to the value specified by Buffer
   1356   and SizeOfBuffer.  Buffer is returned.  If SizeOfBuffer is greater than
   1357   MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
   1358   NULL to indicate that the set operation was not actually performed.
   1359   If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
   1360   MaximumDatumSize and NULL must be returned.
   1361 
   1362   If PatchVariable is NULL, then ASSERT().
   1363   If SizeOfBuffer is NULL, then ASSERT().
   1364   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
   1365 
   1366   @param[out] PatchVariable     A pointer to the global variable in a module that is
   1367                                 the target of the set operation.
   1368   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.
   1369   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.
   1370   @param[in] Buffer             A pointer to the buffer to used to set the target variable.
   1371 
   1372   @return Return the pointer to the buffer been set.
   1373 
   1374 **/
   1375 VOID *
   1376 EFIAPI
   1377 LibPatchPcdSetPtr (
   1378   OUT       VOID        *PatchVariable,
   1379   IN        UINTN       MaximumDatumSize,
   1380   IN OUT    UINTN       *SizeOfBuffer,
   1381   IN CONST  VOID        *Buffer
   1382   )
   1383 {
   1384   ASSERT (PatchVariable != NULL);
   1385   ASSERT (SizeOfBuffer  != NULL);
   1386 
   1387   if (*SizeOfBuffer > 0) {
   1388     ASSERT (Buffer != NULL);
   1389   }
   1390 
   1391   if ((*SizeOfBuffer > MaximumDatumSize) ||
   1392       (*SizeOfBuffer == MAX_ADDRESS)) {
   1393     *SizeOfBuffer = MaximumDatumSize;
   1394     return NULL;
   1395   }
   1396 
   1397   CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
   1398 
   1399   return (VOID *) Buffer;
   1400 }
   1401 
   1402 /**
   1403   Sets a value of a patchable PCD entry that is type pointer.
   1404 
   1405   Sets the PCD entry specified by PatchVariable to the value specified
   1406   by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
   1407   then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
   1408   to indicate that the set operation was not actually performed.
   1409   If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
   1410   MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
   1411 
   1412   If PatchVariable is NULL, then ASSERT().
   1413   If SizeOfBuffer is NULL, then ASSERT().
   1414   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
   1415 
   1416   @param[out] PatchVariable     A pointer to the global variable in a module that is
   1417                                 the target of the set operation.
   1418   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.
   1419   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.
   1420   @param[in] Buffer             A pointer to the buffer to used to set the target variable.
   1421 
   1422   @return The status of the set operation.
   1423 
   1424 **/
   1425 RETURN_STATUS
   1426 EFIAPI
   1427 LibPatchPcdSetPtrS (
   1428   OUT      VOID     *PatchVariable,
   1429   IN       UINTN    MaximumDatumSize,
   1430   IN OUT   UINTN    *SizeOfBuffer,
   1431   IN CONST VOID     *Buffer
   1432   )
   1433 {
   1434   ASSERT (PatchVariable != NULL);
   1435   ASSERT (SizeOfBuffer  != NULL);
   1436 
   1437   if (*SizeOfBuffer > 0) {
   1438     ASSERT (Buffer != NULL);
   1439   }
   1440 
   1441   if ((*SizeOfBuffer > MaximumDatumSize) ||
   1442       (*SizeOfBuffer == MAX_ADDRESS)) {
   1443     *SizeOfBuffer = MaximumDatumSize;
   1444     return RETURN_INVALID_PARAMETER;
   1445   }
   1446 
   1447   CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
   1448 
   1449   return RETURN_SUCCESS;
   1450 }
   1451 
   1452 
   1453 /**
   1454   Sets a value and size of a patchable PCD entry that is type pointer.
   1455 
   1456   Sets the PCD entry specified by PatchVariable to the value specified by Buffer
   1457   and SizeOfBuffer.  Buffer is returned.  If SizeOfBuffer is greater than
   1458   MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
   1459   NULL to indicate that the set operation was not actually performed.
   1460   If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
   1461   MaximumDatumSize and NULL must be returned.
   1462 
   1463   If PatchVariable is NULL, then ASSERT().
   1464   If SizeOfPatchVariable is NULL, then ASSERT().
   1465   If SizeOfBuffer is NULL, then ASSERT().
   1466   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
   1467 
   1468   @param[out] PatchVariable     A pointer to the global variable in a module that is
   1469                                 the target of the set operation.
   1470   @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
   1471   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.
   1472   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.
   1473   @param[in] Buffer             A pointer to the buffer to used to set the target variable.
   1474 
   1475   @return Return the pointer to the buffer been set.
   1476 
   1477 **/
   1478 VOID *
   1479 EFIAPI
   1480 LibPatchPcdSetPtrAndSize (
   1481   OUT       VOID        *PatchVariable,
   1482   OUT       UINTN       *SizeOfPatchVariable,
   1483   IN        UINTN       MaximumDatumSize,
   1484   IN OUT    UINTN       *SizeOfBuffer,
   1485   IN CONST  VOID        *Buffer
   1486   )
   1487 {
   1488   ASSERT (PatchVariable != NULL);
   1489   ASSERT (SizeOfPatchVariable != NULL);
   1490   ASSERT (SizeOfBuffer  != NULL);
   1491 
   1492   if (*SizeOfBuffer > 0) {
   1493     ASSERT (Buffer != NULL);
   1494   }
   1495 
   1496   if ((*SizeOfBuffer > MaximumDatumSize) ||
   1497       (*SizeOfBuffer == MAX_ADDRESS)) {
   1498     *SizeOfBuffer = MaximumDatumSize;
   1499     return NULL;
   1500   }
   1501 
   1502   CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
   1503   *SizeOfPatchVariable = *SizeOfBuffer;
   1504 
   1505   return (VOID *) Buffer;
   1506 }
   1507 
   1508 /**
   1509   Sets a value and size of a patchable PCD entry that is type pointer.
   1510 
   1511   Sets the PCD entry specified by PatchVariable to the value specified
   1512   by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
   1513   then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
   1514   to indicate that the set operation was not actually performed.
   1515   If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
   1516   MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
   1517 
   1518   If PatchVariable is NULL, then ASSERT().
   1519   If SizeOfPatchVariable is NULL, then ASSERT().
   1520   If SizeOfBuffer is NULL, then ASSERT().
   1521   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
   1522 
   1523   @param[out] PatchVariable     A pointer to the global variable in a module that is
   1524                                 the target of the set operation.
   1525   @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
   1526   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.
   1527   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.
   1528   @param[in] Buffer             A pointer to the buffer to used to set the target variable.
   1529 
   1530   @return The status of the set operation.
   1531 
   1532 **/
   1533 RETURN_STATUS
   1534 EFIAPI
   1535 LibPatchPcdSetPtrAndSizeS (
   1536   OUT      VOID     *PatchVariable,
   1537   OUT      UINTN    *SizeOfPatchVariable,
   1538   IN       UINTN    MaximumDatumSize,
   1539   IN OUT   UINTN    *SizeOfBuffer,
   1540   IN CONST VOID     *Buffer
   1541   )
   1542 {
   1543   ASSERT (PatchVariable != NULL);
   1544   ASSERT (SizeOfPatchVariable != NULL);
   1545   ASSERT (SizeOfBuffer  != NULL);
   1546 
   1547   if (*SizeOfBuffer > 0) {
   1548     ASSERT (Buffer != NULL);
   1549   }
   1550 
   1551   if ((*SizeOfBuffer > MaximumDatumSize) ||
   1552       (*SizeOfBuffer == MAX_ADDRESS)) {
   1553     *SizeOfBuffer = MaximumDatumSize;
   1554     return RETURN_INVALID_PARAMETER;
   1555   }
   1556 
   1557   CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
   1558   *SizeOfPatchVariable = *SizeOfBuffer;
   1559 
   1560   return RETURN_SUCCESS;
   1561 }
   1562 
   1563 /**
   1564   Retrieve additional information associated with a PCD token.
   1565 
   1566   This includes information such as the type of value the TokenNumber is associated with as well as possible
   1567   human readable name that is associated with the token.
   1568 
   1569   If TokenNumber is not in the default token space specified, then ASSERT().
   1570 
   1571   @param[in]    TokenNumber The PCD token number.
   1572   @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.
   1573                             The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
   1574 **/
   1575 VOID
   1576 EFIAPI
   1577 LibPcdGetInfo (
   1578   IN        UINTN           TokenNumber,
   1579   OUT       PCD_INFO        *PcdInfo
   1580   )
   1581 {
   1582   EFI_STATUS Status;
   1583 
   1584   Status = GetPcdInfoPpiPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);
   1585   ASSERT_EFI_ERROR (Status);
   1586 }
   1587 
   1588 /**
   1589   Retrieve additional information associated with a PCD token.
   1590 
   1591   This includes information such as the type of value the TokenNumber is associated with as well as possible
   1592   human readable name that is associated with the token.
   1593 
   1594   If TokenNumber is not in the token space specified by Guid, then ASSERT().
   1595 
   1596   @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.
   1597   @param[in]    TokenNumber The PCD token number.
   1598   @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.
   1599                             The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
   1600 **/
   1601 VOID
   1602 EFIAPI
   1603 LibPcdGetInfoEx (
   1604   IN CONST  GUID            *Guid,
   1605   IN        UINTN           TokenNumber,
   1606   OUT       PCD_INFO        *PcdInfo
   1607   )
   1608 {
   1609   EFI_STATUS Status;
   1610 
   1611   Status = GetPiPcdInfoPpiPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);
   1612   ASSERT_EFI_ERROR (Status);
   1613 }
   1614 
   1615 /**
   1616   Retrieve the currently set SKU Id.
   1617 
   1618   If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().
   1619 
   1620   @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the
   1621             default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
   1622             Id is returned.
   1623 **/
   1624 UINTN
   1625 EFIAPI
   1626 LibPcdGetSku (
   1627   VOID
   1628   )
   1629 {
   1630   UINTN SkuId;
   1631 
   1632   SkuId = GetPiPcdInfoPpiPointer()->GetSku ();
   1633   ASSERT (SkuId < PCD_MAX_SKU_ID);
   1634 
   1635   return SkuId;
   1636 }
   1637