]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/FvbRuntimeDxe/FvbSmmDxe.h
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / FvbRuntimeDxe / FvbSmmDxe.h
1 /** @file
2
3 The internal header file includes the common header files, defines
4 internal structure and functions used by FVB module.
5
6 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved. <BR>
7
8 This program and the accompanying materials are licensed and made available under
9 the terms and conditions of the BSD License that accompanies this distribution.
10 The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php.
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16
17 **/
18
19 #ifndef _SMM_FVB_DXE_H_
20 #define _SMM_FVB_DXE_H_
21
22 #include <PiDxe.h>
23
24 #include <Protocol/SmmFirmwareVolumeBlock.h>
25 #include <Protocol/SmmCommunication.h>
26
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/UefiDriverEntryPoint.h>
29 #include <Library/DebugLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/BaseLib.h>
33 #include <Library/MemoryAllocationLib.h>
34 #include <Library/DevicePathLib.h>
35
36 #include <Guid/EventGroup.h>
37 #include "FvbSmmCommon.h"
38
39 #define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'S')
40 #define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FVB_DEVICE, FvbInstance, FVB_DEVICE_SIGNATURE)
41
42 typedef struct {
43 MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
44 EFI_DEVICE_PATH_PROTOCOL EndDevPath;
45 } FV_PIWG_DEVICE_PATH;
46
47 typedef struct {
48 MEMMAP_DEVICE_PATH MemMapDevPath;
49 EFI_DEVICE_PATH_PROTOCOL EndDevPath;
50 } FV_MEMMAP_DEVICE_PATH;
51
52 typedef struct {
53 UINTN Signature;
54 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
55 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FvbInstance;
56 EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *SmmFvbInstance;
57 } EFI_FVB_DEVICE;
58
59 /**
60 This function retrieves the attributes and current settings of the block.
61
62 @param[in] This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.
63
64 @param[out] Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the attributes
65 and current settings are returned. Type EFI_FVB_ATTRIBUTES_2
66 is defined in EFI_FIRMWARE_VOLUME_HEADER.
67
68 @retval EFI_SUCCESS The firmware volume attributes were returned.
69
70 **/
71 EFI_STATUS
72 EFIAPI
73 FvbGetAttributes (
74 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
75 OUT EFI_FVB_ATTRIBUTES_2 *Attributes
76 );
77
78
79 /**
80 Sets Volume attributes. No polarity translations are done.
81
82 @param[in] This Calling context.
83 @param[out] Attributes Output buffer which contains attributes.
84
85 @retval EFI_SUCCESS The function always return successfully.
86
87 **/
88 EFI_STATUS
89 EFIAPI
90 FvbSetAttributes (
91 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
92 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
93 );
94
95
96 /**
97 Retrieves the physical address of the device.
98
99 @param[in] This A pointer to EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL.
100 @param[out] Address Output buffer containing the address.
101
102 @retval EFI_SUCCESS The function always return successfully.
103
104 **/
105 EFI_STATUS
106 EFIAPI
107 FvbGetPhysicalAddress (
108 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
109 OUT EFI_PHYSICAL_ADDRESS *Address
110 );
111
112
113 /**
114 Retrieve the size of a logical block.
115
116 @param[in] This Calling context.
117 @param[in] Lba Indicates which block to return the size for.
118 @param[out] BlockSize A pointer to a caller allocated UINTN in which
119 the size of the block is returned.
120 @param[out] NumOfBlocks A pointer to a caller allocated UINTN in which the
121 number of consecutive blocks starting with Lba is
122 returned. All blocks in this range have a size of
123 BlockSize.
124
125 @retval EFI_SUCCESS The function always return successfully.
126
127 **/
128 EFI_STATUS
129 EFIAPI
130 FvbGetBlockSize (
131 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
132 IN EFI_LBA Lba,
133 OUT UINTN *BlockSize,
134 OUT UINTN *NumOfBlocks
135 );
136
137
138 /**
139 Reads data beginning at Lba:Offset from FV. The Read terminates either
140 when *NumBytes of data have been read, or when a block boundary is
141 reached. *NumBytes is updated to reflect the actual number of bytes
142 written. The write opertion does not include erase. This routine will
143 attempt to write only the specified bytes. If the writes do not stick,
144 it will return an error.
145
146 @param[in] This Calling context.
147 @param[in] Lba Block in which to begin write.
148 @param[in] Offset Offset in the block at which to begin write
149 @param[in,out] NumBytes On input, indicates the requested write size. On
150 output, indicates the actual number of bytes written
151 @param[in] Buffer Buffer containing source data for the write.
152
153 @retval EFI_SUCCESS The firmware volume was read successfully and
154 contents are in Buffer
155 @retval EFI_BAD_BUFFER_SIZE Read attempted across a LBA boundary. On output,
156 NumBytes contains the total number of bytes returned
157 in Buffer
158 @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state
159 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and
160 could not be read
161 @retval EFI_INVALID_PARAMETER NumBytes or Buffer are NULL
162
163 **/
164 EFI_STATUS
165 EFIAPI
166 FvbRead (
167 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
168 IN EFI_LBA Lba,
169 IN UINTN Offset,
170 IN OUT UINTN *NumBytes,
171 OUT UINT8 *Buffer
172 );
173
174
175 /**
176 Writes data beginning at Lba:Offset from FV. The write terminates either
177 when *NumBytes of data have been written, or when a block boundary is
178 reached. *NumBytes is updated to reflect the actual number of bytes
179 written. The write opertion does not include erase. This routine will
180 attempt to write only the specified bytes. If the writes do not stick,
181 it will return an error.
182
183 @param[in] This Calling context.
184 @param[in] Lba Block in which to begin write.
185 @param[in] Offset Offset in the block at which to begin write.
186 @param[in,out] NumBytes On input, indicates the requested write size. On
187 output, indicates the actual number of bytes written
188 @param[in] Buffer Buffer containing source data for the write.
189
190 @retval EFI_SUCCESS The firmware volume was written successfully
191 @retval EFI_BAD_BUFFER_SIZE Write attempted across a LBA boundary. On output,
192 NumBytes contains the total number of bytes
193 actually written.
194 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state
195 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and
196 could not be written.
197 @retval EFI_INVALID_PARAMETER NumBytes or Buffer are NULL.
198
199 **/
200 EFI_STATUS
201 EFIAPI
202 FvbWrite (
203 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
204 IN EFI_LBA Lba,
205 IN UINTN Offset,
206 IN OUT UINTN *NumBytes,
207 IN UINT8 *Buffer
208 );
209
210
211 /**
212 The EraseBlock() function erases one or more blocks as denoted by the
213 variable argument list. The entire parameter list of blocks must be verified
214 prior to erasing any blocks. If a block is requested that does not exist
215 within the associated firmware volume (it has a larger index than the last
216 block of the firmware volume), the EraseBlock() function must return
217 EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
218
219 @param[in] This Calling context.
220 @param[in] ... Starting LBA followed by Number of Lba to erase.
221 a -1 to terminate the list.
222
223 @retval EFI_SUCCESS The erase request was successfully completed.
224 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state
225 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and
226 could not be written. Firmware device may have been
227 partially erased.
228
229 **/
230 EFI_STATUS
231 EFIAPI
232 FvbEraseBlocks (
233 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
234 ...
235 );
236
237 #endif