memhp: merge build_memory_devices() into build_memory_hotplug_aml()

It consolidates memory hotplug AML in one place within DSDT

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Igor Mammedov 2016-12-06 00:32:25 +01:00 committed by Michael S. Tsirkin
parent 8dfba500af
commit 8b35ab271c
3 changed files with 36 additions and 47 deletions

View File

@ -310,9 +310,11 @@ const VMStateDescription vmstate_memory_hotplug = {
void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
uint16_t io_base, uint16_t io_len) uint16_t io_base, uint16_t io_len)
{ {
int i;
Aml *ifctx; Aml *ifctx;
Aml *method; Aml *method;
Aml *pci_scope; Aml *pci_scope;
Aml *sb_scope;
Aml *mem_ctrl_dev; Aml *mem_ctrl_dev;
/* scope for memory hotplug controller device node */ /* scope for memory hotplug controller device node */
@ -610,19 +612,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
} }
aml_append(pci_scope, mem_ctrl_dev); aml_append(pci_scope, mem_ctrl_dev);
aml_append(table, pci_scope); aml_append(table, pci_scope);
}
void build_memory_devices(Aml *sb_scope, int nr_mem,
uint16_t io_base, uint16_t io_len)
{
int i;
Aml *dev;
Aml *method;
Aml *ifctx;
sb_scope = aml_scope("_SB");
/* build memory devices */ /* build memory devices */
for (i = 0; i < nr_mem; i++) { for (i = 0; i < nr_mem; i++) {
#define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "." #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
Aml *dev;
const char *s; const char *s;
dev = aml_device("MP%02X", i); dev = aml_device("MP%02X", i);
@ -673,4 +668,5 @@ void build_memory_devices(Aml *sb_scope, int nr_mem,
aml_append(method, ifctx); aml_append(method, ifctx);
} }
aml_append(sb_scope, method); aml_append(sb_scope, method);
aml_append(table, sb_scope);
} }

View File

@ -2197,45 +2197,40 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
sb_scope = aml_scope("\\_SB"); sb_scope = aml_scope("\\_SB");
{ {
build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base, Object *pci_host;
pm->mem_hp_io_len); PCIBus *bus = NULL;
{ pci_host = acpi_get_i386_pci_host();
Object *pci_host; if (pci_host) {
PCIBus *bus = NULL; bus = PCI_HOST_BRIDGE(pci_host)->bus;
}
pci_host = acpi_get_i386_pci_host();
if (pci_host) { if (bus) {
bus = PCI_HOST_BRIDGE(pci_host)->bus; Aml *scope = aml_scope("PCI0");
} /* Scan all PCI buses. Generate tables to support hotplug. */
build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
if (bus) {
Aml *scope = aml_scope("PCI0"); if (misc->tpm_version != TPM_VERSION_UNSPEC) {
/* Scan all PCI buses. Generate tables to support hotplug. */ dev = aml_device("ISA.TPM");
build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
if (misc->tpm_version != TPM_VERSION_UNSPEC) { crs = aml_resource_template();
dev = aml_device("ISA.TPM"); aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31"))); TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF))); /*
crs = aml_resource_template(); FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE, Rewrite to take IRQ from TPM device model and
TPM_TIS_ADDR_SIZE, AML_READ_WRITE)); fix default IRQ value there to use some unused IRQ
/* */
FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs, /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
Rewrite to take IRQ from TPM device model and aml_append(dev, aml_name_decl("_CRS", crs));
fix default IRQ value there to use some unused IRQ aml_append(scope, dev);
*/ }
/* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(sb_scope, scope);
aml_append(scope, dev);
}
aml_append(sb_scope, scope);
}
} }
aml_append(dsdt, sb_scope);
} }
aml_append(dsdt, sb_scope);
/* copy AML table into ACPI tables blob and patch header there */ /* copy AML table into ACPI tables blob and patch header there */
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);

View File

@ -54,6 +54,4 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
uint16_t io_base, uint16_t io_len); uint16_t io_base, uint16_t io_len);
void build_memory_devices(Aml *sb_scope, int nr_mem,
uint16_t io_base, uint16_t io_len);
#endif #endif