📄 sysnet.c
字号:
/* sysNet.c - template system network initialization *//* Copyright 1984-1999 Wind River Systems, Inc. *//*modification history--------------------01a,01apr99,jkf written.*//*DESCRIPTIONThis library contains board-specific routines for network subsystems.*/#if defined (INCLUDE_NETWORK)/* includes */#include "vxLib.h"#include "config.h"#include "taskLib.h" /******************************************************************************** sysNetHwInit - initialize the network interface** This routine initializes the network hardware to a quiescent state. It* does not connect interrupts.** Only polled mode operation is possible after calling this routine.* Interrupt mode operation is possible after the memory system has been* initialized and sysNetHwInit2() has been called.*/void sysNetHwInit (void) { }/******************************************************************************** sysNetHwInit2 - initialize additional features of the network interface** This routine completes initialization needed for interrupt mode operation* of the network device drivers. Interrupt handlers can be connected.* Interrupt or DMA operations can begin.*/void sysNetHwInit2 (void) {#ifdef INCLUDE_END#if defined (INCLUDE_DC_END) sysDec21x40PciInit(); /* DEC 21x40 device */#endif /* INCLUDE_DC_END */#if defined (INCLUDE_FEI_END) sys557PciInit(); /* Intel FEI 8255x device */#endif /* INCLUDE_FEI_END */#if defined (INCLUDE_LN_97X_END) sysLan97xPciInit (); /* AMD PCNet-FAST 79X97x device */#endif /* INCLUDE_LN_97X_END */#ifdef INCLUDE_EL_3C90X_END sysEl3c90xPciInit (); /* 3COM 3C90x device */#endif /* INCLUDE_LN_97X_END */#endif /* INCLUDE_END */ }#endif /* INCLUDE_NETWORK *//******************************************************************************** sysLanIntEnable - enable the LAN interrupt** This routine enables interrupts at a specified level ** RETURNS: OK, or ERROR if network support not included.** SEE ALSO: sysLanIntDisable()*/STATUS sysLanIntEnable ( int intLevel /* interrupt level to enable */ ) { /* * enable the ISA IRQ for LAN */#if defined (INCLUDE_NETWORK) intEnable (intLevel); return (OK);#else return (ERROR);#endif }/******************************************************************************** sysLanIntDisable - disable the LAN interrupt** This routine disables interrupts for the on-board LAN chip. ** RETURNS: return of intDisable, or ERROR if network support not included.** SEE ALSO: sysLanIntEnable()*/STATUS sysLanIntDisable ( int intLevel /* interrupt level to enable */ ) {#if defined (INCLUDE_NETWORK) return (intDisable (intLevel));#else return (ERROR);#endif }/* DC netif driver specific code */#if defined (INCLUDE_DC_NETIF) && defined (INCLUDE_NETWORK) /* DEC defines */#define ADAPTER_VENDOR_ID DEC21X4X_PCI_VENDOR_ID #define ADAPTER_DEVICE_ID DEC21140_PCI_DEVICE_ID #define ADAPTER_INSTANCE 0/* DEC Ethernet */#define DEC21X4X_PCI_VENDOR_ID 0x1011 /* PCI vendor ID */#define DEC21143_PCI_DEVICE_ID 0x0019 /* PCI device ID */#define DEC21140_PCI_DEVICE_ID 0x0009 /* PCI device ID */#define DEC21040_PCI_DEVICE_ID 0x0002 /* PCI device ID *//******************************************************************************* sysDynDcAttach - Dynamically attach DEC ethernet driver** This function dynamically attaches the network driver to the actual PCI* network hardware via a 'dcattach()' function call. It works in* conjunction with the two macros: NETIF_USR_DECL and NETIF_USR_ENTRIES* defined in "config.h". The presence of these two macros causes* usrNetIfAttach() to call this function 'sysDynDcAttach()' directly* instead of calling 'dcattach()' directly. This function dynamically* determines the CPU memory address, interrupt vector and interrupt* level parameters (associated with the dummy arguments: dummmyDevAdrs,* dummyIvec, dummyIlevel) by using information read from the already* configured PCI configuration header for this device. The "unit"* argument is used to discern between primary ethernet (unit == 0) and* secondary ethernet (unit == 1). ** RETURNS: OK if dcattach() succeeds, ERROR if PCI header not found or* if dcattach() fails.*/STATUS sysDynDcAttach ( int unit, /* unit number */ ULONG dummmyDevAdrs, /* LANCE I/O address (dummy) */ int dummyIvec, /* interrupt vector (dummy) */ int dummyIlevel, /* interrupt level (dummy) */ char * memAdrs, /* address of memory pool (-1 = malloc it) */ ULONG memSize, /* only used if memory pool is NOT malloc'd */ int memWidth, /* byte-width of data (-1 = any width) */ ULONG pciMemBase, /* main memory base as seen from PCI bus */ int dcOpMode /* mode of operation */ ) { IMPORT int dcattach (); int pciBus; int pciDevice; int pciFunc; int status = ERROR; int ivec, ilevel; UINT32 memBaseCsr; UINT8 intLine; UINT32 cpuPciAddr; /* find the device */ if (pciFindDevice ( (int)ADAPTER_VENDOR_ID, (int)ADAPTER_DEVICE_ID, (int)ADAPTER_INSTANCE, &pciBus, &pciDevice, &pciFunc ) == OK) { /* * get the base address - for the Digital 21x40 the first BAR is * IO, second is memory. */ pciConfigInLong ( pciBus, pciDevice, pciFunc, PCI_CFG_BASE_ADDRESS_1, &memBaseCsr); cpuPciAddr = PCI_MEMIO2LOCAL (memBaseCsr & PCI_MEMBASE_MASK); pciConfigInByte ( pciBus, pciDevice, pciFunc, PCI_CFG_DEV_INT_LINE, &intLine); ivec = (int)(intLine + INT_VEC_IRQ0 + EXT_INTERRUPT_BASE); ilevel = (int)(intLine + EXT_INTERRUPT_BASE); /* Do the dcattach() with the dynamiclly computed arguments. */ status = dcattach(0,cpuPciAddr , ivec, ilevel, memAdrs, memSize, memWidth, 0, dcOpMode); } return(status); }#endif /* INCLUDE_DC_NETIF && INCLUDE_NETWORK */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -