1 /*
2  * Copyright (c) 2017 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @brief Run the set of special native tasks corresponding to the given level
9  *
10  * @param level One of _NATIVE_*_LEVEL as defined in soc.h
11  */
run_native_tasks(int level)12 void run_native_tasks(int level)
13 {
14 	extern void (*__native_PRE_BOOT_1_tasks_start[])(void);
15 	extern void (*__native_PRE_BOOT_2_tasks_start[])(void);
16 	extern void (*__native_PRE_BOOT_3_tasks_start[])(void);
17 	extern void (*__native_FIRST_SLEEP_tasks_start[])(void);
18 	extern void (*__native_ON_EXIT_tasks_start[])(void);
19 	extern void (*__native_tasks_end[])(void);
20 
21 	static void (**native_pre_tasks[])(void) = {
22 		__native_PRE_BOOT_1_tasks_start,
23 		__native_PRE_BOOT_2_tasks_start,
24 		__native_PRE_BOOT_3_tasks_start,
25 		__native_FIRST_SLEEP_tasks_start,
26 		__native_ON_EXIT_tasks_start,
27 		__native_tasks_end
28 	};
29 
30 	void (**fptr)(void);
31 
32 	for (fptr = native_pre_tasks[level]; fptr < native_pre_tasks[level+1];
33 		fptr++) {
34 		if (*fptr) { /* LCOV_EXCL_BR_LINE */
35 			(*fptr)();
36 		}
37 	}
38 }
39