blob: 044a4797ed3609fc35453754b70a6aaf326d9e18 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass3b5866d2014-06-12 07:24:46 -06002/*
3 * (C) Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Simon Glass3b5866d2014-06-12 07:24:46 -06005 */
6
7#ifndef _BOOTM_H
8#define _BOOTM_H
9
Simon Glass3b5866d2014-06-12 07:24:46 -060010#include <image.h>
11
Simon Glassed38aef2020-05-10 11:40:03 -060012struct cmd_tbl;
13
Simon Glass3b5866d2014-06-12 07:24:46 -060014#define BOOTM_ERR_RESET (-1)
15#define BOOTM_ERR_OVERLAP (-2)
16#define BOOTM_ERR_UNIMPLEMENTED (-3)
17
18/*
19 * Continue booting an OS image; caller already has:
20 * - copied image header to global variable `header'
21 * - checked header magic number, checksums (both header & image),
22 * - verified image architecture (PPC) and type (KERNEL or MULTI),
23 * - loaded (first part of) image to header load address,
24 * - disabled interrupts.
25 *
26 * @flag: Flags indicating what to do (BOOTM_STATE_...)
27 * @argc: Number of arguments. Note that the arguments are shifted down
28 * so that 0 is the first argument not processed by U-Boot, and
29 * argc is adjusted accordingly. This avoids confusion as to how
30 * many arguments are available for the OS.
31 * @images: Pointers to os/initrd/fdt
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010032 * Return: 1 on error. On success the OS boots so this function does
Simon Glass3b5866d2014-06-12 07:24:46 -060033 * not return.
34 */
Simon Glassed38aef2020-05-10 11:40:03 -060035typedef int boot_os_fn(int flag, int argc, char *const argv[],
Simon Glassdf00afa2022-09-06 20:26:50 -060036 struct bootm_headers *images);
Simon Glass3b5866d2014-06-12 07:24:46 -060037
38extern boot_os_fn do_bootm_linux;
Bin Meng54a735a2018-12-21 07:13:40 -080039extern boot_os_fn do_bootm_vxworks;
40
Simon Glassed38aef2020-05-10 11:40:03 -060041int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
Simon Glass3b5866d2014-06-12 07:24:46 -060042
43boot_os_fn *bootm_os_get_boot_func(int os);
44
Fabrice Fontained00d6b52019-05-03 22:37:05 +020045#if defined(CONFIG_FIT_SIGNATURE)
Simon Glassa51991d2014-06-12 07:24:53 -060046int bootm_host_load_images(const void *fit, int cfg_noffset);
Fabrice Fontained00d6b52019-05-03 22:37:05 +020047#endif
Simon Glassa51991d2014-06-12 07:24:53 -060048
Simon Glassed38aef2020-05-10 11:40:03 -060049int boot_selected_os(int argc, char *const argv[], int state,
Simon Glassdf00afa2022-09-06 20:26:50 -060050 struct bootm_headers *images, boot_os_fn *boot_fn);
Simon Glass3b5866d2014-06-12 07:24:46 -060051
52ulong bootm_disable_interrupts(void);
53
Tom Rini5ce62cd2014-08-14 06:42:36 -040054/* This is a special function used by booti/bootz */
Tero Kristo06086942020-06-12 15:41:20 +030055int bootm_find_images(int flag, int argc, char *const argv[], ulong start,
56 ulong size);
Simon Glass3b5866d2014-06-12 07:24:46 -060057
Simon Glassed38aef2020-05-10 11:40:03 -060058int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
Simon Glassdf00afa2022-09-06 20:26:50 -060059 char *const argv[], int states, struct bootm_headers *images,
Simon Glassed38aef2020-05-10 11:40:03 -060060 int boot_progress);
Simon Glass3b5866d2014-06-12 07:24:46 -060061
Jeroen Hofstee7ade3de2014-10-08 22:58:00 +020062void arch_preboot_os(void);
63
Simon Glassc9b2e232018-05-16 09:42:26 -060064/*
65 * boards should define this to disable devices when EFI exits from boot
66 * services.
67 *
68 * TODO(sjg@chromium.org>): Update this to use driver model's device_remove().
69 */
Simon Glassf55305a2018-05-16 09:42:25 -060070void board_quiesce_devices(void);
71
Heinrich Schuchardtaa0b11b2019-01-08 18:13:06 +010072/**
73 * switch_to_non_secure_mode() - switch to non-secure mode
74 */
75void switch_to_non_secure_mode(void);
76
Simon Glass63660dc2020-11-05 10:33:44 -070077/* Flags to control bootm_process_cmdline() */
78enum bootm_cmdline_t {
79 BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */
Simon Glass529e2082020-11-05 10:33:48 -070080 BOOTM_CL_SUBST = 1 << 1, /* Do substitution */
Simon Glass63660dc2020-11-05 10:33:44 -070081
Simon Glass529e2082020-11-05 10:33:48 -070082 BOOTM_CL_ALL = 3, /* All substitutions */
Simon Glass63660dc2020-11-05 10:33:44 -070083};
84
Heinrich Schuchardt25828e92020-09-15 01:58:11 +020085/**
86 * arch_preboot_os() - arch specific configuration before booting
87 */
88void arch_preboot_os(void);
89
90/**
91 * board_preboot_os() - board specific configuration before booting
92 */
93void board_preboot_os(void);
94
Simon Glass2eab0172020-11-05 10:33:39 -070095/*
Simon Glassb4e1b6d2020-11-05 10:33:45 -070096 * bootm_process_cmdline() - Process fix-ups for the command line
97 *
Simon Glass529e2082020-11-05 10:33:48 -070098 * This handles:
99 *
100 * - making Linux boot silently if requested ('silent_linux' envvar)
101 * - performing substitutions in the command line ('bootargs_subst' envvar)
Simon Glassb4e1b6d2020-11-05 10:33:45 -0700102 *
103 * @maxlen must provide enough space for the string being processed plus the
104 * resulting string
105 *
106 * @buf: buffer holding commandline string to adjust
107 * @maxlen: Maximum length of buffer at @buf (including \0)
108 * @flags: Flags to control what happens (see bootm_cmdline_t)
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100109 * Return: 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too
Simon Glassb4e1b6d2020-11-05 10:33:45 -0700110 * long
111 */
112int bootm_process_cmdline(char *buf, int maxlen, int flags);
113
114/**
Simon Glassa50b6dd2020-11-05 10:33:40 -0700115 * bootm_process_cmdline_env() - Process fix-ups for the command line
Simon Glass2eab0172020-11-05 10:33:39 -0700116 *
Simon Glass529e2082020-11-05 10:33:48 -0700117 * Updates the 'bootargs' envvar as required. This handles:
118 *
119 * - making Linux boot silently if requested ('silent_linux' envvar)
120 * - performing substitutions in the command line ('bootargs_subst' envvar)
Simon Glass2eab0172020-11-05 10:33:39 -0700121 *
Simon Glass63660dc2020-11-05 10:33:44 -0700122 * @flags: Flags to control what happens (see bootm_cmdline_t)
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100123 * Return: 0 if OK, -ENOMEM if out of memory
Simon Glass2eab0172020-11-05 10:33:39 -0700124 */
Simon Glass63660dc2020-11-05 10:33:44 -0700125int bootm_process_cmdline_env(int flags);
Simon Glass07a88862020-11-05 10:33:38 -0700126
Simon Glass3b5866d2014-06-12 07:24:46 -0600127#endif