]>
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 | |
153 | )\r | |
d7dec593 | 154 | ;\r |
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 | |
d7dec593 | 192 | )\r |
d7dec593 | 193 | ;\r |
194 | \r | |
195 | //\r | |
196 | // Internal functions\r | |
197 | //\r | |
6aab8214 | 198 | /**\r |
199 | Restarts a previously interrupted write. The caller must provide the\r | |
200 | block protocol needed to complete the interrupted write.\r | |
201 | \r | |
202 | \r | |
203 | @param FtwLiteDevice The private data of FTW_LITE driver\r | |
204 | FvbHandle - The handle of FVB protocol that provides services for\r | |
205 | reading, writing, and erasing the target block.\r | |
206 | \r | |
207 | @retval EFI_SUCCESS The function completed successfully\r | |
208 | @retval EFI_ACCESS_DENIED No pending writes exist\r | |
209 | @retval EFI_NOT_FOUND FVB protocol not found by the handle\r | |
210 | @retval EFI_ABORTED The function could not complete successfully\r | |
211 | \r | |
212 | **/\r | |
d7dec593 | 213 | EFI_STATUS\r |
214 | FtwRestart (\r | |
215 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
216 | )\r | |
6aab8214 | 217 | ;\r |
d7dec593 | 218 | \r |
6aab8214 | 219 | /**\r |
220 | Aborts all previous allocated writes.\r | |
d7dec593 | 221 | \r |
d7dec593 | 222 | \r |
6aab8214 | 223 | @param FtwLiteDevice The private data of FTW_LITE driver\r |
d7dec593 | 224 | \r |
6aab8214 | 225 | @retval EFI_SUCCESS The function completed successfully\r |
226 | @retval EFI_ABORTED The function could not complete successfully.\r | |
227 | @retval EFI_NOT_FOUND No allocated writes exist.\r | |
d7dec593 | 228 | \r |
6aab8214 | 229 | **/\r |
d7dec593 | 230 | EFI_STATUS\r |
231 | FtwAbort (\r | |
232 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
233 | )\r | |
6aab8214 | 234 | ;\r |
d7dec593 | 235 | \r |
d7dec593 | 236 | \r |
6aab8214 | 237 | /**\r |
238 | Write a record with fault tolerant mannaer.\r | |
239 | Since the content has already backuped in spare block, the write is\r | |
240 | guaranteed to be completed with fault tolerant manner.\r | |
d7dec593 | 241 | \r |
d7dec593 | 242 | \r |
6aab8214 | 243 | @param FtwLiteDevice The private data of FTW_LITE driver\r |
244 | @param Fvb The FVB protocol that provides services for\r | |
245 | reading, writing, and erasing the target block.\r | |
d7dec593 | 246 | \r |
6aab8214 | 247 | @retval EFI_SUCCESS The function completed successfully\r |
248 | @retval EFI_ABORTED The function could not complete successfully\r | |
d7dec593 | 249 | \r |
6aab8214 | 250 | **/\r |
d7dec593 | 251 | EFI_STATUS\r |
252 | FtwWriteRecord (\r | |
253 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
254 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb\r | |
255 | )\r | |
6aab8214 | 256 | ;\r |
d7dec593 | 257 | \r |
6aab8214 | 258 | /**\r |
259 | To Erase one block. The size is FTW_BLOCK_SIZE\r | |
d7dec593 | 260 | \r |
d7dec593 | 261 | \r |
6aab8214 | 262 | @param FtwLiteDevice Calling context\r |
263 | @param FvBlock FVB Protocol interface\r | |
264 | @param Lba Lba of the firmware block\r | |
d7dec593 | 265 | \r |
6aab8214 | 266 | @retval EFI_SUCCESS Block LBA is Erased successfully\r |
267 | @retval Others Error occurs\r | |
d7dec593 | 268 | \r |
6aab8214 | 269 | **/\r |
d7dec593 | 270 | EFI_STATUS\r |
271 | FtwEraseBlock (\r | |
272 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
273 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
274 | EFI_LBA Lba\r | |
275 | )\r | |
6aab8214 | 276 | ;\r |
d7dec593 | 277 | \r |
6aab8214 | 278 | /**\r |
d7dec593 | 279 | \r |
6aab8214 | 280 | Erase spare block.\r |
d7dec593 | 281 | \r |
d7dec593 | 282 | \r |
6aab8214 | 283 | @param FtwLiteDevice Calling context\r |
d7dec593 | 284 | \r |
6aab8214 | 285 | @retval EFI_SUCCESS The erase request was successfully\r |
286 | completed.\r | |
287 | \r | |
288 | @retval EFI_ACCESS_DENIED The firmware volume is in the\r | |
289 | WriteDisabled state.\r | |
290 | @retval EFI_DEVICE_ERROR The block device is not functioning\r | |
291 | correctly and could not be written.\r | |
292 | The firmware device may have been\r | |
293 | partially erased.\r | |
294 | @retval EFI_INVALID_PARAMETER One or more of the LBAs listed\r | |
295 | in the variable argument list do\r | |
296 | not exist in the firmware volume. \r | |
297 | \r | |
298 | **/\r | |
d7dec593 | 299 | EFI_STATUS\r |
300 | FtwEraseSpareBlock (\r | |
301 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
302 | )\r | |
6aab8214 | 303 | ;\r |
d7dec593 | 304 | \r |
6aab8214 | 305 | /**\r |
306 | Retrive the proper FVB protocol interface by HANDLE.\r | |
d7dec593 | 307 | \r |
d7dec593 | 308 | \r |
6aab8214 | 309 | @param FvBlockHandle The handle of FVB protocol that provides services for\r |
310 | reading, writing, and erasing the target block.\r | |
311 | @param FvBlock The interface of FVB protocol\r | |
d7dec593 | 312 | \r |
6aab8214 | 313 | @retval EFI_SUCCESS The function completed successfully\r |
314 | @retval EFI_ABORTED The function could not complete successfully\r | |
d7dec593 | 315 | \r |
6aab8214 | 316 | **/\r |
d7dec593 | 317 | EFI_STATUS\r |
318 | FtwGetFvbByHandle (\r | |
319 | IN EFI_HANDLE FvBlockHandle,\r | |
320 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r | |
321 | )\r | |
6aab8214 | 322 | ;\r |
d7dec593 | 323 | \r |
6aab8214 | 324 | /**\r |
d7dec593 | 325 | \r |
6aab8214 | 326 | Get firmware block by address.\r |
d7dec593 | 327 | \r |
d7dec593 | 328 | \r |
6aab8214 | 329 | @param Address Address specified the block\r |
330 | @param FvBlock The block caller wanted\r | |
331 | \r | |
332 | @retval EFI_SUCCESS The protocol instance if found.\r | |
333 | @retval EFI_NOT_FOUND Block not found\r | |
334 | \r | |
335 | **/\r | |
d7dec593 | 336 | EFI_STATUS\r |
337 | GetFvbByAddress (\r | |
338 | IN EFI_PHYSICAL_ADDRESS Address,\r | |
339 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r | |
340 | )\r | |
6aab8214 | 341 | ;\r |
d7dec593 | 342 | \r |
6aab8214 | 343 | /**\r |
d7dec593 | 344 | \r |
6aab8214 | 345 | Is it in working block?\r |
d7dec593 | 346 | \r |
d7dec593 | 347 | \r |
6aab8214 | 348 | @param FtwLiteDevice Calling context\r |
349 | @param FvBlock Fvb protocol instance\r | |
350 | @param Lba The block specified\r | |
d7dec593 | 351 | \r |
6aab8214 | 352 | @return A BOOLEAN value indicating in working block or not.\r |
d7dec593 | 353 | \r |
6aab8214 | 354 | **/\r |
d7dec593 | 355 | BOOLEAN\r |
356 | IsInWorkingBlock (\r | |
357 | EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
358 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
359 | EFI_LBA Lba\r | |
360 | )\r | |
6aab8214 | 361 | ;\r |
d7dec593 | 362 | \r |
6aab8214 | 363 | /**\r |
d7dec593 | 364 | \r |
6aab8214 | 365 | Check whether the block is a boot block.\r |
d7dec593 | 366 | \r |
d7dec593 | 367 | \r |
6aab8214 | 368 | @param FtwLiteDevice Calling context\r |
369 | @param FvBlock Fvb protocol instance\r | |
370 | @param Lba Lba value\r | |
d7dec593 | 371 | \r |
6aab8214 | 372 | @retval FALSE This is a boot block.\r |
373 | @retval TRUE This is not a boot block.\r | |
d7dec593 | 374 | \r |
6aab8214 | 375 | **/\r |
d7dec593 | 376 | BOOLEAN\r |
377 | IsBootBlock (\r | |
378 | EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
379 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
380 | EFI_LBA Lba\r | |
381 | )\r | |
6aab8214 | 382 | ;\r |
d7dec593 | 383 | \r |
6aab8214 | 384 | /**\r |
385 | Copy the content of spare block to a target block. Size is FTW_BLOCK_SIZE.\r | |
386 | Spare block is accessed by FTW backup FVB protocol interface. LBA is\r | |
387 | FtwLiteDevice->FtwSpareLba.\r | |
388 | Target block is accessed by FvBlock protocol interface. LBA is Lba.\r | |
d7dec593 | 389 | \r |
d7dec593 | 390 | \r |
6aab8214 | 391 | @param FtwLiteDevice The private data of FTW_LITE driver\r |
392 | @param FvBlock FVB Protocol interface to access target block\r | |
393 | @param Lba Lba of the target block\r | |
d7dec593 | 394 | \r |
6aab8214 | 395 | @retval EFI_SUCCESS Spare block content is copied to target block\r |
396 | @retval EFI_INVALID_PARAMETER Input parameter error\r | |
397 | @retval EFI_OUT_OF_RESOURCES Allocate memory error\r | |
398 | @retval EFI_ABORTED The function could not complete successfully\r | |
d7dec593 | 399 | \r |
6aab8214 | 400 | **/\r |
d7dec593 | 401 | EFI_STATUS\r |
402 | FlushSpareBlockToTargetBlock (\r | |
403 | EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
404 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
405 | EFI_LBA Lba\r | |
406 | )\r | |
d7dec593 | 407 | ;\r |
408 | \r | |
6aab8214 | 409 | /**\r |
410 | Copy the content of spare block to working block. Size is FTW_BLOCK_SIZE.\r | |
411 | Spare block is accessed by FTW backup FVB protocol interface. LBA is\r | |
412 | FtwLiteDevice->FtwSpareLba.\r | |
413 | Working block is accessed by FTW working FVB protocol interface. LBA is\r | |
414 | FtwLiteDevice->FtwWorkBlockLba.\r | |
415 | \r | |
416 | \r | |
417 | @param FtwLiteDevice The private data of FTW_LITE driver\r | |
418 | \r | |
419 | @retval EFI_SUCCESS Spare block content is copied to target block\r | |
420 | @retval EFI_OUT_OF_RESOURCES Allocate memory error\r | |
421 | @retval EFI_ABORTED The function could not complete successfully\r | |
422 | Notes:\r | |
423 | Since the working block header is important when FTW initializes, the\r | |
424 | state of the operation should be handled carefully. The Crc value is\r | |
425 | calculated without STATE element.\r | |
426 | \r | |
427 | **/\r | |
d7dec593 | 428 | EFI_STATUS\r |
429 | FlushSpareBlockToWorkingBlock (\r | |
430 | EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
431 | )\r | |
6aab8214 | 432 | ;\r |
d7dec593 | 433 | \r |
6aab8214 | 434 | /**\r |
435 | Copy the content of spare block to a boot block. Size is FTW_BLOCK_SIZE.\r | |
436 | Spare block is accessed by FTW backup FVB protocol interface. LBA is\r | |
437 | FtwLiteDevice->FtwSpareLba.\r | |
438 | Boot block is accessed by BootFvb protocol interface. LBA is 0.\r | |
d7dec593 | 439 | \r |
d7dec593 | 440 | \r |
6aab8214 | 441 | @param FtwLiteDevice The private data of FTW_LITE driver\r |
d7dec593 | 442 | \r |
6aab8214 | 443 | @retval EFI_SUCCESS Spare block content is copied to boot block\r |
444 | @retval EFI_INVALID_PARAMETER Input parameter error\r | |
445 | @retval EFI_OUT_OF_RESOURCES Allocate memory error\r | |
446 | @retval EFI_ABORTED The function could not complete successfully\r | |
447 | Notes:\r | |
d7dec593 | 448 | \r |
6aab8214 | 449 | **/\r |
d7dec593 | 450 | EFI_STATUS\r |
451 | FlushSpareBlockToBootBlock (\r | |
452 | EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
453 | )\r | |
6aab8214 | 454 | ;\r |
d7dec593 | 455 | \r |
6aab8214 | 456 | /**\r |
457 | Update a bit of state on a block device. The location of the bit is\r | |
458 | calculated by the (Lba, Offset, bit). Here bit is determined by the\r | |
459 | the name of a certain bit.\r | |
d7dec593 | 460 | \r |
d7dec593 | 461 | \r |
6aab8214 | 462 | @param FvBlock FVB Protocol interface to access SrcBlock and DestBlock\r |
463 | @param Lba Lba of a block\r | |
464 | @param Offset Offset on the Lba\r | |
465 | @param NewBit New value that will override the old value if it can be change\r | |
d7dec593 | 466 | \r |
6aab8214 | 467 | @retval EFI_SUCCESS A state bit has been updated successfully\r |
468 | @retval Others Access block device error.\r | |
469 | Notes:\r | |
470 | Assume all bits of State are inside the same BYTE.\r | |
471 | @retval EFI_ABORTED Read block fail\r | |
d7dec593 | 472 | \r |
6aab8214 | 473 | **/\r |
d7dec593 | 474 | EFI_STATUS\r |
475 | FtwUpdateFvState (\r | |
476 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r | |
477 | IN EFI_LBA Lba,\r | |
478 | IN UINTN Offset,\r | |
479 | IN UINT8 NewBit\r | |
480 | )\r | |
6aab8214 | 481 | ;\r |
d7dec593 | 482 | \r |
6aab8214 | 483 | /**\r |
484 | Get the last Write record pointer.\r | |
485 | The last record is the record whose 'complete' state hasn't been set.\r | |
486 | After all, this header may be a EMPTY header entry for next Allocate.\r | |
d7dec593 | 487 | \r |
d7dec593 | 488 | \r |
6aab8214 | 489 | @param FtwLiteDevice Private data of this driver\r |
490 | @param FtwLastRecord Pointer to retrieve the last write record\r | |
d7dec593 | 491 | \r |
6aab8214 | 492 | @retval EFI_SUCCESS Get the last write record successfully\r |
493 | @retval EFI_ABORTED The FTW work space is damaged\r | |
d7dec593 | 494 | \r |
6aab8214 | 495 | **/\r |
d7dec593 | 496 | EFI_STATUS\r |
497 | FtwGetLastRecord (\r | |
498 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r | |
499 | OUT EFI_FTW_LITE_RECORD **FtwLastRecord\r | |
500 | )\r | |
6aab8214 | 501 | ;\r |
d7dec593 | 502 | \r |
6aab8214 | 503 | /**\r |
d7dec593 | 504 | \r |
6aab8214 | 505 | Check whether a flash buffer is erased.\r |
d7dec593 | 506 | \r |
d7dec593 | 507 | \r |
6aab8214 | 508 | @param Polarity All 1 or all 0\r |
509 | @param Buffer Buffer to check\r | |
510 | @param BufferSize Size of the buffer\r | |
d7dec593 | 511 | \r |
6aab8214 | 512 | @return A BOOLEAN value indicating erased or not.\r |
513 | \r | |
514 | **/\r | |
d7dec593 | 515 | BOOLEAN\r |
516 | IsErasedFlashBuffer (\r | |
517 | IN BOOLEAN Polarity,\r | |
518 | IN UINT8 *Buffer,\r | |
519 | IN UINTN BufferSize\r | |
520 | )\r | |
6aab8214 | 521 | ;\r |
d7dec593 | 522 | \r |
6aab8214 | 523 | /**\r |
524 | Initialize a work space when there is no work space.\r | |
d7dec593 | 525 | \r |
d7dec593 | 526 | \r |
6aab8214 | 527 | @param WorkingHeader Pointer of working block header\r |
d7dec593 | 528 | \r |
6aab8214 | 529 | @retval EFI_SUCCESS The function completed successfully\r |
530 | @retval EFI_ABORTED The function could not complete successfully.\r | |
d7dec593 | 531 | \r |
6aab8214 | 532 | **/\r |
d7dec593 | 533 | EFI_STATUS\r |
534 | InitWorkSpaceHeader (\r | |
535 | IN EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *WorkingHeader\r | |
536 | )\r | |
6aab8214 | 537 | ;\r |
d7dec593 | 538 | \r |
6aab8214 | 539 | /**\r |
540 | Read from working block to refresh the work space in memory.\r | |
d7dec593 | 541 | \r |
d7dec593 | 542 | \r |
6aab8214 | 543 | @param FtwLiteDevice Point to private data of FTW driver\r |
d7dec593 | 544 | \r |
6aab8214 | 545 | @retval EFI_SUCCESS The function completed successfully\r |
546 | @retval EFI_ABORTED The function could not complete successfully.\r | |
d7dec593 | 547 | \r |
6aab8214 | 548 | **/\r |
d7dec593 | 549 | EFI_STATUS\r |
550 | WorkSpaceRefresh (\r | |
551 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice\r | |
552 | )\r | |
6aab8214 | 553 | ;\r |
d7dec593 | 554 | \r |
6aab8214 | 555 | /**\r |
556 | Check to see if it is a valid work space.\r | |
d7dec593 | 557 | \r |
d7dec593 | 558 | \r |
6aab8214 | 559 | @param WorkingHeader Pointer of working block header\r |
d7dec593 | 560 | \r |
6aab8214 | 561 | @retval EFI_SUCCESS The function completed successfully\r |
562 | @retval EFI_ABORTED The function could not complete successfully.\r | |
d7dec593 | 563 | \r |
6aab8214 | 564 | **/\r |
d7dec593 | 565 | BOOLEAN\r |
566 | IsValidWorkSpace (\r | |
567 | IN EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *WorkingHeader\r | |
568 | )\r | |
6aab8214 | 569 | ;\r |
d7dec593 | 570 | \r |
6aab8214 | 571 | /**\r |
572 | Reclaim the work space on the working block.\r | |
d7dec593 | 573 | \r |
d7dec593 | 574 | \r |
6aab8214 | 575 | @param FtwLiteDevice Point to private data of FTW driver\r |
e11ae3a5 | 576 | @param PreserveRecord Whether to preserve the working record is needed\r |
d7dec593 | 577 | \r |
6aab8214 | 578 | @retval EFI_SUCCESS The function completed successfully\r |
579 | @retval EFI_OUT_OF_RESOURCES Allocate memory error\r | |
580 | @retval EFI_ABORTED The function could not complete successfully\r | |
d7dec593 | 581 | \r |
6aab8214 | 582 | **/\r |
d7dec593 | 583 | EFI_STATUS\r |
584 | FtwReclaimWorkSpace (\r | |
e11ae3a5 LG |
585 | IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r |
586 | IN BOOLEAN PreserveRecord\r | |
d7dec593 | 587 | )\r |
d7dec593 | 588 | ;\r |
589 | \r | |
590 | #endif\r |