/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright 2021 Google LLC
 * Written by Simon Glass <sjg@chromium.org>
 */

#ifndef __bootflow_h
#define __bootflow_h

#include <bootdev.h>
#include <dm/ofnode_decl.h>
#include <linux/list.h>

struct bootstd_priv;
struct expo;

enum {
	BOOTFLOW_MAX_USED_DEVS	= 16,
};

/**
 * 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
};

/**
 * enum bootflow_flags_t - flags for bootflows
 *
 * @BOOTFLOWF_USE_PRIOR_FDT: Indicates that an FDT was not found by the bootmeth
 *	and it is using the prior-stage FDT, which is the U-Boot control FDT.
 *	This is only possible with the EFI bootmeth (distro-efi) and only when
 *	CONFIG_OF_HAS_PRIOR_STAGE is enabled
 * @BOOTFLOWF_STATIC_BUF: Indicates that @bflow->buf is statically set, rather
 *	than being allocated by malloc().
 * @BOOTFLOWF_USE_BUILTIN_FDT : Indicates that current bootflow uses built-in FDT
 */
enum bootflow_flags_t {
	BOOTFLOWF_USE_PRIOR_FDT	= 1 << 0,
	BOOTFLOWF_STATIC_BUF	= 1 << 1,
	BOOTFLOWF_USE_BUILTIN_FDT	= 1 << 2,
};

/**
 * 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: Bootdev device which produced this bootflow, NULL for flows created by
 *      BOOTMETHF_GLOBAL bootmeths
 * @blk: Block device which contains this bootflow, NULL if this is a network
 *	device or sandbox 'host' 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)
 * @logo: Logo to display for this bootflow (BMP format)
 * @logo_size: Size of the logo in bytes
 * @buf: Bootflow file contents (allocated unless @flags & BOOTFLOWF_STATIC_BUF)
 * @size: Size of bootflow file in bytes
 * @err: Error number received (0 if OK)
 * @os_name: Name of the OS / distro being booted, or NULL if not known
 *	(allocated)
 * @fdt_fname: Filename of FDT file
 * @fdt_size: Size of FDT file
 * @fdt_addr: Address of loaded fdt
 * @flags: Flags for the bootflow (see enum bootflow_flags_t)
 * @cmdline: OS command line, or NULL if not known (allocated)
 * @x86_setup: Pointer to x86 setup block inside @buf, NULL if not present
 * @bootmeth_priv: Private data for the bootmeth
 */
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;
	void *logo;
	uint logo_size;
	char *buf;
	int size;
	int err;
	char *os_name;
	char *fdt_fname;
	int fdt_size;
	ulong fdt_addr;
	int flags;
	char *cmdline;
	void *x86_setup;
	void *bootmeth_priv;
};

/**
 * enum bootflow_iter_flags_t - flags for the bootflow iterator
 *
 * @BOOTFLOWIF_FIXED: Only used fixed/internal media
 * @BOOTFLOWIF_SHOW: Show each bootdev before scanning it; show each hunter
 * before using it
 * @BOOTFLOWIF_ALL: Return bootflows with errors as well
 * @BOOTFLOWIF_HUNT: Hunt for new bootdevs using the bootdrv hunters
 *
 * Internal flags:
 * @BOOTFLOWIF_SINGLE_DEV: (internal) Just scan one bootdev
 * @BOOTFLOWIF_SKIP_GLOBAL: (internal) Don't scan global bootmeths
 * @BOOTFLOWIF_SINGLE_UCLASS: (internal) Keep scanning through all devices in
 * this uclass (used with things like "mmc")
 * @BOOTFLOWIF_SINGLE_MEDIA: (internal) Scan one media device in the uclass (used
 * with things like "mmc1")
 * @BOOTFLOWIF_SINGLE_PARTITION: (internal) Scan one partition in media device
 * (used with things like "mmc1:3")
 */
enum bootflow_iter_flags_t {
	BOOTFLOWIF_FIXED		= 1 << 0,
	BOOTFLOWIF_SHOW			= 1 << 1,
	BOOTFLOWIF_ALL			= 1 << 2,
	BOOTFLOWIF_HUNT			= 1 << 3,

	/*
	 * flags used internally by standard boot - do not set these when
	 * calling bootflow_scan_bootdev() etc.
	 */
	BOOTFLOWIF_SINGLE_DEV		= 1 << 16,
	BOOTFLOWIF_SKIP_GLOBAL		= 1 << 17,
	BOOTFLOWIF_SINGLE_UCLASS	= 1 << 18,
	BOOTFLOWIF_SINGLE_MEDIA		= 1 << 19,
	BOOTFLOWIF_SINGLE_PARTITION	= 1 << 20,
};

/**
 * enum bootflow_meth_flags_t - flags controlling which bootmeths are used
 *
 * Used during iteration, e.g. by bootdev_find_by_label(), to determine which
 * bootmeths are used for the current bootdev. The flags reset when the bootdev
 * changes
 *
 * @BOOTFLOW_METHF_DHCP_ONLY: Only use dhcp (scripts and EFI)
 * @BOOTFLOW_METHF_PXE_ONLY: Only use pxe (PXE boot)
 * @BOOTFLOW_METHF_SINGLE_DEV: Scan only a single bootdev (used for labels like
 * "3"). This is used if a sequence number is provided instead of a label
 * @BOOTFLOW_METHF_SINGLE_UCLASS: Scan all bootdevs in this one uclass (used
 * with things like "mmc"). If this is not set, then the bootdev has an integer
 * value in the label (like "mmc2")
 */
enum bootflow_meth_flags_t {
	BOOTFLOW_METHF_DHCP_ONLY	= 1 << 0,
	BOOTFLOW_METHF_PXE_ONLY		= 1 << 1,
	BOOTFLOW_METHF_SINGLE_DEV	= 1 << 2,
	BOOTFLOW_METHF_SINGLE_UCLASS	= 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_iter_flags_t). If
 *	BOOTFLOWIF_GLOBAL_FIRST is enabled then the global bootmeths are being
 *	scanned, otherwise we have moved onto the bootdevs
 * @dev: Current bootdev, NULL if none. This is only ever updated in
 * bootflow_iter_set_dev()
 * @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
 * @first_bootable: First bootable partition, or 0 if none
 * @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_used
 * @max_devs: Maximum number of entries in @dev_used
 * @dev_used: List of bootdevs used during iteration
 * @labels: List of labels to scan for bootdevs
 * @cur_label: Current label being processed
 * @num_methods: Number of bootmeth devices in @method_order
 * @cur_method: Current method number, an index into @method_order
 * @first_glob_method: First global method, if any, else -1
 * @cur_prio: Current priority being scanned
 * @method_order: List of bootmeth devices to use, in order. The normal methods
 *	appear first, then the global ones, if any
 * @doing_global: true if we are iterating through the global bootmeths (which
 *	happens before the normal ones)
 * @method_flags: flags controlling which methods should be used for this @dev
 * (enum bootflow_meth_flags_t)
 */
struct bootflow_iter {
	int flags;
	struct udevice *dev;
	int part;
	struct udevice *method;
	int max_part;
	int first_bootable;
	int err;
	int num_devs;
	int max_devs;
	struct udevice *dev_used[BOOTFLOW_MAX_USED_DEVS];
	const char *const *labels;
	int cur_label;
	int num_methods;
	int cur_method;
	int first_glob_method;
	enum bootdev_prio_t cur_prio;
	struct udevice **method_order;
	bool doing_global;
	int method_flags;
};

/**
 * bootflow_init() - Set up a bootflow struct
 *
 * The bootflow is zeroed and set to state BOOTFLOWST_BASE
 *
 * @bflow: Struct to set up
 * @bootdev: Bootdev to use
 * @meth: Bootmeth to use
 */
void bootflow_init(struct bootflow *bflow, struct udevice *bootdev,
		   struct udevice *meth);

/**
 * 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_iter_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_first() - find the first bootflow for a device or label
 *
 * If @flags includes BOOTFLOWIF_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
 * @label:	Label to control the scan, NULL to work through all devices
 *	until it finds one that can supply a bootflow
 * @iter:	Place to store private info (inited by this call)
 * @flags:	Flags for iterator (enum bootflow_iter_flags_t). Note that if
 *	@dev is NULL, then BOOTFLOWIF_SKIP_GLOBAL is set automatically by this
 *	function
 * @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 udevice *dev, const char *label,
			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_read_all() - Read all bootflow files
 *
 * Some bootmeths delay reading of large files until booting is requested. This
 * causes those files to be read.
 *
 * @bflow: Bootflow to read
 * Return: result of trying to read
 */
int bootflow_read_all(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_check_blk() - 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_check_blk(const struct bootflow_iter *iter);

/**
 * bootflow_iter_check_mmc() - Check that a bootflow uses a MMC device
 *
 * This checks the bootdev in the bootflow to make sure it uses a mmc device
 *
 * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. ethernet)
 */
int bootflow_iter_check_mmc(const struct bootflow_iter *iter);

/**
 * bootflow_iter_check_sf() - Check that a bootflow uses SPI FLASH
 *
 * This checks the bootdev in the bootflow to make sure it uses SPI flash
 *
 * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. ethernet)
 */
int bootflow_iter_check_sf(const struct bootflow_iter *iter);

/**
 * bootflow_iter_check_net() - 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_check_net(const struct bootflow_iter *iter);

/**
 * bootflow_iter_check_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_check_system(const struct bootflow_iter *iter);

/**
 * bootflow_menu_new() - Create a new bootflow menu
 *
 * @expp: Returns the expo created
 * Returns 0 on success, -ve on error
 */
int bootflow_menu_new(struct expo **expp);

/**
 * bootflow_menu_apply_theme() - Apply a theme to a bootmenu
 *
 * @exp: Expo to update
 * @node: Node containing the theme information
 * Returns 0 on success, -ve on error
 */
int bootflow_menu_apply_theme(struct expo *exp, ofnode node);

/**
 * bootflow_menu_run() - Create and run a menu of available bootflows
 *
 * @std: Bootstd information
 * @text_mode: Uses a text-based menu suitable for a serial port
 * @bflowp: Returns chosen bootflow (set to NULL if nothing is chosen)
 * @return 0 if an option was chosen, -EAGAIN if nothing was chosen, -ve on
 * error
 */
int bootflow_menu_run(struct bootstd_priv *std, bool text_mode,
		      struct bootflow **bflowp);

#define BOOTFLOWCL_EMPTY	((void *)1)

/**
 * cmdline_set_arg() - Update or read an argument in a cmdline string
 *
 * Handles updating a single arg in a cmdline string, returning it in a supplied
 * buffer; also reading an arg from a cmdline string
 *
 * When updating, consecutive spaces are squashed as are spaces at the start and
 * end.
 *
 * @buf: Working buffer to use (initial contents are ignored). Use NULL when
 * reading
 * @maxlen: Length of working buffer. Use 0 when reading
 * @cmdline: Command line to update, in the form:
 *
 *	fred mary= jane=123 john="has spaces"
 *
 * @set_arg: Argument to set or read (may or may not exist)
 * @new_val: Value for the new argument. May not include quotes (") but may
 * include embedded spaces, in which case it will be quoted when added to the
 * command line. Use NULL to delete the argument from @cmdline, BOOTFLOWCL_EMPTY
 * to set it to an empty value (no '=' sign after arg), "" to add an '=' sign
 * but with an empty value. Use NULL when reading.
 * @posp: Ignored when setting an argument; when getting an argument, returns
 * the start position of its value in @cmdline, after the first quote, if any
 *
 * Return:
 * For updating:
 *	length of new buffer (including \0 terminator) on success, -ENOENT if
 *	@new_val is NULL and @set_arg does not exist in @from, -EINVAL if a
 *	quoted arg-value in @from is not terminated with a quote, -EBADF if
 *	@new_val has spaces but does not start and end with quotes (or it has
 *	quotes in the middle of the string), -E2BIG if @maxlen is too small
 * For reading:
 *	length of arg value (excluding quotes), -ENOENT if not found
 */
int cmdline_set_arg(char *buf, int maxlen, const char *cmdline,
		    const char *set_arg, const char *new_val, int *posp);

/**
 * bootflow_cmdline_set_arg() - Set a single argument for a bootflow
 *
 * Update the allocated cmdline and set the bootargs variable
 *
 * @bflow: Bootflow to update
 * @arg: Argument to update (e.g. "console")
 * @val: Value to set (e.g. "ttyS2") or NULL to delete the argument if present,
 * "" to set it to an empty value (e.g. "console=") and BOOTFLOWCL_EMPTY to add
 * it without any value ("initrd")
 * @set_env: true to set the "bootargs" environment variable too
 *
 * Return: 0 if OK, -ENOMEM if out of memory
 */
int bootflow_cmdline_set_arg(struct bootflow *bflow, const char *arg,
			     const char *val, bool set_env);

/**
 * cmdline_get_arg() - Read an argument from a cmdline
 *
 * @cmdline: Command line to read, in the form:
 *
 *	fred mary= jane=123 john="has spaces"
 * @arg: Argument to read (may or may not exist)
 * @posp: Returns position of argument (after any leading quote) if present
 * Return: Length of argument value excluding quotes if found, -ENOENT if not
 * found
 */
int cmdline_get_arg(const char *cmdline, const char *arg, int *posp);

/**
 * bootflow_cmdline_get_arg() - Read an argument from a cmdline
 *
 * @bootflow: Bootflow to read from
 * @arg: Argument to read (may or may not exist)
 * @valp: Returns a pointer to the argument (after any leading quote) if present
 * Return: Length of argument value excluding quotes if found, -ENOENT if not
 * found
 */
int bootflow_cmdline_get_arg(struct bootflow *bflow, const char *arg,
			     const char **val);

/**
 * bootflow_cmdline_auto() - Automatically set a value for a known argument
 *
 * This handles a small number of known arguments, for Linux in particular. It
 * adds suitable kernel parameters automatically, e.g. to enable the console.
 *
 * @bflow: Bootflow to update
 * @arg: Name of argument to set (e.g. "earlycon" or "console")
 * Return: 0 if OK -ve on error
 */
int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg);

#endif
