📄 pirate.c
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. This software may only be used
* in accordance with the corresponding license agreement. Any unauthorized
* use, duplication, transmission, distribution, or disclosure of this
* software is expressly forbidden.
*
* This software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
*
* File: pirate.c
*
* Purpose:
*
* Author: Jenda Jao
*
* Date: 0213, 2003
*
* Functions:
*
* Revision History:
*
*/
#include "swrate.h"
#include "str.h"
#include "piportmp.h"
#include "pigencfg.h"
#include "pieeprom.h"
#include "pirate.h"
#if !defined(__SWMSG_H__)
#include "swmsg.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Macros -----------------------------*/
/*--------------------- Export Functions --------------------------*/
void PIRATE_vSetEepDefault(SRatePageCfg* pSPageCfg_Rate, BOOL bWriteDefault)
{
STR_pvMemset(pSPageCfg_Rate, 0, EEP_SIZE_RATE_CFG);
if (bWriteDefault) {
// Set value to nvram software cache.
STR_pvMemcpy(g_pu8NVRSwCache + (EEP_ADDR_RATE_CFG - NVR_ADDR_DATA_AREA_START), (PUINT8)pSPageCfg_Rate, EEP_SIZE_RATE_CFG);
}
else {
PIEEP_vSetCfgIntoEep((PUINT8)pSPageCfg_Rate, EEP_ADDR_RATE_CFG, EEP_SIZE_RATE_CFG);
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
}
UINT8 PIRATE_byOp(SRatePageCfg* pSPageCfg_Rate, UINT8 byOp)
{
UINT32 dwPhyPortMask;
UINT8 byPhyPID, byLogPortIndex=0;
for (byLogPortIndex=0; byLogPortIndex<g_byLogIdNum; byLogPortIndex++)
{
dwPhyPortMask = PIPORTMP_dwLogIdToPhyMsk(g_abyLogIdList[byLogPortIndex]);
for (byPhyPID=0; byPhyPID<SWITCH_PORT_NUM; byPhyPID++)
{
if (dwPhyPortMask & 0x00000001)
{
if (byOp == RATE_OP_EEP_TO_BUF)
{
PIEEP_vGetCfgFromEep(EEP_ADDR_RATE_CFG + byPhyPID*EEP_SIZE_RATE_PORT_BYTE_OFFSET,
EEP_SIZE_RATE_PORT_BYTE_OFFSET,
(PUINT8)(pSPageCfg_Rate->au16Rate) + byLogPortIndex*EEP_SIZE_RATE_PORT_BYTE_OFFSET);
break;
}
// buf to eep and hw
else //if ((byOp == RATE_OP_BUF_TO_HW)||(byOp == RATE_OP_BUF_TO_EEP_HW))
{
// check value valid
if (byPhyPID < SWITCH_MEGA_PORT_NUM){
if (*((PUINT16)((PUINT8)(pSPageCfg_Rate->au16Rate)+byLogPortIndex*EEP_SIZE_RATE_PORT_BYTE_OFFSET)) > 100 ||
*((PUINT16)((PUINT8)(pSPageCfg_Rate->au16Rate)+byLogPortIndex*EEP_SIZE_RATE_PORT_BYTE_OFFSET+DATA_SIZE_IN_RATE)) >100 )
return RATE_OP_BAD_VALUE;
}
else{
if (*((PUINT16)((PUINT8)(pSPageCfg_Rate->au16Rate)+byLogPortIndex*EEP_SIZE_RATE_PORT_BYTE_OFFSET)) > 1000 ||
*((PUINT16)((PUINT8)(pSPageCfg_Rate->au16Rate)+byLogPortIndex*EEP_SIZE_RATE_PORT_BYTE_OFFSET+DATA_SIZE_IN_RATE)) > 1000 )
return RATE_OP_BAD_VALUE;
}
// set to hw
SWRATE_vSetRateCtrlExt(byPhyPID, *((PUINT16)((PUINT8)(pSPageCfg_Rate->au16Rate)+byLogPortIndex*EEP_SIZE_RATE_PORT_BYTE_OFFSET)),
(*((PUINT16)((PUINT8)(pSPageCfg_Rate->au16Rate)+byLogPortIndex*EEP_SIZE_RATE_PORT_BYTE_OFFSET+DATA_SIZE_IN_RATE)))*1000 );
// save to eep
if (byOp == RATE_OP_BUF_TO_EEP_HW)
STR_pvMemcpy (g_pu8NVRSwCache + (EEP_ADDR_RATE_CFG + byPhyPID*EEP_SIZE_RATE_PORT_BYTE_OFFSET - NVR_ADDR_DATA_AREA_START),
(PUINT8)pSPageCfg_Rate->au16Rate + byLogPortIndex*EEP_SIZE_RATE_PORT_BYTE_OFFSET,
EEP_SIZE_RATE_PORT_BYTE_OFFSET);
} // end if byOp
} // end if (dwPhyPortMask & 0x00000001)
dwPhyPortMask >>= 1;
} // end for byPhyPID
} // end for byLogPortIndex
if (byOp == RATE_OP_BUF_TO_EEP_HW) {
//write into flash and update checksum (SWNVRAM_vUpdateChecksum has included in)
PIEEP_vSetCfgIntoEep (g_pu8NVRSwCache + (EEP_ADDR_RATE_CFG - NVR_ADDR_DATA_AREA_START),
EEP_ADDR_RATE_CFG,
EEP_SIZE_RATE_CFG);
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
return OP_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -