]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h
Calculate enough space for 2 variables (public key and variable data) instead of...
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / RuntimeDxe / Variable.h
index 9991dfe3218695dbcf92bb79697dab8fab63fd8c..c0497afe5e0fbfb257b501eefc358f6054ee9f77 100644 (file)
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by Variable modules.\r
 \r
-Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials \r
 are licensed and made available under the terms and conditions of the BSD License \r
 which accompanies this distribution.  The full text of the license may be found at \r
@@ -111,10 +111,8 @@ typedef struct {
 typedef struct {\r
   EFI_GUID    *Guid;\r
   CHAR16      *Name;\r
-  UINT32      Attributes;\r
-  UINTN       DataSize;\r
-  VOID        *Data;\r
-} VARIABLE_CACHE_ENTRY;\r
+  UINTN       VariableSize;\r
+} VARIABLE_ENTRY_CONSISTENCY;\r
 \r
 typedef struct {\r
   EFI_GUID    Guid;\r
@@ -143,8 +141,7 @@ FlushHobVariableToFlash (
   VariableBase. Fault Tolerant Write protocol is used for writing.\r
 \r
   @param  VariableBase   Base address of the variable to write.\r
-  @param  Buffer         Point to the data buffer.\r
-  @param  BufferSize     The number of bytes of the data Buffer.\r
+  @param  VariableBuffer Point to the variable data buffer.\r
 \r
   @retval EFI_SUCCESS    The function completed successfully.\r
   @retval EFI_NOT_FOUND  Fail to locate Fault Tolerant Write protocol.\r
@@ -154,8 +151,7 @@ FlushHobVariableToFlash (
 EFI_STATUS\r
 FtwVariableSpace (\r
   IN EFI_PHYSICAL_ADDRESS   VariableBase,\r
-  IN UINT8                  *Buffer,\r
-  IN UINTN                  BufferSize\r
+  IN VARIABLE_STORE_HEADER  *VariableBuffer\r
   );\r
 \r
 /**\r
@@ -221,6 +217,32 @@ DataSizeOfVariable (
   IN  VARIABLE_HEADER   *Variable\r
   );\r
 \r
+/**\r
+  This function is to check if the remaining variable space is enough to set\r
+  all Variables from argument list successfully. The purpose of the check\r
+  is to keep the consistency of the Variables to be in variable storage.\r
+\r
+  Note: Variables are assumed to be in same storage.\r
+  The set sequence of Variables will be same with the sequence of VariableEntry from argument list,\r
+  so follow the argument sequence to check the Variables.\r
+\r
+  @param[in] Attributes         Variable attributes for Variable entries.\r
+  @param ...                    The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.\r
+                                A NULL terminates the list. The VariableSize of \r
+                                VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.\r
+                                It will be changed to variable total size as output.\r
+\r
+  @retval TRUE                  Have enough variable space to set the Variables successfully.\r
+  @retval FALSE                 No enough variable space to set the Variables successfully.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+CheckRemainingSpaceForConsistency (\r
+  IN UINT32                     Attributes,\r
+  ...\r
+  );\r
+  \r
 /**\r
   Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,\r
   index of associated public key is needed.\r
@@ -402,11 +424,12 @@ VariableCommonInitialize (
   @param[in]      IsVolatile              The variable store is volatile or not;\r
                                           if it is non-volatile, need FTW.\r
   @param[in, out] UpdatingPtrTrack        Pointer to updating variable pointer track structure.\r
+  @param[in]      NewVariable             Pointer to new variable.\r
+  @param[in]      NewVariableSize         New variable size.\r
   @param[in]      ReclaimPubKeyStore      Reclaim for public key database or not.\r
-  @param[in]      ReclaimAnyway           If TRUE, do reclaim anyway.\r
   \r
   @return EFI_SUCCESS                  Reclaim operation has finished successfully.\r
-  @return EFI_OUT_OF_RESOURCES         No enough memory resources.\r
+  @return EFI_OUT_OF_RESOURCES         No enough memory resources or variable space.\r
   @return EFI_DEVICE_ERROR             The public key database doesn't exist.\r
   @return Others                       Unexpect error happened during reclaim operation.\r
 \r
@@ -417,8 +440,9 @@ Reclaim (
   OUT    UINTN                        *LastVariableOffset,\r
   IN     BOOLEAN                      IsVolatile,\r
   IN OUT VARIABLE_POINTER_TRACK       *UpdatingPtrTrack,\r
-  IN     BOOLEAN                      ReclaimPubKeyStore,\r
-  IN     BOOLEAN                      ReclaimAnyway\r
+  IN     VARIABLE_HEADER              *NewVariable,\r
+  IN     UINTN                        NewVariableSize,\r
+  IN     BOOLEAN                      ReclaimPubKeyStore\r
   );\r
 \r
 /**\r
@@ -564,6 +588,34 @@ VariableServiceSetVariable (
   IN VOID                    *Data\r
   );\r
 \r
+/**\r
+\r
+  This code returns information about the EFI variables.\r
+\r
+  Caution: This function may receive untrusted input.\r
+  This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r
+\r
+  @param Attributes                     Attributes bitmask to specify the type of variables\r
+                                        on which to return information.\r
+  @param MaximumVariableStorageSize     Pointer to the maximum size of the storage space available\r
+                                        for the EFI variables associated with the attributes specified.\r
+  @param RemainingVariableStorageSize   Pointer to the remaining size of the storage space available\r
+                                        for EFI variables associated with the attributes specified.\r
+  @param MaximumVariableSize            Pointer to the maximum size of an individual EFI variables\r
+                                        associated with the attributes specified.\r
+\r
+  @return EFI_SUCCESS                   Query successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VariableServiceQueryVariableInfoInternal (\r
+  IN  UINT32                 Attributes,\r
+  OUT UINT64                 *MaximumVariableStorageSize,\r
+  OUT UINT64                 *RemainingVariableStorageSize,\r
+  OUT UINT64                 *MaximumVariableSize\r
+  );\r
+\r
 /**\r
 \r
   This code returns information about the EFI variables.\r