2 * Utilities for working with ACPI tables
4 * Copyright (c) 2013 Red Hat Inc.
7 * Michael S. Tsirkin <mst@redhat.com>,
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef TEST_ACPI_UTILS_H
14 #define TEST_ACPI_UTILS_H
16 #include "hw/acpi/acpi-defs.h"
19 /* DSDT and SSDTs format */
21 AcpiTableHeader header
;
22 gchar
*aml
; /* aml bytecode from guest */
25 gchar
*asl
; /* asl code generated from aml */
28 bool tmp_files_retain
; /* do not delete the temp asl/aml */
31 #define ACPI_READ_FIELD(qts, field, addr) \
33 qtest_memread(qts, addr, &field, sizeof(field)); \
34 addr += sizeof(field); \
37 #define ACPI_READ_ARRAY_PTR(qts, arr, length, addr) \
40 for (idx = 0; idx < length; ++idx) { \
41 ACPI_READ_FIELD(qts, arr[idx], addr); \
45 #define ACPI_READ_ARRAY(qts, arr, addr) \
46 ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr)
48 #define ACPI_READ_TABLE_HEADER(qts, table, addr) \
50 ACPI_READ_FIELD(qts, (table)->signature, addr); \
51 ACPI_READ_FIELD(qts, (table)->length, addr); \
52 ACPI_READ_FIELD(qts, (table)->revision, addr); \
53 ACPI_READ_FIELD(qts, (table)->checksum, addr); \
54 ACPI_READ_ARRAY(qts, (table)->oem_id, addr); \
55 ACPI_READ_ARRAY(qts, (table)->oem_table_id, addr); \
56 ACPI_READ_FIELD(qts, (table)->oem_revision, addr); \
57 ACPI_READ_ARRAY(qts, (table)->asl_compiler_id, addr); \
58 ACPI_READ_FIELD(qts, (table)->asl_compiler_revision, addr); \
61 #define ACPI_ASSERT_CMP(actual, expected) do { \
62 char ACPI_ASSERT_CMP_str[5] = {}; \
63 memcpy(ACPI_ASSERT_CMP_str, &actual, 4); \
64 g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
67 #define ACPI_ASSERT_CMP64(actual, expected) do { \
68 char ACPI_ASSERT_CMP_str[9] = {}; \
69 memcpy(ACPI_ASSERT_CMP_str, &actual, 8); \
70 g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
75 uint8_t acpi_calc_checksum(const uint8_t *data
, int len
);
76 uint32_t acpi_find_rsdp_address(QTestState
*qts
);
77 uint32_t acpi_get_rsdt_address(uint8_t *rsdp_table
);
78 uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table
);
79 void acpi_parse_rsdp_table(QTestState
*qts
, uint32_t addr
, uint8_t *rsdp_table
);
81 #endif /* TEST_ACPI_UTILS_H */