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