+
+void efi_set_bootdev(const char *dev, const char *devnr, const char *path)
+{
+ __maybe_unused struct blk_desc *desc;
+ char devname[32] = { 0 }; /* dp->str is u16[32] long */
+ char *colon;
+
+#if defined(CONFIG_BLK) || CONFIG_IS_ENABLED(ISO_PARTITION)
+ desc = blk_get_dev(dev, simple_strtol(devnr, NULL, 10));
+#endif
+
+#ifdef CONFIG_BLK
+ if (desc) {
+ snprintf(devname, sizeof(devname), "%s", desc->bdev->name);
+ } else
+#endif
+
+ {
+ /* Assemble the condensed device name we use in efi_disk.c */
+ snprintf(devname, sizeof(devname), "%s%s", dev, devnr);
+ }
+
+ colon = strchr(devname, ':');
+
+#if CONFIG_IS_ENABLED(ISO_PARTITION)
+ /* For ISOs we create partition block devices */
+ if (desc && (desc->type != DEV_TYPE_UNKNOWN) &&
+ (desc->part_type == PART_TYPE_ISO)) {
+ if (!colon)
+ snprintf(devname, sizeof(devname), "%s:1", devname);
+
+ colon = NULL;
+ }
+#endif
+
+ if (colon)
+ *colon = '\0';
+
+ /* Patch bootefi_device_path to the target device */
+ memset(bootefi_device_path[0].str, 0, sizeof(bootefi_device_path[0].str));
+ ascii2unicode(bootefi_device_path[0].str, devname);
+
+ /* Patch bootefi_image_path to the target file path */
+ memset(bootefi_image_path[0].str, 0, sizeof(bootefi_image_path[0].str));
+ if (strcmp(dev, "Net")) {
+ /* Add leading / to fs paths, because they're absolute */
+ snprintf(devname, sizeof(devname), "/%s", path);
+ } else {
+ snprintf(devname, sizeof(devname), "%s", path);
+ }
+ ascii2unicode(bootefi_image_path[0].str, devname);
+}