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