]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c
IntelFrameworkModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / FirmwareVolume / FwVolDxe / FwVolRead.c
CommitLineData
c2df8e13 1/** @file\r
2 Implements functions to read firmware file.\r
3\r
67a6cf6d 4 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
c2df8e13 5\r
c0a00b14 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
c2df8e13 7\r
8**/\r
9\r
10#include "FwVolDriver.h"\r
11\r
5eddabfc 12/**\r
67a6cf6d
SZ
13Required Alignment Alignment Value in FFS FFS_ATTRIB_DATA_ALIGNMENT2 Alignment Value in\r
14(bytes) Attributes Field in FFS Attributes Field Firmware Volume Interfaces\r
151 0 0 0\r
1616 1 0 4\r
17128 2 0 7\r
18512 3 0 9\r
191 KB 4 0 10\r
204 KB 5 0 12\r
2132 KB 6 0 15\r
2264 KB 7 0 16\r
23128 KB 0 1 17\r
24256 KB 1 1 18\r
25512 KB 2 1 19\r
261 MB 3 1 20\r
272 MB 4 1 21\r
284 MB 5 1 22\r
298 MB 6 1 23\r
3016 MB 7 1 24\r
5eddabfc
SZ
31**/\r
32UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};\r
67a6cf6d 33UINT8 mFvAttributes2[] = {17, 18, 19, 20, 21, 22, 23, 24};\r
c2df8e13 34\r
35/**\r
36 Convert the FFS File Attributes to FV File Attributes.\r
37\r
38 @param FfsAttributes The attributes of UINT8 type.\r
39\r
40 @return The attributes of EFI_FV_FILE_ATTRIBUTES\r
41\r
42**/\r
43EFI_FV_FILE_ATTRIBUTES\r
44FfsAttributes2FvFileAttributes (\r
45 IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes\r
46 )\r
47{\r
5eddabfc
SZ
48 UINT8 DataAlignment;\r
49 EFI_FV_FILE_ATTRIBUTES FileAttribute;\r
50\r
51 DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);\r
52 ASSERT (DataAlignment < 8);\r
53\r
67a6cf6d
SZ
54 if ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT_2) != 0) {\r
55 FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes2[DataAlignment];\r
56 } else {\r
57 FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];\r
58 }\r
5eddabfc
SZ
59\r
60 if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) {\r
61 FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED;\r
62 }\r
63\r
64 return FileAttribute;\r
c2df8e13 65}\r
66\r
67/**\r
68 Given the input key, search for the next matching file in the volume.\r
69\r
70 @param This Indicates the calling context.\r
71 @param Key Key is a pointer to a caller allocated\r
72 buffer that contains implementation specific\r
73 data that is used to track where to begin\r
74 the search for the next file. The size of\r
75 the buffer must be at least This->KeySize\r
76 bytes long. To reinitialize the search and\r
77 begin from the beginning of the firmware\r
78 volume, the entire buffer must be cleared to\r
79 zero. Other than clearing the buffer to\r
80 initiate a new search, the caller must not\r
81 modify the data in the buffer between calls\r
82 to GetNextFile().\r
83 @param FileType FileType is a pointer to a caller allocated\r
84 EFI_FV_FILETYPE. The GetNextFile() API can\r
85 filter it's search for files based on the\r
86 value of *FileType input. A *FileType input\r
87 of 0 causes GetNextFile() to search for\r
88 files of all types. If a file is found, the\r
89 file's type is returned in *FileType.\r
90 *FileType is not modified if no file is\r
91 found.\r
92 @param NameGuid NameGuid is a pointer to a caller allocated\r
93 EFI_GUID. If a file is found, the file's\r
94 name is returned in *NameGuid. *NameGuid is\r
95 not modified if no file is found.\r
96 @param Attributes Attributes is a pointer to a caller\r
97 allocated EFI_FV_FILE_ATTRIBUTES. If a file\r
98 is found, the file's attributes are returned\r
99 in *Attributes. *Attributes is not modified\r
100 if no file is found.\r
101 @param Size Size is a pointer to a caller allocated\r
102 UINTN. If a file is found, the file's size\r
103 is returned in *Size. *Size is not modified\r
104 if no file is found.\r
105\r
106 @retval EFI_SUCCESS Successfully find the file.\r
107 @retval EFI_DEVICE_ERROR Device error.\r
108 @retval EFI_ACCESS_DENIED Fv could not read.\r
109 @retval EFI_NOT_FOUND No matching file found.\r
110 @retval EFI_INVALID_PARAMETER Invalid parameter\r
111\r
112**/\r
113EFI_STATUS\r
114EFIAPI\r
115FvGetNextFile (\r
116 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
117 IN OUT VOID *Key,\r
118 IN OUT EFI_FV_FILETYPE *FileType,\r
119 OUT EFI_GUID *NameGuid,\r
120 OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r
121 OUT UINTN *Size\r
122 )\r
123{\r
124 EFI_STATUS Status;\r
125 FV_DEVICE *FvDevice;\r
126 EFI_FV_ATTRIBUTES FvAttributes;\r
127 EFI_FFS_FILE_HEADER *FfsFileHeader;\r
128 UINTN *KeyValue;\r
129 LIST_ENTRY *Link;\r
130 FFS_FILE_LIST_ENTRY *FfsFileEntry;\r
c2df8e13 131\r
132 FvDevice = FV_DEVICE_FROM_THIS (This);\r
133\r
134 Status = This->GetVolumeAttributes (This, &FvAttributes);\r
135 if (EFI_ERROR (Status)) {\r
136 return Status;\r
137 }\r
138\r
139 KeyValue = (UINTN *) Key;\r
140 FfsFileHeader = NULL;\r
141\r
142 //\r
143 // Check if read operation is enabled\r
144 //\r
145 if ((FvAttributes & EFI_FV2_READ_STATUS) == 0) {\r
146 return EFI_ACCESS_DENIED;\r
147 }\r
148\r
149 if (*FileType > EFI_FV_FILETYPE_SMM_CORE) {\r
150 //\r
151 // File type needs to be in 0 - 0x0D\r
152 //\r
153 return EFI_NOT_FOUND;\r
154 }\r
155\r
156 do {\r
157 if (*KeyValue == 0) {\r
158 //\r
159 // Search for 1st matching file\r
160 //\r
161 Link = &FvDevice->FfsFileListHeader;\r
162 if (Link->ForwardLink == &FvDevice->FfsFileListHeader) {\r
163 return EFI_NOT_FOUND;\r
164 }\r
165\r
166 FfsFileEntry = (FFS_FILE_LIST_ENTRY *) Link->ForwardLink;\r
167 FfsFileHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
168\r
169 //\r
170 // remember the key\r
171 //\r
172 *KeyValue = (UINTN) FfsFileEntry;\r
173\r
174 //\r
175 // we ignore pad files\r
176 //\r
177 if (FfsFileHeader->Type == EFI_FV_FILETYPE_FFS_PAD) {\r
178 continue;\r
179 }\r
180\r
181 if (*FileType == 0) {\r
182 break;\r
183 }\r
184\r
185 if (*FileType == FfsFileHeader->Type) {\r
186 break;\r
187 }\r
188\r
189 } else {\r
190 //\r
191 // Getting link from last Ffs\r
192 //\r
193 Link = (LIST_ENTRY *) (*KeyValue);\r
194 if (Link->ForwardLink == &FvDevice->FfsFileListHeader) {\r
195 return EFI_NOT_FOUND;\r
196 }\r
197\r
198 FfsFileEntry = (FFS_FILE_LIST_ENTRY *) Link->ForwardLink;\r
199 FfsFileHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
200\r
201 //\r
202 // remember the key\r
203 //\r
204 *KeyValue = (UINTN) FfsFileEntry;\r
205\r
206 //\r
207 // we ignore pad files\r
208 //\r
209 if (FfsFileHeader->Type == EFI_FV_FILETYPE_FFS_PAD) {\r
210 continue;\r
211 }\r
212\r
213 if (*FileType == EFI_FV_FILETYPE_ALL) {\r
214 break;\r
215 }\r
216\r
217 if (*FileType == FfsFileHeader->Type) {\r
218 break;\r
219 }\r
220 }\r
221 } while (Link->ForwardLink != &FvDevice->FfsFileListHeader);\r
222\r
223 //\r
224 // Cache this file entry\r
225 //\r
226 FvDevice->CurrentFfsFile = FfsFileEntry;\r
227\r
228 *FileType = FfsFileHeader->Type;\r
229 CopyGuid (NameGuid, &FfsFileHeader->Name);\r
230 *Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes);\r
5eddabfc
SZ
231 if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {\r
232 *Attributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;\r
233 }\r
c2df8e13 234\r
c2df8e13 235 //\r
236 // we need to substract the header size\r
237 //\r
23491d5c
SZ
238 if (IS_FFS_FILE2 (FfsFileHeader)) {\r
239 *Size = FFS_FILE2_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER2);\r
240 } else {\r
241 *Size = FFS_FILE_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
242 }\r
c2df8e13 243\r
244 if (CompareGuid (&gEfiFirmwareVolumeTopFileGuid, NameGuid)) {\r
245 //\r
246 // specially deal with VTF file\r
247 //\r
248 UINT8 *SrcPtr;\r
249 UINT32 Tmp;\r
250\r
23491d5c
SZ
251 if (IS_FFS_FILE2 (FfsFileHeader)) {\r
252 SrcPtr = ((UINT8 *) FfsFileHeader) + sizeof (EFI_FFS_FILE_HEADER2);\r
253 } else {\r
254 SrcPtr = ((UINT8 *) FfsFileHeader) + sizeof (EFI_FFS_FILE_HEADER);\r
255 }\r
c2df8e13 256\r
257 while (*Size >= 4) {\r
258 Tmp = *(UINT32 *) SrcPtr;\r
259 if (Tmp == 0) {\r
260 SrcPtr += 4;\r
261 (*Size) -= 4;\r
262 } else {\r
263 break;\r
264 }\r
265 }\r
266 }\r
267\r
268 return EFI_SUCCESS;\r
269}\r
270\r
271/**\r
272 Locates a file in the firmware volume and\r
273 copies it to the supplied buffer.\r
274\r
275 @param This Indicates the calling context.\r
276 @param NameGuid Pointer to an EFI_GUID, which is the\r
277 filename.\r
278 @param Buffer Buffer is a pointer to pointer to a buffer\r
279 in which the file or section contents or are\r
280 returned.\r
281 @param BufferSize BufferSize is a pointer to caller allocated\r
282 UINTN. On input *BufferSize indicates the\r
283 size in bytes of the memory region pointed\r
284 to by Buffer. On output, *BufferSize\r
285 contains the number of bytes required to\r
286 read the file.\r
287 @param FoundType FoundType is a pointer to a caller allocated\r
288 EFI_FV_FILETYPE that on successful return\r
289 from Read() contains the type of file read.\r
290 This output reflects the file type\r
291 irrespective of the value of the SectionType\r
292 input.\r
293 @param FileAttributes FileAttributes is a pointer to a caller\r
294 allocated EFI_FV_FILE_ATTRIBUTES. On\r
295 successful return from Read(),\r
296 *FileAttributes contains the attributes of\r
297 the file read.\r
298 @param AuthenticationStatus AuthenticationStatus is a pointer to a\r
299 caller allocated UINTN in which the\r
300 authentication status is returned.\r
301\r
302 @retval EFI_SUCCESS Successfully read to memory buffer.\r
303 @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.\r
304 @retval EFI_NOT_FOUND Not found.\r
305 @retval EFI_DEVICE_ERROR Device error.\r
306 @retval EFI_ACCESS_DENIED Could not read.\r
307 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
308 @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.\r
309\r
310**/\r
311EFI_STATUS\r
312EFIAPI\r
313FvReadFile (\r
314 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
315 IN CONST EFI_GUID *NameGuid,\r
316 IN OUT VOID **Buffer,\r
317 IN OUT UINTN *BufferSize,\r
318 OUT EFI_FV_FILETYPE *FoundType,\r
319 OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r
320 OUT UINT32 *AuthenticationStatus\r
321 )\r
322{\r
323 EFI_STATUS Status;\r
324 FV_DEVICE *FvDevice;\r
325 UINTN Key;\r
326 EFI_GUID SearchNameGuid;\r
327 EFI_FV_ATTRIBUTES FvAttributes;\r
328 EFI_FV_FILETYPE LocalFoundType;\r
329 EFI_FV_FILE_ATTRIBUTES LocalAttributes;\r
330 UINTN FileSize;\r
331 UINT8 *SrcPtr;\r
332 FFS_FILE_LIST_ENTRY *FfsFileEntry;\r
333 EFI_FFS_FILE_HEADER *FfsHeader;\r
334 UINT8 *FileBuffer;\r
335\r
336 if (NULL == This || NULL == NameGuid) {\r
337 return EFI_INVALID_PARAMETER;\r
338 }\r
339\r
340 FvDevice = FV_DEVICE_FROM_THIS (This);\r
341\r
342 Status = This->GetVolumeAttributes (This, &FvAttributes);\r
343 if (EFI_ERROR (Status)) {\r
344 return Status;\r
345 }\r
346 //\r
347 // First check to see that FV is enabled for reads...\r
348 //\r
349 if (0 == (FvAttributes & EFI_FV2_READ_STATUS)) {\r
350 return EFI_ACCESS_DENIED;\r
351 }\r
352\r
353 FfsHeader = NULL;\r
354\r
355 //\r
356 // Check if the file was read last time.\r
357 //\r
358 FfsFileEntry = FvDevice->CurrentFfsFile;\r
359\r
360 if (FfsFileEntry != NULL) {\r
361 FfsHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
362 }\r
363\r
364 if ((FfsFileEntry == NULL) || (!CompareGuid (&FfsHeader->Name, NameGuid))) {\r
365 //\r
366 // If not match or no file cached, search this file\r
367 //\r
368 Key = 0;\r
369 do {\r
370 LocalFoundType = 0;\r
371 Status = This->GetNextFile (\r
372 This,\r
373 &Key,\r
374 &LocalFoundType,\r
375 &SearchNameGuid,\r
376 &LocalAttributes,\r
377 &FileSize\r
378 );\r
379 if (EFI_ERROR (Status)) {\r
380 return EFI_NOT_FOUND;\r
381 }\r
382 } while (!CompareGuid (&SearchNameGuid, NameGuid));\r
383\r
384 //\r
385 // Get file entry\r
386 //\r
387 FfsFileEntry = (FFS_FILE_LIST_ENTRY *) Key;\r
388\r
389 //\r
390 // Update the cache\r
391 //\r
392 FvDevice->CurrentFfsFile = FfsFileEntry;\r
393\r
394 FfsHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
395\r
396 } else {\r
397 //\r
398 // Get File Size of the cached file\r
399 //\r
23491d5c
SZ
400 if (IS_FFS_FILE2 (FfsHeader)) {\r
401 FileSize = FFS_FILE2_SIZE (FfsHeader) - sizeof (EFI_FFS_FILE_HEADER2);\r
402 } else {\r
403 FileSize = FFS_FILE_SIZE (FfsHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
404 }\r
c2df8e13 405 }\r
406 //\r
407 // Get file info\r
408 //\r
409 *FoundType = FfsHeader->Type;\r
410 *FileAttributes = FfsAttributes2FvFileAttributes (FfsHeader->Attributes);\r
5eddabfc
SZ
411 if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {\r
412 *FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;\r
413 }\r
37136e06
SZ
414 //\r
415 // Inherit the authentication status.\r
416 //\r
417 *AuthenticationStatus = FvDevice->AuthenticationStatus;\r
c2df8e13 418\r
419 //\r
420 // If Buffer is NULL, we only want to get some information\r
421 //\r
422 if (Buffer == NULL) {\r
423 *BufferSize = FileSize;\r
424 return EFI_SUCCESS;\r
425 }\r
426\r
23491d5c
SZ
427 if (IS_FFS_FILE2 (FfsHeader)) {\r
428 SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER2);\r
429 } else {\r
430 SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);\r
431 }\r
c2df8e13 432\r
433 if (CompareGuid (&gEfiFirmwareVolumeTopFileGuid, NameGuid)) {\r
434 //\r
435 // specially deal with VTF file\r
436 //\r
437 UINT32 Tmp;\r
438\r
439 while (FileSize >= 4) {\r
440 Tmp = *(UINT32 *) SrcPtr;\r
441 if (Tmp == 0) {\r
442 SrcPtr += 4;\r
443 FileSize -= 4;\r
444 } else {\r
445 break;\r
446 }\r
447 }\r
448 }\r
449 //\r
450 // If we drop out of the above loop, we've found the correct file header...\r
451 //\r
452 if (*Buffer == NULL) {\r
453 FileBuffer = AllocateCopyPool (FileSize, SrcPtr);\r
454 if (FileBuffer == NULL) {\r
455 return EFI_OUT_OF_RESOURCES;\r
456 }\r
457\r
458 *BufferSize = FileSize;\r
459 *Buffer = FileBuffer;\r
460\r
461 return EFI_SUCCESS;\r
462 }\r
463 //\r
464 // If the user's buffer is smaller than the file size, then copy as much\r
465 // as we can and return an appropriate status.\r
466 //\r
467 if (FileSize > *BufferSize) {\r
468 CopyMem (*Buffer, SrcPtr, *BufferSize);\r
469 *BufferSize = FileSize;\r
470 return EFI_WARN_BUFFER_TOO_SMALL;\r
471 }\r
472 //\r
473 // User's buffer size is ok, so copy the entire file to their buffer.\r
474 //\r
475 *BufferSize = FileSize;\r
476 CopyMem (*Buffer, SrcPtr, *BufferSize);\r
477\r
478 return EFI_SUCCESS;\r
479}\r
480\r
481/**\r
482 Locates a section in a given FFS File and\r
483 copies it to the supplied buffer (not including section header).\r
484\r
485 @param This Indicates the calling context.\r
486 @param NameGuid Pointer to an EFI_GUID, which is the\r
487 filename.\r
488 @param SectionType Indicates the section type to return.\r
489 @param SectionInstance Indicates which instance of sections with a\r
490 type of SectionType to return.\r
491 @param Buffer Buffer is a pointer to pointer to a buffer\r
492 in which the file or section contents or are\r
493 returned.\r
494 @param BufferSize BufferSize is a pointer to caller allocated\r
495 UINTN.\r
496 @param AuthenticationStatus AuthenticationStatus is a pointer to a\r
497 caller allocated UINT32 in which the\r
498 authentication status is returned.\r
499\r
500 @retval EFI_SUCCESS Successfully read the file section into\r
501 buffer.\r
502 @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.\r
503 @retval EFI_NOT_FOUND Section not found.\r
504 @retval EFI_DEVICE_ERROR Device error.\r
505 @retval EFI_ACCESS_DENIED Could not read.\r
506 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
507\r
508**/\r
509EFI_STATUS\r
510EFIAPI\r
511FvReadFileSection (\r
512 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
513 IN CONST EFI_GUID *NameGuid,\r
514 IN EFI_SECTION_TYPE SectionType,\r
515 IN UINTN SectionInstance,\r
516 IN OUT VOID **Buffer,\r
517 IN OUT UINTN *BufferSize,\r
518 OUT UINT32 *AuthenticationStatus\r
519 )\r
520{\r
521 EFI_STATUS Status;\r
0c3a1db4 522 FV_DEVICE *FvDevice;\r
c2df8e13 523 EFI_FV_ATTRIBUTES FvAttributes;\r
524 EFI_FV_FILETYPE FileType;\r
525 EFI_FV_FILE_ATTRIBUTES FileAttributes;\r
526 UINTN FileSize;\r
527 UINT8 *FileBuffer;\r
528 EFI_SECTION_EXTRACTION_PROTOCOL *Sep;\r
529 UINTN StreamHandle;\r
530\r
531 if (NULL == This || NULL == NameGuid || Buffer == NULL) {\r
532 return EFI_INVALID_PARAMETER;\r
533 }\r
534\r
0c3a1db4
SZ
535 FvDevice = FV_DEVICE_FROM_THIS (This);\r
536\r
c2df8e13 537 Status = This->GetVolumeAttributes (This, &FvAttributes);\r
538 if (EFI_ERROR (Status)) {\r
539 return Status;\r
540 }\r
541 //\r
542 // First check to see that FV is enabled for reads...\r
543 //\r
544 if (0 == (FvAttributes & EFI_FV2_READ_STATUS)) {\r
545 return EFI_ACCESS_DENIED;\r
546 }\r
547 //\r
548 // Read the whole file into buffer\r
549 //\r
550 FileBuffer = NULL;\r
551 Status = This->ReadFile (\r
552 This,\r
553 NameGuid,\r
554 (VOID **) &FileBuffer,\r
555 &FileSize,\r
556 &FileType,\r
557 &FileAttributes,\r
558 AuthenticationStatus\r
559 );\r
560\r
561 if (EFI_ERROR (Status)) {\r
562 return Status;\r
563 }\r
564 //\r
565 // Check to see that the file actually HAS sections before we go any further.\r
566 //\r
567 if (FileType == EFI_FV_FILETYPE_RAW) {\r
568 FreePool (FileBuffer);\r
569 return EFI_NOT_FOUND;\r
570 }\r
571 //\r
572 // Located the protocol\r
573 //\r
574 Status = gBS->LocateProtocol (\r
575 &gEfiSectionExtractionProtocolGuid,\r
576 NULL,\r
577 (VOID **) &Sep\r
578 );\r
579 if (EFI_ERROR (Status)) {\r
580 FreePool (FileBuffer);\r
581 return Status;\r
582 }\r
583\r
584 Status = Sep->OpenSectionStream (\r
585 Sep,\r
586 FileSize,\r
587 FileBuffer,\r
588 &StreamHandle\r
589 );\r
590\r
591 if (EFI_ERROR (Status)) {\r
592 FreePool (FileBuffer);\r
593 return Status;\r
594 }\r
595\r
596 if (SectionType == 0) {\r
597 //\r
598 // We need the whole section stream\r
599 //\r
600 Status = Sep->GetSection (\r
601 Sep,\r
602 StreamHandle,\r
603 NULL,\r
604 NULL,\r
605 0,\r
606 Buffer,\r
607 BufferSize,\r
608 AuthenticationStatus\r
609 );\r
610 } else {\r
611 Status = Sep->GetSection (\r
612 Sep,\r
613 StreamHandle,\r
614 &SectionType,\r
615 NULL,\r
616 SectionInstance,\r
617 Buffer,\r
618 BufferSize,\r
619 AuthenticationStatus\r
620 );\r
621 }\r
0c3a1db4
SZ
622\r
623 if (!EFI_ERROR (Status)) {\r
624 //\r
625 // Inherit the authentication status.\r
626 //\r
627 *AuthenticationStatus |= FvDevice->AuthenticationStatus;\r
628 }\r
629\r
c2df8e13 630 //\r
631 // Handle AuthenticationStatus if necessary\r
632 //\r
633 Sep->CloseSectionStream (Sep, StreamHandle);\r
634\r
635 FreePool (FileBuffer);\r
636\r
637 return Status;\r
638}\r