Beispiel #1
0
void
Init_System( NU_MEMORY_POOL  *Memory_Pool)
{
        VOID *Stack_Pointer;
        STATUS sts;

        if ( NU_Create_Event_Group(&Buffers_Available, "BUFAVA") != NU_SUCCESS) {
                printf("Error Creating the Event Group\n\r");
                return;
        }

    /* Create Test_Task 0 */
    NU_Allocate_Memory(Memory_Pool, &Stack_Pointer, 50000, NU_NO_SUSPEND);
    NU_Create_Task(&Test_Task0, "Test0", test_0, 0, NU_NULL, 
                                        Stack_Pointer, 10000, 3, 20, NU_PREEMPT, NU_START);
    /* Create Test_Task 1 */
    NU_Allocate_Memory(Memory_Pool, &Stack_Pointer, 50000, NU_NO_SUSPEND);
    NU_Create_Task(&Test_Task1, "Test1", test_1, 0, NU_NULL, 
                                        Stack_Pointer, 10000, 3, 20, NU_PREEMPT, NU_START);

    /* Create Test_Task 2 */
    NU_Allocate_Memory(Memory_Pool, &Stack_Pointer, 50000, NU_NO_SUSPEND);
    NU_Create_Task(&Test_Task2, "Test2", test_2, 0, NU_NULL, 
                                        Stack_Pointer, 10000, 3, 20, NU_PREEMPT, NU_START);
    /* Create Test_Task 3 */
    NU_Allocate_Memory(Memory_Pool, &Stack_Pointer, 50000, NU_NO_SUSPEND);
    NU_Create_Task(&Test_Task3, "Test3", test_3, 0, NU_NULL, 
                                        Stack_Pointer, 10000, 3, 20, NU_PREEMPT, NU_START);
}
Beispiel #2
0
void
Init_System( NU_MEMORY_POOL  *Memory_Pool)
{
	VOID *Stack_Pointer;
	STATUS sts;

    /* Create IOPMaster_Task */
    NU_Allocate_Memory(Memory_Pool, &Stack_Pointer, 10000, NU_NO_SUSPEND);
    NU_Create_Task(&Test_Task0, "Test0", test_0, 0, NU_NULL, 
					Stack_Pointer, 10000, 3, 20, NU_PREEMPT, NU_START);
    NU_Allocate_Memory(Memory_Pool, &Stack_Pointer, 10000, NU_NO_SUSPEND);
    NU_Create_Task(&Test_Task1, "Test1", test_1, 0, NU_NULL, 
					Stack_Pointer, 10000, 3, 20, NU_PREEMPT, NU_START);
}
Beispiel #3
0
int __gc_init()
{
    static char gc_tsk_stack[GC_TASK_STACK_SIZE];
    int a = NU_Create_Task(&gc_tsk, GC_TASK_NAME, gc_thread, 0, 0, 
			   gc_tsk_stack, GC_TASK_STACK_SIZE, GC_TASK_PRIO, 
			   0, NU_PREEMPT, NU_NO_START);
    
    __disable_interrupt();
    __swihook_setfunc(SWINUM_GC, (unsigned int)&__gc_cleanup);
    __enable_interrupt();
    
    memset(&gc_queue, 0, sizeof(gc_queue));
    return a;
}
Beispiel #4
0
void    Application_Initialize(void *first_available_memory)
{
    VOID    *pointer;

    /* Create a system memory pool that will be used to allocate task stacks,
       queue areas, etc.  */
#ifdef  INCLUDE_ODYSSEY
    NU_Create_Memory_Pool(&System_Memory, "SYSMEM", 
                        first_available_memory, 100000000, 56, NU_FIFO);
#else
    NU_Create_Memory_Pool(&System_Memory, "SYSMEM", 
                        first_available_memory, 2000000, 56, NU_FIFO);
#endif
                        
    /* Create IOPMaster_Task */
    NU_Allocate_Memory(&System_Memory, &pointer, 10000, NU_NO_SUSPEND);
    NU_Create_Task(&IOPMaster_Task, "IOPMaster", IOPMaster, 0, NU_NULL, 
                                        pointer, 10000, 1, 20, NU_PREEMPT, NU_START);

}
/*****************************************************************************
 Function   : VOS_CreateTask
 Description: create task with default task mode:
              VOS_T_PREEMPT | VOS_T_NO_TSLICE | VOS_T_SUPV
 Input      : puchName              -- name identify task
              pfnFunc               -- task entry function
              ulPriority            -- task priority
              ulStackSize           -- task stack size
              aulArgs[VOS_TARG_NUM] -- arguments for task
 Output     : pulTaskID             -- task id allocated by dopra
 Return     : result of VOS_CreateTaskEx
 *****************************************************************************/
VOS_UINT32 VOS_CreateTask( VOS_CHAR * puchName,
                           VOS_UINT32 * pulTaskID,
                           VOS_TASK_ENTRY_TYPE pfnFunc,
                           VOS_UINT32 ulPriority,
                           VOS_UINT32 ulStackSize,
                           VOS_UINT32 aulArgs[VOS_TARG_NUM] )
{
    int             i;
    VOS_UINT32      iTid;
    VOS_CHAR        default_name[8];
    VOS_UCHAR       value;
    VOS_VOID        *pStackStartAddress;

    iTid = VOS_TaskCtrlBlkGet();
    if( iTid == (VOS_UINT32)VOS_TASK_CTRL_BLK_NULL )
    {
        VOS_SetErrorNo(VOS_ERRNO_TASK_CREATE_NOFREETCB);
        return( VOS_ERRNO_TASK_CREATE_NOFREETCB );
    }

    /* caller not use name asign a default name */
    if ( VOS_NULL_PTR == puchName )
    {
        default_name[0]= 't';
        default_name[1]= 'i';
        default_name[2]= 'd';
        default_name[3] = (VOS_CHAR)(48 + iTid/100);
        value = (VOS_UCHAR)(iTid%100);
        default_name[4] = (VOS_CHAR)(48 + value/10);
        default_name[5] = (VOS_CHAR)(48 + value%10);
        default_name[6]= '\0';

        /*lint -e534*/
        VOS_MemCpy(vos_TaskCtrlBlk[iTid].Name, default_name, 7);
        /*lint +e534*/
    }
    else
    {
        for(i=0; i<VOS_MAX_LENGTH_TASK_NAME; i++)
        {
            vos_TaskCtrlBlk[iTid].Name[i]= puchName[i];
        }
        vos_TaskCtrlBlk[iTid].Name[i-1]  = '\0';
    }

    pStackStartAddress = NU_StackMalloc(ulStackSize);
    if ( VOS_NULL_PTR == pStackStartAddress )
    {
        VOS_TaskCtrlBlkFree(iTid);
        VOS_SetErrorNo(VOS_ERRNO_TASK_CREATE_OSALCREATEFAIL);
        return( VOS_ERRNO_TASK_CREATE_OSALCREATEFAIL );
    }

    vos_TaskCtrlBlk[iTid].Function   = pfnFunc;
    vos_TaskCtrlBlk[iTid].Priority   = ulPriority;
    vos_TaskCtrlBlk[iTid].StackSize  = ulStackSize;

    for ( i=0; i<VOS_TARG_NUM; i++ )
    {
        vos_TaskCtrlBlk[iTid].Args[i]    = aulArgs[i];
    }

    if ( NU_SUCCESS
        != NU_Create_Task(&(vos_TaskCtrlBlk[iTid].NuTid), vos_TaskCtrlBlk[iTid].Name,
            VOS_NucleusTaskEntry, (VOS_UINT32)(&(vos_TaskCtrlBlk[iTid])),
            VOS_NULL_PTR, pStackStartAddress, ulStackSize, ulPriority, 0,
            NU_PREEMPT, NU_START) )
    {
        NU_StackFree(pStackStartAddress);
        VOS_TaskCtrlBlkFree(iTid);
        VOS_SetErrorNo(VOS_ERRNO_TASK_CREATE_OSALCREATEFAIL);
        return( VOS_ERRNO_TASK_CREATE_OSALCREATEFAIL );
    }

    *pulTaskID = iTid;

    return VOS_OK;
}
Beispiel #6
0
void    Initialize()
{
    VOID    *pointer;
    
    // Create a semaphore so that this task will not finish.
	NU_SEMAPHORE		m_wait_forever_semaphore;
	STATUS status = NU_Create_Semaphore(&m_wait_forever_semaphore, "ReadySem",
		0, // initial count
		NU_FIFO);
	if (status != OK)
	{
		CT_Log_Error(CT_ERROR_TYPE_FATAL,
			"Initialize_SSD", 
			"NU_Create_Semaphore failed",
			status,
			0);
	}

    // Turn on tracing.
    //TraceLevel[TRACE_SSD] = TRACE_ALL_LVL;
   
	char *p_next_available_memory = new (tBIG) char[TEST_PROGRAM_MEMORY_SIZE];
	
    /* Create a system memory pool that will be used to allocate task stacks,
       queue areas, etc.  */
    status = NU_Create_Memory_Pool(&system_memory, "SYSMEM", 
	    p_next_available_memory, 
	    TEST_PROGRAM_MEMORY_SIZE, // # bytes in the pool
	    56, // min # bytes in each allocation,
	    NU_FIFO);
                        
	if (status != OK)
	{
		CT_Log_Error(CT_ERROR_TYPE_FATAL,
			"Initialize_SSD_Test", 
			"NU_Create_Memory_Pool failed",
			status,
			0);
	}

    /* Allocate stack space for task.  */
    status = NU_Allocate_Memory(&system_memory, &pointer, THREAD_STACK_SIZE, NU_NO_SUSPEND);
	if (status != OK)
	{
		CT_Log_Error(CT_ERROR_TYPE_FATAL,
			"Initialize_SSD_Test", 
			"Allocate stack space failed",
			status,
			0);
	}
    
    /* Create task  */
    status = NU_Create_Task(&Task_0, "TASK 0", Initialize_Test, 
    	0, NU_NULL, pointer,
                   THREAD_STACK_SIZE, 1, 20, NU_PREEMPT, NU_START);
	if (status != OK)
	{
		CT_Log_Error(CT_ERROR_TYPE_FATAL,
			"Initialize_SSD_Test", 
			"NU_Create_Task failed",
			status,
			0);
	}

	// Turn on tracing.
	//TraceLevel[TRACE_SSD] = 8;
	
	// Don't let this task finish!
	status = NU_Obtain_Semaphore(
		&m_wait_forever_semaphore,
		NU_SUSPEND);
	// Should never continue!
	//if (status != OK)
	{
		CT_Log_Error(CT_ERROR_TYPE_FATAL,
			"Initialize", 
			"ANU_Obtain_Semaphore failed",
			status,
			0);
	}
	
} // Initialize