Deleted Added
full compact
30c30
< * $FreeBSD: head/sys/dev/atkbdc/atkbdc.c 56836 2000-01-29 15:08:56Z peter $
---
> * $FreeBSD: head/sys/dev/atkbdc/atkbdc.c 58271 2000-03-19 03:25:13Z yokota $
39c39
< #include <sys/kernel.h>
---
> #include <sys/bus.h>
41a42,45
> #include <machine/bus_pio.h>
> #include <machine/bus.h>
> #include <machine/resource.h>
> #include <sys/rman.h>
67a72,78
> #define read_data(k) (bus_space_read_1((k)->iot, (k)->ioh0, 0))
> #define read_status(k) (bus_space_read_1((k)->iot, (k)->ioh1, 0))
> #define write_data(k, d) \
> (bus_space_write_1((k)->iot, (k)->ioh0, 0, (d)))
> #define write_command(k, d) \
> (bus_space_write_1((k)->iot, (k)->ioh1, 0, (d)))
>
83c94,95
< static int atkbdc_setup(atkbdc_softc_t *sc, int port);
---
> static int atkbdc_setup(atkbdc_softc_t *sc, bus_space_tag_t tag,
> bus_space_handle_t h0, bus_space_handle_t h1);
107d118
< sc->port = -1; /* XXX */
113c124
< atkbdc_probe_unit(int unit, int port)
---
> atkbdc_probe_unit(int unit, struct resource *port0, struct resource *port1)
115c126
< if (port <= 0)
---
> if (rman_get_start(port0) <= 0)
116a128,129
> if (rman_get_start(port1) <= 0)
> return ENXIO;
121c134,135
< atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, int port)
---
> atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, struct resource *port0,
> struct resource *port1)
123c137,139
< return atkbdc_setup(sc, port);
---
> return atkbdc_setup(sc, rman_get_bustag(port0),
> rman_get_bushandle(port0),
> rman_get_bushandle(port1));
130c146,173
< return atkbdc_setup(atkbdc_softc[0], -1);
---
> bus_space_tag_t tag;
> bus_space_handle_t h0;
> bus_space_handle_t h1;
> int port0;
> int port1;
>
> port0 = IO_KBD;
> resource_int_value("atkbdc", 0, "port", &port0);
> port1 = IO_KBD + KBD_STATUS_PORT;
> #if 0
> resource_int_value("atkbdc", 0, "port", &port0);
> #endif
>
> /* XXX: tag should be passed from the caller */
> #if defined(__i386__)
> tag = I386_BUS_SPACE_IO;
> #elif defined(__alpha__)
> tag = ALPHA_BUS_SPACE_IO;
> #endif
>
> #if notyet
> bus_space_map(tag, port0, IO_KBDSIZE, 0, &h0);
> bus_space_map(tag, port1, IO_KBDSIZE, 0, &h1);
> #else
> h0 = (bus_space_handle_t)port0;
> h1 = (bus_space_handle_t)port1;
> #endif
> return atkbdc_setup(atkbdc_softc[0], tag, h0, h1);
134c177,178
< atkbdc_setup(atkbdc_softc_t *sc, int port)
---
> atkbdc_setup(atkbdc_softc_t *sc, bus_space_tag_t tag, bus_space_handle_t h0,
> bus_space_handle_t h1)
136,139c180
< if (port <= 0)
< port = IO_KBD;
<
< if (sc->port <= 0) {
---
> if (sc->ioh0 == 0) { /* XXX */
152c193,195
< sc->port = port; /* may override the previous value */
---
> sc->iot = tag;
> sc->ioh0 = h0;
> sc->ioh1 = h1;
156,157c199
< /* associate a port number with a KBDC */
<
---
> /* open a keyboard controller */
159c201
< kbdc_open(int port)
---
> atkbdc_open(int unit)
161,182c203,209
< int s;
< int i;
<
< if (port <= 0)
< port = IO_KBD;
<
< s = spltty();
< for (i = 0; i < sizeof(atkbdc_softc)/sizeof(atkbdc_softc[0]); ++i) {
< if (atkbdc_softc[i] == NULL)
< continue;
< if (atkbdc_softc[i]->port == port) {
< splx(s);
< return (KBDC)atkbdc_softc[i];
< }
< if (atkbdc_softc[i]->port <= 0) {
< if (atkbdc_setup(atkbdc_softc[i], port))
< break;
< splx(s);
< return (KBDC)atkbdc_softc[i];
< }
< }
< splx(s);
---
> if (unit <= 0)
> unit = 0;
> if (unit >= MAXKBDC)
> return NULL;
> if ((atkbdc_softc[unit]->port0 != NULL)
> || (atkbdc_softc[unit]->ioh0 != 0)) /* XXX */
> return (KBDC)atkbdc_softc[unit];
241c268
< || (inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL));
---
> || (read_status(kbdcp(p)) & KBDS_ANY_BUFFER_FULL));
287d313
< int port = kbdc->port;
290c316
< while ((f = inb(port + KBD_STATUS_PORT)) & KBDS_INPUT_BUFFER_FULL) {
---
> while ((f = read_status(kbdc)) & KBDS_INPUT_BUFFER_FULL) {
293c319
< addq(&kbdc->kbd, inb(port + KBD_DATA_PORT));
---
> addq(&kbdc->kbd, read_data(kbdc));
296c322
< addq(&kbdc->aux, inb(port + KBD_DATA_PORT));
---
> addq(&kbdc->aux, read_data(kbdc));
314d339
< int port = kbdc->port;
317c342
< while ((f = inb(port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) == 0) {
---
> while ((f = read_status(kbdc) & KBDS_ANY_BUFFER_FULL) == 0) {
332d356
< int port = kbdc->port;
335c359
< while ((f = inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
---
> while ((f = read_status(kbdc) & KBDS_BUFFER_FULL)
339c363
< addq(&kbdc->aux, inb(port + KBD_DATA_PORT));
---
> addq(&kbdc->aux, read_data(kbdc));
358d381
< int port = kbdc->port;
363c386
< if ((f = inb(port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
---
> if ((f = read_status(kbdc)) & KBDS_ANY_BUFFER_FULL) {
365c388
< b = inb(port + KBD_DATA_PORT);
---
> b = read_data(kbdc);
386d408
< int port = kbdc->port;
389c411
< while ((f = inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
---
> while ((f = read_status(kbdc) & KBDS_BUFFER_FULL)
393c415
< addq(&kbdc->kbd, inb(port + KBD_DATA_PORT));
---
> addq(&kbdc->kbd, read_data(kbdc));
412d433
< int port = kbdc->port;
417c438
< if ((f = inb(port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
---
> if ((f = read_status(kbdc)) & KBDS_ANY_BUFFER_FULL) {
419c440
< b = inb(port + KBD_DATA_PORT);
---
> b = read_data(kbdc);
440c461
< outb(kbdcp(p)->port + KBD_COMMAND_PORT, c);
---
> write_command(kbdcp(p), c);
450c471
< outb(kbdcp(p)->port + KBD_DATA_PORT, c);
---
> write_data(kbdcp(p), c);
460c481
< outb(kbdcp(p)->port + KBD_DATA_PORT, c);
---
> write_data(kbdcp(p), c);
589c610
< return inb(kbdcp(p)->port + KBD_DATA_PORT);
---
> return read_data(kbdcp(p));
614c635
< return inb(kbdcp(p)->port + KBD_DATA_PORT);
---
> return read_data(kbdcp(p));
637c658
< f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
---
> f = read_status(kbdcp(p)) & KBDS_BUFFER_FULL;
640,641c661,662
< addq(&kbdcp(p)->aux, inb(kbdcp(p)->port + KBD_DATA_PORT));
< f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
---
> addq(&kbdcp(p)->aux, read_data(kbdcp(p)));
> f = read_status(kbdcp(p)) & KBDS_BUFFER_FULL;
645c666
< return inb(kbdcp(p)->port + KBD_DATA_PORT);
---
> return read_data(kbdcp(p));
658c679
< return inb(kbdcp(p)->port + KBD_DATA_PORT);
---
> return read_data(kbdcp(p));
671c692
< f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
---
> f = read_status(kbdcp(p)) & KBDS_BUFFER_FULL;
674,675c695,696
< addq(&kbdcp(p)->kbd, inb(kbdcp(p)->port + KBD_DATA_PORT));
< f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
---
> addq(&kbdcp(p)->kbd, read_data(kbdcp(p)));
> f = read_status(kbdcp(p)) & KBDS_BUFFER_FULL;
679c700
< return inb(kbdcp(p)->port + KBD_DATA_PORT);
---
> return read_data(kbdcp(p));
698c719
< if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
---
> if ((f = read_status(kbdcp(p))) & KBDS_ANY_BUFFER_FULL) {
700c721
< b = inb(kbdcp(p)->port + KBD_DATA_PORT);
---
> b = read_data(kbdcp(p));
737c758
< if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
---
> if ((f = read_status(kbdcp(p))) & KBDS_ANY_BUFFER_FULL) {
739c760
< b = inb(kbdcp(p)->port + KBD_DATA_PORT);
---
> b = read_data(kbdcp(p));
775c796
< if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
---
> if ((f = read_status(kbdcp(p))) & KBDS_ANY_BUFFER_FULL) {
777c798
< (void)inb(kbdcp(p)->port + KBD_DATA_PORT);
---
> (void)read_data(kbdcp(p));