Convert to critical sections.
[dragonfly.git] / sys / dev / netif / cm / if_cm_isa.c
CommitLineData
984263bc
MD
1/* $NetBSD: if_bah_zbus.c,v 1.6 2000/01/23 21:06:12 aymeric Exp $ */
2/* $FreeBSD: src/sys/dev/cm/if_cm_isa.c,v 1.1.2.1 2002/02/13 22:33:41 fjoe Exp $ */
1fe12906 3/* $DragonFly: src/sys/dev/netif/cm/Attic/if_cm_isa.c,v 1.7 2005/06/13 21:38:12 joerg Exp $ */
984263bc
MD
4
5/*-
6 * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
7 * All rights reserved.
8 *
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Ignatios Souvatzis.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the NetBSD
23 * Foundation, Inc. and its contributors.
24 * 4. Neither the name of The NetBSD Foundation nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/socket.h>
44#include <sys/kernel.h>
45
46#include <sys/module.h>
47#include <sys/bus.h>
48
49#include <machine/bus.h>
50
51#include <net/if.h>
52#include <net/if_arc.h>
53
1f2de5d4 54#include "smc90cx6var.h"
984263bc 55
b5101a88
RG
56static int cm_isa_probe (device_t);
57static int cm_isa_attach (device_t);
984263bc
MD
58
59static int
60cm_isa_probe(dev)
61 device_t dev;
62{
63 struct cm_softc *sc = device_get_softc(dev);
64 int error;
65
66 bzero(sc, sizeof(struct cm_softc));
67
68 error = cm_probe(dev);
69 if (error == 0)
70 goto end;
71
72end:
73 if (error == 0)
74 error = cm_alloc_irq(dev, 0);
75
76 cm_release_resources(dev);
77 return (error);
78}
79
80static int
81cm_isa_attach(dev)
82 device_t dev;
83{
84 struct cm_softc *sc = device_get_softc(dev);
85 int error;
86
87 cm_alloc_port(dev, sc->port_rid, sc->port_used);
88 cm_alloc_memory(dev, sc->mem_rid, sc->mem_used);
89 cm_alloc_irq(dev, sc->irq_rid);
90
91 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
e9cb6d99 92 cmintr, sc, &sc->irq_handle, NULL);
984263bc
MD
93 if (error) {
94 cm_release_resources(dev);
95 return (error);
96 }
97
3e4a09e7 98 return cm_attach(dev);
984263bc
MD
99}
100
101static int
102cm_isa_detach(device_t dev)
103{
104 struct cm_softc *sc = device_get_softc(dev);
105 struct ifnet *ifp = &sc->sc_arccom.ac_if;
106 int s;
107
108 cm_stop(sc);
109 ifp->if_flags &= ~IFF_RUNNING;
110
1fe12906 111 crit_enter();
984263bc 112 arc_ifdetach(&sc->sc_arccom.ac_if);
984263bc 113 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
1fe12906
JS
114
115 crit_exit();
116
984263bc
MD
117 cm_release_resources(dev);
118
119 return (0);
120}
121
122static device_method_t cm_isa_methods[] = {
123 /* Device interface */
124 DEVMETHOD(device_probe, cm_isa_probe),
125 DEVMETHOD(device_attach, cm_isa_attach),
126 DEVMETHOD(device_detach, cm_isa_detach),
127
128 { 0, 0 }
129};
130
131static driver_t cm_isa_driver = {
132 "cm",
133 cm_isa_methods,
134 sizeof(struct cm_softc)
135};
136
137DRIVER_MODULE(if_cm, isa, cm_isa_driver, cm_devclass, 0, 0);