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

📄 sysend.c

📁 vxworks mv2100 vxworks BSP
💻 C
字号:
/* sysEnd.c - System enhanced network interface support library *//* Copyright 1997-2002 Wind River Systems, Inc. *//* Copyright 1999-2000 Motorola, Inc. All Rights Reserved */#include "copyright_wrs.h"/*modification history--------------------01f,16apr02,dat  Update for T2.2 release01e,01aug00,rcs  Added DEC_USR_MII_10MB | DEC_USR_MII_HD | DEC_USR_MII_100MB                  | DEC_USR_MII_FD | DEC_USR_MII_BUS_MON macros to load string.01d,31jul00,rcs  Added MII_PHY_AUTO in sysDec21x40UpdateLoadStr() to allow                  auto-negotiation.01c,10jul00,dmw  Added DEC_USR_MII to force miiLib to use PHY address 8.01b,28may99,rhk  changed names to dec21x40, changed dec2114xSromWordRead to		 dec21140SromWordRead.  Removed motorola21143SromFix code.01a,29apr99,rhk  Initial file checkin, from MVME2400 version.*//*.SH DESCRIPTIONThis file contains the board-specific routines for the Motorola MV2100 withon-board Digital Semiconductor 21140 Ethernet adapter and the MotorolaMV2100 with the Digital Semiconductor 21143 Ethernet adapter. This file is required to update the END load string that the END driver utilizes for initial configuration. .LPSEE ALSO: endLib*/#include "vxWorks.h"#include "config.h"#include "mv2100.h" #include "vmLib.h"#include "stdio.h"#include "drv/pci/pciAutoConfigLib.h"#include "drv/pci/pciConfigLib.h"#include "drv/end/dec21x40End.h"/* defines */#define END_LD_STR_SIZE 80#define DRV_CTRL        DEC21X40_DRV_CTRL/* DEC driver user flags */#define DEC_USR_FLAGS_143 (DEC_USR_21143 | DEC_USR_MII)#define DEC_USR_FLAGS_140 (DEC_USR_BAR_RX | DEC_USR_RML | DEC_USR_CAL_08 | \			   DEC_USR_PBL_04 | DEC_USR_21140)/* Adapter-specific definitions */#define NET_END_USER_FLAGS DEC_USR_FLAGS_143/* forward declarations */STATUS sysDec21x40EnetAddrGet ( DRV_CTRL *pDrvCtrl, char *enetAdrs );/* typedefs */ /* locals */LOCAL char	endLoadStr[END_LD_STR_SIZE];	/* END load string *//* imports */IMPORT	USHORT dec21140SromWordRead ( DRV_CTRL *pDrvCtrl, UCHAR lineCnt );IMPORT  STATUS sysDynEnetFind ( int unit, UINT bus, PCI_LOC * pciLoc );IMPORT  END_TBL_ENTRY endDevTbl[];/********************************************************************************* sysDec21x40UpdateLoadStr - Update the END load string after PCI Autoconfig** This routine is to be called from sysHwInit() before the END initialization* takes place, but after the network adapter under consideration has been* configured by a mechanism such as PCI autoconfig. This routine will scan* for the ethernet device via a call to the "sysLib.c" routine * sysDynEnetFind().  If the enternet device is found, the device's * configuration space is read, and the END load string is composed from this * information. The endDevTbl entry is then updated with a pointer to the * updated load string, which resides in statically allocated data local to * this module.** Note that this routine assumes that the entry for the END device is the* first entry in the in the END device table (endDevTbl[]).** RETURNS: N/A*/ void sysDec21x40UpdateLoadStr (void)    {    int     pciBus;    int     pciDevice;    int     pciFunc;    int     ivec;     int     ilevel;    UINT32  iobaseCsr;    UINT8   intLine;    UINT32  cpuPciAddr;    STATUS  status;    PCI_LOC pciList;    int     unit = 0;    /* find the ethernet device */    if ((status = (sysDynEnetFind (unit, 0, &pciList))) == OK)	{	pciBus = pciList.bus;	pciDevice = pciList.device;	pciFunc = pciList.function;	/*	 * get the IO base address - for the Digital 21x40 the first BAR is	 * I/O and the second is memory	 */	pciConfigInLong ( pciBus, pciDevice, pciFunc,			  PCI_CFG_BASE_ADDRESS_0, &iobaseCsr );	cpuPciAddr = ((iobaseCsr & 0xfffffffe) | ISA_MSTR_IO_LOCAL);		pciConfigInByte ( pciBus, pciDevice, pciFunc,			  PCI_CFG_DEV_INT_LINE, &intLine );	ivec = (int)intLine;	ilevel = (int)intLine;					/*	 * create the config string. The format is:	 * 	 * <devAdrs>:<pciAdrs>:<ivec>:<inum>:<numrds>:<numtds>:	 * <membase>:<memsize>:<userflags>	 */	sprintf ( endLoadStr, "0x%x:0x%x:0x%x:0x%x:-1:-1:-1:0:0x%x:0x%x:0x%x:0x%x",		  cpuPciAddr, PCI2DRAM_BASE_ADRS, ivec, ilevel, 		  NET_END_USER_FLAGS,8,0,MII_PHY_AUTO |                  DEC_USR_MII_10MB | DEC_USR_MII_HD |                  DEC_USR_MII_100MB | DEC_USR_MII_FD |                  DEC_USR_MII_BUS_MON);	endDevTbl[0].endLoadString = endLoadStr;		/* If this is a dec21143, disable sleep mode */	if (NET_END_USER_FLAGS == DEC_USR_FLAGS_143)	    {	    pciConfigOutLong ( pciBus, pciDevice, pciFunc,			       PCI_CFG_21143_DA, 0 );	    }	}    return;    }/********************************************************************************* sysDec21x40EnetAddrGet - gets the ethernet address from the ROM register ** This routine reads an ethernet address from the serial ROM. It supports* legacy, ver 1/A, and 3.0 serial ROM formats.* * RETURNS: OK on success, and ERROR if the ethernet address bytes cannot be* read.*/STATUS sysDec21x40EnetAddrGet    (    DRV_CTRL *	pDrvCtrl,    char * 	enetAdrs	/* pointer to the ethernet address */     )    {    USHORT	sromData;    int		adrsOffset;    int		len;    /* Check if SROM is programmed. */    sromData = dec21140SromWordRead (pDrvCtrl, 0);    if ( sromData == 0xFFFF )         {        /* SROM is unprogrammed, get MAC address from NVRAM. */        if (( sysNvRamGet ((char *)enetAdrs, 6, 		     (int) ((int) BB_ENET - NV_BOOT_OFFSET)) ) == ERROR )        return (ERROR);        }    else	{    	sromData = dec21140SromWordRead (pDrvCtrl, 13);    	/*     	 * Set MAC address offset from the ROM format.     	 *  Legacy ROMs have ethernet address start at offset 0,     	 *  while the rest (ver 1/A and 3.0) have it at byte offset 20.     	 */    	adrsOffset = (sromData == 0xAA55) ? 0: 10;    	for (len=EADDR_LEN; len; len-=2, adrsOffset++)            {            sromData = dec21140SromWordRead (pDrvCtrl, adrsOffset);            *enetAdrs++ = MSB(sromData);            *enetAdrs++ = LSB(sromData);            }        }    return (OK);    }

⌨️ 快捷键说明

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