Skip to content

Commit 88c61d3

Browse files
Declan Snydercfriedt
authored andcommitted
include: hooks.h: Add mocks
Add mocks of platform hooks so that #ifdef are not needed around calls to these functions. Signed-off-by: Declan Snyder <[email protected]>
1 parent 1f03dcf commit 88c61d3

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

include/zephyr/platform/hooks.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,67 @@
2020
*/
2121

2222

23+
#ifdef CONFIG_SOC_RESET_HOOK
2324
/**
2425
* @brief SoC hook executed at the beginning of the reset vector.
2526
*
2627
* This hook is implemented by the SoC and can be used to perform any
2728
* SoC-specific initialization.
2829
*/
2930
void soc_reset_hook(void);
31+
#else
32+
#define soc_reset_hook() do { } while (0)
33+
#endif
3034

35+
#ifdef CONFIG_SOC_PREP_HOOK
3136
/**
3237
* @brief SoC hook executed after the reset vector.
3338
*
3439
* This hook is implemented by the SoC and can be used to perform any
3540
* SoC-specific initialization.
3641
*/
3742
void soc_prep_hook(void);
43+
#else
44+
#define soc_prep_hook() do { } while (0)
45+
#endif
3846

47+
#ifdef CONFIG_SOC_EARLY_INIT_HOOK
3948
/**
4049
* @brief SoC hook executed before the kernel and devices are initialized.
4150
*
4251
* This hook is implemented by the SoC and can be used to perform any
4352
* SoC-specific initialization.
4453
*/
4554
void soc_early_init_hook(void);
55+
#else
56+
#define soc_early_init_hook() do { } while (0)
57+
#endif
4658

59+
#ifdef CONFIG_SOC_LATE_INIT_HOOK
4760
/**
4861
* @brief SoC hook executed after the kernel and devices are initialized.
4962
*
5063
* This hook is implemented by the SoC and can be used to perform any
5164
* SoC-specific initialization.
5265
*/
5366
void soc_late_init_hook(void);
67+
#else
68+
#define soc_late_init_hook() do { } while (0)
69+
#endif
5470

71+
#ifdef CONFIG_SOC_PER_CORE_INIT_HOOK
5572
/**
5673
* @brief SoC per-core initialization
5774
*
5875
* This hook is implemented by the SoC and can be used to perform any
5976
* SoC-specific per-core initialization
6077
*/
6178
void soc_per_core_init_hook(void);
79+
#else
80+
#define soc_per_core_init_hook() do { } while (0)
81+
#endif
6282

83+
#ifdef CONFIG_BOARD_EARLY_INIT_HOOK
6384
/**
6485
* @brief Board hook executed before the kernel starts.
6586
*
@@ -68,7 +89,11 @@ void soc_per_core_init_hook(void);
6889
* initialization.
6990
*/
7091
void board_early_init_hook(void);
92+
#else
93+
#define board_early_init_hook() do { } while (0)
94+
#endif
7195

96+
#ifdef CONFIG_BOARD_LATE_INIT_HOOK
7297
/**
7398
* @brief Board hook executed after the kernel starts.
7499
*
@@ -77,5 +102,8 @@ void board_early_init_hook(void);
77102
* any board-specific initialization.
78103
*/
79104
void board_late_init_hook(void);
105+
#else
106+
#define board_late_init_hook() do { } while (0)
107+
#endif
80108

81109
#endif

kernel/init.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,10 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
300300
arch_irq_offload_init();
301301
#endif
302302
z_sys_init_run_level(INIT_LEVEL_POST_KERNEL);
303-
#if CONFIG_SOC_LATE_INIT_HOOK
303+
304304
soc_late_init_hook();
305-
#endif
306-
#if CONFIG_BOARD_LATE_INIT_HOOK
305+
307306
board_late_init_hook();
308-
#endif
309307

310308
#if defined(CONFIG_STACK_POINTER_RANDOM) && (CONFIG_STACK_POINTER_RANDOM != 0)
311309
z_stack_adjust_initialized = 1;
@@ -554,12 +552,10 @@ FUNC_NORETURN void z_cstart(void)
554552
/* do any necessary initialization of static devices */
555553
z_device_state_init();
556554

557-
#if CONFIG_SOC_EARLY_INIT_HOOK
558555
soc_early_init_hook();
559-
#endif
560-
#if CONFIG_BOARD_EARLY_INIT_HOOK
556+
561557
board_early_init_hook();
562-
#endif
558+
563559
/* perform basic hardware initialization */
564560
z_sys_init_run_level(INIT_LEVEL_PRE_KERNEL_1);
565561
#if defined(CONFIG_SMP)

0 commit comments

Comments
 (0)