2017-02-17 00:15:38 +01:00
|
|
|
/*
|
|
|
|
* Utilities for working with ACPI tables
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Michael S. Tsirkin <mst@redhat.com>,
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TEST_ACPI_UTILS_H
|
|
|
|
#define TEST_ACPI_UTILS_H
|
|
|
|
|
|
|
|
#include "libqtest.h"
|
|
|
|
|
|
|
|
/* DSDT and SSDTs format */
|
|
|
|
typedef struct {
|
2018-12-27 15:13:34 +01:00
|
|
|
uint8_t *aml; /* aml bytecode from guest */
|
2018-12-27 15:13:31 +01:00
|
|
|
uint32_t aml_len;
|
2017-02-17 00:15:38 +01:00
|
|
|
gchar *aml_file;
|
|
|
|
gchar *asl; /* asl code generated from aml */
|
|
|
|
gsize asl_len;
|
|
|
|
gchar *asl_file;
|
|
|
|
bool tmp_files_retain; /* do not delete the temp asl/aml */
|
2017-03-30 17:30:59 +02:00
|
|
|
} AcpiSdtTable;
|
2017-02-17 00:15:38 +01:00
|
|
|
|
|
|
|
#define ACPI_ASSERT_CMP(actual, expected) do { \
|
|
|
|
char ACPI_ASSERT_CMP_str[5] = {}; \
|
2017-11-16 13:17:02 +01:00
|
|
|
memcpy(ACPI_ASSERT_CMP_str, &actual, 4); \
|
2017-02-17 00:15:38 +01:00
|
|
|
g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ACPI_ASSERT_CMP64(actual, expected) do { \
|
|
|
|
char ACPI_ASSERT_CMP_str[9] = {}; \
|
2017-11-16 13:17:02 +01:00
|
|
|
memcpy(ACPI_ASSERT_CMP_str, &actual, 8); \
|
2017-02-17 00:15:38 +01:00
|
|
|
g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
|
|
|
|
} while (0)
|
|
|
|
|
2017-03-15 07:20:26 +01:00
|
|
|
|
2018-12-27 15:13:31 +01:00
|
|
|
#define ACPI_FOREACH_RSDT_ENTRY(table, table_len, entry_ptr, entry_size) \
|
|
|
|
for (entry_ptr = table + 36 /* 1st Entry */; \
|
|
|
|
entry_ptr < table + table_len; \
|
|
|
|
entry_ptr += entry_size)
|
2017-03-15 07:20:26 +01:00
|
|
|
|
2017-02-17 00:15:38 +01:00
|
|
|
uint8_t acpi_calc_checksum(const uint8_t *data, int len);
|
2017-09-11 19:20:08 +02:00
|
|
|
uint32_t acpi_find_rsdp_address(QTestState *qts);
|
2019-05-02 16:51:56 +02:00
|
|
|
uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
|
|
|
|
uint64_t size);
|
2019-05-02 16:51:52 +02:00
|
|
|
void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
|
2018-12-27 15:13:31 +01:00
|
|
|
void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
|
2019-05-02 16:51:50 +02:00
|
|
|
const uint8_t *addr_ptr, int addr_size, const char *sig,
|
2018-12-27 15:13:31 +01:00
|
|
|
bool verify_checksum);
|
2017-02-17 00:15:38 +01:00
|
|
|
|
2019-03-15 15:51:23 +01:00
|
|
|
#endif /* TEST_ACPI_UTILS_H */
|