1 /*	$OpenBSD: am7990var.h,v 1.9 2002/03/14 01:26:54 millert Exp $	*/
2 /*	$NetBSD: am7990var.h,v 1.8 1996/07/05 23:57:01 abrown Exp $	*/
3 
4 /*
5  * Copyright (c) 1995 Charles M. Hannum.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by Charles M. Hannum.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifdef DDB
34 #define	integrate
35 #define hide
36 #else
37 #define	integrate	static __inline
38 #define hide		static
39 #endif
40 
41 /*
42  * Ethernet software status per device.
43  *
44  * Each interface is referenced by a network interface structure,
45  * arpcom.ac_if, which the routing code uses to locate the interface.
46  * This structure contains the output queue for the interface, its address, ...
47  *
48  * NOTE: this structure MUST be the first element in machine-dependent
49  * le_softc structures!  This is designed SPECIFICALLY to make it possible
50  * to simply cast a "void *" to "struct le_softc *" or to
51  * "struct am7990_softc *".  Among other things, this saves a lot of hair
52  * in the interrupt handlers.
53  */
54 struct am7990_softc {
55 	struct	device sc_dev;		/* base device glue */
56 	struct	arpcom sc_arpcom;	/* Ethernet common part */
57 
58 	/*
59 	 * Memory functions:
60 	 *
61 	 *	copy to/from descriptor
62 	 *	copy to/from buffer
63 	 *	zero bytes in buffer
64 	 */
65 	void	(*sc_copytodesc)(struct am7990_softc *, void *, int, int);
66 	void	(*sc_copyfromdesc)(struct am7990_softc *, void *, int, int);
67 	void	(*sc_copytobuf)(struct am7990_softc *, void *, int, int);
68 	void	(*sc_copyfrombuf)(struct am7990_softc *, void *, int, int);
69 	void	(*sc_zerobuf)(struct am7990_softc *, int, int);
70 
71 	/*
72 	 * Machine-dependent functions:
73 	 *
74 	 *	read/write CSR
75 	 *	hardware reset hook - may be NULL
76 	 *	hardware init hook - may be NULL
77 	 *	no carrier hook - may be NULL
78 	 */
79 	u_int16_t (*sc_rdcsr)(struct am7990_softc *, u_int16_t);
80 	void	(*sc_wrcsr)(struct am7990_softc *, u_int16_t, u_int16_t);
81 	void	(*sc_hwreset)(struct am7990_softc *);
82 	void	(*sc_hwinit)(struct am7990_softc *);
83 	void	(*sc_nocarrier)(struct am7990_softc *);
84 
85 	int	sc_hasifmedia;
86 	struct	ifmedia sc_ifmedia;
87 
88 	void	*sc_sh;		/* shutdownhook cookie */
89 
90 	u_int16_t sc_conf3;	/* CSR3 value */
91 
92 	void	*sc_mem;	/* base address of RAM -- CPU's view */
93 	u_long	sc_addr;	/* base address of RAM -- LANCE's view */
94 
95 	u_long	sc_memsize;	/* size of RAM */
96 
97 	int	sc_nrbuf;	/* number of receive buffers */
98 	int	sc_ntbuf;	/* number of transmit buffers */
99 	int	sc_last_rd;
100 	int	sc_first_td, sc_last_td, sc_no_td;
101 
102 	int	sc_initaddr;
103 	int	sc_rmdaddr;
104 	int	sc_tmdaddr;
105 	int	sc_rbufaddr;
106 	int	sc_tbufaddr;
107 
108 #ifdef LEDEBUG
109 	int	sc_debug;
110 #endif
111 };
112 
113 /* Export this to machine-dependent drivers. */
114 extern struct cfdriver le_cd;
115 
116 void am7990_config(struct am7990_softc *);
117 void am7990_init(struct am7990_softc *);
118 int am7990_ioctl(struct ifnet *, u_long, caddr_t);
119 void am7990_meminit(struct am7990_softc *);
120 void am7990_reset(struct am7990_softc *);
121 void am7990_setladrf(struct arpcom *, u_int16_t *);
122 void am7990_start(struct ifnet *);
123 void am7990_stop(struct am7990_softc *);
124 void am7990_watchdog(struct ifnet *);
125 int am7990_intr(void *);
126 
127 /*
128  * The following functions are only useful on certain cpu/bus
129  * combinations.  They should be written in assembly language for
130  * maximum efficiency, but machine-independent versions are provided
131  * for drivers that have not yet been optimized.
132  */
133 void am7990_copytobuf_contig(struct am7990_softc *, void *, int, int);
134 void am7990_copyfrombuf_contig(struct am7990_softc *, void *, int, int);
135 void am7990_zerobuf_contig(struct am7990_softc *, int, int);
136 
137 #if 0	/* Example only - see am7990.c */
138 void am7990_copytobuf_gap2(struct am7990_softc *, void *, int, int);
139 void am7990_copyfrombuf_gap2(struct am7990_softc *, void *, int, int);
140 void am7990_zerobuf_gap2(struct am7990_softc *, int, int);
141 
142 void am7990_copytobuf_gap16(struct am7990_softc *, void *, int, int);
143 void am7990_copyfrombuf_gap16(struct am7990_softc *, void *, int, int);
144 void am7990_zerobuf_gap16(struct am7990_softc *, int, int);
145 #endif /* Example only */
146