u-boot/test/dm/acpi.c
Simon Glass 91fe8b79f6 acpi: Add a central location for table version numbers
Each ACPI table has its own version number. Add the version numbers in a
single function so we can keep them consistent and easily see what
versions are supported.

Start a new acpi_table file in a generic directory to house this function.
We can move things over to this file from x86 as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-04-16 14:36:28 +08:00

69 lines
1.6 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Tests for ACPI table generation
*
* Copyright 2019 Google LLC
* Written by Simon Glass <sjg@chromium.org>
*/
#include <common.h>
#include <dm.h>
#include <acpi/acpi_table.h>
#include <dm/acpi.h>
#include <dm/test.h>
#include <test/ut.h>
#define ACPI_TEST_DEV_NAME "ABCD"
static int testacpi_get_name(const struct udevice *dev, char *out_name)
{
return acpi_copy_name(out_name, ACPI_TEST_DEV_NAME);
}
struct acpi_ops testacpi_ops = {
.get_name = testacpi_get_name,
};
static const struct udevice_id testacpi_ids[] = {
{ .compatible = "denx,u-boot-acpi-test" },
{ }
};
U_BOOT_DRIVER(testacpi_drv) = {
.name = "testacpi_drv",
.of_match = testacpi_ids,
.id = UCLASS_TEST_ACPI,
ACPI_OPS_PTR(&testacpi_ops)
};
UCLASS_DRIVER(testacpi) = {
.name = "testacpi",
.id = UCLASS_TEST_ACPI,
};
/* Test ACPI get_name() */
static int dm_test_acpi_get_name(struct unit_test_state *uts)
{
char name[ACPI_NAME_MAX];
struct udevice *dev;
ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev));
ut_assertok(acpi_get_name(dev, name));
ut_asserteq_str(ACPI_TEST_DEV_NAME, name);
return 0;
}
DM_TEST(dm_test_acpi_get_name, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
/* Test acpi_get_table_revision() */
static int dm_test_acpi_get_table_revision(struct unit_test_state *uts)
{
ut_asserteq(1, acpi_get_table_revision(ACPITAB_MCFG));
ut_asserteq(2, acpi_get_table_revision(ACPITAB_RSDP));
ut_asserteq(4, acpi_get_table_revision(ACPITAB_TPM2));
ut_asserteq(-EINVAL, acpi_get_table_revision(ACPITAB_COUNT));
return 0;
}
DM_TEST(dm_test_acpi_get_table_revision,
DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);