Add IPMI to firmware tables
v5 cover Add IPMI to firmware tables
This update just fixes some style issues found by checkpatch.pl, which I should have checked to see if it existed, but Markus introduced me to.
-corey
PATCH v5 2/6 pc: Postpone SMBIOS table installation to post machine init
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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
hw/i386/pc.c +6 -5
@@ -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,
@@ -1161,6 +1159,7 @@ void pc_machine_done(Notifier *notifier, void *data) {PCMachineState *pcms =container_of (notifier, PCMachineState, machine_done); +FWCfgState *fw_cfg = pcms->fw_cfg;PCIBus *bus = pcms->bus;if (bus) {
@@ -1172,15 +1171,17 @@ void pc_machine_done(Notifier *notifier, void *data) extra_hosts++; } } -if (extra_hosts && pcms->fw_cfg) { +if (extra_hosts && fw_cfg) {uint64_t *val =g_malloc (sizeof (*val)); *val =cpu_to_le64 (extra_hosts); -fw_cfg_add_file (pcms->fw_cfg, -"etc/extra-pci-roots" , val,sizeof (*val)); +fw_cfg_add_file (fw_cfg,"etc/extra-pci-roots" , val,sizeof (*val)); } }acpi_setup (); +if (fw_cfg) { +pc_build_smbios (fw_cfg); + } }void pc_guest_info_init (PCMachineState *pcms)
Signature · 1 line
2.7.4
PATCH v5 1/6 ipmi: rework the fwinfo to be fetched from the interface
In reply to [email protected]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 v5 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 v5 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 | 114 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/noipmi.c | 14 ++++++ hw/i386/acpi-build.c | 10 +++-- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + include/hw/acpi/ipmi.h | 22 ++++++++++ include/hw/i386/pc.h | 1 + 8 files changed, 162 insertions(+), 3 deletions(-) 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_ACPI),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
hw/acpi/ipmi.c new file +114 -0
114 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 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 acpi_add_ipmi (Aml *table,BusState *bus,const char *resource) +{ +}
hw/i386/acpi-build.c +7 -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,7 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; } -static void build_isa_devices_aml (Aml *table) +static void build_isa_devices_aml (Aml *table,ISABus *isa_bus) {ISADevice *fdc =pc_find_fdc0 ();
@@ -1461,6 +1463,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 )); +acpi_add_ipmi (scope,BUS (isa_bus),"\\_SB.PCI0.ISA" ); +aml_append (table, scope); }
@@ -2011,7 +2015,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->isa_bus);build_piix4_pci_hotplug (dsdt);build_piix4_pci0_int (dsdt); }else {
@@ -2039,7 +2043,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->isa_bus);build_q35_pci0_int (dsdt); }
hw/i386/pc_piix.c +1 -0
@@ -185,6 +185,7 @@ static void pc_init1(MachineState *machine, &error_abort); no_hpet =1 ; } + pcms->isa_bus = isa_bus;isa_bus_irqs (isa_bus, gsi);if (kvm_pic_in_kernel ()) {
hw/i386/pc_q35.c +1 -0
@@ -190,6 +190,7 @@ static void pc_q35_init(MachineState *machine) ICH9_LPC_NB_PIRQS);pci_bus_set_route_irq_fn (host_bus, ich9_route_intx_pin_to_irq); isa_bus = ich9_lpc->isa_bus; + pcms->isa_bus = isa_bus;/*end early*/ isa_bus_irqs (isa_bus, gsi);
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 acpi_add_ipmi (Aml *table,BusState *bus,const char *resource); + +#endif /* HW_ACPI_IPMI_H */
include/hw/i386/pc.h +1 -0
@@ -51,6 +51,7 @@ struct PCMachineState {HotplugHandler *acpi_dev;ISADevice *rtc;PCIBus *bus; +ISABus *isa_bus;FWCfgState *fw_cfg;/* Configuration options: */
Signature · 1 line
2.7.4
PATCH v5 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.
--- hw/smbios/Makefile.objs | 2 + hw/smbios/ipmi.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++ hw/smbios/noipmi.c | 14 ++++++ hw/smbios/smbios.c | 2 + include/hw/smbios/ipmi.h | 15 +++++++ 5 files changed, 147 insertions(+) create mode 100644 hw/smbios/ipmi.c create mode 100644 hw/smbios/noipmi.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)) += ipmi.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
hw/smbios/ipmi.c new file +114 -0
114 lines not on this page · raw message
hw/smbios/noipmi.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 ) +{ +}
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 ();
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
Re: [Qemu-devel] [PATCH v5 2/6] pc: Postpone SMBIOS table installation to post machine init
In reply to [email protected]Quoted 24 lines · On Thu, 19 May 2016 10:23:58 -0500 [email protected] wrote:
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.
Signed-off-by Corey Minyard <[email protected]>--- hw/i386/pc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)hw/i386/pc.c +0
-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,
hw/i386/pc.c void pc_machine_done(Notifier *notifier, void *data) · line 1162
Quoted 4 lines
hw/i386/pc.c +1
-0@@ -1161,6 +1159,7 @@ void pc_machine_done(Notifier *notifier, void *data) {PCMachineState *pcms =container_of (notifier, PCMachineState, machine_done); +FWCfgState *fw_cfg = pcms->fw_cfg;
Patch looks ok.
except of adding extra local var, I'd just use pcms->fw_cfg
Quoted 24 lines
hw/i386/pc.c +5
-3PCIBus *bus = pcms->bus;if (bus) {@@ -1172,15 +1171,17 @@ void pc_machine_done(Notifier *notifier, void *data) extra_hosts++; } } -if (extra_hosts && pcms->fw_cfg) { +if (extra_hosts && fw_cfg) {uint64_t *val =g_malloc (sizeof (*val)); *val =cpu_to_le64 (extra_hosts); -fw_cfg_add_file (pcms->fw_cfg, -"etc/extra-pci-roots" , val,sizeof (*val)); +fw_cfg_add_file (fw_cfg,"etc/extra-pci-roots" , val,sizeof (*val)); } }acpi_setup (); +if (fw_cfg) { +pc_build_smbios (fw_cfg); + } }void pc_guest_info_init (PCMachineState *pcms)
Re: [Qemu-devel] [PATCH v5 4/6] ipmi: Add SMBIOS table entry
In reply to [email protected]Quoted 22 lines · On Thu, 19 May 2016 10:24:00 -0500 [email protected] wrote:
From: Corey Minyard <[email protected]>
Add an IPMI table entry to the SMBIOS.
Signed-off-by Corey Minyard <[email protected]>--- hw/smbios/Makefile.objs | 2 + hw/smbios/ipmi.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++ hw/smbios/noipmi.c | 14 ++++++ hw/smbios/smbios.c | 2 + include/hw/smbios/ipmi.h | 15 +++++++ 5 files changed, 147 insertions(+) create mode 100644 hw/smbios/ipmi.c create mode 100644 hw/smbios/noipmi.c create mode 100644 include/hw/smbios/ipmi.hhw/smbios/Makefile.objs +0
-0
hw/smbios/Makefile.objs line 3
Quoted 3 lines
hw/smbios/Makefile.objs +2
-0@@ -1 +1,3 @@ common-obj-$(CONFIG_SMBIOS) += smbios.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += ipmi.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
why not use existing stub approach instead of adding conditional for noipmi.o?
[...]
hw/smbios/noipmi.c
Quoted 1 line
hw/smbios/noipmi.c +0
-0
this file should be in a/hw/stubs/
and maybe s/noipmi.c/smbios_type_38.c/
Quoted 19 lines
new file mode 100644
index 0000000..ad669a4hw/smbios/noipmi.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 ) +{ +}
[...]
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
In reply to [email protected]Quoted 48 lines · On Thu, 19 May 2016 10:24:01 -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 | 114 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/noipmi.c | 14 ++++++ hw/i386/acpi-build.c | 10 +++-- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + include/hw/acpi/ipmi.h | 22 ++++++++++ include/hw/i386/pc.h | 1 + 8 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 hw/acpi/ipmi.c create mode 100644 hw/acpi/noipmi.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 +common-obj-$(call land,$(CONFIG_ACPI),$(call lnot,$(CONFIG_IPMI))) += noipmi.ohw/acpi/ipmi.c new file +6
-0@@ -0,0 +1,114 @@ +/* +* 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.
hw/acpi/ipmi.c line 16
Quoted 10 lines
hw/acpi/ipmi.c new file +10
-0+* 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" +#include "hw/acpi/ipmi.h" + +static Aml *aml_ipmi_crs (IPMIFwInfo *info,const char *scope)
scope is unused inside this function, drop it?
Quoted 40 lines
hw/acpi/ipmi.c new file +40
-0+{ +Aml *crs =aml_resource_template (); +uint8_t regspacing = info->register_spacing; + +/* +* 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 (); + }
hw/acpi/ipmi.c line 66
Quoted 10 lines
hw/acpi/ipmi.c new file +10
-0+ +if (info->interrupt_number) { +aml_append (crs,aml_irq_no_flags (info->interrupt_number)); + } + +return crs; +} + +static void ipmi_encode_one_acpi (Aml *table,IPMIFwInfo *info, +const char *resource)
it seems that 'resource' is used incorrectly in this patch, or more exactly it's not needed.
s/ipmi_encode_one_acpi/acpi_ipmi_device/ drop 'table' and 'resource' args and make it return 'dev' it composes.
Quoted 12 lines
hw/acpi/ipmi.c new file +12
-0+{ +Aml *dev, *method; +uint16_t version = ((info->ipmi_spec_major_revision <<8 ) + | (info->ipmi_spec_minor_revision <<4 )); + + dev =aml_device ("MI0" ); +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, resource))); +
hw/acpi/ipmi.c line 88
Quoted 10 lines
hw/acpi/ipmi.c new file +10
-0+/* +* The spec seems to require these to be methods. All the examples +* show them this way and it doesn't seem to work if they are not. +*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);
replace these methods with aml_name_decl() as they do not contain any logic except of returning static value.
hw/acpi/ipmi.c line 93
Quoted 5 lines
hw/acpi/ipmi.c new file +5
-0+ +aml_append (table, dev); +} + +void acpi_add_ipmi (Aml *table,BusState *bus,const char *resource)
s/acpi_add_ipmi/build_acpi_ipmi_devices/
drop 'resource'
s/table/scope/
Quoted 9 lines
hw/acpi/ipmi.c new file +9
-0+{ +BusChild *kid; + + QTAILQ_FOREACH(kid, &bus->children, sibling) { +DeviceState *dev = kid->child; +Object *obj =object_dynamic_cast (OBJECT (dev),TYPE_IPMI_INTERFACE ); +IPMIInterface *ii; +IPMIInterfaceClass *iic; +IPMIFwInfo info;
hw/acpi/ipmi.c line 112
Quoted 10 lines
hw/acpi/ipmi.c new file +10
-0+ +if (!obj) { +continue ; + } + + ii =IPMI_INTERFACE (obj); + iic =IPMI_INTERFACE_GET_CLASS (obj); +memset (&info,0 ,sizeof (info)); + iic->get_fwinfo (ii, &info); +ipmi_encode_one_acpi (table, &info, resource);
aml_append(scope, my_ipmi_device)
hw/acpi/noipmi.c
Quoted 7 lines
hw/acpi/ipmi.c new file +2
-0+ } +}hw/acpi/noipmi.c new file +0
-0
move this to .a/stubs/
Quoted 47 lines
hw/acpi/noipmi.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 acpi_add_ipmi (Aml *table,BusState *bus,const char *resource) +{ +}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,7 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; } -static void build_isa_devices_aml (Aml *table) +static void build_isa_devices_aml (Aml *table,ISABus *isa_bus) {ISADevice *fdc =pc_find_fdc0 ();@@ -1461,6 +1463,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 )); +acpi_add_ipmi (scope,BUS (isa_bus),"\\_SB.PCI0.ISA" ); +aml_append (table, scope); }
hw/i386/acpi-build.c build_dsdt(GArray *table_data, GArray *linker, · line 2018
Quoted 5 lines
hw/i386/acpi-build.c +1
-1@@ -2011,7 +2015,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->isa_bus);
I'm not sure about adding 'isa_bus' field to PCMachineState, it might be better to find a ISA bus object internally in build_isa_devices_aml() and assert if found more than one, since code assumes that there is only one anyway.
Quoted 76 lines
hw/i386/acpi-build.c +1
-1build_piix4_pci_hotplug (dsdt);build_piix4_pci0_int (dsdt); }else {@@ -2039,7 +2043,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->isa_bus);build_q35_pci0_int (dsdt); }hw/i386/pc_piix.c +1
-0@@ -185,6 +185,7 @@ static void pc_init1(MachineState *machine, &error_abort); no_hpet =1 ; } + pcms->isa_bus = isa_bus;isa_bus_irqs (isa_bus, gsi);if (kvm_pic_in_kernel ()) {hw/i386/pc_q35.c +1
-0@@ -190,6 +190,7 @@ static void pc_q35_init(MachineState *machine) ICH9_LPC_NB_PIRQS);pci_bus_set_route_irq_fn (host_bus, ich9_route_intx_pin_to_irq); isa_bus = ich9_lpc->isa_bus; + pcms->isa_bus = isa_bus;/*end early*/ isa_bus_irqs (isa_bus, gsi);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 acpi_add_ipmi (Aml *table,BusState *bus,const char *resource); + +#endif /* HW_ACPI_IPMI_H */ include/hw/i386/pc.h +1
-0@@ -51,6 +51,7 @@ struct PCMachineState {HotplugHandler *acpi_dev;ISADevice *rtc;PCIBus *bus; +ISABus *isa_bus;FWCfgState *fw_cfg;/* Configuration options: */
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
Thanks for all the comments. I didn't know about stubs, as there's nothing that currently uses it in hw directory, but it's easy enough to add. I did have two comment below:
Quoted 2 lines · Igor Mammedov
On Thu, 19 May 2016 10:24:01 -0500
[email protected] wrote:
.
.
.
Quoted 16 lines
hw/acpi/ipmi.c new file +15
-0+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, resource))); + +/* +* The spec seems to require these to be methods. All the examples +* show them this way and it doesn't seem to work if they are not. +*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);
Quoted 2 lines
replace these methods with
aml_name_decl()as they do not contain any logic except of returning static value.
I'm not sure why, but what you ask doesn't work. These have to be methods, and that is show by the IPMI spec, as the comment above these says.
.
.
.
Quoted 11 lines
hw/i386/acpi-build.c +1
-1@@ -2011,7 +2015,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_piix4_pm (dsdt);one build_piix4_isa_bridge (dsdt ); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms->isa_bus); I'm not sure about adding 'isa_bus' field to PCMachineState,it might be better to find a ISA bus object internally in
build_isa_devices_aml()and assert if found more than one, since code assumes that there is only one anyway.
I don't see a clean way to find the ISA bus object. Well, I guess you can scan the PCI bus for an ISA bus object, is that what you mean?
-corey
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
Quoted 37 lines · Corey Minyard
Thanks for all the comments. I didn't know about stubs, as there's nothing that currently uses it in hw directory, but it's easy enough to add. I did have two comment below:
Quoted 2 lines · Igor Mammedov
On Thu, 19 May 2016 10:24:01 -0500
[email protected] wrote:.
.
.Quoted 16 lines
hw/acpi/ipmi.c new file +15
-0+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, resource))); + +/* +* The spec seems to require these to be methods. All the examples +* show them this way and it doesn't seem to work if they are not. +*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);Quoted 2 lines
replace these methods with
aml_name_decl()as they do not contain any logic except of returning static value.I'm not sure why, but what you ask doesn't work. These have to be methods, and that is show by the IPMI spec, as the comment above these says.
.
.
.
Quoted 11 lines
Quoted 10 lines
hw/i386/acpi-build.c +1
-1@@ -2011,7 +2015,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_piix4_pm (dsdt);one build_piix4_isa_bridge (dsdt ); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms->isa_bus); I'm not sure about adding 'isa_bus' field to PCMachineState,it might be better to find a ISA bus object internally in
build_isa_devices_aml()and assert if found more than one, since code assumes that there is only one anyway.
I agree.
Quoted 4 lines
I don't see a clean way to find the ISA bus object. Well, I guess you can scan the PCI bus for an ISA bus object, is that what you mean?
You can run a QOM query. Please look for object_resolve_path function. Please let me know if you have difficulties with it.
Thanks,
Marcel
Quoted 2 lines
-corey
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
In reply to Corey MinyardQuoted 29 lines · On Sat, 21 May 2016 19:28:59 -0500 Corey Minyard <[email protected]> wrote:
Thanks for all the comments. I didn't know about stubs, as there's nothing that currently uses it in hw directory, but it's easy enough to add. I did have two comment below:
Quoted 2 lines · Igor Mammedov
On Thu, 19 May 2016 10:24:01 -0500
[email protected] wrote:.
.
.Quoted 16 lines
hw/acpi/ipmi.c new file +15
-0+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, resource))); + +/* +* The spec seems to require these to be methods. All the examples +* show them this way and it doesn't seem to work if they are not. +*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);Quoted 2 lines
replace these methods with
aml_name_decl()as they do not contain any logic except of returning static value.
Quoted 3 lines
I'm not sure why, but what you ask doesn't work. These have to be methods, and that is show by the IPMI spec, as the comment above these says.
on linux these methods are evaluated by ACPICA core and named constant is equivalent to a method without arguments that returns constant value.
It might be worth to investigate why it doesn't work.
Quoted 1 line
-corey
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
Quoted 30 lines · Igor Mammedov
Quoted 27 lines · On Sat, 21 May 2016 19:28:59 -0500 Corey Minyard <[email protected]> wrote:
Thanks for all the comments. I didn't know about stubs, as there's nothing that currently uses it in hw directory, but it's easy enough to add. I did have two comment below:
Quoted 2 lines · Igor Mammedov
On Thu, 19 May 2016 10:24:01 -0500
[email protected] wrote:.
.
.Quoted 17 lines
hw/acpi/ipmi.c new file +15
-0+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, resource))); + +/* +* The spec seems to require these to be methods. All the examples +* show them this way and it doesn't seem to work if they are not. +*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);replace these methods with
aml_name_decl()as they do not contain any logic except of returning static value.
Quoted 7 lines
Quoted 3 lines
I'm not sure why, but what you ask doesn't work. These have to be methods, and that is show by the IPMI spec, as the comment above these says.
on linux these methods are evaluated by ACPICA core and named constant is equivalent to a method without arguments that returns constant value.
It might be worth to investigate why it doesn't work.
I just tried this again and it did work. I'm not sure why it didn't work before, if it was a change in Linux or my error.
However, the latest IPMI spec has the following text:
Note: _IFT and _SRV, following, have been reserved in ACPI 3.0 as names for control methods defined for SPMI
Just because it works in Linux doesn't mean it will work on other OSes. Wouldn't it be safer to use a method here?
-corey
Quoted 1 line
Quoted 1 line
-corey
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
Quoted 42 lines · On Mon, 23 May 2016 07:42:32 -0500 Corey Minyard <[email protected]> wrote:
Quoted 30 lines · Igor Mammedov
Quoted 27 lines · On Sat, 21 May 2016 19:28:59 -0500 Corey Minyard <[email protected]> wrote:
Thanks for all the comments. I didn't know about stubs, as there's nothing that currently uses it in hw directory, but it's easy enough to add. I did have two comment below:
Quoted 2 lines · Igor Mammedov
On Thu, 19 May 2016 10:24:01 -0500
[email protected] wrote:.
.
.Quoted 17 lines
hw/acpi/ipmi.c new file +15
-0+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, resource))); + +/* +* The spec seems to require these to be methods. All the examples +* show them this way and it doesn't seem to work if they are not. +*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);replace these methods with
aml_name_decl()as they do not contain any logic except of returning static value.Quoted 7 lines
Quoted 3 lines
I'm not sure why, but what you ask doesn't work. These have to be methods, and that is show by the IPMI spec, as the comment above these says.
on linux these methods are evaluated by ACPICA core and named constant is equivalent to a method without arguments that returns constant value.
It might be worth to investigate why it doesn't work.
I just tried this again and it did work. I'm not sure why it didn't work before, if it was a change in Linux or my error.
Quoted 7 lines
However, the latest IPMI spec has the following text:
Note:
_IFTand_SRV, following, have been reserved in ACPI 3.0 as names for control methods defined for SPMIJust because it works in Linux doesn't mean it will work on other OSes. Wouldn't it be safer to use a method here?
I think it should be safe to use named constant instead of method. Spec often uses terms method/object interchangeably for argument-less methods and we use it to a make simpler/smaller AML bytecode.
So far there weren't any issues caused by it either on linux/windows guests.
PS:
ACPI6.0 spec uses named object instead of method for _IFT as an example.
Quoted 4 lines
-corey
Quoted 1 line
Quoted 1 line
-corey
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
In reply to Marcel ApfelbaumQuoted 59 lines · Marcel Apfelbaum
Quoted 39 lines · Corey Minyard
Thanks for all the comments. I didn't know about stubs, as there's nothing that currently uses it in hw directory, but it's easy enough to add. I did have two comment below:
Quoted 2 lines · Igor Mammedov
On Thu, 19 May 2016 10:24:01 -0500
[email protected] wrote:.
.
.Quoted 18 lines
hw/acpi/ipmi.c new file +4
-0+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,resource)));
hw/acpi/ipmi.c new file +3
-0+ +/* +* The spec seems to require these to be methods. All the examples
hw/acpi/ipmi.c new file +8
-0+* show them this way and it doesn't seem to work if they are not. +*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);Quoted 2 lines
replace these methods with
aml_name_decl()as they do not contain any logic except of returning static value.I'm not sure why, but what you ask doesn't work. These have to be methods, and that is show by the IPMI spec, as the comment above these says.
.
.
.Quoted 11 lines
Quoted 10 lines
hw/i386/acpi-build.c +1
-1@@ -2011,7 +2015,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_piix4_pm (dsdt);one build_piix4_isa_bridge (dsdt ); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms->isa_bus); I'm not sure about adding 'isa_bus' field to PCMachineState,it might be better to find a ISA bus object internally in
build_isa_devices_aml()and assert if found more than one, since code assumes that there is only one anyway.I agree.
Quoted 4 lines
I don't see a clean way to find the ISA bus object. Well, I guess you can scan the PCI bus for an ISA bus object, is that what you mean?
Quoted 6 lines
You can run a QOM query. Please look for
object_resolve_pathfunction. Please let me know if you have difficulties with it.Thanks,
Marcel
Thanks for that info.
I looked at that, and it works for a single object, but I don't see a way to make this work if there is more than one IPMI device defined.
I changed to the following code, which seems to work ok. You pass in the ISA bus (or the SMBus in the I2C case).
void build_acpi_ipmi_devices(Aml *scope, BusState *bus)
{
BusChild *kid;
QTAILQ_FOREACH(kid, &bus->children, sibling) {
DeviceState *dev = kid->child;
Object *obj = object_dynamic_cast(OBJECT(dev),
TYPE_IPMI_INTERFACE);
IPMIInterface *ii;
IPMIInterfaceClass *iic;
IPMIFwInfo info;
if (!obj) {
continue;
}
ii = IPMI_INTERFACE(obj);
iic = IPMI_INTERFACE_GET_CLASS(obj);
memset(&info, 0, sizeof(info));
iic->get_fwinfo(ii, &info);
aml_append(scope, acpi_ipmi_device(&info));
}
}Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
Quoted 61 lines · Corey Minyard
Quoted 60 lines · Marcel Apfelbaum
Quoted 37 lines · Corey Minyard
Thanks for all the comments. I didn't know about stubs, as there's nothing that currently uses it in hw directory, but it's easy enough to add. I did have two comment below:
Quoted 2 lines · Igor Mammedov
On Thu, 19 May 2016 10:24:01 -0500
[email protected] wrote:.
.
.Quoted 16 lines
hw/acpi/ipmi.c new file +15
-0+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, resource))); + +/* +* The spec seems to require these to be methods. All the examples +* show them this way and it doesn't seem to work if they are not. +*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);Quoted 2 lines
replace these methods with
aml_name_decl()as they do not contain any logic except of returning static value.I'm not sure why, but what you ask doesn't work. These have to be methods, and that is show by the IPMI spec, as the comment above these says.
.
.
.Quoted 11 lines
Quoted 10 lines
hw/i386/acpi-build.c +1
-1@@ -2011,7 +2015,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_piix4_pm (dsdt);one build_piix4_isa_bridge (dsdt ); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms->isa_bus); I'm not sure about adding 'isa_bus' field to PCMachineState,it might be better to find a ISA bus object internally in
build_isa_devices_aml()and assert if found more than one, since code assumes that there is only one anyway.I agree.
Quoted 4 lines
I don't see a clean way to find the ISA bus object. Well, I guess you can scan the PCI bus for an ISA bus object, is that what you mean?
You can run a QOM query. Please look for
object_resolve_pathfunction. Please let me know if you have difficulties with it.
Quoted 8 lines
Quoted 3 lines
Thanks,
MarcelThanks for that info.
I looked at that, and it works for a single object, but I don't see a way to make this work if there is more than one IPMI device defined.
I was under impression that you are looking for a way to find the isa_bus. Since we have only a single isa_bus you can use object_resolve_path instead of adding the isa_bus to the pc machine.
I didn't refer to the IPMI device, sorry if I was not clear enough.
Thanks,
Marcel
Quoted 26 lines
I changed to the following code, which seems to work ok. You pass in the ISA bus (or the SMBus in the I2C case).
void
build_acpi_ipmi_devices(Aml *scope, BusState *bus){ BusChild *kid; QTAILQ_FOREACH(kid, &bus->children, sibling) { DeviceState *dev = kid->child; Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_IPMI_INTERFACE); IPMIInterface *ii; IPMIInterfaceClass *iic; IPMIFwInfo info; if (!obj) { continue; } ii = IPMI_INTERFACE(obj); iic = IPMI_INTERFACE_GET_CLASS(obj); memset(&info, 0, sizeof(info)); iic->get_fwinfo(ii, &info); aml_append(scope, acpi_ipmi_device(&info)); } }
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
Quoted 71 lines · Marcel Apfelbaum
Quoted 70 lines · Corey Minyard
Quoted 60 lines · Marcel Apfelbaum
Quoted 40 lines · Corey Minyard
Thanks for all the comments. I didn't know about stubs, as there's nothing that currently uses it in hw directory, but it's easy enough to add. I did have two comment below:
Quoted 2 lines · Igor Mammedov
On Thu, 19 May 2016 10:24:01 -0500
[email protected] wrote:.
.
.Quoted 19 lines
hw/acpi/ipmi.c new file +4
-0+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,resource)));
hw/acpi/ipmi.c new file +3
-0+ +/* +* The spec seems to require these to be methods. All the examples
+ * show them this way and it doesn't seem to work if they are
not.hw/acpi/ipmi.c new file +7
-0+*/ + method =aml_method ("_IFT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method);Quoted 2 lines
replace these methods with
aml_name_decl()as they do not contain any logic except of returning static value.I'm not sure why, but what you ask doesn't work. These have to be methods, and that is show by the IPMI spec, as the comment above these says.
.
.
.Quoted 11 lines
Quoted 10 lines
hw/i386/acpi-build.c +1
-1@@ -2011,7 +2015,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_hpet_aml (dsdt);build_piix4_pm (dsdt);one build_piix4_isa_bridge (dsdt ); -build_isa_devices_aml (dsdt); +build_isa_devices_aml (dsdt, pcms->isa_bus); I'm not sure about adding 'isa_bus' field to PCMachineState,it might be better to find a ISA bus object internally in
build_isa_devices_aml()and assert if found more than one, since code assumes that there is only one anyway.I agree.
Quoted 4 lines
I don't see a clean way to find the ISA bus object. Well, I guess you can scan the PCI bus for an ISA bus object, is that what you mean?
Quoted 6 lines
You can run a QOM query. Please look for
object_resolve_pathfunction. Please let me know if you have difficulties with it.Thanks,
MarcelThanks for that info.
Quoted 9 lines
Quoted 2 lines
I looked at that, and it works for a single object, but I don't see a way to make this work if there is more than one IPMI device defined.
I was under impression that you are looking for a way to find the
isa_bus. Since we have only a singleisa_busyou can useobject_resolve_pathinstead of adding theisa_busto the pc machine.
I didn't refer to the IPMI device, sorry if I was not clear enough.
Got it, thanks. I was over thinking it.
-corey
Quoted 31 lines
Thanks,
MarcelQuoted 27 lines
I changed to the following code, which seems to work ok. You pass in the ISA bus (or the SMBus in the I2C case).
void
build_acpi_ipmi_devices(Aml *scope, BusState *bus){ BusChild *kid; QTAILQ_FOREACH(kid, &bus->children, sibling) { DeviceState *dev = kid->child; Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_IPMI_INTERFACE); IPMIInterface *ii; IPMIInterfaceClass *iic; IPMIFwInfo info; if (!obj) { continue; } ii = IPMI_INTERFACE(obj); iic = IPMI_INTERFACE_GET_CLASS(obj); memset(&info, 0, sizeof(info)); iic->get_fwinfo(ii, &info); aml_append(scope, acpi_ipmi_device(&info)); } }
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
In reply to Igor MammedovQuoted 7 lines · Igor Mammedov
Quoted 5 lines
hw/acpi/noipmi.c
Quoted 5 lines
hw/acpi/noipmi.c new file +0
-0move this to .a/stubs/
Don't overuse stubs. The stubs library is mostly to share code between QEMU and the tools. What Corey did is more similar to what hw/ already does in other places.
Unfortunately, weak symbols are not portable. :(
Paolo
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
Quoted 9 lines · Paolo Bonzini
Quoted 7 lines · Igor Mammedov
Quoted 5 lines
hw/acpi/noipmi.c
Quoted 5 lines
hw/acpi/noipmi.c new file +0
-0move this to .a/stubs/
Quoted 3 lines
Don't overuse stubs. The stubs library is mostly to share code between QEMU and the tools. What Corey did is more similar to what hw/ already does in other places.
Should I change it back?
Quoted 1 line
Unfortunately, weak symbols are not portable. :(
Yeah, that's really a pain.
-corey
Quoted 1 line
Paolo
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
In reply to Paolo BonziniQuoted 9 lines · On Mon, 23 May 2016 20:06:57 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Quoted 5 lines
hw/acpi/noipmi.c
Quoted 5 lines
hw/acpi/noipmi.c new file +0
-0move this to .a/stubs/
Quoted 3 lines
Don't overuse stubs. The stubs library is mostly to share code between QEMU and the tools. What Corey did is more similar to what hw/ already does in other places.
So what's the rule when one should use stubs or not?
Quoted 4 lines
Unfortunately, weak symbols are not portable. :(
Paolo
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
In reply to Corey MinyardQuoted 5 lines · Corey Minyard
Quoted 3 lines
Don't overuse stubs. The stubs library is mostly to share code between QEMU and the tools. What Corey did is more similar to what hw/ already does in other places.
Should I change it back?
Yes, please. Sorry.
Thanks,
Paolo
Re: [Qemu-devel] [PATCH v5 5/6] acpi: Add IPMI table entries
In reply to Igor MammedovQuoted 5 lines · Igor Mammedov
Quoted 3 lines
Don't overuse stubs. The stubs library is mostly to share code between QEMU and the tools. What Corey did is more similar to what hw/ already does in other places.
So what's the rule when one should use stubs or not?
If you have a config symbol to base your choice on, do not use stubs.
Paolo