1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2000-2009
15 #define BOOTM_ERR_RESET (-1)
16 #define BOOTM_ERR_OVERLAP (-2)
17 #define BOOTM_ERR_UNIMPLEMENTED (-3)
20 * Continue booting an OS image; caller already has:
21 * - copied image header to global variable `header'
22 * - checked header magic number, checksums (both header & image),
23 * - verified image architecture (PPC) and type (KERNEL or MULTI),
24 * - loaded (first part of) image to header load address,
25 * - disabled interrupts.
27 * @flag: Flags indicating what to do (BOOTM_STATE_...)
28 * @argc: Number of arguments. Note that the arguments are shifted down
29 * so that 0 is the first argument not processed by U-Boot, and
30 * argc is adjusted accordingly. This avoids confusion as to how
31 * many arguments are available for the OS.
32 * @images: Pointers to os/initrd/fdt
33 * Return: 1 on error. On success the OS boots so this function does
36 typedef int boot_os_fn(int flag, int argc, char *const argv[],
37 struct bootm_headers *images);
39 extern boot_os_fn do_bootm_linux;
40 extern boot_os_fn do_bootm_vxworks;
42 int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
44 boot_os_fn *bootm_os_get_boot_func(int os);
46 #if defined(CONFIG_FIT_SIGNATURE)
47 int bootm_host_load_images(const void *fit, int cfg_noffset);
50 int boot_selected_os(int argc, char *const argv[], int state,
51 struct bootm_headers *images, boot_os_fn *boot_fn);
53 ulong bootm_disable_interrupts(void);
55 /* This is a special function used by booti/bootz */
56 int bootm_find_images(int flag, int argc, char *const argv[], ulong start,
60 * Measure the boot images. Measurement is the process of hashing some binary
61 * data and storing it into secure memory, i.e. TPM PCRs. In addition, each
62 * measurement is logged into the platform event log such that the operating
63 * system can access it and perform attestation of the boot.
65 * @images: The structure containing the various images to boot (linux,
68 int bootm_measure(struct bootm_headers *images);
70 int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
71 char *const argv[], int states, struct bootm_headers *images,
74 void arch_preboot_os(void);
77 * boards should define this to disable devices when EFI exits from boot
82 void board_quiesce_devices(void);
85 * switch_to_non_secure_mode() - switch to non-secure mode
87 void switch_to_non_secure_mode(void);
89 /* Flags to control bootm_process_cmdline() */
90 enum bootm_cmdline_t {
91 BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */
92 BOOTM_CL_SUBST = 1 << 1, /* Do substitution */
94 BOOTM_CL_ALL = 3, /* All substitutions */
98 * arch_preboot_os() - arch specific configuration before booting
100 void arch_preboot_os(void);
103 * board_preboot_os() - board specific configuration before booting
105 void board_preboot_os(void);
108 * bootm_process_cmdline() - Process fix-ups for the command line
112 * - making Linux boot silently if requested ('silent_linux' envvar)
113 * - performing substitutions in the command line ('bootargs_subst' envvar)
115 * @maxlen must provide enough space for the string being processed plus the
118 * @buf: buffer holding commandline string to adjust
119 * @maxlen: Maximum length of buffer at @buf (including \0)
120 * @flags: Flags to control what happens (see bootm_cmdline_t)
121 * Return: 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too
124 int bootm_process_cmdline(char *buf, int maxlen, int flags);
127 * bootm_process_cmdline_env() - Process fix-ups for the command line
129 * Updates the 'bootargs' envvar as required. This handles:
131 * - making Linux boot silently if requested ('silent_linux' envvar)
132 * - performing substitutions in the command line ('bootargs_subst' envvar)
134 * @flags: Flags to control what happens (see bootm_cmdline_t)
135 * Return: 0 if OK, -ENOMEM if out of memory
137 int bootm_process_cmdline_env(int flags);
140 * zboot_run() - Run through the various steps to boot a zimage
142 * Boot a zimage, given the component parts
144 * @addr: Address where the bzImage is moved before booting, either
145 * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR
146 * @base: Pointer to the boot parameters, typically at address
148 * @initrd: Address of the initial ramdisk, or 0 if none
149 * @initrd_size: Size of the initial ramdisk, or 0 if none
150 * @cmdline: Command line to use for booting
151 * Return: -EFAULT on error (normally it does not return)
153 int zboot_run(ulong addr, ulong size, ulong initrd, ulong initrd_size,
154 ulong base, char *cmdline);
157 * zimage_get_kernel_version() - Get the version string from a kernel
159 * @params: boot_params pointer
160 * @kernel_base: base address of kernel
161 * Return: Kernel version as a NUL-terminated string
163 const char *zimage_get_kernel_version(struct boot_params *params,
167 * zimage_dump() - Dump the metadata of a zimage
169 * This shows all available information in a zimage that has been loaded.
171 * @base_ptr: Pointer to the boot parameters, typically at address
173 * @show_cmdline: true to show the full command line
175 void zimage_dump(struct boot_params *base_ptr, bool show_cmdline);
178 * bootm_boot_start() - Boot an image at the given address
180 * @addr: Image address
181 * @cmdline: Command line to set
183 int bootm_boot_start(ulong addr, const char *cmdline);