Changeset ba38f72c in mainline for uspace/srv/devman/devman.h


Ignore:
Timestamp:
2011-02-07T22:15:37Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b367b4
Parents:
8b5690f
Message:

Split device tree node into dev_node_t (device node) and fun_node_t (function node).

File:
1 edited

Legend:

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

    r8b5690f rba38f72c  
    5656#define DEVMAP_SEPARATOR '\\'
    5757
    58 struct node;
    59 typedef struct node node_t;
     58struct dev_node;
     59typedef struct dev_node dev_node_t;
     60
     61struct fun_node;
     62typedef struct fun_node fun_node_t;
    6063
    6164typedef enum {
     
    117120} device_state_t;
    118121
    119 /** Representation of a node in the device tree. */
    120 struct node {
     122/** Device node in the device tree. */
     123struct dev_node {
    121124        /** The global unique identifier of the device. */
    122125        devman_handle_t handle;
    123         /** The name of the device specified by its parent. */
    124         char *name;
    125        
    126         /**
    127          * Full path and name of the device in device hierarchi (i. e. in full
    128          * path in device tree).
    129          */
    130         char *pathname;
    131        
    132         /** The node of the parent device. */
    133         node_t *parent;
    134        
    135         /**
    136          * Pointers to previous and next child devices in the linked list of
    137          * parent device's node.
    138          */
    139         link_t sibling;
    140        
    141         /** List of child device nodes. */
    142         link_t children;
    143         /** List of device ids for device-to-driver matching. */
    144         match_id_list_t match_ids;
     126       
     127        /** (Parent) function the device is attached to. */
     128        fun_node_t *pfun;
     129       
     130        /** List of device functions. */
     131        link_t functions;
    145132        /** Driver of this device. */
    146133        driver_t *drv;
    147134        /** The state of the device. */
    148135        device_state_t state;
    149         /**
    150          * Pointer to the previous and next device in the list of devices
    151          * owned by one driver.
    152          */
     136        /** Link to list of devices owned by driver (driver_t.devices) */
    153137        link_t driver_devices;
    154138       
    155         /** The list of device classes to which this device belongs. */
    156         link_t classes;
    157         /** Devmap handle if the device is registered by devmapper. */
    158         devmap_handle_t devmap_handle;
    159        
    160139        /**
    161140         * Used by the hash table of devices indexed by devman device handles.
    162141         */
    163         link_t devman_link;
    164        
    165         /**
    166          * Used by the hash table of devices indexed by devmap device handles.
    167          */
    168         link_t devmap_link;
    169 
     142        link_t devman_dev;
     143       
    170144        /**
    171145         * Whether this device was already passed to the driver.
     
    173147        bool passed_to_driver;
    174148};
     149
     150/** Function node in the device tree. */
     151struct fun_node {
     152        /** The global unique identifier of the function */
     153        devman_handle_t handle;
     154        /** Name of the function, assigned by the device driver */
     155        char *name;
     156       
     157        /** Full path and name of the device in device hierarchy */
     158        char *pathname;
     159       
     160        /** Device which this function belongs to */
     161        dev_node_t *dev;
     162       
     163        /** Link to list of functions in the device (device_t.functions) */
     164        link_t dev_functions;
     165       
     166        /** Child device node (if any attached). */
     167        dev_node_t *child;
     168        /** List of device ids for device-to-driver matching. */
     169        match_id_list_t match_ids;
     170       
     171        /** The list of device classes to which this device function belongs. */
     172        link_t classes;
     173        /** Devmap handle if the device function is registered by devmap. */
     174        devmap_handle_t devmap_handle;
     175       
     176        /**
     177         * Used by the hash table of functions indexed by devman device handles.
     178         */
     179        link_t devman_fun;
     180       
     181        /**
     182         * Used by the hash table of functions indexed by devmap device handles.
     183         */
     184        link_t devmap_fun;
     185};
     186
    175187
    176188/** Represents device tree. */
    177189typedef struct dev_tree {
    178190        /** Root device node. */
    179         node_t *root_node;
     191        fun_node_t *root_node;
    180192       
    181193        /**
     
    191203        hash_table_t devman_devices;
    192204       
     205        /** Hash table of all devices indexed by devman handles. */
     206        hash_table_t devman_functions;
     207       
    193208        /**
    194209         * Hash table of devices registered by devmapper, indexed by devmap
    195210         * handles.
    196211         */
    197         hash_table_t devmap_devices;
     212        hash_table_t devmap_functions;
    198213} dev_tree_t;
    199214
     
    227242
    228243/**
    229  * Provides n-to-m mapping between device nodes and classes - each device may
    230  * be register to the arbitrary number of classes and each class may contain
    231  * the arbitrary number of devices.
     244 * Provides n-to-m mapping between function nodes and classes - each function
     245 * can register in an arbitrary number of classes and each class can contain
     246 * an arbitrary number of device functions.
    232247 */
    233248typedef struct dev_class_info {
     
    235250        dev_class_t *dev_class;
    236251        /** The device. */
    237         node_t *dev;
     252        fun_node_t *fun;
    238253       
    239254        /**
     
    249264        link_t dev_classes;
    250265       
    251         /** The name of the device within the class. */
     266        /** The name of the device function within the class. */
    252267        char *dev_name;
    253268        /** The handle of the device by device mapper in the class namespace. */
     
    270285         * indexed by devmap handles.
    271286         */
    272         hash_table_t devmap_devices;
     287        hash_table_t devmap_functions;
    273288       
    274289        /** Fibril mutex for list of classes. */
     
    278293/* Match ids and scores */
    279294
    280 extern int get_match_score(driver_t *, node_t *);
     295extern int get_match_score(driver_t *, dev_node_t *);
    281296
    282297extern bool parse_match_ids(char *, match_id_list_t *);
     
    292307extern int lookup_available_drivers(driver_list_t *, const char *);
    293308
    294 extern driver_t *find_best_match_driver(driver_list_t *, node_t *);
    295 extern bool assign_driver(node_t *, driver_list_t *, dev_tree_t *);
     309extern driver_t *find_best_match_driver(driver_list_t *, dev_node_t *);
     310extern bool assign_driver(dev_node_t *, driver_list_t *, dev_tree_t *);
    296311
    297312extern void add_driver(driver_list_t *, driver_t *);
    298 extern void attach_driver(node_t *, driver_t *);
    299 extern void add_device(int, driver_t *, node_t *, dev_tree_t *);
     313extern void attach_driver(dev_node_t *, driver_t *);
     314extern void add_device(int, driver_t *, dev_node_t *, dev_tree_t *);
    300315extern bool start_driver(driver_t *);
    301316
     
    310325/* Device nodes */
    311326
    312 extern node_t *create_dev_node(void);
    313 extern void delete_dev_node(node_t *node);
    314 extern node_t *find_dev_node_no_lock(dev_tree_t *tree,
     327extern dev_node_t *create_dev_node(void);
     328extern void delete_dev_node(dev_node_t *node);
     329extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree,
    315330    devman_handle_t handle);
    316 extern node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
    317 extern node_t *find_dev_node_by_path(dev_tree_t *, char *);
    318 extern node_t *find_node_child(node_t *, const char *);
     331extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
     332extern dev_node_t *find_dev_function(dev_node_t *, const char *);
     333
     334extern fun_node_t *create_fun_node(void);
     335extern void delete_fun_node(fun_node_t *);
     336extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree,
     337    devman_handle_t handle);
     338extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle);
     339extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
    319340
    320341/* Device tree */
    321342
    322343extern bool init_device_tree(dev_tree_t *, driver_list_t *);
    323 extern bool create_root_node(dev_tree_t *);
    324 extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *);
     344extern bool create_root_nodes(dev_tree_t *);
     345extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
     346extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
    325347
    326348/* Device classes */
     
    330352extern size_t get_new_class_dev_idx(dev_class_t *);
    331353extern char *create_dev_name_for_class(dev_class_t *, const char *);
    332 extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *,
     354extern dev_class_info_t *add_function_to_class(fun_node_t *, dev_class_t *,
    333355    const char *);
    334356
     
    341363/* Devmap devices */
    342364
    343 extern node_t *find_devmap_tree_device(dev_tree_t *, devmap_handle_t);
    344 extern node_t *find_devmap_class_device(class_list_t *, devmap_handle_t);
    345 
    346 extern void class_add_devmap_device(class_list_t *, dev_class_info_t *);
    347 extern void tree_add_devmap_device(dev_tree_t *, node_t *);
     365extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t);
     366extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t);
     367
     368extern void class_add_devmap_function(class_list_t *, dev_class_info_t *);
     369extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *);
    348370
    349371#endif
Note: See TracChangeset for help on using the changeset viewer.