Example #1
0
Reset_Handler(void)
{

	// Use Old Style Data and BSS section initialisation,
	// That will initialise a single BSS sections.

	// Zero fill the bss segment
	bss_init(&__bss_start__, &__bss_end__);

	// Call the standard library initialisation (mandatory, SystemInit()
	// and C++ static constructors are called from here).
	__libc_init_array();

	// Call the main entry point, and save the exit code.
	int r = main();

	// Run the static destructors.
	__libc_fini_array();

	// On test platforms, like semi-hosting, this can be used to inform
	// the host on the test result.
	// On embedded platforms, usually reset the processor.
	_exit(r);

}
Example #2
0
void Boot_Init()
{
	SystemInit(); // CMSIS system initialization
	Board_EarlyInit();
	Console_EarlyInit();

	// Libc-provided function to initialize global structures e.g.
	// calling constructors on global C++ objects
	__libc_init_array();

	OS_Init();
	Console_LateInit();
	Board_LateInit();

	if (__main)
		__main();
	int return_code = main(0, NULL, NULL);

	// If main() returns, call the finalizers/destructors
	extern void __libc_fini_array();
	__libc_fini_array();

	// If we have exit() call that
	if (exit)
		exit(return_code);

	// If exit() returns (!) power down the board
	PowerManagement_PowerDown();
}
Example #3
0
File: initfini.c Project: dtbinh/M2
void exit(int return_code) {
    uint8_t i;
    
    for (i = 0; i < atexit_count; i++) {
        atexit_funcs[i]();
    }
    
    __libc_fini_array();
    _exit(return_code);
}
Example #4
0
void __attribute__((weak)) NORETURN __libnx_exit(int rc)
{
    // Call destructors.
    void __libc_fini_array(void);
    __libc_fini_array();

    // Clean up services.
    __appExit();

    __nx_exit(0, envGetExitFuncPtr());
}
Example #5
0
void _exit(int ret)
{
    int i;

    for (i = 0; __DTOR_LIST__[i] != 0; i++)
        ((void((*)(void)))__DTOR_LIST__[i]) ();
    close_all_files();
    __libc_fini_array();
    printk("main returned %d\n", ret);
#if defined(HAVE_LWIP) && defined(CONFIG_NETFRONT)
    stop_networking();
#endif
    stop_kernel();
    if (!ret) {
	/* No problem, just shutdown.  */
        struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_poweroff };
        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
    }
    do_exit();
}
Example #6
0
void __attribute__((noreturn)) __ctru_exit(int rc)
{
	// Run the global destructors
	__libc_fini_array();

	// TODO: APT exit goes here

	// Unmap the linear heap
	svcControlMemory(&__linear_heap, __linear_heap, 0x0, __linear_heap_size, MEMOP_FREE, 0x0);

	// Unmap the application heap
	svcControlMemory(&heapBase, heapBase, 0x0, __heap_size, MEMOP_FREE, 0x0);

	// Jump to the loader if it provided a callback
	if (__system_retAddr)
		__system_retAddr();

	// Since above did not jump, end this process
	svcExitProcess();
}
Example #7
0
void __attribute__((noreturn)) __ctru_exit(int rc)
{
   __libc_fini_array();
   __appExit();
   __libctru_exit(rc);
}