Changes in uspace/drv/pciintel/pci.c [91579d5:5857be2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/pciintel/pci.c
r91579d5 r5857be2 48 48 49 49 #include <ddf/driver.h> 50 #include <ddf/log.h> 50 51 #include <devman.h> 51 52 #include <ipc/devman.h> … … 95 96 sysarg_t i8259; 96 97 97 int irc_phone = -1; 98 int irc_service = -1; 99 100 if ((sysinfo_get_value("apic", &apic) == EOK) && (apic)) { 101 irc_service = SERVICE_APIC; 102 } else if ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)) { 103 irc_service = SERVICE_I8259; 104 } 105 106 if (irc_service == -1) { 107 return false; 108 } 109 110 irc_phone = service_connect_blocking(irc_service, 0, 0); 98 int irc_phone = ENOTSUP; 99 100 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) 101 || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) { 102 irc_phone = service_connect_blocking(SERVICE_IRC, 0, 0); 103 } 104 111 105 if (irc_phone < 0) { 112 106 return false; 113 107 } 114 108 115 size_t i; 116 for (i = 0; i < dev_data->hw_resources.count; i++) { 117 if (dev_data->hw_resources.resources[i].type == INTERRUPT) { 118 int irq = dev_data->hw_resources.resources[i].res.interrupt.irq; 119 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); 120 116 if (rc != EOK) { 121 117 async_hangup(irc_phone); … … 332 328 333 329 if (match_id_str == NULL) { 334 printf(NAME ": out of memory creating match ID.\n");330 ddf_msg(LVL_ERROR, "Out of memory creating match ID."); 335 331 return; 336 332 } … … 338 334 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90); 339 335 if (rc != EOK) { 340 printf(NAME ": error adding match ID: %s\n",336 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", 341 337 str_error(rc)); 342 338 } … … 435 431 436 432 if (range_addr != 0) { 437 printf(NAME ": function %s : ", fun->fnode->name);438 printf("address = %" PRIx64, range_addr);439 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); 440 436 } 441 437 … … 462 458 hw_res_list->count++; 463 459 464 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); 465 461 } 466 462 … … 518 514 char *fun_name = pci_fun_create_name(fun); 519 515 if (fun_name == NULL) { 520 printf(NAME ": out of memory.\n");516 ddf_msg(LVL_ERROR, "Out of memory."); 521 517 return; 522 518 } … … 524 520 fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name); 525 521 if (fnode == NULL) { 526 printf(NAME ": error creating function.\n");522 ddf_msg(LVL_ERROR, "Failed creating function."); 527 523 return; 528 524 } … … 538 534 fnode->driver_data = fun; 539 535 540 printf(NAME ": adding new function %s.\n",536 ddf_msg(LVL_DEBUG, "Adding new function %s.", 541 537 fnode->name); 542 538 … … 555 551 child_bus = pci_conf_read_8(fun, 556 552 PCI_BRIDGE_SEC_BUS_NUM); 557 printf(NAME ": device is pci-to-pci bridge, " 558 "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); 559 556 if (child_bus > bus_num) 560 557 pci_bus_scan(bus, child_bus); … … 578 575 int rc; 579 576 580 printf(NAME ": pci_add_device\n");577 ddf_msg(LVL_DEBUG, "pci_add_device"); 581 578 dnode->parent_phone = -1; 582 579 583 580 bus = pci_bus_new(); 584 581 if (bus == NULL) { 585 printf(NAME ": pci_add_device allocation failed.\n");582 ddf_msg(LVL_ERROR, "pci_add_device allocation failed."); 586 583 rc = ENOMEM; 587 584 goto fail; … … 593 590 IPC_FLAG_BLOCKING); 594 591 if (dnode->parent_phone < 0) { 595 printf(NAME ":pci_add_device failed to connect to the "596 "parent's driver. \n");592 ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the " 593 "parent's driver."); 597 594 rc = dnode->parent_phone; 598 595 goto fail; … … 603 600 rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources); 604 601 if (rc != EOK) { 605 printf(NAME ": pci_add_device failed to get hw resources for"606 " the device.\n");602 ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources " 603 "for the device."); 607 604 goto fail; 608 605 } 609 606 got_res = true; 610 607 611 printf(NAME ": conf_addr = %" PRIx64 ".\n",608 ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".", 612 609 hw_resources.resources[0].res.io_range.address); 613 610 … … 621 618 if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 8, 622 619 &bus->conf_addr_port)) { 623 printf(NAME ": failed to enable configuration ports.\n");620 ddf_msg(LVL_ERROR, "Failed to enable configuration ports."); 624 621 rc = EADDRNOTAVAIL; 625 622 goto fail; … … 628 625 629 626 /* Make the bus device more visible. It has no use yet. */ 630 printf(NAME ": adding a 'ctl' function\n");627 ddf_msg(LVL_DEBUG, "Adding a 'ctl' function"); 631 628 632 629 ctl = ddf_fun_create(bus->dnode, fun_exposed, "ctl"); 633 630 if (ctl == NULL) { 634 printf(NAME ": error creating control function.\n");631 ddf_msg(LVL_ERROR, "Failed creating control function."); 635 632 rc = ENOMEM; 636 633 goto fail; … … 639 636 rc = ddf_fun_bind(ctl); 640 637 if (rc != EOK) { 641 printf(NAME ": error binding control function.\n");638 ddf_msg(LVL_ERROR, "Failed binding control function."); 642 639 goto fail; 643 640 } 644 641 645 642 /* Enumerate functions. */ 646 printf(NAME ": scanning the bus\n");643 ddf_msg(LVL_DEBUG, "Scanning the bus"); 647 644 pci_bus_scan(bus, 0); 648 645 … … 666 663 static void pciintel_init(void) 667 664 { 665 ddf_log_init(NAME, LVL_ERROR); 668 666 pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops; 669 667 pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops; … … 745 743 int main(int argc, char *argv[]) 746 744 { 747 printf(NAME ": HelenOS pci bus driver (intel method 1).\n");745 printf(NAME ": HelenOS PCI bus driver (Intel method 1).\n"); 748 746 pciintel_init(); 749 747 return ddf_driver_main(&pci_driver);
Note:
See TracChangeset
for help on using the changeset viewer.