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

📄 sysfei82557end.c

📁 WINDRIVER SBC7410 BSP
💻 C
📖 第 1 页 / 共 2 页
字号:
/* sysFei82557End.c - system configuration module for fei82557End *//* Copyright 2002 Wind River Systems, Inc. *//*modification history--------------------01d,06jan03,dee  cleanup01c,08aug01,g_h  add support for the PCI expand board.01b,11jul01,g_h  add support for Intel PRO100S NIC01a,01apr01,g_h  written.*//*DESCRIPTIONThis is the WRS-supplied configuration module for the VxWorksfei82557End (fei) END driver.  It performs the dynamic parameterizationof the fei82557End driver.  This technique of 'just-in-time'parameterization allows driver parameter values to be declaredas something other than static strings.*/#if (defined(INCLUDE_FEI82557END) && defined (INCLUDE_NETWORK) && defined (INCLUDE_END))/* includes */#include "vxWorks.h"#include "stdio.h"#include "stdlib.h"#include "string.h"#include "end.h"#include "config.h"#include "drv/end/fei82557End.h"        #undef  FEI_MAX_UNITS#define FEI_MAX_UNITS 1         /* only support one unit *//* imports */IMPORT FUNCPTR   feiEndIntConnect;IMPORT FUNCPTR   feiEndIntDisconnect;IMPORT END_OBJ * fei82557EndLoad (char *);/* defines */#undef  PRO100B_PCI_VENDOR_ID#define PRO100B_PCI_VENDOR_ID   0x8086  /* PCI vendor ID */#undef  PRO100B_PCI_DEVICE_ID#define PRO100B_PCI_DEVICE_ID   0x1030  /* PCI device ID */#undef  PRO100S_PCI_VENDOR_ID#define PRO100S_PCI_VENDOR_ID   0x8086  /* PCI vendor ID */#undef  PRO100S_PCI_DEVICE_ID#define PRO100S_PCI_DEVICE_ID	0x1229  /* PCI device ID *//* Intel EtherExpress PRO100B LAN Adapter type */#define TYPE_PRO100B_PCI        1       /* Intel EtherExpress PRO-100B PCI */#define TYPE_PRO100S_PCI        2       /* Intel EtherExpress PRO-100S PCI *//* EEPROM control bits */#define EE_SK           0x01            /* shift clock */#define EE_CS           0x02            /* chip select */#define EE_DI           0x04            /* chip data in */#define EE_DO           0x08            /* chip data out *//* EEPROM opcode */#define EE_CMD_WRITE    0x05            /* WRITE opcode, 101 */#define EE_CMD_READ     0x06            /* READ  opcode, 110 */#define EE_CMD_ERASE    0x07            /* ERASE opcode, 111 *//* EEPROM misc. defines */#define EE_CMD_BITS     3               /* number of opcode bits */#define EE_ADDR_BITS    6               /* number of address bits */#define EE_DATA_BITS    16              /* number of data bits */#define EE_SIZE         0x40            /* 0x40 words */#define EE_CHECKSUM     0xbaba          /* checksum *//* unknown values */#define UNKNOWN         -1/* FEI driver access routines *//* typedefs */typedef struct feiResource              /* FEI_RESOURCE */    {    UINT32      membaseCsr;             /* Base Address Register 0 */    UINT32      iobaseCsr;              /* Base Address Register 1 */    UINT32      membaseFlash;           /* Base Address Register 2 */    char        irq;                    /* Interrupt Request Level */    UINT32      configType;             /* type of configuration - unused */    UINT32      boardType;              /* type of LAN board this unit is */    UINT32      pciBus;                 /* PCI Bus number */    UINT32      pciDevice;              /* PCI Device number */    UINT32      pciFunc;                /* PCI Function number */    UINT32      eeprom[0x40];           /* Ethernet Address of this unit */    INT32       timeout;                /* timeout for the self-test */    INT32       str[6];                 /* storage for the self-test result */    volatile INT32 *pResults;           /* pointer to the self-test result */    UINT        memLength;              /* required memory size */    UINT        initialStateMask;       /* mask parameter to vmStateSet */    UINT        initialState;           /* state parameter to vmStateSet */    } FEI_RESOURCE;/* locals */LOCAL STATUS sys557IntEnable(int unit);LOCAL STATUS sys557IntDisable(int unit);LOCAL UINT32 sys557LocalToPciBusAdrs (int unit, UINT32 adrs);LOCAL UINT32 sys557PciBusToLocalAdrs (int unit, UINT32 adrs);LOCAL UINT32 feiUnits;                  /* number of FEIs we found */LOCAL FEI_RESOURCE feiResources [FEI_MAX_UNITS] ={    {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,        UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, {UNKNOWN}, UNKNOWN, {UNKNOWN}, NULL,        UNKNOWN, UNKNOWN, UNKNOWN}};enum phy_chips    {    NonSuchPhy=0, I82553AB, I82553C, I82503,    DP83840, S80C240, S80C24, I82555, DP83840A=10, UndefinedPhy    };LOCAL char isDeviceFound;/* forward declarations */LOCAL UINT16    sys557eepromRead (int unit, int location);LOCAL UINT16    sys557mdioRead   (int unit, int phyId, int location);LOCAL UINT16    sys557mdioWrite  (int unit, int phyId, int location, int value);LOCAL int       sys557IntAck     (int unit);/***************************************************************************    ** sysDelay - delay for a moment** This routin delay for a moment** NOMANUAL*/void sysDelay     (    void    )    {    int i;    for ( i=0;i<0x10;i++ );    EIEIO;    }/***************************************************************************    ** sysFei82557EndLoad - load fei82557 (fei) device.** This routine loads the fei device with initial parameters.** RETURNS: pointer to END object or ERROR.** SEE ALSO: fei82557EndLoad()*/END_OBJ * sysFei82557EndLoad    (    char *  pParamStr,  /* ptr to initialization parameter string */    void *  unused      /* unused optional argument */    )    {    /*     * The fei82557End driver END_LOAD_STRING should be:     * "<memBase>:<memSize>:<nTfds>:<nRfds>:<flags>:<offset>"     */    char *  cp;    char    paramStr [END_INIT_STR_MAX];   /* from end.h */    END_OBJ *   pEnd;    if ( !isDeviceFound )        {        pEnd = 0;        return(pEnd);        }    if ( strlen (pParamStr) == 0 )        {        /*         * muxDevLoad() calls us twice.  If the string is         * zero length, then this is the first time through         * this routine, so we just return.         */        pEnd = fei82557EndLoad (pParamStr);        }    else        {        /*         * On the second pass though here, we actually create         * the initialization parameter string on the fly.         * Note that we will be handed our unit number on the         * second pass through and we need to preserve that information.         * So we use the unit number handed from the input string.         */        cp = strcpy (paramStr, pParamStr); /* cp points to paramStr */        /* Now, we advance cp, by finding the end the string */        cp += strlen (paramStr);        /* finish off the initialization parameter string */        sprintf (cp, "-1:0x00:0x20:0x20:0x00:2");        if ( (pEnd = fei82557EndLoad (paramStr)) == NULL )            {            printf ("Error: device failed fei82557EndLoad routine.\n");            taskDelay(sysClkRateGet()*1);            }        }    return(pEnd);    }/***************************************************************************** sys557PciInit - prepare LAN adapter for 82557 initialization** This routine find out the PCI device, and map its memory and IO address.* It must be done prior to initializing the 82557, sys557Init().  Also* must be done prior to MMU initialization, usrMmuInit().** RETURNS: N/A*/void sys557PciInit     (    void    )    {    FEI_RESOURCE * pReso; /* pointer to fei information */    int     pciBus;       /* pci bus number */    int     pciDevice;    /* pci device number */    int     pciFunc;      /* pci device function number */    int     unit;         /* current fei unit number */    BOOL    duplicate;    /* TRUE if this is a device listed twice */    UINT32  membaseCsr;   /* base address of device memory space */    UINT32  iobaseCsr;    /* base address of device io space */    UINT32  membaseFlash; /* base address of device flash space */    int     ix;           /* general index */    char    irq;          /* device pci irq */    isDeviceFound = 0;    /* find all fei devices */    for ( unit = 0; unit < FEI_MAX_UNITS; unit++ )        {        if ( pciFindDevice (PRO100B_PCI_VENDOR_ID,                             PRO100B_PCI_DEVICE_ID,                             unit,                             &pciBus,                             &pciDevice,                             &pciFunc) != OK )            {            if ( pciFindDevice (PRO100S_PCI_VENDOR_ID,                                 PRO100S_PCI_DEVICE_ID,                                 unit,                                 &pciBus,                                 &pciDevice,                                 &pciFunc) != OK )                continue;            }        isDeviceFound = 1;        /* check for duplicate device */        pReso     = &feiResources [0];        duplicate = FALSE;        for ( ix = 0; ix < FEI_MAX_UNITS; ix++, pReso++ )            {            if ( (ix != unit) && (pReso->pciBus == pciBus) &&                 (pReso->pciDevice == pciDevice) && (pReso->pciFunc == pciFunc) )                duplicate = TRUE;            }        if ( duplicate )            continue;        /* record basic pci info */        pReso            = &feiResources [unit];        pReso->pciBus    = pciBus;        pReso->pciDevice = pciDevice;        pReso->pciFunc   = pciFunc;        /* ask device its memory base address and IO base address */        pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc,                          PCI_CFG_BASE_ADDRESS_0, &membaseCsr);        pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc,                          PCI_CFG_BASE_ADDRESS_1, &iobaseCsr);        pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc,                          PCI_CFG_BASE_ADDRESS_2, &membaseFlash);        pciConfigInByte (pReso->pciBus, pReso->pciDevice, pReso->pciFunc,                          PCI_CFG_DEV_INT_LINE, &irq);        membaseCsr   &= PCI_MEMBASE_MASK;        iobaseCsr    &= PCI_IOBASE_MASK;        membaseFlash &= PCI_MEMBASE_MASK;        /* over write the resource table with read value */        pReso->membaseCsr   = membaseCsr;        pReso->iobaseCsr    = iobaseCsr;        pReso->membaseFlash = membaseFlash;        pReso->irq          = irq;        /* enable mapped memory and IO addresses */        pciConfigOutWord (pReso->pciBus, pReso->pciDevice, pReso->pciFunc,                          PCI_CFG_COMMAND, PCI_CMD_IO_ENABLE |                          PCI_CMD_MEM_ENABLE | PCI_CMD_MASTER_ENABLE);        feiUnits++;        }    /* specify the interrupt connect/disconnect routines to be used */    feiEndIntConnect = (FUNCPTR) intConnect;    feiEndIntDisconnect = NULL;    }/***************************************************************************** sys557Init - prepare LAN adapter for 82557 initialization** This routine is expected to perform any adapter-specific or target-specific* initialization that must be done prior to initializing the 82557.** The 82557 driver calls this routine from the driver attach routine before* any other routines in this library.*

⌨️ 快捷键说明

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