Changeset 8b655705 in mainline for uspace/srv/devman/devman.h


Ignore:
Timestamp:
2011-04-15T19:38:07Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9dd730d1
Parents:
6b9e85b (diff), b2fb47f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    r6b9e85b r8b655705  
    4040#include <adt/list.h>
    4141#include <adt/hash_table.h>
    42 #include <ipc/ipc.h>
    4342#include <ipc/devman.h>
    4443#include <ipc/devmap.h>
     
    5756#define DEVMAP_SEPARATOR '\\'
    5857
    59 struct node;
    60 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;
    6163
    6264typedef enum {
     
    8688       
    8789        /** Phone asociated with this driver. */
    88         sysarg_t phone;
     90        int phone;
    8991        /** Name of the device driver. */
    9092        char *name;
     
    118120} device_state_t;
    119121
    120 /** Representation of a node in the device tree. */
    121 struct node {
     122/** Device node in the device tree. */
     123struct dev_node {
    122124        /** The global unique identifier of the device. */
    123125        devman_handle_t handle;
    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;
     126       
     127        /** (Parent) function the device is attached to. */
     128        fun_node_t *pfun;
     129       
     130        /** List of device functions. */
     131        link_t functions;
    146132        /** Driver of this device. */
    147133        driver_t *drv;
    148134        /** The state of the device. */
    149135        device_state_t state;
    150         /**
    151          * Pointer to the previous and next device in the list of devices
    152          * owned by one driver.
    153          */
     136        /** Link to list of devices owned by driver (driver_t.devices) */
    154137        link_t driver_devices;
    155138       
    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        
    161139        /**
    162140         * Used by the hash table of devices indexed by devman device handles.
    163141         */
    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 
     142        link_t devman_dev;
     143       
    171144        /**
    172145         * Whether this device was already passed to the driver.
     
    174147        bool passed_to_driver;
    175148};
     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 (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
    176187
    177188/** Represents device tree. */
    178189typedef struct dev_tree {
    179190        /** Root device node. */
    180         node_t *root_node;
     191        fun_node_t *root_node;
    181192       
    182193        /**
     
    192203        hash_table_t devman_devices;
    193204       
     205        /** Hash table of all devices indexed by devman handles. */
     206        hash_table_t devman_functions;
     207       
    194208        /**
    195209         * Hash table of devices registered by devmapper, indexed by devmap
    196210         * handles.
    197211         */
    198         hash_table_t devmap_devices;
     212        hash_table_t devmap_functions;
    199213} dev_tree_t;
    200214
     
    228242
    229243/**
    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.
     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.
    233247 */
    234248typedef struct dev_class_info {
     
    236250        dev_class_t *dev_class;
    237251        /** The device. */
    238         node_t *dev;
     252        fun_node_t *fun;
    239253       
    240254        /**
     
    250264        link_t dev_classes;
    251265       
    252         /** The name of the device within the class. */
     266        /** The name of the device function within the class. */
    253267        char *dev_name;
    254268        /** The handle of the device by device mapper in the class namespace. */
     
    271285         * indexed by devmap handles.
    272286         */
    273         hash_table_t devmap_devices;
     287        hash_table_t devmap_functions;
    274288       
    275289        /** Fibril mutex for list of classes. */
     
    279293/* Match ids and scores */
    280294
    281 extern int get_match_score(driver_t *, node_t *);
     295extern int get_match_score(driver_t *, dev_node_t *);
    282296
    283297extern bool parse_match_ids(char *, match_id_list_t *);
     
    293307extern int lookup_available_drivers(driver_list_t *, const char *);
    294308
    295 extern driver_t *find_best_match_driver(driver_list_t *, node_t *);
    296 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 *);
    297311
    298312extern void add_driver(driver_list_t *, driver_t *);
    299 extern void attach_driver(node_t *, driver_t *);
    300 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 *);
    301315extern bool start_driver(driver_t *);
    302316
    303317extern driver_t *find_driver(driver_list_t *, const char *);
    304 extern void set_driver_phone(driver_t *, sysarg_t);
    305318extern void initialize_running_driver(driver_t *, dev_tree_t *);
    306319
     
    311324/* Device nodes */
    312325
    313 extern node_t *create_dev_node(void);
    314 extern void delete_dev_node(node_t *node);
    315 extern node_t *find_dev_node_no_lock(dev_tree_t *tree,
     326extern dev_node_t *create_dev_node(void);
     327extern void delete_dev_node(dev_node_t *node);
     328extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree,
    316329    devman_handle_t handle);
    317 extern node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
    318 extern node_t *find_dev_node_by_path(dev_tree_t *, char *);
    319 extern node_t *find_node_child(node_t *, const char *);
     330extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
     331extern dev_node_t *find_dev_function(dev_node_t *, const char *);
     332
     333extern fun_node_t *create_fun_node(void);
     334extern void delete_fun_node(fun_node_t *);
     335extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree,
     336    devman_handle_t handle);
     337extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle);
     338extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
     339extern fun_node_t *find_fun_node_in_device(dev_node_t *, const char *);
     340extern fun_node_t *find_fun_node_by_class(class_list_t *, const char *, const char *);
    320341
    321342/* Device tree */
    322343
    323344extern bool init_device_tree(dev_tree_t *, driver_list_t *);
    324 extern bool create_root_node(dev_tree_t *);
    325 extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *);
     345extern bool create_root_nodes(dev_tree_t *);
     346extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
     347extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
    326348
    327349/* Device classes */
     
    331353extern size_t get_new_class_dev_idx(dev_class_t *);
    332354extern char *create_dev_name_for_class(dev_class_t *, const char *);
    333 extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *,
     355extern dev_class_info_t *add_function_to_class(fun_node_t *, dev_class_t *,
    334356    const char *);
    335357
     
    338360extern dev_class_t *get_dev_class(class_list_t *, char *);
    339361extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *);
     362extern dev_class_info_t *find_dev_in_class(dev_class_t *, const char *);
    340363extern void add_dev_class_no_lock(class_list_t *, dev_class_t *);
    341364
    342365/* Devmap devices */
    343366
    344 extern node_t *find_devmap_tree_device(dev_tree_t *, devmap_handle_t);
    345 extern node_t *find_devmap_class_device(class_list_t *, devmap_handle_t);
    346 
    347 extern void class_add_devmap_device(class_list_t *, dev_class_info_t *);
    348 extern void tree_add_devmap_device(dev_tree_t *, node_t *);
     367extern void devmap_register_tree_function(fun_node_t *, dev_tree_t *);
     368
     369extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t);
     370extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t);
     371
     372extern void class_add_devmap_function(class_list_t *, dev_class_info_t *);
     373extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *);
    349374
    350375#endif
Note: See TracChangeset for help on using the changeset viewer.