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

📄 zl5011xmm.c

📁 Zalink50114----TDMoIP芯片驱动源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*******************************************************************************
*
*  File name:              zl5011xMm.c
*
*  Version:                26
*
*  Author:                 PJE
*
*  Date created:           03/04/2002
*
*  Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
*  All rights reserved.
*
*  Module Description:
*
*  This file contains all the functions that will initialise and control
*  the MM block.
*
*  Revision History:
*
*  Rev:  Date:       Author:  Comments:
*  1     03/04/2002  PJE      Bit twiddling done
*  2     03/04/2002  PJE      Update
*  3     04/04/2002  PJE      Bit twiddling done
*  4     04/04/2002  PJE      Bit twiddling - some corrections
*  5     05/04/2002  PJE      structure initialised
*  6     26/04/2002  MRC      Changed some data names in response to comments
*                             from Thomas, regarding the MIB interface.
*  7     30/04/2002  MRC      Changed MM init, so that it does not return
*                             the MBIST results.
*  8     09/05/2002  MRC      Added external memory enable to cofigure fn
*  9     13/06/2002  PJE      MmAlloc & MmFree coded.
*
*  10    14/06/2002  PJE      Update
*  11    20/06/2002  MRC      If _NO_DEVICE is set then don't do memory check
*  12    20/06/2002  MRC      Changed defines to control memory checks
*  13    10/07/2002  PJE      Chip simplified- functions removed.
*  14    18/07/2002  MRC      Moved the memory alloc table into the device
*                             structure
*  15    19/07/2002  MRC      Modified memory alloc fns
*  16    01/10/2002  DJA      File header modified
*                             ZL5011X_TRACE messages fixed up
*  17    03/10/2002  MRC      Turned off read and write tracing in memory test
*  18    03/10/2002  MRC      Renamed no memory test define
*  19    25/10/2002  PJE      API tidy up
*  20    31/10/2002  MRC      Added variants + minor fixes
*  21    22/01/2003  MRC      Changed the memory size enum and tidied up
*  22    07/02/2003  MRC      Changed the parity trip point, now initialises
*                             the parity count
*  23    24/06/2003  ARW      Updated function zl5011xMmFree
*  24    04/08/2003  APL      Adjusted heapSize calculation
*  25    23/07/2004  MRC      Fixed some compiler warnings
*  26    29/07/2004  MRC      Fixed some compiler warnings
*  27    26/05/2005  APL      Corrected TRACE statement for memory size
*
*******************************************************************************/

/*****************   INCLUDE FILES                *****************************/

#include "zl5011x.h"
#include "zl5011xMm.h"
#include "zl5011xMmMap.h"
#include "zl5011xUtilLib.h"

/*****************   EXPORTED GLOBAL VARIABLES    *****************************/

/*****************   STATIC GLOBAL VARIABLES      *****************************/

/*****************   STATIC FUNCTION DECLARATIONS *****************************/

/*****************   EXPORTED FUNCTION DEFINTIONS   ***************************/

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

 Function:
    zl5011xMmInit

 Description:
   Checks internal memory and initialises MM parts of device structure.

 Inputs:
    zl5011xParams      Pointer to the structure for this device instance

 Outputs:
   None

 Returns:
   zlStatusE

 Remarks:
   None

*******************************************************************************/
extern zlStatusE zl5011xMmInit(zl5011xParamsS *zl5011xParams)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmInit:", 0, 0, 0, 0, 0, 0);

   /* check the packet memory  */

#ifndef _NO_PACKET_MEMORY_TEST

    status = zl5011xMmTestPacketMemory(zl5011xParams, ZL5011X_INT_MEM_BASE,
                                      ZL5011X_INT_MEMORY_SIZE_IN_BYTES );

#endif

   /* "initialise" structure components of MM */
   if (status == ZL5011X_OK)
   {
      zl5011xParams->packetMemory.granBaseAddr = (Uint32T)ZL5011X_NOT_INITIALISED;
      zl5011xParams->packetMemory.granDescBaseAddr = (Uint32T)ZL5011X_NOT_INITIALISED;
      zl5011xParams->packetMemory.heapStartAddress = (Uint32T)ZL5011X_NOT_INITIALISED;
      zl5011xParams->packetMemory.heapEndAddress = (Uint32T)ZL5011X_NOT_INITIALISED;
   }

   return(status);
}

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

 Function:
    zl5011xMmConfigure

 Description:
   This Function initialises the MM block, and checks that the EXTERNAL memory
   is functional.
   The external memory is located at the bottom of the device memory map.
   The timing for the read and write clock signals are set to default values.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   extMemSize        external memory size in bytes

 Outputs:
    none

 Returns:
   zlStatusE

 Remarks:

*******************************************************************************/
extern zlStatusE zl5011xMmConfigure(zl5011xParamsS *zl5011xParams,
                            zl5011xExtMemChipSizeE extMemSize)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmConfigure: Memory Size (enum) %d", extMemSize, 0, 0, 0, 0, 0);

   /* Set the external mem device size */
   switch(extMemSize)
   {
      case ZL5011X_EXT_MEM_SIZE_0MB:
         zl5011xParams->packetMemory.extMemSizeBytes = 0x0;
         break;
      case ZL5011X_EXT_MEM_SIZE_512KB:
         zl5011xParams->packetMemory.extMemSizeBytes = 0x80000;
         break;
      case ZL5011X_EXT_MEM_SIZE_1MB:
         zl5011xParams->packetMemory.extMemSizeBytes = 0x100000;
         break;
      case ZL5011X_EXT_MEM_SIZE_2MB:
         zl5011xParams->packetMemory.extMemSizeBytes = 0x200000;
         break;
      case ZL5011X_EXT_MEM_SIZE_4MB:
         zl5011xParams->packetMemory.extMemSizeBytes = 0x400000;
         break;
      case ZL5011X_EXT_MEM_SIZE_8MB:
         zl5011xParams->packetMemory.extMemSizeBytes = 0x800000;
         break;
      default:
         status = ZL5011X_PARAMETER_INVALID;
         break;
   }

   /* set read-latency & set the external mem clocks value */
   if (status == ZL5011X_OK)
   {
      zl5011xParams->packetMemory.extMemChipSize = extMemSize;
   }

   /* if there is external memory, then enable it now */
   if (status == ZL5011X_OK)
   {
      if (extMemSize != ZL5011X_EXT_MEM_SIZE_0MB)
      {
         status = zl5011xMmControlExternalMemory(zl5011xParams, ZL5011X_MM_ENABLED);

         if (status == ZL5011X_OK)
         {
            status = zl5011xMmSetArbitrationBurstLength(zl5011xParams,
                  ZL5011X_MM_DEFAULT_BURST_LENGTH);
         }
      }
   }

   /* check packet memory is functional */
   if (status == ZL5011X_OK)
   {

#ifndef _NO_PACKET_MEMORY_TEST

      status = zl5011xMmTestPacketMemory(zl5011xParams, ZL5011X_EXT_MEM_BASE,
                                        zl5011xParams->packetMemory.extMemSizeBytes);
#endif

   }

   return(status);
}

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

 Function:
    zl5011xMmSetGranuleDataBase

 Description:
   This function sets the granule base address in the GRNBASE register with the
   value given.

 Inputs:
    zl5011xParams  Pointer to the structure for this device instance
    granBaseAddr  address for granule data

 Outputs:
    none

 Returns:
    zlStatusE

 Remarks:
   Only bits 23:15 are used to give a resolution of 4k (words of 64bit).

*******************************************************************************/
extern zlStatusE zl5011xMmSetGranuleDataBase(zl5011xParamsS *zl5011xParams,
                                     Uint32T granBaseAddr)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmSetGranuleDataBase: adddress 0x%08x ", granBaseAddr, 0, 0, 0, 0, 0);

   if ((granBaseAddr & ~ZL5011X_MM_GRNBASE_MASK) != 0)
   {
      status = ZL5011X_PARAMETER_INVALID;
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xWrite(zl5011xParams, ZL5011X_MM_GRNBASE, granBaseAddr);

      zl5011xParams->packetMemory.granBaseAddr = granBaseAddr;
   }

   return(status);
}

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

 Function:
    zl5011xMmSetGranuleDescriptorBase

 Description:
   This function sets the granule descriptor base address in the GRNDESBASE
   register with the value given.

 Inputs:
    zl5011xParams     Pointer to the structure for this device instance
    granDescBaseAddr granule base byte address in given resolution. (= 32kbyte)

 Outputs:
    none

 Returns:
    zlStatusE

 Remarks:
   Resolution = 4kwords (of 64bit).

*******************************************************************************/
extern zlStatusE zl5011xMmSetGranuleDescriptorBase(zl5011xParamsS *zl5011xParams,
                                           Uint32T granDescBaseAddr)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmSetGranuleDescriptorBase: adddress 0x%08x ", granDescBaseAddr, 0, 0, 0, 0, 0);
   granDescBaseAddr&= ZL5011X_MM_GRNBASE_MASK;
   status = zl5011xWrite(zl5011xParams, ZL5011X_MM_GRNDESBASE, granDescBaseAddr);
   if (status == ZL5011X_OK)
   {
      zl5011xParams->packetMemory.granDescBaseAddr = granDescBaseAddr;
   }
   return(status);
}

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

 Function:
    zl5011xMmSetArbitrationBurstLength

 Description:
   This function sets the BURSTL register with the maximum number of cycles that
   the module is allowed to keep access to the memory.

 Inputs:
    zl5011xParams      Pointer to the structure for this device instance
    extMemBurstLength number of cycles that a block is granted access to the bus.

 Outputs:
    none

 Returns:
    zlStatusE

 Remarks:

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

extern zlStatusE zl5011xMmSetArbitrationBurstLength(zl5011xParamsS *zl5011xParams,
                                            Uint32T extMemBurstLength)
{
   zlStatusE status = ZL5011X_OK;

   ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmSetArbitrationBurstLength: %d",

⌨️ 快捷键说明

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