Ignore:
File:
1 edited

Legend:

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

    r3e6a98c5 re5556e4a  
    3535#define DEVMAN_H_
    3636
    37 #include <assert.h>
    3837#include <stdbool.h>
    39 #include <dirent.h>
    40 #include <str.h>
    4138#include <adt/list.h>
    4239#include <adt/hash_table.h>
     
    5148#define NAME "devman"
    5249
    53 #define MATCH_EXT ".ma"
    54 
    5550#define LOC_DEVICE_NAMESPACE "devices"
    5651#define LOC_SEPARATOR '\\'
     
    6762} client_t;
    6863
    69 typedef enum {
    70         /** Driver has not been started. */
    71         DRIVER_NOT_STARTED = 0,
    72        
    73         /**
    74          * Driver has been started, but has not registered as running and ready
    75          * to receive requests.
    76          */
    77         DRIVER_STARTING,
    78        
    79         /** Driver is running and prepared to serve incomming requests. */
    80         DRIVER_RUNNING
    81 } driver_state_t;
    82 
    8364/** Representation of device driver. */
    8465typedef struct driver {
    8566        /** Pointers to previous and next drivers in a linked list. */
    8667        link_t drivers;
     68        /** Handle */
     69        devman_handle_t handle;
    8770       
    8871        /**
     
    9073         * and prepared to receive requests.
    9174         */
    92         int state;
     75        driver_state_t state;
    9376       
    9477        /** Session asociated with this driver. */
     
    11598        /** Fibril mutex for list of drivers. */
    11699        fibril_mutex_t drivers_mutex;
     100        /** Next free handle */
     101        devman_handle_t next_handle;
    117102} driver_list_t;
    118103
     
    238223} dev_tree_t;
    239224
    240 /* Match ids and scores */
    241 
    242 extern int get_match_score(driver_t *, dev_node_t *);
    243 
    244 extern bool parse_match_ids(char *, match_id_list_t *);
    245 extern bool read_match_ids(const char *, match_id_list_t *);
    246 extern char *read_match_id(char **);
    247 extern char *read_id(const char **);
    248 
    249 /* Drivers */
    250 
    251 extern void init_driver_list(driver_list_t *);
    252 extern driver_t *create_driver(void);
    253 extern bool get_driver_info(const char *, const char *, driver_t *);
    254 extern int lookup_available_drivers(driver_list_t *, const char *);
    255 
    256 extern driver_t *find_best_match_driver(driver_list_t *, dev_node_t *);
    257 extern bool assign_driver(dev_node_t *, driver_list_t *, dev_tree_t *);
    258 
    259 extern void add_driver(driver_list_t *, driver_t *);
    260 extern void attach_driver(dev_tree_t *, dev_node_t *, driver_t *);
    261 extern void detach_driver(dev_tree_t *, dev_node_t *);
    262 extern void add_device(driver_t *, dev_node_t *, dev_tree_t *);
    263 extern bool start_driver(driver_t *);
    264 extern int driver_dev_remove(dev_tree_t *, dev_node_t *);
    265 extern int driver_dev_gone(dev_tree_t *, dev_node_t *);
    266 extern int driver_fun_online(dev_tree_t *, fun_node_t *);
    267 extern int driver_fun_offline(dev_tree_t *, fun_node_t *);
    268 
    269 extern driver_t *find_driver(driver_list_t *, const char *);
    270 extern void initialize_running_driver(driver_t *, dev_tree_t *);
    271 
    272 extern void init_driver(driver_t *);
    273 extern void clean_driver(driver_t *);
    274 extern void delete_driver(driver_t *);
    275 
    276 /* Device nodes */
    277 
    278 extern dev_node_t *create_dev_node(void);
    279 extern void delete_dev_node(dev_node_t *node);
    280 extern void dev_add_ref(dev_node_t *);
    281 extern void dev_del_ref(dev_node_t *);
    282 
    283 extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree,
    284     devman_handle_t handle);
    285 extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
    286 extern dev_node_t *find_dev_function(dev_node_t *, const char *);
    287 extern int dev_get_functions(dev_tree_t *tree, dev_node_t *, devman_handle_t *,
    288     size_t, size_t *);
    289 
    290 extern fun_node_t *create_fun_node(void);
    291 extern void delete_fun_node(fun_node_t *);
    292 extern void fun_add_ref(fun_node_t *);
    293 extern void fun_del_ref(fun_node_t *);
    294 extern void fun_busy_lock(fun_node_t *);
    295 extern void fun_busy_unlock(fun_node_t *);
    296 extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree,
    297     devman_handle_t handle);
    298 extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle);
    299 extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
    300 extern fun_node_t *find_fun_node_in_device(dev_tree_t *tree, dev_node_t *,
    301     const char *);
    302 
    303 /* Device tree */
    304 
    305 extern bool init_device_tree(dev_tree_t *, driver_list_t *);
    306 extern bool create_root_nodes(dev_tree_t *);
    307 extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
    308 extern void remove_dev_node(dev_tree_t *, dev_node_t *);
    309 extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
    310 extern void remove_fun_node(dev_tree_t *, fun_node_t *);
    311 
    312 /* Loc services */
    313 
    314 extern void loc_register_tree_function(fun_node_t *, dev_tree_t *);
    315 
    316 extern fun_node_t *find_loc_tree_function(dev_tree_t *, service_id_t);
    317 
    318 extern void tree_add_loc_function(dev_tree_t *, fun_node_t *);
    319 
    320225#endif
    321226
Note: See TracChangeset for help on using the changeset viewer.