Changeset e55741e in mainline


Ignore:
Timestamp:
2019-08-06T18:25:27Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
c1b2084
Parents:
4224ef7
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-05-19 16:34:53)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-06 18:25:27)
Message:

sysman: Instrumented devman with autostart

  • created unit files for drivers, their processing in Makefile
  • just naïvely replaced task_spawn with sysman_unit_start in devman

Conflicts:

boot/Makefile.common
uspace/srv/devman/devman.h
uspace/srv/devman/driver.c

Location:
uspace
Files:
43 added
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/Makefile

    r4224ef7 re55741e  
    2929
    3030USPACE_PREFIX = ../..
     31LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a
     32EXTRA_CFLAGS += -I$(LIBSYSMAN_PREFIX)/include
    3133BINARY = devman
    3234STATIC_NEEDED = y
  • uspace/srv/devman/devman.h

    r4224ef7 re55741e  
    7878        /** Name of the device driver. */
    7979        char *name;
    80         /** Path to the driver's binary. */
    81         char *binary_path;
    8280        /** List of device ids for device-to-driver matching. */
    8381        match_id_list_t match_ids;
  • uspace/srv/devman/driver.c

    r4224ef7 re55741e  
    3434#include <dirent.h>
    3535#include <errno.h>
     36#include <fcntl.h>
    3637#include <io/log.h>
    3738#include <vfs/vfs.h>
    3839#include <loc.h>
     40#include <stdio.h>
    3941#include <str_error.h>
    40 #include <stdio.h>
     42#include <sys/stat.h>
     43#include <sysman/ctl.h>
    4144#include <task.h>
    4245
     
    139142        str_cpy(drv->name, name_size, name);
    140143
    141         /* Initialize path with driver's binary. */
    142         drv->binary_path = get_abs_path(base_path, name, "");
    143         if (drv->binary_path == NULL)
    144                 goto cleanup;
    145 
    146         /* Check whether the driver's binary exists. */
    147         vfs_stat_t s;
    148         if (vfs_stat_path(drv->binary_path, &s) != EOK) {
    149                 log_msg(LOG_DEFAULT, LVL_ERROR, "Driver not found at path `%s'.",
    150                     drv->binary_path);
    151                 goto cleanup;
    152         }
    153 
    154144        suc = true;
    155145
    156146cleanup:
    157147        if (!suc) {
    158                 free(drv->binary_path);
    159148                free(drv->name);
    160149                /* Set the driver structure to the default state. */
     
    271260 *
    272261 * @param tree          Device tree
    273  * @param node          The device's node in the device tree.
     262 * @param dev           The device's node in the device tree.
    274263 * @param drv           The driver.
    275264 */
     
    330319        log_msg(LOG_DEFAULT, LVL_DEBUG, "start_driver(drv=\"%s\")", drv->name);
    331320
    332         rc = task_spawnl(NULL, NULL, drv->binary_path, drv->binary_path, NULL);
     321        char *unit_name = NULL;
     322        asprintf(&unit_name, "%s%c%s", drv->name, UNIT_NAME_SEPARATOR,
     323            UNIT_SVC_TYPE_NAME);
     324        if (unit_name == NULL) {
     325                return false;
     326        }
     327
     328        /*
     329         * Non-blocking asynchronous request to start a driver
     330         * FIXME See note about sysman_unit_start non-blocking (asynchronous)
     331         *       API
     332         */
     333        int flags = 0;
     334        rc = sysman_unit_start(unit_name, flags);
     335
    333336        if (rc != EOK) {
    334                 log_msg(LOG_DEFAULT, LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.",
    335                     drv->name, drv->binary_path, str_error(rc));
     337                log_msg(LOG_DEFAULT, LVL_ERROR,
     338                    "Request to start driver `%s' failed: %s.",
     339                    drv->name, str_error(rc));
     340                free(unit_name);
    336341                return false;
    337342        }
    338343
    339344        drv->state = DRIVER_STARTING;
     345        free(unit_name);
    340346        return true;
    341347}
     
    547553
    548554        free(drv->name);
    549         free(drv->binary_path);
    550555
    551556        clean_match_ids(&drv->match_ids);
     
    568573/** Find suitable driver for a device and assign the driver to it.
    569574 *
    570  * @param node          The device node of the device in the device tree.
     575 * @param dev           The device node of the device in the device tree.
    571576 * @param drivers_list  The list of available drivers.
    572577 * @return              True if the suitable driver is found and
     
    627632 *
    628633 * @param drv           The driver's structure.
    629  * @param node          The device's node in the device tree.
     634 * @param dev           The device's node in the device tree.
    630635 */
    631636void add_device(driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
Note: See TracChangeset for help on using the changeset viewer.