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