]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Image/Image.c
Make ASSERT statement more meaningful.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Image / Image.c
index e02f7f13670a88f1b96ec7e2c8d93d1e38430e19..1a6ba313c2c3d2dac0dc34e01a87006157c7c0f3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Load Image Support\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -287,7 +287,9 @@ PeiLoadImageLoadImage (
   Machine = PeCoffLoaderGetMachineType (Pe32Data);\r
   \r
   if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Machine)) {\r
-    return EFI_UNSUPPORTED;  \r
+    if (!EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED (Machine)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
   }\r
 \r
   if (ImageAddressArg != NULL) {\r
@@ -307,7 +309,7 @@ PeiLoadImageLoadImage (
     //\r
     // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi\r
     //\r
-    if (Machine != IMAGE_FILE_MACHINE_IA64) {\r
+    if (Machine != EFI_IMAGE_MACHINE_IA64) {\r
       DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)*EntryPoint));\r
     } else {\r
       //\r
@@ -432,25 +434,20 @@ PeiLoadImage (
                           AuthenticationState\r
                           );\r
       if (!EFI_ERROR (Status)) {\r
+        //\r
+        // The image to be started must have the machine type supported by PeiCore.\r
+        //\r
+        ASSERT (EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCoffLoaderGetMachineType ((VOID *) (UINTN) ImageAddress)));\r
+        if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCoffLoaderGetMachineType ((VOID *) (UINTN) ImageAddress))) {\r
+          return EFI_UNSUPPORTED;\r
+        }\r
         return Status;\r
       }\r
     }\r
     Index++;\r
   } while (!EFI_ERROR (PpiStatus));\r
 \r
-  //\r
-  // If no instances reports EFI_SUCCESS, then build-in support for\r
-  // the PE32+/TE XIP image format is used.\r
-  //\r
-  Status = PeiLoadImageLoadImage (\r
-            PeiServices, \r
-            FileHandle, \r
-            NULL, \r
-            NULL, \r
-            EntryPoint, \r
-            AuthenticationState\r
-            );\r
-  return Status;\r
+  return PpiStatus;\r
 }\r
 \r
 \r