/** This is the RTEMS initialization module. * * @file * @author P. LEROY * * This module contains two very different information: * - specific instructions to configure the compilation of the RTEMS executive * - functions related to the fligth softwre initialization, especially the INIT RTEMS task * */ //************************* // GPL reminder to be added //************************* #include /* configuration information */ #define CONFIGURE_INIT #include /* for device driver prototypes */ /* configuration information */ #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_MAXIMUM_TASKS 20 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) #define CONFIGURE_MAXIMUM_DRIVERS 16 #define CONFIGURE_MAXIMUM_PERIODS 5 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 #ifdef PRINT_STACK_REPORT #define CONFIGURE_STACK_CHECKER_ENABLED #endif #include /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ #ifdef RTEMS_DRVMGR_STARTUP #ifdef LEON3 /* Add Timer and UART Driver */ #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER #endif #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART #endif #endif #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ #include #endif #include "timegen_init.h" #include "fsw_config.c" rtems_task Init( rtems_task_argument ignored ) { /** This is the RTEMS INIT taks, it the first task launched by the system. * * @param unused is the starting argument of the RTEMS task * * The INIT task create and run all other RTEMS tasks. * */ rtems_status_code status; rtems_status_code status_spw; // initCoarseTime(); // UART settings send_console_outputs_on_apbuart_port(); set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); enable_apbuart_transmitter(); DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") PRINTF("\n\n\n\n\n") PRINTF("*************************\n") PRINTF("** Time Generator **\n") PRINTF1("** %d.", SW_VERSION_N1) PRINTF1("%d.", SW_VERSION_N2) PRINTF1("%d.", SW_VERSION_N3) PRINTF1("%d **\n", SW_VERSION_N4) PRINTF("*************************\n") PRINTF("\n\n") // init_local_mode_parameters(); // init_housekeeping_parameters(); // updateLFRCurrentMode(); // BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) create_names(); // create all names status = create_message_queues(); // create message queues if (status != RTEMS_SUCCESSFUL) { PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) } status = create_all_tasks(); // create all tasks if (status != RTEMS_SUCCESSFUL) { PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) } // ************************** // grspw_timecode_callback = &timegen_timecode_irq_handler; status_spw = spacewire_open_link(); // (1) open the link if ( status_spw != RTEMS_SUCCESSFUL ) { PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) } if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link { status_spw = spacewire_configure_link( fdSPW ); if ( status_spw != RTEMS_SUCCESSFUL ) { PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) } } if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link { status_spw = spacewire_start_link( fdSPW ); if ( status_spw != RTEMS_SUCCESSFUL ) { PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) } } // // *************************** status = start_all_tasks(); // start all tasks if (status != RTEMS_SUCCESSFUL) { PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) } // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization status = start_recv_send_tasks(); if ( status != RTEMS_SUCCESSFUL ) { PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) } // suspend science tasks. they will be restarted later depending on the mode status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) if (status != RTEMS_SUCCESSFUL) { PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) } // if the spacewire link is not up then send an event to the SPIQ task for link recovery if ( status_spw != RTEMS_SUCCESSFUL ) { status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); if ( status != RTEMS_SUCCESSFUL ) { PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) } } BOOT_PRINTF("delete INIT\n") status = rtems_task_delete(RTEMS_SELF); } void init_local_mode_parameters( void ) { /** This function initialize the param_local global variable with default values. * */ unsigned int i; // LOCAL PARAMETERS // set_local_nb_interrupt_f0_MAX(); BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) // init sequence counters for(i = 0; i