From: Laszlo Ersek <lersek@redhat.com>
To: qemu-devel@nongnu.org, mst@redhat.com, aliguori@us.ibm.com,
kraxel@redhat.com
Subject: [Qemu-devel] [PATCH 02/11] change element type from "char" to "unsigned char" in ACPI table data
Date: Thu, 21 Mar 2013 00:23:14 +0100 [thread overview]
Message-ID: <1363821803-3380-3-git-send-email-lersek@redhat.com> (raw)
In-Reply-To: <1363821803-3380-1-git-send-email-lersek@redhat.com>
The data is binary, not textual.
Also, acpi_table_add() abuses the "char *f" pointer -- which normally
points to file names to load -- to poke into the table. Introduce "char
unsigned *table_start" for that purpose.
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
hw/pc.h | 2 +-
hw/acpi.c | 17 +++++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/hw/pc.h b/hw/pc.h
index dbbd8cd..fe1768b 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -109,7 +109,7 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
/* acpi.c */
extern int acpi_enabled;
-extern char *acpi_tables;
+extern char unsigned *acpi_tables;
extern size_t acpi_tables_len;
void acpi_bios_init(void);
diff --git a/hw/acpi.c b/hw/acpi.c
index 53e47d5..c6320d5 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -41,14 +41,14 @@ struct acpi_table_header {
#define ACPI_TABLE_HDR_SIZE sizeof(struct acpi_table_header)
#define ACPI_TABLE_PFX_SIZE sizeof(uint16_t) /* size of the extra prefix */
-static const char dfl_hdr[ACPI_TABLE_HDR_SIZE] =
+static const char unsigned dfl_hdr[ACPI_TABLE_HDR_SIZE] =
"\0\0" /* fake _length (2) */
"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) */
;
-char *acpi_tables;
+char unsigned *acpi_tables;
size_t acpi_tables_len;
static int acpi_checksum(const uint8_t *data, int len)
@@ -71,6 +71,7 @@ int acpi_table_add(const char *t)
int changed;
int r;
struct acpi_table_header hdr;
+ char unsigned *table_start;
r = 0;
r |= get_param_value(buf, sizeof(buf), "data", t) ? 1 : 0;
@@ -112,7 +113,7 @@ int acpi_table_add(const char *t)
}
for (;;) {
- char data[8192];
+ char unsigned data[8192];
r = read(fd, data, sizeof(data));
if (r == 0) {
break;
@@ -133,11 +134,11 @@ int acpi_table_add(const char *t)
/* now fill in the header fields */
- f = acpi_tables + start; /* start of the table */
+ table_start = acpi_tables + start; /* start of the table */
changed = 0;
/* copy the header to temp place to align the fields */
- memcpy(&hdr, has_header ? f : dfl_hdr, ACPI_TABLE_HDR_SIZE);
+ memcpy(&hdr, has_header ? table_start : dfl_hdr, ACPI_TABLE_HDR_SIZE);
/* length of the table minus our prefix */
len = allen - start - ACPI_TABLE_PFX_SIZE;
@@ -225,11 +226,11 @@ int acpi_table_add(const char *t)
hdr.checksum = 0; /* for checksum calculation */
/* put header back */
- memcpy(f, &hdr, sizeof(hdr));
+ memcpy(table_start, &hdr, sizeof(hdr));
if (changed || !has_header || 1) {
- ((struct acpi_table_header *)f)->checksum =
- acpi_checksum((uint8_t *)f + ACPI_TABLE_PFX_SIZE, len);
+ ((struct acpi_table_header *)table_start)->checksum =
+ acpi_checksum((uint8_t *)table_start + ACPI_TABLE_PFX_SIZE, len);
}
/* increase number of tables */
--
1.7.1
next prev parent reply other threads:[~2013-03-20 23:21 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-20 23:23 [Qemu-devel] [PATCH 00/11] build ACPI MADT for fw_cfg clients Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 01/11] strip some whitespace Laszlo Ersek
2013-03-20 23:23 ` Laszlo Ersek [this message]
2013-03-20 23:40 ` [Qemu-devel] [PATCH 02/11] change element type from "char" to "unsigned char" in ACPI table data Eric Blake
2013-03-21 0:18 ` Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 03/11] acpi_table_add(): report fatal errors through an internal Error object Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 04/11] qapi schema: add AcpiTableOptions Laszlo Ersek
2013-03-20 23:45 ` Eric Blake
2013-03-21 0:31 ` Laszlo Ersek
2013-03-21 10:41 ` Laszlo Ersek
2013-03-21 11:51 ` Paolo Bonzini
2013-03-21 12:36 ` Michael S. Tsirkin
2013-03-21 12:42 ` Laszlo Ersek
2013-03-21 12:44 ` Paolo Bonzini
2013-04-03 19:59 ` Anthony Liguori
2013-04-03 20:01 ` Anthony Liguori
2013-03-20 23:23 ` [Qemu-devel] [PATCH 05/11] acpi_table_add(): accept QemuOpts and parse it with OptsVisitor Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 06/11] acpi_table_add(): extract and reimplement internals Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 07/11] like acpi_table_install(), acpi_table_add() should propagate Errors Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 08/11] extract/unify the constant 0xfee00000 as APIC_DEFAULT_ADDRESS Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 09/11] Introduce IO_APIC_DEFAULT_ADDRESS for 0xfec00000 Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 10/11] pc_acpi_init(): don't bail as soon as failing to find default DSDT Laszlo Ersek
2013-03-20 23:23 ` [Qemu-devel] [PATCH 11/11] i386/pc: build ACPI MADT for fw_cfg clients Laszlo Ersek
2013-04-03 16:44 ` [Qemu-devel] [PATCH 00/11] " Laszlo Ersek
2013-04-03 20:05 ` Anthony Liguori
2013-04-04 7:52 ` Laszlo Ersek
2013-04-04 23:22 ` Kevin O'Connor
2013-04-05 11:39 ` Laszlo Ersek
2013-04-05 12:51 ` 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=1363821803-3380-3-git-send-email-lersek@redhat.com \
--to=lersek@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=kraxel@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 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).