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. |
| 5 | * |
| 6 | * Add to readline cmdline-editing by |
| 7 | * (C) Copyright 2005 |
| 8 | * JinHua Luo, GuangDong Linux Center, <luo.jinhua@gd-linux.com> |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef __AUTOBOOT_H |
| 12 | #define __AUTOBOOT_H |
| 13 | |
Simon Glass | d8c6017 | 2021-07-24 15:14:39 -0600 | [diff] [blame] | 14 | #include <stdbool.h> |
| 15 | |
| 16 | #ifdef CONFIG_SANDBOX |
| 17 | |
| 18 | /** |
| 19 | * autoboot_keyed() - check whether keyed autoboot should be used |
| 20 | * |
| 21 | * This is only implemented for sandbox since other platforms don't have a way |
| 22 | * of controlling the feature at runtime. |
| 23 | * |
| 24 | * @return true if enabled, false if not |
| 25 | */ |
| 26 | bool autoboot_keyed(void); |
| 27 | |
| 28 | /** |
| 29 | * autoboot_set_keyed() - set whether keyed autoboot should be used |
| 30 | * |
| 31 | * @autoboot_keyed: true to enable the feature, false to disable |
| 32 | * @return old value of the flag |
| 33 | */ |
| 34 | bool autoboot_set_keyed(bool autoboot_keyed); |
| 35 | #else |
| 36 | static inline bool autoboot_keyed(void) |
| 37 | { |
| 38 | /* There is no runtime flag, so just use the CONFIG */ |
| 39 | return IS_ENABLED(CONFIG_AUTOBOOT_KEYED); |
| 40 | } |
| 41 | |
| 42 | static inline bool autoboot_set_keyed(bool autoboot_keyed) |
| 43 | { |
| 44 | /* There is no runtime flag to set */ |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | #endif |
| 49 | |
Masahiro Yamada | 622a01c | 2016-06-20 17:33:39 +0900 | [diff] [blame] | 50 | #ifdef CONFIG_AUTOBOOT |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 51 | /** |
| 52 | * bootdelay_process() - process the bootd delay |
| 53 | * |
| 54 | * Process the boot delay, boot limit, then get the value of either |
| 55 | * bootcmd, failbootcmd or altbootcmd depending on the current state. |
| 56 | * Return this command so it can be executed. |
| 57 | * |
| 58 | * @return command to executed |
| 59 | */ |
| 60 | const char *bootdelay_process(void); |
| 61 | |
| 62 | /** |
| 63 | * autoboot_command() - run the autoboot command |
| 64 | * |
| 65 | * If enabled, run the autoboot command returned from bootdelay_process(). |
Simon Glass | 9e476d9 | 2019-07-20 20:51:21 -0600 | [diff] [blame] | 66 | * Also do the CONFIG_AUTOBOOT_MENUKEY processing if enabled. |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 67 | * |
| 68 | * @cmd: Command to run |
| 69 | */ |
| 70 | void autoboot_command(const char *cmd); |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 71 | #else |
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 72 | static inline const char *bootdelay_process(void) |
| 73 | { |
| 74 | return NULL; |
| 75 | } |
| 76 | |
| 77 | static inline void autoboot_command(const char *s) |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 78 | { |
| 79 | } |
| 80 | #endif |
| 81 | |
| 82 | #endif |