mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
tests/acpi-utils: Drop dependence on global_qtest
As a general rule, we prefer avoiding implicit global state because it makes code harder to safely copy and paste without thinking about the global state. Adjust the helper code to use explicit state instead, and update all callers. bios-tables-test no longer depends on global_qtest, now that it passes explicit state through the testsuite data; an assert proves this fact (although we will get rid of it later, once global_qtest is gone). Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> [thuth: adapted patch to current master branch] Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
24c01ffa9d
commit
273e3d92cf
4 changed files with 96 additions and 92 deletions
|
@ -28,34 +28,34 @@ typedef struct {
|
|||
bool tmp_files_retain; /* do not delete the temp asl/aml */
|
||||
} AcpiSdtTable;
|
||||
|
||||
#define ACPI_READ_FIELD(field, addr) \
|
||||
do { \
|
||||
memread(addr, &field, sizeof(field)); \
|
||||
addr += sizeof(field); \
|
||||
#define ACPI_READ_FIELD(qts, field, addr) \
|
||||
do { \
|
||||
qtest_memread(qts, addr, &field, sizeof(field)); \
|
||||
addr += sizeof(field); \
|
||||
} while (0)
|
||||
|
||||
#define ACPI_READ_ARRAY_PTR(arr, length, addr) \
|
||||
do { \
|
||||
int idx; \
|
||||
for (idx = 0; idx < length; ++idx) { \
|
||||
ACPI_READ_FIELD(arr[idx], addr); \
|
||||
} \
|
||||
#define ACPI_READ_ARRAY_PTR(qts, arr, length, addr) \
|
||||
do { \
|
||||
int idx; \
|
||||
for (idx = 0; idx < length; ++idx) { \
|
||||
ACPI_READ_FIELD(qts, arr[idx], addr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ACPI_READ_ARRAY(arr, addr) \
|
||||
ACPI_READ_ARRAY_PTR(arr, sizeof(arr) / sizeof(arr[0]), addr)
|
||||
#define ACPI_READ_ARRAY(qts, arr, addr) \
|
||||
ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr)
|
||||
|
||||
#define ACPI_READ_TABLE_HEADER(table, addr) \
|
||||
#define ACPI_READ_TABLE_HEADER(qts, table, addr) \
|
||||
do { \
|
||||
ACPI_READ_FIELD((table)->signature, addr); \
|
||||
ACPI_READ_FIELD((table)->length, addr); \
|
||||
ACPI_READ_FIELD((table)->revision, addr); \
|
||||
ACPI_READ_FIELD((table)->checksum, addr); \
|
||||
ACPI_READ_ARRAY((table)->oem_id, addr); \
|
||||
ACPI_READ_ARRAY((table)->oem_table_id, addr); \
|
||||
ACPI_READ_FIELD((table)->oem_revision, addr); \
|
||||
ACPI_READ_ARRAY((table)->asl_compiler_id, addr); \
|
||||
ACPI_READ_FIELD((table)->asl_compiler_revision, addr); \
|
||||
ACPI_READ_FIELD(qts, (table)->signature, addr); \
|
||||
ACPI_READ_FIELD(qts, (table)->length, addr); \
|
||||
ACPI_READ_FIELD(qts, (table)->revision, addr); \
|
||||
ACPI_READ_FIELD(qts, (table)->checksum, addr); \
|
||||
ACPI_READ_ARRAY(qts, (table)->oem_id, addr); \
|
||||
ACPI_READ_ARRAY(qts, (table)->oem_table_id, addr); \
|
||||
ACPI_READ_FIELD(qts, (table)->oem_revision, addr); \
|
||||
ACPI_READ_ARRAY(qts, (table)->asl_compiler_id, addr); \
|
||||
ACPI_READ_FIELD(qts, (table)->asl_compiler_revision, addr); \
|
||||
} while (0)
|
||||
|
||||
#define ACPI_ASSERT_CMP(actual, expected) do { \
|
||||
|
@ -70,18 +70,19 @@ typedef struct {
|
|||
g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
|
||||
} while (0)
|
||||
|
||||
#define ACPI_READ_GENERIC_ADDRESS(field, addr) \
|
||||
do { \
|
||||
ACPI_READ_FIELD((field).space_id, addr); \
|
||||
ACPI_READ_FIELD((field).bit_width, addr); \
|
||||
ACPI_READ_FIELD((field).bit_offset, addr); \
|
||||
ACPI_READ_FIELD((field).access_width, addr); \
|
||||
ACPI_READ_FIELD((field).address, addr); \
|
||||
#define ACPI_READ_GENERIC_ADDRESS(qts, field, addr) \
|
||||
do { \
|
||||
ACPI_READ_FIELD(qts, (field).space_id, addr); \
|
||||
ACPI_READ_FIELD(qts, (field).bit_width, addr); \
|
||||
ACPI_READ_FIELD(qts, (field).bit_offset, addr); \
|
||||
ACPI_READ_FIELD(qts, (field).access_width, addr); \
|
||||
ACPI_READ_FIELD(qts, (field).address, addr); \
|
||||
} while (0)
|
||||
|
||||
|
||||
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
|
||||
uint32_t acpi_find_rsdp_address(void);
|
||||
void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table);
|
||||
uint32_t acpi_find_rsdp_address(QTestState *qts);
|
||||
void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr,
|
||||
AcpiRsdpDescriptor *rsdp_table);
|
||||
|
||||
#endif /* TEST_ACPI_UTILS_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue