Changeset 73aec008 in mainline


Ignore:
Timestamp:
2011-03-31T18:23:41Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a30e435
Parents:
917a8c8 (diff), 3acb285 (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:

Merge devman and driver logging improvements. Devman started by default.

Files:
4 added
15 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r917a8c8 r73aec008  
    528528! [PLATFORM=sparc64&MACHINE=generic] CONFIG_AOUT_ISOFS_B (y)
    529529
     530% Run devman on startup
     531! CONFIG_START_DEVMAN (y/n)
     532
     533% Launch (devman) test drivers
     534! [CONFIG_START_DEVMAN=y&CONFIG_DEBUG=y] CONFIG_TEST_DRIVERS (y/n)
     535
    530536% Load disk drivers on startup
    531537! CONFIG_START_BD (n/y)
     
    548554% Line debugging information
    549555! [CONFIG_STRIP_BINARIES!=y] CONFIG_LINE_DEBUG (n/y)
    550 
    551 % Launch (devman) test drivers
    552 ! [CONFIG_DEBUG=y] CONFIG_TEST_DRIVERS (y/n)
    553 
  • uspace/app/init/init.c

    r917a8c8 r73aec008  
    272272        mount_tmpfs();
    273273       
     274#ifdef CONFIG_START_DEVMAN
     275        spawn("/srv/devman");
     276#endif
    274277        spawn("/srv/apic");
    275278        spawn("/srv/i8259");
  • uspace/drv/isa/isa.c

    r917a8c8 r73aec008  
    5353
    5454#include <ddf/driver.h>
     55#include <ddf/log.h>
    5556#include <ops/hw_res.h>
    5657
     
    134135        fd = open(conf_path, O_RDONLY);
    135136        if (fd < 0) {
    136                 printf(NAME ": unable to open %s\n", conf_path);
     137                ddf_msg(LVL_ERROR, "Unable to open %s\n", conf_path);
    137138                goto cleanup;
    138139        }
     
    141142
    142143        len = lseek(fd, 0, SEEK_END);
    143         lseek(fd, 0, SEEK_SET); 
     144        lseek(fd, 0, SEEK_SET);
    144145        if (len == 0) {
    145                 printf(NAME ": fun_conf_read error: configuration file '%s' "
    146                     "is empty.\n", conf_path);
     146                ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.\n",
     147                    conf_path);
    147148                goto cleanup;
    148149        }
     
    150151        buf = malloc(len + 1);
    151152        if (buf == NULL) {
    152                 printf(NAME ": fun_conf_read error: memory allocation failed.\n");
     153                ddf_msg(LVL_ERROR, "Memory allocation failed.\n");
    153154                goto cleanup;
    154155        }
    155156
    156157        if (0 >= read(fd, buf, len)) {
    157                 printf(NAME ": fun_conf_read error: unable to read file '%s'.\n",
    158                     conf_path);
     158                ddf_msg(LVL_ERROR, "Unable to read file '%s'.\n", conf_path);
    159159                goto cleanup;
    160160        }
     
    252252                fun->hw_resources.count++;
    253253
    254                 printf(NAME ": added irq 0x%x to function %s\n", irq,
     254                ddf_msg(LVL_NOTE, "Added irq 0x%x to function %s\n", irq,
    255255                    fun->fnode->name);
    256256        }
     
    270270                fun->hw_resources.count++;
    271271
    272                 printf(NAME ": added io range (addr=0x%x, size=0x%x) to "
     272                ddf_msg(LVL_NOTE, "Added io range (addr=0x%x, size=0x%x) to "
    273273                    "function %s\n", (unsigned int) addr, (unsigned int) len,
    274274                    fun->fnode->name);
     
    331331        score = (int)strtol(val, &end, 10);
    332332        if (val == end) {
    333                 printf(NAME " : error - could not read match score for "
    334                     "function %s.\n", fun->fnode->name);
     333                ddf_msg(LVL_ERROR, "Cannot read match score for function "
     334                    "%s.\n", fun->fnode->name);
    335335                return;
    336336        }
     
    339339        get_match_id(&id, val);
    340340        if (id == NULL) {
    341                 printf(NAME " : error - could not read match id for "
    342                     "function %s.\n", fun->fnode->name);
     341                ddf_msg(LVL_ERROR, "Cannot read match ID for function %s.\n",
     342                    fun->fnode->name);
    343343                return;
    344344        }
    345345
    346         printf(NAME ": adding match id '%s' with score %d to function %s\n", id,
    347             score, fun->fnode->name);
     346        ddf_msg(LVL_DEBUG, "Adding match id '%s' with score %d to "
     347            "function %s\n", id, score, fun->fnode->name);
    348348
    349349        rc = ddf_fun_add_match_id(fun->fnode, id, score);
    350         if (rc != EOK)
    351                 printf(NAME ": error adding match ID: %s\n", str_error(rc));
     350        if (rc != EOK) {
     351                ddf_msg(LVL_ERROR, "Failed adding match ID: %s\n",
     352                    str_error(rc));
     353        }
    352354}
    353355
     
    375377        if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) &&
    376378            !prop_parse(fun, line, "irq", &fun_parse_irq) &&
    377             !prop_parse(fun, line, "match", &fun_parse_match_id))
    378         {
    379             printf(NAME " error undefined device property at line '%s'\n",
    380                 line);
     379            !prop_parse(fun, line, "match", &fun_parse_match_id)) {
     380
     381                ddf_msg(LVL_ERROR, "Undefined device property at line '%s'\n",
     382                    line);
    381383        }
    382384}
     
    439441        fun->fnode->ops = &isa_fun_ops;
    440442
    441         printf(NAME ": Binding function %s.\n", fun->fnode->name);
     443        ddf_msg(LVL_DEBUG, "Binding function %s.\n", fun->fnode->name);
    442444
    443445        /* XXX Handle error */
     
    467469static int isa_add_device(ddf_dev_t *dev)
    468470{
    469         printf(NAME ": isa_add_device, device handle = %d\n",
     471        ddf_msg(LVL_DEBUG, "isa_add_device, device handle = %d\n",
    470472            (int) dev->handle);
    471473
    472474        /* Make the bus device more visible. Does not do anything. */
    473         printf(NAME ": adding a 'ctl' function\n");
     475        ddf_msg(LVL_DEBUG, "Adding a 'ctl' function\n");
    474476
    475477        ddf_fun_t *ctl = ddf_fun_create(dev, fun_exposed, "ctl");
    476478        if (ctl == NULL) {
    477                 printf(NAME ": Error creating control function.\n");
     479                ddf_msg(LVL_ERROR, "Failed creating control function.\n");
    478480                return EXDEV;
    479481        }
    480482
    481483        if (ddf_fun_bind(ctl) != EOK) {
    482                 printf(NAME ": Error binding control function.\n");
     484                ddf_msg(LVL_ERROR, "Failed binding control function.\n");
    483485                return EXDEV;
    484486        }
     
    486488        /* Add functions as specified in the configuration file. */
    487489        isa_functions_add(dev);
    488         printf(NAME ": finished the enumeration of legacy functions\n");
     490        ddf_msg(LVL_NOTE, "Finished enumerating legacy functions\n");
    489491
    490492        return EOK;
     
    493495static void isa_init()
    494496{
     497        ddf_log_init(NAME, LVL_ERROR);
    495498        isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops;
    496499}
  • uspace/drv/ns8250/ns8250.c

    r917a8c8 r73aec008  
    5555#include <ddf/driver.h>
    5656#include <ddf/interrupt.h>
     57#include <ddf/log.h>
    5758#include <ops/char_dev.h>
    5859
     
    275276static bool ns8250_pio_enable(ns8250_t *ns)
    276277{
    277         printf(NAME ": ns8250_pio_enable %s\n", ns->dev->name);
     278        ddf_msg(LVL_DEBUG, "ns8250_pio_enable %s\n", ns->dev->name);
    278279       
    279280        /* Gain control over port's registers. */
    280281        if (pio_enable((void *)(uintptr_t) ns->io_addr, REG_COUNT,
    281282            (void **) &ns->port)) {
    282                 printf(NAME ": error - cannot gain the port %#" PRIx32 " for device "
    283                     "%s.\n", ns->io_addr, ns->dev->name);
     283                ddf_msg(LVL_ERROR, "Cannot map the port %#" PRIx32
     284                    " for device %s.\n", ns->io_addr, ns->dev->name);
    284285                return false;
    285286        }
     
    295296static bool ns8250_dev_probe(ns8250_t *ns)
    296297{
    297         printf(NAME ": ns8250_dev_probe %s\n", ns->dev->name);
     298        ddf_msg(LVL_DEBUG, "ns8250_dev_probe %s\n", ns->dev->name);
    298299       
    299300        ioport8_t *port_addr = ns->port;
     
    313314        pio_write_8(port_addr + 4, olddata);
    314315       
    315         if (!res)
    316                 printf(NAME ": device %s is not present.\n", ns->dev->name);
     316        if (!res) {
     317                ddf_msg(LVL_DEBUG, "Device %s is not present.\n",
     318                    ns->dev->name);
     319        }
    317320       
    318321        return res;
     
    326329static int ns8250_dev_initialize(ns8250_t *ns)
    327330{
    328         printf(NAME ": ns8250_dev_initialize %s\n", ns->dev->name);
     331        ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s\n", ns->dev->name);
    329332       
    330333        int ret = EOK;
     
    337340            IPC_FLAG_BLOCKING);
    338341        if (ns->dev->parent_phone < 0) {
    339                 printf(NAME ": failed to connect to the parent driver of the "
     342                ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
    340343                    "device %s.\n", ns->dev->name);
    341344                ret = ns->dev->parent_phone;
     
    346349        ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources);
    347350        if (ret != EOK) {
    348                 printf(NAME ": failed to get hw resources for the device "
     351                ddf_msg(LVL_ERROR, "Failed to get HW resources for device "
    349352                    "%s.\n", ns->dev->name);
    350353                goto failed;
     
    362365                        ns->irq = res->res.interrupt.irq;
    363366                        irq = true;
    364                         printf(NAME ": the %s device was asigned irq = 0x%x.\n",
     367                        ddf_msg(LVL_NOTE, "Device %s was asigned irq = 0x%x.\n",
    365368                            ns->dev->name, ns->irq);
    366369                        break;
     
    369372                        ns->io_addr = res->res.io_range.address;
    370373                        if (res->res.io_range.size < REG_COUNT) {
    371                                 printf(NAME ": i/o range assigned to the device "
    372                                     "%s is too small.\n", ns->dev->name);
     374                                ddf_msg(LVL_ERROR, "I/O range assigned to "
     375                                    "device %s is too small.\n", ns->dev->name);
    373376                                ret = ELIMIT;
    374377                                goto failed;
    375378                        }
    376379                        ioport = true;
    377                         printf(NAME ": the %s device was asigned i/o address = "
     380                        ddf_msg(LVL_NOTE, "Device %s was asigned I/O address = "
    378381                            "0x%x.\n", ns->dev->name, ns->io_addr);
    379382                        break;
     
    385388       
    386389        if (!irq || !ioport) {
    387                 printf(NAME ": missing hw resource(s) for the device %s.\n",
     390                ddf_msg(LVL_ERROR, "Missing HW resource(s) for device %s.\n",
    388391                    ns->dev->name);
    389392                ret = ENOENT;
     
    470473       
    471474        if (baud_rate < 50 || MAX_BAUD_RATE % baud_rate != 0) {
    472                 printf(NAME ": error - somebody tried to set invalid baud rate "
    473                     "%d\n", baud_rate);
     475                ddf_msg(LVL_ERROR, "Invalid baud rate %d requested.\n",
     476                    baud_rate);
    474477                return EINVAL;
    475478        }
     
    654657                        if (ns->client_connected) {
    655658                                if (!buf_push_back(&ns->input_buffer, val)) {
    656                                         printf(NAME ": buffer overflow on "
     659                                        ddf_msg(LVL_WARN, "Buffer overflow on "
    657660                                            "%s.\n", ns->dev->name);
    658661                                } else {
    659                                         printf(NAME ": the character %c saved "
     662                                        ddf_msg(LVL_DEBUG2, "Character %c saved "
    660663                                            "to the buffer of %s.\n",
    661664                                            val, ns->dev->name);
     
    714717        int rc;
    715718       
    716         printf(NAME ": ns8250_add_device %s (handle = %d)\n",
     719        ddf_msg(LVL_DEBUG, "ns8250_add_device %s (handle = %d)\n",
    717720            dev->name, (int) dev->handle);
    718721       
     
    749752        /* Register interrupt handler. */
    750753        if (ns8250_register_interrupt_handler(ns) != EOK) {
    751                 printf(NAME ": failed to register interrupt handler.\n");
     754                ddf_msg(LVL_ERROR, "Failed to register interrupt handler.\n");
    752755                rc = EADDRNOTAVAIL;
    753756                goto fail;
     
    757760        rc = ns8250_interrupt_enable(ns);
    758761        if (rc != EOK) {
    759                 printf(NAME ": failed to enable the interrupt. Error code = "
     762                ddf_msg(LVL_ERROR, "Failed to enable the interrupt. Error code = "
    760763                    "%d.\n", rc);
    761764                goto fail;
     
    764767        fun = ddf_fun_create(dev, fun_exposed, "a");
    765768        if (fun == NULL) {
    766                 printf(NAME ": error creating function.\n");
     769                ddf_msg(LVL_ERROR, "Failed creating function.\n");
    767770                goto fail;
    768771        }
     
    772775        rc = ddf_fun_bind(fun);
    773776        if (rc != EOK) {
    774                 printf(NAME ": error binding function.\n");
     777                ddf_msg(LVL_ERROR, "Failed binding function.\n");
    775778                goto fail;
    776779        }
     
    780783        ddf_fun_add_to_class(fun, "serial");
    781784       
    782         printf(NAME ": the %s device has been successfully initialized.\n",
     785        ddf_msg(LVL_NOTE, "Device %s successfully initialized.\n",
    783786            dev->name);
    784787       
     
    862865        fibril_mutex_unlock(&data->mutex);
    863866       
    864         printf(NAME ": ns8250_get_props: baud rate %d, parity 0x%x, word "
     867        ddf_msg(LVL_DEBUG, "ns8250_get_props: baud rate %d, parity 0x%x, word "
    865868            "length %d, stop bits %d\n", *baud_rate, *parity, *word_length,
    866869            *stop_bits);
     
    879882    unsigned int parity, unsigned int word_length, unsigned int stop_bits)
    880883{
    881         printf(NAME ": ns8250_set_props: baud rate %d, parity 0x%x, word "
     884        ddf_msg(LVL_DEBUG, "ns8250_set_props: baud rate %d, parity 0x%x, word "
    882885            "length %d, stop bits %d\n", baud_rate, parity, word_length,
    883886            stop_bits);
     
    940943static void ns8250_init(void)
    941944{
     945        ddf_log_init(NAME, LVL_ERROR);
     946       
    942947        ns8250_dev_ops.open = &ns8250_open;
    943948        ns8250_dev_ops.close = &ns8250_close;
  • uspace/drv/pciintel/pci.c

    r917a8c8 r73aec008  
    4848
    4949#include <ddf/driver.h>
     50#include <ddf/log.h>
    5051#include <devman.h>
    5152#include <ipc/devman.h>
     
    225226
    226227        if (match_id_str == NULL) {
    227                 printf(NAME ": out of memory creating match ID.\n");
     228                ddf_msg(LVL_ERROR, "Out of memory creating match ID.\n");
    228229                return;
    229230        }
     
    231232        rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90);
    232233        if (rc != EOK) {
    233                 printf(NAME ": error adding match ID: %s\n",
     234                ddf_msg(LVL_ERROR, "Failed adding match ID: %s\n",
    234235                    str_error(rc));
    235236        }
     
    323324       
    324325        if (range_addr != 0) {
    325                 printf(NAME ": function %s : ", fun->fnode->name);
    326                 printf("address = %" PRIx64, range_addr);
    327                 printf(", size = %x\n", (unsigned int) range_size);
     326                ddf_msg(LVL_DEBUG, "Function %s : address = %" PRIx64
     327                    ", size = %x\n", fun->fnode->name, range_addr,
     328                    (unsigned int) range_size);
    328329        }
    329330       
     
    350351        hw_res_list->count++;
    351352       
    352         printf(NAME ": function %s uses irq %x.\n", fun->fnode->name, irq);
     353        ddf_msg(LVL_NOTE, "Function %s uses irq %x.\n", fun->fnode->name, irq);
    353354}
    354355
     
    406407                        char *fun_name = pci_fun_create_name(fun);
    407408                        if (fun_name == NULL) {
    408                                 printf(NAME ": out of memory.\n");
     409                                ddf_msg(LVL_ERROR, "Out of memory.\n");
    409410                                return;
    410411                        }
     
    412413                        fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name);
    413414                        if (fnode == NULL) {
    414                                 printf(NAME ": error creating function.\n");
     415                                ddf_msg(LVL_ERROR, "Failed creating function.\n");
    415416                                return;
    416417                        }
     
    426427                        fnode->driver_data = fun;
    427428                       
    428                         printf(NAME ": adding new function %s.\n",
     429                        ddf_msg(LVL_DEBUG, "Adding new function %s.\n",
    429430                            fnode->name);
    430431                       
     
    443444                                child_bus = pci_conf_read_8(fun,
    444445                                    PCI_BRIDGE_SEC_BUS_NUM);
    445                                 printf(NAME ": device is pci-to-pci bridge, "
    446                                     "secondary bus number = %d.\n", bus_num);
     446                                ddf_msg(LVL_DEBUG, "Device is pci-to-pci "
     447                                    "bridge, secondary bus number = %d.\n",
     448                                    bus_num);
    447449                                if (child_bus > bus_num)
    448450                                        pci_bus_scan(bus, child_bus);
     
    466468        int rc;
    467469       
    468         printf(NAME ": pci_add_device\n");
     470        ddf_msg(LVL_DEBUG, "pci_add_device\n");
    469471        dnode->parent_phone = -1;
    470472       
    471473        bus = pci_bus_new();
    472474        if (bus == NULL) {
    473                 printf(NAME ": pci_add_device allocation failed.\n");
     475                ddf_msg(LVL_ERROR, "pci_add_device allocation failed.\n");
    474476                rc = ENOMEM;
    475477                goto fail;
     
    481483            IPC_FLAG_BLOCKING);
    482484        if (dnode->parent_phone < 0) {
    483                 printf(NAME ": pci_add_device failed to connect to the "
     485                ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the "
    484486                    "parent's driver.\n");
    485487                rc = dnode->parent_phone;
     
    491493        rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources);
    492494        if (rc != EOK) {
    493                 printf(NAME ": pci_add_device failed to get hw resources for "
    494                     "the device.\n");
     495                ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources "
     496                    "for the device.\n");
    495497                goto fail;
    496498        }
    497499        got_res = true;
    498500       
    499         printf(NAME ": conf_addr = %" PRIx64 ".\n",
     501        ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".\n",
    500502            hw_resources.resources[0].res.io_range.address);
    501503       
     
    509511        if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 8,
    510512            &bus->conf_addr_port)) {
    511                 printf(NAME ": failed to enable configuration ports.\n");
     513                ddf_msg(LVL_ERROR, "Failed to enable configuration ports.\n");
    512514                rc = EADDRNOTAVAIL;
    513515                goto fail;
     
    516518       
    517519        /* Make the bus device more visible. It has no use yet. */
    518         printf(NAME ": adding a 'ctl' function\n");
     520        ddf_msg(LVL_DEBUG, "Adding a 'ctl' function\n");
    519521       
    520522        ctl = ddf_fun_create(bus->dnode, fun_exposed, "ctl");
     
    532534       
    533535        /* Enumerate functions. */
    534         printf(NAME ": scanning the bus\n");
     536        ddf_msg(LVL_DEBUG, "Scanning the bus\n");
    535537        pci_bus_scan(bus, 0);
    536538       
     
    554556static void pciintel_init(void)
    555557{
     558        ddf_log_init(NAME, LVL_ERROR);
    556559        pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops;
    557560}
  • uspace/drv/root/root.c

    r917a8c8 r73aec008  
    5252
    5353#include <ddf/driver.h>
     54#include <ddf/log.h>
    5455#include <devman.h>
    5556#include <ipc/devman.h>
     
    8990        int rc;
    9091
    91         printf(NAME ": adding new function for virtual devices.\n");
    92         printf(NAME ":   function node is `%s' (%d %s)\n", name,
     92        ddf_msg(LVL_DEBUG, "Adding new function for virtual devices. "
     93            "Function node is `%s' (%d %s)\n", name,
    9394            VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID);
    9495
    9596        fun = ddf_fun_create(dev, fun_inner, name);
    9697        if (fun == NULL) {
    97                 printf(NAME ": error creating function %s\n", name);
     98                ddf_msg(LVL_ERROR, "Failed creating function %s\n", name);
    9899                return ENOMEM;
    99100        }
     
    102103            VIRTUAL_FUN_MATCH_SCORE);
    103104        if (rc != EOK) {
    104                 printf(NAME ": error adding match IDs to function %s\n", name);
     105                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n", name);
    105106                ddf_fun_destroy(fun);
    106107                return rc;
     
    109110        rc = ddf_fun_bind(fun);
    110111        if (rc != EOK) {
    111                 printf(NAME ": error binding function %s: %s\n", name,
     112                ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name,
    112113                    str_error(rc));
    113114                ddf_fun_destroy(fun);
     
    136137        platform = sysinfo_get_data("platform", &platform_size);
    137138        if (platform == NULL) {
    138                 printf(NAME ": Failed to obtain platform name.\n");
     139                ddf_msg(LVL_ERROR, "Failed to obtain platform name.\n");
    139140                return ENOENT;
    140141        }
     
    143144        platform = realloc(platform, platform_size + 1);
    144145        if (platform == NULL) {
    145                 printf(NAME ": Memory allocation failed.\n");
     146                ddf_msg(LVL_ERROR, "Memory allocation failed.\n");
    146147                return ENOMEM;
    147148        }
     
    151152        /* Construct match ID. */
    152153        if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
    153                 printf(NAME ": Memory allocation failed.\n");
     154                ddf_msg(LVL_ERROR, "Memory allocation failed.\n");
    154155                return ENOMEM;
    155156        }
    156157
    157158        /* Add function. */
    158         printf(NAME ": adding platform function\n");
    159         printf(NAME ":   function node is `%s' (%d %s)\n", PLATFORM_FUN_NAME,
    160             PLATFORM_FUN_MATCH_SCORE, match_id);
     159        ddf_msg(LVL_DEBUG, "Adding platform function. Function node is `%s' "
     160            " (%d %s)\n", PLATFORM_FUN_NAME, PLATFORM_FUN_MATCH_SCORE,
     161            match_id);
    161162
    162163        fun = ddf_fun_create(dev, fun_inner, name);
    163164        if (fun == NULL) {
    164                 printf(NAME ": error creating function %s\n", name);
     165                ddf_msg(LVL_ERROR, "Error creating function %s\n", name);
    165166                return ENOMEM;
    166167        }
     
    168169        rc = ddf_fun_add_match_id(fun, match_id, PLATFORM_FUN_MATCH_SCORE);
    169170        if (rc != EOK) {
    170                 printf(NAME ": error adding match IDs to function %s\n", name);
     171                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n",
     172                    name);
    171173                ddf_fun_destroy(fun);
    172174                return rc;
     
    175177        rc = ddf_fun_bind(fun);
    176178        if (rc != EOK) {
    177                 printf(NAME ": error binding function %s: %s\n", name,
     179                ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name,
    178180                    str_error(rc));
    179181                ddf_fun_destroy(fun);
     
    191193static int root_add_device(ddf_dev_t *dev)
    192194{
    193         printf(NAME ": root_add_device, device handle=%" PRIun "\n",
     195        ddf_msg(LVL_DEBUG, "root_add_device, device handle=%" PRIun "\n",
    194196            dev->handle);
    195197
     
    204206        int res = add_platform_fun(dev);
    205207        if (EOK != res)
    206                 printf(NAME ": failed to add child device for platform.\n");
     208                ddf_msg(LVL_ERROR, "Failed adding child device for platform.\n");
    207209
    208210        return res;
     
    212214{
    213215        printf(NAME ": HelenOS root device driver\n");
     216
     217        ddf_log_init(NAME, LVL_ERROR);
    214218        return ddf_driver_main(&root_driver);
    215219}
  • uspace/drv/rootpc/rootpc.c

    r917a8c8 r73aec008  
    4747
    4848#include <ddf/driver.h>
     49#include <ddf/log.h>
    4950#include <devman.h>
    5051#include <ipc/devman.h>
     
    119120    rootpc_fun_t *fun)
    120121{
    121         printf(NAME ": adding new function '%s'.\n", name);
     122        ddf_msg(LVL_DEBUG, "Adding new function '%s'.\n", name);
    122123       
    123124        ddf_fun_t *fnode = NULL;
     
    145146        /* Register function. */
    146147        if (ddf_fun_bind(fnode) != EOK) {
    147                 printf(NAME ": error binding function %s.\n", name);
     148                ddf_msg(LVL_ERROR, "Failed binding function %s.\n", name);
    148149                goto failure;
    149150        }
     
    158159                ddf_fun_destroy(fnode);
    159160       
    160         printf(NAME ": failed to add function '%s'.\n", name);
     161        ddf_msg(LVL_ERROR, "Failed adding function '%s'.\n", name);
    161162       
    162163        return false;
     
    176177static int rootpc_add_device(ddf_dev_t *dev)
    177178{
    178         printf(NAME ": rootpc_add_device, device handle = %d\n",
     179        ddf_msg(LVL_DEBUG, "rootpc_add_device, device handle = %d\n",
    179180            (int)dev->handle);
    180181       
    181182        /* Register functions. */
    182183        if (!rootpc_add_functions(dev)) {
    183                 printf(NAME ": failed to add functions for PC platform.\n");
     184                ddf_msg(LVL_ERROR, "Failed to add functions for PC platform.\n");
    184185        }
    185186       
     
    189190static void root_pc_init(void)
    190191{
     192        ddf_log_init(NAME, LVL_ERROR);
    191193        rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
    192194}
  • uspace/drv/rootvirt/rootvirt.c

    r917a8c8 r73aec008  
    4040#include <str_error.h>
    4141#include <ddf/driver.h>
     42#include <ddf/log.h>
    4243
    4344#define NAME "rootvirt"
     
    8384        int rc;
    8485
    85         printf(NAME ": registering function `%s' (match \"%s\")\n",
     86        ddf_msg(LVL_DEBUG, "Registering function `%s' (match \"%s\")\n",
    8687            vfun->name, vfun->match_id);
    8788
    8889        fun = ddf_fun_create(vdev, fun_inner, vfun->name);
    8990        if (fun == NULL) {
    90                 printf(NAME ": error creating function %s\n", vfun->name);
     91                ddf_msg(LVL_ERROR, "Failed creating function %s\n", vfun->name);
    9192                return ENOMEM;
    9293        }
     
    9495        rc = ddf_fun_add_match_id(fun, vfun->match_id, 10);
    9596        if (rc != EOK) {
    96                 printf(NAME ": error adding match IDs to function %s\n",
     97                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n",
    9798                    vfun->name);
    9899                ddf_fun_destroy(fun);
     
    102103        rc = ddf_fun_bind(fun);
    103104        if (rc != EOK) {
    104                 printf(NAME ": error binding function %s: %s\n", vfun->name,
     105                ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", vfun->name,
    105106                    str_error(rc));
    106107                ddf_fun_destroy(fun);
     
    108109        }
    109110
    110         printf(NAME ": registered child device `%s'\n", vfun->name);
     111        ddf_msg(LVL_NOTE, "Registered child device `%s'\n", vfun->name);
    111112        return EOK;
    112113}
     
    124125        }
    125126
    126         printf(NAME ": add_device(handle=%d)\n", (int)dev->handle);
     127        ddf_msg(LVL_DEBUG, "add_device(handle=%d)\n", (int)dev->handle);
    127128
    128129        /*
     
    142143{
    143144        printf(NAME ": HelenOS virtual devices root driver\n");
     145
     146        ddf_log_init(NAME, LVL_ERROR);
    144147        return ddf_driver_main(&rootvirt_driver);
    145148}
  • uspace/drv/test1/test1.c

    r917a8c8 r73aec008  
    3535#include <str_error.h>
    3636#include <ddf/driver.h>
     37#include <ddf/log.h>
    3738
    3839#include "test1.h"
     
    6364        int rc;
    6465
    65         printf(NAME ": registering function `%s': %s.\n", name, message);
     66        ddf_msg(LVL_DEBUG, "Registering function `%s': %s.\n", name, message);
    6667
    6768        fun = ddf_fun_create(parent, fun_inner, name);
    6869        if (fun == NULL) {
    69                 printf(NAME ": error creating function %s\n", name);
     70                ddf_msg(LVL_ERROR, "Failed creating function %s\n", name);
    7071                return ENOMEM;
    7172        }
     
    7374        rc = ddf_fun_add_match_id(fun, match_id, match_score);
    7475        if (rc != EOK) {
    75                 printf(NAME ": error adding match IDs to function %s\n", name);
     76                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n",
     77                    name);
    7678                ddf_fun_destroy(fun);
    7779                return rc;
     
    8082        rc = ddf_fun_bind(fun);
    8183        if (rc != EOK) {
    82                 printf(NAME ": error binding function %s: %s\n", name,
     84                ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name,
    8385                    str_error(rc));
    8486                ddf_fun_destroy(fun);
     
    8688        }
    8789
    88         printf(NAME ": registered child device `%s'\n", name);
     90        ddf_msg(LVL_NOTE, "Registered child device `%s'\n", name);
    8991        return EOK;
    9092}
     
    112114        int rc;
    113115
    114         printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
     116        ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)\n",
    115117            dev->name, (int) dev->handle);
    116118
    117119        fun_a = ddf_fun_create(dev, fun_exposed, "a");
    118120        if (fun_a == NULL) {
    119                 printf(NAME ": error creating function 'a'.\n");
     121                ddf_msg(LVL_ERROR, "Failed creating function 'a'.\n");
    120122                return ENOMEM;
    121123        }
     
    123125        rc = ddf_fun_bind(fun_a);
    124126        if (rc != EOK) {
    125                 printf(NAME ": error binding function 'a'.\n");
     127                ddf_msg(LVL_ERROR, "Failed binding function 'a'.\n");
    126128                return rc;
    127129        }
     
    140142        }
    141143
    142         printf(NAME ": device `%s' accepted.\n", dev->name);
     144        ddf_msg(LVL_DEBUG, "Device `%s' accepted.\n", dev->name);
    143145
    144146        return EOK;
     
    148150{
    149151        printf(NAME ": HelenOS test1 virtual device driver\n");
     152        ddf_log_init(NAME, LVL_ERROR);
    150153        return ddf_driver_main(&test1_driver);
    151154}
  • uspace/drv/test2/test2.c

    r917a8c8 r73aec008  
    3636#include <str_error.h>
    3737#include <ddf/driver.h>
     38#include <ddf/log.h>
    3839
    3940#define NAME "test2"
     
    6465        int rc;
    6566
    66         printf(NAME ": registering function `%s': %s.\n", name, message);
     67        ddf_msg(LVL_DEBUG, "Registering function `%s': %s.\n", name, message);
    6768
    6869        fun = ddf_fun_create(parent, fun_inner, name);
    6970        if (fun == NULL) {
    70                 printf(NAME ": error creating function %s\n", name);
     71                ddf_msg(LVL_ERROR, "Failed creating function %s\n", name);
    7172                return ENOMEM;
    7273        }
     
    7475        rc = ddf_fun_add_match_id(fun, match_id, match_score);
    7576        if (rc != EOK) {
    76                 printf(NAME ": error adding match IDs to function %s\n", name);
     77                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n",
     78                    name);
    7779                ddf_fun_destroy(fun);
    7880                return rc;
     
    8183        rc = ddf_fun_bind(fun);
    8284        if (rc != EOK) {
    83                 printf(NAME ": error binding function %s: %s\n", name,
     85                ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name,
    8486                    str_error(rc));
    8587                ddf_fun_destroy(fun);
     
    8789        }
    8890
    89         printf(NAME ": registered child device `%s'\n", name);
     91        ddf_msg(LVL_NOTE, "Registered child device `%s'\n", name);
    9092        return EOK;
    9193}
     
    111113        fun_a = ddf_fun_create(dev, fun_exposed, "a");
    112114        if (fun_a == NULL) {
    113                 printf(NAME ": error creating function 'a'.\n");
     115                ddf_msg(LVL_ERROR, "Failed creating function 'a'.\n");
    114116                return ENOMEM;
    115117        }
     
    117119        rc = ddf_fun_bind(fun_a);
    118120        if (rc != EOK) {
    119                 printf(NAME ": error binding function 'a'.\n");
     121                ddf_msg(LVL_ERROR, "Failed binding function 'a'.\n");
    120122                return rc;
    121123        }
     
    128130static int test2_add_device(ddf_dev_t *dev)
    129131{
    130         printf(NAME ": test2_add_device(name=\"%s\", handle=%d)\n",
     132        ddf_msg(LVL_DEBUG, "test2_add_device(name=\"%s\", handle=%d)\n",
    131133            dev->name, (int) dev->handle);
    132134
     
    134136                fid_t postpone = fibril_create(postponed_birth, dev);
    135137                if (postpone == 0) {
    136                         printf(NAME ": fibril_create() error\n");
     138                        ddf_msg(LVL_ERROR, "fibril_create() failed.\n");
    137139                        return ENOMEM;
    138140                }
     
    149151{
    150152        printf(NAME ": HelenOS test2 virtual device driver\n");
     153        ddf_log_init(NAME, LVL_ERROR);
    151154        return ddf_driver_main(&test2_driver);
    152155}
  • uspace/lib/c/Makefile

    r917a8c8 r73aec008  
    7676        generic/io/io.c \
    7777        generic/io/printf.c \
     78        generic/io/log.c \
    7879        generic/io/klog.c \
    7980        generic/io/snprintf.c \
  • uspace/lib/drv/Makefile

    r917a8c8 r73aec008  
    3535        generic/driver.c \
    3636        generic/dev_iface.c \
     37        generic/log.c \
    3738        generic/remote_hw_res.c \
    3839        generic/remote_char_dev.c
  • uspace/lib/drv/generic/driver.c

    r917a8c8 r73aec008  
    273273       
    274274        res = driver->driver_ops->add_device(dev);
    275         if (res == EOK) {
    276                 printf("%s: new device with handle=%" PRIun " was added.\n",
    277                     driver->name, dev_handle);
    278         } else {
    279                 printf("%s: failed to add a new device with handle = %" PRIun ".\n",
    280                     driver->name, dev_handle);
     275        if (res != EOK)
    281276                delete_device(dev);
    282         }
    283277       
    284278        async_answer_0(iid, res);
  • uspace/srv/devman/devman.c

    r917a8c8 r73aec008  
    3434#include <fcntl.h>
    3535#include <sys/stat.h>
     36#include <io/log.h>
    3637#include <ipc/driver.h>
    3738#include <ipc/devman.h>
     
    146147        fibril_mutex_unlock(&drivers_list->drivers_mutex);
    147148
    148         printf(NAME": the '%s' driver was added to the list of available "
     149        log_msg(LVL_NOTE, "Driver `%s' was added to the list of available "
    149150            "drivers.\n", drv->name);
    150151}
     
    237238bool read_match_ids(const char *conf_path, match_id_list_t *ids)
    238239{
    239         printf(NAME ": read_match_ids conf_path = %s.\n", conf_path);
     240        log_msg(LVL_DEBUG, "read_match_ids(conf_path=\"%s\")\n", conf_path);
    240241       
    241242        bool suc = false;
     
    247248        fd = open(conf_path, O_RDONLY);
    248249        if (fd < 0) {
    249                 printf(NAME ": unable to open %s\n", conf_path);
     250                log_msg(LVL_ERROR, "Unable to open `%s' for reading: %s.\n",
     251                    conf_path, str_error(fd));
    250252                goto cleanup;
    251253        }
     
    255257        lseek(fd, 0, SEEK_SET);
    256258        if (len == 0) {
    257                 printf(NAME ": configuration file '%s' is empty.\n", conf_path);
     259                log_msg(LVL_ERROR, "Configuration file '%s' is empty.\n",
     260                    conf_path);
    258261                goto cleanup;
    259262        }
     
    261264        buf = malloc(len + 1);
    262265        if (buf == NULL) {
    263                 printf(NAME ": memory allocation failed when parsing file "
     266                log_msg(LVL_ERROR, "Memory allocation failed when parsing file "
    264267                    "'%s'.\n", conf_path);
    265268                goto cleanup;
     
    268271        ssize_t read_bytes = safe_read(fd, buf, len);
    269272        if (read_bytes <= 0) {
    270                 printf(NAME ": unable to read file '%s'.\n", conf_path);
     273                log_msg(LVL_ERROR, "Unable to read file '%s'.\n", conf_path);
    271274                goto cleanup;
    272275        }
     
    306309bool get_driver_info(const char *base_path, const char *name, driver_t *drv)
    307310{
    308         printf(NAME ": get_driver_info base_path = %s, name = %s.\n",
     311        log_msg(LVL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")\n",
    309312            base_path, name);
    310313       
     
    338341        struct stat s;
    339342        if (stat(drv->binary_path, &s) == ENOENT) { /* FIXME!! */
    340                 printf(NAME ": driver not found at path %s.", drv->binary_path);
     343                log_msg(LVL_ERROR, "Driver not found at path `%s'.",
     344                    drv->binary_path);
    341345                goto cleanup;
    342346        }
     
    365369int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path)
    366370{
    367         printf(NAME ": lookup_available_drivers, dir = %s \n", dir_path);
     371        log_msg(LVL_DEBUG, "lookup_available_drivers(dir=\"%s\")\n", dir_path);
    368372       
    369373        int drv_cnt = 0;
     
    399403        dev_node_t *dev;
    400404       
    401         printf(NAME ": create_root_nodes\n");
     405        log_msg(LVL_DEBUG, "create_root_nodes()\n");
    402406       
    403407        fibril_rwlock_write_lock(&tree->rwlock);
     
    484488void attach_driver(dev_node_t *dev, driver_t *drv)
    485489{
    486         printf(NAME ": attach_driver %s to device %s\n",
    487             drv->name, dev->pfun->pathname);
     490        log_msg(LVL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")\n",
     491            dev->pfun->pathname, drv->name);
    488492       
    489493        fibril_mutex_lock(&drv->driver_mutex);
     
    507511        assert(fibril_mutex_is_locked(&drv->driver_mutex));
    508512       
    509         printf(NAME ": start_driver '%s'\n", drv->name);
     513        log_msg(LVL_DEBUG, "start_driver(drv=\"%s\")\n", drv->name);
    510514       
    511515        rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL);
    512516        if (rc != EOK) {
    513                 printf(NAME ": error spawning %s (%s)\n",
    514                     drv->name, str_error(rc));
     517                log_msg(LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.\n",
     518                    drv->name, drv->binary_path, str_error(rc));
    515519                return false;
    516520        }
     
    574578        int phone;
    575579
    576         printf(NAME ": pass_devices_to_driver(`%s')\n", driver->name);
     580        log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")\n",
     581            driver->name);
    577582
    578583        fibril_mutex_lock(&driver->driver_mutex);
     
    641646         * immediately and possibly started here as well.
    642647         */
    643         printf(NAME ": driver %s goes into running state.\n", driver->name);
     648        log_msg(LVL_DEBUG, "Driver `%s' enters running state.\n", driver->name);
    644649        driver->state = DRIVER_RUNNING;
    645650
     
    658663void initialize_running_driver(driver_t *driver, dev_tree_t *tree)
    659664{
    660         printf(NAME ": initialize_running_driver (`%s')\n", driver->name);
     665        log_msg(LVL_DEBUG, "initialize_running_driver(driver=\"%s\")\n",
     666            driver->name);
    661667       
    662668        /*
     
    748754         * access any structures that would affect driver_t.
    749755         */
    750         printf(NAME ": add_device (driver `%s', device `%s')\n", drv->name,
    751             dev->pfun->name);
     756        log_msg(LVL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")\n",
     757            drv->name, dev->pfun->name);
    752758       
    753759        sysarg_t rc;
     
    810816        driver_t *drv = find_best_match_driver(drivers_list, dev);
    811817        if (drv == NULL) {
    812                 printf(NAME ": no driver found for device '%s'.\n",
     818                log_msg(LVL_ERROR, "No driver found for device `%s'.\n",
    813819                    dev->pfun->pathname);
    814820                return false;
     
    848854bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list)
    849855{
    850         printf(NAME ": init_device_tree.\n");
     856        log_msg(LVL_DEBUG, "init_device_tree()\n");
    851857       
    852858        tree->current_handle = 0;
     
    10271033        fun->pathname = (char *) malloc(pathsize);
    10281034        if (fun->pathname == NULL) {
    1029                 printf(NAME ": failed to allocate device path.\n");
     1035                log_msg(LVL_ERROR, "Failed to allocate device path.\n");
    10301036                return false;
    10311037        }
     
    10581064        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    10591065       
     1066        log_msg(LVL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])\n",
     1067            dev, pfun, pfun->pathname);
     1068
    10601069        /* Add the node to the handle-to-node map. */
    10611070        dev->handle = ++tree->current_handle;
     
    10641073
    10651074        /* Add the node to the list of its parent's children. */
    1066         printf("insert_dev_node: dev=%p, dev->pfun := %p\n", dev, pfun);
    10671075        dev->pfun = pfun;
    10681076        pfun->child = dev;
  • uspace/srv/devman/main.c

    r917a8c8 r73aec008  
    4343#include <stdio.h>
    4444#include <errno.h>
     45#include <str_error.h>
    4546#include <bool.h>
    4647#include <fibril_synch.h>
     
    5152#include <sys/stat.h>
    5253#include <ctype.h>
     54#include <io/log.h>
    5355#include <ipc/devman.h>
    5456#include <ipc/driver.h>
     
    7173        driver_t *driver = NULL;
    7274
    73         printf(NAME ": devman_driver_register \n");
     75        log_msg(LVL_DEBUG, "devman_driver_register\n");
    7476       
    7577        iid = async_get_call(&icall);
     
    8890        }
    8991
    90         printf(NAME ": the %s driver is trying to register by the service.\n",
     92        log_msg(LVL_DEBUG, "The `%s' driver is trying to register.\n",
    9193            drv_name);
    9294       
     
    9597       
    9698        if (driver == NULL) {
    97                 printf(NAME ": no driver named %s was found.\n", drv_name);
     99                log_msg(LVL_ERROR, "No driver named `%s' was found.\n", drv_name);
    98100                free(drv_name);
    99101                drv_name = NULL;
     
    106108       
    107109        /* Create connection to the driver. */
    108         printf(NAME ":  creating connection to the %s driver.\n", driver->name);
     110        log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.\n",
     111            driver->name);
    109112        ipc_call_t call;
    110113        ipc_callid_t callid = async_get_call(&call);
     
    118121        set_driver_phone(driver, IPC_GET_ARG5(call));
    119122       
    120         printf(NAME ": the %s driver was successfully registered as running.\n",
     123        log_msg(LVL_NOTE,
     124            "The `%s' driver was successfully registered as running.\n",
    121125            driver->name);
    122126       
     
    142146        callid = async_get_call(&call);
    143147        if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
    144                 printf(NAME ": ERROR: devman_receive_match_id - invalid "
    145                     "protocol.\n");
     148                log_msg(LVL_ERROR,
     149                    "Invalid protocol when trying to receive match id.\n");
    146150                async_answer_0(callid, EINVAL);
    147151                delete_match_id(match_id);
     
    150154       
    151155        if (match_id == NULL) {
    152                 printf(NAME ": ERROR: devman_receive_match_id - failed to "
    153                     "allocate match id.\n");
     156                log_msg(LVL_ERROR, "Failed to allocate match id.\n");
    154157                async_answer_0(callid, ENOMEM);
    155158                return ENOMEM;
     
    165168        if (rc != EOK) {
    166169                delete_match_id(match_id);
    167                 printf(NAME ": devman_receive_match_id - failed to receive "
    168                     "match id string.\n");
     170                log_msg(LVL_ERROR, "Failed to receive match id string: %s.\n",
     171                    str_error(rc));
    169172                return rc;
    170173        }
     
    172175        list_append(&match_id->link, &match_ids->ids);
    173176       
    174         printf(NAME ": received match id '%s', score = %d \n",
     177        log_msg(LVL_DEBUG, "Received match id `%s', score %d.\n",
    175178            match_id->id, match_id->score);
    176179        return rc;
     
    228231        if (ftype != fun_inner && ftype != fun_exposed) {
    229232                /* Unknown function type */
    230                 printf(NAME ": Error, unknown function type provided by driver!\n");
     233                log_msg(LVL_ERROR,
     234                    "Unknown function type %d provided by driver.\n",
     235                    (int) ftype);
    231236
    232237                fibril_rwlock_write_unlock(&tree->rwlock);
     
    265270        fibril_rwlock_write_unlock(&tree->rwlock);
    266271       
    267         printf(NAME ": devman_add_function %s\n", fun->pathname);
     272        log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\")\n", fun->pathname);
    268273       
    269274        devman_receive_match_ids(match_count, &fun->match_ids);
     
    347352        devmap_register_class_dev(class_info);
    348353       
    349         printf(NAME ": function'%s' added to class '%s', class name '%s' was "
    350             "asigned to it\n", fun->pathname, class_name, class_info->dev_name);
     354        log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.\n",
     355            fun->pathname, class_name, class_info->dev_name);
    351356
    352357        async_answer_0(callid, EOK);
     
    363368       
    364369        initialize_running_driver(driver, &device_tree);
    365         printf(NAME ": the %s driver was successfully initialized. \n",
     370        log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized.\n",
    366371            driver->name);
    367372        return 0;
     
    385390        fid_t fid = fibril_create(init_running_drv, driver);
    386391        if (fid == 0) {
    387                 printf(NAME ": Error creating fibril for the initialization of "
    388                     "the newly registered running driver.\n");
     392                log_msg(LVL_ERROR, "Failed to create initialization fibril " \
     393                    "for driver `%s' .\n", driver->name);
    389394                return;
    390395        }
     
    484489         */
    485490        if (dev == NULL) {
    486                 printf(NAME ": devman_forward error - no device or function with "
    487                     "handle %" PRIun " was found.\n", handle);
     491                log_msg(LVL_ERROR, "IPC forwarding failed - no device or "
     492                    "function with handle %" PRIun " was found.\n", handle);
    488493                async_answer_0(iid, ENOENT);
    489494                return;
     
    491496
    492497        if (fun == NULL && !drv_to_parent) {
    493                 printf(NAME ": devman_forward error - cannot connect to "
    494                     "handle %" PRIun ", refers to a device.\n", handle);
     498                log_msg(LVL_ERROR, NAME ": devman_forward error - cannot "
     499                    "connect to handle %" PRIun ", refers to a device.\n",
     500                    handle);
    495501                async_answer_0(iid, ENOENT);
    496502                return;
     
    513519       
    514520        if (driver == NULL) {
    515                 printf(NAME ": devman_forward error - the device is not in %" PRIun
    516                     " usable state.\n", handle);
     521                log_msg(LVL_ERROR, "IPC forwarding refused - " \
     522                    "the device %" PRIun " is not in usable state.\n", handle);
    517523                async_answer_0(iid, ENOENT);
    518524                return;
     
    526532       
    527533        if (driver->phone <= 0) {
    528                 printf(NAME ": devman_forward: cound not forward to driver %s ",
    529                     driver->name);
    530                 printf("the driver's phone is %" PRIun ").\n", driver->phone);
     534                log_msg(LVL_ERROR,
     535                    "Could not forward to driver `%s' (phone is %d).\n",
     536                    driver->name, (int) driver->phone);
    531537                async_answer_0(iid, EINVAL);
    532538                return;
     
    534540
    535541        if (fun != NULL) {
    536                 printf(NAME ": devman_forward: forward connection to function %s to "
    537                     "driver %s.\n", fun->pathname, driver->name);
     542                log_msg(LVL_DEBUG,
     543                    "Forwarding request for `%s' function to driver `%s'.\n",
     544                    fun->pathname, driver->name);
    538545        } else {
    539                 printf(NAME ": devman_forward: forward connection to device %s to "
    540                     "driver %s.\n", dev->pfun->pathname, driver->name);
     546                log_msg(LVL_DEBUG,
     547                    "Forwarding request for `%s' device to driver `%s'.\n",
     548                    dev->pfun->pathname, driver->name);
    541549        }
    542550
     
    570578        async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0,
    571579            IPC_FF_NONE);
    572         printf(NAME ": devman_connection_devmapper: forwarded connection to "
    573             "device %s to driver %s.\n", fun->pathname, dev->drv->name);
     580        log_msg(LVL_DEBUG,
     581            "Forwarding devmapper request for `%s' function to driver `%s'.\n",
     582            fun->pathname, dev->drv->name);
    574583}
    575584
     
    606615static bool devman_init(void)
    607616{
    608         printf(NAME ": devman_init - looking for available drivers.\n");
     617        log_msg(LVL_DEBUG, "devman_init - looking for available drivers.\n");
    609618       
    610619        /* Initialize list of available drivers. */
     
    612621        if (lookup_available_drivers(&drivers_list,
    613622            DRIVER_DEFAULT_STORE) == 0) {
    614                 printf(NAME " no drivers found.");
     623                log_msg(LVL_FATAL, "no drivers found.");
    615624                return false;
    616625        }
    617626
    618         printf(NAME ": devman_init - list of drivers has been initialized.\n");
     627        log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized.\n");
    619628
    620629        /* Create root device node. */
    621630        if (!init_device_tree(&device_tree, &drivers_list)) {
    622                 printf(NAME " failed to initialize device tree.");
     631                log_msg(LVL_FATAL, "Failed to initialize device tree.");
    623632                return false;
    624633        }
     
    641650        printf(NAME ": HelenOS Device Manager\n");
    642651
     652        if (log_init(NAME, LVL_ERROR) != EOK) {
     653                printf(NAME ": Error initializing logging subsystem.\n");
     654                return -1;
     655        }
     656
    643657        if (!devman_init()) {
    644                 printf(NAME ": Error while initializing service\n");
     658                log_msg(LVL_ERROR, "Error while initializing service.\n");
    645659                return -1;
    646660        }
     
    650664
    651665        /* Register device manager at naming service. */
    652         if (service_register(SERVICE_DEVMAN) != EOK)
     666        if (service_register(SERVICE_DEVMAN) != EOK) {
     667                log_msg(LVL_ERROR, "Failed registering as a service.\n");
    653668                return -1;
    654 
    655         printf(NAME ": Accepting connections\n");
     669        }
     670
     671        printf(NAME ": Accepting connections.\n");
    656672        async_manager();
    657673
Note: See TracChangeset for help on using the changeset viewer.