Deleted Added
full compact
atkbdc_isa.c (147271) atkbdc_isa.c (158041)
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

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

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
27#include <sys/cdefs.h>
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

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

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
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/atkbdc/atkbdc_isa.c 147271 2005-06-10 20:56:38Z marius $");
28__FBSDID("$FreeBSD: head/sys/dev/atkbdc/atkbdc_isa.c 158041 2006-04-26 06:05:16Z sobomax $");
29
30#include "opt_kbd.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/bus.h>

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

88atkbdc_isa_probe(device_t dev)
89{
90 struct resource *port0;
91 struct resource *port1;
92 u_long start;
93 u_long count;
94 int error;
95 int rid;
29
30#include "opt_kbd.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/bus.h>

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

88atkbdc_isa_probe(device_t dev)
89{
90 struct resource *port0;
91 struct resource *port1;
92 u_long start;
93 u_long count;
94 int error;
95 int rid;
96#if defined(__i386__)
97 bus_space_tag_t tag;
98 bus_space_handle_t ioh1;
99 volatile int i;
100 register_t flags;
101#endif
96
97 /* check PnP IDs */
98 if (ISA_PNP_PROBE(device_get_parent(dev), dev, atkbdc_ids) == ENXIO)
99 return ENXIO;
100
101 device_set_desc(dev, "Keyboard controller (i8042)");
102
103 /*

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

122 if (bus_get_resource(dev, SYS_RES_IOPORT, rid, NULL, NULL) != 0)
123 bus_set_resource(dev, SYS_RES_IOPORT, 1,
124 start + KBD_STATUS_PORT, 1);
125 port1 = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
126 if (port1 == NULL) {
127 bus_release_resource(dev, SYS_RES_IOPORT, 0, port0);
128 return ENXIO;
129 }
102
103 /* check PnP IDs */
104 if (ISA_PNP_PROBE(device_get_parent(dev), dev, atkbdc_ids) == ENXIO)
105 return ENXIO;
106
107 device_set_desc(dev, "Keyboard controller (i8042)");
108
109 /*

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

128 if (bus_get_resource(dev, SYS_RES_IOPORT, rid, NULL, NULL) != 0)
129 bus_set_resource(dev, SYS_RES_IOPORT, 1,
130 start + KBD_STATUS_PORT, 1);
131 port1 = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
132 if (port1 == NULL) {
133 bus_release_resource(dev, SYS_RES_IOPORT, 0, port0);
134 return ENXIO;
135 }
136
137#if defined(__i386__)
138 /*
139 * Check if we really have AT keyboard controller. Poll status
140 * register until we get "all clear" indication. If no such
141 * indication comes, it probably means that there is no AT
142 * keyboard controller present. Give up in such case. Check relies
143 * on the fact that reading from non-existing in/out port returns
144 * 0xff on i386. May or may not be true on other platforms.
145 */
146 tag = rman_get_bustag(port0);
147 ioh1 = rman_get_bushandle(port1);
148 flags = intr_disable();
149 for (i = 0; i != 65535; i++) {
150 if ((bus_space_read_1(tag, ioh1, 0) & 0x2) == 0)
151 break;
152 }
153 intr_restore(flags);
154 if (i == 65535) {
155 bus_release_resource(dev, SYS_RES_IOPORT, 0, port0);
156 bus_release_resource(dev, SYS_RES_IOPORT, 1, port1);
157 return ENXIO;
158 }
159#endif
160
130 device_verbose(dev);
131
132 error = atkbdc_probe_unit(device_get_unit(dev), port0, port1);
133 if (error == 0)
134 bus_generic_probe(dev);
135
136 bus_release_resource(dev, SYS_RES_IOPORT, 0, port0);
137 bus_release_resource(dev, SYS_RES_IOPORT, 1, port1);

--- 98 unchanged lines hidden ---
161 device_verbose(dev);
162
163 error = atkbdc_probe_unit(device_get_unit(dev), port0, port1);
164 if (error == 0)
165 bus_generic_probe(dev);
166
167 bus_release_resource(dev, SYS_RES_IOPORT, 0, port0);
168 bus_release_resource(dev, SYS_RES_IOPORT, 1, port1);

--- 98 unchanged lines hidden ---