Changeset 5cd136ab in mainline for uspace/srv/devman
- Timestamp:
- 2010-04-02T13:37:58Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9a66bc2e
- Parents:
- 57937dd
- Location:
- uspace/srv/devman
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r57937dd r5cd136ab 506 506 if (rc != EOK) { 507 507 // TODO handle error 508 return false;508 return; 509 509 } 510 510 511 511 // TODO inspect return value (ret) to find out whether the device was successfully probed and added 512 512 513 return true;513 return; 514 514 } 515 515 … … 618 618 * @return true on success, false otherwise (insufficient resources etc.). 619 619 */ 620 bool insert_dev_node(dev_tree_t *tree, node_t *node, c onst char *dev_name, node_t *parent)620 bool insert_dev_node(dev_tree_t *tree, node_t *node, char *dev_name, node_t *parent) 621 621 { 622 622 printf(NAME ": insert_dev_node\n"); … … 650 650 } 651 651 652 /** 653 * Find device node with a specified path in the device tree. 654 * 655 * @param path the path of the device node in the device tree. 656 * @param tree the device tree. 657 * 658 * @return the device node if it is present in the tree, NULL otherwise. 659 */ 660 node_t * find_dev_node_by_path(dev_tree_t *tree, char *path) 661 { 662 node_t *dev = tree->root_node; 663 char *rel_path = path; 664 char *next_path_elem = NULL; 665 size_t elem_size = 0; 666 bool cont = '/' == rel_path[0]; 667 668 while (cont && NULL != dev) { 669 next_path_elem = get_path_elem_end(rel_path+1); 670 if ('/' == next_path_elem[0]) { 671 cont = true; 672 next_path_elem[0] = 0; 673 } else { 674 cont = false; 675 } 676 677 dev = find_node_child(dev, rel_path); 678 679 if (cont) { 680 next_path_elem[0] = '/'; 681 } 682 rel_path = next_path_elem; 683 } 684 685 return dev; 686 } 687 688 /** 689 * Find child device node with a specified name. 690 * 691 * @param parent the parent device node. 692 * @param name the name of the child device node. 693 * 694 * @return the child device node. 695 */ 696 node_t *find_node_child(node_t *parent, const char *name) 697 { 698 node_t *dev; 699 link_t *link; 700 701 fibril_mutex_lock(&parent->children_mutex); 702 link = parent->children.next; 703 704 while (link != &parent->children) { 705 dev = list_get_instance(link, node_t, sibling); 706 707 if (0 == str_cmp(name, dev->name)) { 708 fibril_mutex_unlock(&parent->children_mutex); 709 return dev; 710 } 711 } 712 713 fibril_mutex_unlock(&parent->children_mutex); 714 return NULL; 715 } 716 652 717 /** @} 653 718 */ -
uspace/srv/devman/devman.h
r57937dd r5cd136ab 238 238 } 239 239 240 /** 241 * Delete a device node. 242 * 243 * @param node a device node structure. 244 * 245 */ 240 246 static inline void delete_dev_node(node_t *node) 241 247 { … … 263 269 } 264 270 271 node_t * find_dev_node_by_path(dev_tree_t *tree, char *path); 272 node_t *find_node_child(node_t *parent, const char *name); 273 265 274 // Device tree 266 275 267 276 bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list); 268 277 bool create_root_node(dev_tree_t *tree); 269 bool insert_dev_node(dev_tree_t *tree, node_t *node, c onst char *dev_name, node_t *parent);278 bool insert_dev_node(dev_tree_t *tree, node_t *node, char *dev_name, node_t *parent); 270 279 271 280 #endif -
uspace/srv/devman/main.c
r57937dd r5cd136ab 51 51 #include <ctype.h> 52 52 #include <ipc/devman.h> 53 #include <ipc/driver.h> 53 54 #include <thread.h> 54 55 … … 158 159 { 159 160 int ret = EOK; 160 int i;161 size_t i; 161 162 for (i = 0; i < match_count; i++) { 162 163 if (EOK != (ret = devman_receive_match_id(match_ids))) { … … 257 258 } 258 259 260 static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent) { 261 device_handle_t handle; 262 node_t *dev = find_dev_node(&device_tree, handle); 263 if (NULL == dev) { 264 ipc_answer_0(iid, ENOENT); 265 return; 266 } 267 268 driver_t *driver = NULL; 269 270 if (drv_to_parent) { 271 driver = dev->parent->drv; 272 } else { 273 driver = dev->drv; 274 } 275 276 if (NULL == driver) { 277 ipc_answer_0(iid, ENOENT); 278 return; 279 } 280 281 int method; 282 if (drv_to_parent) { 283 method = DRIVER_DRIVER; 284 } else { 285 method = DRIVER_CLIENT; 286 } 287 288 ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE); 289 } 290 259 291 /** Function for handling connections to device manager. 260 292 * … … 269 301 /*case DEVMAN_CLIENT: 270 302 devmap_connection_client(iid, icall); 271 break; 303 break;*/ 272 304 case DEVMAN_CONNECT_TO_DEVICE: 273 305 // Connect client to selected device 274 devmap_forward(iid, icall); 275 break;*/ 306 devman_forward(iid, icall, false); 307 break; 308 case DEVMAN_CONNECT_TO_PARENTS_DEVICE: 309 // Connect client to selected device 310 devman_forward(iid, icall, true); 311 break; 276 312 default: 277 313 /* No such interface */ -
uspace/srv/devman/util.c
r57937dd r5cd136ab 61 61 return res; 62 62 } 63 64 const char * get_path_elem_end(const char *path) 65 { 66 while (0 != *path && '/' != *path) { 67 path++; 68 } 69 return path; 70 } -
uspace/srv/devman/util.h
r57937dd r5cd136ab 38 38 39 39 char * get_abs_path(const char *base_path, const char *name, const char *ext); 40 const char * get_path_elem_end(const char *path); 40 41 41 42 static inline bool skip_spaces(const char **buf)
Note:
See TracChangeset
for help on using the changeset viewer.
