summaryrefslogtreecommitdiff
path: root/test/dm
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2025-12-08 13:17:27 -0600
committerTom Rini <[email protected]>2025-12-08 13:17:27 -0600
commit59202e5ae76ef3acb34c4236e43248f1cd3fc642 (patch)
tree30004ced6a059b2c25afb0aca8b049908c2212c3 /test/dm
parent8e12d6ccb3cfa84dd275a1b852b2a235de0162b0 (diff)
parent0e0a198a68be71148f5ec27ef86796174f91436f (diff)
Merge tag 'v2026.01-rc4' into next
Prepare v2026.01-rc4
Diffstat (limited to 'test/dm')
-rw-r--r--test/dm/fdtdec.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c
index 1f24f1d5dff..ea5a494612c 100644
--- a/test/dm/fdtdec.c
+++ b/test/dm/fdtdec.c
@@ -7,6 +7,9 @@
#include <asm/global_data.h>
#include <dm/of_extra.h>
#include <dm/test.h>
+#include <fdt_support.h>
+#include <mapmem.h>
+#include <smbios.h>
#include <test/ut.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -129,3 +132,48 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
}
DM_TEST(dm_test_fdtdec_add_reserved_memory,
UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_FLAT_TREE);
+
+static int dm_test_fdt_chosen_smbios(struct unit_test_state *uts)
+{
+ void *blob;
+ ulong val;
+ struct smbios3_entry *entry;
+ int chosen, blob_sz;
+ const fdt64_t *prop;
+
+ if (!CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)) {
+ return -EAGAIN;
+ }
+
+ blob_sz = fdt_totalsize(gd->fdt_blob) + 4096;
+ blob = memalign(8, blob_sz);
+ ut_assertnonnull(blob);
+
+ /* Make a writable copy of the fdt blob */
+ ut_assertok(fdt_open_into(gd->fdt_blob, blob, blob_sz));
+
+ /* Mock SMBIOS table */
+ entry = map_sysmem(gd->arch.smbios_start, sizeof(struct smbios3_entry));
+ memcpy(entry->anchor, "_SM3_", 5);
+ entry->length = sizeof(struct smbios3_entry);
+ unmap_sysmem(entry);
+
+ /* Force fdt_chosen to run */
+ ut_assertok(fdt_chosen(blob));
+
+ chosen = fdt_path_offset(blob, "/chosen");
+ ut_assert(chosen >= 0);
+
+ /* Verify the property exists */
+ prop = fdt_getprop(blob, chosen, "smbios3-entrypoint", NULL);
+ ut_assertnonnull(prop);
+
+ /* Verify the property matches smbios_start */
+ val = fdt64_to_cpu(*prop);
+ ut_asserteq_64(gd->arch.smbios_start, val);
+
+ free(blob);
+
+ return 0;
+}
+DM_TEST(dm_test_fdt_chosen_smbios, UTF_SCAN_PDATA | UTF_SCAN_FDT);