atkbd_atkbdc.c (8a99777019d90941ac62dcf3b476880facf4099f) atkbd_atkbdc.c (e9deda23ae07ac86ee4f289ee3ac6979f2205627)
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: $
26 * $Id: atkbd_isa.c,v 1.1 1999/01/23 16:53:27 dfr Exp $
27 */
28
29#include "atkbd.h"
30#include "opt_kbd.h"
31
32#if NATKBD > 0
33
34#include <sys/param.h>

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

47
48#include <isa/isareg.h>
49#include <isa/isavar.h>
50
51devclass_t atkbd_devclass;
52
53static int atkbdprobe(device_t dev);
54static int atkbdattach(device_t dev);
27 */
28
29#include "atkbd.h"
30#include "opt_kbd.h"
31
32#if NATKBD > 0
33
34#include <sys/param.h>

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

47
48#include <isa/isareg.h>
49#include <isa/isavar.h>
50
51devclass_t atkbd_devclass;
52
53static int atkbdprobe(device_t dev);
54static int atkbdattach(device_t dev);
55static void atkbd_isa_intr(void *arg);
55
56static device_method_t atkbd_methods[] = {
57 DEVMETHOD(device_probe, atkbdprobe),
58 DEVMETHOD(device_attach, atkbdattach),
59 { 0, 0 }
60};
61
62static driver_t atkbd_driver = {
63 ATKBD_DRIVER_NAME,
64 atkbd_methods,
65 DRIVER_TYPE_TTY,
66 sizeof(atkbd_softc_t),
67};
68
69static int
70atkbdprobe(device_t dev)
71{
56
57static device_method_t atkbd_methods[] = {
58 DEVMETHOD(device_probe, atkbdprobe),
59 DEVMETHOD(device_attach, atkbdattach),
60 { 0, 0 }
61};
62
63static driver_t atkbd_driver = {
64 ATKBD_DRIVER_NAME,
65 atkbd_methods,
66 DRIVER_TYPE_TTY,
67 sizeof(atkbd_softc_t),
68};
69
70static int
71atkbdprobe(device_t dev)
72{
72 atkbd_softc_t *sc;
73 u_long port;
74 u_long irq;
75 u_long flags;
76
73 u_long port;
74 u_long irq;
75 u_long flags;
76
77 sc = (atkbd_softc_t *)device_get_softc(dev);
78
79 device_set_desc(dev, "AT Keyboard");
80
81 /* obtain parameters */
82 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
83 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
84 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
85
86 /* probe the device */
77 device_set_desc(dev, "AT Keyboard");
78
79 /* obtain parameters */
80 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
81 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
82 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
83
84 /* probe the device */
87 return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags);
85 return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
88}
89
90static int
91atkbdattach(device_t dev)
92{
93 atkbd_softc_t *sc;
86}
87
88static int
89atkbdattach(device_t dev)
90{
91 atkbd_softc_t *sc;
92 u_long port;
94 u_long irq;
93 u_long irq;
94 u_long flags;
95 struct resource *res;
96 void *ih;
97 int zero = 0;
98 int error;
99
100 sc = (atkbd_softc_t *)device_get_softc(dev);
101
95 struct resource *res;
96 void *ih;
97 int zero = 0;
98 int error;
99
100 sc = (atkbd_softc_t *)device_get_softc(dev);
101
102 error = atkbd_attach_unit(device_get_unit(dev), sc);
102 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
103 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
104 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
105
106 error = atkbd_attach_unit(device_get_unit(dev), sc, port, irq, flags);
103 if (error)
104 return error;
105
106 /* declare our interrupt handler */
107 if (error)
108 return error;
109
110 /* declare our interrupt handler */
107 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
108 res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
109 RF_SHAREABLE | RF_ACTIVE);
111 res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
112 RF_SHAREABLE | RF_ACTIVE);
110 BUS_SETUP_INTR(device_get_parent(dev), dev, res,
111 (driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd,
113 BUS_SETUP_INTR(device_get_parent(dev), dev, res, atkbd_isa_intr, sc,
112 &ih);
113
114 return 0;
115}
116
114 &ih);
115
116 return 0;
117}
118
119static void
120atkbd_isa_intr(void *arg)
121{
122 atkbd_softc_t *sc;
123
124 sc = (atkbd_softc_t *)arg;
125 (*kbdsw[sc->kbd->kb_index]->intr)(sc->kbd, NULL);
126}
127
117DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
118
119#endif /* NATKBD > 0 */
128DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
129
130#endif /* NATKBD > 0 */