All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: minyard@acm.org
Cc: Corey Minyard <cminyard@mvista.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables
Date: Fri, 3 Jul 2015 10:21:37 +0200	[thread overview]
Message-ID: <20150703101831-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1433812331-18993-15-git-send-email-minyard@acm.org>

On Mon, Jun 08, 2015 at 08:12:09PM -0500, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> Some devices, like IPMI, need to add ACPI table entries to report
> their presence.  Add a method for adding these entries.
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> ---
>  hw/acpi/Makefile.objs             |  1 +
>  hw/acpi/acpi-dev-tables.c         | 80 +++++++++++++++++++++++++++++++++++++++
>  hw/i386/acpi-build.c              | 17 +++++++++
>  include/hw/acpi/acpi-dev-tables.h | 38 +++++++++++++++++++
>  4 files changed, 136 insertions(+)
>  create mode 100644 hw/acpi/acpi-dev-tables.c
>  create mode 100644 include/hw/acpi/acpi-dev-tables.h
> 
> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> index b9fefa7..2b84f08 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-dev-tables.o
> diff --git a/hw/acpi/acpi-dev-tables.c b/hw/acpi/acpi-dev-tables.c
> new file mode 100644
> index 0000000..7f07a3d
> --- /dev/null
> +++ b/hw/acpi/acpi-dev-tables.c
> @@ -0,0 +1,80 @@
> +/*
> + * Add and get ACPI tables registered by devices.
> + *
> + * 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 <string.h>
> +#include <hw/acpi/acpi-dev-tables.h>
> +#include <qemu/queue.h>
> +
> +struct acpi_dev_table {
> +    void *data;
> +    int size;
> +    const char *sig;
> +    uint8_t rev;
> +    QSLIST_ENTRY(acpi_dev_table) next;
> +};
> +
> +static QSLIST_HEAD(, acpi_dev_table) acpi_table_entries;
> +
> +void
> +add_acpi_dev_table(void *data, int size, const char *sig, uint8_t rev)
> +{
> +    struct acpi_dev_table *e = g_malloc(sizeof(*e));
> +
> +    e->data = g_malloc(size);
> +    memcpy(e->data, data, size);
> +    e->size = size;
> +    e->sig = sig;
> +    e->rev = rev;
> +    QSLIST_INSERT_HEAD(&acpi_table_entries, e, next);
> +}
> +
> +struct acpi_dev_table *acpi_dev_table_first(void)
> +{
> +    return QSLIST_FIRST(&acpi_table_entries);
> +}
> +
> +struct acpi_dev_table *acpi_dev_table_next(struct acpi_dev_table *current)
> +{
> +    return QSLIST_NEXT(current, next);
> +}
> +
> +uint8_t *acpi_dev_table_data(struct acpi_dev_table *e)
> +{
> +    return e->data;
> +}
> +
> +unsigned acpi_dev_table_len(struct acpi_dev_table *e)
> +{
> +    return e->size;
> +}
> +
> +const char *acpi_dev_table_sig(struct acpi_dev_table *e)
> +{
> +    return e->sig;
> +}
> +
> +uint8_t acpi_dev_table_rev(struct acpi_dev_table *e)
> +{
> +    return e->rev;
> +}
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index e761005..0b4d195 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-dev-tables.h"
>  #include "hw/nvram/fw_cfg.h"
>  #include "hw/acpi/bios-linker-loader.h"
>  #include "hw/loader.h"
> @@ -1377,6 +1378,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>      AcpiMcfgInfo mcfg;
>      PcPciInfo pci;
>      uint8_t *u;
> +    struct acpi_dev_table *dt;
>      size_t aml_len = 0;
>      GArray *tables_blob = tables->table_data;
>  
> @@ -1448,6 +1450,21 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>          build_dmar_q35(tables_blob, tables->linker);
>      }
>  
> +    /* Add tables from devices. */
> +    for (dt = acpi_dev_table_first(); dt; dt = acpi_dev_table_next(dt)) {
> +        unsigned len = acpi_dev_table_len(dt);
> +        void *data = acpi_dev_table_data(dt);
> +
> +        acpi_add_table(table_offsets, tables_blob);
> +        acpi_data_push(tables_blob, sizeof(AcpiTableHeader));
> +        g_array_append_vals(tables_blob, data, len);
> +        build_header(tables->linker, tables_blob,
> +            (void *)(tables_blob->data + tables_blob->len -
> +                     len - sizeof(AcpiTableHeader)),
> +            acpi_dev_table_sig(dt), len + sizeof(AcpiTableHeader),
> +            acpi_dev_table_rev(dt));
> +    }
> +
>      /* Add tables supplied by user (if any) */
>      for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
>          unsigned len = acpi_table_len(u);
> diff --git a/include/hw/acpi/acpi-dev-tables.h b/include/hw/acpi/acpi-dev-tables.h
> new file mode 100644
> index 0000000..6dd18a5
> --- /dev/null
> +++ b/include/hw/acpi/acpi-dev-tables.h
> @@ -0,0 +1,38 @@
> +/*
> + * Add and get ACPI tables registered by 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>

you don't seem to do anything with this header.
why include it?

> +
> +void add_acpi_dev_table(void *data, int size, const char *sig, uint8_t rev);
> +
> +struct acpi_dev_table;

Any particular reason to violate the coding style with
the name of this structure.

> +
> +struct acpi_dev_table *acpi_dev_table_first(void);
> +struct acpi_dev_table *acpi_dev_table_next(struct acpi_dev_table *current);
> +uint8_t *acpi_dev_table_data(struct acpi_dev_table *);
> +unsigned acpi_dev_table_len(struct acpi_dev_table *);
> +const char *acpi_dev_table_sig(struct acpi_dev_table *);
> +uint8_t acpi_dev_table_rev(struct acpi_dev_table *);


Pls add documentation for the APIs.

> +
> +#endif /* QEMU_HW_ACPI_HOOKS_H */
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2015-07-03  8:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09  1:11 [Qemu-devel] [PATCH v3 00/16] Add an IPMI device to QEMU minyard
2015-06-09  1:11 ` [Qemu-devel] [PATCH v3 01/16] Add a base IPMI interface minyard
2015-06-09  1:11 ` [Qemu-devel] [PATCH v3 02/16] ipmi: Add a local BMC simulation minyard
2015-06-09  1:11 ` [Qemu-devel] [PATCH v3 03/16] ipmi: Add an external connection simulation interface minyard
2015-06-09  1:11 ` [Qemu-devel] [PATCH v3 04/16] ipmi: Add an ISA KCS low-level interface minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 05/16] ipmi: Add a BT " minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 06/16] ipmi: Add tests minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 07/16] ipmi: Add documentation minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 08/16] ipmi: Add migration capability to the IPMI devices minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 09/16] ipmi: Add a firmware configuration repository minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 10/16] ipmi: Add firmware registration to the ISA interface minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 11/16] smbios: Add a function to directly add an entry minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 12/16] pc: Postpone SMBIOS table installation to post machine init minyard
2015-07-03  8:17   ` Michael S. Tsirkin
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 13/16] ipmi: Add SMBIOS table entry minyard
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 14/16] acpi: Add a way for devices to add ACPI tables minyard
2015-07-03  8:21   ` Michael S. Tsirkin [this message]
2015-07-03  8:27   ` Michael S. Tsirkin
2015-07-07  8:08   ` Igor Mammedov
2015-07-08 17:44     ` Paolo Bonzini
2015-07-08 19:26       ` Igor Mammedov
2015-07-08 20:39         ` Paolo Bonzini
2015-07-09  8:25           ` Igor Mammedov
2015-07-13 21:55             ` Corey Minyard
2015-07-14  7:36               ` Igor Mammedov
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 15/16] ipmi: Add ACPI table entries minyard
2015-07-07  9:47   ` Igor Mammedov
2015-06-09  1:12 ` [Qemu-devel] [PATCH v3 16/16] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard
2015-07-03  0:30 ` [Qemu-devel] [PATCH v3 00/16] Add an IPMI device to QEMU Benjamin Herrenschmidt
2015-07-03  6:50 ` Paolo Bonzini
2015-07-03  8:23 ` Michael S. Tsirkin

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=20150703101831-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.