From: "Michael S. Tsirkin" <mst@redhat.com>
To: Corey Minyard <minyard@acm.org>
Cc: Corey Minyard <cminyard@mvista.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table
Date: Mon, 13 Apr 2015 08:36:24 +0200 [thread overview]
Message-ID: <20150413082924-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <552B1C45.1080304@acm.org>
On Sun, Apr 12, 2015 at 08:30:45PM -0500, Corey Minyard wrote:
> On 04/12/2015 11:17 AM, Michael S. Tsirkin wrote:
> > On Tue, Apr 07, 2015 at 02:51:43PM -0500, minyard@acm.org wrote:
> >> From: Corey Minyard <cminyard@mvista.com>
> >>
> >> 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 <cminyard@mvista.com>
> > 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.
>
> >
> > 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.
> >
> > 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.
> But
> it's not a big deal either way.
>
> -corey
Yes, there isn't a lot of difference really. Seems slightly neater.
> >
> >
> >> ---
> >> 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 <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);
> >> + }
> >> +}
> >> 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 <cminyard@mvista.com>
> >> + *
> >> + * 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 */
> >> --
> >> 1.8.3.1
> >>
next prev parent reply other threads:[~2015-04-13 6:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 19:51 [Qemu-devel] [PATCH 00/15] IPMI device for qemu minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 01/15] Add a base IPMI interface minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 02/15] ipmi: Add a PC ISA type structure minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 03/15] ipmi: Add a KCS low-level interface minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 04/15] ipmi: Add a BT " minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 05/15] ipmi: Add a local BMC simulation minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 06/15] ipmi: Add an external connection simulation interface minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 07/15] ipmi: Add tests minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 08/15] ipmi: Add documentation minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 09/15] ipmi: Add migration capability to the IPMI device minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry minyard
2015-04-12 16:05 ` Michael S. Tsirkin
2015-04-13 1:26 ` Corey Minyard
2015-04-13 7:00 ` Michael S. Tsirkin
2015-04-13 16:34 ` Corey Minyard
2015-04-13 16:40 ` Paolo Bonzini
2015-04-14 6:31 ` Michael S. Tsirkin
2015-04-14 15:30 ` Corey Minyard
2015-04-14 16:31 ` Paolo Bonzini
2015-04-14 6:41 ` Michael S. Tsirkin
2015-04-07 19:51 ` [Qemu-devel] [PATCH 11/15] pc: Postpone SMBIOS table installation to post machine init minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 12/15] ipmi: Add SMBIOS table entry minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 13/15] configure: Copy some items from default configs to target configs minyard
2015-04-10 11:47 ` Paolo Bonzini
2015-04-07 19:51 ` [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table minyard
2015-04-10 11:29 ` Paolo Bonzini
2015-04-12 16:17 ` Michael S. Tsirkin
2015-04-13 1:30 ` Corey Minyard
2015-04-13 6:36 ` Michael S. Tsirkin [this message]
2015-04-13 8:39 ` Paolo Bonzini
2015-04-13 11:32 ` Michael S. Tsirkin
2015-04-13 13:47 ` Paolo Bonzini
2015-04-13 13:44 ` Paolo Bonzini
2015-04-13 16:00 ` Corey Minyard
2015-04-13 16:41 ` Paolo Bonzini
2015-04-10 11:48 ` [Qemu-devel] [PATCH 00/15] IPMI device for qemu Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150413082924-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=cminyard@mvista.com \
--cc=minyard@acm.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).