]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / FaultTolerantWriteDxe / FaultTolerantWrite.h
CommitLineData
85e923a5
LG
1/** @file\r
2\r
3 The internal header file includes the common header files, defines\r
4 internal structure and functions used by FtwLite module.\r
5\r
e5eed7d3
HT
6Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
7This program and the accompanying materials \r
85e923a5
LG
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
14\r
15**/\r
16\r
17#ifndef _EFI_FAULT_TOLERANT_WRITE_H_\r
18#define _EFI_FAULT_TOLERANT_WRITE_H_\r
19\r
20#include <PiDxe.h>\r
21\r
22#include <Guid/SystemNvDataGuid.h>\r
23#include <Protocol/FaultTolerantWrite.h>\r
24#include <Protocol/FirmwareVolumeBlock.h>\r
25#include <Protocol/SwapAddressRange.h>\r
26\r
27#include <Library/PcdLib.h>\r
28#include <Library/DebugLib.h>\r
93367605 29#include <Library/UefiLib.h>\r
85e923a5
LG
30#include <Library/UefiDriverEntryPoint.h>\r
31#include <Library/BaseMemoryLib.h>\r
32#include <Library/MemoryAllocationLib.h>\r
33#include <Library/UefiBootServicesTableLib.h>\r
34\r
35//\r
36// Flash erase polarity is 1\r
37//\r
38#define FTW_ERASE_POLARITY 1\r
39\r
40#define FTW_VALID_STATE 0\r
41#define FTW_INVALID_STATE 1\r
42\r
43#define FTW_ERASED_BYTE ((UINT8) (255))\r
44#define FTW_POLARITY_REVERT ((UINT8) (255))\r
45\r
46//\r
47// EFI Fault tolerant block update write queue entry\r
48//\r
49typedef struct {\r
50 UINT8 HeaderAllocated : 1;\r
51 UINT8 WritesAllocated : 1;\r
52 UINT8 Complete : 1;\r
53#define HEADER_ALLOCATED 0x1\r
54#define WRITES_ALLOCATED 0x2\r
55#define WRITES_COMPLETED 0x4\r
56 UINT8 Reserved : 5;\r
57 EFI_GUID CallerId;\r
58 UINTN NumberOfWrites;\r
59 UINTN PrivateDataSize;\r
60} EFI_FAULT_TOLERANT_WRITE_HEADER;\r
61\r
62//\r
63// EFI Fault tolerant block update write queue record\r
64//\r
65typedef struct {\r
66 UINT8 BootBlockUpdate : 1;\r
67 UINT8 SpareComplete : 1;\r
68 UINT8 DestinationComplete : 1;\r
69#define BOOT_BLOCK_UPDATE 0x1\r
70#define SPARE_COMPLETED 0x2\r
71#define DEST_COMPLETED 0x4\r
72 UINT8 Reserved : 5;\r
73 EFI_LBA Lba;\r
74 UINTN Offset;\r
75 UINTN Length;\r
76 EFI_PHYSICAL_ADDRESS FvBaseAddress;\r
77 //\r
78 // UINT8 PrivateData[PrivateDataSize]\r
79 //\r
80} EFI_FAULT_TOLERANT_WRITE_RECORD;\r
81\r
82\r
83#define RECORD_SIZE(PrivateDataSize) (sizeof (EFI_FAULT_TOLERANT_WRITE_RECORD) + PrivateDataSize)\r
84\r
85#define RECORD_TOTAL_SIZE(NumberOfWrites, PrivateDataSize) \\r
86 ((NumberOfWrites) * (sizeof (EFI_FAULT_TOLERANT_WRITE_RECORD) + PrivateDataSize))\r
87\r
88#define WRITE_TOTAL_SIZE(NumberOfWrites, PrivateDataSize) \\r
89 ( \\r
90 sizeof (EFI_FAULT_TOLERANT_WRITE_HEADER) + (NumberOfWrites) * \\r
91 (sizeof (EFI_FAULT_TOLERANT_WRITE_RECORD) + PrivateDataSize) \\r
92 )\r
93\r
94#define FTW_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'T', 'W', 'D')\r
95\r
96//\r
97// EFI Fault tolerant protocol private data structure\r
98//\r
99typedef struct {\r
100 UINTN Signature;\r
101 EFI_HANDLE Handle;\r
102 EFI_FAULT_TOLERANT_WRITE_PROTOCOL FtwInstance;\r
103 EFI_PHYSICAL_ADDRESS WorkSpaceAddress; // Base address of working space range in flash.\r
104 EFI_PHYSICAL_ADDRESS SpareAreaAddress; // Base address of spare range in flash.\r
105 UINTN WorkSpaceLength; // Size of working space range in flash.\r
106 UINTN SpareAreaLength; // Size of spare range in flash.\r
107 UINTN NumberOfSpareBlock; // Number of the blocks in spare block.\r
108 UINTN BlockSize; // Block size in bytes of the blocks in flash\r
109 EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FtwWorkSpaceHeader;// Pointer to Working Space Header in memory buffer\r
110 EFI_FAULT_TOLERANT_WRITE_HEADER *FtwLastWriteHeader;// Pointer to last record header in memory buffer\r
111 EFI_FAULT_TOLERANT_WRITE_RECORD *FtwLastWriteRecord;// Pointer to last record in memory buffer\r
112 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FtwFvBlock; // FVB of working block\r
113 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FtwBackupFvb; // FVB of spare block\r
114 EFI_LBA FtwSpareLba; // Start LBA of spare block\r
115 EFI_LBA FtwWorkBlockLba; // Start LBA of working block that contains working space in its last block.\r
116 EFI_LBA FtwWorkSpaceLba; // Start LBA of working space\r
117 UINTN FtwWorkSpaceBase; // Offset into the FtwWorkSpaceLba block.\r
118 UINTN FtwWorkSpaceSize; // Size of working space range that stores write record.\r
119 UINT8 *FtwWorkSpace; // Point to Work Space in memory buffer \r
120 //\r
121 // Following a buffer of FtwWorkSpace[FTW_WORK_SPACE_SIZE],\r
122 // Allocated with EFI_FTW_DEVICE.\r
123 //\r
124} EFI_FTW_DEVICE;\r
125\r
126#define FTW_CONTEXT_FROM_THIS(a) CR (a, EFI_FTW_DEVICE, FtwInstance, FTW_DEVICE_SIGNATURE)\r
127\r
128//\r
129// Driver entry point\r
130//\r
131/**\r
132 This function is the entry point of the Fault Tolerant Write driver.\r
133\r
134 @param ImageHandle A handle for the image that is initializing this driver\r
135 @param SystemTable A pointer to the EFI system table\r
136\r
137 @return EFI_SUCCESS FTW has finished the initialization\r
138 @retval EFI_NOT_FOUND Locate FVB protocol error\r
139 @retval EFI_OUT_OF_RESOURCES Allocate memory error\r
140 @retval EFI_VOLUME_CORRUPTED Firmware volume is error\r
141 @retval EFI_ABORTED FTW initialization error\r
142\r
143**/\r
144EFI_STATUS\r
145EFIAPI\r
146InitializeFaultTolerantWrite (\r
147 IN EFI_HANDLE ImageHandle,\r
148 IN EFI_SYSTEM_TABLE *SystemTable\r
149 );\r
150\r
151//\r
152// Fault Tolerant Write Protocol API\r
153//\r
154\r
155/**\r
156 Query the largest block that may be updated in a fault tolerant manner.\r
157\r
158\r
159 @param This Indicates a pointer to the calling context.\r
160 @param BlockSize A pointer to a caller allocated UINTN that is updated to\r
161 indicate the size of the largest block that can be updated.\r
162\r
163 @return EFI_SUCCESS The function completed successfully\r
164\r
165**/\r
166EFI_STATUS\r
167EFIAPI\r
168FtwGetMaxBlockSize (\r
169 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
170 OUT UINTN *BlockSize\r
171 );\r
172\r
173/**\r
174 Allocates space for the protocol to maintain information about writes.\r
175 Since writes must be completed in a fault tolerant manner and multiple\r
176 updates will require more resources to be successful, this function\r
177 enables the protocol to ensure that enough space exists to track\r
178 information about the upcoming writes.\r
179\r
180 All writes must be completed or aborted before another fault tolerant write can occur.\r
181\r
182 @param This Indicates a pointer to the calling context.\r
183 @param CallerId The GUID identifying the write.\r
184 @param PrivateDataSize The size of the caller's private data\r
185 that must be recorded for each write.\r
186 @param NumberOfWrites The number of fault tolerant block writes\r
187 that will need to occur.\r
188\r
189 @return EFI_SUCCESS The function completed successfully\r
190 @retval EFI_ABORTED The function could not complete successfully.\r
191 @retval EFI_ACCESS_DENIED All allocated writes have not been completed.\r
192\r
193**/\r
194EFI_STATUS\r
195EFIAPI\r
196FtwAllocate (\r
197 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
198 IN EFI_GUID *CallerId,\r
199 IN UINTN PrivateDataSize,\r
200 IN UINTN NumberOfWrites\r
201 );\r
202\r
203/**\r
204 Starts a target block update. This function will record data about write\r
205 in fault tolerant storage and will complete the write in a recoverable\r
206 manner, ensuring at all times that either the original contents or\r
207 the modified contents are available.\r
208\r
209\r
210 @param This Calling context\r
211 @param Lba The logical block address of the target block.\r
212 @param Offset The offset within the target block to place the data.\r
213 @param Length The number of bytes to write to the target block.\r
214 @param PrivateData A pointer to private data that the caller requires to\r
215 complete any pending writes in the event of a fault.\r
216 @param FvBlockHandle The handle of FVB protocol that provides services for\r
217 reading, writing, and erasing the target block.\r
218 @param Buffer The data to write.\r
219\r
220 @retval EFI_SUCCESS The function completed successfully \r
221 @retval EFI_ABORTED The function could not complete successfully. \r
222 @retval EFI_BAD_BUFFER_SIZE The input data can't fit within the spare block. \r
223 Offset + *NumBytes > SpareAreaLength.\r
224 @retval EFI_ACCESS_DENIED No writes have been allocated. \r
225 @retval EFI_OUT_OF_RESOURCES Cannot allocate enough memory resource.\r
226 @retval EFI_NOT_FOUND Cannot find FVB protocol by handle.\r
227\r
228**/\r
229EFI_STATUS\r
230EFIAPI\r
231FtwWrite (\r
232 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
233 IN EFI_LBA Lba,\r
234 IN UINTN Offset,\r
235 IN UINTN Length,\r
236 IN VOID *PrivateData,\r
237 IN EFI_HANDLE FvBlockHandle,\r
238 IN VOID *Buffer\r
239 );\r
240\r
241/**\r
242 Restarts a previously interrupted write. The caller must provide the\r
243 block protocol needed to complete the interrupted write.\r
244\r
245 @param This Calling context.\r
246 @param FvBlockHandle The handle of FVB protocol that provides services for\r
247 reading, writing, and erasing the target block.\r
248\r
249 @retval EFI_SUCCESS The function completed successfully\r
250 @retval EFI_ACCESS_DENIED No pending writes exist\r
251 @retval EFI_NOT_FOUND FVB protocol not found by the handle\r
252 @retval EFI_ABORTED The function could not complete successfully\r
253\r
254**/\r
255EFI_STATUS\r
256EFIAPI\r
257FtwRestart (\r
258 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
259 IN EFI_HANDLE FvBlockHandle\r
260 );\r
261\r
262/**\r
263 Aborts all previous allocated writes.\r
264\r
265 @param This Calling context\r
266\r
267 @retval EFI_SUCCESS The function completed successfully\r
268 @retval EFI_ABORTED The function could not complete successfully.\r
269 @retval EFI_NOT_FOUND No allocated writes exist.\r
270\r
271**/\r
272EFI_STATUS\r
273EFIAPI\r
274FtwAbort (\r
275 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This\r
276 );\r
277\r
278/**\r
279 Starts a target block update. This records information about the write\r
280 in fault tolerant storage and will complete the write in a recoverable\r
281 manner, ensuring at all times that either the original contents or\r
282 the modified contents are available.\r
283\r
284 @param This Indicates a pointer to the calling context.\r
285 @param CallerId The GUID identifying the last write.\r
286 @param Lba The logical block address of the last write.\r
287 @param Offset The offset within the block of the last write.\r
288 @param Length The length of the last write.\r
289 @param PrivateDataSize bytes from the private data\r
290 stored for this write.\r
291 @param PrivateData A pointer to a buffer. The function will copy\r
292 @param Complete A Boolean value with TRUE indicating\r
293 that the write was completed.\r
294\r
295 @retval EFI_SUCCESS The function completed successfully\r
296 @retval EFI_ABORTED The function could not complete successfully\r
297 @retval EFI_NOT_FOUND No allocated writes exist\r
298 @retval EFI_BUFFER_TOO_SMALL Input buffer is not larget enough\r
299\r
300**/\r
301EFI_STATUS\r
302EFIAPI\r
303FtwGetLastWrite (\r
304 IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
305 OUT EFI_GUID *CallerId,\r
306 OUT EFI_LBA *Lba,\r
307 OUT UINTN *Offset,\r
308 OUT UINTN *Length,\r
309 IN OUT UINTN *PrivateDataSize,\r
310 OUT VOID *PrivateData,\r
311 OUT BOOLEAN *Complete\r
312 );\r
313\r
314/**\r
315 Erase spare block.\r
316\r
317 @param FtwDevice The private data of FTW driver\r
318\r
319 @retval EFI_SUCCESS The erase request was successfully completed.\r
320 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
321 @retval EFI_DEVICE_ERROR The block device is not functioning\r
322 correctly and could not be written.\r
323 The firmware device may have been\r
324 partially erased.\r
325 @retval EFI_INVALID_PARAMETER One or more of the LBAs listed\r
326 in the variable argument list do\r
327 not exist in the firmware volume. \r
328\r
329\r
330**/\r
331EFI_STATUS\r
332FtwEraseSpareBlock (\r
333 IN EFI_FTW_DEVICE *FtwDevice\r
334 );\r
335\r
336/**\r
337 Retrive the proper FVB protocol interface by HANDLE.\r
338\r
339\r
340 @param FvBlockHandle The handle of FVB protocol that provides services for\r
341 reading, writing, and erasing the target block.\r
342 @param FvBlock The interface of FVB protocol\r
343\r
344 @retval EFI_SUCCESS The function completed successfully\r
345 @retval EFI_ABORTED The function could not complete successfully\r
346\r
347**/\r
348EFI_STATUS\r
349FtwGetFvbByHandle (\r
350 IN EFI_HANDLE FvBlockHandle,\r
351 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r
352 );\r
353\r
354/**\r
355\r
356 Is it in working block?\r
357\r
358 @param FtwDevice The private data of FTW driver\r
359 @param FvBlock Fvb protocol instance\r
360 @param Lba The block specified\r
361\r
362 @return A BOOLEAN value indicating in working block or not.\r
363\r
364**/\r
365BOOLEAN\r
366IsWorkingBlock (\r
367 EFI_FTW_DEVICE *FtwDevice,\r
368 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r
369 EFI_LBA Lba\r
370 );\r
371\r
372/**\r
373\r
374 Is it in boot block?\r
375\r
376 @param FtwDevice The private data of FTW driver\r
377 @param FvBlock Fvb protocol instance\r
378 @param Lba The block specified\r
379\r
380 @return A BOOLEAN value indicating in boot block or not.\r
381\r
382**/\r
383BOOLEAN\r
384IsBootBlock (\r
385 EFI_FTW_DEVICE *FtwDevice,\r
386 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r
387 EFI_LBA Lba\r
388 );\r
389\r
390/**\r
391 Copy the content of spare block to a target block. Size is FTW_BLOCK_SIZE.\r
392 Spare block is accessed by FTW backup FVB protocol interface. LBA is 1.\r
393 Target block is accessed by FvbBlock protocol interface. LBA is Lba.\r
394\r
395\r
396 @param FtwDevice The private data of FTW driver\r
397 @param FvBlock FVB Protocol interface to access target block\r
398 @param Lba Lba of the target block\r
399\r
400 @retval EFI_SUCCESS Spare block content is copied to target block\r
401 @retval EFI_INVALID_PARAMETER Input parameter error\r
402 @retval EFI_OUT_OF_RESOURCES Allocate memory error\r
403 @retval EFI_ABORTED The function could not complete successfully\r
404\r
405**/\r
406EFI_STATUS\r
407FlushSpareBlockToTargetBlock (\r
408 EFI_FTW_DEVICE *FtwDevice,\r
409 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r
410 EFI_LBA Lba\r
411 );\r
412\r
413/**\r
414 Copy the content of spare block to working block. Size is FTW_BLOCK_SIZE.\r
415 Spare block is accessed by FTW backup FVB protocol interface. LBA is\r
416 FtwDevice->FtwSpareLba.\r
417 Working block is accessed by FTW working FVB protocol interface. LBA is\r
418 FtwDevice->FtwWorkBlockLba.\r
419\r
420 Since the working block header is important when FTW initializes, the\r
421 state of the operation should be handled carefully. The Crc value is\r
422 calculated without STATE element.\r
423\r
424 @param FtwDevice The private data of FTW driver\r
425\r
426 @retval EFI_SUCCESS Spare block content is copied to target block\r
427 @retval EFI_OUT_OF_RESOURCES Allocate memory error\r
428 @retval EFI_ABORTED The function could not complete successfully\r
429\r
430**/\r
431EFI_STATUS\r
432FlushSpareBlockToWorkingBlock (\r
433 EFI_FTW_DEVICE *FtwDevice\r
434 );\r
435\r
436/**\r
437 Copy the content of spare block to a boot block. Size is FTW_BLOCK_SIZE.\r
438 Spare block is accessed by FTW working FVB protocol interface. LBA is 1.\r
439 Target block is accessed by FvbBlock protocol interface. LBA is Lba.\r
440\r
441 FTW will do extra work on boot block update.\r
442 FTW should depend on a protocol of EFI_ADDRESS_RANGE_SWAP_PROTOCOL,\r
443 which is produced by a chipset driver.\r
444 FTW updating boot block steps may be:\r
445 1. GetRangeLocation(), if the Range is inside the boot block, FTW know\r
446 that boot block will be update. It shall add a FLAG in the working block.\r
447 2. When spare block is ready,\r
448 3. SetSwapState(EFI_SWAPPED)\r
449 4. erasing boot block,\r
450 5. programming boot block until the boot block is ok.\r
451 6. SetSwapState(UNSWAPPED)\r
452 FTW shall not allow to update boot block when battery state is error.\r
453\r
454 @param FtwDevice The private data of FTW driver\r
455\r
456 @retval EFI_SUCCESS Spare block content is copied to boot block\r
457 @retval EFI_INVALID_PARAMETER Input parameter error\r
458 @retval EFI_OUT_OF_RESOURCES Allocate memory error\r
459 @retval EFI_ABORTED The function could not complete successfully\r
460\r
461**/\r
462EFI_STATUS\r
463FlushSpareBlockToBootBlock (\r
464 EFI_FTW_DEVICE *FtwDevice\r
465 );\r
466\r
467/**\r
468 Update a bit of state on a block device. The location of the bit is\r
469 calculated by the (Lba, Offset, bit). Here bit is determined by the\r
470 the name of a certain bit.\r
471\r
472\r
473 @param FvBlock FVB Protocol interface to access SrcBlock and DestBlock\r
474 @param Lba Lba of a block\r
475 @param Offset Offset on the Lba\r
476 @param NewBit New value that will override the old value if it can be change\r
477\r
478 @retval EFI_SUCCESS A state bit has been updated successfully\r
479 @retval Others Access block device error.\r
480 Notes:\r
481 Assume all bits of State are inside the same BYTE.\r
482 @retval EFI_ABORTED Read block fail\r
483\r
484**/\r
485EFI_STATUS\r
486FtwUpdateFvState (\r
487 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r
488 IN EFI_LBA Lba,\r
489 IN UINTN Offset,\r
490 IN UINT8 NewBit\r
491 );\r
492\r
493/**\r
494 Get the last Write Header pointer.\r
495 The last write header is the header whose 'complete' state hasn't been set.\r
496 After all, this header may be a EMPTY header entry for next Allocate.\r
497\r
498\r
499 @param FtwWorkSpaceHeader Pointer of the working block header\r
500 @param FtwWorkSpaceSize Size of the work space\r
501 @param FtwWriteHeader Pointer to retrieve the last write header\r
502\r
503 @retval EFI_SUCCESS Get the last write record successfully\r
504 @retval EFI_ABORTED The FTW work space is damaged\r
505\r
506**/\r
507EFI_STATUS\r
508FtwGetLastWriteHeader (\r
509 IN EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FtwWorkSpaceHeader,\r
510 IN UINTN FtwWorkSpaceSize,\r
511 OUT EFI_FAULT_TOLERANT_WRITE_HEADER **FtwWriteHeader\r
512 );\r
513\r
514/**\r
515 Get the last Write Record pointer. The last write Record is the Record\r
516 whose DestinationCompleted state hasn't been set. After all, this Record\r
517 may be a EMPTY record entry for next write.\r
518\r
519\r
520 @param FtwWriteHeader Pointer to the write record header\r
521 @param FtwWriteRecord Pointer to retrieve the last write record\r
522\r
523 @retval EFI_SUCCESS Get the last write record successfully\r
524 @retval EFI_ABORTED The FTW work space is damaged\r
525\r
526**/\r
527EFI_STATUS\r
528FtwGetLastWriteRecord (\r
529 IN EFI_FAULT_TOLERANT_WRITE_HEADER *FtwWriteHeader,\r
530 OUT EFI_FAULT_TOLERANT_WRITE_RECORD **FtwWriteRecord\r
531 );\r
532\r
533/**\r
534 To check if FtwRecord is the first record of FtwHeader.\r
535\r
536 @param FtwHeader Pointer to the write record header\r
537 @param FtwRecord Pointer to the write record\r
538\r
539 @retval TRUE FtwRecord is the first Record of the FtwHeader\r
540 @retval FALSE FtwRecord is not the first Record of the FtwHeader\r
541\r
542**/\r
543BOOLEAN\r
544IsFirstRecordOfWrites (\r
545 IN EFI_FAULT_TOLERANT_WRITE_HEADER *FtwHeader,\r
546 IN EFI_FAULT_TOLERANT_WRITE_RECORD *FtwRecord\r
547 );\r
548\r
549/**\r
550 To check if FtwRecord is the last record of FtwHeader. Because the\r
551 FtwHeader has NumberOfWrites & PrivateDataSize, the FtwRecord can be\r
552 determined if it is the last record of FtwHeader.\r
553\r
554 @param FtwHeader Pointer to the write record header\r
555 @param FtwRecord Pointer to the write record\r
556\r
557 @retval TRUE FtwRecord is the last Record of the FtwHeader\r
558 @retval FALSE FtwRecord is not the last Record of the FtwHeader\r
559\r
560**/\r
561BOOLEAN\r
562IsLastRecordOfWrites (\r
563 IN EFI_FAULT_TOLERANT_WRITE_HEADER *FtwHeader,\r
564 IN EFI_FAULT_TOLERANT_WRITE_RECORD *FtwRecord\r
565 );\r
566\r
567/**\r
568 To check if FtwRecord is the first record of FtwHeader.\r
569\r
570 @param FtwHeader Pointer to the write record header\r
571 @param FtwRecord Pointer to retrieve the previous write record\r
572\r
573 @retval EFI_ACCESS_DENIED Input record is the first record, no previous record is return.\r
574 @retval EFI_SUCCESS The previous write record is found.\r
575\r
576**/\r
577EFI_STATUS\r
578GetPreviousRecordOfWrites (\r
579 IN EFI_FAULT_TOLERANT_WRITE_HEADER *FtwHeader,\r
580 IN OUT EFI_FAULT_TOLERANT_WRITE_RECORD **FtwRecord\r
581 );\r
582\r
583/**\r
584\r
585 Check whether a flash buffer is erased.\r
586\r
587 @param Buffer Buffer to check\r
588 @param BufferSize Size of the buffer\r
589\r
590 @return A BOOLEAN value indicating erased or not.\r
591\r
592**/\r
593BOOLEAN\r
594IsErasedFlashBuffer (\r
595 IN UINT8 *Buffer,\r
596 IN UINTN BufferSize\r
597 );\r
598/**\r
599 Initialize a work space when there is no work space.\r
600\r
601 @param WorkingHeader Pointer of working block header\r
602\r
603 @retval EFI_SUCCESS The function completed successfully\r
604 @retval EFI_ABORTED The function could not complete successfully.\r
605\r
606**/\r
607EFI_STATUS\r
608InitWorkSpaceHeader (\r
609 IN EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *WorkingHeader\r
610 );\r
611/**\r
612 Read from working block to refresh the work space in memory.\r
613\r
614 @param FtwDevice Point to private data of FTW driver\r
615\r
616 @retval EFI_SUCCESS The function completed successfully\r
617 @retval EFI_ABORTED The function could not complete successfully.\r
618\r
619**/\r
620EFI_STATUS\r
621WorkSpaceRefresh (\r
622 IN EFI_FTW_DEVICE *FtwDevice\r
623 );\r
624/**\r
625 Check to see if it is a valid work space.\r
626\r
627\r
628 @param WorkingHeader Pointer of working block header\r
629\r
630 @retval EFI_SUCCESS The function completed successfully\r
631 @retval EFI_ABORTED The function could not complete successfully.\r
632\r
633**/\r
634BOOLEAN\r
635IsValidWorkSpace (\r
636 IN EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *WorkingHeader\r
637 );\r
638/**\r
639 Reclaim the work space on the working block.\r
640\r
641 @param FtwDevice Point to private data of FTW driver\r
642 @param PreserveRecord Whether to preserve the working record is needed\r
643\r
644 @retval EFI_SUCCESS The function completed successfully\r
645 @retval EFI_OUT_OF_RESOURCES Allocate memory error\r
646 @retval EFI_ABORTED The function could not complete successfully\r
647\r
648**/\r
649EFI_STATUS\r
650FtwReclaimWorkSpace (\r
651 IN EFI_FTW_DEVICE *FtwDevice,\r
652 IN BOOLEAN PreserveRecord\r
653 );\r
654\r
655/**\r
656\r
657 Get firmware block by address.\r
658\r
659\r
660 @param Address Address specified the block\r
661 @param FvBlock The block caller wanted\r
662\r
663 @retval EFI_SUCCESS The protocol instance if found.\r
664 @retval EFI_NOT_FOUND Block not found\r
665\r
666**/\r
667EFI_HANDLE\r
668GetFvbByAddress (\r
669 IN EFI_PHYSICAL_ADDRESS Address,\r
670 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r
671 );\r
672\r
673#endif\r