1 /*++ @file 2 Firmware volume block driver for Intel Firmware Hub (FWH) device 3 4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR> 5 Portions copyright (c) 2011, Apple Inc. All rights reserved. 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 **/ 15 16 #ifndef _FW_BLOCK_SERVICE_H 17 #define _FW_BLOCK_SERVICE_H 18 19 // 20 // BugBug: Add documentation here for data structure!!!! 21 // 22 #define FVB_PHYSICAL 0 23 #define FVB_VIRTUAL 1 24 25 typedef struct { 26 EFI_LOCK FvbDevLock; 27 UINTN FvBase[2]; 28 UINTN NumOfBlocks; 29 EFI_FIRMWARE_VOLUME_HEADER VolumeHeader; 30 } EFI_FW_VOL_INSTANCE; 31 32 typedef struct { 33 UINT32 NumFv; 34 EFI_FW_VOL_INSTANCE *FvInstance[2]; 35 } ESAL_FWB_GLOBAL; 36 37 // 38 // Fvb Protocol instance data 39 // 40 #define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE) 41 #define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE) 42 #define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N') 43 44 typedef struct { 45 MEMMAP_DEVICE_PATH MemMapDevPath; 46 EFI_DEVICE_PATH_PROTOCOL EndDevPath; 47 } FV_DEVICE_PATH; 48 49 typedef struct { 50 UINTN Signature; 51 FV_DEVICE_PATH DevicePath; 52 UINTN Instance; 53 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; 54 } EFI_FW_VOL_BLOCK_DEVICE; 55 56 EFI_STATUS 57 GetFvbInfo ( 58 IN UINT64 FvLength, 59 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo 60 ) 61 ; 62 63 EFI_STATUS 64 FvbReadBlock ( 65 IN UINTN Instance, 66 IN EFI_LBA Lba, 67 IN UINTN BlockOffset, 68 IN OUT UINTN *NumBytes, 69 IN UINT8 *Buffer, 70 IN ESAL_FWB_GLOBAL *Global, 71 IN BOOLEAN Virtual 72 ) 73 ; 74 75 EFI_STATUS 76 FvbWriteBlock ( 77 IN UINTN Instance, 78 IN EFI_LBA Lba, 79 IN UINTN BlockOffset, 80 IN OUT UINTN *NumBytes, 81 IN UINT8 *Buffer, 82 IN ESAL_FWB_GLOBAL *Global, 83 IN BOOLEAN Virtual 84 ) 85 ; 86 87 EFI_STATUS 88 FvbEraseBlock ( 89 IN UINTN Instance, 90 IN EFI_LBA Lba, 91 IN ESAL_FWB_GLOBAL *Global, 92 IN BOOLEAN Virtual 93 ) 94 ; 95 96 EFI_STATUS 97 FvbSetVolumeAttributes ( 98 IN UINTN Instance, 99 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes, 100 IN ESAL_FWB_GLOBAL *Global, 101 IN BOOLEAN Virtual 102 ) 103 ; 104 105 EFI_STATUS 106 FvbGetVolumeAttributes ( 107 IN UINTN Instance, 108 OUT EFI_FVB_ATTRIBUTES_2 *Attributes, 109 IN ESAL_FWB_GLOBAL *Global, 110 IN BOOLEAN Virtual 111 ) 112 ; 113 114 EFI_STATUS 115 FvbGetPhysicalAddress ( 116 IN UINTN Instance, 117 OUT EFI_PHYSICAL_ADDRESS *Address, 118 IN ESAL_FWB_GLOBAL *Global, 119 IN BOOLEAN Virtual 120 ) 121 ; 122 123 EFI_STATUS 124 EFIAPI 125 FvbInitialize ( 126 IN EFI_HANDLE ImageHandle, 127 IN EFI_SYSTEM_TABLE *SystemTable 128 ) 129 ; 130 131 132 VOID 133 EFIAPI 134 FvbClassAddressChangeEvent ( 135 IN EFI_EVENT Event, 136 IN VOID *Context 137 ) 138 ; 139 140 EFI_STATUS 141 FvbGetLbaAddress ( 142 IN UINTN Instance, 143 IN EFI_LBA Lba, 144 OUT UINTN *LbaAddress, 145 OUT UINTN *LbaLength, 146 OUT UINTN *NumOfBlocks, 147 IN ESAL_FWB_GLOBAL *Global, 148 IN BOOLEAN Virtual 149 ) 150 ; 151 152 // 153 // Protocol APIs 154 // 155 EFI_STATUS 156 EFIAPI 157 FvbProtocolGetAttributes ( 158 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 159 OUT EFI_FVB_ATTRIBUTES_2 *Attributes 160 ) 161 ; 162 163 EFI_STATUS 164 EFIAPI 165 FvbProtocolSetAttributes ( 166 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 167 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes 168 ) 169 ; 170 171 EFI_STATUS 172 EFIAPI 173 FvbProtocolGetPhysicalAddress ( 174 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 175 OUT EFI_PHYSICAL_ADDRESS *Address 176 ) 177 ; 178 179 EFI_STATUS 180 EFIAPI 181 FvbProtocolGetBlockSize ( 182 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 183 IN EFI_LBA Lba, 184 OUT UINTN *BlockSize, 185 OUT UINTN *NumOfBlocks 186 ) 187 ; 188 189 EFI_STATUS 190 EFIAPI 191 FvbProtocolRead ( 192 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 193 IN EFI_LBA Lba, 194 IN UINTN Offset, 195 IN OUT UINTN *NumBytes, 196 IN UINT8 *Buffer 197 ) 198 ; 199 200 EFI_STATUS 201 EFIAPI 202 FvbProtocolWrite ( 203 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 204 IN EFI_LBA Lba, 205 IN UINTN Offset, 206 IN OUT UINTN *NumBytes, 207 IN UINT8 *Buffer 208 ) 209 ; 210 211 EFI_STATUS 212 EFIAPI 213 FvbProtocolEraseBlocks ( 214 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 215 ... 216 ) 217 ; 218 219 #endif 220