]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2Pkg/Include/Ppi/Variable.h
IntelFsp2Pkg: Add Definition of EDKII_PEI_VARIABLE_PPI
[mirror_edk2.git] / IntelFsp2Pkg / Include / Ppi / Variable.h
diff --git a/IntelFsp2Pkg/Include/Ppi/Variable.h b/IntelFsp2Pkg/Include/Ppi/Variable.h
new file mode 100644 (file)
index 0000000..3e1f4b9
--- /dev/null
@@ -0,0 +1,195 @@
+/** @file\r
+  EDKII PEI Variable PPI provides an implementation of variables\r
+  intended for use as a means to store data in the PEI environment.\r
+\r
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef EDKII_PEI_VARIABLE_PPI_H_\r
+#define EDKII_PEI_VARIABLE_PPI_H_\r
+\r
+#define EDKII_PEI_VARIABLE_PPI_GUID \\r
+  { \\r
+    0xe7b2cd04, 0x4b14, 0x44c2, { 0xb7, 0x48, 0xce, 0xaf, 0x2b, 0x66, 0x4a, 0xb0 } \\r
+  }\r
+\r
+typedef struct _EDKII_PEI_VARIABLE_PPI EDKII_PEI_VARIABLE_PPI;\r
+\r
+/**\r
+  This service retrieves a variable's value using its name and GUID.\r
+\r
+  Read the specified variable from the UEFI variable store. If the Data\r
+  buffer is too small to hold the contents of the variable,\r
+  the error EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the\r
+  required buffer size to obtain the data.\r
+\r
+  @param[in]        This              A pointer to this instance of the EDKII_PEI_VARIABLE_PPI.\r
+  @param[in]        VariableName      A pointer to a null-terminated string that is the variable's name.\r
+  @param[in]        VariableGuid      A pointer to an EFI_GUID that is the variable's GUID. The combination of\r
+                                      VariableGuid and VariableName must be unique.\r
+  @param[out]       Attributes        If non-NULL, on return, points to the variable's attributes.\r
+  @param[in, out]   DataSize          On entry, points to the size in bytes of the Data buffer.\r
+                                      On return, points to the size of the data returned in Data.\r
+  @param[out]       Data              Points to the buffer which will hold the returned variable value.\r
+                                      May be NULL with a zero DataSize in order to determine the size of the\r
+                                      buffer needed.\r
+\r
+  @retval EFI_SUCCESS                 The variable was read successfully.\r
+  @retval EFI_NOT_FOUND               The variable was not found.\r
+  @retval EFI_BUFFER_TOO_SMALL        The DataSize is too small for the resulting data.\r
+                                      DataSize is updated with the size required for\r
+                                      the specified variable.\r
+  @retval EFI_INVALID_PARAMETER       VariableName, VariableGuid, DataSize or Data is NULL.\r
+  @retval EFI_DEVICE_ERROR            The variable could not be retrieved because of a device error.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EDKII_PEI_GET_VARIABLE)(\r
+  IN CONST  EDKII_PEI_VARIABLE_PPI    *This,\r
+  IN CONST  CHAR16                    *VariableName,\r
+  IN CONST  EFI_GUID                  *VariableGuid,\r
+  OUT       UINT32                    *Attributes   OPTIONAL,\r
+  IN OUT    UINTN                     *DataSize,\r
+  OUT       VOID                      *Data         OPTIONAL\r
+  );\r
+\r
+/**\r
+  Return the next variable name and GUID.\r
+\r
+  This function is called multiple times to retrieve the VariableName\r
+  and VariableGuid of all variables currently available in the system.\r
+  On each call, the previous results are passed into the interface,\r
+  and, on return, the interface returns the data for the next\r
+  variable. To get started, VariableName should initially contain L"\0"\r
+  and VariableNameSize should be sizeof(CHAR16). When the entire\r
+  variable list has been returned, EFI_NOT_FOUND is returned.\r
+\r
+  @param[in]        This              A pointer to this instance of the EDKII_PEI_VARIABLE_PPI.\r
+  @param[in, out]   VariableNameSize  On entry, points to the size of the buffer pointed to by VariableName.\r
+                                      On return, the size of the variable name buffer.\r
+  @param[in, out]   VariableName      On entry, a pointer to a null-terminated string that is the variable's name.\r
+                                      On return, points to the next variable's null-terminated name string.\r
+  @param[in, out]   VariableGuid      On entry, a pointer to an EFI_GUID that is the variable's GUID.\r
+                                      On return, a pointer to the next variable's GUID.\r
+\r
+  @retval EFI_SUCCESS                 The next variable name was read successfully.\r
+  @retval EFI_NOT_FOUND               All variables have been enumerated.\r
+  @retval EFI_BUFFER_TOO_SMALL        The VariableNameSize is too small for the resulting\r
+                                      data. VariableNameSize is updated with the size\r
+                                      required for the specified variable.\r
+  @retval EFI_INVALID_PARAMETER       VariableName, VariableGuid or\r
+                                      VariableNameSize is NULL.\r
+  @retval EFI_DEVICE_ERROR            The variable could not be retrieved because of a device error.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EDKII_PEI_GET_NEXT_VARIABLE_NAME)(\r
+  IN CONST  EDKII_PEI_VARIABLE_PPI    *This,\r
+  IN OUT    UINTN                     *VariableNameSize,\r
+  IN OUT    CHAR16                    *VariableName,\r
+  IN OUT    EFI_GUID                  *VariableGuid\r
+  );\r
+\r
+/**\r
+  Sets the value of a variable.\r
+\r
+  @param[in]        This              A pointer to this instance of the EDKII_PEI_VARIABLE_PPI.\r
+  @param[in]        VariableName      A Null-terminated string that is the name of the vendor's variable.\r
+                                      Each VariableName is unique for each VendorGuid. VariableName must\r
+                                      contain 1 or more characters. If VariableName is an empty string,\r
+                                      then EFI_INVALID_PARAMETER is returned.\r
+  @param[in]        VendorGuid        A unique identifier for the vendor.\r
+  @param[in]        Attributes        Attributes bitmask to set for the variable.\r
+  @param[in]        DataSize          The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE\r
+                                      attribute is set, a size of zero causes the variable to be deleted. When the\r
+                                      EFI_VARIABLE_APPEND_WRITE attribute is set, then a SetVariable() call with a\r
+                                      DataSize of zero will not cause any change to the variable value.\r
+  @param[in]        Data              The contents for the variable.\r
+\r
+  @retval EFI_SUCCESS                 The firmware has successfully stored the variable and its data as\r
+                                      defined by the Attributes.\r
+  @retval EFI_INVALID_PARAMETER       An invalid combination of attribute bits, name, and GUID was supplied, or the\r
+                                      DataSize exceeds the maximum allowed.\r
+  @retval EFI_INVALID_PARAMETER       VariableName is an empty string.\r
+  @retval EFI_OUT_OF_RESOURCES        Not enough storage is available to hold the variable and its data.\r
+  @retval EFI_DEVICE_ERROR            The variable could not be stored due to a hardware error.\r
+  @retval EFI_WRITE_PROTECTED         The variable in question is read-only.\r
+  @retval EFI_WRITE_PROTECTED         The variable in question cannot be deleted.\r
+  @retval EFI_SECURITY_VIOLATION      The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS,\r
+                                      or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS, or\r
+                                      EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS being set. Writing to authenticated\r
+                                      variables is not supported in the PEI environment. Updates to authenticated\r
+                                      variables can be requested during PEI via the EFI_AUTHENTICATED_VARIABLE_HOB, but\r
+                                      these updates won't be written to non-volatile storage until later in DXE.\r
+                                      The EFI_AUTHENTICATED_VARIABLE_HOB is a HOB with the GUID\r
+                                      gEfiAuthenticatedVariableGuid. This HOB contains a VARIABLE_STORE_HEADER followed\r
+                                      by one or more UEFI variables, which are stored as DWORD aligned tuples of\r
+                                      (VARIABLE_HEADER + CHAR16 VariableName + VariableData).\r
+                                      See MdeModulePkg/Include/Guid/VariableFormat.h for these data structure\r
+                                      definitions and MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c for\r
+                                      an example of how to parse these data structures.\r
+  @retval EFI_NOT_FOUND               The variable trying to be updated or deleted was not found.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EDKII_PEI_SET_VARIABLE)(\r
+  IN CONST  EDKII_PEI_VARIABLE_PPI    *This,\r
+  IN        CHAR16                    *VariableName,\r
+  IN        EFI_GUID                  *VendorGuid,\r
+  IN        UINT32                    Attributes,\r
+  IN        UINTN                     DataSize,\r
+  IN        VOID                      *Data\r
+  );\r
+\r
+/**\r
+  Returns information about the UEFI variables.\r
+\r
+  @param[in]        This                          A pointer to this instance of the EDKII_PEI_VARIABLE_PPI.\r
+  @param[in]        Attributes                    Attributes bitmask to specify the type of variables on\r
+                                                  which to return information.\r
+  @param[out]       MaximumVariableStorageSize    On output the maximum size of the storage space\r
+                                                  available for the EFI variables associated with the\r
+                                                  attributes specified.\r
+  @param[out]       RemainingVariableStorageSize  Returns the remaining size of the storage space\r
+                                                  available for the EFI variables associated with the\r
+                                                  attributes specified.\r
+  @param[out]       MaximumVariableSize           Returns the maximum size of the individual EFI\r
+                                                  variables associated with the attributes specified.\r
+\r
+  @retval EFI_SUCCESS                             Valid answer returned.\r
+  @retval EFI_INVALID_PARAMETER                   An invalid combination of attribute bits was supplied\r
+  @retval EFI_UNSUPPORTED                         The attribute is not supported on this platform, and the\r
+                                                  MaximumVariableStorageSize,\r
+                                                  RemainingVariableStorageSize, MaximumVariableSize\r
+                                                  are undefined.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EDKII_PEI_QUERY_VARIABLE_INFO)(\r
+  IN CONST  EDKII_PEI_VARIABLE_PPI    *This,\r
+  IN        UINT32                    Attributes,\r
+  OUT       UINT64                    *MaximumVariableStorageSize,\r
+  OUT       UINT64                    *RemainingVariableStorageSize,\r
+  OUT       UINT64                    *MaximumVariableSize\r
+  );\r
+\r
+///\r
+/// PEI Variable PPI is intended for use as a means\r
+/// to store data in the PEI environment.\r
+///\r
+struct _EDKII_PEI_VARIABLE_PPI {\r
+  EDKII_PEI_GET_VARIABLE            GetVariable;\r
+  EDKII_PEI_GET_NEXT_VARIABLE_NAME  GetNextVariableName;\r
+  EDKII_PEI_SET_VARIABLE            SetVariable;\r
+  EDKII_PEI_QUERY_VARIABLE_INFO     QueryVariableInfo;\r
+};\r
+\r
+extern EFI_GUID  gEdkiiPeiVariablePpiGuid;\r
+\r
+#endif\r