Exemple #1
0
/**
 *
 * @brief Mainline for kernel's background task
 *
 * This routine completes kernel initialization by invoking the remaining
 * init functions, then invokes application's main() routine.
 *
 * @return N/A
 */
static void _main(void *unused1, void *unused2, void *unused3)
{
	ARG_UNUSED(unused1);
	ARG_UNUSED(unused2);
	ARG_UNUSED(unused3);

	_sys_device_do_config_level(_SYS_INIT_LEVEL_POST_KERNEL);

	/* Final init level before app starts */
	_sys_device_do_config_level(_SYS_INIT_LEVEL_APPLICATION);

#ifdef CONFIG_CPLUSPLUS
	/* Process the .ctors and .init_array sections */
	extern void __do_global_ctors_aux(void);
	extern void __do_init_array_aux(void);
	__do_global_ctors_aux();
	__do_init_array_aux();
#endif

	_init_static_threads();

#ifdef CONFIG_BOOT_TIME_MEASUREMENT
	/* record timestamp for kernel's _main() function */
	extern u64_t __main_tsc;

	__main_tsc = _tsc_read();
#endif

	extern void main(void);

	main();

	/* Terminate thread normally since it has no more work to do */
	_main_thread->base.user_options &= ~K_ESSENTIAL;
}
Exemple #2
0
/**
 *
 * @brief Mainline for nanokernel's background task
 *
 * This routine completes kernel initialization by invoking the remaining
 * init functions, then invokes application's main() routine.
 *
 * @return N/A
 */
static void _main(void)
{
    _sys_device_do_config_level(_SYS_INIT_LEVEL_SECONDARY);
    _sys_device_do_config_level(_SYS_INIT_LEVEL_NANOKERNEL);
    _sys_device_do_config_level(_SYS_INIT_LEVEL_APPLICATION);

#ifdef CONFIG_CPLUSPLUS
    /* Process the .ctors and .init_array sections */
    extern void __do_global_ctors_aux(void);
    extern void __do_init_array_aux(void);
    __do_global_ctors_aux();
    __do_init_array_aux();
#endif

    extern void main(void);
    main();
}
Exemple #3
0
/**
 *
 * @brief Initialize kernel
 *
 * This routine is invoked when the system is ready to run C code. The
 * processor must be running in 32-bit mode, and the BSS must have been
 * cleared/zeroed.
 *
 * @return Does not return
 */
FUNC_NORETURN void _Cstart(void)
{
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
	void *dummy_thread = NULL;
#else
	/* floating point is NOT used during kernel init */

	char __stack dummy_stack[_K_THREAD_NO_FLOAT_SIZEOF];
	void *dummy_thread = dummy_stack;
#endif

	/*
	 * Initialize kernel data structures. This step includes
	 * initializing the interrupt subsystem, which must be performed
	 * before the hardware initialization phase.
	 */

	prepare_multithreading(dummy_thread);

	/* perform basic hardware initialization */
	_sys_device_do_config_level(_SYS_INIT_LEVEL_PRE_KERNEL_1);
	_sys_device_do_config_level(_SYS_INIT_LEVEL_PRE_KERNEL_2);

	/* initialize stack canaries */
#ifdef CONFIG_STACK_CANARIES
	__stack_chk_guard = (void *)sys_rand32_get();
#endif

	/* display boot banner */

	PRINT_BOOT_BANNER();

	switch_to_main_thread();

	/*
	 * Compiler can't tell that the above routines won't return and issues
	 * a warning unless we explicitly tell it that control never gets this
	 * far.
	 */

	CODE_UNREACHABLE;
}
Exemple #4
0
/**
 *
 * @brief Initialize nanokernel
 *
 * This routine is invoked when the system is ready to run C code. The
 * processor must be running in 32-bit mode, and the BSS must have been
 * cleared/zeroed.
 *
 * @return Does not return
 */
FUNC_NORETURN void _Cstart(void)
{
    /* floating point operations are NOT performed during nanokernel init */

    char dummyTCS[__tTCS_NOFLOAT_SIZEOF];

    /*
     * Initialize nanokernel data structures. This step includes
     * initializing the interrupt subsystem, which must be performed
     * before the hardware initialization phase.
     */

    nano_init((struct tcs *)&dummyTCS);

    /* perform basic hardware initialization */

    _sys_device_do_config_level(_SYS_INIT_LEVEL_PRIMARY);

    /*
     * Initialize random number generator
     * As a platform may implement it in hardware, it has to be
     * initialized after rest of hardware initialization and
     * before stack canaries that use it
     */

    RAND32_INIT();

    /* initialize stack canaries */

    STACK_CANARY_INIT();

    /* display boot banner */

    PRINT_BOOT_BANNER();

    /* context switch to main task (entry function is _main()) */

    _nano_fiber_swap();

    /*
     * Compiler can't tell that the above routines won't return and issues
     * a warning unless we explicitly tell it that control never gets this
     * far.
     */

    CODE_UNREACHABLE;
}