📄 sysnet.c
字号:
/* sysNet.c - IBM Spruce system network initialization *//******************************************************************************* This source and object code has been made available to you by IBM on an AS-IS basis. IT IS PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE OR OF NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL IBM OR ITS LICENSORS BE LIABLE FOR INCIDENTAL, CONSEQUENTIAL OR PUNITIVE DAMAGES. IBM'S OR ITS LICENSOR'S DAMAGES FOR ANY CAUSE OF ACTION, WHETHER IN CONTRACT OR IN TORT, AT LAW OR AT EQUITY, SHALL BE LIMITED TO A MAXIMUM OF $1,000 PER LICENSE. Anyone receiving this source or object code is licensed under IBM copyrights to use it in any way he or she deems fit, including copying it, modifying it, compiling it, and redistributing it either with or without modifications. No license under IBM patents or patent applications is to be implied by the copyright license. Any user of this software should understand that neither IBM nor its licensors will be responsible for any consequences resulting from the use of this software. Any person who transfers this object code or any derivative work must include the IBM copyright notice in the transferred software. COPYRIGHT I B M CORPORATION 1999 LICENSED MATERIAL - PROGRAM PROPERTY OF I B M"*******************************************************************************//* Copyright 1984-2002 Wind River Systems, Inc. *//*modification history--------------------01e,21jun02,pch cleanup01d,03apr02,pch use generic pciConfigLib01c,27mar01,kab Removed IBM support info per request01b,06oct99,mcg changed for Tornado 2 End Driver01a,11mar99,mcg create from template version 01d*//*DESCRIPTIONThis library contains board-specific routines for network subsystems.This library will support the AMD 97x family of Ethernet controllers.For Spruce, a PCI adapter card must be used. Two examples are the AlliedTelesyn AT-2450T (AMD 79C970 PCnet-PCI II controller) or the Allied TelesynAT-2700TX (AMD 79C972 PCnet-FAST+ controller).*//* This file contributes nothing if INCLUDE_NETWORK is not defined */#ifdef INCLUDE_NETWORK/* includes */#include "vxLib.h"#include "stdio.h"#include "drv/end/ln97xEnd.h"/***** GLOBALS *****/unsigned char sysEnetAddr[6]; /* MAC address for the Am79C97x */char sys97xLoadString[100]; /* load string for sys97xLoad *//* Forward declarations */STATUS sysln97xEndBldLoadStr(void);/******************************************************************************** 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.** RETURNS: N/A** SEE ALSO: sysNetHwInit2()*/void sysNetHwInit ( void ) { /* * A PCI reset was done in sysPciInit() */ /* * Build the load string for the PCI Ethernet END driver */ sysln97xEndBldLoadStr(); return; }/******************************************************************************** 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.** RETURNS: N/A** SEE ALSO: lnPciattachSpruce()*/void sysNetHwInit2 ( void ) { /* * */ return; }/******************************************************************************** sysln97xEndBldLoadStr - determines arguments for and builds the ln97xEndLoad* parameter string** Searches for the PCI Ethernet card, gets the base memory address of the card* that was assigned during PCI configuration, selects the correct interrupt* vector based on the PCI slot, reads the MAC address of the card, and calls* ln97xEndLoad with all of these parameters.* This function also enables the Ethernet card for PCI memory cycles and* and bus mastership.** RETURNS: ERROR if the PCI card is not found**/STATUS sysln97xEndBldLoadStr ( void ) { int i; int intvec; int intlvl; UINT32 pciMemAddr; int bus, dev, func; /* * Find and configure the first AMD Am79C97x device on the PCI bus. * pciFindDevice will set up busDevFunc if the device is found. */ if (pciFindDevice(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_79C97X, 0, &bus, &dev, &func)) return(ERROR); /* * Base Address 1 of the 97x contains the PCI Memory space base address. * This address was setup by the pciScan() function. */ pciConfigInLong(bus, dev, func, PCI_CFG_BASE_ADDRESS_1, &pciMemAddr); pciMemAddr &= 0xFFFFFFF0; /* * Set latency timer to 50. */ pciConfigOutByte(bus, dev, func, PCI_LATENCY_TIMER, 50); /* * Each PCI slot on the Spruce board is connected to a different pin on * the CPC700's integrated Universal Interrupt Controller. Determine the * interrupt level based on the PCI slot the Ethernet card is plugged in. */ switch (dev) { case 1 : intvec = INT_VEC_PCI_SLOT3; /* Spruce connector J25 */ intlvl = INT_LVL_PCI_SLOT3; break; case 2 : intvec = INT_VEC_PCI_SLOT2; /* Spruce connector J26 */ intlvl = INT_LVL_PCI_SLOT2; break; case 3 : intvec = INT_VEC_PCI_SLOT1; /* Spruce connector J29 */ intlvl = INT_LVL_PCI_SLOT1; break; case 4 : intvec = INT_VEC_PCI_SLOT0; /* Spruce connector J31 */ intlvl = INT_LVL_PCI_SLOT0; break; default : return(ERROR); /* Not possible, error */ } /* * Enable PCI memory cycles and Bus Master operations. */ pciConfigOutWord(bus, dev, func, PCI_CFG_COMMAND, PCI_CMD_MEM_ENABLE | PCI_CMD_MASTER_ENABLE); /* * Use memory cycles to copy the hardware address from the APROM area * to the board_cfg structure and elsewhere. The PCI Ethernet adapter * has a serial EEPROM on board that contains the MAC address of the card. * When the card first powers up, the address is copied into the APROM * registers. The value in the APROM regs will be read from the card and * place into the global variable sysEnetAddr so the driver can find it. */ for (i=0; i<6; i++) sysEnetAddr[i] = sysInByte(pciMemAddr+APROM01+i); /* * Build the initialization string. It looks like this: * * <devMemAddr>:<devIoAddr>:<pciMemBase>:<vecNum>:<intLvl>:<memAdrs>: * <memSize>:<memWidth>:<csr3b>:<offset>:<flags> * * The unit number will be tacked onto the beginning by muxEndLoad */ sprintf(sys97xLoadString, "0x%x:0x%x:0:%d:%d:0x%x:0:0x%x:0:0:0", (unsigned int)pciMemAddr, NONE, intvec, intlvl, NONE,NONE); return(0); }/******************************************************************************** sysLan97xIntEnable - enable the LAN interrupt** Enables the interrupt in the UIC corresponding to the PCI slot where* the Ethernet card was found** RETURNS: N/A**/void sysLan97xIntEnable ( UINT intlvl ) { intEnable (intlvl); }/******************************************************************************** sysLan97xIntDisable - disable the LAN interrupt** Disables the interrupt in the UIC corresponding to the PCI slot where* the Ethernet card was found** RETURNS: N/A**/void sysLan97xIntDisable ( UINT intlvl ) { intDisable (intlvl); }/******************************************************************************** sysLan97xEnetAddrGet - get the Ethernet controller's MAC address** Returns the Ethernet controller's MAC address to the END driver.** RETURNS: N/A**/void sysLan97xEnetAddrGet ( LN_97X_DRV_CTRL *pDrvCtrl, char *enetAdrs ) { memcpy(enetAdrs, sysEnetAddr, sizeof(sysEnetAddr)); }#endif /* INCLUDE_NETWORK */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -