aboutsummaryrefslogtreecommitdiff
path: root/tests/acpi-utils.h
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2017-09-11 12:20:08 -0500
committerThomas Huth <thuth@redhat.com>2018-12-17 15:36:39 +0100
commit273e3d92cfa26ae07a72657b75b4b76105a0fbc4 (patch)
tree8d0c2fda69cbd7116c38d75ff337fefc70f63114 /tests/acpi-utils.h
parent24c01ffa9d356eed4530e31f7ef93844b6599502 (diff)
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>
Diffstat (limited to 'tests/acpi-utils.h')
-rw-r--r--tests/acpi-utils.h63
1 files changed, 32 insertions, 31 deletions
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index ac52abd0dd..a06a4ed964 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -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 */