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