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