示例#1
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;
}
示例#2
0
文件: init.c 项目: bigdinotech/zephyr
/**
 *
 * @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;
}