]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[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 - 2012, Intel Corporation. All rights reserved.<BR>\r
6SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
10#ifndef _FWVOL_BLOCK_H_\r
11#define _FWVOL_BLOCK_H_\r
12\r
13\r
14#define FVB_DEVICE_SIGNATURE SIGNATURE_32('_','F','V','B')\r
15\r
16\r
17typedef struct {\r
18 UINTN Base;\r
19 UINTN Length;\r
20} LBA_CACHE;\r
21\r
22typedef struct {\r
23 MEMMAP_DEVICE_PATH MemMapDevPath;\r
24 EFI_DEVICE_PATH_PROTOCOL EndDevPath;\r
25} FV_MEMMAP_DEVICE_PATH;\r
26\r
27//\r
28// UEFI Specification define FV device path format if FV provide name guid in extension header\r
29//\r
30typedef struct {\r
31 MEDIA_FW_VOL_DEVICE_PATH FvDevPath;\r
32 EFI_DEVICE_PATH_PROTOCOL EndDevPath;\r
33} FV_PIWG_DEVICE_PATH;\r
34\r
35typedef struct {\r
36 UINTN Signature;\r
37 EFI_HANDLE Handle;\r
38 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
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
44 UINT32 AuthenticationStatus;\r
45} EFI_FW_VOL_BLOCK_DEVICE;\r
46\r
47\r
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
52/**\r
53 Retrieves Volume attributes. No polarity translations are done.\r
54\r
55 @param This Calling context\r
56 @param Attributes output buffer which contains attributes\r
57\r
58 @retval EFI_SUCCESS The firmware volume attributes were returned.\r
59\r
60**/\r
61EFI_STATUS\r
62EFIAPI\r
63FwVolBlockGetAttributes (\r
64 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
65 OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
66 );\r
67\r
68\r
69\r
70/**\r
71 Modifies the current settings of the firmware volume according to the input parameter.\r
72\r
73 @param This Calling context\r
74 @param Attributes input buffer which contains attributes\r
75\r
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
80 @retval EFI_UNSUPPORTED Not supported.\r
81\r
82**/\r
83EFI_STATUS\r
84EFIAPI\r
85FwVolBlockSetAttributes (\r
86 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
87 IN CONST EFI_FVB_ATTRIBUTES_2 *Attributes\r
88 );\r
89\r
90\r
91\r
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
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
112 @retval EFI_UNSUPPORTED Not supported.\r
113\r
114**/\r
115EFI_STATUS\r
116EFIAPI\r
117FwVolBlockEraseBlock (\r
118 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
119 ...\r
120 );\r
121\r
122\r
123\r
124/**\r
125 Read the specified number of bytes from the block to the input buffer.\r
126\r
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
141 be read.\r
142\r
143**/\r
144EFI_STATUS\r
145EFIAPI\r
146FwVolBlockReadBlock (\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
152 );\r
153\r
154\r
155\r
156/**\r
157 Writes the specified number of bytes from the input buffer to the block.\r
158\r
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
177 @retval EFI_UNSUPPORTED Not supported.\r
178\r
179**/\r
180EFI_STATUS\r
181EFIAPI\r
182FwVolBlockWriteBlock (\r
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
189\r
190\r
191\r
192/**\r
193 Get Fvb's base address.\r
194\r
195 @param This Indicates the calling context.\r
196 @param Address Fvb device base address.\r
197\r
198 @retval EFI_SUCCESS Successfully got Fvb's base address.\r
199 @retval EFI_UNSUPPORTED Not supported.\r
200\r
201**/\r
202EFI_STATUS\r
203EFIAPI\r
204FwVolBlockGetPhysicalAddress (\r
205 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
206 OUT EFI_PHYSICAL_ADDRESS *Address\r
207 );\r
208\r
209\r
210\r
211/**\r
212 Retrieves the size in bytes of a specific block within a firmware volume.\r
213\r
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
225 @retval EFI_INVALID_PARAMETER The requested LBA is out of range.\r
226\r
227**/\r
228EFI_STATUS\r
229EFIAPI\r
230FwVolBlockGetBlockSize (\r
231 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
232 IN CONST EFI_LBA Lba,\r
233 IN OUT UINTN *BlockSize,\r
234 IN OUT UINTN *NumberOfBlocks\r
235 );\r
236\r
237\r
238#endif\r