Beispiel #1
0
/* Available in: irq. */
void __tt_schedule (void)
{
	unsigned int	priority;
	
#ifdef	TT_SUPPORT_STACK_CHECK
	/* Check if thread stack is healty */
	tt_check_stack(g_thread_current);
#endif	// TT_SUPPORT_STACK_CHECK

	__tt_wakeup ();
	
	for (priority = g_athread_high_priorty;
		priority < TT_THREAD_PRIORITY_NUM;
		g_athread_high_priorty = ++priority)
	{
		if (listGetNext (&g_athread_running[priority]) != &g_athread_running[priority])
		{
			/* Run next thread. */
			LIST_T *next = listGetNext (&g_athread_running[priority]);
			g_thread_next = GetParentAddr (next, TT_THREAD_T, list_schedule);
			goto end;
		}
	}
	
	/* Run to here means no thread is running! */
	g_thread_next = NULL;
	//g_thread_next = (TT_THREAD_T *) TCB_AT(g_thread_nop_buffer, sizeof (g_thread_nop_buffer));
	//sysSafePrintf ("current: (%08x) %s\n", 	g_thread_current, g_thread_current->name);
	//sysSafePrintf ("%08x %08x %08x\n", g_thread_current->uPC, g_thread_current->uLR, g_thread_current->uSP);

end:
	if (g_thread_current != g_thread_next)
		SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;
}
Beispiel #2
0
void thread_write_audio(cyg_addrword_t data)
{
	VP_BUFFER_TEST_AUDIO_BITSTREAM_T *ptestaudio;
	IO_THREAD_READ_T readarg;
	
	while(1)
	{
		cyg_semaphore_wait(&g_testaudio.pcAudio.consumer);
		if (!listIsEmpty (&g_testaudio.listAudio))
		{
			ptestaudio = GetParentAddr (g_testaudio.listAudio.pNext, VP_BUFFER_TEST_AUDIO_BITSTREAM_T, list);
			listDetach(&ptestaudio->list);
		}
		else
		{
			diag_printf("No auido data???\n");
			while(1);
		}
		
		readarg.txbuf = ptestaudio->aucAudio;
		readarg.txlen = ptestaudio->iAudioLen;
		readarg.mediatype = MEDIA_TYPE_AUDIO;
		iothread_Write(&readarg);
		
		bufTestAudioDecRef(ptestaudio);
		cyg_semaphore_post(&g_testaudio.pcAudio.producer);
	}
	cyg_thread_exit();
}
Beispiel #3
0
void tt_dump_threads (void (*func_dump) (TT_THREAD_T *thread, void *arg), void *arg)
{
	LIST_T *list;
	tt_disable_irq ();
	
	for (list = listGetNext (&g_all_threads); list != &g_all_threads; list = listGetNext (list))
	{
		TT_THREAD_T *thread = GetParentAddr (list, TT_THREAD_T, list_threads);
		(*func_dump) (thread, arg);
	}
	
	tt_enable_irq ();
}
Beispiel #4
0
/*
   Return:
	NULL, failed
	other, the message pushed.
 */
static TT_BMSG_T *tt_bmsg_push (TT_BMSG_QUEUE_T *msg_queue, void *msg_data)
{
	LIST_T *msg_node = memNew (msg_queue->queue.msg_buffer);
	if (msg_node == NULL)
		return NULL;
	else
	{
		TT_BMSG_T *msg	= GetParentAddr (msg_node, TT_BMSG_T, list);
		memcpy(&msg->msg_data[0], msg_data, msg_queue->each_msg_size);
		listAttach (&msg_queue->queue.msg_used, &msg->list);
		return msg;
	}
}
Beispiel #5
0
/*
   Return:
	NULL, failed
	other, the message pushed.
 */
static TT_MSG_T *tt_msg_push (TT_MSG_QUEUE_T *msg_queue, FUN_TT_MSG_PROC msg_proc, void *msg_data)
{
	LIST_T *msg_node = memNew (msg_queue->msg_buffer);
	if (msg_node == NULL)
		return NULL;
	else
	{
		TT_MSG_T *msg	= GetParentAddr (msg_node, TT_MSG_T, list);
		msg->msg_proc	= msg_proc;
		msg->msg_data	= msg_data;
		listAttach (&msg_queue->msg_used, &msg->list);
		return msg;
	}
}
Beispiel #6
0
static void __tt_wq_set_event (void *arg)
{
	TT_WQ_T *wait_queue = (TT_WQ_T *)arg;
	
	while (!listIsEmpty (&wait_queue->list))
	{
		LIST_T *list = listGetNext (&wait_queue->list);
		TT_THREAD_T *thread = GetParentAddr (list, TT_THREAD_T, list_schedule);

		/* Append the thread to running thread */
		tt_set_thread_running (thread);
		
		__tt_schedule_yield (NULL);
	}	
}
Beispiel #7
0
/*
   Return:
	NULL, failed
	other, the message poped.
   Return pointer just indicates if a message was popped. Do not use it for other purpose.
 */
static TT_BMSG_T *tt_bmsg_pop (TT_BMSG_QUEUE_T *msg_queue, void **msg_data)
{
	LIST_T *msg_node = listGetNext (&msg_queue->queue.msg_used);
	if (msg_node == &msg_queue->queue.msg_used)
		return NULL;
	else
	{
		TT_BMSG_T *msg	= GetParentAddr (msg_node, TT_BMSG_T, list);
		listDetach (msg_node);
		
		if (msg_data != NULL)
			*msg_data = msg->msg_data;

		return msg;
	}
}
Beispiel #8
0
VP_BUFFER_JPEG_ENCODER_T *vjpegGetEncBuffer(void)
{
 	VP_BUFFER_JPEG_ENCODER_T *pReturn;
	LIST_T *pNode;
    
	sysDisableIRQ ();
    pNode = g_vpJPEG.listEncodedJPEG.pNext;
 	if (pNode == &g_vpJPEG.listEncodedJPEG)
		pReturn = NULL;
	else
	{
		pReturn = GetParentAddr (pNode, VP_BUFFER_JPEG_ENCODER_T, list);
		sysSafePrintf ("Get buffer: %d\n", &pReturn->list);
	}

	sysEnableIRQ ();
    return pReturn;
}
Beispiel #9
0
/*
   Return:
	NULL, failed
	other, the message poped.
   Return pointer just indicates if a message was popped. Do not use it for other purpose.
 */
static TT_MSG_T *tt_msg_pop (TT_MSG_QUEUE_T *msg_queue, FUN_TT_MSG_PROC *msg_proc, void **msg_data)
{
	LIST_T *msg_node = listGetNext (&msg_queue->msg_used);
	if (msg_node == &msg_queue->msg_used)
		return NULL;
	else
	{
		TT_MSG_T *msg	= GetParentAddr (msg_node, TT_MSG_T, list);
		listDetach (msg_node);
		
		if (msg_proc != NULL)
			*msg_proc = msg->msg_proc;
		if (msg_data != NULL)
			*msg_data = msg->msg_data;
		
		memDel (msg_queue->msg_buffer, msg_node);
		return msg;
	}
}
Beispiel #10
0
/* Available in: irq, thread */
void tt_bmsg_recv_free (TT_BMSG_QUEUE_T *msg_queue, void *msg_data)
{
	TT_BMSG_T *msg	= GetParentAddr (msg_data, TT_BMSG_T, msg_data);
	memDel (msg_queue->queue.msg_buffer, &msg->list);	
}