⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storage.c

📁 这是单板上DPRAM的驱动程序
💻 C
字号:
/* @(#) pSOSystem PowerPC/V2.2.2*/
/***********************************************************************/
/*                                                                     */
/*   MODULE:  bsps/fuc8xx/src/storage.c                                */
/*   DATE:    98/07/03                                                 */
/*   AUTHOR:  Shan Zhengguang                                          */
/*   PURPOSE: Functions to store and retrieve configuration data to    */
/*            and from RAM (NO NVR) storage.                           */
/*                                                                     */
/*---------------------------------------------------------------------*/
/*                                                                     */
/*         Copyright 1998 -  1999, ZHONGXING TELECOM CO.,LTD.          */
/*                      ALL RIGHTS RESERVED                            */
/*                                                                     */
/*---------------------------------------------------------------------*/
/*                                                                     */
/***********************************************************************/
#include "bsp.h"
#include <bspfuncs.h>
#include <sysvars.h>

unsigned char *nvram;

/***********************************************************************/
/* Local Functions                                                     */
/***********************************************************************/

/***********************************************************************/
/*  StorageRead: Read configuration data from EEPROM                   */
/*                                                                     */
/*  INPUTS: nbytes - number of bytes to read                           */
/*          *Start - starting address                                  */
/*          *buff  - pointer to buffer to read into                    */
/*                                                                     */
/***********************************************************************/
void StorageRead(unsigned int nbytes, void *Start, void *buff)
{
UCHAR *dest, *src;
UINT i;
dest  = (UCHAR *)buff;
nvram = (UCHAR *)(BSP_RAM_BASE + 0x4000);
src   = (UCHAR *)((long)nvram + (long)Start);

for (i = 0; i < nbytes; i++)
    *dest++ = *src++;
#if 0
    {/* modify ip address */
	int temp=((getBrdNum()&0x08)>>3)*100
	       +((getBrdNum()&0xc0)>>6)*10
	       +((getBrdNum()&0x30)>>4)*2
               +(getBrdNum()&0x1);
	if(temp<256 && temp>0)
	{
		((struct BspParms *)(BspVars))->Eth05=temp;
		SysVars.Lan1IP=0x8a010a00+temp;
	}
    }/* modify ip address end */
#endif
}

/***********************************************************************/
/* StorageWrite: Write configuration data to EEPROM                    */
/*                                                                     */
/*  INPUTS: nbytes - number of bytes to write                          */
/*          *Start - starting offset to write to (0 - 255)             */
/*          *buff  - pointer to buffer to write from                   */
/*                                                                     */
/*  NOTE: The 256th byte in the EEPROM is a special case.  It is used  */
/*        for write protection.  We never program it.                  */
/*                                                                     */
/***********************************************************************/
void StorageWrite(unsigned int nbytes, void *Start, void *buff)
{
UCHAR *dest, *src;
UINT i;

src   = (UCHAR *)buff;
nvram = (UCHAR *)(BSP_RAM_BASE + 0x4000);
dest  = (UCHAR *)((long)nvram + (long)Start);

for (i = 0; i < nbytes; i++)
    *dest++ = *src++;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -