isa.c (46743) | isa.c (47178) |
---|---|
1/*- 2 * Copyright (c) 1998 Doug Rabson 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 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Doug Rabson 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 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: isa.c,v 1.124 1999/05/08 21:28:39 peter Exp $ | 26 * $Id: isa.c,v 1.125 1999/05/08 21:59:25 dfr Exp $ |
27 */ 28 29/* 30 * Modifications for Intel architecture by Garrett A. Wollman. 31 * Copyright 1998 Massachusetts Institute of Technology 32 * 33 * Permission to use, copy, modify, and distribute this software and 34 * its documentation for any purpose and without fee is hereby --- 52 unchanged lines hidden (view full) --- 87 struct resource *id_irqres[ISA_NIRQ_IVARS]; 88 struct resource *id_drqres[ISA_NDRQ_IVARS]; 89}; 90 91#define DEVTOISA(dev) ((struct isa_device *) device_get_ivars(dev)) 92 93static devclass_t isa_devclass; 94 | 27 */ 28 29/* 30 * Modifications for Intel architecture by Garrett A. Wollman. 31 * Copyright 1998 Massachusetts Institute of Technology 32 * 33 * Permission to use, copy, modify, and distribute this software and 34 * its documentation for any purpose and without fee is hereby --- 52 unchanged lines hidden (view full) --- 87 struct resource *id_irqres[ISA_NIRQ_IVARS]; 88 struct resource *id_drqres[ISA_NDRQ_IVARS]; 89}; 90 91#define DEVTOISA(dev) ((struct isa_device *) device_get_ivars(dev)) 92 93static devclass_t isa_devclass; 94 |
95static void 96isa_add_device(device_t dev, const char *name, int unit) 97{ 98 struct isa_device *idev; 99 device_t child; 100 int sensitive, t; 101 static device_t last_sensitive; 102 103 /* device-specific flag overrides any wildcard */ 104 sensitive = 0; 105 if (resource_int_value(name, unit, "sensitive", &sensitive) != 0) 106 resource_int_value(name, -1, "sensitive", &sensitive); 107 108 idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); 109 if (!idev) 110 return; 111 bzero(idev, sizeof *idev); 112 113 if (resource_int_value(name, unit, "port", &t) == 0) 114 idev->id_port[0] = t; 115 else 116 idev->id_port[0] = -1; 117 idev->id_port[1] = 0; 118 119 if (resource_int_value(name, unit, "portsize", &t) == 0) 120 idev->id_portsize[0] = t; 121 else 122 idev->id_portsize[0] = 0; 123 idev->id_portsize[1] = 0; 124 125 if (resource_int_value(name, unit, "maddr", &t) == 0) 126 idev->id_maddr[0] = t; 127 else 128 idev->id_maddr[0] = 0; 129 idev->id_maddr[1] = 0; 130 131 if (resource_int_value(name, unit, "msize", &t) == 0) 132 idev->id_msize[0] = t; 133 else 134 idev->id_msize[0] = 0; 135 idev->id_msize[1] = 0; 136 137 if (resource_int_value(name, unit, "flags", &t) == 0) 138 idev->id_flags = t; 139 else 140 idev->id_flags = 0; 141 142 if (resource_int_value(name, unit, "irq", &t) == 0) 143 idev->id_irq[0] = t; 144 else 145 idev->id_irq[0] = -1; 146 idev->id_irq[1] = -1; 147 148 if (resource_int_value(name, unit, "drq", &t) == 0) 149 idev->id_drq[0] = t; 150 else 151 idev->id_drq[0] = -1; 152 idev->id_drq[1] = -1; 153 154 if (sensitive) 155 child = device_add_child_after(dev, last_sensitive, name, 156 unit, idev); 157 else 158 child = device_add_child(dev, name, unit, idev); 159 if (child == 0) 160 return; 161 else if (sensitive) 162 last_sensitive = child; 163 164 if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0) 165 device_disable(child); 166} 167 | |
168/* 169 * At 'probe' time, we add all the devices which we know about to the 170 * bus. The generic attach routine will probe and attach them if they 171 * are alive. 172 */ 173static int 174isa_probe(device_t dev) 175{ | 95/* 96 * At 'probe' time, we add all the devices which we know about to the 97 * bus. The generic attach routine will probe and attach them if they 98 * are alive. 99 */ 100static int 101isa_probe(device_t dev) 102{ |
176 int i; 177 static char buf[] = "isaXXX"; 178 179 device_set_desc(dev, "ISA bus"); 180 181 /* 182 * Add all devices configured to be attached to isa0. 183 */ 184 sprintf(buf, "isa%d", device_get_unit(dev)); 185 for (i = resource_query_string(-1, "at", buf); 186 i != -1; 187 i = resource_query_string(i, "at", buf)) { 188 if (strcmp(resource_query_name(i), "atkbd") == 0) 189 continue; /* old GENERIC kludge */ 190 isa_add_device(dev, resource_query_name(i), 191 resource_query_unit(i)); 192 } 193 194 /* 195 * and isa? 196 */ 197 for (i = resource_query_string(-1, "at", "isa"); 198 i != -1; 199 i = resource_query_string(i, "at", "isa")) { 200 if (strcmp(resource_query_name(i), "atkbd") == 0) 201 continue; /* old GENERIC kludge */ 202 isa_add_device(dev, resource_query_name(i), 203 resource_query_unit(i)); 204 } 205 | |
206 isa_wrap_old_drivers(); | 103 isa_wrap_old_drivers(); |
207 208 return 0; | 104 return bus_generic_probe(dev); |
209} 210 211extern device_t isa_bus_device; 212 213static int 214isa_attach(device_t dev) 215{ 216 /* 217 * Arrange for bus_generic_attach(dev) to be called later. 218 */ 219 isa_bus_device = dev; 220 return 0; 221} 222 | 105} 106 107extern device_t isa_bus_device; 108 109static int 110isa_attach(device_t dev) 111{ 112 /* 113 * Arrange for bus_generic_attach(dev) to be called later. 114 */ 115 isa_bus_device = dev; 116 return 0; 117} 118 |
119/* 120 * Add a new child with default ivars. 121 */ 122static device_t 123isa_add_child(device_t dev, device_t place, const char *name, int unit) 124{ 125 struct isa_device *idev; 126 127 idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); 128 if (!idev) 129 return 0; 130 bzero(idev, sizeof *idev); 131 132 idev->id_port[0] = -1; 133 idev->id_port[1] = -1; 134 idev->id_portsize[0] = 0; 135 idev->id_portsize[1] = 0; 136 idev->id_maddr[0] = 0; 137 idev->id_maddr[1] = 0; 138 idev->id_msize[0] = 0; 139 idev->id_msize[1] = 0; 140 idev->id_irq[0] = -1; 141 idev->id_irq[1] = -1; 142 idev->id_drq[0] = -1; 143 idev->id_drq[1] = -1; 144 idev->id_flags = 0; 145 146 if (place) 147 return device_add_child_after(dev, place, name, unit, idev); 148 else 149 return device_add_child(dev, name, unit, idev); 150} 151 |
|
223static void 224isa_print_child(device_t bus, device_t dev) 225{ 226 struct isa_device *id = DEVTOISA(dev); 227 228 if (id->id_port[0] > 0 || id->id_port[1] > 0 229 || id->id_maddr[0] > 0 || id->id_maddr[1] > 0 230 || id->id_irq[0] >= 0 || id->id_irq[1] >= 0 --- 352 unchanged lines hidden (view full) --- 583 DEVMETHOD(device_probe, isa_probe), 584 DEVMETHOD(device_attach, isa_attach), 585 DEVMETHOD(device_detach, bus_generic_detach), 586 DEVMETHOD(device_shutdown, bus_generic_shutdown), 587 DEVMETHOD(device_suspend, bus_generic_suspend), 588 DEVMETHOD(device_resume, bus_generic_resume), 589 590 /* Bus interface */ | 152static void 153isa_print_child(device_t bus, device_t dev) 154{ 155 struct isa_device *id = DEVTOISA(dev); 156 157 if (id->id_port[0] > 0 || id->id_port[1] > 0 158 || id->id_maddr[0] > 0 || id->id_maddr[1] > 0 159 || id->id_irq[0] >= 0 || id->id_irq[1] >= 0 --- 352 unchanged lines hidden (view full) --- 512 DEVMETHOD(device_probe, isa_probe), 513 DEVMETHOD(device_attach, isa_attach), 514 DEVMETHOD(device_detach, bus_generic_detach), 515 DEVMETHOD(device_shutdown, bus_generic_shutdown), 516 DEVMETHOD(device_suspend, bus_generic_suspend), 517 DEVMETHOD(device_resume, bus_generic_resume), 518 519 /* Bus interface */ |
520 DEVMETHOD(bus_add_child, isa_add_child), |
|
591 DEVMETHOD(bus_print_child, isa_print_child), 592 DEVMETHOD(bus_read_ivar, isa_read_ivar), 593 DEVMETHOD(bus_write_ivar, isa_write_ivar), 594 DEVMETHOD(bus_alloc_resource, isa_alloc_resource), 595 DEVMETHOD(bus_release_resource, isa_release_resource), 596 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 597 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 598 DEVMETHOD(bus_setup_intr, isa_setup_intr), --- 16 unchanged lines hidden --- | 521 DEVMETHOD(bus_print_child, isa_print_child), 522 DEVMETHOD(bus_read_ivar, isa_read_ivar), 523 DEVMETHOD(bus_write_ivar, isa_write_ivar), 524 DEVMETHOD(bus_alloc_resource, isa_alloc_resource), 525 DEVMETHOD(bus_release_resource, isa_release_resource), 526 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 527 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 528 DEVMETHOD(bus_setup_intr, isa_setup_intr), --- 16 unchanged lines hidden --- |