Add IPMI to firmware tables
PATCH v8 1/4 smbios: Move table build tools into an include file.
In reply to [email protected]From: Corey Minyard <[email protected]>
This will let things in other files (like IPMI) build SMBIOS tables.
--- hw/smbios/smbios.c | 70 ++++---------------------------------- hw/smbios/smbios_build.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 64 deletions(-) create mode 100644 hw/smbios/smbios_build.h
hw/smbios/smbios.c +6 -64
@@ -24,6 +24,7 @@#include "hw/smbios/smbios.h" #include "hw/loader.h" #include "exec/cpu-common.h" +#include "smbios_build.h" /* legacy structures and constants for <= 2.0 machines */ struct smbios_header {
@@ -53,10 +54,10 @@ static bool smbios_uuid_encoded = true;/* end: legacy structures & constants for <= 2.0 machines */ -static uint8_t *smbios_tables; -static size_t smbios_tables_len; -static unsigned smbios_table_max; -static unsigned smbios_table_cnt; +uint8_t *smbios_tables; +size_t smbios_tables_len; +unsigned smbios_table_max; +unsigned smbios_table_cnt;static SmbiosEntryPointType smbios_ep_type =SMBIOS_ENTRY_POINT_21 ;static SmbiosEntryPoint ep;
@@ -429,7 +430,7 @@ uint8_t *smbios_get_table_legacy(size_t *length)/* end: legacy setup functions for <= 2.0 machines */ -static bool smbios_skip_table (uint8_t type,bool required_table) +bool smbios_skip_table (uint8_t type,bool required_table) {if (test_bit (type, have_binfile_bitmap)) {return true;/* user provided their own binary blob(s) */
@@ -443,65 +444,6 @@ static bool smbios_skip_table(uint8_t type, bool required_table)return true; } -#define SMBIOS_BUILD_TABLE_PRE (tbl_type, tbl_handle, tbl_required) \ - struct smbios_type_##tbl_type *t; \ - size_t t_off;/* table offset into smbios_tables */ \ -int str_index =0 ; \ -do { \ -/* should we skip building this table ? */ \ -if (smbios_skip_table (tbl_type, tbl_required)) { \ -return ; \ - } \ - \ -/* use offset of table t within smbios_tables */ \ -/* (pointer must be updated after each realloc) */ \ - t_off = smbios_tables_len; \ - smbios_tables_len +=sizeof (*t); \ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len); \ - t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \ - \ - t->header.type = tbl_type; \ - t->header.length =sizeof (*t); \ - t->header.handle =cpu_to_le16 (tbl_handle); \ - } while (0) - -#define SMBIOS_TABLE_SET_STR (tbl_type, field, value) \ - do { \ - int len = (value != NULL) ? strlen(value) + 1 : 0; \ - if (len > 1) { \ - smbios_tables = g_realloc(smbios_tables, \ - smbios_tables_len + len); \ - memcpy(smbios_tables + smbios_tables_len, value, len); \ - smbios_tables_len += len; \ -/* update pointer post-realloc */ \ - t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \ - t->field = ++str_index; \ - } else { \ - t->field = 0; \ - } \ - } while (0) - -#define SMBIOS_BUILD_TABLE_POST \ - do { \ - size_t term_cnt, t_size; \ - \ -/* add '\0' terminator (add two if no strings defined) */ \ - term_cnt = (str_index ==0 ) ?2 :1 ; \ - smbios_tables =g_realloc (smbios_tables, \ - smbios_tables_len + term_cnt); \ -memset (smbios_tables + smbios_tables_len,0 , term_cnt); \ - smbios_tables_len += term_cnt; \ - \ -/* update smbios max. element size */ \ - t_size = smbios_tables_len - t_off; \ -if (t_size > smbios_table_max) { \ - smbios_table_max = t_size; \ - } \ - \ -/* update smbios element count */ \ - smbios_table_cnt++; \ - }while (0 ) -static void smbios_build_type_0_table (void ) {SMBIOS_BUILD_TABLE_PRE (0 ,0x000 , false);/* optional, leave up to BIOS */
hw/smbios/smbios_build.h new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v8 2/4 ipmi: Add SMBIOS table entry
In reply to [email protected]From: Corey Minyard <[email protected]>
Add an IPMI table entry to the SMBIOS.
--- hw/smbios/Makefile.objs | 2 + hw/smbios/no_smbios_type_38.c | 14 +++++ hw/smbios/smbios.c | 2 + hw/smbios/smbios_type_38.c | 117 ++++++++++++++++++++++++++++++++++++++++++ include/hw/smbios/ipmi.h | 15 ++++++ 5 files changed, 150 insertions(+) create mode 100644 hw/smbios/no_smbios_type_38.c create mode 100644 hw/smbios/smbios_type_38.c create mode 100644 include/hw/smbios/ipmi.h
hw/smbios/Makefile.objs +2 -0
@@ -1 +1,3 @@ common-obj-$(CONFIG_SMBIOS) += smbios.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += smbios_type_38.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += no_smbios_type_38.o
hw/smbios/no_smbios_type_38.c new file +14 -0
@@ -0,0 +1,14 @@ +/* +* IPMI SMBIOS firmware handling +* +* Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "hw/smbios/ipmi.h" + +void smbios_build_type_38_table (void ) +{ +}
hw/smbios/smbios.c +2 -0
@@ -25,6 +25,7 @@#include "hw/loader.h" #include "exec/cpu-common.h" #include "smbios_build.h" +#include "hw/smbios/ipmi.h" /* legacy structures and constants for <= 2.0 machines */ struct smbios_header {
@@ -848,6 +849,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array, }smbios_build_type_32_table (); +smbios_build_type_38_table ();smbios_build_type_127_table ();smbios_validate_table ();
hw/smbios/smbios_type_38.c new file +117 -0
117 lines not on this page · raw message
include/hw/smbios/ipmi.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* IPMI SMBIOS firmware handling +* +* Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef QEMU_SMBIOS_IPMI_H +#define QEMU_SMBIOS_IPMI_H + +void smbios_build_type_38_table (void ); + +#endif /* QEMU_SMBIOS_IPMI_H */
Signature · 1 line
2.7.4
PATCH v8 4/4 bios: Add tests for the IPMI ACPI and SMBIOS entries
In reply to [email protected]From: Corey Minyard <[email protected]>
--- tests/acpi-test-data/pc/DSDT.ipmikcs | Bin 0 -> 5575 bytes tests/acpi-test-data/q35/DSDT.ipmibt | Bin 0 -> 8340 bytes tests/bios-tables-test.c | 60 ++++++++++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 tests/acpi-test-data/pc/DSDT.ipmikcs create mode 100644 tests/acpi-test-data/q35/DSDT.ipmibt
tests/acpi-test-data/pc/DSDT.ipmikcs new file binary +0 -0
tests/acpi-test-data/q35/DSDT.ipmibt new file binary +0 -0
tests/bios-tables-test.c +56 -4
125 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v8 3/4 acpi: Add IPMI table entries
In reply to [email protected]From: Corey Minyard <[email protected]>
Use the ACPI table construction tools to create an ACPI entry for IPMI. This adds a function called build_acpi_ipmi_devices to add an DSDT entry for IPMI if IPMI is compiled in and an IPMI device exists. It also adds a dummy function if IPMI is not compiled in.
This conforms to section "C3-2 Locating IPMI System Interfaces in ACPI Name Space" in the IPMI 2.0 specification.
--- hw/acpi/Makefile.objs | 2 + hw/acpi/ipmi.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/noipmi.c | 14 +++++++ hw/i386/acpi-build.c | 12 ++++++ include/hw/acpi/ipmi.h | 22 +++++++++++ 5 files changed, 155 insertions(+) create mode 100644 hw/acpi/ipmi.c create mode 100644 hw/acpi/noipmi.c create mode 100644 include/hw/acpi/ipmi.h
hw/acpi/Makefile.objs +2 -0
@@ -6,3 +6,5 @@ obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.o +common-obj-$(call land,$(CONFIG_ACPI),$(CONFIG_IPMI)) += ipmi.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
hw/acpi/ipmi.c new file +105 -0
105 lines not on this page · raw message
hw/acpi/noipmi.c new file +14 -0
@@ -0,0 +1,14 @@ +/* +* IPMI ACPI firmware handling +* +* Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "hw/acpi/ipmi.h" + +void build_acpi_ipmi_devices (Aml *table,BusState *bus) +{ +}
hw/i386/acpi-build.c +12 -0
@@ -58,6 +58,8 @@#include "qapi/qmp/qint.h" #include "qom/qom-qobject.h" +#include "hw/acpi/ipmi.h" +/* These are used to size the ACPI tables for -M pc-i440fx-1.7 and * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows * a little bit, there should be plenty of free space since the DSDT
@@ -1334,8 +1336,10 @@ static Aml *build_com_device_aml(uint8_t uid)static void build_isa_devices_aml (Aml *table) {ISADevice *fdc =pc_find_fdc0 (); +bool ambiguous;Aml *scope =aml_scope ("_SB.PCI0.ISA" ); +Object *obj =object_resolve_path_type ("" ,TYPE_ISA_BUS , &ambiguous);aml_append (scope,build_rtc_device_aml ());aml_append (scope,build_kbd_device_aml ());
@@ -1347,6 +1351,14 @@ static void build_isa_devices_aml(Aml *table)aml_append (scope,build_com_device_aml (1 ));aml_append (scope,build_com_device_aml (2 )); +if (ambiguous) { +error_report ("Multiple ISA busses, unable to define IPMI ACPI data" ); + }else if (!obj) { +error_report ("No ISA bus, unable to define IPMI ACPI data" ); + }else { +build_acpi_ipmi_devices (scope,BUS (obj)); + } +aml_append (table, scope); }
include/hw/acpi/ipmi.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* QEMU IPMI ACPI handling +* +* Copyright (c) 2015,2016 Corey Minyard <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#ifndef HW_ACPI_IPMI_H +#define HW_ACPI_IPMI_H + +#include "qemu/osdep.h" +#include "hw/acpi/aml-build.h" + +/* +* Add ACPI IPMI entries for all registered IPMI devices whose parent +* bus matches the given bus. The resource is the ACPI resource that +* contains the IPMI device, this is required for the I2C CRS. +*/ +void build_acpi_ipmi_devices (Aml *table,BusState *bus); + +#endif /* HW_ACPI_IPMI_H */
Signature · 1 line
2.7.4
v8 cover Add IPMI to firmware tables
Since I haven't received any more feedback in a while...
Changes from v7:
* Added the proper license and author header to the smbios.h file, a copy of what was in the smbios.c file
* Fixed the name of the function in the change header for the change that added the IPMI table entries (patch 3).
Thanks,
-corey