📄 pimod.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: pimod.c
*
* Purpose: Module card detecting and setting functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#include "swreg.h"
#if !defined(__SWCFG_H__)
#include "swcfg.h"
#endif
#if !defined(__NVRAM_H__)
#include "nvram.h"
#endif
#include "swport.h"
#include "pidef.h"
#include "pieeprom.h"
#include "piport.h"
#include "pimod.h"
/*--------------------- Static Definitions ------------------------*/
// spd/dup string map, mapping to g_aszSpdDpxCfg
// the first ability is default value of eeprom
//MOD_CARD_NA
UINT8 g_abySpdDupStringMap0[] = {0, 1, 2, 3, 4, 5, 6, 7};
//MOD_CARD_1000TX
UINT8 g_abySpdDupStringMap1[] = {PORT_SPDPX_AUTO, PORT_SPDPX_100M_FULL, PORT_SPDPX_100M_HALF, PORT_SPDPX_10M_FULL, PORT_SPDPX_10M_HALF};
//MOD_CARD_1000FX_DULMODE
UINT8 g_abySpdDupStringMap2[] = {PORT_SPDPX_AUTO, PORT_SPDPX_1000M_FULL, PORT_SPDPX_1000M_HALF};
//MOD_CARD_1000FX_SIGMODE(TBI)
UINT8 g_abySpdDupStringMap3[] = {PORT_SPDPX_1000M_FULL};
//MOD_CARD_100TX
UINT8 g_abySpdDupStringMap4[] = {PORT_SPDPX_AUTO, PORT_SPDPX_100M_FULL, PORT_SPDPX_100M_HALF, PORT_SPDPX_10M_FULL, PORT_SPDPX_10M_HALF};
//MOD_CARD_100FX_DULMODE
UINT8 g_abySpdDupStringMap5[] = {PORT_SPDPX_AUTO, PORT_SPDPX_100M_FULL, PORT_SPDPX_100M_HALF, PORT_SPDPX_10M_FULL, PORT_SPDPX_10M_HALF};
//MOD_CARD_100FX_SIGMODE
UINT8 g_abySpdDupStringMap6[] = {PORT_SPDPX_100M_FULL};
//MOD_CARD_MII
UINT8 g_abySpdDupStringMap7[] = {PORT_SPDPX_NA};
//MOD_CARD_1000_COMBO
UINT8 g_abySpdDupStringMap8[] = {PORT_SPDPX_AUTO, PORT_SPDPX_100M_FULL, PORT_SPDPX_100M_HALF, PORT_SPDPX_10M_FULL, PORT_SPDPX_10M_HALF};
SStringTableMap g_aSStrMapSpdDup[MOD_CARD_TYPE_NUM] = {
{0, g_abySpdDupStringMap0},
{sizeof(g_abySpdDupStringMap1), g_abySpdDupStringMap1},
{sizeof(g_abySpdDupStringMap2), g_abySpdDupStringMap2},
{sizeof(g_abySpdDupStringMap3), g_abySpdDupStringMap3},
{sizeof(g_abySpdDupStringMap4), g_abySpdDupStringMap4},
{sizeof(g_abySpdDupStringMap5), g_abySpdDupStringMap5},
{sizeof(g_abySpdDupStringMap6), g_abySpdDupStringMap6},
{sizeof(g_abySpdDupStringMap7), g_abySpdDupStringMap7},
{sizeof(g_abySpdDupStringMap8), g_abySpdDupStringMap8},
};
SGigaPortCfg g_aSPortCfgDefault[MOD_CARD_TYPE_NUM] = {
{LISTBOX_ENDIS_NA, LISTBOX_ONOFF_NA, LISTBOX_SPDDPX_NA, LISTBOX_ONOFF_NA}, // for N/A
{DEFAULT_PORT_ENABLE, 1, 0, DEFAULT_FLOW_CONTROL},
{DEFAULT_PORT_ENABLE, 1, 0, DEFAULT_FLOW_CONTROL},
{DEFAULT_PORT_ENABLE, 0, 0, DEFAULT_FLOW_CONTROL},
{DEFAULT_PORT_ENABLE, 1, 0, DEFAULT_FLOW_CONTROL},
{DEFAULT_PORT_ENABLE, 1, 0, DEFAULT_FLOW_CONTROL},
{DEFAULT_PORT_ENABLE, 0, 0, DEFAULT_FLOW_CONTROL},
{DEFAULT_PORT_ENABLE, 1, 0, DEFAULT_FLOW_CONTROL},
{DEFAULT_PORT_ENABLE, 1, 0, DEFAULT_FLOW_CONTROL},
};
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
#define s_vSetModuleType(byModuleCardId, byType) NVRAM_bWriteU8(EEP_ADDR_MOD_CARD_TYPE + byModuleCardId, byType)
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
void PIMOD_vDetectModuleCard(void)
{
UINT8 byModuleCardId, byModuleType;
BOOL bUpdateChecksum = 0;
// Scan all module card.
// the order of getting module type = eeprom -> pin define -> strapping
for (byModuleCardId = 0; byModuleCardId < SWITCH_GIGA_PORT_NUM; byModuleCardId++) {
byModuleType = SWMODL_byDetectModuleType(byModuleCardId);
// According module phisical type, compare if module card change.
if (PIMOD_byGetModuleType(byModuleCardId) != byModuleType) {
// If Module card change, write back new phisical type value and
// set port to default by physical type.
s_vSetModuleType(byModuleCardId, byModuleType);
PIEEP_vSetCfgIntoEep((PUINT8)(g_aSPortCfgDefault + byModuleType),
EEP_ADDR_GIGA_PORT_CFG + EEP_SIZE_GIGA_PORT_OFFSET * byModuleCardId,
EEP_SIZE_GIGA_PORT_OFFSET);
bUpdateChecksum = 1;
}
}
if (bUpdateChecksum)
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
UINT8 PIMOD_byGetModuleType(UINT8 byModuleCardId)
{
UINT8 byType = MOD_CARD_NA;
NVRAM_bReadU8(EEP_ADDR_MOD_CARD_TYPE + byModuleCardId, &byType);
return byType;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -