Changeset 957cfa58 in mainline for uspace/srv/devman/devman.h
- Timestamp:
- 2010-05-26T20:25:43Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c9f3b45c
- Parents:
- d51ee2b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.h
rd51ee2b r957cfa58 39 39 #include <str.h> 40 40 #include <adt/list.h> 41 #include <adt/hash_table.h> 41 42 #include <ipc/ipc.h> 42 43 #include <ipc/devman.h> … … 50 51 51 52 #define MATCH_EXT ".ma" 52 #define MAX_DEV25653 #define DEVICE_BUCKETS 256 53 54 54 55 struct node; … … 115 116 /** List of child device nodes. */ 116 117 link_t children; 117 /** Fibril mutex for the list of child device nodes of this node. */118 fibril_mutex_t children_mutex;119 118 /** List of device ids for device-to-driver matching.*/ 120 119 match_id_list_t match_ids; … … 128 127 /** The list of device classes to which this device belongs.*/ 129 128 link_t classes; 129 /** Devmap handle if the device is registered by devmapper. */ 130 dev_handle_t devmap_handle; 131 /** Used by the hash table of devices indexed by devman device handles.*/ 132 link_t devman_link; 133 /** Used by the hash table of devices indexed by devmap device handles.*/ 134 link_t devmap_link; 130 135 }; 136 131 137 132 138 /** Represents device tree. … … 136 142 node_t *root_node; 137 143 /** The next available handle - handles are assigned in a sequential manner.*/ 138 atomic_t current_handle; 139 /** Handle-to-node mapping. */ 140 node_t * node_map[MAX_DEV]; 144 device_handle_t current_handle; 145 /** Synchronize access to the device tree.*/ 146 fibril_rwlock_t rwlock; 147 /** Hash table of all devices indexed by devman handles.*/ 148 hash_table_t devman_devices; 149 /** Hash table of devices registered by devmapper, indexed by devmap handles.*/ 150 hash_table_t devmap_devices; 151 141 152 } dev_tree_t; 142 153 … … 277 288 list_initialize(&res->children); 278 289 list_initialize(&res->match_ids.ids); 279 fibril_mutex_initialize(&res->children_mutex);280 290 281 291 return res; … … 301 311 * Find the device node structure of the device witch has the specified handle. 302 312 * 313 * Device tree's rwlock should be held at least for reading. 314 * 303 315 * @param tree the device tree where we look for the device node. 304 316 * @param handle the handle of the device. 305 317 * @return the device node. 306 318 */ 307 static inline node_t * find_dev_node(dev_tree_t *tree, long handle) 308 { 309 if (handle < MAX_DEV) { 310 return tree->node_map[handle]; 311 } 312 return NULL; 319 static inline node_t * find_dev_node_no_lock(dev_tree_t *tree, device_handle_t handle) 320 { 321 unsigned long key = handle; 322 link_t *link = hash_table_find(&tree->devman_devices, &key); 323 return hash_table_get_instance(link, node_t, devman_link); 324 } 325 326 /** 327 * Find the device node structure of the device witch has the specified handle. 328 * 329 * @param tree the device tree where we look for the device node. 330 * @param handle the handle of the device. 331 * @return the device node. 332 */ 333 static inline node_t * find_dev_node(dev_tree_t *tree, device_handle_t handle) 334 { 335 node_t *node = NULL; 336 337 fibril_rwlock_read_lock(&tree->rwlock); 338 339 node = find_dev_node_no_lock(tree, handle); 340 341 fibril_rwlock_read_unlock(&tree->rwlock); 342 343 return node; 313 344 } 314 345
Note:
See TracChangeset
for help on using the changeset viewer.