diff options
| author | Tom Rini <[email protected]> | 2021-07-23 14:50:43 -0400 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2021-07-23 14:50:43 -0400 |
| commit | edecc15eb9593b94dcd6a5f4f5ea5f134125b6a0 (patch) | |
| tree | 1c8f414dc7ae2d0e914a706e3dd8aaebb945c946 /include | |
| parent | f534d93cbf34f1d1762b04eb5680e84bef5e1fe1 (diff) | |
| parent | 25c8b9f298e46ea6048b5308f7ee207c6461c36a (diff) | |
Merge branch '2021-07-23-reboot-mode-and-cryptfs-passwd-support'
- A new driver uclass is created to handle the reboot mode control.
- Add support for libcrypt-style passwords for autoboot
Diffstat (limited to 'include')
| -rw-r--r-- | include/console.h | 17 | ||||
| -rw-r--r-- | include/crypt.h | 14 | ||||
| -rw-r--r-- | include/dm/uclass-id.h | 1 | ||||
| -rw-r--r-- | include/reboot-mode/reboot-mode-gpio.h | 32 | ||||
| -rw-r--r-- | include/reboot-mode/reboot-mode-rtc.h | 16 | ||||
| -rw-r--r-- | include/reboot-mode/reboot-mode.h | 56 | ||||
| -rw-r--r-- | include/test/common.h | 15 | ||||
| -rw-r--r-- | include/test/suites.h | 1 |
8 files changed, 152 insertions, 0 deletions
diff --git a/include/console.h b/include/console.h index f848bcbf037..b182440fcd6 100644 --- a/include/console.h +++ b/include/console.h @@ -83,6 +83,17 @@ int console_record_readline(char *str, int maxlen); * @return available bytes (0 if empty) */ int console_record_avail(void); + +/** + * console_in_puts() - Write a string to the console input buffer + * + * This writes the given string to the console_in buffer which will then be + * returned if a function calls e.g. `getc()` + * + * @str: the string to write + * @return the number of bytes added + */ +int console_in_puts(const char *str); #else static inline int console_record_init(void) { @@ -114,6 +125,12 @@ static inline int console_record_avail(void) return 0; } +static inline int console_in_puts(const char *str) +{ + /* There is never anything written */ + return 0; +} + #endif /* !CONFIG_CONSOLE_RECORD */ /** diff --git a/include/crypt.h b/include/crypt.h new file mode 100644 index 00000000000..f18a1705d4d --- /dev/null +++ b/include/crypt.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright (C) 2020 Steffen Jaeckel <[email protected]> */ + +/** + * Compare should with the processed passphrase. + * + * @should The crypt-style string to compare against + * @passphrase The plaintext passphrase + * @equal Pointer to an int where the result is stored + * '0' = unequal + * '1' = equal + * @return 0 on success, error code of errno else + */ +int crypt_compare(const char *should, const char *passphrase, int *equal); diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index d800f679d56..9d474533ba8 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -92,6 +92,7 @@ enum uclass_id { UCLASS_PWRSEQ, /* Power sequence device */ UCLASS_QFW, /* QEMU firmware config device */ UCLASS_RAM, /* RAM controller */ + UCLASS_REBOOT_MODE, /* Reboot mode */ UCLASS_REGULATOR, /* Regulator device */ UCLASS_REMOTEPROC, /* Remote Processor device */ UCLASS_RESET, /* Reset controller device */ diff --git a/include/reboot-mode/reboot-mode-gpio.h b/include/reboot-mode/reboot-mode-gpio.h new file mode 100644 index 00000000000..16b1185c698 --- /dev/null +++ b/include/reboot-mode/reboot-mode-gpio.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) Vaisala Oyj. + */ + +#ifndef REBOOT_MODE_REBOOT_MODE_GPIO_H_ +#define REBOOT_MODE_REBOOT_MODE_GPIO_H_ + +#include <asm/gpio.h> + +/* + * In case of initializing the driver statically (using U_BOOT_DEVICE macro), + * we can use this struct to declare the pins used. + */ + +#if !CONFIG_IS_ENABLED(OF_CONTROL) +struct reboot_mode_gpio_config { + int gpio_dev_offset; + int gpio_offset; + int flags; +}; +#endif + +struct reboot_mode_gpio_platdata { + struct gpio_desc *gpio_desc; +#if !CONFIG_IS_ENABLED(OF_CONTROL) + struct reboot_mode_gpio_config *gpios_config; +#endif + int gpio_count; +}; + +#endif /* REBOOT_MODE_REBOOT_MODE_GPIO_H_ */ diff --git a/include/reboot-mode/reboot-mode-rtc.h b/include/reboot-mode/reboot-mode-rtc.h new file mode 100644 index 00000000000..3613678f636 --- /dev/null +++ b/include/reboot-mode/reboot-mode-rtc.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c), Vaisala Oyj + */ + +#ifndef REBOOT_MODE_REBOOT_MODE_RTC_H_ +#define REBOOT_MODE_REBOOT_MODE_RTC_H_ + +struct reboot_mode_rtc_platdata { + struct udevice *rtc; + bool is_big_endian; + int addr; + size_t size; +}; + +#endif /* REBOOT_MODE_REBOOT_MODE_RTC_H_ */ diff --git a/include/reboot-mode/reboot-mode.h b/include/reboot-mode/reboot-mode.h new file mode 100644 index 00000000000..86b51f881ca --- /dev/null +++ b/include/reboot-mode/reboot-mode.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c), Vaisala Oyj + */ + +#ifndef REBOOT_MODE_REBOOT_MODE_H__ +#define REBOOT_MODE_REBOOT_MODE_H__ + +#include <asm/types.h> +#include <dm/device.h> + +struct reboot_mode_mode { + const char *mode_name; + u32 mode_id; +}; + +struct reboot_mode_uclass_platdata { + struct reboot_mode_mode *modes; + u8 count; + const char *env_variable; +}; + +struct reboot_mode_ops { + /** + * get() - get the current reboot mode value + * + * Returns the current value from the reboot mode backing store. + * + * @dev: Device to read from + * @rebootmode: Address to save the current reboot mode value + */ + int (*get)(struct udevice *dev, u32 *rebootmode); + + /** + * set() - set a reboot mode value + * + * Sets the value in the reboot mode backing store. + * + * @dev: Device to read from + * @rebootmode: New reboot mode value to store + */ + int (*set)(struct udevice *dev, u32 rebootmode); +}; + +/* Access the operations for a reboot mode device */ +#define reboot_mode_get_ops(dev) ((struct reboot_mode_ops *)(dev)->driver->ops) + +/** + * dm_reboot_mode_update() - Update the reboot mode env variable. + * + * @dev: Device to read from + * @return 0 if OK, -ve on error + */ +int dm_reboot_mode_update(struct udevice *dev); + +#endif /* REBOOT_MODE_REBOOT_MODE_H__ */ diff --git a/include/test/common.h b/include/test/common.h new file mode 100644 index 00000000000..81260d06ad6 --- /dev/null +++ b/include/test/common.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2019 Heinrich Schuchardt <[email protected]> + * Copyright (c) 2021 Steffen Jaeckel <[email protected]> + */ + +#ifndef __TEST_COMMON_H__ +#define __TEST_COMMON_H__ + +#include <test/test.h> + +/* Declare a new common function test */ +#define COMMON_TEST(_name, _flags) UNIT_TEST(_name, _flags, common_test) + +#endif /* __TEST_COMMON_H__ */ diff --git a/include/test/suites.h b/include/test/suites.h index 80b41f188c7..d35cd83a4eb 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -31,6 +31,7 @@ int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); |
