16c2e3ddeSDoug Rabson /*- 26c2e3ddeSDoug Rabson * Copyright (c) 1999 Doug Rabson 36c2e3ddeSDoug Rabson * All rights reserved. 46c2e3ddeSDoug Rabson * 56c2e3ddeSDoug Rabson * Redistribution and use in source and binary forms, with or without 66c2e3ddeSDoug Rabson * modification, are permitted provided that the following conditions 76c2e3ddeSDoug Rabson * are met: 86c2e3ddeSDoug Rabson * 1. Redistributions of source code must retain the above copyright 96c2e3ddeSDoug Rabson * notice, this list of conditions and the following disclaimer. 106c2e3ddeSDoug Rabson * 2. Redistributions in binary form must reproduce the above copyright 116c2e3ddeSDoug Rabson * notice, this list of conditions and the following disclaimer in the 126c2e3ddeSDoug Rabson * documentation and/or other materials provided with the distribution. 136c2e3ddeSDoug Rabson * 146c2e3ddeSDoug Rabson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 156c2e3ddeSDoug Rabson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 166c2e3ddeSDoug Rabson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 176c2e3ddeSDoug Rabson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 186c2e3ddeSDoug Rabson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 196c2e3ddeSDoug Rabson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 206c2e3ddeSDoug Rabson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 216c2e3ddeSDoug Rabson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 226c2e3ddeSDoug Rabson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 236c2e3ddeSDoug Rabson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 246c2e3ddeSDoug Rabson * SUCH DAMAGE. 256c2e3ddeSDoug Rabson */ 266c2e3ddeSDoug Rabson 278c9bbf48SDavid E. O'Brien #include <sys/cdefs.h> 288c9bbf48SDavid E. O'Brien __FBSDID("$FreeBSD$"); 298c9bbf48SDavid E. O'Brien 306c2e3ddeSDoug Rabson #include <sys/param.h> 316c2e3ddeSDoug Rabson #include <sys/systm.h> 326c2e3ddeSDoug Rabson #include <sys/kernel.h> 336c2e3ddeSDoug Rabson #include <sys/bus.h> 346c2e3ddeSDoug Rabson #include <sys/module.h> 356c2e3ddeSDoug Rabson #include <isa/isavar.h> 36a3be63b3SDoug Rabson #include <machine/resource.h> 376c2e3ddeSDoug Rabson 386c2e3ddeSDoug Rabson static void 396c2e3ddeSDoug Rabson isahint_add_device(device_t parent, const char *name, int unit) 406c2e3ddeSDoug Rabson { 416c2e3ddeSDoug Rabson device_t child; 42e5979322SNate Lawson int sensitive, start, count; 43bea6af4dSDoug Rabson int order; 446c2e3ddeSDoug Rabson 456c2e3ddeSDoug Rabson /* device-specific flag overrides any wildcard */ 466c2e3ddeSDoug Rabson sensitive = 0; 476c2e3ddeSDoug Rabson if (resource_int_value(name, unit, "sensitive", &sensitive) != 0) 486c2e3ddeSDoug Rabson resource_int_value(name, -1, "sensitive", &sensitive); 496c2e3ddeSDoug Rabson 506c2e3ddeSDoug Rabson if (sensitive) 51bea6af4dSDoug Rabson order = ISA_ORDER_SENSITIVE; 526c2e3ddeSDoug Rabson else 53bea6af4dSDoug Rabson order = ISA_ORDER_SPECULATIVE; 54bea6af4dSDoug Rabson 55bea6af4dSDoug Rabson child = BUS_ADD_CHILD(parent, order, name, unit); 566c2e3ddeSDoug Rabson if (child == 0) 576c2e3ddeSDoug Rabson return; 586c2e3ddeSDoug Rabson 59a3be63b3SDoug Rabson start = 0; 60a3be63b3SDoug Rabson count = 0; 610197892dSYoshihiro Takahashi resource_int_value(name, unit, "port", &start); 620197892dSYoshihiro Takahashi resource_int_value(name, unit, "portsize", &count); 630197892dSYoshihiro Takahashi if (start > 0 || count > 0) 6425afb89bSDoug Rabson bus_set_resource(child, SYS_RES_IOPORT, 0, start, count); 656c2e3ddeSDoug Rabson 66a3be63b3SDoug Rabson start = 0; 67a3be63b3SDoug Rabson count = 0; 680197892dSYoshihiro Takahashi resource_int_value(name, unit, "maddr", &start); 690197892dSYoshihiro Takahashi resource_int_value(name, unit, "msize", &count); 700197892dSYoshihiro Takahashi if (start > 0 || count > 0) 7125afb89bSDoug Rabson bus_set_resource(child, SYS_RES_MEMORY, 0, start, count); 726c2e3ddeSDoug Rabson 73828cb040SKazutaka YOKOTA if (resource_int_value(name, unit, "irq", &start) == 0 && start > 0) 7425afb89bSDoug Rabson bus_set_resource(child, SYS_RES_IRQ, 0, start, 1); 756c2e3ddeSDoug Rabson 760e7e521cSAndrew Gallatin if (resource_int_value(name, unit, "drq", &start) == 0 && start >= 0) 7725afb89bSDoug Rabson bus_set_resource(child, SYS_RES_DRQ, 0, start, 1); 786c2e3ddeSDoug Rabson 798a9bc9c0SJohn Baldwin if (resource_disabled(name, unit)) 806c2e3ddeSDoug Rabson device_disable(child); 812ca94fcaSMatthew N. Dodd 822ca94fcaSMatthew N. Dodd isa_set_configattr(child, (isa_get_configattr(child)|ISACFGATTR_HINTS)); 836c2e3ddeSDoug Rabson } 846c2e3ddeSDoug Rabson 856c2e3ddeSDoug Rabson static void 866c2e3ddeSDoug Rabson isahint_identify(driver_t *driver, device_t parent) 876c2e3ddeSDoug Rabson { 886c2e3ddeSDoug Rabson int i; 896c2e3ddeSDoug Rabson static char buf[] = "isaXXX"; 902398f0cdSPeter Wemm const char *dname; 912398f0cdSPeter Wemm int dunit; 926c2e3ddeSDoug Rabson 936c2e3ddeSDoug Rabson /* 946c2e3ddeSDoug Rabson * Add all devices configured to be attached to parent. 956c2e3ddeSDoug Rabson */ 966c2e3ddeSDoug Rabson sprintf(buf, "isa%d", device_get_unit(parent)); 972398f0cdSPeter Wemm i = 0; 982398f0cdSPeter Wemm while ((resource_find_match(&i, &dname, &dunit, "at", buf)) == 0) { 992398f0cdSPeter Wemm if (strcmp(dname, "atkbd") == 0) 1006c2e3ddeSDoug Rabson continue; /* old GENERIC kludge */ 1012398f0cdSPeter Wemm isahint_add_device(parent, dname, dunit); 1026c2e3ddeSDoug Rabson } 1036c2e3ddeSDoug Rabson 1046c2e3ddeSDoug Rabson /* 1056c2e3ddeSDoug Rabson * and isa? 1066c2e3ddeSDoug Rabson */ 1072398f0cdSPeter Wemm i = 0; 1082398f0cdSPeter Wemm while ((resource_find_match(&i, &dname, &dunit, "at", "isa")) == 0) { 1092398f0cdSPeter Wemm if (strcmp(dname, "atkbd") == 0) 1106c2e3ddeSDoug Rabson continue; /* old GENERIC kludge */ 1112398f0cdSPeter Wemm isahint_add_device(parent, dname, dunit); 1126c2e3ddeSDoug Rabson } 1136c2e3ddeSDoug Rabson } 1146c2e3ddeSDoug Rabson 1156c2e3ddeSDoug Rabson static device_method_t isahint_methods[] = { 1166c2e3ddeSDoug Rabson /* Device interface */ 1176c2e3ddeSDoug Rabson DEVMETHOD(device_identify, isahint_identify), 1186c2e3ddeSDoug Rabson 1196c2e3ddeSDoug Rabson { 0, 0 } 1206c2e3ddeSDoug Rabson }; 1216c2e3ddeSDoug Rabson 1226c2e3ddeSDoug Rabson static driver_t isahint_driver = { 1236c2e3ddeSDoug Rabson "hint", 1246c2e3ddeSDoug Rabson isahint_methods, 1256c2e3ddeSDoug Rabson 1, /* no softc */ 1266c2e3ddeSDoug Rabson }; 1276c2e3ddeSDoug Rabson 1286c2e3ddeSDoug Rabson static devclass_t hint_devclass; 1296c2e3ddeSDoug Rabson 1306c2e3ddeSDoug Rabson DRIVER_MODULE(isahint, isa, isahint_driver, hint_devclass, 0, 0); 131