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