]>
Commit | Line | Data |
---|---|---|
23c98c94 | 1 | /** @file\r |
022c6d45 | 2 | Firmware Volume Block protocol functions.\r |
23c98c94 | 3 | Consumes FV hobs and creates appropriate block protocols.\r |
4 | \r | |
0c3a1db4 | 5 | Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
28a00297 | 7 | \r |
504214c4 | 8 | **/\r |
28a00297 | 9 | \r |
10 | #ifndef _FWVOL_BLOCK_H_\r | |
11 | #define _FWVOL_BLOCK_H_\r | |
12 | \r | |
13 | \r | |
f3f2e05d | 14 | #define FVB_DEVICE_SIGNATURE SIGNATURE_32('_','F','V','B')\r |
28a00297 | 15 | \r |
ec90508b | 16 | \r |
28a00297 | 17 | typedef struct {\r |
18 | UINTN Base;\r | |
19 | UINTN Length;\r | |
20 | } LBA_CACHE;\r | |
21 | \r | |
22 | typedef struct {\r | |
23 | MEMMAP_DEVICE_PATH MemMapDevPath;\r | |
24 | EFI_DEVICE_PATH_PROTOCOL EndDevPath;\r | |
84266565 | 25 | } FV_MEMMAP_DEVICE_PATH;\r |
28a00297 | 26 | \r |
84266565 | 27 | //\r |
28 | // UEFI Specification define FV device path format if FV provide name guid in extension header\r | |
29 | //\r | |
30 | typedef struct {\r | |
31 | MEDIA_FW_VOL_DEVICE_PATH FvDevPath;\r | |
32 | EFI_DEVICE_PATH_PROTOCOL EndDevPath;\r | |
33 | } FV_PIWG_DEVICE_PATH;\r | |
28a00297 | 34 | \r |
35 | typedef struct {\r | |
36 | UINTN Signature;\r | |
37 | EFI_HANDLE Handle;\r | |
84266565 | 38 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r |
28a00297 | 39 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;\r |
40 | UINTN NumBlocks;\r | |
41 | LBA_CACHE *LbaCache;\r | |
42 | UINT32 FvbAttributes;\r | |
43 | EFI_PHYSICAL_ADDRESS BaseAddress;\r | |
0c3a1db4 | 44 | UINT32 AuthenticationStatus;\r |
28a00297 | 45 | } EFI_FW_VOL_BLOCK_DEVICE;\r |
46 | \r | |
ec90508b | 47 | \r |
28a00297 | 48 | #define FVB_DEVICE_FROM_THIS(a) \\r |
49 | CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)\r | |
50 | \r | |
51 | \r | |
162ed594 | 52 | /**\r |
53 | Retrieves Volume attributes. No polarity translations are done.\r | |
54 | \r | |
022c6d45 | 55 | @param This Calling context\r |
56 | @param Attributes output buffer which contains attributes\r | |
162ed594 | 57 | \r |
58 | @retval EFI_SUCCESS The firmware volume attributes were returned.\r | |
59 | \r | |
60 | **/\r | |
28a00297 | 61 | EFI_STATUS\r |
62 | EFIAPI\r | |
63 | FwVolBlockGetAttributes (\r | |
64 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
8ee3a199 | 65 | OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r |
23c98c94 | 66 | );\r |
28a00297 | 67 | \r |
28a00297 | 68 | \r |
28a00297 | 69 | \r |
162ed594 | 70 | /**\r |
71 | Modifies the current settings of the firmware volume according to the input parameter.\r | |
28a00297 | 72 | \r |
022c6d45 | 73 | @param This Calling context\r |
74 | @param Attributes input buffer which contains attributes\r | |
28a00297 | 75 | \r |
022c6d45 | 76 | @retval EFI_SUCCESS The firmware volume attributes were returned.\r |
77 | @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with\r | |
78 | the capabilities as declared in the firmware\r | |
79 | volume header.\r | |
162ed594 | 80 | @retval EFI_UNSUPPORTED Not supported.\r |
28a00297 | 81 | \r |
162ed594 | 82 | **/\r |
28a00297 | 83 | EFI_STATUS\r |
84 | EFIAPI\r | |
85 | FwVolBlockSetAttributes (\r | |
86 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
8ee3a199 | 87 | IN CONST EFI_FVB_ATTRIBUTES_2 *Attributes\r |
23c98c94 | 88 | );\r |
28a00297 | 89 | \r |
28a00297 | 90 | \r |
28a00297 | 91 | \r |
162ed594 | 92 | /**\r |
93 | The EraseBlock() function erases one or more blocks as denoted by the\r | |
94 | variable argument list. The entire parameter list of blocks must be verified\r | |
95 | prior to erasing any blocks. If a block is requested that does not exist\r | |
96 | within the associated firmware volume (it has a larger index than the last\r | |
97 | block of the firmware volume), the EraseBlock() function must return\r | |
98 | EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.\r | |
99 | \r | |
022c6d45 | 100 | @param This Calling context\r |
101 | @param ... Starting LBA followed by Number of Lba to erase.\r | |
102 | a -1 to terminate the list.\r | |
103 | \r | |
104 | @retval EFI_SUCCESS The erase request was successfully completed.\r | |
105 | @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled\r | |
106 | state.\r | |
107 | @retval EFI_DEVICE_ERROR The block device is not functioning correctly\r | |
108 | and could not be written. The firmware device\r | |
109 | may have been partially erased.\r | |
110 | @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable\r | |
111 | argument list do\r | |
162ed594 | 112 | @retval EFI_UNSUPPORTED Not supported.\r |
28a00297 | 113 | \r |
162ed594 | 114 | **/\r |
28a00297 | 115 | EFI_STATUS\r |
116 | EFIAPI\r | |
117 | FwVolBlockEraseBlock (\r | |
118 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
119 | ...\r | |
23c98c94 | 120 | );\r |
28a00297 | 121 | \r |
122 | \r | |
162ed594 | 123 | \r |
124 | /**\r | |
125 | Read the specified number of bytes from the block to the input buffer.\r | |
126 | \r | |
022c6d45 | 127 | @param This Indicates the calling context.\r |
128 | @param Lba The starting logical block index to read.\r | |
129 | @param Offset Offset into the block at which to begin reading.\r | |
130 | @param NumBytes Pointer to a UINT32. At entry, *NumBytes\r | |
131 | contains the total size of the buffer. At exit,\r | |
132 | *NumBytes contains the total number of bytes\r | |
133 | actually read.\r | |
134 | @param Buffer Pinter to a caller-allocated buffer that\r | |
135 | contains the destine for the read.\r | |
136 | \r | |
137 | @retval EFI_SUCCESS The firmware volume was read successfully.\r | |
138 | @retval EFI_BAD_BUFFER_SIZE The read was attempted across an LBA boundary.\r | |
139 | @retval EFI_ACCESS_DENIED Access denied.\r | |
140 | @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not\r | |
162ed594 | 141 | be read.\r |
142 | \r | |
143 | **/\r | |
28a00297 | 144 | EFI_STATUS\r |
145 | EFIAPI\r | |
146 | FwVolBlockReadBlock (\r | |
147 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
148 | IN CONST EFI_LBA Lba,\r | |
149 | IN CONST UINTN Offset,\r | |
150 | IN OUT UINTN *NumBytes,\r | |
151 | IN OUT UINT8 *Buffer\r | |
23c98c94 | 152 | );\r |
28a00297 | 153 | \r |
022c6d45 | 154 | \r |
162ed594 | 155 | \r |
156 | /**\r | |
157 | Writes the specified number of bytes from the input buffer to the block.\r | |
158 | \r | |
022c6d45 | 159 | @param This Indicates the calling context.\r |
160 | @param Lba The starting logical block index to write to.\r | |
161 | @param Offset Offset into the block at which to begin writing.\r | |
162 | @param NumBytes Pointer to a UINT32. At entry, *NumBytes\r | |
163 | contains the total size of the buffer. At exit,\r | |
164 | *NumBytes contains the total number of bytes\r | |
165 | actually written.\r | |
166 | @param Buffer Pinter to a caller-allocated buffer that\r | |
167 | contains the source for the write.\r | |
168 | \r | |
169 | @retval EFI_SUCCESS The firmware volume was written successfully.\r | |
170 | @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary.\r | |
171 | On output, NumBytes contains the total number of\r | |
172 | bytes actually written.\r | |
173 | @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled\r | |
174 | state.\r | |
175 | @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not\r | |
176 | be written.\r | |
162ed594 | 177 | @retval EFI_UNSUPPORTED Not supported.\r |
178 | \r | |
179 | **/\r | |
28a00297 | 180 | EFI_STATUS\r |
181 | EFIAPI\r | |
182 | FwVolBlockWriteBlock (\r | |
23c98c94 | 183 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r |
184 | IN EFI_LBA Lba,\r | |
185 | IN UINTN Offset,\r | |
186 | IN OUT UINTN *NumBytes,\r | |
187 | IN UINT8 *Buffer\r | |
188 | );\r | |
28a00297 | 189 | \r |
022c6d45 | 190 | \r |
162ed594 | 191 | \r |
192 | /**\r | |
193 | Get Fvb's base address.\r | |
194 | \r | |
022c6d45 | 195 | @param This Indicates the calling context.\r |
196 | @param Address Fvb device base address.\r | |
162ed594 | 197 | \r |
022c6d45 | 198 | @retval EFI_SUCCESS Successfully got Fvb's base address.\r |
162ed594 | 199 | @retval EFI_UNSUPPORTED Not supported.\r |
200 | \r | |
201 | **/\r | |
28a00297 | 202 | EFI_STATUS\r |
203 | EFIAPI\r | |
204 | FwVolBlockGetPhysicalAddress (\r | |
23c98c94 | 205 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r |
206 | OUT EFI_PHYSICAL_ADDRESS *Address\r | |
207 | );\r | |
28a00297 | 208 | \r |
28a00297 | 209 | \r |
28a00297 | 210 | \r |
162ed594 | 211 | /**\r |
212 | Retrieves the size in bytes of a specific block within a firmware volume.\r | |
213 | \r | |
022c6d45 | 214 | @param This Indicates the calling context.\r |
215 | @param Lba Indicates the block for which to return the\r | |
216 | size.\r | |
217 | @param BlockSize Pointer to a caller-allocated UINTN in which the\r | |
218 | size of the block is returned.\r | |
219 | @param NumberOfBlocks Pointer to a caller-allocated UINTN in which the\r | |
220 | number of consecutive blocks starting with Lba\r | |
221 | is returned. All blocks in this range have a\r | |
222 | size of BlockSize.\r | |
223 | \r | |
224 | @retval EFI_SUCCESS The firmware volume base address is returned.\r | |
162ed594 | 225 | @retval EFI_INVALID_PARAMETER The requested LBA is out of range.\r |
28a00297 | 226 | \r |
162ed594 | 227 | **/\r |
28a00297 | 228 | EFI_STATUS\r |
229 | EFIAPI\r | |
230 | FwVolBlockGetBlockSize (\r | |
231 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
232 | IN CONST EFI_LBA Lba,\r | |
23c98c94 | 233 | IN OUT UINTN *BlockSize,\r |
234 | IN OUT UINTN *NumberOfBlocks\r | |
235 | );\r | |
28a00297 | 236 | \r |
28a00297 | 237 | \r |
238 | #endif\r |