📄 sweep.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: sweep.c
*
* Purpose: EEPROM hardware accessing functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__PLATFORM_H__)
#include "platform.h"
#endif
#if !defined(__SWITCH_H__)
#include "switch.h"
#endif
#if !defined(__SWREG_H__)
#include "swreg.h"
#endif
#if !defined(__SWEEP_H__)
#include "sweep.h"
#endif
/*--------------------- Static Definitions ------------------------*/
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
//lucas
/************************************************************************
* EEPROM Wait Busy
************************************************************************/
static void
s_vEepromBusyWait(void)
{
UINT8 u8RegData;
do
{
SWREG_vReadU8(INITCTL_EEP_STATUS, &u8RegData);
} while ((u8RegData & EEP_STATUS_BUSY) == EEP_STATUS_BUSY);
} /* end s)vEepromBusyWait */
BOOL SWEEP_bReadU8(UINT16 u16Addr, PUINT8 pu8Data)
{
// protect eeprom data reg from being ruined before using it
PLAT_vCpuCriticalEnter();
// Set address
SWREG_vWriteU8(INITCTL_EEP_ADDR, (UINT8)(u16Addr));
// Set device id and issue read command
// (0~255 => dev id = 0; 256~511 => dev id = 1....)
SWREG_vWriteU8(INITCTL_EEP_CMD, ((u16Addr >> 7) & EEP_CMD_DEV_ID_MSK) | EEP_CMD_RD );
// loop to wait for EEPROM operation complete
#if (0)
if (!SWREG_bWaitStatus(INITCTL_EEP_STATUS, EEP_STATUS_BUSY, FALSE))
{
PLAT_vCpuCriticalExit();
return FALSE;
}
#else
s_vEepromBusyWait();
#endif
// get data and return true
SWREG_vReadU8(INITCTL_EEP_RD_DATA, pu8Data);
PLAT_vCpuCriticalExit();
return TRUE;
}
BOOL SWEEP_bWriteU8(UINT16 u16Addr, UINT8 u8Data)
{
// protect eeprom data reg from being ruined before using it
PLAT_vCpuCriticalEnter();
// Set address
SWREG_vWriteU8(INITCTL_EEP_ADDR, (UINT8)(u16Addr));
// Set written value
SWREG_vWriteU8(INITCTL_EEP_WR_DATA, u8Data);
// Set device id and issue write command
// (0~255 => dev id = 0; 256~511 => dev id = 1....)
SWREG_vWriteU8(INITCTL_EEP_CMD, ((u16Addr >> 7) & EEP_CMD_DEV_ID_MSK) | EEP_CMD_WR );
// loop to wait for EEPROM operation complete
#if (0)
if (!SWREG_bWaitStatus(INITCTL_EEP_STATUS, EEP_STATUS_BUSY, FALSE))
{
PLAT_vCpuCriticalExit();
return FALSE;
}
#else
s_vEepromBusyWait();
#endif
PLAT_vCpuCriticalExit();
return TRUE;
}
BOOL SWEEP_bVerifyCheckSum (UINT16 wStartAddr, UINT16 wBlockSize)
{
UINT8 bySromPtr;
UINT8 byCheckSum = 0;
UINT16 ii;
for (ii = wStartAddr; ii < wStartAddr+wBlockSize; ii++) {
SWEEP_bReadU8(ii, &bySromPtr);
byCheckSum ^= bySromPtr;
}
if (byCheckSum == 0)
return TRUE;
else
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -