/src/barebox/include/bbu.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | | #ifndef __INCLUDE_BBU_H |
3 | | #define __INCLUDE_BBU_H |
4 | | |
5 | | #include <linux/errno.h> |
6 | | #include <linux/list.h> |
7 | | #include <linux/types.h> |
8 | | #include <filetype.h> |
9 | | |
10 | | struct bbu_data { |
11 | | #define BBU_FLAG_FORCE (1 << 0) |
12 | 0 | #define BBU_FLAG_YES (1 << 1) |
13 | | unsigned long flags; |
14 | | int force; |
15 | | const void *image; |
16 | | const char *imagefile; |
17 | | const char *devicefile; |
18 | | size_t len; |
19 | | const char *handler_name; |
20 | | const struct imd_header *imd_data; |
21 | | }; |
22 | | |
23 | | struct bbu_handler { |
24 | | int (*handler)(struct bbu_handler *, struct bbu_data *); |
25 | | const char *name; |
26 | | struct list_head list; |
27 | | #define BBU_HANDLER_FLAG_DEFAULT (1 << 0) |
28 | | #define BBU_HANDLER_CAN_REFRESH (1 << 1) |
29 | | #define BBU_HANDLER_FLAG_MMC_BOOT_ACK (1 << 16) |
30 | | /* |
31 | | * The lower 16bit are generic flags, the upper 16bit are reserved |
32 | | * for handler specific flags. |
33 | | */ |
34 | | unsigned long flags; |
35 | | |
36 | | /* default device file, can be overwritten on the command line */ |
37 | | const char *devicefile; |
38 | | }; |
39 | | |
40 | | int bbu_force(struct bbu_data *, const char *fmt, ...) __printf(2, 3); |
41 | | |
42 | | int bbu_confirm(struct bbu_data *); |
43 | | |
44 | | int barebox_update(struct bbu_data *, struct bbu_handler *); |
45 | | |
46 | | struct bbu_handler *bbu_find_handler_by_name(const char *name); |
47 | | struct bbu_handler *bbu_find_handler_by_device(const char *devicepath); |
48 | | |
49 | | void bbu_handlers_list(void); |
50 | | |
51 | | struct file_list; |
52 | | |
53 | | int bbu_mmcboot_handler(struct bbu_handler *, struct bbu_data *, |
54 | | int (*chained_handler)(struct bbu_handler *, struct bbu_data *)); |
55 | | |
56 | | int bbu_std_file_handler(struct bbu_handler *handler, |
57 | | struct bbu_data *data); |
58 | | |
59 | | int bbu_flash(struct bbu_data *data, loff_t offset); |
60 | | |
61 | | #ifdef CONFIG_BAREBOX_UPDATE |
62 | | |
63 | | bool bbu_handlers_available(void); |
64 | | |
65 | | int bbu_register_handler(struct bbu_handler *); |
66 | | |
67 | | int bbu_register_std_file_update(const char *name, unsigned long flags, |
68 | | const char *devicefile, enum filetype imagetype); |
69 | | |
70 | | void bbu_append_handlers_to_file_list(struct file_list *files); |
71 | | |
72 | | int bbu_mmcboot_register_handler(const char *name, |
73 | | const char *devicefile, |
74 | | unsigned long flags); |
75 | | |
76 | | #else |
77 | | |
78 | | static inline bool bbu_handlers_available(void) |
79 | 0 | { |
80 | 0 | return false; |
81 | 0 | } Unexecuted instantiation: fastboot.c:bbu_handlers_available Unexecuted instantiation: bfetch.c:bbu_handlers_available |
82 | | |
83 | | static inline int bbu_register_handler(struct bbu_handler *unused) |
84 | 0 | { |
85 | 0 | return -EINVAL; |
86 | 0 | } Unexecuted instantiation: fastboot.c:bbu_register_handler Unexecuted instantiation: bfetch.c:bbu_register_handler |
87 | | |
88 | | static inline int bbu_register_std_file_update(const char *name, unsigned long flags, |
89 | | const char *devicefile, enum filetype imagetype) |
90 | 0 | { |
91 | 0 | return -ENOSYS; |
92 | 0 | } Unexecuted instantiation: fastboot.c:bbu_register_std_file_update Unexecuted instantiation: bfetch.c:bbu_register_std_file_update |
93 | | |
94 | | static inline void bbu_append_handlers_to_file_list(struct file_list *files) |
95 | 0 | { |
96 | | /* none could be registered, so nothing to do */ |
97 | 0 | } Unexecuted instantiation: fastboot.c:bbu_append_handlers_to_file_list Unexecuted instantiation: bfetch.c:bbu_append_handlers_to_file_list |
98 | | |
99 | | static inline int bbu_mmcboot_register_handler(const char *name, |
100 | | const char *devicefile, |
101 | | unsigned long flags) |
102 | 0 | { |
103 | 0 | return -ENOSYS; |
104 | 0 | } Unexecuted instantiation: fastboot.c:bbu_mmcboot_register_handler Unexecuted instantiation: bfetch.c:bbu_mmcboot_register_handler |
105 | | |
106 | | #endif |
107 | | |
108 | | #if defined(CONFIG_BAREBOX_UPDATE_IMX_NAND_FCB) |
109 | | int imx6_bbu_nand_register_handler(const char *name, const char *devicefile, unsigned long flags); |
110 | | int imx7_bbu_nand_register_handler(const char *name, const char *devicefile, unsigned long flags); |
111 | | int imx28_bbu_nand_register_handler(const char *name, const char *devicefile, unsigned long flags); |
112 | | #else |
113 | | static inline int imx6_bbu_nand_register_handler(const char *name, |
114 | | const char *devicefile, |
115 | | unsigned long flags) |
116 | 0 | { |
117 | 0 | return -ENOSYS; |
118 | 0 | } Unexecuted instantiation: fastboot.c:imx6_bbu_nand_register_handler Unexecuted instantiation: bfetch.c:imx6_bbu_nand_register_handler |
119 | | static inline int imx7_bbu_nand_register_handler(const char *name, |
120 | | const char *devicefile, |
121 | | unsigned long flags) |
122 | 0 | { |
123 | 0 | return -ENOSYS; |
124 | 0 | } Unexecuted instantiation: fastboot.c:imx7_bbu_nand_register_handler Unexecuted instantiation: bfetch.c:imx7_bbu_nand_register_handler |
125 | | static inline int imx28_bbu_nand_register_handler(const char *name, |
126 | | const char *devicefile, |
127 | | unsigned long flags) |
128 | 0 | { |
129 | 0 | return -ENOSYS; |
130 | 0 | } Unexecuted instantiation: fastboot.c:imx28_bbu_nand_register_handler Unexecuted instantiation: bfetch.c:imx28_bbu_nand_register_handler |
131 | | #endif |
132 | | |
133 | | #endif /* __INCLUDE_BBU_H */ |