Changeset 73aec008 in mainline for uspace/srv/devman/devman.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.