⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wrapper.c

📁 MTK手机平台的MMI部分的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
*  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:
 * ---------
 *  Wrapper.c
 *
 * Project:
 * --------
 *  MAUI
 *
 * Description:
 * ------------
 *  
 *
 * Author:
 * -------
 *  
 *
 *==============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *==============================================================================
 *******************************************************************************/

/**
 * Copyright Notice
 * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
 * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
 *  (It is illegal to remove this copyright notice from this software or any
 *  portion of it)
 */

/**************************************************************

   FILENAME : Wrapper.c

   PURPOSE     : OS wrapper functions to make the task structure functionality 
            independant of underlying operating system. 
   REMARKS     : nil

   AUTHOR      : Neeraj Sharma

   DATE     : Dec' 28, 2002

**************************************************************/

/* Include files ----------------------------------- */
/* [001] */
#include "WrapperGprot.h"
#include "pixteldatatypes.h"
#ifdef MMI_ON_WIN32
#include "TaskInit.h"
#include "QueueGprot.h"
#include "NVRAMProt.h"
#include "stdafx.h"
extern CRITICAL_SECTION TimerCS;
oslSoftTimerid TimerId[MAX_TIMERS];
oslTimerid TimerCallBackHdlr;
#include <assert.h>
#endif /* MMI_ON_WIN32 */ 
#ifndef MMI_ON_WIN32
#include "l4dr.h"
#endif 

#include "oslmemory.h"
/* Macros and Data Structor Declerations -------------- */

/* static oslTimerid TimerPtrs[MAX_TIMERS]; */
static U8 TimerExist[MAX_TIMERS];

/* kill all the semaphore and thread objects     */

/* ------Functions Decleration ------------------------------------- */

/*-------------------------------------------------------------------
Function Name  :  oslTaskid OslIntCreateTask
Description    :  This module creates the task 
Input       :  PS8 task_name,
               U8 priority,
               U32 stack_size,
               oslTaskFuncPtr entry_func,
               void * entry_param,
               U8 misc_options
Output         :  taskID
-------------------------------------------------------------------*/


/*****************************************************************************
 * FUNCTION
 *  OslIntCreateTask
 * DESCRIPTION
 *  
 * PARAMETERS
 *  task_name           [IN]        
 *  priority            [IN]        
 *  stack_size          [IN]        
 *  entry_func          [IN]        
 *  entry_param         [?]         
 *  misc_options        [IN]        
 * RETURNS
 *  
 *****************************************************************************/
oslTaskid OslIntCreateTask(
            PS8 task_name,
            U8 priority,
            U32 stack_size,
            oslTaskFuncPtr entry_func,
            void *entry_param,
            U8 misc_options)
{
#ifdef MMI_ON_WIN32
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U32 tThreadId;
    U32 win32_priority;
    oslTaskid taskid;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    taskid = CreateThread(
                NULL,
                stack_size,
                (LPTHREAD_START_ROUTINE) entry_func,
                entry_param,
                CREATE_SUSPENDED,
                &tThreadId);
    if (priority >= 0 && priority < 52)
    {
        win32_priority = THREAD_PRIORITY_HIGHEST;
    }
    else if (priority >= 52 && priority < 104)
    {
        win32_priority = THREAD_PRIORITY_ABOVE_NORMAL;
    }
    else if (priority >= 104 && priority < 156)
    {
        win32_priority = THREAD_PRIORITY_NORMAL;
    }
    else if (priority >= 156 && priority < 208)
    {
        win32_priority = THREAD_PRIORITY_BELOW_NORMAL;
    }
    else if (priority >= 208 && priority <= 255)
    {
        win32_priority = THREAD_PRIORITY_LOWEST;
    }
    SetThreadPriority(taskid, win32_priority);
    ResumeThread(taskid);
    return taskid;
#else /* MMI_ON_WIN32 */ 
    return NULL;
#endif /* MMI_ON_WIN32 */ 
}

/*-------------------------------------------------------------------
Function Name  :  OslIntDleteTask
Description    :  This module creates the task 
Input       :  TaskID
Output         :  TRYE or FALSE
-------------------------------------------------------------------*/


/*****************************************************************************
 * FUNCTION
 *  OslIntDleteTask
 * DESCRIPTION
 *  
 * PARAMETERS
 *  taskid      [IN]        
 * RETURNS
 *  
 *****************************************************************************/
OSLSTATUS OslIntDleteTask(oslTaskid taskid)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifdef MMI_ON_WIN32
    CloseHandle(taskid);
#endif 
    return OSL_SUCCESS;
}

/*-------------------------------------------------------------------
Function Name  :  StartMyTimer
Description    :  This module starts the timer
Input       :  unsigned short nTimerId,
               unsigned short nTimeDuration,
               oslTimerFuncPtr TimerExpiry)
Output         :  BOOL
-------------------------------------------------------------------*/


/*****************************************************************************
 * FUNCTION
 *  StartMyTimerInt
 * DESCRIPTION
 *  
 * PARAMETERS
 *  nTimerId            [IN]        
 *  nTimeDuration       [IN]        
 *  TimerExpiry         [IN]        
 *  alignment           [IN]        
 * RETURNS
 *  
 *****************************************************************************/
U16 StartMyTimerInt(U16 nTimerId, U32 nTimeDuration, oslTimerFuncPtr TimerExpiry, U8 alignment)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (TimerExist[nTimerId])
    {
        OslStopSoftTimer(nTimerId);
    }
    OslStartSoftTimer(nTimerId, TimerExpiry, nTimerId, nTimeDuration, alignment);
    TimerExist[nTimerId] = 1;
    return TRUE;
}

/*-------------------------------------------------------------------
Function Name  :  StopMyTimer
Description    :  This module stops the timer
Input       :  timerID
Output         :  bool
-------------------------------------------------------------------*/


/*****************************************************************************
 * FUNCTION
 *  StopMyTimer
 * DESCRIPTION
 *  
 * PARAMETERS
 *  nTimerId        [IN]        
 * RETURNS
 *  
 *****************************************************************************/
U16 StopMyTimer(U16 nTimerId)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (TimerExist[nTimerId])
    {
        OslStopSoftTimer(nTimerId);
        TimerExist[nTimerId] = 0;
    }
    return TRUE;
}

/*-------------------------------------------------------------------
Function Name  :  IsMyTimerExist
Description    :  This module stops the timer
Input       :  timerID
Output         :  bool

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -