]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/DxeIpl/HobGeneration.c
SecurityPkg: TcgSmm: Handle invalid parameter in MOR SMI handler
[mirror_edk2.git] / DuetPkg / DxeIpl / HobGeneration.c
index 224d6a710e9a2fae3f18b266a8a9c56c6cf91965..03e44d594d73c6442e6100c6c8d7cb491600317d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+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
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -23,10 +23,9 @@ Revision History:
 #include "FlashLayout.h"\r
 #include "Debug.h"\r
 \r
-#define EFI_DXE_FILE_GUID \\r
-  { 0xb1644c1a, 0xc16a, 0x4c5b, {0x88, 0xde, 0xea, 0xfb, 0xa9, 0x7e, 0x74, 0xd8 }}\r
-\r
-#define CPUID_EXTENDED_ADD_SIZE  0x80000008\r
+#define EFI_CPUID_EXTENDED_FUNCTION  0x80000000\r
+#define CPUID_EXTENDED_ADD_SIZE      0x80000008\r
+#define EBDA_VALUE_ADDRESS           0x40E\r
 \r
 HOB_TEMPLATE  gHobTemplate = {\r
   { // Phit\r
@@ -187,7 +186,7 @@ HOB_TEMPLATE  gHobTemplate = {
         0, 0, 0, 0                                  // UINT8                 Reserved[4]; \r
       },\r
     },\r
-    EFI_DXE_FILE_GUID,\r
+    DXE_CORE_FILE_NAME_GUID,\r
     0x0                                             //  EFI_PHYSICAL_ADDRESS of EntryPoint;\r
   },\r
   { // MemoryDxeCore\r
@@ -352,7 +351,7 @@ HOB_TEMPLATE  gHobTemplate = {
       },\r
       EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID\r
     },\r
-    NULL\r
+    0\r
   },\r
   { // EFILDR Memory Descriptor\r
     {\r
@@ -361,7 +360,7 @@ HOB_TEMPLATE  gHobTemplate = {
         sizeof (MEMORY_DESC_HOB),          // Hob size\r
         0                                  // reserved\r
       },\r
-      EFI_LDR_MEMORY_DESCRIPTOR_GUID\r
+      LDR_MEMORY_DESCRIPTOR_GUID\r
     },\r
     0,\r
     NULL\r
@@ -604,12 +603,21 @@ Return:
 --*/\r
 {\r
   UINTN                Index;\r
+  UINT64               EbdaAddress;\r
 \r
   //\r
   // Prepare Low Memory\r
   // 0x18 pages is 72 KB.\r
   //\r
-  gHob->MemoryFreeUnder1MB.ResourceLength = EFI_MEMORY_BELOW_1MB_END - EFI_MEMORY_BELOW_1MB_START;\r
+  EbdaAddress = ((UINT64)(*(UINT16 *)(UINTN)(EBDA_VALUE_ADDRESS))) << 4;\r
+  if (EbdaAddress < 0x9A000 || EbdaAddress > EFI_MEMORY_BELOW_1MB_END) {\r
+    //\r
+    // EBDA should not go below 0x9A000 in any implementation,\r
+    // so add check here to make sure EBDA_VALUE_ADDRESS has a valid value.\r
+    //\r
+    EbdaAddress = EFI_MEMORY_BELOW_1MB_END;\r
+  }\r
+  gHob->MemoryFreeUnder1MB.ResourceLength = EbdaAddress - EFI_MEMORY_BELOW_1MB_START;\r
   gHob->MemoryFreeUnder1MB.PhysicalStart  = EFI_MEMORY_BELOW_1MB_START;\r
 \r
   //\r
@@ -719,7 +727,7 @@ PrepareHobBfv (
 \r
   //\r
   // Calculate BFV location at top of the memory region.\r
-  // This is like a RAM Disk. Align to page boundry.\r
+  // This is like a RAM Disk. Align to page boundary.\r
   //\r
   //BfvLengthPageSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (BfvLength));\r
  \r
@@ -957,21 +965,18 @@ PrepareHobCpu (
   VOID\r
   )\r
 {\r
-  EFI_CPUID_REGISTER          Reg;\r
-  UINT8                       CpuMemoryAddrBitNumber;\r
+  UINT32  CpuidEax;\r
 \r
   //\r
   // Create a CPU hand-off information\r
   //\r
-  CpuMemoryAddrBitNumber = 36;\r
-  AsmCpuid (EFI_CPUID_EXTENDED_FUNCTION, &Reg.RegEax, &Reg.RegEbx, &Reg.RegEcx, &Reg.RegEdx);\r
+  gHob->Cpu.SizeOfMemorySpace = 36;\r
 \r
-  if (Reg.RegEax >= CPUID_EXTENDED_ADD_SIZE) {\r
-    AsmCpuid (CPUID_EXTENDED_ADD_SIZE, &Reg.RegEax, &Reg.RegEbx, &Reg.RegEcx, &Reg.RegEdx);\r
-    CpuMemoryAddrBitNumber = (UINT8)(UINTN)(Reg.RegEax & 0xFF);\r
+  AsmCpuid (EFI_CPUID_EXTENDED_FUNCTION, &CpuidEax, NULL, NULL, NULL);\r
+  if (CpuidEax >= CPUID_EXTENDED_ADD_SIZE) {\r
+    AsmCpuid (CPUID_EXTENDED_ADD_SIZE, &CpuidEax, NULL, NULL, NULL);\r
+    gHob->Cpu.SizeOfMemorySpace = (UINT8)(CpuidEax & 0xFF);\r
   }\r
-  \r
-  gHob->Cpu.SizeOfMemorySpace = CpuMemoryAddrBitNumber;\r
 }\r
 \r
 VOID\r