]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.h
MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
[mirror_edk2.git] / MdeModulePkg / Universal / FaultTolerantWriteDxe / FaultTolerantWriteSmmDxe.h
CommitLineData
f3b80a8e 1/** @file\r
2\r
3 The internal header file includes the common header files, defines\r
4 internal structure and functions used by FTW module.\r
5\r
d1102dba
LG
6Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. <BR>\r
7This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
f3b80a8e 14\r
15**/\r
16\r
17#ifndef __SMM_FTW_DXE_H__\r
18#define __SMM_FTW_DXE_H__\r
19\r
20#include <PiDxe.h>\r
21\r
22#include <Protocol/SmmCommunication.h>\r
23\r
24#include <Library/UefiBootServicesTableLib.h>\r
25#include <Library/UefiDriverEntryPoint.h>\r
26#include <Library/DebugLib.h>\r
27#include <Library/BaseMemoryLib.h>\r
28#include <Library/UefiLib.h>\r
29#include <Library/BaseLib.h>\r
30#include <Library/MemoryAllocationLib.h>\r
31\r
32#include <Guid/EventGroup.h>\r
33\r
34#include "FaultTolerantWriteSmmCommon.h"\r
35\r
36/**\r
37 Get the size of the largest block that can be updated in a fault-tolerant manner.\r
38\r
39 @param[in] This Indicates a pointer to the calling context.\r
40 @param[out] BlockSize A pointer to a caller-allocated UINTN that is\r
41 updated to indicate the size of the largest block\r
42 that can be updated.\r
43\r
44 @retval EFI_SUCCESS The function completed successfully.\r
45 @retval EFI_ABORTED The function could not complete successfully.\r
46\r
47**/\r
48EFI_STATUS\r
49EFIAPI\r
50FtwGetMaxBlockSize (\r
51 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
52 OUT UINTN *BlockSize\r
53 );\r
54\r
55\r
56/**\r
57 Allocates space for the protocol to maintain information about writes.\r
58 Since writes must be completed in a fault-tolerant manner and multiple\r
59 writes require more resources to be successful, this function\r
60 enables the protocol to ensure that enough space exists to track\r
61 information about upcoming writes.\r
62\r
63 @param[in] This A pointer to the calling context.\r
64 @param[in] CallerId The GUID identifying the write.\r
65 @param[in] PrivateDataSize The size of the caller's private data that must be\r
66 recorded for each write.\r
67 @param[in] NumberOfWrites The number of fault tolerant block writes that will\r
68 need to occur.\r
69\r
70 @retval EFI_SUCCESS The function completed successfully\r
71 @retval EFI_ABORTED The function could not complete successfully.\r
72 @retval EFI_ACCESS_DENIED Not all allocated writes have been completed. All\r
73 writes must be completed or aborted before another\r
74 fault tolerant write can occur.\r
75\r
76**/\r
77EFI_STATUS\r
78EFIAPI\r
79FtwAllocate (\r
80 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
81 IN EFI_GUID *CallerId,\r
82 IN UINTN PrivateDataSize,\r
83 IN UINTN NumberOfWrites\r
84 );\r
85\r
86\r
87/**\r
88 Starts a target block update. This records information about the write\r
89 in fault tolerant storage, and will complete the write in a recoverable\r
90 manner, ensuring at all times that either the original contents or\r
91 the modified contents are available.\r
92\r
93 @param[in] This The calling context.\r
94 @param[in] Lba The logical block address of the target block.\r
95 @param[in] Offset The offset within the target block to place the\r
96 data.\r
97 @param[in] Length The number of bytes to write to the target block.\r
98 @param[in] PrivateData A pointer to private data that the caller requires\r
99 to complete any pending writes in the event of a\r
100 fault.\r
101 @param[in] FvBlockHandle The handle of FVB protocol that provides services\r
102 for reading, writing, and erasing the target block.\r
103 @param[in] Buffer The data to write.\r
104\r
105 @retval EFI_SUCCESS The function completed successfully.\r
106 @retval EFI_ABORTED The function could not complete successfully.\r
107 @retval EFI_BAD_BUFFER_SIZE The write would span a block boundary, which is not\r
108 a valid action.\r
109 @retval EFI_ACCESS_DENIED No writes have been allocated.\r
110 @retval EFI_NOT_READY The last write has not been completed. Restart()\r
111 must be called to complete it.\r
112\r
113**/\r
114EFI_STATUS\r
115EFIAPI\r
116FtwWrite (\r
117 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
118 IN EFI_LBA Lba,\r
119 IN UINTN Offset,\r
120 IN UINTN Length,\r
121 IN VOID *PrivateData,\r
122 IN EFI_HANDLE FvBlockHandle,\r
123 IN VOID *Buffer\r
124 );\r
125\r
126\r
127/**\r
128 Restarts a previously interrupted write. The caller must provide the\r
129 block protocol needed to complete the interrupted write.\r
130\r
131 @param[in] This The calling context.\r
132 @param[in] FvBlockHandle The handle of FVB protocol that provides services.\r
133\r
134 @retval EFI_SUCCESS The function completed successfully.\r
135 @retval EFI_ABORTED The function could not complete successfully.\r
136 @retval EFI_ACCESS_DENIED No pending writes exist.\r
137\r
138**/\r
139EFI_STATUS\r
140EFIAPI\r
141FtwRestart (\r
142 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
143 IN EFI_HANDLE FvBlockHandle\r
144 );\r
145\r
146\r
147/**\r
148 Aborts all previously allocated writes.\r
149\r
150 @param This The calling context.\r
151\r
152 @retval EFI_SUCCESS The function completed successfully.\r
153 @retval EFI_ABORTED The function could not complete successfully.\r
154 @retval EFI_NOT_FOUND No allocated writes exist.\r
155\r
156**/\r
157EFI_STATUS\r
158EFIAPI\r
159FtwAbort (\r
160 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This\r
161 );\r
162\r
163\r
164/**\r
165 Starts a target block update. This function records information about the write\r
166 in fault-tolerant storage and completes the write in a recoverable\r
167 manner, ensuring at all times that either the original contents or\r
168 the modified contents are available.\r
169\r
170 @param[in] This Indicates a pointer to the calling context.\r
171 @param[out] CallerId The GUID identifying the last write.\r
172 @param[out] Lba The logical block address of the last write.\r
173 @param[out] Offset The offset within the block of the last write.\r
174 @param[out] Length The length of the last write.\r
175 @param[in, out] PrivateDataSize On input, the size of the PrivateData buffer. On\r
176 output, the size of the private data stored for\r
177 this write.\r
178 @param[out] PrivateData A pointer to a buffer. The function will copy\r
179 PrivateDataSize bytes from the private data stored\r
180 for this write.\r
181 @param[out] Complete A Boolean value with TRUE indicating that the write\r
182 was completed.\r
183\r
184 @retval EFI_SUCCESS The function completed successfully.\r
185 @retval EFI_ABORTED The function could not complete successfully.\r
186 @retval EFI_NOT_FOUND No allocated writes exist.\r
187\r
188**/\r
189EFI_STATUS\r
190EFIAPI\r
191FtwGetLastWrite (\r
192 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
193 OUT EFI_GUID *CallerId,\r
194 OUT EFI_LBA *Lba,\r
195 OUT UINTN *Offset,\r
196 OUT UINTN *Length,\r
197 IN OUT UINTN *PrivateDataSize,\r
198 OUT VOID *PrivateData,\r
199 OUT BOOLEAN *Complete\r
200 );\r
201\r
202#endif\r