提交 cb88a4ea 编写于 作者: L Laszlo Ersek 提交者: Anthony Liguori

change element type from "char" to "unsigned char" in ACPI table data

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: NLaszlo Ersek <lersek@redhat.com>
Reviewed-by: NAnthony Liguori <aliguori@us.ibm.com>
Message-id: 1363821803-3380-3-git-send-email-lersek@redhat.com
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 4d8b3c63
...@@ -41,14 +41,14 @@ struct acpi_table_header { ...@@ -41,14 +41,14 @@ struct acpi_table_header {
#define ACPI_TABLE_HDR_SIZE sizeof(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 */ #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) */ "\0\0" /* fake _length (2) */
"QEMU\0\0\0\0\1\0" /* sig (4), len(4), revno (1), csum (1) */ "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) */ "QEMUQEQEMUQEMU\1\0\0\0" /* OEM id (6), table (8), revno (4) */
"QEMU\1\0\0\0" /* ASL compiler ID (4), version (4) */ "QEMU\1\0\0\0" /* ASL compiler ID (4), version (4) */
; ;
char *acpi_tables; char unsigned *acpi_tables;
size_t acpi_tables_len; size_t acpi_tables_len;
static int acpi_checksum(const uint8_t *data, int len) static int acpi_checksum(const uint8_t *data, int len)
...@@ -71,6 +71,7 @@ int acpi_table_add(const char *t) ...@@ -71,6 +71,7 @@ int acpi_table_add(const char *t)
int changed; int changed;
int r; int r;
struct acpi_table_header hdr; struct acpi_table_header hdr;
char unsigned *table_start;
r = 0; r = 0;
r |= get_param_value(buf, sizeof(buf), "data", t) ? 1 : 0; r |= get_param_value(buf, sizeof(buf), "data", t) ? 1 : 0;
...@@ -112,7 +113,7 @@ int acpi_table_add(const char *t) ...@@ -112,7 +113,7 @@ int acpi_table_add(const char *t)
} }
for (;;) { for (;;) {
char data[8192]; char unsigned data[8192];
r = read(fd, data, sizeof(data)); r = read(fd, data, sizeof(data));
if (r == 0) { if (r == 0) {
break; break;
...@@ -133,11 +134,11 @@ int acpi_table_add(const char *t) ...@@ -133,11 +134,11 @@ int acpi_table_add(const char *t)
/* now fill in the header fields */ /* 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; changed = 0;
/* copy the header to temp place to align the fields */ /* 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 */ /* length of the table minus our prefix */
len = allen - start - ACPI_TABLE_PFX_SIZE; len = allen - start - ACPI_TABLE_PFX_SIZE;
...@@ -225,11 +226,11 @@ int acpi_table_add(const char *t) ...@@ -225,11 +226,11 @@ int acpi_table_add(const char *t)
hdr.checksum = 0; /* for checksum calculation */ hdr.checksum = 0; /* for checksum calculation */
/* put header back */ /* put header back */
memcpy(f, &hdr, sizeof(hdr)); memcpy(table_start, &hdr, sizeof(hdr));
if (changed || !has_header || 1) { if (changed || !has_header || 1) {
((struct acpi_table_header *)f)->checksum = ((struct acpi_table_header *)table_start)->checksum =
acpi_checksum((uint8_t *)f + ACPI_TABLE_PFX_SIZE, len); acpi_checksum((uint8_t *)table_start + ACPI_TABLE_PFX_SIZE, len);
} }
/* increase number of tables */ /* increase number of tables */
......
...@@ -109,7 +109,7 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name); ...@@ -109,7 +109,7 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
/* acpi.c */ /* acpi.c */
extern int acpi_enabled; extern int acpi_enabled;
extern char *acpi_tables; extern char unsigned *acpi_tables;
extern size_t acpi_tables_len; extern size_t acpi_tables_len;
void acpi_bios_init(void); void acpi_bios_init(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册