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