From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgX7h-0005aI-4G for qemu-devel@nongnu.org; Fri, 10 Apr 2015 07:29:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YgX7e-0004nZ-Aq for qemu-devel@nongnu.org; Fri, 10 Apr 2015 07:29:21 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:33267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgX7d-0004nT-WD for qemu-devel@nongnu.org; Fri, 10 Apr 2015 07:29:18 -0400 Received: by wiax7 with SMTP id x7so14083037wia.0 for ; Fri, 10 Apr 2015 04:29:17 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5527B409.9070608@redhat.com> Date: Fri, 10 Apr 2015 13:29:13 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1428436304-24044-1-git-send-email-minyard@acm.org> <1428436304-24044-15-git-send-email-minyard@acm.org> In-Reply-To: <1428436304-24044-15-git-send-email-minyard@acm.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: minyard@acm.org, qemu-devel@nongnu.org Cc: Corey Minyard , "Michael S. Tsirkin" On 07/04/2015 21:51, minyard@acm.org wrote: > From: Corey Minyard > > 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 > --- > 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 > > diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs > index b9fefa7..f60b12a 100644 > --- a/hw/acpi/Makefile.objs > +++ b/hw/acpi/Makefile.objs > @@ -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 > diff --git a/hw/acpi/acpi-hooks.c b/hw/acpi/acpi-hooks.c > new file mode 100644 > index 0000000..c499208 > --- /dev/null > +++ b/hw/acpi/acpi-hooks.c > @@ -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 > +#include > + > +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); > + } > +} > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index e761005..3a4b1ce 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -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, > diff --git a/include/hw/acpi/acpi-hooks.h b/include/hw/acpi/acpi-hooks.h > new file mode 100644 > index 0000000..ae66925 > --- /dev/null > +++ b/include/hw/acpi/acpi-hooks.h > @@ -0,0 +1,31 @@ > +/* > + * Hooks for dynamically construct ACPI tables in devices > + * > + * Copyright (C) 2015 Corey Minyard > + * > + * 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 > + * > + * 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 > + > +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