2014-05-20 18:33:19 +02:00
|
|
|
/** @file
|
|
|
|
Find and extract QEMU SMBIOS data from fw_cfg.
|
|
|
|
|
|
|
|
Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>
|
|
|
|
|
2019-04-04 01:06:33 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2014-05-20 18:33:19 +02:00
|
|
|
**/
|
|
|
|
|
|
|
|
#include "SmbiosPlatformDxe.h"
|
|
|
|
#include <Library/QemuFwCfgLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
2015-08-06 12:14:03 +02:00
|
|
|
#include <Library/PcdLib.h>
|
2014-05-20 18:33:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Locates and extracts the QEMU SMBIOS data if present in fw_cfg
|
|
|
|
|
|
|
|
@return Address of extracted QEMU SMBIOS data
|
|
|
|
|
|
|
|
**/
|
|
|
|
UINT8 *
|
|
|
|
GetQemuSmbiosTables (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2015-08-06 12:14:03 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
FIRMWARE_CONFIG_ITEM Tables;
|
|
|
|
UINTN TablesSize;
|
2014-05-20 18:33:19 +02:00
|
|
|
UINT8 *QemuTables;
|
|
|
|
|
2015-08-06 12:14:03 +02:00
|
|
|
if (!PcdGetBool (PcdQemuSmbiosValidated)) {
|
2014-05-20 18:33:19 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-06 12:14:03 +02:00
|
|
|
Status = QemuFwCfgFindFile ("etc/smbios/smbios-tables", &Tables,
|
|
|
|
&TablesSize);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
ASSERT (TablesSize > 0);
|
2014-05-20 18:33:19 +02:00
|
|
|
|
|
|
|
QemuTables = AllocatePool (TablesSize);
|
|
|
|
if (QemuTables == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
QemuFwCfgSelectItem (Tables);
|
|
|
|
QemuFwCfgReadBytes (TablesSize, QemuTables);
|
|
|
|
|
|
|
|
return QemuTables;
|
|
|
|
}
|