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.5 1999/05/09 20:45:53 peter Exp $ |
27 */ 28 29#include "atkbdc.h" 30#include "opt_kbd.h" 31 32#if NATKBDC > 0 33 34#include <sys/param.h> --- 25 unchanged lines hidden (view full) --- 60static int atkbdc_read_ivar(device_t bus, device_t dev, int index, 61 u_long *val); 62static int atkbdc_write_ivar(device_t bus, device_t dev, int index, 63 u_long val); 64 65static device_method_t atkbdc_methods[] = { 66 DEVMETHOD(device_probe, atkbdc_probe), 67 DEVMETHOD(device_attach, atkbdc_attach), |
68 DEVMETHOD(device_suspend, bus_generic_suspend), 69 DEVMETHOD(device_resume, bus_generic_resume), |
70 71 DEVMETHOD(bus_print_child, atkbdc_print_child), 72 DEVMETHOD(bus_read_ivar, atkbdc_read_ivar), 73 DEVMETHOD(bus_write_ivar, atkbdc_write_ivar), 74 DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), 75 DEVMETHOD(bus_release_resource, bus_generic_release_resource), 76 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 77 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), --- 7 unchanged lines hidden (view full) --- 85 ATKBDC_DRIVER_NAME, 86 atkbdc_methods, 87 sizeof(atkbdc_softc_t *), 88}; 89 90static int 91atkbdc_probe(device_t dev) 92{ |
93 int error; 94 |
95 device_set_desc(dev, "keyboard controller (i8042)"); |
96 error = atkbdc_probe_unit(device_get_unit(dev), isa_get_port(dev)); |
97 if (error == 0) |
98 isa_set_portsize(dev, IO_KBDSIZE); |
99 return error; 100} 101 102static void 103atkbdc_add_device(device_t dev, const char *name, int unit) 104{ 105 atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev); 106 atkbdc_device_t *kdev; --- 19 unchanged lines hidden (view full) --- 126 127 child = device_add_child(dev, name, unit, kdev); 128} 129 130static int 131atkbdc_attach(device_t dev) 132{ 133 atkbdc_softc_t *sc; |
134 int unit; 135 int error; |
136 int i; 137 |
138 unit = device_get_unit(dev); |
139 sc = *(atkbdc_softc_t **)device_get_softc(dev); |
140 if (sc == NULL) { 141 /* 142 * We have to maintain two copies of the kbdc_softc struct, 143 * as the low-level console needs to have access to the 144 * keyboard controller before kbdc is probed and attached. 145 * kbdc_soft[] contains the default entry for that purpose. 146 * See atkbdc.c. XXX 147 */ 148 sc = atkbdc_get_softc(unit); 149 if (sc == NULL) 150 return ENOMEM; 151 } |
152 |
153 error = atkbdc_attach_unit(unit, sc, isa_get_port(dev)); 154 if (error) 155 return error; 156 *(atkbdc_softc_t **)device_get_softc(dev) = sc; 157 |
158 /* 159 * Add all devices configured to be attached to atkbdc0. 160 */ 161 for (i = resource_query_string(-1, "at", "atkbdc0"); 162 i != -1; 163 i = resource_query_string(i, "at", "atkbdc0")) { 164 atkbdc_add_device(dev, resource_query_name(i), 165 resource_query_unit(i)); --- 79 unchanged lines hidden --- |