• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Find and extract QEMU SMBIOS data from fw_cfg.
3 
4   Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>
5 
6   This program and the accompanying materials are licensed and made
7   available under the terms and conditions of the BSD License which
8   accompanies this distribution.   The full text of the license may
9   be found at http://opensource.org/licenses/bsd-license.php
10 
11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 **/
14 
15 #include "SmbiosPlatformDxe.h"
16 #include <Library/QemuFwCfgLib.h>
17 #include <Library/MemoryAllocationLib.h>
18 #include <Library/PcdLib.h>
19 
20 /**
21   Locates and extracts the QEMU SMBIOS data if present in fw_cfg
22 
23   @return                 Address of extracted QEMU SMBIOS data
24 
25 **/
26 UINT8 *
GetQemuSmbiosTables(VOID)27 GetQemuSmbiosTables (
28   VOID
29   )
30 {
31   EFI_STATUS               Status;
32   FIRMWARE_CONFIG_ITEM     Tables;
33   UINTN                    TablesSize;
34   UINT8                    *QemuTables;
35 
36   if (!PcdGetBool (PcdQemuSmbiosValidated)) {
37     return NULL;
38   }
39 
40   Status = QemuFwCfgFindFile ("etc/smbios/smbios-tables", &Tables,
41              &TablesSize);
42   ASSERT_EFI_ERROR (Status);
43   ASSERT (TablesSize > 0);
44 
45   QemuTables = AllocatePool (TablesSize);
46   if (QemuTables == NULL) {
47     return NULL;
48   }
49 
50   QemuFwCfgSelectItem (Tables);
51   QemuFwCfgReadBytes (TablesSize, QemuTables);
52 
53   return QemuTables;
54 }
55