]> git.proxmox.com Git - mirror_qemu.git/blob - tests/acpi-utils.h
tests: smbios: fetch whole table in one step instead of reading it step by step
[mirror_qemu.git] / tests / acpi-utils.h
1 /*
2 * Utilities for working with ACPI tables
3 *
4 * Copyright (c) 2013 Red Hat Inc.
5 *
6 * Authors:
7 * Michael S. Tsirkin <mst@redhat.com>,
8 *
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.
11 */
12
13 #ifndef TEST_ACPI_UTILS_H
14 #define TEST_ACPI_UTILS_H
15
16 #include "hw/acpi/acpi-defs.h"
17 #include "libqtest.h"
18
19 /* DSDT and SSDTs format */
20 typedef struct {
21 union {
22 AcpiTableHeader *header;
23 uint8_t *aml; /* aml bytecode from guest */
24 };
25 uint32_t aml_len;
26 gchar *aml_file;
27 gchar *asl; /* asl code generated from aml */
28 gsize asl_len;
29 gchar *asl_file;
30 bool tmp_files_retain; /* do not delete the temp asl/aml */
31 } AcpiSdtTable;
32
33 #define ACPI_ASSERT_CMP(actual, expected) do { \
34 char ACPI_ASSERT_CMP_str[5] = {}; \
35 memcpy(ACPI_ASSERT_CMP_str, &actual, 4); \
36 g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
37 } while (0)
38
39 #define ACPI_ASSERT_CMP64(actual, expected) do { \
40 char ACPI_ASSERT_CMP_str[9] = {}; \
41 memcpy(ACPI_ASSERT_CMP_str, &actual, 8); \
42 g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
43 } while (0)
44
45
46 #define ACPI_FOREACH_RSDT_ENTRY(table, table_len, entry_ptr, entry_size) \
47 for (entry_ptr = table + 36 /* 1st Entry */; \
48 entry_ptr < table + table_len; \
49 entry_ptr += entry_size)
50
51 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
52 uint32_t acpi_find_rsdp_address(QTestState *qts);
53 uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
54 void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
55 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
56 const uint8_t *addr_ptr, const char *sig,
57 bool verify_checksum);
58
59 #endif /* TEST_ACPI_UTILS_H */