1139749Simp/*-
254994Simp * Copyright (c) 1999 M. Warner Losh <imp@village.org>
354994Simp * All rights reserved.
454994Simp *
554994Simp * Redistribution and use in source and binary forms, with or without
654994Simp * modification, are permitted provided that the following conditions
754994Simp * are met:
854994Simp * 1. Redistributions of source code must retain the above copyright
954994Simp *    notice, this list of conditions and the following disclaimer.
1054994Simp * 2. Redistributions in binary form must reproduce the above copyright
1154994Simp *    notice, this list of conditions and the following disclaimer in the
1254994Simp *    documentation and/or other materials provided with the distribution.
1354994Simp *
1454994Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1554994Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1654994Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1754994Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1854994Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1954994Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2054994Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2154994Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2254994Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2354994Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2454994Simp *
2554994Simp * $FreeBSD$
2654994Simp */
2754994Simp
2854994Simp#ifndef _IF_SNVAR_H
2954994Simp#define _IF_SNVAR_H
3054994Simp
3154994Simp#include <net/if_arp.h>
3254994Simp
3354994Simpstruct sn_softc {
34147256Sbrooks	struct ifnet    *ifp;
35121589Simp	struct mtx sc_mtx;
36199559Sjhb	struct callout watchdog;
37199559Sjhb	int		timer;
3854994Simp	int             pages_wanted;	/* Size of outstanding MMU ALLOC */
3954994Simp	int             intr_mask;	/* Most recently set interrupt mask */
4054994Simp	device_t	dev;
4154994Simp	void		*intrhand;
4254994Simp	struct resource *irq_res;
4354994Simp	int		irq_rid;
4454994Simp	struct resource	*port_res;
4554994Simp	int		port_rid;
46149095Simp	struct resource	*modem_res;	/* Extra resource for modem */
47149095Simp	int		modem_rid;
4854994Simp};
4954994Simp
50147797Simpint	sn_probe(device_t);
5154994Simpint	sn_attach(device_t);
5269955Simpint	sn_detach(device_t);
5354994Simpvoid	sn_intr(void *);
5454994Simp
5554994Simpint	sn_activate(device_t);
5654994Simpvoid	sn_deactivate(device_t);
5754994Simp
58199414Sjhb#define CSR_READ_1(sc, off) (bus_read_1((sc)->port_res, off))
59199414Sjhb#define CSR_READ_2(sc, off) (bus_read_2((sc)->port_res, off))
60121514Simp#define CSR_WRITE_1(sc, off, val) \
61199414Sjhb	bus_write_1((sc)->port_res, off, val)
62121514Simp#define CSR_WRITE_2(sc, off, val) \
63199414Sjhb	bus_write_2((sc)->port_res, off, val)
64121514Simp#define CSR_WRITE_MULTI_1(sc, off, addr, count) \
65199414Sjhb	bus_write_multi_1((sc)->port_res, off, addr, count)
66121514Simp#define CSR_WRITE_MULTI_2(sc, off, addr, count) \
67199414Sjhb	bus_write_multi_2((sc)->port_res, off, addr, count)
68121514Simp#define CSR_READ_MULTI_1(sc, off, addr, count) \
69199414Sjhb	bus_read_multi_1((sc)->port_res, off, addr, count)
70121514Simp#define CSR_READ_MULTI_2(sc, off, addr, count) \
71199414Sjhb	bus_read_multi_2((sc)->port_res, off, addr, count)
72121514Simp
73121514Simp#define SN_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
74121514Simp#define	SN_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
75121514Simp#define SN_LOCK_INIT(_sc) \
76121514Simp	mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \
77121514Simp	    MTX_NETWORK_LOCK, MTX_DEF)
78150183Sru#define SN_LOCK_DESTROY(_sc)	mtx_destroy(&_sc->sc_mtx);
79121514Simp#define SN_ASSERT_LOCKED(_sc)	mtx_assert(&_sc->sc_mtx, MA_OWNED);
80121514Simp#define SN_ASSERT_UNLOCKED(_sc)	mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);
81121514Simp
8254994Simp#endif /* _IF_SNVAR_H */
83