📄 sysend.c
字号:
/* sysEnd.c - system configuration module for END devices */ /* Copyright 1984-2000 Wind River Systems, Inc. *//* Copyright 1999-2000 Motorola, Inc., All Rights Reserved */ /*modification history--------------------01a,30nov00,djs Written (from version 01d of mv5100/sysEnd.c)*//*DESCRIPTIONThis is the WRS-supplied configuration module for the VxWorks END drivers. It performs the dynamic parameterization specific to the End drivers. This technique of 'just-in-time' parameterization allows driver parameter values to be declared as any other defined constants rather than as static strings. */ #if (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"#ifdef INCLUDE_DEC_END# include "drv/end/dec21x40End.h" #endif /* INCLUDE_DEC_END */#include "./pci/pciAutoConfigLib.h"#include "drv/pci/pciConfigLib.h"/* defines */#ifdef INCLUDE_DEC_END/* DEC driver user flags */# define DEC_USR_FLAGS_143 (DEC_USR_21143 | DEC_USR_PHY_CHK)# define DEC_USR_FLAGS_140 (DEC_USR_BAR_RX | DEC_USR_RML | DEC_USR_CAL_08 | \ DEC_USR_PBL_04 | DEC_USR_21140 | 0x00800000)/* Adapter-specific definitions */# define NET_END_USER_FLAGS DEC_USR_FLAGS_143#endif /* INCLUDE_DEC_END */#ifdef INCLUDE_SECONDARY_ENET# define NUM_END_DEVICES 2 #else# define NUM_END_DEVICES 1#endif /* INCLUDE_SECONDARY_ENET */ /* forward declarations */STATUS sysPciInit (void);/* locals */typedef struct endInfo { PCI_ID pciId; UINT32 bar0Csr; UINT32 bar1Csr; UINT8 irqnum; UINT8 irqvec; } endInfoType; LOCAL endInfoType endDevices[NUM_END_DEVICES]; LOCAL char dbgMsg[100];LOCAL initUnit = 0; /* initialization unit - not sent by end interface *//* imports */#ifdef INCLUDE_DEC_ENDIMPORT END_OBJ* dec21x40EndLoad (char *);#endif /* INCLUDE_DEC_END */IMPORT END_OBJ* i82559DrvEndLoad (char *);IMPORT void sysDebugMsg (char * str, UINT32 recovery);/******************************************************************************** sysEndLoad - create load string and load the END devices.** This routine loads the END devices with initial parameters.** RETURNS: pointer to END object or ERROR.** SEE ALSO: driver xxxEndLoad() functions.*/ END_OBJ * sysEndLoad ( char * pParamStr, /* ptr to initialization parameter string */ void * unused /* unused optional argument */ ) { static BOOL configured = FALSE; /* * The End driver END_LOAD_STRING should be: * The format of the parameter string is: * * "<device_addr>:<PCI_addr>:<ivec>:<ilevel>:<num_rds>:<num_tds>: * <mem_base>:<mem_size>:<user_flags>" * * Note that unit number is prepended in muxDevLoad, so we * don't put it here! */ char * cp; char paramStr [END_INIT_STR_MAX]; /* end.h */ END_OBJ * pEnd = (END_OBJ *)NULL;#ifdef INCLUDE_DEC_END static char decParamTemplate[] = "0x%x:0x%x:0x%x:0x%x:-1:-1:-1:0:0x%x";#endif /* INCLUDE_DEC_END */ UINT32 unit = 0; char unitString[3]; /* read PCI configuration and initialize endDevices[] */ if (!configured) { sysPciInit (); configured = 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. */ switch (endDevices[initUnit].pciId.devVend) { case PCI_ID_I82559: case PCI_ID_I82559ER: pEnd = i82559DrvEndLoad (pParamStr); break;#ifdef INCLUDE_DEC_END case PCI_ID_LN_DEC21040: case PCI_ID_LN_DEC21140: case PCI_ID_LN_DEC21143: pEnd = dec21x40EndLoad (pParamStr); break;#endif /* INCLUDE_DEC_END */ default: sprintf(dbgMsg, "Unknown End device %x unit %d\r\n", endDevices[initUnit].pciId.devVend, initUnit); sysDebugMsg(dbgMsg, 0); return ((END_OBJ *)NULL); } initUnit++; /* never go past the end of the list */ if (initUnit == NUM_END_DEVICES) initUnit = 0; } 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 */ unitString[0] = paramStr[0]; unitString[1] = '\0'; unit = atoi(unitString); /* Now, we advance cp, by finding the end the string */ cp += strlen (paramStr); /* finish off the initialization parameter string */ switch (endDevices[unit].pciId.devVend) { case PCI_ID_I82559: case PCI_ID_I82559ER: sprintf (cp, "%d:%d:0x%x:0x%x:0x%x:0x%x:0x%x:0x%x:0x%x:0x%x", unit, 0, endDevices[unit].pciId.loc.bus, endDevices[unit].pciId.loc.device, endDevices[unit].pciId.loc.function, endDevices[unit].irqvec, endDevices[unit].irqnum, endDevices[unit].bar1Csr, /* device io base */ (UINT) PCI_SLV_MEM_BUS, /* pciMemBase */ 0); /* user flags */ if ((pEnd = i82559DrvEndLoad (paramStr)) == (END_OBJ *)ERROR) { sprintf(dbgMsg, "Failed i82559DrvEndLoad.\r\n"); sysDebugMsg(dbgMsg, 0); return ((END_OBJ *)NULL); } break;#ifdef INCLUDE_DEC_END case PCI_ID_LN_DEC21040: case PCI_ID_LN_DEC21140: case PCI_ID_LN_DEC21143: sprintf (cp, decParamTemplate, (UINT) (endDevices[unit].bar0Csr), /* device io base */ (UINT) PCI_SLV_MEM_BUS, /* pciMemBase */ endDevices[unit].irqvec, /* interrupt irq vector */ endDevices[unit].irqnum, /* interrupt irq number */ NET_END_USER_FLAGS); if ((pEnd = dec21x40EndLoad (paramStr)) == (END_OBJ *)ERROR) { sprintf(dbgMsg, "Failed dec21x40EndLoad.\r\n"); sysDebugMsg(dbgMsg, 0); return ((END_OBJ *)NULL); } break;#endif /* INCLUDE_DEC_END */ default: sprintf(dbgMsg, "Unknown End device %x unit %d\r\n", endDevices[unit].pciId.devVend, unit); sysDebugMsg(dbgMsg, 0); return ((END_OBJ *)NULL); } } return (pEnd); }/********************************************************************************* sysPciInit - prepare LAN adapters for initialization** This routine finds the PCI device, and maps its memory and IO address.** RETURNS: N/A*/STATUS sysPciInit (void) { UINT32 pciBus; UINT32 unit = 0; endDevices[0].pciId.loc.device = PCI_IDSEL_PRI_LAN; /* limit search to bus 0 */ pciBus = 0;#ifdef INCLUDE_SECONDARY_ENET for (;unit < NUM_END_DEVICES; unit++) { if (unit) endDevices[unit].pciId.loc.device = PCI_IDSEL_SEC_LAN;#endif /* INCLUDE_SECONDARY_ENET */ endDevices[unit].pciId.loc.bus = pciBus; pciConfigInLong (pciBus, endDevices[unit].pciId.loc.device, 0, PCI_CFG_VENDOR_ID, &(endDevices[unit].pciId.devVend)); /* get memory base address, IO base address, and interrupt line */ pciConfigInLong (endDevices[unit].pciId.loc.bus, endDevices[unit].pciId.loc.device, endDevices[unit].pciId.loc.function, PCI_CFG_BASE_ADDRESS_0, &(endDevices[unit].bar0Csr)); pciConfigInLong (endDevices[unit].pciId.loc.bus, endDevices[unit].pciId.loc.device, endDevices[unit].pciId.loc.function, PCI_CFG_BASE_ADDRESS_1, &(endDevices[unit].bar1Csr)); pciConfigInByte (endDevices[unit].pciId.loc.bus, endDevices[unit].pciId.loc.device, endDevices[unit].pciId.loc.function, PCI_CFG_DEV_INT_LINE, &(endDevices[unit].irqvec)); endDevices[unit].irqnum = endDevices[unit].irqvec; switch (endDevices[unit].pciId.devVend) { case PCI_ID_I82559: case PCI_ID_I82559ER: /* convert Memory base addresses from PCI space to CPU space */ endDevices[unit].bar0Csr = TRANSLATE( (endDevices[unit].bar0Csr & PCI_MEMBASE_MASK), PCI_MSTR_MEMIO_BUS, PCI_MSTR_MEMIO_LOCAL); /* convert I/O base addresses from PCI space to CPU space */ endDevices[unit].bar1Csr = TRANSLATE( (endDevices[unit].bar1Csr & PCI_IOBASE_MASK), PCI_MSTR_IO_BUS,PCI_MSTR_IO_LOCAL); break;#ifdef INCLUDE_DEC_END case PCI_ID_LN_DEC21040: case PCI_ID_LN_DEC21140: case PCI_ID_LN_DEC21143: /* convert I/O and Memory base from PCI space to CPU space */ endDevices[unit].bar0Csr = TRANSLATE( (endDevices[unit].bar0Csr & PCI_IOBASE_MASK), PCI_MSTR_IO_BUS,PCI_MSTR_IO_LOCAL); endDevices[unit].bar1Csr = TRANSLATE( (endDevices[unit].bar1Csr & PCI_MEMBASE_MASK), PCI_MSTR_MEMIO_BUS, PCI_MSTR_MEMIO_LOCAL); if (endDevices[unit].pciId.devVend == PCI_ID_LN_DEC21143) { /* disable sleep mode */ pciConfigOutByte (endDevices[unit].pciId.loc.bus, endDevices[unit].pciId.loc.device, endDevices[unit].pciId.loc.function, PCI_CFG_MODE, SLEEP_MODE_DIS); pciConfigOutLong (endDevices[unit].pciId.loc.bus, endDevices[unit].pciId.loc.device, endDevices[unit].pciId.loc.function, PCI_CFG_21143_DA, 0 ); } break;#endif /* INCLUDE_DEC_END */ default: sprintf(dbgMsg, "Unknown End device %x unit %d\r\n", endDevices[unit].pciId.devVend, unit); sysDebugMsg(dbgMsg, 0); break; }#ifdef INCLUDE_SECONDARY_ENET }#endif /* INCLUDE_SECONDARY_ENET */ return (OK); }/********************************************************************************* sysDec21x40EnetAddrGet - gets the ethernet address from the ROM register** This routine returns ERROR. It is legacy and should never be called.** RETURNS: ERROR*/STATUS sysDec21x40EnetAddrGet ( ) { return (ERROR); }#endif /* defined(INCLUDE_NETWORK) && defined (INCLUDE_END) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -