Ignore:
File:
1 edited

Legend:

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

    r83a2f43 rffa2c8ef  
    5656#define DEVMAP_SEPARATOR '\\'
    5757
    58 struct dev_node;
    59 typedef struct dev_node dev_node_t;
    60 
    61 struct fun_node;
    62 typedef struct fun_node fun_node_t;
     58struct node;
     59typedef struct node node_t;
    6360
    6461typedef enum {
     
    120117} device_state_t;
    121118
    122 /** Device node in the device tree. */
    123 struct dev_node {
     119/** Representation of a node in the device tree. */
     120struct node {
    124121        /** The global unique identifier of the device. */
    125122        devman_handle_t handle;
    126        
    127         /** (Parent) function the device is attached to. */
    128         fun_node_t *pfun;
    129        
    130         /** List of device functions. */
    131         link_t functions;
     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;
    132145        /** Driver of this device. */
    133146        driver_t *drv;
    134147        /** The state of the device. */
    135148        device_state_t state;
    136         /** Link to list of devices owned by driver (driver_t.devices) */
     149        /**
     150         * Pointer to the previous and next device in the list of devices
     151         * owned by one driver.
     152         */
    137153        link_t driver_devices;
    138154       
     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       
    139160        /**
    140161         * Used by the hash table of devices indexed by devman device handles.
    141162         */
    142         link_t devman_dev;
    143        
     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
    144170        /**
    145171         * Whether this device was already passed to the driver.
     
    147173        bool passed_to_driver;
    148174};
    149 
    150 /** Function node in the device tree. */
    151 struct 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 (ddf_dev_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 
    187175
    188176/** Represents device tree. */
    189177typedef struct dev_tree {
    190178        /** Root device node. */
    191         fun_node_t *root_node;
     179        node_t *root_node;
    192180       
    193181        /**
     
    203191        hash_table_t devman_devices;
    204192       
    205         /** Hash table of all devices indexed by devman handles. */
    206         hash_table_t devman_functions;
    207        
    208193        /**
    209194         * Hash table of devices registered by devmapper, indexed by devmap
    210195         * handles.
    211196         */
    212         hash_table_t devmap_functions;
     197        hash_table_t devmap_devices;
    213198} dev_tree_t;
    214199
     
    242227
    243228/**
    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.
     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.
    247232 */
    248233typedef struct dev_class_info {
     
    250235        dev_class_t *dev_class;
    251236        /** The device. */
    252         fun_node_t *fun;
     237        node_t *dev;
    253238       
    254239        /**
     
    264249        link_t dev_classes;
    265250       
    266         /** The name of the device function within the class. */
     251        /** The name of the device within the class. */
    267252        char *dev_name;
    268253        /** The handle of the device by device mapper in the class namespace. */
     
    285270         * indexed by devmap handles.
    286271         */
    287         hash_table_t devmap_functions;
     272        hash_table_t devmap_devices;
    288273       
    289274        /** Fibril mutex for list of classes. */
     
    293278/* Match ids and scores */
    294279
    295 extern int get_match_score(driver_t *, dev_node_t *);
     280extern int get_match_score(driver_t *, node_t *);
    296281
    297282extern bool parse_match_ids(char *, match_id_list_t *);
     
    307292extern int lookup_available_drivers(driver_list_t *, const char *);
    308293
    309 extern driver_t *find_best_match_driver(driver_list_t *, dev_node_t *);
    310 extern bool assign_driver(dev_node_t *, driver_list_t *, dev_tree_t *);
     294extern driver_t *find_best_match_driver(driver_list_t *, node_t *);
     295extern bool assign_driver(node_t *, driver_list_t *, dev_tree_t *);
    311296
    312297extern void add_driver(driver_list_t *, driver_t *);
    313 extern void attach_driver(dev_node_t *, driver_t *);
    314 extern void add_device(int, driver_t *, dev_node_t *, dev_tree_t *);
     298extern void attach_driver(node_t *, driver_t *);
     299extern void add_device(int, driver_t *, node_t *, dev_tree_t *);
    315300extern bool start_driver(driver_t *);
    316301
     
    325310/* Device nodes */
    326311
    327 extern dev_node_t *create_dev_node(void);
    328 extern void delete_dev_node(dev_node_t *node);
    329 extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree,
     312extern node_t *create_dev_node(void);
     313extern void delete_dev_node(node_t *node);
     314extern node_t *find_dev_node_no_lock(dev_tree_t *tree,
    330315    devman_handle_t handle);
    331 extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
    332 extern dev_node_t *find_dev_function(dev_node_t *, const char *);
    333 
    334 extern fun_node_t *create_fun_node(void);
    335 extern void delete_fun_node(fun_node_t *);
    336 extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree,
    337     devman_handle_t handle);
    338 extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle);
    339 extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
     316extern node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
     317extern node_t *find_dev_node_by_path(dev_tree_t *, char *);
     318extern node_t *find_node_child(node_t *, const char *);
    340319
    341320/* Device tree */
    342321
    343322extern bool init_device_tree(dev_tree_t *, driver_list_t *);
    344 extern bool create_root_nodes(dev_tree_t *);
    345 extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
    346 extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
     323extern bool create_root_node(dev_tree_t *);
     324extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *);
    347325
    348326/* Device classes */
     
    352330extern size_t get_new_class_dev_idx(dev_class_t *);
    353331extern char *create_dev_name_for_class(dev_class_t *, const char *);
    354 extern dev_class_info_t *add_function_to_class(fun_node_t *, dev_class_t *,
     332extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *,
    355333    const char *);
    356334
     
    363341/* Devmap devices */
    364342
    365 extern void devmap_register_tree_function(fun_node_t *, dev_tree_t *);
    366 
    367 extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t);
    368 extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t);
    369 
    370 extern void class_add_devmap_function(class_list_t *, dev_class_info_t *);
    371 extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *);
     343extern node_t *find_devmap_tree_device(dev_tree_t *, devmap_handle_t);
     344extern node_t *find_devmap_class_device(class_list_t *, devmap_handle_t);
     345
     346extern void class_add_devmap_device(class_list_t *, dev_class_info_t *);
     347extern void tree_add_devmap_device(dev_tree_t *, node_t *);
    372348
    373349#endif
Note: See TracChangeset for help on using the changeset viewer.