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