1. 程式人生 > >【手記】MTK之TASK創建及使用

【手記】MTK之TASK創建及使用

pre port mes eset urn 配置 *** ram 發送消息

/*************************************************************************
* STRUCT
*  syscomp_info_struct
*
* DESCRIPTION
*  The structure defines component task configuration information
*
* FIELDS
*  comp_name_ptr  -  pointer to component task name
*  comp_qname_ptr -  pointer to component task‘s external queue name
*  comp_priority  -  component task‘s priority
*  comp_stack_size   -  component task‘s stack size
*  comp_ext_qsize -  component task‘s external queue size
*  comp_int_qsize -  component task‘s internal queue size
*  comp_create_func- component entity‘s create function
*
* GLOBALS AFFECTED
*
************************************************************************
*/ typedef struct { kal_char *comp_name_ptr;//<Task名稱 kal_char *comp_qname_ptr;//<外部隊列名稱 kal_uint32 comp_priority;//<Task優先級 kal_uint32 comp_stack_size;//<Task堆棧大小 kal_create_func_ptr comp_create_func;//<創建Task的入口函數,返回kal_bool類型,要求參數為comptask_handler_struct **,定義見下方。
kal_bool comp_internal_ram_stack;//<暫不知道作何用處,一般為KAL_FALSE kal_uint8 comp_ext_qsize;//<外部隊列大小 kal_uint8 comp_int_qsize;//<內部隊列大小 kal_uint8 comp_boot_mode; } comptask_info_struct;

/*************************************************************************
* STRUCT
*  syscomp_info_struct
*
* DESCRIPTION
*  The structure defines component task configuration information
*
* FIELDS
*  comp_entry_func   -  component task‘s entry function
*  comp_cfg_func  -  component task‘s configurantion handler
*  comp_init_func -  component task‘s initialization handler
*  comp_reset_func   -  component task‘s reset handler
*  comp_end_func  -  component task‘s termination handler
*  comp_modmain_func -  component task‘s module main handler
*
* GLOBALS AFFECTED
*
************************************************************************
*/ typedef struct { kal_task_func_ptr comp_entry_func;//<主函數,實現為一個消息循環 task_init_func_ptr comp_init_func;//<初始化函數 task_cfg_func_ptr comp_cfg_func;//<配置函數 task_reset_func_ptr comp_reset_func;//<重置函數 task_end_func_ptr comp_end_func;//<Task結束時調用 } comptask_handler_struct; typedef kal_bool (*kal_create_func_ptr)(comptask_handler_struct **);

const comptask_info_struct sys_comp_config_tbl[RPS_TOTAL_STACK_TASKS] =
{
    #include "hal_task_config.h"
    #include "app_task_config.h"
};

#define task_name(p1)                       {p1, 
#define task_queue_name(p1)                  p1,   
#define task_priority(p1)                    p1,
#define task_stack_size(p1)                  (p1 + TASK_STACK_COMMON_PLUS),
#define null_task_create_entry(p1)          (kal_create_func_ptr)TASK_NO_CREATE_PATTERN,
#define task_create_function(p1)             p1,
#define task_stack_internalRAM(p1)           p1,
#define task_external_queue_size(p1)         p1, 
#define task_internal_queue_size(p1)         p1,
#define task_boot_mode(p1)                   p1},

/*************************Task CFG Begin****************/
/*task_indx_type*/
task_index(INDX_MMI) 
/*module_type and mod_task_g*/
#ifdef WISDOM_MMI
/* under construction !*/
/* under construction !*/
#else
task_module_map(INDX_MMI, MOD_MMI)
#endif
/* MOD_MMI is used by HAL file, please don‘t delete or modify it */

/*task‘s parameters*/
task_name("MMI")
task_queue_name("MMI Q")
task_priority(TASK_PRIORITY_MMI)

#if defined(NEPTUNE_MMI)
#if defined(__LOW_COST_SUPPORT_ULC__)
task_stack_size(3072)
#else /* __LOW_COST_SUPPORT_ULC__ */
task_stack_size(4096)
#endif /* __LOW_COST_SUPPORT_ULC__ */
#else  /* Default value */
#if defined(WISDOM_MMI)
#if defined(OPERA_BROWSER) /* MMI: + 4 KB */
/* under construction !*/
#else
/* under construction !*/
#endif
#else  /* WISDOM_MMI */
#ifdef __MOBILE_VIDEO_SUPPORT__
task_stack_size(20480)
#else
#if defined(__MRE_PACKAGE_FULL__) || defined(__MRE_PACKAGE_NORMAL__)
task_stack_size(16348) /* MRE APP opera need 16KB */
#elif defined(OPERA_BROWSER) /* MMI: + 4 KB */
task_stack_size(10240)
#else
task_stack_size(6144)
#endif
#endif
#endif /* WISDOM_MMI */
#endif /* NEPTUNE_MMI */    
#ifdef MMI_NOT_PRESENT
null_task_create_entry(NULL)
#elif !defined(WISDOM_MMI)
task_create_function(mmi_create)
#else
/* under construction !*/
#endif
task_stack_internalRAM(KAL_FALSE)
#if defined(WISDOM_MMI)
/* under construction !*/
/* under construction !*/
#else
   #if (defined(__GEMINI__)) && (GEMINI_PLUS >= 4)
/* under construction !*/
   #else
      task_external_queue_size(30)
   #endif
task_internal_queue_size(0)
#endif
task_boot_mode(NORMAL_M | USB_M)
/*************************Task CFG END******************/

/*****************************************************************************
 * FUNCTION
 *  mmi_create
 * DESCRIPTION
 *  MMI task create function for system service.
 * PARAMETERS
 *  handle      [IN]            
 *  a(?)        [IN/OUT]        Handle: provide the create task related routine function.
 * RETURNS
 *  The result is ok or not.
 *****************************************************************************/
kal_bool mmi_create(comptask_handler_struct **handle)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    static comptask_handler_struct mmi_handler_info = 
    {
        MMI_task,   /* task entry function */
        MMI_Init,   /* task initialization function */
        NULL,
        NULL,       /* task reset handler */
        NULL,       /* task termination handler */
    };

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    *handle = &mmi_handler_info;
    return KAL_TRUE;
}

發送消息

/*
  NOTE: User must take care about the usage of this API, 
        if the message is sent to the same task, the message
        will be sent to internal queue, task must process the 
        internal queue. Otherwise, internal queue will full.
*/
#define SEND_ILM( src_mod, dest_mod, sap, ilm_ptr)\
{    ilm_ptr->src_mod_id  = src_mod;     ilm_ptr->dest_mod_id = dest_mod;    ilm_ptr->sap_id = sap;    if (mod_task_g[src_mod] == mod_task_g[dest_mod]) {      msg_send_int_queue(ilm_ptr);    } else {      msg_send_ext_queue(ilm_ptr);    } }

【手記】MTK之TASK創建及使用