Changeset f8e8738 in mainline for uspace/drv/pciintel/pci.c
- Timestamp:
- 2011-04-07T20:22:40Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fee6381
- Parents:
- 61257f4 (diff), a82889e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/pciintel/pci.c
r61257f4 rf8e8738 48 48 49 49 #include <ddf/driver.h> 50 #include <ddf/log.h> 50 51 #include <devman.h> 51 52 #include <ipc/devman.h> … … 106 107 } 107 108 108 size_t i; 109 for (i = 0; i < dev_data->hw_resources.count; i++) { 110 if (dev_data->hw_resources.resources[i].type == INTERRUPT) { 111 int irq = dev_data->hw_resources.resources[i].res.interrupt.irq; 112 int rc = async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq); 109 size_t i = 0; 110 hw_resource_list_t *res = &dev_data->hw_resources; 111 for (; i < res->count; i++) { 112 if (res->resources[i].type == INTERRUPT) { 113 const int irq = res->resources[i].res.interrupt.irq; 114 const int rc = 115 async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq); 113 116 if (rc != EOK) { 114 117 async_hangup(irc_phone); … … 325 328 326 329 if (match_id_str == NULL) { 327 printf(NAME ": out of memory creating match ID.\n");330 ddf_msg(LVL_ERROR, "Out of memory creating match ID."); 328 331 return; 329 332 } … … 331 334 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90); 332 335 if (rc != EOK) { 333 printf(NAME ": error adding match ID: %s\n",336 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", 334 337 str_error(rc)); 335 338 } … … 428 431 429 432 if (range_addr != 0) { 430 printf(NAME ": function %s : ", fun->fnode->name);431 printf("address = %" PRIx64, range_addr);432 printf(", size = %x\n",(unsigned int) range_size);433 ddf_msg(LVL_DEBUG, "Function %s : address = %" PRIx64 434 ", size = %x", fun->fnode->name, range_addr, 435 (unsigned int) range_size); 433 436 } 434 437 … … 455 458 hw_res_list->count++; 456 459 457 printf(NAME ": function %s uses irq %x.\n", fun->fnode->name, irq);460 ddf_msg(LVL_NOTE, "Function %s uses irq %x.", fun->fnode->name, irq); 458 461 } 459 462 … … 511 514 char *fun_name = pci_fun_create_name(fun); 512 515 if (fun_name == NULL) { 513 printf(NAME ": out of memory.\n");516 ddf_msg(LVL_ERROR, "Out of memory."); 514 517 return; 515 518 } … … 517 520 fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name); 518 521 if (fnode == NULL) { 519 printf(NAME ": error creating function.\n");522 ddf_msg(LVL_ERROR, "Failed creating function."); 520 523 return; 521 524 } … … 531 534 fnode->driver_data = fun; 532 535 533 printf(NAME ": adding new function %s.\n",536 ddf_msg(LVL_DEBUG, "Adding new function %s.", 534 537 fnode->name); 535 538 … … 548 551 child_bus = pci_conf_read_8(fun, 549 552 PCI_BRIDGE_SEC_BUS_NUM); 550 printf(NAME ": device is pci-to-pci bridge, " 551 "secondary bus number = %d.\n", bus_num); 553 ddf_msg(LVL_DEBUG, "Device is pci-to-pci " 554 "bridge, secondary bus number = %d.", 555 bus_num); 552 556 if (child_bus > bus_num) 553 557 pci_bus_scan(bus, child_bus); … … 571 575 int rc; 572 576 573 printf(NAME ": pci_add_device\n");577 ddf_msg(LVL_DEBUG, "pci_add_device"); 574 578 dnode->parent_phone = -1; 575 579 576 580 bus = pci_bus_new(); 577 581 if (bus == NULL) { 578 printf(NAME ": pci_add_device allocation failed.\n");582 ddf_msg(LVL_ERROR, "pci_add_device allocation failed."); 579 583 rc = ENOMEM; 580 584 goto fail; … … 586 590 IPC_FLAG_BLOCKING); 587 591 if (dnode->parent_phone < 0) { 588 printf(NAME ":pci_add_device failed to connect to the "589 "parent's driver. \n");592 ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the " 593 "parent's driver."); 590 594 rc = dnode->parent_phone; 591 595 goto fail; … … 596 600 rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources); 597 601 if (rc != EOK) { 598 printf(NAME ": pci_add_device failed to get hw resources for"599 " the device.\n");602 ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources " 603 "for the device."); 600 604 goto fail; 601 605 } 602 606 got_res = true; 603 607 604 printf(NAME ": conf_addr = %" PRIx64 ".\n",608 ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".", 605 609 hw_resources.resources[0].res.io_range.address); 606 610 … … 614 618 if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 8, 615 619 &bus->conf_addr_port)) { 616 printf(NAME ": failed to enable configuration ports.\n");620 ddf_msg(LVL_ERROR, "Failed to enable configuration ports."); 617 621 rc = EADDRNOTAVAIL; 618 622 goto fail; … … 621 625 622 626 /* Make the bus device more visible. It has no use yet. */ 623 printf(NAME ": adding a 'ctl' function\n");627 ddf_msg(LVL_DEBUG, "Adding a 'ctl' function"); 624 628 625 629 ctl = ddf_fun_create(bus->dnode, fun_exposed, "ctl"); 626 630 if (ctl == NULL) { 627 printf(NAME ": error creating control function.\n");631 ddf_msg(LVL_ERROR, "Failed creating control function."); 628 632 rc = ENOMEM; 629 633 goto fail; … … 632 636 rc = ddf_fun_bind(ctl); 633 637 if (rc != EOK) { 634 printf(NAME ": error binding control function.\n");638 ddf_msg(LVL_ERROR, "Failed binding control function."); 635 639 goto fail; 636 640 } 637 641 638 642 /* Enumerate functions. */ 639 printf(NAME ": scanning the bus\n");643 ddf_msg(LVL_DEBUG, "Scanning the bus"); 640 644 pci_bus_scan(bus, 0); 641 645 … … 659 663 static void pciintel_init(void) 660 664 { 665 ddf_log_init(NAME, LVL_ERROR); 661 666 pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops; 662 667 pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops; … … 738 743 int main(int argc, char *argv[]) 739 744 { 740 printf(NAME ": HelenOS pci bus driver (intel method 1).\n");745 printf(NAME ": HelenOS PCI bus driver (Intel method 1).\n"); 741 746 pciintel_init(); 742 747 return ddf_driver_main(&pci_driver);
Note:
See TracChangeset
for help on using the changeset viewer.