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