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

📄 sysend.c

📁 mtx604在vxworks下的bsp源代码
💻 C
字号:
/* sysEnd.c - System enhanced network interface support library *//* Copyright 1997-1999 Wind River Systems, Inc. *//* Copyright 1999 Motorola, Inc. All Rights Reserved */#include "copyright_wrs.h"/*modification history--------------------01j,26mar02,dtr  Removing compiler warnings.01i,28mar01,pch  Remove references to DEC_USR_PHY_CHK, which is no longer                 defined.01h,17jul99,dmw  added support for a secondary ethernet device.01g,17may99,tm   Added DEC_USR_PHY_CHK (poll phy via mii) to default flags01f,26apr99,srr  changed dec2114xSromWordRead to dec21140SromWordRead.01e,20apr99,srr  Remove motorola21143SromFix and change names to dec21x40.01d,15apr99,srr  Changed to WRS address space naming convention.01c,27jan99,scb	 Changed dec21140SromWordRead to dec2114xSromWordRead01b,20jan99,scb	 Adapted for the Motorola MCPN750 and MCP75001a,17jun98,tm   derived from ebsa285 sysEnd.c*//*.SH DESCRIPTIONThis file contains the board-specific routines for the Motorola MCP750 withon-board Digital Semiconductor 21140 Ethernet adapter and the MotorolaMCPN750 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 "vmLib.h"#include "stdio.h"#include "drv/pci/pciAutoConfigLib.h"#include "drv/pci/pciConfigLib.h"#include "drv/end/dec21x40End.h"/* defines */#define DEC_USR_21140   0x80000000      /* DEC 21140 part */#define DEC_USR_21143   0x40000000      /* DEC 21143 part *//* Special dec21143 configuration device driver area register */#define PCI_CFG_21143_DA        0x40#define END_LD_STR_SIZE 80#define DRV_CTRL        DEC21X40_DRV_CTRL/* DEC driver user flags */#define DEC_USR_FLAGS_143 (DEC_USR_21143)#define DEC_USR_FLAGS_140 (DEC_USR_BAR_RX | DEC_USR_RML | DEC_USR_CAL_08 | \			   DEC_USR_PBL_04 | DEC_USR_21140)#define DEC_USR_FLAGS_040 (DEC_USR_BAR_RX | DEC_USR_RML | DEC_USR_CAL_08 | \			   DEC_USR_PBL_04)/* forward declarations */STATUS sysDec21x40EnetAddrGet ( DRV_CTRL *pDrvCtrl, char *enetAdrs );/* typedefs */ /* locals *//* END load strings */LOCAL char	endLoadStr[NUM_ENET_UNITS][END_LD_STR_SIZE];/* imports */IMPORT  STATUS sysDynEnetFind (UINT bus, UINT dev, UINT func, PCI_ID * pciId); 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     curBus = PRIMARY_ENET_BUS;    int     curDev = PRIMARY_ENET_DEV;    int     curFnc = PRIMARY_ENET_FNC;    int     ivec;     int     ilevel;    UINT32  iobaseCsr;    UINT8   intLine;    UINT32  cpuPciAddr;    UINT32  flags = 0;    STATUS  status;    PCI_ID  pciId;    int	    unit = 0;    /* find the ethernet devices */    for (;unit < NUM_ENET_UNITS; unit++)        {#ifdef INCLUDE_SECONDARY_ENET        if (unit != 0)            {            curBus = SECONDARY_ENET_BUS;            curDev = SECONDARY_ENET_DEV;            curFnc = SECONDARY_ENET_FNC;            }#endif /* INCLUDE_SECONDARY_ENET */                if ((status = (sysDynEnetFind (curBus, curDev, curFnc, &pciId))) == OK)	    {	    pciBus = pciId.loc.bus;	    pciDevice = pciId.loc.device;	    pciFunc = pciId.loc.function;	    /*	     * get the IO base address - for the Digital 21x4x 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);            switch (pciId.devVend)                {                case PCI_ID_LN_DEC21040:                    flags = DEC_USR_FLAGS_040;                    break;                case PCI_ID_LN_DEC21140:                    flags = DEC_USR_FLAGS_140;                    break;                case PCI_ID_LN_DEC21143:                    flags = DEC_USR_FLAGS_143;                    break;                default:                    printf("Unsupported Ethernet device found\r\n");                    break;                }	    /*	     * create the config string. The format is:	     * 	     * <devAdrs>:<pciAdrs>:<ivec>:<inum>:<numrds>:<numtds>:	     * <membase>:<memsize>:<userflags>	     */	    sprintf ( endLoadStr[unit], "0x%x:0x%x:0x%x:0x%x:-1:-1:-1:0:0x%x",		      cpuPciAddr, PCI2DRAM_BASE_ADRS, ivec, ilevel, 		      flags );	    endDevTbl[unit].endLoadString = endLoadStr[unit];		    /* If this is a dec21143, disable sleep mode */	    if (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 */     )    {#ifndef INCLUDE_END    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);            }        }#endif    return (OK);    }

⌨️ 快捷键说明

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