]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/FvbRuntimeService/FwBlockService.h
clean up the un-suitable ';' location when declaring the functions.
[mirror_edk2.git] / DuetPkg / FvbRuntimeService / FwBlockService.h
1 /**@file
2 Copyright (c) 2007, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 Module Name:
12
13 FwBlockService.h
14
15 Abstract:
16
17 Firmware volume block driver for Intel Firmware Hub (FWH) device
18
19 **/
20 #ifndef _FW_BLOCK_SERVICE_H
21 #define _FW_BLOCK_SERVICE_H
22
23 //
24 // The package level header files this module uses
25 //
26 #include <PiDxe.h>
27
28 //
29 // The protocols, PPI and GUID defintions for this module
30 //
31 #include <Guid/EventGroup.h>
32 #include <Guid/FirmwareFileSystem2.h>
33 #include <Protocol/FvbExtension.h>
34 #include <Protocol/FirmwareVolumeBlock.h>
35 #include <Guid/AlternateFvBlock.h>
36 #include <Protocol/DevicePath.h>
37 #include <Protocol/SimpleFileSystem.h>
38 #include <Protocol/BlockIo.h>
39 #include <Library/DevicePathLib.h>
40 #include <Guid/SystemNvDataGuid.h>
41 #include <Guid/FlashMapHob.h>
42 #include <Guid/HobList.h>
43 #include <Guid/AlternateFvBlock.h>
44 #include <Protocol/FvbExtension.h>
45
46 //
47 // The Library classes this module consumes
48 //
49 #include <Library/UefiLib.h>
50 #include <Library/UefiDriverEntryPoint.h>
51 #include <Library/BaseLib.h>
52 #include <Library/DxeServicesTableLib.h>
53 #include <Library/UefiRuntimeLib.h>
54 #include <Library/DebugLib.h>
55 #include <Library/HobLib.h>
56 #include <Library/BaseMemoryLib.h>
57 #include <Library/MemoryAllocationLib.h>
58 #include <Library/UefiBootServicesTableLib.h>
59 #include <Library/PcdLib.h>
60
61
62 #define FWH_READ_LOCK (1 << 2)
63 #define FWH_LOCK_DOWN (1 << 1)
64 #define FWH_WRITE_LOCK 1
65 #define FWH_WRITE_STATE_STATUS (1 << 7)
66 #define FWH_ERASE_STATUS (1 << 5)
67 #define FWH_PROGRAM_STATUS (1 << 4)
68 #define FWH_VPP_STATUS (1 << 3)
69 #define STALL_TIME 5
70 #define FWH_ERASE_STATUS_BITS (FWH_ERASE_STATUS || FWH_VPP_STATUS)
71 #define FWH_WRITE_STATUS_BITS (FWH_WRITE_STATUS || FWH_VPP_STATUS)
72
73 //
74 // BugBug: Add documentation here for data structure!!!!
75 //
76 #define FVB_PHYSICAL 0
77 #define FVB_VIRTUAL 1
78
79 #define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP | \
80 EFI_FVB2_READ_ENABLED_CAP | \
81 EFI_FVB2_WRITE_DISABLED_CAP | \
82 EFI_FVB2_WRITE_ENABLED_CAP | \
83 EFI_FVB2_LOCK_CAP \
84 )
85 #define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
86
87 typedef struct {
88 EFI_LOCK FvbDevLock;
89 UINTN FvBase[2];
90 //
91 // We can treat VolumeSignature combined with MappedFile
92 // as a unique key to locate the mapped file.
93 #define MAX_PATH 256
94 UINT32 VolumeId;
95 CHAR16 MappedFile[MAX_PATH];
96 UINT32 ActuralSize;
97 UINT32 Offset;
98
99 EFI_DEVICE_PATH_PROTOCOL *Device; // only used in BS period, won't use after memory map changed
100 UINTN NumOfBlocks;
101 BOOLEAN WriteEnabled;
102 EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
103 } EFI_FW_VOL_INSTANCE;
104
105 typedef struct {
106 UINT32 NumFv;
107 EFI_FW_VOL_INSTANCE *FvInstance[2];
108 UINT8 *FvbScratchSpace[2];
109 } ESAL_FWB_GLOBAL;
110
111 //
112 // Fvb Protocol instance data
113 //
114 #define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
115 #define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)
116 #define FVB_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('F', 'V', 'B', 'C')
117
118 typedef struct {
119 MEMMAP_DEVICE_PATH MemMapDevPath;
120 EFI_DEVICE_PATH_PROTOCOL EndDevPath;
121 } FV_DEVICE_PATH;
122
123 typedef struct {
124 UINTN Signature;
125 FV_DEVICE_PATH DevicePath;
126 UINTN Instance;
127 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
128 EFI_FVB_EXTENSION_PROTOCOL FvbExtension;
129 } EFI_FW_VOL_BLOCK_DEVICE;
130
131 EFI_STATUS
132 GetFvbInfo (
133 IN EFI_PHYSICAL_ADDRESS FvBaseAddress,
134 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
135 );
136
137 EFI_STATUS
138 EnableFvbWrites (
139 IN BOOLEAN EnableWrites
140 );
141
142 EFI_STATUS
143 PlatformGetFvbWriteBase (
144 IN UINTN CurrentBaseAddress,
145 IN UINTN *NewBaseAddress,
146 IN BOOLEAN *WriteEnabled
147 );
148
149 EFI_STATUS
150 EnablePlatformFvb (
151 VOID
152 );
153
154 BOOLEAN
155 SetPlatformFvbLock (
156 IN UINTN LbaAddress
157 );
158
159 EFI_STATUS
160 FvbReadBlock (
161 IN UINTN Instance,
162 IN EFI_LBA Lba,
163 IN UINTN BlockOffset,
164 IN OUT UINTN *NumBytes,
165 IN UINT8 *Buffer,
166 IN ESAL_FWB_GLOBAL *Global,
167 IN BOOLEAN Virtual
168 );
169
170 EFI_STATUS
171 FvbWriteBlock (
172 IN UINTN Instance,
173 IN EFI_LBA Lba,
174 IN UINTN BlockOffset,
175 IN OUT UINTN *NumBytes,
176 IN UINT8 *Buffer,
177 IN ESAL_FWB_GLOBAL *Global,
178 IN BOOLEAN Virtual
179 );
180
181 EFI_STATUS
182 FvbEraseBlock (
183 IN UINTN Instance,
184 IN EFI_LBA Lba,
185 IN ESAL_FWB_GLOBAL *Global,
186 IN BOOLEAN Virtual
187 );
188
189 EFI_STATUS
190 FvbSetVolumeAttributes (
191 IN UINTN Instance,
192 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
193 IN ESAL_FWB_GLOBAL *Global,
194 IN BOOLEAN Virtual
195 );
196
197 EFI_STATUS
198 FvbGetVolumeAttributes (
199 IN UINTN Instance,
200 OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
201 IN ESAL_FWB_GLOBAL *Global,
202 IN BOOLEAN Virtual
203 );
204
205 EFI_STATUS
206 FvbGetPhysicalAddress (
207 IN UINTN Instance,
208 OUT EFI_PHYSICAL_ADDRESS *Address,
209 IN ESAL_FWB_GLOBAL *Global,
210 IN BOOLEAN Virtual
211 );
212
213 EFI_STATUS
214 EFIAPI
215 FvbInitialize (
216 IN EFI_HANDLE ImageHandle,
217 IN EFI_SYSTEM_TABLE *SystemTable
218 );
219
220 VOID
221 EFIAPI
222 FvbClassAddressChangeEvent (
223 IN EFI_EVENT Event,
224 IN VOID *Context
225 );
226
227 EFI_STATUS
228 FvbSpecificInitialize (
229 IN ESAL_FWB_GLOBAL *mFvbModuleGlobal
230 );
231
232 EFI_STATUS
233 FvbGetLbaAddress (
234 IN UINTN Instance,
235 IN EFI_LBA Lba,
236 OUT UINTN *LbaAddress,
237 OUT UINTN *LbaLength,
238 OUT UINTN *NumOfBlocks,
239 IN ESAL_FWB_GLOBAL *Global,
240 IN BOOLEAN Virtual
241 );
242
243 EFI_STATUS
244 FvbEraseCustomBlockRange (
245 IN UINTN Instance,
246 IN EFI_LBA StartLba,
247 IN UINTN OffsetStartLba,
248 IN EFI_LBA LastLba,
249 IN UINTN OffsetLastLba,
250 IN ESAL_FWB_GLOBAL *Global,
251 IN BOOLEAN Virtual
252 );
253
254 //
255 // Protocol APIs
256 //
257 EFI_STATUS
258 EFIAPI
259 FvbProtocolGetAttributes (
260 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
261 OUT EFI_FVB_ATTRIBUTES_2 *Attributes
262 );
263
264 EFI_STATUS
265 EFIAPI
266 FvbProtocolSetAttributes (
267 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
268 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
269 );
270
271 EFI_STATUS
272 EFIAPI
273 FvbProtocolGetPhysicalAddress (
274 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
275 OUT EFI_PHYSICAL_ADDRESS *Address
276 );
277
278 EFI_STATUS
279 EFIAPI
280 FvbProtocolGetBlockSize (
281 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
282 IN EFI_LBA Lba,
283 OUT UINTN *BlockSize,
284 OUT UINTN *NumOfBlocks
285 );
286
287 EFI_STATUS
288 EFIAPI
289 FvbProtocolRead (
290 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
291 IN EFI_LBA Lba,
292 IN UINTN Offset,
293 IN OUT UINTN *NumBytes,
294 IN UINT8 *Buffer
295 );
296
297 EFI_STATUS
298 EFIAPI
299 FvbProtocolWrite (
300 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
301 IN EFI_LBA Lba,
302 IN UINTN Offset,
303 IN OUT UINTN *NumBytes,
304 IN UINT8 *Buffer
305 );
306
307 EFI_STATUS
308 EFIAPI
309 FvbProtocolEraseBlocks (
310 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
311 ...
312 );
313
314 EFI_STATUS
315 EFIAPI
316 FvbExtendProtocolEraseCustomBlockRange (
317 IN EFI_FVB_EXTENSION_PROTOCOL *This,
318 IN EFI_LBA StartLba,
319 IN UINTN OffsetStartLba,
320 IN EFI_LBA LastLba,
321 IN UINTN OffsetLastLba
322 );
323
324 #endif