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