Changes in uspace/srv/devman/devman.c [9b415c9:fc8c2b6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r9b415c9 rfc8c2b6 34 34 #include <fcntl.h> 35 35 #include <sys/stat.h> 36 #include <io/log.h>37 36 #include <ipc/driver.h> 38 37 #include <ipc/devman.h> … … 147 146 fibril_mutex_unlock(&drivers_list->drivers_mutex); 148 147 149 log_msg(LVL_NOTE, "Driver `%s'was added to the list of available "148 printf(NAME": the '%s' driver was added to the list of available " 150 149 "drivers.\n", drv->name); 151 150 } … … 238 237 bool read_match_ids(const char *conf_path, match_id_list_t *ids) 239 238 { 240 log_msg(LVL_DEBUG, "read_match_ids(conf_path=\"%s\")\n", conf_path);239 printf(NAME ": read_match_ids conf_path = %s.\n", conf_path); 241 240 242 241 bool suc = false; … … 248 247 fd = open(conf_path, O_RDONLY); 249 248 if (fd < 0) { 250 log_msg(LVL_ERROR, "Unable to open `%s' for reading: %s.\n", 251 conf_path, str_error(fd)); 249 printf(NAME ": unable to open %s\n", conf_path); 252 250 goto cleanup; 253 251 } … … 257 255 lseek(fd, 0, SEEK_SET); 258 256 if (len == 0) { 259 log_msg(LVL_ERROR, "Configuration file '%s' is empty.\n", 260 conf_path); 257 printf(NAME ": configuration file '%s' is empty.\n", conf_path); 261 258 goto cleanup; 262 259 } … … 264 261 buf = malloc(len + 1); 265 262 if (buf == NULL) { 266 log_msg(LVL_ERROR, "Memory allocation failed when parsing file "263 printf(NAME ": memory allocation failed when parsing file " 267 264 "'%s'.\n", conf_path); 268 265 goto cleanup; … … 271 268 ssize_t read_bytes = safe_read(fd, buf, len); 272 269 if (read_bytes <= 0) { 273 log_msg(LVL_ERROR, "Unable to read file '%s'.\n", conf_path);270 printf(NAME ": unable to read file '%s'.\n", conf_path); 274 271 goto cleanup; 275 272 } … … 309 306 bool get_driver_info(const char *base_path, const char *name, driver_t *drv) 310 307 { 311 log_msg(LVL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")\n",308 printf(NAME ": get_driver_info base_path = %s, name = %s.\n", 312 309 base_path, name); 313 310 … … 341 338 struct stat s; 342 339 if (stat(drv->binary_path, &s) == ENOENT) { /* FIXME!! */ 343 log_msg(LVL_ERROR, "Driver not found at path `%s'.", 344 drv->binary_path); 340 printf(NAME ": driver not found at path %s.", drv->binary_path); 345 341 goto cleanup; 346 342 } … … 369 365 int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path) 370 366 { 371 log_msg(LVL_DEBUG, "lookup_available_drivers(dir=\"%s\")\n", dir_path);367 printf(NAME ": lookup_available_drivers, dir = %s \n", dir_path); 372 368 373 369 int drv_cnt = 0; … … 403 399 dev_node_t *dev; 404 400 405 log_msg(LVL_DEBUG, "create_root_nodes()\n");401 printf(NAME ": create_root_nodes\n"); 406 402 407 403 fibril_rwlock_write_lock(&tree->rwlock); … … 488 484 void attach_driver(dev_node_t *dev, driver_t *drv) 489 485 { 490 log_msg(LVL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")\n",491 d ev->pfun->pathname, drv->name);486 printf(NAME ": attach_driver %s to device %s\n", 487 drv->name, dev->pfun->pathname); 492 488 493 489 fibril_mutex_lock(&drv->driver_mutex); … … 511 507 assert(fibril_mutex_is_locked(&drv->driver_mutex)); 512 508 513 log_msg(LVL_DEBUG, "start_driver(drv=\"%s\")\n", drv->name);509 printf(NAME ": start_driver '%s'\n", drv->name); 514 510 515 511 rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL); 516 512 if (rc != EOK) { 517 log_msg(LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.\n",518 drv->name, drv->binary_path,str_error(rc));513 printf(NAME ": error spawning %s (%s)\n", 514 drv->name, str_error(rc)); 519 515 return false; 520 516 } … … 578 574 int phone; 579 575 580 log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")\n", 581 driver->name); 576 printf(NAME ": pass_devices_to_driver(`%s')\n", driver->name); 582 577 583 578 fibril_mutex_lock(&driver->driver_mutex); … … 646 641 * immediately and possibly started here as well. 647 642 */ 648 log_msg(LVL_DEBUG, "Driver `%s' entersrunning state.\n", driver->name);643 printf(NAME ": driver %s goes into running state.\n", driver->name); 649 644 driver->state = DRIVER_RUNNING; 650 645 … … 663 658 void initialize_running_driver(driver_t *driver, dev_tree_t *tree) 664 659 { 665 log_msg(LVL_DEBUG, "initialize_running_driver(driver=\"%s\")\n", 666 driver->name); 660 printf(NAME ": initialize_running_driver (`%s')\n", driver->name); 667 661 668 662 /* … … 754 748 * access any structures that would affect driver_t. 755 749 */ 756 log_msg(LVL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")\n",757 d rv->name, dev->pfun->name);750 printf(NAME ": add_device (driver `%s', device `%s')\n", drv->name, 751 dev->pfun->name); 758 752 759 753 sysarg_t rc; … … 816 810 driver_t *drv = find_best_match_driver(drivers_list, dev); 817 811 if (drv == NULL) { 818 log_msg(LVL_ERROR, "No driver found for device `%s'.\n",812 printf(NAME ": no driver found for device '%s'.\n", 819 813 dev->pfun->pathname); 820 814 return false; … … 854 848 bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list) 855 849 { 856 log_msg(LVL_DEBUG, "init_device_tree()\n");850 printf(NAME ": init_device_tree.\n"); 857 851 858 852 tree->current_handle = 0; … … 1033 1027 fun->pathname = (char *) malloc(pathsize); 1034 1028 if (fun->pathname == NULL) { 1035 log_msg(LVL_ERROR, "Failed to allocate device path.\n");1029 printf(NAME ": failed to allocate device path.\n"); 1036 1030 return false; 1037 1031 } … … 1064 1058 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 1065 1059 1066 log_msg(LVL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])\n",1067 dev, pfun, pfun->pathname);1068 1069 1060 /* Add the node to the handle-to-node map. */ 1070 1061 dev->handle = ++tree->current_handle; … … 1073 1064 1074 1065 /* Add the node to the list of its parent's children. */ 1066 printf("insert_dev_node: dev=%p, dev->pfun := %p\n", dev, pfun); 1075 1067 dev->pfun = pfun; 1076 1068 pfun->child = dev; … … 1173 1165 } 1174 1166 1167 /** Find function with a specified name belonging to given device. 1168 * 1169 * Device tree rwlock should be held at least for reading. 1170 * 1171 * @param dev Device the function belongs to. 1172 * @param name Function name (not path). 1173 * @return Function node. 1174 * @retval NULL No function with given name. 1175 */ 1176 fun_node_t *find_fun_node_in_device(dev_node_t *dev, const char *name) 1177 { 1178 assert(dev != NULL); 1179 assert(name != NULL); 1180 1181 fun_node_t *fun; 1182 link_t *link; 1183 1184 for (link = dev->functions.next; 1185 link != &dev->functions; 1186 link = link->next) { 1187 fun = list_get_instance(link, fun_node_t, dev_functions); 1188 1189 if (str_cmp(name, fun->name) == 0) 1190 return fun; 1191 } 1192 1193 return NULL; 1194 } 1195 1196 /** Find function node by its class name and index. */ 1197 fun_node_t *find_fun_node_by_class(class_list_t *class_list, 1198 const char *class_name, const char *dev_name) 1199 { 1200 assert(class_list != NULL); 1201 assert(class_name != NULL); 1202 assert(dev_name != NULL); 1203 1204 fibril_rwlock_read_lock(&class_list->rwlock); 1205 1206 dev_class_t *cl = find_dev_class_no_lock(class_list, class_name); 1207 if (cl == NULL) { 1208 fibril_rwlock_read_unlock(&class_list->rwlock); 1209 return NULL; 1210 } 1211 1212 dev_class_info_t *dev = find_dev_in_class(cl, dev_name); 1213 if (dev == NULL) { 1214 fibril_rwlock_read_unlock(&class_list->rwlock); 1215 return NULL; 1216 } 1217 1218 fun_node_t *fun = dev->fun; 1219 1220 fibril_rwlock_read_unlock(&class_list->rwlock); 1221 1222 return fun; 1223 } 1224 1225 1175 1226 /** Find child function node with a specified name. 1176 1227 * … … 1183 1234 fun_node_t *find_node_child(fun_node_t *pfun, const char *name) 1184 1235 { 1185 fun_node_t *fun; 1186 link_t *link; 1187 1188 link = pfun->child->functions.next; 1189 1190 while (link != &pfun->child->functions) { 1191 fun = list_get_instance(link, fun_node_t, dev_functions); 1192 1193 if (str_cmp(name, fun->name) == 0) 1194 return fun; 1195 1196 link = link->next; 1197 } 1198 1199 return NULL; 1236 return find_fun_node_in_device(pfun->child, name); 1200 1237 } 1201 1238 … … 1359 1396 } 1360 1397 1398 dev_class_info_t *find_dev_in_class(dev_class_t *dev_class, const char *dev_name) 1399 { 1400 assert(dev_class != NULL); 1401 assert(dev_name != NULL); 1402 1403 link_t *link; 1404 for (link = dev_class->devices.next; 1405 link != &dev_class->devices; 1406 link = link->next) { 1407 dev_class_info_t *dev = list_get_instance(link, 1408 dev_class_info_t, link); 1409 1410 if (str_cmp(dev->dev_name, dev_name) == 0) { 1411 return dev; 1412 } 1413 } 1414 1415 return NULL; 1416 } 1417 1361 1418 void init_class_list(class_list_t *class_list) 1362 1419 {
Note:
See TracChangeset
for help on using the changeset viewer.