#include <dm.h>
#include <log.h>
#include <malloc.h>
+#include <mapmem.h>
#include <acpi/acpi_device.h>
#include <dm/acpi.h>
#include <dm/device-internal.h>
TYPE_OTHER,
};
+const char *gen_type_str[] = {
+ "-",
+ "ssdt",
+ "dsdt",
+ "other",
+};
+
/* Type of method to call */
enum method_t {
METHOD_WRITE_TABLES,
* @dev: Device that generated this data
* @type: Table type it refers to
* @writer: Writer that wrote this table
- * @buf: Buffer containing the data
+ * @base: Pointer to base of table in its original location
+ * @buf: Buffer allocated to contain the data (NULL if not allocated)
* @size: Size of the data in bytes
*/
struct acpi_item {
struct udevice *dev;
const struct acpi_writer *writer;
enum gen_type_t type;
+ const char *base;
char *buf;
int size;
};
item->writer = writer;
item->type = type;
item->size = end - start;
+ item->base = start;
if (!item->size)
return 0;
if (type != TYPE_OTHER) {
{
int i;
+ printf("Seq Type Base Size Device/Writer\n");
+ printf("--- ----- -------- ---- -------------\n");
for (i = 0; i < item_count; i++) {
struct acpi_item *item = &acpi_item[i];
- printf("dev '%s', type %d, size %x\n", item->dev->name,
- item->type, item->size);
+ printf("%3x %-5s %8lx %5x %s\n", i,
+ gen_type_str[item->type],
+ (ulong)map_to_sysmem(item->base), item->size,
+ item->dev ? item->dev->name : item->writer->name);
if (option == ACPI_DUMP_CONTENTS) {
- print_buffer(0, item->buf, 1, item->size, 0);
+ print_buffer(0, item->buf ? item->buf : item->base, 1,
+ item->size, 0);
printf("\n");
}
}
static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
{
struct acpi_ctx ctx;
+ ulong addr;
void *buf;
buf = malloc(BUF_SIZE);
ut_assertnonnull(buf);
+ addr = map_to_sysmem(buf);
acpi_reset_items();
ctx.current = buf;
ut_assertok(acpi_fill_ssdt(&ctx));
console_record_reset();
run_command("acpi items", 0);
- ut_assert_nextline("dev 'acpi-test', type 1, size 2");
- ut_assert_nextline("dev 'acpi-test2', type 1, size 2");
+ ut_assert_nextline("Seq Type Base Size Device/Writer");
+ ut_assert_nextline("--- ----- -------- ---- -------------");
+ ut_assert_nextline(" 0 ssdt %8lx 2 acpi-test", addr);
+ ut_assert_nextline(" 1 ssdt %8lx 2 acpi-test2", addr + 2);
ut_assert_console_end();
acpi_reset_items();
ut_assertok(acpi_inject_dsdt(&ctx));
console_record_reset();
run_command("acpi items", 0);
- ut_assert_nextline("dev 'acpi-test', type 2, size 2");
- ut_assert_nextline("dev 'acpi-test2', type 2, size 2");
+ ut_assert_nextlinen("Seq");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 dsdt %8lx 2 acpi-test", addr);
+ ut_assert_nextline(" 1 dsdt %8lx 2 acpi-test2", addr + 2);
ut_assert_console_end();
console_record_reset();
run_command("acpi items -d", 0);
- ut_assert_nextline("dev 'acpi-test', type 2, size 2");
+ ut_assert_nextlinen("Seq");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 dsdt %8lx 2 acpi-test", addr);
ut_assert_nextlines_are_dump(2);
ut_assert_nextline("%s", "");
- ut_assert_nextline("dev 'acpi-test2', type 2, size 2");
+ ut_assert_nextline(" 1 dsdt %8lx 2 acpi-test2", addr + 2);
ut_assert_nextlines_are_dump(2);
ut_assert_nextline("%s", "");
ut_assert_console_end();