2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND MIT
4 * Copyright (c) 1999 Doug Rabson
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * Modifications for Intel architecture by Garrett A. Wollman.
30 * Copyright 1998 Massachusetts Institute of Technology
32 * Permission to use, copy, modify, and distribute this software and
33 * its documentation for any purpose and without fee is hereby
34 * granted, provided that both the above copyright notice and this
35 * permission notice appear in all copies, that both the above
36 * copyright notice and this permission notice appear in all
37 * supporting documentation, and that the name of M.I.T. not be used
38 * in advertising or publicity pertaining to distribution of the
39 * software without specific, written prior permission. M.I.T. makes
40 * no representations about the suitability of this software for any
41 * purpose. It is provided "as is" without express or implied
44 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
45 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
46 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
47 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
48 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
50 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
51 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
52 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
54 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * Parts of the ISA bus implementation common to all architectures.
62 #include <sys/cdefs.h>
63 __FBSDID("$FreeBSD$");
67 #include <sys/param.h>
68 #include <sys/systm.h>
69 #include <sys/kernel.h>
71 #include <sys/endian.h>
72 #include <sys/malloc.h>
73 #include <sys/module.h>
74 #include <machine/bus.h>
76 #include <sys/sysctl.h>
78 #include <machine/resource.h>
80 #include <isa/isavar.h>
81 #include <isa/isa_common.h>
83 static int isa_print_child(device_t bus, device_t dev);
85 static MALLOC_DEFINE(M_ISADEV, "isadev", "ISA device");
87 static int isa_running;
90 * At 'probe' time, we add all the devices which we know about to the
91 * bus. The generic attach routine will probe and attach them if they
95 isa_probe(device_t dev)
97 device_set_desc(dev, "ISA bus");
98 isa_init(dev); /* Allow machdep code to initialise */
102 extern device_t isa_bus_device;
105 isa_attach(device_t dev)
108 * Arrange for isa_probe_children(dev) to be called later. XXX
110 isa_bus_device = dev;
115 * Find a working set of memory regions for a child using the ranges
116 * in *config and return the regions in *result. Returns non-zero if
117 * a set of ranges was found.
120 isa_find_memory(device_t child, struct isa_config *config,
121 struct isa_config *result)
124 struct resource *res[ISA_NMEM];
127 * First clear out any existing resource definitions.
129 for (i = 0; i < ISA_NMEM; i++) {
130 bus_delete_resource(child, SYS_RES_MEMORY, i);
135 result->ic_nmem = config->ic_nmem;
136 for (i = 0; i < config->ic_nmem; i++) {
137 uint32_t start, end, size, align;
139 size = config->ic_mem[i].ir_size;
141 /* the PnP device may have a null resource as filler */
143 result->ic_mem[i].ir_start = 0;
144 result->ic_mem[i].ir_end = 0;
145 result->ic_mem[i].ir_size = 0;
146 result->ic_mem[i].ir_align = 0;
150 for (start = config->ic_mem[i].ir_start,
151 end = config->ic_mem[i].ir_end,
152 align = config->ic_mem[i].ir_align;
153 start + size - 1 <= end && start + size > start;
154 start += MAX(align, 1)) {
155 bus_set_resource(child, SYS_RES_MEMORY, i,
157 res[i] = bus_alloc_resource_any(child,
159 rman_make_alignment_flags(align) /* !RF_ACTIVE */);
161 result->ic_mem[i].ir_start = start;
162 result->ic_mem[i].ir_end = start + size - 1;
163 result->ic_mem[i].ir_size = size;
164 result->ic_mem[i].ir_align = align;
170 * If we didn't find a place for memory range i, then
179 for (i = 0; i < ISA_NMEM; i++) {
181 bus_release_resource(child, SYS_RES_MEMORY,
189 * Find a working set of port regions for a child using the ranges
190 * in *config and return the regions in *result. Returns non-zero if
191 * a set of ranges was found.
194 isa_find_port(device_t child, struct isa_config *config,
195 struct isa_config *result)
198 struct resource *res[ISA_NPORT];
201 * First clear out any existing resource definitions.
203 for (i = 0; i < ISA_NPORT; i++) {
204 bus_delete_resource(child, SYS_RES_IOPORT, i);
209 result->ic_nport = config->ic_nport;
210 for (i = 0; i < config->ic_nport; i++) {
211 uint32_t start, end, size, align;
213 size = config->ic_port[i].ir_size;
215 /* the PnP device may have a null resource as filler */
217 result->ic_port[i].ir_start = 0;
218 result->ic_port[i].ir_end = 0;
219 result->ic_port[i].ir_size = 0;
220 result->ic_port[i].ir_align = 0;
224 for (start = config->ic_port[i].ir_start,
225 end = config->ic_port[i].ir_end,
226 align = config->ic_port[i].ir_align;
227 start + size - 1 <= end;
229 bus_set_resource(child, SYS_RES_IOPORT, i,
231 res[i] = bus_alloc_resource_any(child,
233 rman_make_alignment_flags(align) /* !RF_ACTIVE */);
235 result->ic_port[i].ir_start = start;
236 result->ic_port[i].ir_end = start + size - 1;
237 result->ic_port[i].ir_size = size;
238 result->ic_port[i].ir_align = align;
244 * If we didn't find a place for port range i, then
253 for (i = 0; i < ISA_NPORT; i++) {
255 bus_release_resource(child, SYS_RES_IOPORT,
263 * Return the index of the first bit in the mask (or -1 if mask is empty.
266 find_first_bit(uint32_t mask)
268 return (ffs(mask) - 1);
272 * Return the index of the next bit in the mask, or -1 if there are no more.
275 find_next_bit(uint32_t mask, int bit)
278 while (bit < 32 && !(mask & (1 << bit)))
286 * Find a working set of irqs for a child using the masks in *config
287 * and return the regions in *result. Returns non-zero if a set of
291 isa_find_irq(device_t child, struct isa_config *config,
292 struct isa_config *result)
295 struct resource *res[ISA_NIRQ];
298 * First clear out any existing resource definitions.
300 for (i = 0; i < ISA_NIRQ; i++) {
301 bus_delete_resource(child, SYS_RES_IRQ, i);
306 result->ic_nirq = config->ic_nirq;
307 for (i = 0; i < config->ic_nirq; i++) {
308 uint32_t mask = config->ic_irqmask[i];
311 /* the PnP device may have a null resource as filler */
313 result->ic_irqmask[i] = 0;
317 for (irq = find_first_bit(mask);
319 irq = find_next_bit(mask, irq)) {
320 bus_set_resource(child, SYS_RES_IRQ, i,
322 res[i] = bus_alloc_resource_any(child,
324 0 /* !RF_ACTIVE */ );
326 result->ic_irqmask[i] = (1 << irq);
332 * If we didn't find a place for irq range i, then
341 for (i = 0; i < ISA_NIRQ; i++) {
343 bus_release_resource(child, SYS_RES_IRQ,
351 * Find a working set of drqs for a child using the masks in *config
352 * and return the regions in *result. Returns non-zero if a set of
356 isa_find_drq(device_t child, struct isa_config *config,
357 struct isa_config *result)
360 struct resource *res[ISA_NDRQ];
363 * First clear out any existing resource definitions.
365 for (i = 0; i < ISA_NDRQ; i++) {
366 bus_delete_resource(child, SYS_RES_DRQ, i);
371 result->ic_ndrq = config->ic_ndrq;
372 for (i = 0; i < config->ic_ndrq; i++) {
373 uint32_t mask = config->ic_drqmask[i];
376 /* the PnP device may have a null resource as filler */
378 result->ic_drqmask[i] = 0;
382 for (drq = find_first_bit(mask);
384 drq = find_next_bit(mask, drq)) {
385 bus_set_resource(child, SYS_RES_DRQ, i,
387 res[i] = bus_alloc_resource_any(child,
391 result->ic_drqmask[i] = (1 << drq);
397 * If we didn't find a place for drq range i, then
406 for (i = 0; i < ISA_NDRQ; i++) {
408 bus_release_resource(child, SYS_RES_DRQ,
416 * Attempt to find a working set of resources for a device. Return
417 * non-zero if a working configuration is found.
420 isa_assign_resources(device_t child)
422 struct isa_device *idev = DEVTOISA(child);
423 struct isa_config_entry *ice;
424 struct isa_config *cfg;
427 reason = "Empty ISA id_configs";
428 cfg = malloc(sizeof(struct isa_config), M_TEMP, M_NOWAIT|M_ZERO);
431 TAILQ_FOREACH(ice, &idev->id_configs, ice_link) {
433 if (!isa_find_memory(child, &ice->ice_config, cfg))
436 if (!isa_find_port(child, &ice->ice_config, cfg))
439 if (!isa_find_irq(child, &ice->ice_config, cfg))
442 if (!isa_find_drq(child, &ice->ice_config, cfg))
446 * A working configuration was found enable the device
447 * with this configuration.
449 reason = "no callback";
450 if (idev->id_config_cb) {
451 idev->id_config_cb(idev->id_config_arg,
459 * Disable the device.
461 bus_print_child_header(device_get_parent(child), child);
462 printf(" can't assign resources (%s)\n", reason);
464 isa_print_child(device_get_parent(child), child);
465 bzero(cfg, sizeof (*cfg));
466 if (idev->id_config_cb)
467 idev->id_config_cb(idev->id_config_arg, cfg, 0);
468 device_disable(child);
475 * Claim any unallocated resources to keep other devices from using
479 isa_claim_resources(device_t dev, device_t child)
481 struct isa_device *idev = DEVTOISA(child);
482 struct resource_list *rl = &idev->id_resources;
483 struct resource_list_entry *rle;
486 STAILQ_FOREACH(rle, rl, link) {
489 resource_list_alloc(rl, dev, child, rle->type, &rid,
496 * Called after other devices have initialised to probe for isa devices.
499 isa_probe_children(device_t dev)
501 struct isa_device *idev;
502 device_t *children, child;
503 struct isa_config *cfg;
504 int nchildren, i, err;
507 * Create all the non-hinted children by calling drivers'
510 bus_generic_probe(dev);
512 if (device_get_children(dev, &children, &nchildren))
516 * First disable all pnp devices so that they don't get
517 * matched by legacy probes.
520 printf("isa_probe_children: disabling PnP devices\n");
522 cfg = malloc(sizeof(*cfg), M_TEMP, M_NOWAIT|M_ZERO);
524 free(children, M_TEMP);
528 for (i = 0; i < nchildren; i++) {
529 idev = DEVTOISA(children[i]);
531 bzero(cfg, sizeof(*cfg));
532 if (idev->id_config_cb)
533 idev->id_config_cb(idev->id_config_arg, cfg, 0);
539 * Next, probe all the PnP BIOS devices so they can subsume any
542 for (i = 0; i < nchildren; i++) {
544 idev = DEVTOISA(child);
546 if (idev->id_order > ISA_ORDER_PNPBIOS)
548 if (!TAILQ_EMPTY(&idev->id_configs) &&
549 !isa_assign_resources(child))
552 if (device_probe_and_attach(child) == 0)
553 isa_claim_resources(dev, child);
555 free(children, M_TEMP);
558 * Next, enumerate hinted devices and probe all non-pnp devices so
559 * that they claim their resources first.
561 bus_enumerate_hinted_children(dev);
562 if (device_get_children(dev, &children, &nchildren))
565 printf("isa_probe_children: probing non-PnP devices\n");
566 for (i = 0; i < nchildren; i++) {
568 idev = DEVTOISA(child);
570 if (device_is_attached(child) ||
571 !TAILQ_EMPTY(&idev->id_configs))
574 err = device_probe_and_attach(child);
575 if (err == 0 && idev->id_vendorid == 0 &&
576 strcmp(kern_ident, "GENERIC") == 0 &&
577 device_is_attached(child))
579 "non-PNP ISA device will be removed from GENERIC in FreeBSD 12.\n");
583 * Finally assign resource to pnp devices and probe them.
586 printf("isa_probe_children: probing PnP devices\n");
587 for (i = 0; i < nchildren; i++) {
589 idev = DEVTOISA(child);
591 if (device_is_attached(child) || TAILQ_EMPTY(&idev->id_configs))
594 if (isa_assign_resources(child)) {
595 device_probe_and_attach(child);
596 isa_claim_resources(dev, child);
600 free(children, M_TEMP);
606 * Add a new child with default ivars.
609 isa_add_child(device_t dev, u_int order, const char *name, int unit)
612 struct isa_device *idev;
614 child = device_add_child_ordered(dev, order, name, unit);
618 idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT | M_ZERO);
622 resource_list_init(&idev->id_resources);
623 TAILQ_INIT(&idev->id_configs);
624 idev->id_order = order;
626 device_set_ivars(child, idev);
632 isa_print_all_resources(device_t dev)
634 struct isa_device *idev = DEVTOISA(dev);
635 struct resource_list *rl = &idev->id_resources;
638 if (STAILQ_FIRST(rl) || device_get_flags(dev))
639 retval += printf(" at");
641 retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#jx");
642 retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#jx");
643 retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%jd");
644 retval += resource_list_print_type(rl, "drq", SYS_RES_DRQ, "%jd");
645 if (device_get_flags(dev))
646 retval += printf(" flags %#x", device_get_flags(dev));
647 if (idev->id_vendorid)
648 retval += printf(" pnpid %s", pnp_eisaformat(idev->id_vendorid));
654 isa_print_child(device_t bus, device_t dev)
658 retval += bus_print_child_header(bus, dev);
659 retval += isa_print_all_resources(dev);
660 retval += bus_print_child_footer(bus, dev);
666 isa_probe_nomatch(device_t dev, device_t child)
669 bus_print_child_header(dev, child);
670 printf(" failed to probe");
671 isa_print_all_resources(child);
672 bus_print_child_footer(dev, child);
679 isa_read_ivar(device_t bus, device_t dev, int index, uintptr_t * result)
681 struct isa_device* idev = DEVTOISA(dev);
682 struct resource_list *rl = &idev->id_resources;
683 struct resource_list_entry *rle;
686 case ISA_IVAR_PORT_0:
687 rle = resource_list_find(rl, SYS_RES_IOPORT, 0);
689 *result = rle->start;
694 case ISA_IVAR_PORT_1:
695 rle = resource_list_find(rl, SYS_RES_IOPORT, 1);
697 *result = rle->start;
702 case ISA_IVAR_PORTSIZE_0:
703 rle = resource_list_find(rl, SYS_RES_IOPORT, 0);
705 *result = rle->count;
710 case ISA_IVAR_PORTSIZE_1:
711 rle = resource_list_find(rl, SYS_RES_IOPORT, 1);
713 *result = rle->count;
718 case ISA_IVAR_MADDR_0:
719 rle = resource_list_find(rl, SYS_RES_MEMORY, 0);
721 *result = rle->start;
726 case ISA_IVAR_MADDR_1:
727 rle = resource_list_find(rl, SYS_RES_MEMORY, 1);
729 *result = rle->start;
734 case ISA_IVAR_MEMSIZE_0:
735 rle = resource_list_find(rl, SYS_RES_MEMORY, 0);
737 *result = rle->count;
742 case ISA_IVAR_MEMSIZE_1:
743 rle = resource_list_find(rl, SYS_RES_MEMORY, 1);
745 *result = rle->count;
751 rle = resource_list_find(rl, SYS_RES_IRQ, 0);
753 *result = rle->start;
759 rle = resource_list_find(rl, SYS_RES_IRQ, 1);
761 *result = rle->start;
767 rle = resource_list_find(rl, SYS_RES_DRQ, 0);
769 *result = rle->start;
775 rle = resource_list_find(rl, SYS_RES_DRQ, 1);
777 *result = rle->start;
782 case ISA_IVAR_VENDORID:
783 *result = idev->id_vendorid;
786 case ISA_IVAR_SERIAL:
787 *result = idev->id_serial;
790 case ISA_IVAR_LOGICALID:
791 *result = idev->id_logicalid;
794 case ISA_IVAR_COMPATID:
795 *result = idev->id_compatid;
798 case ISA_IVAR_CONFIGATTR:
799 *result = idev->id_config_attr;
802 case ISA_IVAR_PNP_CSN:
803 *result = idev->id_pnp_csn;
806 case ISA_IVAR_PNP_LDN:
807 *result = idev->id_pnp_ldn;
810 case ISA_IVAR_PNPBIOS_HANDLE:
811 *result = idev->id_pnpbios_handle;
822 isa_write_ivar(device_t bus, device_t dev, int index, uintptr_t value)
824 struct isa_device* idev = DEVTOISA(dev);
827 case ISA_IVAR_PORT_0:
828 case ISA_IVAR_PORT_1:
829 case ISA_IVAR_PORTSIZE_0:
830 case ISA_IVAR_PORTSIZE_1:
831 case ISA_IVAR_MADDR_0:
832 case ISA_IVAR_MADDR_1:
833 case ISA_IVAR_MEMSIZE_0:
834 case ISA_IVAR_MEMSIZE_1:
841 case ISA_IVAR_VENDORID:
842 idev->id_vendorid = value;
845 case ISA_IVAR_SERIAL:
846 idev->id_serial = value;
849 case ISA_IVAR_LOGICALID:
850 idev->id_logicalid = value;
853 case ISA_IVAR_COMPATID:
854 idev->id_compatid = value;
857 case ISA_IVAR_CONFIGATTR:
858 idev->id_config_attr = value;
869 * Free any resources which the driver missed or which we were holding for
870 * it (see isa_probe_children).
873 isa_child_detached(device_t dev, device_t child)
875 struct isa_device* idev = DEVTOISA(child);
877 if (TAILQ_FIRST(&idev->id_configs))
878 isa_claim_resources(dev, child);
882 isa_driver_added(device_t dev, driver_t *driver)
888 * Don't do anything if drivers are dynamically
889 * added during autoconfiguration (cf. ymf724).
890 * since that would end up calling identify
896 DEVICE_IDENTIFY(driver, dev);
897 if (device_get_children(dev, &children, &nchildren))
900 for (i = 0; i < nchildren; i++) {
901 device_t child = children[i];
902 struct isa_device *idev = DEVTOISA(child);
903 struct resource_list *rl = &idev->id_resources;
904 struct resource_list_entry *rle;
906 if (device_get_state(child) != DS_NOTPRESENT)
908 if (!device_is_enabled(child))
912 * Free resources which we were holding on behalf of
915 STAILQ_FOREACH(rle, &idev->id_resources, link) {
917 resource_list_release(rl, dev, child,
923 if (TAILQ_FIRST(&idev->id_configs))
924 if (!isa_assign_resources(child))
927 device_probe_and_attach(child);
929 if (TAILQ_FIRST(&idev->id_configs))
930 isa_claim_resources(dev, child);
933 free(children, M_TEMP);
937 isa_set_resource(device_t dev, device_t child, int type, int rid,
938 rman_res_t start, rman_res_t count)
940 struct isa_device* idev = DEVTOISA(child);
941 struct resource_list *rl = &idev->id_resources;
943 if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY
944 && type != SYS_RES_IRQ && type != SYS_RES_DRQ)
948 if (type == SYS_RES_IOPORT && rid >= ISA_NPORT)
950 if (type == SYS_RES_MEMORY && rid >= ISA_NMEM)
952 if (type == SYS_RES_IRQ && rid >= ISA_NIRQ)
954 if (type == SYS_RES_DRQ && rid >= ISA_NDRQ)
957 resource_list_add(rl, type, rid, start, start + count - 1, count);
962 static struct resource_list *
963 isa_get_resource_list (device_t dev, device_t child)
965 struct isa_device* idev = DEVTOISA(child);
966 struct resource_list *rl = &idev->id_resources;
975 isa_add_config(device_t dev, device_t child, int priority,
976 struct isa_config *config)
978 struct isa_device* idev = DEVTOISA(child);
979 struct isa_config_entry *newice, *ice;
981 newice = malloc(sizeof *ice, M_DEVBUF, M_NOWAIT);
985 newice->ice_priority = priority;
986 newice->ice_config = *config;
988 TAILQ_FOREACH(ice, &idev->id_configs, ice_link) {
989 if (ice->ice_priority > priority)
993 TAILQ_INSERT_BEFORE(ice, newice, ice_link);
995 TAILQ_INSERT_TAIL(&idev->id_configs, newice, ice_link);
1001 isa_set_config_callback(device_t dev, device_t child, isa_config_cb *fn,
1004 struct isa_device* idev = DEVTOISA(child);
1006 idev->id_config_cb = fn;
1007 idev->id_config_arg = arg;
1011 isa_pnp_probe(device_t dev, device_t child, struct isa_pnp_id *ids)
1013 struct isa_device* idev = DEVTOISA(child);
1015 if (!idev->id_vendorid)
1018 while (ids && ids->ip_id) {
1020 * Really ought to support >1 compat id per device.
1022 if (idev->id_logicalid == ids->ip_id
1023 || idev->id_compatid == ids->ip_id) {
1025 device_set_desc(child, ids->ip_desc);
1035 isa_child_pnpinfo_str(device_t bus, device_t child, char *buf,
1038 struct isa_device *idev = DEVTOISA(child);
1040 if (idev->id_vendorid)
1041 snprintf(buf, buflen, "pnpid=%s",
1042 pnp_eisaformat(idev->id_vendorid));
1047 isa_child_location_str(device_t bus, device_t child, char *buf,
1051 /* id_pnphandle isn't there yet */
1052 struct isa_device *idev = DEVTOISA(child);
1054 if (idev->id_vendorid)
1055 snprintf(buf, buflen, "pnphandle=%d", idev->id_pnphandle);
1057 /* Nothing here yet */
1062 static device_method_t isa_methods[] = {
1063 /* Device interface */
1064 DEVMETHOD(device_probe, isa_probe),
1065 DEVMETHOD(device_attach, isa_attach),
1066 DEVMETHOD(device_detach, bus_generic_detach),
1067 DEVMETHOD(device_shutdown, bus_generic_shutdown),
1068 DEVMETHOD(device_suspend, bus_generic_suspend),
1069 DEVMETHOD(device_resume, bus_generic_resume),
1072 DEVMETHOD(bus_add_child, isa_add_child),
1073 DEVMETHOD(bus_print_child, isa_print_child),
1074 DEVMETHOD(bus_probe_nomatch, isa_probe_nomatch),
1075 DEVMETHOD(bus_read_ivar, isa_read_ivar),
1076 DEVMETHOD(bus_write_ivar, isa_write_ivar),
1077 DEVMETHOD(bus_child_detached, isa_child_detached),
1078 DEVMETHOD(bus_driver_added, isa_driver_added),
1079 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
1080 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
1082 DEVMETHOD(bus_get_resource_list,isa_get_resource_list),
1083 DEVMETHOD(bus_alloc_resource, isa_alloc_resource),
1084 DEVMETHOD(bus_release_resource, isa_release_resource),
1085 DEVMETHOD(bus_set_resource, isa_set_resource),
1086 DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
1087 DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource),
1088 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
1089 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
1090 DEVMETHOD(bus_child_pnpinfo_str, isa_child_pnpinfo_str),
1091 DEVMETHOD(bus_child_location_str, isa_child_location_str),
1092 DEVMETHOD(bus_hinted_child, isa_hinted_child),
1093 DEVMETHOD(bus_hint_device_unit, isa_hint_device_unit),
1096 DEVMETHOD(isa_add_config, isa_add_config),
1097 DEVMETHOD(isa_set_config_callback, isa_set_config_callback),
1098 DEVMETHOD(isa_pnp_probe, isa_pnp_probe),
1103 DEFINE_CLASS_0(isa, isa_driver, isa_methods, 0);
1105 devclass_t isa_devclass;
1108 * ISA can be attached to a PCI-ISA bridge, or other locations on some
1111 DRIVER_MODULE(isa, isab, isa_driver, isa_devclass, 0, 0);
1112 DRIVER_MODULE(isa, eisab, isa_driver, isa_devclass, 0, 0);
1113 MODULE_VERSION(isa, 1);
1116 * Code common to ISA bridges.
1119 devclass_t isab_devclass;
1122 isab_attach(device_t dev)
1126 child = device_add_child(dev, "isa", 0);
1128 return (bus_generic_attach(dev));
1133 pnp_eisaformat(uint32_t id)
1136 static char idbuf[8];
1137 const char hextoascii[] = "0123456789abcdef";
1140 data = (uint8_t *)&id;
1141 idbuf[0] = '@' + ((data[0] & 0x7c) >> 2);
1142 idbuf[1] = '@' + (((data[0] & 0x3) << 3) + ((data[1] & 0xe0) >> 5));
1143 idbuf[2] = '@' + (data[1] & 0x1f);
1144 idbuf[3] = hextoascii[(data[2] >> 4)];
1145 idbuf[4] = hextoascii[(data[2] & 0xf)];
1146 idbuf[5] = hextoascii[(data[3] >> 4)];
1147 idbuf[6] = hextoascii[(data[3] & 0xf)];