2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
1999-09-01 21:21:03 +00:00
|
|
|
* Copyright (c) 1995, David Greenman
|
|
|
|
* 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 unmodified, 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*
|
1999-09-05 15:21:05 +00:00
|
|
|
* $FreeBSD$
|
1999-09-01 21:21:03 +00:00
|
|
|
*/
|
|
|
|
|
2000-12-26 06:38:04 +00:00
|
|
|
#ifndef SYS_DEV_ED_IF_EDVAR_H
|
|
|
|
#define SYS_DEV_ED_IF_EDVAR_H
|
1999-09-01 21:21:03 +00:00
|
|
|
/*
|
|
|
|
* ed_softc: per line info and status
|
|
|
|
*/
|
|
|
|
struct ed_softc {
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp;
|
2005-08-28 23:56:25 +00:00
|
|
|
struct ifmedia ifmedia; /* Media info */
|
|
|
|
device_t dev;
|
|
|
|
struct mtx sc_mtx;
|
1999-09-01 21:21:03 +00:00
|
|
|
|
|
|
|
char *type_str; /* pointer to type string */
|
|
|
|
u_char vendor; /* interface vendor */
|
|
|
|
u_char type; /* interface type code */
|
2005-02-14 06:25:06 +00:00
|
|
|
u_char chip_type; /* the type of chip (one of ED_CHIP_TYPE_*) */
|
|
|
|
u_char isa16bit; /* width of access to card 0=8 or 1=16 */
|
|
|
|
u_char mem_shared; /* NIC memory is shared with host */
|
|
|
|
u_char xmit_busy; /* transmitter is busy */
|
2005-06-10 16:49:24 +00:00
|
|
|
u_char enaddr[6];
|
1999-09-01 21:21:03 +00:00
|
|
|
|
|
|
|
int port_used; /* nonzero if ports used */
|
|
|
|
struct resource* port_res; /* resource for port range */
|
2009-04-20 01:19:59 +00:00
|
|
|
struct resource* port_res2; /* resource for port range */
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_tag_t port_bst;
|
|
|
|
bus_space_handle_t port_bsh;
|
1999-09-01 21:21:03 +00:00
|
|
|
int mem_used; /* nonzero if memory used */
|
|
|
|
struct resource* mem_res; /* resource for memory range */
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_tag_t mem_bst;
|
|
|
|
bus_space_handle_t mem_bsh;
|
1999-09-01 21:21:03 +00:00
|
|
|
struct resource* irq_res; /* resource for irq */
|
|
|
|
void* irq_handle; /* handle for irq handler */
|
2005-09-18 20:51:34 +00:00
|
|
|
int (*sc_media_ioctl)(struct ed_softc *sc, struct ifreq *ifr,
|
|
|
|
u_long command);
|
|
|
|
void (*sc_mediachg)(struct ed_softc *);
|
2001-03-03 08:31:37 +00:00
|
|
|
device_t miibus; /* MII bus for cards with MII. */
|
2002-03-20 02:08:01 +00:00
|
|
|
void (*mii_writebits)(struct ed_softc *, u_int, int);
|
|
|
|
u_int (*mii_readbits)(struct ed_softc *, int);
|
2005-08-28 23:56:25 +00:00
|
|
|
struct callout tick_ch;
|
2009-11-17 14:23:09 +00:00
|
|
|
void (*sc_tick)(struct ed_softc *);
|
2005-08-28 23:56:25 +00:00
|
|
|
void (*readmem)(struct ed_softc *sc, bus_size_t src, uint8_t *dst,
|
|
|
|
uint16_t amount);
|
2006-01-27 19:10:13 +00:00
|
|
|
u_short (*sc_write_mbufs)(struct ed_softc *, struct mbuf *, bus_size_t);
|
1999-09-01 21:21:03 +00:00
|
|
|
|
2009-11-17 14:23:09 +00:00
|
|
|
int tx_timer;
|
2000-08-17 12:15:45 +00:00
|
|
|
int nic_offset; /* NIC (DS8390) I/O bus address offset */
|
|
|
|
int asic_offset; /* ASIC I/O bus address offset */
|
1999-09-01 21:21:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The following 'proto' variable is part of a work-around for 8013EBT asics
|
|
|
|
* being write-only. It's sort of a prototype/shadow of the real thing.
|
|
|
|
*/
|
|
|
|
u_char wd_laar_proto;
|
|
|
|
u_char cr_proto;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HP PC LAN PLUS card support.
|
|
|
|
*/
|
|
|
|
|
|
|
|
u_short hpp_options; /* flags controlling behaviour of the HP card */
|
|
|
|
u_short hpp_id; /* software revision and other fields */
|
2000-08-17 12:15:45 +00:00
|
|
|
caddr_t hpp_mem_start; /* Memory-mapped IO register address */
|
1999-09-01 21:21:03 +00:00
|
|
|
|
2005-08-28 23:56:25 +00:00
|
|
|
bus_size_t mem_start; /* NIC memory start address */
|
|
|
|
bus_size_t mem_end; /* NIC memory end address */
|
2005-01-19 07:37:32 +00:00
|
|
|
uint32_t mem_size; /* total NIC memory size */
|
2005-08-28 23:56:25 +00:00
|
|
|
bus_size_t mem_ring; /* start of RX ring-buffer (in NIC mem) */
|
1999-09-01 21:21:03 +00:00
|
|
|
|
|
|
|
u_char txb_cnt; /* number of transmit buffers */
|
|
|
|
u_char txb_inuse; /* number of TX buffers currently in-use */
|
|
|
|
|
|
|
|
u_char txb_new; /* pointer to where new buffer will be added */
|
|
|
|
u_char txb_next_tx; /* pointer to next buffer ready to xmit */
|
|
|
|
u_short txb_len[8]; /* buffered xmit buffer lengths */
|
|
|
|
u_char tx_page_start; /* first page of TX buffer area */
|
|
|
|
u_char rec_page_start; /* first page of RX ring-buffer */
|
|
|
|
u_char rec_page_stop; /* last page of RX ring-buffer */
|
|
|
|
u_char next_packet; /* pointer to next unread RX packet */
|
2006-06-12 04:30:42 +00:00
|
|
|
u_int tx_mem; /* Total amount of RAM for tx */
|
|
|
|
u_int rx_mem; /* Total amount of RAM for rx */
|
1999-09-01 21:21:03 +00:00
|
|
|
struct ifmib_iso_8802_3 mibdata; /* stuff for network mgmt */
|
|
|
|
};
|
1999-10-15 03:12:48 +00:00
|
|
|
|
2000-08-17 12:15:45 +00:00
|
|
|
#define ed_nic_inb(sc, port) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_1(sc->port_bst, sc->port_bsh, (sc)->nic_offset + (port))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_nic_outb(sc, port, value) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_1(sc->port_bst, sc->port_bsh, \
|
|
|
|
(sc)->nic_offset + (port), (value))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_nic_inw(sc, port) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_2(sc->port_bst, sc->port_bsh, (sc)->nic_offset + (port))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_nic_outw(sc, port, value) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_2(sc->port_bst, sc->port_bsh, \
|
|
|
|
(sc)->nic_offset + (port), (value))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_nic_insb(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_multi_1(sc->port_bst, sc->port_bsh, \
|
2000-08-17 12:15:45 +00:00
|
|
|
(sc)->nic_offset + (port), (addr), (count))
|
|
|
|
|
|
|
|
#define ed_nic_outsb(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_multi_1(sc->port_bst, sc->port_bsh, \
|
2000-08-17 12:15:45 +00:00
|
|
|
(sc)->nic_offset + (port), (addr), (count))
|
|
|
|
|
|
|
|
#define ed_nic_insw(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_multi_2(sc->port_bst, sc->port_bsh, \
|
2005-01-19 07:37:32 +00:00
|
|
|
(sc)->nic_offset + (port), (uint16_t *)(addr), (count))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_nic_outsw(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_multi_2(sc->port_bst, sc->port_bsh, \
|
2005-01-19 07:37:32 +00:00
|
|
|
(sc)->nic_offset + (port), (uint16_t *)(addr), (count))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_nic_insl(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_multi_4(sc->port_bst, sc->port_bsh, \
|
2005-01-19 07:37:32 +00:00
|
|
|
(sc)->nic_offset + (port), (uint32_t *)(addr), (count))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_nic_outsl(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_multi_4(sc->port_bst, sc->port_bsh, \
|
2005-01-19 07:37:32 +00:00
|
|
|
(sc)->nic_offset + (port), (uint32_t *)(addr), (count))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_asic_inb(sc, port) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_1(sc->port_bst, sc->port_bsh, \
|
|
|
|
(sc)->asic_offset + (port))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_asic_outb(sc, port, value) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_1(sc->port_bst, sc->port_bsh, \
|
|
|
|
(sc)->asic_offset + (port), (value))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_asic_inw(sc, port) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_2(sc->port_bst, sc->port_bsh, \
|
|
|
|
(sc)->asic_offset + (port))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_asic_outw(sc, port, value) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_2(sc->port_bst, sc->port_bsh, \
|
|
|
|
(sc)->asic_offset + (port), (value))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_asic_insb(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_multi_1(sc->port_bst, sc->port_bsh, \
|
2000-08-17 12:15:45 +00:00
|
|
|
(sc)->asic_offset + (port), (addr), (count))
|
|
|
|
|
|
|
|
#define ed_asic_outsb(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_multi_1(sc->port_bst, sc->port_bsh, \
|
2000-08-17 12:15:45 +00:00
|
|
|
(sc)->asic_offset + (port), (addr), (count))
|
|
|
|
|
|
|
|
#define ed_asic_insw(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_multi_2(sc->port_bst, sc->port_bsh, \
|
2005-01-19 07:37:32 +00:00
|
|
|
(sc)->asic_offset + (port), (uint16_t *)(addr), (count))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_asic_outsw(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_multi_2(sc->port_bst, sc->port_bsh, \
|
2005-01-19 07:37:32 +00:00
|
|
|
(sc)->asic_offset + (port), (uint16_t *)(addr), (count))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_asic_insl(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_read_multi_4(sc->port_bst, sc->port_bsh, \
|
2005-01-19 07:37:32 +00:00
|
|
|
(sc)->asic_offset + (port), (uint32_t *)(addr), (count))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
|
|
|
#define ed_asic_outsl(sc, port, addr, count) \
|
2005-02-22 05:12:25 +00:00
|
|
|
bus_space_write_multi_4(sc->port_bst, sc->port_bsh, \
|
2005-01-19 07:37:32 +00:00
|
|
|
(sc)->asic_offset + (port), (uint32_t *)(addr), (count))
|
2000-08-17 12:15:45 +00:00
|
|
|
|
2005-02-08 05:41:54 +00:00
|
|
|
void ed_release_resources(device_t);
|
|
|
|
int ed_alloc_port(device_t, int, int);
|
|
|
|
int ed_alloc_memory(device_t, int, int);
|
|
|
|
int ed_alloc_irq(device_t, int, int);
|
|
|
|
|
|
|
|
int ed_probe_generic8390(struct ed_softc *);
|
|
|
|
int ed_probe_WD80x3(device_t, int, int);
|
2005-02-08 05:59:43 +00:00
|
|
|
int ed_probe_WD80x3_generic(device_t, int, uint16_t *[]);
|
2005-10-05 05:21:07 +00:00
|
|
|
int ed_probe_RTL80x9(device_t, int, int);
|
2005-02-20 18:44:45 +00:00
|
|
|
#ifdef ED_3C503
|
2005-02-08 05:41:54 +00:00
|
|
|
int ed_probe_3Com(device_t, int, int);
|
2005-02-20 18:44:45 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ED_SIC
|
2005-02-08 05:41:54 +00:00
|
|
|
int ed_probe_SIC(device_t, int, int);
|
2005-02-20 18:44:45 +00:00
|
|
|
#endif
|
2005-09-07 03:20:33 +00:00
|
|
|
int ed_probe_Novell_generic(device_t, int);
|
2005-02-08 05:41:54 +00:00
|
|
|
int ed_probe_Novell(device_t, int, int);
|
2005-02-14 22:28:51 +00:00
|
|
|
void ed_Novell_read_mac(struct ed_softc *);
|
2005-02-20 18:44:45 +00:00
|
|
|
#ifdef ED_HPP
|
2005-02-08 05:41:54 +00:00
|
|
|
int ed_probe_HP_pclanp(device_t, int, int);
|
2005-02-20 18:44:45 +00:00
|
|
|
#endif
|
2005-02-08 05:41:54 +00:00
|
|
|
|
|
|
|
int ed_attach(device_t);
|
2005-02-08 05:45:35 +00:00
|
|
|
int ed_detach(device_t);
|
2005-02-08 23:57:43 +00:00
|
|
|
int ed_clear_memory(device_t);
|
2005-02-09 20:03:40 +00:00
|
|
|
int ed_isa_mem_ok(device_t, u_long, u_int); /* XXX isa specific */
|
2005-02-08 05:41:54 +00:00
|
|
|
void ed_stop(struct ed_softc *);
|
2005-08-28 23:56:25 +00:00
|
|
|
void ed_shmem_readmem16(struct ed_softc *, bus_size_t, uint8_t *, uint16_t);
|
|
|
|
void ed_shmem_readmem8(struct ed_softc *, bus_size_t, uint8_t *, uint16_t);
|
2006-01-27 19:10:13 +00:00
|
|
|
u_short ed_shmem_write_mbufs(struct ed_softc *, struct mbuf *, bus_size_t);
|
2005-08-28 23:56:25 +00:00
|
|
|
void ed_pio_readmem(struct ed_softc *, bus_size_t, uint8_t *, uint16_t);
|
2005-02-08 05:59:43 +00:00
|
|
|
void ed_pio_writemem(struct ed_softc *, uint8_t *, uint16_t, uint16_t);
|
2006-01-27 19:10:13 +00:00
|
|
|
u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, bus_size_t);
|
2005-02-09 20:03:40 +00:00
|
|
|
|
2005-02-10 23:48:13 +00:00
|
|
|
void ed_disable_16bit_access(struct ed_softc *);
|
|
|
|
void ed_enable_16bit_access(struct ed_softc *);
|
|
|
|
|
2009-04-07 05:41:38 +00:00
|
|
|
void ed_gen_ifmedia_init(struct ed_softc *);
|
|
|
|
|
1999-10-15 03:12:48 +00:00
|
|
|
driver_intr_t edintr;
|
|
|
|
|
2000-12-26 06:38:04 +00:00
|
|
|
extern devclass_t ed_devclass;
|
2005-02-14 22:28:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Vendor types
|
|
|
|
*/
|
|
|
|
#define ED_VENDOR_WD_SMC 0x00 /* Western Digital/SMC */
|
|
|
|
#define ED_VENDOR_3COM 0x01 /* 3Com */
|
|
|
|
#define ED_VENDOR_NOVELL 0x02 /* Novell */
|
|
|
|
#define ED_VENDOR_HP 0x03 /* Hewlett Packard */
|
|
|
|
#define ED_VENDOR_SIC 0x04 /* Allied-Telesis SIC */
|
|
|
|
|
|
|
|
/*
|
2006-01-27 07:51:26 +00:00
|
|
|
* Configure time flags
|
2005-02-14 22:28:51 +00:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* this sets the default for enabling/disabling the transceiver
|
|
|
|
*/
|
|
|
|
#define ED_FLAGS_DISABLE_TRANCEIVER 0x0001
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This forces the board to be used in 8/16bit mode even if it
|
|
|
|
* autoconfigs differently
|
|
|
|
*/
|
|
|
|
#define ED_FLAGS_FORCE_8BIT_MODE 0x0002
|
|
|
|
#define ED_FLAGS_FORCE_16BIT_MODE 0x0004
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This disables the use of double transmit buffers.
|
|
|
|
*/
|
|
|
|
#define ED_FLAGS_NO_MULTI_BUFFERING 0x0008
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This forces all operations with the NIC memory to use Programmed
|
|
|
|
* I/O (i.e. not via shared memory)
|
|
|
|
*/
|
|
|
|
#define ED_FLAGS_FORCE_PIO 0x0010
|
|
|
|
|
2009-03-28 04:56:56 +00:00
|
|
|
/*
|
|
|
|
* This forces a PC Card, and disables ISA memory range checks
|
|
|
|
*/
|
|
|
|
#define ED_FLAGS_PCCARD 0x0020
|
|
|
|
|
2005-02-14 22:28:51 +00:00
|
|
|
/*
|
|
|
|
* These are flags describing the chip type.
|
|
|
|
*/
|
|
|
|
#define ED_FLAGS_TOSH_ETHER 0x10000
|
|
|
|
#define ED_FLAGS_GWETHER 0x20000
|
|
|
|
|
|
|
|
#define ED_FLAGS_GETTYPE(flg) ((flg) & 0xff0000)
|
|
|
|
|
2005-08-28 23:56:25 +00:00
|
|
|
#define ED_MUTEX(_sc) (&(_sc)->sc_mtx)
|
|
|
|
#define ED_LOCK(_sc) mtx_lock(ED_MUTEX(_sc))
|
|
|
|
#define ED_UNLOCK(_sc) mtx_unlock(ED_MUTEX(_sc))
|
|
|
|
#define ED_LOCK_INIT(_sc) \
|
|
|
|
mtx_init(ED_MUTEX(_sc), device_get_nameunit(_sc->dev), \
|
|
|
|
MTX_NETWORK_LOCK, MTX_DEF)
|
|
|
|
#define ED_LOCK_DESTROY(_sc) mtx_destroy(ED_MUTEX(_sc));
|
|
|
|
#define ED_ASSERT_LOCKED(_sc) mtx_assert(ED_MUTEX(_sc), MA_OWNED);
|
|
|
|
#define ED_ASSERT_UNLOCKED(_sc) mtx_assert(ED_MUTEX(_sc), MA_NOTOWNED);
|
|
|
|
|
2000-12-26 06:38:04 +00:00
|
|
|
#endif /* SYS_DEV_ED_IF_EDVAR_H */
|