]>
Commit | Line | Data |
---|---|---|
6cc9ca32 | 1 | /** @file\r |
d7dec593 | 2 | \r |
6cc9ca32 LG |
3 | The internal header file includes the common header files, defines\r |
4 | internal structure and functions used by FtwLite module.\r | |
5 | \r | |
6 | Copyright (c) 2006 - 2008, Intel Corporation \r | |
d7dec593 | 7 | All rights reserved. This program and the accompanying materials \r |
8 | are licensed and made available under the terms and conditions of the BSD License \r | |
9 | which accompanies this distribution. The full text of the license may be found at \r | |
10 | http://opensource.org/licenses/bsd-license.php \r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
14 | \r | |
6cc9ca32 | 15 | **/\r |
d7dec593 | 16 | \r |
17 | #ifndef _EFI_FAULT_TOLERANT_WRITE_LITE_H_\r | |
18 | #define _EFI_FAULT_TOLERANT_WRITE_LITE_H_\r | |
19 | \r | |
ed7748fe | 20 | \r |
d7dec593 | 21 | #include <PiDxe.h>\r |
ed7748fe | 22 | \r |
d7dec593 | 23 | #include <Protocol/PciRootBridgeIo.h>\r |
24 | #include <Guid/SystemNvDataGuid.h>\r | |
25 | #include <Protocol/FaultTolerantWriteLite.h>\r | |
26 | #include <Protocol/FirmwareVolumeBlock.h>\r | |
ed7748fe | 27 | \r |
d7dec593 | 28 | #include <Library/PcdLib.h>\r |
29 | #include <Library/DebugLib.h>\r | |
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 | |
3cfb790c | 35 | #include <WorkingBlockHeader.h>\r |
d7dec593 | 36 | \r |
37 | #define EFI_D_FTW_LITE EFI_D_ERROR\r | |
38 | #define EFI_D_FTW_INFO EFI_D_INFO\r | |
39 | \r | |
40 | //\r | |
41 | // Flash erase polarity is 1\r | |
42 | //\r | |
43 | #define FTW_ERASE_POLARITY 1\r | |
44 | \r | |
45 | #define FTW_VALID_STATE 0\r | |
46 | #define FTW_INVALID_STATE 1\r | |
47 | \r | |
48 | #define FTW_ERASED_BYTE ((UINT8) (255))\r | |
49 | #define FTW_POLARITY_REVERT ((UINT8) (255))\r | |
50 | \r | |
51 | typedef struct {\r | |
52 | UINT8 WriteAllocated : 1;\r | |
53 | UINT8 SpareCompleted : 1;\r | |
54 | UINT8 WriteCompleted : 1;\r | |
55 | UINT8 Reserved : 5;\r | |
56 | #define WRITE_ALLOCATED 0x1\r | |
57 | #define SPARE_COMPLETED 0x2\r | |
58 | #define WRITE_COMPLETED 0x4\r | |
59 | \r | |
60 | EFI_DEV_PATH DevPath;\r | |
61 | EFI_LBA Lba;\r | |
62 | UINTN Offset;\r | |
63 | UINTN NumBytes;\r | |
64 | //\r | |
65 | // UINTN SpareAreaOffset;\r | |
66 | //\r | |
67 | } EFI_FTW_LITE_RECORD;\r | |
68 | \r | |
69 | #define FTW_LITE_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('F', 'T', 'W', 'L')\r | |
70 | \r | |
71 | //\r | |
72 | // MACRO for Block size.\r | |
73 | // Flash Erasing will do in block granularity.\r | |
74 | //\r | |
75 | #ifdef FV_BLOCK_SIZE\r | |
76 | #define FTW_BLOCK_SIZE FV_BLOCK_SIZE\r | |
77 | #else\r | |
78 | #define FV_BLOCK_SIZE 0x10000\r | |
79 | #define FTW_BLOCK_SIZE FV_BLOCK_SIZE\r | |
80 | #endif\r | |
81 | //\r | |
82 | // MACRO for FTW WORK SPACE Base & Size\r | |
83 | //\r | |
84 | #ifdef EFI_FTW_WORKING_OFFSET\r | |
85 | #define FTW_WORK_SPACE_BASE EFI_FTW_WORKING_OFFSET\r | |
86 | #else\r | |
87 | #define FTW_WORK_SPACE_BASE 0x00E000\r | |
88 | #endif\r | |
89 | \r | |
90 | #ifdef EFI_FTW_WORKING_LENGTH\r | |
91 | #define FTW_WORK_SPACE_SIZE EFI_FTW_WORKING_LENGTH\r | |
92 | #else\r | |
93 | #define FTW_WORK_SPACE_SIZE 0x002000\r | |
94 | #endif\r | |
95 | //\r | |
96 | // MACRO for FTW header and record\r | |
97 | //\r | |
98 | #define FTW_WORKING_QUEUE_SIZE (FTW_WORK_SPACE_SIZE - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER))\r | |
99 | #define FTW_LITE_RECORD_SIZE (sizeof (EFI_FTW_LITE_RECORD))\r | |
100 | #define WRITE_TOTAL_SIZE FTW_LITE_RECORD_SIZE\r | |
101 | \r | |
102 | //\r | |
103 | // EFI Fault tolerant protocol private data structure\r | |
104 | //\r | |
105 | typedef struct {\r | |
106 | UINTN Signature;\r | |
107 | EFI_HANDLE Handle;\r | |
108 | EFI_FTW_LITE_PROTOCOL FtwLiteInstance;\r | |
109 | EFI_PHYSICAL_ADDRESS WorkSpaceAddress;\r | |
110 | UINTN WorkSpaceLength;\r | |
111 | EFI_PHYSICAL_ADDRESS SpareAreaAddress;\r | |
112 | UINTN SpareAreaLength;\r | |
113 | UINTN NumberOfSpareBlock; // Number of the blocks in spare block\r | |
114 | UINTN SizeOfSpareBlock; // Block size in bytes of the blocks in spare block\r | |
115 | EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FtwWorkSpaceHeader;\r | |
116 | EFI_FTW_LITE_RECORD *FtwLastRecord;\r | |
117 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FtwFvBlock; // FVB of working block\r | |
118 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FtwBackupFvb; // FVB of spare block\r | |
119 | EFI_LBA FtwSpareLba;\r | |
120 | EFI_LBA FtwWorkBlockLba; // Start LBA of working block\r | |
121 | EFI_LBA FtwWorkSpaceLba; // Start LBA of working space\r | |
122 | UINTN FtwWorkSpaceBase; // Offset from LBA start addr\r | |
123 | UINTN FtwWorkSpaceSize;\r | |
124 | UINT8 *FtwWorkSpace;\r | |
125 | //\r | |
126 | // Following a buffer of FtwWorkSpace[FTW_WORK_SPACE_SIZE],\r | |
127 | // Allocated with EFI_FTW_LITE_DEVICE.\r | |
128 | //\r | |
129 | } EFI_FTW_LITE_DEVICE;\r | |
130 | \r | |
131 | #define FTW_LITE_CONTEXT_FROM_THIS(a) CR (a, EFI_FTW_LITE_DEVICE, FtwLiteInstance, FTW_LITE_DEVICE_SIGNATURE)\r | |
132 | \r | |
133 | //\r | |
134 | // Driver entry point\r | |
135 | //\r | |
6aab8214 | 136 | /**\r |
137 | This function is the entry point of the Fault Tolerant Write driver.\r | |
138 | \r | |
139 | \r | |
140 | @param ImageHandle EFI_HANDLE: A handle for the image that is initializing\r | |
141 | this driver\r | |
142 | @param SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table\r | |
143 | \r | |
144 | @retval EFI_SUCCESS FTW has finished the initialization\r | |
145 | @retval EFI_ABORTED FTW initialization error\r | |
146 | \r | |
147 | **/\r | |
d7dec593 | 148 | EFI_STATUS\r |
149 | EFIAPI\r | |
150 | InitializeFtwLite (\r | |
151 | IN EFI_HANDLE ImageHandle,\r | |
152 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
ed66e1bc | 153 | );\r |
d7dec593 | 154 | \r |
155 | //\r | |
156 | // Fault Tolerant Write Protocol API\r | |
157 | //\r | |
6aab8214 | 158 | /**\r |
159 | Starts a target block update. This function will record data about write\r | |
160 | in fault tolerant storage and will complete the write in a recoverable\r | |
161 | manner, ensuring at all times that either the original contents or\r | |
162 | the modified contents are available.\r | |
163 | \r | |
164 | \r | |
165 | @param This Calling context\r | |
166 | @param FvbHandle The handle of FVB protocol that provides services for\r | |
167 | reading, writing, and erasing the target block.\r | |
168 | @param Lba The logical block address of the target block.\r | |
169 | @param Offset The offset within the target block to place the data.\r | |
170 | @param NumBytes The number of bytes to write to the target block.\r | |
171 | @param Buffer The data to write.\r | |
172 | \r | |
173 | @retval EFI_SUCCESS The function completed successfully\r | |
174 | @retval EFI_BAD_BUFFER_SIZE The write would span a target block, which is not\r | |
175 | a valid action.\r | |
176 | @retval EFI_ACCESS_DENIED No writes have been allocated.\r | |
177 | @retval EFI_NOT_FOUND Cannot find FVB by handle.\r | |
178 | @retval EFI_OUT_OF_RESOURCES Cannot allocate memory.\r | |
179 | @retval EFI_ABORTED The function could not complete successfully.\r | |
180 | \r | |
181 | **/\r | |
d7dec593 | 182 | EFI_STATUS\r |
183 | EFIAPI\r | |
184 | FtwLiteWrite (\r | |
6aab8214 | 185 | IN EFI_FTW_LITE_PROTOCOL *This,\r |
186 | IN EFI_HANDLE FvbHandle,\r | |
187 | IN EFI_LBA Lba,\r | |
188 | IN UINTN Offset,\r | |
189 | IN OUT UINTN *NumBytes,\r | |
190 | IN VOID *Buffer\r | |
ed66e1bc | 191 | );\r |
d7dec593 | 192 | \r |
193 | //\r | |
194 | // Internal functions\r | |
195 | //\r | |
6aab8214 | 196 | /**\r |
197 | Restarts a previously interrupted write. The caller must provide the\r | |
198 | block protocol needed to complete the interrupted write.\r | |
199 | \r | |
200 | \r | |
201 | @param FtwLiteDevice The private data of FTW_LITE driver\r | |
202 | FvbHandle - The handle of FVB protocol that provides services for\r | |
203 | reading, writing, and erasing the target block.\r | |
204 | \r | |
205 | @retval EFI_SUCCESS The function completed successfully\r | |
206 | @retval EFI_ACCESS_DENIED No pending writes exist\r | |
207 | @retval EFI_NOT_FOUND FVB protocol not found by the handle\r | |
208 | @retval EFI_ABORTED The function could not complete successfully\r | |
209 | \r | |
210 | **/\r | |
d7dec593 | 211 | EFI_STATUS\r |
212 | FtwRestart (\r | |
213 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
ed66e1bc | 214 | );\r |
d7dec593 | 215 | \r |
6aab8214 | 216 | /**\r |
217 | Aborts all previous allocated writes.\r | |
d7dec593 | 218 | \r |
d7dec593 | 219 | \r |
6aab8214 | 220 | @param FtwLiteDevice The private data of FTW_LITE driver\r |
d7dec593 | 221 | \r |
6aab8214 | 222 | @retval EFI_SUCCESS The function completed successfully\r |
223 | @retval EFI_ABORTED The function could not complete successfully.\r | |
224 | @retval EFI_NOT_FOUND No allocated writes exist.\r | |
d7dec593 | 225 | \r |
6aab8214 | 226 | **/\r |
d7dec593 | 227 | EFI_STATUS\r |
228 | FtwAbort (\r | |
229 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
ed66e1bc | 230 | );\r |
d7dec593 | 231 | \r |
d7dec593 | 232 | \r |
6aab8214 | 233 | /**\r |
234 | Write a record with fault tolerant mannaer.\r | |
235 | Since the content has already backuped in spare block, the write is\r | |
236 | guaranteed to be completed with fault tolerant manner.\r | |
d7dec593 | 237 | \r |
d7dec593 | 238 | \r |
6aab8214 | 239 | @param FtwLiteDevice The private data of FTW_LITE driver\r |
240 | @param Fvb The FVB protocol that provides services for\r | |
241 | reading, writing, and erasing the target block.\r | |
d7dec593 | 242 | \r |
6aab8214 | 243 | @retval EFI_SUCCESS The function completed successfully\r |
244 | @retval EFI_ABORTED The function could not complete successfully\r | |
d7dec593 | 245 | \r |
6aab8214 | 246 | **/\r |
d7dec593 | 247 | EFI_STATUS\r |
248 | FtwWriteRecord (\r | |
249 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
250 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb\r | |
ed66e1bc | 251 | );\r |
d7dec593 | 252 | \r |
6aab8214 | 253 | /**\r |
254 | To Erase one block. The size is FTW_BLOCK_SIZE\r | |
d7dec593 | 255 | \r |
d7dec593 | 256 | \r |
6aab8214 | 257 | @param FtwLiteDevice Calling context\r |
258 | @param FvBlock FVB Protocol interface\r | |
259 | @param Lba Lba of the firmware block\r | |
d7dec593 | 260 | \r |
6aab8214 | 261 | @retval EFI_SUCCESS Block LBA is Erased successfully\r |
262 | @retval Others Error occurs\r | |
d7dec593 | 263 | \r |
6aab8214 | 264 | **/\r |
d7dec593 | 265 | EFI_STATUS\r |
266 | FtwEraseBlock (\r | |
267 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
268 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
269 | EFI_LBA Lba\r | |
ed66e1bc | 270 | );\r |
d7dec593 | 271 | \r |
6aab8214 | 272 | /**\r |
d7dec593 | 273 | \r |
6aab8214 | 274 | Erase spare block.\r |
d7dec593 | 275 | \r |
d7dec593 | 276 | \r |
6aab8214 | 277 | @param FtwLiteDevice Calling context\r |
d7dec593 | 278 | \r |
6aab8214 | 279 | @retval EFI_SUCCESS The erase request was successfully\r |
280 | completed.\r | |
281 | \r | |
282 | @retval EFI_ACCESS_DENIED The firmware volume is in the\r | |
283 | WriteDisabled state.\r | |
284 | @retval EFI_DEVICE_ERROR The block device is not functioning\r | |
285 | correctly and could not be written.\r | |
286 | The firmware device may have been\r | |
287 | partially erased.\r | |
288 | @retval EFI_INVALID_PARAMETER One or more of the LBAs listed\r | |
289 | in the variable argument list do\r | |
290 | not exist in the firmware volume. \r | |
291 | \r | |
292 | **/\r | |
d7dec593 | 293 | EFI_STATUS\r |
294 | FtwEraseSpareBlock (\r | |
295 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
ed66e1bc | 296 | );\r |
d7dec593 | 297 | \r |
6aab8214 | 298 | /**\r |
299 | Retrive the proper FVB protocol interface by HANDLE.\r | |
d7dec593 | 300 | \r |
d7dec593 | 301 | \r |
6aab8214 | 302 | @param FvBlockHandle The handle of FVB protocol that provides services for\r |
303 | reading, writing, and erasing the target block.\r | |
304 | @param FvBlock The interface of FVB protocol\r | |
d7dec593 | 305 | \r |
6aab8214 | 306 | @retval EFI_SUCCESS The function completed successfully\r |
307 | @retval EFI_ABORTED The function could not complete successfully\r | |
d7dec593 | 308 | \r |
6aab8214 | 309 | **/\r |
d7dec593 | 310 | EFI_STATUS\r |
311 | FtwGetFvbByHandle (\r | |
312 | IN EFI_HANDLE FvBlockHandle,\r | |
313 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r | |
ed66e1bc | 314 | );\r |
d7dec593 | 315 | \r |
6aab8214 | 316 | /**\r |
d7dec593 | 317 | \r |
6aab8214 | 318 | Get firmware block by address.\r |
d7dec593 | 319 | \r |
d7dec593 | 320 | \r |
6aab8214 | 321 | @param Address Address specified the block\r |
322 | @param FvBlock The block caller wanted\r | |
323 | \r | |
324 | @retval EFI_SUCCESS The protocol instance if found.\r | |
325 | @retval EFI_NOT_FOUND Block not found\r | |
326 | \r | |
327 | **/\r | |
d7dec593 | 328 | EFI_STATUS\r |
329 | GetFvbByAddress (\r | |
330 | IN EFI_PHYSICAL_ADDRESS Address,\r | |
331 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r | |
ed66e1bc | 332 | );\r |
d7dec593 | 333 | \r |
6aab8214 | 334 | /**\r |
d7dec593 | 335 | \r |
6aab8214 | 336 | Is it in working block?\r |
d7dec593 | 337 | \r |
d7dec593 | 338 | \r |
6aab8214 | 339 | @param FtwLiteDevice Calling context\r |
340 | @param FvBlock Fvb protocol instance\r | |
341 | @param Lba The block specified\r | |
d7dec593 | 342 | \r |
6aab8214 | 343 | @return A BOOLEAN value indicating in working block or not.\r |
d7dec593 | 344 | \r |
6aab8214 | 345 | **/\r |
d7dec593 | 346 | BOOLEAN\r |
347 | IsInWorkingBlock (\r | |
348 | EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
349 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
350 | EFI_LBA Lba\r | |
ed66e1bc | 351 | );\r |
d7dec593 | 352 | \r |
6aab8214 | 353 | /**\r |
d7dec593 | 354 | \r |
6aab8214 | 355 | Check whether the block is a boot block.\r |
d7dec593 | 356 | \r |
d7dec593 | 357 | \r |
6aab8214 | 358 | @param FtwLiteDevice Calling context\r |
359 | @param FvBlock Fvb protocol instance\r | |
360 | @param Lba Lba value\r | |
d7dec593 | 361 | \r |
6aab8214 | 362 | @retval FALSE This is a boot block.\r |
363 | @retval TRUE This is not a boot block.\r | |
d7dec593 | 364 | \r |
6aab8214 | 365 | **/\r |
d7dec593 | 366 | BOOLEAN\r |
367 | IsBootBlock (\r | |
368 | EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
369 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
370 | EFI_LBA Lba\r | |
ed66e1bc | 371 | );\r |
d7dec593 | 372 | \r |
6aab8214 | 373 | /**\r |
374 | Copy the content of spare block to a target block. Size is FTW_BLOCK_SIZE.\r | |
375 | Spare block is accessed by FTW backup FVB protocol interface. LBA is\r | |
376 | FtwLiteDevice->FtwSpareLba.\r | |
377 | Target block is accessed by FvBlock protocol interface. LBA is Lba.\r | |
d7dec593 | 378 | \r |
d7dec593 | 379 | \r |
6aab8214 | 380 | @param FtwLiteDevice The private data of FTW_LITE driver\r |
381 | @param FvBlock FVB Protocol interface to access target block\r | |
382 | @param Lba Lba of the target block\r | |
d7dec593 | 383 | \r |
6aab8214 | 384 | @retval EFI_SUCCESS Spare block content is copied to target block\r |
385 | @retval EFI_INVALID_PARAMETER Input parameter error\r | |
386 | @retval EFI_OUT_OF_RESOURCES Allocate memory error\r | |
387 | @retval EFI_ABORTED The function could not complete successfully\r | |
d7dec593 | 388 | \r |
6aab8214 | 389 | **/\r |
d7dec593 | 390 | EFI_STATUS\r |
391 | FlushSpareBlockToTargetBlock (\r | |
392 | EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
393 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
394 | EFI_LBA Lba\r | |
ed66e1bc | 395 | );\r |
d7dec593 | 396 | \r |
6aab8214 | 397 | /**\r |
398 | Copy the content of spare block to working block. Size is FTW_BLOCK_SIZE.\r | |
399 | Spare block is accessed by FTW backup FVB protocol interface. LBA is\r | |
400 | FtwLiteDevice->FtwSpareLba.\r | |
401 | Working block is accessed by FTW working FVB protocol interface. LBA is\r | |
402 | FtwLiteDevice->FtwWorkBlockLba.\r | |
403 | \r | |
404 | \r | |
405 | @param FtwLiteDevice The private data of FTW_LITE driver\r | |
406 | \r | |
407 | @retval EFI_SUCCESS Spare block content is copied to target block\r | |
408 | @retval EFI_OUT_OF_RESOURCES Allocate memory error\r | |
409 | @retval EFI_ABORTED The function could not complete successfully\r | |
410 | Notes:\r | |
411 | Since the working block header is important when FTW initializes, the\r | |
412 | state of the operation should be handled carefully. The Crc value is\r | |
413 | calculated without STATE element.\r | |
414 | \r | |
415 | **/\r | |
d7dec593 | 416 | EFI_STATUS\r |
417 | FlushSpareBlockToWorkingBlock (\r | |
418 | EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
ed66e1bc | 419 | );\r |
d7dec593 | 420 | \r |
6aab8214 | 421 | /**\r |
422 | Copy the content of spare block to a boot block. Size is FTW_BLOCK_SIZE.\r | |
423 | Spare block is accessed by FTW backup FVB protocol interface. LBA is\r | |
424 | FtwLiteDevice->FtwSpareLba.\r | |
425 | Boot block is accessed by BootFvb protocol interface. LBA is 0.\r | |
d7dec593 | 426 | \r |
d7dec593 | 427 | \r |
6aab8214 | 428 | @param FtwLiteDevice The private data of FTW_LITE driver\r |
d7dec593 | 429 | \r |
6aab8214 | 430 | @retval EFI_SUCCESS Spare block content is copied to boot block\r |
431 | @retval EFI_INVALID_PARAMETER Input parameter error\r | |
432 | @retval EFI_OUT_OF_RESOURCES Allocate memory error\r | |
433 | @retval EFI_ABORTED The function could not complete successfully\r | |
434 | Notes:\r | |
d7dec593 | 435 | \r |
6aab8214 | 436 | **/\r |
d7dec593 | 437 | EFI_STATUS\r |
438 | FlushSpareBlockToBootBlock (\r | |
439 | EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
ed66e1bc | 440 | );\r |
d7dec593 | 441 | \r |
6aab8214 | 442 | /**\r |
443 | Update a bit of state on a block device. The location of the bit is\r | |
444 | calculated by the (Lba, Offset, bit). Here bit is determined by the\r | |
445 | the name of a certain bit.\r | |
d7dec593 | 446 | \r |
d7dec593 | 447 | \r |
6aab8214 | 448 | @param FvBlock FVB Protocol interface to access SrcBlock and DestBlock\r |
449 | @param Lba Lba of a block\r | |
450 | @param Offset Offset on the Lba\r | |
451 | @param NewBit New value that will override the old value if it can be change\r | |
d7dec593 | 452 | \r |
6aab8214 | 453 | @retval EFI_SUCCESS A state bit has been updated successfully\r |
454 | @retval Others Access block device error.\r | |
455 | Notes:\r | |
456 | Assume all bits of State are inside the same BYTE.\r | |
457 | @retval EFI_ABORTED Read block fail\r | |
d7dec593 | 458 | \r |
6aab8214 | 459 | **/\r |
d7dec593 | 460 | EFI_STATUS\r |
461 | FtwUpdateFvState (\r | |
462 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
463 | IN EFI_LBA Lba,\r | |
464 | IN UINTN Offset,\r | |
465 | IN UINT8 NewBit\r | |
ed66e1bc | 466 | );\r |
d7dec593 | 467 | \r |
6aab8214 | 468 | /**\r |
469 | Get the last Write record pointer.\r | |
470 | The last record is the record whose 'complete' state hasn't been set.\r | |
471 | After all, this header may be a EMPTY header entry for next Allocate.\r | |
d7dec593 | 472 | \r |
d7dec593 | 473 | \r |
6aab8214 | 474 | @param FtwLiteDevice Private data of this driver\r |
475 | @param FtwLastRecord Pointer to retrieve the last write record\r | |
d7dec593 | 476 | \r |
6aab8214 | 477 | @retval EFI_SUCCESS Get the last write record successfully\r |
478 | @retval EFI_ABORTED The FTW work space is damaged\r | |
d7dec593 | 479 | \r |
6aab8214 | 480 | **/\r |
d7dec593 | 481 | EFI_STATUS\r |
482 | FtwGetLastRecord (\r | |
483 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
484 | OUT EFI_FTW_LITE_RECORD **FtwLastRecord\r | |
ed66e1bc | 485 | );\r |
d7dec593 | 486 | \r |
6aab8214 | 487 | /**\r |
d7dec593 | 488 | \r |
6aab8214 | 489 | Check whether a flash buffer is erased.\r |
d7dec593 | 490 | \r |
d7dec593 | 491 | \r |
6aab8214 | 492 | @param Polarity All 1 or all 0\r |
493 | @param Buffer Buffer to check\r | |
494 | @param BufferSize Size of the buffer\r | |
d7dec593 | 495 | \r |
6aab8214 | 496 | @return A BOOLEAN value indicating erased or not.\r |
497 | \r | |
498 | **/\r | |
d7dec593 | 499 | BOOLEAN\r |
500 | IsErasedFlashBuffer (\r | |
501 | IN BOOLEAN Polarity,\r | |
502 | IN UINT8 *Buffer,\r | |
503 | IN UINTN BufferSize\r | |
ed66e1bc | 504 | );\r |
d7dec593 | 505 | \r |
6aab8214 | 506 | /**\r |
507 | Initialize a work space when there is no work space.\r | |
d7dec593 | 508 | \r |
d7dec593 | 509 | \r |
6aab8214 | 510 | @param WorkingHeader Pointer of working block header\r |
d7dec593 | 511 | \r |
6aab8214 | 512 | @retval EFI_SUCCESS The function completed successfully\r |
513 | @retval EFI_ABORTED The function could not complete successfully.\r | |
d7dec593 | 514 | \r |
6aab8214 | 515 | **/\r |
d7dec593 | 516 | EFI_STATUS\r |
517 | InitWorkSpaceHeader (\r | |
518 | IN EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *WorkingHeader\r | |
ed66e1bc | 519 | );\r |
d7dec593 | 520 | \r |
6aab8214 | 521 | /**\r |
522 | Read from working block to refresh the work space in memory.\r | |
d7dec593 | 523 | \r |
d7dec593 | 524 | \r |
6aab8214 | 525 | @param FtwLiteDevice Point to private data of FTW driver\r |
d7dec593 | 526 | \r |
6aab8214 | 527 | @retval EFI_SUCCESS The function completed successfully\r |
528 | @retval EFI_ABORTED The function could not complete successfully.\r | |
d7dec593 | 529 | \r |
6aab8214 | 530 | **/\r |
d7dec593 | 531 | EFI_STATUS\r |
532 | WorkSpaceRefresh (\r | |
533 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
ed66e1bc | 534 | );\r |
d7dec593 | 535 | \r |
6aab8214 | 536 | /**\r |
537 | Check to see if it is a valid work space.\r | |
d7dec593 | 538 | \r |
d7dec593 | 539 | \r |
6aab8214 | 540 | @param WorkingHeader Pointer of working block header\r |
d7dec593 | 541 | \r |
6aab8214 | 542 | @retval EFI_SUCCESS The function completed successfully\r |
543 | @retval EFI_ABORTED The function could not complete successfully.\r | |
d7dec593 | 544 | \r |
6aab8214 | 545 | **/\r |
d7dec593 | 546 | BOOLEAN\r |
547 | IsValidWorkSpace (\r | |
548 | IN EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *WorkingHeader\r | |
ed66e1bc | 549 | );\r |
d7dec593 | 550 | \r |
6aab8214 | 551 | /**\r |
552 | Reclaim the work space on the working block.\r | |
d7dec593 | 553 | \r |
d7dec593 | 554 | \r |
6aab8214 | 555 | @param FtwLiteDevice Point to private data of FTW driver\r |
e11ae3a5 | 556 | @param PreserveRecord Whether to preserve the working record is needed\r |
d7dec593 | 557 | \r |
6aab8214 | 558 | @retval EFI_SUCCESS The function completed successfully\r |
559 | @retval EFI_OUT_OF_RESOURCES Allocate memory error\r | |
560 | @retval EFI_ABORTED The function could not complete successfully\r | |
d7dec593 | 561 | \r |
6aab8214 | 562 | **/\r |
d7dec593 | 563 | EFI_STATUS\r |
564 | FtwReclaimWorkSpace (\r | |
e11ae3a5 LG |
565 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r |
566 | IN BOOLEAN PreserveRecord\r | |
ed66e1bc | 567 | );\r |
d7dec593 | 568 | \r |
569 | #endif\r |