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