aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-04-25 16:02:27 -0400
committerTom Rini <trini@konsulko.com>2022-04-25 16:02:27 -0400
commit8cfac237b9814d52c843e939a05fc211ba3906de (patch)
tree975bba394b3c71a225283c2cb04ecda5c4bb189d /include
parentbc9da9fb50ac3ba7603487a0366d4db60b984812 (diff)
parente7b2ce191ecab558b130b3b926dddcfc7231deb0 (diff)
downloadu-boot-8cfac237b9814d52c843e939a05fc211ba3906de.zip
u-boot-8cfac237b9814d52c843e939a05fc211ba3906de.tar.gz
u-boot-8cfac237b9814d52c843e939a05fc211ba3906de.tar.bz2
Merge branch '2022-04-25-initial-implementation-of-stdboot'
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
Diffstat (limited to 'include')
-rw-r--r--include/blk.h8
-rw-r--r--include/bootdev.h275
-rw-r--r--include/bootflow.h310
-rw-r--r--include/bootmeth.h234
-rw-r--r--include/bootstd.h80
-rw-r--r--include/distro.h24
-rw-r--r--include/dm/device.h2
-rw-r--r--include/dm/uclass-id.h3
-rw-r--r--include/dm/uclass-internal.h16
-rw-r--r--include/dm/uclass.h6
-rw-r--r--include/env_callback.h7
-rw-r--r--include/fs.h11
-rw-r--r--include/mmc.h12
-rw-r--r--include/test/suites.h2
-rw-r--r--include/vsprintf.h117
15 files changed, 1054 insertions, 53 deletions
diff --git a/include/blk.h b/include/blk.h
index dbe9ae2..9503369 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -434,6 +434,14 @@ int blk_select_hwpart(struct udevice *dev, int hwpart);
int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
/**
+ * blk_get_devtype() - Get the device type of a block device
+ *
+ * @dev: Block device to check
+ * Return: device tree, i.e. the uclass name of its parent, e.g. "mmc"
+ */
+const char *blk_get_devtype(struct udevice *dev);
+
+/**
* blk_get_by_device() - Get the block device descriptor for the given device
* @dev: Instance of a storage device
*
diff --git a/include/bootdev.h b/include/bootdev.h
new file mode 100644
index 0000000..9fc2198
--- /dev/null
+++ b/include/bootdev.h
@@ -0,0 +1,275 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootdev_h
+#define __bootdev_h
+
+#include <linux/list.h>
+
+struct bootflow;
+struct bootflow_iter;
+struct udevice;
+
+/**
+ * enum bootdev_prio_t - priority of each bootdev
+ *
+ * These values are associated with each bootdev and set up by the driver.
+ *
+ * Smallest value is the highest priority. By default, bootdevs are scanned from
+ * highest to lowest priority
+ */
+enum bootdev_prio_t {
+ BOOTDEVP_0_INTERNAL_FAST = 10,
+ BOOTDEVP_1_INTERNAL_SLOW = 20,
+ BOOTDEVP_2_SCAN_FAST = 30,
+ BOOTDEVP_3_SCAN_SLOW = 40,
+ BOOTDEVP_4_NET_BASE = 50,
+ BOOTDEVP_5_NET_FALLBACK = 60,
+ BOOTDEVP_6_SYSTEM = 70,
+
+ BOOTDEVP_COUNT,
+};
+
+/**
+ * struct bootdev_uc_plat - uclass information about a bootdev
+ *
+ * This is attached to each device in the bootdev uclass and accessible via
+ * dev_get_uclass_plat(dev)
+ *
+ * @bootflows: List of available bootflows for this bootdev
+ * @piro: Priority of this bootdev
+ */
+struct bootdev_uc_plat {
+ struct list_head bootflow_head;
+ enum bootdev_prio_t prio;
+};
+
+/** struct bootdev_ops - Operations for the bootdev uclass */
+struct bootdev_ops {
+ /**
+ * get_bootflow() - get a bootflow
+ *
+ * @dev: Bootflow device to check
+ * @iter: Provides current dev, part, method to get. Should update
+ * max_part if there is a partition table. Should update state,
+ * subdir, fname, buf, size according to progress
+ * @bflow: Updated bootflow if found
+ * Return: 0 if OK, -ESHUTDOWN if there are no more bootflows on this
+ * device, -ENOSYS if this device doesn't support bootflows,
+ * other -ve value on other error
+ */
+ int (*get_bootflow)(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow);
+};
+
+#define bootdev_get_ops(dev) ((struct bootdev_ops *)(dev)->driver->ops)
+
+/**
+ * bootdev_get_bootflow() - get a bootflow
+ *
+ * @dev: Bootflow device to check
+ * @iter: Provides current part, method to get
+ * @bflow: Returns bootflow if found
+ * Return: 0 if OK, -ESHUTDOWN if there are no more bootflows on this device,
+ * -ENOSYS if this device doesn't support bootflows, other -ve value on
+ * other error
+ */
+int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow);
+
+/**
+ * bootdev_bind() - Bind a new named bootdev device
+ *
+ * @parent: Parent of the new device
+ * @drv_name: Driver name to use for the bootdev device
+ * @name: Name for the device (parent name is prepended)
+ * @devp: the new device (which has not been probed)
+ */
+int bootdev_bind(struct udevice *parent, const char *drv_name, const char *name,
+ struct udevice **devp);
+
+/**
+ * bootdev_find_in_blk() - Find a bootdev in a block device
+ *
+ * @dev: Bootflow device associated with this block device
+ * @blk: Block device to search
+ * @iter: Provides current dev, part, method to get. Should update
+ * max_part if there is a partition table
+ * @bflow: On entry, provides information about the partition and device to
+ * check. On exit, returns bootflow if found
+ * Return: 0 if found, -ESHUTDOWN if no more bootflows, other -ve on error
+ */
+int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
+ struct bootflow_iter *iter, struct bootflow *bflow);
+
+/**
+ * bootdev_list() - List all available bootdevs
+ *
+ * @probe: true to probe devices, false to leave them as is
+ */
+void bootdev_list(bool probe);
+
+/**
+ * bootdev_clear_bootflows() - Clear bootflows from a bootdev
+ *
+ * Each bootdev maintains a list of discovered bootflows. This provides a
+ * way to clear it. These bootflows are removed from the global list too.
+ *
+ * @dev: bootdev device to update
+ */
+void bootdev_clear_bootflows(struct udevice *dev);
+
+/**
+ * bootdev_add_bootflow() - Add a bootflow to the bootdev's list
+ *
+ * All fields in @bflow must be set up. Note that @bflow->dev is used to add the
+ * bootflow to that device.
+ *
+ * @dev: Bootdevice device to add to
+ * @bflow: Bootflow to add. Note that fields within bflow must be allocated
+ * since this function takes over ownership of these. This functions makes
+ * a copy of @bflow itself (without allocating its fields again), so the
+ * caller must dispose of the memory used by the @bflow pointer itself
+ * Return: 0 if OK, -ENOMEM if out of memory
+ */
+int bootdev_add_bootflow(struct bootflow *bflow);
+
+/**
+ * bootdev_first_bootflow() - Get the first bootflow from a bootdev
+ *
+ * Returns the first bootflow attached to a bootdev
+ *
+ * @dev: bootdev device
+ * @bflowp: Returns a pointer to the bootflow
+ * Return: 0 if found, -ENOENT if there are no bootflows
+ */
+int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp);
+
+/**
+ * bootdev_next_bootflow() - Get the next bootflow from a bootdev
+ *
+ * Returns the next bootflow attached to a bootdev
+ *
+ * @bflowp: On entry, the last bootflow returned , e.g. from
+ * bootdev_first_bootflow()
+ * Return: 0 if found, -ENOENT if there are no more bootflows
+ */
+int bootdev_next_bootflow(struct bootflow **bflowp);
+
+/**
+ * bootdev_find_by_label() - Look up a bootdev by label
+ *
+ * Each bootdev has a label which contains the media-uclass name and a number,
+ * e.g. 'mmc2'. This looks up the label and returns the associated bootdev
+ *
+ * The lookup is performed based on the media device's sequence number. So for
+ * 'mmc2' this looks for a device in UCLASS_MMC with a dev_seq() of 2.
+ *
+ * @label: Label to look up (e.g. "mmc1" or "mmc0")
+ * @devp: Returns the bootdev device found, or NULL if none (note it does not
+ * return the media device, but its bootdev child)
+ * Return: 0 if OK, -EINVAL if the uclass is not supported by this board,
+ * -ENOENT if there is no device with that number
+ */
+int bootdev_find_by_label(const char *label, struct udevice **devp);
+
+/**
+ * bootdev_find_by_any() - Find a bootdev by name, label or sequence
+ *
+ * @name: name (e.g. "mmc2.bootdev"), label ("mmc2"), or sequence ("2") to find
+ * @devp: returns the device found, on success
+ * Return: 0 if OK, -ve on error
+ */
+int bootdev_find_by_any(const char *name, struct udevice **devp);
+
+/**
+ * bootdev_setup_iter_order() - Set up the ordering of bootdevs to scan
+ *
+ * This sets up the ordering information in @iter, based on the priority of each
+ * bootdev and the bootdev-order property in the bootstd node
+ *
+ * If a single device is requested, no ordering is needed
+ *
+ * @iter: Iterator to update with the order
+ * @devp: On entry, *devp is NULL to scan all, otherwise this is the (single)
+ * device to scan. Returns the first device to use, which is the passed-in
+ * @devp if it was non-NULL
+ * Return: 0 if OK, -ENOENT if no bootdevs, -ENOMEM if out of memory, other -ve
+ * on other error
+ */
+int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp);
+
+#if CONFIG_IS_ENABLED(BOOTSTD)
+/**
+ * bootdev_setup_for_dev() - Bind a new bootdev device
+ *
+ * Creates a bootdev device as a child of @parent. This should be called from
+ * the driver's bind() method or its uclass' post_bind() method.
+ *
+ * If a child bootdev already exists, this function does nothing
+ *
+ * @parent: Parent device (e.g. MMC or Ethernet)
+ * @drv_name: Name of bootdev driver to bind
+ * Return: 0 if OK, -ve on error
+ */
+int bootdev_setup_for_dev(struct udevice *parent, const char *drv_name);
+
+/**
+ * bootdev_setup_for_blk() - Bind a new bootdev device for a blk device
+ *
+ * Creates a bootdev device as a sibling of @blk. This should be called from
+ * the driver's bind() method or its uclass' post_bind() method, at the same
+ * time as the bould device is bound
+ *
+ * If a device of the same name already exists, this function does nothing
+ *
+ * @parent: Parent device (e.g. MMC or Ethernet)
+ * @drv_name: Name of bootdev driver to bind
+ * Return: 0 if OK, -ve on error
+ */
+int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name);
+
+/**
+ * bootdev_get_sibling_blk() - Locate the block device for a bootdev
+ *
+ * @dev: bootdev to check
+ * @blkp: returns associated block device
+ * Return: 0 if OK, -EINVAL if @dev is not a bootdev device, other -ve on other
+ * error
+ */
+int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp);
+
+/**
+ * bootdev_unbind_dev() - Unbind a bootdev device
+ *
+ * Remove and unbind a bootdev device which is a child of @parent. This should
+ * be called from the driver's unbind() method or its uclass' post_bind()
+ * method.
+ *
+ * @parent: Parent device (e.g. MMC or Ethernet)
+ * Return: 0 if OK, -ve on error
+ */
+int bootdev_unbind_dev(struct udevice *parent);
+#else
+static inline int bootdev_setup_for_dev(struct udevice *parent,
+ const char *drv_name)
+{
+ return 0;
+}
+
+static inline int bootdev_setup_sibling_blk(struct udevice *blk,
+ const char *drv_name)
+{
+ return 0;
+}
+
+static inline int bootdev_unbind_dev(struct udevice *parent)
+{
+ return 0;
+}
+#endif
+
+#endif
diff --git a/include/bootflow.h b/include/bootflow.h
new file mode 100644
index 0000000..c30ba04
--- /dev/null
+++ b/include/bootflow.h
@@ -0,0 +1,310 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootflow_h
+#define __bootflow_h
+
+#include <linux/list.h>
+
+/**
+ * enum bootflow_state_t - states that a particular bootflow can be in
+ *
+ * Only bootflows in state BOOTFLOWST_READY can be used to boot.
+ *
+ * See bootflow_state[] for the names for each of these
+ */
+enum bootflow_state_t {
+ BOOTFLOWST_BASE, /**< Nothing known yet */
+ BOOTFLOWST_MEDIA, /**< Media exists */
+ BOOTFLOWST_PART, /**< Partition exists */
+ BOOTFLOWST_FS, /**< Filesystem exists */
+ BOOTFLOWST_FILE, /**< Bootflow file exists */
+ BOOTFLOWST_READY, /**< Bootflow file loaded */
+
+ BOOTFLOWST_COUNT
+};
+
+/**
+ * struct bootflow - information about a bootflow
+ *
+ * This is connected into two separate linked lists:
+ *
+ * bm_sibling - links all bootflows in the same bootdev
+ * glob_sibling - links all bootflows in all bootdevs
+ *
+ * @bm_node: Points to siblings in the same bootdev
+ * @glob_node: Points to siblings in the global list (all bootdev)
+ * @dev: Bootdevice device which produced this bootflow
+ * @blk: Block device which contains this bootflow, NULL if this is a network
+ * device
+ * @part: Partition number (0 for whole device)
+ * @fs_type: Filesystem type (FS_TYPE...) if this is fixed by the media, else 0.
+ * For example, the sandbox host-filesystem bootdev sets this to
+ * FS_TYPE_SANDBOX
+ * @method: Bootmethod device used to perform the boot and read files
+ * @name: Name of bootflow (allocated)
+ * @state: Current state (enum bootflow_state_t)
+ * @subdir: Subdirectory to fetch files from (with trailing /), or NULL if none
+ * @fname: Filename of bootflow file (allocated)
+ * @buf: Bootflow file contents (allocated)
+ * @size: Size of bootflow file in bytes
+ * @err: Error number received (0 if OK)
+ */
+struct bootflow {
+ struct list_head bm_node;
+ struct list_head glob_node;
+ struct udevice *dev;
+ struct udevice *blk;
+ int part;
+ int fs_type;
+ struct udevice *method;
+ char *name;
+ enum bootflow_state_t state;
+ char *subdir;
+ char *fname;
+ char *buf;
+ int size;
+ int err;
+};
+
+/**
+ * enum bootflow_flags_t - flags for the bootflow iterator
+ *
+ * @BOOTFLOWF_FIXED: Only used fixed/internal media
+ * @BOOTFLOWF_SHOW: Show each bootdev before scanning it
+ * @BOOTFLOWF_ALL: Return bootflows with errors as well
+ * @BOOTFLOWF_SINGLE_DEV: Just scan one bootmeth
+ */
+enum bootflow_flags_t {
+ BOOTFLOWF_FIXED = 1 << 0,
+ BOOTFLOWF_SHOW = 1 << 1,
+ BOOTFLOWF_ALL = 1 << 2,
+ BOOTFLOWF_SINGLE_DEV = 1 << 3,
+};
+
+/**
+ * struct bootflow_iter - state for iterating through bootflows
+ *
+ * This starts at with the first bootdev/partition/bootmeth and can be used to
+ * iterate through all of them.
+ *
+ * Iteration starts with the bootdev. The first partition (0, i.e. whole device)
+ * is scanned first. For partition 0, it iterates through all the available
+ * bootmeths to see which one(s) can provide a bootflow. Then it moves to
+ * parition 1 (if there is one) and the process continues. Once all partitions
+ * are examined, it moves to the next bootdev.
+ *
+ * Initially @max_part is 0, meaning that only the whole device (@part=0) can be
+ * used. During scanning, if a partition table is found, then @max_part is
+ * updated to a larger value, no less than the number of available partitions.
+ * This ensures that iteration works through all partitions on the bootdev.
+ *
+ * @flags: Flags to use (see enum bootflow_flags_t)
+ * @dev: Current bootdev
+ * @part: Current partition number (0 for whole device)
+ * @method: Current bootmeth
+ * @max_part: Maximum hardware partition number in @dev, 0 if there is no
+ * partition table
+ * @err: Error obtained from checking the last iteration. This is used to skip
+ * forward (e.g. to skip the current partition because it is not valid)
+ * -ESHUTDOWN: try next bootdev
+ * @num_devs: Number of bootdevs in @dev_order
+ * @cur_dev: Current bootdev number, an index into @dev_order[]
+ * @dev_order: List of bootdevs to scan, in order of priority. The scan starts
+ * with the first one on the list
+ * @num_methods: Number of bootmeth devices in @method_order
+ * @cur_method: Current method number, an index into @method_order
+ * @method_order: List of bootmeth devices to use, in order
+ */
+struct bootflow_iter {
+ int flags;
+ struct udevice *dev;
+ int part;
+ struct udevice *method;
+ int max_part;
+ int err;
+ int num_devs;
+ int cur_dev;
+ struct udevice **dev_order;
+ int num_methods;
+ int cur_method;
+ struct udevice **method_order;
+};
+
+/**
+ * bootflow_iter_init() - Reset a bootflow iterator
+ *
+ * This sets everything to the starting point, ready for use.
+ *
+ * @iter: Place to store private info (inited by this call)
+ * @flags: Flags to use (see enum bootflow_flags_t)
+ */
+void bootflow_iter_init(struct bootflow_iter *iter, int flags);
+
+/**
+ * bootflow_iter_uninit() - Free memory used by an interator
+ *
+ * @iter: Iterator to free
+ */
+void bootflow_iter_uninit(struct bootflow_iter *iter);
+
+/**
+ * bootflow_iter_drop_bootmeth() - Remove a bootmeth from an iterator
+ *
+ * Update the iterator so that the bootmeth will not be used again while this
+ * iterator is in use
+ *
+ * @iter: Iterator to update
+ * @bmeth: Boot method to remove
+ */
+int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter,
+ const struct udevice *bmeth);
+
+/**
+ * bootflow_scan_bootdev() - find the first bootflow in a bootdev
+ *
+ * If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too
+ *
+ * @dev: Boot device to scan, NULL to work through all of them until it
+ * finds one that * can supply a bootflow
+ * @iter: Place to store private info (inited by this call)
+ * @flags: Flags for bootdev (enum bootflow_flags_t)
+ * @bflow: Place to put the bootflow if found
+ * Return: 0 if found, -ENODEV if no device, other -ve on other error
+ * (iteration can continue)
+ */
+int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter,
+ int flags, struct bootflow *bflow);
+
+/**
+ * bootflow_scan_first() - find the first bootflow
+ *
+ * This works through the available bootdev devices until it finds one that
+ * can supply a bootflow. It then returns that
+ *
+ * If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too
+ *
+ * @iter: Place to store private info (inited by this call), with
+ * @flags: Flags for bootdev (enum bootflow_flags_t)
+ * @bflow: Place to put the bootflow if found
+ * Return: 0 if found, -ENODEV if no device, other -ve on other error (iteration
+ * can continue)
+ */
+int bootflow_scan_first(struct bootflow_iter *iter, int flags,
+ struct bootflow *bflow);
+
+/**
+ * bootflow_scan_next() - find the next bootflow
+ *
+ * This works through the available bootdev devices until it finds one that
+ * can supply a bootflow. It then returns that bootflow
+ *
+ * @iter: Private info (as set up by bootflow_scan_first())
+ * @bflow: Place to put the bootflow if found
+ * Return: 0 if found, -ENODEV if no device, -ESHUTDOWN if no more bootflows,
+ * other -ve on other error (iteration can continue)
+ */
+int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow);
+
+/**
+ * bootflow_first_glob() - Get the first bootflow from the global list
+ *
+ * Returns the first bootflow in the global list, no matter what bootflow it is
+ * attached to
+ *
+ * @bflowp: Returns a pointer to the bootflow
+ * Return: 0 if found, -ENOENT if there are no bootflows
+ */
+int bootflow_first_glob(struct bootflow **bflowp);
+
+/**
+ * bootflow_next_glob() - Get the next bootflow from the global list
+ *
+ * Returns the next bootflow in the global list, no matter what bootflow it is
+ * attached to
+ *
+ * @bflowp: On entry, the last bootflow returned , e.g. from
+ * bootflow_first_glob()
+ * Return: 0 if found, -ENOENT if there are no more bootflows
+ */
+int bootflow_next_glob(struct bootflow **bflowp);
+
+/**
+ * bootflow_free() - Free memory used by a bootflow
+ *
+ * This frees fields within @bflow, but not the @bflow pointer itself
+ */
+void bootflow_free(struct bootflow *bflow);
+
+/**
+ * bootflow_boot() - boot a bootflow
+ *
+ * @bflow: Bootflow to boot
+ * Return: -EPROTO if bootflow has not been loaded, -ENOSYS if the bootflow
+ * type is not supported, -EFAULT if the boot returned without an error
+ * when we are expecting it to boot, -ENOTSUPP if trying method resulted in
+ * finding out that is not actually supported for this boot and should not
+ * be tried again unless something changes
+ */
+int bootflow_boot(struct bootflow *bflow);
+
+/**
+ * bootflow_run_boot() - Try to boot a bootflow
+ *
+ * @iter: Current iteration (or NULL if none). Used to disable a bootmeth if the
+ * boot returns -ENOTSUPP
+ * @bflow: Bootflow to boot
+ * Return: result of trying to boot
+ */
+int bootflow_run_boot(struct bootflow_iter *iter, struct bootflow *bflow);
+
+/**
+ * bootflow_state_get_name() - Get the name of a bootflow state
+ *
+ * @state: State to check
+ * Return: name, or "?" if invalid
+ */
+const char *bootflow_state_get_name(enum bootflow_state_t state);
+
+/**
+ * bootflow_remove() - Remove a bootflow and free its memory
+ *
+ * This updates the linked lists containing the bootflow then frees it.
+ *
+ * @bflow: Bootflow to remove
+ */
+void bootflow_remove(struct bootflow *bflow);
+
+/**
+ * bootflow_iter_uses_blk_dev() - Check that a bootflow uses a block device
+ *
+ * This checks the bootdev in the bootflow to make sure it uses a block device
+ *
+ * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. ethernet)
+ */
+int bootflow_iter_uses_blk_dev(const struct bootflow_iter *iter);
+
+/**
+ * bootflow_iter_uses_network() - Check that a bootflow uses a network device
+ *
+ * This checks the bootdev in the bootflow to make sure it uses a network
+ * device
+ *
+ * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. MMC)
+ */
+int bootflow_iter_uses_network(const struct bootflow_iter *iter);
+
+/**
+ * bootflow_iter_uses_system() - Check that a bootflow uses the bootstd device
+ *
+ * This checks the bootdev in the bootflow to make sure it uses the bootstd
+ * device
+ *
+ * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. MMC)
+ */
+int bootflow_iter_uses_system(const struct bootflow_iter *iter);
+
+#endif
diff --git a/include/bootmeth.h b/include/bootmeth.h
new file mode 100644
index 0000000..484e503
--- /dev/null
+++ b/include/bootmeth.h
@@ -0,0 +1,234 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootmeth_h
+#define __bootmeth_h
+
+struct blk_desc;
+struct bootflow;
+struct bootflow_iter;
+struct udevice;
+
+/**
+ * struct bootmeth_uc_plat - information the uclass keeps about each bootmeth
+ *
+ * @desc: A long description of the bootmeth
+ */
+struct bootmeth_uc_plat {
+ const char *desc;
+};
+
+/** struct bootmeth_ops - Operations for boot methods */
+struct bootmeth_ops {
+ /**
+ * check_supported() - check if a bootmeth supports this bootflow
+ *
+ * This is optional. If not provided, the bootdev is assumed to be
+ * supported
+ *
+ * The bootmeth can check the bootdev (e.g. to make sure it is a
+ * network device) or the partition information. The following fields
+ * in @iter are available:
+ *
+ * name, dev, state, part
+ * max_part may be set if part != 0 (i.e. there is a valid partition
+ * table). Otherwise max_part is 0
+ * method is available but is the same as @dev
+ * the partition has not yet been read, nor has the filesystem been
+ * checked
+ *
+ * It may update only the flags in @iter
+ *
+ * @dev: Bootmethod device to check against
+ * @iter: On entry, provides bootdev, hwpart, part
+ * Return: 0 if OK, -ENOTSUPP if this bootdev is not supported
+ */
+ int (*check)(struct udevice *dev, struct bootflow_iter *iter);
+
+ /**
+ * read_bootflow() - read a bootflow for a device
+ *
+ * @dev: Bootmethod device to use
+ * @bflow: On entry, provides dev, hwpart, part and method.
+ * Returns updated bootflow if found
+ * Return: 0 if OK, -ve on error
+ */
+ int (*read_bootflow)(struct udevice *dev, struct bootflow *bflow);
+
+ /**
+ * read_file() - read a file needed for a bootflow
+ *
+ * Read a file from the same place as the bootflow came from
+ *
+ * @dev: Bootmethod device to use
+ * @bflow: Bootflow providing info on where to read from
+ * @file_path: Path to file (may be absolute or relative)
+ * @addr: Address to load file
+ * @sizep: On entry provides the maximum permitted size; on exit
+ * returns the size of the file
+ * Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
+ * -ve value if something else goes wrong
+ */
+ int (*read_file)(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep);
+
+ /**
+ * boot() - boot a bootflow
+ *
+ * @dev: Bootmethod device to boot
+ * @bflow: Bootflow to boot
+ * Return: does not return on success, since it should boot the
+ * Operating Systemn. Returns -EFAULT if that fails, -ENOTSUPP if
+ * trying method resulted in finding out that is not actually
+ * supported for this boot and should not be tried again unless
+ * something changes, other -ve on other error
+ */
+ int (*boot)(struct udevice *dev, struct bootflow *bflow);
+};
+
+#define bootmeth_get_ops(dev) ((struct bootmeth_ops *)(dev)->driver->ops)
+
+/**
+ * bootmeth_check() - check if a bootmeth supports this bootflow
+ *
+ * This is optional. If not provided, the bootdev is assumed to be
+ * supported
+ *
+ * The bootmeth can check the bootdev (e.g. to make sure it is a
+ * network device) or the partition information. The following fields
+ * in @iter are available:
+ *
+ * name, dev, state, part
+ * max_part may be set if part != 0 (i.e. there is a valid partition
+ * table). Otherwise max_part is 0
+ * method is available but is the same as @dev
+ * the partition has not yet been read, nor has the filesystem been
+ * checked
+ *
+ * It may update only the flags in @iter
+ *
+ * @dev: Bootmethod device to check against
+ * @iter: On entry, provides bootdev, hwpart, part
+ * Return: 0 if OK, -ENOTSUPP if this bootdev is not supported
+ */
+int bootmeth_check(struct udevice *dev, struct bootflow_iter *iter);
+
+/**
+ * bootmeth_read_bootflow() - set up a bootflow for a device
+ *
+ * @dev: Bootmethod device to check
+ * @bflow: On entry, provides dev, hwpart, part and method.
+ * Returns updated bootflow if found
+ * Return: 0 if OK, -ve on error
+ */
+int bootmeth_read_bootflow(struct udevice *dev, struct bootflow *bflow);
+
+/**
+ * bootmeth_read_file() - read a file needed for a bootflow
+ *
+ * Read a file from the same place as the bootflow came from
+ *
+ * @dev: Bootmethod device to use
+ * @bflow: Bootflow providing info on where to read from
+ * @file_path: Path to file (may be absolute or relative)
+ * @addr: Address to load file
+ * @sizep: On entry provides the maximum permitted size; on exit
+ * returns the size of the file
+ * Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
+ * -ve value if something else goes wrong
+ */
+int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep);
+
+/**
+ * bootmeth_boot() - boot a bootflow
+ *
+ * @dev: Bootmethod device to boot
+ * @bflow: Bootflow to boot
+ * Return: does not return on success, since it should boot the
+ * Operating Systemn. Returns -EFAULT if that fails, other -ve on
+ * other error
+ */
+int bootmeth_boot(struct udevice *dev, struct bootflow *bflow);
+
+/**
+ * bootmeth_setup_iter_order() - Set up the ordering of bootmeths to scan
+ *
+ * This sets up the ordering information in @iter, based on the selected
+ * ordering of the bootmethds in bootstd_priv->bootmeth_order. If there is no
+ * ordering there, then all bootmethods are added
+ *
+ * @iter: Iterator to update with the order
+ * Return: 0 if OK, -ENOENT if no bootdevs, -ENOMEM if out of memory, other -ve
+ * on other error
+ */
+int bootmeth_setup_iter_order(struct bootflow_iter *iter);
+
+/**
+ * bootmeth_set_order() - Set the bootmeth order
+ *
+ * This selects the ordering to use for bootmeths
+ *
+ * @order_str: String containing the ordering. This is a comma-separate list of
+ * bootmeth-device names, e.g. "syslinux,efi". If empty then a default ordering
+ * is used, based on the sequence number of devices (i.e. using aliases)
+ * Return: 0 if OK, -ENODEV if an unknown bootmeth is mentioned, -ENOMEM if
+ * out of memory, -ENOENT if there are no bootmeth devices
+ */
+int bootmeth_set_order(const char *order_str);
+
+/**
+ * bootmeth_try_file() - See we can access a given file
+ *
+ * Check for a file with a given name. If found, the filename is allocated in
+ * @bflow
+ *
+ * Sets the state to BOOTFLOWST_FILE on success. It also calls
+ * fs_set_blk_dev_with_part() so that this does not need to be done by the
+ * caller before reading the file.
+ *
+ * @bflow: Information about file to try
+ * @desc: Block descriptor to read from
+ * @prefix: Filename prefix to prepend to @fname (NULL for none)
+ * @fname: Filename to read
+ * Return: 0 if OK, -ENOMEM if not enough memory to allocate bflow->fname,
+ * other -ve value on other error
+ */
+int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc,
+ const char *prefix, const char *fname);
+
+/**
+ * bootmeth_alloc_file() - Allocate and read a bootflow file
+ *
+ * Allocates memory for a bootflow file and reads it in. Sets the state to
+ * BOOTFLOWST_READY on success
+ *
+ * Note that fs_set_blk_dev_with_part() must have been called previously.
+ *
+ * @bflow: Information about file to read
+ * @size_limit: Maximum file size to permit
+ * @align: Allocation alignment (1 for unaligned)
+ * Return: 0 if OK, -E2BIG if file is too large, -ENOMEM if out of memory,
+ * other -ve on other error
+ */
+int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align);
+
+/**
+ * bootmeth_common_read_file() - Common handler for reading a file
+ *
+ * Reads a named file from the same location as the bootflow file.
+ *
+ * @dev: bootmeth device to read from
+ * @bflow: Bootflow information
+ * @file_path: Path to file
+ * @addr: Address to load file to
+ * @sizep: On entry, the maximum file size to accept, on exit the actual file
+ * size read
+ */
+int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep);
+
+#endif
diff --git a/include/bootstd.h b/include/bootstd.h
new file mode 100644
index 0000000..b002365
--- /dev/null
+++ b/include/bootstd.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Standard U-Boot boot framework
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootstd_h
+#define __bootstd_h
+
+struct udevice;
+
+/**
+ * struct bootstd_priv - priv data for the bootstd driver
+ *
+ * This is attached to the (only) bootstd device, so there is only one instance
+ * of this struct. It provides overall information about bootdevs and bootflows.
+ *
+ * @prefixes: NULL-terminated list of prefixes to use for bootflow filenames,
+ * e.g. "/", "/boot/"; NULL if none
+ * @bootdev_order: Order to use for bootdevs (or NULL if none), with each item
+ * being a bootdev label, e.g. "mmc2", "mmc1";
+ * @cur_bootdev: Currently selected bootdev (for commands)
+ * @cur_bootflow: Currently selected bootflow (for commands)
+ * @glob_head: Head for the global list of all bootflows across all bootdevs
+ * @bootmeth_count: Number of bootmeth devices in @bootmeth_order
+ * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated
+ */
+struct bootstd_priv {
+ const char **prefixes;
+ const char **bootdev_order;
+ struct udevice *cur_bootdev;
+ struct bootflow *cur_bootflow;
+ struct list_head glob_head;
+ int bootmeth_count;
+ struct udevice **bootmeth_order;
+};
+
+/**
+ * bootstd_get_bootdev_order() - Get the boot-order list
+ *
+ * This reads the boot order, e.g. {"mmc0", "mmc2", NULL}
+ *
+ * The list is alloced by the bootstd driver so should not be freed. That is the
+ * reason for all the const stuff in the function signature
+ *
+ * Return: list of string points, terminated by NULL; or NULL if no boot order
+ */
+const char *const *const bootstd_get_bootdev_order(struct udevice *dev);
+
+/**
+ * bootstd_get_prefixes() - Get the filename-prefixes list
+ *
+ * This reads the prefixes, e.g. {"/", "/bpot", NULL}
+ *
+ * The list is alloced by the bootstd driver so should not be freed. That is the
+ * reason for all the const stuff in the function signature
+ *
+ * Return: list of string points, terminated by NULL; or NULL if no boot order
+ */
+const char *const *const bootstd_get_prefixes(struct udevice *dev);
+
+/**
+ * bootstd_get_priv() - Get the (single) state for the bootstd system
+ *
+ * The state holds a global list of all bootflows that have been found.
+ *
+ * Return: 0 if OK, -ve if the uclass does not exist
+ */
+int bootstd_get_priv(struct bootstd_priv **stdp);
+
+/**
+ * bootstd_clear_glob() - Clear the global list of bootflows
+ *
+ * This removes all bootflows globally and across all bootdevs.
+ */
+void bootstd_clear_glob(void);
+
+#endif
diff --git a/include/distro.h b/include/distro.h
new file mode 100644
index 0000000..2ee1458
--- /dev/null
+++ b/include/distro.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __distro_h
+#define __distro_h
+
+#define DISTRO_FNAME "extlinux/extlinux.conf"
+
+/**
+ * struct distro_info - useful information for distro_getfile()
+ *
+ * @dev: bootmethod device being used to boot
+ * @bflow: bootflow being booted
+ */
+struct distro_info {
+ struct udevice *dev;
+ struct bootflow *bflow;
+ struct cmd_tbl *cmdtp;
+};
+
+#endif
diff --git a/include/dm/device.h b/include/dm/device.h
index e0f86f5..b474888 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -799,7 +799,7 @@ int device_find_first_child_by_uclass(const struct udevice *parent,
struct udevice **devp);
/**
- * device_find_child_by_name() - Find a child by device name
+ * device_find_child_by_namelen() - Find a child by device name
*
* @parent: Parent device to search
* @name: Name to look for
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 230b1ea..3ba69ad 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -38,6 +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 */
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index daf856c..3ddcdd2 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -155,6 +155,22 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp);
int uclass_find_next_device(struct udevice **devp);
/**
+ * uclass_find_device_by_namelen() - Find uclass device based on ID and name
+ *
+ * This searches for a device with the exactly given name.
+ *
+ * The device is NOT probed, it is merely returned.
+ *
+ * @id: ID to look up
+ * @name: name of a device to find
+ * @len: Length of @name (the uclass driver name must have the same length)
+ * @devp: Returns pointer to device (the first one with the name)
+ * Return: 0 if OK, -ve on error
+ */
+int uclass_find_device_by_namelen(enum uclass_id id, const char *name, int len,
+ struct udevice **devp);
+
+/**
* uclass_find_device_by_name() - Find uclass device based on ID and name
*
* This searches for a device with the exactly given name.
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index aafe652..f6c0110 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -173,13 +173,13 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);
const char *uclass_get_name(enum uclass_id id);
/**
- * uclass_get_by_name_len() - Look up a uclass by its partial driver name
+ * uclass_get_by_namelen() - Look up a uclass by its driver name
*
* @name: Name to look up
- * @len: Length of the partial name
+ * @len: Length of @name (the uclass driver name must have the same length)
* Return: the associated uclass ID, or UCLASS_INVALID if not found
*/
-enum uclass_id uclass_get_by_name_len(const char *name, int len);
+enum uclass_id uclass_get_by_namelen(const char *name, int len);
/**
* uclass_get_by_name() - Look up a uclass by its driver name
diff --git a/include/env_callback.h b/include/env_callback.h
index 05e9516..d5d2b2f 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -57,6 +57,12 @@
#define NET_CALLBACKS
#endif
+#ifdef CONFIG_BOOTSTD
+#define BOOTSTD_CALLBACK "bootmeths:bootmeths,"
+#else
+#define BOOTSTD_CALLBACK
+#endif
+
/*
* This list of callback bindings is static, but may be overridden by defining
* a new association in the ".callbacks" environment variable.
@@ -65,6 +71,7 @@
ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \
"baudrate:baudrate," \
NET_CALLBACKS \
+ BOOTSTD_CALLBACK \
"loadaddr:loadaddr," \
SILENT_CALLBACK \
SPLASHIMAGE_CALLBACK \
diff --git a/include/fs.h b/include/fs.h
index e2beba3..b43f16a 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -57,6 +57,17 @@ int do_ext2load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
*/
int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype);
+/**
+ * fs_set_type() - Tell fs layer which filesystem type is used
+ *
+ * This is needed when reading from a non-block device such as sandbox. It does
+ * a similar job to fs_set_blk_dev() but just sets the filesystem type instead
+ * of detecting it and loading it on the block device
+ *
+ * @type: Filesystem type to use (FS_TYPE...)
+ */
+void fs_set_type(int type);
+
/*
* fs_set_blk_dev_with_part - Set current block device + partition
*
diff --git a/include/mmc.h b/include/mmc.h
index 6bdcce8..9b4dc68 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -956,11 +956,21 @@ int mmc_get_env_dev(void);
* mmc_get_blk_desc() - Get the block descriptor for an MMC device
*
* @mmc: MMC device
- * Return: block device if found, else NULL
+ * Return: block descriptor if found, else NULL
*/
struct blk_desc *mmc_get_blk_desc(struct mmc *mmc);
/**
+ * mmc_get_blk() - Get the block device for an MMC device
+ *
+ * @dev: MMC device
+ * @blkp: Returns pointer to probed block device on sucesss
+ *
+ * Return: 0 on success, -ve on error
+ */
+int mmc_get_blk(struct udevice *dev, struct udevice **blkp);
+
+/**
* mmc_send_ext_csd() - read the extended CSD register
*
* @mmc: MMC device
diff --git a/include/test/suites.h b/include/test/suites.h
index 6553a76..ee6858a 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -29,6 +29,8 @@ int cmd_ut_category(const char *name, const char *prefix,
int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[]);
int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[]);
int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[]);
int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/include/vsprintf.h b/include/vsprintf.h
index 532ef36..e006af2 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -13,9 +13,9 @@
/**
* simple_strtoul - convert a string to an unsigned long
*
- * @param cp The string to be converted
- * @param endp Updated to point to the first character not converted
- * @param base The number base to use (0 for the default)
+ * @cp: The string to be converted
+ * @endp: Updated to point to the first character not converted
+ * @base: The number base to use (0 for the default)
* Return: value decoded from string (0 if invalid)
*
* Converts a string to an unsigned long. If there are invalid characters at
@@ -34,8 +34,8 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
/**
* hex_strtoul - convert a string in hex to an unsigned long
*
- * @param cp The string to be converted
- * @param endp Updated to point to the first character not converted
+ * @cp: The string to be converted
+ * @endp: Updated to point to the first character not converted
* Return: value decoded from string (0 if invalid)
*
* Converts a hex string to an unsigned long. If there are invalid characters at
@@ -47,8 +47,8 @@ unsigned long hextoul(const char *cp, char **endp);
/**
* dec_strtoul - convert a string in decimal to an unsigned long
*
- * @param cp The string to be converted
- * @param endp Updated to point to the first character not converted
+ * @cp: The string to be converted
+ * @endp: Updated to point to the first character not converted
* Return: value decoded from string (0 if invalid)
*
* Converts a decimal string to an unsigned long. If there are invalid
@@ -59,11 +59,11 @@ unsigned long dectoul(const char *cp, char **endp);
/**
* strict_strtoul - convert a string to an unsigned long strictly
- * @param cp The string to be converted
- * @param base The number base to use (0 for the default)
- * @param res The converted result value
- * Return: 0 if conversion is successful and *res is set to the converted
- * value, otherwise it returns -EINVAL and *res is set to 0.
+ * @cp: The string to be converted
+ * @base: The number base to use (0 for the default)
+ * @res: The converted result value
+ * Return: 0 if conversion is successful and `*res` is set to the converted
+ * value, otherwise it returns -EINVAL and `*res` is set to 0.
*
* strict_strtoul converts a string to an unsigned long only if the
* string is really an unsigned long string, any string containing
@@ -98,8 +98,11 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base);
* Given a string this finds a trailing number on the string and returns it.
* For example, "abc123" would return 123.
*
- * @str: String to exxamine
- * Return: training number if found, else -1
+ * Note that this does not handle a string without a prefix. See dectoul() for
+ * that case.
+ *
+ * @str: String to examine
+ * Return: trailing number if found, else -1
*/
long trailing_strtol(const char *str);
@@ -111,20 +114,38 @@ long trailing_strtol(const char *str);
* characters between @str and @end - 1 are examined. If @end is NULL, it is
* set to str + strlen(str).
*
- * @str: String to exxamine
+ * @str: String to examine
* @end: Pointer to end of string to examine, or NULL to use the
* whole string
- * Return: training number if found, else -1
+ * Return: trailing number if found, else -1
*/
long trailing_strtoln(const char *str, const char *end);
/**
+ * trailing_strtoln_end() - extract trailing integer from a fixed-length string
+ *
+ * Given a fixed-length string this finds a trailing number on the string
+ * and returns it. For example, "abc123" would return 123. Only the
+ * characters between @str and @end - 1 are examined. If @end is NULL, it is
+ * set to str + strlen(str).
+ *
+ * @str: String to examine
+ * @end: Pointer to end of string to examine, or NULL to use the
+ * whole string
+ * @endp: If non-NULL, this is set to point to the character where the
+ * number starts, e.g. for "mmc0" this would be point to the '0'; if no
+ * trailing number is found, it is set to the end of the string
+ * Return: training number if found, else -1
+ */
+long trailing_strtoln_end(const char *str, const char *end, char const **endp);
+
+/**
* panic() - Print a message and reset/hang
*
* Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is
* defined, then it will hang instead of resetting.
*
- * @param fmt: printf() format string for message, which should not include
+ * @fmt: printf() format string for message, which should not include
* \n, followed by arguments
*/
void panic(const char *fmt, ...)
@@ -139,16 +160,16 @@ void panic(const char *fmt, ...)
* This function can be used instead of panic() when your board does not
* already use printf(), * to keep code size small.
*
- * @param fmt: string to display, which should not include \n
+ * @str: string to display, which should not include \n
*/
void panic_str(const char *str) __attribute__ ((noreturn));
/**
* Format a string and place it in a buffer
*
- * @param buf The buffer to place the result into
- * @param fmt The format string to use
- * @param ... Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
*
* The function returns the number of characters written
* into @buf.
@@ -161,9 +182,9 @@ int sprintf(char *buf, const char *fmt, ...)
/**
* Format a string and place it in a buffer (va_list version)
*
- * @param buf The buffer to place the result into
- * @param fmt The format string to use
- * @param args Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @fmt: The format string to use
+ * @args: Arguments for the format string
* Return: the number of characters which have been written into
* the @buf not including the trailing '\0'.
*
@@ -178,7 +199,7 @@ int vsprintf(char *buf, const char *fmt, va_list args);
*
* This returns a static string containing the decimal representation of the
* given value. The returned value may be overwritten by other calls to other
- * simple_... functions, so should be used immediately
+ * simple... functions, so should be used immediately
*
* @val: Value to convert
* Return: string containing the decimal representation of @val
@@ -190,9 +211,9 @@ char *simple_itoa(ulong val);
*
* This returns a static string containing the hexadecimal representation of the
* given value. The returned value may be overwritten by other calls to other
- * simple_... functions, so should be used immediately
+ * simple... functions, so should be used immediately
*
- * @val: Value to convert
+ * @num: Value to convert
* Return: string containing the hexecimal representation of @val
*/
char *simple_xtoa(ulong num);
@@ -200,10 +221,10 @@ char *simple_xtoa(ulong num);
/**
* Format a string and place it in a buffer
*
- * @param buf The buffer to place the result into
- * @param size The size of the buffer, including the trailing null space
- * @param fmt The format string to use
- * @param ... Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
* Return: the number of characters which would be
* generated for the given input, excluding the trailing null,
* as per ISO C99. If the return is greater than or equal to
@@ -217,10 +238,10 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
/**
* Format a string and place it in a buffer
*
- * @param buf The buffer to place the result into
- * @param size The size of the buffer, including the trailing null space
- * @param fmt The format string to use
- * @param ... Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
*
* The return value is the number of characters written into @buf not including
* the trailing '\0'. If @size is == 0 the function returns 0.
@@ -233,10 +254,10 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...)
/**
* Format a string and place it in a buffer (base function)
*
- * @param buf The buffer to place the result into
- * @param size The size of the buffer, including the trailing null space
- * @param fmt The format string to use
- * @param args Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @args: Arguments for the format string
* Return: The number characters which would be generated for the given
* input, excluding the trailing '\0', as per ISO C99. Note that fewer
* characters may be written if this number of characters is >= size.
@@ -258,10 +279,10 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
/**
* Format a string and place it in a buffer (va_list version)
*
- * @param buf The buffer to place the result into
- * @param size The size of the buffer, including the trailing null space
- * @param fmt The format string to use
- * @param args Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @args: Arguments for the format string
* Return: the number of characters which have been written into
* the @buf not including the trailing '\0'. If @size is == 0 the function
* returns 0.
@@ -278,8 +299,8 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
* This prints a value with grouped digits, like 12,345,678 to make it easier
* to read.
*
- * @val: Value to print
- * @digits: Number of digiits to print
+ * @int_val: Value to print
+ * @digits: Number of digiits to print
*/
void print_grouped_ull(unsigned long long int_val, int digits);
@@ -309,9 +330,9 @@ void str_to_upper(const char *in, char *out, size_t len);
/**
* vsscanf - Unformat a buffer into a list of arguments
- * @buf: input buffer
- * @fmt: format of buffer
- * @args: arguments
+ * @inp: input buffer
+ * @fmt0: format of buffer
+ * @ap: arguments
*/
int vsscanf(const char *inp, char const *fmt0, va_list ap);