Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2000 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Jeroen Hofstee | f682d8c | 2014-07-13 22:57:58 +0200 | [diff] [blame] | 8 | #include <autoboot.h> |
Simon Glass | 399ed9a | 2014-04-10 20:01:30 -0600 | [diff] [blame] | 9 | #include <bootretry.h> |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 10 | #include <cli.h> |
Simon Glass | a73bda4 | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 11 | #include <console.h> |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 12 | #include <fdtdec.h> |
Simon Glass | 6a2e09f | 2019-07-20 20:51:16 -0600 | [diff] [blame] | 13 | #include <hash.h> |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 14 | #include <menu.h> |
| 15 | #include <post.h> |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 16 | #include <u-boot/sha256.h> |
Lukasz Majewski | 4fc1891 | 2018-05-02 16:10:53 +0200 | [diff] [blame] | 17 | #include <bootcount.h> |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
| 21 | #define MAX_DELAY_STOP_STR 32 |
| 22 | |
| 23 | #ifndef DEBUG_BOOTKEYS |
| 24 | #define DEBUG_BOOTKEYS 0 |
| 25 | #endif |
| 26 | #define debug_bootkeys(fmt, args...) \ |
| 27 | debug_cond(DEBUG_BOOTKEYS, fmt, ##args) |
| 28 | |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 29 | /* Stored value of bootdelay, used by autoboot_command() */ |
| 30 | static int stored_bootdelay; |
| 31 | |
Simon Glass | 760d3fb | 2019-07-20 20:51:15 -0600 | [diff] [blame] | 32 | #ifdef CONFIG_AUTOBOOT_ENCRYPTION |
| 33 | #define AUTOBOOT_STOP_STR_SHA256 CONFIG_AUTOBOOT_STOP_STR_SHA256 |
| 34 | #else |
| 35 | #define AUTOBOOT_STOP_STR_SHA256 "" |
| 36 | #endif |
| 37 | |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 38 | #if defined(CONFIG_AUTOBOOT_KEYED) |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 39 | |
| 40 | /* |
| 41 | * Use a "constant-length" time compare function for this |
| 42 | * hash compare: |
| 43 | * |
| 44 | * https://crackstation.net/hashing-security.htm |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 45 | */ |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 46 | static int slow_equals(u8 *a, u8 *b, int len) |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 47 | { |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 48 | int diff = 0; |
| 49 | int i; |
| 50 | |
| 51 | for (i = 0; i < len; i++) |
| 52 | diff |= a[i] ^ b[i]; |
| 53 | |
| 54 | return diff == 0; |
| 55 | } |
| 56 | |
Simon Glass | a8cab88 | 2019-07-20 20:51:17 -0600 | [diff] [blame] | 57 | /** |
| 58 | * passwd_abort_sha256() - check for a hashed key sequence to abort booting |
| 59 | * |
| 60 | * This checks for the user entering a SHA256 hash within a given time. |
| 61 | * |
| 62 | * @etime: Timeout value ticks (stop when get_ticks() reachs this) |
| 63 | * @return 0 if autoboot should continue, 1 if it should stop |
| 64 | */ |
Simon Glass | 6a2e09f | 2019-07-20 20:51:16 -0600 | [diff] [blame] | 65 | static int passwd_abort_sha256(uint64_t etime) |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 66 | { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 67 | const char *sha_env_str = env_get("bootstopkeysha256"); |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 68 | u8 sha_env[SHA256_SUM_LEN]; |
| 69 | u8 sha[SHA256_SUM_LEN]; |
| 70 | char presskey[MAX_DELAY_STOP_STR]; |
| 71 | const char *algo_name = "sha256"; |
| 72 | u_int presskey_len = 0; |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 73 | int abort = 0; |
Martin Etnestad | 055afba | 2018-01-12 09:04:38 +0100 | [diff] [blame] | 74 | int size = sizeof(sha); |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 75 | int ret; |
| 76 | |
| 77 | if (sha_env_str == NULL) |
Simon Glass | 760d3fb | 2019-07-20 20:51:15 -0600 | [diff] [blame] | 78 | sha_env_str = AUTOBOOT_STOP_STR_SHA256; |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 79 | |
| 80 | /* |
| 81 | * Generate the binary value from the environment hash value |
| 82 | * so that we can compare this value with the computed hash |
| 83 | * from the user input |
| 84 | */ |
| 85 | ret = hash_parse_string(algo_name, sha_env_str, sha_env); |
| 86 | if (ret) { |
| 87 | printf("Hash %s not supported!\n", algo_name); |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | * We don't know how long the stop-string is, so we need to |
| 93 | * generate the sha256 hash upon each input character and |
| 94 | * compare the value with the one saved in the environment |
| 95 | */ |
| 96 | do { |
| 97 | if (tstc()) { |
| 98 | /* Check for input string overflow */ |
| 99 | if (presskey_len >= MAX_DELAY_STOP_STR) |
| 100 | return 0; |
| 101 | |
| 102 | presskey[presskey_len++] = getc(); |
| 103 | |
| 104 | /* Calculate sha256 upon each new char */ |
| 105 | hash_block(algo_name, (const void *)presskey, |
| 106 | presskey_len, sha, &size); |
| 107 | |
| 108 | /* And check if sha matches saved value in env */ |
| 109 | if (slow_equals(sha, sha_env, SHA256_SUM_LEN)) |
| 110 | abort = 1; |
| 111 | } |
| 112 | } while (!abort && get_ticks() <= etime); |
| 113 | |
| 114 | return abort; |
| 115 | } |
Simon Glass | 6a2e09f | 2019-07-20 20:51:16 -0600 | [diff] [blame] | 116 | |
Simon Glass | a8cab88 | 2019-07-20 20:51:17 -0600 | [diff] [blame] | 117 | /** |
| 118 | * passwd_abort_key() - check for a key sequence to aborted booting |
| 119 | * |
| 120 | * This checks for the user entering a string within a given time. |
| 121 | * |
| 122 | * @etime: Timeout value ticks (stop when get_ticks() reachs this) |
| 123 | * @return 0 if autoboot should continue, 1 if it should stop |
| 124 | */ |
Simon Glass | 6a2e09f | 2019-07-20 20:51:16 -0600 | [diff] [blame] | 125 | static int passwd_abort_key(uint64_t etime) |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 126 | { |
| 127 | int abort = 0; |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 128 | struct { |
| 129 | char *str; |
| 130 | u_int len; |
| 131 | int retry; |
| 132 | } |
| 133 | delaykey[] = { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 134 | { .str = env_get("bootdelaykey"), .retry = 1 }, |
| 135 | { .str = env_get("bootstopkey"), .retry = 0 }, |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | char presskey[MAX_DELAY_STOP_STR]; |
| 139 | u_int presskey_len = 0; |
| 140 | u_int presskey_max = 0; |
| 141 | u_int i; |
| 142 | |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 143 | # ifdef CONFIG_AUTOBOOT_DELAY_STR |
| 144 | if (delaykey[0].str == NULL) |
| 145 | delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR; |
| 146 | # endif |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 147 | # ifdef CONFIG_AUTOBOOT_STOP_STR |
Stefan Roese | 0a48c7a | 2015-05-18 14:08:22 +0200 | [diff] [blame] | 148 | if (delaykey[1].str == NULL) |
| 149 | delaykey[1].str = CONFIG_AUTOBOOT_STOP_STR; |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 150 | # endif |
| 151 | |
| 152 | for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i++) { |
| 153 | delaykey[i].len = delaykey[i].str == NULL ? |
| 154 | 0 : strlen(delaykey[i].str); |
| 155 | delaykey[i].len = delaykey[i].len > MAX_DELAY_STOP_STR ? |
| 156 | MAX_DELAY_STOP_STR : delaykey[i].len; |
| 157 | |
| 158 | presskey_max = presskey_max > delaykey[i].len ? |
| 159 | presskey_max : delaykey[i].len; |
| 160 | |
| 161 | debug_bootkeys("%s key:<%s>\n", |
| 162 | delaykey[i].retry ? "delay" : "stop", |
| 163 | delaykey[i].str ? delaykey[i].str : "NULL"); |
| 164 | } |
| 165 | |
| 166 | /* In order to keep up with incoming data, check timeout only |
| 167 | * when catch up. |
| 168 | */ |
| 169 | do { |
| 170 | if (tstc()) { |
| 171 | if (presskey_len < presskey_max) { |
| 172 | presskey[presskey_len++] = getc(); |
| 173 | } else { |
| 174 | for (i = 0; i < presskey_max - 1; i++) |
| 175 | presskey[i] = presskey[i + 1]; |
| 176 | |
| 177 | presskey[i] = getc(); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i++) { |
| 182 | if (delaykey[i].len > 0 && |
| 183 | presskey_len >= delaykey[i].len && |
| 184 | memcmp(presskey + presskey_len - |
| 185 | delaykey[i].len, delaykey[i].str, |
| 186 | delaykey[i].len) == 0) { |
| 187 | debug_bootkeys("got %skey\n", |
| 188 | delaykey[i].retry ? "delay" : |
| 189 | "stop"); |
| 190 | |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 191 | /* don't retry auto boot */ |
| 192 | if (!delaykey[i].retry) |
| 193 | bootretry_dont_retry(); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 194 | abort = 1; |
| 195 | } |
| 196 | } |
| 197 | } while (!abort && get_ticks() <= etime); |
| 198 | |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 199 | return abort; |
| 200 | } |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 201 | |
| 202 | /*************************************************************************** |
| 203 | * Watch for 'delay' seconds for autoboot stop or autoboot delay string. |
| 204 | * returns: 0 - no key string, allow autoboot 1 - got key string, abort |
| 205 | */ |
Masahiro Yamada | 6d1248a | 2016-06-27 16:23:02 +0900 | [diff] [blame] | 206 | static int __abortboot(int bootdelay) |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 207 | { |
| 208 | int abort; |
| 209 | uint64_t etime = endtick(bootdelay); |
| 210 | |
Stefan Roese | 0ed2e46 | 2015-05-18 14:08:24 +0200 | [diff] [blame] | 211 | # ifdef CONFIG_AUTOBOOT_PROMPT |
| 212 | /* |
| 213 | * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards. |
| 214 | * To print the bootdelay value upon bootup. |
| 215 | */ |
| 216 | printf(CONFIG_AUTOBOOT_PROMPT, bootdelay); |
| 217 | # endif |
| 218 | |
Simon Glass | 6a2e09f | 2019-07-20 20:51:16 -0600 | [diff] [blame] | 219 | if (IS_ENABLED(CONFIG_AUTOBOOT_ENCRYPTION)) |
| 220 | abort = passwd_abort_sha256(etime); |
| 221 | else |
| 222 | abort = passwd_abort_key(etime); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 223 | if (!abort) |
| 224 | debug_bootkeys("key timeout\n"); |
| 225 | |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 226 | return abort; |
| 227 | } |
| 228 | |
| 229 | # else /* !defined(CONFIG_AUTOBOOT_KEYED) */ |
| 230 | |
| 231 | #ifdef CONFIG_MENUKEY |
| 232 | static int menukey; |
| 233 | #endif |
| 234 | |
Masahiro Yamada | 6d1248a | 2016-06-27 16:23:02 +0900 | [diff] [blame] | 235 | static int __abortboot(int bootdelay) |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 236 | { |
| 237 | int abort = 0; |
| 238 | unsigned long ts; |
| 239 | |
| 240 | #ifdef CONFIG_MENUPROMPT |
| 241 | printf(CONFIG_MENUPROMPT); |
| 242 | #else |
Masahiro Yamada | 9a33386 | 2016-06-27 16:23:04 +0900 | [diff] [blame] | 243 | printf("Hit any key to stop autoboot: %2d ", bootdelay); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 244 | #endif |
| 245 | |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 246 | /* |
| 247 | * Check if key already pressed |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 248 | */ |
Masahiro Yamada | 9a33386 | 2016-06-27 16:23:04 +0900 | [diff] [blame] | 249 | if (tstc()) { /* we got a key press */ |
| 250 | (void) getc(); /* consume input */ |
| 251 | puts("\b\b\b 0"); |
| 252 | abort = 1; /* don't auto boot */ |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 253 | } |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 254 | |
| 255 | while ((bootdelay > 0) && (!abort)) { |
| 256 | --bootdelay; |
| 257 | /* delay 1000 ms */ |
| 258 | ts = get_timer(0); |
| 259 | do { |
| 260 | if (tstc()) { /* we got a key press */ |
| 261 | abort = 1; /* don't auto boot */ |
| 262 | bootdelay = 0; /* no more delay */ |
| 263 | # ifdef CONFIG_MENUKEY |
| 264 | menukey = getc(); |
| 265 | # else |
| 266 | (void) getc(); /* consume input */ |
| 267 | # endif |
| 268 | break; |
| 269 | } |
| 270 | udelay(10000); |
| 271 | } while (!abort && get_timer(ts) < 1000); |
| 272 | |
| 273 | printf("\b\b\b%2d ", bootdelay); |
| 274 | } |
| 275 | |
| 276 | putc('\n'); |
| 277 | |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 278 | return abort; |
| 279 | } |
| 280 | # endif /* CONFIG_AUTOBOOT_KEYED */ |
| 281 | |
| 282 | static int abortboot(int bootdelay) |
| 283 | { |
Masahiro Yamada | 9a33386 | 2016-06-27 16:23:04 +0900 | [diff] [blame] | 284 | int abort = 0; |
Masahiro Yamada | d88f872 | 2016-06-27 16:23:03 +0900 | [diff] [blame] | 285 | |
Masahiro Yamada | 9a33386 | 2016-06-27 16:23:04 +0900 | [diff] [blame] | 286 | if (bootdelay >= 0) |
| 287 | abort = __abortboot(bootdelay); |
Masahiro Yamada | d88f872 | 2016-06-27 16:23:03 +0900 | [diff] [blame] | 288 | |
Simon Glass | 3a31505 | 2019-07-20 20:51:18 -0600 | [diff] [blame^] | 289 | if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && abort) |
Masahiro Yamada | d88f872 | 2016-06-27 16:23:03 +0900 | [diff] [blame] | 290 | gd->flags &= ~GD_FLG_SILENT; |
Masahiro Yamada | d88f872 | 2016-06-27 16:23:03 +0900 | [diff] [blame] | 291 | |
| 292 | return abort; |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 293 | } |
| 294 | |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 295 | static void process_fdt_options(const void *blob) |
| 296 | { |
Stefan Roese | c9fa9a5 | 2016-01-28 17:34:40 +0100 | [diff] [blame] | 297 | #if defined(CONFIG_OF_CONTROL) && defined(CONFIG_SYS_TEXT_BASE) |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 298 | ulong addr; |
| 299 | |
| 300 | /* Add an env variable to point to a kernel payload, if available */ |
| 301 | addr = fdtdec_get_config_int(gd->fdt_blob, "kernel-offset", 0); |
| 302 | if (addr) |
Simon Glass | 4d949a2 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 303 | env_set_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr)); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 304 | |
| 305 | /* Add an env variable to point to a root disk, if available */ |
| 306 | addr = fdtdec_get_config_int(gd->fdt_blob, "rootdisk-offset", 0); |
| 307 | if (addr) |
Simon Glass | 4d949a2 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 308 | env_set_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr)); |
Stefan Roese | c9fa9a5 | 2016-01-28 17:34:40 +0100 | [diff] [blame] | 309 | #endif /* CONFIG_OF_CONTROL && CONFIG_SYS_TEXT_BASE */ |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 310 | } |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 311 | |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 312 | const char *bootdelay_process(void) |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 313 | { |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 314 | char *s; |
| 315 | int bootdelay; |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 316 | |
Lukasz Majewski | 4fc1891 | 2018-05-02 16:10:53 +0200 | [diff] [blame] | 317 | bootcount_inc(); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 318 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 319 | s = env_get("bootdelay"); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 320 | bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY; |
| 321 | |
| 322 | #ifdef CONFIG_OF_CONTROL |
| 323 | bootdelay = fdtdec_get_config_int(gd->fdt_blob, "bootdelay", |
| 324 | bootdelay); |
| 325 | #endif |
| 326 | |
| 327 | debug("### main_loop entered: bootdelay=%d\n\n", bootdelay); |
| 328 | |
| 329 | #if defined(CONFIG_MENU_SHOW) |
| 330 | bootdelay = menu_show(bootdelay); |
| 331 | #endif |
Simon Glass | 09007c4 | 2014-04-10 20:01:31 -0600 | [diff] [blame] | 332 | bootretry_init_cmd_timeout(); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 333 | |
| 334 | #ifdef CONFIG_POST |
| 335 | if (gd->flags & GD_FLG_POSTFAIL) { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 336 | s = env_get("failbootcmd"); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 337 | } else |
| 338 | #endif /* CONFIG_POST */ |
Lukasz Majewski | 4fc1891 | 2018-05-02 16:10:53 +0200 | [diff] [blame] | 339 | if (bootcount_error()) |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 340 | s = env_get("altbootcmd"); |
Lukasz Majewski | 4fc1891 | 2018-05-02 16:10:53 +0200 | [diff] [blame] | 341 | else |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 342 | s = env_get("bootcmd"); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 343 | |
| 344 | process_fdt_options(gd->fdt_blob); |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 345 | stored_bootdelay = bootdelay; |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 346 | |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 347 | return s; |
| 348 | } |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 349 | |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 350 | void autoboot_command(const char *s) |
| 351 | { |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 352 | debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>"); |
| 353 | |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 354 | if (stored_bootdelay != -1 && s && !abortboot(stored_bootdelay)) { |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 355 | #if defined(CONFIG_AUTOBOOT_KEYED) && !defined(CONFIG_AUTOBOOT_KEYED_CTRLC) |
| 356 | int prev = disable_ctrlc(1); /* disable Control C checking */ |
| 357 | #endif |
| 358 | |
| 359 | run_command_list(s, -1, 0); |
| 360 | |
| 361 | #if defined(CONFIG_AUTOBOOT_KEYED) && !defined(CONFIG_AUTOBOOT_KEYED_CTRLC) |
| 362 | disable_ctrlc(prev); /* restore Control C checking */ |
| 363 | #endif |
| 364 | } |
| 365 | |
| 366 | #ifdef CONFIG_MENUKEY |
| 367 | if (menukey == CONFIG_MENUKEY) { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 368 | s = env_get("menucmd"); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 369 | if (s) |
| 370 | run_command_list(s, -1, 0); |
| 371 | } |
| 372 | #endif /* CONFIG_MENUKEY */ |
| 373 | } |