Changes in uspace/srv/devman/devman.h [83a2f43:96b02eb9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.h
r83a2f43 r96b02eb9 40 40 #include <adt/list.h> 41 41 #include <adt/hash_table.h> 42 #include <ipc/ipc.h> 42 43 #include <ipc/devman.h> 43 44 #include <ipc/devmap.h> … … 56 57 #define DEVMAP_SEPARATOR '\\' 57 58 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; 59 struct node; 60 typedef struct node node_t; 63 61 64 62 typedef enum { … … 120 118 } device_state_t; 121 119 122 /** Devicenode in the device tree. */123 struct dev_node {120 /** Representation of a node in the device tree. */ 121 struct node { 124 122 /** The global unique identifier of the device. */ 125 123 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; 132 146 /** Driver of this device. */ 133 147 driver_t *drv; 134 148 /** The state of the device. */ 135 149 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 */ 137 154 link_t driver_devices; 138 155 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 139 161 /** 140 162 * Used by the hash table of devices indexed by devman device handles. 141 163 */ 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 144 171 /** 145 172 * Whether this device was already passed to the driver. … … 147 174 bool passed_to_driver; 148 175 }; 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 187 176 188 177 /** Represents device tree. */ 189 178 typedef struct dev_tree { 190 179 /** Root device node. */ 191 fun_node_t *root_node;180 node_t *root_node; 192 181 193 182 /** … … 203 192 hash_table_t devman_devices; 204 193 205 /** Hash table of all devices indexed by devman handles. */206 hash_table_t devman_functions;207 208 194 /** 209 195 * Hash table of devices registered by devmapper, indexed by devmap 210 196 * handles. 211 197 */ 212 hash_table_t devmap_ functions;198 hash_table_t devmap_devices; 213 199 } dev_tree_t; 214 200 … … 242 228 243 229 /** 244 * Provides n-to-m mapping between function nodes and classes - each function245 * can register in an arbitrary number of classes and each class cancontain246 * 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. 247 233 */ 248 234 typedef struct dev_class_info { … … 250 236 dev_class_t *dev_class; 251 237 /** The device. */ 252 fun_node_t *fun;238 node_t *dev; 253 239 254 240 /** … … 264 250 link_t dev_classes; 265 251 266 /** The name of the device functionwithin the class. */252 /** The name of the device within the class. */ 267 253 char *dev_name; 268 254 /** The handle of the device by device mapper in the class namespace. */ … … 285 271 * indexed by devmap handles. 286 272 */ 287 hash_table_t devmap_ functions;273 hash_table_t devmap_devices; 288 274 289 275 /** Fibril mutex for list of classes. */ … … 293 279 /* Match ids and scores */ 294 280 295 extern int get_match_score(driver_t *, dev_node_t *);281 extern int get_match_score(driver_t *, node_t *); 296 282 297 283 extern bool parse_match_ids(char *, match_id_list_t *); … … 307 293 extern int lookup_available_drivers(driver_list_t *, const char *); 308 294 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 *);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 *); 311 297 312 298 extern 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 *);299 extern void attach_driver(node_t *, driver_t *); 300 extern void add_device(int, driver_t *, node_t *, dev_tree_t *); 315 301 extern bool start_driver(driver_t *); 316 302 … … 325 311 /* Device nodes */ 326 312 327 extern dev_node_t *create_dev_node(void);328 extern void delete_dev_node( dev_node_t *node);329 extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree,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, 330 316 devman_handle_t handle); 331 extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle); 332 extern dev_node_t *find_dev_function(dev_node_t *, const char *); 333 334 extern fun_node_t *create_fun_node(void); 335 extern void delete_fun_node(fun_node_t *); 336 extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree, 337 devman_handle_t handle); 338 extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle); 339 extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *); 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 *); 340 320 341 321 /* Device tree */ 342 322 343 323 extern bool init_device_tree(dev_tree_t *, driver_list_t *); 344 extern bool create_root_nodes(dev_tree_t *); 345 extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *); 346 extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *); 324 extern bool create_root_node(dev_tree_t *); 325 extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *); 347 326 348 327 /* Device classes */ … … 352 331 extern size_t get_new_class_dev_idx(dev_class_t *); 353 332 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 *,333 extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *, 355 334 const char *); 356 335 … … 363 342 /* Devmap devices */ 364 343 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 *); 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 *); 372 349 373 350 #endif
Note:
See TracChangeset
for help on using the changeset viewer.