]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix issue with SMBIOS driver assumming memory exists below 4GB.
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 29 Aug 2011 20:47:22 +0000 (20:47 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 29 Aug 2011 20:47:22 +0000 (20:47 +0000)
approved-by: andrewfish
reviewed-by: li-elvin

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12220 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c

index c15ecb54fa693407da0cf9bb4595588c8c5c0c82..596e8b2d8bb2774a0647e664f218930b327cfbf8 100644 (file)
@@ -103,6 +103,7 @@ SMBIOS_TABLE_ENTRY_POINT EntryPointStructureData = {
 };\r
 \r
 \r
+\r
 /**\r
 \r
   Get the full size of SMBIOS structure including optional strings that follow the formatted structure.\r
@@ -889,7 +890,11 @@ SmbiosCreateTable (
   //\r
   SmbiosProtocol = &mPrivateData.Smbios;\r
 \r
-  PreAllocatedPages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength);\r
+  if (EntryPointStructure->TableAddress == 0) {\r
+    PreAllocatedPages = 0;\r
+  } else {\r
+    PreAllocatedPages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength);\r
+  }\r
 \r
   //\r
   // Make some statistics about all the structures\r
@@ -957,9 +962,12 @@ SmbiosCreateTable (
                     &PhysicalAddress\r
                     );\r
     if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "SmbiosCreateTable() could not allocate SMBIOS table < 4GB\n"));\r
+      EntryPointStructure->TableAddress = 0;\r
       return EFI_OUT_OF_RESOURCES;\r
+    } else {\r
+      EntryPointStructure->TableAddress = (UINT32) PhysicalAddress;\r
     }\r
-    EntryPointStructure->TableAddress = (UINT32) PhysicalAddress;\r
   }\r
   \r
   //\r
@@ -1061,7 +1069,16 @@ SmbiosDriverEntryPoint (
                   &PhysicalAddress\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
+    DEBUG ((EFI_D_ERROR, "SmbiosDriverEntryPoint() could not allocate EntryPointStructure < 4GB\n"));\r
+    Status = gBS->AllocatePages (\r
+                    AllocateAnyPages,\r
+                    EfiReservedMemoryType,\r
+                    EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)),\r
+                    &PhysicalAddress\r
+                    );\r
+   if (EFI_ERROR (Status)) {   \r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
   }\r
 \r
   EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) (UINTN) PhysicalAddress;\r
@@ -1086,14 +1103,14 @@ SmbiosDriverEntryPoint (
                   &PhysicalAddress\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    FreePages ((VOID*) EntryPointStructure, EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)));\r
-    EntryPointStructure = NULL;\r
-    return EFI_OUT_OF_RESOURCES;\r
+    DEBUG ((EFI_D_ERROR, "SmbiosDriverEntryPoint() could not allocate SMBIOS table < 4GB\n"));\r
+    EntryPointStructure->TableAddress = 0;\r
+    EntryPointStructure->TableLength  = 0;\r
+  } else {\r
+    EntryPointStructure->TableAddress = (UINT32) PhysicalAddress;\r
+    EntryPointStructure->TableLength  = EFI_PAGES_TO_SIZE (1);\r
   }\r
-\r
-  EntryPointStructure->TableAddress = (UINT32) PhysicalAddress;\r
-  EntryPointStructure->TableLength  = EFI_PAGES_TO_SIZE (1);\r
-\r
+  \r
   //\r
   // Make a new handle and install the protocol\r
   //\r