]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Core/Pei/Image/Image.c
1. PEI core needs to check image machine type
[mirror_edk2.git] / EdkModulePkg / Core / Pei / Image / Image.c
index dfe4668c1b5ec6fa5e6d677f2f31a1b488bd3412..202936869b62eb4b2f9417f4b5dc6562d76f934c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, 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
 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
@@ -56,6 +56,7 @@ Returns:
   UINT64                      ImageSize;\r
   EFI_PHYSICAL_ADDRESS        ImageEntryPoint;\r
   EFI_TE_IMAGE_HEADER         *TEImageHeader;\r
   UINT64                      ImageSize;\r
   EFI_PHYSICAL_ADDRESS        ImageEntryPoint;\r
   EFI_TE_IMAGE_HEADER         *TEImageHeader;\r
+  UINT16                      Machine;\r
 \r
   *EntryPoint   = NULL;\r
   TEImageHeader = NULL;\r
 \r
   *EntryPoint   = NULL;\r
   TEImageHeader = NULL;\r
@@ -114,7 +115,7 @@ Returns:
       // Retrieve the entry point from the TE image header\r
       //\r
       ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) TEImageHeader;\r
       // Retrieve the entry point from the TE image header\r
       //\r
       ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) TEImageHeader;\r
-      *EntryPoint = (VOID *)((UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) +\r
+      *EntryPoint  = (VOID *)((UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) +\r
                     TEImageHeader->AddressOfEntryPoint - TEImageHeader->StrippedSize);\r
     }\r
   } else {\r
                     TEImageHeader->AddressOfEntryPoint - TEImageHeader->StrippedSize);\r
     }\r
   } else {\r
@@ -128,6 +129,17 @@ Returns:
     }\r
   }\r
 \r
     }\r
   }\r
 \r
+  if (((EFI_TE_IMAGE_HEADER *) (UINTN) ImageAddress)->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    TEImageHeader = (EFI_TE_IMAGE_HEADER *) (UINTN) ImageAddress;\r
+    Machine = TEImageHeader->Machine;\r
+  } else {\r
+    Machine = PeCoffLoaderGetMachineType (Pe32Data);\r
+  } \r
+  \r
+  if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Machine)) {\r
+    return EFI_UNSUPPORTED;  \r
+  }\r
+\r
   //\r
   // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi\r
   //\r
   //\r
   // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi\r
   //\r