TaskInit.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:12k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * TaskInit.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * Initilize the task structure for the entire application. Functions to allocate task resources,
- * create task communication interfaces and synchronization mechanism for common resource sharing.
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include "GlobalConstants.h"
- #ifdef MMI_ON_WIN32
- #include "stdC.h"
- #include "ThrdOsInterface.h"
- #include "DebugInitDef.h"
- #include "EventsGprot.h"
- #include "WrapperGprot.h"
- #include "AllAppGprot.h"
- #include "WrapperGprot.h"
- #include "DebugInitProt.h"
- #include "OslGexdcl.h"
- #include "taskinit.h"
- #include "queuegprot.h"
- #include "MMItaskProt.h"
- /*****************************************************************************
- * Define
- *****************************************************************************/
- /*****************************************************************************
- * Typedef
- *****************************************************************************/
- /*****************************************************************************
- * Local Variable
- *****************************************************************************/
- /*****************************************************************************
- * Local Function
- *****************************************************************************/
- /*****************************************************************************
- * Global Variable
- *****************************************************************************/
- osl_task_info task_info_g1[TOTAL_TASKS];
- oslTimerid TimerCallBackHdlr;
- CRITICAL_SECTION TimerCS;
- oslSoftTimerid TimerId[MAX_TIMERS];
- const osl_task_create_info task_create_tbl[TOTAL_TASKS] =
- {
- {"DUM1 TASK", "DUM1 Q", 127, 128, 0, Dummy_task},
- {"DUM2 TASK", "DUM2 Q", 127, 128, MAX_PRT_NODES, Dummy_task},
- {"MMI TASK", "MMI Q", 127, 4096, MAX_PRT_NODES, MMI_task},
- {"DUM3 TASK", "DUM3 Q", 127, 128, 0, Dummy_task},
- };
- /*****************************************************************************
- * Global Function
- *****************************************************************************/
- extern void TimerCallBack(void *param);
- /*****************************************************************************
- * FUNCTION
- * Dummy_task
- * DESCRIPTION
- * read a messages & diapatche it to proper handler
- *
- * This is used to read a messages & diapatche it to proper handler
- * PARAMETERS
- * entry_param [?]
- * RETURNS
- * void
- *****************************************************************************/
- void Dummy_task(oslEntryType *entry_param)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- }
- /*****************************************************************************
- * FUNCTION
- * InitApplication
- * DESCRIPTION
- * Create/Inititialize trace mechanism,task queues, semaphores,Threads etc..
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void InitApplication()
- {
- #ifdef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- int i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- DebugInit();
- for (i = 0; i < MAX_TIMERS; i++)
- {
- TimerId[i] = NULL;
- }
- InitializeCriticalSection(&TimerCS);
- TimerCallBackHdlr = OslCreateTimer("TIMER");
- OslSetTimer(TimerCallBackHdlr, TimerCallBack, 0, TIMER_CALLBACK_RESOLUTION); /* 100 msec soft timer */
- for (i = 0; i < TOTAL_TASKS - 9; i++)
- {
- task_info_g1[i + 9].task_ext_qid = OslCreateMsgQ(
- task_create_tbl[i].task_qname,
- sizeof(MYQUEUE),
- task_create_tbl[i].task_ext_qsize);
- task_info_g1[i + 9].task_id = osl_create_task(
- task_create_tbl[i].task_name,
- task_create_tbl[i].task_priority,
- task_create_tbl[i].task_stack_size,
- task_create_tbl[i].task_entry_func,
- (void*)(i + 9),
- 0);
- task_info_g1[i + 9].task_name = task_create_tbl[i].task_name;
- task_info_g1[i + 9].task_priority = task_create_tbl[i].task_priority;
- task_info_g1[i + 9].task_stack_size = task_create_tbl[i].task_stack_size;
- task_info_g1[i + 9].task_entry_func = task_create_tbl[i].task_entry_func;
- task_info_g1[i + 9].task_qname = task_create_tbl[i].task_qname;
- task_info_g1[i + 9].task_ext_qsize = task_create_tbl[i].task_ext_qsize;
- }
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * TimerCallBack
- * DESCRIPTION
- * Soft Timer Handler for Windows.
- * PARAMETERS
- * param [?]
- * RETURNS
- * void
- *****************************************************************************/
- void TimerCallBack(void *param)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i;
- void *tmr_callback_arg = NULL;
- oslTaskFuncPtr tmr_callback = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EnterCriticalSection(&TimerCS);
- for (i = 0; i < MAX_TIMERS; i++)
- {
- if (TimerId[i] != NULL)
- {
- TimerId[i]->tmr_count -= TIMER_CALLBACK_RESOLUTION;
- if (TimerId[i]->tmr_count == 0)
- {
- tmr_callback_arg = TimerId[i]->tmr_callback_arg;
- tmr_callback = TimerId[i]->tmr_callback;
- OslMfree(TimerId[i]);
- TimerId[i] = NULL;
- LeaveCriticalSection(&TimerCS);
- /*
- * Before execute timer_expiry_callback, leave the
- * criticalsection first. It avoids the deadlock that
- * if start/stop the timer in tmr_callback().
- */
- if (tmr_callback != NULL)
- {
- tmr_callback(tmr_callback_arg);
- }
- /*
- * Before continuing search the next
- * timer_expiry_callback, enter the critical section first.
- */
- EnterCriticalSection(&TimerCS);
- }
- }
- }
- LeaveCriticalSection(&TimerCS);
- }
- #endif /* MMI_ON_WIN32 */
- #ifndef MMI_ON_WIN32
- /*************************************************************************
- * Include Statements
- *************************************************************************/
- #include "kal_release.h"
- #include "stack_types.h"
- #include "syscomp_config.h"
- #include "taskinit.h"
- #include "stack_buff_pool.h"
- #include "ctrl_buff_pool.h"
- #include "PixtelDataTypes.h"
- /*****************************************************************************
- * Global Function
- *****************************************************************************/
- extern void MMI_task(oslEntryType *entry_param);
- extern MMI_BOOL MMI_Init(task_indx_type task_indx);
- /*****************************************************************************
- * 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;
- }
- #endif /* MMI_ON_WIN32 */