Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2000-2009 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _BOOTM_H |
| 8 | #define _BOOTM_H |
| 9 | |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 10 | #include <image.h> |
| 11 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 12 | struct cmd_tbl; |
| 13 | |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 14 | #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 Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 32 | * Return: 1 on error. On success the OS boots so this function does |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 33 | * not return. |
| 34 | */ |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 35 | typedef int boot_os_fn(int flag, int argc, char *const argv[], |
Simon Glass | d9d7c20 | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 36 | struct bootm_headers *images); |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 37 | |
| 38 | extern boot_os_fn do_bootm_linux; |
Bin Meng | f2a53c7 | 2018-12-21 07:13:40 -0800 | [diff] [blame] | 39 | extern boot_os_fn do_bootm_vxworks; |
| 40 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 41 | int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 42 | |
| 43 | boot_os_fn *bootm_os_get_boot_func(int os); |
| 44 | |
Fabrice Fontaine | 93e0788 | 2019-05-03 22:37:05 +0200 | [diff] [blame] | 45 | #if defined(CONFIG_FIT_SIGNATURE) |
Simon Glass | ce1400f | 2014-06-12 07:24:53 -0600 | [diff] [blame] | 46 | int bootm_host_load_images(const void *fit, int cfg_noffset); |
Fabrice Fontaine | 93e0788 | 2019-05-03 22:37:05 +0200 | [diff] [blame] | 47 | #endif |
Simon Glass | ce1400f | 2014-06-12 07:24:53 -0600 | [diff] [blame] | 48 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 49 | int boot_selected_os(int argc, char *const argv[], int state, |
Simon Glass | d9d7c20 | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 50 | struct bootm_headers *images, boot_os_fn *boot_fn); |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 51 | |
| 52 | ulong bootm_disable_interrupts(void); |
| 53 | |
Tom Rini | d2b2ffe | 2014-08-14 06:42:36 -0400 | [diff] [blame] | 54 | /* This is a special function used by booti/bootz */ |
Tero Kristo | fbde758 | 2020-06-12 15:41:20 +0300 | [diff] [blame] | 55 | int bootm_find_images(int flag, int argc, char *const argv[], ulong start, |
| 56 | ulong size); |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 57 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 58 | int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, |
Simon Glass | d9d7c20 | 2022-09-06 20:26:50 -0600 | [diff] [blame] | 59 | char *const argv[], int states, struct bootm_headers *images, |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 60 | int boot_progress); |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 61 | |
Jeroen Hofstee | f1bd871 | 2014-10-08 22:58:00 +0200 | [diff] [blame] | 62 | void arch_preboot_os(void); |
| 63 | |
Simon Glass | 896019b | 2018-05-16 09:42:26 -0600 | [diff] [blame] | 64 | /* |
| 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 Glass | 329da48 | 2018-05-16 09:42:25 -0600 | [diff] [blame] | 70 | void board_quiesce_devices(void); |
| 71 | |
Heinrich Schuchardt | f6c6df7 | 2019-01-08 18:13:06 +0100 | [diff] [blame] | 72 | /** |
| 73 | * switch_to_non_secure_mode() - switch to non-secure mode |
| 74 | */ |
| 75 | void switch_to_non_secure_mode(void); |
| 76 | |
Simon Glass | b3c0167 | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 77 | /* Flags to control bootm_process_cmdline() */ |
| 78 | enum bootm_cmdline_t { |
| 79 | BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */ |
Simon Glass | 51bb338 | 2020-11-05 10:33:48 -0700 | [diff] [blame] | 80 | BOOTM_CL_SUBST = 1 << 1, /* Do substitution */ |
Simon Glass | b3c0167 | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 81 | |
Simon Glass | 51bb338 | 2020-11-05 10:33:48 -0700 | [diff] [blame] | 82 | BOOTM_CL_ALL = 3, /* All substitutions */ |
Simon Glass | b3c0167 | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
Heinrich Schuchardt | 73fdb95 | 2020-09-15 01:58:11 +0200 | [diff] [blame] | 85 | /** |
| 86 | * arch_preboot_os() - arch specific configuration before booting |
| 87 | */ |
| 88 | void arch_preboot_os(void); |
| 89 | |
| 90 | /** |
| 91 | * board_preboot_os() - board specific configuration before booting |
| 92 | */ |
| 93 | void board_preboot_os(void); |
| 94 | |
Simon Glass | 4ae4264 | 2020-11-05 10:33:39 -0700 | [diff] [blame] | 95 | /* |
Simon Glass | 4448fe8 | 2020-11-05 10:33:45 -0700 | [diff] [blame] | 96 | * bootm_process_cmdline() - Process fix-ups for the command line |
| 97 | * |
Simon Glass | 51bb338 | 2020-11-05 10:33:48 -0700 | [diff] [blame] | 98 | * This handles: |
| 99 | * |
| 100 | * - making Linux boot silently if requested ('silent_linux' envvar) |
| 101 | * - performing substitutions in the command line ('bootargs_subst' envvar) |
Simon Glass | 4448fe8 | 2020-11-05 10:33:45 -0700 | [diff] [blame] | 102 | * |
| 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 Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 109 | * Return: 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too |
Simon Glass | 4448fe8 | 2020-11-05 10:33:45 -0700 | [diff] [blame] | 110 | * long |
| 111 | */ |
| 112 | int bootm_process_cmdline(char *buf, int maxlen, int flags); |
| 113 | |
| 114 | /** |
Simon Glass | 4dcb815 | 2020-11-05 10:33:40 -0700 | [diff] [blame] | 115 | * bootm_process_cmdline_env() - Process fix-ups for the command line |
Simon Glass | 4ae4264 | 2020-11-05 10:33:39 -0700 | [diff] [blame] | 116 | * |
Simon Glass | 51bb338 | 2020-11-05 10:33:48 -0700 | [diff] [blame] | 117 | * 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 Glass | 4ae4264 | 2020-11-05 10:33:39 -0700 | [diff] [blame] | 121 | * |
Simon Glass | b3c0167 | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 122 | * @flags: Flags to control what happens (see bootm_cmdline_t) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 123 | * Return: 0 if OK, -ENOMEM if out of memory |
Simon Glass | 4ae4264 | 2020-11-05 10:33:39 -0700 | [diff] [blame] | 124 | */ |
Simon Glass | b3c0167 | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 125 | int bootm_process_cmdline_env(int flags); |
Simon Glass | f158ba1 | 2020-11-05 10:33:38 -0700 | [diff] [blame] | 126 | |
Simon Glass | b639640 | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 127 | #endif |