📄 sysfei82557end.c
字号:
/* sysFei82557End.c - system configuration module for fei82557End */ /* Copyright 1984 - 1999 Wind River Systems, Inc. *//* Copyright 1999-2001 Motorola, Inc. All Rights Reserved */ /*modification history--------------------01j,07mar02,kab SPR 70817: *EndLoad returns NULL on failure01i,17jan02,dtr Fixing diab warnings.01h,06dec01,dtr Mod to distinguish between SECONDARY and TERTIARY_ENET.01g,06dec01,dtr Fix for CARRIER_1 board.01f,15oct01,scb shared memory fixes for new prpmc800 window mapping.01e,28sep01,srr Add PrPMC Adapter-specific definitions.01d,10may01,pch Add IMPORT declaration for sysUsDelay() to fix compiler warning; use macro for PCI device ID.01c,28jan00,jkf enabling 557 interrupt after connecting ISR, SPR#30132.01b,29apr99,jkf merged with T201a,01apr99,jkf written *//*DESCRIPTIONThis is the WRS-supplied configuration module for the VxWorks fei82557End (fei) END driver. It performs the dynamic parameterization of the fei82557End driver. This technique of 'just-in-time' parameterization allows driver parameter values to be declared as something other than static strings. */ /* includes */#include "vxWorks.h"#include "stdio.h"#include "stdlib.h"#include "string.h"#include "end.h"#include "config.h"#include "prpmc800.h" /* PCI_ID_I82559ER *//* mattr */#include "logLib.h"#include "drv/end/fei82557End.h" #if (defined(INCLUDE_FEI_END) && defined (INCLUDE_NETWORK) \ && defined (INCLUDE_END))END_OBJ * sysFei82557EndLoad ( char * pParamStr, /* ptr to initialization parameter string */ void * unused /* unused optional argument */ ); /* imports */IMPORT FUNCPTR feiEndIntConnect;IMPORT FUNCPTR feiEndIntDisconnect;IMPORT END_OBJ * fei82557EndLoad (char *);IMPORT void sysUsDelay (UINT32);IMPORT BOOL sysMonarchMode; /* TRUE if Monarch *//* defines */#ifdef I82557_DEBUG# undef LOCAL# define LOCAL#endif /* I82557_DEBUG */ /* Intel EtherExpress PRO100B LAN Adapter type */ #define TYPE_PRO100B_PCI 1 /* Intel EtherExpress PRO-100B 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 /* Adapter-specific definitions */#if (CARRIER_TYPE != PRPMC_G) && defined(INCLUDE_SECONDARY_ENET)# define NUM_END_DEVICES 2 #else# define NUM_END_DEVICES 1#endif /* (CARRIER_TYPE != PRPMC_G) && defined(INCLUDE_SECONDARY_ENET) */#if (CARRIER_TYPE == PRPMC_CARRIER_1) && defined(INCLUDE_TERTIARY_ENET)# undef NUM_END_DEVICES# define NUM_END_DEVICES 3 #endif /* (CARRIER_TYPE == PRPMC_CARRIER_1) && defined(INCLUDE_TERTIARY_ENET) */ /* 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 */ 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 UINT32 sys557LocalToPciBusAdrs (int unit, UINT32 adrs);LOCAL UINT32 sys557PciBusToLocalAdrs (int unit, UINT32 adrs);LOCAL UINT32 feiUnits; /* number of FEIs we found */LOCAL BOOL sys557PciInitdone=FALSE; LOCAL FEI_RESOURCE feiResources [FEI_MAX_UNITS] = { {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, {UNKNOWN}, UNKNOWN, {UNKNOWN}, NULL, UNKNOWN, UNKNOWN, UNKNOWN}, {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, {UNKNOWN}, UNKNOWN, {UNKNOWN}, NULL, UNKNOWN, UNKNOWN, UNKNOWN}, {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, {UNKNOWN}, UNKNOWN, {UNKNOWN}, NULL, UNKNOWN, UNKNOWN, UNKNOWN}, {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, {UNKNOWN}, UNKNOWN, {UNKNOWN}, NULL, UNKNOWN, UNKNOWN, UNKNOWN}, }; LOCAL const char *phys[] = { "None", "i82553-A/B", "i82553-C", "i82503", "DP83840", "80c240", "80c24", "unknown" }; enum phy_chips { NonSuchPhy=0, I82553AB, I82553C, I82503, DP83840, S80C240, S80C24, UndefinedPhy }; LOCAL const char *connectors[] = {" RJ45", " BNC", " AUI", " MII"};/* globals */ /* i82559 buffer in low memory */UCHAR lowMemBufFei[0x50000 + PPC_PAGE_SIZE];#ifdef INCLUDE_SECONDARY_ENETUCHAR lowMemBufFei1[0x50000 + PPC_PAGE_SIZE];# ifdef INCLUDE_TERTIARY_ENETUCHAR lowMemBufFei2[0x50000 + PPC_PAGE_SIZE];# endif #endif /* INCLUDE_SECONDARY_ENET *//* forward declarations */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);LOCAL STATUS sys557IntDisable (int unit);LOCAL STATUS sys557IntEnable (int unit);void sys557PciInit (void);void sys557Show(int unit /* unit number */);STATUS sys557Init(int unit, FEI_BOARD_INFO *pBoard);/******************************************************************************** sysFei82557EndLoad - load fei82557 (fei) device.** This routine loads the fei device with initial parameters. ** RETURNS: pointer to END object or NULL.** 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>" * */ char * cp; char paramStr [END_INIT_STR_MAX]; /* from end.h */ END_OBJ * pEnd; /* read PCI configuration and initialize endDevices[] */#ifndef SLAVE_OWNS_ETHERNET if (!sysMonarchMode) return ((END_OBJ *)NULL);#endif /* SLAVE_OWNS_ETHERNET */ if (sys557PciInitdone == FALSE) { sys557PciInit(); sys557PciInitdone = TRUE; } 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); /* align to cache boundary */ if(strcmp(pParamStr,"0:")==0) { /* align to cache boundary */ sprintf (cp, "0x%x:0x%x:0x20:0x20:0x0", ENET_BUF_ALIGN (lowMemBufFei), sizeof(lowMemBufFei) - (ENET_BUF_ALIGN (lowMemBufFei) - (UINT32)(lowMemBufFei))); }#ifdef INCLUDE_SECONDARY_ENET else if(strcmp(pParamStr,"1:")==0) { /* align to cache boundary */ sprintf (cp, "0x%x:0x%x:0x20:0x20:0x0", ENET_BUF_ALIGN (lowMemBufFei1), sizeof(lowMemBufFei1) - (ENET_BUF_ALIGN (lowMemBufFei1) - (UINT32)(lowMemBufFei1))); }#ifdef INCLUDE_TERTIARY_ENET else if(strcmp(pParamStr,"2:")==0) { /* align to cache boundary */ sprintf (cp, "0x%x:0x%x:0x20:0x20:0x0", ENET_BUF_ALIGN (lowMemBufFei2), sizeof(lowMemBufFei2) - (ENET_BUF_ALIGN (lowMemBufFei2) - (UINT32)(lowMemBufFei2))); }#endif#endif else logMsg("Bad Unit.\n",0,0,0,0,0,0); if ((pEnd = fei82557EndLoad (paramStr)) == (END_OBJ *)NULL) { printf ("Error: device failed fei82557EndLoad routine.\n"); } } 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; int pciBus[NUM_END_DEVICES]; int pciDevice[NUM_END_DEVICES]; int unit; UINT32 membaseCsr; UINT32 iobaseCsr; UINT32 membaseFlash; char irq; int no_of_feiUnits; feiUnits=0; unit=0; pciBus[0]=0; /* limit search to bus 0 */ #if (CARRIER_TYPE == PRPMC_CARRIER_1) pciBus[0] = PCI_CARRIER_1_PRI_BUS;#endif /* (CARRIER_TYPE == PRPMC_CARRIER_1) */ for (unit=0;unit < NUM_END_DEVICES; unit++) { if (unit==0) { if (sysMonarchMode) pciDevice[0] = PCI_IDSEL_PRI_LAN; #if (CARRIER_TYPE == PRPMC_BASE) else pciDevice[0] = PCI_IDSEL_SLAVE_LAN; #endif /* (CARRIER_TYPE == PRPMC_BASE) */ }#ifdef INCLUDE_SECONDARY_ENET if (unit == 1) {# if (CARRIER_TYPE==PRPMC_BASE) /* not fei */ unit++; feiUnits--;# else# if (CARRIER_TYPE==PRPMC_CARRIER_1) pciBus[feiUnits] = 1;# endif pciDevice[feiUnits] = PCI_IDSEL_SEC_LAN;# endif }#if (CARRIER_TYPE == PRPMC_CARRIER_1)# ifdef INCLUDE_TERTIARY_ENET if (unit == 2) { pciDevice[feiUnits] = PCI_IDSEL_TER_LAN; pciBus[feiUnits] = 1; }# endif /* INCLUDE_TERTIARY_ENET */#endif /* (CARRIER_TYPE == PRPMC_CARRIER_1) */#endif /* INCLUDE_SECONDARY_ENET */ feiUnits++; } no_of_feiUnits = feiUnits; for(feiUnits=0;feiUnits<no_of_feiUnits;feiUnits++) { pReso = &feiResources [feiUnits]; pReso->pciBus = pciBus[feiUnits]; pReso->pciDevice = pciDevice[feiUnits]; pReso->pciFunc = 0; /* get 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=no_of_feiUnits; /* specify the interrupt connect/disconnect routines to be used */ feiEndIntConnect = (FUNCPTR) intConnect; feiEndIntDisconnect = (FUNCPTR) intDisable; } /********************************************************************************* 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.** This routine returns the interrupt level the <pIntLvl> parameter.** RETURNS: OK or ERROR if the adapter could not be prepared for initialization.*/ STATUS sys557Init ( int unit, /* unit number */ FEI_BOARD_INFO *pBoard /* board information for the end driver */ ) { FEI_RESOURCE *pReso = &feiResources [unit]; UINT16 sum = 0; int ix; int iy; UINT16 value;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -