// SPDX-License-Identifier: GPL-2.0+
/*
 * Tests for ACPI code generation
 *
 * Copyright 2019 Google LLC
 * Written by Simon Glass <sjg@chromium.org>
 */

#include <dm.h>
#include <irq.h>
#include <malloc.h>
#include <u-boot/uuid.h>
#include <acpi/acpigen.h>
#include <acpi/acpi_device.h>
#include <acpi/acpi_table.h>
#include <asm/gpio.h>
#include <asm/unaligned.h>
#include <dm/acpi.h>
#include <dm/test.h>
#include <dm/uclass-internal.h>
#include <test/ut.h>
#include "acpi.h"

/* Maximum size of the ACPI context needed for most tests */
#define ACPI_CONTEXT_SIZE	150

#define TEST_STRING	"frogmore"
#define TEST_STRING2	"ranch"
#define TEST_STREAM2	"\xfa\xde"

#define TEST_INT8	0x7d
#define TEST_INT16	0x2345
#define TEST_INT32	0x12345678
#define TEST_INT64	0x4567890123456

int acpi_test_alloc_context_size(struct acpi_ctx **ctxp, int size)
{
	struct acpi_ctx *ctx;

	*ctxp = NULL;
	ctx = malloc(sizeof(*ctx));
	if (!ctx)
		return -ENOMEM;
	ctx->base = malloc(size);
	if (!ctx->base) {
		free(ctx);
		return -ENOMEM;
	}
	ctx->ltop = 0;
	ctx->current = ctx->base;
	*ctxp = ctx;

	return 0;
}

int acpi_test_get_length(u8 *ptr)
{
	if (!(*ptr & 0x80))
		return -EINVAL;

	return (*ptr & 0xf) | ptr[1] << 4 | ptr[2] << 12;
}

static int alloc_context(struct acpi_ctx **ctxp)
{
	return acpi_test_alloc_context_size(ctxp, ACPI_CONTEXT_SIZE);
}

static void free_context(struct acpi_ctx **ctxp)
{
	free((*ctxp)->base);
	free(*ctxp);
	*ctxp = NULL;
}

/* Test emitting simple types and acpigen_get_current() */
static int dm_test_acpi_emit_simple(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_emit_byte(ctx, 0x23);
	ut_asserteq(1, acpigen_get_current(ctx) - ptr);
	ut_asserteq(0x23, *(u8 *)ptr);

	acpigen_emit_word(ctx, 0x1234);
	ut_asserteq(3, acpigen_get_current(ctx) - ptr);
	ut_asserteq(0x1234, get_unaligned((u16 *)(ptr + 1)));

	acpigen_emit_dword(ctx, 0x87654321);
	ut_asserteq(7, acpigen_get_current(ctx) - ptr);
	ut_asserteq(0x87654321, get_unaligned((u32 *)(ptr + 3)));

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_emit_simple, 0);

/* Test emitting a stream */
static int dm_test_acpi_emit_stream(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_emit_stream(ctx, TEST_STREAM2, 2);
	ut_asserteq(2, acpigen_get_current(ctx) - ptr);
	ut_asserteq((u8)TEST_STREAM2[0], ptr[0]);
	ut_asserteq((u8)TEST_STREAM2[1], ptr[1]);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_emit_stream, 0);

/* Test emitting a string */
static int dm_test_acpi_emit_string(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_emit_string(ctx, TEST_STRING);
	ut_asserteq(sizeof(TEST_STRING), acpigen_get_current(ctx) - ptr);
	ut_asserteq_str(TEST_STRING, (char *)ptr);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_emit_string, 0);

/* Test emitting an interrupt descriptor */
static int dm_test_acpi_interrupt(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	struct udevice *dev;
	struct irq irq;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	ut_assertok(uclass_first_device_err(UCLASS_TEST_FDT, &dev));
	ut_assertok(irq_get_by_index(dev, 0, &irq));

	/* See a-test, property interrupts-extended in the device tree */
	ut_asserteq(3, acpi_device_write_interrupt_irq(ctx, &irq));
	ut_asserteq(9, acpigen_get_current(ctx) - ptr);
	ut_asserteq(ACPI_DESCRIPTOR_INTERRUPT, ptr[0]);
	ut_asserteq(6, get_unaligned((u16 *)(ptr + 1)));
	ut_asserteq(0x19, ptr[3]);
	ut_asserteq(1, ptr[4]);
	ut_asserteq(3, get_unaligned((u32 *)(ptr + 5)));

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_interrupt, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test emitting a GPIO descriptor */
static int dm_test_acpi_gpio(struct unit_test_state *uts)
{
	struct gpio_desc desc;
	struct acpi_ctx *ctx;
	struct udevice *dev;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
	ut_asserteq_str("a-test", dev->name);
	ut_assertok(gpio_request_by_name(dev, "test-gpios", 1, &desc, 0));

	/* This should write GPIO pin 4 (see device tree test.dts ) */
	ut_asserteq(4, acpi_device_write_gpio_desc(ctx, &desc));
	ut_asserteq(35, acpigen_get_current(ctx) - ptr);
	ut_asserteq(ACPI_DESCRIPTOR_GPIO, ptr[0]);
	ut_asserteq(32, get_unaligned((u16 *)(ptr + 1)));
	ut_asserteq(ACPI_GPIO_REVISION_ID, ptr[3]);
	ut_asserteq(ACPI_GPIO_TYPE_IO, ptr[4]);
	ut_asserteq(1, get_unaligned((u16 *)(ptr + 5)));
	ut_asserteq(9, get_unaligned((u16 *)(ptr + 7)));
	ut_asserteq(ACPI_GPIO_PULL_UP, ptr[9]);
	ut_asserteq(1234, get_unaligned((u16 *)(ptr + 10)));
	ut_asserteq(0, get_unaligned((u16 *)(ptr + 12)));
	ut_asserteq(23, get_unaligned((u16 *)(ptr + 14)));
	ut_asserteq(0, ptr[16]);
	ut_asserteq(25, get_unaligned((u16 *)(ptr + 17)));
	ut_asserteq(35, get_unaligned((u16 *)(ptr + 19)));
	ut_asserteq(0, get_unaligned((u16 *)(ptr + 21)));

	/* pin0 */
	ut_asserteq(4, get_unaligned((u16 *)(ptr + 23)));

	ut_asserteq_str("\\_SB.PINC", (char *)ptr + 25);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_gpio, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test emitting a GPIO descriptor with an interrupt */
static int dm_test_acpi_gpio_irq(struct unit_test_state *uts)
{
	struct gpio_desc desc;
	struct acpi_ctx *ctx;
	struct udevice *dev;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
	ut_asserteq_str("a-test", dev->name);
	ut_assertok(gpio_request_by_name(dev, "test2-gpios", 2, &desc, 0));

	/* This should write GPIO pin 6 (see device tree test.dts ) */
	ut_asserteq(6, acpi_device_write_gpio_desc(ctx, &desc));
	ut_asserteq(35, acpigen_get_current(ctx) - ptr);
	ut_asserteq(ACPI_DESCRIPTOR_GPIO, ptr[0]);
	ut_asserteq(32, get_unaligned((u16 *)(ptr + 1)));
	ut_asserteq(ACPI_GPIO_REVISION_ID, ptr[3]);
	ut_asserteq(ACPI_GPIO_TYPE_INTERRUPT, ptr[4]);
	ut_asserteq(1, get_unaligned((u16 *)(ptr + 5)));
	ut_asserteq(29, get_unaligned((u16 *)(ptr + 7)));
	ut_asserteq(ACPI_GPIO_PULL_DOWN, ptr[9]);
	ut_asserteq(0, get_unaligned((u16 *)(ptr + 10)));
	ut_asserteq(4321, get_unaligned((u16 *)(ptr + 12)));
	ut_asserteq(23, get_unaligned((u16 *)(ptr + 14)));
	ut_asserteq(0, ptr[16]);
	ut_asserteq(25, get_unaligned((u16 *)(ptr + 17)));
	ut_asserteq(35, get_unaligned((u16 *)(ptr + 19)));
	ut_asserteq(0, get_unaligned((u16 *)(ptr + 21)));

	/* pin0 */
	ut_asserteq(6, get_unaligned((u16 *)(ptr + 23)));

	ut_asserteq_str("\\_SB.PINC", (char *)ptr + 25);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_gpio_irq, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test emitting either a GPIO or interrupt descriptor */
static int dm_test_acpi_interrupt_or_gpio(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	struct udevice *dev;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	/* This should produce an interrupt, even though it also has a GPIO */
	ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
	ut_asserteq_str("a-test", dev->name);
	ut_asserteq(3, acpi_device_write_interrupt_or_gpio(ctx, dev,
							   "test2-gpios"));
	ut_asserteq(ACPI_DESCRIPTOR_INTERRUPT, ptr[0]);

	/* This has no interrupt so should produce a GPIO */
	ptr = ctx->current;
	ut_assertok(uclass_find_first_device(UCLASS_PANEL_BACKLIGHT, &dev));
	ut_asserteq(1, acpi_device_write_interrupt_or_gpio(ctx, dev,
							   "enable-gpios"));
	ut_asserteq(ACPI_DESCRIPTOR_GPIO, ptr[0]);

	/* This one has neither */
	ptr = acpigen_get_current(ctx);
	ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 3, &dev));
	ut_asserteq_str("b-test", dev->name);
	ut_asserteq(-ENOENT,
		    acpi_device_write_interrupt_or_gpio(ctx, dev,
							"enable-gpios"));

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_interrupt_or_gpio, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test emitting an I2C descriptor */
static int dm_test_acpi_i2c(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	struct udevice *dev;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	ut_assertok(uclass_get_device(UCLASS_RTC, 0, &dev));
	ut_asserteq(0x43, acpi_device_write_i2c_dev(ctx, dev));
	ut_asserteq(28, acpigen_get_current(ctx) - ptr);
	ut_asserteq(ACPI_DESCRIPTOR_SERIAL_BUS, ptr[0]);
	ut_asserteq(25, get_unaligned((u16 *)(ptr + 1)));
	ut_asserteq(ACPI_I2C_SERIAL_BUS_REVISION_ID, ptr[3]);
	ut_asserteq(0, ptr[4]);
	ut_asserteq(ACPI_SERIAL_BUS_TYPE_I2C, ptr[5]);
	ut_asserteq(0, get_unaligned((u16 *)(ptr + 7)));
	ut_asserteq(ACPI_I2C_TYPE_SPECIFIC_REVISION_ID, ptr[9]);
	ut_asserteq(6, get_unaligned((u16 *)(ptr + 10)));
	ut_asserteq(100000, get_unaligned((u32 *)(ptr + 12)));
	ut_asserteq(0x43, get_unaligned((u16 *)(ptr + 16)));
	ut_asserteq_str("\\_SB.I2C0", (char *)ptr + 18);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_i2c, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test emitting a SPI descriptor */
static int dm_test_acpi_spi(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	struct udevice *dev;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	ut_assertok(uclass_first_device_err(UCLASS_SPI_FLASH, &dev));
	ut_assertok(acpi_device_write_spi_dev(ctx, dev));
	ut_asserteq(31, acpigen_get_current(ctx) - ptr);
	ut_asserteq(ACPI_DESCRIPTOR_SERIAL_BUS, ptr[0]);
	ut_asserteq(28, get_unaligned((u16 *)(ptr + 1)));
	ut_asserteq(ACPI_SPI_SERIAL_BUS_REVISION_ID, ptr[3]);
	ut_asserteq(0, ptr[4]);
	ut_asserteq(ACPI_SERIAL_BUS_TYPE_SPI, ptr[5]);
	ut_asserteq(2, ptr[6]);
	ut_asserteq(0, get_unaligned((u16 *)(ptr + 7)));
	ut_asserteq(ACPI_SPI_TYPE_SPECIFIC_REVISION_ID, ptr[9]);
	ut_asserteq(9, get_unaligned((u16 *)(ptr + 10)));
	ut_asserteq(40000000, get_unaligned((u32 *)(ptr + 12)));
	ut_asserteq(8, ptr[16]);
	ut_asserteq(0, ptr[17]);
	ut_asserteq(0, ptr[18]);
	ut_asserteq(0, get_unaligned((u16 *)(ptr + 19)));
	ut_asserteq_str("\\_SB.SPI0", (char *)ptr + 21);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_spi, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test emitting a length */
static int dm_test_acpi_len(struct unit_test_state *uts)
{
	const int size = 0xc0000;
	struct acpi_ctx *ctx;
	u8 *ptr;
	int i;

	ut_assertok(acpi_test_alloc_context_size(&ctx, size));

	ptr = acpigen_get_current(ctx);

	/* Write a byte and a 3-byte length */
	acpigen_write_len_f(ctx);
	acpigen_emit_byte(ctx, 0x23);
	acpigen_pop_len(ctx);
	ut_asserteq(1 + 3, acpi_test_get_length(ptr));

	/* Write 200 bytes so we need two length bytes */
	ptr = ctx->current;
	acpigen_write_len_f(ctx);
	for (i = 0; i < 200; i++)
		acpigen_emit_byte(ctx, 0x23);
	acpigen_pop_len(ctx);
	ut_asserteq(200 + 3, acpi_test_get_length(ptr));

	/* Write 40KB so we need three length bytes */
	ptr = ctx->current;
	acpigen_write_len_f(ctx);
	for (i = 0; i < 40000; i++)
		acpigen_emit_byte(ctx, 0x23);
	acpigen_pop_len(ctx);
	ut_asserteq(40000 + 3, acpi_test_get_length(ptr));

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_len, 0);

/* Test writing a package */
static int dm_test_acpi_package(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	char *num_elements;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	num_elements = acpigen_write_package(ctx, 3);
	ut_asserteq_ptr(num_elements, ptr + 4);

	/* For ease of testing, just emit a byte, not valid package contents */
	acpigen_emit_byte(ctx, 0x23);
	acpigen_pop_len(ctx);
	ut_asserteq(PACKAGE_OP, ptr[0]);
	ut_asserteq(5, acpi_test_get_length(ptr + 1));
	ut_asserteq(3, ptr[4]);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_package, 0);

/* Test writing an integer */
static int dm_test_acpi_integer(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	acpigen_write_integer(ctx, 0);
	acpigen_write_integer(ctx, 1);
	acpigen_write_integer(ctx, TEST_INT8);
	acpigen_write_integer(ctx, TEST_INT16);
	acpigen_write_integer(ctx, TEST_INT32);
	acpigen_write_integer(ctx, TEST_INT64);

	ut_asserteq(6 + 1 + 2 + 4 + 8, acpigen_get_current(ctx) - ptr);

	ut_asserteq(ZERO_OP, ptr[0]);

	ut_asserteq(ONE_OP, ptr[1]);

	ut_asserteq(BYTE_PREFIX, ptr[2]);
	ut_asserteq(TEST_INT8, ptr[3]);

	ut_asserteq(WORD_PREFIX, ptr[4]);
	ut_asserteq(TEST_INT16, get_unaligned((u16 *)(ptr + 5)));

	ut_asserteq(DWORD_PREFIX, ptr[7]);
	ut_asserteq(TEST_INT32, get_unaligned((u32 *)(ptr + 8)));

	ut_asserteq(QWORD_PREFIX, ptr[12]);
	ut_asserteq_64(TEST_INT64, get_unaligned((u64 *)(ptr + 13)));

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_integer, 0);

/* Test writing a string */
static int dm_test_acpi_string(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	acpigen_write_string(ctx, TEST_STRING);
	acpigen_write_string(ctx, TEST_STRING2);

	ut_asserteq(2 + sizeof(TEST_STRING) + sizeof(TEST_STRING2),
		    acpigen_get_current(ctx) - ptr);
	ut_asserteq(STRING_PREFIX, ptr[0]);
	ut_asserteq_str(TEST_STRING, (char *)ptr + 1);
	ptr += 1 + sizeof(TEST_STRING);
	ut_asserteq(STRING_PREFIX, ptr[0]);
	ut_asserteq_str(TEST_STRING2, (char *)ptr + 1);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_string, 0);

/* Test writing a name */
static int dm_test_acpi_name(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	/*
	 * The names here are made up for testing the various cases. The
	 * grammar is in the ACPI spec 6.3 section 19.2.2
	 */
	acpigen_write_name(ctx, "\\_SB");
	acpigen_write_name(ctx, "\\_SB.I2C0");
	acpigen_write_name(ctx, "\\_SB.I2C0.TPM2");
	acpigen_write_name(ctx, "\\_SB.I2C0.TPM2.LONG");
	acpigen_write_name(ctx, "^^^^SPI0.FLAS");
	acpigen_write_name(ctx, "NN");
	acpigen_write_name(ctx, "^AB.CD.D.EFG");
	acpigen_write_name(ctx, "^^^^");
	acpigen_write_name(ctx, "\\");
	acpigen_write_name(ctx, "\\ABCD");

	ut_asserteq(107, acpigen_get_current(ctx) - ptr);
	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq_strn("\\_SB_", (char *)ptr + 1);
	ptr += 6;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq('\\', ptr[1]);
	ut_asserteq(DUAL_NAME_PREFIX, ptr[2]);
	ut_asserteq_strn("_SB_I2C0", (char *)ptr + 3);
	ptr += 11;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq('\\', ptr[1]);
	ut_asserteq(MULTI_NAME_PREFIX, ptr[2]);
	ut_asserteq(3, ptr[3]);
	ut_asserteq_strn("_SB_I2C0TPM2", (char *)ptr + 4);
	ptr += 16;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq('\\', ptr[1]);
	ut_asserteq(MULTI_NAME_PREFIX, ptr[2]);
	ut_asserteq(4, ptr[3]);
	ut_asserteq_strn("_SB_I2C0TPM2LONG", (char *)ptr + 4);
	ptr += 20;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq('^', ptr[1]);
	ut_asserteq('^', ptr[2]);
	ut_asserteq('^', ptr[3]);
	ut_asserteq('^', ptr[4]);
	ut_asserteq(DUAL_NAME_PREFIX, ptr[5]);
	ut_asserteq_strn("SPI0FLAS", (char *)ptr + 6);
	ptr += 14;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq_strn("NN__", (char *)ptr + 1);
	ptr += 5;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq('^', ptr[1]);
	ut_asserteq(MULTI_NAME_PREFIX, ptr[2]);
	ut_asserteq(4, ptr[3]);
	ut_asserteq_strn("AB__CD__D___EFG_", (char *)ptr + 4);
	ptr += 20;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq('^', ptr[1]);
	ut_asserteq('^', ptr[2]);
	ut_asserteq('^', ptr[3]);
	ut_asserteq('^', ptr[4]);
	ut_asserteq(ZERO_OP, ptr[5]);
	ptr += 6;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq('\\', ptr[1]);
	ut_asserteq(ZERO_OP, ptr[2]);
	ptr += 3;

	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq_strn("\\ABCD", (char *)ptr + 1);
	ptr += 5;

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_name, 0);

/* Test writing a UUID */
static int dm_test_acpi_uuid(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	ut_assertok(acpigen_write_uuid(ctx,
				       "dbb8e3e6-5886-4ba6-8795-1319f52a966b"));
	ut_asserteq(23, acpigen_get_current(ctx) - ptr);
	ut_asserteq(BUFFER_OP, ptr[0]);
	ut_asserteq(22, acpi_test_get_length(ptr + 1));
	ut_asserteq(0xdbb8e3e6, get_unaligned((u32 *)(ptr + 7)));
	ut_asserteq(0x5886, get_unaligned((u16 *)(ptr + 11)));
	ut_asserteq(0x4ba6, get_unaligned((u16 *)(ptr + 13)));
	ut_asserteq(0x9587, get_unaligned((u16 *)(ptr + 15)));
	ut_asserteq(0x2af51913, get_unaligned((u32 *)(ptr + 17)));
	ut_asserteq(0x6b96, get_unaligned((u16 *)(ptr + 21)));

	/* Try a bad UUID */
	ut_asserteq(-EINVAL,
		    acpigen_write_uuid(ctx,
				       "dbb8e3e6-5886-4ba6x8795-1319f52a966b"));

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_uuid, 0);

/* Test writing misc ACPI codes */
static int dm_test_acpi_misc(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	const int flags = 3;
	const int nargs = 4;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_sleep(ctx, TEST_INT64);
	ut_asserteq_64(TEST_INT64, get_unaligned((u64 *)(ptr + 3)));
	ptr += 11;

	acpigen_write_store(ctx);
	ut_asserteq(STORE_OP, *ptr);
	ptr++;

	acpigen_write_debug_string(ctx, TEST_STRING);
	ut_asserteq_str(TEST_STRING, (char *)ptr + 2);
	ptr += 2 +  sizeof(TEST_STRING);
	ut_asserteq(EXT_OP_PREFIX, ptr[0]);
	ut_asserteq(DEBUG_OP, ptr[1]);
	ptr += 2;

	acpigen_write_sta(ctx, flags);
	ut_asserteq(METHOD_OP, ptr[0]);
	ut_asserteq(11, acpi_test_get_length(ptr + 1));
	ut_asserteq_strn("_STA", (char *)ptr + 4);
	ut_asserteq(0, ptr[8]);
	ut_asserteq(RETURN_OP, ptr[9]);
	ut_asserteq(BYTE_PREFIX, ptr[10]);
	ut_asserteq(flags, ptr[11]);
	ptr += 12;

	acpigen_write_sleep(ctx, TEST_INT16);
	ut_asserteq(SLEEP_OP, ptr[1]);
	ut_asserteq(TEST_INT16, get_unaligned((u16 *)(ptr + 3)));
	ptr += 5;

	acpigen_write_method_serialized(ctx, "FRED", nargs);
	ut_asserteq(METHOD_OP, ptr[0]);
	ut_asserteq_strn("FRED", (char *)ptr + 4);
	ut_asserteq(1 << 3 | nargs, ptr[8]);
	ut_asserteq(1, ctx->ltop);	/* method is unfinished */

	ptr += 9;
	acpigen_write_or(ctx, LOCAL0_OP, LOCAL1_OP, LOCAL2_OP);
	acpigen_write_and(ctx, LOCAL3_OP, LOCAL4_OP, LOCAL5_OP);
	acpigen_write_not(ctx, LOCAL6_OP, LOCAL7_OP);
	ut_asserteq(OR_OP, ptr[0]);
	ut_asserteq(LOCAL0_OP, ptr[1]);
	ut_asserteq(LOCAL1_OP, ptr[2]);
	ut_asserteq(LOCAL2_OP, ptr[3]);

	ptr += 4;
	ut_asserteq(AND_OP, ptr[0]);
	ut_asserteq(LOCAL3_OP, ptr[1]);
	ut_asserteq(LOCAL4_OP, ptr[2]);
	ut_asserteq(LOCAL5_OP, ptr[3]);

	ptr += 4;
	ut_asserteq(NOT_OP, ptr[0]);
	ut_asserteq(LOCAL6_OP, ptr[1]);
	ut_asserteq(LOCAL7_OP, ptr[2]);
	ptr += 3;
	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_misc, 0);

/* Test writing an ACPI power resource */
static int dm_test_acpi_power_res(struct unit_test_state *uts)
{
	const char *const states[] = { "_PR0", "_PR3" };
	const char *name = "PRIC";
	const int level = 3;
	const int order = 2;
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);

	/* PowerResource (PRIC, 0, 0) */
	acpigen_write_power_res(ctx, name, level, order, states,
				ARRAY_SIZE(states));
	ut_asserteq(0x28, acpigen_get_current(ctx) - ptr);
	ut_asserteq(NAME_OP, ptr[0]);
	ut_asserteq_strn(states[0], (char *)ptr + 1);
	ut_asserteq(8, acpi_test_get_length(ptr + 6));
	ut_asserteq_strn(name, (char *)ptr + 0xa);

	ut_asserteq_strn(states[1], (char *)ptr + 0xf);
	ut_asserteq(8, acpi_test_get_length(ptr + 0x14));
	ut_asserteq_strn(name, (char *)ptr + 0x18);

	ut_asserteq(POWER_RES_OP, ptr[0x1d]);
	ut_asserteq_strn(name, (char *)ptr + 0x21);
	ut_asserteq(level, ptr[0x25]);
	ut_asserteq(order, get_unaligned((u16 *)(ptr + 0x26)));

	/* The length is not set - caller must use acpigen_pop_len() */
	ut_asserteq(1, ctx->ltop);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_power_res, 0);

/* Test writing ACPI code to toggle a GPIO */
static int dm_test_acpi_gpio_toggle(struct unit_test_state *uts)
{
	const uint addr = 0x80012;
	const int txbit = BIT(2);
	struct gpio_desc desc;
	struct acpi_gpio gpio;
	struct acpi_ctx *ctx;
	struct udevice *dev;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
	ut_asserteq_str("a-test", dev->name);
	ut_assertok(gpio_request_by_name(dev, "test2-gpios", 2, &desc, 0));
	ut_assertok(gpio_get_acpi(&desc, &gpio));

	/* Spot-check the results - see sb_gpio_get_acpi() */
	ptr = acpigen_get_current(ctx);
	acpigen_set_enable_tx_gpio(ctx, txbit, "\\_SB.GPC0", "\\_SB.SPC0",
				   &gpio, true);
	acpigen_set_enable_tx_gpio(ctx, txbit, "\\_SB.GPC0", "\\_SB.SPC0",
				   &gpio, false);

	/* Since this GPIO is active low, we expect it to be cleared here */
	ut_asserteq(STORE_OP, *ptr);
	ut_asserteq_strn("_SB_GPC0", (char *)ptr + 3);
	ut_asserteq(addr + desc.offset, get_unaligned((u32 *)(ptr + 0xc)));
	ut_asserteq(LOCAL5_OP, ptr[0x10]);

	ut_asserteq(STORE_OP, ptr[0x11]);
	ut_asserteq(BYTE_PREFIX, ptr[0x12]);
	ut_asserteq(txbit, ptr[0x13]);
	ut_asserteq(LOCAL0_OP, ptr[0x14]);

	ut_asserteq(NOT_OP, ptr[0x15]);
	ut_asserteq(LOCAL0_OP, ptr[0x16]);
	ut_asserteq(LOCAL6_OP, ptr[0x17]);
	ut_asserteq(AND_OP, ptr[0x18]);
	ut_asserteq_strn("_SB_SPC0", (char *)ptr + 0x1e);
	ut_asserteq(addr + desc.offset, get_unaligned((u32 *)(ptr + 0x27)));
	ut_asserteq(LOCAL5_OP, ptr[0x2b]);

	/* Now the second one, which should be set */
	ut_asserteq_strn("_SB_GPC0", (char *)ptr + 0x2f);
	ut_asserteq(addr + desc.offset, get_unaligned((u32 *)(ptr + 0x38)));
	ut_asserteq(LOCAL5_OP, ptr[0x3c]);

	ut_asserteq(STORE_OP, ptr[0x3d]);

	ut_asserteq(OR_OP, ptr[0x41]);
	ut_asserteq(LOCAL0_OP, ptr[0x43]);
	ut_asserteq_strn("_SB_SPC0", (char *)ptr + 0x47);
	ut_asserteq(addr + desc.offset, get_unaligned((u32 *)(ptr + 0x50)));
	ut_asserteq(LOCAL5_OP, ptr[0x54]);
	ut_asserteq(0x55, acpigen_get_current(ctx) - ptr);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_gpio_toggle, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test writing ACPI code to output power-sequence info */
static int dm_test_acpi_power_seq(struct unit_test_state *uts)
{
	struct gpio_desc reset, enable, stop;
	const uint addr = 0xc00dc, addr_act_low = 0x80012;
	const int txbit = BIT(2);
	struct acpi_ctx *ctx;
	struct udevice *dev;
	u8 *ptr;

	ut_assertok(acpi_test_alloc_context_size(&ctx, 400));

	ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
	ut_asserteq_str("a-test", dev->name);
	ut_assertok(gpio_request_by_name(dev, "test2-gpios", 0, &reset, 0));
	ut_assertok(gpio_request_by_name(dev, "test2-gpios", 1, &enable, 0));
	ut_assertok(gpio_request_by_name(dev, "test2-gpios", 2, &stop, 0));
	ptr = acpigen_get_current(ctx);

	ut_assertok(acpi_device_add_power_res(ctx, txbit, "\\_SB.GPC0",
					      "\\_SB.SPC0", &reset, 2, 3,
					      &enable, 4, 5, &stop, 6, 7));
	ut_asserteq(0x186, acpigen_get_current(ctx) - ptr);
	ut_asserteq_strn("PRIC", (char *)ptr + 0x18);

	/* First the 'ON' sequence - spot check */
	ut_asserteq_strn("_ON_", (char *)ptr + 0x38);

	/* reset set */
	ut_asserteq(addr + reset.offset, get_unaligned((u32 *)(ptr + 0x49)));
	ut_asserteq(OR_OP, ptr[0x52]);

	/* enable set */
	ut_asserteq(addr + enable.offset, get_unaligned((u32 *)(ptr + 0x72)));
	ut_asserteq(OR_OP, ptr[0x7b]);

	/* reset clear */
	ut_asserteq(addr + reset.offset, get_unaligned((u32 *)(ptr + 0x9f)));
	ut_asserteq(NOT_OP, ptr[0xa8]);

	/* stop set (disable, active low) */
	ut_asserteq(addr_act_low + stop.offset,
		    get_unaligned((u32 *)(ptr + 0xcf)));
	ut_asserteq(OR_OP, ptr[0xd8]);

	/* Now the 'OFF' sequence */
	ut_asserteq_strn("_OFF", (char *)ptr + 0xf4);

	/* stop clear (enable, active low) */
	ut_asserteq(addr_act_low + stop.offset,
		    get_unaligned((u32 *)(ptr + 0x105)));
	ut_asserteq(NOT_OP, ptr[0x10e]);

	/* reset clear */
	ut_asserteq(addr + reset.offset, get_unaligned((u32 *)(ptr + 0x135)));
	ut_asserteq(OR_OP, ptr[0x13e]);

	/* enable clear */
	ut_asserteq(addr + enable.offset, get_unaligned((u32 *)(ptr + 0x162)));
	ut_asserteq(NOT_OP, ptr[0x16b]);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_power_seq, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test writing values */
static int dm_test_acpi_write_values(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));
	ptr = acpigen_get_current(ctx);

	acpigen_write_zero(ctx);
	acpigen_write_one(ctx);
	acpigen_write_byte(ctx, TEST_INT8);
	acpigen_write_word(ctx, TEST_INT16);
	acpigen_write_dword(ctx, TEST_INT32);
	acpigen_write_qword(ctx, TEST_INT64);

	ut_asserteq(ZERO_OP, *ptr++);

	ut_asserteq(ONE_OP, *ptr++);

	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(TEST_INT8, *ptr++);

	ut_asserteq(WORD_PREFIX, *ptr++);
	ut_asserteq(TEST_INT16, get_unaligned((u16 *)ptr));
	ptr += 2;

	ut_asserteq(DWORD_PREFIX, *ptr++);
	ut_asserteq(TEST_INT32, get_unaligned((u32 *)ptr));
	ptr += 4;

	ut_asserteq(QWORD_PREFIX, *ptr++);
	ut_asserteq_64(TEST_INT64, get_unaligned((u64 *)ptr));
	ptr += 8;

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_values, 0);

/* Test writing a scope */
static int dm_test_acpi_scope(struct unit_test_state *uts)
{
	char buf[ACPI_PATH_MAX];
	struct acpi_ctx *ctx;
	struct udevice *dev;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));
	ptr = acpigen_get_current(ctx);

	ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev));
	ut_assertok(acpi_device_path(dev, buf, sizeof(buf)));
	acpigen_write_scope(ctx, buf);
	acpigen_pop_len(ctx);

	ut_asserteq(SCOPE_OP, *ptr++);
	ut_asserteq(13, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(ROOT_PREFIX, *ptr++);
	ut_asserteq(DUAL_NAME_PREFIX, *ptr++);
	ut_asserteq_strn("_SB_" ACPI_TEST_DEV_NAME, (char *)ptr);
	ptr += 8;
	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_scope, UTF_SCAN_PDATA | UTF_SCAN_FDT);

/* Test writing a resource template */
static int dm_test_acpi_resource_template(struct unit_test_state *uts)
{
	struct acpi_gen_regaddr addr;
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));
	ptr = acpigen_get_current(ctx);

	addr.space_id = ACPI_ADDRESS_SPACE_EC;
	addr.bit_width = 32;
	addr.bit_offset = 8;
	addr.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
	addr.addrl = TEST_INT64 & 0xffffffff;
	addr.addrh = TEST_INT64 >> 32;
	acpigen_write_register_resource(ctx, &addr);

	ut_asserteq(BUFFER_OP, *ptr++);
	ut_asserteq(0x17, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(WORD_PREFIX, *ptr++);
	ut_asserteq(0x11, get_unaligned((u16 *)ptr));
	ptr += 2;
	ut_asserteq(ACPI_DESCRIPTOR_REGISTER, *ptr++);
	ut_asserteq(0xc, *ptr++);
	ut_asserteq(0, *ptr++);
	ut_asserteq(ACPI_ADDRESS_SPACE_EC, *ptr++);
	ut_asserteq(32, *ptr++);
	ut_asserteq(8, *ptr++);
	ut_asserteq(ACPI_ACCESS_SIZE_DWORD_ACCESS, *ptr++);
	ut_asserteq(TEST_INT64 & 0xffffffff, get_unaligned((u32 *)ptr));
	ptr += 4;
	ut_asserteq(TEST_INT64 >> 32, get_unaligned((u32 *)ptr));
	ptr += 4;
	ut_asserteq(ACPI_END_TAG, *ptr++);
	ut_asserteq(0x00, *ptr++);
	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_resource_template, 0);

/* Test writing a device */
static int dm_test_acpi_device(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));
	ptr = acpigen_get_current(ctx);

	acpigen_write_device(ctx, "\\_SB." ACPI_TEST_DEV_NAME);
	acpigen_pop_len(ctx);

	ut_asserteq(EXT_OP_PREFIX, *ptr++);
	ut_asserteq(DEVICE_OP, *ptr++);
	ut_asserteq(0xd, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(ROOT_PREFIX, *ptr++);
	ut_asserteq(DUAL_NAME_PREFIX, *ptr++);
	ptr += 8;
	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_device, 0);

/* Test writing named values */
static int dm_test_acpi_write_name(struct unit_test_state *uts)
{
	const char *name = "\\_SB." ACPI_TEST_DEV_NAME;
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));
	ptr = acpigen_get_current(ctx);

	acpigen_write_name_zero(ctx, name);
	acpigen_write_name_one(ctx, name);
	acpigen_write_name_byte(ctx, name, TEST_INT8);
	acpigen_write_name_word(ctx, name, TEST_INT16);
	acpigen_write_name_dword(ctx, name, TEST_INT32);
	acpigen_write_name_qword(ctx, name, TEST_INT64);
	acpigen_write_name_integer(ctx, name, TEST_INT64 + 1);
	acpigen_write_name_string(ctx, name, "baldrick");
	acpigen_write_name_string(ctx, name, NULL);

	ut_asserteq(NAME_OP, *ptr++);
	ut_asserteq_strn("\\._SB_ABCD", (char *)ptr);
	ptr += 10;
	ut_asserteq(ZERO_OP, *ptr++);

	ut_asserteq(NAME_OP, *ptr++);
	ptr += 10;
	ut_asserteq(ONE_OP, *ptr++);

	ut_asserteq(NAME_OP, *ptr++);
	ptr += 10;
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(TEST_INT8, *ptr++);

	ut_asserteq(NAME_OP, *ptr++);
	ptr += 10;
	ut_asserteq(WORD_PREFIX, *ptr++);
	ut_asserteq(TEST_INT16, get_unaligned((u16 *)ptr));
	ptr += 2;

	ut_asserteq(NAME_OP, *ptr++);
	ptr += 10;
	ut_asserteq(DWORD_PREFIX, *ptr++);
	ut_asserteq(TEST_INT32, get_unaligned((u32 *)ptr));
	ptr += 4;

	ut_asserteq(NAME_OP, *ptr++);
	ptr += 10;
	ut_asserteq(QWORD_PREFIX, *ptr++);
	ut_asserteq_64(TEST_INT64, get_unaligned((u64 *)ptr));
	ptr += 8;

	ut_asserteq(NAME_OP, *ptr++);
	ptr += 10;
	ut_asserteq(QWORD_PREFIX, *ptr++);
	ut_asserteq_64(TEST_INT64 + 1, get_unaligned((u64 *)ptr));
	ptr += 8;

	ut_asserteq(NAME_OP, *ptr++);
	ptr += 10;
	ut_asserteq(STRING_PREFIX, *ptr++);
	ut_asserteq_str("baldrick", (char *)ptr);
	ptr += 9;

	ut_asserteq(NAME_OP, *ptr++);
	ptr += 10;
	ut_asserteq(STRING_PREFIX, *ptr++);
	ut_asserteq('\0', *ptr++);

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_name, 0);

/* Test emitting a _PRW component */
static int dm_test_acpi_write_prw(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_prw(ctx, 5, 3);
	ut_asserteq(NAME_OP, *ptr++);

	ut_asserteq_strn("_PRW", (char *)ptr);
	ptr += 4;
	ut_asserteq(PACKAGE_OP, *ptr++);
	ut_asserteq(8, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(2, *ptr++);
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(5, *ptr++);
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(3, *ptr++);
	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_prw, 0);

/* Test emitting writing conditionals */
static int dm_test_acpi_write_cond(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_if(ctx);
	acpigen_pop_len(ctx);
	ut_asserteq(IF_OP, *ptr++);
	ut_asserteq(3, acpi_test_get_length(ptr));
	ptr += 3;

	acpigen_write_else(ctx);
	acpigen_pop_len(ctx);
	ut_asserteq(ELSE_OP, *ptr++);
	ut_asserteq(3, acpi_test_get_length(ptr));
	ptr += 3;

	acpigen_write_if_lequal_op_int(ctx, LOCAL1_OP, 5);
	acpigen_pop_len(ctx);
	ut_asserteq(IF_OP, *ptr++);
	ut_asserteq(7, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(LEQUAL_OP, *ptr++);
	ut_asserteq(LOCAL1_OP, *ptr++);
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(5, *ptr++);

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_cond, 0);

/* Test emitting writing return values and ToBuffer/ToInteger */
static int dm_test_acpi_write_return(struct unit_test_state *uts)
{
	int len = sizeof(TEST_STRING);
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_to_buffer(ctx, ARG0_OP, LOCAL0_OP);
	ut_asserteq(TO_BUFFER_OP, *ptr++);
	ut_asserteq(ARG0_OP, *ptr++);
	ut_asserteq(LOCAL0_OP, *ptr++);

	acpigen_write_to_integer(ctx, ARG0_OP, LOCAL0_OP);
	ut_asserteq(TO_INTEGER_OP, *ptr++);
	ut_asserteq(ARG0_OP, *ptr++);
	ut_asserteq(LOCAL0_OP, *ptr++);

	acpigen_write_return_byte_buffer(ctx, (u8 *)TEST_STRING, len);
	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BUFFER_OP, *ptr++);
	ut_asserteq(5 + len, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(len, *ptr++);
	ut_asserteq_mem(TEST_STRING, ptr, len);
	ptr += len;

	acpigen_write_return_singleton_buffer(ctx, 123);
	len = 1;
	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BUFFER_OP, *ptr++);
	ut_asserteq(4 + len, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(ONE_OP, *ptr++);
	ut_asserteq(123, *ptr++);

	acpigen_write_return_byte(ctx, 43);
	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(43, *ptr++);

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_return, 0);

/* Test emitting a DSM for an I2C HID */
static int dm_test_acpi_write_i2c_dsm(struct unit_test_state *uts)
{
	char uuid_str[UUID_STR_LEN + 1];
	const int reg_offset = 0x20;
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	ut_assertok(acpi_device_write_dsm_i2c_hid(ctx, reg_offset));

	/* acpigen_write_dsm_start() */
	ut_asserteq(METHOD_OP, *ptr++);
	ut_asserteq(0x78, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq_strn("_DSM", (char *)ptr);
	ptr += 4;
	ut_asserteq(ACPI_METHOD_SERIALIZED_MASK | 4, *ptr++);

	ut_asserteq(TO_BUFFER_OP, *ptr++);
	ut_asserteq(ARG0_OP, *ptr++);
	ut_asserteq(LOCAL0_OP, *ptr++);

	/* acpigen_write_dsm_uuid_start() */
	ut_asserteq(IF_OP, *ptr++);
	ut_asserteq(0x65, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(LEQUAL_OP, *ptr++);
	ut_asserteq(LOCAL0_OP, *ptr++);

	ut_asserteq(BUFFER_OP, *ptr++);
	ut_asserteq(UUID_BIN_LEN + 6, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(WORD_PREFIX, *ptr++);
	ut_asserteq(UUID_BIN_LEN, get_unaligned((u16 *)ptr));
	ptr += 2;
	uuid_bin_to_str(ptr, uuid_str, UUID_STR_FORMAT_GUID);
	ut_asserteq_str(ACPI_DSM_I2C_HID_UUID, uuid_str);
	ptr += UUID_BIN_LEN;

	ut_asserteq(TO_INTEGER_OP, *ptr++);
	ut_asserteq(ARG2_OP, *ptr++);
	ut_asserteq(LOCAL1_OP, *ptr++);

	/* acpigen_write_dsm_uuid_start_cond() */
	ut_asserteq(IF_OP, *ptr++);
	ut_asserteq(0x34, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(LEQUAL_OP, *ptr++);
	ut_asserteq(LOCAL1_OP, *ptr++);
	ut_asserteq(ZERO_OP, *ptr++);

	/*
	 * See code from acpi_device_write_dsm_i2c_hid(). We don't check every
	 * piece
	 */
	ut_asserteq(TO_INTEGER_OP, *ptr++);
	ut_asserteq(ARG1_OP, *ptr++);
	ut_asserteq(LOCAL2_OP, *ptr++);

	ut_asserteq(IF_OP, *ptr++);
	ut_asserteq(0xd, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(LEQUAL_OP, *ptr++);
	ut_asserteq(LOCAL2_OP, *ptr++);
	ut_asserteq(ZERO_OP, *ptr++);	/* function 0 */

	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BUFFER_OP, *ptr++);
	ptr += 5;

	ut_asserteq(ELSE_OP, *ptr++);
	ptr += 3;

	ut_asserteq(IF_OP, *ptr++);
	ut_asserteq(0xd, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(LEQUAL_OP, *ptr++);
	ut_asserteq(LOCAL2_OP, *ptr++);
	ut_asserteq(ONE_OP, *ptr++);

	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BUFFER_OP, *ptr++);
	ptr += 5;

	ut_asserteq(ELSE_OP, *ptr++);
	ptr += 3;

	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BUFFER_OP, *ptr++);
	ptr += 5;

	/* acpigen_write_dsm_uuid_start_cond() */
	ut_asserteq(IF_OP, *ptr++);
	ut_asserteq(9, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq(LEQUAL_OP, *ptr++);
	ut_asserteq(LOCAL1_OP, *ptr++);
	ut_asserteq(ONE_OP, *ptr++);	/* function 1 */

	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(reg_offset, *ptr++);

	/* acpigen_write_dsm_uuid_end() */
	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BUFFER_OP, *ptr++);
	ptr += 5;

	/* acpigen_write_dsm_end */
	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq(BUFFER_OP, *ptr++);
	ptr += 5;

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_i2c_dsm, 0);

/* Test emitting a processor */
static int dm_test_acpi_write_processor(struct unit_test_state *uts)
{
	const int cpuindex = 6;
	const u32 pblock_addr = 0x12345600;
	const u32 pblock_len = 0x60;
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_processor(ctx, cpuindex, pblock_addr, pblock_len);
	acpigen_pop_len(ctx);

	ut_asserteq(EXT_OP_PREFIX, *ptr++);
	ut_asserteq(PROCESSOR_OP, *ptr++);
	ut_asserteq(0x13, acpi_test_get_length(ptr));
	ptr += 3;
	ut_asserteq_strn("\\._PR_CP06", (char *)ptr);
	ptr += 10;
	ut_asserteq(cpuindex, *ptr++);
	ut_asserteq(pblock_addr, get_unaligned((u32 *)ptr));
	ptr += 4;
	ut_asserteq(pblock_len, *ptr++);

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_processor, 0);

/* Test emitting a processor package */
static int dm_test_acpi_write_processor_package(struct unit_test_state *uts)
{
	const int core_count = 3;
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_processor_package(ctx, "XCPU", 0, core_count);

	ut_asserteq(NAME_OP, *ptr++);
	ut_asserteq_strn("XCPU", (char *)ptr);
	ptr += 4;
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(core_count, *ptr++);

	ut_asserteq_strn("\\._PR_CP00", (char *)ptr);
	ptr += 10;
	ut_asserteq_strn("\\._PR_CP01", (char *)ptr);
	ptr += 10;
	ut_asserteq_strn("\\._PR_CP02", (char *)ptr);
	ptr += 10;

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_processor_package, 0);

/* Test emitting a processor notification package */
static int dm_test_acpi_write_processor_cnot(struct unit_test_state *uts)
{
	const int core_count = 3;
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_processor_cnot(ctx, core_count);

	ut_asserteq(METHOD_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq_strn("\\._PR_CNOT", (char *)ptr);
	ptr += 10;
	ut_asserteq(1, *ptr++);

	ut_asserteq(NOTIFY_OP, *ptr++);
	ut_asserteq_strn("\\._PR_CP00", (char *)ptr);
	ptr += 10;
	ut_asserteq(ARG0_OP, *ptr++);
	ut_asserteq(NOTIFY_OP, *ptr++);
	ut_asserteq_strn("\\._PR_CP01", (char *)ptr);
	ptr += 10;
	ut_asserteq(ARG0_OP, *ptr++);
	ut_asserteq(NOTIFY_OP, *ptr++);
	ut_asserteq_strn("\\._PR_CP02", (char *)ptr);
	ptr += 10;
	ut_asserteq(ARG0_OP, *ptr++);

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_processor_cnot, 0);

/* Test acpigen_write_tpc */
static int dm_test_acpi_write_tpc(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_tpc(ctx, "\\TLVL");

	ut_asserteq(METHOD_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq_strn("_TPC", (char *)ptr);
	ptr += 4;
	ut_asserteq(0, *ptr++);
	ut_asserteq(RETURN_OP, *ptr++);
	ut_asserteq_strn("\\TLVL", (char *)ptr);
	ptr += 5;

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_tpc, 0);

/* Test acpigen_write_pss_package(), etc. */
static int dm_test_acpi_write_pss_psd(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_pss_package(ctx, 1, 2, 3, 4, 5, 6);
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(6, *ptr++);

	ut_asserteq(DWORD_PREFIX, *ptr++);
	ut_asserteq(1, get_unaligned((u32 *)ptr));
	ptr += 5;

	ut_asserteq(2, get_unaligned((u32 *)ptr));
	ptr += 5;

	ut_asserteq(3, get_unaligned((u32 *)ptr));
	ptr += 5;

	ut_asserteq(4, get_unaligned((u32 *)ptr));
	ptr += 5;

	ut_asserteq(5, get_unaligned((u32 *)ptr));
	ptr += 5;

	ut_asserteq(6, get_unaligned((u32 *)ptr));
	ptr += 4;

	acpigen_write_psd_package(ctx, 6, 7, HW_ALL);
	ut_asserteq(NAME_OP, *ptr++);
	ut_asserteq_strn("_PSD", (char *)ptr);
	ptr += 4;
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(1, *ptr++);
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(5, *ptr++);

	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(5, *ptr++);
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(0, *ptr++);

	ut_asserteq(DWORD_PREFIX, *ptr++);
	ut_asserteq(6, get_unaligned((u32 *)ptr));
	ptr += 5;

	ut_asserteq(HW_ALL, get_unaligned((u32 *)ptr));
	ptr += 5;

	ut_asserteq(7, get_unaligned((u32 *)ptr));
	ptr += 4;

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_pss_psd, 0);

/* Test acpi_write_cst_package() */
static int dm_test_acpi_write_cst(struct unit_test_state *uts)
{
	static struct acpi_cstate cstate_map[] = {
		{
			/* C1 */
			.ctype = 1,		/* ACPI C1 */
			.latency = 1,
			.power = 1000,
			.resource = {
				.space_id = ACPI_ADDRESS_SPACE_FIXED,
			},
		}, {
			.ctype = 2,		/* ACPI C2 */
			.latency = 50,
			.power = 10,
			.resource = {
				.space_id = ACPI_ADDRESS_SPACE_IO,
				.bit_width = 8,
				.addrl = 0x415,
			},
		},
	};
	int nentries = ARRAY_SIZE(cstate_map);
	struct acpi_ctx *ctx;
	u8 *ptr;
	int i;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_cst_package(ctx, cstate_map, nentries);

	ut_asserteq(NAME_OP, *ptr++);
	ut_asserteq_strn("_CST", (char *)ptr);
	ptr += 4;
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(nentries + 1, *ptr++);
	ut_asserteq(DWORD_PREFIX, *ptr++);
	ut_asserteq(nentries, get_unaligned((u32 *)ptr));
	ptr += 4;

	for (i = 0; i < nentries; i++) {
		ut_asserteq(PACKAGE_OP, *ptr++);
		ptr += 3;  /* skip length */
		ut_asserteq(4, *ptr++);
		ut_asserteq(BUFFER_OP, *ptr++);
		ptr += 0x17;
		ut_asserteq(DWORD_PREFIX, *ptr++);
		ut_asserteq(cstate_map[i].ctype, get_unaligned((u32 *)ptr));
		ptr += 5;
		ut_asserteq(cstate_map[i].latency, get_unaligned((u32 *)ptr));
		ptr += 5;
		ut_asserteq(cstate_map[i].power, get_unaligned((u32 *)ptr));
		ptr += 4;
	}

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_cst, 0);

/* Test acpi_write_cst_package() */
static int dm_test_acpi_write_csd(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_csd_package(ctx, 12, 34, CSD_HW_ALL, 56);

	ut_asserteq(NAME_OP, *ptr++);
	ut_asserteq_strn("_CSD", (char *)ptr);
	ptr += 4;
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(1, *ptr++);
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(6, *ptr++);

	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(6, *ptr++);
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(0, *ptr++);
	ut_asserteq(DWORD_PREFIX, *ptr++);
	ut_asserteq(12, get_unaligned((u32 *)ptr));
	ptr += 5;
	ut_asserteq(CSD_HW_ALL, get_unaligned((u32 *)ptr));
	ptr += 5;
	ut_asserteq(34, get_unaligned((u32 *)ptr));
	ptr += 5;
	ut_asserteq(56, get_unaligned((u32 *)ptr));
	ptr += 4;

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_csd, 0);

/* Test acpigen_write_tss_package() */
static int dm_test_acpi_write_tss(struct unit_test_state *uts)
{
	static struct acpi_tstate tstate_list[] = {
		{ 1, 2, 3, 4, 5, },
		{ 6, 7, 8, 9, 10, },
	};
	int nentries = ARRAY_SIZE(tstate_list);
	struct acpi_ctx *ctx;
	u8 *ptr;
	int i;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_tss_package(ctx, tstate_list, nentries);

	ut_asserteq(NAME_OP, *ptr++);
	ut_asserteq_strn("_TSS", (char *)ptr);
	ptr += 4;
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(nentries, *ptr++);

	for (i = 0; i < nentries; i++) {
		ut_asserteq(PACKAGE_OP, *ptr++);
		ptr += 3;  /* skip length */
		ut_asserteq(5, *ptr++);
		ut_asserteq(DWORD_PREFIX, *ptr++);
		ut_asserteq(tstate_list[i].percent, get_unaligned((u32 *)ptr));
		ptr += 5;
		ut_asserteq(tstate_list[i].power, get_unaligned((u32 *)ptr));
		ptr += 5;
		ut_asserteq(tstate_list[i].latency, get_unaligned((u32 *)ptr));
		ptr += 5;
		ut_asserteq(tstate_list[i].control, get_unaligned((u32 *)ptr));
		ptr += 5;
		ut_asserteq(tstate_list[i].status, get_unaligned((u32 *)ptr));
		ptr += 4;
	}

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_tss, 0);

/* Test acpigen_write_tsd_package() */
static int dm_test_acpi_write_tsd_package(struct unit_test_state *uts)
{
	struct acpi_ctx *ctx;
	u8 *ptr;

	ut_assertok(alloc_context(&ctx));

	ptr = acpigen_get_current(ctx);
	acpigen_write_tsd_package(ctx, 12, 34, HW_ALL);

	ut_asserteq(NAME_OP, *ptr++);
	ut_asserteq_strn("_TSD", (char *)ptr);
	ptr += 4;
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(1, *ptr++);
	ut_asserteq(PACKAGE_OP, *ptr++);
	ptr += 3;  /* skip length */
	ut_asserteq(5, *ptr++);

	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(5, *ptr++);
	ut_asserteq(BYTE_PREFIX, *ptr++);
	ut_asserteq(0, *ptr++);
	ut_asserteq(DWORD_PREFIX, *ptr++);
	ut_asserteq(12, get_unaligned((u32 *)ptr));
	ptr += 5;
	ut_asserteq(CSD_HW_ALL, get_unaligned((u32 *)ptr));
	ptr += 5;
	ut_asserteq(34, get_unaligned((u32 *)ptr));
	ptr += 4;

	ut_asserteq_ptr(ptr, ctx->current);

	free_context(&ctx);

	return 0;
}
DM_TEST(dm_test_acpi_write_tsd_package, 0);
