Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 3b5866d | 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 | 3b5866d | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _BOOTM_H |
| 8 | #define _BOOTM_H |
| 9 | |
Simon Glass | 3b5866d | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 10 | #include <image.h> |
| 11 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 12 | struct cmd_tbl; |
| 13 | |
Simon Glass | 3b5866d | 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 |
| 32 | * @return 1 on error. On success the OS boots so this function does |
| 33 | * not return. |
| 34 | */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 35 | typedef int boot_os_fn(int flag, int argc, char *const argv[], |
Simon Glass | 3b5866d | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 36 | bootm_headers_t *images); |
| 37 | |
| 38 | extern boot_os_fn do_bootm_linux; |
Bin Meng | 54a735a | 2018-12-21 07:13:40 -0800 | [diff] [blame] | 39 | extern boot_os_fn do_bootm_vxworks; |
| 40 | |
Simon Glass | ed38aef | 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 | 3b5866d | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 42 | void lynxkdi_boot(image_header_t *hdr); |
| 43 | |
| 44 | boot_os_fn *bootm_os_get_boot_func(int os); |
| 45 | |
Fabrice Fontaine | d00d6b5 | 2019-05-03 22:37:05 +0200 | [diff] [blame] | 46 | #if defined(CONFIG_FIT_SIGNATURE) |
Simon Glass | a51991d | 2014-06-12 07:24:53 -0600 | [diff] [blame] | 47 | int bootm_host_load_images(const void *fit, int cfg_noffset); |
Fabrice Fontaine | d00d6b5 | 2019-05-03 22:37:05 +0200 | [diff] [blame] | 48 | #endif |
Simon Glass | a51991d | 2014-06-12 07:24:53 -0600 | [diff] [blame] | 49 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 50 | int boot_selected_os(int argc, char *const argv[], int state, |
Simon Glass | 3b5866d | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 51 | bootm_headers_t *images, boot_os_fn *boot_fn); |
| 52 | |
| 53 | ulong bootm_disable_interrupts(void); |
| 54 | |
Tom Rini | 5ce62cd | 2014-08-14 06:42:36 -0400 | [diff] [blame] | 55 | /* This is a special function used by booti/bootz */ |
Tero Kristo | 0608694 | 2020-06-12 15:41:20 +0300 | [diff] [blame] | 56 | int bootm_find_images(int flag, int argc, char *const argv[], ulong start, |
| 57 | ulong size); |
Simon Glass | 3b5866d | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 58 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 59 | int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, |
| 60 | char *const argv[], int states, bootm_headers_t *images, |
| 61 | int boot_progress); |
Simon Glass | 3b5866d | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 62 | |
Jeroen Hofstee | 7ade3de | 2014-10-08 22:58:00 +0200 | [diff] [blame] | 63 | void arch_preboot_os(void); |
| 64 | |
Simon Glass | c9b2e23 | 2018-05-16 09:42:26 -0600 | [diff] [blame] | 65 | /* |
| 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 Glass | f55305a | 2018-05-16 09:42:25 -0600 | [diff] [blame] | 71 | void board_quiesce_devices(void); |
| 72 | |
Heinrich Schuchardt | aa0b11b | 2019-01-08 18:13:06 +0100 | [diff] [blame] | 73 | /** |
| 74 | * switch_to_non_secure_mode() - switch to non-secure mode |
| 75 | */ |
| 76 | void switch_to_non_secure_mode(void); |
| 77 | |
Simon Glass | 63660dc | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 78 | /* Flags to control bootm_process_cmdline() */ |
| 79 | enum bootm_cmdline_t { |
| 80 | BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */ |
Simon Glass | 529e208 | 2020-11-05 10:33:48 -0700 | [diff] [blame] | 81 | BOOTM_CL_SUBST = 1 << 1, /* Do substitution */ |
Simon Glass | 63660dc | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 82 | |
Simon Glass | 529e208 | 2020-11-05 10:33:48 -0700 | [diff] [blame] | 83 | BOOTM_CL_ALL = 3, /* All substitutions */ |
Simon Glass | 63660dc | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
Heinrich Schuchardt | 25828e9 | 2020-09-15 01:58:11 +0200 | [diff] [blame] | 86 | /** |
| 87 | * arch_preboot_os() - arch specific configuration before booting |
| 88 | */ |
| 89 | void arch_preboot_os(void); |
| 90 | |
| 91 | /** |
| 92 | * board_preboot_os() - board specific configuration before booting |
| 93 | */ |
| 94 | void board_preboot_os(void); |
| 95 | |
Simon Glass | 2eab017 | 2020-11-05 10:33:39 -0700 | [diff] [blame] | 96 | /* |
Simon Glass | b4e1b6d | 2020-11-05 10:33:45 -0700 | [diff] [blame] | 97 | * bootm_process_cmdline() - Process fix-ups for the command line |
| 98 | * |
Simon Glass | 529e208 | 2020-11-05 10:33:48 -0700 | [diff] [blame] | 99 | * This handles: |
| 100 | * |
| 101 | * - making Linux boot silently if requested ('silent_linux' envvar) |
| 102 | * - performing substitutions in the command line ('bootargs_subst' envvar) |
Simon Glass | b4e1b6d | 2020-11-05 10:33:45 -0700 | [diff] [blame] | 103 | * |
| 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) |
| 110 | * @return 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too |
| 111 | * long |
| 112 | */ |
| 113 | int bootm_process_cmdline(char *buf, int maxlen, int flags); |
| 114 | |
| 115 | /** |
Simon Glass | a50b6dd | 2020-11-05 10:33:40 -0700 | [diff] [blame] | 116 | * bootm_process_cmdline_env() - Process fix-ups for the command line |
Simon Glass | 2eab017 | 2020-11-05 10:33:39 -0700 | [diff] [blame] | 117 | * |
Simon Glass | 529e208 | 2020-11-05 10:33:48 -0700 | [diff] [blame] | 118 | * 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 Glass | 2eab017 | 2020-11-05 10:33:39 -0700 | [diff] [blame] | 122 | * |
Simon Glass | 63660dc | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 123 | * @flags: Flags to control what happens (see bootm_cmdline_t) |
Simon Glass | 2eab017 | 2020-11-05 10:33:39 -0700 | [diff] [blame] | 124 | * @return 0 if OK, -ENOMEM if out of memory |
| 125 | */ |
Simon Glass | 63660dc | 2020-11-05 10:33:44 -0700 | [diff] [blame] | 126 | int bootm_process_cmdline_env(int flags); |
Simon Glass | 07a8886 | 2020-11-05 10:33:38 -0700 | [diff] [blame] | 127 | |
Simon Glass | 3b5866d | 2014-06-12 07:24:46 -0600 | [diff] [blame] | 128 | #endif |