Changes in uspace/srv/devman/devman.h [83a2f43:45059d6b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.h
r83a2f43 r45059d6b 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 41 42 #include <adt/hash_table.h> 42 43 #include <ipc/devman.h> 43 #include <ipc/ devmap.h>44 #include <ipc/loc.h> 44 45 #include <fibril_synch.h> 45 46 #include <atomic.h> 47 #include <async.h> 46 48 47 49 #include "util.h" … … 52 54 #define DEVICE_BUCKETS 256 53 55 54 #define DEVMAP_CLASS_NAMESPACE "class" 55 #define DEVMAP_DEVICE_NAMESPACE "devices" 56 #define DEVMAP_SEPARATOR '\\' 56 #define LOC_DEVICE_NAMESPACE "devices" 57 #define LOC_SEPARATOR '\\' 57 58 58 59 struct dev_node; … … 87 88 int state; 88 89 89 /** Phoneasociated with this driver. */90 sysarg_t phone;90 /** Session asociated with this driver. */ 91 async_sess_t *sess; 91 92 /** Name of the device driver. */ 92 93 char *name; … … 95 96 /** List of device ids for device-to-driver matching. */ 96 97 match_id_list_t match_ids; 97 /** Pointer to the linked list of devices controlled by this driver. */98 li nk_t devices;99 100 /** 101 * Fibril mutex for this driver - driver state, list of devices, phone.98 /** List of devices controlled by this driver. */ 99 list_t devices; 100 101 /** 102 * Fibril mutex for this driver - driver state, list of devices, session. 102 103 */ 103 104 fibril_mutex_t driver_mutex; … … 107 108 typedef struct driver_list { 108 109 /** List of drivers */ 109 li nk_t drivers;110 list_t drivers; 110 111 /** Fibril mutex for list of drivers. */ 111 112 fibril_mutex_t drivers_mutex; … … 129 130 130 131 /** List of device functions. */ 131 li nk_t functions;132 list_t functions; 132 133 /** Driver of this device. */ 133 134 driver_t *drv; … … 154 155 /** Name of the function, assigned by the device driver */ 155 156 char *name; 157 /** Function type */ 158 fun_type_t ftype; 156 159 157 160 /** Full path and name of the device in device hierarchy */ … … 169 172 match_id_list_t match_ids; 170 173 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; 174 /** Service ID if the device function is registered with loc. */ 175 service_id_t service_id; 175 176 176 177 /** … … 180 181 181 182 /** 182 * Used by the hash table of functions indexed by devmap device handles.183 */ 184 link_t devmap_fun;183 * Used by the hash table of functions indexed by service IDs. 184 */ 185 link_t loc_fun; 185 186 }; 186 187 … … 207 208 208 209 /** 209 * Hash table of devices registered by devmapper, indexed by devmap210 * handles.211 */ 212 hash_table_t devmap_functions;210 * Hash table of services registered with location service, indexed by 211 * service IDs. 212 */ 213 hash_table_t loc_functions; 213 214 } dev_tree_t; 214 215 typedef struct dev_class {216 /** The name of the class. */217 const char *name;218 219 /**220 * Pointer to the previous and next class in the list of registered221 * classes.222 */223 link_t link;224 225 /**226 * List of dev_class_info structures - one for each device registered by227 * this class.228 */229 link_t devices;230 231 /**232 * Default base name for the device within the class, might be overrided233 * by the driver.234 */235 const char *base_dev_name;236 237 /** Unique numerical identifier of the newly added device. */238 size_t curr_dev_idx;239 /** Synchronize access to the list of devices in this class. */240 fibril_mutex_t mutex;241 } dev_class_t;242 243 /**244 * Provides n-to-m mapping between function nodes and classes - each function245 * can register in an arbitrary number of classes and each class can contain246 * an arbitrary number of device functions.247 */248 typedef struct dev_class_info {249 /** The class. */250 dev_class_t *dev_class;251 /** The device. */252 fun_node_t *fun;253 254 /**255 * Pointer to the previous and next class info in the list of devices256 * registered by the class.257 */258 link_t link;259 260 /**261 * Pointer to the previous and next class info in the list of classes262 * by which the device is registered.263 */264 link_t dev_classes;265 266 /** The name of the device function within the class. */267 char *dev_name;268 /** The handle of the device by device mapper in the class namespace. */269 devmap_handle_t devmap_handle;270 271 /**272 * Link in the hash table of devices registered by the devmapper using273 * their class names.274 */275 link_t devmap_link;276 } dev_class_info_t;277 278 /** The list of device classes. */279 typedef struct class_list {280 /** List of classes. */281 link_t classes;282 283 /**284 * Hash table of devices registered by devmapper using their class name,285 * indexed by devmap handles.286 */287 hash_table_t devmap_functions;288 289 /** Fibril mutex for list of classes. */290 fibril_rwlock_t rwlock;291 } class_list_t;292 215 293 216 /* Match ids and scores */ … … 312 235 extern void add_driver(driver_list_t *, driver_t *); 313 236 extern void attach_driver(dev_node_t *, driver_t *); 314 extern void add_device( int,driver_t *, dev_node_t *, dev_tree_t *);237 extern void add_device(driver_t *, dev_node_t *, dev_tree_t *); 315 238 extern bool start_driver(driver_t *); 316 239 317 240 extern driver_t *find_driver(driver_list_t *, const char *); 318 extern void set_driver_phone(driver_t *, sysarg_t);319 241 extern void initialize_running_driver(driver_t *, dev_tree_t *); 320 242 … … 331 253 extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle); 332 254 extern dev_node_t *find_dev_function(dev_node_t *, const char *); 255 extern int dev_get_functions(dev_tree_t *tree, dev_node_t *, devman_handle_t *, 256 size_t, size_t *); 333 257 334 258 extern fun_node_t *create_fun_node(void); … … 338 262 extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle); 339 263 extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *); 264 extern fun_node_t *find_fun_node_in_device(dev_node_t *, const char *); 340 265 341 266 /* Device tree */ … … 345 270 extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *); 346 271 extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *); 347 348 /* Device classes */ 349 350 extern dev_class_t *create_dev_class(void); 351 extern dev_class_info_t *create_dev_class_info(void); 352 extern size_t get_new_class_dev_idx(dev_class_t *); 353 extern 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 *, 355 const char *); 356 357 extern void init_class_list(class_list_t *); 358 359 extern dev_class_t *get_dev_class(class_list_t *, char *); 360 extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *); 361 extern void add_dev_class_no_lock(class_list_t *, dev_class_t *); 362 363 /* Devmap devices */ 364 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 *); 272 extern void remove_fun_node(dev_tree_t *, fun_node_t *); 273 274 /* Loc services */ 275 276 extern void loc_register_tree_function(fun_node_t *, dev_tree_t *); 277 278 extern fun_node_t *find_loc_tree_function(dev_tree_t *, service_id_t); 279 280 extern void tree_add_loc_function(dev_tree_t *, fun_node_t *); 372 281 373 282 #endif
Note:
See TracChangeset
for help on using the changeset viewer.