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