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

📄 hi3560_eth.c

📁 华为 HI3510 BOOTLOADER HIBOOT 源码包
💻 C
字号:
#include <common.h>#include <command.h>#include <config.h>#include "Hi3560_Eth.h"#include "ETH_Reg.h"#include "ETH_Struct.h"#include "ETH_TypeDef.h"#include <net.h>#include <linux-adapter.h>#if (CONFIG_COMMANDS & CFG_CMD_NET)#undef DEBUG#define MAC_LEN 6#define print_mac(mac) 	do{ int i;\	printf("MAC:  ");\	for (i = 0; i < MAC_LEN; i++)\		printf("%c%02X", i ? '-' : ' ', *(((unsigned char*)mac)+i));\	printf("\n");\	}while(0)void string_to_mac(unsigned char *mac, char* s){	int i;	char *e;        for (i=0; i<MAC_LEN; ++i) {                mac[i] = s ? simple_strtoul(s, &e, 16) : 0;                if (s) {                        s = (*e) ? e+1 : e;                }        }}void init_eth_mac_env(void){	unsigned char mac[MAC_LEN];	char* s=getenv("ethaddr");	if(s==NULL)		return;	string_to_mac(mac,s);	print_mac(mac);#define GEN_MAC(n) ((((unsigned int)mac[n*2])<<8) | mac[n*2+1])	ETH_AddMACFiltFormContent(0,GEN_MAC(2), GEN_MAC(1), GEN_MAC(0));}UINT32 ETH_FrameTransmit (In UINT16 u16FrameLen, In UINT8 *pu8FrameTransmitData) ;UINT32 ETH_FrameReceive (Out UINT8 *pu8FrameReceiveData ,Out UINT16 *pu16Length) ;	 UINT32 ETH_SoftResetPort(In UINT32 u32PortReset);static void eth_reset (void){	unsigned long t;	t = readl(0x101e0020);		t |= 0x10;	writel(t, 0x101e0020);	udelay(100);	t &= ~0x10;	writel(t, 0x101e0020);	udelay(100);}static void eth_reginit (void){     UINT32 ulIntEn = 0;	/*disable the interrupt*/	ulIntEn = *((volatile UINT32 *) ETH_GLB_REG(1));	*((volatile UINT32 *) ETH_GLB_REG(1)) = (ulIntEn & (0x0000));}void eth_halt (void){	ETH_SoftResetPort(1);}void hisf_set_mac_addr( char* addr );void SF_Init( void );int eth_init (bd_t * bd){	DECLARE_GLOBAL_DATA_PTR;	dbg_info("%s,%s,%d\n",__FILE__,__FUNCTION__,__LINE__);	eth_reset ();	eth_reginit ();	ETH_SoftResetPort(1);	ETH_Init();	ETH_SoftResetPort(0);	init_eth_mac_env();	return 0;}/* Get a data block via Ethernet */int eth_rx (void){	unsigned short rxlen=0;	dbg_info("%s,%s,%d\n",__FILE__,__FUNCTION__,__LINE__);       if( ETH_FrameReceive((UINT8 *)NetRxPackets[0],&rxlen) ==1 )	/* Pass the packet up to the protocol layers. */	NetReceive (NetRxPackets[0], rxlen);	return rxlen;}/* Send a data block via Ethernet. */int eth_send (volatile void *packet, int length){	dbg_info("%s,%s,%d\n",__FILE__,__FUNCTION__,__LINE__);	ETH_FrameTransmit((UINT16)length,(UINT8 *)packet);		return 0;}#endif	/* COMMANDS & CFG_NET */

⌨️ 快捷键说明

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