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