Home | History | Annotate | Download | only in Ppi
      1 /** @file
      2   Platform Configuration Database (PCD) PPI defined in PI 1.2 Vol3
      3 
      4   A platform database that contains a variety of current platform settings or
      5   directives that can be accessed by a driver or application.
      6   PI PCD ppi only provide the accessing interfaces for Dynamic-Ex type PCD.
      7 
      8   This is the base PCD service API that provides an abstraction for accessing configuration content in
      9   the platform. It a seamless mechanism for extracting information regardless of where the
     10   information is stored (such as in Read-only data, or an EFI Variable).
     11   This protocol allows access to data through size-granular APIs and provides a mechanism for a
     12   firmware component to monitor specific settings and be alerted when a setting is changed.
     13 
     14   Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
     15   This program and the accompanying materials
     16   are licensed and made available under the terms and conditions of the BSD License
     17   which accompanies this distribution.  The full text of the license may be found at
     18   http://opensource.org/licenses/bsd-license.php
     19 
     20   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     21   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     22 
     23   @par Revision Reference:
     24   PI Version 1.2 Vol 3.
     25 **/
     26 
     27 #ifndef __PI_PCD_PPI_H__
     28 #define __PI_PCD_PPI_H__
     29 
     30 extern EFI_GUID gEfiPeiPcdPpiGuid;
     31 
     32 #define EFI_PEI_PCD_PPI_GUID \
     33   { 0x1f34d25, 0x4de2, 0x23ad, { 0x3f, 0xf3, 0x36, 0x35, 0x3f, 0xf3, 0x23, 0xf1 } }
     34 
     35 #define EFI_PCD_INVALID_TOKEN_NUMBER ((UINTN) 0)
     36 
     37 /**
     38   SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. SetSku() is
     39   normally called only once by the system.
     40   For each item (token), the database can hold a single value that applies to all SKUs, or multiple
     41   values, where each value is associated with a specific SKU Id. Items with multiple, SKU-specific
     42   values are called SKU enabled.
     43   The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255. For tokens that are
     44   not SKU enabled, the system ignores any set SKU Id and works with the single value for that token.
     45   For SKU-enabled tokens, the system will use the SKU Id set by the last call to SetSku(). If no
     46   SKU Id is set or the currently set SKU Id isn't valid for the specified token, the system uses the
     47   default SKU Id. If the system attempts to use the default SKU Id and no value has been set for that
     48   Id, the results are unpredictable.
     49 
     50   @param[in]    SkuId   The SKU value to set.
     51 **/
     52 typedef
     53 VOID
     54 (EFIAPI *EFI_PEI_PCD_PPI_SET_SKU)(
     55   IN UINTN SkuId
     56 );
     57 
     58 /**
     59   Retrieves the current byte-sized value for a PCD token number. If the TokenNumber is invalid,
     60   the results are unpredictable.
     61 
     62   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
     63   @param[in]    TokenNumber   The PCD token number.
     64 
     65   @return 8-bit value for a given PCD token.
     66 **/
     67 typedef
     68 UINT8
     69 (EFIAPI *EFI_PEI_PCD_PPI_GET_8)(
     70   IN CONST  EFI_GUID  *Guid,
     71   IN        UINTN     TokenNumber
     72 );
     73 
     74 /**
     75   Retrieves the current word-sized value for a PCD token number. If the TokenNumber is invalid,
     76   the results are unpredictable.
     77 
     78   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
     79   @param[in]    TokenNumber   The PCD token number.
     80 
     81   @return 16-bit value for a given PCD token.
     82 **/
     83 typedef
     84 UINT16
     85 (EFIAPI *EFI_PEI_PCD_PPI_GET_16)(
     86   IN CONST  EFI_GUID  *Guid,
     87   IN        UINTN     TokenNumber
     88 );
     89 
     90 /**
     91   Retrieves the current 32-bit value for a PCD token number. If the TokenNumber is invalid, the
     92   results are unpredictable.
     93 
     94   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
     95   @param[in]    TokenNumber   The PCD token number.
     96 
     97   @return 32-bit value for a given PCD token.
     98 **/
     99 typedef
    100 UINT32
    101 (EFIAPI *EFI_PEI_PCD_PPI_GET_32)(
    102   IN CONST  EFI_GUID  *Guid,
    103   IN        UINTN     TokenNumber
    104 );
    105 
    106 /**
    107   Retrieves the current 64-bit value for a PCD token number. If the TokenNumber is invalid, the
    108   results are unpredictable.
    109 
    110   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    111   @param[in]    TokenNumber   The PCD token number.
    112 
    113   @return 64-bit value for a given PCD token.
    114 **/
    115 typedef
    116 UINT64
    117 (EFIAPI *EFI_PEI_PCD_PPI_GET_64)(
    118   IN CONST  EFI_GUID  *Guid,
    119   IN        UINTN     TokenNumber
    120 );
    121 
    122 /**
    123   Retrieves the current pointer to the value for a PCD token number. There should not be any
    124   alignment assumptions about the pointer that is returned by this function call. If the TokenNumber
    125   is invalid, the results are unpredictable.
    126 
    127   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    128   @param[in]    TokenNumber   The PCD token number.
    129 **/
    130 typedef
    131 VOID *
    132 (EFIAPI *EFI_PEI_PCD_PPI_GET_POINTER)(
    133   IN CONST  EFI_GUID  *Guid,
    134   IN        UINTN     TokenNumber
    135 );
    136 
    137 /**
    138   Retrieves the current Boolean-sized value for a PCD token number. If the TokenNumber is
    139   invalid, the results are unpredictable.
    140 
    141   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    142   @param[in]    TokenNumber   The PCD token number.
    143 
    144   @return Boolean value for a given PCD token.
    145 **/
    146 typedef
    147 BOOLEAN
    148 (EFIAPI *EFI_PEI_PCD_PPI_GET_BOOLEAN)(
    149   IN CONST  EFI_GUID  *Guid,
    150   IN        UINTN     TokenNumber
    151 );
    152 
    153 /**
    154   Retrieves the current size of a particular PCD token. If the TokenNumber is invalid, the results are
    155   unpredictable.
    156 
    157   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    158   @param[in]    TokenNumber   The PCD token number.
    159 
    160   @return the size of the value for a given PCD token.
    161 **/
    162 typedef
    163 UINTN
    164 (EFIAPI *EFI_PEI_PCD_PPI_GET_SIZE)(
    165   IN CONST  EFI_GUID  *Guid,
    166   IN        UINTN     TokenNumber
    167 );
    168 
    169 /**
    170   Sets an 8-bit value for a given PCD token.
    171 
    172   When the PCD service sets a value, it will check to ensure that the size of the value being set is
    173   compatible with the Token's existing definition. If it is not, an error will be returned.
    174 
    175   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    176   @param[in]    TokenNumber   The PCD token number.
    177   @param[in]    Value         The value to set for the PCD token.
    178 
    179   @retval   EFI_SUCCESS             The PCD service has set the value requested
    180   @retval   EFI_INVALID_PARAMETER   The PCD service determined that the size of the data being set was
    181                                     incompatible with a call to this function. Use GetSizeEx() to
    182                                     retrieve the size of the target data.
    183   @retval   EFI_NOT_FOUND           The PCD service could not find the requested token number.
    184 **/
    185 typedef
    186 EFI_STATUS
    187 (EFIAPI *EFI_PEI_PCD_PPI_SET_8)(
    188   IN CONST  EFI_GUID  *Guid,
    189   IN        UINTN     TokenNumber,
    190   IN        UINT8     Value
    191 );
    192 
    193 /**
    194   Sets an 16-bit value for a given PCD token.
    195 
    196   When the PCD service sets a value, it will check to ensure that the size of the value being set is
    197   compatible with the Token's existing definition. If it is not, an error will be returned.
    198 
    199   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    200   @param[in]    TokenNumber   The PCD token number.
    201   @param[in]    Value         The value to set for the PCD token.
    202 
    203   @retval   EFI_SUCCESS             The PCD service has set the value requested
    204   @retval   EFI_INVALID_PARAMETER   The PCD service determined that the size of the data being set was
    205                                     incompatible with a call to this function. Use GetSizeEx() to
    206                                     retrieve the size of the target data.
    207   @retval   EFI_NOT_FOUND           The PCD service could not find the requested token number.
    208 **/
    209 typedef
    210 EFI_STATUS
    211 (EFIAPI *EFI_PEI_PCD_PPI_SET_16)(
    212   IN CONST  EFI_GUID  *Guid,
    213   IN        UINTN     TokenNumber,
    214   IN        UINT16    Value
    215 );
    216 
    217 /**
    218   Sets an 32-bit value for a given PCD token.
    219 
    220   When the PCD service sets a value, it will check to ensure that the size of the value being set is
    221   compatible with the Token's existing definition. If it is not, an error will be returned.
    222 
    223   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    224   @param[in]    TokenNumber   The PCD token number.
    225   @param[in]    Value         The value to set for the PCD token.
    226 
    227   @retval   EFI_SUCCESS             The PCD service has set the value requested
    228   @retval   EFI_INVALID_PARAMETER   The PCD service determined that the size of the data being set was
    229                                     incompatible with a call to this function. Use GetSizeEx() to
    230                                     retrieve the size of the target data.
    231   @retval   EFI_NOT_FOUND           The PCD service could not find the requested token number.
    232 **/
    233 typedef
    234 EFI_STATUS
    235 (EFIAPI *EFI_PEI_PCD_PPI_SET_32)(
    236   IN CONST  EFI_GUID  *Guid,
    237   IN        UINTN     TokenNumber,
    238   IN        UINT32    Value
    239 );
    240 
    241 /**
    242   Sets an 64-bit value for a given PCD token.
    243 
    244   When the PCD service sets a value, it will check to ensure that the size of the value being set is
    245   compatible with the Token's existing definition. If it is not, an error will be returned.
    246 
    247   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    248   @param[in]    TokenNumber   The PCD token number.
    249   @param[in]    Value         The value to set for the PCD token.
    250 
    251   @retval   EFI_SUCCESS             The PCD service has set the value requested
    252   @retval   EFI_INVALID_PARAMETER   The PCD service determined that the size of the data being set was
    253                                     incompatible with a call to this function. Use GetSizeEx() to
    254                                     retrieve the size of the target data.
    255   @retval   EFI_NOT_FOUND           The PCD service could not find the requested token number.
    256 **/
    257 typedef
    258 EFI_STATUS
    259 (EFIAPI *EFI_PEI_PCD_PPI_SET_64)(
    260   IN CONST  EFI_GUID  *Guid,
    261   IN        UINTN     TokenNumber,
    262   IN        UINT64    Value
    263 );
    264 
    265 /**
    266   Sets a value of the specified size for a given PCD token.
    267 
    268   When the PCD service sets a value, it will check to ensure that the size of the value being set is
    269   compatible with the Token's existing definition. If it is not, an error will be returned.
    270 
    271   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    272   @param[in]    TokenNumber   The PCD token number.
    273   @param[in]    SizeOfValue   The length of the value being set for the PCD token. If too large of a length is
    274                               specified, upon return from this function the value of SizeOfValue will reflect the
    275                               maximum size for the PCD token.
    276   @param[in]    Buffer        A pointer to the buffer containing the value to set for the PCD token.
    277 
    278   @retval   EFI_SUCCESS             The PCD service has set the value requested
    279   @retval   EFI_INVALID_PARAMETER   The PCD service determined that the size of the data being set was
    280                                     incompatible with a call to this function. Use GetSizeEx() to
    281                                     retrieve the size of the target data.
    282   @retval   EFI_NOT_FOUND           The PCD service could not find the requested token number.
    283 **/
    284 typedef
    285 EFI_STATUS
    286 (EFIAPI *EFI_PEI_PCD_PPI_SET_POINTER)(
    287   IN CONST  EFI_GUID  *Guid,
    288   IN        UINTN     TokenNumber,
    289   IN OUT    UINTN     *SizeOfValue,
    290   IN        VOID      *Buffer
    291 );
    292 
    293 /**
    294   Sets a Boolean value for a given PCD token.
    295 
    296   When the PCD service sets a value, it will check to ensure that the size of the value being set is
    297   compatible with the Token's existing definition. If it is not, an error will be returned.
    298 
    299   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    300   @param[in]    TokenNumber   The PCD token number.
    301   @param[in]    Value         The value to set for the PCD token.
    302 
    303   @retval   EFI_SUCCESS             The PCD service has set the value requested
    304   @retval   EFI_INVALID_PARAMETER   The PCD service determined that the size of the data being set was
    305                                     incompatible with a call to this function. Use GetSizeEx() to
    306                                     retrieve the size of the target data.
    307   @retval   EFI_NOT_FOUND           The PCD service could not find the requested token number.
    308 **/
    309 typedef
    310 EFI_STATUS
    311 (EFIAPI *EFI_PEI_PCD_PPI_SET_BOOLEAN)(
    312   IN CONST  EFI_GUID  *Guid,
    313   IN        UINTN     TokenNumber,
    314   IN        BOOLEAN   Value
    315 );
    316 
    317 typedef
    318 VOID
    319 (EFIAPI *EFI_PEI_PCD_PPI_CALLBACK)(
    320   IN     EFI_GUID *Guid     OPTIONAL,
    321   IN     UINTN    CallBackToken,
    322   IN OUT VOID     *TokenData,
    323   IN     UINTN    TokenDatSize
    324 );
    325 
    326 /**
    327   Specifies a function to be called anytime the value of a designated token is changed.
    328 
    329   @param[in]    Guid              The 128-bit unique value that designates which namespace to monitor. If NULL, use
    330                                   the standard platform namespace.
    331   @param[in]    CallBackToken     The PCD token number to monitor.
    332   @param[in]    CallBackFunction  The function prototype that will be called when the value associated with the
    333                                   CallBackToken is set.
    334 
    335   @retval EFI_SUCCESS     The PCD service has successfully established a call event for the
    336                           CallBackToken requested.
    337   @retval EFI_NOT_FOUND   The PCD service could not find the referenced token number.
    338 **/
    339 typedef
    340 EFI_STATUS
    341 (EFIAPI *EFI_PEI_PCD_PPI_CALLBACK_ON_SET)(
    342   IN CONST  EFI_GUID                  *Guid   OPTIONAL,
    343   IN        UINTN                     CallBackToken,
    344   IN        EFI_PEI_PCD_PPI_CALLBACK  CallBackFunction
    345 );
    346 
    347 /**
    348   Cancels a previously set callback function for a particular PCD token number.
    349 
    350   @param[in]  Guid              The 128-bit unique value that designates which namespace to monitor. If NULL, use
    351                                 the standard platform namespace.
    352   @param[in]  CallBackToken     The PCD token number to cancel monitoring.
    353   @param[in]  CallBackFunction  The function prototype that was originally passed to the CallBackOnSet function.
    354 
    355   @retval     EFI_SUCCESS       The PCD service has cancelled the call event associated with the
    356                                 CallBackToken.
    357   @retval     EFI_INVALID_PARAMETER   The PCD service did not match the CallBackFunction to one
    358                                       that is currently being monitored.
    359   @retval     EFI_NOT_FOUND     The PCD service could not find data the requested token number.
    360 **/
    361 typedef
    362 EFI_STATUS
    363 (EFIAPI *EFI_PEI_PCD_PPI_CANCEL_CALLBACK)(
    364   IN CONST  EFI_GUID                  *Guid   OPTIONAL,
    365   IN        UINTN                     CallBackToken,
    366   IN        EFI_PEI_PCD_PPI_CALLBACK  CallBackFunction
    367 );
    368 
    369 /**
    370   Retrieves the next valid PCD token for a given namespace.
    371 
    372   This provides a means by which to get the next valid token number in a given namespace. This is
    373   useful since the PCD infrastructure has a sparse list of token numbers in it, and one cannot a priori
    374   know what token numbers are valid in the database.
    375 
    376   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.
    377   @param[in]    TokenNumber   A pointer to the PCD token number to use to find the subsequent token number. To
    378                               retrieve the "first" token, have the pointer reference a TokenNumber value of 0.
    379 
    380   @retval   EFI_SUCCESS       The PCD service has retrieved the value requested.
    381   @retval   EFI_NOT_FOUND     The PCD service could not find data from the requested token number.
    382 **/
    383 typedef
    384 EFI_STATUS
    385 (EFIAPI *EFI_PEI_PCD_PPI_GET_NEXT_TOKEN)(
    386   IN CONST  EFI_GUID      *Guid     OPTIONAL,
    387   IN        UINTN         *TokenNumber
    388 );
    389 
    390 /**
    391   Retrieves the next valid PCD token namespace for a given namespace.
    392 
    393   Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
    394   token namespaces on a platform.
    395 
    396   @param[in, out]   Guid    An indirect pointer to EFI_GUID. On input it designates a known token
    397                             namespace from which the search will start. On output, it designates the next valid
    398                             token namespace on the platform. If *Guid is NULL, then the GUID of the first token
    399                             space of the current platform is returned. If the search cannot locate the next valid
    400                             token namespace, an error is returned and the value of *Guid is undefined.
    401 
    402   @retval  EFI_SUCCESS      The PCD service retrieved the value requested.
    403   @retval  EFI_NOT_FOUND    The PCD service could not find the next valid token namespace.
    404 **/
    405 typedef
    406 EFI_STATUS
    407 (EFIAPI *EFI_PEI_PCD_PPI_GET_NEXT_TOKEN_SPACE)(
    408   IN OUT CONST EFI_GUID     **Guid
    409 );
    410 
    411 typedef struct {
    412   EFI_PEI_PCD_PPI_SET_SKU               SetSku;
    413   EFI_PEI_PCD_PPI_GET_8                 Get8;
    414   EFI_PEI_PCD_PPI_GET_16                Get16;
    415   EFI_PEI_PCD_PPI_GET_32                Get32;
    416   EFI_PEI_PCD_PPI_GET_64                Get64;
    417   EFI_PEI_PCD_PPI_GET_POINTER           GetPtr;
    418   EFI_PEI_PCD_PPI_GET_BOOLEAN           GetBool;
    419   EFI_PEI_PCD_PPI_GET_SIZE              GetSize;
    420   EFI_PEI_PCD_PPI_SET_8                 Set8;
    421   EFI_PEI_PCD_PPI_SET_16                Set16;
    422   EFI_PEI_PCD_PPI_SET_32                Set32;
    423   EFI_PEI_PCD_PPI_SET_64                Set64;
    424   EFI_PEI_PCD_PPI_SET_POINTER           SetPtr;
    425   EFI_PEI_PCD_PPI_SET_BOOLEAN           SetBool;
    426   EFI_PEI_PCD_PPI_CALLBACK_ON_SET       CallbackOnSet;
    427   EFI_PEI_PCD_PPI_CANCEL_CALLBACK       CancelCallback;
    428   EFI_PEI_PCD_PPI_GET_NEXT_TOKEN        GetNextToken;
    429   EFI_PEI_PCD_PPI_GET_NEXT_TOKEN_SPACE  GetNextTokenSpace;
    430 } EFI_PEI_PCD_PPI;
    431 
    432 #endif
    433