/******************************************************************************
**  Function:  CFE_PSP_Restart()
**
**  Purpose:
**    Provides a common interface to reset the processor.  This implementation
**      may need to be customized for missions with custom reset requirements.
**
**  Arguments:
**    reset_type  : Type of reset.
**
**  Return:
**    (none)
*/
void CFE_PSP_Restart(uint32 reset_type)
{
   OS_printf("\nWarning: CFE PSP Restart with reset type %u!\n\n", reset_type);

   /*
   ** Delay for second or two, allow the print statement to send
   */

   taskDelay(100);

#ifndef _WRS_VX_SMP /* Changed for SMP API compatability. */
   taskLock();
   intLock();
#else
   /* Note: This only locks the current CPU core.  Other cores
    *  are still active and may continue to access system resources
    *  or service the watchdog on an SMP system.
    */
   taskCpuLock();
   intCpuLock();
#endif

   if ( reset_type == CFE_ES_POWERON_RESET )
   {
      CFE_PSP_ReservedMemoryPtr->bsp_reset_type = CFE_ES_POWERON_RESET;
      /*
      ** The sysToMonitor function flushes caches for us
      *
      * reboot(BOOT_CLEAR);
      */

      /*
      ** Use the watchdog timer to assert a reset
      */
      CFE_PSP_WatchdogEnable();

      for(;;)
      {
         /*
         ** Set the current count value to something small
         */
         CFE_PSP_WatchdogSet(CFE_PSP_WATCHDOG_MIN);

         /*
         ** Wait for the watchdog to expire...
         */
         taskDelay(100);
      }

   }
   else
   {
      CFE_PSP_ReservedMemoryPtr->bsp_reset_type = CFE_ES_PROCESSOR_RESET;
      /*
      ** The sysToMonitor function flushes caches for us
      *
      * reboot(0);
      */

      /*
      ** Use the watchdog timer to assert a reset
      */
      CFE_PSP_WatchdogEnable();

      for(;;)
      {
         /*
         ** Set the current count value to something small
         */
         CFE_PSP_WatchdogSet(CFE_PSP_WATCHDOG_MIN);

         /*
         ** Wait for the watchdog to expire...
         */
         taskDelay(100);
      }
   }
}
Beispiel #2
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_AppMain(void)
{
    int32   Status      = CFE_SUCCESS;
    uint32  RunStatus   = CFE_ES_APP_RUN;

    /*
    ** Performance Log, Start
    */
    CFE_ES_PerfLogEntry(HS_APPMAIN_PERF_ID);

    /*
    ** Register this application with Executive Services
    */
    Status = CFE_ES_RegisterApp();

    /*
    ** Perform application specific initialization
    */
    if (Status == CFE_SUCCESS)
    {
        Status = HS_AppInit();
    }

    /*
    ** If no errors were detected during initialization, then wait for everyone to start
    */
    if (Status == CFE_SUCCESS)
    {
       CFE_ES_WaitForStartupSync(HS_STARTUP_SYNC_TIMEOUT);

       /*
       ** Enable and set the watchdog timer
       */
       CFE_PSP_WatchdogSet(HS_WATCHDOG_TIMEOUT_VALUE);
       CFE_PSP_WatchdogService();
       CFE_PSP_WatchdogEnable();
       CFE_PSP_WatchdogService();

       /*
       ** Subscribe to Event Messages
       */
       if (HS_AppData.CurrentEventMonState == HS_STATE_ENABLED)
       {
          Status = CFE_SB_SubscribeEx(CFE_EVS_EVENT_MSG_MID,
                                      HS_AppData.EventPipe,
                                      CFE_SB_Default_Qos,
                                      HS_EVENT_PIPE_DEPTH);
          if (Status != CFE_SUCCESS)
          {
             CFE_EVS_SendEvent(HS_SUB_EVS_ERR_EID, CFE_EVS_ERROR,
                 "Error Subscribing to Events,RC=0x%08X",Status);
          }
       }
    }

    if (Status != CFE_SUCCESS)
    {
       /*
       ** Set run status to terminate main loop
       */
       RunStatus = CFE_ES_APP_ERROR;
    }

    /*
    ** Application main loop
    */
    while(CFE_ES_RunLoop(&RunStatus) == TRUE)
    {
        /*
        ** Performance Log, Stop
        */
        CFE_ES_PerfLogExit(HS_APPMAIN_PERF_ID);

        /*
        ** Task Delay for a configured timeout
        */
#if HS_POST_PROCESSING_DELAY != 0
        OS_TaskDelay(HS_POST_PROCESSING_DELAY);
#endif

        /*
        ** Task Delay for a configured timeout
        */
        Status = CFE_SB_RcvMsg(&HS_AppData.MsgPtr, HS_AppData.WakeupPipe, HS_WAKEUP_TIMEOUT);

        /*
        ** Performance Log, Start
        */
        CFE_ES_PerfLogEntry(HS_APPMAIN_PERF_ID);

        /*
        ** Process the software bus message
        */
        if ((Status == CFE_SUCCESS) ||
            (Status == CFE_SB_NO_MESSAGE) ||
            (Status == CFE_SB_TIME_OUT))
        {
            Status = HS_ProcessMain();
        }

        /*
        ** Note: If there were some reason to exit the task
        **       normally (without error) then we would set
        **       RunStatus = CFE_ES_APP_EXIT
        */
        if (Status != CFE_SUCCESS)
        {
            /*
            ** Set request to terminate main loop
            */
            RunStatus = CFE_ES_APP_ERROR;
        }

    } /* end CFS_ES_RunLoop while */

    /*
    ** Check for "fatal" process error...
    */
    if (Status != CFE_SUCCESS)
    {
        /*
        ** Send an event describing the reason for the termination
        */
        CFE_EVS_SendEvent(HS_APP_EXIT_EID, CFE_EVS_CRITICAL,
                          "Application Terminating, err = 0x%08X", Status);

        /*
        ** In case cFE Event Services is not working
        */
        CFE_ES_WriteToSysLog("HS App: Application Terminating, ERR = 0x%08X\n", Status);
    }

    HS_CustomCleanup();

    /*
    ** Performance Log, Stop
    */
    CFE_ES_PerfLogExit(HS_APPMAIN_PERF_ID);

    /*
    ** Exit the application
    */
    CFE_ES_ExitApp(RunStatus);

} /* end HS_AppMain */