1 /*++ 2 3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> 4 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 // Fvb Protocol instance data 27 // 28 #define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE) 29 #define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N') 30 31 #pragma pack (1) 32 33 typedef struct { 34 35 EFI_FIRMWARE_VOLUME_HEADER FvHdr; 36 EFI_FV_BLOCK_MAP_ENTRY EndBlockMap; 37 VARIABLE_STORE_HEADER VarHdr; 38 39 } FVB_FV_HDR_AND_VARS_TEMPLATE; 40 41 typedef struct { 42 MEMMAP_DEVICE_PATH MemMapDevPath; 43 EFI_DEVICE_PATH_PROTOCOL EndDevPath; 44 } FV_DEVICE_PATH; 45 46 #pragma pack () 47 48 typedef struct { 49 UINTN Signature; 50 FV_DEVICE_PATH DevicePath; 51 VOID *BufferPtr; 52 UINTN BlockSize; 53 UINTN Size; 54 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; 55 } EFI_FW_VOL_BLOCK_DEVICE; 56 57 58 // 59 // Constants 60 // 61 #define EMU_FVB_BLOCK_SIZE (FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) 62 #define EMU_FVB_SIZE (2 * FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) 63 #define FTW_WRITE_QUEUE_SIZE \ 64 (FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) - \ 65 sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER)) 66 #define EMU_FV_HEADER_LENGTH OFFSET_OF (FVB_FV_HDR_AND_VARS_TEMPLATE, VarHdr) 67 68 #define NOT_ERASED_BIT 0 69 #define ERASED_BIT 1 70 #define ERASED_UINT8 0xff 71 #define ERASED_UINT32 0xffffffff 72 73 // 74 // Protocol APIs 75 // 76 EFI_STATUS 77 EFIAPI 78 FvbProtocolGetAttributes ( 79 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 80 OUT EFI_FVB_ATTRIBUTES_2 *Attributes 81 ) 82 ; 83 84 EFI_STATUS 85 EFIAPI 86 FvbProtocolSetAttributes ( 87 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 88 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes 89 ) 90 ; 91 92 EFI_STATUS 93 EFIAPI 94 FvbProtocolGetPhysicalAddress ( 95 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 96 OUT EFI_PHYSICAL_ADDRESS *Address 97 ) 98 ; 99 100 EFI_STATUS 101 EFIAPI 102 FvbProtocolGetBlockSize ( 103 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 104 IN EFI_LBA Lba, 105 OUT UINTN *BlockSize, 106 OUT UINTN *NumberOfBlocks 107 ) 108 ; 109 110 EFI_STATUS 111 EFIAPI 112 FvbProtocolRead ( 113 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 114 IN EFI_LBA Lba, 115 IN UINTN Offset, 116 IN OUT UINTN *NumBytes, 117 IN OUT UINT8 *Buffer 118 ) 119 ; 120 121 EFI_STATUS 122 EFIAPI 123 FvbProtocolWrite ( 124 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 125 IN EFI_LBA Lba, 126 IN UINTN Offset, 127 IN OUT UINTN *NumBytes, 128 IN UINT8 *Buffer 129 ) 130 ; 131 132 EFI_STATUS 133 EFIAPI 134 FvbProtocolEraseBlocks ( 135 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, 136 ... 137 ) 138 ; 139 140 #endif 141