1 /* 2 * Copyright (c) 2017 Oticon A/S 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef _POSIX_SOC_INF_CLOCK_POSIX_NATIVE_TASK_H 8 #define _POSIX_SOC_INF_CLOCK_POSIX_NATIVE_TASK_H 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 /** 15 * NATIVE_TASK 16 * 17 * For native_posix, register a function to be called at particular moments 18 * during the native_posix execution. 19 * 20 * There is 5 choices for when the function will be called (level): 21 * * PRE_BOOT_1: Will be called before the command line parameters are parsed, 22 * or the HW models are initialized 23 * 24 * * PRE_BOOT_2: Will be called after the command line parameters are parsed, 25 * but before the HW models are initialized 26 * 27 * * PRE_BOOT_3: Will be called after the HW models initialization, right before 28 * the "CPU is booted" and Zephyr is started. 29 * 30 * * FIRST_SLEEP: Will be called the 1st time the CPU is sent to sleep 31 * 32 * * ON_EXIT: Will be called during termination of the native application 33 * execution. 34 * 35 * The function must take no parameters and return nothing. 36 * Note that for the PRE and ON_EXIT levels neither the Zephyr kernel or 37 * any Zephyr thread are running. 38 */ 39 #define NATIVE_TASK(fn, level, prio) \ 40 static void (* const _CONCAT(__native_task_, fn))() __used __noasan \ 41 __attribute__((__section__(".native_" #level STRINGIFY(prio) "_task")))\ 42 = fn 43 44 45 #define _NATIVE_PRE_BOOT_1_LEVEL 0 46 #define _NATIVE_PRE_BOOT_2_LEVEL 1 47 #define _NATIVE_PRE_BOOT_3_LEVEL 2 48 #define _NATIVE_FIRST_SLEEP_LEVEL 3 49 #define _NATIVE_ON_EXIT_LEVEL 4 50 51 /** 52 * @brief Run the set of special native tasks corresponding to the given level 53 * 54 * @param level One of _NATIVE_*_LEVEL as defined in soc.h 55 */ 56 void run_native_tasks(int level); 57 58 #ifdef __cplusplus 59 } 60 #endif 61 62 #endif /* _POSIX_SOC_INF_CLOCK_POSIX_NATIVE_TASK_H */ 63