|
34 | 34 | #ifndef H_BOOTUTIL_HOOKS
|
35 | 35 | #define H_BOOTUTIL_HOOKS
|
36 | 36 |
|
37 |
| -#ifdef MCUBOOT_IMAGE_ACCESS_HOOKS |
| 37 | +#include "bootutil/bootutil.h" |
| 38 | +#include "bootutil/fault_injection_hardening.h" |
38 | 39 |
|
39 |
| -#define BOOT_HOOK_CALL(f, ret_default, ...) f(__VA_ARGS__) |
| 40 | +#define DO_HOOK_CALL(f, ret_default, ...) \ |
| 41 | + f(__VA_ARGS__) |
40 | 42 |
|
41 |
| -#define BOOT_HOOK_CALL_FIH(f, fih_ret_default, fih_rc, ...) \ |
| 43 | +#define DO_HOOK_CALL_FIH(f, fih_ret_default, fih_rc, ...) \ |
42 | 44 | do { \
|
43 | 45 | FIH_CALL(f, fih_rc, __VA_ARGS__); \
|
44 | 46 | } while(0);
|
45 | 47 |
|
46 |
| -#else |
47 |
| - |
48 |
| -#define BOOT_HOOK_CALL(f, ret_default, ...) ret_default |
| 48 | +#define HOOK_CALL_NOP(f, ret_default, ...) ret_default |
49 | 49 |
|
50 |
| -#define BOOT_HOOK_CALL_FIH(f, fih_ret_default, fih_rc, ...) \ |
| 50 | +#define HOOK_CALL_FIH_NOP(f, fih_ret_default, fih_rc, ...) \ |
51 | 51 | do { \
|
52 | 52 | fih_rc = fih_ret_default; \
|
53 | 53 | } while(0);
|
54 | 54 |
|
55 |
| -#endif |
| 55 | +#ifdef MCUBOOT_IMAGE_ACCESS_HOOKS |
| 56 | + |
| 57 | +#define BOOT_HOOK_CALL(f, ret_default, ...) \ |
| 58 | + DO_HOOK_CALL(f, ret_default, __VA_ARGS__) |
| 59 | + |
| 60 | +#define BOOT_HOOK_CALL_FIH(f, fih_ret_default, fih_rc, ...) \ |
| 61 | + DO_HOOK_CALL_FIH(f, fih_ret_default, fih_rc, __VA_ARGS__) |
| 62 | + |
| 63 | +#else |
| 64 | + |
| 65 | +#define BOOT_HOOK_CALL(f, ret_default, ...) \ |
| 66 | + HOOK_CALL_NOP(f, ret_default, __VA_ARGS__) |
| 67 | + |
| 68 | +#define BOOT_HOOK_CALL_FIH(f, fih_ret_default, fih_rc, ...) \ |
| 69 | + HOOK_CALL_FIH_NOP(f, fih_ret_default, fih_rc, __VA_ARGS__) |
| 70 | + |
| 71 | +#endif /* MCUBOOT_IMAGE_ACCESS_HOOKS */ |
| 72 | + |
| 73 | +#ifdef MCUBOOT_BOOT_GO_HOOKS |
| 74 | + |
| 75 | +#define BOOT_HOOK_GO_CALL_FIH(f, fih_ret_default, fih_rc, ...) \ |
| 76 | + DO_HOOK_CALL_FIH(f, fih_ret_default, fih_rc, __VA_ARGS__); |
| 77 | + |
| 78 | +#else |
| 79 | + |
| 80 | +#define BOOT_HOOK_GO_CALL_FIH(f, fih_ret_default, fih_rc, ...) \ |
| 81 | + HOOK_CALL_FIH_NOP(f, fih_ret_default, fih_rc, __VA_ARGS__) |
| 82 | + |
| 83 | +#endif /* MCUBOOT_BOOT_GO_HOOKS */ |
| 84 | + |
56 | 85 |
|
57 | 86 | /** Hook for provide image header data.
|
58 | 87 | *
|
@@ -173,6 +202,19 @@ int boot_img_install_stat_hook(int image_index, int slot,
|
173 | 202 | */
|
174 | 203 | int boot_reset_request_hook(bool force);
|
175 | 204 |
|
| 205 | +/** |
| 206 | + * Hook to implement custom action before boot_go() function. |
| 207 | + * |
| 208 | + * @param rsp boot response structure. |
| 209 | + * |
| 210 | + * @retval FIH_SUCCESS: boot_go() should be skipped, boot response is already |
| 211 | + * filled. |
| 212 | + * FIH_FAILURE: boot_go() should be skipped, boot response is already |
| 213 | + * filled with error. |
| 214 | + * FIH_BOOT_HOOK_REGULAR: follow the normal execution path. |
| 215 | + */ |
| 216 | +fih_ret boot_go_hook(struct boot_rsp *rsp); |
| 217 | + |
176 | 218 | #define BOOT_RESET_REQUEST_HOOK_BUSY 1
|
177 | 219 | #define BOOT_RESET_REQUEST_HOOK_TIMEOUT 2
|
178 | 220 | #define BOOT_RESET_REQUEST_HOOK_CHECK_FAILED 3
|
|
0 commit comments