Пример #1
0
/******************************************************************************
**  Function:  CFE_PSP_InitLocalTime()
**
**  Purpose: Initializes the vxWorks Aux and TimeStamp timers.
**
**  Arguments: none
******************************************************************************/
void CFE_PSP_InitLocalTime(void)
{
	   /* Set the sys clock rate */
	   sysClkRateSet(200);

	   /*
	   ** Disable the Aux timer interrupt
	   */
	   sysAuxClkDisable();

	   /*
	   ** Set the Aux timer rate
	   */
	   if(sysAuxClkRateGet() != CFE_PSP_TIMER_AUX_TICK_PER_SEC)
	   {
	      if(sysAuxClkRateSet(CFE_PSP_TIMER_AUX_TICK_PER_SEC) == ERROR)
	      {
	         OS_printf("CFE_PSP: Unable to set Aux Clock Rate!\n");
	      }

	      if(CFE_PSP_TIMER_PRINT_DBG == TRUE)
	      {
	         OS_printf("CFE_PSP: Aux Clock Rate %d.\n", sysAuxClkRateGet());
	      }
	   }
}
Пример #2
0
void task_3(void)
{
    uint32             status;
    OS_bin_sem_prop_t  bin_sem_prop;
    int                counter = 0;

    OS_printf("Starting task 3\n");
    OS_TaskRegister();

    OS_printf("TASK 3: Waiting on the semaphore\n");
    status = OS_BinSemTake(bin_sem_id);
    if ( status != OS_SUCCESS )
    {
       OS_printf("TASK 3: Error calling OS_BinSemTake\n");
    }
    else
    {
       status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
       OS_printf("TASK 3: out of BinSemTake: %d\n",(int)bin_sem_prop.value);
    }

    while(1)
    {
        OS_TaskDelay(1000);
        OS_printf("TASK 3:   Doing some work: %d\n", (int)counter++);

    }
}
Пример #3
0
void TimerFunction(uint32 timer_id)
{
   int32              status;
   OS_bin_sem_prop_t  bin_sem_prop;
  
   timer_counter++;

   status = OS_BinSemGive(bin_sem_id);

   /* 
   ** Note: The timer callback function in RTEMS runs as an ISR
   **       so calls that block cannot be made.
   */
   #ifndef _RTEMS_OS_ 
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      if ( bin_sem_prop.value > 1 )
      {
         OS_printf("Error: Binary sem value > 1 ( in timer):%d !\n",(int)bin_sem_prop.value);
         exit(-1);
      }
      else if ( bin_sem_prop.value < -1 )
      {
         OS_printf("Error: Binary sem value < -1 ( in timer):%d !\n",(int)bin_sem_prop.value);
         exit(-1);
      }
   #endif

}
Пример #4
0
/*--------------------------------------------------------------------------------------
    Name: OS_SymbolLookup

    Purpose: Find the Address of a Symbol

    Parameters:

    Returns: OS_ERROR if the symbol could not be found
             OS_SUCCESS if the symbol is found
             OS_INVALID_POINTER if the pointer passed in is invalid

             The address of the symbol will be stored in the pointer that is passed in.
---------------------------------------------------------------------------------------*/
int32 OS_SymbolLookup( uint32 *SymbolAddress, char *SymbolName )
{
int32 returnStatus=OS_SUCCESS;
boolean symbolFound=FALSE;
int i;

	/* Check the arguments for validity */
	if (SymbolAddress != NULL && SymbolName != NULL)
	{
		/* Search the table for the Symbol */
		for (i=0; i<UTF_MAX_SYMBOLS; i++)
		{
			if (strcmp(SymbolName, symbolTbl[i].symbolName) == 0)
            {
            	*SymbolAddress = symbolTbl[i].symbolAddr;
            	symbolFound = TRUE;
				OS_printf("OSAL: Address passed back = %x\n",*SymbolAddress);
            	break;
            }
		}

        if (symbolFound == FALSE)
        {
			OS_printf("OSAL: Error, cannot locate symbol '%s'\n",SymbolName);
			returnStatus = OS_ERROR;
        }
	}
	else
		returnStatus = OS_INVALID_POINTER;

   return(returnStatus);
}/* end OS_SymbolLookup */
Пример #5
0
void task_1(void)
{
    uint32             status;
    uint32             data_received;
    uint32             data_size;

    OS_printf("Starting task 1\n");

    OS_TaskRegister();

    OS_printf("Delay for 1 second before starting\n");
    OS_TaskDelay(1000);

    while(1)
    {

        status = OS_QueueGet(msgq_id, (void*)&data_received, MSGQ_SIZE, &data_size, 1000);

        if ( status == OS_SUCCESS )
        {
           OS_printf("TASK 1: Recieved a message on the queue\n");
        }
        else if ( status == OS_QUEUE_TIMEOUT )
        {
           OS_printf("TASK 1: Timeout on Queue! Timer counter = %d\n", timer_counter);
        }
        else
        {
            OS_printf("TASK 1: Queue Get error!\n");
        }
    }
}
Пример #6
0
void task_3(void)
{   
    
    uint32 data_received;
    uint32 data_size;
    uint32 status;

    OS_printf("Starting task 3\n");

    OS_TaskRegister();

    while(1)
    {
        status = OS_QueueGet(msgq_id, (void*)&data_received, MSGQ_SIZE, &data_size, OS_PEND);
   
        if (status == OS_SUCCESS)
        {
            OS_printf("TASK 3: Received - %d\n", (int)data_received+1);
        } 
        else
        {
            OS_printf("TASK 3: Error calling OS_QueueGet\n");
        }
    }
}
Пример #7
0
void EIM_ResetTlmConnection(void)
{
	int status = 0;
	struct sockaddr_in si_tmp;
	char cBuf[] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0};
	int len=14;

	OS_printf("EIM: Sending reset message.\n");

    memset((char *) &si_tmp, 0, sizeof(si_tmp));
    si_tmp.sin_family      = AF_INET;
    inet_aton(EIM_WIFI_IP, &si_tmp.sin_addr);
    si_tmp.sin_port        = htons(EIM_NAV_DATA_PORT);

	status = sendto(EIM_AppData.NavSocketID, cBuf, len, 0,
				(struct sockaddr *) &si_tmp, sizeof(si_tmp) );
	if ( status < 0 )
	{
		CFE_EVS_SendEvent(EIM_TELEM_TASK_ERR_EID, CFE_EVS_ERROR, "EIM: Failed to send NAVDATA reset.  errno: %d", errno);
		CFE_ES_ExitChildTask();
	}
	else
	{
		OS_printf("EIM: Reset message sent.\n");
	}
}
Пример #8
0
/******************************************************************************
** Function: LABTLM_Main
**
*/
void LABTLM_Main(void)
{

   int32  Status    = CFE_SEVERITY_ERROR;
   uint32 RunStatus = CFE_ES_APP_ERROR;


   Status = CFE_ES_RegisterApp();
   CFE_EVS_Register(NULL,0,0);

   /*
   ** Perform application specific initialization
   */
   if (Status == CFE_SUCCESS)
   {
       OS_printf("TO-LAB: About to call init\n");
       Status = InitApp();
   }

   /*
   ** At this point many flight apps use CFE_ES_WaitForStartupSync() to
   ** synchronize their startup timing with other apps. This is not
   ** needed.
   */

   if (Status == CFE_SUCCESS) RunStatus = CFE_ES_APP_RUN;

   /*
   ** Main process loop
   */
   OS_printf("TO-LAB: About to enter loop\n");
   while (CFE_ES_RunLoop(&RunStatus))
   {

      OS_TaskDelay(LABTLM_RUNLOOP_DELAY);

      PKTMGR_OutputTelemetry();

      ProcessCommands();

   } /* End CFE_ES_RunLoop */


   /* Write to system log in case events not working */

   CFE_ES_WriteToSysLog("LABTLM App terminating, err = 0x%08X\n", Status);

   CFE_EVS_SendEvent(LABTLM_EXIT_ERR_EID, CFE_EVS_CRITICAL, "LABTLM App: terminating, err = 0x%08X", Status);

   CFE_ES_ExitApp(RunStatus);  /* Let cFE kill the task (and any child tasks) */

} /* End of LABTLM_Main() */
Пример #9
0
void OS_Application_Startup(void)
{
   uint32             status;

   OS_API_Init();

   OS_printf("OS Application Startup\n");

   status = OS_QueueCreate( &msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Message Queue\n");
   }

   /*
   ** Create a timer
   */
   status = OS_TimerCreate(&timer_id, "Timer 1", &timer_accuracy, &(TimerFunction));
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating OS Timer\n");
   }
   else
   {
      OS_printf("Timer ID = %d\n", (int)timer_id);
      OS_printf("Timer Accuracy = %d microseconds \n",(int)timer_accuracy);
   }

   /*
   ** Create the "consumer" task.
   */
   status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 1\n");
   }
   else
   {
      OS_printf("Created Task 1\n");
   }

   /*
   ** Start the timer
   */
   status  =  OS_TimerSet(timer_id, timer_start, timer_interval);
   if ( status != OS_SUCCESS )
   {
       OS_printf("Error calling OS_TimerSet: ID = %d\n", (int)timer_id);
   }
   else
   {
       OS_printf("Timer programmed\n");
   }

}
Пример #10
0
/******************************************************************************
**  Function:  CFE_PSP_SysInit()
**
**  Purpose:
**    Initializes core PSP functionality.  This is called by both the primary
**      CFE_PSP_Main startup, as well as the alternative initialization in the
**      Startup Manager (SM) component.  The SM uses the PSP and OSAL but does
**      not start cFE or initialize all components of the PSP.  
**
**  Arguments:
**    psp_reset_type - output
**    psp_reset_subtype - output
**    last_bsp_reset_type  - input - TBD - do we need to keep this?
**
**  Return:
**    (none)
**
*/
void CFE_PSP_SysInit(uint32* psp_reset_type, uint32* psp_reset_subtype, uint32 last_bsp_reset_type)
{
   int TicksPerSecond = 0;
   uint32 mcfg2 = 0;

   /* 
   ** Delay for one second. 
   */
   TicksPerSecond = sysClkRateGet();
   (void) taskDelay( TicksPerSecond );


   /* This register should be initialized by the Kernel or Bootloader.  It's value
   **  is verified here to ensure correct operation of the system.  This section may
   **  be tweaked as necessary for project requirements if not set directly in the
   **  bootloader.
   ** Rick - Need to verify this solves the memory access exceptions.  SPARC is 
   **        very touchy about this, more so than PPC or coldfire.
   **        
   ** Brute force...  Make sure the read-modify-write bit is set in mcfg2 register
   ** The bit is 0x00000040 in mcfg2 reg, and should probably always be set.  If there
   ** is a performance hit, that's still better than random crashes.
   */
   mcfg2 = *(uint32*)0x80000004;
   
   if(!(mcfg2 & 0x00000040))
   {
      /*
      ** Set the rmw bit now and print something saying you did so...
      */
      
      mcfg2 = *(uint32*)0x80000004 = mcfg2 | 0x00000040;
      
      OS_printf("\nNOTE: Set the rmw bit MCFG2 reg. Current value = %08X\n\n", mcfg2);
   }
   else
   {
      OS_printf("\nNOTE: The rmw bit in MCFG2 reg is already set. Current value = %08X\n\n", mcfg2);
   }

   /* Assign the reset cause */
   /* for now always start up in a power on reset */
   *psp_reset_type    = CFE_ES_POWERON_RESET;
   *psp_reset_subtype = CFE_ES_POWER_CYCLE;

   ResetType = *psp_reset_type;
   ResetSubtype = *psp_reset_subtype;

}
Пример #11
0
/******************************************************************************
**  Function:  CFE_PSP_Init1HzTimer()
**
**  Purpose: Initializes the 1Hz Timer and connects it to the cFE TIME 1Hz routine
**
**
**  NOTE: This function has to be called after CFE_ES_Main() in CFE_PSP_Start()
**  because the 1Hz ISR has a semaphore that is created in CFE_ES_Main().
**
**  Arguments: none
******************************************************************************/
void CFE_PSP_Init1HzTimer(void)
{
    /*
    ** Attach a handler to the timer interrupt
    */

	/* Either the Aux clock */
    if(sysAuxClkConnect((FUNCPTR)CFE_PSP_AuxClkHandler,
                         CFE_PSP_TIMER_AUX_TICK_PER_SEC) == ERROR)
    {
       printf("CFE_PSP: Unable to connect handler to Aux Clock!\n");
    }

    /*
    ** Enable the Aux timer interrupt
    ** Enable the Timestamp timer, which also sets it to zero
    */
    sysAuxClkEnable();

    if(sysTimestampEnable() == ERROR)
    {
       OS_printf("CFE_PSP: Unable to enable the Timestamp timer!\n");
    }

    g_bTimerInitialized = TRUE;

}/* end CFE_PSP_Init1HzTimer */
Пример #12
0
void CFE_PSP_SigintHandler (int arg)
{
      OS_printf("\nCFE_PSP: Control-C Captured - Exiting cFE\n");
      CFE_PSP_DeleteProcessorReservedMemory();
      CFE_PSP_DeleteOSResources();
      exit(0);
}
Пример #13
0
void OS_BSPMain( void )
{
   int    TicksPerSecond;
   
   /*
   ** Initialize the OS API
   */
   OS_API_Init();

   /* 
   ** Delay for one second. 
   */
   TicksPerSecond = sysClkRateGet();
   (void) taskDelay( TicksPerSecond );

   OS_printf("Starting Up OSAPI App.\n");
   
   /*
   ** Call OSAL entry point.    
   */
   OS_Application_Startup();

   /*
   ** Exit the main thread.
   ** in VxWorks we can delete all of the OS tasks if we want.
   */

}
Пример #14
0
/*
** TO delete callback function.
** This function will be called in the event that the TO app is killed. 
** It will close the network socket for TO
*/
void TO_delete_callback(void)
{
    OS_printf("TO delete callback -- Closing TO Network socket.\n");
    if ( downlink_on == TRUE )
    {
        close(TLMsockid);
    }
}
Пример #15
0
void task_2(void)
{
    uint32 status;

    OS_printf("Starting task 2\n");

    OS_TaskRegister();

    while(1)
    {
        status = OS_MutSemTake(mutex_id);
        if ( status != OS_SUCCESS )
        {
           OS_printf("TASK 2:Error calling OS_MutSemTake\n");
        }

        shared_resource_x = task_2_id;

        status = OS_QueuePut(msgq_id, (void*)&shared_resource_x, sizeof(uint32), 0);
        if ( status != OS_SUCCESS )
        {
           OS_printf("TASK 2:Error calling OS_QueuePut (1)\n");
        }
            
        OS_TaskDelay(150);

        shared_resource_x = task_2_id;

        status = OS_QueuePut(msgq_id, (void*)&shared_resource_x, sizeof(uint32), 0);
        if ( status != OS_SUCCESS )
        {
           OS_printf("TASK 2:Error calling OS_QueuePut (2)\n");
        }

        status = OS_MutSemGive(mutex_id);
        if ( status != OS_SUCCESS )
        {
           OS_printf("TASK 2:Error calling OS_MutSemGive\n");
        }

        OS_TaskDelay(500);
    }  
}
Пример #16
0
/******************************************************************************
**  Function: CFE_PSP_InitUserReservedArea 
**
**  Purpose:
**    This function is used by the ES startup code to initialize the
**      ES user reserved area.
**
**  Arguments:
**    (none)
**
**  Return:
**    (none)
*/
int32 CFE_PSP_InitUserReservedArea(uint32 RestartType )
{
   int32 return_code;
   key_t key;

   /* 
   ** Make the Shared memory key
   */
   if ((key = ftok(CFE_PSP_RESERVED_KEY_FILE, 'R')) == -1) 
   {
        OS_printf("CFE_PSP: Cannot Create User Reserved Area Shared memory key!\n");
        exit(-1);
   }

   /* 
   ** connect to (and possibly create) the segment: 
   */
   if ((UserShmId = shmget(key, CFE_PSP_USER_RESERVED_SIZE, 0644 | IPC_CREAT)) == -1) 
   {
        OS_printf("CFE_PSP: Cannot shmget User Reserved Area Shared memory Segment!\n");
        exit(-1);
   }

   /* 
   ** attach to the segment to get a pointer to it: 
   */
   CFE_PSP_UserReservedAreaPtr = shmat(UserShmId, (void *)0, 0);
   if (CFE_PSP_UserReservedAreaPtr == (uint8 *)(-1)) 
   {
        OS_printf("CFE_PSP: Cannot shmat to User Reserved Area Shared memory Segment!\n");
        exit(-1);
   }

   if ( RestartType == CFE_ES_POWERON_RESET )
   {
      OS_printf("CFE_PSP: Clearing out CFE User Reserved Shared memory segment.\n");
      memset(CFE_PSP_UserReservedAreaPtr, 0, CFE_PSP_USER_RESERVED_SIZE);
   }
   
   return_code = CFE_PSP_SUCCESS;
   return(return_code);

}
Пример #17
0
void CFE_PSP_AttachExceptions(void)
{
   /*
   ** Always attach exception hook
   */
   excHookAdd((FUNCPTR)CFE_PSP_ExceptionHook);

   OS_printf("BSP: Attached cFE Exception Handler. Context Size = %d bytes.\n",
    CFE_PSP_CPU_CONTEXT_SIZE);
}
Пример #18
0
/******************************************************************************
**  Function:  OS_TimerSet
**
**  Purpose:  
**
**  Arguments:
**    (none)
**
**  Return:
**    (none)
*/
int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time)
{
   rtems_interval    timeout;
   rtems_status_code status;
   
   /* 
   ** Check to see if the timer_id given is valid 
   */
   if (timer_id >= OS_MAX_TIMERS || OS_timer_table[timer_id].free == TRUE)
   {
      return OS_ERR_INVALID_ID;
   }

   /*
   ** Round up the accuracy of the start time and interval times.
   ** Still want to preserve zero, since that has a special meaning. 
   */
   if (( start_time > 0 ) && (start_time < os_clock_accuracy))
   {
      start_time = os_clock_accuracy;
   }
 
   if ((interval_time > 0) && (interval_time < os_clock_accuracy ))
   {
      interval_time = os_clock_accuracy;
   }

   /*
   ** Save the start and interval times 
   */
   OS_timer_table[timer_id].start_time = start_time;
   OS_timer_table[timer_id].interval_time = interval_time;

   /*
   ** The defined behavior is to not arm the timer if the start time is zero
   ** If the interval time is zero, then the timer will not be re-armed.
   */
   if ( start_time > 0 )
   {
      /*
      ** Convert from Microseconds to the timeout
      */
      OS_UsecsToTicks(start_time, &timeout);

      status = rtems_timer_fire_after(OS_timer_table[timer_id].host_timerid, 
                                        timeout, 
                                        OS_TimerSignalHandler, (void *)timer_id );
      if ( status != RTEMS_SUCCESSFUL )
      {
         OS_printf("BSP: Error: Cannot setup interval timer to fire.\n");
         return ( OS_TIMER_ERR_INTERNAL);
      }
   }
   return OS_SUCCESS;
}
Пример #19
0
/******************************************************************************
**  Function:  CFE_PSP_WatchdogEnable()
**
**  Purpose:
**    Enable the watchdog timer
**
**  Arguments:
**
**  Return:
*/
void CFE_PSP_WatchdogEnable(void)
{
   unsigned long reg = *(unsigned long *)TIMER4_CONTROL;
   
         OS_printf("WatchdogEna Tmr: %08X\n", CFE_PSP_WatchdogGet());
         OS_printf("WatchdogEna Lod: %08X\n", *(unsigned long *)(0x80000344));
         OS_printf("WatchdogEna ctl: %08X\n", *(unsigned long *)(0x80000348));
   
   /*
   ** Enable the timer is logic zero
   */
   
   reg &= ~TIMER4_CONTROL_IP;   /* clear an interrupt pending */
   
   reg |= TIMER4_CONTROL_IE;    /* Enable interrupt */
   
   reg |= TIMER4_CONTROL_EN;    /* Enable timer */
   
   *(unsigned long *)TIMER4_CONTROL = reg;

         OS_printf("WatchdogEna Tmr: %08X\n", CFE_PSP_WatchdogGet());
         OS_printf("WatchdogEna Lod: %08X\n", *(unsigned long *)(0x80000344));
         OS_printf("WatchdogEna ctl: %08X\n", *(unsigned long *)(0x80000348));
   
   return;
}
Пример #20
0
void CFE_PSP_InitLocalTime(void)
{
	/* Set the sys clock rate */
	sysClkRateSet(200);

   /*
   ** Disable the Aux timer interrupt, and disable the Timestamp timer
   */
   sysAuxClkDisable();

   if(sysTimestampDisable() == ERROR)
   {
      OS_printf("CFE_PSP: Unable to disable the Timestamp timer!\n");
   }

   /*
   ** Set the Aux timer
   */
   if(sysAuxClkRateGet() != CFE_PSP_TIMER_AUX_TICK_PER_SEC)
   {
      if(sysAuxClkRateSet(CFE_PSP_TIMER_AUX_TICK_PER_SEC) == ERROR)
      {
         OS_printf("CFE_PSP: Unable to set Aux Clock Rate!\n");
      }


      if(CFE_PSP_TIMER_PRINT_DBG == TRUE)
      {
         OS_printf("CFE_PSP: Aux Clock Rate %d.\n", sysAuxClkRateGet());

         OS_printf("CFE_PSP: Timestamp Frequency %u.\n", sysTimestampFreq());

         OS_printf("CFE_PSP: Timestamp Period %u.\n", sysTimestampPeriod());
      }
   }


}/* end CFE_PSP_InitLocalTime */
Пример #21
0
void TO_ForwardTelemetry(uint32 PrioMask)
{
    int32   cfeStatus;
    uint32	msgSize;
    uint32	Surplus = 0;
    uint32 	i=0;

    for(i=0; i < TO_MAX_TLM_CLASS_QUEUES; i++)
    {
    	TO_TlmClassQueue_t *clsQueue = &TO_AppData.Config->ClassQueue[i];

    	uint32 budget = clsQueue->Quantum + clsQueue->Deficit + Surplus;
    	while(1)
    	{
    		if(TO_AppData.Config->ClassQueue[i].PktPtr == 0)
    		{
				cfeStatus = CFE_SB_RcvMsg(&TO_AppData.Config->ClassQueue[i].PktPtr, clsQueue->PipeId, CFE_SB_POLL);
				if((cfeStatus != CFE_SUCCESS))
				{
					clsQueue->Deficit = 0;
					Surplus = budget;
					break;
				}
    		}

    		if(i == 3)
    		{
    			OS_printf("Video telemetry out.");
    		}

    		msgSize = CFE_SB_GetTotalMsgLength(TO_AppData.Config->ClassQueue[i].PktPtr);
			if(msgSize <= budget)
			{
				TO_SendToChannel(TO_AppData.Config->ClassQueue[i].ChannelIdx,
						TO_AppData.Config->ClassQueue[i].PktPtr,
						msgSize);

				TO_AppData.Config->ClassQueue[i].PktPtr = 0;
				budget -= msgSize;
			}
			else
			{
				clsQueue->DeferredCount++;
				clsQueue->Deficit = budget - Surplus;
				Surplus = budget;
				break;
			}
		}
   	}
}
Пример #22
0
void task_3(void)
{
    uint32             status;

    OS_printf("Starting task 3\n");
    OS_TaskRegister();

    while(1)
    {
       OS_TaskDelay(1000);

       OS_printf("TASK 3: Waiting on the semaphore\n");
       status = OS_CountSemTake(count_sem_id);
       if ( status != OS_SUCCESS )
       {
          OS_printf("TASK 3: Error calling OS_CountSemTake\n");
       }
       else
       {
          OS_printf("TASK 3: grabbed Counting Sem\n");
       }
    }
}
Пример #23
0
void CFE_PSP_Panic(int32 ErrorCode)
{

   OS_printf("\nWarning: CFE PSP Panic with error code %d!  A restart will occur!\n\n", ErrorCode);

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

   taskDelay(100);

   /*
   ** Debug Switch is not set, do a processor Reset
   */
   CFE_PSP_Restart(CFE_ES_PROCESSOR_RESET);
}
Пример #24
0
/******************************************************************************
**  Function: CFE_PSP_InitProcessorReservedMemory
**
**  Purpose:
**    This function performs the top level reserved memory initialization.
**
**  Arguments:
**    (none)
**
**  Return:
**    (none)
*/
int32 CFE_PSP_InitProcessorReservedMemory( uint32 RestartType )
{
   int32 return_code;

   if ( RestartType != CFE_ES_PROCESSOR_RESET )
   {
      OS_printf("CFE_PSP: Clearing Processor Reserved Memory.\n");
      memset((void *)CFE_PSP_ReservedMemoryPtr, 0, sizeof(CFE_PSP_ReservedMemory_t));

      /*
      ** Set the default reset type in case a watchdog reset occurs
      */
      CFE_PSP_ReservedMemoryPtr->bsp_reset_type = CFE_ES_PROCESSOR_RESET;

   }
   return_code = CFE_PSP_SUCCESS;
   return(return_code);

}
Пример #25
0
void CFE_PSP_Restart(uint32 reset_type)
{

   if ( reset_type == CFE_ES_POWERON_RESET )
   {
      CFE_PSP_ReservedMemoryPtr->bsp_reset_type = CFE_ES_POWERON_RESET;
      CFE_PSP_FlushCaches(1, (uint32 )CFE_PSP_ReservedMemoryPtr, sizeof(CFE_PSP_ReservedMemory_t));
      /* reboot(BOOT_CLEAR); Need RTEMS equiv. */
   }
   else
   {
      CFE_PSP_ReservedMemoryPtr->bsp_reset_type = CFE_ES_PROCESSOR_RESET;
      CFE_PSP_FlushCaches(1, (uint32 )CFE_PSP_ReservedMemoryPtr, sizeof(CFE_PSP_ReservedMemory_t));
      /* reboot(BOOT_NORMAL); Need RTEMS Equiv */
   }

   OS_printf("CFE_PSP_Restart is not implemented on this platform ( yet ! )\n");
   exit(-1);

}
Пример #26
0
void task_1(void)
{
    uint32             status;
    OS_bin_sem_prop_t  bin_sem_prop;
    int                printf_counter = 0;

    OS_printf("Starting task 1\n");

    OS_TaskRegister();

    OS_printf("Delay for 1 second before starting\n");
    OS_TaskDelay(1000);

    while(1)
    {

        status = OS_BinSemTake(bin_sem_id);
        if ( status != OS_SUCCESS )
        {
           OS_printf("TASK 1:Error calling OS_BinSemTake\n");
           exit(-1);
        }
        else
        {
           printf_counter++;
           counter++;
          
           if ( printf_counter > 100 ) 
           {
              OS_printf("TASK 1: counter:%d timer_counter:%d\n", (int)counter,(int)timer_counter);
              printf_counter = 0;
           }
           status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
           if ( bin_sem_prop.value > 1 )
           {
                OS_printf("Error: Binary sem value > 1 ( in task):%d !\n",(int)bin_sem_prop.value);
                exit(-1);
           }
           else if ( bin_sem_prop.value < -1 )
           {
                OS_printf("Error: Binary sem value < -1 ( in task):%d !\n",(int)bin_sem_prop.value);
                exit(-1);
           }
        }

    }
}
Пример #27
0
void CI_TaskMain( void )
{
    int32   status;
    uint32  RunStatus = CFE_ES_APP_RUN;

    CFE_ES_PerfLogEntry(CI_MAIN_TASK_PERF_ID);

    CI_TaskInit();

#ifdef _CI_DELAY_TEST
    OS_printf("CI going to delay for 40 seconds before calling runloop\n");
    OS_TaskDelay(40000);
#endif

    /*
    ** CI Runloop
    */
    while (CFE_ES_RunLoop(&RunStatus) == TRUE)
    {
        CFE_ES_PerfLogExit(CI_MAIN_TASK_PERF_ID);

        /* Pend on receipt of command packet -- timeout set to 500 millisecs */
        status = CFE_SB_RcvMsg(&CIMsgPtr, CI_CommandPipe, 500);
        CFE_ES_PerfLogEntry(CI_MAIN_TASK_PERF_ID);

        if (status == CFE_SUCCESS)
        {
            CI_ProcessCommandPacket();
        }

        /* Regardless of packet vs timeout, always process uplink queue      */
        if (CI_SocketConnected)
        {
            CI_ReadUpLink();
        }
    }
    CFE_ES_ExitApp(RunStatus);

} /* End of CI_TaskMain() */
Пример #28
0
void OS_Application_Startup(void)
{
  uint32 status;
  OS_printf("********If You see this, we got into OS_Application_Startup****\n");

  status = OS_QueueCreate( &msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0);
  if ( status != OS_SUCCESS )
  {
     OS_printf("Error creating Message Queue\n");
  }

  status = OS_MutSemCreate( &mutex_id, "Mutex", 0);
  if ( status != OS_SUCCESS )
  {
     OS_printf("Error creating mutex\n");
  }
  else
  {
     OS_printf("MutexSem ID = %d\n",mutex_id);
  }

  status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0);
  if ( status != OS_SUCCESS )
  {
     OS_printf("Error creating Task 1\n");
  }

  status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_2_STACK_SIZE, TASK_2_PRIORITY, 0);
  if ( status != OS_SUCCESS )
  {
     OS_printf("Error creating Task 2\n");
  }

  status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_3_STACK_SIZE, TASK_3_PRIORITY, 0);
  if ( status != OS_SUCCESS )
  {
     OS_printf("Error creating Task 3\n");
  }


}
Пример #29
0
void task_1(void)
{
    uint32             status;

    OS_printf("Starting task 1\n");
    OS_TaskRegister();

    while(1)
    {
       OS_TaskDelay(2000);

       OS_printf("TASK 1: Giving the counting semaphore 1\n");
       status = OS_CountSemGive(count_sem_id);
       if ( status != OS_SUCCESS )
       {
          OS_printf("TASK 1: Error calling OS_CountSemGive 1\n");
       }
       else
       {
          OS_printf("TASK 1: Counting Sem Give 1 complete\n");
       }

       OS_TaskDelay(500);

       OS_printf("TASK 1: Giving the counting semaphore 2\n");
       status = OS_CountSemGive(count_sem_id);
       if ( status != OS_SUCCESS )
       {
          OS_printf("TASK 1: Error calling OS_CountSemGive 2\n");
       }
       else
       {
          OS_printf("TASK 1: Counting Sem Give 2 complete\n");
       }

    }
}
Пример #30
0
/******************************************************************************
**  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);
      }
   }
}