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

📄 txc_envoy_database.c

📁 TranSwitch Envoy CE2 & Envoy CE4 设备驱动及编程指南
💻 C
📖 第 1 页 / 共 2 页
字号:
/*--------------------------------------------------------------------------

  *******                           ****
     *     *****     **    *    *  *       *    *   *  *****   ****   *    *
     *     *    *   *  *   **   *  *       *    *   *    *    *    *  *    *
     *     *    *  *    *  * *  *   ****   *    *   *    *    *       ******
     *     *****   ******  *  * *       *  * ** *   *    *    *       *    *
     *     *   *   *    *  *   **  *    *  **  **   *    *    *    *  *    *
     *     *    *  *    *  *    *   ****   *    *   *    *     ****   *    *

                        Proprietary and Confidential 

    This program is made available only to customers and prospective customers 
of TranSwitch Corporation under license and may be used only with TranSwitch 
semi-conductor products.

                      Copyright(c) 2004 TranSwitch Inc.

 --------------------------------------------------------------------------

             *******  **      **  **        **   ********   **      **
             *******  ***     **  **        **  **********  **      **
             **       ** *    **  **        **  **      **   **    **
             *****    **  *   **   **      **   **      **     *  *
             *****    **   *  **    **    **    **      **      **
             **       **    * **     **  **     **      **      **
             *******  **     ***      ****      **********      **
             *******  **      **       **        ********       **

 --------------------------------------------------------------------------
                           TranSwitch Envoy-CE2/CE4
                                Device Driver
 --------------------------------------------------------------------------
                                                                           
  Workfile:     txc_envoy_database.c                                                 
                                                                           
  Description:  this file contains the database and access function                                                   
                                                                           
 --------------------------------------------------------------------------
                              Revision History                             
 --------------------------------------------------------------------------
    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
 *--------------------------------------------------------------------------*/


/****************************************************************************
 **                             Include Files                              **
 ****************************************************************************/

#include "txc_envoy_api.h"
#include "txc_envoy_database.h"
#include "txc_os_sem.h"

#include <string.h>


/****************************************************************************
 **                            Static Functions                            **
 ****************************************************************************/



/****************************************************************************
 **                        Static/Global Variables                         **
 ****************************************************************************/

ENVOY_DRIVER_DATABASE envoyDatabase=
{
    0, /* driverActive */
    0, /* semId        */
};


/****************************************************************************
 **                                  Code                                  **
 ****************************************************************************/



/*--------------------------------------------------------------------------*
                                                                           
  FUNCTION: TXC_ENVOY_InitDatabase                                                   
                                                                           
  DESCRIPTION: This function could be used in the boot task to make sure the 
    ENVOY database is clear if the user does not have initialized on boot ram
    segments                                       
                                                                           
  INPUTS: none                                                           
                                                                           
  RETURNS: none                                                         
                                                                           
  CAVEATS: none                                                         
                                                                           
   REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
 *--------------------------------------------------------------------------*/

void TXC_ENVOY_InitDatabase (void)
{
#ifndef TXC_ENVOY_VIRTUAL_DEVICE_MODE


    /* make sure the semaphore is deleted  */
    if (envoyDatabase.semId != TXC_NULL)
        TXC_SemDelete (envoyDatabase.semId);
        
#endif

    /* clear the database */
    memset (&envoyDatabase, TXC_NULL, sizeof (ENVOY_DRIVER_DATABASE) );
}

/*--------------------------------------------------------------------------*
                                                                           
  FUNCTION: ENVOY_DbVerifyHandle                                                  
                                                                           
  DESCRIPTION: This function checks that the driver has been created and the
               input handle is active.                                        
                                                                           
  INPUTS: handle                                                           
                                                                           
  RETURNS: TXC_NO_ERR, TXC_INVALID_HANDLE_ERR or TXC_DRIVER_NOT_CREATED_ERR                                                         
                                                                           
  CAVEATS: None                                                         
                                                                           
  REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
 *--------------------------------------------------------------------------*/


TXC_U16BIT ENVOY_DbVerifyHandle (TXC_U16BIT handle)
{

    /* first, test if the driver is active */
    if (envoyDatabase.driverActive == TXC_FALSE)
        return TXC_DRIVER_NOT_CREATED_ERR;

    /* second, test if the handle is active */
    if (envoyDatabase.envoyDeviceData[handle].deviceActive == TXC_FALSE)
        return TXC_INVALID_HANDLE_ERR;

    /* next, test if the handle is less than max num devices */
    if ( handle >= ENVOY_MAX_DEVICES)
        return TXC_INVALID_HANDLE_ERR;

    return TXC_NO_ERR;

}

/*--------------------------------------------------------------------------*

  FUNCTION: ENVOY_DbGetMaxMacPorts

  DESCRIPTION: This function returns the maximum allowable MAC ports.

  INPUTS: handle

  RETURNS: maximum allowable MAC ports.

  CAVEATS: None

  REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
 *--------------------------------------------------------------------------*/

TXC_U16BIT ENVOY_DbGetMaxMacPorts (TXC_U16BIT handle)
{
    TXC_U16BIT deviceType;

    /* First, get the device type. */
    deviceType = ENVOY_DbGetDeviceType (handle);

    if (deviceType == ENVOY_CE2)
    {
        return ENVOY_CE2_MAX_MAC_PORTS;
    }
    else if (deviceType == ENVOY_CE4)
    {
        return ENVOY_CE4_MAX_MAC_PORTS;
    }
    else
        return 0;
}


/*--------------------------------------------------------------------------*

  FUNCTION: ENVOY_DbGetMaxMacPortBlocks

  DESCRIPTION: This function returns the maximum allowable MAC port blocks.

  INPUTS: handle

  RETURNS: maximum allowable MAC ports.

  CAVEATS: None

⌨️ 快捷键说明

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