QEMU_SMBIOS_ANCHOR QemuAnchor;\r
UINT16 SmbiosVersion;\r
\r
+ if (PcdGetBool (PcdQemuSmbiosValidated)) {\r
+ //\r
+ // Some other module, linked against this library, has already performed\r
+ // the task at hand. This should never happen, but it's easy to handle;\r
+ // just exit early.\r
+ //\r
+ return RETURN_SUCCESS;\r
+ }\r
+\r
if (RETURN_ERROR (QemuFwCfgFindFile (\r
"etc/smbios/smbios-anchor", &Anchor, &AnchorSize)) ||\r
RETURN_ERROR (QemuFwCfgFindFile (\r
SmbiosVersion));\r
PcdSet16 (PcdSmbiosVersion, SmbiosVersion);\r
\r
+ //\r
+ // SMBIOS platform drivers can now fetch and install\r
+ // "etc/smbios/smbios-tables" from QEMU.\r
+ //\r
+ PcdSetBool (PcdQemuSmbiosValidated, TRUE);\r
return RETURN_SUCCESS;\r
}\r
#include "SmbiosPlatformDxe.h"\r
#include <Library/QemuFwCfgLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
\r
/**\r
Locates and extracts the QEMU SMBIOS data if present in fw_cfg\r
VOID\r
)\r
{\r
- SMBIOS_TABLE_ENTRY_POINT QemuAnchor;\r
- FIRMWARE_CONFIG_ITEM Anchor, Tables;\r
- UINTN AnchorSize, TablesSize;\r
+ EFI_STATUS Status;\r
+ FIRMWARE_CONFIG_ITEM Tables;\r
+ UINTN TablesSize;\r
UINT8 *QemuTables;\r
\r
- if (EFI_ERROR (QemuFwCfgFindFile (\r
- "etc/smbios/smbios-anchor", &Anchor, &AnchorSize)) ||\r
- EFI_ERROR (QemuFwCfgFindFile (\r
- "etc/smbios/smbios-tables", &Tables, &TablesSize)) ||\r
- AnchorSize != sizeof (QemuAnchor) ||\r
- TablesSize == 0) {\r
+ if (!PcdGetBool (PcdQemuSmbiosValidated)) {\r
return NULL;\r
}\r
\r
- //\r
- // We copy the entry point structure to perform some additional checks,\r
- // but discard it upon return.\r
- //\r
- QemuFwCfgSelectItem (Anchor);\r
- QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);\r
-\r
- if (AsciiStrnCmp ((CHAR8 *)QemuAnchor.AnchorString, "_SM_", 4) ||\r
- AsciiStrnCmp ((CHAR8 *)QemuAnchor.IntermediateAnchorString, "_DMI_", 5) ||\r
- TablesSize != QemuAnchor.TableLength) {\r
- return NULL;\r
- }\r
+ Status = QemuFwCfgFindFile ("etc/smbios/smbios-tables", &Tables,\r
+ &TablesSize);\r
+ ASSERT_EFI_ERROR (Status);\r
+ ASSERT (TablesSize > 0);\r
\r
QemuTables = AllocatePool (TablesSize);\r
if (QemuTables == NULL) {\r