3 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
4 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "StandaloneMmCore.h"
16 #include <Library/FvLib.h>
19 // List of file types supported by dispatcher
21 EFI_FV_FILETYPE mMmFileTypes
[] = {
23 0xE, //EFI_FV_FILETYPE_MM_STANDALONE,
25 // Note: DXE core will process the FV image file, so skip it in MM core
26 // EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
32 IN EFI_HANDLE FvHandle
,
34 IN UINTN Pe32DataSize
,
37 IN EFI_GUID
*DriverName
42 IN EFI_HANDLE FvHandle
47 IN EFI_HANDLE FvHandle
51 MmCoreFfsFindMmDriver (
52 IN EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
57 Given the pointer to the Firmware Volume Header find the
58 MM driver and return it's PE32 image.
61 FwVolHeader - Pointer to memory mapped FV
69 EFI_STATUS DepexStatus
;
70 EFI_FFS_FILE_HEADER
*FileHeader
;
71 EFI_FV_FILETYPE FileType
;
78 DEBUG ((DEBUG_INFO
, "MmCoreFfsFindMmDriver - 0x%x\n", FwVolHeader
));
80 if (FvHasBeenProcessed (FwVolHeader
)) {
84 FvIsBeingProcesssed (FwVolHeader
);
86 for (Index
= 0; Index
< sizeof (mMmFileTypes
) / sizeof (mMmFileTypes
[0]); Index
++) {
87 DEBUG ((DEBUG_INFO
, "Check MmFileTypes - 0x%x\n", mMmFileTypes
[Index
]));
88 FileType
= mMmFileTypes
[Index
];
91 Status
= FfsFindNextFile (FileType
, FwVolHeader
, &FileHeader
);
92 if (!EFI_ERROR (Status
)) {
93 Status
= FfsFindSectionData (EFI_SECTION_PE32
, FileHeader
, &Pe32Data
, &Pe32DataSize
);
94 DEBUG ((DEBUG_INFO
, "Find PE data - 0x%x\n", Pe32Data
));
95 DepexStatus
= FfsFindSectionData (EFI_SECTION_MM_DEPEX
, FileHeader
, &Depex
, &DepexSize
);
96 if (!EFI_ERROR (DepexStatus
)) {
97 MmAddToDriverList (FwVolHeader
, Pe32Data
, Pe32DataSize
, Depex
, DepexSize
, &FileHeader
->Name
);
100 } while (!EFI_ERROR (Status
));