Ignore:
File:
1 edited

Legend:

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

    r3ad7b1c r96b02eb9  
    4040#include <adt/list.h>
    4141#include <adt/hash_table.h>
     42#include <ipc/ipc.h>
    4243#include <ipc/devman.h>
    4344#include <ipc/devmap.h>
     
    5657#define DEVMAP_SEPARATOR '\\'
    5758
    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;
     59struct node;
     60typedef struct node node_t;
    6361
    6462typedef enum {
     
    8886       
    8987        /** Phone asociated with this driver. */
    90         int phone;
     88        sysarg_t phone;
    9189        /** Name of the device driver. */
    9290        char *name;
     
    120118} device_state_t;
    121119
    122 /** Device node in the device tree. */
    123 struct dev_node {
     120/** Representation of a node in the device tree. */
     121struct node {
    124122        /** The global unique identifier of the device. */
    125123        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;
     124        /** The name of the device specified by its parent. */
     125        char *name;
     126       
     127        /**
     128         * Full path and name of the device in device hierarchi (i. e. in full
     129         * path in device tree).
     130         */
     131        char *pathname;
     132       
     133        /** The node of the parent device. */
     134        node_t *parent;
     135       
     136        /**
     137         * Pointers to previous and next child devices in the linked list of
     138         * parent device's node.
     139         */
     140        link_t sibling;
     141       
     142        /** List of child device nodes. */
     143        link_t children;
     144        /** List of device ids for device-to-driver matching. */
     145        match_id_list_t match_ids;
    132146        /** Driver of this device. */
    133147        driver_t *drv;
    134148        /** The state of the device. */
    135149        device_state_t state;
    136         /** Link to list of devices owned by driver (driver_t.devices) */
     150        /**
     151         * Pointer to the previous and next device in the list of devices
     152         * owned by one driver.
     153         */
    137154        link_t driver_devices;
    138155       
     156        /** The list of device classes to which this device belongs. */
     157        link_t classes;
     158        /** Devmap handle if the device is registered by devmapper. */
     159        devmap_handle_t devmap_handle;
     160       
    139161        /**
    140162         * Used by the hash table of devices indexed by devman device handles.
    141163         */
    142         link_t devman_dev;
    143        
     164        link_t devman_link;
     165       
     166        /**
     167         * Used by the hash table of devices indexed by devmap device handles.
     168         */
     169        link_t devmap_link;
     170
    144171        /**
    145172         * Whether this device was already passed to the driver.
     
    147174        bool passed_to_driver;
    148175};
    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 
    187176
    188177/** Represents device tree. */
    189178typedef struct dev_tree {
    190179        /** Root device node. */
    191         fun_node_t *root_node;
     180        node_t *root_node;
    192181       
    193182        /**
     
    203192        hash_table_t devman_devices;
    204193       
    205         /** Hash table of all devices indexed by devman handles. */
    206         hash_table_t devman_functions;
    207        
    208194        /**
    209195         * Hash table of devices registered by devmapper, indexed by devmap
    210196         * handles.
    211197         */
    212         hash_table_t devmap_functions;
     198        hash_table_t devmap_devices;
    213199} dev_tree_t;
    214200
     
    242228
    243229/**
    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.
     230 * Provides n-to-m mapping between device nodes and classes - each device may
     231 * be register to the arbitrary number of classes and each class may contain
     232 * the arbitrary number of devices.
    247233 */
    248234typedef struct dev_class_info {
     
    250236        dev_class_t *dev_class;
    251237        /** The device. */
    252         fun_node_t *fun;
     238        node_t *dev;
    253239       
    254240        /**
     
    264250        link_t dev_classes;
    265251       
    266         /** The name of the device function within the class. */
     252        /** The name of the device within the class. */
    267253        char *dev_name;
    268254        /** The handle of the device by device mapper in the class namespace. */
     
    285271         * indexed by devmap handles.
    286272         */
    287         hash_table_t devmap_functions;
     273        hash_table_t devmap_devices;
    288274       
    289275        /** Fibril mutex for list of classes. */
     
    293279/* Match ids and scores */
    294280
    295 extern int get_match_score(driver_t *, dev_node_t *);
     281extern int get_match_score(driver_t *, node_t *);
    296282
    297283extern bool parse_match_ids(char *, match_id_list_t *);
     
    307293extern int lookup_available_drivers(driver_list_t *, const char *);
    308294
    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 *);
     295extern driver_t *find_best_match_driver(driver_list_t *, node_t *);
     296extern bool assign_driver(node_t *, driver_list_t *, dev_tree_t *);
    311297
    312298extern 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 *);
     299extern void attach_driver(node_t *, driver_t *);
     300extern void add_device(int, driver_t *, node_t *, dev_tree_t *);
    315301extern bool start_driver(driver_t *);
    316302
    317303extern driver_t *find_driver(driver_list_t *, const char *);
     304extern void set_driver_phone(driver_t *, sysarg_t);
    318305extern void initialize_running_driver(driver_t *, dev_tree_t *);
    319306
     
    324311/* Device nodes */
    325312
    326 extern dev_node_t *create_dev_node(void);
    327 extern void delete_dev_node(dev_node_t *node);
    328 extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree,
     313extern node_t *create_dev_node(void);
     314extern void delete_dev_node(node_t *node);
     315extern node_t *find_dev_node_no_lock(dev_tree_t *tree,
    329316    devman_handle_t handle);
    330 extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
    331 extern dev_node_t *find_dev_function(dev_node_t *, const char *);
    332 
    333 extern fun_node_t *create_fun_node(void);
    334 extern void delete_fun_node(fun_node_t *);
    335 extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree,
    336     devman_handle_t handle);
    337 extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle);
    338 extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
    339 extern fun_node_t *find_fun_node_in_device(dev_node_t *, const char *);
    340 extern fun_node_t *find_fun_node_by_class(class_list_t *, const char *, const char *);
     317extern node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
     318extern node_t *find_dev_node_by_path(dev_tree_t *, char *);
     319extern node_t *find_node_child(node_t *, const char *);
    341320
    342321/* Device tree */
    343322
    344323extern bool init_device_tree(dev_tree_t *, driver_list_t *);
    345 extern bool create_root_nodes(dev_tree_t *);
    346 extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
    347 extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
     324extern bool create_root_node(dev_tree_t *);
     325extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *);
    348326
    349327/* Device classes */
     
    353331extern size_t get_new_class_dev_idx(dev_class_t *);
    354332extern char *create_dev_name_for_class(dev_class_t *, const char *);
    355 extern dev_class_info_t *add_function_to_class(fun_node_t *, dev_class_t *,
     333extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *,
    356334    const char *);
    357335
     
    360338extern dev_class_t *get_dev_class(class_list_t *, char *);
    361339extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *);
    362 extern dev_class_info_t *find_dev_in_class(dev_class_t *, const char *);
    363340extern void add_dev_class_no_lock(class_list_t *, dev_class_t *);
    364341
    365342/* Devmap devices */
    366343
    367 extern void devmap_register_tree_function(fun_node_t *, dev_tree_t *);
    368 
    369 extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t);
    370 extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t);
    371 
    372 extern void class_add_devmap_function(class_list_t *, dev_class_info_t *);
    373 extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *);
     344extern node_t *find_devmap_tree_device(dev_tree_t *, devmap_handle_t);
     345extern node_t *find_devmap_class_device(class_list_t *, devmap_handle_t);
     346
     347extern void class_add_devmap_device(class_list_t *, dev_class_info_t *);
     348extern void tree_add_devmap_device(dev_tree_t *, node_t *);
    374349
    375350#endif
Note: See TracChangeset for help on using the changeset viewer.