All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Laszlo Ersek <lersek@redhat.com>, mst@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 4/7] hw/acpi: export default ACPI headers using the type just introduced
Date: Thu, 25 Apr 2013 13:49:47 -0500	[thread overview]
Message-ID: <87wqrqjvhw.fsf@codemonkey.ws> (raw)
In-Reply-To: <1366316544-1428-5-git-send-email-lersek@redhat.com>

Laszlo Ersek <lersek@redhat.com> writes:

> This enables reuse when preparing per-table fw_cfg blobs later.
>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  include/hw/acpi/acpi.h |    2 ++
>  hw/acpi/core.c         |   39 ++++++++++++++++++++++++---------------
>  2 files changed, 26 insertions(+), 15 deletions(-)
>
> diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
> index 0e26f63..bc7e107 100644
> --- a/include/hw/acpi/acpi.h
> +++ b/include/hw/acpi/acpi.h
> @@ -178,4 +178,6 @@ typedef struct acpi_table_std_header {
>      char asl_compiler_id[4];  /* ASL compiler vendor ID */
>      uint32_t asl_compiler_revision; /* ASL compiler revision number */
>  } QEMU_PACKED AcpiTableStdHdr;
> +
> +extern const AcpiTableStdHdr acpi_dfl_hdr;

Can we do this without using a global variable?  I assume this gets
memcpy()'d or referenced as a pointer later on or something like that?
Can we make a function that does that?

Regards,

Anthony Liguori

>  #endif /* !QEMU_HW_ACPI_H */
> diff --git a/hw/acpi/core.c b/hw/acpi/core.c
> index d348f81..36a4d03 100644
> --- a/hw/acpi/core.c
> +++ b/hw/acpi/core.c
> @@ -37,11 +37,20 @@ struct acpi_table_header {
>  /* size of the extra prefix */
>  #define ACPI_TABLE_PFX_SIZE offsetof(struct acpi_table_header, std)
>  
> -static const char unsigned dfl_hdr[sizeof(AcpiTableStdHdr)] =
> -    "QEMU\0\0\0\0\1\0"       /* sig (4), len(4), revno (1), csum (1) */
> -    "QEMUQEQEMUQEMU\1\0\0\0" /* OEM id (6), table (8), revno (4) */
> -    "QEMU\1\0\0\0"           /* ASL compiler ID (4), version (4) */
> -    ;
> +const AcpiTableStdHdr acpi_dfl_hdr = {
> +    .sig = "QEMU",
> +    .revision = 1,
> +    .oem_id = "QEMUQE",
> +    .oem_table_id = "QEMUQEMU",
> +    .asl_compiler_id = "QEMU",
> +#ifdef HOST_WORDS_BIGENDIAN
> +    .oem_revision = 0x01000000,
> +    .asl_compiler_revision = 0x01000000
> +#else
> +    .oem_revision = 1,
> +    .asl_compiler_revision = 1
> +#endif
> +};
>  
>  char unsigned *acpi_tables;
>  size_t acpi_tables_len;
> @@ -74,8 +83,8 @@ static int acpi_checksum(const uint8_t *data, int len)
>  /* Install a copy of the ACPI table specified in @blob.
>   *
>   * If @has_header is set, @blob starts with the System Description Table Header
> - * structure. Otherwise, "dfl_hdr" is prepended. In any case, each header field
> - * is optionally overwritten from @hdrs.
> + * structure. Otherwise, "acpi_dfl_hdr" is prepended. In any case, each header
> + * field is optionally overwritten from @hdrs.
>   *
>   * It is valid to call this function with
>   * (@blob == NULL && @bloblen == 0 && !@has_header).
> @@ -105,13 +114,13 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,
>      if (has_header) {
>          /*   _length             | ACPI header in blob | blob body
>           *   ^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^
> -         *   ACPI_TABLE_PFX_SIZE     sizeof dfl_hdr      body_size
> +         *   ACPI_TABLE_PFX_SIZE   sizeof acpi_dfl_hdr   body_size
>           *                           == body_start
>           *
>           *                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>           *                           acpi_payload_size == bloblen
>           */
> -        body_start = sizeof dfl_hdr;
> +        body_start = sizeof acpi_dfl_hdr;
>  
>          if (bloblen < body_start) {
>              error_setg(errp, "ACPI table claiming to have header is too "
> @@ -123,17 +132,17 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,
>      } else {
>          /*   _length             | ACPI header in template | blob body
>           *   ^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^^
> -         *   ACPI_TABLE_PFX_SIZE       sizeof dfl_hdr        body_size
> +         *   ACPI_TABLE_PFX_SIZE     sizeof acpi_dfl_hdr     body_size
>           *                                                   == bloblen
>           *
>           *                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>           *                                  acpi_payload_size
>           */
>          body_start = 0;
> -        hdr_src = dfl_hdr;
> +        hdr_src = (const char unsigned *)&acpi_dfl_hdr;
>      }
>      body_size = bloblen - body_start;
> -    acpi_payload_size = sizeof dfl_hdr + body_size;
> +    acpi_payload_size = sizeof acpi_dfl_hdr + body_size;
>  
>      if (acpi_payload_size > UINT16_MAX) {
>          error_setg(errp, "ACPI table too big, requested: %zu, max: %u",
> @@ -149,13 +158,13 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,
>  
>      acpi_tables = g_realloc(acpi_tables, acpi_tables_len +
>                                           ACPI_TABLE_PFX_SIZE +
> -                                         sizeof dfl_hdr + body_size);
> +                                         sizeof acpi_dfl_hdr + body_size);
>  
>      ext_hdr = (struct acpi_table_header *)(acpi_tables + acpi_tables_len);
>      acpi_tables_len += ACPI_TABLE_PFX_SIZE;
>  
> -    memcpy(acpi_tables + acpi_tables_len, hdr_src, sizeof dfl_hdr);
> -    acpi_tables_len += sizeof dfl_hdr;
> +    memcpy(acpi_tables + acpi_tables_len, hdr_src, sizeof acpi_dfl_hdr);
> +    acpi_tables_len += sizeof acpi_dfl_hdr;
>  
>      if (blob != NULL) {
>          memcpy(acpi_tables + acpi_tables_len, blob + body_start, body_size);
> -- 
> 1.7.1

  reply	other threads:[~2013-04-25 18:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-18 20:22 [Qemu-devel] [PATCH v4 0/7] publish etc/acpi/APIC in fw_cfg Laszlo Ersek
2013-04-18 20:22 ` [Qemu-devel] [PATCH v4 1/7] refer to FWCfgState explicitly Laszlo Ersek
2013-04-25 18:44   ` Anthony Liguori
2013-04-25 21:04     ` Michael S. Tsirkin
2013-04-18 20:22 ` [Qemu-devel] [PATCH v4 2/7] acpi_table_install(): fix funcparam formatting in leading comment Laszlo Ersek
2013-04-25 18:44   ` Anthony Liguori
2013-04-18 20:22 ` [Qemu-devel] [PATCH v4 3/7] hw/acpi: extract standard table headers as a standalone structure Laszlo Ersek
2013-04-25 18:47   ` Anthony Liguori
2013-04-26  9:32     ` Laszlo Ersek
2013-04-18 20:22 ` [Qemu-devel] [PATCH v4 4/7] hw/acpi: export default ACPI headers using the type just introduced Laszlo Ersek
2013-04-25 18:49   ` Anthony Liguori [this message]
2013-04-26  9:53     ` Laszlo Ersek
2013-04-18 20:22 ` [Qemu-devel] [PATCH v4 5/7] hw/acpi: export acpi_checksum() Laszlo Ersek
2013-04-25 18:55   ` Anthony Liguori
2013-04-18 20:22 ` [Qemu-devel] [PATCH v4 6/7] hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h Laszlo Ersek
2013-04-25 18:55   ` Anthony Liguori
2013-04-18 20:22 ` [Qemu-devel] [PATCH v4 7/7] hw/i386: build ACPI MADT (APIC) for fw_cfg clients Laszlo Ersek
2013-04-18 20:30   ` Michael S. Tsirkin
2013-04-19 10:58     ` Laszlo Ersek
2013-04-24  9:42       ` Michael S. Tsirkin
2013-04-25 19:03   ` Anthony Liguori
2013-04-25 20:11     ` Eduardo Habkost
2013-04-25 20:45       ` Anthony Liguori
2013-04-25 20:57         ` [Qemu-devel] Purpose of qemu-common.h (was Re: [PATCH v4 7/7] hw/i386: build ACPI MADT (APIC) for fw_cfg clients) Eduardo Habkost
2013-04-25 21:33           ` Michael S. Tsirkin
2013-04-26 11:13     ` [Qemu-devel] [PATCH v4 7/7] hw/i386: build ACPI MADT (APIC) for fw_cfg clients Laszlo Ersek
2013-04-29  8:20       ` Michael S. Tsirkin
2013-04-29 12:39         ` Kevin O'Connor
2013-04-29 13:21           ` Michael S. Tsirkin
2013-04-29 13:21           ` Laszlo Ersek
2013-04-24  9:39 ` [Qemu-devel] [PATCH v4 0/7] publish etc/acpi/APIC in fw_cfg Laszlo Ersek
2013-04-25 16:45   ` Anthony Liguori

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=87wqrqjvhw.fsf@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --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.