pc: acpi-build: drop template patching and memory hotplug objects dynamically
in addition it saves us ~330LOC and makes it one binary blob less stored in QEMU source tree by removing need to keep and update hw/i386/ssdt-mem.hex.generated file there. 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:
parent
e2ea299b01
commit
8698c0c0ed
|
@ -11,7 +11,6 @@ hw/i386/acpi-build.o: hw/i386/acpi-build.c \
|
||||||
hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \
|
hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \
|
||||||
hw/i386/ssdt-pcihp.hex \
|
hw/i386/ssdt-pcihp.hex \
|
||||||
hw/i386/ssdt-misc.hex \
|
hw/i386/ssdt-misc.hex \
|
||||||
hw/i386/ssdt-mem.hex \
|
|
||||||
hw/i386/ssdt-tpm.hex
|
hw/i386/ssdt-tpm.hex
|
||||||
|
|
||||||
iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
|
iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
|
||||||
|
|
|
@ -307,28 +307,6 @@ static void build_append_and_cleanup_method(GArray *device, GArray *method)
|
||||||
build_free_array(method);
|
build_free_array(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build_append_notify_target_ifequal(GArray *method,
|
|
||||||
GArray *target_name,
|
|
||||||
uint32_t value)
|
|
||||||
{
|
|
||||||
GArray *notify = build_alloc_array();
|
|
||||||
uint8_t op = 0xA0; /* IfOp */
|
|
||||||
|
|
||||||
build_append_byte(notify, 0x93); /* LEqualOp */
|
|
||||||
build_append_byte(notify, 0x68); /* Arg0Op */
|
|
||||||
build_append_int(notify, value);
|
|
||||||
build_append_byte(notify, 0x86); /* NotifyOp */
|
|
||||||
build_append_array(notify, target_name);
|
|
||||||
build_append_byte(notify, 0x69); /* Arg1Op */
|
|
||||||
|
|
||||||
/* Pack it up */
|
|
||||||
build_package(notify, op);
|
|
||||||
|
|
||||||
build_append_array(method, notify);
|
|
||||||
|
|
||||||
build_free_array(notify);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End here */
|
/* End here */
|
||||||
#define ACPI_PORT_SMI_CMD 0x00b2 /* TODO: this is APM_CNT_IOPORT */
|
#define ACPI_PORT_SMI_CMD 0x00b2 /* TODO: this is APM_CNT_IOPORT */
|
||||||
|
|
||||||
|
@ -550,14 +528,6 @@ static inline char acpi_get_hex(uint32_t val)
|
||||||
#define ACPI_PCIQXL_SIZEOF (*ssdt_pciqxl_end - *ssdt_pciqxl_start)
|
#define ACPI_PCIQXL_SIZEOF (*ssdt_pciqxl_end - *ssdt_pciqxl_start)
|
||||||
#define ACPI_PCIQXL_AML (ssdp_pcihp_aml + *ssdt_pciqxl_start)
|
#define ACPI_PCIQXL_AML (ssdp_pcihp_aml + *ssdt_pciqxl_start)
|
||||||
|
|
||||||
#include "hw/i386/ssdt-mem.hex"
|
|
||||||
|
|
||||||
/* 0x5B 0x82 DeviceOp PkgLength NameString DimmID */
|
|
||||||
#define ACPI_MEM_OFFSET_HEX (*ssdt_mem_name - *ssdt_mem_start + 2)
|
|
||||||
#define ACPI_MEM_OFFSET_ID (*ssdt_mem_id - *ssdt_mem_start + 7)
|
|
||||||
#define ACPI_MEM_SIZEOF (*ssdt_mem_end - *ssdt_mem_start)
|
|
||||||
#define ACPI_MEM_AML (ssdm_mem_aml + *ssdt_mem_start)
|
|
||||||
|
|
||||||
#define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */
|
#define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */
|
||||||
#define ACPI_SSDT_HEADER_LENGTH 36
|
#define ACPI_SSDT_HEADER_LENGTH 36
|
||||||
|
|
||||||
|
@ -565,24 +535,6 @@ static inline char acpi_get_hex(uint32_t val)
|
||||||
#include "hw/i386/ssdt-pcihp.hex"
|
#include "hw/i386/ssdt-pcihp.hex"
|
||||||
#include "hw/i386/ssdt-tpm.hex"
|
#include "hw/i386/ssdt-tpm.hex"
|
||||||
|
|
||||||
static void
|
|
||||||
build_append_notify_method(GArray *device, const char *name,
|
|
||||||
const char *format, int count)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
GArray *method = build_alloc_method(name, 2);
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
|
||||||
GArray *target = build_alloc_array();
|
|
||||||
build_append_namestring(target, format, i);
|
|
||||||
assert(i < 256); /* Fits in 1 byte */
|
|
||||||
build_append_notify_target_ifequal(method, target, i);
|
|
||||||
build_free_array(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
build_append_and_cleanup_method(device, method);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void patch_pcihp(int slot, uint8_t *ssdt_ptr)
|
static void patch_pcihp(int slot, uint8_t *ssdt_ptr)
|
||||||
{
|
{
|
||||||
unsigned devfn = PCI_DEVFN(slot, 0);
|
unsigned devfn = PCI_DEVFN(slot, 0);
|
||||||
|
@ -1073,27 +1025,55 @@ build_ssdt(GArray *table_data, GArray *linker,
|
||||||
}
|
}
|
||||||
aml_append(sb_scope, aml_name_decl("CPON", pkg));
|
aml_append(sb_scope, aml_name_decl("CPON", pkg));
|
||||||
|
|
||||||
if (nr_mem) {
|
/* build memory devices */
|
||||||
assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
|
assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
|
||||||
/* build memory devices */
|
|
||||||
for (i = 0; i < nr_mem; i++) {
|
|
||||||
char id[3];
|
|
||||||
uint8_t *mem = acpi_data_push(sb_scope->buf, ACPI_MEM_SIZEOF);
|
|
||||||
|
|
||||||
snprintf(id, sizeof(id), "%02X", i);
|
for (i = 0; i < nr_mem; i++) {
|
||||||
memcpy(mem, ACPI_MEM_AML, ACPI_MEM_SIZEOF);
|
#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
|
||||||
memcpy(mem + ACPI_MEM_OFFSET_HEX, id, 2);
|
const char *s;
|
||||||
memcpy(mem + ACPI_MEM_OFFSET_ID, id, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
|
dev = aml_device("MP%02X", i);
|
||||||
* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ...
|
aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
|
||||||
*/
|
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
|
||||||
build_append_notify_method(sb_scope->buf,
|
|
||||||
stringify(MEMORY_SLOT_NOTIFY_METHOD),
|
method = aml_method("_CRS", 0);
|
||||||
"MP%0.02X", nr_mem);
|
s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
|
||||||
|
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
|
||||||
|
aml_append(dev, method);
|
||||||
|
|
||||||
|
method = aml_method("_STA", 0);
|
||||||
|
s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
|
||||||
|
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
|
||||||
|
aml_append(dev, method);
|
||||||
|
|
||||||
|
method = aml_method("_PXM", 0);
|
||||||
|
s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
|
||||||
|
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
|
||||||
|
aml_append(dev, method);
|
||||||
|
|
||||||
|
method = aml_method("_OST", 3);
|
||||||
|
s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
|
||||||
|
aml_append(method, aml_return(aml_call4(
|
||||||
|
s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
|
||||||
|
)));
|
||||||
|
aml_append(dev, method);
|
||||||
|
|
||||||
|
aml_append(sb_scope, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
|
||||||
|
* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ...
|
||||||
|
*/
|
||||||
|
method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
|
||||||
|
for (i = 0; i < nr_mem; i++) {
|
||||||
|
ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
|
||||||
|
aml_append(ifctx,
|
||||||
|
aml_notify(aml_name("MP%.02X", i), aml_arg(1))
|
||||||
|
);
|
||||||
|
aml_append(method, ifctx);
|
||||||
|
}
|
||||||
|
aml_append(sb_scope, method);
|
||||||
|
|
||||||
{
|
{
|
||||||
AcpiBuildPciBusHotplugState hotplug_state;
|
AcpiBuildPciBusHotplugState hotplug_state;
|
||||||
Object *pci_host;
|
Object *pci_host;
|
||||||
|
|
|
@ -1,77 +0,0 @@
|
||||||
/*
|
|
||||||
* Memory hotplug ACPI DSDT static objects definitions
|
|
||||||
*
|
|
||||||
* Copyright ProfitBricks GmbH 2012
|
|
||||||
* Copyright (C) 2013-2014 Red Hat Inc
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This file is the basis for the ssdt_mem[] variable in src/acpi.c.
|
|
||||||
* It defines the contents of the memory device object. At
|
|
||||||
* runtime, a dynamically generated SSDT will contain one copy of this
|
|
||||||
* AML snippet for every possible memory device in the system. The
|
|
||||||
* objects will be placed in the \_SB_ namespace.
|
|
||||||
*
|
|
||||||
* In addition to the aml code generated from this file, the
|
|
||||||
* src/acpi.c file creates a MTFY method with an entry for each memdevice:
|
|
||||||
* Method(MTFY, 2) {
|
|
||||||
* If (LEqual(Arg0, 0x00)) { Notify(MP00, Arg1) }
|
|
||||||
* If (LEqual(Arg0, 0x01)) { Notify(MP01, Arg1) }
|
|
||||||
* ...
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
#include "hw/acpi/pc-hotplug.h"
|
|
||||||
|
|
||||||
ACPI_EXTRACT_ALL_CODE ssdm_mem_aml
|
|
||||||
|
|
||||||
DefinitionBlock ("ssdt-mem.aml", "SSDT", 0x02, "BXPC", "CSSDT", 0x1)
|
|
||||||
{
|
|
||||||
|
|
||||||
External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_CRS_METHOD, MethodObj)
|
|
||||||
External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_STATUS_METHOD, MethodObj)
|
|
||||||
External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_OST_METHOD, MethodObj)
|
|
||||||
External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_PROXIMITY_METHOD, MethodObj)
|
|
||||||
|
|
||||||
Scope(\_SB) {
|
|
||||||
/* v------------------ DO NOT EDIT ------------------v */
|
|
||||||
ACPI_EXTRACT_DEVICE_START ssdt_mem_start
|
|
||||||
ACPI_EXTRACT_DEVICE_END ssdt_mem_end
|
|
||||||
ACPI_EXTRACT_DEVICE_STRING ssdt_mem_name
|
|
||||||
Device(MPAA) {
|
|
||||||
ACPI_EXTRACT_NAME_STRING ssdt_mem_id
|
|
||||||
Name(_UID, "0xAA")
|
|
||||||
/* ^------------------ DO NOT EDIT ------------------^
|
|
||||||
* Don't change the above without also updating the C code.
|
|
||||||
*/
|
|
||||||
Name(_HID, EISAID("PNP0C80"))
|
|
||||||
|
|
||||||
Method(_CRS, 0) {
|
|
||||||
Return(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_CRS_METHOD(_UID))
|
|
||||||
}
|
|
||||||
|
|
||||||
Method(_STA, 0) {
|
|
||||||
Return(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_STATUS_METHOD(_UID))
|
|
||||||
}
|
|
||||||
|
|
||||||
Method(_PXM, 0) {
|
|
||||||
Return(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_PROXIMITY_METHOD(_UID))
|
|
||||||
}
|
|
||||||
|
|
||||||
Method(_OST, 3) {
|
|
||||||
\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_OST_METHOD(_UID, Arg0, Arg1, Arg2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue