if_edvar.h revision 84151
1254721Semaste/*
2254721Semaste * Copyright (c) 1995, David Greenman
3254721Semaste * All rights reserved.
4254721Semaste *
5254721Semaste * Redistribution and use in source and binary forms, with or without
6254721Semaste * modification, are permitted provided that the following conditions
7254721Semaste * are met:
8254721Semaste * 1. Redistributions of source code must retain the above copyright
9254721Semaste *    notice unmodified, this list of conditions, and the following
10254721Semaste *    disclaimer.
11254721Semaste * 2. Redistributions in binary form must reproduce the above copyright
12254721Semaste *    notice, this list of conditions and the following disclaimer in the
13254721Semaste *    documentation and/or other materials provided with the distribution.
14254721Semaste *
15254721Semaste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16254721Semaste * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17254721Semaste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18254721Semaste * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19254721Semaste * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20254721Semaste * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21254721Semaste * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22254721Semaste * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23254721Semaste * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24254721Semaste * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25254721Semaste * SUCH DAMAGE.
26254721Semaste *
27254721Semaste * $FreeBSD: head/sys/dev/ed/if_edvar.h 84151 2001-09-29 22:32:03Z iedowse $
28254721Semaste */
29254721Semaste
30254721Semaste#ifndef SYS_DEV_ED_IF_EDVAR_H
31254721Semaste#define SYS_DEV_ED_IF_EDVAR_H
32254721Semaste/*
33254721Semaste * ed_softc: per line info and status
34254721Semaste */
35254721Semastestruct ed_softc {
36254721Semaste	struct arpcom arpcom;	/* ethernet common */
37254721Semaste
38254721Semaste	char   *type_str;	/* pointer to type string */
39254721Semaste	u_char  vendor;		/* interface vendor */
40254721Semaste	u_char  type;		/* interface type code */
41254721Semaste	u_char	gone;		/* HW missing, presumed having a good time */
42254721Semaste
43254721Semaste	int	port_rid;	/* resource id for port range */
44254721Semaste	int	port_used;	/* nonzero if ports used */
45254721Semaste	struct resource* port_res; /* resource for port range */
46254721Semaste	int	mem_rid;	/* resource id for memory range */
47254721Semaste	int	mem_used;	/* nonzero if memory used */
48254721Semaste	struct resource* mem_res; /* resource for memory range */
49254721Semaste	int	irq_rid;	/* resource id for irq */
50254721Semaste	struct resource* irq_res; /* resource for irq */
51254721Semaste	void*	irq_handle;	/* handle for irq handler */
52254721Semaste	device_t miibus;	/* MII bus for cards with MII. */
53254721Semaste	void	(*mii_writebits)__P((struct ed_softc *, u_int, int));
54254721Semaste	u_int	(*mii_readbits)__P((struct ed_softc *, int));
55254721Semaste	struct callout_handle tick_ch; /* Callout handle for ed_tick */
56254721Semaste
57254721Semaste	int	nic_offset;	/* NIC (DS8390) I/O bus address offset */
58254721Semaste	int	asic_offset;	/* ASIC I/O bus address offset */
59254721Semaste
60254721Semaste/*
61254721Semaste * The following 'proto' variable is part of a work-around for 8013EBT asics
62254721Semaste *	being write-only. It's sort of a prototype/shadow of the real thing.
63254721Semaste */
64254721Semaste	u_char  wd_laar_proto;
65254721Semaste	u_char	cr_proto;
66254721Semaste	u_char  isa16bit;	/* width of access to card 0=8 or 1=16 */
67254721Semaste	int	chip_type;	/* the type of chip (one of ED_CHIP_TYPE_*) */
68254721Semaste
69254721Semaste/*
70254721Semaste * HP PC LAN PLUS card support.
71254721Semaste */
72254721Semaste
73254721Semaste	u_short	hpp_options;	/* flags controlling behaviour of the HP card */
74254721Semaste	u_short hpp_id;		/* software revision and other fields */
75254721Semaste	caddr_t hpp_mem_start;	/* Memory-mapped IO register address */
76254721Semaste
77254721Semaste	caddr_t mem_start;	/* NIC memory start address */
78254721Semaste	caddr_t mem_end;		/* NIC memory end address */
79254721Semaste	u_int32_t mem_size;	/* total NIC memory size */
80254721Semaste	caddr_t mem_ring;	/* start of RX ring-buffer (in NIC mem) */
81254721Semaste
82254721Semaste	u_char  mem_shared;	/* NIC memory is shared with host */
83254721Semaste	u_char  xmit_busy;	/* transmitter is busy */
84254721Semaste	u_char  txb_cnt;	/* number of transmit buffers */
85254721Semaste	u_char  txb_inuse;	/* number of TX buffers currently in-use */
86254721Semaste
87254721Semaste	u_char  txb_new;	/* pointer to where new buffer will be added */
88254721Semaste	u_char  txb_next_tx;	/* pointer to next buffer ready to xmit */
89254721Semaste	u_short txb_len[8];	/* buffered xmit buffer lengths */
90254721Semaste	u_char  tx_page_start;	/* first page of TX buffer area */
91254721Semaste	u_char  rec_page_start;	/* first page of RX ring-buffer */
92254721Semaste	u_char  rec_page_stop;	/* last page of RX ring-buffer */
93254721Semaste	u_char  next_packet;	/* pointer to next unread RX packet */
94254721Semaste	struct	ifmib_iso_8802_3 mibdata; /* stuff for network mgmt */
95254721Semaste};
96254721Semaste
97254721Semaste#define	ed_nic_inb(sc, port) \
98254721Semaste	bus_space_read_1(rman_get_bustag((sc)->port_res), \
99254721Semaste		rman_get_bushandle((sc)->port_res), (sc)->nic_offset + (port))
100254721Semaste
101254721Semaste#define	ed_nic_outb(sc, port, value) \
102254721Semaste	bus_space_write_1(rman_get_bustag((sc)->port_res), \
103254721Semaste		rman_get_bushandle((sc)->port_res), (sc)->nic_offset + (port), \
104254721Semaste		(value))
105254721Semaste
106254721Semaste#define	ed_nic_inw(sc, port) \
107254721Semaste	bus_space_read_2(rman_get_bustag((sc)->port_res), \
108254721Semaste		rman_get_bushandle((sc)->port_res), (sc)->nic_offset + (port))
109254721Semaste
110254721Semaste#define	ed_nic_outw(sc, port, value) \
111254721Semaste	bus_space_write_2(rman_get_bustag((sc)->port_res), \
112254721Semaste		rman_get_bushandle((sc)->port_res), (sc)->nic_offset + (port), \
113254721Semaste		(value))
114254721Semaste
115254721Semaste#define	ed_nic_insb(sc, port, addr, count) \
116254721Semaste	bus_space_read_multi_1(rman_get_bustag((sc)->port_res), \
117254721Semaste		rman_get_bushandle((sc)->port_res), \
118254721Semaste		(sc)->nic_offset + (port), (addr), (count))
119254721Semaste
120254721Semaste#define	ed_nic_outsb(sc, port, addr, count) \
121254721Semaste	bus_space_write_multi_1(rman_get_bustag((sc)->port_res), \
122254721Semaste		rman_get_bushandle((sc)->port_res), \
123254721Semaste		(sc)->nic_offset + (port), (addr), (count))
124254721Semaste
125254721Semaste#define	ed_nic_insw(sc, port, addr, count) \
126254721Semaste	bus_space_read_multi_2(rman_get_bustag((sc)->port_res), \
127254721Semaste		rman_get_bushandle((sc)->port_res), \
128254721Semaste		(sc)->nic_offset + (port), (u_int16_t *)(addr), (count))
129254721Semaste
130254721Semaste#define	ed_nic_outsw(sc, port, addr, count) \
131254721Semaste	bus_space_write_multi_2(rman_get_bustag((sc)->port_res), \
132254721Semaste		rman_get_bushandle((sc)->port_res), \
133254721Semaste		(sc)->nic_offset + (port), (u_int16_t *)(addr), (count))
134254721Semaste
135254721Semaste#define	ed_nic_insl(sc, port, addr, count) \
136254721Semaste	bus_space_read_multi_4(rman_get_bustag((sc)->port_res), \
137254721Semaste		rman_get_bushandle((sc)->port_res), \
138254721Semaste		(sc)->nic_offset + (port), (u_int32_t *)(addr), (count))
139254721Semaste
140254721Semaste#define	ed_nic_outsl(sc, port, addr, count) \
141254721Semaste	bus_space_write_multi_4(rman_get_bustag((sc)->port_res), \
142254721Semaste		rman_get_bushandle((sc)->port_res), \
143254721Semaste		(sc)->nic_offset + (port), (u_int32_t *)(addr), (count))
144254721Semaste
145254721Semaste#define	ed_asic_inb(sc, port) \
146254721Semaste	bus_space_read_1(rman_get_bustag((sc)->port_res), \
147254721Semaste		rman_get_bushandle((sc)->port_res), (sc)->asic_offset + (port))
148254721Semaste
149254721Semaste#define	ed_asic_outb(sc, port, value) \
150254721Semaste	bus_space_write_1(rman_get_bustag((sc)->port_res), \
151254721Semaste		rman_get_bushandle((sc)->port_res), (sc)->asic_offset + (port), \
152254721Semaste		(value))
153254721Semaste
154254721Semaste#define	ed_asic_inw(sc, port) \
155254721Semaste	bus_space_read_2(rman_get_bustag((sc)->port_res), \
156254721Semaste		rman_get_bushandle((sc)->port_res), (sc)->asic_offset + (port))
157254721Semaste
158254721Semaste#define	ed_asic_outw(sc, port, value) \
159254721Semaste	bus_space_write_2(rman_get_bustag((sc)->port_res), \
160254721Semaste		rman_get_bushandle((sc)->port_res), (sc)->asic_offset + (port), \
161254721Semaste		(value))
162254721Semaste
163254721Semaste#define	ed_asic_insb(sc, port, addr, count) \
164254721Semaste	bus_space_read_multi_1(rman_get_bustag((sc)->port_res), \
165254721Semaste		rman_get_bushandle((sc)->port_res), \
166254721Semaste		(sc)->asic_offset + (port), (addr), (count))
167254721Semaste
168254721Semaste#define	ed_asic_outsb(sc, port, addr, count) \
169254721Semaste	bus_space_write_multi_1(rman_get_bustag((sc)->port_res), \
170254721Semaste		rman_get_bushandle((sc)->port_res), \
171254721Semaste		(sc)->asic_offset + (port), (addr), (count))
172254721Semaste
173254721Semaste#define	ed_asic_insw(sc, port, addr, count) \
174254721Semaste	bus_space_read_multi_2(rman_get_bustag((sc)->port_res), \
175254721Semaste		rman_get_bushandle((sc)->port_res), \
176254721Semaste		(sc)->asic_offset + (port), (u_int16_t *)(addr), (count))
177254721Semaste
178254721Semaste#define	ed_asic_outsw(sc, port, addr, count) \
179254721Semaste	bus_space_write_multi_2(rman_get_bustag((sc)->port_res), \
180254721Semaste		rman_get_bushandle((sc)->port_res), \
181254721Semaste		(sc)->asic_offset + (port), (u_int16_t *)(addr), (count))
182254721Semaste
183254721Semaste#define	ed_asic_insl(sc, port, addr, count) \
184254721Semaste	bus_space_read_multi_4(rman_get_bustag((sc)->port_res), \
185254721Semaste		rman_get_bushandle((sc)->port_res), \
186254721Semaste		(sc)->asic_offset + (port), (u_int32_t *)(addr), (count))
187254721Semaste
188254721Semaste#define	ed_asic_outsl(sc, port, addr, count) \
189254721Semaste	bus_space_write_multi_4(rman_get_bustag((sc)->port_res), \
190254721Semaste		rman_get_bushandle((sc)->port_res), \
191254721Semaste		(sc)->asic_offset + (port), (u_int32_t *)(addr), (count))
192254721Semaste
193254721Semastevoid	ed_release_resources	__P((device_t));
194254721Semasteint	ed_alloc_port		__P((device_t, int, int));
195254721Semasteint	ed_alloc_memory		__P((device_t, int, int));
196254721Semasteint	ed_alloc_irq		__P((device_t, int, int));
197254721Semaste
198254721Semasteint	ed_probe_generic8390	__P((struct ed_softc *));
199254721Semasteint	ed_probe_WD80x3		__P((device_t, int, int));
200254721Semasteint	ed_probe_WD80x3_generic	__P((device_t, int, unsigned short *[]));
201254721Semasteint	ed_probe_3Com		__P((device_t, int, int));
202254721Semasteint	ed_probe_Novell		__P((device_t, int, int));
203254721Semasteint	ed_probe_Novell_generic	__P((device_t, int));
204254721Semasteint	ed_probe_HP_pclanp	__P((device_t, int, int));
205254721Semaste
206254721Semasteint	ed_attach		__P((struct ed_softc *, int, int));
207254721Semastevoid	ed_stop			__P((struct ed_softc *));
208254721Semastevoid	ed_pio_readmem		__P((struct ed_softc *, int, unsigned char *,
209254721Semaste				     unsigned short));
210254721Semastevoid	ed_pio_writemem		__P((struct ed_softc *, char *,
211254721Semaste				     unsigned short, unsigned short));
212254721Semaste#ifndef ED_NO_MIIBUS
213254721Semasteint	ed_miibus_readreg	__P((device_t, int, int));
214254721Semastevoid	ed_miibus_writereg	__P((device_t, int, int, int));
215254721Semasteint	ed_ifmedia_upd		__P((struct ifnet *));
216254721Semastevoid	ed_ifmedia_sts		__P((struct ifnet *, struct ifmediareq *));
217254721Semastevoid	ed_child_detached	__P((device_t, device_t));
218254721Semaste#endif
219254721Semaste
220254721Semastedriver_intr_t	edintr;
221254721Semaste
222254721Semasteextern devclass_t ed_devclass;
223254721Semaste#endif /* SYS_DEV_ED_IF_EDVAR_H */
224254721Semaste