]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/FvbRuntimeService/FwBlockService.h
Add missing module for duet package.
[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
138 EFI_STATUS
139 EnableFvbWrites (
140 IN BOOLEAN EnableWrites
141 )
142 ;
143
144 EFI_STATUS
145 PlatformGetFvbWriteBase (
146 IN UINTN CurrentBaseAddress,
147 IN UINTN *NewBaseAddress,
148 IN BOOLEAN *WriteEnabled
149 )
150 ;
151
152 EFI_STATUS
153 EnablePlatformFvb (
154 VOID
155 )
156 ;
157
158 BOOLEAN
159 SetPlatformFvbLock (
160 IN UINTN LbaAddress
161 )
162 ;
163
164 EFI_STATUS
165 FvbReadBlock (
166 IN UINTN Instance,
167 IN EFI_LBA Lba,
168 IN UINTN BlockOffset,
169 IN OUT UINTN *NumBytes,
170 IN UINT8 *Buffer,
171 IN ESAL_FWB_GLOBAL *Global,
172 IN BOOLEAN Virtual
173 )
174 ;
175
176 EFI_STATUS
177 FvbWriteBlock (
178 IN UINTN Instance,
179 IN EFI_LBA Lba,
180 IN UINTN BlockOffset,
181 IN OUT UINTN *NumBytes,
182 IN UINT8 *Buffer,
183 IN ESAL_FWB_GLOBAL *Global,
184 IN BOOLEAN Virtual
185 )
186 ;
187
188 EFI_STATUS
189 FvbEraseBlock (
190 IN UINTN Instance,
191 IN EFI_LBA Lba,
192 IN ESAL_FWB_GLOBAL *Global,
193 IN BOOLEAN Virtual
194 )
195 ;
196
197 EFI_STATUS
198 FvbSetVolumeAttributes (
199 IN UINTN Instance,
200 IN OUT EFI_FVB_ATTRIBUTES *Attributes,
201 IN ESAL_FWB_GLOBAL *Global,
202 IN BOOLEAN Virtual
203 )
204 ;
205
206 EFI_STATUS
207 FvbGetVolumeAttributes (
208 IN UINTN Instance,
209 OUT EFI_FVB_ATTRIBUTES *Attributes,
210 IN ESAL_FWB_GLOBAL *Global,
211 IN BOOLEAN Virtual
212 )
213 ;
214
215 EFI_STATUS
216 FvbGetPhysicalAddress (
217 IN UINTN Instance,
218 OUT EFI_PHYSICAL_ADDRESS *Address,
219 IN ESAL_FWB_GLOBAL *Global,
220 IN BOOLEAN Virtual
221 )
222 ;
223
224 EFI_STATUS
225 EFIAPI
226 FvbInitialize (
227 IN EFI_HANDLE ImageHandle,
228 IN EFI_SYSTEM_TABLE *SystemTable
229 )
230 ;
231
232 VOID
233 EFIAPI
234 FvbClassAddressChangeEvent (
235 IN EFI_EVENT Event,
236 IN VOID *Context
237 )
238 ;
239
240 EFI_STATUS
241 FvbSpecificInitialize (
242 IN ESAL_FWB_GLOBAL *mFvbModuleGlobal
243 )
244 ;
245
246 EFI_STATUS
247 FvbGetLbaAddress (
248 IN UINTN Instance,
249 IN EFI_LBA Lba,
250 OUT UINTN *LbaAddress,
251 OUT UINTN *LbaLength,
252 OUT UINTN *NumOfBlocks,
253 IN ESAL_FWB_GLOBAL *Global,
254 IN BOOLEAN Virtual
255 )
256 ;
257
258 EFI_STATUS
259 FvbEraseCustomBlockRange (
260 IN UINTN Instance,
261 IN EFI_LBA StartLba,
262 IN UINTN OffsetStartLba,
263 IN EFI_LBA LastLba,
264 IN UINTN OffsetLastLba,
265 IN ESAL_FWB_GLOBAL *Global,
266 IN BOOLEAN Virtual
267 )
268 ;
269
270 //
271 // Protocol APIs
272 //
273 EFI_STATUS
274 EFIAPI
275 FvbProtocolGetAttributes (
276 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
277 OUT EFI_FVB_ATTRIBUTES *Attributes
278 )
279 ;
280
281 EFI_STATUS
282 EFIAPI
283 FvbProtocolSetAttributes (
284 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
285 IN OUT EFI_FVB_ATTRIBUTES *Attributes
286 )
287 ;
288
289 EFI_STATUS
290 EFIAPI
291 FvbProtocolGetPhysicalAddress (
292 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
293 OUT EFI_PHYSICAL_ADDRESS *Address
294 )
295 ;
296
297 EFI_STATUS
298 EFIAPI
299 FvbProtocolGetBlockSize (
300 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
301 IN EFI_LBA Lba,
302 OUT UINTN *BlockSize,
303 OUT UINTN *NumOfBlocks
304 )
305 ;
306
307 EFI_STATUS
308 EFIAPI
309 FvbProtocolRead (
310 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
311 IN EFI_LBA Lba,
312 IN UINTN Offset,
313 IN OUT UINTN *NumBytes,
314 IN UINT8 *Buffer
315 )
316 ;
317
318 EFI_STATUS
319 EFIAPI
320 FvbProtocolWrite (
321 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
322 IN EFI_LBA Lba,
323 IN UINTN Offset,
324 IN OUT UINTN *NumBytes,
325 IN UINT8 *Buffer
326 )
327 ;
328
329 EFI_STATUS
330 EFIAPI
331 FvbProtocolEraseBlocks (
332 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
333 ...
334 )
335 ;
336
337 EFI_STATUS
338 EFIAPI
339 FvbExtendProtocolEraseCustomBlockRange (
340 IN EFI_FVB_EXTENSION_PROTOCOL *This,
341 IN EFI_LBA StartLba,
342 IN UINTN OffsetStartLba,
343 IN EFI_LBA LastLba,
344 IN UINTN OffsetLastLba
345 )
346 ;
347
348 #endif