Eugeniu Rosca | e74670a | 2020-10-23 11:52:22 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2020 Eugeniu Rosca <rosca.eugeniu@gmail.com> |
| 4 | * |
| 5 | * Android Bootloader Control Block Header |
| 6 | */ |
| 7 | |
| 8 | #ifndef __BCB_H__ |
| 9 | #define __BCB_H__ |
| 10 | |
Dmitrii Merkurev | dfeb4f0 | 2023-11-10 05:59:55 +0000 | [diff] [blame] | 11 | #include <part.h> |
| 12 | |
| 13 | enum bcb_field { |
| 14 | BCB_FIELD_COMMAND, |
| 15 | BCB_FIELD_STATUS, |
| 16 | BCB_FIELD_RECOVERY, |
| 17 | BCB_FIELD_STAGE |
| 18 | }; |
| 19 | |
Simon Glass | 71e3e21 | 2023-02-05 15:36:21 -0700 | [diff] [blame] | 20 | #if IS_ENABLED(CONFIG_CMD_BCB) |
Dmitrii Merkurev | dfeb4f0 | 2023-11-10 05:59:55 +0000 | [diff] [blame] | 21 | |
| 22 | int bcb_find_partition_and_load(const char *iface, |
| 23 | int devnum, char *partp); |
| 24 | int bcb_load(struct blk_desc *block_description, |
| 25 | struct disk_partition *disk_partition); |
| 26 | int bcb_set(enum bcb_field field, const char *value); |
| 27 | |
| 28 | /** |
| 29 | * bcb_get() - get the field value. |
| 30 | * @field: field to get |
| 31 | * @value_out: buffer to copy bcb field value to |
| 32 | * @value_size: buffer size to avoid overflow in case |
| 33 | * value_out is smaller then the field value |
| 34 | */ |
| 35 | int bcb_get(enum bcb_field field, char *value_out, size_t value_size); |
| 36 | |
| 37 | int bcb_store(void); |
| 38 | void bcb_reset(void); |
| 39 | |
Eugeniu Rosca | e74670a | 2020-10-23 11:52:22 +0300 | [diff] [blame] | 40 | #else |
Dmitrii Merkurev | dfeb4f0 | 2023-11-10 05:59:55 +0000 | [diff] [blame] | 41 | |
Eugeniu Rosca | e74670a | 2020-10-23 11:52:22 +0300 | [diff] [blame] | 42 | #include <linux/errno.h> |
Dmitrii Merkurev | dfeb4f0 | 2023-11-10 05:59:55 +0000 | [diff] [blame] | 43 | |
| 44 | static inline int bcb_load(struct blk_desc *block_description, |
| 45 | struct disk_partition *disk_partition) |
Eugeniu Rosca | e74670a | 2020-10-23 11:52:22 +0300 | [diff] [blame] | 46 | { |
| 47 | return -EOPNOTSUPP; |
| 48 | } |
Dmitrii Merkurev | dfeb4f0 | 2023-11-10 05:59:55 +0000 | [diff] [blame] | 49 | |
| 50 | static inline int bcb_find_partition_and_load(const char *iface, |
| 51 | int devnum, char *partp) |
| 52 | { |
| 53 | return -EOPNOTSUPP; |
| 54 | } |
| 55 | |
| 56 | static inline int bcb_set(enum bcb_field field, const char *value) |
| 57 | { |
| 58 | return -EOPNOTSUPP; |
| 59 | } |
| 60 | |
Mattijs Korpershoek | 065ed55 | 2024-06-03 11:04:58 +0200 | [diff] [blame] | 61 | static inline int bcb_get(enum bcb_field field, |
| 62 | char *value_out, size_t value_size) |
Dmitrii Merkurev | dfeb4f0 | 2023-11-10 05:59:55 +0000 | [diff] [blame] | 63 | { |
| 64 | return -EOPNOTSUPP; |
| 65 | } |
| 66 | |
| 67 | static inline int bcb_store(void) |
| 68 | { |
| 69 | return -EOPNOTSUPP; |
| 70 | } |
| 71 | |
| 72 | static inline void bcb_reset(void) |
| 73 | { |
| 74 | } |
Eugeniu Rosca | e74670a | 2020-10-23 11:52:22 +0300 | [diff] [blame] | 75 | #endif |
| 76 | |
| 77 | #endif /* __BCB_H__ */ |