isa_common.c (5f96beb9e08be2b08309a6b98967246b64272ade) | isa_common.c (09aafea1c6836ca1eeb8bd739f5420b68d6476e0) |
---|---|
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 --- 80 unchanged lines hidden (view full) --- 89 * bus. The generic attach routine will probe and attach them if they 90 * are alive. 91 */ 92static int 93isa_probe(device_t dev) 94{ 95 device_set_desc(dev, "ISA bus"); 96 isa_init(dev); /* Allow machdep code to initialise */ | 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 --- 80 unchanged lines hidden (view full) --- 89 * bus. The generic attach routine will probe and attach them if they 90 * are alive. 91 */ 92static int 93isa_probe(device_t dev) 94{ 95 device_set_desc(dev, "ISA bus"); 96 isa_init(dev); /* Allow machdep code to initialise */ |
97 return 0; | 97 return (0); |
98} 99 100extern device_t isa_bus_device; 101 102static int 103isa_attach(device_t dev) 104{ 105 /* 106 * Arrange for isa_probe_children(dev) to be called later. XXX 107 */ 108 isa_bus_device = dev; | 98} 99 100extern device_t isa_bus_device; 101 102static int 103isa_attach(device_t dev) 104{ 105 /* 106 * Arrange for isa_probe_children(dev) to be called later. XXX 107 */ 108 isa_bus_device = dev; |
109 return 0; | 109 return (0); |
110} 111 112/* 113 * Find a working set of memory regions for a child using the ranges 114 * in *config and return the regions in *result. Returns non-zero if 115 * a set of ranges was found. 116 */ 117static int | 110} 111 112/* 113 * Find a working set of memory regions for a child using the ranges 114 * in *config and return the regions in *result. Returns non-zero if 115 * a set of ranges was found. 116 */ 117static int |
118isa_find_memory(device_t child, 119 struct isa_config *config, 120 struct isa_config *result) | 118isa_find_memory(device_t child, struct isa_config *config, 119 struct isa_config *result) |
121{ 122 int success, i; 123 struct resource *res[ISA_NMEM]; 124 125 /* 126 * First clear out any existing resource definitions. 127 */ 128 for (i = 0; i < ISA_NMEM; i++) { 129 bus_delete_resource(child, SYS_RES_MEMORY, i); 130 res[i] = NULL; 131 } 132 133 success = 1; 134 result->ic_nmem = config->ic_nmem; 135 for (i = 0; i < config->ic_nmem; i++) { | 120{ 121 int success, i; 122 struct resource *res[ISA_NMEM]; 123 124 /* 125 * First clear out any existing resource definitions. 126 */ 127 for (i = 0; i < ISA_NMEM; i++) { 128 bus_delete_resource(child, SYS_RES_MEMORY, i); 129 res[i] = NULL; 130 } 131 132 success = 1; 133 result->ic_nmem = config->ic_nmem; 134 for (i = 0; i < config->ic_nmem; i++) { |
136 u_int32_t start, end, size, align; | 135 uint32_t start, end, size, align; |
137 138 size = config->ic_mem[i].ir_size; 139 140 /* the PnP device may have a null resource as filler */ 141 if (size == 0) { 142 result->ic_mem[i].ir_start = 0; 143 result->ic_mem[i].ir_end = 0; 144 result->ic_mem[i].ir_size = 0; --- 31 unchanged lines hidden (view full) --- 176 } 177 178 for (i = 0; i < ISA_NMEM; i++) { 179 if (res[i]) 180 bus_release_resource(child, SYS_RES_MEMORY, 181 i, res[i]); 182 } 183 | 136 137 size = config->ic_mem[i].ir_size; 138 139 /* the PnP device may have a null resource as filler */ 140 if (size == 0) { 141 result->ic_mem[i].ir_start = 0; 142 result->ic_mem[i].ir_end = 0; 143 result->ic_mem[i].ir_size = 0; --- 31 unchanged lines hidden (view full) --- 175 } 176 177 for (i = 0; i < ISA_NMEM; i++) { 178 if (res[i]) 179 bus_release_resource(child, SYS_RES_MEMORY, 180 i, res[i]); 181 } 182 |
184 return success; | 183 return (success); |
185} 186 187/* 188 * Find a working set of port regions for a child using the ranges 189 * in *config and return the regions in *result. Returns non-zero if 190 * a set of ranges was found. 191 */ 192static int | 184} 185 186/* 187 * Find a working set of port regions for a child using the ranges 188 * in *config and return the regions in *result. Returns non-zero if 189 * a set of ranges was found. 190 */ 191static int |
193isa_find_port(device_t child, 194 struct isa_config *config, 195 struct isa_config *result) | 192isa_find_port(device_t child, struct isa_config *config, 193 struct isa_config *result) |
196{ 197 int success, i; 198 struct resource *res[ISA_NPORT]; 199 200 /* 201 * First clear out any existing resource definitions. 202 */ 203 for (i = 0; i < ISA_NPORT; i++) { 204 bus_delete_resource(child, SYS_RES_IOPORT, i); 205 res[i] = NULL; 206 } 207 208 success = 1; 209 result->ic_nport = config->ic_nport; 210 for (i = 0; i < config->ic_nport; i++) { | 194{ 195 int success, i; 196 struct resource *res[ISA_NPORT]; 197 198 /* 199 * First clear out any existing resource definitions. 200 */ 201 for (i = 0; i < ISA_NPORT; i++) { 202 bus_delete_resource(child, SYS_RES_IOPORT, i); 203 res[i] = NULL; 204 } 205 206 success = 1; 207 result->ic_nport = config->ic_nport; 208 for (i = 0; i < config->ic_nport; i++) { |
211 u_int32_t start, end, size, align; | 209 uint32_t start, end, size, align; |
212 213 size = config->ic_port[i].ir_size; 214 215 /* the PnP device may have a null resource as filler */ 216 if (size == 0) { 217 result->ic_port[i].ir_start = 0; 218 result->ic_port[i].ir_end = 0; 219 result->ic_port[i].ir_size = 0; --- 38 unchanged lines hidden (view full) --- 258 259 return success; 260} 261 262/* 263 * Return the index of the first bit in the mask (or -1 if mask is empty. 264 */ 265static int | 210 211 size = config->ic_port[i].ir_size; 212 213 /* the PnP device may have a null resource as filler */ 214 if (size == 0) { 215 result->ic_port[i].ir_start = 0; 216 result->ic_port[i].ir_end = 0; 217 result->ic_port[i].ir_size = 0; --- 38 unchanged lines hidden (view full) --- 256 257 return success; 258} 259 260/* 261 * Return the index of the first bit in the mask (or -1 if mask is empty. 262 */ 263static int |
266find_first_bit(u_int32_t mask) | 264find_first_bit(uint32_t mask) |
267{ | 265{ |
268 return ffs(mask) - 1; | 266 return (ffs(mask) - 1); |
269} 270 271/* 272 * Return the index of the next bit in the mask, or -1 if there are no more. 273 */ 274static int | 267} 268 269/* 270 * Return the index of the next bit in the mask, or -1 if there are no more. 271 */ 272static int |
275find_next_bit(u_int32_t mask, int bit) | 273find_next_bit(uint32_t mask, int bit) |
276{ 277 bit++; 278 while (bit < 32 && !(mask & (1 << bit))) 279 bit++; 280 if (bit != 32) | 274{ 275 bit++; 276 while (bit < 32 && !(mask & (1 << bit))) 277 bit++; 278 if (bit != 32) |
281 return bit; 282 return -1; | 279 return (bit); 280 return (-1); |
283} 284 285/* 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 288 * irqs was found. 289 */ 290static int | 281} 282 283/* 284 * Find a working set of irqs for a child using the masks in *config 285 * and return the regions in *result. Returns non-zero if a set of 286 * irqs was found. 287 */ 288static int |
291isa_find_irq(device_t child, 292 struct isa_config *config, 293 struct isa_config *result) | 289isa_find_irq(device_t child, struct isa_config *config, 290 struct isa_config *result) |
294{ 295 int success, i; 296 struct resource *res[ISA_NIRQ]; 297 298 /* 299 * First clear out any existing resource definitions. 300 */ 301 for (i = 0; i < ISA_NIRQ; i++) { 302 bus_delete_resource(child, SYS_RES_IRQ, i); 303 res[i] = NULL; 304 } 305 306 success = 1; 307 result->ic_nirq = config->ic_nirq; 308 for (i = 0; i < config->ic_nirq; i++) { | 291{ 292 int success, i; 293 struct resource *res[ISA_NIRQ]; 294 295 /* 296 * First clear out any existing resource definitions. 297 */ 298 for (i = 0; i < ISA_NIRQ; i++) { 299 bus_delete_resource(child, SYS_RES_IRQ, i); 300 res[i] = NULL; 301 } 302 303 success = 1; 304 result->ic_nirq = config->ic_nirq; 305 for (i = 0; i < config->ic_nirq; i++) { |
309 u_int32_t mask = config->ic_irqmask[i]; | 306 uint32_t mask = config->ic_irqmask[i]; |
310 int irq; 311 312 /* the PnP device may have a null resource as filler */ 313 if (mask == 0) { 314 result->ic_irqmask[i] = 0; 315 continue; 316 } 317 --- 22 unchanged lines hidden (view full) --- 340 } 341 342 for (i = 0; i < ISA_NIRQ; i++) { 343 if (res[i]) 344 bus_release_resource(child, SYS_RES_IRQ, 345 i, res[i]); 346 } 347 | 307 int irq; 308 309 /* the PnP device may have a null resource as filler */ 310 if (mask == 0) { 311 result->ic_irqmask[i] = 0; 312 continue; 313 } 314 --- 22 unchanged lines hidden (view full) --- 337 } 338 339 for (i = 0; i < ISA_NIRQ; i++) { 340 if (res[i]) 341 bus_release_resource(child, SYS_RES_IRQ, 342 i, res[i]); 343 } 344 |
348 return success; | 345 return (success); |
349} 350 351/* 352 * Find a working set of drqs for a child using the masks in *config 353 * and return the regions in *result. Returns non-zero if a set of 354 * drqs was found. 355 */ 356static int | 346} 347 348/* 349 * Find a working set of drqs for a child using the masks in *config 350 * and return the regions in *result. Returns non-zero if a set of 351 * drqs was found. 352 */ 353static int |
357isa_find_drq(device_t child, 358 struct isa_config *config, 359 struct isa_config *result) | 354isa_find_drq(device_t child, struct isa_config *config, 355 struct isa_config *result) |
360{ 361 int success, i; 362 struct resource *res[ISA_NDRQ]; 363 364 /* 365 * First clear out any existing resource definitions. 366 */ 367 for (i = 0; i < ISA_NDRQ; i++) { 368 bus_delete_resource(child, SYS_RES_DRQ, i); 369 res[i] = NULL; 370 } 371 372 success = 1; 373 result->ic_ndrq = config->ic_ndrq; 374 for (i = 0; i < config->ic_ndrq; i++) { | 356{ 357 int success, i; 358 struct resource *res[ISA_NDRQ]; 359 360 /* 361 * First clear out any existing resource definitions. 362 */ 363 for (i = 0; i < ISA_NDRQ; i++) { 364 bus_delete_resource(child, SYS_RES_DRQ, i); 365 res[i] = NULL; 366 } 367 368 success = 1; 369 result->ic_ndrq = config->ic_ndrq; 370 for (i = 0; i < config->ic_ndrq; i++) { |
375 u_int32_t mask = config->ic_drqmask[i]; | 371 uint32_t mask = config->ic_drqmask[i]; |
376 int drq; 377 378 /* the PnP device may have a null resource as filler */ 379 if (mask == 0) { 380 result->ic_drqmask[i] = 0; 381 continue; 382 } 383 --- 22 unchanged lines hidden (view full) --- 406 } 407 408 for (i = 0; i < ISA_NDRQ; i++) { 409 if (res[i]) 410 bus_release_resource(child, SYS_RES_DRQ, 411 i, res[i]); 412 } 413 | 372 int drq; 373 374 /* the PnP device may have a null resource as filler */ 375 if (mask == 0) { 376 result->ic_drqmask[i] = 0; 377 continue; 378 } 379 --- 22 unchanged lines hidden (view full) --- 402 } 403 404 for (i = 0; i < ISA_NDRQ; i++) { 405 if (res[i]) 406 bus_release_resource(child, SYS_RES_DRQ, 407 i, res[i]); 408 } 409 |
414 return success; | 410 return (success); |
415} 416 417/* 418 * Attempt to find a working set of resources for a device. Return 419 * non-zero if a working configuration is found. 420 */ 421static int 422isa_assign_resources(device_t child) --- 25 unchanged lines hidden (view full) --- 448 * A working configuration was found enable the device 449 * with this configuration. 450 */ 451 reason = "no callback"; 452 if (idev->id_config_cb) { 453 idev->id_config_cb(idev->id_config_arg, 454 cfg, 1); 455 free(cfg, M_TEMP); | 411} 412 413/* 414 * Attempt to find a working set of resources for a device. Return 415 * non-zero if a working configuration is found. 416 */ 417static int 418isa_assign_resources(device_t child) --- 25 unchanged lines hidden (view full) --- 444 * A working configuration was found enable the device 445 * with this configuration. 446 */ 447 reason = "no callback"; 448 if (idev->id_config_cb) { 449 idev->id_config_cb(idev->id_config_arg, 450 cfg, 1); 451 free(cfg, M_TEMP); |
456 return 1; | 452 return (1); |
457 } 458 } 459 460 /* 461 * Disable the device. 462 */ 463 bus_print_child_header(device_get_parent(child), child); 464 printf(" can't assign resources (%s)\n", reason); 465 if (bootverbose) | 453 } 454 } 455 456 /* 457 * Disable the device. 458 */ 459 bus_print_child_header(device_get_parent(child), child); 460 printf(" can't assign resources (%s)\n", reason); 461 if (bootverbose) |
466 isa_print_child(device_get_parent(child), child); | 462 isa_print_child(device_get_parent(child), child); |
467 bzero(cfg, sizeof (*cfg)); 468 if (idev->id_config_cb) 469 idev->id_config_cb(idev->id_config_arg, cfg, 0); 470 device_disable(child); 471 472 free(cfg, M_TEMP); | 463 bzero(cfg, sizeof (*cfg)); 464 if (idev->id_config_cb) 465 idev->id_config_cb(idev->id_config_arg, cfg, 0); 466 device_disable(child); 467 468 free(cfg, M_TEMP); |
473 return 0; | 469 return (0); |
474} 475 476/* 477 * Return non-zero if the device has a single configuration, that is, 478 * a fixed set of resoruces. 479 */ 480static int 481isa_has_single_config(device_t dev) 482{ 483 struct isa_device *idev = DEVTOISA(dev); 484 struct isa_config_entry *ice; | 470} 471 472/* 473 * Return non-zero if the device has a single configuration, that is, 474 * a fixed set of resoruces. 475 */ 476static int 477isa_has_single_config(device_t dev) 478{ 479 struct isa_device *idev = DEVTOISA(dev); 480 struct isa_config_entry *ice; |
485 u_int32_t mask; | 481 uint32_t mask; |
486 int i; 487 488 ice = TAILQ_FIRST(&idev->id_configs); 489 if (TAILQ_NEXT(ice, ice_link)) | 482 int i; 483 484 ice = TAILQ_FIRST(&idev->id_configs); 485 if (TAILQ_NEXT(ice, ice_link)) |
490 return 0; | 486 return (0); |
491 492 for (i = 0; i < ice->ice_config.ic_nmem; ++i) { 493 if (ice->ice_config.ic_mem[i].ir_size == 0) 494 continue; 495 if (ice->ice_config.ic_mem[i].ir_end != 496 ice->ice_config.ic_mem[i].ir_start + 497 ice->ice_config.ic_mem[i].ir_size - 1) | 487 488 for (i = 0; i < ice->ice_config.ic_nmem; ++i) { 489 if (ice->ice_config.ic_mem[i].ir_size == 0) 490 continue; 491 if (ice->ice_config.ic_mem[i].ir_end != 492 ice->ice_config.ic_mem[i].ir_start + 493 ice->ice_config.ic_mem[i].ir_size - 1) |
498 return 0; | 494 return (0); |
499 } 500 for (i = 0; i < ice->ice_config.ic_nport; ++i) { 501 if (ice->ice_config.ic_port[i].ir_size == 0) 502 continue; 503 if (ice->ice_config.ic_port[i].ir_end != 504 ice->ice_config.ic_port[i].ir_start + 505 ice->ice_config.ic_port[i].ir_size - 1) | 495 } 496 for (i = 0; i < ice->ice_config.ic_nport; ++i) { 497 if (ice->ice_config.ic_port[i].ir_size == 0) 498 continue; 499 if (ice->ice_config.ic_port[i].ir_end != 500 ice->ice_config.ic_port[i].ir_start + 501 ice->ice_config.ic_port[i].ir_size - 1) |
506 return 0; | 502 return (0); |
507 } 508 for (i = 0; i < ice->ice_config.ic_nirq; ++i) { 509 mask = ice->ice_config.ic_irqmask[i]; 510 if (mask == 0) 511 continue; 512 if (find_next_bit(mask, find_first_bit(mask)) != -1) | 503 } 504 for (i = 0; i < ice->ice_config.ic_nirq; ++i) { 505 mask = ice->ice_config.ic_irqmask[i]; 506 if (mask == 0) 507 continue; 508 if (find_next_bit(mask, find_first_bit(mask)) != -1) |
513 return 0; | 509 return (0); |
514 } 515 for (i = 0; i < ice->ice_config.ic_ndrq; ++i) { 516 mask = ice->ice_config.ic_drqmask[i]; 517 if (mask == 0) 518 continue; 519 if (find_next_bit(mask, find_first_bit(mask)) != -1) | 510 } 511 for (i = 0; i < ice->ice_config.ic_ndrq; ++i) { 512 mask = ice->ice_config.ic_drqmask[i]; 513 if (mask == 0) 514 continue; 515 if (find_next_bit(mask, find_first_bit(mask)) != -1) |
520 return 0; | 516 return (0); |
521 } | 517 } |
522 return 1; | 518 return (1); |
523} 524 525/* 526 * Called after other devices have initialised to probe for isa devices. 527 */ 528void 529isa_probe_children(device_t dev) 530{ --- 98 unchanged lines hidden (view full) --- 629 struct isa_device *idev; 630 631 child = device_add_child_ordered(dev, order, name, unit); 632 if (child == NULL) 633 return (child); 634 635 idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT | M_ZERO); 636 if (!idev) | 519} 520 521/* 522 * Called after other devices have initialised to probe for isa devices. 523 */ 524void 525isa_probe_children(device_t dev) 526{ --- 98 unchanged lines hidden (view full) --- 625 struct isa_device *idev; 626 627 child = device_add_child_ordered(dev, order, name, unit); 628 if (child == NULL) 629 return (child); 630 631 idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT | M_ZERO); 632 if (!idev) |
637 return 0; | 633 return (0); |
638 639 resource_list_init(&idev->id_resources); 640 TAILQ_INIT(&idev->id_configs); 641 642 device_set_ivars(child, idev); 643 644 return (child); 645} --- 10 unchanged lines hidden (view full) --- 656 657 retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx"); 658 retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx"); 659 retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld"); 660 retval += resource_list_print_type(rl, "drq", SYS_RES_DRQ, "%ld"); 661 if (device_get_flags(dev)) 662 retval += printf(" flags %#x", device_get_flags(dev)); 663 | 634 635 resource_list_init(&idev->id_resources); 636 TAILQ_INIT(&idev->id_configs); 637 638 device_set_ivars(child, idev); 639 640 return (child); 641} --- 10 unchanged lines hidden (view full) --- 652 653 retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx"); 654 retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx"); 655 retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld"); 656 retval += resource_list_print_type(rl, "drq", SYS_RES_DRQ, "%ld"); 657 if (device_get_flags(dev)) 658 retval += printf(" flags %#x", device_get_flags(dev)); 659 |
664 return retval; | 660 return (retval); |
665} 666 667static int 668isa_print_child(device_t bus, device_t dev) 669{ 670 int retval = 0; 671 672 retval += bus_print_child_header(bus, dev); --- 136 unchanged lines hidden (view full) --- 809 *result = idev->id_compatid; 810 break; 811 812 case ISA_IVAR_CONFIGATTR: 813 *result = idev->id_config_attr; 814 break; 815 816 default: | 661} 662 663static int 664isa_print_child(device_t bus, device_t dev) 665{ 666 int retval = 0; 667 668 retval += bus_print_child_header(bus, dev); --- 136 unchanged lines hidden (view full) --- 805 *result = idev->id_compatid; 806 break; 807 808 case ISA_IVAR_CONFIGATTR: 809 *result = idev->id_config_attr; 810 break; 811 812 default: |
817 return ENOENT; | 813 return (ENOENT); |
818 } 819 | 814 } 815 |
820 return 0; | 816 return (0); |
821} 822 823static int | 817} 818 819static int |
824isa_write_ivar(device_t bus, device_t dev, 825 int index, uintptr_t value) | 820isa_write_ivar(device_t bus, device_t dev, int index, uintptr_t value) |
826{ 827 struct isa_device* idev = DEVTOISA(dev); 828 829 switch (index) { 830 case ISA_IVAR_PORT_0: 831 case ISA_IVAR_PORT_1: 832 case ISA_IVAR_PORTSIZE_0: 833 case ISA_IVAR_PORTSIZE_1: 834 case ISA_IVAR_MADDR_0: 835 case ISA_IVAR_MADDR_1: 836 case ISA_IVAR_MEMSIZE_0: 837 case ISA_IVAR_MEMSIZE_1: 838 case ISA_IVAR_IRQ_0: 839 case ISA_IVAR_IRQ_1: 840 case ISA_IVAR_DRQ_0: 841 case ISA_IVAR_DRQ_1: | 821{ 822 struct isa_device* idev = DEVTOISA(dev); 823 824 switch (index) { 825 case ISA_IVAR_PORT_0: 826 case ISA_IVAR_PORT_1: 827 case ISA_IVAR_PORTSIZE_0: 828 case ISA_IVAR_PORTSIZE_1: 829 case ISA_IVAR_MADDR_0: 830 case ISA_IVAR_MADDR_1: 831 case ISA_IVAR_MEMSIZE_0: 832 case ISA_IVAR_MEMSIZE_1: 833 case ISA_IVAR_IRQ_0: 834 case ISA_IVAR_IRQ_1: 835 case ISA_IVAR_DRQ_0: 836 case ISA_IVAR_DRQ_1: |
842 return EINVAL; | 837 return (EINVAL); |
843 844 case ISA_IVAR_VENDORID: 845 idev->id_vendorid = value; 846 break; 847 848 case ISA_IVAR_SERIAL: 849 idev->id_serial = value; 850 break; --- 108 unchanged lines hidden (view full) --- 959 } 960 } 961 962 free(children, M_TEMP); 963} 964 965static int 966isa_set_resource(device_t dev, device_t child, int type, int rid, | 838 839 case ISA_IVAR_VENDORID: 840 idev->id_vendorid = value; 841 break; 842 843 case ISA_IVAR_SERIAL: 844 idev->id_serial = value; 845 break; --- 108 unchanged lines hidden (view full) --- 954 } 955 } 956 957 free(children, M_TEMP); 958} 959 960static int 961isa_set_resource(device_t dev, device_t child, int type, int rid, |
967 u_long start, u_long count) | 962 u_long start, u_long count) |
968{ 969 struct isa_device* idev = DEVTOISA(child); 970 struct resource_list *rl = &idev->id_resources; 971 972 if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY 973 && type != SYS_RES_IRQ && type != SYS_RES_DRQ) | 963{ 964 struct isa_device* idev = DEVTOISA(child); 965 struct resource_list *rl = &idev->id_resources; 966 967 if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY 968 && type != SYS_RES_IRQ && type != SYS_RES_DRQ) |
974 return EINVAL; | 969 return (EINVAL); |
975 if (rid < 0) | 970 if (rid < 0) |
976 return EINVAL; | 971 return (EINVAL); |
977 if (type == SYS_RES_IOPORT && rid >= ISA_NPORT) | 972 if (type == SYS_RES_IOPORT && rid >= ISA_NPORT) |
978 return EINVAL; | 973 return (EINVAL); |
979 if (type == SYS_RES_MEMORY && rid >= ISA_NMEM) | 974 if (type == SYS_RES_MEMORY && rid >= ISA_NMEM) |
980 return EINVAL; | 975 return (EINVAL); |
981 if (type == SYS_RES_IRQ && rid >= ISA_NIRQ) | 976 if (type == SYS_RES_IRQ && rid >= ISA_NIRQ) |
982 return EINVAL; | 977 return (EINVAL); |
983 if (type == SYS_RES_DRQ && rid >= ISA_NDRQ) | 978 if (type == SYS_RES_DRQ && rid >= ISA_NDRQ) |
984 return EINVAL; | 979 return (EINVAL); |
985 986 resource_list_add(rl, type, rid, start, start + count - 1, count); 987 | 980 981 resource_list_add(rl, type, rid, start, start + count - 1, count); 982 |
988 return 0; | 983 return (0); |
989} 990 991static struct resource_list * 992isa_get_resource_list (device_t dev, device_t child) 993{ 994 struct isa_device* idev = DEVTOISA(child); 995 struct resource_list *rl = &idev->id_resources; 996 997 if (!rl) 998 return (NULL); 999 1000 return (rl); 1001} 1002 1003static int | 984} 985 986static struct resource_list * 987isa_get_resource_list (device_t dev, device_t child) 988{ 989 struct isa_device* idev = DEVTOISA(child); 990 struct resource_list *rl = &idev->id_resources; 991 992 if (!rl) 993 return (NULL); 994 995 return (rl); 996} 997 998static int |
1004isa_add_config(device_t dev, device_t child, 1005 int priority, struct isa_config *config) | 999isa_add_config(device_t dev, device_t child, int priority, 1000 struct isa_config *config) |
1006{ 1007 struct isa_device* idev = DEVTOISA(child); 1008 struct isa_config_entry *newice, *ice; 1009 1010 newice = malloc(sizeof *ice, M_DEVBUF, M_NOWAIT); 1011 if (!newice) | 1001{ 1002 struct isa_device* idev = DEVTOISA(child); 1003 struct isa_config_entry *newice, *ice; 1004 1005 newice = malloc(sizeof *ice, M_DEVBUF, M_NOWAIT); 1006 if (!newice) |
1012 return ENOMEM; | 1007 return (ENOMEM); |
1013 1014 newice->ice_priority = priority; 1015 newice->ice_config = *config; 1016 1017 TAILQ_FOREACH(ice, &idev->id_configs, ice_link) { 1018 if (ice->ice_priority > priority) 1019 break; 1020 } 1021 if (ice) 1022 TAILQ_INSERT_BEFORE(ice, newice, ice_link); 1023 else 1024 TAILQ_INSERT_TAIL(&idev->id_configs, newice, ice_link); 1025 1026 if (isa_has_single_config(child)) 1027 idev->id_config_attr &= ~ISACFGATTR_MULTI; 1028 else 1029 idev->id_config_attr |= ISACFGATTR_MULTI; 1030 | 1008 1009 newice->ice_priority = priority; 1010 newice->ice_config = *config; 1011 1012 TAILQ_FOREACH(ice, &idev->id_configs, ice_link) { 1013 if (ice->ice_priority > priority) 1014 break; 1015 } 1016 if (ice) 1017 TAILQ_INSERT_BEFORE(ice, newice, ice_link); 1018 else 1019 TAILQ_INSERT_TAIL(&idev->id_configs, newice, ice_link); 1020 1021 if (isa_has_single_config(child)) 1022 idev->id_config_attr &= ~ISACFGATTR_MULTI; 1023 else 1024 idev->id_config_attr |= ISACFGATTR_MULTI; 1025 |
1031 return 0; | 1026 return (0); |
1032} 1033 1034static void | 1027} 1028 1029static void |
1035isa_set_config_callback(device_t dev, device_t child, 1036 isa_config_cb *fn, void *arg) | 1030isa_set_config_callback(device_t dev, device_t child, isa_config_cb *fn, 1031 void *arg) |
1037{ 1038 struct isa_device* idev = DEVTOISA(child); 1039 1040 idev->id_config_cb = fn; 1041 idev->id_config_arg = arg; 1042} 1043 1044static int 1045isa_pnp_probe(device_t dev, device_t child, struct isa_pnp_id *ids) 1046{ 1047 struct isa_device* idev = DEVTOISA(child); 1048 1049 if (!idev->id_vendorid) | 1032{ 1033 struct isa_device* idev = DEVTOISA(child); 1034 1035 idev->id_config_cb = fn; 1036 idev->id_config_arg = arg; 1037} 1038 1039static int 1040isa_pnp_probe(device_t dev, device_t child, struct isa_pnp_id *ids) 1041{ 1042 struct isa_device* idev = DEVTOISA(child); 1043 1044 if (!idev->id_vendorid) |
1050 return ENOENT; | 1045 return (ENOENT); |
1051 1052 while (ids && ids->ip_id) { 1053 /* 1054 * Really ought to support >1 compat id per device. 1055 */ 1056 if (idev->id_logicalid == ids->ip_id 1057 || idev->id_compatid == ids->ip_id) { 1058 if (ids->ip_desc) 1059 device_set_desc(child, ids->ip_desc); | 1046 1047 while (ids && ids->ip_id) { 1048 /* 1049 * Really ought to support >1 compat id per device. 1050 */ 1051 if (idev->id_logicalid == ids->ip_id 1052 || idev->id_compatid == ids->ip_id) { 1053 if (ids->ip_desc) 1054 device_set_desc(child, ids->ip_desc); |
1060 return 0; | 1055 return (0); |
1061 } 1062 ids++; 1063 } 1064 | 1056 } 1057 ids++; 1058 } 1059 |
1065 return ENXIO; | 1060 return (ENXIO); |
1066} 1067 1068static device_method_t isa_methods[] = { 1069 /* Device interface */ 1070 DEVMETHOD(device_probe, isa_probe), 1071 DEVMETHOD(device_attach, isa_attach), 1072 DEVMETHOD(device_detach, bus_generic_detach), 1073 DEVMETHOD(device_shutdown, bus_generic_shutdown), --- 63 unchanged lines hidden --- | 1061} 1062 1063static device_method_t isa_methods[] = { 1064 /* Device interface */ 1065 DEVMETHOD(device_probe, isa_probe), 1066 DEVMETHOD(device_attach, isa_attach), 1067 DEVMETHOD(device_detach, bus_generic_detach), 1068 DEVMETHOD(device_shutdown, bus_generic_shutdown), --- 63 unchanged lines hidden --- |