Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Tests for ACPI table generation |
| 4 | * |
| 5 | * Copyright 2019 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 10 | #include <console.h> |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 11 | #include <dm.h> |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 12 | #include <malloc.h> |
Simon Glass | 575a547 | 2020-04-26 09:19:50 -0600 | [diff] [blame] | 13 | #include <mapmem.h> |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 14 | #include <tables_csum.h> |
Simon Glass | 90b0127 | 2023-04-29 19:21:46 -0600 | [diff] [blame^] | 15 | #include <version_string.h> |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 16 | #include <acpi/acpigen.h> |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 17 | #include <acpi/acpi_device.h> |
Simon Glass | b2672ea | 2020-04-08 16:57:38 -0600 | [diff] [blame] | 18 | #include <acpi/acpi_table.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 19 | #include <asm/global_data.h> |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 20 | #include <dm/acpi.h> |
| 21 | #include <dm/test.h> |
| 22 | #include <test/ut.h> |
Simon Glass | 6fcdaf1 | 2020-07-07 21:32:10 -0600 | [diff] [blame] | 23 | #include "acpi.h" |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 24 | |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 25 | #define BUF_SIZE 4096 |
| 26 | |
Simon Glass | 90b0127 | 2023-04-29 19:21:46 -0600 | [diff] [blame^] | 27 | #define OEM_REVISION ((((version_num / 1000) % 10) << 28) | \ |
| 28 | (((version_num / 100) % 10) << 24) | \ |
| 29 | (((version_num / 10) % 10) << 20) | \ |
| 30 | ((version_num % 10) << 16) | \ |
| 31 | (((version_num_patch / 10) % 10) << 12) | \ |
| 32 | ((version_num_patch % 10) << 8) | \ |
Pali Rohár | f0de20e | 2021-07-10 13:10:01 +0200 | [diff] [blame] | 33 | 0x01) |
| 34 | |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 35 | /** |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 36 | * struct testacpi_plat - Platform data for the test ACPI device |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 37 | * |
| 38 | * @no_name: true to emit an empty ACPI name from testacpi_get_name() |
| 39 | * @return_error: true to return an error instead of a name |
| 40 | */ |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 41 | struct testacpi_plat { |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 42 | bool return_error; |
| 43 | bool no_name; |
| 44 | }; |
| 45 | |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 46 | /** |
| 47 | * setup_ctx_and_base_tables() - Set up context along with RSDP, RSDT and XSDT |
| 48 | * |
| 49 | * Set up the context with the given start position. Some basic tables are |
| 50 | * always needed, so set them up as well. |
| 51 | * |
| 52 | * @ctx: Context to set up |
| 53 | */ |
Simon Glass | e9f6e6a | 2021-12-01 09:02:50 -0700 | [diff] [blame] | 54 | static int setup_ctx_and_base_tables(struct unit_test_state *uts, |
| 55 | struct acpi_ctx *ctx, ulong start) |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 56 | { |
Simon Glass | e9f6e6a | 2021-12-01 09:02:50 -0700 | [diff] [blame] | 57 | struct acpi_writer *entry = ACPI_WRITER_GET(0base); |
| 58 | |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 59 | acpi_setup_ctx(ctx, start); |
Simon Glass | e9f6e6a | 2021-12-01 09:02:50 -0700 | [diff] [blame] | 60 | |
| 61 | ctx->tab_start = ctx->current; |
| 62 | ut_assertok(acpi_write_one(ctx, entry)); |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 63 | |
| 64 | return 0; |
| 65 | } |
| 66 | |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 67 | static int testacpi_write_tables(const struct udevice *dev, |
| 68 | struct acpi_ctx *ctx) |
| 69 | { |
| 70 | struct acpi_dmar *dmar; |
Simon Glass | 575a547 | 2020-04-26 09:19:50 -0600 | [diff] [blame] | 71 | int ret; |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 72 | |
| 73 | dmar = (struct acpi_dmar *)ctx->current; |
| 74 | acpi_create_dmar(dmar, DMAR_INTR_REMAP); |
| 75 | ctx->current += sizeof(struct acpi_dmar); |
Simon Glass | 575a547 | 2020-04-26 09:19:50 -0600 | [diff] [blame] | 76 | ret = acpi_add_table(ctx, dmar); |
| 77 | if (ret) |
| 78 | return log_msg_ret("add", ret); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 79 | |
| 80 | return 0; |
| 81 | } |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 82 | |
| 83 | static int testacpi_get_name(const struct udevice *dev, char *out_name) |
| 84 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 85 | struct testacpi_plat *plat = dev_get_plat(dev); |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 86 | |
| 87 | if (plat->return_error) |
| 88 | return -EINVAL; |
| 89 | if (plat->no_name) { |
| 90 | *out_name = '\0'; |
| 91 | return 0; |
| 92 | } |
| 93 | if (device_get_uclass_id(dev->parent) == UCLASS_TEST_ACPI) |
| 94 | return acpi_copy_name(out_name, ACPI_TEST_CHILD_NAME); |
| 95 | else |
| 96 | return acpi_copy_name(out_name, ACPI_TEST_DEV_NAME); |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 97 | } |
| 98 | |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 99 | static int testacpi_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) |
| 100 | { |
| 101 | const char *data; |
| 102 | |
| 103 | data = dev_read_string(dev, "acpi-ssdt-test-data"); |
| 104 | if (data) { |
| 105 | while (*data) |
| 106 | acpigen_emit_byte(ctx, *data++); |
| 107 | } |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 112 | static int testacpi_inject_dsdt(const struct udevice *dev, struct acpi_ctx *ctx) |
| 113 | { |
| 114 | const char *data; |
| 115 | |
| 116 | data = dev_read_string(dev, "acpi-dsdt-test-data"); |
| 117 | if (data) { |
| 118 | while (*data) |
| 119 | acpigen_emit_byte(ctx, *data++); |
| 120 | } |
| 121 | |
| 122 | return 0; |
| 123 | } |
| 124 | |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 125 | struct acpi_ops testacpi_ops = { |
| 126 | .get_name = testacpi_get_name, |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 127 | .write_tables = testacpi_write_tables, |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 128 | .fill_ssdt = testacpi_fill_ssdt, |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 129 | .inject_dsdt = testacpi_inject_dsdt, |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | static const struct udevice_id testacpi_ids[] = { |
| 133 | { .compatible = "denx,u-boot-acpi-test" }, |
| 134 | { } |
| 135 | }; |
| 136 | |
| 137 | U_BOOT_DRIVER(testacpi_drv) = { |
| 138 | .name = "testacpi_drv", |
| 139 | .of_match = testacpi_ids, |
| 140 | .id = UCLASS_TEST_ACPI, |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 141 | .bind = dm_scan_fdt_dev, |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 142 | .plat_auto = sizeof(struct testacpi_plat), |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 143 | ACPI_OPS_PTR(&testacpi_ops) |
| 144 | }; |
| 145 | |
| 146 | UCLASS_DRIVER(testacpi) = { |
| 147 | .name = "testacpi", |
| 148 | .id = UCLASS_TEST_ACPI, |
| 149 | }; |
| 150 | |
| 151 | /* Test ACPI get_name() */ |
| 152 | static int dm_test_acpi_get_name(struct unit_test_state *uts) |
| 153 | { |
| 154 | char name[ACPI_NAME_MAX]; |
Simon Glass | 9a65513 | 2020-12-16 21:20:23 -0700 | [diff] [blame] | 155 | struct udevice *dev, *dev2, *i2c, *spi, *timer, *sound; |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 156 | struct udevice *pci, *root; |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 157 | |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 158 | /* Test getting the name from the driver */ |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 159 | ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev)); |
| 160 | ut_assertok(acpi_get_name(dev, name)); |
| 161 | ut_asserteq_str(ACPI_TEST_DEV_NAME, name); |
| 162 | |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 163 | /* Test getting the name from the device tree */ |
| 164 | ut_assertok(uclass_get_device_by_name(UCLASS_TEST_FDT, "a-test", |
| 165 | &dev2)); |
| 166 | ut_assertok(acpi_get_name(dev2, name)); |
| 167 | ut_asserteq_str("GHIJ", name); |
| 168 | |
| 169 | /* Test getting the name from acpi_device_get_name() */ |
Michal Suchanek | ac12a2f | 2022-10-12 21:57:59 +0200 | [diff] [blame] | 170 | ut_assertok(uclass_first_device_err(UCLASS_I2C, &i2c)); |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 171 | ut_assertok(acpi_get_name(i2c, name)); |
| 172 | ut_asserteq_str("I2C0", name); |
| 173 | |
Michal Suchanek | ac12a2f | 2022-10-12 21:57:59 +0200 | [diff] [blame] | 174 | ut_assertok(uclass_first_device_err(UCLASS_SPI, &spi)); |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 175 | ut_assertok(acpi_get_name(spi, name)); |
| 176 | ut_asserteq_str("SPI0", name); |
| 177 | |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 178 | /* ACPI doesn't know about the timer */ |
Michal Suchanek | ac12a2f | 2022-10-12 21:57:59 +0200 | [diff] [blame] | 179 | ut_assertok(uclass_first_device_err(UCLASS_TIMER, &timer)); |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 180 | ut_asserteq(-ENOENT, acpi_get_name(timer, name)); |
| 181 | |
| 182 | /* May as well test the rest of the cases */ |
Michal Suchanek | ac12a2f | 2022-10-12 21:57:59 +0200 | [diff] [blame] | 183 | ut_assertok(uclass_first_device_err(UCLASS_SOUND, &sound)); |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 184 | ut_assertok(acpi_get_name(sound, name)); |
| 185 | ut_asserteq_str("HDAS", name); |
| 186 | |
Michal Suchanek | ac12a2f | 2022-10-12 21:57:59 +0200 | [diff] [blame] | 187 | ut_assertok(uclass_first_device_err(UCLASS_PCI, &pci)); |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 188 | ut_assertok(acpi_get_name(pci, name)); |
| 189 | ut_asserteq_str("PCI0", name); |
| 190 | |
Michal Suchanek | ac12a2f | 2022-10-12 21:57:59 +0200 | [diff] [blame] | 191 | ut_assertok(uclass_first_device_err(UCLASS_ROOT, &root)); |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 192 | ut_assertok(acpi_get_name(root, name)); |
| 193 | ut_asserteq_str("\\_SB", name); |
| 194 | |
| 195 | /* Note that we don't have tests for acpi_name_from_id() */ |
| 196 | |
Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame] | 197 | return 0; |
| 198 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 199 | DM_TEST(dm_test_acpi_get_name, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | b2672ea | 2020-04-08 16:57:38 -0600 | [diff] [blame] | 200 | |
| 201 | /* Test acpi_get_table_revision() */ |
| 202 | static int dm_test_acpi_get_table_revision(struct unit_test_state *uts) |
| 203 | { |
| 204 | ut_asserteq(1, acpi_get_table_revision(ACPITAB_MCFG)); |
| 205 | ut_asserteq(2, acpi_get_table_revision(ACPITAB_RSDP)); |
| 206 | ut_asserteq(4, acpi_get_table_revision(ACPITAB_TPM2)); |
| 207 | ut_asserteq(-EINVAL, acpi_get_table_revision(ACPITAB_COUNT)); |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | DM_TEST(dm_test_acpi_get_table_revision, |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 212 | UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | e962989 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 213 | |
Simon Glass | e962989 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 214 | /* Test acpi_create_dmar() */ |
| 215 | static int dm_test_acpi_create_dmar(struct unit_test_state *uts) |
| 216 | { |
| 217 | struct acpi_dmar dmar; |
Heinrich Schuchardt | 6c2a871 | 2020-07-17 00:20:14 +0200 | [diff] [blame] | 218 | struct udevice *cpu; |
Simon Glass | e962989 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 219 | |
Michal Suchanek | ac12a2f | 2022-10-12 21:57:59 +0200 | [diff] [blame] | 220 | ut_assertok(uclass_first_device_err(UCLASS_CPU, &cpu)); |
Heinrich Schuchardt | 6c2a871 | 2020-07-17 00:20:14 +0200 | [diff] [blame] | 221 | ut_assertnonnull(cpu); |
Simon Glass | e962989 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 222 | ut_assertok(acpi_create_dmar(&dmar, DMAR_INTR_REMAP)); |
| 223 | ut_asserteq(DMAR_INTR_REMAP, dmar.flags); |
| 224 | ut_asserteq(32 - 1, dmar.host_address_width); |
| 225 | |
| 226 | return 0; |
| 227 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 228 | DM_TEST(dm_test_acpi_create_dmar, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 229 | |
| 230 | /* Test acpi_fill_header() */ |
| 231 | static int dm_test_acpi_fill_header(struct unit_test_state *uts) |
| 232 | { |
| 233 | struct acpi_table_header hdr; |
| 234 | |
| 235 | /* Make sure these 5 fields are not changed */ |
| 236 | hdr.length = 0x11; |
| 237 | hdr.revision = 0x22; |
| 238 | hdr.checksum = 0x33; |
| 239 | hdr.aslc_revision = 0x44; |
| 240 | acpi_fill_header(&hdr, "ABCD"); |
| 241 | |
| 242 | ut_asserteq_mem("ABCD", hdr.signature, sizeof(hdr.signature)); |
| 243 | ut_asserteq(0x11, hdr.length); |
| 244 | ut_asserteq(0x22, hdr.revision); |
| 245 | ut_asserteq(0x33, hdr.checksum); |
| 246 | ut_asserteq_mem(OEM_ID, hdr.oem_id, sizeof(hdr.oem_id)); |
| 247 | ut_asserteq_mem(OEM_TABLE_ID, hdr.oem_table_id, |
| 248 | sizeof(hdr.oem_table_id)); |
Pali Rohár | f0de20e | 2021-07-10 13:10:01 +0200 | [diff] [blame] | 249 | ut_asserteq(OEM_REVISION, hdr.oem_revision); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 250 | ut_asserteq_mem(ASLC_ID, hdr.aslc_id, sizeof(hdr.aslc_id)); |
| 251 | ut_asserteq(0x44, hdr.aslc_revision); |
| 252 | |
| 253 | return 0; |
| 254 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 255 | DM_TEST(dm_test_acpi_fill_header, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 256 | |
| 257 | /* Test ACPI write_tables() */ |
| 258 | static int dm_test_acpi_write_tables(struct unit_test_state *uts) |
| 259 | { |
| 260 | struct acpi_dmar *dmar; |
| 261 | struct acpi_ctx ctx; |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 262 | ulong addr; |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 263 | void *buf; |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 264 | int i; |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 265 | |
| 266 | buf = malloc(BUF_SIZE); |
| 267 | ut_assertnonnull(buf); |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 268 | addr = map_to_sysmem(buf); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 269 | |
Simon Glass | e9f6e6a | 2021-12-01 09:02:50 -0700 | [diff] [blame] | 270 | ut_assertok(setup_ctx_and_base_tables(uts, &ctx, addr)); |
Simon Glass | 575a547 | 2020-04-26 09:19:50 -0600 | [diff] [blame] | 271 | dmar = ctx.current; |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 272 | ut_assertok(acpi_write_dev_tables(&ctx)); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 273 | |
| 274 | /* |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 275 | * We should have three dmar tables, one for each |
| 276 | * "denx,u-boot-acpi-test" device |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 277 | */ |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 278 | ut_asserteq_ptr(dmar + 3, ctx.current); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 279 | ut_asserteq(DMAR_INTR_REMAP, dmar->flags); |
| 280 | ut_asserteq(32 - 1, dmar->host_address_width); |
| 281 | |
| 282 | ut_asserteq(DMAR_INTR_REMAP, dmar[1].flags); |
| 283 | ut_asserteq(32 - 1, dmar[1].host_address_width); |
| 284 | |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 285 | ut_asserteq(DMAR_INTR_REMAP, dmar[2].flags); |
| 286 | ut_asserteq(32 - 1, dmar[2].host_address_width); |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 287 | |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 288 | /* Check that the pointers were added correctly */ |
| 289 | for (i = 0; i < 3; i++) { |
| 290 | ut_asserteq(map_to_sysmem(dmar + i), ctx.rsdt->entry[i]); |
| 291 | ut_asserteq(map_to_sysmem(dmar + i), ctx.xsdt->entry[i]); |
| 292 | } |
| 293 | ut_asserteq(0, ctx.rsdt->entry[3]); |
| 294 | ut_asserteq(0, ctx.xsdt->entry[3]); |
Simon Glass | abeaca8 | 2020-04-26 09:19:52 -0600 | [diff] [blame] | 295 | |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 296 | return 0; |
| 297 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 298 | DM_TEST(dm_test_acpi_write_tables, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | 0e11384 | 2020-04-26 09:19:47 -0600 | [diff] [blame] | 299 | |
| 300 | /* Test basic ACPI functions */ |
| 301 | static int dm_test_acpi_basic(struct unit_test_state *uts) |
| 302 | { |
| 303 | struct acpi_ctx ctx; |
| 304 | |
| 305 | /* Check align works */ |
| 306 | ctx.current = (void *)5; |
| 307 | acpi_align(&ctx); |
| 308 | ut_asserteq_ptr((void *)16, ctx.current); |
| 309 | |
| 310 | /* Check that align does nothing if already aligned */ |
| 311 | acpi_align(&ctx); |
| 312 | ut_asserteq_ptr((void *)16, ctx.current); |
| 313 | acpi_align64(&ctx); |
| 314 | ut_asserteq_ptr((void *)64, ctx.current); |
| 315 | acpi_align64(&ctx); |
| 316 | ut_asserteq_ptr((void *)64, ctx.current); |
| 317 | |
| 318 | /* Check incrementing */ |
| 319 | acpi_inc(&ctx, 3); |
| 320 | ut_asserteq_ptr((void *)67, ctx.current); |
| 321 | acpi_inc_align(&ctx, 3); |
| 322 | ut_asserteq_ptr((void *)80, ctx.current); |
| 323 | |
| 324 | return 0; |
| 325 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 326 | DM_TEST(dm_test_acpi_basic, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 327 | |
Simon Glass | 1617088 | 2021-12-01 09:02:49 -0700 | [diff] [blame] | 328 | /* Test setup_ctx_and_base_tables */ |
| 329 | static int dm_test_setup_ctx_and_base_tables(struct unit_test_state *uts) |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 330 | { |
| 331 | struct acpi_rsdp *rsdp; |
| 332 | struct acpi_rsdt *rsdt; |
| 333 | struct acpi_xsdt *xsdt; |
| 334 | struct acpi_ctx ctx; |
| 335 | void *buf, *end; |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 336 | ulong addr; |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 337 | |
| 338 | /* |
| 339 | * Use an unaligned address deliberately, by allocating an aligned |
| 340 | * address and then adding 4 to it |
| 341 | */ |
| 342 | buf = memalign(64, BUF_SIZE); |
| 343 | ut_assertnonnull(buf); |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 344 | addr = map_to_sysmem(buf); |
Simon Glass | e9f6e6a | 2021-12-01 09:02:50 -0700 | [diff] [blame] | 345 | ut_assertok(setup_ctx_and_base_tables(uts, &ctx, addr + 4)); |
Simon Glass | b33f2f9 | 2021-12-01 09:02:37 -0700 | [diff] [blame] | 346 | ut_asserteq(map_to_sysmem(PTR_ALIGN(buf + 4, 16)), gd_acpi_start()); |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 347 | |
| 348 | rsdp = buf + 16; |
| 349 | ut_asserteq_ptr(rsdp, ctx.rsdp); |
Simon Glass | a3186e6 | 2020-05-10 12:52:45 -0600 | [diff] [blame] | 350 | ut_asserteq_mem(RSDP_SIG, rsdp->signature, sizeof(rsdp->signature)); |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 351 | ut_asserteq(sizeof(*rsdp), rsdp->length); |
| 352 | ut_assertok(table_compute_checksum(rsdp, 20)); |
| 353 | ut_assertok(table_compute_checksum(rsdp, sizeof(*rsdp))); |
| 354 | |
| 355 | rsdt = PTR_ALIGN((void *)rsdp + sizeof(*rsdp), 16); |
| 356 | ut_asserteq_ptr(rsdt, ctx.rsdt); |
Simon Glass | a3186e6 | 2020-05-10 12:52:45 -0600 | [diff] [blame] | 357 | ut_asserteq_mem("RSDT", rsdt->header.signature, ACPI_NAME_LEN); |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 358 | ut_asserteq(sizeof(*rsdt), rsdt->header.length); |
| 359 | ut_assertok(table_compute_checksum(rsdt, sizeof(*rsdt))); |
| 360 | |
| 361 | xsdt = PTR_ALIGN((void *)rsdt + sizeof(*rsdt), 16); |
Simon Glass | abeaca8 | 2020-04-26 09:19:52 -0600 | [diff] [blame] | 362 | ut_asserteq_ptr(xsdt, ctx.xsdt); |
Simon Glass | a3186e6 | 2020-05-10 12:52:45 -0600 | [diff] [blame] | 363 | ut_asserteq_mem("XSDT", xsdt->header.signature, ACPI_NAME_LEN); |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 364 | ut_asserteq(sizeof(*xsdt), xsdt->header.length); |
| 365 | ut_assertok(table_compute_checksum(xsdt, sizeof(*xsdt))); |
| 366 | |
| 367 | end = PTR_ALIGN((void *)xsdt + sizeof(*xsdt), 64); |
| 368 | ut_asserteq_ptr(end, ctx.current); |
| 369 | |
| 370 | ut_asserteq(map_to_sysmem(rsdt), rsdp->rsdt_address); |
| 371 | ut_asserteq(map_to_sysmem(xsdt), rsdp->xsdt_address); |
| 372 | |
| 373 | return 0; |
| 374 | } |
Simon Glass | 1617088 | 2021-12-01 09:02:49 -0700 | [diff] [blame] | 375 | DM_TEST(dm_test_setup_ctx_and_base_tables, |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 376 | UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 377 | |
| 378 | /* Test 'acpi list' command */ |
| 379 | static int dm_test_acpi_cmd_list(struct unit_test_state *uts) |
| 380 | { |
| 381 | struct acpi_ctx ctx; |
| 382 | ulong addr; |
| 383 | void *buf; |
| 384 | |
| 385 | buf = memalign(16, BUF_SIZE); |
| 386 | ut_assertnonnull(buf); |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 387 | addr = map_to_sysmem(buf); |
Simon Glass | e9f6e6a | 2021-12-01 09:02:50 -0700 | [diff] [blame] | 388 | ut_assertok(setup_ctx_and_base_tables(uts, &ctx, addr)); |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 389 | |
| 390 | ut_assertok(acpi_write_dev_tables(&ctx)); |
| 391 | |
| 392 | console_record_reset(); |
| 393 | run_command("acpi list", 0); |
Simon Glass | eb025f3 | 2021-12-01 09:03:06 -0700 | [diff] [blame] | 394 | ut_assert_nextline("Name Base Size Detail"); |
| 395 | ut_assert_nextline("---- -------- ----- ------"); |
| 396 | ut_assert_nextline("RSDP %08lx %5zx v02 U-BOOT", addr, |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 397 | sizeof(struct acpi_rsdp)); |
| 398 | addr = ALIGN(addr + sizeof(struct acpi_rsdp), 16); |
Simon Glass | eb025f3 | 2021-12-01 09:03:06 -0700 | [diff] [blame] | 399 | ut_assert_nextline("RSDT %08lx %5zx v01 U-BOOT U-BOOTBL %x INTL 0", |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 400 | addr, sizeof(struct acpi_table_header) + |
Pali Rohár | f0de20e | 2021-07-10 13:10:01 +0200 | [diff] [blame] | 401 | 3 * sizeof(u32), OEM_REVISION); |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 402 | addr = ALIGN(addr + sizeof(struct acpi_rsdt), 16); |
Simon Glass | eb025f3 | 2021-12-01 09:03:06 -0700 | [diff] [blame] | 403 | ut_assert_nextline("XSDT %08lx %5zx v01 U-BOOT U-BOOTBL %x INTL 0", |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 404 | addr, sizeof(struct acpi_table_header) + |
Pali Rohár | f0de20e | 2021-07-10 13:10:01 +0200 | [diff] [blame] | 405 | 3 * sizeof(u64), OEM_REVISION); |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 406 | addr = ALIGN(addr + sizeof(struct acpi_xsdt), 64); |
Simon Glass | eb025f3 | 2021-12-01 09:03:06 -0700 | [diff] [blame] | 407 | ut_assert_nextline("DMAR %08lx %5zx v01 U-BOOT U-BOOTBL %x INTL 0", |
Pali Rohár | f0de20e | 2021-07-10 13:10:01 +0200 | [diff] [blame] | 408 | addr, sizeof(struct acpi_dmar), OEM_REVISION); |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 409 | addr = ALIGN(addr + sizeof(struct acpi_dmar), 16); |
Simon Glass | eb025f3 | 2021-12-01 09:03:06 -0700 | [diff] [blame] | 410 | ut_assert_nextline("DMAR %08lx %5zx v01 U-BOOT U-BOOTBL %x INTL 0", |
Pali Rohár | f0de20e | 2021-07-10 13:10:01 +0200 | [diff] [blame] | 411 | addr, sizeof(struct acpi_dmar), OEM_REVISION); |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 412 | addr = ALIGN(addr + sizeof(struct acpi_dmar), 16); |
Simon Glass | eb025f3 | 2021-12-01 09:03:06 -0700 | [diff] [blame] | 413 | ut_assert_nextline("DMAR %08lx %5zx v01 U-BOOT U-BOOTBL %x INTL 0", |
Pali Rohár | f0de20e | 2021-07-10 13:10:01 +0200 | [diff] [blame] | 414 | addr, sizeof(struct acpi_dmar), OEM_REVISION); |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 415 | ut_assert_console_end(); |
| 416 | |
| 417 | return 0; |
| 418 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 419 | DM_TEST(dm_test_acpi_cmd_list, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 420 | |
| 421 | /* Test 'acpi dump' command */ |
| 422 | static int dm_test_acpi_cmd_dump(struct unit_test_state *uts) |
| 423 | { |
| 424 | struct acpi_ctx ctx; |
| 425 | ulong addr; |
| 426 | void *buf; |
| 427 | |
| 428 | buf = memalign(16, BUF_SIZE); |
| 429 | ut_assertnonnull(buf); |
Simon Glass | 37acc66 | 2021-12-01 09:02:48 -0700 | [diff] [blame] | 430 | addr = map_to_sysmem(buf); |
Simon Glass | e9f6e6a | 2021-12-01 09:02:50 -0700 | [diff] [blame] | 431 | ut_assertok(setup_ctx_and_base_tables(uts, &ctx, addr)); |
Simon Glass | faf08c7 | 2020-04-26 09:19:53 -0600 | [diff] [blame] | 432 | |
| 433 | ut_assertok(acpi_write_dev_tables(&ctx)); |
| 434 | |
| 435 | /* First search for a non-existent table */ |
| 436 | console_record_reset(); |
| 437 | run_command("acpi dump rdst", 0); |
| 438 | ut_assert_nextline("Table 'RDST' not found"); |
| 439 | ut_assert_console_end(); |
| 440 | |
| 441 | /* Now a real table */ |
| 442 | console_record_reset(); |
| 443 | run_command("acpi dump dmar", 0); |
| 444 | addr = ALIGN(map_to_sysmem(ctx.xsdt) + sizeof(struct acpi_xsdt), 64); |
| 445 | ut_assert_nextline("DMAR @ %08lx", addr); |
| 446 | ut_assert_nextlines_are_dump(0x30); |
| 447 | ut_assert_console_end(); |
| 448 | |
| 449 | return 0; |
| 450 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 451 | DM_TEST(dm_test_acpi_cmd_dump, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 452 | |
| 453 | /* Test acpi_device_path() */ |
| 454 | static int dm_test_acpi_device_path(struct unit_test_state *uts) |
| 455 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 456 | struct testacpi_plat *plat; |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 457 | char buf[ACPI_PATH_MAX]; |
| 458 | struct udevice *dev, *child; |
| 459 | |
| 460 | ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev)); |
| 461 | ut_assertok(acpi_device_path(dev, buf, sizeof(buf))); |
| 462 | ut_asserteq_str("\\_SB." ACPI_TEST_DEV_NAME, buf); |
| 463 | |
| 464 | /* Test running out of space */ |
| 465 | buf[5] = '\0'; |
| 466 | ut_asserteq(-ENOSPC, acpi_device_path(dev, buf, 5)); |
| 467 | ut_asserteq('\0', buf[5]); |
| 468 | |
| 469 | /* Test a three-component name */ |
| 470 | ut_assertok(device_first_child_err(dev, &child)); |
| 471 | ut_assertok(acpi_device_path(child, buf, sizeof(buf))); |
| 472 | ut_asserteq_str("\\_SB." ACPI_TEST_DEV_NAME "." ACPI_TEST_CHILD_NAME, |
| 473 | buf); |
| 474 | |
| 475 | /* Test handling of a device which doesn't produce a name */ |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 476 | plat = dev_get_plat(dev); |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 477 | plat->no_name = true; |
| 478 | ut_assertok(acpi_device_path(child, buf, sizeof(buf))); |
| 479 | ut_asserteq_str("\\_SB." ACPI_TEST_CHILD_NAME, buf); |
| 480 | |
| 481 | /* Test handling of a device which returns an error */ |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 482 | plat = dev_get_plat(dev); |
Simon Glass | ebb2e83 | 2020-07-07 13:11:39 -0600 | [diff] [blame] | 483 | plat->return_error = true; |
| 484 | ut_asserteq(-EINVAL, acpi_device_path(child, buf, sizeof(buf))); |
| 485 | |
| 486 | return 0; |
| 487 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 488 | DM_TEST(dm_test_acpi_device_path, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | 8965cc9 | 2020-07-07 13:11:40 -0600 | [diff] [blame] | 489 | |
| 490 | /* Test acpi_device_status() */ |
| 491 | static int dm_test_acpi_device_status(struct unit_test_state *uts) |
| 492 | { |
| 493 | struct udevice *dev; |
| 494 | |
| 495 | ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev)); |
| 496 | ut_asserteq(ACPI_DSTATUS_ALL_ON, acpi_device_status(dev)); |
| 497 | |
| 498 | return 0; |
| 499 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 500 | DM_TEST(dm_test_acpi_device_status, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 501 | |
| 502 | /* Test acpi_fill_ssdt() */ |
| 503 | static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts) |
| 504 | { |
| 505 | struct acpi_ctx ctx; |
| 506 | u8 *buf; |
| 507 | |
| 508 | buf = malloc(BUF_SIZE); |
| 509 | ut_assertnonnull(buf); |
| 510 | |
Simon Glass | a385d49 | 2020-11-04 09:57:33 -0700 | [diff] [blame] | 511 | acpi_reset_items(); |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 512 | ctx.current = buf; |
| 513 | buf[4] = 'z'; /* sentinel */ |
| 514 | ut_assertok(acpi_fill_ssdt(&ctx)); |
| 515 | |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 516 | /* |
| 517 | * These values come from acpi-test2's acpi-ssdt-test-data property. |
| 518 | * This device comes first because of u-boot,acpi-ssdt-order |
| 519 | */ |
| 520 | ut_asserteq('c', buf[0]); |
| 521 | ut_asserteq('d', buf[1]); |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 522 | |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 523 | /* These values come from acpi-test's acpi-ssdt-test-data property */ |
| 524 | ut_asserteq('a', buf[2]); |
| 525 | ut_asserteq('b', buf[3]); |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 526 | |
| 527 | ut_asserteq('z', buf[4]); |
| 528 | |
| 529 | return 0; |
| 530 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 531 | DM_TEST(dm_test_acpi_fill_ssdt, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 532 | |
| 533 | /* Test acpi_inject_dsdt() */ |
| 534 | static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts) |
| 535 | { |
| 536 | struct acpi_ctx ctx; |
| 537 | u8 *buf; |
| 538 | |
| 539 | buf = malloc(BUF_SIZE); |
| 540 | ut_assertnonnull(buf); |
| 541 | |
Simon Glass | a385d49 | 2020-11-04 09:57:33 -0700 | [diff] [blame] | 542 | acpi_reset_items(); |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 543 | ctx.current = buf; |
| 544 | buf[4] = 'z'; /* sentinel */ |
| 545 | ut_assertok(acpi_inject_dsdt(&ctx)); |
| 546 | |
| 547 | /* |
| 548 | * These values come from acpi-test's acpi-dsdt-test-data property. |
| 549 | * There is no u-boot,acpi-dsdt-order so device-tree order is used. |
| 550 | */ |
| 551 | ut_asserteq('h', buf[0]); |
| 552 | ut_asserteq('i', buf[1]); |
| 553 | |
| 554 | /* These values come from acpi-test's acpi-dsdt-test-data property */ |
| 555 | ut_asserteq('j', buf[2]); |
| 556 | ut_asserteq('k', buf[3]); |
| 557 | |
| 558 | ut_asserteq('z', buf[4]); |
| 559 | |
| 560 | return 0; |
| 561 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 562 | DM_TEST(dm_test_acpi_inject_dsdt, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 563 | |
| 564 | /* Test 'acpi items' command */ |
| 565 | static int dm_test_acpi_cmd_items(struct unit_test_state *uts) |
| 566 | { |
| 567 | struct acpi_ctx ctx; |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 568 | ulong addr; |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 569 | void *buf; |
| 570 | |
| 571 | buf = malloc(BUF_SIZE); |
| 572 | ut_assertnonnull(buf); |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 573 | addr = map_to_sysmem(buf); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 574 | |
Simon Glass | a385d49 | 2020-11-04 09:57:33 -0700 | [diff] [blame] | 575 | acpi_reset_items(); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 576 | ctx.current = buf; |
| 577 | ut_assertok(acpi_fill_ssdt(&ctx)); |
| 578 | console_record_reset(); |
| 579 | run_command("acpi items", 0); |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 580 | ut_assert_nextline("Seq Type Base Size Device/Writer"); |
| 581 | ut_assert_nextline("--- ----- -------- ---- -------------"); |
| 582 | ut_assert_nextline(" 0 ssdt %8lx 2 acpi-test", addr); |
| 583 | ut_assert_nextline(" 1 ssdt %8lx 2 acpi-test2", addr + 2); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 584 | ut_assert_console_end(); |
| 585 | |
Simon Glass | a385d49 | 2020-11-04 09:57:33 -0700 | [diff] [blame] | 586 | acpi_reset_items(); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 587 | ctx.current = buf; |
| 588 | ut_assertok(acpi_inject_dsdt(&ctx)); |
| 589 | console_record_reset(); |
| 590 | run_command("acpi items", 0); |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 591 | ut_assert_nextlinen("Seq"); |
| 592 | ut_assert_nextlinen("---"); |
| 593 | ut_assert_nextline(" 0 dsdt %8lx 2 acpi-test", addr); |
| 594 | ut_assert_nextline(" 1 dsdt %8lx 2 acpi-test2", addr + 2); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 595 | ut_assert_console_end(); |
| 596 | |
| 597 | console_record_reset(); |
| 598 | run_command("acpi items -d", 0); |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 599 | ut_assert_nextlinen("Seq"); |
| 600 | ut_assert_nextlinen("---"); |
| 601 | ut_assert_nextline(" 0 dsdt %8lx 2 acpi-test", addr); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 602 | ut_assert_nextlines_are_dump(2); |
| 603 | ut_assert_nextline("%s", ""); |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 604 | ut_assert_nextline(" 1 dsdt %8lx 2 acpi-test2", addr + 2); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 605 | ut_assert_nextlines_are_dump(2); |
| 606 | ut_assert_nextline("%s", ""); |
| 607 | ut_assert_console_end(); |
| 608 | |
| 609 | return 0; |
| 610 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 611 | DM_TEST(dm_test_acpi_cmd_items, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |