📄 pifwupdt.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: pifwupdt.c
*
* Purpose:
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#include "swmsg.h"
#include "pidef.h"
#if !defined(__SWPKT_H__)
#include "swpkt.h"
#endif
#if !defined(__NETIF_H__)
#include "netif.h"
#endif
#include "pifwupdt.h"
/*--------------------- Static Definitions ------------------------*/
#define DOWNLOAD_BUFFER_SIZE ASIC_ROM_0_SIZE // 4M bytes
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
static UINT8 sg_au8DownloadBuffer[DOWNLOAD_BUFFER_SIZE];
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
void PIFWUPDT_vInitPage(SFwUpdtPageCfg* pSPageCfg_FwUpdt)
{
SFwUpdtFlshCfg sCfg;
PIEEP_vGetCfgFromEep(NVR_ADDR_FWUPDT, NVR_SIZE_FWUPDT, (PUINT8)&sCfg);
STR_vCvtIpValtoStr(pSPageCfg_FwUpdt->aszTftpServeIp, sCfg.u32TftpSrvIp);
STR_pszStrcpy(pSPageCfg_FwUpdt->aszTftpFilename, sCfg.aszTftpFilename);
}
void PIFWUPDT_vSetCfgToHW(SFwUpdtFlshCfg* psFwUpdtCfg)
{
g_u32TftpServeIpAddr = psFwUpdtCfg->u32TftpSrvIp;
STR_pszStrcpy(g_aszTftpFilename, psFwUpdtCfg->aszTftpFilename);
}
void PIFWUPDT_vSetHwFromEep(void)
{
SFwUpdtFlshCfg sCfg;
PIEEP_vGetCfgFromEep(NVR_ADDR_FWUPDT, NVR_SIZE_FWUPDT, (PUINT8)&sCfg);
PIFWUPDT_vSetCfgToHW(&sCfg);
}
void PIFWUPDT_vSetEepDefault(BOOL bWriteDefault)
{
SFwUpdtFlshCfg sCfg;
sCfg.u32TftpSrvIp = DEFAULT_TFTP_SRV_IP_ADDR;
STR_pszStrcpy(sCfg.aszTftpFilename, DEFAULT_TFTP_FILENAME);
if (bWriteDefault) {
// Set value to nvram software cache
STR_pvMemcpy(g_abyNVRSwCache + (NVR_ADDR_FWUPDT - NVR_ADDR_IPCONF), (PUINT8)&sCfg, NVR_SIZE_FWUPDT);
}
else {
PIEEP_vSetCfgIntoEep((PUINT8)&sCfg, NVR_ADDR_FWUPDT, NVR_SIZE_FWUPDT);
}
}
UINT8 PIFWUPDT_bySavePage(SFwUpdtPageCfg* pSPageCfg_FwUpdt)
{
SFwUpdtFlshCfg sCfg;
if (0 == (sCfg.u32TftpSrvIp = STR_dwCvtIpStrtoVal(pSPageCfg_FwUpdt->aszTftpServeIp)))
return FWUPDT_OP_INVALID_IP;
STR_pszStrcpy(sCfg.aszTftpFilename, pSPageCfg_FwUpdt->aszTftpFilename);
PIEEP_vSetCfgIntoEep((PUINT8)&sCfg, NVR_ADDR_FWUPDT, NVR_SIZE_FWUPDT);
PIFWUPDT_vSetCfgToHW(&sCfg);
return OP_OK;
}
BOOL PIFWUPDT_bFirmwareUpdate (UINT32 u32SvrIpAddr, PSTR pszFileName, UINT uStopState)
{
// init tftp state data structure
g_TftpState.pu8TftpBuffer = sg_au8DownloadBuffer;
g_TftpState.u32MaxBufSize = DOWNLOAD_BUFFER_SIZE;
g_TftpState.u32SvrIpAddr = u32SvrIpAddr;
STR_iStrcpy(g_TftpState.acFileName, pszFileName);
g_TftpState.uStateToStop = uStopState;
// set state to start
g_TftpState.uState = TFTP_STA_START;
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -