]>
Commit | Line | Data |
---|---|---|
9071550e | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006 - 2007, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | FSVariable.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | --*/\r | |
19 | \r | |
20 | #ifndef _FS_VARIABLE_H\r | |
21 | #define _FS_VARIABLE_H\r | |
22 | \r | |
23 | //\r | |
24 | // Statements that include other header files\r | |
25 | //\r | |
26 | #include <PiDxe.h>\r | |
27 | \r | |
28 | #include <Library/BaseLib.h>\r | |
29 | #include <Library/PcdLib.h>\r | |
30 | #include <Library/BaseMemoryLib.h>\r | |
31 | #include <Library/UefiBootServicesTableLib.h>\r | |
32 | #include <Library/UefiRuntimeLib.h>\r | |
33 | #include <Library/DebugLib.h>\r | |
34 | #include <Library/UefiLib.h>\r | |
35 | #include <Library/HobLib.h>\r | |
36 | #include <Library/DxeServicesTableLib.h>\r | |
37 | #include <Library/DevicePathLib.h>\r | |
38 | \r | |
39 | #include <Guid/HobList.h>\r | |
40 | #include <Guid/FlashMapHob.h>\r | |
41 | \r | |
42 | #include <Protocol/Variable.h>\r | |
43 | #include <Protocol/VariableWrite.h>\r | |
44 | #include <Protocol/SimpleFileSystem.h>\r | |
45 | #include <Protocol/BlockIo.h>\r | |
46 | \r | |
47 | \r | |
48 | #include "EfiFlashMap.h"\r | |
49 | #include "VariableFormat.h"\r | |
50 | #include "VariableStorage.h"\r | |
51 | \r | |
52 | #define VOLATILE_VARIABLE_STORE_SIZE (64 * 1024)\r | |
53 | #define VARIABLE_SCRATCH_SIZE (4 * 1024)\r | |
54 | #define VARIABLE_RECLAIM_THRESHOLD (1024)\r | |
55 | \r | |
56 | //\r | |
57 | // Define GET_PAD_SIZE to optimize compiler\r | |
58 | //\r | |
59 | #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))\r | |
60 | #define GET_PAD_SIZE(a) (0)\r | |
61 | #else\r | |
62 | #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))\r | |
63 | #endif\r | |
64 | \r | |
65 | #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))\r | |
66 | \r | |
67 | typedef enum {\r | |
68 | Physical,\r | |
69 | Virtual\r | |
70 | } VARIABLE_POINTER_TYPE;\r | |
71 | \r | |
72 | typedef enum {\r | |
73 | NonVolatile,\r | |
74 | Volatile,\r | |
75 | MaxType\r | |
76 | } VARIABLE_STORAGE_TYPE;\r | |
77 | \r | |
78 | typedef struct {\r | |
79 | VARIABLE_HEADER *CurrPtr;\r | |
80 | VARIABLE_HEADER *EndPtr;\r | |
81 | VARIABLE_HEADER *StartPtr;\r | |
82 | VARIABLE_STORAGE_TYPE Type;\r | |
83 | } VARIABLE_POINTER_TRACK;\r | |
84 | \r | |
85 | #define VARIABLE_MEMBER_OFFSET(Member, StartOffset) \\r | |
86 | ( sizeof (VARIABLE_STORE_HEADER) + (StartOffset) + \\r | |
87 | (UINTN) ((UINT8 *) &((VARIABLE_HEADER*) 0)->Member - (UINT8 *) &((VARIABLE_HEADER*) 0)->StartId) \\r | |
88 | )\r | |
89 | \r | |
90 | \r | |
91 | typedef struct {\r | |
92 | EFI_EVENT_NOTIFY GoVirtualChildEvent[MaxType];\r | |
93 | VARIABLE_STORAGE *VariableStore[MaxType]; // Instance of VariableStorage\r | |
94 | VOID *VariableBase[MaxType]; // Start address of variable storage\r | |
95 | UINTN LastVariableOffset[MaxType]; // The position to write new variable to (index from VariableBase)\r | |
96 | VOID *Scratch; // Buffer used during reclaim\r | |
97 | } VARIABLE_GLOBAL;\r | |
98 | \r | |
99 | //\r | |
100 | // Functions\r | |
101 | //\r | |
102 | \r | |
103 | EFI_STATUS\r | |
104 | EFIAPI\r | |
105 | VariableServiceInitialize (\r | |
106 | IN EFI_HANDLE ImageHandle,\r | |
107 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
ed66e1bc | 108 | );\r |
9071550e | 109 | \r |
110 | VOID\r | |
111 | EFIAPI\r | |
112 | VariableClassAddressChangeEvent (\r | |
113 | IN EFI_EVENT Event,\r | |
114 | IN VOID *Context\r | |
ed66e1bc | 115 | );\r |
9071550e | 116 | \r |
117 | EFI_STATUS\r | |
118 | EFIAPI\r | |
119 | GetVariable (\r | |
120 | IN CHAR16 *VariableName,\r | |
121 | IN EFI_GUID *VendorGuid,\r | |
122 | OUT UINT32 *Attributes OPTIONAL,\r | |
123 | IN OUT UINTN *DataSize,\r | |
124 | OUT VOID *Data\r | |
ed66e1bc | 125 | );\r |
9071550e | 126 | \r |
127 | EFI_STATUS\r | |
128 | EFIAPI\r | |
129 | GetNextVariableName (\r | |
130 | IN OUT UINTN *VariableNameSize,\r | |
131 | IN OUT CHAR16 *VariableName,\r | |
132 | IN OUT EFI_GUID *VendorGuid\r | |
ed66e1bc | 133 | );\r |
9071550e | 134 | \r |
135 | EFI_STATUS\r | |
136 | EFIAPI\r | |
137 | SetVariable (\r | |
138 | IN CHAR16 *VariableName,\r | |
139 | IN EFI_GUID *VendorGuid,\r | |
140 | IN UINT32 Attributes,\r | |
141 | IN UINTN DataSize,\r | |
142 | IN VOID *Data\r | |
ed66e1bc | 143 | );\r |
9071550e | 144 | \r |
145 | #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r | |
146 | EFI_STATUS\r | |
147 | EFIAPI\r | |
148 | QueryVariableInfo (\r | |
149 | IN UINT32 Attributes,\r | |
150 | OUT UINT64 *MaximumVariableStorageSize,\r | |
151 | OUT UINT64 *RemainingVariableStorageSize,\r | |
152 | OUT UINT64 *MaximumVariableSize\r | |
ed66e1bc | 153 | );\r |
9071550e | 154 | #endif // EFI_SPECIFICATION_VERSION >= 0x00020000\r |
155 | \r | |
156 | #endif\r |