]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/Pei/Variable.h
1. delete Include/Guid/VariableInfo.h
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / Pei / Variable.h
1 /** @file
2
3 The internal header file includes the common header files, defines
4 internal structure and functions used by PeiVariable module.
5
6 Copyright (c) 2006 - 2008, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef _PEI_VARIABLE_H_
18 #define _PEI_VARIABLE_H_
19
20 #include <PiPei.h>
21 #include <Ppi/ReadOnlyVariable2.h>
22
23 #include <Library/DebugLib.h>
24 #include <Library/PeimEntryPoint.h>
25 #include <Library/HobLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/PeiServicesTablePointerLib.h>
29 #include <Library/PeiServicesLib.h>
30
31 #include <Guid/VariableFormat.h>
32
33 typedef struct {
34 VARIABLE_HEADER *CurrPtr;
35 VARIABLE_HEADER *EndPtr;
36 VARIABLE_HEADER *StartPtr;
37 } VARIABLE_POINTER_TRACK;
38
39 #define VARIABLE_INDEX_TABLE_VOLUME 122
40
41 #define EFI_VARIABLE_INDEX_TABLE_GUID \
42 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }
43
44 typedef struct {
45 UINT16 Length;
46 UINT16 GoneThrough;
47 VARIABLE_HEADER *EndPtr;
48 VARIABLE_HEADER *StartPtr;
49 UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];
50 } VARIABLE_INDEX_TABLE;
51
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
91 @retval EFI_SUCCESS The variable was read successfully.
92 @retval EFI_NOT_FOUND The variable could not be found.
93 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the resulting data.
94 DataSize is updated with the size required for
95 the specified variable.
96 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.
97 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.
98
99 **/
100 EFI_STATUS
101 EFIAPI
102 PeiGetVariable (
103 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
104 IN CONST CHAR16 *VariableName,
105 IN CONST EFI_GUID *VariableGuid,
106 OUT UINT32 *Attributes,
107 IN OUT UINTN *DataSize,
108 OUT VOID *Data
109 );
110
111 /**
112 Return the next variable name and GUID.
113
114 This function is called multiple times to retrieve the VariableName
115 and VariableGuid of all variables currently available in the system.
116 On each call, the previous results are passed into the interface,
117 and, on return, the interface returns the data for the next
118 interface. When the entire variable list has been returned,
119 EFI_NOT_FOUND is returned.
120
121 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.
122
123 @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.
124 @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.
125 On return, points to the next variable's null-terminated name string.
126
127 @param VariableGuid On entry, a pointer to an UEFI _GUID that is the variable's GUID.
128 On return, a pointer to the next variable's GUID.
129
130 @retval EFI_SUCCESS The variable was read successfully.
131 @retval EFI_NOT_FOUND The variable could not be found.
132 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the resulting
133 data. VariableNameSize is updated with the size
134 required for the specified variable.
135 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid or
136 VariableNameSize is NULL.
137 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.
138
139 **/
140 EFI_STATUS
141 EFIAPI
142 PeiGetNextVariableName (
143 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
144 IN OUT UINTN *VariableNameSize,
145 IN OUT CHAR16 *VariableName,
146 IN OUT EFI_GUID *VariableGuid
147 );
148
149 /**
150 Get one variable by the index count.
151
152 @param IndexTable The pointer to variable index table.
153 @param Count The index count of variable in index table.
154
155 @return The pointer to variable header indexed by count.
156
157 **/
158 VARIABLE_HEADER *
159 GetVariableByIndex (
160 IN VARIABLE_INDEX_TABLE *IndexTable,
161 IN UINT32 Count
162 );
163
164 /**
165 Record Variable in VariableIndex HOB.
166
167 Record Variable in VariableIndex HOB and update the length of variable index table.
168
169 @param IndexTable The pointer to variable index table.
170 @param Variable The pointer to the variable that will be recorded.
171
172 **/
173 VOID
174 VariableIndexTableUpdate (
175 IN OUT VARIABLE_INDEX_TABLE *IndexTable,
176 IN VARIABLE_HEADER *Variable
177 );
178
179 #endif