void ALT_EXIT (int exit_code) { /* ALT_LOG - please see HAL/inc/alt_log_printf.h for details */ ALT_LOG_PRINT_BOOT("[alt_exit.c] Entering _exit() function.\r\n"); ALT_LOG_PRINT_BOOT("[alt_exit.c] Exit code from main was %d.\r\n",exit_code); /* Stop all other threads */ ALT_LOG_PRINT_BOOT("[alt_exit.c] Calling ALT_OS_STOP().\r\n"); ALT_OS_STOP(); /* Provide notification to the simulator that we've stopped */ ALT_LOG_PRINT_BOOT("[alt_exit.c] Calling ALT_SIM_HALT().\r\n"); ALT_SIM_HALT(exit_code); /* spin forever, since there's no where to go back to */ ALT_LOG_PRINT_BOOT("[alt_exit.c] Spinning forever.\r\n"); while (1); }
void alt_main (void) { #ifndef ALT_NO_EXIT int result; #endif /* ALT LOG - please see HAL/sys/alt_log_printf.h for details */ ALT_LOG_PRINT_BOOT("[alt_main.c] Entering alt_main, calling alt_irq_init.\r\n"); /* Initialize the interrupt controller. */ alt_irq_init (NULL); /* Initialize the operating system */ ALT_LOG_PRINT_BOOT("[alt_main.c] Done alt_irq_init, calling alt_os_init.\r\n"); ALT_OS_INIT(); /* * Initialize the semaphore used to control access to the file descriptor * list. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Done OS Init, calling alt_sem_create.\r\n"); ALT_SEM_CREATE (&alt_fd_list_lock, 1); /* Initialize the device drivers/software components. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Calling alt_sys_init.\r\n"); alt_sys_init(); ALT_LOG_PRINT_BOOT("[alt_main.c] Done alt_sys_init.\r\n"); #if !defined(ALT_USE_DIRECT_DRIVERS) && (defined(ALT_STDIN_PRESENT) || defined(ALT_STDOUT_PRESENT) || defined(ALT_STDERR_PRESENT)) /* * Redirect stdio to the apropriate devices now that the devices have * been initialized. This is only done if the user has requested these * devices be present (not equal to /dev/null) and if direct drivers * aren't being used. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Redirecting IO.\r\n"); alt_io_redirect(ALT_STDOUT, ALT_STDIN, ALT_STDERR); #endif #ifndef ALT_NO_C_PLUS_PLUS /* * Call the C++ constructors */ ALT_LOG_PRINT_BOOT("[alt_main.c] Calling C++ constructors.\r\n"); _do_ctors (); #endif /* ALT_NO_C_PLUS_PLUS */ #if !defined(ALT_NO_C_PLUS_PLUS) && !defined(ALT_NO_CLEAN_EXIT) && !defined(ALT_NO_EXIT) /* * Set the C++ destructors to be called at system shutdown. This is only done * if a clean exit has been requested (i.e. the exit() function has not been * redefined as _exit()). This is in the interest of reducing code footprint, * in that the atexit() overhead is removed when it's not needed. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Calling atexit.\r\n"); atexit (_do_dtors); #endif /* * Finally, call main(). The return code is then passed to a subsequent * call to exit() unless the application is never supposed to exit. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Calling main.\r\n"); #ifdef ALT_NO_EXIT main (alt_argc, alt_argv, alt_envp); #else result = main (alt_argc, alt_argv, alt_envp); close(STDOUT_FILENO); exit (result); #endif ALT_LOG_PRINT_BOOT("[alt_main.c] After main - we should not be here?.\r\n"); }