From b2b7e6c1812d2b6bea517ea8f7df5c23ae04ce84 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 24 Aug 2023 13:55:33 -0600 Subject: part: Add an accessor for struct disk_partition sys_ind This field is only present when a CONFIG is set. To avoid annoying #ifdefs in the source code, add an accessor. Update the only usage. Note that the accessor is optional. It can be omitted if it is known that the option is enabled. Signed-off-by: Simon Glass --- boot/bootdev-uclass.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'boot/bootdev-uclass.c') diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index fa52bc3a9c4..c4044d87dc3 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -184,12 +184,11 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, if (ret) return log_msg_ret("fs", ret); - /* Use an #ifdef due to info.sys_ind */ -#ifdef CONFIG_DOS_PARTITION log_debug("%s: Found partition %x type %x fstype %d\n", - blk->name, bflow->part, info.sys_ind, + blk->name, bflow->part, + IS_ENABLED(CONFIG_DOS_PARTITION) ? + disk_partition_sys_ind(&info) : 0, ret ? -1 : fs_get_type()); -#endif bflow->blk = blk; bflow->state = BOOTFLOWST_FS; } -- cgit v1.2.3 From 831405f41de122c2a3a0908f07c632c87266709a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 24 Aug 2023 13:55:43 -0600 Subject: bootstd: Support bootmeths which can scan any partition Some bootmeths support scanning a partition without a filesystem on it. Add a flag to support this. This will allow the ChromiumOS bootmeth to find kernel partition, which are stored in a special format, without a filesystem. Signed-off-by: Simon Glass --- boot/bootdev-uclass.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'boot/bootdev-uclass.c') diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index c4044d87dc3..69506e3865f 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -111,6 +111,8 @@ int bootdev_bind(struct udevice *parent, const char *drv_name, const char *name, int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, struct bootflow_iter *iter, struct bootflow *bflow) { + struct bootmeth_uc_plat *plat = dev_get_uclass_plat(bflow->method); + bool allow_any_part = plat->flags & BOOTMETHF_ANY_PART; struct blk_desc *desc = dev_get_uclass_plat(blk); struct disk_partition info; char partstr[20]; @@ -142,6 +144,7 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, * us whether there is valid media there */ ret = part_get_info(desc, iter->part, &info); + log_debug("part_get_info() returned %d\n", ret); if (!iter->part && ret == -ENOENT) ret = 0; @@ -154,7 +157,7 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, ret = -ESHUTDOWN; else bflow->state = BOOTFLOWST_MEDIA; - if (ret) { + if (ret && !allow_any_part) { /* allow partition 1 to be missing */ if (iter->part == 1) { iter->max_part = 3; @@ -174,9 +177,15 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, if (!iter->part) { iter->first_bootable = part_get_bootable(desc); log_debug("checking bootable=%d\n", iter->first_bootable); + } else if (allow_any_part) { + /* + * allow any partition to be scanned, by skipping any checks + * for filesystems or partition contents on this disk + */ /* if there are bootable partitions, scan only those */ - } else if (iter->first_bootable ? !info.bootable : iter->part != 1) { + } else if (iter->first_bootable >= 0 && + (iter->first_bootable ? !info.bootable : iter->part != 1)) { return log_msg_ret("boot", -EINVAL); } else { ret = fs_set_blk_dev_with_part(desc, bflow->part); @@ -193,6 +202,7 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, bflow->state = BOOTFLOWST_FS; } + log_debug("method %s\n", bflow->method->name); ret = bootmeth_read_bootflow(bflow->method, bflow); if (ret) return log_msg_ret("method", ret); @@ -559,7 +569,8 @@ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, { const struct bootdev_ops *ops = bootdev_get_ops(dev); - log_debug("->get_bootflow %s=%p\n", dev->name, ops->get_bootflow); + log_debug("->get_bootflow %s,%x=%p\n", dev->name, iter->part, + ops->get_bootflow); bootflow_init(bflow, dev, iter->method); if (!ops->get_bootflow) return default_get_bootflow(dev, iter, bflow); -- cgit v1.2.3 From 1b1d36ec58f43585081b387ee44053278e480171 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 20 Sep 2023 07:29:49 -0600 Subject: bootstd: Keep track of use of usb stop When 'usb stop' is run, doing 'bootflow scan' does not run the USB hunter again so does not see any devices. Fix this by telling bootstd about the state of USB. Signed-off-by: Simon Glass --- boot/bootdev-uclass.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'boot/bootdev-uclass.c') diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 69506e3865f..974ddee5d2f 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -830,6 +830,33 @@ int bootdev_hunt(const char *spec, bool show) return result; } +int bootdev_unhunt(enum uclass_id id) +{ + struct bootdev_hunter *start; + int n_ent, i; + + start = ll_entry_start(struct bootdev_hunter, bootdev_hunter); + n_ent = ll_entry_count(struct bootdev_hunter, bootdev_hunter); + for (i = 0; i < n_ent; i++) { + struct bootdev_hunter *info = start + i; + + if (info->uclass == id) { + struct bootstd_priv *std; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return log_msg_ret("std", ret); + if (!(std->hunters_used & BIT(i))) + return -EALREADY; + std->hunters_used &= ~BIT(i); + return 0; + } + } + + return -ENOENT; +} + int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show) { struct bootdev_hunter *start; -- cgit v1.2.3