aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini2023-12-21 16:10:00 -0500
committerTom Rini2023-12-21 16:10:00 -0500
commit7c4647b8fb448ac658a9bc726681ad9e75e6b9e8 (patch)
tree5ecb1a3c90c2fc5c16176914748ad207005772a3 /include
parentced928b1994b6dd8d133797f506c0991b0e6196d (diff)
parentd37086a95f4b2c39f9ecfe602b792df8ab3bd8f9 (diff)
Merge patch series "Complete decoupling of bootm logic from commands"
Simon Glass <sjg@chromium.org> says: This series continues refactoring the bootm code to allow it to be used with CONFIG_COMMAND disabled. The OS-handling code is refactored and a new bootm_run() function is created to run through the bootm stages. This completes the work. A booti_go() function is created also, in case it proves useful, but at last for now standard boot does not use this. This is cmdd (part d of CMDLINE refactoring) It depends on dm/bootstda-working which depends on dm/cmdc-working
Diffstat (limited to 'include')
-rw-r--r--include/bootm.h142
1 files changed, 129 insertions, 13 deletions
diff --git a/include/bootm.h b/include/bootm.h
index f5229ea90b3..9e0f8d60de0 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -16,6 +16,55 @@ struct cmd_tbl;
#define BOOTM_ERR_OVERLAP (-2)
#define BOOTM_ERR_UNIMPLEMENTED (-3)
+/**
+ * struct bootm_info() - information used when processing images to boot
+ *
+ * These mirror the first three arguments of the bootm command. They are
+ * designed to handle any type of image, but typically it is a FIT.
+ *
+ * @addr_img: Address of image to bootm, as passed to
+ * genimg_get_kernel_addr_fit() for processing:
+ *
+ * NULL: Usees default load address, i.e. image_load_addr
+ * <addr>: Uses hex address
+ *
+ * For FIT:
+ * "[<addr>]#<conf>": Uses address (or image_load_addr) and also specifies
+ * the FIT configuration to use
+ * "[<addr>]:<subimage>": Uses address (or image_load_addr) and also
+ * specifies the subimage name containing the OS
+ *
+ * @conf_ramdisk: Address (or with FIT, the name) of the ramdisk image, as
+ * passed to boot_get_ramdisk() for processing, or NULL for none
+ * @conf_fdt: Address (or with FIT, the name) of the FDT image, as passed to
+ * boot_get_fdt() for processing, or NULL for none
+ * @boot_progress: true to show boot progress
+ * @images: images information
+ * @cmd_name: command which invoked this operation, e.g. "bootm"
+ * @argc: Number of arguments to the command (excluding the actual command).
+ * This is 0 if there are no arguments
+ * @argv: NULL-terminated list of arguments, or NULL if there are no arguments
+ */
+struct bootm_info {
+ const char *addr_img;
+ const char *conf_ramdisk;
+ const char *conf_fdt;
+ bool boot_progress;
+ struct bootm_headers *images;
+ const char *cmd_name;
+ int argc;
+ char *const *argv;
+};
+
+/**
+ * bootm_init() - Set up a bootm_info struct with useful defaults
+ *
+ * Set up the struct with default values for all members:
+ * @boot_progress is set to true and @images is set to the global images
+ * variable. Everything else is set to NULL except @argc which is 0
+ */
+void bootm_init(struct bootm_info *bmi);
+
/*
* Continue booting an OS image; caller already has:
* - copied image header to global variable `header'
@@ -25,21 +74,16 @@ struct cmd_tbl;
* - disabled interrupts.
*
* @flag: Flags indicating what to do (BOOTM_STATE_...)
- * @argc: Number of arguments. Note that the arguments are shifted down
- * so that 0 is the first argument not processed by U-Boot, and
- * argc is adjusted accordingly. This avoids confusion as to how
- * many arguments are available for the OS.
- * @images: Pointers to os/initrd/fdt
+ * bmi: Bootm information
* Return: 1 on error. On success the OS boots so this function does
* not return.
*/
-typedef int boot_os_fn(int flag, int argc, char *const argv[],
- struct bootm_headers *images);
+typedef int boot_os_fn(int flag, struct bootm_info *bmi);
extern boot_os_fn do_bootm_linux;
extern boot_os_fn do_bootm_vxworks;
-int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_bootelf(struct cmd_tbl *cmdtp, int fglag, int argc, char *const argv[]);
boot_os_fn *bootm_os_get_boot_func(int os);
@@ -47,8 +91,7 @@ boot_os_fn *bootm_os_get_boot_func(int os);
int bootm_host_load_images(const void *fit, int cfg_noffset);
#endif
-int boot_selected_os(int argc, char *const argv[], int state,
- struct bootm_headers *images, boot_os_fn *boot_fn);
+int boot_selected_os(int state, struct bootm_info *bmi, boot_os_fn *boot_fn);
ulong bootm_disable_interrupts(void);
@@ -87,9 +130,82 @@ int bootm_find_images(ulong img_addr, const char *conf_ramdisk,
*/
int bootm_measure(struct bootm_headers *images);
-int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[], int states, struct bootm_headers *images,
- int boot_progress);
+/**
+ * bootm_run_states() - Execute selected states of the bootm command.
+ *
+ * Note that if states contains more than one flag it MUST contain
+ * BOOTM_STATE_START, since this handles the addr_fit, conf_ramdisk and conf_fit
+ * members of @bmi
+ *
+ * Also note that aside from boot_os_fn functions and bootm_load_os, no other
+ * functions store the return value of in 'ret' may use a negative return
+ * value, without special handling.
+ *
+ * @bmi: bootm information
+ * @states Mask containing states to run (BOOTM_STATE_...)
+ * Return: 0 if ok, something else on error. Some errors will cause this
+ * function to perform a reboot! If states contains BOOTM_STATE_OS_GO
+ * then the intent is to boot an OS, so this function will not return
+ * unless the image type is standalone.
+ */
+int bootm_run_states(struct bootm_info *bmi, int states);
+
+/**
+ * boot_run() - Run the entire bootm/booti/bootz process
+ *
+ * This runs through the boot process from start to finish, with a base set of
+ * states, along with the extra ones supplied.
+ *
+ * This uses bootm_run_states().
+ *
+ * Note that it is normally easier to use bootm_run(), etc. since they handle
+ * the extra states correctly.
+ *
+ * @bmi: bootm information
+ * @cmd: command being run, NULL if none
+ * @extra_states: Mask of extra states to use for the boot
+ * Return: 0 if ok, something else on error
+ */
+int boot_run(struct bootm_info *bmi, const char *cmd, int extra_states);
+
+/**
+ * bootm_run() - Run the entire bootm process
+ *
+ * This runs through the bootm process from start to finish, using the default
+ * set of states.
+ *
+ * This uses bootm_run_states().
+ *
+ * @bmi: bootm information
+ * Return: 0 if ok, something else on error
+ */
+int bootm_run(struct bootm_info *bmi);
+
+/**
+ * bootz_run() - Run the entire bootz process
+ *
+ * This runs through the bootz process from start to finish, using the default
+ * set of states.
+ *
+ * This uses bootm_run_states().
+ *
+ * @bmi: bootm information
+ * Return: 0 if ok, something else on error
+ */
+int bootz_run(struct bootm_info *bmi);
+
+/**
+ * booti_run() - Run the entire booti process
+ *
+ * This runs through the booti process from start to finish, using the default
+ * set of states.
+ *
+ * This uses bootm_run_states().
+ *
+ * @bmi: bootm information
+ * Return: 0 if ok, something else on error
+ */
+int booti_run(struct bootm_info *bmi);
void arch_preboot_os(void);