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

📄 if_ex.c

📁 IXP425的BSP代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* if_ex.c - Excelan EXOS 201/202/302 Ethernet network interface driver *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/* * Copyright (c) 1980, 1986 Regents of the University of California. * All rights reserved.  The Berkeley software License Agreement * specify the terms and conditions for redistribution. * *      @(#)if_ex.c     7.1 (Berkeley) 6/5/86 *//*modification history--------------------03u,15jul97,spm  added ARP request to SIOCSIFADDR ioctl handler03t,07apr97,spm  code cleanup, corrected statistics, and upgraded to BSD 4.403s,14oct93,wmd  Added use of ntohs macro to correct parameter passed in		 do_protocol_with_type(), spr #2571.03r,11aug93,jmm  Changed ioctl.h and socket.h to sys/ioctl.h and sys/socket.h03q,27apr93,jdi  restored '/' to beginning of line 1 (spr 2180).03p,22feb93,jdi  documentation cleanup.03o,28jan93,rfs  Reworked sequence within attach routine that gleans the                 Ethernet address from the exos board.  The reply message                 is now handled by the interrupt handler.  SPR #1931.03n,14oct92,rfs  Added documentation.03m,02oct92,rfs  Made multiple attach calls per unit return OK, not ERROR.03l,30sep92,rfs  Gathered all shared memory areas into one area that is                 allocated from cache-safe memory.  The driver will abort if                 a cache-safe area cannot be provided.  Also brought the                 driver up to conventions used in the others, except I left in                 the outgoing mbuf queue, since the driver only uses one                 transmit buffer.03k,09sep92,gae  documentation tweaks.03j,04sep92,ccc  Added address modifier parameter to exattach() routine.                 Now uses sysBusToLocalAdrs() to convert base address.03i,18jul92,smb  Changed errno.h to errnoLib.h.03h,26may92,rrr  the tree shuffle                 -changed includes to have absolute path from h/03g,04may92,elh  changed exInit to return 0 if running.  cleaned up                 some ansi warnings.03f,22apr92,jwt  converted CPU==SPARC to CPU_FAMILY==SPARC; copyright.03e,11nov91,jpb  fixed bug in exoutput status return path.                 disable data cache (currently SPARC only).03d,04oct91,rrr  passed through the ansification filter                 -changed functions to ansi style                 -changed includes to have absolute path from h/                 -fixed #else and #endif                 -changed READ, WRITE and UPDATE to O_RDONLY O_WRONLY and O_RDWR                 -changed VOID to void                 -changed copyright notice03c,13sep91,jpb  added argument to exattach to specify address modifier for                 DME access to memory.  Made exBusAdrsSpace local.03b,29apr91,hdn  use SIZEOF_ETHERHEADER instead of sizeof(ether_header).03a,10apr91,jdi  documentation cleanup; fixed comment block in exattach() that                 had effectively commented out declaration of ivec;                 doc review by elh.02z,02oct90,hjb  made exinit() return int always.02y,19sep90,dab  made exinit() return int.02x,10aug90,dnw  added forward declarations of void routines.                 added include of if_subr.h.02w,15jul90,dnw  coerced calloc() to (char*) where necessary02v,11jul90,hjb  removed references to ipintr().  changed calls to do_protocol()                 to use do_protocol_with_type() instead.02u,26jun90,hjb  copy_from_mbufs() & m_freem() fix02t,02may90,gae  fixed EXOS 302 initialization of address modifier register.           +hjb  changed ETHERMIN+X to ETHERSMALL.  Turned off DEBUG.                 increased exconfig test delay from 5 secs.02s,19apr90,hjb  deleted param.h, de-linted, modifications for                 copy_from_mbufs().02r,18mar90,hjb  reduction of redundant code and addition of cluster support.02q,07aug89,gae  SPARC cleanup.    07apr89,ecs  fixed references to unaligned structure in exhangrcv & exstart.02p,29jul88,gae  fixed printf happening at interrupt level.02o,30may88,dnw  changed to v4 names.02n,28jan88,jcf  made kernel independent.02m,05jan88,rdc  added include of systm.h02l,20nov87,ecs  lint           &dnw  changed exattach to take int vec num instead of vec adrs.02k,17nov87,dnw  fixed printing of transmit errors.02j,03nov87,dnw  added vxTdelay(1) to init and configuration wait loops so that                 entire cpu (and in some cases entire bus!) isn't tied up.                 added global variable exBusAdrsSpace to allow modification                 of what address space excelan should use to address buffers.                 added output hook code.                 changed calling sequence to input hook.                 changed exreset to actually reset hardware.02i,21oct87,ecs  delinted02h,03may87,dnw  removed unnecessary includes.                 changed BUS_ADDR macro to exHostAdrs() routine                 which uses new call to sysLocalToBusAdrs().                 added input hook code.02g,29apr87,dnw  changed exconfig() to set meaninfug status on error.02f,08apr87,llk  enable interrupts from the excelan board with sysIntEnable.02e,03apr87,ecs  added copyright.02d,01apr87,jlf  delinted.02c,20mar87,dnw  Added probe of excelan board and timeout of self-test                 in exconfig.02b,14feb87,dnw  Formatted and cleaned up.                 Changed to keep array of ptrs to ex_softc structure                 and to dynamically allocate those structures as attached.                 Up to 10 controllers allowed.                 Fixed call to intConnect to pass unit to interrupt routine.                 Changed to use global sysBus, sysLocalToBusAdrs(), and                 sysIntAck(), instead of passing bus type, bus adrs offset,                 and ack address, respectively, to exattach().02a,02feb87,jlf  Removed CLEAN ifdefs.01c,30nov86,dnw  added exIntrAck kludge to ack ints for hkv2f.                 changed vmeOffset to exBusOffset.01b,26nov86,llk  got rid of conditional compiles dependent on BUS.                 Added LOCAL varibles exBus and vmeOffset.01a,31oct86,jlf  changed BUS_ADDR to mask out upper address bits                 added HK kludge.... adapted from original Excelan interface by George Powers*//*This module implements the Excelan EXOS 201/202/302 Ethernet networkinterface driver.This driver is designed to be moderately generic, operating unmodifiedacross the range of architectures and targets supported by VxWorks.To achieve this, the driver must be given several target-specificparameters.  These parameters, and the mechanisms used to communicate themto the driver, are detailed below.  This driver supports up to fourindividual units per CPU.All packet control information and data moves between the EXOS board and thetarget board in a shared memory region.  This shared memory must reside on thetarget board, since the EXOS board does not present any memory to the VME bus. Therefore, this driver will obtain an area of local memory, and assumes thatthis area of memory can be accessed from the VME bus.BOARD LAYOUTThe diagram below shows the relevant jumpers for VxWorks configuration.Default values are: I/O address 0x00ff0000, Standard Addressing (A24),interrupt level 2..bS______________________________                                            _|             P1             | EXOS 202 OLD             NO P2!            ||                            |___________________________________________ ||:::XDDDU:::X:::::::X:::::X:                                              ||BGINBGOTBREQ IO ADRS INT LVL                                             ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                  "                                      ||                                   X INT ACK                             ||                                   X                                     ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||_________________________________________________________________________|.bE.bS______________________________              _______________________________|             P1             | EXOS 202 NEW |             P2              ||                            ----------------                             ||:::::X UUUD :::X  :::::::X  :::::X:                                      ||BGIN   BGOT BREQ   IO ADRS  INT LVL                                      ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         || -"-                                                                     ||                                                                         || INT ACK                                                                 ||                                                                         ||                                                                         ||                                                                         ||_________________________________________________________________________|.bE.bS______________________________              _______________________________|             P1             |   EXOS 302   |             P2              ||                            ----------------                             ||             :X:  :::::X:    :::::    ::::::::XXXXXXXX                   ||         INT ACK  INT LVL    *24/32 ADR   IO ADRS                        ||         J54-J56  J47-J53    J42-J46      J26-J41                        ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||                                                                         ||         ::::::X:                                                        ||           SQE                       * remove J44 for A32 master mode    ||          J2-J9                      * remove J46 for A32 slave mode     ||_________________________________________________________________________|.bEEXTERNAL INTERFACEThis driver provides the standard external interface with the followingexceptions.  All initialization is performed within the attach routine;there is no separate initialization routine.  Therefore, in the global interfacestructure, the function pointer to the initialization routine is NULL.The only user-callable routine is exattach(), which publishes the `ex'interface and initializes the driver and device.TARGET-SPECIFIC PARAMETERS.iP "base VME address of EXOS I/O ports"This parameter is passed to the driver by exattach().The EXOS board presents a small set of I/O ports onto the VME bus.  Thisaddress is jumper selectable on the EXOS board.  This parameter is thesame as the address selected on the EXOS board..iP "VME address modifier code, EXOS access"This parameter is passed to the driver by exattach().It specifies the AM (address modifier) code to use when the driver accesses the VME address space (ports) of the EXOS board..iP "VME address modifier code, target access"This parameter is passed to the driver by exattach().It specifies the AM code that the EXOS board needs to usewhen it accesses the shared memory on the target board..iP "interrupt vector"This parameter is passed to the driver by exattach().It specifies the interrupt vector to be used by the driverto service an interrupt from the EXOS board.  The driver connectsthe interrupt handler to this vector by calling intConnect()..iP "interrupt level"This parameter is passed to the driver by exattach().It specifies the interrupt level that is associated with theinterrupt vector.  The driver enables the interrupt from the EXOS bycalling sysIntEnable() with this parameter..LPSYSTEM RESOURCE USAGEWhen implemented, this driver requires the following system resources:    - one interrupt vector    - 8 bytes in the initialized data section (data)    - 668 bytes in the uninitialized data section (BSS)The above data and BSS requirements are for the MC68020 architecture and may vary for other architectures.  Code size (text) varies greatly betweenarchitectures and is therefore not quoted here.This driver uses cacheDmaMalloc() to allocate the memory to be shared with the EXOS board.  The size requested is 3512 bytes.This driver can only be operated if this shared memory region is non-cacheable.The driver cannot maintain cache coherency for the shared memory because asynchronous modifications by the EXOS board may share cache lines withlocations being operated on by the driver.SEE ALSO: ifLib*/#include "vxWorks.h"#include "vme.h"#include "net/mbuf.h"#include "net/protosw.h"#include "sys/socket.h"#include "sys/ioctl.h"#include "errnoLib.h"#include "iv.h"#include "memLib.h"#include "cacheLib.h"#include "net/if.h"#include "net/route.h"#ifdef  INET#include "netinet/in.h"#include "netinet/in_systm.h"#include "netinet/in_var.h"#include "netinet/ip.h"#include "netinet/if_ether.h"#endif  /* INET */#include "drv/netif/if_exreg.h"#include "sysLib.h"#include "wdLib.h"#include "iosLib.h"#include "intLib.h"#include "etherLib.h"#include "netLib.h"#include "stdlib.h"#include "stdio.h"#include "logLib.h"#include "vxLib.h"#include "net/systm.h"#include "net/if_subr.h"#include "net/unixLib.h"/***** LOCAL DEFINITIONS *****/#define EX_DEBUG                /* enable some debug checks and messages */#define MAX_UNITS  4            /* max number of EXOS controllers supported */#define NH2X    4               /* a sufficient number is critical */#define NX2H    1               /* this is pretty arbitrary *//* Typedefs for external structures that are not typedef'd in their .h files */typedef struct mbuf MBUF;typedef struct arpcom IDR;                  /* Interface Data Record wrapper */typedef struct ifnet IFNET;                 /* real Interface Data Record */typedef struct sockaddr SOCK;               /* generic socket address */typedef struct exdevice DEV_CTRL;           /* EXOS device control */typedef struct ex_msg EX_MSG;               /* an EXOS message */typedef struct confmsg CFG_MSG;             /* an EXOS configuration message */typedef struct stat_array STAT_ARRAY;       /* EXOS status area */#define EX_MSG_SIZ      sizeof(EX_MSG)#define CFG_MSG_SIZ     sizeof(CFG_MSG)#define STAT_ARRAY_SIZ  sizeof(STAT_ARRAY)/* The definition of the driver control structure */typedef struct drv_ctrl    {    IDR                 idr;            /* interface data record */    BOOL                attached;       /* indicates attach completed */    int                 ivec;           /* interrupt vector */    int                 ilevel;         /* interrupt level */    int                 flags;          /* private flags */

⌨️ 快捷键说明

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