Merge branch '2022-04-25-initial-implementation-of-stdboot'
authorTom Rini <trini@konsulko.com>
Mon, 25 Apr 2022 20:02:27 +0000 (16:02 -0400)
committerTom Rini <trini@konsulko.com>
Mon, 25 Apr 2022 20:02:27 +0000 (16:02 -0400)
To quote the author:
The bootflow feature provide a built-in way for U-Boot to automatically
boot an Operating System without custom scripting and other customisation.
This is called 'standard boot' since it provides a standard way for
U-Boot to boot a distro, without scripting.

It introduces the following concepts:

   - bootdev - a device which can hold a distro
   - bootmeth - a method to scan a bootdev to find bootflows (owned by
                U-Boot)
   - bootflow - a description of how to boot (owned by the distro)

This series provides an implementation of these, enabled to scan for
bootflows from MMC, USB and Ethernet. It supports the existing distro
boot as well as the EFI loader flow (bootefi/bootmgr). It works
similiarly to the existing script-based approach, but is native to
U-Boot.

With this we can boot on a Raspberry Pi 3 with just one command:

   bootflow scan -lb

which means to scan, listing (-l) each bootflow and trying to boot each
one (-b). The final patch shows this.

With a standard way to identify boot devices, booting become easier. It
also should be possible to support U-Boot scripts, for backwards
compatibility only.

...

The design is described in these two documents:

https://drive.google.com/file/d/1ggW0KJpUOR__vBkj3l61L2dav4ZkNC12/view?usp=sharing

https://drive.google.com/file/d/1kTrflO9vvGlKp-ZH_jlgb9TY3WYG6FF9/view?usp=sharing

1  2 
MAINTAINERS
cmd/Kconfig
drivers/block/blk-uclass.c
include/dm/uclass-id.h

diff --combined MAINTAINERS
@@@ -690,10 -690,30 +690,31 @@@ F:      arch/arm/dts/phytium-durian.dt
  
  BINMAN
  M:    Simon Glass <sjg@chromium.org>
 +M:    Alper Nebi Yasak <alpernebiyasak@gmail.com>
  S:    Maintained
  F:    tools/binman/
  
+ BOOTDEVICE
+ M:    Simon Glass <sjg@chromium.org>
+ S:    Maintained
+ F:    boot/bootdev*.c
+ F:    boot/bootflow.c
+ F:    boot/bootmeth*.c
+ F:    boot/bootstd.c
+ F:    cmd/bootdev.c
+ F:    cmd/bootflow.c
+ F:    doc/develop/bootstd.rst
+ F:    doc/usage/bootdev.rst
+ F:    doc/usage/bootflow.rst
+ F:    doc/usage/bootmeth.rst
+ F:    drivers/mmc/mmc_bootdev.c
+ F:    include/bootdev.h
+ F:    include/bootflow.h
+ F:    include/bootmeth.h
+ F:    include/bootstd.h
+ F:    net/eth_bootdevice.c
+ F:    test/boot/
  BTRFS
  M:    Marek Behun <marek.behun@nic.cz>
  R:    Qu Wenruo <wqu@suse.com>
diff --combined cmd/Kconfig
@@@ -211,6 -211,45 +211,45 @@@ config CMD_BOOTM_PRE_LOA
         This stage allow to check or modify the image provided
         to the bootm command.
  
+ config CMD_BOOTDEV
+       bool "bootdev"
+       depends on BOOTSTD
+       default y if BOOTSTD_FULL
+       help
+         Support listing available bootdevs (boot devices) which can provide an
+         OS to boot, as well as showing information about a particular one.
+         This command is not necessary for bootstd to work.
+ config CMD_BOOTFLOW
+       bool "bootflow"
+       depends on BOOTSTD
+       default y
+       help
+         Support scanning for bootflows available with the bootdevs. The
+         bootflows can optionally be booted.
+ config CMD_BOOTFLOW_FULL
+       bool "bootflow - extract subcommands"
+       depends on BOOTSTD_FULL
+       default y if BOOTSTD_FULL
+       help
+         Add the ability to list the available bootflows, select one and obtain
+         information about it.
+         This command is not necessary for bootstd to work.
+ config CMD_BOOTMETH
+       bool "bootmeth"
+       depends on BOOTSTD
+       default y if BOOTSTD_FULL
+       help
+         Support listing available bootmethds (methods used to boot an
+         Operating System), as well as selecting the order that the bootmeths
+         are used.
+         This command is not necessary for bootstd to work.
  config BOOTM_EFI
        bool "Support booting UEFI FIT images"
        depends on CMD_BOOTEFI && CMD_BOOTM && FIT
@@@ -1246,7 -1285,6 +1285,7 @@@ config CMD_OS
  
  config CMD_PART
        bool "part"
 +      depends on PARTITIONS
        select HAVE_BLOCK_DEVICE
        select PARTITION_UUIDS
        help
@@@ -509,6 -509,13 +509,13 @@@ int blk_get_from_parent(struct udevice 
        return 0;
  }
  
+ const char *blk_get_devtype(struct udevice *dev)
+ {
+       struct udevice *parent = dev_get_parent(dev);
+       return uclass_get_name(device_get_uclass_id(parent));
+ };
  int blk_find_max_devnum(enum if_type if_type)
  {
        struct udevice *dev;
@@@ -741,10 -748,6 +748,10 @@@ static int blk_post_probe(struct udevic
                struct blk_desc *desc = dev_get_uclass_plat(dev);
  
                part_init(desc);
 +
 +              if (desc->part_type != PART_TYPE_UNKNOWN &&
 +                  part_create_block_devices(dev))
 +                      debug("*** creating partitions failed\n");
        }
  
        return 0;
diff --combined include/dm/uclass-id.h
@@@ -38,6 -38,9 +38,9 @@@ enum uclass_id 
        UCLASS_AXI,             /* AXI bus */
        UCLASS_BLK,             /* Block device */
        UCLASS_BOOTCOUNT,       /* Bootcount backing store */
+       UCLASS_BOOTDEV,         /* Boot device for locating an OS to boot */
+       UCLASS_BOOTMETH,        /* Bootmethod for booting an OS */
+       UCLASS_BOOTSTD,         /* Standard boot driver */
        UCLASS_BUTTON,          /* Button */
        UCLASS_CACHE,           /* Cache controller */
        UCLASS_CLK,             /* Clock source, e.g. used by peripherals */
@@@ -83,7 -86,6 +86,7 @@@
        UCLASS_P2SB,            /* (x86) Primary-to-Sideband Bus */
        UCLASS_PANEL,           /* Display panel, such as an LCD */
        UCLASS_PANEL_BACKLIGHT, /* Backlight controller for panel */
 +      UCLASS_PARTITION,       /* Logical disk partition device */
        UCLASS_PCH,             /* x86 platform controller hub */
        UCLASS_PCI,             /* PCI bus */
        UCLASS_PCI_EP,          /* PCI endpoint device */