History log of /u-boot/test/boot/bootdev.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# d678a59d 18-May-2024 Tom Rini <trini@konsulko.com>

Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""

When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay
Ethernet"' I failed to notice that b4 noticed it was based on next and
so took that as the base commit and merged that part of next to master.

This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing
changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 752ed086 27-Apr-2024 Tom Rini <trini@konsulko.com>

test: Remove <common.h> and add needed includes

Remove <common.h> from all "test/" files and when needed add
missing include files directly.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 7a790f01 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Scan all bootdevs in a boot_targets entry (take 2)

When the boot_targets environment variable is used with the distro-boot
scripts, each device is included individually. For example, if there
are three mmc devices, then we will have something like:

boot_targets="mmc0 mmc1 mmc2"

In contrast, standard boot supports specifying just the uclass, i.e.:

boot_targets="mmc"

The intention is that this should scan all MMC devices, but in fact it
currently only scans the first.

Update the logic to handle this case, without required BOOTSTD_FULL to
be enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Date Huang <tjjh89017@hotmail.com>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>
Reported-by: Ivan Ivanov <ivan.ivanov@suse.com>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# 16e19350 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Correct logic for single uclass

The current logic for "bootflow mmc" is flawed since it checks the
uclass of the bootdev instead of its parent, the media device. Correct
this and add a test that covers this scenario.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# 7ae83bfa 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Expand boot-ordering test to include USB

Scan the USB bus as well, so we can check that different uclasses work
correctly in boot_targets

update the function comment with more detail.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# abd1e94f 23-Oct-2023 Simon Glass <sjg@chromium.org>

Revert "bootstd: Scan all bootdevs in a boot_targets entry"

This commit was intended to allow all bootdevs in each boot_targets
entry to be scanned. However it causes bad ordering with bootdevs, e.g.
scanning Ethernet bootdevs when it should be keeping to mmc.

Revert it so we can try another approach.

This reverts commit e824d0d0c219bc6da767f13f90c5b00eefe929f0.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# e824d0d0 23-Sep-2023 Simon Glass <sjg@chromium.org>

bootstd: Scan all bootdevs in a boot_targets entry

When the boot_targets environment variable is used with the distro-boot
scripts, each device is included individually. For example, if there
are three mmc devices, then we will have something like:

boot_targets="mmc0 mmc1 mmc2"

In contrast, standard boot supports specifying just the uclass, i.e.:

boot_targets="mmc"

The intention is that this should scan all MMC devices, but in fact it
currently only scans the first.

Update the logic to handle this case, without required BOOTSTD_FULL to
be enabled.

I believe at least three people reported this, but I found two.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Date Huang <tjjh89017@hotmail.com>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>

# 8c29b732 05-May-2023 Simon Glass <sjg@chromium.org>

bootstd: usb: Avoid initing USB twice

This causes crashes on some boards, e.g. rockpro64. In any case, we
should not do it.

Check the usb_started flag to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Tom Rini <trini@konsulko.com>

# 9fea3a79 05-May-2023 Simon Glass <sjg@chromium.org>

usb: Tidy up the usb_start flag

This should be declared in a header file so that type-checking works
correctly.

Add a single declaration to usb.h and remove the others.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

# 80778f50 25-Apr-2023 Simon Glass <sjg@chromium.org>

ide: Move ide_init() into probing

At present the code does ide_init() as a separate operation, then calls
device_probe() to copy over the information. We can call ide_init() from
probe just as easily.

The only difference is that using 'ide init' twice will do nothing.
However it already fails to copy over the new data in that case, so the
effect is the same. For now, unbind the block devices and remove the IDE
device, which causes the bus to be probed again. Later patches will fix
this up fully, so that all blk_desc data is copied across.

Since ide_reset() is only called from ide_init(), there is no need to init
the ide_dev_desc[] array. This is already done at the end of ide_init() so
drop this code.

The call to uclass_first_device() is now within the probe() function of
the same device, so does nothing. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 1736b4af 23-Apr-2023 Simon Glass <sjg@chromium.org>

bootstd: Report missing labels only when asked

Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini <trini@konsulko.com>

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4f806f31 22-Feb-2023 Simon Glass <sjg@chromium.org>

bootflow: Rename bootflow_flags_t

These flags actually relate to the iterator, not the bootflow struct
itself. Rename them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 662cfa03 28-Jan-2023 Simon Glass <sjg@chromium.org>

arm: qemu: Move GUIDs to the C file

These are only used in one place, so move them there.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1413f6 23-Jan-2023 Linus Walleij <linus.walleij@linaro.org>

test: bootdev: Do not require USB to compile test

This test will block compilation of the entire test suite
on platforms without USB support. Make the extern
"usb_started" conditional on USB host or gadget and
define a dummy flag if neither is enabled.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 752ed086 27-Apr-2024 Tom Rini <trini@konsulko.com>

test: Remove <common.h> and add needed includes

Remove <common.h> from all "test/" files and when needed add
missing include files directly.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 7a790f01 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Scan all bootdevs in a boot_targets entry (take 2)

When the boot_targets environment variable is used with the distro-boot
scripts, each device is included individually. For example, if there
are three mmc devices, then we will have something like:

boot_targets="mmc0 mmc1 mmc2"

In contrast, standard boot supports specifying just the uclass, i.e.:

boot_targets="mmc"

The intention is that this should scan all MMC devices, but in fact it
currently only scans the first.

Update the logic to handle this case, without required BOOTSTD_FULL to
be enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Date Huang <tjjh89017@hotmail.com>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>
Reported-by: Ivan Ivanov <ivan.ivanov@suse.com>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# 16e19350 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Correct logic for single uclass

The current logic for "bootflow mmc" is flawed since it checks the
uclass of the bootdev instead of its parent, the media device. Correct
this and add a test that covers this scenario.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# 7ae83bfa 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Expand boot-ordering test to include USB

Scan the USB bus as well, so we can check that different uclasses work
correctly in boot_targets

update the function comment with more detail.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# abd1e94f 23-Oct-2023 Simon Glass <sjg@chromium.org>

Revert "bootstd: Scan all bootdevs in a boot_targets entry"

This commit was intended to allow all bootdevs in each boot_targets
entry to be scanned. However it causes bad ordering with bootdevs, e.g.
scanning Ethernet bootdevs when it should be keeping to mmc.

Revert it so we can try another approach.

This reverts commit e824d0d0c219bc6da767f13f90c5b00eefe929f0.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# e824d0d0 23-Sep-2023 Simon Glass <sjg@chromium.org>

bootstd: Scan all bootdevs in a boot_targets entry

When the boot_targets environment variable is used with the distro-boot
scripts, each device is included individually. For example, if there
are three mmc devices, then we will have something like:

boot_targets="mmc0 mmc1 mmc2"

In contrast, standard boot supports specifying just the uclass, i.e.:

boot_targets="mmc"

The intention is that this should scan all MMC devices, but in fact it
currently only scans the first.

Update the logic to handle this case, without required BOOTSTD_FULL to
be enabled.

I believe at least three people reported this, but I found two.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Date Huang <tjjh89017@hotmail.com>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>

# 8c29b732 05-May-2023 Simon Glass <sjg@chromium.org>

bootstd: usb: Avoid initing USB twice

This causes crashes on some boards, e.g. rockpro64. In any case, we
should not do it.

Check the usb_started flag to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Tom Rini <trini@konsulko.com>

# 9fea3a79 05-May-2023 Simon Glass <sjg@chromium.org>

usb: Tidy up the usb_start flag

This should be declared in a header file so that type-checking works
correctly.

Add a single declaration to usb.h and remove the others.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

# 80778f50 25-Apr-2023 Simon Glass <sjg@chromium.org>

ide: Move ide_init() into probing

At present the code does ide_init() as a separate operation, then calls
device_probe() to copy over the information. We can call ide_init() from
probe just as easily.

The only difference is that using 'ide init' twice will do nothing.
However it already fails to copy over the new data in that case, so the
effect is the same. For now, unbind the block devices and remove the IDE
device, which causes the bus to be probed again. Later patches will fix
this up fully, so that all blk_desc data is copied across.

Since ide_reset() is only called from ide_init(), there is no need to init
the ide_dev_desc[] array. This is already done at the end of ide_init() so
drop this code.

The call to uclass_first_device() is now within the probe() function of
the same device, so does nothing. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 1736b4af 23-Apr-2023 Simon Glass <sjg@chromium.org>

bootstd: Report missing labels only when asked

Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini <trini@konsulko.com>

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4f806f31 22-Feb-2023 Simon Glass <sjg@chromium.org>

bootflow: Rename bootflow_flags_t

These flags actually relate to the iterator, not the bootflow struct
itself. Rename them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 662cfa03 28-Jan-2023 Simon Glass <sjg@chromium.org>

arm: qemu: Move GUIDs to the C file

These are only used in one place, so move them there.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1413f6 23-Jan-2023 Linus Walleij <linus.walleij@linaro.org>

test: bootdev: Do not require USB to compile test

This test will block compilation of the entire test suite
on platforms without USB support. Make the extern
"usb_started" conditional on USB host or gadget and
define a dummy flag if neither is enabled.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 7a790f01 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Scan all bootdevs in a boot_targets entry (take 2)

When the boot_targets environment variable is used with the distro-boot
scripts, each device is included individually. For example, if there
are three mmc devices, then we will have something like:

boot_targets="mmc0 mmc1 mmc2"

In contrast, standard boot supports specifying just the uclass, i.e.:

boot_targets="mmc"

The intention is that this should scan all MMC devices, but in fact it
currently only scans the first.

Update the logic to handle this case, without required BOOTSTD_FULL to
be enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Date Huang <tjjh89017@hotmail.com>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>
Reported-by: Ivan Ivanov <ivan.ivanov@suse.com>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# 16e19350 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Correct logic for single uclass

The current logic for "bootflow mmc" is flawed since it checks the
uclass of the bootdev instead of its parent, the media device. Correct
this and add a test that covers this scenario.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# 7ae83bfa 23-Oct-2023 Simon Glass <sjg@chromium.org>

bootstd: Expand boot-ordering test to include USB

Scan the USB bus as well, so we can check that different uclasses work
correctly in boot_targets

update the function comment with more detail.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# abd1e94f 23-Oct-2023 Simon Glass <sjg@chromium.org>

Revert "bootstd: Scan all bootdevs in a boot_targets entry"

This commit was intended to allow all bootdevs in each boot_targets
entry to be scanned. However it causes bad ordering with bootdevs, e.g.
scanning Ethernet bootdevs when it should be keeping to mmc.

Revert it so we can try another approach.

This reverts commit e824d0d0c219bc6da767f13f90c5b00eefe929f0.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>

# e824d0d0 23-Sep-2023 Simon Glass <sjg@chromium.org>

bootstd: Scan all bootdevs in a boot_targets entry

When the boot_targets environment variable is used with the distro-boot
scripts, each device is included individually. For example, if there
are three mmc devices, then we will have something like:

boot_targets="mmc0 mmc1 mmc2"

In contrast, standard boot supports specifying just the uclass, i.e.:

boot_targets="mmc"

The intention is that this should scan all MMC devices, but in fact it
currently only scans the first.

Update the logic to handle this case, without required BOOTSTD_FULL to
be enabled.

I believe at least three people reported this, but I found two.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Date Huang <tjjh89017@hotmail.com>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>

# 8c29b732 05-May-2023 Simon Glass <sjg@chromium.org>

bootstd: usb: Avoid initing USB twice

This causes crashes on some boards, e.g. rockpro64. In any case, we
should not do it.

Check the usb_started flag to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Tom Rini <trini@konsulko.com>

# 9fea3a79 05-May-2023 Simon Glass <sjg@chromium.org>

usb: Tidy up the usb_start flag

This should be declared in a header file so that type-checking works
correctly.

Add a single declaration to usb.h and remove the others.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

# 80778f50 25-Apr-2023 Simon Glass <sjg@chromium.org>

ide: Move ide_init() into probing

At present the code does ide_init() as a separate operation, then calls
device_probe() to copy over the information. We can call ide_init() from
probe just as easily.

The only difference is that using 'ide init' twice will do nothing.
However it already fails to copy over the new data in that case, so the
effect is the same. For now, unbind the block devices and remove the IDE
device, which causes the bus to be probed again. Later patches will fix
this up fully, so that all blk_desc data is copied across.

Since ide_reset() is only called from ide_init(), there is no need to init
the ide_dev_desc[] array. This is already done at the end of ide_init() so
drop this code.

The call to uclass_first_device() is now within the probe() function of
the same device, so does nothing. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 1736b4af 23-Apr-2023 Simon Glass <sjg@chromium.org>

bootstd: Report missing labels only when asked

Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini <trini@konsulko.com>

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4f806f31 22-Feb-2023 Simon Glass <sjg@chromium.org>

bootflow: Rename bootflow_flags_t

These flags actually relate to the iterator, not the bootflow struct
itself. Rename them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 662cfa03 28-Jan-2023 Simon Glass <sjg@chromium.org>

arm: qemu: Move GUIDs to the C file

These are only used in one place, so move them there.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1413f6 23-Jan-2023 Linus Walleij <linus.walleij@linaro.org>

test: bootdev: Do not require USB to compile test

This test will block compilation of the entire test suite
on platforms without USB support. Make the extern
"usb_started" conditional on USB host or gadget and
define a dummy flag if neither is enabled.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e824d0d0 23-Sep-2023 Simon Glass <sjg@chromium.org>

bootstd: Scan all bootdevs in a boot_targets entry

When the boot_targets environment variable is used with the distro-boot
scripts, each device is included individually. For example, if there
are three mmc devices, then we will have something like:

boot_targets="mmc0 mmc1 mmc2"

In contrast, standard boot supports specifying just the uclass, i.e.:

boot_targets="mmc"

The intention is that this should scan all MMC devices, but in fact it
currently only scans the first.

Update the logic to handle this case, without required BOOTSTD_FULL to
be enabled.

I believe at least three people reported this, but I found two.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Date Huang <tjjh89017@hotmail.com>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>

# 8c29b732 05-May-2023 Simon Glass <sjg@chromium.org>

bootstd: usb: Avoid initing USB twice

This causes crashes on some boards, e.g. rockpro64. In any case, we
should not do it.

Check the usb_started flag to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Tom Rini <trini@konsulko.com>

# 9fea3a79 05-May-2023 Simon Glass <sjg@chromium.org>

usb: Tidy up the usb_start flag

This should be declared in a header file so that type-checking works
correctly.

Add a single declaration to usb.h and remove the others.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

# 80778f50 25-Apr-2023 Simon Glass <sjg@chromium.org>

ide: Move ide_init() into probing

At present the code does ide_init() as a separate operation, then calls
device_probe() to copy over the information. We can call ide_init() from
probe just as easily.

The only difference is that using 'ide init' twice will do nothing.
However it already fails to copy over the new data in that case, so the
effect is the same. For now, unbind the block devices and remove the IDE
device, which causes the bus to be probed again. Later patches will fix
this up fully, so that all blk_desc data is copied across.

Since ide_reset() is only called from ide_init(), there is no need to init
the ide_dev_desc[] array. This is already done at the end of ide_init() so
drop this code.

The call to uclass_first_device() is now within the probe() function of
the same device, so does nothing. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 1736b4af 23-Apr-2023 Simon Glass <sjg@chromium.org>

bootstd: Report missing labels only when asked

Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini <trini@konsulko.com>

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4f806f31 22-Feb-2023 Simon Glass <sjg@chromium.org>

bootflow: Rename bootflow_flags_t

These flags actually relate to the iterator, not the bootflow struct
itself. Rename them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 662cfa03 28-Jan-2023 Simon Glass <sjg@chromium.org>

arm: qemu: Move GUIDs to the C file

These are only used in one place, so move them there.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1413f6 23-Jan-2023 Linus Walleij <linus.walleij@linaro.org>

test: bootdev: Do not require USB to compile test

This test will block compilation of the entire test suite
on platforms without USB support. Make the extern
"usb_started" conditional on USB host or gadget and
define a dummy flag if neither is enabled.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8c29b732 05-May-2023 Simon Glass <sjg@chromium.org>

bootstd: usb: Avoid initing USB twice

This causes crashes on some boards, e.g. rockpro64. In any case, we
should not do it.

Check the usb_started flag to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Tom Rini <trini@konsulko.com>

# 9fea3a79 05-May-2023 Simon Glass <sjg@chromium.org>

usb: Tidy up the usb_start flag

This should be declared in a header file so that type-checking works
correctly.

Add a single declaration to usb.h and remove the others.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

# 80778f50 25-Apr-2023 Simon Glass <sjg@chromium.org>

ide: Move ide_init() into probing

At present the code does ide_init() as a separate operation, then calls
device_probe() to copy over the information. We can call ide_init() from
probe just as easily.

The only difference is that using 'ide init' twice will do nothing.
However it already fails to copy over the new data in that case, so the
effect is the same. For now, unbind the block devices and remove the IDE
device, which causes the bus to be probed again. Later patches will fix
this up fully, so that all blk_desc data is copied across.

Since ide_reset() is only called from ide_init(), there is no need to init
the ide_dev_desc[] array. This is already done at the end of ide_init() so
drop this code.

The call to uclass_first_device() is now within the probe() function of
the same device, so does nothing. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 1736b4af 23-Apr-2023 Simon Glass <sjg@chromium.org>

bootstd: Report missing labels only when asked

Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini <trini@konsulko.com>

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4f806f31 22-Feb-2023 Simon Glass <sjg@chromium.org>

bootflow: Rename bootflow_flags_t

These flags actually relate to the iterator, not the bootflow struct
itself. Rename them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 662cfa03 28-Jan-2023 Simon Glass <sjg@chromium.org>

arm: qemu: Move GUIDs to the C file

These are only used in one place, so move them there.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1413f6 23-Jan-2023 Linus Walleij <linus.walleij@linaro.org>

test: bootdev: Do not require USB to compile test

This test will block compilation of the entire test suite
on platforms without USB support. Make the extern
"usb_started" conditional on USB host or gadget and
define a dummy flag if neither is enabled.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 1736b4af 23-Apr-2023 Simon Glass <sjg@chromium.org>

bootstd: Report missing labels only when asked

Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini <trini@konsulko.com>

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4f806f31 22-Feb-2023 Simon Glass <sjg@chromium.org>

bootflow: Rename bootflow_flags_t

These flags actually relate to the iterator, not the bootflow struct
itself. Rename them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 662cfa03 28-Jan-2023 Simon Glass <sjg@chromium.org>

arm: qemu: Move GUIDs to the C file

These are only used in one place, so move them there.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1413f6 23-Jan-2023 Linus Walleij <linus.walleij@linaro.org>

test: bootdev: Do not require USB to compile test

This test will block compilation of the entire test suite
on platforms without USB support. Make the extern
"usb_started" conditional on USB host or gadget and
define a dummy flag if neither is enabled.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4f806f31 22-Feb-2023 Simon Glass <sjg@chromium.org>

bootflow: Rename bootflow_flags_t

These flags actually relate to the iterator, not the bootflow struct
itself. Rename them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 662cfa03 28-Jan-2023 Simon Glass <sjg@chromium.org>

arm: qemu: Move GUIDs to the C file

These are only used in one place, so move them there.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1413f6 23-Jan-2023 Linus Walleij <linus.walleij@linaro.org>

test: bootdev: Do not require USB to compile test

This test will block compilation of the entire test suite
on platforms without USB support. Make the extern
"usb_started" conditional on USB host or gadget and
define a dummy flag if neither is enabled.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 662cfa03 28-Jan-2023 Simon Glass <sjg@chromium.org>

arm: qemu: Move GUIDs to the C file

These are only used in one place, so move them there.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1413f6 23-Jan-2023 Linus Walleij <linus.walleij@linaro.org>

test: bootdev: Do not require USB to compile test

This test will block compilation of the entire test suite
on platforms without USB support. Make the extern
"usb_started" conditional on USB host or gadget and
define a dummy flag if neither is enabled.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a950f285 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Record the bootdevs used during scanning

Add a way to record the bootdevs used when scanning for bootflows. This is
useful for testing.

Enable this only with BOOTSTD_FULL and do the same for the progress
reporting.

Re-enable and update the affected tests now that we have this feature.

For bootdev_test_order_default() there is no-longer any support for using
the bootdev aliases to specify an ordering, so drop that part of the test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b7cb058 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Drop the old bootflow_scan_first()

This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 91943ff7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow scanning a single bootdev label

We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.

This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.

Add a test for bootdev_find_by_any() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 47aedc29 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Switch bootdev scanning to use labels

At present we set up the bootdev order at the start, then scan the
bootdevs one by one.

However this approach cannot be used with hunters, since the bootdevs may
not exist until the hunter is used. Nor can we just run all the hunters at
the start, since that violate's U-Boot's 'lazy init' requirement. It also
increases boot time.

So we need to adjust the algorithm to scan by labels instead. As a first
step, drop the dev_order[] array in favour of a list of labels. Update the
name of bootdev_setup_iter_order() to better reflect what it does.

Update some related comments and log messages. Also disable a few tests
until a later commit where we can use them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18552d2a 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for the extension feature

This needs to run before any bootdev is used, so add a hunter for it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43e89a30 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next bootdev priortiy

Add a function which moves to the next priority to be processed.

This works by storing the current priority in the bootflow iterator. The
logic to set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e4b69489 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow iterating to the next label in a list

Add a function which moves to the next label in a list of labels. This
allows processing the boot_targets environment variable.

This works using a new label list in the bootflow iterator. The logic to
set this up is included in a subsequent commit.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66e3dce7 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for a bootdev by label

Add a function to hunt for a bootdev label and find the bootdev produced
by the hunter (or already present).

Add a few extra flags so that we can distinguish between "mmc1", "mmc" and
"1" which all need to be handled differently.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eacc2611 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79a7d4a6 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow hunting for bootdevs of a given priority

Add a way to run the hunter function for a particular priority, so that
new bootdevs can be found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9f48579 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Treat DHCP and PXE as bootdev labels

These are associated with the ethernet boot device but do not match its
uclass name, so handle them as special cases.

Provide a way to pass flags through with the bootdev so that we know
how to process it. The flags are checked by the bootmeths, to ensure that
only the selected bootmeth is used.

While these both use the network device, they work quite differently. It
is common to run only one of these, or to run PXE before DHCP. Provide
bootflow flags to control which methods are used. Check these in the two
bootmeths so that only the chosen one is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0c1f4a9f 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a60f7a3e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a virtio bootdev

Add a bootdev for virtio so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 758c706c 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an NVMe bootdev

Add a bootdev for NVMe so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0d77f8f1 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an IDE bootdev

Add a bootdev for IDE so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8f090b67 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a SCSI bootdev

Add a bootdev for SCSI so that these devices can be used with standard
boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f0e358f0 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Only scan bootable partitions

At present all partitions are scanned, whether marked bootable or not.
Use only bootable partitions, defaulting to partition 1 if none is
found.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4146c823 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a hunter for ethernet

Sometimes ethernet devices are attached to PCI. Since it is quick to scan,
add this into the ethernet hunter.

Run dhcp to establish the network connection. Drop this from the bootdev
since that is not needed now. Update a log message for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 843160fa 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add an MMC hunter

Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 04fb2b6e 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add a USB hunter

Add a hunter for USB which enumerates the bus to find new bootdevs.

Update the tests and speed up bootdev_test_prio() while we are here, by
dropping the USB delays.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c7b63d50 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Support running bootdev hunters

Add a way to run a bootdev hunter to find bootdevs of a certain type. Add
this to the 'bootdev hunt' command. Test for this are added in a later
patch, since a useful test needs some hunters to work with.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bd90b092 17-Jan-2023 Simon Glass <sjg@chromium.org>

bootstd: Add the concept of a bootdev hunter

Some bootdevs must be enumerated before they appear. For example, USB
bootdevs are not visible until USB is enumerated.

With standard boot this needs to happen automatically, since we only
want to enumerate a bus if it is needed.

Add a way to define bootdev 'hunters' which can be used to hunt for
bootdevs of a given type. Track which ones have been used and add a
command to list them.

Include a clang work-around which seems to be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fb1451be 24-Apr-2022 Simon Glass <sjg@chromium.org>

bootstd: Add tests for bootstd including all uclasses

Add a set of combined tests for the bootdev, bootflow and bootmeth
commands, along with associated functionality.

Expand the sandbox console-recording limit so that these can work.

These tests rely on a filesystem script which is not yet added to the
Python tests. It is included here as a shell script.

Signed-off-by: Simon Glass <sjg@chromium.org>