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