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