Changeset f8e8738 in mainline for uspace/drv/pciintel/pci.c


Ignore:
Timestamp:
2011-04-07T20:22:40Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
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.
Message:

Changes from development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/pciintel/pci.c

    r61257f4 rf8e8738  
    4848
    4949#include <ddf/driver.h>
     50#include <ddf/log.h>
    5051#include <devman.h>
    5152#include <ipc/devman.h>
     
    106107        }
    107108
    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);
    113116                        if (rc != EOK) {
    114117                                async_hangup(irc_phone);
     
    325328
    326329        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.");
    328331                return;
    329332        }
     
    331334        rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90);
    332335        if (rc != EOK) {
    333                 printf(NAME ": error adding match ID: %s\n",
     336                ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
    334337                    str_error(rc));
    335338        }
     
    428431       
    429432        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);
    433436        }
    434437       
     
    455458        hw_res_list->count++;
    456459       
    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);
    458461}
    459462
     
    511514                        char *fun_name = pci_fun_create_name(fun);
    512515                        if (fun_name == NULL) {
    513                                 printf(NAME ": out of memory.\n");
     516                                ddf_msg(LVL_ERROR, "Out of memory.");
    514517                                return;
    515518                        }
     
    517520                        fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name);
    518521                        if (fnode == NULL) {
    519                                 printf(NAME ": error creating function.\n");
     522                                ddf_msg(LVL_ERROR, "Failed creating function.");
    520523                                return;
    521524                        }
     
    531534                        fnode->driver_data = fun;
    532535                       
    533                         printf(NAME ": adding new function %s.\n",
     536                        ddf_msg(LVL_DEBUG, "Adding new function %s.",
    534537                            fnode->name);
    535538                       
     
    548551                                child_bus = pci_conf_read_8(fun,
    549552                                    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);
    552556                                if (child_bus > bus_num)
    553557                                        pci_bus_scan(bus, child_bus);
     
    571575        int rc;
    572576       
    573         printf(NAME ": pci_add_device\n");
     577        ddf_msg(LVL_DEBUG, "pci_add_device");
    574578        dnode->parent_phone = -1;
    575579       
    576580        bus = pci_bus_new();
    577581        if (bus == NULL) {
    578                 printf(NAME ": pci_add_device allocation failed.\n");
     582                ddf_msg(LVL_ERROR, "pci_add_device allocation failed.");
    579583                rc = ENOMEM;
    580584                goto fail;
     
    586590            IPC_FLAG_BLOCKING);
    587591        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.");
    590594                rc = dnode->parent_phone;
    591595                goto fail;
     
    596600        rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources);
    597601        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.");
    600604                goto fail;
    601605        }
    602606        got_res = true;
    603607       
    604         printf(NAME ": conf_addr = %" PRIx64 ".\n",
     608        ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".",
    605609            hw_resources.resources[0].res.io_range.address);
    606610       
     
    614618        if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 8,
    615619            &bus->conf_addr_port)) {
    616                 printf(NAME ": failed to enable configuration ports.\n");
     620                ddf_msg(LVL_ERROR, "Failed to enable configuration ports.");
    617621                rc = EADDRNOTAVAIL;
    618622                goto fail;
     
    621625       
    622626        /* 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");
    624628       
    625629        ctl = ddf_fun_create(bus->dnode, fun_exposed, "ctl");
    626630        if (ctl == NULL) {
    627                 printf(NAME ": error creating control function.\n");
     631                ddf_msg(LVL_ERROR, "Failed creating control function.");
    628632                rc = ENOMEM;
    629633                goto fail;
     
    632636        rc = ddf_fun_bind(ctl);
    633637        if (rc != EOK) {
    634                 printf(NAME ": error binding control function.\n");
     638                ddf_msg(LVL_ERROR, "Failed binding control function.");
    635639                goto fail;
    636640        }
    637641       
    638642        /* Enumerate functions. */
    639         printf(NAME ": scanning the bus\n");
     643        ddf_msg(LVL_DEBUG, "Scanning the bus");
    640644        pci_bus_scan(bus, 0);
    641645       
     
    659663static void pciintel_init(void)
    660664{
     665        ddf_log_init(NAME, LVL_ERROR);
    661666        pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops;
    662667        pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops;
     
    738743int main(int argc, char *argv[])
    739744{
    740         printf(NAME ": HelenOS pci bus driver (intel method 1).\n");
     745        printf(NAME ": HelenOS PCI bus driver (Intel method 1).\n");
    741746        pciintel_init();
    742747        return ddf_driver_main(&pci_driver);
Note: See TracChangeset for help on using the changeset viewer.