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