@@ -6,3 +6,5 @@ obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
common-obj-$(CONFIG_ACPI) += acpi_interface.o
common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
common-obj-$(CONFIG_ACPI) += aml-build.o
+common-obj-$(call land,$(CONFIG_ACPI),$(CONFIG_IPMI)) += ipmi.o
+common-obj-$(call land,$(CONFIG_ACPI),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
new file mode 100644
@@ -0,0 +1,102 @@
+/*
+ * IPMI ACPI firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/ipmi/ipmi.h"
+#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi.h"
+#include "hw/acpi/ipmi.h"
+
+static Aml *aml_ipmi_crs(IPMIFwInfo *info, const char *scope)
+{
+ Aml *crs = aml_resource_template();
+ uint8_t regspacing = info->register_spacing;
+
+ /*
+ * The base address is fixed and cannot change. That may be different
+ * if someone does PCI, but we aren't there yet.
+ */
+ switch (info->memspace) {
+ case IPMI_MEMSPACE_IO:
+ aml_append(crs, aml_io(AML_DECODE16, info->base_address,
+ info->base_address + info->register_length - 1,
+ regspacing, info->register_length));
+ break;
+ case IPMI_MEMSPACE_MEM32:
+ aml_append(crs,
+ aml_dword_memory(AML_POS_DECODE,
+ AML_MIN_FIXED, AML_MAX_FIXED,
+ AML_NON_CACHEABLE, AML_READ_WRITE,
+ 0xffffffff,
+ info->base_address,
+ info->base_address + info->register_length - 1,
+ regspacing, info->register_length));
+ break;
+ case IPMI_MEMSPACE_MEM64:
+ aml_append(crs,
+ aml_qword_memory(AML_POS_DECODE,
+ AML_MIN_FIXED, AML_MAX_FIXED,
+ AML_NON_CACHEABLE, AML_READ_WRITE,
+ 0xffffffffffffffffULL,
+ info->base_address,
+ info->base_address + info->register_length - 1,
+ regspacing, info->register_length));
+ break;
+ case IPMI_MEMSPACE_SMBUS:
+ aml_append(crs, aml_return(aml_int(info->base_address)));
+ break;
+ default:
+ abort();
+ }
+
+ if (info->interrupt_number) {
+ aml_append(crs, aml_irq_no_flags(info->interrupt_number));
+ }
+
+ return crs;
+}
+
+static void ipmi_encode_one_acpi(Aml *table, IPMIFwInfo *info,
+ const char *resource)
+{
+ Aml *dev, *method;
+ uint16_t version = ((info->ipmi_spec_major_revision << 8)
+ | (info->ipmi_spec_minor_revision << 4));
+
+ dev = aml_device("MI0");
+ aml_append(dev, aml_name_decl("_HID", aml_eisaid("IPI0001")));
+ aml_append(dev, aml_name_decl("_STR", aml_string("ipmi_%s",
+ info->interface_name)));
+ aml_append(dev, aml_name_decl("_UID", aml_int(info->uuid)));
+ aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info, resource)));
+
+ /*
+ * The spec seems to require these to be methods. All the examples
+ * show them this way and it doesn't seem to work if they are not.
+ */
+ method = aml_method("_IFT", 0, AML_NOTSERIALIZED);
+ aml_append(method, aml_return(aml_int(info->interface_type)));
+ aml_append(dev, method);
+ method = aml_method("_SRV", 0, AML_NOTSERIALIZED);
+ aml_append(method, aml_return(aml_int(version)));
+ aml_append(dev, method);
+
+ aml_append(table, dev);
+}
+
+void acpi_add_ipmi(Aml *table, BusState *bus, const char *resource)
+{
+ IPMIFwInfo *info = ipmi_first_fwinfo();
+
+ while (info) {
+ if (qdev_get_parent_bus(info->dev) == bus)
+ ipmi_encode_one_acpi(table, info, resource);
+ info = ipmi_next_fwinfo(info);
+ }
+}
new file mode 100644
@@ -0,0 +1,14 @@
+/*
+ * IPMI ACPI firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/acpi/ipmi.h"
+
+void acpi_add_ipmi(Aml *table, BusState *bus, const char *resource)
+{
+}
@@ -59,6 +59,8 @@
#include "qapi/qmp/qint.h"
#include "qom/qom-qobject.h"
+#include "hw/acpi/ipmi.h"
+
/* These are used to size the ACPI tables for -M pc-i440fx-1.7 and
* -M pc-i440fx-2.0. Even if the actual amount of AML generated grows
* a little bit, there should be plenty of free space since the DSDT
@@ -1445,7 +1447,7 @@ static Aml *build_com_device_aml(uint8_t uid)
return dev;
}
-static void build_isa_devices_aml(Aml *table)
+static void build_isa_devices_aml(Aml *table, ISABus *isa_bus)
{
ISADevice *fdc = pc_find_fdc0();
@@ -1461,6 +1463,8 @@ static void build_isa_devices_aml(Aml *table)
aml_append(scope, build_com_device_aml(1));
aml_append(scope, build_com_device_aml(2));
+ acpi_add_ipmi(scope, BUS(isa_bus), "\\_SB.PCI0.ISA");
+
aml_append(table, scope);
}
@@ -2011,7 +2015,7 @@ build_dsdt(GArray *table_data, GArray *linker,
build_hpet_aml(dsdt);
build_piix4_pm(dsdt);
build_piix4_isa_bridge(dsdt);
- build_isa_devices_aml(dsdt);
+ build_isa_devices_aml(dsdt, pcms->isa_bus);
build_piix4_pci_hotplug(dsdt);
build_piix4_pci0_int(dsdt);
} else {
@@ -2039,7 +2043,7 @@ build_dsdt(GArray *table_data, GArray *linker,
build_hpet_aml(dsdt);
build_q35_isa_bridge(dsdt);
- build_isa_devices_aml(dsdt);
+ build_isa_devices_aml(dsdt, pcms->isa_bus);
build_q35_pci0_int(dsdt);
}
@@ -185,6 +185,7 @@ static void pc_init1(MachineState *machine,
&error_abort);
no_hpet = 1;
}
+ pcms->isa_bus = isa_bus;
isa_bus_irqs(isa_bus, gsi);
if (kvm_pic_in_kernel()) {
@@ -190,6 +190,7 @@ static void pc_q35_init(MachineState *machine)
ICH9_LPC_NB_PIRQS);
pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq);
isa_bus = ich9_lpc->isa_bus;
+ pcms->isa_bus = isa_bus;
/*end early*/
isa_bus_irqs(isa_bus, gsi);
new file mode 100644
@@ -0,0 +1,22 @@
+/*
+ * QEMU IPMI ACPI handling
+ *
+ * Copyright (c) 2015 Corey Minyard <cminyard@mvista.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef HW_ACPI_IPMI_H
+#define HW_ACPI_IPMI_H
+
+#include "qemu/osdep.h"
+#include "hw/acpi/aml-build.h"
+
+/*
+ * Add ACPI IPMI entries for all registered IPMI devices whose parent
+ * bus matches the given bus. The resource is the ACPI resource that
+ * contains the IPMI device, this is required for the I2C CRS.
+ */
+void acpi_add_ipmi(Aml *table, BusState *bus, const char *resource);
+
+#endif /* HW_ACPI_IPMI_H */
@@ -51,6 +51,7 @@ struct PCMachineState {
HotplugHandler *acpi_dev;
ISADevice *rtc;
PCIBus *bus;
+ ISABus *isa_bus;
FWCfgState *fw_cfg;
/* Configuration options: */