diff --git a/lk2nd/device/device.c b/lk2nd/device/device.c index 95790dc904..fe56208db3 100644 --- a/lk2nd/device/device.c +++ b/lk2nd/device/device.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -14,6 +15,14 @@ struct lk2nd_device lk2nd_dev; +/** + * lk2nd_device_get_dtb_hints() - Get a null-terminated array of DTB names. + */ +char **lk2nd_device_get_dtb_hints(void) +{ + return lk2nd_dev.dtbfiles; +} + static int find_device_node(const void *dtb) { int lk2nd_node, node, ret; @@ -108,6 +117,10 @@ static void parse_dtb(const void *dtb) else dprintf(CRITICAL, "Failed to read 'model': %d\n", len); + lk2nd_dev.dtbfiles = lkfdt_stringlist_get_all(dtb, node, "lk2nd,dtb-files", &len); + if (len < 0) + dprintf(CRITICAL, "Failed to read 'lk2nd,dtb-files': %d\n", len); + dprintf(INFO, "Detected device: %s (compatible: %s)\n", lk2nd_dev.model, lk2nd_dev.compatible); diff --git a/lk2nd/device/device.h b/lk2nd/device/device.h index 6407eca508..e285452352 100644 --- a/lk2nd/device/device.h +++ b/lk2nd/device/device.h @@ -20,6 +20,8 @@ struct lk2nd_device { const char *model; const char *battery; + char **dtbfiles; + struct lk2nd_panel panel; #if WITH_LK2ND_DEVICE_2ND diff --git a/lk2nd/include/lk2nd/device.h b/lk2nd/include/lk2nd/device.h index e529021f20..55c8813e7a 100644 --- a/lk2nd/include/lk2nd/device.h +++ b/lk2nd/include/lk2nd/device.h @@ -10,4 +10,10 @@ bool lk2nd_device2nd_have_atags(void) __PURE; void lk2nd_device2nd_copy_atags(void *tags, const char *cmdline, void *ramdisk, unsigned ramdisk_size); +#if WITH_LK2ND_DEVICE +char **lk2nd_device_get_dtb_hints(void); +#else +static inline char **lk2nd_device_get_dtb_hints(void) { return NULL; }; +#endif + #endif /* LK2ND_DEVICE_H */