Ejemplo n.º 1
0
/*****************************************************************************
 * FUNCTION
 *  ies_task_main
 * DESCRIPTION
 *  image viewer daemon task main function & MSG loop
 * PARAMETERS
 *  *task_entry_ptr    [IN]    task entry structure
 * RETURNS
 *  void
 *****************************************************************************/
static void ies_task_main(task_entry_struct *task_entry_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    ilm_struct current_ilm;
    kal_uint32 msg_count;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_set_active_module_id(MOD_IES);

    while(1)
    {
        /* peek and check command */
        msg_count = msg_get_extq_messages();
        while(msg_count > 0)
        {
            msg_receive_extq_for_stack(&current_ilm);
            _ies_task_dispatch_message(&current_ilm);
            destroy_ilm(&current_ilm);

            // consume ext queue eagerly
            msg_count = msg_get_extq_messages();
        }
        
        if(!g_ies_task_context.pJob)
        {
            // At this point, there may be pending jobs.
            _ies_task_job_handle_queue();
            if (!g_ies_task_context.pJob)
            {
                // We still have nothing to do
                if ((LIST_EMPTY(&(g_ies_task_context.normal))) &&
                    (LIST_EMPTY(&(g_ies_task_context.lowest))))
                {
                    msg_receive_extq_for_stack(&current_ilm);
                    _ies_task_dispatch_message(&current_ilm);
                    destroy_ilm(&current_ilm);
                }
            }
        }
        else
        {
            /* after processed all commands,
            perform job iteration if there are active jobs. */
            if(_ies_task_job_handle_start(g_ies_task_context.pJob))
            {
                // job finished
                g_ies_task_context.pJob = NULL;
                _ies_task_job_handle_queue();
            }
        }
    }
}
Ejemplo n.º 2
0
static void uart_core_task_main(task_entry_struct* task_entry_ptr)
{
	ilm_struct current_ilm;
	kal_uint32 rt_event, uart_event=0;
	kal_uint32 count = 0;

	kal_set_active_module_id(MOD_UARTCORE);
	kal_mem_set(&current_ilm, 0, sizeof(ilm_struct));

	while(1)
	{
		//dbg_print("=========>uartcore_task_main\r\n");

		// msg_receive_extq will block, therefore we poll if any message exist first
		while(msg_get_extq_messages() > 0)
		{
			if(msg_receive_extq(&current_ilm) != KAL_TRUE)
			{
				break;
			}

			switch (current_ilm.msg_id)
			{
				default:
					break;
			}

			destroy_ilm(&current_ilm);
		}
			// wait some open uart port first time;
		if(uart_open_event <= 0){
			uart_event = hmu_hifeg_wait(HIF_DRV_EG_UART_IND_EVENT);
		}
		if((HIF_DRV_EG_UART_IND_EVENT & uart_event) || uart_open_event>0){
		// Wait someone notify HMU to wake up HIF.
		rt_event = hmu_hifeg_wait(HIF_DRV_EG_HIF_TICK_EVENT_UART);
		if((HIF_DRV_EG_HIF_TICK_EVENT_UART & rt_event))
		{
			count++;
			if(0 == (count % 1) )
			{
				if(uart_tgpd_head[uart_port1] != uart_tgpd_tail[uart_port1])
					uart_en_q_de_q_with_mutex(uart_port1, UART_TX, UART_DE_Q, NULL, NULL);
			
				if(uart_rgpd_head[uart_port1] != uart_rgpd_tail[uart_port1])
					uart_en_q_de_q_with_mutex(uart_port1, UART_RX, UART_DE_Q, NULL, NULL);
#if defined(__FLAVOR_MULTI_MODE_ROUTER__) || defined(__FLAVOR_SINGLE_MODE_ROUTER__)
	//in Router product. SUART0 is AP  own, so it should not be init here.
#else
				if(uart_tgpd_head[uart_port2] != uart_tgpd_tail[uart_port2])
					uart_en_q_de_q_with_mutex(uart_port2, UART_TX, UART_DE_Q, NULL, NULL);
			
				if(uart_rgpd_head[uart_port2] != uart_rgpd_tail[uart_port2])
					uart_en_q_de_q_with_mutex(uart_port2, UART_RX, UART_DE_Q, NULL, NULL);
#endif
			}
		}
	}
}
}
Ejemplo n.º 3
0
void usbc_cosim_core_task_main(task_entry_struct* task_entry_ptr)
{
    kal_uint8 wait_count = 0;
    ilm_struct current_ilm;
    kal_uint32 rt_event;
    kal_uint16 timer_index;
    module_type dest_mod;
    msg_type msg_id;
    usbc_class_device_esl_connect_parm  *rsp_msg_p;
    usbc_core_t* pUsbCore = usbc_core_get_instance();

    kal_set_active_module_id(MOD_USBCORE);
    kal_mem_set(&current_ilm, 0, sizeof(ilm_struct));

    usbc_esl_printf("Start USBCORE task loop...\n");
    while(1)
    {
        while ( msg_get_extq_messages() > 0 )
        {
            if ( msg_receive_extq(&current_ilm) != KAL_TRUE )
            {
                break;
            }

            switch (current_ilm.msg_id)
            {
                case MSG_ID_TIMER_EXPIRY:
                    timer_index = evshed_get_index(&current_ilm);
                    switch (timer_index)
                    {
                        case USBC_WK_NOTIFY_INDEX:
                            ASSERT(0);
                            evshed_timer_handler(pUsbCore->usbc_es_wk_notify_g);
                            break;

                        default:
                            break;
                    }
                    break;

                default:
                    break;
            }

            destroy_ilm(&current_ilm);
        }

        /* Wait someone notify HMU to wake up HIF. */
        rt_event = hmu_hifeg_wait(HIF_DRV_EG_HIF_TICK_EVENT | HIF_DRV_EG_USBC_IND_EVENT);
        if ((HIF_DRV_EG_HIF_TICK_EVENT & rt_event) &&
            (pUsbCore->state != USBC_USB_STATE_SUSPENDED))
        {
            /* poll HIF queue data */
            usbc_esl_printf("Start HIF USB poll queue...\n");
            usbc_normal_hif_poll_queue();
            usbc_esl_printf("End HIF USB poll queue...\n");
        }
        if ((HIF_DRV_EG_USBC_IND_EVENT & rt_event))
        {
            /* Handle indications */
            usbc_normal_hif_process_indications();
        }

        // wait for IPCORE finishing handling ILMs in ipc_init
        if (wait_count < 1)
        {
            wait_count++;

            if(wait_count == 1)
            {
                usbc_esl_printf("Emulare USB enumeration...\n");
                // Emulate USB plug-in for ESL COSIM
                usbc_cosim_hif_attach();

                usbc_esl_printf("Set USB class to connected state...\n");
                // change USB classes state to transfer data
                rsp_msg_p = (usbc_class_device_esl_connect_parm*)construct_local_para(sizeof(usbc_class_device_esl_connect_parm), TD_RESET);
                ASSERT(rsp_msg_p);
                rsp_msg_p->class_device_id = 0;
                msg_id = MSG_ID_USBCLASS_USBCORE_ESL_ENTER_CONNECTED_STATE_REQ;

                switch ((pUsbCore->class_device[0]).class_type)
                {
#ifdef __USB_MBIM_SUPPORT__
                    case USB_CLASS_MBIM:
                        dest_mod = MOD_MBIM;
                        break;
#endif
#ifdef __USB_ECM_SUPPORT__
                    case USB_CLASS_ECM:
                        dest_mod = MOD_ECM;
                        break;
#endif
#ifdef __USB_RNDIS_SUPPORT__			
                    case USB_CLASS_RNDIS:
                        dest_mod = MOD_RNDIS;
                        break;
#endif			
                    default:
                        // We assume the first class device must be a NIC for ESL CO-SIM
                        ASSERT(0);
                        return;
                        break;
                }

                msg_send6(MOD_USBCORE,  // src module
                          dest_mod,  // dst module
                          0,       // sap id
                          msg_id,
                          (local_para_struct*)rsp_msg_p,
                          0); //msg id
            }
        }
    }
}