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