/src/barebox/include/bootm.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | | #ifndef __BOOTM_H |
3 | | #define __BOOTM_H |
4 | | |
5 | | #include <image.h> |
6 | | #include <filetype.h> |
7 | | #include <linux/list.h> |
8 | | #include <loadable.h> |
9 | | |
10 | | enum bootm_verify { |
11 | | BOOTM_VERIFY_NONE, |
12 | | BOOTM_VERIFY_HASH, |
13 | | BOOTM_VERIFY_SIGNATURE, |
14 | | BOOTM_VERIFY_AVAILABLE, |
15 | | }; |
16 | | |
17 | | enum bootm_efi_mode { |
18 | | BOOTM_EFI_DISABLED, |
19 | | BOOTM_EFI_AVAILABLE, |
20 | | BOOTM_EFI_REQUIRED, |
21 | | }; |
22 | | |
23 | | struct bootm_data { |
24 | | const char *os_file; |
25 | | const char *initrd_file; |
26 | | const char *oftree_file; |
27 | | const char *root_dev; |
28 | | const char *root_param; |
29 | | int verbose; |
30 | | enum bootm_verify verify; |
31 | | bool force; |
32 | | bool dryrun; |
33 | | /* |
34 | | * appendroot - if true, try to add a suitable root= Kernel option to |
35 | | * mount the rootfs from the same device as the Kernel comes from. |
36 | | * The default rootfs device can be overridden with root_dev. |
37 | | */ |
38 | | bool appendroot; |
39 | | /* |
40 | | * provide_machine_id - if true, try to add systemd.machine_id= with |
41 | | * value of global.machine_id to Kernel. |
42 | | */ |
43 | | bool provide_machine_id; |
44 | | /* |
45 | | * provide_hostname - if true, try to add systemd.hostname= with value |
46 | | * of global.hostname to Kernel. |
47 | | */ |
48 | | bool provide_hostname; |
49 | | /* |
50 | | * provide_policy - if true, try to add barebox.security.policy= with |
51 | | * with value of currently selected policy |
52 | | */ |
53 | | bool provide_policy; |
54 | | enum bootm_efi_mode efi_boot; |
55 | | unsigned long initrd_address; |
56 | | unsigned long os_address; |
57 | | unsigned long os_entry; |
58 | | }; |
59 | | |
60 | | int bootm_image_name_and_part(const char *name, char **filename, char **part); |
61 | | |
62 | | int bootm_boot(const struct bootm_data *data); |
63 | | |
64 | | struct image_data *bootm_boot_prep(const struct bootm_data *bootm_data); |
65 | | int bootm_open_os_compressed(struct image_data *data); |
66 | | int bootm_boot_handler(struct image_data *data); |
67 | | void bootm_boot_cleanup(struct image_data *data); |
68 | | |
69 | | struct image_data { |
70 | | /* simplest case. barebox has already loaded the os here */ |
71 | | struct resource *os_res; |
72 | | |
73 | | /* Generic loadable object for OS image */ |
74 | | struct loadable *os; |
75 | | |
76 | | /* if os is an uImage this will be provided */ |
77 | | struct uimage_handle *os_uimage; |
78 | | |
79 | | char *os_part; |
80 | | |
81 | | /* otherwise only the filename will be provided */ |
82 | | char *os_file; |
83 | | |
84 | | /* |
85 | | * The address the user wants to load the os image to. |
86 | | * May be UIMAGE_INVALID_ADDRESS to indicate that the |
87 | | * user has not specified any address. In this case the |
88 | | * handler may choose a suitable address |
89 | | */ |
90 | | unsigned long os_address; |
91 | | |
92 | | /* entry point to the os. relative to the start of the image */ |
93 | | unsigned long os_entry; |
94 | | |
95 | | /* initial os_address/os_entry supplied at entry to bootm_boot */ |
96 | | unsigned long os_address_hint; |
97 | | unsigned long os_entry_hint; |
98 | | |
99 | | /* if initrd is already loaded this resource will be !NULL */ |
100 | | struct resource *initrd_res; |
101 | | |
102 | | /* Generic loadable object for initrd */ |
103 | | struct loadable *initrd; |
104 | | |
105 | | /* if initrd is an uImage this will be provided */ |
106 | | struct uimage_handle *initrd_uimage; |
107 | | char *initrd_part; |
108 | | |
109 | | /* otherwise only the filename will be provided */ |
110 | | char *initrd_file; |
111 | | |
112 | | unsigned long initrd_address; |
113 | | |
114 | | char *oftree_file; |
115 | | char *oftree_part; |
116 | | |
117 | | /* if oftree is an uImage this will be provided */ |
118 | | struct uimage_handle *oftree_uimage; |
119 | | |
120 | | struct device_node *of_root_node; |
121 | | struct resource *oftree_res; |
122 | | |
123 | | /* Generic loadable object for oftree */ |
124 | | struct loadable *oftree; |
125 | | |
126 | | /* |
127 | | * The first PAGE_SIZE bytes of the OS image. Can be used by the image |
128 | | * handlers to analyze the OS image before actually loading the bulk of |
129 | | * it. |
130 | | */ |
131 | | void *os_header; |
132 | | |
133 | | /* Type of OS image, e.g. filetype_fit or the same as kernel_type */ |
134 | | enum filetype image_type; |
135 | | /* Type of kernel image that's going to be booted */ |
136 | | enum filetype kernel_type; |
137 | | |
138 | | enum bootm_verify verify; |
139 | | int verbose; |
140 | | int force; |
141 | | int dryrun; |
142 | | struct { |
143 | | u8 os:1; |
144 | | u8 initrd:1; |
145 | | u8 oftree:1; |
146 | | } is_override; |
147 | | enum bootm_efi_mode efi_boot; |
148 | | }; |
149 | | |
150 | | struct image_handler { |
151 | | const char *name; |
152 | | |
153 | | struct list_head list; |
154 | | |
155 | | int ih_os; |
156 | | |
157 | | enum filetype filetype; |
158 | | bool (*check_image)(struct image_handler *handler, |
159 | | struct image_data *data, |
160 | | enum filetype detected_filetype); |
161 | | int (*bootm)(struct image_data *data); |
162 | | }; |
163 | | |
164 | | int register_image_handler(struct image_handler *handle); |
165 | | |
166 | | #ifdef CONFIG_BOOTM_VERBOSE |
167 | | static inline int bootm_verbose(struct image_data *data) |
168 | | { |
169 | | return data->verbose; |
170 | | } |
171 | | #else |
172 | | static inline int bootm_verbose(struct image_data *data) |
173 | 0 | { |
174 | 0 | return 0; |
175 | 0 | } Unexecuted instantiation: bootm.c:bootm_verbose Unexecuted instantiation: booti.c:bootm_verbose Unexecuted instantiation: bootm-uimage.c:bootm_verbose Unexecuted instantiation: image-fit.c:bootm_verbose Unexecuted instantiation: bootm-fit.c:bootm_verbose Unexecuted instantiation: boot.c:bootm_verbose Unexecuted instantiation: fastboot.c:bootm_verbose Unexecuted instantiation: overlay.c:bootm_verbose |
176 | | #endif |
177 | | |
178 | | void bootm_data_init_defaults(struct bootm_data *data); |
179 | | void bootm_data_restore_defaults(const struct bootm_data *data); |
180 | | |
181 | | const struct resource * |
182 | | bootm_load_os(struct image_data *data, |
183 | | ulong load_address, ulong end_address); |
184 | | |
185 | | const struct resource * |
186 | | bootm_load_initrd(struct image_data *data, |
187 | | ulong load_address, ulong end_address); |
188 | | |
189 | | void *bootm_get_devicetree(struct image_data *data); |
190 | | |
191 | | const struct resource * |
192 | | bootm_load_devicetree(struct image_data *data, void *fdt, |
193 | | ulong load_address, ulong end_address); |
194 | | loff_t bootm_get_os_size(struct image_data *data); |
195 | | |
196 | | enum bootm_verify bootm_get_verify_mode(void); |
197 | | void bootm_set_verify_mode(enum bootm_verify mode); |
198 | | |
199 | | bool bootm_signed_images_are_forced(void); |
200 | | void bootm_force_signed_images(void); |
201 | | |
202 | 0 | #define UIMAGE_SOME_ADDRESS (UIMAGE_INVALID_ADDRESS - 1) |
203 | | #define UIMAGE_IS_ADDRESS_VALID(addr) \ |
204 | 0 | ((addr) != UIMAGE_INVALID_ADDRESS && \ |
205 | 0 | (addr) != UIMAGE_SOME_ADDRESS) |
206 | | |
207 | | void *booti_load_image(struct image_data *data, phys_addr_t *oftree); |
208 | | |
209 | | bool bootm_efi_check_image(struct image_handler *handler, |
210 | | struct image_data *data, |
211 | | enum filetype detected_filetype); |
212 | | |
213 | | int file_read_and_detect_boot_image_type(const char *os_file, void **os_header); |
214 | | |
215 | | #endif /* __BOOTM_H */ |