Changeset bda60d9 in mainline for uspace/srv/devman/devman.h
- Timestamp:
- 2010-03-19T14:40:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d347b53
- Parents:
- 7707954
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.h
r7707954 rbda60d9 40 40 #include <adt/list.h> 41 41 #include <ipc/ipc.h> 42 #include <ipc/devman.h> 42 43 #include <fibril_synch.h> 43 44 #include <atomic.h> … … 48 49 49 50 #define MATCH_EXT ".ma" 51 #define MAX_DEV 256 50 52 51 53 struct node; 52 54 53 55 typedef struct node node_t; 54 55 /** Ids of device models used for device-to-driver matching.56 */57 typedef struct match_id {58 /** Pointers to next and previous ids.59 */60 link_t link;61 /** Id of device model.62 */63 const char *id;64 /** Relevancy of device-to-driver match.65 * The higher is the product of scores specified for the device by the bus driver and by the leaf driver,66 * the more suitable is the leaf driver for handling the device.67 */68 unsigned int score;69 } match_id_t;70 71 /** List of ids for matching devices to drivers sorted72 * according to match scores in descending order.73 */74 typedef struct match_id_list {75 link_t ids;76 } match_id_list_t;77 56 78 57 typedef enum { … … 117 96 struct node { 118 97 /** The global unique identifier of the device.*/ 119 long handle; 98 device_handle_t handle; 99 /** The name of the device specified by its parent. */ 100 char *name; 101 /** Full path and name of the device in device hierarchi (i. e. in full path in device tree).*/ 102 char *pathname; 120 103 /** The node of the parent device. */ 121 104 node_t *parent; … … 140 123 /** Root device node. */ 141 124 node_t *root_node; 125 /** The next available handle - handles are assigned in a sequential manner.*/ 142 126 atomic_t current_handle; 127 /** Handle-to-node mapping. */ 128 node_t * node_map[MAX_DEV]; 143 129 } dev_tree_t; 144 130 … … 152 138 bool read_match_ids(const char *conf_path, match_id_list_t *ids); 153 139 char * read_id(const char **buf) ; 154 void add_match_id(match_id_list_t *ids, match_id_t *id);155 156 void clean_match_ids(match_id_list_t *ids);157 158 159 static inline match_id_t * create_match_id()160 {161 match_id_t *id = malloc(sizeof(match_id_t));162 memset(id, 0, sizeof(match_id_t));163 return id;164 }165 166 static inline void delete_match_id(match_id_t *id)167 {168 if (id) {169 free_not_null(id->id);170 free(id);171 }172 }173 174 175 176 177 140 178 141 // Drivers … … 248 211 } 249 212 250 static inline void insert_dev_node(dev_tree_t *tree, node_t *node, node_t *parent) 251 { 252 assert(NULL != node && NULL != tree); 253 254 node->handle = atomic_postinc(&tree->current_handle); 255 256 node->parent = parent; 257 if (NULL != parent) { 258 fibril_mutex_lock(&parent->children_mutex); 259 list_append(&node->sibling, &parent->children); 260 fibril_mutex_unlock(&parent->children_mutex); 213 static inline node_t * find_dev_node(dev_tree_t *tree, long handle) 214 { 215 if (handle < MAX_DEV) { 216 return tree->node_map[handle]; 261 217 } 262 } 263 218 return NULL; 219 } 264 220 265 221 // Device tree … … 267 223 bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list); 268 224 bool create_root_node(dev_tree_t *tree); 269 225 bool insert_dev_node(dev_tree_t *tree, node_t *node, const char *dev_name, node_t *parent); 270 226 271 227 #endif
Note:
See TracChangeset
for help on using the changeset viewer.