]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
Calculate enough space for 2 variables (public key and variable data) instead of...
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / Variable.h
index 7cc039dea85c47f3fea3928b791a2437a32c3b94..ac71f0c957ad8e77687cd92ec4ef902fe1079c75 100644 (file)
@@ -3,7 +3,7 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by Variable modules.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -22,7 +22,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/FaultTolerantWrite.h>\r
 #include <Protocol/FirmwareVolumeBlock.h>\r
 #include <Protocol/Variable.h>\r
+#include <Protocol/VariableLock.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/DxeServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
@@ -36,22 +38,47 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/GlobalVariable.h>\r
 #include <Guid/EventGroup.h>\r
 #include <Guid/VariableFormat.h>\r
+#include <Guid/SystemNvDataGuid.h>\r
+#include <Guid/FaultTolerantWrite.h>\r
+#include <Guid/HardwareErrorVariable.h>\r
 \r
-#define VARIABLE_RECLAIM_THRESHOLD (1024)\r
+#define VARIABLE_ATTRIBUTE_BS_RT        (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)\r
+#define VARIABLE_ATTRIBUTE_NV_BS_RT     (VARIABLE_ATTRIBUTE_BS_RT | EFI_VARIABLE_NON_VOLATILE)\r
+#define VARIABLE_ATTRIBUTE_NV_BS_RT_AT  (VARIABLE_ATTRIBUTE_NV_BS_RT | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)\r
+\r
+typedef struct {\r
+  CHAR16      *Name;\r
+  UINT32      Attributes;\r
+} GLOBAL_VARIABLE_ENTRY;\r
 \r
 ///\r
 /// The size of a 3 character ISO639 language code.\r
 ///\r
 #define ISO_639_2_ENTRY_SIZE    3\r
 \r
+typedef enum {\r
+  VariableStoreTypeVolatile,\r
+  VariableStoreTypeHob,\r
+  VariableStoreTypeNv,\r
+  VariableStoreTypeMax\r
+} VARIABLE_STORE_TYPE;\r
+\r
 typedef struct {\r
   VARIABLE_HEADER *CurrPtr;\r
+  //\r
+  // If both ADDED and IN_DELETED_TRANSITION variable are present,\r
+  // InDeletedTransitionPtr will point to the IN_DELETED_TRANSITION one.\r
+  // Otherwise, CurrPtr will point to the ADDED or IN_DELETED_TRANSITION one,\r
+  // and InDeletedTransitionPtr will be NULL at the same time.\r
+  //\r
+  VARIABLE_HEADER *InDeletedTransitionPtr;\r
   VARIABLE_HEADER *EndPtr;\r
   VARIABLE_HEADER *StartPtr;\r
   BOOLEAN         Volatile;\r
 } VARIABLE_POINTER_TRACK;\r
 \r
 typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  HobVariableBase;\r
   EFI_PHYSICAL_ADDRESS  VolatileVariableBase;\r
   EFI_PHYSICAL_ADDRESS  NonVolatileVariableBase;\r
   EFI_LOCK              VariableServicesLock;\r
@@ -74,10 +101,27 @@ 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
+  CHAR16      *Name;\r
+  LIST_ENTRY  Link;\r
+} VARIABLE_ENTRY;\r
+\r
+/**\r
+  Flush the HOB variable to flash.\r
+\r
+  @param[in] VariableName       Name of variable has been updated or deleted.\r
+  @param[in] VendorGuid         Guid of variable has been updated or deleted.\r
+\r
+**/\r
+VOID\r
+FlushHobVariableToFlash (\r
+  IN CHAR16                     *VariableName,\r
+  IN EFI_GUID                   *VendorGuid\r
+  );\r
 \r
 /**\r
   Writes a buffer to variable storage space, in the working block.\r
@@ -87,8 +131,7 @@ typedef struct {
   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
@@ -98,8 +141,7 @@ typedef struct {
 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
@@ -117,7 +159,7 @@ FtwVariableSpace (
 \r
   @param[in] Attributes         Attribues of the variable.\r
 \r
-  @param[in] Variable           The variable information that is used to keep track of variable usage.\r
+  @param[in, out] Variable      The variable information that is used to keep track of variable usage.\r
 \r
   @retval EFI_SUCCESS           The update operation is success.\r
 \r
@@ -131,7 +173,7 @@ UpdateVariable (
   IN      VOID            *Data,\r
   IN      UINTN           DataSize,\r
   IN      UINT32          Attributes OPTIONAL,\r
-  IN      VARIABLE_POINTER_TRACK *Variable\r
+  IN OUT  VARIABLE_POINTER_TRACK *Variable\r
   );\r
 \r
 \r
@@ -399,6 +441,31 @@ VariableServiceSetVariable (
   IN VOID                    *Data\r
   );\r
 \r
+/**\r
+\r
+  This code returns information about the EFI variables.\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
@@ -425,7 +492,30 @@ VariableServiceQueryVariableInfo (
   OUT UINT64                 *RemainingVariableStorageSize,\r
   OUT UINT64                 *MaximumVariableSize\r
   );  \r
-  \r
+\r
+/**\r
+  Mark a variable that will become read-only after leaving the DXE phase of execution.\r
+\r
+  @param[in] This          The VARIABLE_LOCK_PROTOCOL instance.\r
+  @param[in] VariableName  A pointer to the variable name that will be made read-only subsequently.\r
+  @param[in] VendorGuid    A pointer to the vendor GUID that will be made read-only subsequently.\r
+\r
+  @retval EFI_SUCCESS           The variable specified by the VariableName and the VendorGuid was marked\r
+                                as pending to be read-only.\r
+  @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.\r
+                                Or VariableName is an empty string.\r
+  @retval EFI_ACCESS_DENIED     EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r
+                                already been signaled.\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough resource to hold the lock request.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VariableLockRequestToLock (\r
+  IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,\r
+  IN       CHAR16                       *VariableName,\r
+  IN       EFI_GUID                     *VendorGuid\r
+  );\r
+\r
 extern VARIABLE_MODULE_GLOBAL  *mVariableModuleGlobal;\r
 \r
 #endif\r