isa_common.c (184564) | isa_common.c (185059) |
---|---|
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> | 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 184564 2008-11-02 18:48:54Z imp $"); | 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 | 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 */ |
|
470void 471isa_probe_children(device_t dev) 472{ | 494void 495isa_probe_children(device_t dev) 496{ |
473 device_t *children; | 497 struct isa_device *idev; 498 device_t *children, child; |
474 struct isa_config *cfg; 475 int nchildren, i; 476 477 /* | 499 struct isa_config *cfg; 500 int nchildren, i; 501 502 /* |
478 * Create all the children by calling driver's identify methods. | 503 * Create all the non-hinted children by calling drivers' 504 * identify methods. |
479 */ 480 bus_generic_probe(dev); 481 482 if (device_get_children(dev, &children, &nchildren)) 483 return; 484 485 /* 486 * First disable all pnp devices so that they don't get --- 4 unchanged lines hidden (view full) --- 491 492 cfg = malloc(sizeof(*cfg), M_TEMP, M_NOWAIT|M_ZERO); 493 if (cfg == NULL) { 494 free(children, M_TEMP); 495 return; 496 } 497 498 for (i = 0; i < nchildren; i++) { | 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++) { |
499 device_t child = children[i]; 500 struct isa_device *idev = DEVTOISA(child); | 525 idev = DEVTOISA(children[i]); |
501 502 bzero(cfg, sizeof(*cfg)); 503 if (idev->id_config_cb) 504 idev->id_config_cb(idev->id_config_arg, cfg, 0); 505 } 506 507 free(cfg, M_TEMP); 508 509 /* | 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 /* |
510 * Next probe all non-pnp devices so that they claim their 511 * resources first. | 535 * Next, probe all the PnP BIOS devices so they can subsume any 536 * hints. |
512 */ | 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; |
|
513 if (bootverbose) 514 printf("isa_probe_children: probing non-PnP devices\n"); 515 for (i = 0; i < nchildren; i++) { | 560 if (bootverbose) 561 printf("isa_probe_children: probing non-PnP devices\n"); 562 for (i = 0; i < nchildren; i++) { |
516 device_t child = children[i]; 517 struct isa_device *idev = DEVTOISA(child); | 563 child = children[i]; 564 idev = DEVTOISA(child); |
518 | 565 |
519 if (TAILQ_FIRST(&idev->id_configs)) | 566 if (device_is_attached(child) || 567 !TAILQ_EMPTY(&idev->id_configs)) |
520 continue; 521 522 device_probe_and_attach(child); 523 } 524 525 /* 526 * Finally assign resource to pnp devices and probe them. 527 */ 528 if (bootverbose) 529 printf("isa_probe_children: probing PnP devices\n"); 530 for (i = 0; i < nchildren; i++) { | 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++) { |
531 device_t child = children[i]; 532 struct isa_device* idev = DEVTOISA(child); | 579 child = children[i]; 580 idev = DEVTOISA(child); |
533 | 581 |
534 if (!TAILQ_FIRST(&idev->id_configs)) | 582 if (device_is_attached(child) || TAILQ_EMPTY(&idev->id_configs)) |
535 continue; 536 537 if (isa_assign_resources(child)) { | 583 continue; 584 585 if (isa_assign_resources(child)) { |
538 struct resource_list *rl = &idev->id_resources; 539 struct resource_list_entry *rle; 540 | |
541 device_probe_and_attach(child); | 586 device_probe_and_attach(child); |
542 543 /* 544 * Claim any unallocated resources to keep other 545 * devices from using them. 546 */ 547 STAILQ_FOREACH(rle, rl, link) { 548 if (!rle->res) { 549 int rid = rle->rid; 550 resource_list_alloc(rl, dev, child, 551 rle->type, 552 &rid, 553 0, ~0, 1, 0); 554 } 555 } | 587 isa_claim_resources(dev, child); |
556 } 557 } 558 559 free(children, M_TEMP); 560 561 isa_running = 1; 562} 563 --- 11 unchanged lines hidden (view full) --- 575 return (child); 576 577 idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT | M_ZERO); 578 if (!idev) 579 return (0); 580 581 resource_list_init(&idev->id_resources); 582 TAILQ_INIT(&idev->id_configs); | 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; |
|
583 584 device_set_ivars(child, idev); 585 586 return (child); 587} 588 589static int 590isa_print_all_resources(device_t dev) --- 237 unchanged lines hidden (view full) --- 828/* 829 * Free any resources which the driver missed or which we were holding for 830 * it (see isa_probe_children). 831 */ 832static void 833isa_child_detached(device_t dev, device_t child) 834{ 835 struct isa_device* idev = DEVTOISA(child); | 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); |
836 struct resource_list *rl = &idev->id_resources; 837 struct resource_list_entry *rle; | |
838 | 869 |
839 if (TAILQ_FIRST(&idev->id_configs)) { 840 /* 841 * Claim any unallocated resources to keep other 842 * devices from using them. 843 */ 844 STAILQ_FOREACH(rle, rl, link) { 845 if (!rle->res) { 846 int rid = rle->rid; 847 resource_list_alloc(rl, dev, child, 848 rle->type, 849 &rid, 0, ~0, 1, 0); 850 } 851 } 852 } | 870 if (TAILQ_FIRST(&idev->id_configs)) 871 isa_claim_resources(dev, child); |
853} 854 855static void 856isa_driver_added(device_t dev, driver_t *driver) 857{ 858 device_t *children; 859 int nchildren, i; 860 --- 34 unchanged lines hidden (view full) --- 895 } 896 897 if (TAILQ_FIRST(&idev->id_configs)) 898 if (!isa_assign_resources(child)) 899 continue; 900 901 device_probe_and_attach(child); 902 | 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 |
903 if (TAILQ_FIRST(&idev->id_configs)) { 904 /* 905 * Claim any unallocated resources to keep other 906 * devices from using them. 907 */ 908 STAILQ_FOREACH(rle, rl, link) { 909 if (!rle->res) { 910 int rid = rle->rid; 911 resource_list_alloc(rl, dev, child, 912 rle->type, 913 &rid, 0, ~0, 1, 0); 914 } 915 } 916 } | 922 if (TAILQ_FIRST(&idev->id_configs)) 923 isa_claim_resources(dev, child); |
917 } 918 919 free(children, M_TEMP); 920} 921 922static int 923isa_set_resource(device_t dev, device_t child, int type, int rid, 924 u_long start, u_long count) --- 147 unchanged lines hidden (view full) --- 1072 DEVMETHOD(bus_release_resource, isa_release_resource), 1073 DEVMETHOD(bus_set_resource, isa_set_resource), 1074 DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), 1075 DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource), 1076 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 1077 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 1078 DEVMETHOD(bus_child_pnpinfo_str, isa_child_pnpinfo_str), 1079 DEVMETHOD(bus_child_location_str, isa_child_location_str), | 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), |
|
1080 1081 /* ISA interface */ 1082 DEVMETHOD(isa_add_config, isa_add_config), 1083 DEVMETHOD(isa_set_config_callback, isa_set_config_callback), 1084 DEVMETHOD(isa_pnp_probe, isa_pnp_probe), 1085 1086 { 0, 0 } 1087}; 1088 | 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 |
1089driver_t isa_driver = { 1090 "isa", 1091 isa_methods, 1092 1, /* no softc */ 1093}; | 1098DEFINE_CLASS_0(isa, isa_driver, isa_methods, 0); |
1094 1095devclass_t isa_devclass; 1096 1097/* 1098 * ISA can be attached to a PCI-ISA bridge, or other locations on some 1099 * platforms. 1100 */ 1101DRIVER_MODULE(isa, isab, isa_driver, isa_devclass, 0, 0); --- 19 unchanged lines hidden --- | 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 --- |