forked from Imagelibrary/rtems
2001-09-19 Chris Johns <ccj@acm.org>
* network/README.i82586, network/i82586.c, network/i82586reg.h, network/i82586var.h: New files. Network driver for Intel i82586.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2001-09-19 Chris Johns <ccj@acm.org>
|
||||
|
||||
* network/README.i82586, network/i82586.c, network/i82586reg.h,
|
||||
network/i82586var.h: New files. Network driver for Intel
|
||||
i82586.
|
||||
|
||||
2001-04-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* configure.in: Add [-ansi -fasm] to RTEMS_PROG_CC_FOR_TARGET.
|
||||
|
||||
@@ -10,10 +10,10 @@ LIBNAME = libnetchip
|
||||
LIB = $(ARCH)/$(LIBNAME).a
|
||||
|
||||
# add cs8900.c to work with it and make it compile
|
||||
C_FILES = dec21140.c sonic.c
|
||||
C_FILES = dec21140.c i82586.h sonic.c
|
||||
C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
|
||||
|
||||
include_libchip_HEADERS = cs8900.h sonic.h
|
||||
include_libchip_HEADERS = cs8900.h i82586var.h sonic.h
|
||||
|
||||
OBJS = $(C_O_FILES)
|
||||
|
||||
@@ -52,7 +52,7 @@ endif
|
||||
|
||||
.PRECIOUS: $(LIB)
|
||||
|
||||
EXTRA_DIST = README README.cs8900 README.dec21140 README.sonic \
|
||||
cs8900.c dec21140.c sonic.c
|
||||
EXTRA_DIST = README README.cs8900 README.dec21140 README.i82586 README.sonic \
|
||||
cs8900.c dec21140.c i82586.c sonic.c
|
||||
|
||||
include $(top_srcdir)/../../../automake/local.am
|
||||
|
||||
5
c/src/libchip/network/README.i82586
Normal file
5
c/src/libchip/network/README.i82586
Normal file
@@ -0,0 +1,5 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
TBD
|
||||
2195
c/src/libchip/network/i82586.c
Normal file
2195
c/src/libchip/network/i82586.c
Normal file
File diff suppressed because it is too large
Load Diff
436
c/src/libchip/network/i82586reg.h
Normal file
436
c/src/libchip/network/i82586reg.h
Normal file
@@ -0,0 +1,436 @@
|
||||
/* $NetBSD: i82586reg.h,v 1.7 1998/02/28 01:07:45 pk Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Paul Kranenburg.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, University of Vermont and State Agricultural College.
|
||||
* Copyright (c) 1992, Garrett A. Wollman.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* Vermont and State Agricultural College and Garrett A. Wollman.
|
||||
* 4. Neither the name of the University nor the name of the author
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR AUTHOR BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Intel 82586 Ethernet chip
|
||||
* Register, bit, and structure definitions.
|
||||
*
|
||||
* Written by GAW with reference to the Clarkson Packet Driver code for this
|
||||
* chip written by Russ Nelson and others.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE, the structure definitions in here are for reference only.
|
||||
* We use integer offsets exclusively to access the i82586 data structures.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This is the master configuration block.
|
||||
* It tells the hardware where all the rest of the stuff is.
|
||||
*-
|
||||
struct __ie_sys_conf_ptr {
|
||||
u_int16_t mbz; // must be zero
|
||||
u_int8_t ie_bus_use; // true if 8-bit only
|
||||
u_int8_t mbz2[5]; // must be zero
|
||||
u_int32_t ie_iscp_ptr; // 24-bit physaddr of ISCP
|
||||
};
|
||||
*/
|
||||
#define IE_SCP_SZ 12
|
||||
#define IE_SCP_BUS_USE(base) ((base) + 2)
|
||||
#define IE_SCP_ISCP(base) ((base) + 8)
|
||||
|
||||
/*
|
||||
* Note that this is wired in hardware; the SCP is always located here, no
|
||||
* matter what.
|
||||
*/
|
||||
#define IE_SCP_ADDR 0xfffff4
|
||||
|
||||
/*
|
||||
* The tells the hardware where all the rest of the stuff is, too.
|
||||
* FIXME: some of these should be re-commented after we figure out their
|
||||
* REAL function.
|
||||
*-
|
||||
struct __ie_int_sys_conf_ptr {
|
||||
u_int8_t ie_busy; // zeroed after init
|
||||
u_int8_t mbz;
|
||||
u_int16_t ie_scb_offset; // 16-bit physaddr of next struct
|
||||
caddr_t ie_base; // 24-bit physaddr for all 16-bit vars
|
||||
};
|
||||
*/
|
||||
#define IE_ISCP_SZ 8
|
||||
#define IE_ISCP_BUSY(base) ((base) + 0)
|
||||
#define IE_ISCP_SCB(base) ((base) + 2)
|
||||
#define IE_ISCP_BASE(base) ((base) + 4)
|
||||
|
||||
/*
|
||||
* This FINALLY tells the hardware what to do and where to put it.
|
||||
*-
|
||||
struct __ie_sys_ctl_block {
|
||||
u_int16_t ie_status; // status word
|
||||
u_int16_t ie_command; // command word
|
||||
u_int16_t ie_command_list; // 16-pointer to command block list
|
||||
u_int16_t ie_recv_list; // 16-pointer to receive frame list
|
||||
u_int16_t ie_err_crc; // CRC errors
|
||||
u_int16_t ie_err_align; // Alignment errors
|
||||
u_int16_t ie_err_resource; // Resource errors
|
||||
u_int16_t ie_err_overrun; // Overrun errors
|
||||
};
|
||||
*/
|
||||
#define IE_SCB_SZ 16
|
||||
#define IE_SCB_STATUS(base) ((base) + 0)
|
||||
#define IE_SCB_CMD(base) ((base) + 2)
|
||||
#define IE_SCB_CMDLST(base) ((base) + 4)
|
||||
#define IE_SCB_RCVLST(base) ((base) + 6)
|
||||
#define IE_SCB_ERRCRC(base) ((base) + 8)
|
||||
#define IE_SCB_ERRALN(base) ((base) + 10)
|
||||
#define IE_SCB_ERRRES(base) ((base) + 12)
|
||||
#define IE_SCB_ERROVR(base) ((base) + 14)
|
||||
|
||||
/* Command values */
|
||||
#define IE_RUC_MASK 0x0070 /* mask for RU command */
|
||||
#define IE_RUC_NOP 0 /* for completeness */
|
||||
#define IE_RUC_START 0x0010 /* start receive unit command */
|
||||
#define IE_RUC_RESUME 0x0020 /* resume a suspended receiver command */
|
||||
#define IE_RUC_SUSPEND 0x0030 /* suspend receiver command */
|
||||
#define IE_RUC_ABORT 0x0040 /* abort current receive operation */
|
||||
|
||||
#define IE_CUC_MASK 0x0700 /* mask for CU command */
|
||||
#define IE_CUC_NOP 0 /* included for completeness */
|
||||
#define IE_CUC_START 0x0100 /* do-command command */
|
||||
#define IE_CUC_RESUME 0x0200 /* resume a suspended cmd list */
|
||||
#define IE_CUC_SUSPEND 0x0300 /* suspend current command */
|
||||
#define IE_CUC_ABORT 0x0400 /* abort current command */
|
||||
|
||||
#define IE_ACK_COMMAND 0xf000 /* mask for ACK command */
|
||||
#define IE_ACK_CX 0x8000 /* ack IE_ST_CX */
|
||||
#define IE_ACK_FR 0x4000 /* ack IE_ST_FR */
|
||||
#define IE_ACK_CNA 0x2000 /* ack IE_ST_CNA */
|
||||
#define IE_ACK_RNR 0x1000 /* ack IE_ST_RNR */
|
||||
|
||||
#define IE_ACTION_COMMAND(x) (((x) & IE_CUC_MASK) == IE_CUC_START)
|
||||
/* is this command an action command? */
|
||||
|
||||
/* Status values */
|
||||
#define IE_ST_WHENCE 0xf000 /* mask for cause of interrupt */
|
||||
#define IE_ST_CX 0x8000 /* command with I bit completed */
|
||||
#define IE_ST_FR 0x4000 /* frame received */
|
||||
#define IE_ST_CNA 0x2000 /* all commands completed */
|
||||
#define IE_ST_RNR 0x1000 /* receive not ready */
|
||||
|
||||
#define IE_CUS_MASK 0x0700 /* mask for command unit status */
|
||||
#define IE_CUS_ACTIVE 0x0200 /* command unit is active */
|
||||
#define IE_CUS_SUSPEND 0x0100 /* command unit is suspended */
|
||||
|
||||
#define IE_RUS_MASK 0x0070 /* mask for receiver unit status */
|
||||
#define IE_RUS_SUSPEND 0x0010 /* receiver is suspended */
|
||||
#define IE_RUS_NOSPACE 0x0020 /* receiver has no resources */
|
||||
#define IE_RUS_READY 0x0040 /* receiver is ready */
|
||||
|
||||
/*
|
||||
* This is filled in partially by the chip, partially by us.
|
||||
*-
|
||||
struct __ie_recv_frame_desc {
|
||||
u_int16_t ie_fd_status; // status for this frame
|
||||
u_int16_t ie_fd_last; // end of frame list flag
|
||||
u_int16_t ie_fd_next; // 16-pointer to next RFD
|
||||
u_int16_t ie_fd_buf_desc; // 16-pointer to list of buffer descs
|
||||
struct __ie_en_addr dest; // destination ether
|
||||
struct __ie_en_addr src; // source ether
|
||||
u_int16_t ie_length; // 802 length/Ether type
|
||||
u_short mbz; // must be zero
|
||||
};
|
||||
*/
|
||||
#define IE_RFRAME_SZ 24
|
||||
#define IE_RFRAME_ADDR(base,i) ((base) + (i) * IE_RFRAME_SZ)
|
||||
#define IE_RFRAME_STATUS(b,i) (IE_RFRAME_ADDR(b,i) + 0)
|
||||
#define IE_RFRAME_LAST(b,i) (IE_RFRAME_ADDR(b,i) + 2)
|
||||
#define IE_RFRAME_NEXT(b,i) (IE_RFRAME_ADDR(b,i) + 4)
|
||||
#define IE_RFRAME_BUFDESC(b,i) (IE_RFRAME_ADDR(b,i) + 6)
|
||||
#define IE_RFRAME_EDST(b,i) (IE_RFRAME_ADDR(b,i) + 8)
|
||||
#define IE_RFRAME_ESRC(b,i) (IE_RFRAME_ADDR(b,i) + 14)
|
||||
#define IE_RFRAME_ELEN(b,i) (IE_RFRAME_ADDR(b,i) + 20)
|
||||
|
||||
/* "last" bits */
|
||||
#define IE_FD_EOL 0x8000 /* last rfd in list */
|
||||
#define IE_FD_SUSP 0x4000 /* suspend RU after receipt */
|
||||
|
||||
/* status field bits */
|
||||
#define IE_FD_COMPLETE 0x8000 /* frame is complete */
|
||||
#define IE_FD_BUSY 0x4000 /* frame is busy */
|
||||
#define IE_FD_OK 0x2000 /* frame is ok */
|
||||
#define IE_FD_CRC 0x0800 /* CRC error */
|
||||
#define IE_FD_ALGN 0x0400 /* Alignment error */
|
||||
#define IE_FD_RNR 0x0200 /* receiver out of resources here */
|
||||
#define IE_FD_OVR 0x0100 /* DMA overrun */
|
||||
#define IE_FD_SHORT 0x0080 /* Short frame */
|
||||
#define IE_FD_NOEOF 0x0040 /* no EOF (?) */
|
||||
#define IE_FD_ERRMASK /* all error bits */ \
|
||||
(IE_FD_CRC|IE_FD_ALGN|IE_FD_RNR|IE_FD_OVR|IE_FD_SHORT|IE_FD_NOEOF)
|
||||
#define IE_FD_STATUSBITS \
|
||||
"\20\20COMPLT\17BUSY\16OK\14CRC\13ALGN\12RNR\11OVR\10SHORT\7NOEOF"
|
||||
|
||||
/*
|
||||
* linked list of buffers...
|
||||
*-
|
||||
struct __ie_recv_buf_desc {
|
||||
u_int16_t ie_rbd_status; // status for this buffer
|
||||
u_int16_t ie_rbd_next; // 16-pointer to next RBD
|
||||
caddr_t ie_rbd_buffer; // 24-pointer to buffer for this RBD
|
||||
u_int16_t ie_rbd_length; // length of the buffer
|
||||
u_int16_t mbz; // must be zero
|
||||
};
|
||||
*/
|
||||
#define IE_RBD_SZ 12
|
||||
#define IE_RBD_ADDR(base,i) ((base) + (i) * IE_RBD_SZ)
|
||||
#define IE_RBD_STATUS(b,i) (IE_RBD_ADDR(b,i) + 0)
|
||||
#define IE_RBD_NEXT(b,i) (IE_RBD_ADDR(b,i) + 2)
|
||||
#define IE_RBD_BUFADDR(b,i) (IE_RBD_ADDR(b,i) + 4)
|
||||
#define IE_RBD_BUFLEN(b,i) (IE_RBD_ADDR(b,i) + 8)
|
||||
|
||||
/* RBD status fields */
|
||||
#define IE_RBD_LAST 0x8000 /* last buffer */
|
||||
#define IE_RBD_USED 0x4000 /* this buffer has data */
|
||||
#define IE_RBD_CNTMASK 0x3fff /* byte count of buffer data */
|
||||
|
||||
/* RDB `End Of List' flag; encoded in `buffer length' field */
|
||||
#define IE_RBD_EOL 0x8000 /* last buffer */
|
||||
|
||||
|
||||
/*
|
||||
* All commands share this in common.
|
||||
*-
|
||||
struct __ie_cmd_common {
|
||||
u_int16_t ie_cmd_status; // status of this command
|
||||
u_int16_t ie_cmd_cmd; // command word
|
||||
u_int16_t ie_cmd_link; // link to next command
|
||||
};
|
||||
*/
|
||||
#define IE_CMD_COMMON_SZ 6
|
||||
#define IE_CMD_COMMON_STATUS(base) ((base) + 0)
|
||||
#define IE_CMD_COMMON_CMD(base) ((base) + 2)
|
||||
#define IE_CMD_COMMON_LINK(base) ((base) + 4)
|
||||
|
||||
#define IE_STAT_COMPL 0x8000 /* command is completed */
|
||||
#define IE_STAT_BUSY 0x4000 /* command is running now */
|
||||
#define IE_STAT_OK 0x2000 /* command completed successfully */
|
||||
#define IE_STAT_ABORT 0x1000 /* command was aborted */
|
||||
|
||||
#define IE_CMD_NOP 0x0000 /* NOP */
|
||||
#define IE_CMD_IASETUP 0x0001 /* initial address setup */
|
||||
#define IE_CMD_CONFIG 0x0002 /* configure command */
|
||||
#define IE_CMD_MCAST 0x0003 /* multicast setup command */
|
||||
#define IE_CMD_XMIT 0x0004 /* transmit command */
|
||||
#define IE_CMD_TDR 0x0005 /* time-domain reflectometer command */
|
||||
#define IE_CMD_DUMP 0x0006 /* dump command */
|
||||
#define IE_CMD_DIAGNOSE 0x0007 /* diagnostics command */
|
||||
|
||||
#define IE_CMD_LAST 0x8000 /* this is the last command in the list */
|
||||
#define IE_CMD_SUSPEND 0x4000 /* suspend CU after this command */
|
||||
#define IE_CMD_INTR 0x2000 /* post an interrupt after completion */
|
||||
|
||||
/*
|
||||
* No-op commands; just like COMMON but "indexable"
|
||||
*/
|
||||
#define IE_CMD_NOP_SZ IE_CMD_COMMON_SZ
|
||||
#define IE_CMD_NOP_ADDR(base,i) ((base) + (i) * IE_CMD_NOP_SZ)
|
||||
#define IE_CMD_NOP_STATUS(b,i) (IE_CMD_NOP_ADDR(b,i) + 0)
|
||||
#define IE_CMD_NOP_CMD(b,i) (IE_CMD_NOP_ADDR(b,i) + 2)
|
||||
#define IE_CMD_NOP_LINK(b,i) (IE_CMD_NOP_ADDR(b,i) + 4)
|
||||
|
||||
|
||||
/*
|
||||
* This is the command to transmit a frame.
|
||||
*-
|
||||
struct __ie_xmit_cmd {
|
||||
struct __ie_cmd_common com; // common part
|
||||
#define __ie_xmit_status com.ie_cmd_status
|
||||
|
||||
u_int16_t ie_xmit_desc; // pointer to buffer descriptor
|
||||
struct __ie_en_addr ie_xmit_addr; // destination address
|
||||
u_int16_t ie_xmit_length; // 802.3 length/Ether type field
|
||||
};
|
||||
*/
|
||||
#define IE_CMD_XMIT_SZ (IE_CMD_COMMON_SZ + 10)
|
||||
#define IE_CMD_XMIT_ADDR(base,i) ((base) + (i) * IE_CMD_XMIT_SZ)
|
||||
#define IE_CMD_XMIT_STATUS(b,i) \
|
||||
(IE_CMD_XMIT_ADDR(b,i) + 0) /* == CMD_COMMON_STATUS */
|
||||
#define IE_CMD_XMIT_CMD(b,i) \
|
||||
(IE_CMD_XMIT_ADDR(b,i) + 2) /* == CMD_COMMON_CMD */
|
||||
#define IE_CMD_XMIT_LINK(b,i) \
|
||||
(IE_CMD_XMIT_ADDR(b,i) + 4) /* == CMD_COMMON_LINK */
|
||||
#define IE_CMD_XMIT_DESC(b,i) \
|
||||
(IE_CMD_XMIT_ADDR(b,i) + IE_CMD_COMMON_SZ + 0)
|
||||
#define IE_CMD_XMIT_EADDR(b,i) \
|
||||
(IE_CMD_XMIT_ADDR(b,i) + IE_CMD_COMMON_SZ + 2)
|
||||
#define IE_CMD_XMIT_LEN(b,i) \
|
||||
(IE_CMD_XMIT_ADDR(b,i) + IE_CMD_COMMON_SZ + 8)
|
||||
|
||||
#define IE_XS_MAXCOLL 0x000f /* number of collisions during transmit */
|
||||
#define IE_XS_EXCMAX 0x0020 /* exceeded maximum number of collisions */
|
||||
#define IE_XS_SQE 0x0040 /* SQE positive */
|
||||
#define IE_XS_DEFERRED 0x0080 /* transmission deferred */
|
||||
#define IE_XS_UNDERRUN 0x0100 /* DMA underrun */
|
||||
#define IE_XS_LOSTCTS 0x0200 /* Lost CTS */
|
||||
#define IE_XS_NOCARRIER 0x0400 /* No Carrier */
|
||||
#define IE_XS_LATECOLL 0x0800 /* Late collision */
|
||||
|
||||
/*
|
||||
* This is a buffer descriptor for a frame to be transmitted.
|
||||
*-
|
||||
struct __ie_xmit_buf {
|
||||
u_int16_t ie_xmit_flags; // see below
|
||||
u_int16_t ie_xmit_next; // 16-pointer to next desc
|
||||
caddr_t ie_xmit_buf; // 24-pointer to the actual buffer
|
||||
};
|
||||
*/
|
||||
#define IE_XBD_SZ 8
|
||||
#define IE_XBD_ADDR(base,i) ((base) + (i) * IE_XBD_SZ)
|
||||
#define IE_XBD_FLAGS(b,i) (IE_XBD_ADDR(b,i) + 0)
|
||||
#define IE_XBD_NEXT(b,i) (IE_XBD_ADDR(b,i) + 2)
|
||||
#define IE_XBD_BUF(b,i) (IE_XBD_ADDR(b,i) + 4)
|
||||
|
||||
#define IE_TBD_EOL 0x8000 /* this TBD is the last one */
|
||||
#define IE_TBD_CNTMASK 0x3fff /* The rest of the `flags' word
|
||||
is actually the length. */
|
||||
|
||||
|
||||
/*
|
||||
* Multicast setup command.
|
||||
*-
|
||||
struct __ie_mcast_cmd {
|
||||
struct __ie_cmd_common com; // common part
|
||||
#define ie_mcast_status com.ie_cmd_status
|
||||
|
||||
// size (in bytes) of multicast addresses
|
||||
u_short ie_mcast_bytes;
|
||||
struct __ie_en_addr ie_mcast_addrs[IE_MAXMCAST + 1];// space for them
|
||||
};
|
||||
*/
|
||||
#define IE_CMD_MCAST_SZ (IE_CMD_COMMON_SZ + 2 /* + XXX */)
|
||||
#define IE_CMD_MCAST_BYTES(base) ((base) + IE_CMD_COMMON_SZ + 0)
|
||||
#define IE_CMD_MCAST_MADDR(base) ((base) + IE_CMD_COMMON_SZ + 2)
|
||||
|
||||
/*
|
||||
* Time Domain Reflectometer command.
|
||||
*-
|
||||
struct __ie_tdr_cmd {
|
||||
struct __ie_cmd_common com; // common part
|
||||
#define ie_tdr_status com.ie_cmd_status
|
||||
u_short ie_tdr_time; // error bits and time
|
||||
};
|
||||
*/
|
||||
#define IE_CMD_TDR_SZ (IE_CMD_COMMON_SZ + 2)
|
||||
#define IE_CMD_TDR_TIME(base) ((base) + IE_CMD_COMMON_SZ + 0)
|
||||
|
||||
#define IE_TDR_SUCCESS 0x8000 /* TDR succeeded without error */
|
||||
#define IE_TDR_XCVR 0x4000 /* detected a transceiver problem */
|
||||
#define IE_TDR_OPEN 0x2000 /* detected an incorrect termination ("open") */
|
||||
#define IE_TDR_SHORT 0x1000 /* TDR detected a short circuit */
|
||||
#define IE_TDR_TIME 0x07ff /* mask for reflection time */
|
||||
|
||||
/*
|
||||
* Initial Address Setup command
|
||||
*-
|
||||
struct __ie_iasetup_cmd {
|
||||
struct __ie_cmd_common com;
|
||||
#define ie_iasetup_status com.ie_cmd_status
|
||||
struct __ie_en_addr ie_address;
|
||||
};
|
||||
*/
|
||||
#define IE_CMD_IAS_SZ (IE_CMD_COMMON_SZ + 6)
|
||||
#define IE_CMD_IAS_EADDR(base) ((base) + IE_CMD_COMMON_SZ + 0)
|
||||
|
||||
/*
|
||||
* Configuration command
|
||||
*-
|
||||
struct __ie_config_cmd {
|
||||
struct __ie_cmd_common com; // common part
|
||||
#define ie_config_status com.ie_cmd_status
|
||||
|
||||
u_int8_t ie_config_count; // byte count (0x0c)
|
||||
u_int8_t ie_fifo; // fifo (8)
|
||||
u_int8_t ie_save_bad; // save bad frames (0x40)
|
||||
u_int8_t ie_addr_len; // address length (0x2e) (AL-LOC == 1)
|
||||
u_int8_t ie_priority; // priority and backoff (0x0)
|
||||
u_int8_t ie_ifs; // inter-frame spacing (0x60)
|
||||
u_int8_t ie_slot_low; // slot time, LSB (0x0)
|
||||
u_int8_t ie_slot_high; // slot time, MSN, and retries (0xf2)
|
||||
u_int8_t ie_promisc; // 1 if promiscuous, else 0
|
||||
u_int8_t ie_crs_cdt; // CSMA/CD parameters (0x0)
|
||||
u_int8_t ie_min_len; // min frame length (0x40)
|
||||
u_int8_t ie_junk; // stuff for 82596 (0xff)
|
||||
};
|
||||
*/
|
||||
#define IE_CMD_CFG_SZ (IE_CMD_COMMON_SZ + 12)
|
||||
#define IE_CMD_CFG_CNT(base) ((base) + IE_CMD_COMMON_SZ + 0)
|
||||
#define IE_CMD_CFG_FIFO(base) ((base) + IE_CMD_COMMON_SZ + 1)
|
||||
#define IE_CMD_CFG_SAVEBAD(base) ((base) + IE_CMD_COMMON_SZ + 2)
|
||||
#define IE_CMD_CFG_ADDRLEN(base) ((base) + IE_CMD_COMMON_SZ + 3)
|
||||
#define IE_CMD_CFG_PRIORITY(base) ((base) + IE_CMD_COMMON_SZ + 4)
|
||||
#define IE_CMD_CFG_IFS(base) ((base) + IE_CMD_COMMON_SZ + 5)
|
||||
#define IE_CMD_CFG_SLOT_LOW(base) ((base) + IE_CMD_COMMON_SZ + 6)
|
||||
#define IE_CMD_CFG_SLOT_HIGH(base) ((base) + IE_CMD_COMMON_SZ + 7)
|
||||
#define IE_CMD_CFG_PROMISC(base) ((base) + IE_CMD_COMMON_SZ + 8)
|
||||
#define IE_CMD_CFG_CRSCDT(base) ((base) + IE_CMD_COMMON_SZ + 9)
|
||||
#define IE_CMD_CFG_MINLEN(base) ((base) + IE_CMD_COMMON_SZ + 10)
|
||||
#define IE_CMD_CFG_JUNK(base) ((base) + IE_CMD_COMMON_SZ + 11)
|
||||
319
c/src/libchip/network/i82586var.h
Normal file
319
c/src/libchip/network/i82586var.h
Normal file
@@ -0,0 +1,319 @@
|
||||
/* $NetBSD: i82586var.h,v 1.15 2001/01/22 22:28:45 bjh21 Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Paul Kranenburg and Charles M. Hannum.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, University of Vermont and State
|
||||
* Agricultural College.
|
||||
* Copyright (c) 1992, 1993, Garrett A. Wollman.
|
||||
*
|
||||
* Portions:
|
||||
* Copyright (c) 1994, 1995, Rafal K. Boni
|
||||
* Copyright (c) 1990, 1991, William F. Jolitz
|
||||
* Copyright (c) 1990, The Regents of the University of California
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of Vermont
|
||||
* and State Agricultural College and Garrett A. Wollman, by William F.
|
||||
* Jolitz, and by the University of California, Berkeley, Lawrence
|
||||
* Berkeley Laboratory, and its contributors.
|
||||
* 4. Neither the names of the Universities nor the names of the authors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR AUTHORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Intel 82586 Ethernet chip
|
||||
* Register, bit, and structure definitions.
|
||||
*
|
||||
* Original StarLAN driver written by Garrett Wollman with reference to the
|
||||
* Clarkson Packet Driver code for this chip written by Russ Nelson and others.
|
||||
*
|
||||
* BPF support code taken from hpdev/if_le.c, supplied with tcpdump.
|
||||
*
|
||||
* 3C507 support is loosely based on code donated to NetBSD by Rafal Boni.
|
||||
*
|
||||
* Majorly cleaned up and 3C507 code merged by Charles Hannum.
|
||||
*
|
||||
* Converted to SUN ie driver by Charles D. Cranor,
|
||||
* October 1994, January 1995.
|
||||
* This sun version based on i386 version 1.30.
|
||||
*/
|
||||
|
||||
#ifndef I82586_DEBUG
|
||||
#define I82586_DEBUG 0
|
||||
#endif
|
||||
|
||||
/* Debug elements */
|
||||
#define IED_RINT 0x01
|
||||
#define IED_TINT 0x02
|
||||
#define IED_RNR 0x04
|
||||
#define IED_CNA 0x08
|
||||
#define IED_READFRAME 0x10
|
||||
#define IED_ENQ 0x20
|
||||
#define IED_XMIT 0x40
|
||||
#define IED_ALL 0x7f
|
||||
|
||||
#define B_PER_F 3 /* recv buffers per frame */
|
||||
#define IE_RBUF_SIZE 256 /* size of each receive buffer;
|
||||
MUST BE POWER OF TWO */
|
||||
#define NTXBUF 2 /* number of transmit commands */
|
||||
#define IE_TBUF_SIZE ETHER_MAX_LEN /* length of transmit buffer */
|
||||
|
||||
#define IE_MAXMCAST (IE_TBUF_SIZE/6)/* must fit in transmit buffer */
|
||||
|
||||
|
||||
#define INTR_ENTER 0 /* intr hook called on ISR entry */
|
||||
#define INTR_EXIT 1 /* intr hook called on ISR exit */
|
||||
#define INTR_LOOP 2 /* intr hook called on ISR loop */
|
||||
#define INTR_ACK 3 /* intr hook called on ie_ack */
|
||||
|
||||
#define CHIP_PROBE 0 /* reset called from chip probe */
|
||||
#define CARD_RESET 1 /* reset called from card reset */
|
||||
|
||||
#if I82586_DEBUG
|
||||
#define I82586_INTS_REQ 0
|
||||
#define I82586_INTS_IN 1
|
||||
#define I82586_INTS_LOOPS 2
|
||||
#define I82586_INTS_OUT 3
|
||||
#define I82586_RX_INT 4
|
||||
#define I82586_RX_DROP 5
|
||||
#define I82586_RX_ERR 6
|
||||
#define I82586_RX_OK 7
|
||||
#define I82586_RX_START 8
|
||||
#define I82586_START_TX 9
|
||||
#define I82586_TX_START 10
|
||||
#define I82586_TX_INT 11
|
||||
#define I82586_TX_REQ 12
|
||||
#define I82586_TX_EVT 13
|
||||
#define I82586_TX_EMIT 14
|
||||
#define I82586_TX_BAD 15
|
||||
#define I82586_TX_ACTIVE 16
|
||||
#define I82586_TRACE_CNT 17
|
||||
|
||||
#define I82586_TRACE_FLOW (10000)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ethernet status, per interface.
|
||||
*
|
||||
* The chip uses two types of pointers: 16 bit and 24 bit
|
||||
* 24 bit pointers cover the board's memory.
|
||||
* 16 bit pointers are offsets from the ISCP's `ie_base'
|
||||
*
|
||||
* The board's memory is represented by the bus handle `bh'. The MI
|
||||
* i82586 driver deals exclusively with offsets relative to the
|
||||
* board memory bus handle. The `ie_softc' fields below that are marked
|
||||
* `MD' are in the domain of the front-end driver; they opaque to the
|
||||
* MI driver part.
|
||||
*
|
||||
* The front-end is required to manage the SCP and ISCP structures. i.e.
|
||||
* allocate room for them on the board's memory, and arrange to point the
|
||||
* chip at the SCB stucture, the offset of which is passed to the MI
|
||||
* driver in `sc_scb'.
|
||||
*
|
||||
* The following functions provide the glue necessary to deal with
|
||||
* host and bus idiosyncracies:
|
||||
*
|
||||
* hwreset - board reset
|
||||
* hwinit - board initialization
|
||||
* chan_attn - get chip to look at prepared commands
|
||||
* intrhook - board dependent interrupt processing
|
||||
*
|
||||
* All of the following shared-memory access function use an offset
|
||||
* relative to the bus handle to indicate the shared memory location.
|
||||
* The bus_{read/write}N function take or return offset into the
|
||||
* shared memory in the host's byte-order.
|
||||
*
|
||||
* memcopyin - copy device memory: board to KVA
|
||||
* memcopyout - copy device memory: KVA to board
|
||||
* bus_read16 - read a 16-bit i82586 pointer
|
||||
`offset' argument will be 16-bit aligned
|
||||
* bus_write16 - write a 16-bit i82586 pointer
|
||||
`offset' argument will be 16-bit aligned
|
||||
* bus_write24 - write a 24-bit i82586 pointer
|
||||
`offset' argument will be 32-bit aligned
|
||||
* bus_barrier - perform a bus barrier operation, forcing
|
||||
all outstanding reads/writes to complete
|
||||
*
|
||||
*/
|
||||
|
||||
struct ie_softc {
|
||||
struct arpcom arpcom;
|
||||
|
||||
/*
|
||||
* For RTEMS we run the tx and rx handlers under a task due to the
|
||||
* network semaphore stuff.
|
||||
*/
|
||||
|
||||
rtems_id intr_task;
|
||||
rtems_id tx_task;
|
||||
|
||||
void *sc_iobase; /* (MD) KVA of base of 24 bit addr space */
|
||||
void *sc_maddr; /* (MD) KVA of base of chip's RAM
|
||||
(16bit addr space) */
|
||||
u_int sc_msize; /* (MD) how much RAM we have/use */
|
||||
|
||||
/* Bus glue */
|
||||
void (*hwreset) (struct ie_softc *, int);
|
||||
void (*hwinit) (struct ie_softc *);
|
||||
void (*chan_attn) (struct ie_softc *, int);
|
||||
int (*intrhook) (struct ie_softc *, int where);
|
||||
|
||||
void (*memcopyin) (struct ie_softc *, void *, int, size_t);
|
||||
void (*memcopyout) (struct ie_softc *, const void *,
|
||||
int, size_t);
|
||||
u_int16_t (*ie_bus_read16) (struct ie_softc *, int offset);
|
||||
void (*ie_bus_write16) (struct ie_softc *, int offset,
|
||||
u_int16_t value);
|
||||
void (*ie_bus_write24) (struct ie_softc *, int offset,
|
||||
int addr);
|
||||
void (*ie_bus_barrier) (struct ie_softc *, int offset,
|
||||
int length, int flags);
|
||||
|
||||
/* Media management */
|
||||
int (*sc_mediachange) (struct ie_softc *);
|
||||
/* card dependent media change */
|
||||
void (*sc_mediastatus) (struct ie_softc *, struct ifmediareq *);
|
||||
/* card dependent media status */
|
||||
|
||||
/*
|
||||
* Offsets (relative to bus handle) of the i82586 SYSTEM structures.
|
||||
*/
|
||||
int scp; /* Offset to the SCP (set by front-end) */
|
||||
int iscp; /* Offset to the ISCP (set by front-end) */
|
||||
int scb; /* Offset to SCB (set by front-end) */
|
||||
|
||||
/*
|
||||
* Offset and size of a block of board memory where the buffers
|
||||
* are to be allocated from (initialized by front-end).
|
||||
*/
|
||||
int buf_area; /* Start of descriptors and buffers */
|
||||
int buf_area_sz; /* Size of above */
|
||||
|
||||
/*
|
||||
* The buffers & descriptors (recv and xmit)
|
||||
*/
|
||||
int rframes; /* Offset to `nrxbuf' frame descriptors */
|
||||
int rbds; /* Offset to `nrxbuf' buffer descriptors */
|
||||
int rbufs; /* Offset to `nrxbuf' receive buffers */
|
||||
#define IE_RBUF_ADDR(sc, i) (sc->rbufs + ((i) * IE_RBUF_SIZE))
|
||||
int rfhead, rftail;
|
||||
int rbhead, rbtail;
|
||||
int nframes; /* number of frames in use */
|
||||
int nrxbuf; /* number of recv buffs in use */
|
||||
int rnr_expect; /* XXX - expect a RCVR not ready interrupt */
|
||||
|
||||
int nop_cmds; /* Offset to NTXBUF no-op commands */
|
||||
int xmit_cmds; /* Offset to NTXBUF transmit commands */
|
||||
int xbds; /* Offset to NTXBUF buffer descriptors */
|
||||
int xbufs; /* Offset to NTXBUF transmit buffers */
|
||||
#define IE_XBUF_ADDR(sc, i) (sc->xbufs + ((i) * IE_TBUF_SIZE))
|
||||
|
||||
int xchead, xctail;
|
||||
int xmit_busy;
|
||||
int do_xmitnopchain; /* Controls use of xmit NOP chains */
|
||||
int xmit_req;
|
||||
|
||||
/* Multicast addresses */
|
||||
char *mcast_addrs; /* Current MC filter addresses */
|
||||
int mcast_addrs_size; /* Current size of MC buffer */
|
||||
int mcast_count; /* Current # of addrs in buffer */
|
||||
int want_mcsetup; /* run mcsetup at next opportunity */
|
||||
|
||||
int promisc; /* are we in promisc mode? */
|
||||
int async_cmd_inprogress; /* we didn't wait for 586 to accept
|
||||
a command */
|
||||
|
||||
#if I82586_DEBUG
|
||||
#define I82586_TRACE(s, e, d) \
|
||||
do { rtems_interrupt_level level; rtems_interrupt_disable (level); \
|
||||
(s)->trace_flow[(s)->trace_flow_in++] = (e); \
|
||||
(s)->trace_flow[(s)->trace_flow_in++] = (unsigned int)(d); \
|
||||
if ((s)->trace_flow_in >= I82586_TRACE_FLOW) { \
|
||||
(s)->trace_flow_in = 0; \
|
||||
(s)->trace_flow_wrap = 1; \
|
||||
} \
|
||||
rtems_interrupt_enable (level); \
|
||||
} while (0)
|
||||
|
||||
int sc_debug;
|
||||
unsigned int trace_flow[I82586_TRACE_FLOW * 2];
|
||||
unsigned int trace_flow_wrap;
|
||||
#endif
|
||||
unsigned int trace_flow_in;
|
||||
};
|
||||
|
||||
/* Exported functions */
|
||||
rtems_isr i82586_intr (rtems_vector_number , void *);
|
||||
int i82586_proberam (struct ie_softc *);
|
||||
int i82586_attach (struct rtems_bsdnet_ifconfig *config, int attaching);
|
||||
|
||||
/* Shortcut macros to optional (driver uses default if unspecified) callbacks */
|
||||
#define xIE_BUS_BARRIER(sc, offset, length, flags) \
|
||||
do { \
|
||||
if ((sc)->ie_bus_barrier) \
|
||||
((sc)->ie_bus_barrier)((sc), (offset), (length), (flags));\
|
||||
else \
|
||||
bus_space_barrier((sc)->bt, (sc)->bh, (offset), (length), \
|
||||
(flags)); \
|
||||
} while (0)
|
||||
|
||||
#define IE_BUS_BARRIER(sc, offset, length, flags)
|
||||
Reference in New Issue
Block a user