1/*- 2 * Copyright (c) 1999 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 --- 44 unchanged lines hidden (view full) --- 53 * SUCH DAMAGE. 54 */ 55 56/* 57 * Parts of the ISA bus implementation common to all architectures. 58 */ 59 60#include <sys/cdefs.h> |
61__FBSDID("$FreeBSD: head/sys/isa/isa_common.c 185059 2008-11-18 21:01:54Z jhb $"); |
62 63#include "opt_isa.h" 64 65#include <sys/param.h> 66#include <sys/systm.h> 67#include <sys/kernel.h> 68#include <sys/bus.h> 69#include <sys/malloc.h> --- 392 unchanged lines hidden (view full) --- 462 if (idev->id_config_cb) 463 idev->id_config_cb(idev->id_config_arg, cfg, 0); 464 device_disable(child); 465 466 free(cfg, M_TEMP); 467 return (0); 468} 469 |
470/* 471 * Claim any unallocated resources to keep other devices from using 472 * them. 473 */ 474static void 475isa_claim_resources(device_t dev, device_t child) 476{ 477 struct isa_device *idev = DEVTOISA(child); 478 struct resource_list *rl = &idev->id_resources; 479 struct resource_list_entry *rle; 480 int rid; 481 482 STAILQ_FOREACH(rle, rl, link) { 483 if (!rle->res) { 484 rid = rle->rid; 485 resource_list_alloc(rl, dev, child, rle->type, &rid, 486 0ul, ~0ul, 1, 0); 487 } 488 } 489} 490 491/* 492 * Called after other devices have initialised to probe for isa devices. 493 */ |
494void 495isa_probe_children(device_t dev) 496{ |
497 struct isa_device *idev; 498 device_t *children, child; |
499 struct isa_config *cfg; 500 int nchildren, i; 501 502 /* |
503 * Create all the non-hinted children by calling drivers' 504 * identify methods. |
505 */ 506 bus_generic_probe(dev); 507 508 if (device_get_children(dev, &children, &nchildren)) 509 return; 510 511 /* 512 * First disable all pnp devices so that they don't get --- 4 unchanged lines hidden (view full) --- 517 518 cfg = malloc(sizeof(*cfg), M_TEMP, M_NOWAIT|M_ZERO); 519 if (cfg == NULL) { 520 free(children, M_TEMP); 521 return; 522 } 523 524 for (i = 0; i < nchildren; i++) { |
525 idev = DEVTOISA(children[i]); |
526 527 bzero(cfg, sizeof(*cfg)); 528 if (idev->id_config_cb) 529 idev->id_config_cb(idev->id_config_arg, cfg, 0); 530 } 531 532 free(cfg, M_TEMP); 533 534 /* |
535 * Next, probe all the PnP BIOS devices so they can subsume any 536 * hints. |
537 */ |
538 for (i = 0; i < nchildren; i++) { 539 child = children[i]; 540 idev = DEVTOISA(child); 541 542 if (idev->id_order > ISA_ORDER_PNPBIOS) 543 continue; 544 if (!TAILQ_EMPTY(&idev->id_configs) && 545 !isa_assign_resources(child)) 546 continue; 547 548 if (device_probe_and_attach(child) == 0) 549 isa_claim_resources(dev, child); 550 } 551 free(children, M_TEMP); 552 553 /* 554 * Next, enumerate hinted devices and probe all non-pnp devices so 555 * that they claim their resources first. 556 */ 557 bus_enumerate_hinted_children(dev); 558 if (device_get_children(dev, &children, &nchildren)) 559 return; |
560 if (bootverbose) 561 printf("isa_probe_children: probing non-PnP devices\n"); 562 for (i = 0; i < nchildren; i++) { |
563 child = children[i]; 564 idev = DEVTOISA(child); |
565 |
566 if (device_is_attached(child) || 567 !TAILQ_EMPTY(&idev->id_configs)) |
568 continue; 569 570 device_probe_and_attach(child); 571 } 572 573 /* 574 * Finally assign resource to pnp devices and probe them. 575 */ 576 if (bootverbose) 577 printf("isa_probe_children: probing PnP devices\n"); 578 for (i = 0; i < nchildren; i++) { |
579 child = children[i]; 580 idev = DEVTOISA(child); |
581 |
582 if (device_is_attached(child) || TAILQ_EMPTY(&idev->id_configs)) |
583 continue; 584 585 if (isa_assign_resources(child)) { |
586 device_probe_and_attach(child); |
587 isa_claim_resources(dev, child); |
588 } 589 } 590 591 free(children, M_TEMP); 592 593 isa_running = 1; 594} 595 --- 11 unchanged lines hidden (view full) --- 607 return (child); 608 609 idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT | M_ZERO); 610 if (!idev) 611 return (0); 612 613 resource_list_init(&idev->id_resources); 614 TAILQ_INIT(&idev->id_configs); |
615 idev->id_order = order; |
616 617 device_set_ivars(child, idev); 618 619 return (child); 620} 621 622static int 623isa_print_all_resources(device_t dev) --- 237 unchanged lines hidden (view full) --- 861/* 862 * Free any resources which the driver missed or which we were holding for 863 * it (see isa_probe_children). 864 */ 865static void 866isa_child_detached(device_t dev, device_t child) 867{ 868 struct isa_device* idev = DEVTOISA(child); |
869 |
870 if (TAILQ_FIRST(&idev->id_configs)) 871 isa_claim_resources(dev, child); |
872} 873 874static void 875isa_driver_added(device_t dev, driver_t *driver) 876{ 877 device_t *children; 878 int nchildren, i; 879 --- 34 unchanged lines hidden (view full) --- 914 } 915 916 if (TAILQ_FIRST(&idev->id_configs)) 917 if (!isa_assign_resources(child)) 918 continue; 919 920 device_probe_and_attach(child); 921 |
922 if (TAILQ_FIRST(&idev->id_configs)) 923 isa_claim_resources(dev, child); |
924 } 925 926 free(children, M_TEMP); 927} 928 929static int 930isa_set_resource(device_t dev, device_t child, int type, int rid, 931 u_long start, u_long count) --- 147 unchanged lines hidden (view full) --- 1079 DEVMETHOD(bus_release_resource, isa_release_resource), 1080 DEVMETHOD(bus_set_resource, isa_set_resource), 1081 DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), 1082 DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource), 1083 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 1084 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 1085 DEVMETHOD(bus_child_pnpinfo_str, isa_child_pnpinfo_str), 1086 DEVMETHOD(bus_child_location_str, isa_child_location_str), |
1087 DEVMETHOD(bus_hinted_child, isa_hinted_child), 1088 DEVMETHOD(bus_hint_device_unit, isa_hint_device_unit), |
1089 1090 /* ISA interface */ 1091 DEVMETHOD(isa_add_config, isa_add_config), 1092 DEVMETHOD(isa_set_config_callback, isa_set_config_callback), 1093 DEVMETHOD(isa_pnp_probe, isa_pnp_probe), 1094 1095 { 0, 0 } 1096}; 1097 |
1098DEFINE_CLASS_0(isa, isa_driver, isa_methods, 0); |
1099 1100devclass_t isa_devclass; 1101 1102/* 1103 * ISA can be attached to a PCI-ISA bridge, or other locations on some 1104 * platforms. 1105 */ 1106DRIVER_MODULE(isa, isab, isa_driver, isa_devclass, 0, 0); --- 19 unchanged lines hidden --- |