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