aboutsummaryrefslogtreecommitdiff
path: root/tests/acpi-utils.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2019-05-02 16:51:50 +0200
committerMichael S. Tsirkin <mst@redhat.com>2019-05-20 18:40:02 -0400
commit4b14d543f3338985fd9c74ae6f6a6d3861c841dd (patch)
tree646d60303735f369187ea216f159faede2b90f28 /tests/acpi-utils.c
parent38fb3d7100b871eef3237cba2e4e1fed56d2bd1f (diff)
tests: acpi: make acpi_fetch_table() take size of fetched table pointer
Currently acpi_fetch_table() assumes 32 bit size of table pointer in ACPI tables. However X_foo variants are 64 bit, prepare acpi_fetch_table() to handle both by adding an argument for addr_ptr pointed entry size. Follow up commits will use that to read XSDT and X_foo entries in ACPI tables. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <1556808723-226478-3-git-send-email-imammedo@redhat.com> Reviewed-by: Wei Yang <richardw.yang@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'tests/acpi-utils.c')
-rw-r--r--tests/acpi-utils.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 633d8f513d..644c87b5f9 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -91,13 +91,15 @@ void acpi_fetch_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
* actual one.
*/
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
- const uint8_t *addr_ptr, const char *sig,
+ const uint8_t *addr_ptr, int addr_size, const char *sig,
bool verify_checksum)
{
- uint32_t addr, len;
+ uint32_t len;
+ uint64_t addr = 0;
- memcpy(&addr, addr_ptr , sizeof(addr));
- addr = le32_to_cpu(addr);
+ g_assert(addr_size == 4 || addr_size == 8);
+ memcpy(&addr, addr_ptr , addr_size);
+ addr = le64_to_cpu(addr);
qtest_memread(qts, addr + 4, &len, 4); /* Length of ACPI table */
*aml_len = le32_to_cpu(len);
*aml = g_malloc0(*aml_len);