summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-26 09:32:30 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-26 09:32:30 +0000
commit60c0073fd7b0f99d064919cd67e6ca5fb229e080 (patch)
treeb579fae9de0adcffca2b4dc073af950ea64ae3fb /MdeModulePkg/Core
parent0dfef49a30ac932f994683a4482c8b949491785c (diff)
downloadedk2-platforms-60c0073fd7b0f99d064919cd67e6ca5fb229e080.tar.xz
Remove ASSERT (EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->Machine)) in StartImage.
Signed-off-by: lgao4 Reviewed-by: jyao1 rsun3 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12443 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/Dxe/Image/Image.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 56d93ade80..da68d502ea 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -77,6 +77,46 @@ LOADED_IMAGE_PRIVATE_DATA mCorePrivateImage = {
//
GLOBAL_REMOVE_IF_UNREFERENCED UINT64 *mDxeCodeMemoryRangeUsageBitMap=NULL;
+typedef struct {
+ UINT16 MachineType;
+ CHAR16 *MachineTypeName;
+} MACHINE_TYPE_INFO;
+
+//
+// EBC machine is not listed in this table, because EBC is in the default supported scopes of other machine type.
+//
+GLOBAL_REMOVE_IF_UNREFERENCED MACHINE_TYPE_INFO mMachineTypeInfo[] = {
+ {EFI_IMAGE_MACHINE_IA32, L"IA32"},
+ {EFI_IMAGE_MACHINE_IA64, L"IA64"},
+ {EFI_IMAGE_MACHINE_X64, L"X64"},
+ {EFI_IMAGE_MACHINE_ARMTHUMB_MIXED, L"ARM"}
+};
+
+UINT16 mDxeCoreImageMachineType = 0;
+
+/**
+ Return machine type name.
+
+ @param MachineType The machine type
+
+ @return machine type name
+**/
+CHAR16 *
+GetMachineTypeName (
+ UINT16 MachineType
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mMachineTypeInfo)/sizeof(mMachineTypeInfo[0]); Index++) {
+ if (mMachineTypeInfo[Index].MachineType == MachineType) {
+ return mMachineTypeInfo[Index].MachineTypeName;
+ }
+ }
+
+ return L"<Unknown>";
+}
+
/**
Add the Image Services to EFI Boot Services Table and install the protocol
interfaces for this image.
@@ -147,6 +187,7 @@ CoreInitializeImageServices (
//
// Fill in DXE globals
//
+ mDxeCoreImageMachineType = PeCoffLoaderGetMachineType (Image->Info.ImageBase);
gDxeCoreImageHandle = Image->Handle;
gDxeCoreLoadedImage = &Image->Info;
@@ -426,6 +467,7 @@ CoreLoadPeImage (
// The PE/COFF loader can support loading image types that can be executed.
// If we loaded an image type that we can not execute return EFI_UNSUPORTED.
//
+ DEBUG ((EFI_D_ERROR, "Image type %s can't be loaded on %s UEFI system.\n", GetMachineTypeName(Image->ImageContext.Machine), GetMachineTypeName(mDxeCoreImageMachineType)));
return EFI_UNSUPPORTED;
}
}
@@ -1436,8 +1478,12 @@ CoreStartImage (
//
// The image to be started must have the machine type supported by DxeCore.
//
- ASSERT (EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->Machine));
if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->Machine)) {
+ //
+ // Do not ASSERT here, because image might be loaded via EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED
+ // But it can not be started.
+ //
+ DEBUG ((EFI_D_ERROR, "Image type %s can't be started on %s UEFI system.\n", GetMachineTypeName(Image->Machine), GetMachineTypeName(mDxeCoreImageMachineType)));
return EFI_UNSUPPORTED;
}