?? zl5011xinit.c
字號:
gotDevice = ZL5011X_TRUE;
}
}
/* main function code starts */
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_INIT_FN_ID, "zl5011xInit: %d", par->deviceType, 0, 0, 0, 0, 0);
/* Set up the appropriate device limits for this device type */
zl5011xParams->deviceType = par->deviceType;
memcpy(&zl5011xParams->devLimits, &Zl5011xLimits[par->deviceType], sizeof(zl5011xParams->devLimits));
/* initialising the admin block is the first thing to do to the
device */
status = zl5011xAdmInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xInitBlocks(zl5011xParams, ZL5011X_ADM_GM_BIT);
}
if (status == ZL5011X_OK)
{
zl5011xParams->systemClockFreq = par->systemClockFreq;
}
if (status == ZL5011X_OK)
{
status = zl5011xMmInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xGmInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xTmInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
zl5011xParams->initialised = ZL5011X_TRUE;
zl5011xParams->memoryInitialised = ZL5011X_FALSE;
zl5011xParams->wanInitialised = ZL5011X_FALSE;
zl5011xParams->lanInitialised = ZL5011X_FALSE;
zl5011xParams->running = ZL5011X_FALSE;
for (loop = 0; loop < ZL5011X_MAX_NUM_LAN_PORTS; loop++)
{
zl5011xParams->lanPortInitialised[loop] = ZL5011X_FALSE;
}
}
if (gotDevice == ZL5011X_TRUE)
{
if (status == ZL5011X_OK)
{
status = zl5011xReleaseDevice(zl5011xParams);
}
else
{
/* already have an error code, so don't overwrite it */
(void)zl5011xReleaseDevice(zl5011xParams);
}
}
return status;
}
/*******************************************************************************
Function:
zl5011xConfigureMemoryStructInit
Description:
Initialises structure used by zl5011xConfigureMemory function.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to the structure for configuration items.
See main function
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xConfigureMemoryStructInit(zl5011xParamsS *zl5011xParams, zl5011xConfigureMemoryS *par)
{
zlStatusE status = ZL5011X_OK;
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_INIT_FN_ID, "zl5011xConfigureMemoryStructInit:", 0, 0, 0, 0, 0, 0);
par->extMemChipSize = ZL5011X_EXT_MEM_SIZE_0MB;
par->extMemParity = ZL5011X_MM_PARITY_NONE;
/* set an invalid number of granules - this will allow the API to make the
setting automatically */
par->numberGranules = (Uint32T)ZL5011X_INVALID;
/* default to 10% of the internal memory for TDM queues in kBytes */
par->maxWanQueueSizeInkBytes = (ZL5011X_INT_MEMORY_SIZE_IN_BYTES / 10) / 1024;
par->osExclusionEnable = ZL5011X_TRUE;
}
return status;
}
/*******************************************************************************
Function:
zl5011xConfigureMemory
Description:
This function configures the external memory, initialises the granule manager
and then runs the granule manager. The granule manager is one of the first
blocks to be configured in the device, since most of the blocks require
granules for operation.
There are several functions used to configure the device from reset. They
are shown below, and must be called in this sequence, in order to enable the
device.
zl5011xInit
zl5011xConfigureMemory
zl5011xWanInit
zl5011xLanInit
zl5011xRun
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to the structure for configuration items. See below:
Structure inputs:
extMemChipSize size of the memory attached to the device in bytes.
(the memory width is 64 bits)
extMemParity parity mode - none, odd or even
numberGranules how many granules to initialise
maxWanQueueSizeInkBytes how much memory to reserve for the Wan Tx queues
osExclusionEnable ZL5011X_TRUE to enable OS exclusion
Structure outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xConfigureMemory(zl5011xParamsS *zl5011xParams, zl5011xConfigureMemoryS *par)
{
zlStatusE status = ZL5011X_OK;
Uint32T heapStartAddress = 0;
Uint32T heapEndAddress = 0;
Uint32T dataBase = 0, descBase = 0, numGranules;
zl5011xBooleanE gotDevice = ZL5011X_FALSE;
/* do some parameter checking */
status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);
if ((status == ZL5011X_OK) && (par->osExclusionEnable == ZL5011X_TRUE))
{
/* get access to the device */
status = zl5011xGetDevice(zl5011xParams, ZL5011X_GET_DEVICE_TIMEOUT_MODE);
if (status == ZL5011X_OK)
{
gotDevice = ZL5011X_TRUE;
}
}
/* main function code starts */
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_INIT_FN_ID,
"zl5011xConfigureMemory: Ext size %d, num granules %d",
par->extMemChipSize, par->numberGranules, 0, 0, 0, 0);
/* the basic initialisation must be performed before the memory is configured */
if (zl5011xParams->initialised == ZL5011X_FALSE)
{
status = ZL5011X_NOT_INIT;
}
}
if (status == ZL5011X_OK)
{
if (zl5011xParams->memoryInitialised == ZL5011X_TRUE)
{
status = ZL5011X_MULTIPLE_INIT_ATTEMPT;
}
}
if (status == ZL5011X_OK)
{
/* Check the memory size and parity parameters */
switch (zl5011xParams->deviceType)
{
case ZL_DEVICE_ZL50110:
case ZL_DEVICE_ZL50111:
case ZL_DEVICE_ZL50114:
case ZL_DEVICE_ZL50130:
case ZL_DEVICE_ZL80041:
/* These devices support external memory */
break;
case ZL_DEVICE_ZL50115:
case ZL_DEVICE_ZL50116:
case ZL_DEVICE_ZL50117:
case ZL_DEVICE_ZL50118:
case ZL_DEVICE_ZL50119:
case ZL_DEVICE_ZL50120:
case ZL_DEVICE_ZL30300:
case ZL_DEVICE_ZL30301:
case ZL_DEVICE_ZL30302:
/* These devices do not support external memory therefore the size must be specified as zero
and the parity must be specified as none */
if ((par->extMemChipSize != ZL5011X_EXT_MEM_SIZE_0MB) ||
(par->extMemParity != ZL5011X_MM_PARITY_NONE))
{
status = ZL5011X_PARAMETER_INVALID;
}
break;
default:
/* Device unknown */
status = ZL5011X_UNKNOWN_DEVICE_ID;
break;
}
}
if (status == ZL5011X_OK)
{
status = zl5011xMmConfigure(zl5011xParams, par->extMemChipSize);
}
if (status == ZL5011X_OK)
{
status = zl5011xMmSetParityMode(zl5011xParams, par->extMemParity);
}
if (par->numberGranules != (Uint32T)ZL5011X_INVALID)
{
status = zl5011xMemoryCalcAddrGranules(zl5011xParams, par,
&descBase, &dataBase, &heapStartAddress, &heapEndAddress);
numGranules = par->numberGranules;
}
else
{
status = zl5011xMemoryCalcAddrGranulesMax(zl5011xParams, par,
&descBase, &dataBase, &heapStartAddress, &heapEndAddress, &numGranules);
}
if (status == ZL5011X_OK)
{
status = zl5011xMmSetGranuleDataBase(zl5011xParams, dataBase);
}
if (status == ZL5011X_OK)
{
status = zl5011xMmSetGranuleDescriptorBase(zl5011xParams, descBase);
}
/* the granule manager has already been initialised. The memory manager is now
programmed, so setup the granule chains */
if (status == ZL5011X_OK)
{
status = zl5011xGmConfigure(zl5011xParams, numGranules);
}
/* enable the granule manager, now that the chain has been setup */
if (status == ZL5011X_OK)
{
status = zl5011xAdmEnableBlocks(zl5011xParams, ZL5011X_ADM_GM_BIT);
}
if (status == ZL5011X_OK)
{
status = zl5011xMmSetHeap(zl5011xParams, heapStartAddress, heapEndAddress);
}
if (status == ZL5011X_OK)
{
zl5011xParams->memoryInitialised = ZL5011X_TRUE;
}
if (gotDevice == ZL5011X_TRUE)
{
if (status == ZL5011X_OK)
{
status = zl5011xReleaseDevice(zl5011xParams);
}
else
{
/* already have an error code, so don't overwrite it */
(void)zl5011xReleaseDevice(zl5011xParams);
}
}
return status;
}
/*******************************************************************************
Function:
zl5011xWanInitStructInit
Description:
Initialises structure used by zl5011xWanInit function.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to the structure for configuration items.
See main function
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xWanInitStructInit(zl5011xParamsS *zl5011xParams, zl5011xWanInitS *par)
{
zlStatusE status = ZL5011X_OK;
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_INIT_FN_ID, "zl5011xWanInitStructInit: ", 0, 0, 0, 0, 0, 0);
par->ifType = ZL5011X_WAN_FRAMED_2M;
par->liuFreq = ZL5011X_WAN_LIU_FREQ_2_048M;
par->liuFreqHz = (Uint32T)ZL5011X_INVALID;
/* set a default for the maximum number of granules for the Tx queues,
will be need to be increased if external memory is used */
par->txQueueMaxNumberOfGranules = 4000;
par->osExclusionEnable = ZL5011X_TRUE;
}
return status;
}
/*******************************************************************************
Function:
zl5011xWanInit
Description:
This function initialises the WAN interface blocks, and then configures
the blocks using the interface type.
There are several functions used to configure the device from reset. They
are shown below, and must be called in this sequence, in order to enable the
device.
zl5011xInit
zl5011xConfigureMemory
zl5011xWanInit
zl5011xLanInit
zl5011xRun
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to the structure for configuration items. See below:
Structure inputs:
ifType Wan interface type
liuFreq the frequency of the LIU
liuFreqHz the frequency of the stream clocks if the variable liuFreq is set
to ZL5011X_WAN_LIU_FREQ_OTHER
txQueueMaxNumberOfGranules sets the maximum number of granules that can be
active within the TDM queues
osExclusionEnable ZL5011X_TRUE to enable OS exclusion
Structure outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xWanInit(zl5011xParamsS *zl5011xParams, zl5011xWanInitS *par)
{
Uint32T loop;
zlStatusE status = ZL5011X_OK;
zl5011xBooleanE gotDevice = ZL5011X_FALSE;
/* do some parameter checking */
status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);
if ((status == ZL5011X_OK) && (par->osExclusionEnable == ZL5011X_TRUE))
{
/* get access to the device */
status = zl5011xGetDevice(zl5011xParams, ZL5011X_GET_DEVICE_TIMEOUT_MODE);
if (status == ZL5011X_OK)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -