IPMI device for qemu
cover IPMI device for qemu
This set of patches adds an IPMI KCS or BT interface to qemu, along with a local simulated baseboard management controller (BMC) and a way to connect to an external BMC. It is mostly unchanged from previous release, except for bug fixes and the following changes:
The ACPI generation code custom to this was removed and it's now using the new aml-build code.
Because of the previous change, capability was added to hook into the SSDT build process so that devices could insert their own table entries.
Also because of this, and because Benjamin Herrenschmidt pointed out the need to have this on systems without SMBIOS and ACPI, that code has now been made optional. The SMBIOS uses TARGET_I386 to do this, which seems to be safe. The ACPI code required transfering the CONFIG_ACPI entry from the default configs to the target configs, in a new patch (patch 13). I'm not sure this was the best way, but adding a new file to do it got messy, and this seemed simple. Maybe there's a better way.
Also, there's lots of config options for this, and I'm not sure they are really all necessary. Should there be just one CONFIG_IPMI that covers everything?
Thanks,
-corey
PATCH 2/15 ipmi: Add a PC ISA type structure
From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi.c | 144 +++++++++++++++++++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 11 ++- 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 hw/ipmi/isa_ipmi.c
default-configs/i386-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -1 +1,2 @@ common-obj-$(CONFIG_IPMI) += ipmi.o +obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
hw/ipmi/isa_ipmi.c new file +144 -0
144 lines not on this page · raw message
include/hw/nvram/fw_cfg.h +10 -1
@@ -38,7 +38,16 @@#define FW_CFG_FILE_FIRST 0x20#define FW_CFG_FILE_SLOTS 0x10 -#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS) + +#define FW_CFG_IPMI_INTERFACE 0x30 +#define FW_CFG_IPMI_BASE_ADDR 0x31 +#define FW_CFG_IPMI_REG_SPACE 0x32 +#define FW_CFG_IPMI_REG_SPACING 0x33 +#define FW_CFG_IPMI_SLAVE_ADDR 0x34 +#define FW_CFG_IPMI_IRQ 0x35 +#define FW_CFG_IPMI_VERSION 0x36 + +#define FW_CFG_MAX_ENTRY (FW_CFG_IPMI_VERSION + 1)#define FW_CFG_WRITE_CHANNEL 0x4000#define FW_CFG_ARCH_LOCAL 0x8000
Signature · 1 line
1.8.3.1
PATCH 1/15 Add a base IPMI interface
In reply to [email protected]From: Corey Minyard <[email protected]>
Add the basic IPMI types and infrastructure to QEMU. Low-level interfaces and simulation interfaces will register with this; it's kind of the go-between to tie them together.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi.c | 135 +++++++++++++++++++++++ hw/ipmi/ipmi.h | 215 +++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 2 + 7 files changed, 356 insertions(+) create mode 100644 hw/ipmi/Makefile.objs create mode 100644 hw/ipmi/ipmi.c create mode 100644 hw/ipmi/ipmi.h
default-configs/i386-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_VGA_ISA=y CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y +CONFIG_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_VGA_ISA=y CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y +CONFIG_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += ide/ devices-dirs-$(CONFIG_SOFTMMU) += input/ devices-dirs-$(CONFIG_SOFTMMU) += intc/ devices-dirs-$(CONFIG_IPACK) += ipack/ +devices-dirs-$(CONFIG_SOFTMMU) += ipmi/ devices-dirs-$(CONFIG_SOFTMMU) += isa/ devices-dirs-$(CONFIG_SOFTMMU) += misc/ devices-dirs-$(CONFIG_SOFTMMU) += net/
hw/ipmi/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +common-obj-$(CONFIG_IPMI) += ipmi.o
hw/ipmi/ipmi.c new file +135 -0
135 lines not on this page · raw message
hw/ipmi/ipmi.h new file +215 -0
215 lines not on this page · raw message
qemu-doc.texi +2 -0
@@ -195,6 +195,8 @@ PCI and ISA network adapters @item Serial ports @item +IPMI BMC, either and internal or external one +@item Creative SoundBlaster 16 sound card @item ENSONIQ AudioPCI ES1370 sound card
Signature · 1 line
1.8.3.1
PATCH 3/15 ipmi: Add a KCS low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the KCS hardware interface.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 2 + hw/ipmi/ipmi_kcs.c | 337 +++++++++++++++++++++++++++++++++++++ 4 files changed, 341 insertions(+) create mode 100644 hw/ipmi/ipmi_kcs.c
default-configs/i386-softmmu.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_ISA_IPMI=y +CONFIG_IPMI_KCS=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_ISA_IPMI=y +CONFIG_IPMI_KCS=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +2 -0
@@ -1,2 +1,4 @@ common-obj-$(CONFIG_IPMI) += ipmi.o +common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o + obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
hw/ipmi/ipmi_kcs.c new file +337 -0
337 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 8/15 ipmi: Add documentation
In reply to [email protected]From: Corey Minyard <[email protected]>
Add some basic documentation for the IPMI device.
--- qemu-options.hx | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
qemu-options.hx +38 -0
@@ -373,6 +373,44 @@ Add device @var{driver}. @var{prop}=@var{value} sets driver properties. Valid properties depend on the driver. To get help on possible drivers and properties, use @code{-device help} and @code{-device @var{driver},help}. + +Some drivers are: +@item -device isa-ipmi[,interface=kcs|bt][,iobase=@var{val}][,irq=@var{val}][,slave_addr=@var{val}][,chardev=name] + +Add an IPMI device. This also adds a corresponding ACPI and SMBIOS entries, +if appropriate. The following options are handled: +@table @option +@item interface=kcs|bt +Define the interface type to use. Currently the IPMI-defined KCS and +BT interfaces are handled. The default is KCS. +@item iobase=@var{val} +Define the I/O address of the interface. The default is 0xca0 for KCS +and 0xe4 for BT. +@item irq=@var{val} +Define the interrupt to use. The default is 5. To disable interrupts, +set this to 0. +@item slave_addr=@var{val} +The IPMI slave address to use for the BMC. The default is 0x20. +This address is the BMC's address on the I2C network of management +controllers. If you don't know what this means, it is safe to ignore +it. +@item chardev=name +If a chardev is not specified, the IPMI driver uses a built-in baseboard +management controller (BMC) simulator. It provides a basic BMC with a +watchdog timer and associated sensor. + +If a chardev is specified, A connection is made to an external BMC +simulator. If you do this, it is strongly recommended that you use +the "reconnect=" chardev option to reconnect to the simulator if the +connection is lost. Note that if this is not used carefully, it can +be a security issue, as the interface has the ability to send resets, +NMIs, and power off the VM. It's best if QEMU makes a connection to +an external simulator running on a secure port on localhost, so +neither the simulator nor QEMU is exposed to any outside network. + +See the "lanserv/README.vm" file in the OpenIPMI library for more +details on the external interface. +@end table ETEXI DEF("name", HAS_ARG, QEMU_OPTION_name,
Signature · 1 line
1.8.3.1
PATCH 4/15 ipmi: Add a BT low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the BT hardware interface for IPMI.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_bt.c | 374 +++++++++++++++++++++++++++++++++++++ 4 files changed, 377 insertions(+) create mode 100644 hw/ipmi/ipmi_bt.c
default-configs/i386-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y +CONFIG_IPMI_BT=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y +CONFIG_IPMI_BT=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -1,4 +1,5 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o +common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
hw/ipmi/ipmi_bt.c new file +374 -0
374 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 9/15 ipmi: Add migration capability to the IPMI device.
In reply to [email protected]From: Corey Minyard <[email protected]>
--- hw/ipmi/ipmi.c | 17 +++++++++++++++++ hw/ipmi/ipmi.h | 2 ++ hw/ipmi/ipmi_bt.c | 14 ++++++++++++++ hw/ipmi/ipmi_extern.c | 42 ++++++++++++++++++++++++++++++++++++++---- hw/ipmi/ipmi_kcs.c | 15 +++++++++++++++ hw/ipmi/ipmi_sim.c | 30 ++++++++++++++++++++++++++++++ hw/ipmi/isa_ipmi.c | 12 ++++++++++++ 7 files changed, 128 insertions(+), 4 deletions(-)
hw/ipmi/ipmi.c +17 -0
@@ -118,6 +118,23 @@ void ipmi_bmc_init(IPMIBmc *s, Error **errp) } } +const VMStateDescription vmstate_IPMIInterface = { + .name =TYPE_IPMI_INTERFACE , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_BOOL (obf_irq_set, IPMIInterface), +VMSTATE_BOOL (atn_irq_set, IPMIInterface), +VMSTATE_BOOL (use_irq, IPMIInterface), +VMSTATE_BOOL (irqs_enabled, IPMIInterface), +VMSTATE_UINT32 (outpos, IPMIInterface), +VMSTATE_UINT32 (outlen, IPMIInterface), +VMSTATE_VBUFFER_UINT32 (inmsg, IPMIInterface,1 ,NULL ,0 , inlen), +VMSTATE_BOOL (write_end, IPMIInterface), +VMSTATE_END_OF_LIST () + } +}; +static TypeInfo ipmi_bmc_type_info = { .name =TYPE_IPMI_BMC , .parent =TYPE_OBJECT ,
hw/ipmi/ipmi.h +2 -0
@@ -153,6 +153,8 @@ typedef struct IPMIInterfaceClass { unsigned char *rsp, unsigned int rsp_len); } IPMIInterfaceClass; +extern const VMStateDescription vmstate_IPMIInterface; +void ipmi_interface_init (IPMIInterface *s,Error **errp);void ipmi_interface_reset (IPMIInterface *s);
hw/ipmi/ipmi_bt.c +14 -0
@@ -335,6 +335,19 @@ static void ipmi_bt_handle_reset(IPMIInterface *s, bool is_cold) } } +static const VMStateDescription vmstate_ipmi_bt = { + .name =TYPE_IPMI_INTERFACE_BT , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (control_reg, IPMIBtInterface), +VMSTATE_UINT8 (mask_reg, IPMIBtInterface), +VMSTATE_UINT8 (waiting_rsp, IPMIBtInterface), +VMSTATE_UINT8 (waiting_seq, IPMIBtInterface), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_bt_init (IPMIInterface *s,Error **errp) {IPMIBtInterface *bt =IPMI_INTERFACE_BT (s);
@@ -345,6 +358,7 @@ static void ipmi_bt_init(IPMIInterface *s, Error **errp) s->io_length =3 ;memory_region_init_io (&s->io,NULL , &ipmi_bt_io_ops, bt,"ipmi-bt" ,3 ); +vmstate_register (NULL ,0 , &vmstate_ipmi_bt, bt); }static void ipmi_bt_class_init (ObjectClass *klass,void *data)
hw/ipmi/ipmi_extern.c +38 -4
60 lines not on this page · raw message
hw/ipmi/ipmi_kcs.c +15 -0
@@ -299,6 +299,20 @@ static void ipmi_kcs_set_atn(IPMIInterface *s, int val, int irq) } } +static const VMStateDescription vmstate_ipmi_kcs = { + .name =TYPE_IPMI_INTERFACE_KCS , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (status_reg, IPMIKcsInterface), +VMSTATE_UINT8 (data_out_reg, IPMIKcsInterface), +VMSTATE_INT16 (data_in_reg, IPMIKcsInterface), +VMSTATE_INT16 (cmd_reg, IPMIKcsInterface), +VMSTATE_UINT8 (waiting_rsp, IPMIKcsInterface), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_kcs_init (IPMIInterface *s,Error **errp) {IPMIKcsInterface *kcs =IPMI_INTERFACE_KCS (s);
@@ -309,6 +323,7 @@ static void ipmi_kcs_init(IPMIInterface *s, Error **errp) s->io_length =2 ;memory_region_init_io (&s->io,NULL , &ipmi_kcs_io_ops, kcs,"ipmi-kcs" ,2 ); +vmstate_register (NULL ,0 , &vmstate_ipmi_kcs, kcs); }static void ipmi_kcs_class_init (ObjectClass *class,void *data)
hw/ipmi/ipmi_sim.c +30 -0
@@ -1658,6 +1658,34 @@ static const uint8_t init_sdrs[] = {0xff ,0xff ,0x00 ,0x00 ,0x00 }; +static const VMStateDescription vmstate_ipmi_sim = { + .name =TYPE_IPMI_BMC_SIMULATOR , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (bmc_global_enables, IPMISimBmc), +VMSTATE_UINT8 (msg_flags, IPMISimBmc), +VMSTATE_BOOL (watchdog_initialized, IPMISimBmc), +VMSTATE_UINT8 (watchdog_use, IPMISimBmc), +VMSTATE_UINT8 (watchdog_action, IPMISimBmc), +VMSTATE_UINT8 (watchdog_pretimeout, IPMISimBmc), +VMSTATE_BOOL (watchdog_expired, IPMISimBmc), +VMSTATE_UINT16 (watchdog_timeout, IPMISimBmc), +VMSTATE_BOOL (watchdog_running, IPMISimBmc), +VMSTATE_BOOL (watchdog_preaction_ran, IPMISimBmc), +VMSTATE_INT64 (watchdog_expiry, IPMISimBmc), +VMSTATE_UINT8_ARRAY (evtbuf, IPMISimBmc,16 ), +VMSTATE_UINT8 (sensors[IPMI_WATCHDOG_SENSOR ].status, IPMISimBmc), +VMSTATE_UINT8 (sensors[IPMI_WATCHDOG_SENSOR ].reading, IPMISimBmc), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].states, IPMISimBmc), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].assert_states, IPMISimBmc), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].deassert_states, + IPMISimBmc), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].assert_enable, IPMISimBmc), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_sim_init (IPMIBmc *b,Error **errp) {unsigned int i;
@@ -1705,6 +1733,8 @@ static void ipmi_sim_init(IPMIBmc *b, Error **errp)register_cmds (ss); ss->timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , ipmi_timeout, ss); + +vmstate_register (NULL ,0 , &vmstate_ipmi_sim, ss); }static void ipmi_sim_class_init (ObjectClass *klass,void *data)
hw/ipmi/isa_ipmi.c +12 -0
@@ -121,11 +121,23 @@ static Property ipmi_isa_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static const VMStateDescription vmstate_isa_ipmi = { + .name =TYPE_ISA_IPMI , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_STRUCT_POINTER (intf, ISAIPMIDevice, vmstate_IPMIInterface, + IPMIInterface), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_isa_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->realize = ipmi_isa_realizefn; dc->reset = ipmi_isa_reset; + dc->vmsd = &vmstate_isa_ipmi; dc->props = ipmi_isa_properties; }
Signature · 1 line
1.8.3.1
PATCH 11/15 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 | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
hw/i386/pc.c +18 -17
@@ -680,8 +680,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_tables, *smbios_anchor; -size_t smbios_tables_len, smbios_anchor_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);
@@ -707,21 +705,6 @@ static FWCfgState *bochs_bios_init(void) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_tables =smbios_get_table_legacy (&smbios_tables_len); -if (smbios_tables) { -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_tables, smbios_tables_len); - } - -smbios_get_tables (&smbios_tables, &smbios_tables_len, - &smbios_anchor, &smbios_anchor_len); -if (smbios_anchor) { -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , - smbios_tables, smbios_tables_len); -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , - smbios_anchor, smbios_anchor_len); - } -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,
@@ -1119,7 +1102,25 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)PcGuestInfoState *guest_info_state =container_of (notifier, PcGuestInfoState, machine_done); +uint8_t *smbios_tables, *smbios_anchor; +size_t smbios_tables_len, smbios_anchor_len; +FWCfgState *fw_cfg = guest_info_state->info.fw_cfg; +acpi_setup (&guest_info_state->info); + + smbios_tables =smbios_get_table_legacy (&smbios_tables_len); +if (smbios_tables) { +fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_tables, smbios_tables_len); + } +smbios_get_tables (&smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len); +if (smbios_anchor) { +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , + smbios_tables, smbios_tables_len); +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , + smbios_anchor, smbios_anchor_len); + } } PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
Signature · 1 line
1.8.3.1
PATCH 6/15 ipmi: Add an external connection simulation interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This adds an interface for IPMI that connects to a remote BMC over a chardev (generally a TCP socket). The OpenIPMI lanserv simulator describes this interface, see that for interface details.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_extern.c | 457 +++++++++++++++++++++++++++++++++++++ 4 files changed, 460 insertions(+) create mode 100644 hw/ipmi/ipmi_extern.c
default-configs/i386-softmmu.mak +1 -0
@@ -13,6 +13,7 @@ CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y CONFIG_IPMI_BT=y CONFIG_IPMI_LOCAL=y +CONFIG_IPMI_EXTERN=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -13,6 +13,7 @@ CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y CONFIG_IPMI_BT=y CONFIG_IPMI_LOCAL=y +CONFIG_IPMI_EXTERN=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -2,5 +2,6 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o +common-obj-$(CONFIG_IPMI_EXTERN) += ipmi_extern.o obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
hw/ipmi/ipmi_extern.c new file +457 -0
457 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 10/15 smbios: Add a function to directly add an entry
In reply to [email protected]From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
--- hw/i386/smbios.c | 149 ++++++++++++++++++++++++++++++----------------- include/hw/i386/smbios.h | 13 +++++ 2 files changed, 110 insertions(+), 52 deletions(-)
hw/i386/smbios.c +97 -52
@@ -831,6 +831,25 @@ static void smbios_entry_point_setup(void) ep.structure_table_address =cpu_to_le32 (0 ); } +struct smbios_device_handler { +void (*handle_device_table)(void *opaque); +void *opaque; +struct smbios_device_handler *prev; +}; +static struct smbios_device_handler *device_handlers; + +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque) +{ +struct smbios_device_handler *handler =g_malloc (sizeof (*handler)); + + handler->handle_device_table = handle_device_table; + handler->opaque = opaque; + handler->prev = device_handlers; + device_handlers = handler; +} +void smbios_get_tables (uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len) {
@@ -875,6 +894,14 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, }smbios_build_type_32_table (); + +while (device_handlers) { +struct smbios_device_handler *handler = device_handlers; + device_handlers = handler->prev; + handler->handle_device_table (handler->opaque); +g_free (handler); + } +smbios_build_type_127_table ();smbios_validate_table ();
@@ -898,6 +925,71 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) } } +int smbios_table_entry_add (void *data,int size,bool append_zeros) +{ +struct smbios_structure_header *header; +struct smbios_table *table;/* legacy mode only */ + +/* +* NOTE: standard double '\0' terminator expected, per smbios spec. +* (except in legacy mode, where the second '\0' is implicit and +* will be inserted by the BIOS). +*/ +if (append_zeros) { + size +=2 ; + } + smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); + header = (struct smbios_structure_header *)(smbios_tables + + smbios_tables_len); + +memcpy (header, data, size); + +if (test_bit (header->type, have_fields_bitmap)) { +error_report ("can't load type %d struct, fields already specified!" , + header->type); +exit (1 ); + } +set_bit (header->type, have_binfile_bitmap); + +if (header->type ==4 ) { + smbios_type4_count++; + } + + smbios_tables_len += size; +if (size > smbios_table_max) { + smbios_table_max = size; + } + smbios_table_cnt++; + +/* add a copy of the newly loaded blob to legacy smbios_entries */ +/* NOTE: This code runs before smbios_set_defaults(), so we don't +* yet know which mode (legacy vs. aggregate-table) will be +* required. We therefore add the binary blob to both legacy +* (smbios_entries) and aggregate (smbios_tables) tables, and +* delete the one we don't need from smbios_set_defaults(), +* once we know which machine version has been requested. +*/ +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } +if (append_zeros) { + size -=1 ;/* The BIOS adds the second zero in legacy mode. */ + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + + size +sizeof (*table)); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); +memcpy (table->data, header, size); + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +/* end: add a copy of the newly loaded blob to legacy smbios_entries */ + +return 0 ; +} +void smbios_entry_add (QemuOpts *opts) {Error *local_err =NULL ;
@@ -907,9 +999,8 @@ void smbios_entry_add(QemuOpts *opts) val =qemu_opt_get (opts,"file" );if (val) { -struct smbios_structure_header *header;int size; -struct smbios_table *table;/* legacy mode only */ +uint8_t *data;qemu_opts_validate (opts, qemu_smbios_file_opts, &local_err);if (local_err) {
@@ -923,60 +1014,14 @@ void smbios_entry_add(QemuOpts *opts)exit (1 ); } -/* -* NOTE: standard double '\0' terminator expected, per smbios spec. -* (except in legacy mode, where the second '\0' is implicit and -* will be inserted by the BIOS). -*/ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); - header = (struct smbios_structure_header *)(smbios_tables + - smbios_tables_len); - -if (load_image (val, (uint8_t *)header) != size) { + data =g_malloc (size); +if (load_image (val, data) != size) {error_report ("Failed to load SMBIOS file %s" , val);exit (1 ); } -if (test_bit (header->type, have_fields_bitmap)) { -error_report ("can't load type %d struct, fields already specified!" , - header->type); -exit (1 ); - } -set_bit (header->type, have_binfile_bitmap); - -if (header->type ==4 ) { - smbios_type4_count++; - } - - smbios_tables_len += size; -if (size > smbios_table_max) { - smbios_table_max = size; - } - smbios_table_cnt++; - -/* add a copy of the newly loaded blob to legacy smbios_entries */ -/* NOTE: This code runs before smbios_set_defaults(), so we don't -* yet know which mode (legacy vs. aggregate-table) will be -* required. We therefore add the binary blob to both legacy -* (smbios_entries) and aggregate (smbios_tables) tables, and -* delete the one we don't need from smbios_set_defaults(), -* once we know which machine version has been requested. -*/ -if (!smbios_entries) { - smbios_entries_len =sizeof (uint16_t ); - smbios_entries =g_malloc0 (smbios_entries_len); - } - smbios_entries =g_realloc (smbios_entries, smbios_entries_len + - size +sizeof (*table)); - table = (struct smbios_table *)(smbios_entries + smbios_entries_len); - table->header.type =SMBIOS_TABLE_ENTRY ; - table->header.length =cpu_to_le16 (sizeof (*table) + size); -memcpy (table->data, header, size); - smbios_entries_len +=sizeof (*table) + size; - (*(uint16_t *)smbios_entries) = -cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); -/* end: add a copy of the newly loaded blob to legacy smbios_entries */ - +smbios_table_entry_add (data, size, false); +g_free (data);return ; }
include/hw/i386/smbios.h +13 -0
@@ -27,6 +27,19 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len);/* +* Add an external entry to the SMBIOS table. Can only be called +* from a registered device table handler. +*/ +int smbios_table_entry_add (void *data,int size,bool append_zeros); + +/* +* When constructing SMBIOS tables, call a function at the end of the +* add process to allow devices to add their own SMBIOS table entries. +*/ +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque); +/* * SMBIOS spec defined tables */
Signature · 1 line
1.8.3.1
PATCH 12/15 ipmi: Add SMBIOS table entry
In reply to [email protected]From: Corey Minyard <[email protected]>
Add an IPMI table entry to the SMBIOS.
--- hw/ipmi/isa_ipmi.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
hw/ipmi/isa_ipmi.c +47 -0
@@ -27,6 +27,7 @@#include "qemu/timer.h" #include "sysemu/char.h" #include "sysemu/sysemu.h" +#include "hw/i386/smbios.h" #include "ipmi.h" /* This is the type the user specifies on the -device command line */
@@ -36,13 +37,52 @@typedef struct ISAIPMIDevice {ISADevice dev;char *interface; +int intftype;uint32_t iobase;int32 isairq;uint8_t slave_addr; +uint8_t version;CharDriverState *chr;IPMIInterface *intf; }ISAIPMIDevice ; +#ifdef TARGET_I386 +/* SMBIOS type 38 - IPMI */ +struct smbios_type_38 { +struct smbios_structure_header header; +uint8_t interface_type; +uint8_t ipmi_spec_revision; +uint8_t i2c_slave_address; +uint8_t nv_storage_device_address; +uint64_t base_address; +uint8_t base_address_modifier; +uint8_t interrupt_number; +}QEMU_PACKED ; + +static void ipmi_encode_smbios (void *opaque) +{ +ISAIPMIDevice *info = opaque; +struct smbios_type_38 smb38; + + smb38.header.type =38 ; + smb38.header.length =sizeof (smb38); + smb38.header.handle =cpu_to_le16 (0x3000 ); + smb38.interface_type = info->intftype; + smb38.ipmi_spec_revision = info->version; + smb38.i2c_slave_address = info->slave_addr; + smb38.nv_storage_device_address =0 ; + +/* or 1 to set it to I/O space */ + smb38.base_address =cpu_to_le64 (info->iobase |1 ); + +/* 1-byte boundaries, addr bit0=0, level triggered irq */ + smb38.base_address_modifier =1 ; + smb38.interrupt_number = info->isairq; +smbios_table_entry_add ((struct smbios_structure_header *) &smb38, +sizeof (smb38), true); +} +#endif +static void ipmi_isa_realizefn (DeviceState *dev,Error **errp) {ISADevice *isadev =ISA_DEVICE (dev);
@@ -50,6 +90,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)char typename[20 ];Object *intfobj;IPMIInterface *intf; +IPMIInterfaceClass *intfk;Object *bmcobj;IPMIBmc *bmc;
@@ -68,10 +109,13 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) TYPE_IPMI_INTERFACE_PREFIX "%s", ipmi->interface); intfobj =object_new (typename); intf =IPMI_INTERFACE (intfobj); + intfk =IPMI_INTERFACE_GET_CLASS (intf); bmc->intf = intf; intf->bmc = bmc; intf->io_base = ipmi->iobase; intf->slave_addr = ipmi->slave_addr; + ipmi->intftype = intfk->smbios_type; + ipmi->version =0x20 ;/* Version 2.0 */ ipmi_interface_init (intf, errp);if (*errp) {return ;
@@ -103,6 +147,9 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)qdev_set_legacy_instance_id (dev, intf->io_base, intf->io_length);isa_register_ioport (isadev, &intf->io, intf->io_base); +#ifdef TARGET_I386 +smbios_register_device_table_handler (ipmi_encode_smbios, ipmi); +#endif }static void ipmi_isa_reset (DeviceState *qdev)
Signature · 1 line
1.8.3.1
PATCH 13/15 configure: Copy some items from default configs to target configs
In reply to [email protected]From: Corey Minyard <[email protected]>
This is to get CONFIG_ACPI into the target config so devices that may use ACPI know to do this or not.
--- configure | 7 +++++++ 1 file changed, 7 insertions(+)
configure +7 -0
@@ -5073,6 +5073,9 @@ if test "$linux" = "yes" ; then fi fi +# Copy these from the default config to the target config +defconfig_to_target="CONFIG_ACPI" + for target in $target_list; do target_dir="$target" config_target_mak=$target_dir/config-target.mak
@@ -5431,6 +5434,10 @@ fi echo "LDFLAGS+=$ldflags" >> $config_target_mak echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak +for i in $defconfig_to_target; do + grep $i $source_path/default-configs/${target}.mak >> $config_target_mak +done + done # for target in $targets if [ "$pixman" = "internal" ]; then
Signature · 1 line
1.8.3.1
PATCH 7/15 ipmi: Add tests
In reply to [email protected]From: Corey Minyard <[email protected]>
Test the KCS interface with a local BMC and a BT interface with an external BMC.
--- tests/Makefile | 4 + tests/ipmi-bt-test.c | 440 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ipmi-kcs-test.c | 294 +++++++++++++++++++++++++++++++++ 3 files changed, 738 insertions(+) create mode 100644 tests/ipmi-bt-test.c create mode 100644 tests/ipmi-kcs-test.c
tests/Makefile +4 -0
@@ -146,6 +146,8 @@ gcov-files-i386-y += hw/block/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/bios-tables-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-i386-y += tests/drive_del-test$(EXESUF)
@@ -326,6 +328,8 @@ tests/spapr-phb-test$(EXESUF): tests/spapr-phb-test.o $(libqos-obj-y) tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y) +tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o +tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o $(libqos-obj-y)
tests/ipmi-bt-test.c new file +440 -0
440 lines not on this page · raw message
tests/ipmi-kcs-test.c new file +294 -0
294 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 14/15 acpi: Add hooks for adding things to the SSDT table
In reply to [email protected]From: Corey Minyard <[email protected]>
This way devices can tie in when then SSDT is built and can add their own entries. This didn't seem to fit anyplace else, primarily because it required the Aml type, so I added a new file for it.
--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-hooks.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/acpi-hooks.h | 31 +++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 hw/acpi/acpi-hooks.c create mode 100644 include/hw/acpi/acpi-hooks.h
hw/acpi/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.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-$(CONFIG_ACPI) += acpi-hooks.o
hw/acpi/acpi-hooks.c new file +55 -0
55 lines not on this page · raw message
hw/i386/acpi-build.c +3 -0
@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-hooks.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h"
@@ -1008,6 +1009,8 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (ssdt, sb_scope); } +call_device_ssdt_encoders (ssdt); +/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, ssdt->buf->data, ssdt->buf->len); build_header(linker, table_data,
include/hw/acpi/acpi-hooks.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Hooks for dynamically construct ACPI tables in devices +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque), +void *opaque); +void call_device_ssdt_encoders (Aml *ssdt); + +#endif /* QEMU_HW_ACPI_HOOKS_H */
Signature · 1 line
1.8.3.1
PATCH 5/15 ipmi: Add a local BMC simulation
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides a minimal local BMC, basically enough to comply with the spec and provide a complete watchdog timer (including a sensor, SDR, and event).
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_sim.c | 1730 ++++++++++++++++++++++++++++++++++++ 4 files changed, 1733 insertions(+) create mode 100644 hw/ipmi/ipmi_sim.c
default-configs/i386-softmmu.mak +1 -0
@@ -12,6 +12,7 @@ CONFIG_IPMI=y CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y CONFIG_IPMI_BT=y +CONFIG_IPMI_LOCAL=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -12,6 +12,7 @@ CONFIG_IPMI=y CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y CONFIG_IPMI_BT=y +CONFIG_IPMI_LOCAL=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -1,5 +1,6 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o +common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
hw/ipmi/ipmi_sim.c new file +1730 -0
1,730 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
In reply to [email protected]Quoted 135 lines · On 07/04/2015 21:51, [email protected] wrote:
From: Corey Minyard <[email protected]>
This way devices can tie in when then SSDT is built and can add their own entries. This didn't seem to fit anyplace else, primarily because it required the Aml type, so I added a new file for it.
Signed-off-by Corey Minyard <[email protected]>--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-hooks.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/acpi-hooks.h | 31 +++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 hw/acpi/acpi-hooks.c create mode 100644 include/hw/acpi/acpi-hooks.hhw/acpi/Makefile.objs +1
-0@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.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-$(CONFIG_ACPI) += acpi-hooks.ohw/acpi/acpi-hooks.c new file +55
-0@@ -0,0 +1,55 @@ +/* +* ACPI hooks for inserting table entries from devices into the SSDT table. +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <hw/acpi/acpi-hooks.h> +#include <qemu/queue.h> + +struct ssdt_device_encoder { +void (*encode)(Aml *ssdt,void *opaque); +void *opaque; +QSLIST_ENTRY (ssdt_device_encoder) next; +}; + +static QSLIST_HEAD(ssdt_device_encoders, ssdt_device_encoder) + ssdt_device_encoders =QSLIST_HEAD_INITIALIZER (&ssdt_device_encoders); + +void +add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque),void *opaque) +{ + struct ssdt_device_encoder *e = g_new0(struct ssdt_device_encoder, 1); + + e->encode = encode; + e->opaque = opaque; +QSLIST_INSERT_HEAD (&ssdt_device_encoders, e, next); +} + +void +call_device_ssdt_encoders (Aml *ssdt) +{ +struct ssdt_device_encoder *e; + + QSLIST_FOREACH(e, &ssdt_device_encoders, next) { + e->encode (ssdt, e->opaque); + } +}hw/i386/acpi-build.c +3
-0@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-hooks.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h" @@ -1008,6 +1009,8 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (ssdt, sb_scope); } +call_device_ssdt_encoders (ssdt); +/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, ssdt->buf->data, ssdt->buf->len); build_header(linker, table_data,include/hw/acpi/acpi-hooks.h new file +21
-0@@ -0,0 +1,31 @@ +/* +* Hooks for dynamically construct ACPI tables in devices +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ +
include/hw/acpi/acpi-hooks.h line 31
Quoted 10 lines
include/hw/acpi/acpi-hooks.h new file +10
-0+#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque), +void *opaque); +void call_device_ssdt_encoders (Aml *ssdt); + +#endif /* QEMU_HW_ACPI_HOOKS_H */
I like this. Michael, can you please review patches 10/11/14 in this series?
Paolo
Quoted 13 lines · On 07/04/2015 21:51, [email protected] wrote:
This set of patches adds an IPMI KCS or BT interface to qemu, along with a local simulated baseboard management controller (BMC) and a way to connect to an external BMC. It is mostly unchanged from previous release, except for bug fixes and the following changes:
The ACPI generation code custom to this was removed and it's now using the new aml-build code.
Because of the previous change, capability was added to hook into the SSDT build process so that devices could insert their own table entries.
Quoted 8 lines
Also because of this, and because Benjamin Herrenschmidt pointed out the need to have this on systems without SMBIOS and ACPI, that code has now been made optional. The SMBIOS uses
TARGET_I386to do this, which seems to be safe. The ACPI code required transfering theCONFIG_ACPIentry from the default configs to the target configs, in a new patch (patch 13). I'm not sure this was the best way, but adding a new file to do it got messy, and this seemed simple. Maybe there's a better way.
I tried suggesting one in the reply to patch 13.
It requires splitting into three files (one for basic ISA IPMI, one for SMBIOS, one for ACPI).
Quoted 3 lines
Also, there's lots of config options for this, and I'm not sure they are really all necessary. Should there be just one
CONFIG_IPMIthat covers everything?
I think it doesn't hurt to have more flexibility.
I didn't receive patch 15.
Paolo
Re: [Qemu-devel] [PATCH 13/15] configure: Copy some items from default configs to target configs
In reply to [email protected]Quoted 26 lines · On 07/04/2015 21:51, [email protected] wrote:
From: Corey Minyard <[email protected]>
This is to get
CONFIG_ACPIinto the target config so devices that may use ACPI know to do this or not.Signed-off-by Corey Minyard <[email protected]>--- configure | 7 +++++++ 1 file changed, 7 insertions(+)configure +3
-0@@ -5073,6 +5073,9 @@ if test "$linux" = "yes" ; then fi fi +# Copy these from the default config to the target config +defconfig_to_target="CONFIG_ACPI" + for target in $target_list; do target_dir="$target" config_target_mak=$target_dir/config-target.mak
configure fi · line 5443
Quoted 10 lines
configure +4
-0@@ -5431,6 +5434,10 @@ fi echo "LDFLAGS+=$ldflags" >> $config_target_mak echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak +for i in $defconfig_to_target; do + grep $i $source_path/default-configs/${target}.mak >> $config_target_mak +done + done # for target in $targets if [ "$pixman" = "internal" ]; then
This doesn't support "include" directives.
Also, it's ugly that you have to compile files per-target.
Perhaps you can use something like:
CONFIG_NOT_ACPI := $(call lnot,$(CONFIG_ACPI))CONFIG_NOT_SMBIOS := $(call lnot,$(CONFIG_SMBIOS))
common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
common-obj-$(call land,$(CONFIG_ISA_IPMI),$(CONFIG_ACPI)) += isa_ipmi-ssdt.o
common-obj-$(call land,$(CONFIG_ISA_IPMI),$(CONFIG_NOT_ACPI)) += isa_ipmi-ssdt-stub.o
common-obj-$(call land,$(CONFIG_ISA_IPMI),$(CONFIG_SMBIOS)) += isa_ipmi-smbios.o
common-obj-$(call land,$(CONFIG_ISA_IPMI),$(CONFIG_NOT_ACPI)) += isa_ipmi-smbios-stub.o
# Make toplevel always build these
common-obj-$(CONFIG_ALL) += isa_ipmi-ssdt-stub.o isa_ipmi-smbios-stub.o
Paolo
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
In reply to [email protected]Quoted 8 lines · On Tue, Apr 07, 2015 at 02:51:39PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Signed-off-by Corey Minyard <[email protected]>
Do we have to use a callback for this?
It seems that if smbios_table_entry_add just added the table itself to some array or a linked list, then devices could just call smbios_table_entry_add instead of registering a handler.
And smbios_get_tables would scan that and get the tables.
On systems without smbios, this function could be a nop stub.
Did I miss something?
Quoted 225 lines
--- hw/i386/smbios.c | 149 ++++++++++++++++++++++++++++++----------------- include/hw/i386/smbios.h | 13 +++++ 2 files changed, 110 insertions(+), 52 deletions(-)hw/i386/smbios.c +97
-52@@ -831,6 +831,25 @@ static void smbios_entry_point_setup(void) ep.structure_table_address =cpu_to_le32 (0 ); } +struct smbios_device_handler { +void (*handle_device_table)(void *opaque); +void *opaque; +struct smbios_device_handler *prev; +}; +static struct smbios_device_handler *device_handlers; + +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque) +{ +struct smbios_device_handler *handler =g_malloc (sizeof (*handler)); + + handler->handle_device_table = handle_device_table; + handler->opaque = opaque; + handler->prev = device_handlers; + device_handlers = handler; +} +void smbios_get_tables (uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len) {@@ -875,6 +894,14 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, }smbios_build_type_32_table (); + +while (device_handlers) { +struct smbios_device_handler *handler = device_handlers; + device_handlers = handler->prev; + handler->handle_device_table (handler->opaque); +g_free (handler); + } +smbios_build_type_127_table ();smbios_validate_table ();@@ -898,6 +925,71 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) } } +int smbios_table_entry_add (void *data,int size,bool append_zeros) +{ +struct smbios_structure_header *header; +struct smbios_table *table;/* legacy mode only */ + +/* +* NOTE: standard double '\0' terminator expected, per smbios spec. +* (except in legacy mode, where the second '\0' is implicit and +* will be inserted by the BIOS). +*/ +if (append_zeros) { + size +=2 ; + } + smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); + header = (struct smbios_structure_header *)(smbios_tables + + smbios_tables_len); + +memcpy (header, data, size); + +if (test_bit (header->type, have_fields_bitmap)) { +error_report ("can't load type %d struct, fields already specified!" , + header->type); +exit (1 ); + } +set_bit (header->type, have_binfile_bitmap); + +if (header->type ==4 ) { + smbios_type4_count++; + } + + smbios_tables_len += size; +if (size > smbios_table_max) { + smbios_table_max = size; + } + smbios_table_cnt++; + +/* add a copy of the newly loaded blob to legacy smbios_entries */ +/* NOTE: This code runs before smbios_set_defaults(), so we don't +* yet know which mode (legacy vs. aggregate-table) will be +* required. We therefore add the binary blob to both legacy +* (smbios_entries) and aggregate (smbios_tables) tables, and +* delete the one we don't need from smbios_set_defaults(), +* once we know which machine version has been requested. +*/ +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } +if (append_zeros) { + size -=1 ;/* The BIOS adds the second zero in legacy mode. */ + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + + size +sizeof (*table)); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); +memcpy (table->data, header, size); + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +/* end: add a copy of the newly loaded blob to legacy smbios_entries */ + +return 0 ; +} +void smbios_entry_add (QemuOpts *opts) {Error *local_err =NULL ;@@ -907,9 +999,8 @@ void smbios_entry_add(QemuOpts *opts) val =qemu_opt_get (opts,"file" );if (val) { -struct smbios_structure_header *header;int size; -struct smbios_table *table;/* legacy mode only */ +uint8_t *data;qemu_opts_validate (opts, qemu_smbios_file_opts, &local_err);if (local_err) {@@ -923,60 +1014,14 @@ void smbios_entry_add(QemuOpts *opts)exit (1 ); } -/* -* NOTE: standard double '\0' terminator expected, per smbios spec. -* (except in legacy mode, where the second '\0' is implicit and -* will be inserted by the BIOS). -*/ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); - header = (struct smbios_structure_header *)(smbios_tables + - smbios_tables_len); - -if (load_image (val, (uint8_t *)header) != size) { + data =g_malloc (size); +if (load_image (val, data) != size) {error_report ("Failed to load SMBIOS file %s" , val);exit (1 ); } -if (test_bit (header->type, have_fields_bitmap)) { -error_report ("can't load type %d struct, fields already specified!" , - header->type); -exit (1 ); - } -set_bit (header->type, have_binfile_bitmap); - -if (header->type ==4 ) { - smbios_type4_count++; - } - - smbios_tables_len += size; -if (size > smbios_table_max) { - smbios_table_max = size; - } - smbios_table_cnt++; - -/* add a copy of the newly loaded blob to legacy smbios_entries */ -/* NOTE: This code runs before smbios_set_defaults(), so we don't -* yet know which mode (legacy vs. aggregate-table) will be -* required. We therefore add the binary blob to both legacy -* (smbios_entries) and aggregate (smbios_tables) tables, and -* delete the one we don't need from smbios_set_defaults(), -* once we know which machine version has been requested. -*/ -if (!smbios_entries) { - smbios_entries_len =sizeof (uint16_t ); - smbios_entries =g_malloc0 (smbios_entries_len); - } - smbios_entries =g_realloc (smbios_entries, smbios_entries_len + - size +sizeof (*table)); - table = (struct smbios_table *)(smbios_entries + smbios_entries_len); - table->header.type =SMBIOS_TABLE_ENTRY ; - table->header.length =cpu_to_le16 (sizeof (*table) + size); -memcpy (table->data, header, size); - smbios_entries_len +=sizeof (*table) + size; - (*(uint16_t *)smbios_entries) = -cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); -/* end: add a copy of the newly loaded blob to legacy smbios_entries */ - +smbios_table_entry_add (data, size, false); +g_free (data);return ; }include/hw/i386/smbios.h +13
-0@@ -27,6 +27,19 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len);/* +* Add an external entry to the SMBIOS table. Can only be called +* from a registered device table handler. +*/ +int smbios_table_entry_add (void *data,int size,bool append_zeros); + +/* +* When constructing SMBIOS tables, call a function at the end of the +* add process to allow devices to add their own SMBIOS table entries. +*/ +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque); +/* * SMBIOS spec defined tables */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
In reply to [email protected]Quoted 7 lines · On Tue, Apr 07, 2015 at 02:51:43PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
This way devices can tie in when then SSDT is built and can add their own entries. This didn't seem to fit anyplace else, primarily because it required the Aml type, so I added a new file for it.
Signed-off-by Corey Minyard <[email protected]>
Hmm, I don't see patch 15/15 so I don't know how this is used.
Presumably devices register using add_device_ssdt_encoder? Can't they, instead, add their tables to some list at that point?
It also would seem a bit easier to debug to have devices add their own tables rather than patch SSDT.
Somewhere near the line
/* Add tables supplied by user (if any) */
would be a good place to stick this.
Quoted 140 lines
--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-hooks.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/acpi-hooks.h | 31 +++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 hw/acpi/acpi-hooks.c create mode 100644 include/hw/acpi/acpi-hooks.hhw/acpi/Makefile.objs +1
-0@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.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-$(CONFIG_ACPI) += acpi-hooks.ohw/acpi/acpi-hooks.c new file +55
-0@@ -0,0 +1,55 @@ +/* +* ACPI hooks for inserting table entries from devices into the SSDT table. +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <hw/acpi/acpi-hooks.h> +#include <qemu/queue.h> + +struct ssdt_device_encoder { +void (*encode)(Aml *ssdt,void *opaque); +void *opaque; +QSLIST_ENTRY (ssdt_device_encoder) next; +}; + +static QSLIST_HEAD(ssdt_device_encoders, ssdt_device_encoder) + ssdt_device_encoders =QSLIST_HEAD_INITIALIZER (&ssdt_device_encoders); + +void +add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque),void *opaque) +{ + struct ssdt_device_encoder *e = g_new0(struct ssdt_device_encoder, 1); + + e->encode = encode; + e->opaque = opaque; +QSLIST_INSERT_HEAD (&ssdt_device_encoders, e, next); +} + +void +call_device_ssdt_encoders (Aml *ssdt) +{ +struct ssdt_device_encoder *e; + + QSLIST_FOREACH(e, &ssdt_device_encoders, next) { + e->encode (ssdt, e->opaque); + } +}hw/i386/acpi-build.c +3
-0@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-hooks.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h" @@ -1008,6 +1009,8 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (ssdt, sb_scope); } +call_device_ssdt_encoders (ssdt); +/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, ssdt->buf->data, ssdt->buf->len); build_header(linker, table_data,include/hw/acpi/acpi-hooks.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* Hooks for dynamically construct ACPI tables in devices +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque), +void *opaque); +void call_device_ssdt_encoders (Aml *ssdt); + +#endif /* QEMU_HW_ACPI_HOOKS_H */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
In reply to Michael S. TsirkinQuoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · On Tue, Apr 07, 2015 at 02:51:39PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Quoted 8 lines
Quoted 1 line
Signed-off-by Corey Minyard <[email protected]>Do we have to use a callback for this?
It seems that if
smbios_table_entry_addjust added the table itself to some array or a linked list, then devices could just callsmbios_table_entry_addinstead of registering a handler.And
smbios_get_tableswould scan that and get the tables.
Well, there are many ways you could handle this, and it doesn't seem much different in the end to me. You either have a list of items to add to the table or a list of callbacks to fill in the data.
I made this the same as the ACPI code, which you have to have as a callback if you are adding it to a common SSDT. Plus it reduced the amount of dynamic allocation required.
Quoted 2 lines
On systems without smbios, this function could be a nop stub.
One nice things about the callbacks is you can eliminate any stubs. I find stubs kind of ugly, personally.
-corey
Quoted 228 lines
Did I miss something?
Quoted 225 lines
--- hw/i386/smbios.c | 149 ++++++++++++++++++++++++++++++----------------- include/hw/i386/smbios.h | 13 +++++ 2 files changed, 110 insertions(+), 52 deletions(-)hw/i386/smbios.c +97
-52@@ -831,6 +831,25 @@ static void smbios_entry_point_setup(void) ep.structure_table_address =cpu_to_le32 (0 ); } +struct smbios_device_handler { +void (*handle_device_table)(void *opaque); +void *opaque; +struct smbios_device_handler *prev; +}; +static struct smbios_device_handler *device_handlers; + +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque) +{ +struct smbios_device_handler *handler =g_malloc (sizeof (*handler)); + + handler->handle_device_table = handle_device_table; + handler->opaque = opaque; + handler->prev = device_handlers; + device_handlers = handler; +} +void smbios_get_tables (uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len) {@@ -875,6 +894,14 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, }smbios_build_type_32_table (); + +while (device_handlers) { +struct smbios_device_handler *handler = device_handlers; + device_handlers = handler->prev; + handler->handle_device_table (handler->opaque); +g_free (handler); + } +smbios_build_type_127_table ();smbios_validate_table ();@@ -898,6 +925,71 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) } } +int smbios_table_entry_add (void *data,int size,bool append_zeros) +{ +struct smbios_structure_header *header; +struct smbios_table *table;/* legacy mode only */ + +/* +* NOTE: standard double '\0' terminator expected, per smbios spec. +* (except in legacy mode, where the second '\0' is implicit and +* will be inserted by the BIOS). +*/ +if (append_zeros) { + size +=2 ; + } + smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); + header = (struct smbios_structure_header *)(smbios_tables + + smbios_tables_len); + +memcpy (header, data, size); + +if (test_bit (header->type, have_fields_bitmap)) { +error_report ("can't load type %d struct, fields already specified!" , + header->type); +exit (1 ); + } +set_bit (header->type, have_binfile_bitmap); + +if (header->type ==4 ) { + smbios_type4_count++; + } + + smbios_tables_len += size; +if (size > smbios_table_max) { + smbios_table_max = size; + } + smbios_table_cnt++; + +/* add a copy of the newly loaded blob to legacy smbios_entries */ +/* NOTE: This code runs before smbios_set_defaults(), so we don't +* yet know which mode (legacy vs. aggregate-table) will be +* required. We therefore add the binary blob to both legacy +* (smbios_entries) and aggregate (smbios_tables) tables, and +* delete the one we don't need from smbios_set_defaults(), +* once we know which machine version has been requested. +*/ +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } +if (append_zeros) { + size -=1 ;/* The BIOS adds the second zero in legacy mode. */ + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + + size +sizeof (*table)); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); +memcpy (table->data, header, size); + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +/* end: add a copy of the newly loaded blob to legacy smbios_entries */ + +return 0 ; +} +void smbios_entry_add (QemuOpts *opts) {Error *local_err =NULL ;@@ -907,9 +999,8 @@ void smbios_entry_add(QemuOpts *opts) val =qemu_opt_get (opts,"file" );if (val) { -struct smbios_structure_header *header;int size; -struct smbios_table *table;/* legacy mode only */ +uint8_t *data;qemu_opts_validate (opts, qemu_smbios_file_opts, &local_err);if (local_err) {@@ -923,60 +1014,14 @@ void smbios_entry_add(QemuOpts *opts)exit (1 ); } -/* -* NOTE: standard double '\0' terminator expected, per smbios spec. -* (except in legacy mode, where the second '\0' is implicit and -* will be inserted by the BIOS). -*/ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); - header = (struct smbios_structure_header *)(smbios_tables + - smbios_tables_len); - -if (load_image (val, (uint8_t *)header) != size) { + data =g_malloc (size); +if (load_image (val, data) != size) {error_report ("Failed to load SMBIOS file %s" , val);exit (1 ); } -if (test_bit (header->type, have_fields_bitmap)) { -error_report ("can't load type %d struct, fields already specified!" , - header->type); -exit (1 ); - } -set_bit (header->type, have_binfile_bitmap); - -if (header->type ==4 ) { - smbios_type4_count++; - } - - smbios_tables_len += size; -if (size > smbios_table_max) { - smbios_table_max = size; - } - smbios_table_cnt++; - -/* add a copy of the newly loaded blob to legacy smbios_entries */ -/* NOTE: This code runs before smbios_set_defaults(), so we don't -* yet know which mode (legacy vs. aggregate-table) will be -* required. We therefore add the binary blob to both legacy -* (smbios_entries) and aggregate (smbios_tables) tables, and -* delete the one we don't need from smbios_set_defaults(), -* once we know which machine version has been requested. -*/ -if (!smbios_entries) { - smbios_entries_len =sizeof (uint16_t ); - smbios_entries =g_malloc0 (smbios_entries_len); - } - smbios_entries =g_realloc (smbios_entries, smbios_entries_len + - size +sizeof (*table)); - table = (struct smbios_table *)(smbios_entries + smbios_entries_len); - table->header.type =SMBIOS_TABLE_ENTRY ; - table->header.length =cpu_to_le16 (sizeof (*table) + size); -memcpy (table->data, header, size); - smbios_entries_len +=sizeof (*table) + size; - (*(uint16_t *)smbios_entries) = -cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); -/* end: add a copy of the newly loaded blob to legacy smbios_entries */ - +smbios_table_entry_add (data, size, false); +g_free (data);return ; }include/hw/i386/smbios.h +13
-0@@ -27,6 +27,19 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len);/* +* Add an external entry to the SMBIOS table. Can only be called +* from a registered device table handler. +*/ +int smbios_table_entry_add (void *data,int size,bool append_zeros); + +/* +* When constructing SMBIOS tables, call a function at the end of the +* add process to allow devices to add their own SMBIOS table entries. +*/ +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque); +/* * SMBIOS spec defined tables */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
In reply to Michael S. TsirkinQuoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · On Tue, Apr 07, 2015 at 02:51:43PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
This way devices can tie in when then SSDT is built and can add their own entries. This didn't seem to fit anyplace else, primarily because it required the Aml type, so I added a new file for it.
Signed-off-by Corey Minyard <[email protected]>Hmm, I don't see patch 15/15 so I don't know how this is used.
Yeah, I resent and I don't know what's happened. All the others were sent exactly the same way. Something doesn't like that patch.
Quoted 3 lines
Presumably devices register using
add_device_ssdt_encoder? Can't they, instead, add their tables to some list at that point?
Not if they are adding to a common SSDT.
Quoted 6 lines
It also would seem a bit easier to debug to have devices add their own tables rather than patch SSDT.
Somewhere near the line/* Add tables supplied by user (if any) */would be a good place to stick this.
So you are suggesting each device add it's own SSDT? I'm not sure how that helps debugging, it seems simpler to add it to a common one. But it's not a big deal either way.
-corey
Quoted 142 lines
Quoted 142 lines
--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-hooks.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/acpi-hooks.h | 31 +++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 hw/acpi/acpi-hooks.c create mode 100644 include/hw/acpi/acpi-hooks.hhw/acpi/Makefile.objs +1
-0@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.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-$(CONFIG_ACPI) += acpi-hooks.ohw/acpi/acpi-hooks.c new file +55
-0@@ -0,0 +1,55 @@ +/* +* ACPI hooks for inserting table entries from devices into the SSDT table. +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <hw/acpi/acpi-hooks.h> +#include <qemu/queue.h> + +struct ssdt_device_encoder { +void (*encode)(Aml *ssdt,void *opaque); +void *opaque; +QSLIST_ENTRY (ssdt_device_encoder) next; +}; + +static QSLIST_HEAD(ssdt_device_encoders, ssdt_device_encoder) + ssdt_device_encoders =QSLIST_HEAD_INITIALIZER (&ssdt_device_encoders); + +void +add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque),void *opaque) +{ + struct ssdt_device_encoder *e = g_new0(struct ssdt_device_encoder, 1); + + e->encode = encode; + e->opaque = opaque; +QSLIST_INSERT_HEAD (&ssdt_device_encoders, e, next); +} + +void +call_device_ssdt_encoders (Aml *ssdt) +{ +struct ssdt_device_encoder *e; + + QSLIST_FOREACH(e, &ssdt_device_encoders, next) { + e->encode (ssdt, e->opaque); + } +}hw/i386/acpi-build.c +3
-0@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-hooks.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h" @@ -1008,6 +1009,8 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (ssdt, sb_scope); } +call_device_ssdt_encoders (ssdt); +/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, ssdt->buf->data, ssdt->buf->len); build_header(linker, table_data,include/hw/acpi/acpi-hooks.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* Hooks for dynamically construct ACPI tables in devices +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque), +void *opaque); +void call_device_ssdt_encoders (Aml *ssdt); + +#endif /* QEMU_HW_ACPI_HOOKS_H */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
Quoted 11 lines · Corey Minyard
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · On Tue, Apr 07, 2015 at 02:51:43PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
This way devices can tie in when then SSDT is built and can add their own entries. This didn't seem to fit anyplace else, primarily because it required the Aml type, so I added a new file for it.
Signed-off-by Corey Minyard <[email protected]>Hmm, I don't see patch 15/15 so I don't know how this is used.
Quoted 8 lines
Yeah, I resent and I don't know what's happened. All the others were sent exactly the same way. Something doesn't like that patch.
Quoted 3 lines
Presumably devices register using
add_device_ssdt_encoder? Can't they, instead, add their tables to some list at that point?Not if they are adding to a common SSDT.
Why not? Just walk the list after building the rest of the SSDT.
Quoted 9 lines
Quoted 6 lines
It also would seem a bit easier to debug to have devices add their own tables rather than patch SSDT.
Somewhere near the line/* Add tables supplied by user (if any) */would be a good place to stick this.
So you are suggesting each device add it's own SSDT? I'm not sure how that helps debugging, it seems simpler to add it to a common one.
For example, it's easier to write a unit test: encode something specific in one of the IDs, then look it up.
Which is, btw, something that's missing in this patchset.
Quoted 4 lines
But
it's not a big deal either way.-corey
Yes, there isn't a lot of difference really. Seems slightly neater.
Quoted 142 lines
Quoted 142 lines
Quoted 142 lines
--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-hooks.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/acpi-hooks.h | 31 +++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 hw/acpi/acpi-hooks.c create mode 100644 include/hw/acpi/acpi-hooks.hhw/acpi/Makefile.objs +1
-0@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += memory_hotplug.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-$(CONFIG_ACPI) += acpi-hooks.ohw/acpi/acpi-hooks.c new file +55
-0@@ -0,0 +1,55 @@ +/* +* ACPI hooks for inserting table entries from devices into the SSDT table. +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <hw/acpi/acpi-hooks.h> +#include <qemu/queue.h> + +struct ssdt_device_encoder { +void (*encode)(Aml *ssdt,void *opaque); +void *opaque; +QSLIST_ENTRY (ssdt_device_encoder) next; +}; + +static QSLIST_HEAD(ssdt_device_encoders, ssdt_device_encoder) + ssdt_device_encoders =QSLIST_HEAD_INITIALIZER (&ssdt_device_encoders); + +void +add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque),void *opaque) +{ + struct ssdt_device_encoder *e = g_new0(struct ssdt_device_encoder, 1); + + e->encode = encode; + e->opaque = opaque; +QSLIST_INSERT_HEAD (&ssdt_device_encoders, e, next); +} + +void +call_device_ssdt_encoders (Aml *ssdt) +{ +struct ssdt_device_encoder *e; + + QSLIST_FOREACH(e, &ssdt_device_encoders, next) { + e->encode (ssdt, e->opaque); + } +}hw/i386/acpi-build.c +3
-0@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-hooks.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h" @@ -1008,6 +1009,8 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (ssdt, sb_scope); } +call_device_ssdt_encoders (ssdt); +/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, ssdt->buf->data, ssdt->buf->len); build_header(linker, table_data,include/hw/acpi/acpi-hooks.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* Hooks for dynamically construct ACPI tables in devices +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_device_ssdt_encoder (void (*encode)(Aml *ssdt,void *opaque), +void *opaque); +void call_device_ssdt_encoders (Aml *ssdt); + +#endif /* QEMU_HW_ACPI_HOOKS_H */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
In reply to Corey MinyardQuoted 16 lines · Corey Minyard
Quoted 15 lines · Michael S. Tsirkin
Quoted 8 lines · On Tue, Apr 07, 2015 at 02:51:39PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Signed-off-by Corey Minyard <[email protected]>Do we have to use a callback for this?
It seems that if
smbios_table_entry_addjust added the table itself to some array or a linked list, then devices could just callsmbios_table_entry_addinstead of registering a handler.
Quoted 8 lines
Quoted 1 line
And
smbios_get_tableswould scan that and get the tables.Well, there are many ways you could handle this, and it doesn't seem much different in the end to me. You either have a list of items to add to the table or a list of callbacks to fill in the data.
I made this the same as the ACPI code, which you have to have as a callback if you are adding it to a common SSDT.
Not really I think.
Quoted 2 lines
Plus it reduced the
amount of dynamic allocation required.
Not sure why this matters though.
Quoted 7 lines
Quoted 2 lines
On systems without smbios, this function could be a nop stub.
One nice things about the callbacks is you can eliminate any stubs. I find stubs kind of ugly, personally.
-corey
You still need a stub for the register function, don't you?
Quoted 228 lines
Quoted 228 lines
Did I miss something?
Quoted 225 lines
--- hw/i386/smbios.c | 149 ++++++++++++++++++++++++++++++----------------- include/hw/i386/smbios.h | 13 +++++ 2 files changed, 110 insertions(+), 52 deletions(-)hw/i386/smbios.c +97
-52@@ -831,6 +831,25 @@ static void smbios_entry_point_setup(void) ep.structure_table_address =cpu_to_le32 (0 ); } +struct smbios_device_handler { +void (*handle_device_table)(void *opaque); +void *opaque; +struct smbios_device_handler *prev; +}; +static struct smbios_device_handler *device_handlers; + +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque) +{ +struct smbios_device_handler *handler =g_malloc (sizeof (*handler)); + + handler->handle_device_table = handle_device_table; + handler->opaque = opaque; + handler->prev = device_handlers; + device_handlers = handler; +} +void smbios_get_tables (uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len) {@@ -875,6 +894,14 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, }smbios_build_type_32_table (); + +while (device_handlers) { +struct smbios_device_handler *handler = device_handlers; + device_handlers = handler->prev; + handler->handle_device_table (handler->opaque); +g_free (handler); + } +smbios_build_type_127_table ();smbios_validate_table ();@@ -898,6 +925,71 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) } } +int smbios_table_entry_add (void *data,int size,bool append_zeros) +{ +struct smbios_structure_header *header; +struct smbios_table *table;/* legacy mode only */ + +/* +* NOTE: standard double '\0' terminator expected, per smbios spec. +* (except in legacy mode, where the second '\0' is implicit and +* will be inserted by the BIOS). +*/ +if (append_zeros) { + size +=2 ; + } + smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); + header = (struct smbios_structure_header *)(smbios_tables + + smbios_tables_len); + +memcpy (header, data, size); + +if (test_bit (header->type, have_fields_bitmap)) { +error_report ("can't load type %d struct, fields already specified!" , + header->type); +exit (1 ); + } +set_bit (header->type, have_binfile_bitmap); + +if (header->type ==4 ) { + smbios_type4_count++; + } + + smbios_tables_len += size; +if (size > smbios_table_max) { + smbios_table_max = size; + } + smbios_table_cnt++; + +/* add a copy of the newly loaded blob to legacy smbios_entries */ +/* NOTE: This code runs before smbios_set_defaults(), so we don't +* yet know which mode (legacy vs. aggregate-table) will be +* required. We therefore add the binary blob to both legacy +* (smbios_entries) and aggregate (smbios_tables) tables, and +* delete the one we don't need from smbios_set_defaults(), +* once we know which machine version has been requested. +*/ +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } +if (append_zeros) { + size -=1 ;/* The BIOS adds the second zero in legacy mode. */ + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + + size +sizeof (*table)); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); +memcpy (table->data, header, size); + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +/* end: add a copy of the newly loaded blob to legacy smbios_entries */ + +return 0 ; +} +void smbios_entry_add (QemuOpts *opts) {Error *local_err =NULL ;@@ -907,9 +999,8 @@ void smbios_entry_add(QemuOpts *opts) val =qemu_opt_get (opts,"file" );if (val) { -struct smbios_structure_header *header;int size; -struct smbios_table *table;/* legacy mode only */ +uint8_t *data;qemu_opts_validate (opts, qemu_smbios_file_opts, &local_err);if (local_err) {@@ -923,60 +1014,14 @@ void smbios_entry_add(QemuOpts *opts)exit (1 ); } -/* -* NOTE: standard double '\0' terminator expected, per smbios spec. -* (except in legacy mode, where the second '\0' is implicit and -* will be inserted by the BIOS). -*/ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); - header = (struct smbios_structure_header *)(smbios_tables + - smbios_tables_len); - -if (load_image (val, (uint8_t *)header) != size) { + data =g_malloc (size); +if (load_image (val, data) != size) {error_report ("Failed to load SMBIOS file %s" , val);exit (1 ); } -if (test_bit (header->type, have_fields_bitmap)) { -error_report ("can't load type %d struct, fields already specified!" , - header->type); -exit (1 ); - } -set_bit (header->type, have_binfile_bitmap); - -if (header->type ==4 ) { - smbios_type4_count++; - } - - smbios_tables_len += size; -if (size > smbios_table_max) { - smbios_table_max = size; - } - smbios_table_cnt++; - -/* add a copy of the newly loaded blob to legacy smbios_entries */ -/* NOTE: This code runs before smbios_set_defaults(), so we don't -* yet know which mode (legacy vs. aggregate-table) will be -* required. We therefore add the binary blob to both legacy -* (smbios_entries) and aggregate (smbios_tables) tables, and -* delete the one we don't need from smbios_set_defaults(), -* once we know which machine version has been requested. -*/ -if (!smbios_entries) { - smbios_entries_len =sizeof (uint16_t ); - smbios_entries =g_malloc0 (smbios_entries_len); - } - smbios_entries =g_realloc (smbios_entries, smbios_entries_len + - size +sizeof (*table)); - table = (struct smbios_table *)(smbios_entries + smbios_entries_len); - table->header.type =SMBIOS_TABLE_ENTRY ; - table->header.length =cpu_to_le16 (sizeof (*table) + size); -memcpy (table->data, header, size); - smbios_entries_len +=sizeof (*table) + size; - (*(uint16_t *)smbios_entries) = -cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); -/* end: add a copy of the newly loaded blob to legacy smbios_entries */ - +smbios_table_entry_add (data, size, false); +g_free (data);return ; }include/hw/i386/smbios.h +13
-0@@ -27,6 +27,19 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len);/* +* Add an external entry to the SMBIOS table. Can only be called +* from a registered device table handler. +*/ +int smbios_table_entry_add (void *data,int size,bool append_zeros); + +/* +* When constructing SMBIOS tables, call a function at the end of the +* add process to allow devices to add their own SMBIOS table entries. +*/ +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque); +/* * SMBIOS spec defined tables */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
In reply to Michael S. TsirkinQuoted 5 lines · Michael S. Tsirkin
Quoted 2 lines
Quoted 2 lines
So you are suggesting each device add it's own SSDT? I'm not sure how that helps debugging, it seems simpler to add it to a common one.
For example, it's easier to write a unit test: encode something specific in one of the IDs, then look it up.
Which is, btw, something that's missing in this patchset.
A unit test for what?
Paolo
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
Quoted 5 lines · Paolo Bonzini
Quoted 2 lines · Michael S. Tsirkin
Quoted 2 lines
Quoted 2 lines
So you are suggesting each device add it's own SSDT? I'm not sure how that helps debugging, it seems simpler to add it to a common one.
Quoted 7 lines
Quoted 3 lines
For example, it's easier to write a unit test: encode something specific in one of the IDs, then look it up.
Which is, btw, something that's missing in this patchset.A unit test for what?
Paolo
The ACPI code added. With an extra table it would be easy to test that it's there.
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
In reply to Corey MinyardQuoted 4 lines · Corey Minyard
Quoted 1 line
Hmm, I don't see patch 15/15 so I don't know how this is used.
Yeah, I resent and I don't know what's happened. All the others were sent exactly the same way. Something doesn't like that patch.
Can you send that privately? Or put it somewhere on the web.
Paolo
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
In reply to Michael S. TsirkinQuoted 11 lines · Michael S. Tsirkin
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
So you are suggesting each device add it's own SSDT? I'm not sure how that helps debugging, it seems simpler to add it to a common one.
For example, it's easier to write a unit test: encode something specific in one of the IDs, then look it up.
Which is, btw, something that's missing in this patchset.A unit test for what?
The ACPI code added. With an extra table it would be easy to test that it's there.
Ah, I agree that patch 15 should add something like commit 3a9c86df/71096d6c, but that doesn't need a separate table.
Paolo
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
In reply to Paolo BonziniQuoted 6 lines · Paolo Bonzini
Quoted 3 lines · Corey Minyard
Quoted 1 line
Hmm, I don't see patch 15/15 so I don't know how this is used.
Yeah, I resent and I don't know what's happened. All the others were sent exactly the same way. Something doesn't like that patch.
Can you send that privately? Or put it somewhere on the web.
Ok, attaching it. Hopefully it goes through this way.
-corey
Quoted 1 line
From
f2d3d72d517596385381ad565405cbaddee1d787Mon Sep 17 00:00:00 2001
From: Corey Minyard <[email protected]>
Date: Thu, 23 May 2013 16:58:30 -0500
Subject: [PATCH 15/22] ipmi: Add ACPI table entries for BMCs
Use the new ACPI table construction tools to create an ACPI entry for IPMI.
--- hw/ipmi/isa_ipmi.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
hw/ipmi/isa_ipmi.c +59 -0
@@ -23,6 +23,9 @@*/ #include "hw/hw.h" #include "hw/isa/isa.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-hooks.h" #include "hw/i386/pc.h" #include "qemu/timer.h" #include "sysemu/char.h"
@@ -39,6 +42,8 @@ typedef struct ISAIPMIDevice {char *interface;int intftype;uint32_t iobase; +uint32_t iolength; +uint8_t regspacing;int32 isairq;uint8_t slave_addr;uint8_t version;
@@ -83,6 +88,55 @@ static void ipmi_encode_smbios(void *opaque) }#endif +#ifdef CONFIG_ACPI +static Aml *aml_ipmi_crs (ISAIPMIDevice *info) +{ +Aml *crs =aml_resource_template (); +uint8_t regspacing = info->regspacing; + +if (regspacing ==1 ) { + regspacing =0 ; + } + +aml_append (crs,aml_io (aml_decode16, info->iobase, + info->iobase + info->iolength -1 , + regspacing, info->iolength)); +if (info->isairq) { +aml_append (crs,aml_irq_no_flags (info->isairq)); + } + +return crs; +} + +static void +ipmi_encode_acpi (Aml *ssdt,void *opaque) +{ +ISAIPMIDevice *info = opaque; +char *name; +Aml *scope =aml_scope ("\\_SB.PCI0.ISA" ); +Aml *dev =aml_device ("MI0" ); +Aml *method; +int version = ((info->version &0xf0 ) <<4 ) | (info->version &0x0f ); + + name =g_strdup_printf ("ipmi_%s" , info->interface); + +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("IPI0001" ))); +aml_append (dev,aml_name_decl ("_STR" ,aml_string ("%s" , name))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("_CRS" ,aml_ipmi_crs (info))); + method =aml_method ("_IFT" ,0 ); +aml_append (method,aml_return (aml_int (info->intftype))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method); + +aml_append (scope, dev); + +aml_append (ssdt, scope); +} +#endif +static void ipmi_isa_realizefn (DeviceState *dev,Error **errp) {ISADevice *isadev =ISA_DEVICE (dev);
@@ -112,6 +166,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) intfk =IPMI_INTERFACE_GET_CLASS (intf); bmc->intf = intf; intf->bmc = bmc; + ipmi->regspacing =1 ; intf->io_base = ipmi->iobase; intf->slave_addr = ipmi->slave_addr; ipmi->intftype = intfk->smbios_type;
@@ -120,6 +175,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)if (*errp) {return ; } + ipmi->iolength = intf->io_length;ipmi_bmc_init (bmc, errp);if (*errp) {return ;
@@ -150,6 +206,9 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)#ifdef TARGET_I386 smbios_register_device_table_handler (ipmi_encode_smbios, ipmi);#endif +#ifdef CONFIG_ACPI +add_device_ssdt_encoder (ipmi_encode_acpi, ipmi); +#endif }static void ipmi_isa_reset (DeviceState *qdev)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
In reply to Michael S. TsirkinQuoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Corey Minyard
Quoted 15 lines · Michael S. Tsirkin
Quoted 8 lines · On Tue, Apr 07, 2015 at 02:51:39PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Signed-off-by Corey Minyard <[email protected]>Do we have to use a callback for this?
It seems that if
smbios_table_entry_addjust added the table itself to some array or a linked list, then devices could just callsmbios_table_entry_addinstead of registering a handler.
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
And
smbios_get_tableswould scan that and get the tables.Well, there are many ways you could handle this, and it doesn't seem much different in the end to me. You either have a list of items to add to the table or a list of callbacks to fill in the data.
I made this the same as the ACPI code, which you have to have as a callback if you are adding it to a common SSDT.
Not really I think.
The AML functions require that you have a tree to attach what you are adding. If you did your own SSDT, you wouldn't need a callback. You could add a binary blob that gets put into the SSDT, but I think that would require adding some AML functions.
Quoted 4 lines
Quoted 3 lines
Plus it reduced the
amount of dynamic allocation required.Not sure why this matters though.
I'm a kernel guy and we are insane about this kind of stuff :).
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
On systems without smbios, this function could be a nop stub.
One nice things about the callbacks is you can eliminate any stubs. I find stubs kind of ugly, personally.
-corey
You still need a stub for the register function, don't you?
It depends on how you design it. I had already redesigned it based on Paulo's comments to add the firmware to a holding list in the base IPMI code, then when the callbacks came from SMBIOS and ACPI the code would iterate that list and add the table entries. No stubs required. Creating a separate SSDT and adding the list to ACPI/SMBIOS code is not an issue, either, and stubs aren't a big deal.
Thanks,
-corey
Quoted 227 lines
Quoted 227 lines
Quoted 227 lines
Did I miss something?
Quoted 225 lines
--- hw/i386/smbios.c | 149 ++++++++++++++++++++++++++++++----------------- include/hw/i386/smbios.h | 13 +++++ 2 files changed, 110 insertions(+), 52 deletions(-)hw/i386/smbios.c +97
-52@@ -831,6 +831,25 @@ static void smbios_entry_point_setup(void) ep.structure_table_address =cpu_to_le32 (0 ); } +struct smbios_device_handler { +void (*handle_device_table)(void *opaque); +void *opaque; +struct smbios_device_handler *prev; +}; +static struct smbios_device_handler *device_handlers; + +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque) +{ +struct smbios_device_handler *handler =g_malloc (sizeof (*handler)); + + handler->handle_device_table = handle_device_table; + handler->opaque = opaque; + handler->prev = device_handlers; + device_handlers = handler; +} +void smbios_get_tables (uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len) {@@ -875,6 +894,14 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, }smbios_build_type_32_table (); + +while (device_handlers) { +struct smbios_device_handler *handler = device_handlers; + device_handlers = handler->prev; + handler->handle_device_table (handler->opaque); +g_free (handler); + } +smbios_build_type_127_table ();smbios_validate_table ();@@ -898,6 +925,71 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) } } +int smbios_table_entry_add (void *data,int size,bool append_zeros) +{ +struct smbios_structure_header *header; +struct smbios_table *table;/* legacy mode only */ + +/* +* NOTE: standard double '\0' terminator expected, per smbios spec. +* (except in legacy mode, where the second '\0' is implicit and +* will be inserted by the BIOS). +*/ +if (append_zeros) { + size +=2 ; + } + smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); + header = (struct smbios_structure_header *)(smbios_tables + + smbios_tables_len); + +memcpy (header, data, size); + +if (test_bit (header->type, have_fields_bitmap)) { +error_report ("can't load type %d struct, fields already specified!" , + header->type); +exit (1 ); + } +set_bit (header->type, have_binfile_bitmap); + +if (header->type ==4 ) { + smbios_type4_count++; + } + + smbios_tables_len += size; +if (size > smbios_table_max) { + smbios_table_max = size; + } + smbios_table_cnt++; + +/* add a copy of the newly loaded blob to legacy smbios_entries */ +/* NOTE: This code runs before smbios_set_defaults(), so we don't +* yet know which mode (legacy vs. aggregate-table) will be +* required. We therefore add the binary blob to both legacy +* (smbios_entries) and aggregate (smbios_tables) tables, and +* delete the one we don't need from smbios_set_defaults(), +* once we know which machine version has been requested. +*/ +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } +if (append_zeros) { + size -=1 ;/* The BIOS adds the second zero in legacy mode. */ + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + + size +sizeof (*table)); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); +memcpy (table->data, header, size); + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +/* end: add a copy of the newly loaded blob to legacy smbios_entries */ + +return 0 ; +} +void smbios_entry_add (QemuOpts *opts) {Error *local_err =NULL ;@@ -907,9 +999,8 @@ void smbios_entry_add(QemuOpts *opts) val =qemu_opt_get (opts,"file" );if (val) { -struct smbios_structure_header *header;int size; -struct smbios_table *table;/* legacy mode only */ +uint8_t *data;qemu_opts_validate (opts, qemu_smbios_file_opts, &local_err);if (local_err) {@@ -923,60 +1014,14 @@ void smbios_entry_add(QemuOpts *opts)exit (1 ); } -/* -* NOTE: standard double '\0' terminator expected, per smbios spec. -* (except in legacy mode, where the second '\0' is implicit and -* will be inserted by the BIOS). -*/ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); - header = (struct smbios_structure_header *)(smbios_tables + - smbios_tables_len); - -if (load_image (val, (uint8_t *)header) != size) { + data =g_malloc (size); +if (load_image (val, data) != size) {error_report ("Failed to load SMBIOS file %s" , val);exit (1 ); } -if (test_bit (header->type, have_fields_bitmap)) { -error_report ("can't load type %d struct, fields already specified!" , - header->type); -exit (1 ); - } -set_bit (header->type, have_binfile_bitmap); - -if (header->type ==4 ) { - smbios_type4_count++; - } - - smbios_tables_len += size; -if (size > smbios_table_max) { - smbios_table_max = size; - } - smbios_table_cnt++; - -/* add a copy of the newly loaded blob to legacy smbios_entries */ -/* NOTE: This code runs before smbios_set_defaults(), so we don't -* yet know which mode (legacy vs. aggregate-table) will be -* required. We therefore add the binary blob to both legacy -* (smbios_entries) and aggregate (smbios_tables) tables, and -* delete the one we don't need from smbios_set_defaults(), -* once we know which machine version has been requested. -*/ -if (!smbios_entries) { - smbios_entries_len =sizeof (uint16_t ); - smbios_entries =g_malloc0 (smbios_entries_len); - } - smbios_entries =g_realloc (smbios_entries, smbios_entries_len + - size +sizeof (*table)); - table = (struct smbios_table *)(smbios_entries + smbios_entries_len); - table->header.type =SMBIOS_TABLE_ENTRY ; - table->header.length =cpu_to_le16 (sizeof (*table) + size); -memcpy (table->data, header, size); - smbios_entries_len +=sizeof (*table) + size; - (*(uint16_t *)smbios_entries) = -cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); -/* end: add a copy of the newly loaded blob to legacy smbios_entries */ - +smbios_table_entry_add (data, size, false); +g_free (data);return ; }include/hw/i386/smbios.h +13
-0@@ -27,6 +27,19 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len);/* +* Add an external entry to the SMBIOS table. Can only be called +* from a registered device table handler. +*/ +int smbios_table_entry_add (void *data,int size,bool append_zeros); + +/* +* When constructing SMBIOS tables, call a function at the end of the +* add process to allow devices to add their own SMBIOS table entries. +*/ +void smbios_register_device_table_handler (void (*handle_device_table) + (void *opaque), +void *opaque); +/* * SMBIOS spec defined tables */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
Quoted 9 lines · Corey Minyard
Quoted 4 lines
Quoted 2 lines
I made this the same as the ACPI code, which you have to have as a callback if you are adding it to a common SSDT.
Not really I think.
The AML functions require that you have a tree to attach what you are adding. If you did your own SSDT, you wouldn't need a callback. You could add a binary blob that gets put into the SSDT, but I think that would require adding some AML functions.
I very much prefer the callback idea. Long term it could be used by more devices and possibly it could be turned into an AMLProvider QOM interface. Then the ACPI builder could iterate on all QOM devices and just ask which of them can provide some AML.
Also, tables are rebuilt when the firmware loads them, and handing in a blob makes it harder to achieve this on-the-fly modification, compared to callbacks.
Paolo
Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
In reply to Corey MinyardQuoted 9 lines · Corey Minyard
Quoted 6 lines · Paolo Bonzini
Quoted 3 lines · Corey Minyard
Quoted 1 line
Hmm, I don't see patch 15/15 so I don't know how this is used.
Yeah, I resent and I don't know what's happened. All the others were sent exactly the same way. Something doesn't like that patch.
Can you send that privately? Or put it somewhere on the web.
Ok, attaching it. Hopefully it goes through this way.
Ok, looks good apart that I'd prefer IPMI-specific stubs to SMBIOS/ACPI stubs or ifdef-fery. Also it would be nice to have a unit test like we have for PCI bridges.
Paolo
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
In reply to Paolo BonziniQuoted 13 lines · Paolo Bonzini
Quoted 9 lines · Corey Minyard
Quoted 4 lines
Quoted 2 lines
I made this the same as the ACPI code, which you have to have as a callback if you are adding it to a common SSDT.
Not really I think.
The AML functions require that you have a tree to attach what you are adding. If you did your own SSDT, you wouldn't need a callback. You could add a binary blob that gets put into the SSDT, but I think that would require adding some AML functions.
Quoted 4 lines
I very much prefer the callback idea. Long term it could be used by more devices and possibly it could be turned into an AMLProvider QOM interface. Then the ACPI builder could iterate on all QOM devices and just ask which of them can provide some AML.
Yes, that would make sense. Devices which have a static AML could provide a static AML property, with very little code, those that have dynamic AML - dynamic AML property with more code.
But I don't see callbacks as a step in that direction - more like code that will have to be ripped out later.
I was looking for ways to remove dependencies for this patchset, not add them.
Quoted 5 lines
Also, tables are rebuilt when the firmware loads them, and handing in a blob makes it harder to achieve this on-the-fly modification, compared to callbacks.
Paolo
Well that's not true for smbios, is it?
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
In reply to Corey MinyardQuoted 23 lines · Corey Minyard
Quoted 22 lines · Michael S. Tsirkin
Quoted 21 lines · Corey Minyard
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · On Tue, Apr 07, 2015 at 02:51:39PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Quoted 8 lines
Quoted 1 line
Signed-off-by Corey Minyard <[email protected]>Do we have to use a callback for this?
It seems that if
smbios_table_entry_addjust added the table itself to some array or a linked list, then devices could just callsmbios_table_entry_addinstead of registering a handler.And
smbios_get_tableswould scan that and get the tables.Well, there are many ways you could handle this, and it doesn't seem much different in the end to me. You either have a list of items to add to the table or a list of callbacks to fill in the data.
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
I made this the same as the ACPI code, which you have to have as a callback if you are adding it to a common SSDT.
Not really I think.
The AML functions require that you have a tree to attach what you are adding. If you did your own SSDT, you wouldn't need a callback. You could add a binary blob that gets put into the SSDT, but I think that would require adding some AML functions.
Oh, you are using functions from aml-build.c. I forgot that they can only be used within ssdt ATM.
Maybe that's worth fixing. I need to ponder this a bit.
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
In reply to Michael S. TsirkinQuoted 18 lines · Michael S. Tsirkin
Quoted 5 lines · Paolo Bonzini
Quoted 3 lines · Corey Minyard
Quoted 3 lines
Quoted 2 lines
I made this the same as the ACPI code, which you have to have as a callback if you are adding it to a common SSDT.
Not really I think.
Quoted 8 lines
Quoted 4 lines
The AML functions require that you have a tree to attach what you are adding. If you did your own SSDT, you wouldn't need a callback. You could add a binary blob that gets put into the SSDT, but I think that would require adding some AML functions.
I very much prefer the callback idea. Long term it could be used by more devices and possibly it could be turned into an AMLProvider QOM interface. Then the ACPI builder could iterate on all QOM devices and just ask which of them can provide some AML.
Yes, that would make sense. Devices which have a static AML could provide a static AML property, with very little code, those that have dynamic AML - dynamic AML property with more code.
Quoted 5 lines
But I don't see callbacks as a step in that direction - more like code that will have to be ripped out later.
I was looking for ways to remove dependencies for this patchset, not add them.
I don't see a dependency difference between the two. Either way we are adding something to the ACPI code to store these things, and adding something to i386 (and arm64, when that happens) to get these entries from ACPI and add them to the firmware.
Quoted 6 lines
Quoted 5 lines
Also, tables are rebuilt when the firmware loads them, and handing in a blob makes it harder to achieve this on-the-fly modification, compared to callbacks.
Paolo
Well that's not true for smbios, is it?
Both tables are dynamically built at runtime. The SMBIOS table is fixed size, but the contents will vary depending on what the user specifies about IPMI.
-corey
Re: [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry
In reply to Michael S. TsirkinQuoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Paolo Bonzini
Quoted 9 lines · Corey Minyard
Quoted 4 lines
Quoted 2 lines
I made this the same as the ACPI code, which you have to have as a callback if you are adding it to a common SSDT.
Not really I think.
The AML functions require that you have a tree to attach what you are adding. If you did your own SSDT, you wouldn't need a callback. You could add a binary blob that gets put into the SSDT, but I think that would require adding some AML functions.
Quoted 8 lines
Quoted 4 lines
I very much prefer the callback idea. Long term it could be used by more devices and possibly it could be turned into an AMLProvider QOM interface. Then the ACPI builder could iterate on all QOM devices and just ask which of them can provide some AML.
Yes, that would make sense. Devices which have a static AML could provide a static AML property, with very little code, those that have dynamic AML - dynamic AML property with more code.
Why complicate the ACPI hooks unnecessarily? The generic code is written to support dynamic AML, why should devices support both? This seems like premature optimization.
Quoted 2 lines
I was looking for ways to remove dependencies for this patchset, not add them.
I'm not sure which dependencies these are.
Quoted 5 lines
Quoted 3 lines
Also, tables are rebuilt when the firmware loads them, and handing in a blob makes it harder to achieve this on-the-fly modification, compared to callbacks.
Well that's not true for smbios, is it?
No, it's not. For smbios, I agree that passing a static table to the API (i.e. having smbios_register_device_table instead of smbios_register_device_table_handler, and calling smbios_table_entry_add directly from smbios_get_tables) is also a valid choice.
Paolo