Changeset e85920d in mainline


Ignore:
Timestamp:
2010-02-18T15:23:15Z (15 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c3666d
Parents:
08d9c4e6
Message:

parts of device manager

Location:
uspace/srv/devman
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devman.c

    r08d9c4e6 re85920d  
    244244node_t * create_root_node()
    245245{
     246        printf(NAME ": create_root_node\n");
    246247        node_t *node = create_dev_node();
    247248        if (node) {
     
    257258driver_t * find_best_match_driver(link_t *drivers_list, node_t *node)
    258259{
     260        printf(NAME ": find_best_match_driver\n");
    259261        driver_t *best_drv = NULL, *drv = NULL;
    260262        int best_score = 0, score = 0;
     
    267269                        best_score = score;
    268270                        best_drv = drv;
    269                 }               
     271                }       
     272                link = link->next;
    270273        }       
    271274       
     
    281284bool start_driver(driver_t *drv)
    282285{
     286        printf(NAME ": start_driver\n");
     287       
    283288        char *argv[2];
    284289       
     
    293298        }
    294299       
     300        drv->state = DRIVER_STARTING;
    295301        return true;
    296302}
     
    298304bool add_device(driver_t *drv, node_t *node)
    299305{
     306        printf(NAME ": add_device\n");
     307       
    300308        // TODO
    301309       
     
    310318bool assign_driver(node_t *node, link_t *drivers_list)
    311319{
     320        printf(NAME ": assign_driver\n");
     321       
    312322        // find the driver which is the most suitable for handling this device
    313323        driver_t *drv = find_best_match_driver(drivers_list, node);
    314324        if (NULL == drv) {
     325                printf(NAME ": no driver found for device.\n");
    315326                return false;           
    316327        }
     
    319330        attach_driver(node, drv);
    320331       
    321         if (!drv->running) {
     332        if (DRIVER_NOT_STARTED == drv->state) {
    322333                // start driver
    323334                start_driver(drv);
    324         } else {
     335        }
     336       
     337        if (DRIVER_RUNNING == drv->state) {
    325338                // notify driver about new device
    326339                add_device(drv, node);         
     
    332345bool init_device_tree(dev_tree_t *tree, link_t *drivers_list)
    333346{
    334         printf(NAME ": init_device_tree.");
     347        printf(NAME ": init_device_tree.\n");
    335348        // create root node and add it to the device tree
    336349        if (NULL == (tree->root_node = create_root_node())) {
  • uspace/srv/devman/devman.h

    r08d9c4e6 re85920d  
    4040#include <adt/list.h>
    4141#include <ipc/ipc.h>
     42#include <fibril_synch.h>
    4243
    4344#include "util.h"
     
    7475} match_id_list_t;
    7576
     77typedef enum {
     78        /** driver has not been started */
     79        DRIVER_NOT_STARTED = 0,
     80        /** driver has been started, but has not registered as running and ready to receive requests */
     81        DRIVER_STARTING,
     82        /** driver is running and prepared to serve incomming requests */
     83        DRIVER_RUNNING
     84} driver_state_t;
     85
    7686/** Representation of device driver.
    7787 */
     
    7989        /** Pointers to previous and next drivers in a linked list */
    8090        link_t drivers;
    81         /** Specifies whether the driver has been started.*/
    82         bool running;
     91        /** Specifies whether the driver has been started and wheter is running and prepared to receive requests.*/
     92        int state;
    8393        /** Phone asociated with this driver */
    8494        ipcarg_t phone;
     
    91101        /** Pointer to the linked list of devices controlled by this driver */
    92102        link_t devices;
     103        /** Fibril mutex for this driver - driver state, list of devices, phone.*/
     104        fibril_mutex_t driver_mutex;
    93105} driver_t;
     106
     107/** The list of drivers. */
     108typedef struct driver_list {
     109        /** List of drivers */
     110        link_t drivers;
     111        /** Fibril mutex for list of drivers. */
     112        fibril_mutex_t drivers_mutex;   
     113} driver_list_t;
    94114
    95115/** Representation of a node in the device tree.*/
     
    101121        /** List of child device nodes. */
    102122        link_t children;
     123        /** Fibril mutex for the list of child device nodes of this node. */
     124        fibril_mutex_t children_mutex;
    103125        /** List of device ids for device-to-driver matching.*/
    104126        match_id_list_t match_ids;
Note: See TracChangeset for help on using the changeset viewer.