]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Variable/Pei/Variable.h
MdeModulePkg/Variable: Consume Variable Flash Info
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / Pei / Variable.h
CommitLineData
504214c4 1/** @file\r
504214c4
LG
2 The internal header file includes the common header files, defines\r
3 internal structure and functions used by PeiVariable module.\r
4\r
9977995e 5Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
8d3a5c82 7\r
504214c4 8**/\r
8d3a5c82 9\r
33479ddf 10#ifndef _PEI_VARIABLE_H_\r
11#define _PEI_VARIABLE_H_\r
8d3a5c82 12\r
13#include <PiPei.h>\r
14#include <Ppi/ReadOnlyVariable2.h>\r
33479ddf 15\r
8d3a5c82 16#include <Library/DebugLib.h>\r
17#include <Library/PeimEntryPoint.h>\r
18#include <Library/HobLib.h>\r
19#include <Library/PcdLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
21#include <Library/PeiServicesTablePointerLib.h>\r
33479ddf 22#include <Library/PeiServicesLib.h>\r
4dbebc2d
MK
23#include <Library/SafeIntLib.h>\r
24#include <Library/VariableFlashInfoLib.h>\r
33479ddf 25\r
3709c4cd 26#include <Guid/VariableFormat.h>\r
9725730b 27#include <Guid/VariableIndexTable.h>\r
d6550260 28#include <Guid/SystemNvDataGuid.h>\r
3e02ebb2 29#include <Guid/FaultTolerantWrite.h>\r
0f7aff72
RN
30\r
31typedef enum {\r
32 VariableStoreTypeHob,\r
33 VariableStoreTypeNv,\r
34 VariableStoreTypeMax\r
35} VARIABLE_STORE_TYPE;\r
36\r
3e02ebb2
SZ
37typedef struct {\r
38 VARIABLE_STORE_HEADER *VariableStoreHeader;\r
39 VARIABLE_INDEX_TABLE *IndexTable;\r
40 //\r
41 // If it is not NULL, it means there may be an inconsecutive variable whose\r
42 // partial content is still in NV storage, but another partial content is backed up\r
43 // in spare block.\r
44 //\r
45 FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *FtwLastWriteData;\r
77ba12cc 46 BOOLEAN AuthFlag;\r
3e02ebb2
SZ
47} VARIABLE_STORE_INFO;\r
48\r
8d3a5c82 49//\r
50// Functions\r
51//\r
1436aea4 52\r
33479ddf 53/**\r
54 Provide the functionality of the variable services.\r
77ba12cc
SZ
55\r
56 @param FileHandle Handle of the file being invoked.\r
33479ddf 57 Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().\r
58 @param PeiServices General purpose services available to every PEIM.\r
59\r
60 @retval EFI_SUCCESS If the interface could be successfully installed\r
61 @retval Others Returned from PeiServicesInstallPpi()\r
62\r
63**/\r
8d3a5c82 64EFI_STATUS\r
65EFIAPI\r
66PeimInitializeVariableServices (\r
1436aea4
MK
67 IN EFI_PEI_FILE_HANDLE FileHandle,\r
68 IN CONST EFI_PEI_SERVICES **PeiServices\r
33479ddf 69 );\r
8d3a5c82 70\r
33479ddf 71/**\r
72 This service retrieves a variable's value using its name and GUID.\r
73\r
77ba12cc 74 Read the specified variable from the UEFI variable store. If the Data\r
33479ddf 75 buffer is too small to hold the contents of the variable, the error\r
76 EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer\r
77 size to obtain the data.\r
78\r
79 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
80 @param VariableName A pointer to a null-terminated string that is the variable's name.\r
81 @param VariableGuid A pointer to an EFI_GUID that is the variable's GUID. The combination of\r
82 VariableGuid and VariableName must be unique.\r
83 @param Attributes If non-NULL, on return, points to the variable's attributes.\r
84 @param DataSize On entry, points to the size in bytes of the Data buffer.\r
85 On return, points to the size of the data returned in Data.\r
86 @param Data Points to the buffer which will hold the returned variable value.\r
9977995e 87 May be NULL with a zero DataSize in order to determine the size of the buffer needed.\r
33479ddf 88\r
89 @retval EFI_SUCCESS The variable was read successfully.\r
9977995e 90 @retval EFI_NOT_FOUND The variable was not found.\r
77ba12cc
SZ
91 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the resulting data.\r
92 DataSize is updated with the size required for\r
33479ddf 93 the specified variable.\r
94 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.\r
95 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.\r
8d3a5c82 96\r
33479ddf 97**/\r
8d3a5c82 98EFI_STATUS\r
99EFIAPI\r
100PeiGetVariable (\r
1436aea4
MK
101 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
102 IN CONST CHAR16 *VariableName,\r
103 IN CONST EFI_GUID *VariableGuid,\r
104 OUT UINT32 *Attributes,\r
105 IN OUT UINTN *DataSize,\r
106 OUT VOID *Data OPTIONAL\r
33479ddf 107 );\r
8d3a5c82 108\r
33479ddf 109/**\r
110 Return the next variable name and GUID.\r
8d3a5c82 111\r
77ba12cc
SZ
112 This function is called multiple times to retrieve the VariableName\r
113 and VariableGuid of all variables currently available in the system.\r
114 On each call, the previous results are passed into the interface,\r
115 and, on return, the interface returns the data for the next\r
116 interface. When the entire variable list has been returned,\r
33479ddf 117 EFI_NOT_FOUND is returned.\r
8d3a5c82 118\r
33479ddf 119 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
8d3a5c82 120\r
33479ddf 121 @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.\r
122 @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.\r
123 On return, points to the next variable's null-terminated name string.\r
8d3a5c82 124\r
77ba12cc 125 @param VariableGuid On entry, a pointer to an UEFI _GUID that is the variable's GUID.\r
33479ddf 126 On return, a pointer to the next variable's GUID.\r
8d3a5c82 127\r
33479ddf 128 @retval EFI_SUCCESS The variable was read successfully.\r
129 @retval EFI_NOT_FOUND The variable could not be found.\r
130 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the resulting\r
131 data. VariableNameSize is updated with the size\r
132 required for the specified variable.\r
133 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid or\r
134 VariableNameSize is NULL.\r
135 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.\r
8d3a5c82 136\r
33479ddf 137**/\r
8d3a5c82 138EFI_STATUS\r
139EFIAPI\r
140PeiGetNextVariableName (\r
1436aea4
MK
141 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
142 IN OUT UINTN *VariableNameSize,\r
143 IN OUT CHAR16 *VariableName,\r
144 IN OUT EFI_GUID *VariableGuid\r
33479ddf 145 );\r
8d3a5c82 146\r
33479ddf 147#endif\r