iotests: Replace assertEquals() with assertEqual()
[qemu/ar7.git] / tests / acpi-utils.h
blobac52abd0ddb107a50b85829f1dd9d7a54ab06612
1 /*
2 * Utilities for working with ACPI tables
4 * Copyright (c) 2013 Red Hat Inc.
6 * Authors:
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"
17 #include "libqtest.h"
19 /* DSDT and SSDTs format */
20 typedef struct {
21 AcpiTableHeader header;
22 gchar *aml; /* aml bytecode from guest */
23 gsize aml_len;
24 gchar *aml_file;
25 gchar *asl; /* asl code generated from aml */
26 gsize asl_len;
27 gchar *asl_file;
28 bool tmp_files_retain; /* do not delete the temp asl/aml */
29 } AcpiSdtTable;
31 #define ACPI_READ_FIELD(field, addr) \
32 do { \
33 memread(addr, &field, sizeof(field)); \
34 addr += sizeof(field); \
35 } while (0)
37 #define ACPI_READ_ARRAY_PTR(arr, length, addr) \
38 do { \
39 int idx; \
40 for (idx = 0; idx < length; ++idx) { \
41 ACPI_READ_FIELD(arr[idx], addr); \
42 } \
43 } while (0)
45 #define ACPI_READ_ARRAY(arr, addr) \
46 ACPI_READ_ARRAY_PTR(arr, sizeof(arr) / sizeof(arr[0]), addr)
48 #define ACPI_READ_TABLE_HEADER(table, addr) \
49 do { \
50 ACPI_READ_FIELD((table)->signature, addr); \
51 ACPI_READ_FIELD((table)->length, addr); \
52 ACPI_READ_FIELD((table)->revision, addr); \
53 ACPI_READ_FIELD((table)->checksum, addr); \
54 ACPI_READ_ARRAY((table)->oem_id, addr); \
55 ACPI_READ_ARRAY((table)->oem_table_id, addr); \
56 ACPI_READ_FIELD((table)->oem_revision, addr); \
57 ACPI_READ_ARRAY((table)->asl_compiler_id, addr); \
58 ACPI_READ_FIELD((table)->asl_compiler_revision, addr); \
59 } while (0)
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); \
65 } while (0)
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); \
71 } while (0)
73 #define ACPI_READ_GENERIC_ADDRESS(field, addr) \
74 do { \
75 ACPI_READ_FIELD((field).space_id, addr); \
76 ACPI_READ_FIELD((field).bit_width, addr); \
77 ACPI_READ_FIELD((field).bit_offset, addr); \
78 ACPI_READ_FIELD((field).access_width, addr); \
79 ACPI_READ_FIELD((field).address, addr); \
80 } while (0)
83 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
84 uint32_t acpi_find_rsdp_address(void);
85 void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table);
87 #endif /* TEST_ACPI_UTILS_H */