Deleted Added
full compact
if_sbni_isa.c (113506) if_sbni_isa.c (119419)
1/*
2 * Copyright (c) 1997-2001 Granch, Ltd. All rights reserved.
3 * Author: Denis I.Timofeev <timofeev@granch.ru>
4 *
5 * Redistributon and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*
2 * Copyright (c) 1997-2001 Granch, Ltd. All rights reserved.
3 * Author: Denis I.Timofeev <timofeev@granch.ru>
4 *
5 * Redistributon and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/sbni/if_sbni_isa.c 113506 2003-04-15 06:37:30Z mdodd $
28 */
29
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/sbni/if_sbni_isa.c 119419 2003-08-24 18:03:45Z obrien $");
30
31
32
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/socket.h>
34
35#include <sys/bus.h>
36#include <sys/kernel.h>
37#include <sys/module.h>
38#include <machine/bus.h>
39#include <machine/resource.h>
40#include <sys/rman.h>
41
42#include <net/if.h>
43#include <net/ethernet.h>
44#include <net/if_arp.h>
45
46#include <isa/isavar.h>
47
48#include <dev/sbni/if_sbnireg.h>
49#include <dev/sbni/if_sbnivar.h>
50
51static int sbni_probe_isa(device_t);
52static int sbni_attach_isa(device_t);
53
54static device_method_t sbni_isa_methods[] = {
55 /* Device interface */
56 DEVMETHOD(device_probe, sbni_probe_isa),
57 DEVMETHOD(device_attach, sbni_attach_isa),
58 { 0, 0 }
59};
60
61static driver_t sbni_isa_driver = {
62 "sbni",
63 sbni_isa_methods,
64 sizeof(struct sbni_softc)
65};
66
67static devclass_t sbni_isa_devclass;
68static struct isa_pnp_id sbni_ids[] = {
69 { 0, NULL } /* we have no pnp sbni cards atm. */
70};
71
72DRIVER_MODULE(sbni, isa, sbni_isa_driver, sbni_isa_devclass, 0, 0);
73MODULE_DEPEND(sbni, isa, 1, 1, 1);
74
75static int
76sbni_probe_isa(device_t dev)
77{
78 struct sbni_softc *sc;
79 int error;
80
81 error = ISA_PNP_PROBE(device_get_parent(dev), dev, sbni_ids);
82 if (error && error != ENOENT)
83 return (error);
84
85 sc = device_get_softc(dev);
86 bzero(sc, sizeof(struct sbni_softc));
87
88 sc->io_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->io_rid,
89 0ul, ~0ul, SBNI_PORTS, RF_ACTIVE);
90 if (!sc->io_res) {
91 printf("sbni: cannot allocate io ports!\n");
92 return (ENOENT);
93 }
94
95 if (sbni_probe(sc) != 0) {
96 bus_release_resource(dev, SYS_RES_IOPORT,
97 sc->io_rid, sc->io_res);
98 return (ENXIO);
99 }
100
101 device_quiet(dev);
102 return (0);
103}
104
105
106static int
107sbni_attach_isa(device_t dev)
108{
109 struct sbni_softc *sc;
110 struct sbni_flags flags;
111 int error;
112
113 sc = device_get_softc(dev);
114
115 printf("sbni%d: <Granch SBNI12/ISA adapter> port 0x%lx",
116 next_sbni_unit, rman_get_start(sc->io_res));
117 sc->irq_res = bus_alloc_resource(
118 dev, SYS_RES_IRQ, &sc->irq_rid, 0ul, ~0ul, 1, RF_ACTIVE);
119
120 if (sc->irq_res) {
121 printf(" irq %ld\n", rman_get_start(sc->irq_res));
122 error = bus_setup_intr(
123 dev, sc->irq_res, INTR_TYPE_NET,
124 sbni_intr, sc, &sc->irq_handle);
125 if (error) {
126 printf("sbni%d: bus_setup_intr\n", next_sbni_unit);
127 bus_release_resource(
128 dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res);
129 bus_release_resource(
130 dev, SYS_RES_IRQ, sc->irq_rid, sc->irq_res);
131 return (error);
132 }
133
134#ifndef SBNI_DUAL_COMPOUND
135
136 } else {
137 printf("\nsbni%d: irq conflict!\n", next_sbni_unit);
138 bus_release_resource(dev, SYS_RES_IOPORT,
139 sc->io_rid, sc->io_res);
140 return (ENOENT);
141 }
142
143#else /* SBNI_DUAL_COMPOUND */
144
145 sc->link = sbni_headlist;
146 sbni_headlist = sc;
147 } else {
148 struct sbni_softc *master;
149
150 if ((master = connect_to_master(sc)) == 0) {
151 printf("\nsbni%d: failed to alloc irq\n",
152 next_sbni_unit);
153 bus_release_resource(
154 dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res);
155 return (ENXIO);
156 } else {
157 printf(" shared irq with sbni%d\n",
158 master->arpcom.ac_if.if_unit);
159 }
160 }
161#endif /* SBNI_DUAL_COMPOUND */
162
163 *(u_int32_t*)&flags = device_get_flags(dev);
164
165 sbni_attach(sc, next_sbni_unit++, flags);
166 return (0);
167}
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/socket.h>
36
37#include <sys/bus.h>
38#include <sys/kernel.h>
39#include <sys/module.h>
40#include <machine/bus.h>
41#include <machine/resource.h>
42#include <sys/rman.h>
43
44#include <net/if.h>
45#include <net/ethernet.h>
46#include <net/if_arp.h>
47
48#include <isa/isavar.h>
49
50#include <dev/sbni/if_sbnireg.h>
51#include <dev/sbni/if_sbnivar.h>
52
53static int sbni_probe_isa(device_t);
54static int sbni_attach_isa(device_t);
55
56static device_method_t sbni_isa_methods[] = {
57 /* Device interface */
58 DEVMETHOD(device_probe, sbni_probe_isa),
59 DEVMETHOD(device_attach, sbni_attach_isa),
60 { 0, 0 }
61};
62
63static driver_t sbni_isa_driver = {
64 "sbni",
65 sbni_isa_methods,
66 sizeof(struct sbni_softc)
67};
68
69static devclass_t sbni_isa_devclass;
70static struct isa_pnp_id sbni_ids[] = {
71 { 0, NULL } /* we have no pnp sbni cards atm. */
72};
73
74DRIVER_MODULE(sbni, isa, sbni_isa_driver, sbni_isa_devclass, 0, 0);
75MODULE_DEPEND(sbni, isa, 1, 1, 1);
76
77static int
78sbni_probe_isa(device_t dev)
79{
80 struct sbni_softc *sc;
81 int error;
82
83 error = ISA_PNP_PROBE(device_get_parent(dev), dev, sbni_ids);
84 if (error && error != ENOENT)
85 return (error);
86
87 sc = device_get_softc(dev);
88 bzero(sc, sizeof(struct sbni_softc));
89
90 sc->io_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->io_rid,
91 0ul, ~0ul, SBNI_PORTS, RF_ACTIVE);
92 if (!sc->io_res) {
93 printf("sbni: cannot allocate io ports!\n");
94 return (ENOENT);
95 }
96
97 if (sbni_probe(sc) != 0) {
98 bus_release_resource(dev, SYS_RES_IOPORT,
99 sc->io_rid, sc->io_res);
100 return (ENXIO);
101 }
102
103 device_quiet(dev);
104 return (0);
105}
106
107
108static int
109sbni_attach_isa(device_t dev)
110{
111 struct sbni_softc *sc;
112 struct sbni_flags flags;
113 int error;
114
115 sc = device_get_softc(dev);
116
117 printf("sbni%d: <Granch SBNI12/ISA adapter> port 0x%lx",
118 next_sbni_unit, rman_get_start(sc->io_res));
119 sc->irq_res = bus_alloc_resource(
120 dev, SYS_RES_IRQ, &sc->irq_rid, 0ul, ~0ul, 1, RF_ACTIVE);
121
122 if (sc->irq_res) {
123 printf(" irq %ld\n", rman_get_start(sc->irq_res));
124 error = bus_setup_intr(
125 dev, sc->irq_res, INTR_TYPE_NET,
126 sbni_intr, sc, &sc->irq_handle);
127 if (error) {
128 printf("sbni%d: bus_setup_intr\n", next_sbni_unit);
129 bus_release_resource(
130 dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res);
131 bus_release_resource(
132 dev, SYS_RES_IRQ, sc->irq_rid, sc->irq_res);
133 return (error);
134 }
135
136#ifndef SBNI_DUAL_COMPOUND
137
138 } else {
139 printf("\nsbni%d: irq conflict!\n", next_sbni_unit);
140 bus_release_resource(dev, SYS_RES_IOPORT,
141 sc->io_rid, sc->io_res);
142 return (ENOENT);
143 }
144
145#else /* SBNI_DUAL_COMPOUND */
146
147 sc->link = sbni_headlist;
148 sbni_headlist = sc;
149 } else {
150 struct sbni_softc *master;
151
152 if ((master = connect_to_master(sc)) == 0) {
153 printf("\nsbni%d: failed to alloc irq\n",
154 next_sbni_unit);
155 bus_release_resource(
156 dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res);
157 return (ENXIO);
158 } else {
159 printf(" shared irq with sbni%d\n",
160 master->arpcom.ac_if.if_unit);
161 }
162 }
163#endif /* SBNI_DUAL_COMPOUND */
164
165 *(u_int32_t*)&flags = device_get_flags(dev);
166
167 sbni_attach(sc, next_sbni_unit++, flags);
168 return (0);
169}