int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp)
{
struct udevice *bootstd, *dev = *devp, **order;
+ bool show = iter->flags & BOOTFLOWF_SHOW;
struct uclass *uc;
int count, upto;
int ret;
return log_msg_ret("std", ret);
}
+ /* hunt for any pre-scan devices */
+ if (iter->flags & BOOTFLOWF_HUNT) {
+ ret = bootdev_hunt_prio(BOOTDEVP_1_PRE_SCAN, show);
+ if (ret)
+ return log_msg_ret("pre", ret);
+ }
+
/* Handle scanning a single device */
if (dev) {
iter->flags |= BOOTFLOWF_SINGLE_DEV;
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_0_INTERNAL_FAST;
+ ucp->prio = BOOTDEVP_2_INTERNAL_FAST;
return 0;
}
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_3_SCAN_SLOW;
+ ucp->prio = BOOTDEVP_5_SCAN_SLOW;
return 0;
}
};
BOOTDEV_HUNTER(ide_bootdev_hunter) = {
- .prio = BOOTDEVP_3_SCAN_SLOW,
+ .prio = BOOTDEVP_5_SCAN_SLOW,
.uclass = UCLASS_IDE,
.hunt = ide_bootdev_hunt,
.drv = DM_DRIVER_REF(ide_bootdev),
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_0_INTERNAL_FAST;
+ ucp->prio = BOOTDEVP_2_INTERNAL_FAST;
return 0;
}
};
BOOTDEV_HUNTER(mmc_bootdev_hunter) = {
- .prio = BOOTDEVP_0_INTERNAL_FAST,
+ .prio = BOOTDEVP_2_INTERNAL_FAST,
.uclass = UCLASS_MMC,
.drv = DM_DRIVER_REF(mmc_bootdev),
};
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_2_SCAN_FAST;
+ ucp->prio = BOOTDEVP_4_SCAN_FAST;
return 0;
}
};
BOOTDEV_HUNTER(sf_bootdev_hunter) = {
- .prio = BOOTDEVP_2_SCAN_FAST,
+ .prio = BOOTDEVP_4_SCAN_FAST,
.uclass = UCLASS_SPI_FLASH,
.drv = DM_DRIVER_REF(sf_bootdev),
};
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_2_SCAN_FAST;
+ ucp->prio = BOOTDEVP_4_SCAN_FAST;
return 0;
}
};
BOOTDEV_HUNTER(nvme_bootdev_hunter) = {
- .prio = BOOTDEVP_2_SCAN_FAST,
+ .prio = BOOTDEVP_4_SCAN_FAST,
.uclass = UCLASS_NVME,
.hunt = nvme_bootdev_hunt,
.drv = DM_DRIVER_REF(nvme_bootdev),
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_2_SCAN_FAST;
+ ucp->prio = BOOTDEVP_4_SCAN_FAST;
return 0;
}
};
BOOTDEV_HUNTER(scsi_bootdev_hunter) = {
- .prio = BOOTDEVP_2_SCAN_FAST,
+ .prio = BOOTDEVP_4_SCAN_FAST,
.uclass = UCLASS_SCSI,
.hunt = scsi_bootdev_hunt,
.drv = DM_DRIVER_REF(scsi_bootdev),
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_3_SCAN_SLOW;
+ ucp->prio = BOOTDEVP_5_SCAN_SLOW;
return 0;
}
};
BOOTDEV_HUNTER(usb_bootdev_hunter) = {
- .prio = BOOTDEVP_3_SCAN_SLOW,
+ .prio = BOOTDEVP_5_SCAN_SLOW,
.uclass = UCLASS_USB,
.hunt = usb_bootdev_hunt,
.drv = DM_DRIVER_REF(usb_bootdev),
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_2_SCAN_FAST;
+ ucp->prio = BOOTDEVP_4_SCAN_FAST;
return 0;
}
};
BOOTDEV_HUNTER(virtio_bootdev_hunter) = {
- .prio = BOOTDEVP_2_SCAN_FAST,
+ .prio = BOOTDEVP_4_SCAN_FAST,
.uclass = UCLASS_VIRTIO,
.hunt = virtio_bootdev_hunt,
.drv = DM_DRIVER_REF(virtio_bootdev),
*
* Smallest value is the highest priority. By default, bootdevs are scanned from
* highest to lowest priority
+ *
+ * BOOTDEVP_0_NONE: Invalid value, do not use
+ * @BOOTDEVP_6_PRE_SCAN: Scan bootdevs with this priority always, before
+ * starting any bootflow scan
+ * @BOOTDEVP_2_INTERNAL_FAST: Internal devices which don't need scanning and
+ * generally very quick to access, e.g. less than 100ms
+ * @BOOTDEVP_3_INTERNAL_SLOW: Internal devices which don't need scanning but
+ * take a significant fraction of a second to access
+ * @BOOTDEVP_4_SCAN_FAST: Extenal devices which need scanning or bus
+ * enumeration to find, but this enumeration happens quickly, typically under
+ * 100ms
+ * @BOOTDEVP_5_SCAN_SLOW: Extenal devices which need scanning or bus
+ * enumeration to find. The enumeration takes significant fraction of a second
+ * to complete
+ * @BOOTDEVP_6_NET_BASE: Basic network devices which are quickly and easily
+ * available. Typically used for an internal Ethernet device
+ * @BOOTDEVP_7_NET_FALLBACK: Secondary network devices which require extra time
+ * to start up, or are less desirable. Typically used for secondary Ethernet
+ * devices. Note that USB ethernet devices are found during USB enumeration,
+ * so do not use this priority
*/
enum bootdev_prio_t {
- BOOTDEVP_0_INTERNAL_FAST = 10,
- BOOTDEVP_1_INTERNAL_SLOW = 20,
- BOOTDEVP_2_SCAN_FAST = 30,
- BOOTDEVP_3_SCAN_SLOW = 40,
- BOOTDEVP_4_NET_BASE = 50,
- BOOTDEVP_5_NET_FALLBACK = 60,
- BOOTDEVP_6_SYSTEM = 70,
+ BOOTDEVP_0_NONE,
+ BOOTDEVP_1_PRE_SCAN,
+ BOOTDEVP_2_INTERNAL_FAST,
+ BOOTDEVP_3_INTERNAL_SLOW,
+ BOOTDEVP_4_SCAN_FAST,
+ BOOTDEVP_5_SCAN_SLOW,
+ BOOTDEVP_6_NET_BASE,
+ BOOTDEVP_7_NET_FALLBACK,
BOOTDEVP_COUNT,
};
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
- ucp->prio = BOOTDEVP_4_NET_BASE;
+ ucp->prio = BOOTDEVP_6_NET_BASE;
return 0;
}
};
BOOTDEV_HUNTER(eth_bootdev_hunt) = {
- .prio = BOOTDEVP_4_NET_BASE,
+ .prio = BOOTDEVP_6_NET_BASE,
.uclass = UCLASS_ETH,
.hunt = eth_bootdev_hunt,
.drv = DM_DRIVER_REF(eth_bootdev),
bootdev_list_hunters(std);
ut_assert_nextline("Prio Used Uclass Hunter");
ut_assert_nextlinen("----");
- ut_assert_nextline(" 50 ethernet eth_bootdev");
- ut_assert_nextline(" 40 ide ide_bootdev");
- ut_assert_nextline(" 10 mmc mmc_bootdev");
- ut_assert_nextline(" 30 nvme nvme_bootdev");
- ut_assert_nextline(" 30 scsi scsi_bootdev");
- ut_assert_nextline(" 30 spi_flash sf_bootdev");
- ut_assert_nextline(" 40 usb usb_bootdev");
- ut_assert_nextline(" 30 virtio virtio_bootdev");
+ ut_assert_nextline(" 6 ethernet eth_bootdev");
+ ut_assert_nextline(" 5 ide ide_bootdev");
+ ut_assert_nextline(" 2 mmc mmc_bootdev");
+ ut_assert_nextline(" 4 nvme nvme_bootdev");
+ ut_assert_nextline(" 4 scsi scsi_bootdev");
+ ut_assert_nextline(" 4 spi_flash sf_bootdev");
+ ut_assert_nextline(" 5 usb usb_bootdev");
+ ut_assert_nextline(" 4 virtio virtio_bootdev");
ut_assert_nextline("(total hunters: 8)");
ut_assert_console_end();
ut_assertok(run_command("bootdev hunt -l", 0));
ut_assert_nextline("Prio Used Uclass Hunter");
ut_assert_nextlinen("----");
+ ut_assert_nextline(" 6 ethernet eth_bootdev");
+ ut_assert_skip_to_line("(total hunters: 8)");
+ ut_assert_console_end();
+
+ /* Use the MMC hunter and see that it updates */
+ ut_assertok(run_command("bootdev hunt mmc", 0));
+ ut_assertok(run_command("bootdev hunt -l", 0));
+ ut_assert_skip_to_line(" 5 ide ide_bootdev");
+ ut_assert_nextline(" 2 * mmc mmc_bootdev");
ut_assert_skip_to_line("(total hunters: 8)");
ut_assert_console_end();
/* Scan all hunters */
sandbox_set_eth_enable(false);
-
+ test_set_skip_delays(true);
ut_assertok(run_command("bootdev hunt", 0));
ut_assert_nextline("Hunting with: ethernet");
ut_assert_nextline("Hunting with: ide");
ut_assert_nextline("Bus 0: not available ");
- ut_assert_nextline("Hunting with: mmc");
+
+ /* mmc hunter has already been used so should not run again */
+
ut_assert_nextline("Hunting with: nvme");
ut_assert_nextline("Hunting with: scsi");
ut_assert_nextline("scanning bus for devices...");
ut_assertok(run_command("bootdev hunt -l", 0));
ut_assert_nextlinen("Prio");
ut_assert_nextlinen("----");
- ut_assert_nextline(" 50 * ethernet eth_bootdev");
- ut_assert_nextline(" 40 * ide ide_bootdev");
- ut_assert_nextline(" 10 * mmc mmc_bootdev");
- ut_assert_nextline(" 30 * nvme nvme_bootdev");
- ut_assert_nextline(" 30 * scsi scsi_bootdev");
- ut_assert_nextline(" 30 * spi_flash sf_bootdev");
- ut_assert_nextline(" 40 * usb usb_bootdev");
- ut_assert_nextline(" 30 * virtio virtio_bootdev");
+ ut_assert_nextline(" 6 * ethernet eth_bootdev");
+ ut_assert_nextline(" 5 * ide ide_bootdev");
+ ut_assert_nextline(" 2 * mmc mmc_bootdev");
+ ut_assert_nextline(" 4 * nvme nvme_bootdev");
+ ut_assert_nextline(" 4 * scsi scsi_bootdev");
+ ut_assert_nextline(" 4 * spi_flash sf_bootdev");
+ ut_assert_nextline(" 5 * usb usb_bootdev");
+ ut_assert_nextline(" 4 * virtio virtio_bootdev");
ut_assert_nextline("(total hunters: 8)");
ut_assert_console_end();
test_set_skip_delays(true);
console_record_reset_enable();
- ut_assertok(bootdev_hunt_prio(BOOTDEVP_2_SCAN_FAST, false));
+ ut_assertok(bootdev_hunt_prio(BOOTDEVP_4_SCAN_FAST, false));
ut_assert_nextline("scanning bus for devices...");
ut_assert_skip_to_line(" Type: Hard Disk");
ut_assert_nextlinen(" Capacity:");
ut_assert_console_end();
/* now try a different priority, verbosely */
- ut_assertok(bootdev_hunt_prio(BOOTDEVP_3_SCAN_SLOW, true));
+ ut_assertok(bootdev_hunt_prio(BOOTDEVP_5_SCAN_SLOW, true));
ut_assert_nextline("Hunting with: ide");
ut_assert_nextline("Bus 0: not available ");
ut_assert_nextline("Hunting with: usb");