📄 ixf6048.c
字号:
static void GetHptCounters(ushort* BaseAddress,
uint ChanNum,
boolean CntrsBuffFlag,
bb_RxHptCounters_t* pRxHpt);
static void GetMsaCounters(ushort* BaseAddress,
uint ChanNum,
boolean CntrsBuffFlag,
bb_AuPtrCounters_t* pRxMsa);
static void GetAtmCounters(ushort* BaseAddress,
uint ChanNum,
ixf6048_AtmCounters_t* pAtm);
static void GetPosCounters(ushort* BaseAddress,
uint ChanNum,
ixf6048_PosCounters_t* pPos);
#endif
/* ------------------ Test Specific Functions ------------------ */
#if 0
static void TestChanSdh(ushort* BaseAddress,
ixf6048_ChanTestCfg_t* pTestCfg);
static void TestChanPtrs(ushort* BaseAddress,
ixf6048_ChanTestCfg_t* pTestCfg);
static void TestChanAtm(ushort* BaseAddress,
ixf6048_ChanTestCfg_t* pTestCfg);
static void TestChanPos(ushort* BaseAddress,
ixf6048_ChanTestCfg_t* pTestCfg);
static bb_Error_e TestChanLoopbacks(ushort* BaseAddress,
ixf6048_ChanTestCfg_t* pTestCfg);
#endif
/* ------------------ Oht Configuration Functions ------------------ */
/* RECEIVE Side OHT Configuration */
static bb_Error_e EditRxRstCfg(ushort* BaseAddress,
uint ChanNum,
ixf6048_RxRstCfg_t* pRstCfg);
static bb_Error_e EditRxMstCfg(ushort* BaseAddress,
uint ChanNum,
ixf6048_RxMstCfg_t* pMstCfg);
static bb_Error_e EditRxMsaCfg(ushort* BaseAddress,
uint ChanNum,
ixf6048_RxMsaCfg_t* pMsaCfg);
static bb_Error_e EditRxHptCfg(ushort* BaseAddress,
uint ChanNum,
ixf6048_RxHptCfg_t* pHptCfg);
/* TRANSMIT Side OHT Configuration */
static bb_Error_e EditTxRstCfg(ushort* BaseAddress,
uint ChanNum,
ixf6048_TxRstCfg_t* pRstCfg);
static bb_Error_e EditTxMstCfg(ushort* BaseAddress,
uint ChanNum,
ixf6048_TxMstCfg_t* pMstCfg);
static bb_Error_e EditTxMsaCfg(ushort* BaseAddress,
uint ChanNum,
ixf6048_TxMsaCfg_t* pMsaCfg);
static bb_Error_e EditTxHptCfg(ushort* BaseAddress,
uint ChanNum,
ixf6048_TxHptCfg_t* pHptCfg);
/* ------------------ Local Utility Functions ---------------------*/
void SetRegBits(ushort *RegValue, ushort BitValue,
ushort BitMask, ushort Shift);
unsigned long int ReadCounterLong(ushort* BaseAddress,
ushort CounterMSBAddress,
ushort CounterLSBAddress,
uint bCountersBufferedFlag);
unsigned long int ReadCounterShort( ushort* BaseAddress,
ushort CounterAddress,
uint bCountersBufferedFlag);
/* ------------------ Utility Functions ---------------------*/
/***********************************************************************
* Procedure Name: SetRegBits
*
* Description: Set Register Bit Value using a Shift and a Mask
*
* Conditions for Use:
* Local Method Only
* Notes:
*
*
* End
**********************************************************************/
void SetRegBits(ushort *RegValue, ushort BitValue,
ushort BitMask, ushort Shift)
{
ushort value;
value = READ_FROM_HW(RegValue);
WRITE_TO_HW(RegValue, (value & ~BitMask));
value = READ_FROM_HW(RegValue);
WRITE_TO_HW(RegValue, (value | ((BitValue << Shift) & BitMask)));
#ifdef TAKEMEOUT
*RegValue &= ~BitMask;
*RegValue |= (BitValue << Shift) & BitMask;
#endif
}
/***********************************************************************
* Procedure Name: ReadCounterLong
*
* Description: Returns the Value contained in 2 Registers
*
* Conditions for Use:
* Local Method Only
* Notes:
*
*
* End
**********************************************************************/
unsigned long int ReadCounterLong(ushort* BaseAddress,
ushort CounterMSBAddress,
ushort CounterLSBAddress,
uint bCntrsBuffered)
{
unsigned long int RegValueMSB = 0;
unsigned long int RegValueLSB = 0;
unsigned long int RegValue;
if(!bCntrsBuffered)
WRITE_TO_HW((BaseAddress + CounterMSBAddress), 0);
RegValueMSB = READ_FROM_HW(BaseAddress + CounterMSBAddress);
RegValueLSB = READ_FROM_HW(BaseAddress + CounterLSBAddress);
RegValue = (RegValueMSB << 16) + RegValueLSB;
return (RegValue);
}
/***********************************************************************
* Procedure Name: ReadCounterShort
*
* Description: Returns the Value contained in a Registers
*
* Conditions for Use:
* Local Method Only
* Notes:
*
*
* End
**********************************************************************/
unsigned long int ReadCounterShort( ushort* BaseAddress,
ushort CounterAddress,
uint bCntrsBuffered)
{
ushort RegValue;
if(!bCntrsBuffered)
WRITE_TO_HW((BaseAddress + CounterAddress), 0);
RegValue = READ_FROM_HW(BaseAddress + CounterAddress);
return ((ulong)RegValue);
}
#if 0
/***********************************************************************
* Procedure Name: ixf6048_InitpAlarmCallback
*
* Description: Assign a pointer to an Alarm Callback Method.
*
* Conditions for Use:
* Called by ixf6048_InitpAlarmCallback
* Notes:
* Assign A pointer to user defined the Alarm Callback method.
*
*
* End
**********************************************************************/
bb_Error_e ixf6048_InitAlarmCallback (ixf6048_pAlarmCallback pAlarmCallbackArg)
{
/* Assign the Alarm Callback Function Pointer */
pAlarmCallback = pAlarmCallbackArg;
return bb_NO_ERROR;
}
#endif
/***********************************************************************
* Procedure Name: ixf6048_InitChip
*
* Description:Initialize Chip Data
*
* Conditions for Use:
* none
*
* Note:
* ChipData is validated by bb_InitChip:
* pChipData Is Non Null
* ChipType = 6048
* pChipCfg is non-NULL
* pAlarmCfg is non-NULL, if Polled or Interrupt-driver Alarms used
* bb_InitDriver - has completed OK
*
* Common config is validated each time - to be sure.
* If it has changed - new values used (whether consistent or not)
*
* End
**********************************************************************/
#if 0
bb_Error_e ixf6048_InitChip (bb_ChipData_t *pChipData)
{
bb_Error_e rc = bb_NO_ERROR;
ixf6048_ChipCfg_t* pChipCfg= NULL; /* -> OHT Chip cfg */
ixf6048_ChipLevelCfg_t* pChipLevelCfg=NULL; /* -> Common cfg */
ixf6048_AlarmCfg_t* pAlarmCfg= NULL; /* -> All alarm cfg */
register ushort* BaseAddress;
/* Convert each void* into valid, typed struct ptr */
pChipCfg = (ixf6048_ChipCfg_t*)(pChipData->pChipCfg);
pAlarmCfg = pChipData->pAlarmCfg;
BaseAddress = pChipData->BaseAddress;
if (pChipCfg->pChipLevelCfg)
pChipLevelCfg = pChipCfg->pChipLevelCfg;
else
{
return bb_NO_CHIP_LEVEL_CFG;
}
/* Ensure that the chip is Off-Line Prior to Changing any Global Settings */
ixf6048_SetChipOffline(pChipData);
/* Set/Clear the QMode Bit (Quad or Single Channel Mode) */
if(pChipCfg->NumChanCfg == ixf6048_eSINGLE_CHAN)
{
Ixf6048ClrBit((BaseAddress + ixf6048_GOCNF_OFFSET), ixf6048_bQUAD_MODE);
}
else
{
/* Must be Quad Channel Mode */
Ixf6048SetBit((BaseAddress + ixf6048_GOCNF_OFFSET), ixf6048_bQUAD_MODE);
}
/* Edit the Chip Level Configuration */
rc = EditChipLevelCfg(BaseAddress, ixf6048_eSIDE_BOTH, pChipLevelCfg);
if (rc != bb_NO_ERROR)
return rc;
/* Now Set the data for the specific Channel information.
All structures are assumed to have been validated */
rc = InitChanCfg(BaseAddress, ixf6048_eSIDE_BOTH, pChipCfg);
if (rc != bb_NO_ERROR)
return rc;
/* Edit alarms & create MaskedGlobalIntSources, if Alarms used */
if (pAlarmCfg) /* If alarms used */
{
AlarmsUsed = TRUE;
rc = EditAlarms(BaseAddress, ixf6048_eSIDE_BOTH, pChipCfg, pAlarmCfg);
if (rc != bb_NO_ERROR)
return rc;
}
/* Set The chip Online */
ixf6048_SetChipOnline(pChipData); /* Set OHT online */
#ifdef UNIT_TEST_6048
printf("Appl Online => SONET/SDH at 0x%x set Online\n",
pChipData->BaseAddress);
#endif
return bb_NO_ERROR;
}
/***********************************************************************
* Procedure Name: EditChipLevelCfg
*
* Description: Edit Chip Level config
*
* Conditions for Use:
* Driver is initialized OK
* pCfg is non-NULL
*
* Notes:
* This Function will write all of the Chip Level Config data
* to the Chip.
* Assumes that the passed pointers have been validated prior to this call.
* Assumes that all data has been validated prior to calling this function.
*
*
* End
**********************************************************************/
static bb_Error_e EditChipLevelCfg(ushort* BaseAddress,
ixf6048_Side_e Side,
ixf6048_ChipLevelCfg_t* pCfg)
{
bb_Error_e rc = bb_NO_ERROR;
register ushort* pReg;
register ushort RegVal =0;
register ushort macroRegVal =0;
/* PSN_TODO -- Get a copy of the Release Draft of the Spec Sheet and
-- Check for Changes in the Global Config. */
/* Configure the Byte Change updates --Used primarily for Testing */
/* PSN_ADDED B1 Release Changes Note RegVal Changes */
if (pCfg->ByteChgUpdDsbl == ixf6048_eBYTE_CHG_UPDATE_ENABLE)
Ixf6048SetBit((BaseAddress + ixf6048_MACNF_OFFSET), ixf6048_bBYTE_CHG_UPD_DSBL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -