Align with the latest upstream native simulator 4c595794588f9d7f67fcf0fe05c3db02892a00f9 including: * 4c59579 Makefile: Add option to build native part * 910f934 Makefile: NSI_EXTRA_INCLUDES option and lots of commentary * d9bf489 cmd line parsin: Minor header refactoring * 02f3555 cmd line cleanup: Run as NSI_TASK instead of calling expl. * 2c88173 Split exit call in two * 2b989b4 CPU IF change: nsif_cpu0_cleanup() to return int * e696228 HW scheduler: Add API to get next event time * ae0e9e8 native irq ctrl: Miscellaneous fixes and improvements * 3fd84cd NSI_TASK: Add compile check of valid priority * 7e09fb8 HW events: Change internal storage And two minor updates to the native_sim board, to align with this updated version: * nsif_cpu0_cleanup(void) now must return an int * We need to explicitly tell the native simulator build we want the native components built Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
73 lines
2.1 KiB
C
73 lines
2.1 KiB
C
/*
|
|
* Copyright (c) 2023 Nordic Semiconductor ASA
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#ifndef NSI_COMMON_SRC_NSI_TASKS_H
|
|
#define NSI_COMMON_SRC_NSI_TASKS_H
|
|
|
|
#include "nsi_utils.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define NSITASK_PRE_BOOT_1_LEVEL 0
|
|
#define NSITASK_PRE_BOOT_2_LEVEL 1
|
|
#define NSITASK_HW_INIT_LEVEL 2
|
|
#define NSITASK_PRE_BOOT_3_LEVEL 3
|
|
#define NSITASK_FIRST_SLEEP_LEVEL 4
|
|
#define NSITASK_ON_EXIT_PRE_LEVEL 5
|
|
#define NSITASK_ON_EXIT_POST_LEVEL 6
|
|
|
|
/**
|
|
* NSI_TASK
|
|
*
|
|
* Register a function to be called at particular moments
|
|
* during the Native Simulator execution.
|
|
*
|
|
* There is 5 choices for when the function will be called (level):
|
|
* * PRE_BOOT_1: Will be called before the command line parameters are parsed,
|
|
* or the HW models are initialized
|
|
*
|
|
* * PRE_BOOT_2: Will be called after the command line parameters are parsed,
|
|
* but before the HW models are initialized
|
|
*
|
|
* * HW_INIT: Will be called during HW models initialization
|
|
*
|
|
* * PRE_BOOT_3: Will be called after the HW models initialization, right before
|
|
* the "CPUs are booted" and embedded SW in them is started.
|
|
*
|
|
* * FIRST_SLEEP: Will be called after the 1st time all CPUs are sent to sleep
|
|
*
|
|
* * ON_EXIT_PRE: Will be called during termination of the runner
|
|
* execution, as a first set.
|
|
*
|
|
* * ON_EXIT_POST: Will be called during termination of the runner
|
|
* execution, as the very last set before the program returns.
|
|
*
|
|
* The function must take no parameters and return nothing.
|
|
*/
|
|
#define NSI_TASK(fn, level, prio) \
|
|
static void (* const NSI_CONCAT(__nsi_task_, fn))(void) \
|
|
__attribute__((__used__)) \
|
|
__attribute__((__section__(".nsi_" #level NSI_STRINGIFY(prio) "_task")))\
|
|
= fn; \
|
|
/* Let's cross-check the macro level is a valid one, so we don't silently drop it */ \
|
|
_Static_assert(NSITASK_##level##_LEVEL >= 0, \
|
|
"Using a non pre-defined level, it will be dropped")
|
|
|
|
/**
|
|
* @brief Run the set of special native tasks corresponding to the given level
|
|
*
|
|
* @param level One of NSITASK_*_LEVEL as defined in soc.h
|
|
*/
|
|
void nsi_run_tasks(int level);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* NSI_COMMON_SRC_NSI_TASKS_H */
|