blob: c3c7336207b166a8fea6ea477a707ba3b282d647 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glassb6396402014-06-12 07:24:46 -06002/*
3 * (C) Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Simon Glassb6396402014-06-12 07:24:46 -06005 */
6
7#ifndef _BOOTM_H
8#define _BOOTM_H
9
Simon Glassb6396402014-06-12 07:24:46 -060010#include <image.h>
11
Simon Glass1a081092023-07-30 11:16:53 -060012struct boot_params;
Simon Glass09140112020-05-10 11:40:03 -060013struct cmd_tbl;
14
Simon Glassb6396402014-06-12 07:24:46 -060015#define BOOTM_ERR_RESET (-1)
16#define BOOTM_ERR_OVERLAP (-2)
17#define BOOTM_ERR_UNIMPLEMENTED (-3)
18
19/*
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.
26 *
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
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010033 * Return: 1 on error. On success the OS boots so this function does
Simon Glassb6396402014-06-12 07:24:46 -060034 * not return.
35 */
Simon Glass09140112020-05-10 11:40:03 -060036typedef int boot_os_fn(int flag, int argc, char *const argv[],
Simon Glassd9d7c202022-09-06 20:26:50 -060037 struct bootm_headers *images);
Simon Glassb6396402014-06-12 07:24:46 -060038
39extern boot_os_fn do_bootm_linux;
Bin Mengf2a53c72018-12-21 07:13:40 -080040extern boot_os_fn do_bootm_vxworks;
41
Simon Glass09140112020-05-10 11:40:03 -060042int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
Simon Glassb6396402014-06-12 07:24:46 -060043
44boot_os_fn *bootm_os_get_boot_func(int os);
45
Fabrice Fontaine93e07882019-05-03 22:37:05 +020046#if defined(CONFIG_FIT_SIGNATURE)
Simon Glassce1400f2014-06-12 07:24:53 -060047int bootm_host_load_images(const void *fit, int cfg_noffset);
Fabrice Fontaine93e07882019-05-03 22:37:05 +020048#endif
Simon Glassce1400f2014-06-12 07:24:53 -060049
Simon Glass09140112020-05-10 11:40:03 -060050int boot_selected_os(int argc, char *const argv[], int state,
Simon Glassd9d7c202022-09-06 20:26:50 -060051 struct bootm_headers *images, boot_os_fn *boot_fn);
Simon Glassb6396402014-06-12 07:24:46 -060052
53ulong bootm_disable_interrupts(void);
54
Tom Rinid2b2ffe2014-08-14 06:42:36 -040055/* This is a special function used by booti/bootz */
Tero Kristofbde7582020-06-12 15:41:20 +030056int bootm_find_images(int flag, int argc, char *const argv[], ulong start,
57 ulong size);
Simon Glassb6396402014-06-12 07:24:46 -060058
Simon Glass09140112020-05-10 11:40:03 -060059int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
Simon Glassd9d7c202022-09-06 20:26:50 -060060 char *const argv[], int states, struct bootm_headers *images,
Simon Glass09140112020-05-10 11:40:03 -060061 int boot_progress);
Simon Glassb6396402014-06-12 07:24:46 -060062
Jeroen Hofsteef1bd8712014-10-08 22:58:00 +020063void arch_preboot_os(void);
64
Simon Glass896019b2018-05-16 09:42:26 -060065/*
66 * boards should define this to disable devices when EFI exits from boot
67 * services.
68 *
69 * TODO(sjg@chromium.org>): Update this to use driver model's device_remove().
70 */
Simon Glass329da482018-05-16 09:42:25 -060071void board_quiesce_devices(void);
72
Heinrich Schuchardtf6c6df72019-01-08 18:13:06 +010073/**
74 * switch_to_non_secure_mode() - switch to non-secure mode
75 */
76void switch_to_non_secure_mode(void);
77
Simon Glassb3c01672020-11-05 10:33:44 -070078/* Flags to control bootm_process_cmdline() */
79enum bootm_cmdline_t {
80 BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */
Simon Glass51bb3382020-11-05 10:33:48 -070081 BOOTM_CL_SUBST = 1 << 1, /* Do substitution */
Simon Glassb3c01672020-11-05 10:33:44 -070082
Simon Glass51bb3382020-11-05 10:33:48 -070083 BOOTM_CL_ALL = 3, /* All substitutions */
Simon Glassb3c01672020-11-05 10:33:44 -070084};
85
Heinrich Schuchardt73fdb952020-09-15 01:58:11 +020086/**
87 * arch_preboot_os() - arch specific configuration before booting
88 */
89void arch_preboot_os(void);
90
91/**
92 * board_preboot_os() - board specific configuration before booting
93 */
94void board_preboot_os(void);
95
Simon Glass4ae42642020-11-05 10:33:39 -070096/*
Simon Glass4448fe82020-11-05 10:33:45 -070097 * bootm_process_cmdline() - Process fix-ups for the command line
98 *
Simon Glass51bb3382020-11-05 10:33:48 -070099 * This handles:
100 *
101 * - making Linux boot silently if requested ('silent_linux' envvar)
102 * - performing substitutions in the command line ('bootargs_subst' envvar)
Simon Glass4448fe82020-11-05 10:33:45 -0700103 *
104 * @maxlen must provide enough space for the string being processed plus the
105 * resulting string
106 *
107 * @buf: buffer holding commandline string to adjust
108 * @maxlen: Maximum length of buffer at @buf (including \0)
109 * @flags: Flags to control what happens (see bootm_cmdline_t)
Heinrich Schuchardt185f8122022-01-19 18:05:50 +0100110 * Return: 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too
Simon Glass4448fe82020-11-05 10:33:45 -0700111 * long
112 */
113int bootm_process_cmdline(char *buf, int maxlen, int flags);
114
115/**
Simon Glass4dcb8152020-11-05 10:33:40 -0700116 * bootm_process_cmdline_env() - Process fix-ups for the command line
Simon Glass4ae42642020-11-05 10:33:39 -0700117 *
Simon Glass51bb3382020-11-05 10:33:48 -0700118 * Updates the 'bootargs' envvar as required. This handles:
119 *
120 * - making Linux boot silently if requested ('silent_linux' envvar)
121 * - performing substitutions in the command line ('bootargs_subst' envvar)
Simon Glass4ae42642020-11-05 10:33:39 -0700122 *
Simon Glassb3c01672020-11-05 10:33:44 -0700123 * @flags: Flags to control what happens (see bootm_cmdline_t)
Heinrich Schuchardt185f8122022-01-19 18:05:50 +0100124 * Return: 0 if OK, -ENOMEM if out of memory
Simon Glass4ae42642020-11-05 10:33:39 -0700125 */
Simon Glassb3c01672020-11-05 10:33:44 -0700126int bootm_process_cmdline_env(int flags);
Simon Glassf158ba12020-11-05 10:33:38 -0700127
Simon Glass1a081092023-07-30 11:16:53 -0600128/**
129 * zboot_start() - Boot a zimage
130 *
131 * Boot a zimage, given the component parts
132 *
133 * @addr: Address where the bzImage is moved before booting, either
134 * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR
135 * @base: Pointer to the boot parameters, typically at address
136 * DEFAULT_SETUP_BASE
137 * @initrd: Address of the initial ramdisk, or 0 if none
138 * @initrd_size: Size of the initial ramdisk, or 0 if none
139 * @cmdline: Command line to use for booting
140 * Return: -EFAULT on error (normally it does not return)
141 */
142int zboot_start(ulong addr, ulong size, ulong initrd, ulong initrd_size,
143 ulong base, char *cmdline);
144
145/*
146 * zimage_get_kernel_version() - Get the version string from a kernel
147 *
148 * @params: boot_params pointer
149 * @kernel_base: base address of kernel
150 * Return: Kernel version as a NUL-terminated string
151 */
152const char *zimage_get_kernel_version(struct boot_params *params,
153 void *kernel_base);
154
Simon Glasscbb607d2023-07-30 11:17:00 -0600155/**
156 * zimage_dump() - Dump the metadata of a zimage
157 *
158 * This shows all available information in a zimage that has been loaded.
159 *
160 * @base_ptr: Pointer to the boot parameters, typically at address
161 * DEFAULT_SETUP_BASE
162 * @show_cmdline: true to show the full command line
163 */
164void zimage_dump(struct boot_params *base_ptr, bool show_cmdline);
165
Simon Glassdaffb0b2023-07-30 11:17:02 -0600166/*
167 * bootm_boot_start() - Boot an image at the given address
168 *
169 * @addr: Image address
170 * @cmdline: Command line to set
171 */
172int bootm_boot_start(ulong addr, const char *cmdline);
173
Simon Glassb6396402014-06-12 07:24:46 -0600174#endif