]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.h
Optimize the log entry search algorithm to save boot performance.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / FwVolBlock / FwVolBlock.h
... / ...
CommitLineData
1/** @file\r
2 Firmware Volume Block protocol functions.\r
3 Consumes FV hobs and creates appropriate block protocols.\r
4\r
5Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _FWVOL_BLOCK_H_\r
17#define _FWVOL_BLOCK_H_\r
18\r
19\r
20#define FVB_DEVICE_SIGNATURE SIGNATURE_32('_','F','V','B')\r
21\r
22\r
23typedef struct {\r
24 UINTN Base;\r
25 UINTN Length;\r
26} LBA_CACHE;\r
27\r
28typedef struct {\r
29 MEMMAP_DEVICE_PATH MemMapDevPath;\r
30 EFI_DEVICE_PATH_PROTOCOL EndDevPath;\r
31} FV_MEMMAP_DEVICE_PATH;\r
32\r
33//\r
34// UEFI Specification define FV device path format if FV provide name guid in extension header\r
35//\r
36typedef struct {\r
37 MEDIA_FW_VOL_DEVICE_PATH FvDevPath;\r
38 EFI_DEVICE_PATH_PROTOCOL EndDevPath;\r
39} FV_PIWG_DEVICE_PATH;\r
40\r
41typedef struct {\r
42 UINTN Signature;\r
43 EFI_HANDLE Handle;\r
44 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
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
52\r
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
57/**\r
58 Retrieves Volume attributes. No polarity translations are done.\r
59\r
60 @param This Calling context\r
61 @param Attributes output buffer which contains attributes\r
62\r
63 @retval EFI_SUCCESS The firmware volume attributes were returned.\r
64\r
65**/\r
66EFI_STATUS\r
67EFIAPI\r
68FwVolBlockGetAttributes (\r
69 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
70 OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
71 );\r
72\r
73\r
74\r
75/**\r
76 Modifies the current settings of the firmware volume according to the input parameter.\r
77\r
78 @param This Calling context\r
79 @param Attributes input buffer which contains attributes\r
80\r
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
85 @retval EFI_UNSUPPORTED Not supported.\r
86\r
87**/\r
88EFI_STATUS\r
89EFIAPI\r
90FwVolBlockSetAttributes (\r
91 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
92 IN CONST EFI_FVB_ATTRIBUTES_2 *Attributes\r
93 );\r
94\r
95\r
96\r
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
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
117 @retval EFI_UNSUPPORTED Not supported.\r
118\r
119**/\r
120EFI_STATUS\r
121EFIAPI\r
122FwVolBlockEraseBlock (\r
123 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
124 ...\r
125 );\r
126\r
127\r
128\r
129/**\r
130 Read the specified number of bytes from the block to the input buffer.\r
131\r
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
146 be read.\r
147\r
148**/\r
149EFI_STATUS\r
150EFIAPI\r
151FwVolBlockReadBlock (\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
157 );\r
158\r
159\r
160\r
161/**\r
162 Writes the specified number of bytes from the input buffer to the block.\r
163\r
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
182 @retval EFI_UNSUPPORTED Not supported.\r
183\r
184**/\r
185EFI_STATUS\r
186EFIAPI\r
187FwVolBlockWriteBlock (\r
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
194\r
195\r
196\r
197/**\r
198 Get Fvb's base address.\r
199\r
200 @param This Indicates the calling context.\r
201 @param Address Fvb device base address.\r
202\r
203 @retval EFI_SUCCESS Successfully got Fvb's base address.\r
204 @retval EFI_UNSUPPORTED Not supported.\r
205\r
206**/\r
207EFI_STATUS\r
208EFIAPI\r
209FwVolBlockGetPhysicalAddress (\r
210 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
211 OUT EFI_PHYSICAL_ADDRESS *Address\r
212 );\r
213\r
214\r
215\r
216/**\r
217 Retrieves the size in bytes of a specific block within a firmware volume.\r
218\r
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
230 @retval EFI_INVALID_PARAMETER The requested LBA is out of range.\r
231\r
232**/\r
233EFI_STATUS\r
234EFIAPI\r
235FwVolBlockGetBlockSize (\r
236 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
237 IN CONST EFI_LBA Lba,\r
238 IN OUT UINTN *BlockSize,\r
239 IN OUT UINTN *NumberOfBlocks\r
240 );\r
241\r
242\r
243#endif\r