]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Variable/Pei/Variable.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[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
33479ddf 50/**\r
51 Provide the functionality of the variable services.\r
77ba12cc
SZ
52\r
53 @param FileHandle Handle of the file being invoked.\r
33479ddf 54 Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().\r
55 @param PeiServices General purpose services available to every PEIM.\r
56\r
57 @retval EFI_SUCCESS If the interface could be successfully installed\r
58 @retval Others Returned from PeiServicesInstallPpi()\r
59\r
60**/\r
8d3a5c82 61EFI_STATUS\r
62EFIAPI\r
63PeimInitializeVariableServices (\r
33479ddf 64 IN EFI_PEI_FILE_HANDLE FileHandle,\r
65 IN CONST EFI_PEI_SERVICES **PeiServices\r
66 );\r
8d3a5c82 67\r
33479ddf 68/**\r
69 This service retrieves a variable's value using its name and GUID.\r
70\r
77ba12cc 71 Read the specified variable from the UEFI variable store. If the Data\r
33479ddf 72 buffer is too small to hold the contents of the variable, the error\r
73 EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer\r
74 size to obtain the data.\r
75\r
76 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
77 @param VariableName A pointer to a null-terminated string that is the variable's name.\r
78 @param VariableGuid A pointer to an EFI_GUID that is the variable's GUID. The combination of\r
79 VariableGuid and VariableName must be unique.\r
80 @param Attributes If non-NULL, on return, points to the variable's attributes.\r
81 @param DataSize On entry, points to the size in bytes of the Data buffer.\r
82 On return, points to the size of the data returned in Data.\r
83 @param Data Points to the buffer which will hold the returned variable value.\r
9977995e 84 May be NULL with a zero DataSize in order to determine the size of the buffer needed.\r
33479ddf 85\r
86 @retval EFI_SUCCESS The variable was read successfully.\r
9977995e 87 @retval EFI_NOT_FOUND The variable was not found.\r
77ba12cc
SZ
88 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the resulting data.\r
89 DataSize is updated with the size required for\r
33479ddf 90 the specified variable.\r
91 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.\r
92 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.\r
8d3a5c82 93\r
33479ddf 94**/\r
8d3a5c82 95EFI_STATUS\r
96EFIAPI\r
97PeiGetVariable (\r
98 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
99 IN CONST CHAR16 *VariableName,\r
100 IN CONST EFI_GUID *VariableGuid,\r
101 OUT UINT32 *Attributes,\r
102 IN OUT UINTN *DataSize,\r
9977995e 103 OUT VOID *Data OPTIONAL\r
33479ddf 104 );\r
8d3a5c82 105\r
33479ddf 106/**\r
107 Return the next variable name and GUID.\r
8d3a5c82 108\r
77ba12cc
SZ
109 This function is called multiple times to retrieve the VariableName\r
110 and VariableGuid of all variables currently available in the system.\r
111 On each call, the previous results are passed into the interface,\r
112 and, on return, the interface returns the data for the next\r
113 interface. When the entire variable list has been returned,\r
33479ddf 114 EFI_NOT_FOUND is returned.\r
8d3a5c82 115\r
33479ddf 116 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
8d3a5c82 117\r
33479ddf 118 @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.\r
119 @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.\r
120 On return, points to the next variable's null-terminated name string.\r
8d3a5c82 121\r
77ba12cc 122 @param VariableGuid On entry, a pointer to an UEFI _GUID that is the variable's GUID.\r
33479ddf 123 On return, a pointer to the next variable's GUID.\r
8d3a5c82 124\r
33479ddf 125 @retval EFI_SUCCESS The variable was read successfully.\r
126 @retval EFI_NOT_FOUND The variable could not be found.\r
127 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the resulting\r
128 data. VariableNameSize is updated with the size\r
129 required for the specified variable.\r
130 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid or\r
131 VariableNameSize is NULL.\r
132 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.\r
8d3a5c82 133\r
33479ddf 134**/\r
8d3a5c82 135EFI_STATUS\r
136EFIAPI\r
137PeiGetNextVariableName (\r
138 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
139 IN OUT UINTN *VariableNameSize,\r
140 IN OUT CHAR16 *VariableName,\r
141 IN OUT EFI_GUID *VariableGuid\r
33479ddf 142 );\r
8d3a5c82 143\r
33479ddf 144#endif\r