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