]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c
Following UEFI spec, update SmbiosDxe to use EfiRuntimeServicesData to put SMBIOS...
[mirror_edk2.git] / IntelFrameworkModulePkg / Csm / LegacyBiosDxe / LegacyBootSupport.c
index dfdac356cfb89039e77108d261e04bdc831a84d4..bf27605504423229493d2d0cb2598d12e8dc9c2e 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -33,6 +33,10 @@ UINT64              mLowWater           = 0xffffffffffffffffULL;
 \r
 extern BBS_TABLE           *mBbsTable;\r
 \r
+extern VOID                  *mRuntimeSmbiosEntryPoint;\r
+extern EFI_PHYSICAL_ADDRESS  mReserveSmbiosEntryPoint;\r
+extern EFI_PHYSICAL_ADDRESS  mStructureTableAddress;\r
+\r
 /**\r
   Print the BBS Table.\r
 \r
@@ -777,6 +781,63 @@ LegacyGetDataOrTable (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Copy SMBIOS table to EfiReservedMemoryType of memory for legacy boot.\r
+\r
+**/\r
+VOID\r
+CreateSmbiosTableInReservedMemory (\r
+  VOID\r
+  )\r
+{\r
+  SMBIOS_TABLE_ENTRY_POINT    *EntryPointStructure;\r
+  \r
+  if ((mRuntimeSmbiosEntryPoint == NULL) || \r
+      (mReserveSmbiosEntryPoint == 0) || \r
+      (mStructureTableAddress == 0)) {\r
+    return;\r
+  }\r
+  \r
+  EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) mRuntimeSmbiosEntryPoint;\r
+  \r
+  //\r
+  // Copy SMBIOS Entry Point Structure\r
+  //\r
+  CopyMem (\r
+    (VOID *)(UINTN) mReserveSmbiosEntryPoint,\r
+    EntryPointStructure,\r
+    EntryPointStructure->EntryPointLength\r
+  );\r
+  \r
+  //\r
+  // Copy SMBIOS Structure Table into EfiReservedMemoryType memory\r
+  //\r
+  CopyMem (\r
+    (VOID *)(UINTN) mStructureTableAddress,\r
+    (VOID *)(UINTN) EntryPointStructure->TableAddress,\r
+    EntryPointStructure->TableLength\r
+  );\r
+  \r
+  //\r
+  // Update TableAddress in Entry Point Structure\r
+  //\r
+  EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)(UINTN) mReserveSmbiosEntryPoint;\r
+  EntryPointStructure->TableAddress = (UINT32)(UINTN) mStructureTableAddress;\r
+  \r
+  //\r
+  // Fixup checksums in the Entry Point Structure\r
+  //\r
+  EntryPointStructure->IntermediateChecksum = 0;\r
+  EntryPointStructure->EntryPointStructureChecksum = 0;\r
+\r
+  EntryPointStructure->IntermediateChecksum = \r
+    CalculateCheckSum8 (\r
+      (UINT8 *) EntryPointStructure + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString), \r
+      EntryPointStructure->EntryPointLength - OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString)\r
+      );\r
+  EntryPointStructure->EntryPointStructureChecksum =\r
+    CalculateCheckSum8 ((UINT8 *) EntryPointStructure, EntryPointStructure->EntryPointLength);\r
+}\r
 \r
 /**\r
   Assign drive number to legacy HDD drives prior to booting an EFI\r
@@ -815,7 +876,6 @@ GenericLegacyBoot (
   EFI_HANDLE                        IdeController;\r
   UINTN                             HandleCount;\r
   EFI_HANDLE                        *HandleBuffer;\r
-  VOID                              *SmbiosTable;\r
   VOID                              *AcpiTable;\r
   UINTN                             ShadowAddress;\r
   UINT32                            Granularity;\r
@@ -904,21 +964,15 @@ GenericLegacyBoot (
       );\r
     Private->Legacy16Table->E820Length = (UINT32) CopySize;\r
   }\r
-  //\r
-  // Get SMBIOS and ACPI table pointers\r
-  //\r
-  SmbiosTable = NULL;\r
-  EfiGetSystemConfigurationTable (\r
-    &gEfiSmbiosTableGuid,\r
-    &SmbiosTable\r
-    );\r
+\r
   //\r
   // We do not ASSERT if SmbiosTable not found. It is possbile that a platform does not produce SmbiosTable.\r
   //\r
-  if (SmbiosTable == NULL) {\r
+  if (mReserveSmbiosEntryPoint == 0) {\r
     DEBUG ((EFI_D_INFO, "Smbios table is not found!\n"));\r
   }\r
-  EfiToLegacy16BootTable->SmbiosTable = (UINT32)(UINTN)SmbiosTable;\r
+  CreateSmbiosTableInReservedMemory ();\r
+  EfiToLegacy16BootTable->SmbiosTable = (UINT32)(UINTN)mReserveSmbiosEntryPoint;\r
 \r
   AcpiTable = NULL;\r
   Status = EfiGetSystemConfigurationTable (\r