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