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