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