Home | History | Annotate | Download | only in Library
      1 /** @file
      2   Provides variable check services and database management.
      3 
      4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
      5 This program and the accompanying materials are licensed and made available under
      6 the terms and conditions of the BSD License that accompanies this distribution.
      7 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 #ifndef _VARIABLE_CHECK_LIB_H_
     16 #define _VARIABLE_CHECK_LIB_H_
     17 
     18 #include <Protocol/VarCheck.h>
     19 
     20 typedef enum {
     21   VarCheckRequestReserved0 = 0,
     22   VarCheckRequestReserved1 = 1,
     23   VarCheckFromTrusted = 2,
     24   VarCheckFromUntrusted = 3,
     25 } VAR_CHECK_REQUEST_SOURCE;
     26 
     27 typedef
     28 VOID
     29 (EFIAPI *VAR_CHECK_END_OF_DXE_CALLBACK) (
     30   VOID
     31   );
     32 
     33 /**
     34   Register END_OF_DXE callback.
     35   The callback will be invoked by VarCheckLibInitializeAtEndOfDxe().
     36 
     37   @param[in] Callback           END_OF_DXE callback.
     38 
     39   @retval EFI_SUCCESS           The callback was registered successfully.
     40   @retval EFI_INVALID_PARAMETER Callback is NULL.
     41   @retval EFI_ACCESS_DENIED     EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
     42                                 already been signaled.
     43   @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the callback register request.
     44 
     45 **/
     46 EFI_STATUS
     47 EFIAPI
     48 VarCheckLibRegisterEndOfDxeCallback (
     49   IN VAR_CHECK_END_OF_DXE_CALLBACK  Callback
     50   );
     51 
     52 /**
     53   Var check initialize at END_OF_DXE.
     54 
     55   This function needs to be called at END_OF_DXE.
     56   Address pointers may be returned,
     57   and caller needs to ConvertPointer() for the pointers.
     58 
     59   @param[in, out] AddressPointerCount   Output pointer to address pointer count.
     60 
     61   @return Address pointer buffer, NULL if input AddressPointerCount is NULL.
     62 
     63 **/
     64 VOID ***
     65 EFIAPI
     66 VarCheckLibInitializeAtEndOfDxe (
     67   IN OUT UINTN                  *AddressPointerCount OPTIONAL
     68   );
     69 
     70 /**
     71   Register address pointer.
     72   The AddressPointer may be returned by VarCheckLibInitializeAtEndOfDxe().
     73 
     74   @param[in] AddressPointer     Address pointer.
     75 
     76   @retval EFI_SUCCESS           The address pointer was registered successfully.
     77   @retval EFI_INVALID_PARAMETER AddressPointer is NULL.
     78   @retval EFI_ACCESS_DENIED     EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
     79                                 already been signaled.
     80   @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the address pointer register request.
     81 
     82 **/
     83 EFI_STATUS
     84 EFIAPI
     85 VarCheckLibRegisterAddressPointer (
     86   IN VOID                       **AddressPointer
     87   );
     88 
     89 /**
     90   Register SetVariable check handler.
     91 
     92   @param[in] Handler            Pointer to check handler.
     93 
     94   @retval EFI_SUCCESS           The SetVariable check handler was registered successfully.
     95   @retval EFI_INVALID_PARAMETER Handler is NULL.
     96   @retval EFI_ACCESS_DENIED     EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
     97                                 already been signaled.
     98   @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the SetVariable check handler register request.
     99   @retval EFI_UNSUPPORTED       This interface is not implemented.
    100                                 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
    101 
    102 **/
    103 EFI_STATUS
    104 EFIAPI
    105 VarCheckLibRegisterSetVariableCheckHandler (
    106   IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER   Handler
    107   );
    108 
    109 /**
    110   Variable property set.
    111 
    112   @param[in] Name               Pointer to the variable name.
    113   @param[in] Guid               Pointer to the vendor GUID.
    114   @param[in] VariableProperty   Pointer to the input variable property.
    115 
    116   @retval EFI_SUCCESS           The property of variable specified by the Name and Guid was set successfully.
    117   @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
    118                                 or the fields of VariableProperty are not valid.
    119   @retval EFI_ACCESS_DENIED     EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
    120                                 already been signaled.
    121   @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the variable property set request.
    122 
    123 **/
    124 EFI_STATUS
    125 EFIAPI
    126 VarCheckLibVariablePropertySet (
    127   IN CHAR16                         *Name,
    128   IN EFI_GUID                       *Guid,
    129   IN VAR_CHECK_VARIABLE_PROPERTY    *VariableProperty
    130   );
    131 
    132 /**
    133   Variable property get.
    134 
    135   @param[in]  Name              Pointer to the variable name.
    136   @param[in]  Guid              Pointer to the vendor GUID.
    137   @param[out] VariableProperty  Pointer to the output variable property.
    138 
    139   @retval EFI_SUCCESS           The property of variable specified by the Name and Guid was got successfully.
    140   @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
    141   @retval EFI_NOT_FOUND         The property of variable specified by the Name and Guid was not found.
    142 
    143 **/
    144 EFI_STATUS
    145 EFIAPI
    146 VarCheckLibVariablePropertyGet (
    147   IN CHAR16                         *Name,
    148   IN EFI_GUID                       *Guid,
    149   OUT VAR_CHECK_VARIABLE_PROPERTY   *VariableProperty
    150   );
    151 
    152 /**
    153   SetVariable check.
    154 
    155   @param[in] VariableName       Name of Variable to set.
    156   @param[in] VendorGuid         Variable vendor GUID.
    157   @param[in] Attributes         Attribute value of the variable.
    158   @param[in] DataSize           Size of Data to set.
    159   @param[in] Data               Data pointer.
    160   @param[in] RequestSource      Request source.
    161 
    162   @retval EFI_SUCCESS           The SetVariable check result was success.
    163   @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, GUID,
    164                                 DataSize and Data value was supplied.
    165   @retval EFI_WRITE_PROTECTED   The variable in question is read-only.
    166   @retval Others                The other return status from check handler.
    167 
    168 **/
    169 EFI_STATUS
    170 EFIAPI
    171 VarCheckLibSetVariableCheck (
    172   IN CHAR16                     *VariableName,
    173   IN EFI_GUID                   *VendorGuid,
    174   IN UINT32                     Attributes,
    175   IN UINTN                      DataSize,
    176   IN VOID                       *Data,
    177   IN VAR_CHECK_REQUEST_SOURCE   RequestSource
    178   );
    179 
    180 #endif
    181