]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c
ArmPlatformPkg/ArmVExpressSecLibRTSM: Only use extended name of system registers...
[mirror_edk2.git] / ArmPlatformPkg / Drivers / NorFlashDxe / NorFlashFvbDxe.c
CommitLineData
1e57a462 1/*++ @file NorFlashFvbDxe.c\r
2\r
2dff0c1a 3 Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r
1e57a462 4\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13 --*/\r
14\r
15#include <PiDxe.h>\r
16\r
17#include <Library/PcdLib.h>\r
18#include <Library/BaseLib.h>\r
19#include <Library/HobLib.h>\r
20#include <Library/UefiLib.h>\r
21#include <Library/BaseMemoryLib.h>\r
22#include <Library/MemoryAllocationLib.h>\r
1dbbfc17 23#include <Library/DxeServicesTableLib.h>\r
1e57a462 24#include <Library/UefiBootServicesTableLib.h>\r
25\r
26#include <Guid/VariableFormat.h>\r
27#include <Guid/SystemNvDataGuid.h>\r
28\r
29#include "NorFlashDxe.h"\r
30\r
1dbbfc17
OM
31STATIC EFI_EVENT mFvbVirtualAddrChangeEvent;\r
32STATIC UINTN mFlashNvStorageVariableBase;\r
1e57a462 33\r
34///\r
35/// The Firmware Volume Block Protocol is the low-level interface\r
36/// to a firmware volume. File-level access to a firmware volume\r
37/// should not be done using the Firmware Volume Block Protocol.\r
38/// Normal access to a firmware volume must use the Firmware\r
39/// Volume Protocol. Typically, only the file system driver that\r
40/// produces the Firmware Volume Protocol will bind to the\r
41/// Firmware Volume Block Protocol.\r
42///\r
43\r
44/**\r
45 Initialises the FV Header and Variable Store Header\r
46 to support variable operations.\r
47\r
48 @param[in] Ptr - Location to initialise the headers\r
49\r
50**/\r
51EFI_STATUS\r
52InitializeFvAndVariableStoreHeaders (\r
53 IN NOR_FLASH_INSTANCE *Instance\r
54 )\r
55{\r
56 EFI_STATUS Status;\r
57 VOID* Headers;\r
58 UINTN HeadersLength;\r
59 EFI_FIRMWARE_VOLUME_HEADER *FirmwareVolumeHeader;\r
60 VARIABLE_STORE_HEADER *VariableStoreHeader;\r
61\r
62 if (!Instance->Initialized && Instance->Initialize) {\r
63 Instance->Initialize (Instance);\r
64 }\r
65\r
66 HeadersLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(VARIABLE_STORE_HEADER);\r
67 Headers = AllocateZeroPool(HeadersLength);\r
68\r
69 // FirmwareVolumeHeader->FvLength is declared to have the Variable area AND the FTW working area AND the FTW Spare contiguous.\r
70 ASSERT(PcdGet32(PcdFlashNvStorageVariableBase) + PcdGet32(PcdFlashNvStorageVariableSize) == PcdGet32(PcdFlashNvStorageFtwWorkingBase));\r
71 ASSERT(PcdGet32(PcdFlashNvStorageFtwWorkingBase) + PcdGet32(PcdFlashNvStorageFtwWorkingSize) == PcdGet32(PcdFlashNvStorageFtwSpareBase));\r
72\r
73 // Check if the size of the area is at least one block size\r
74 ASSERT((PcdGet32(PcdFlashNvStorageVariableSize) > 0) && (PcdGet32(PcdFlashNvStorageVariableSize) / Instance->Media.BlockSize > 0));\r
75 ASSERT((PcdGet32(PcdFlashNvStorageFtwWorkingSize) > 0) && (PcdGet32(PcdFlashNvStorageFtwWorkingSize) / Instance->Media.BlockSize > 0));\r
76 ASSERT((PcdGet32(PcdFlashNvStorageFtwSpareSize) > 0) && (PcdGet32(PcdFlashNvStorageFtwSpareSize) / Instance->Media.BlockSize > 0));\r
77\r
78 // Ensure the Variable area Base Addresses are aligned on a block size boundaries\r
79 ASSERT(PcdGet32(PcdFlashNvStorageVariableBase) % Instance->Media.BlockSize == 0);\r
80 ASSERT(PcdGet32(PcdFlashNvStorageFtwWorkingBase) % Instance->Media.BlockSize == 0);\r
81 ASSERT(PcdGet32(PcdFlashNvStorageFtwSpareBase) % Instance->Media.BlockSize == 0);\r
82\r
83 //\r
84 // EFI_FIRMWARE_VOLUME_HEADER\r
85 //\r
86 FirmwareVolumeHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Headers;\r
87 CopyGuid (&FirmwareVolumeHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid);\r
88 FirmwareVolumeHeader->FvLength =\r
89 PcdGet32(PcdFlashNvStorageVariableSize) +\r
90 PcdGet32(PcdFlashNvStorageFtwWorkingSize) +\r
91 PcdGet32(PcdFlashNvStorageFtwSpareSize);\r
92 FirmwareVolumeHeader->Signature = EFI_FVH_SIGNATURE;\r
93 FirmwareVolumeHeader->Attributes = (EFI_FVB_ATTRIBUTES_2) (\r
94 EFI_FVB2_READ_ENABLED_CAP | // Reads may be enabled\r
95 EFI_FVB2_READ_STATUS | // Reads are currently enabled\r
96 EFI_FVB2_STICKY_WRITE | // A block erase is required to flip bits into EFI_FVB2_ERASE_POLARITY\r
97 EFI_FVB2_MEMORY_MAPPED | // It is memory mapped\r
98 EFI_FVB2_ERASE_POLARITY | // After erasure all bits take this value (i.e. '1')\r
99 EFI_FVB2_WRITE_STATUS | // Writes are currently enabled\r
100 EFI_FVB2_WRITE_ENABLED_CAP // Writes may be enabled\r
101 );\r
102 FirmwareVolumeHeader->HeaderLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY);\r
103 FirmwareVolumeHeader->Revision = EFI_FVH_REVISION;\r
104 FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->Media.LastBlock + 1;\r
105 FirmwareVolumeHeader->BlockMap[0].Length = Instance->Media.BlockSize;\r
106 FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0;\r
107 FirmwareVolumeHeader->BlockMap[1].Length = 0;\r
108 FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ((UINT16*)FirmwareVolumeHeader,FirmwareVolumeHeader->HeaderLength);\r
109\r
110 //\r
111 // VARIABLE_STORE_HEADER\r
112 //\r
d5cd447b 113 VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)Headers + FirmwareVolumeHeader->HeaderLength);\r
1e57a462 114 CopyGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid);\r
115 VariableStoreHeader->Size = PcdGet32(PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength;\r
116 VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED;\r
117 VariableStoreHeader->State = VARIABLE_STORE_HEALTHY;\r
118\r
119 // Install the combined super-header in the NorFlash\r
120 Status = FvbWrite (&Instance->FvbProtocol, 0, 0, &HeadersLength, Headers);\r
121\r
122 FreePool (Headers);\r
123 return Status;\r
124}\r
125\r
126/**\r
127 Check the integrity of firmware volume header.\r
128\r
129 @param[in] FwVolHeader - A pointer to a firmware volume header\r
130\r
131 @retval EFI_SUCCESS - The firmware volume is consistent\r
132 @retval EFI_NOT_FOUND - The firmware volume has been corrupted.\r
133\r
134**/\r
135EFI_STATUS\r
136ValidateFvHeader (\r
137 IN NOR_FLASH_INSTANCE *Instance\r
138 )\r
139{\r
140 UINT16 Checksum;\r
141 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
142 VARIABLE_STORE_HEADER *VariableStoreHeader;\r
143 UINTN VariableStoreLength;\r
144 UINTN FvLength;\r
145\r
146 FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Instance->RegionBaseAddress;\r
147\r
148 FvLength = PcdGet32(PcdFlashNvStorageVariableSize) + PcdGet32(PcdFlashNvStorageFtwWorkingSize) +\r
149 PcdGet32(PcdFlashNvStorageFtwSpareSize);\r
150\r
151 //\r
152 // Verify the header revision, header signature, length\r
153 // Length of FvBlock cannot be 2**64-1\r
154 // HeaderLength cannot be an odd number\r
155 //\r
156 if ( (FwVolHeader->Revision != EFI_FVH_REVISION)\r
157 || (FwVolHeader->Signature != EFI_FVH_SIGNATURE)\r
158 || (FwVolHeader->FvLength != FvLength)\r
159 )\r
160 {\r
161 DEBUG ((EFI_D_ERROR, "ValidateFvHeader: No Firmware Volume header present\n"));\r
162 return EFI_NOT_FOUND;\r
163 }\r
164\r
165 // Check the Firmware Volume Guid\r
166 if( CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid) == FALSE ) {\r
167 DEBUG ((EFI_D_ERROR, "ValidateFvHeader: Firmware Volume Guid non-compatible\n"));\r
168 return EFI_NOT_FOUND;\r
169 }\r
170\r
171 // Verify the header checksum\r
172 Checksum = CalculateSum16((UINT16*)FwVolHeader, FwVolHeader->HeaderLength);\r
173 if (Checksum != 0) {\r
174 DEBUG ((EFI_D_ERROR, "ValidateFvHeader: FV checksum is invalid (Checksum:0x%X)\n",Checksum));\r
175 return EFI_NOT_FOUND;\r
176 }\r
177\r
d5cd447b 178 VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)FwVolHeader + FwVolHeader->HeaderLength);\r
1e57a462 179\r
180 // Check the Variable Store Guid\r
181 if( CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) == FALSE ) {\r
182 DEBUG ((EFI_D_ERROR, "ValidateFvHeader: Variable Store Guid non-compatible\n"));\r
183 return EFI_NOT_FOUND;\r
184 }\r
185\r
186 VariableStoreLength = PcdGet32 (PcdFlashNvStorageVariableSize) - FwVolHeader->HeaderLength;\r
187 if (VariableStoreHeader->Size != VariableStoreLength) {\r
188 DEBUG ((EFI_D_ERROR, "ValidateFvHeader: Variable Store Length does not match\n"));\r
189 return EFI_NOT_FOUND;\r
190 }\r
191\r
192 return EFI_SUCCESS;\r
193}\r
194\r
195/**\r
196 The GetAttributes() function retrieves the attributes and\r
197 current settings of the block.\r
198\r
199 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r
200\r
201 @param Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the attributes and\r
202 current settings are returned.\r
203 Type EFI_FVB_ATTRIBUTES_2 is defined in EFI_FIRMWARE_VOLUME_HEADER.\r
204\r
205 @retval EFI_SUCCESS The firmware volume attributes were returned.\r
206\r
207 **/\r
208EFI_STATUS\r
209EFIAPI\r
210FvbGetAttributes(\r
211 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r
212 OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
213 )\r
214{\r
215 EFI_FVB_ATTRIBUTES_2 FlashFvbAttributes;\r
216 NOR_FLASH_INSTANCE *Instance;\r
217\r
218 Instance = INSTANCE_FROM_FVB_THIS(This);\r
219\r
220 FlashFvbAttributes = (EFI_FVB_ATTRIBUTES_2) (\r
221\r
222 EFI_FVB2_READ_ENABLED_CAP | // Reads may be enabled\r
223 EFI_FVB2_READ_STATUS | // Reads are currently enabled\r
224 EFI_FVB2_STICKY_WRITE | // A block erase is required to flip bits into EFI_FVB2_ERASE_POLARITY\r
225 EFI_FVB2_MEMORY_MAPPED | // It is memory mapped\r
226 EFI_FVB2_ERASE_POLARITY // After erasure all bits take this value (i.e. '1')\r
227\r
228 );\r
229\r
230 // Check if it is write protected\r
231 if (Instance->Media.ReadOnly != TRUE) {\r
232\r
233 FlashFvbAttributes = FlashFvbAttributes |\r
234 EFI_FVB2_WRITE_STATUS | // Writes are currently enabled\r
235 EFI_FVB2_WRITE_ENABLED_CAP; // Writes may be enabled\r
236 }\r
237\r
238 *Attributes = FlashFvbAttributes;\r
239\r
240 DEBUG ((DEBUG_BLKIO, "FvbGetAttributes(0x%X)\n", *Attributes));\r
241\r
242 return EFI_SUCCESS;\r
243}\r
244\r
245/**\r
246 The SetAttributes() function sets configurable firmware volume attributes\r
247 and returns the new settings of the firmware volume.\r
248\r
249\r
250 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r
251\r
252 @param Attributes On input, Attributes is a pointer to EFI_FVB_ATTRIBUTES_2\r
253 that contains the desired firmware volume settings.\r
254 On successful return, it contains the new settings of\r
255 the firmware volume.\r
256 Type EFI_FVB_ATTRIBUTES_2 is defined in EFI_FIRMWARE_VOLUME_HEADER.\r
257\r
258 @retval EFI_SUCCESS The firmware volume attributes were returned.\r
259\r
260 @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with the capabilities\r
261 as declared in the firmware volume header.\r
262\r
263 **/\r
264EFI_STATUS\r
265EFIAPI\r
266FvbSetAttributes(\r
267 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r
268 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
269 )\r
270{\r
271 DEBUG ((DEBUG_BLKIO, "FvbSetAttributes(0x%X) is not supported\n",*Attributes));\r
272 return EFI_UNSUPPORTED;\r
273}\r
274\r
275/**\r
276 The GetPhysicalAddress() function retrieves the base address of\r
277 a memory-mapped firmware volume. This function should be called\r
278 only for memory-mapped firmware volumes.\r
279\r
280 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r
281\r
282 @param Address Pointer to a caller-allocated\r
283 EFI_PHYSICAL_ADDRESS that, on successful\r
284 return from GetPhysicalAddress(), contains the\r
285 base address of the firmware volume.\r
286\r
287 @retval EFI_SUCCESS The firmware volume base address was returned.\r
288\r
289 @retval EFI_NOT_SUPPORTED The firmware volume is not memory mapped.\r
290\r
291 **/\r
292EFI_STATUS\r
293EFIAPI\r
294FvbGetPhysicalAddress (\r
295 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r
296 OUT EFI_PHYSICAL_ADDRESS *Address\r
297 )\r
298{\r
299 NOR_FLASH_INSTANCE *Instance;\r
300\r
301 Instance = INSTANCE_FROM_FVB_THIS(This);\r
302\r
303 DEBUG ((DEBUG_BLKIO, "FvbGetPhysicalAddress(BaseAddress=0x%08x)\n", Instance->RegionBaseAddress));\r
304\r
305 ASSERT(Address != NULL);\r
306\r
1dbbfc17 307 *Address = mFlashNvStorageVariableBase;\r
1e57a462 308 return EFI_SUCCESS;\r
309}\r
310\r
311/**\r
312 The GetBlockSize() function retrieves the size of the requested\r
313 block. It also returns the number of additional blocks with\r
314 the identical size. The GetBlockSize() function is used to\r
315 retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER).\r
316\r
317\r
318 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r
319\r
320 @param Lba Indicates the block for which to return the size.\r
321\r
322 @param BlockSize Pointer to a caller-allocated UINTN in which\r
323 the size of the block is returned.\r
324\r
325 @param NumberOfBlocks Pointer to a caller-allocated UINTN in\r
326 which the number of consecutive blocks,\r
327 starting with Lba, is returned. All\r
328 blocks in this range have a size of\r
329 BlockSize.\r
330\r
331\r
332 @retval EFI_SUCCESS The firmware volume base address was returned.\r
333\r
334 @retval EFI_INVALID_PARAMETER The requested LBA is out of range.\r
335\r
336 **/\r
337EFI_STATUS\r
338EFIAPI\r
339FvbGetBlockSize (\r
340 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r
341 IN EFI_LBA Lba,\r
342 OUT UINTN *BlockSize,\r
343 OUT UINTN *NumberOfBlocks\r
344 )\r
345{\r
346 EFI_STATUS Status;\r
347 NOR_FLASH_INSTANCE *Instance;\r
348\r
349 Instance = INSTANCE_FROM_FVB_THIS(This);\r
350\r
351 DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize(Lba=%ld, BlockSize=0x%x, LastBlock=%ld)\n", Lba, Instance->Media.BlockSize, Instance->Media.LastBlock));\r
352\r
353 if (Lba > Instance->Media.LastBlock) {\r
354 DEBUG ((EFI_D_ERROR, "FvbGetBlockSize: ERROR - Parameter LBA %ld is beyond the last Lba (%ld).\n", Lba, Instance->Media.LastBlock));\r
355 Status = EFI_INVALID_PARAMETER;\r
356 } else {\r
357 // This is easy because in this platform each NorFlash device has equal sized blocks.\r
358 *BlockSize = (UINTN) Instance->Media.BlockSize;\r
359 *NumberOfBlocks = (UINTN) (Instance->Media.LastBlock - Lba + 1);\r
360\r
361 DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize: *BlockSize=0x%x, *NumberOfBlocks=0x%x.\n", *BlockSize, *NumberOfBlocks));\r
362\r
363 Status = EFI_SUCCESS;\r
364 }\r
365\r
366 return Status;\r
367}\r
368\r
369/**\r
370 Reads the specified number of bytes into a buffer from the specified block.\r
371\r
372 The Read() function reads the requested number of bytes from the\r
373 requested block and stores them in the provided buffer.\r
374 Implementations should be mindful that the firmware volume\r
375 might be in the ReadDisabled state. If it is in this state,\r
376 the Read() function must return the status code\r
377 EFI_ACCESS_DENIED without modifying the contents of the\r
378 buffer. The Read() function must also prevent spanning block\r
379 boundaries. If a read is requested that would span a block\r
380 boundary, the read must read up to the boundary but not\r
381 beyond. The output parameter NumBytes must be set to correctly\r
382 indicate the number of bytes actually read. The caller must be\r
383 aware that a read may be partially completed.\r
384\r
385 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r
386\r
387 @param Lba The starting logical block index from which to read.\r
388\r
389 @param Offset Offset into the block at which to begin reading.\r
390\r
391 @param NumBytes Pointer to a UINTN.\r
392 At entry, *NumBytes contains the total size of the buffer.\r
393 At exit, *NumBytes contains the total number of bytes read.\r
394\r
395 @param Buffer Pointer to a caller-allocated buffer that will be used\r
396 to hold the data that is read.\r
397\r
398 @retval EFI_SUCCESS The firmware volume was read successfully, and contents are\r
399 in Buffer.\r
400\r
401 @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA boundary.\r
402 On output, NumBytes contains the total number of bytes\r
403 returned in Buffer.\r
404\r
405 @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state.\r
406\r
407 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be read.\r
408\r
409 **/\r
410EFI_STATUS\r
411EFIAPI\r
412FvbRead (\r
413 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r
414 IN EFI_LBA Lba,\r
415 IN UINTN Offset,\r
416 IN OUT UINTN *NumBytes,\r
417 IN OUT UINT8 *Buffer\r
418 )\r
419{\r
1e57a462 420 EFI_STATUS TempStatus;\r
421 UINTN BlockSize;\r
1e57a462 422 NOR_FLASH_INSTANCE *Instance;\r
423\r
424 Instance = INSTANCE_FROM_FVB_THIS(This);\r
425\r
426 DEBUG ((DEBUG_BLKIO, "FvbRead(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Instance->StartLba + Lba, Offset, *NumBytes, Buffer));\r
427\r
428 if (!Instance->Initialized && Instance->Initialize) {\r
429 Instance->Initialize(Instance);\r
430 }\r
431\r
518c243d 432 TempStatus = EFI_SUCCESS;\r
1e57a462 433\r
434 // Cache the block size to avoid de-referencing pointers all the time\r
435 BlockSize = Instance->Media.BlockSize;\r
436\r
437 DEBUG ((DEBUG_BLKIO, "FvbRead: Check if (Offset=0x%x + NumBytes=0x%x) <= BlockSize=0x%x\n", Offset, *NumBytes, BlockSize ));\r
438\r
439 // The read must not span block boundaries.\r
440 // We need to check each variable individually because adding two large values together overflows.\r
441 if ((Offset >= BlockSize) ||\r
442 (*NumBytes > BlockSize) ||\r
443 ((Offset + *NumBytes) > BlockSize)) {\r
444 DEBUG ((EFI_D_ERROR, "FvbRead: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize ));\r
445 return EFI_BAD_BUFFER_SIZE;\r
446 }\r
447\r
448 // We must have some bytes to read\r
449 if (*NumBytes == 0) {\r
450 return EFI_BAD_BUFFER_SIZE;\r
451 }\r
452\r
518c243d
HL
453 // Decide if we are doing full block reads or not.\r
454 if (*NumBytes % BlockSize != 0) {\r
455 TempStatus = NorFlashRead (Instance, Instance->StartLba + Lba, Offset, *NumBytes, Buffer);\r
456 if (EFI_ERROR (TempStatus)) {\r
457 return EFI_DEVICE_ERROR;\r
458 }\r
459 } else {\r
460 // Read NOR Flash data into shadow buffer\r
461 TempStatus = NorFlashReadBlocks (Instance, Instance->StartLba + Lba, BlockSize, Buffer);\r
462 if (EFI_ERROR (TempStatus)) {\r
463 // Return one of the pre-approved error statuses\r
464 return EFI_DEVICE_ERROR;\r
465 }\r
1e57a462 466 }\r
518c243d 467 return EFI_SUCCESS;\r
1e57a462 468}\r
469\r
470/**\r
471 Writes the specified number of bytes from the input buffer to the block.\r
472\r
473 The Write() function writes the specified number of bytes from\r
474 the provided buffer to the specified block and offset. If the\r
475 firmware volume is sticky write, the caller must ensure that\r
476 all the bits of the specified range to write are in the\r
477 EFI_FVB_ERASE_POLARITY state before calling the Write()\r
478 function, or else the result will be unpredictable. This\r
479 unpredictability arises because, for a sticky-write firmware\r
480 volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY\r
481 state but cannot flip it back again. Before calling the\r
482 Write() function, it is recommended for the caller to first call\r
483 the EraseBlocks() function to erase the specified block to\r
484 write. A block erase cycle will transition bits from the\r
485 (NOT)EFI_FVB_ERASE_POLARITY state back to the\r
486 EFI_FVB_ERASE_POLARITY state. Implementations should be\r
487 mindful that the firmware volume might be in the WriteDisabled\r
488 state. If it is in this state, the Write() function must\r
489 return the status code EFI_ACCESS_DENIED without modifying the\r
490 contents of the firmware volume. The Write() function must\r
491 also prevent spanning block boundaries. If a write is\r
492 requested that spans a block boundary, the write must store up\r
493 to the boundary but not beyond. The output parameter NumBytes\r
494 must be set to correctly indicate the number of bytes actually\r
495 written. The caller must be aware that a write may be\r
496 partially completed. All writes, partial or otherwise, must be\r
497 fully flushed to the hardware before the Write() service\r
498 returns.\r
499\r
500 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r
501\r
502 @param Lba The starting logical block index to write to.\r
503\r
504 @param Offset Offset into the block at which to begin writing.\r
505\r
506 @param NumBytes The pointer to a UINTN.\r
507 At entry, *NumBytes contains the total size of the buffer.\r
508 At exit, *NumBytes contains the total number of bytes actually written.\r
509\r
510 @param Buffer The pointer to a caller-allocated buffer that contains the source for the write.\r
511\r
512 @retval EFI_SUCCESS The firmware volume was written successfully.\r
513\r
514 @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary.\r
515 On output, NumBytes contains the total number of bytes\r
516 actually written.\r
517\r
518 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
519\r
520 @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not be written.\r
521\r
522\r
523 **/\r
524EFI_STATUS\r
525EFIAPI\r
526FvbWrite (\r
527 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r
528 IN EFI_LBA Lba,\r
529 IN UINTN Offset,\r
530 IN OUT UINTN *NumBytes,\r
531 IN UINT8 *Buffer\r
532 )\r
533{\r
1e57a462 534 EFI_STATUS TempStatus;\r
518c243d
HL
535 UINT32 Tmp;\r
536 UINT32 TmpBuf;\r
537 UINT32 WordToWrite;\r
538 UINT32 Mask;\r
539 UINTN DoErase;\r
540 UINTN BytesToWrite;\r
541 UINTN CurOffset;\r
542 UINTN WordAddr;\r
1e57a462 543 UINTN BlockSize;\r
1e57a462 544 NOR_FLASH_INSTANCE *Instance;\r
518c243d
HL
545 UINTN BlockAddress;\r
546 UINTN PrevBlockAddress;\r
547\r
548 PrevBlockAddress = 0;\r
1e57a462 549\r
550 Instance = INSTANCE_FROM_FVB_THIS(This);\r
551\r
552 if (!Instance->Initialized && Instance->Initialize) {\r
553 Instance->Initialize(Instance);\r
554 }\r
555\r
556 DEBUG ((DEBUG_BLKIO, "FvbWrite(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Instance->StartLba + Lba, Offset, *NumBytes, Buffer));\r
557\r
1e57a462 558 // Detect WriteDisabled state\r
559 if (Instance->Media.ReadOnly == TRUE) {\r
560 DEBUG ((EFI_D_ERROR, "FvbWrite: ERROR - Can not write: Device is in WriteDisabled state.\n"));\r
561 // It is in WriteDisabled state, return an error right away\r
562 return EFI_ACCESS_DENIED;\r
563 }\r
564\r
565 // Cache the block size to avoid de-referencing pointers all the time\r
566 BlockSize = Instance->Media.BlockSize;\r
567\r
568 // The write must not span block boundaries.\r
569 // We need to check each variable individually because adding two large values together overflows.\r
570 if ( ( Offset >= BlockSize ) ||\r
571 ( *NumBytes > BlockSize ) ||\r
572 ( (Offset + *NumBytes) > BlockSize ) ) {\r
573 DEBUG ((EFI_D_ERROR, "FvbWrite: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize ));\r
574 return EFI_BAD_BUFFER_SIZE;\r
575 }\r
576\r
577 // We must have some bytes to write\r
578 if (*NumBytes == 0) {\r
579 DEBUG ((EFI_D_ERROR, "FvbWrite: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize ));\r
580 return EFI_BAD_BUFFER_SIZE;\r
581 }\r
582\r
518c243d
HL
583 // Pick 128bytes as a good start for word operations as opposed to erasing the\r
584 // block and writing the data regardless if an erase is really needed.\r
585 // It looks like most individual NV variable writes are smaller than 128bytes.\r
586 if (*NumBytes <= 128) {\r
587 // Check to see if we need to erase before programming the data into NOR.\r
588 // If the destination bits are only changing from 1s to 0s we can just write.\r
589 // After a block is erased all bits in the block is set to 1.\r
590 // If any byte requires us to erase we just give up and rewrite all of it.\r
591 DoErase = 0;\r
592 BytesToWrite = *NumBytes;\r
593 CurOffset = Offset;\r
594\r
595 while (BytesToWrite > 0) {\r
596 // Read full word from NOR, splice as required. A word is the smallest\r
597 // unit we can write.\r
598 TempStatus = NorFlashRead (Instance, Instance->StartLba + Lba,\r
599 CurOffset & ~(0x3), sizeof(Tmp), &Tmp);\r
600 if (EFI_ERROR (TempStatus)) {\r
601 return EFI_DEVICE_ERROR;\r
602 }\r
603\r
604 // Physical address of word in NOR to write.\r
605 WordAddr = (CurOffset & ~(0x3)) + GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress,\r
606 Lba, BlockSize);\r
607 // The word of data that is to be written.\r
608 TmpBuf = *((UINT32*)(Buffer + (*NumBytes - BytesToWrite)));\r
609\r
610 // First do word aligned chunks.\r
611 if ((CurOffset & 0x3) == 0) {\r
612 if (BytesToWrite >= 4) {\r
613 // Is the destination still in 'erased' state?\r
614 if (~Tmp != 0) {\r
615 // Check to see if we are only changing bits to zero.\r
616 if ((Tmp ^ TmpBuf) & TmpBuf) {\r
617 DoErase = 1;\r
618 break;\r
619 }\r
620 }\r
621 // Write this word to NOR\r
622 WordToWrite = TmpBuf;\r
623 CurOffset += sizeof(TmpBuf);\r
624 BytesToWrite -= sizeof(TmpBuf);\r
625 } else {\r
626 // BytesToWrite < 4. Do small writes and left-overs\r
627 Mask = ~((~0) << (BytesToWrite * 8));\r
628 // Mask out the bytes we want.\r
629 TmpBuf &= Mask;\r
630 // Is the destination still in 'erased' state?\r
631 if ((Tmp & Mask) != Mask) {\r
632 // Check to see if we are only changing bits to zero.\r
633 if ((Tmp ^ TmpBuf) & TmpBuf) {\r
634 DoErase = 1;\r
635 break;\r
636 }\r
637 }\r
638 // Merge old and new data. Write merged word to NOR\r
639 WordToWrite = (Tmp & ~Mask) | TmpBuf;\r
640 CurOffset += BytesToWrite;\r
641 BytesToWrite = 0;\r
642 }\r
643 } else {\r
644 // Do multiple words, but starting unaligned.\r
645 if (BytesToWrite > (4 - (CurOffset & 0x3))) {\r
646 Mask = ~((~0) << ((CurOffset & 0x3) * 8));\r
647 // Mask out the bytes we want.\r
648 TmpBuf = (TmpBuf << ((CurOffset & 0x3) * 8)) & Mask;\r
649 // Is the destination still in 'erased' state?\r
650 if ((Tmp & Mask) != Mask) {\r
651 // Check to see if we are only changing bits to zero.\r
652 if ((Tmp ^ TmpBuf) & TmpBuf) {\r
653 DoErase = 1;\r
654 break;\r
655 }\r
656 }\r
657 // Merge old and new data. Write merged word to NOR\r
658 WordToWrite = (Tmp & ~Mask) | TmpBuf;\r
659 BytesToWrite -= (4 - (CurOffset & 0x3));\r
660 CurOffset += (4 - (CurOffset & 0x3));\r
661 } else {\r
662 // Unaligned and fits in one word.\r
663 Mask = (~((~0) << (BytesToWrite * 8))) << ((CurOffset & 0x3) * 8);\r
664 // Mask out the bytes we want.\r
665 TmpBuf = (TmpBuf << ((CurOffset & 0x3) * 8)) & Mask;\r
666 // Is the destination still in 'erased' state?\r
667 if ((Tmp & Mask) != Mask) {\r
668 // Check to see if we are only changing bits to zero.\r
669 if ((Tmp ^ TmpBuf) & TmpBuf) {\r
670 DoErase = 1;\r
671 break;\r
672 }\r
673 }\r
674 // Merge old and new data. Write merged word to NOR\r
675 WordToWrite = (Tmp & ~Mask) | TmpBuf;\r
676 CurOffset += BytesToWrite;\r
677 BytesToWrite = 0;\r
678 }\r
679 }\r
680\r
681 //\r
682 // Write the word to NOR.\r
683 //\r
684\r
685 BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, BlockSize);\r
686 if (BlockAddress != PrevBlockAddress) {\r
687 TempStatus = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress);\r
688 if (EFI_ERROR (TempStatus)) {\r
689 return EFI_DEVICE_ERROR;\r
690 }\r
691 PrevBlockAddress = BlockAddress;\r
692 }\r
693 TempStatus = NorFlashWriteSingleWord (Instance, WordAddr, WordToWrite);\r
694 if (EFI_ERROR (TempStatus)) {\r
695 return EFI_DEVICE_ERROR;\r
696 }\r
697 }\r
698 // Exit if we got here and could write all the data. Otherwise do the\r
699 // Erase-Write cycle.\r
700 if (!DoErase) {\r
701 return EFI_SUCCESS;\r
702 }\r
703 }\r
704\r
705 // Check we did get some memory. Buffer is BlockSize.\r
2dff0c1a
OM
706 if (Instance->FvbBuffer == NULL) {\r
707 DEBUG ((EFI_D_ERROR, "FvbWrite: ERROR - Buffer not ready\n"));\r
1e57a462 708 return EFI_DEVICE_ERROR;\r
709 }\r
710\r
711 // Read NOR Flash data into shadow buffer\r
2dff0c1a 712 TempStatus = NorFlashReadBlocks (Instance, Instance->StartLba + Lba, BlockSize, Instance->FvbBuffer);\r
1e57a462 713 if (EFI_ERROR (TempStatus)) {\r
714 // Return one of the pre-approved error statuses\r
2dff0c1a 715 return EFI_DEVICE_ERROR;\r
1e57a462 716 }\r
717\r
718 // Put the data at the appropriate location inside the buffer area\r
2dff0c1a 719 CopyMem ((VOID*)((UINTN)Instance->FvbBuffer + Offset), Buffer, *NumBytes);\r
1e57a462 720\r
721 // Write the modified buffer back to the NorFlash\r
2dff0c1a 722 TempStatus = NorFlashWriteBlocks (Instance, Instance->StartLba + Lba, BlockSize, Instance->FvbBuffer);\r
1e57a462 723 if (EFI_ERROR (TempStatus)) {\r
724 // Return one of the pre-approved error statuses\r
2dff0c1a 725 return EFI_DEVICE_ERROR;\r
1e57a462 726 }\r
727\r
518c243d 728 return EFI_SUCCESS;\r
1e57a462 729}\r
730\r
731/**\r
732 Erases and initialises a firmware volume block.\r
733\r
734 The EraseBlocks() function erases one or more blocks as denoted\r
735 by the variable argument list. The entire parameter list of\r
736 blocks must be verified before erasing any blocks. If a block is\r
737 requested that does not exist within the associated firmware\r
738 volume (it has a larger index than the last block of the\r
739 firmware volume), the EraseBlocks() function must return the\r
740 status code EFI_INVALID_PARAMETER without modifying the contents\r
741 of the firmware volume. Implementations should be mindful that\r
742 the firmware volume might be in the WriteDisabled state. If it\r
743 is in this state, the EraseBlocks() function must return the\r
744 status code EFI_ACCESS_DENIED without modifying the contents of\r
745 the firmware volume. All calls to EraseBlocks() must be fully\r
746 flushed to the hardware before the EraseBlocks() service\r
747 returns.\r
748\r
749 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL\r
750 instance.\r
751\r
752 @param ... The variable argument list is a list of tuples.\r
753 Each tuple describes a range of LBAs to erase\r
754 and consists of the following:\r
755 - An EFI_LBA that indicates the starting LBA\r
756 - A UINTN that indicates the number of blocks to erase.\r
757\r
758 The list is terminated with an EFI_LBA_LIST_TERMINATOR.\r
759 For example, the following indicates that two ranges of blocks\r
760 (5-7 and 10-11) are to be erased:\r
761 EraseBlocks (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR);\r
762\r
763 @retval EFI_SUCCESS The erase request successfully completed.\r
764\r
765 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
766\r
767 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be written.\r
768 The firmware device may have been partially erased.\r
769\r
770 @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable argument list do\r
771 not exist in the firmware volume.\r
772\r
773 **/\r
774EFI_STATUS\r
775EFIAPI\r
776FvbEraseBlocks (\r
777 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r
778 ...\r
779 )\r
780{\r
781 EFI_STATUS Status;\r
782 VA_LIST Args;\r
783 UINTN BlockAddress; // Physical address of Lba to erase\r
784 EFI_LBA StartingLba; // Lba from which we start erasing\r
785 UINTN NumOfLba; // Number of Lba blocks to erase\r
786 NOR_FLASH_INSTANCE *Instance;\r
787\r
788 Instance = INSTANCE_FROM_FVB_THIS(This);\r
789\r
790 DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks()\n"));\r
791\r
792 Status = EFI_SUCCESS;\r
793\r
794 // Detect WriteDisabled state\r
795 if (Instance->Media.ReadOnly == TRUE) {\r
796 // Firmware volume is in WriteDisabled state\r
797 DEBUG ((EFI_D_ERROR, "FvbEraseBlocks: ERROR - Device is in WriteDisabled state.\n"));\r
798 return EFI_ACCESS_DENIED;\r
799 }\r
800\r
801 // Before erasing, check the entire list of parameters to ensure all specified blocks are valid\r
802\r
803 VA_START (Args, This);\r
804 do {\r
805 // Get the Lba from which we start erasing\r
806 StartingLba = VA_ARG (Args, EFI_LBA);\r
807\r
808 // Have we reached the end of the list?\r
809 if (StartingLba == EFI_LBA_LIST_TERMINATOR) {\r
810 //Exit the while loop\r
811 break;\r
812 }\r
813\r
814 // How many Lba blocks are we requested to erase?\r
815 NumOfLba = VA_ARG (Args, UINT32);\r
816\r
817 // All blocks must be within range\r
818 DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Check if: ( StartingLba=%ld + NumOfLba=%d - 1 ) > LastBlock=%ld.\n", Instance->StartLba + StartingLba, NumOfLba, Instance->Media.LastBlock));\r
819 if ((NumOfLba == 0) || ((Instance->StartLba + StartingLba + NumOfLba - 1) > Instance->Media.LastBlock)) {\r
820 VA_END (Args);\r
821 DEBUG ((EFI_D_ERROR, "FvbEraseBlocks: ERROR - Lba range goes past the last Lba.\n"));\r
822 Status = EFI_INVALID_PARAMETER;\r
823 goto EXIT;\r
824 }\r
825 } while (TRUE);\r
826 VA_END (Args);\r
827\r
828 //\r
829 // To get here, all must be ok, so start erasing\r
830 //\r
831 VA_START (Args, This);\r
832 do {\r
833 // Get the Lba from which we start erasing\r
834 StartingLba = VA_ARG (Args, EFI_LBA);\r
835\r
836 // Have we reached the end of the list?\r
837 if (StartingLba == EFI_LBA_LIST_TERMINATOR) {\r
838 // Exit the while loop\r
839 break;\r
840 }\r
841\r
842 // How many Lba blocks are we requested to erase?\r
843 NumOfLba = VA_ARG (Args, UINT32);\r
844\r
845 // Go through each one and erase it\r
846 while (NumOfLba > 0) {\r
847\r
848 // Get the physical address of Lba to erase\r
849 BlockAddress = GET_NOR_BLOCK_ADDRESS (\r
850 Instance->RegionBaseAddress,\r
851 Instance->StartLba + StartingLba,\r
852 Instance->Media.BlockSize\r
853 );\r
854\r
855 // Erase it\r
856 DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Erasing Lba=%ld @ 0x%08x.\n", Instance->StartLba + StartingLba, BlockAddress));\r
857 Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress);\r
858 if (EFI_ERROR(Status)) {\r
859 VA_END (Args);\r
860 Status = EFI_DEVICE_ERROR;\r
861 goto EXIT;\r
862 }\r
863\r
864 // Move to the next Lba\r
865 StartingLba++;\r
866 NumOfLba--;\r
867 }\r
868 } while (TRUE);\r
869 VA_END (Args);\r
870\r
871EXIT:\r
872 return Status;\r
873}\r
874\r
1dbbfc17
OM
875/**\r
876 Fixup internal data so that EFI can be call in virtual mode.\r
877 Call the passed in Child Notify event and convert any pointers in\r
878 lib to virtual mode.\r
879\r
880 @param[in] Event The Event that is being processed\r
881 @param[in] Context Event Context\r
882**/\r
883VOID\r
884EFIAPI\r
885FvbVirtualNotifyEvent (\r
886 IN EFI_EVENT Event,\r
887 IN VOID *Context\r
888 )\r
889{\r
890 EfiConvertPointer (0x0, (VOID**)&mFlashNvStorageVariableBase);\r
891 return;\r
892}\r
893\r
1e57a462 894EFI_STATUS\r
895EFIAPI\r
896NorFlashFvbInitialize (\r
897 IN NOR_FLASH_INSTANCE* Instance\r
898 )\r
899{\r
900 EFI_STATUS Status;\r
901 UINT32 FvbNumLba;\r
902 EFI_BOOT_MODE BootMode;\r
1dbbfc17 903 UINTN RuntimeMmioRegionSize;\r
1e57a462 904\r
905 DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));\r
906\r
907 Instance->Initialized = TRUE;\r
1dbbfc17 908 mFlashNvStorageVariableBase = FixedPcdGet32 (PcdFlashNvStorageVariableBase);\r
1e57a462 909\r
910 // Set the index of the first LBA for the FVB\r
911 Instance->StartLba = (PcdGet32 (PcdFlashNvStorageVariableBase) - Instance->RegionBaseAddress) / Instance->Media.BlockSize;\r
912\r
913 BootMode = GetBootModeHob ();\r
914 if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {\r
915 Status = EFI_INVALID_PARAMETER;\r
916 } else {\r
917 // Determine if there is a valid header at the beginning of the NorFlash\r
918 Status = ValidateFvHeader (Instance);\r
919 }\r
920\r
921 // Install the Default FVB header if required \r
922 if (EFI_ERROR(Status)) {\r
923 // There is no valid header, so time to install one.\r
924 DEBUG((EFI_D_ERROR,"NorFlashFvbInitialize: ERROR - The FVB Header is not valid. Installing a correct one for this volume.\n"));\r
925\r
926 // Erase all the NorFlash that is reserved for variable storage\r
927 FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) + PcdGet32(PcdFlashNvStorageFtwWorkingSize) + PcdGet32(PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize;\r
928\r
929 Status = FvbEraseBlocks (&Instance->FvbProtocol, (EFI_LBA)0, FvbNumLba, EFI_LBA_LIST_TERMINATOR);\r
930 if (EFI_ERROR(Status)) {\r
931 return Status;\r
932 }\r
933\r
934 // Install all appropriate headers\r
935 Status = InitializeFvAndVariableStoreHeaders (Instance);\r
936 if (EFI_ERROR(Status)) {\r
937 return Status;\r
938 }\r
939 }\r
1dbbfc17
OM
940\r
941 //\r
942 // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME\r
943 //\r
944\r
945 // Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory;\r
946 // even if we only use the small block region at the top of the NOR Flash.\r
947 // The reason is when the NOR Flash memory is set into program mode, the command\r
948 // is written as the base of the flash region (ie: Instance->DeviceBaseAddress)\r
949 RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size;\r
950\r
951 Status = gDS->AddMemorySpace (\r
952 EfiGcdMemoryTypeMemoryMappedIo,\r
953 Instance->DeviceBaseAddress, RuntimeMmioRegionSize,\r
954 EFI_MEMORY_UC | EFI_MEMORY_RUNTIME\r
955 );\r
956 ASSERT_EFI_ERROR (Status);\r
957\r
958 Status = gDS->SetMemorySpaceAttributes (\r
959 Instance->DeviceBaseAddress, RuntimeMmioRegionSize,\r
960 EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);\r
961 ASSERT_EFI_ERROR (Status);\r
962\r
963 //\r
964 // Register for the virtual address change event\r
965 //\r
966 Status = gBS->CreateEventEx (\r
967 EVT_NOTIFY_SIGNAL,\r
968 TPL_NOTIFY,\r
969 FvbVirtualNotifyEvent,\r
970 NULL,\r
971 &gEfiEventVirtualAddressChangeGuid,\r
972 &mFvbVirtualAddrChangeEvent\r
973 );\r
974 ASSERT_EFI_ERROR (Status);\r
975\r
1e57a462 976 return Status;\r
977}\r