Deleted Added
full compact
atkbdc_isa.c (47618) atkbdc_isa.c (48341)
1/*-
2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Redistribution 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 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Redistribution 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 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $Id: atkbdc_isa.c,v 1.7 1999/05/22 15:47:33 dfr Exp $
26 * $Id: atkbdc_isa.c,v 1.8 1999/05/30 11:12:27 dfr Exp $
27 */
28
29#include "atkbdc.h"
30#include "opt_kbd.h"
31
32#if NATKBDC > 0
33
34#include <sys/param.h>

--- 79 unchanged lines hidden (view full) ---

114
115static void
116atkbdc_add_device(device_t dev, const char *name, int unit)
117{
118 atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev);
119 atkbdc_device_t *kdev;
120 device_t child;
121 int t;
27 */
28
29#include "atkbdc.h"
30#include "opt_kbd.h"
31
32#if NATKBDC > 0
33
34#include <sys/param.h>

--- 79 unchanged lines hidden (view full) ---

114
115static void
116atkbdc_add_device(device_t dev, const char *name, int unit)
117{
118 atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev);
119 atkbdc_device_t *kdev;
120 device_t child;
121 int t;
122 int rid;
123 struct resource *port;
124
125 kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT);
126 if (!kdev)
127 return;
128 bzero(kdev, sizeof *kdev);
129
122
123 kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT);
124 if (!kdev)
125 return;
126 bzero(kdev, sizeof *kdev);
127
130 /* XXX should track resource in softc */
131 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
132 0, ~0, IO_KBDSIZE, RF_ACTIVE);
133 kdev->port = sc->port;
134
135 if (resource_int_value(name, unit, "irq", &t) == 0)
136 kdev->irq = t;
137 else
138 kdev->irq = -1;
139
140 if (resource_int_value(name, unit, "flags", &t) == 0)
141 kdev->flags = t;
142 else
143 kdev->flags = 0;
144
145 child = device_add_child(dev, name, unit, kdev);
146}
147
148static int
149atkbdc_attach(device_t dev)
150{
151 atkbdc_softc_t *sc;
128 kdev->port = sc->port;
129
130 if (resource_int_value(name, unit, "irq", &t) == 0)
131 kdev->irq = t;
132 else
133 kdev->irq = -1;
134
135 if (resource_int_value(name, unit, "flags", &t) == 0)
136 kdev->flags = t;
137 else
138 kdev->flags = 0;
139
140 child = device_add_child(dev, name, unit, kdev);
141}
142
143static int
144atkbdc_attach(device_t dev)
145{
146 atkbdc_softc_t *sc;
147 struct resource *port;
152 int unit;
153 int error;
148 int unit;
149 int error;
150 int rid;
154 int i;
155
156 unit = device_get_unit(dev);
157 sc = *(atkbdc_softc_t **)device_get_softc(dev);
158 if (sc == NULL) {
159 /*
160 * We have to maintain two copies of the kbdc_softc struct,
161 * as the low-level console needs to have access to the
162 * keyboard controller before kbdc is probed and attached.
163 * kbdc_soft[] contains the default entry for that purpose.
164 * See atkbdc.c. XXX
165 */
166 sc = atkbdc_get_softc(unit);
167 if (sc == NULL)
168 return ENOMEM;
169 }
170
151 int i;
152
153 unit = device_get_unit(dev);
154 sc = *(atkbdc_softc_t **)device_get_softc(dev);
155 if (sc == NULL) {
156 /*
157 * We have to maintain two copies of the kbdc_softc struct,
158 * as the low-level console needs to have access to the
159 * keyboard controller before kbdc is probed and attached.
160 * kbdc_soft[] contains the default entry for that purpose.
161 * See atkbdc.c. XXX
162 */
163 sc = atkbdc_get_softc(unit);
164 if (sc == NULL)
165 return ENOMEM;
166 }
167
171 error = atkbdc_attach_unit(unit, sc, isa_get_port(dev));
168 /* XXX should track resource in softc */
169 rid = 0;
170 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
171 0, ~0, IO_KBDSIZE, RF_ACTIVE);
172 if (!port)
173 return ENXIO;
174 error = atkbdc_attach_unit(unit, sc, rman_get_start(port));
172 if (error)
173 return error;
174 *(atkbdc_softc_t **)device_get_softc(dev) = sc;
175
176 /*
177 * Add all devices configured to be attached to atkbdc0.
178 */
179 for (i = resource_query_string(-1, "at", "atkbdc0");

--- 83 unchanged lines hidden ---
175 if (error)
176 return error;
177 *(atkbdc_softc_t **)device_get_softc(dev) = sc;
178
179 /*
180 * Add all devices configured to be attached to atkbdc0.
181 */
182 for (i = resource_query_string(-1, "at", "atkbdc0");

--- 83 unchanged lines hidden ---