Add IPMI to firmware tables
v6 cover Add IPMI to firmware tables
This patch has changes to address all comments.
The isa_bus is no longer stored, it is searched for.
Methods entries are changed to named constants for the _SRV and _IFT entries in the IPMI table.
Minor function renames to make the names more consistent.
Switched to using stubs for when ACPI is present and IPMI is not.
Thanks for all the comments and help.
-corey
PATCH v6 1/6 ipmi: rework the fwinfo to be fetched from the interface
From: Corey Minyard <[email protected]>
Instead of scanning IPMI devices from a fwinfo list, allow the fwinfo to be fetched from the IPMI interface class. Then the code looking for IPMI fwinfo can scan devices on a bus and look for ones that implement the IPMI class.
This will let the ACPI scope be defined by the calling code so the IPMI code doesn't have to know the scope.
--- hw/ipmi/ipmi.c | 34 +++++------------------ hw/ipmi/isa_ipmi_bt.c | 57 +++++++++++++++++++++----------------- hw/ipmi/isa_ipmi_kcs.c | 56 +++++++++++++++++++++----------------- include/hw/ipmi/ipmi.h | 74 ++++++++++++++++++++++++++------------------------ 4 files changed, 109 insertions(+), 112 deletions(-)
hw/ipmi/ipmi.c +7 -27
@@ -30,6 +30,13 @@#include "qom/object_interfaces.h" #include "qapi/visitor.h" +static uint32_t ipmi_current_uuid =1 ; + +uint32_t ipmi_next_uuid (void ) +{ +return ipmi_current_uuid++; +} +static int ipmi_do_hw_op (IPMIInterface *s,enum ipmi_op op,int checkonly) {switch (op) {
@@ -122,30 +129,3 @@ static void ipmi_register_types(void) }type_init (ipmi_register_types) - -static IPMIFwInfo *ipmi_fw_info; -static unsigned int ipmi_fw_info_len; - -static uint32_t current_uuid =1 ; - -void ipmi_add_fwinfo (IPMIFwInfo *info,Error **errp) -{ - info->uuid = current_uuid++; - ipmi_fw_info =g_realloc (ipmi_fw_info, -sizeof (*ipmi_fw_info) * (ipmi_fw_info_len +1 )); - ipmi_fw_info[ipmi_fw_info_len] = *info; -} - -IPMIFwInfo *ipmi_first_fwinfo (void ) -{ -return ipmi_fw_info; -} - -IPMIFwInfo *ipmi_next_fwinfo (IPMIFwInfo *current) -{ - current++; -if (current >= &ipmi_fw_info[ipmi_fw_info_len]) { -return NULL ; - } -return current; -}
hw/ipmi/isa_ipmi_bt.c +32 -25
83 lines not on this page · raw message
hw/ipmi/isa_ipmi_kcs.c +31 -25
82 lines not on this page · raw message
include/hw/ipmi/ipmi.h +39 -35
92 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 4/6 ipmi: Add SMBIOS table entry
In reply to [email protected]From: Corey Minyard <[email protected]>
Add an IPMI table entry to the SMBIOS.
--- Makefile.objs | 2 +- hw/Makefile.objs | 2 + hw/smbios/Makefile.objs | 1 + hw/smbios/smbios.c | 2 + hw/smbios/smbios_type_38.c | 114 +++++++++++++++++++++++++++++++++++++++++++++ hw/stubs/Makefile.objs | 1 + hw/stubs/smbios_type_38.c | 14 ++++++ include/hw/smbios/ipmi.h | 15 ++++++ 8 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 hw/smbios/smbios_type_38.c create mode 100644 hw/stubs/Makefile.objs create mode 100644 hw/stubs/smbios_type_38.c create mode 100644 include/hw/smbios/ipmi.h
Makefile.objs +1 -1
@@ -1,6 +1,6 @@ ####################################################################### # Common libraries for tools and emulators -stub-obj-y = stubs/ crypto/ +stub-obj-y = stubs/ crypto/ hw/ util-obj-y = util/ qobject/ qapi/ util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
hw/Makefile.objs +2 -0
@@ -36,3 +36,5 @@ devices-dirs-$(CONFIG_SMBIOS) += smbios/ devices-dirs-y += core/ common-obj-y += $(devices-dirs-y) obj-y += $(devices-dirs-y) + +stub-obj-y += stubs/
hw/smbios/Makefile.objs +1 -0
@@ -1 +1,2 @@ common-obj-$(CONFIG_SMBIOS) += smbios.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += smbios_type_38.o
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 +114 -0
114 lines not on this page · raw message
hw/stubs/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +stub-obj-$(CONFIG_SMBIOS) += smbios_type_38.o
hw/stubs/smbios_type_38.c new file +14 -0
@@ -0,0 +1,14 @@ +/* +* IPMI SMBIOS firmware handling +* +* Copyright (c) 2015 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 ) +{ +}
include/hw/smbios/ipmi.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* IPMI SMBIOS firmware handling +* +* Copyright (c) 2015 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 v6 5/6 acpi: Add IPMI table entries
In reply to [email protected]From: Corey Minyard <[email protected]>
Use the new ACPI table construction tools to create an ACPI entry for IPMI. This adds a function called from build_dsdt to add an DSDT entry for IPMI if IPMI is compiled in and has registered firmware. 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/i386/acpi-build.c | 24 +++++++++-- hw/stubs/Makefile.objs | 1 + hw/stubs/acpi_ipmi.c | 14 +++++++ include/hw/acpi/ipmi.h | 22 +++++++++++ 6 files changed, 165 insertions(+), 3 deletions(-) create mode 100644 hw/acpi/ipmi.c create mode 100644 hw/stubs/acpi_ipmi.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 +
hw/acpi/ipmi.c new file +105 -0
105 lines not on this page · raw message
hw/i386/acpi-build.c +21 -3
@@ -59,6 +59,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
@@ -1445,7 +1447,21 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; } -static void build_isa_devices_aml (Aml *table) +static void build_isa_ipmi_aml (Aml *scope) +{ +bool ambiguous; +Object *obj =object_resolve_path_type ("" ,TYPE_ISA_BUS , &ambiguous); + +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)); + } +} + +static void build_isa_devices_aml (Aml *table,PCMachineState *pcms) {ISADevice *fdc =pc_find_fdc0 ();
@@ -1461,6 +1477,8 @@ static void build_isa_devices_aml(Aml *table)aml_append (scope,build_com_device_aml (1 ));aml_append (scope,build_com_device_aml (2 )); +build_isa_ipmi_aml (scope); +aml_append (table, scope); }
@@ -2011,7 +2029,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_piix4_pm (dsdt);build_piix4_isa_bridge (dsdt); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms);build_piix4_pci_hotplug (dsdt);build_piix4_pci0_int (dsdt); }else {
@@ -2039,7 +2057,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_q35_isa_bridge (dsdt); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms);build_q35_pci0_int (dsdt); }
hw/stubs/Makefile.objs +1 -0
@@ -1 +1,2 @@ stub-obj-$(CONFIG_SMBIOS) += smbios_type_38.o +stub-obj-$(CONFIG_ACPI) += acpi_ipmi.o
hw/stubs/acpi_ipmi.c new file +14 -0
@@ -0,0 +1,14 @@ +/* +* IPMI ACPI firmware handling +* +* Copyright (c) 2015 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) +{ +}
include/hw/acpi/ipmi.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* QEMU IPMI ACPI handling +* +* Copyright (c) 2015 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
PATCH v6 2/6 pc: Postpone SMBIOS table installation to post machine init
In reply to [email protected]From: Corey Minyard <[email protected]>
This is the same place that the ACPI SSDT table gets added, so that devices can add themselves to the SMBIOS table.
--- hw/i386/pc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/i386/pc.c +3 -2
@@ -764,8 +764,6 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); -pc_build_smbios (fw_cfg); -fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_reserve,sizeof (e820_reserve)); fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
@@ -1181,6 +1179,9 @@ void pc_machine_done(Notifier *notifier, void *data) }acpi_setup (); +if (pcms->fw_cfg) { +pc_build_smbios (pcms->fw_cfg); + } }void pc_guest_info_init (PCMachineState *pcms)
Signature · 1 line
2.7.4
PATCH v6 3/6 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 | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 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 +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 6/6 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 -> 5659 bytes tests/acpi-test-data/q35/DSDT.ipmibt | Bin 0 -> 8432 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
Re: [Qemu-devel] [PATCH v6 5/6] acpi: Add IPMI table entries
In reply to [email protected]Quoted 49 lines · On Mon, 23 May 2016 12:40:16 -0500 [email protected] wrote:
From: Corey Minyard <[email protected]>
Use the new ACPI table construction tools to create an ACPI entry for IPMI. This adds a function called from
build_dsdtto add an DSDT entry for IPMI if IPMI is compiled in and has registered firmware. 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.
Signed-off-by Corey Minyard <[email protected]>--- hw/acpi/Makefile.objs | 2 + hw/acpi/ipmi.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 24 +++++++++-- hw/stubs/Makefile.objs | 1 + hw/stubs/acpi_ipmi.c | 14 +++++++ include/hw/acpi/ipmi.h | 22 +++++++++++ 6 files changed, 165 insertions(+), 3 deletions(-) create mode 100644 hw/acpi/ipmi.c create mode 100644 hw/stubs/acpi_ipmi.c create mode 100644 include/hw/acpi/ipmi.hhw/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 +hw/acpi/ipmi.c new file +9
-0@@ -0,0 +1,105 @@ +/* +* IPMI ACPI firmware handling +* +* Copyright (c) 2015 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. +*/ +
hw/acpi/ipmi.c line 19
Quoted 10 lines
hw/acpi/ipmi.c new file +10
-0+#include "qemu/osdep.h" +#include "hw/ipmi/ipmi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/ipmi.h" + +static Aml *aml_ipmi_crs (IPMIFwInfo *info) +{ +Aml *crs =aml_resource_template (); +uint8_t regspacing = info->register_spacing;
nit about naming,
why not s/regspacing|register_spacing/reg_alignment/
Quoted 40 lines
hw/acpi/ipmi.c new file +40
-0+ +/* +* The base address is fixed and cannot change. That may be different +* if someone does PCI, but we aren't there yet. +*/ +switch (info->memspace) { +case IPMI_MEMSPACE_IO : +aml_append (crs,aml_io (AML_DECODE16 , info->base_address, + info->base_address + info->register_length -1 , + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_MEM32 : +aml_append (crs, +aml_dword_memory (AML_POS_DECODE , +AML_MIN_FIXED ,AML_MAX_FIXED , +AML_NON_CACHEABLE ,AML_READ_WRITE , +0xffffffff , + info->base_address, + info->base_address + info->register_length -1 , + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_MEM64 : +aml_append (crs, +aml_qword_memory (AML_POS_DECODE , +AML_MIN_FIXED ,AML_MAX_FIXED , +AML_NON_CACHEABLE ,AML_READ_WRITE , +0xffffffffffffffffULL , + info->base_address, + info->base_address + info->register_length -1 , + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_SMBUS : +aml_append (crs,aml_return (aml_int (info->base_address))); +break ; +default : +abort (); + } + +if (info->interrupt_number) { +aml_append (crs,aml_irq_no_flags (info->interrupt_number));
hw/acpi/ipmi.c line 69
Quoted 10 lines
hw/acpi/ipmi.c new file +10
-0+ } + +return crs; +} + +static Aml *aml_ipmi_device (IPMIFwInfo *info) +{ +Aml *dev; +uint16_t version = ((info->ipmi_spec_major_revision <<8 ) + | (info->ipmi_spec_minor_revision <<4 ));
revisions potentially could silently overlap when ORed, add assert to make sure the it won't go unnoticed.
Quoted 10 lines
hw/acpi/ipmi.c new file +10
-0+ + dev =aml_device ("MI%d" , info->uuid); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("IPI0001" ))); +aml_append (dev,aml_name_decl ("_STR" ,aml_string ("ipmi_%s" , + info->interface_name))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (info->uuid))); +aml_append (dev,aml_name_decl ("_CRS" ,aml_ipmi_crs (info))); +aml_append (dev,aml_name_decl ("_IFT" ,aml_int (info->interface_type))); +aml_append (dev,aml_name_decl ("_SRV" ,aml_int (version))); +
hw/acpi/ipmi.c line 89
Quoted 10 lines
hw/acpi/ipmi.c new file +10
-0+return dev; +} + +void build_acpi_ipmi_devices (Aml *scope,BusState *bus) +{ + +BusChild *kid; + + QTAILQ_FOREACH(kid, &bus->children, sibling) { +DeviceState *dev = kid->child;
another nit,
not necessary just use OBJECT(kid->child)
hw/acpi/ipmi.c line 90
Quoted 1 line
hw/acpi/ipmi.c new file +1
-0+Object *obj =object_dynamic_cast (OBJECT (dev),TYPE_IPMI_INTERFACE );
put it below IPMIFwInfo info; to make it prettier :)
hw/acpi/ipmi.c line 101
Quoted 12 lines
hw/acpi/ipmi.c new file +11
-0+IPMIInterface *ii; +IPMIInterfaceClass *iic; +IPMIFwInfo info; + +if (!obj) { +continue ; + } + + ii =IPMI_INTERFACE (obj); + iic =IPMI_INTERFACE_GET_CLASS (obj); +memset (&info,0 ,sizeof (info));
why not to put memset() inside iic->get_fwinfo(), that way every caller won't have to do it (SMBIOS call site).
Quoted 25 lines
hw/acpi/ipmi.c new file +4
-0+ iic->get_fwinfo (ii, &info); +aml_append (scope,aml_ipmi_device (&info)); + } +}hw/i386/acpi-build.c +5
-1@@ -59,6 +59,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 @@ -1445,7 +1447,21 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; } -static void build_isa_devices_aml (Aml *table) +static void build_isa_ipmi_aml (Aml *scope) +{ +bool ambiguous;
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1462
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+Object *obj =object_resolve_path_type ("" ,TYPE_ISA_BUS , &ambiguous); + +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)); + } +}
I'd fold this function into build_acpi_ipmi_devices() if there aren't any plans for IPMI devices being present on another bus.
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1464
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+ +static void build_isa_devices_aml (Aml *table,PCMachineState *pcms)
why is pcms is added here, it doesn't seem to be used?
Quoted 64 lines
hw/i386/acpi-build.c +4
-2{ISADevice *fdc =pc_find_fdc0 ();@@ -1461,6 +1477,8 @@ static void build_isa_devices_aml(Aml *table)aml_append (scope,build_com_device_aml (1 ));aml_append (scope,build_com_device_aml (2 )); +build_isa_ipmi_aml (scope); +aml_append (table, scope); }@@ -2011,7 +2029,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_piix4_pm (dsdt);build_piix4_isa_bridge (dsdt); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms);build_piix4_pci_hotplug (dsdt);build_piix4_pci0_int (dsdt); }else {@@ -2039,7 +2057,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_q35_isa_bridge (dsdt); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms);build_q35_pci0_int (dsdt); }hw/stubs/Makefile.objs +1
-0@@ -1 +1,2 @@ stub-obj-$(CONFIG_SMBIOS) += smbios_type_38.o +stub-obj-$(CONFIG_ACPI) += acpi_ipmi.ohw/stubs/acpi_ipmi.c new file +14
-0@@ -0,0 +1,14 @@ +/* +* IPMI ACPI firmware handling +* +* Copyright (c) 2015 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) +{ +}include/hw/acpi/ipmi.h new file +0
-0
include/hw/acpi/ipmi.h line 4
Quoted 4 lines
include/hw/acpi/ipmi.h new file +4
-0@@ -0,0 +1,22 @@ +/* +* QEMU IPMI ACPI handling +* +* Copyright (c) 2015 Corey Minyard <[email protected]>
s/2015/2016/ throughout series???
Quoted 17 lines
include/hw/acpi/ipmi.h new file +17
-0+* 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 */
Re: [Qemu-devel] [PATCH v6 5/6] acpi: Add IPMI table entries
Quoted 56 lines · Igor Mammedov
Quoted 53 lines · On Mon, 23 May 2016 12:40:16 -0500 [email protected] wrote:
From: Corey Minyard <[email protected]>
Use the new ACPI table construction tools to create an ACPI entry for IPMI. This adds a function called from
build_dsdtto add an DSDT entry for IPMI if IPMI is compiled in and has registered firmware. 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.
Signed-off-by Corey Minyard <[email protected]>--- hw/acpi/Makefile.objs | 2 + hw/acpi/ipmi.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 24 +++++++++-- hw/stubs/Makefile.objs | 1 + hw/stubs/acpi_ipmi.c | 14 +++++++ include/hw/acpi/ipmi.h | 22 +++++++++++ 6 files changed, 165 insertions(+), 3 deletions(-)create mode 100644
hw/acpi/ipmi.c
create mode 100644hw/stubs/acpi_ipmi.c
create mode 100644include/hw/acpi/ipmi.hhw/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 +hw/acpi/ipmi.c new file +13
-0@@ -0,0 +1,105 @@ +/* +* IPMI ACPI firmware handling +* +* Copyright (c) 2015 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 "qemu/osdep.h" +#include "hw/ipmi/ipmi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi.h"
Quoted 8 lines
hw/acpi/ipmi.c line 19
Quoted 6 lines
hw/acpi/ipmi.c new file +6
-0+#include "hw/acpi/ipmi.h" + +static Aml *aml_ipmi_crs (IPMIFwInfo *info) +{ +Aml *crs =aml_resource_template (); +uint8_t regspacing = info->register_spacing;nit about naming,
why not s/regspacing|register_spacing/reg_alignment/
"Register spacing" comes from the SMBIOS definition in the IPMI spec. Since I did SMBIOS first, it won.
There's no reason to have a local for this now (I think there was at some point).
.
.
.
Quoted 10 lines
hw/acpi/ipmi.c line 101
Quoted 8 lines
hw/acpi/ipmi.c new file +8
-0+ +if (!obj) { +continue ; + } + + ii =IPMI_INTERFACE (obj); + iic =IPMI_INTERFACE_GET_CLASS (obj); +memset (&info,0 ,sizeof (info));why not to put
memset()insideiic->get_fwinfo(), that way every caller won't have to do it (SMBIOS call site).
I debated on that, but there are actually fewer call sites than implementers here. Well, they are equal now, but with SMBus there will be more implementers.
Quoted 21 lines
Quoted 21 lines
hw/acpi/ipmi.c new file +4
-0+ iic->get_fwinfo (ii, &info); +aml_append (scope,aml_ipmi_device (&info)); + } +}hw/i386/acpi-build.c +2
-0@@ -59,6 +59,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 @@ -1445,7 +1447,21 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; }
Quoted 16 lines
Quoted 4 lines
hw/i386/acpi-build.c +3
-1-static void build_isa_devices_aml (Aml *table) +static void build_isa_ipmi_aml (Aml *scope) +{ +bool ambiguous;hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1462
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+Object *obj =object_resolve_path_type ("" ,TYPE_ISA_BUS , &ambiguous); + +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)); + } +}I'd fold this function into
build_acpi_ipmi_devices()if there aren't any plans for IPMI devices being present on another bus.
Ok, it looked a little neater this way to me, but that's fine.
Quoted 3 lines
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1464
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+ +static void build_isa_devices_aml (Aml *table,PCMachineState *pcms)why is pcms is added here, it doesn't seem to be used?
I forgot to remove it when I removed the isa_bus from PCMachineState.
Thanks,
-corey