Changeset a1a101d in mainline for uspace/srv/devman
- Timestamp:
- 2012-08-17T16:58:51Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bc0ccab
- Parents:
- 920d0fc
- Location:
- uspace/srv/devman
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r920d0fc ra1a101d 151 151 fibril_mutex_unlock(&drivers_list->drivers_mutex); 152 152 153 log_msg(L VL_NOTE, "Driver `%s' was added to the list of available "153 log_msg(LOG_DEFAULT, LVL_NOTE, "Driver `%s' was added to the list of available " 154 154 "drivers.", drv->name); 155 155 } … … 242 242 bool read_match_ids(const char *conf_path, match_id_list_t *ids) 243 243 { 244 log_msg(L VL_DEBUG, "read_match_ids(conf_path=\"%s\")", conf_path);244 log_msg(LOG_DEFAULT, LVL_DEBUG, "read_match_ids(conf_path=\"%s\")", conf_path); 245 245 246 246 bool suc = false; … … 252 252 fd = open(conf_path, O_RDONLY); 253 253 if (fd < 0) { 254 log_msg(L VL_ERROR, "Unable to open `%s' for reading: %s.",254 log_msg(LOG_DEFAULT, LVL_ERROR, "Unable to open `%s' for reading: %s.", 255 255 conf_path, str_error(fd)); 256 256 goto cleanup; … … 261 261 lseek(fd, 0, SEEK_SET); 262 262 if (len == 0) { 263 log_msg(L VL_ERROR, "Configuration file '%s' is empty.",263 log_msg(LOG_DEFAULT, LVL_ERROR, "Configuration file '%s' is empty.", 264 264 conf_path); 265 265 goto cleanup; … … 268 268 buf = malloc(len + 1); 269 269 if (buf == NULL) { 270 log_msg(L VL_ERROR, "Memory allocation failed when parsing file "270 log_msg(LOG_DEFAULT, LVL_ERROR, "Memory allocation failed when parsing file " 271 271 "'%s'.", conf_path); 272 272 goto cleanup; … … 275 275 ssize_t read_bytes = read_all(fd, buf, len); 276 276 if (read_bytes <= 0) { 277 log_msg(L VL_ERROR, "Unable to read file '%s' (%zd).", conf_path,277 log_msg(LOG_DEFAULT, LVL_ERROR, "Unable to read file '%s' (%zd).", conf_path, 278 278 read_bytes); 279 279 goto cleanup; … … 314 314 bool get_driver_info(const char *base_path, const char *name, driver_t *drv) 315 315 { 316 log_msg(L VL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")",316 log_msg(LOG_DEFAULT, LVL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")", 317 317 base_path, name); 318 318 … … 346 346 struct stat s; 347 347 if (stat(drv->binary_path, &s) == ENOENT) { /* FIXME!! */ 348 log_msg(L VL_ERROR, "Driver not found at path `%s'.",348 log_msg(LOG_DEFAULT, LVL_ERROR, "Driver not found at path `%s'.", 349 349 drv->binary_path); 350 350 goto cleanup; … … 374 374 int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path) 375 375 { 376 log_msg(L VL_DEBUG, "lookup_available_drivers(dir=\"%s\")", dir_path);376 log_msg(LOG_DEFAULT, LVL_DEBUG, "lookup_available_drivers(dir=\"%s\")", dir_path); 377 377 378 378 int drv_cnt = 0; … … 408 408 dev_node_t *dev; 409 409 410 log_msg(L VL_DEBUG, "create_root_nodes()");410 log_msg(LOG_DEFAULT, LVL_DEBUG, "create_root_nodes()"); 411 411 412 412 fibril_rwlock_write_lock(&tree->rwlock); … … 495 495 void attach_driver(dev_tree_t *tree, dev_node_t *dev, driver_t *drv) 496 496 { 497 log_msg(L VL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")",497 log_msg(LOG_DEFAULT, LVL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")", 498 498 dev->pfun->pathname, drv->name); 499 499 … … 520 520 assert(drv != NULL); 521 521 522 log_msg(L VL_DEBUG, "detach_driver(dev=\"%s\",drv=\"%s\")",522 log_msg(LOG_DEFAULT, LVL_DEBUG, "detach_driver(dev=\"%s\",drv=\"%s\")", 523 523 dev->pfun->pathname, drv->name); 524 524 … … 545 545 assert(fibril_mutex_is_locked(&drv->driver_mutex)); 546 546 547 log_msg(L VL_DEBUG, "start_driver(drv=\"%s\")", drv->name);547 log_msg(LOG_DEFAULT, LVL_DEBUG, "start_driver(drv=\"%s\")", drv->name); 548 548 549 549 rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL); 550 550 if (rc != EOK) { 551 log_msg(L VL_ERROR, "Spawning driver `%s' (%s) failed: %s.",551 log_msg(LOG_DEFAULT, LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.", 552 552 drv->name, drv->binary_path, str_error(rc)); 553 553 return false; … … 594 594 link_t *link; 595 595 596 log_msg(L VL_DEBUG, "pass_devices_to_driver(driver=\"%s\")",596 log_msg(LOG_DEFAULT, LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")", 597 597 driver->name); 598 598 … … 614 614 } 615 615 616 log_msg(L VL_DEBUG, "pass_devices_to_driver: dev->refcnt=%d\n",616 log_msg(LOG_DEFAULT, LVL_DEBUG, "pass_devices_to_driver: dev->refcnt=%d\n", 617 617 (int)atomic_get(&dev->refcnt)); 618 618 dev_add_ref(dev); … … 650 650 * immediately and possibly started here as well. 651 651 */ 652 log_msg(L VL_DEBUG, "Driver `%s' enters running state.", driver->name);652 log_msg(LOG_DEFAULT, LVL_DEBUG, "Driver `%s' enters running state.", driver->name); 653 653 driver->state = DRIVER_RUNNING; 654 654 … … 667 667 void initialize_running_driver(driver_t *driver, dev_tree_t *tree) 668 668 { 669 log_msg(L VL_DEBUG, "initialize_running_driver(driver=\"%s\")",669 log_msg(LOG_DEFAULT, LVL_DEBUG, "initialize_running_driver(driver=\"%s\")", 670 670 driver->name); 671 671 … … 761 761 * access any structures that would affect driver_t. 762 762 */ 763 log_msg(L VL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")",763 log_msg(LOG_DEFAULT, LVL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")", 764 764 drv->name, dev->pfun->name); 765 765 … … 827 827 driver_t *drv = find_best_match_driver(drivers_list, dev); 828 828 if (drv == NULL) { 829 log_msg(L VL_ERROR, "No driver found for device `%s'.",829 log_msg(LOG_DEFAULT, LVL_ERROR, "No driver found for device `%s'.", 830 830 dev->pfun->pathname); 831 831 return false; … … 867 867 assert(dev != NULL); 868 868 869 log_msg(L VL_DEBUG, "driver_dev_remove(%p)", dev);869 log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_dev_remove(%p)", dev); 870 870 871 871 fibril_rwlock_read_lock(&tree->rwlock); … … 890 890 assert(dev != NULL); 891 891 892 log_msg(L VL_DEBUG, "driver_dev_gone(%p)", dev);892 log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_dev_gone(%p)", dev); 893 893 894 894 fibril_rwlock_read_lock(&tree->rwlock); … … 911 911 devman_handle_t handle; 912 912 913 log_msg(L VL_DEBUG, "driver_fun_online(%p)", fun);913 log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_fun_online(%p)", fun); 914 914 915 915 fibril_rwlock_read_lock(&tree->rwlock); … … 939 939 devman_handle_t handle; 940 940 941 log_msg(L VL_DEBUG, "driver_fun_offline(%p)", fun);941 log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_fun_offline(%p)", fun); 942 942 943 943 fibril_rwlock_read_lock(&tree->rwlock); … … 970 970 bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list) 971 971 { 972 log_msg(L VL_DEBUG, "init_device_tree()");972 log_msg(LOG_DEFAULT, LVL_DEBUG, "init_device_tree()"); 973 973 974 974 tree->current_handle = 0; … … 1261 1261 fun->pathname = (char *) malloc(pathsize); 1262 1262 if (fun->pathname == NULL) { 1263 log_msg(L VL_ERROR, "Failed to allocate device path.");1263 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to allocate device path."); 1264 1264 return false; 1265 1265 } … … 1289 1289 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 1290 1290 1291 log_msg(L VL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])",1291 log_msg(LOG_DEFAULT, LVL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])", 1292 1292 dev, pfun, pfun->pathname); 1293 1293 … … 1313 1313 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 1314 1314 1315 log_msg(L VL_DEBUG, "remove_dev_node(dev=%p)", dev);1315 log_msg(LOG_DEFAULT, LVL_DEBUG, "remove_dev_node(dev=%p)", dev); 1316 1316 1317 1317 /* Remove node from the handle-to-node map. */ -
uspace/srv/devman/main.c
r920d0fc ra1a101d 73 73 char *drv_name = NULL; 74 74 75 log_msg(L VL_DEBUG, "devman_driver_register");75 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_driver_register"); 76 76 77 77 /* Get driver name. */ … … 82 82 } 83 83 84 log_msg(L VL_DEBUG, "The `%s' driver is trying to register.",84 log_msg(LOG_DEFAULT, LVL_DEBUG, "The `%s' driver is trying to register.", 85 85 drv_name); 86 86 … … 88 88 driver = find_driver(&drivers_list, drv_name); 89 89 if (driver == NULL) { 90 log_msg(L VL_ERROR, "No driver named `%s' was found.", drv_name);90 log_msg(LOG_DEFAULT, LVL_ERROR, "No driver named `%s' was found.", drv_name); 91 91 free(drv_name); 92 92 drv_name = NULL; … … 102 102 if (driver->sess) { 103 103 /* We already have a connection to the driver. */ 104 log_msg(L VL_ERROR, "Driver '%s' already started.\n",104 log_msg(LOG_DEFAULT, LVL_ERROR, "Driver '%s' already started.\n", 105 105 driver->name); 106 106 fibril_mutex_unlock(&driver->driver_mutex); … … 112 112 case DRIVER_NOT_STARTED: 113 113 /* Somebody started the driver manually. */ 114 log_msg(L VL_NOTE, "Driver '%s' started manually.\n",114 log_msg(LOG_DEFAULT, LVL_NOTE, "Driver '%s' started manually.\n", 115 115 driver->name); 116 116 driver->state = DRIVER_STARTING; … … 125 125 126 126 /* Create connection to the driver. */ 127 log_msg(L VL_DEBUG, "Creating connection to the `%s' driver.",127 log_msg(LOG_DEFAULT, LVL_DEBUG, "Creating connection to the `%s' driver.", 128 128 driver->name); 129 129 driver->sess = async_callback_receive(EXCHANGE_PARALLEL); … … 136 136 async_sess_args_set(driver->sess, DRIVER_DEVMAN, 0, 0); 137 137 138 log_msg(L VL_NOTE,138 log_msg(LOG_DEFAULT, LVL_NOTE, 139 139 "The `%s' driver was successfully registered as running.", 140 140 driver->name); … … 147 147 fid_t fid = fibril_create(init_running_drv, driver); 148 148 if (fid == 0) { 149 log_msg(L VL_ERROR, "Failed to create initialization fibril " \149 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to create initialization fibril " \ 150 150 "for driver `%s'.", driver->name); 151 151 fibril_mutex_unlock(&driver->driver_mutex); … … 176 176 callid = async_get_call(&call); 177 177 if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) { 178 log_msg(L VL_ERROR,178 log_msg(LOG_DEFAULT, LVL_ERROR, 179 179 "Invalid protocol when trying to receive match id."); 180 180 async_answer_0(callid, EINVAL); … … 184 184 185 185 if (match_id == NULL) { 186 log_msg(L VL_ERROR, "Failed to allocate match id.");186 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to allocate match id."); 187 187 async_answer_0(callid, ENOMEM); 188 188 return ENOMEM; … … 198 198 if (rc != EOK) { 199 199 delete_match_id(match_id); 200 log_msg(L VL_ERROR, "Failed to receive match id string: %s.",200 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to receive match id string: %s.", 201 201 str_error(rc)); 202 202 return rc; … … 205 205 list_append(&match_id->link, &match_ids->ids); 206 206 207 log_msg(L VL_DEBUG, "Received match id `%s', score %d.",207 log_msg(LOG_DEFAULT, LVL_DEBUG, "Received match id `%s', score %d.", 208 208 match_id->id, match_id->score); 209 209 return rc; … … 248 248 if (fun->state == FUN_ON_LINE) { 249 249 fibril_rwlock_write_unlock(&device_tree.rwlock); 250 log_msg(L VL_WARN, "Function %s is already on line.",250 log_msg(LOG_DEFAULT, LVL_WARN, "Function %s is already on line.", 251 251 fun->pathname); 252 252 return EOK; … … 264 264 } 265 265 266 log_msg(L VL_DEBUG, "devman_add_function(fun=\"%s\")", fun->pathname);266 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_add_function(fun=\"%s\")", fun->pathname); 267 267 268 268 if (fun->ftype == fun_inner) { … … 282 282 fid_t assign_fibril = fibril_create(assign_driver_fibril, dev); 283 283 if (assign_fibril == 0) { 284 log_msg(L VL_ERROR, "Failed to create fibril for "284 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to create fibril for " 285 285 "assigning driver."); 286 286 /* XXX Cleanup */ … … 305 305 if (fun->state == FUN_OFF_LINE) { 306 306 fibril_rwlock_write_unlock(&device_tree.rwlock); 307 log_msg(L VL_WARN, "Function %s is already off line.",307 log_msg(LOG_DEFAULT, LVL_WARN, "Function %s is already off line.", 308 308 fun->pathname); 309 309 return EOK; … … 311 311 312 312 if (fun->ftype == fun_inner) { 313 log_msg(L VL_DEBUG, "Offlining inner function %s.",313 log_msg(LOG_DEFAULT, LVL_DEBUG, "Offlining inner function %s.", 314 314 fun->pathname); 315 315 … … 359 359 if (rc != EOK) { 360 360 fibril_rwlock_write_unlock(&device_tree.rwlock); 361 log_msg(L VL_ERROR, "Failed unregistering tree service.");361 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed unregistering tree service."); 362 362 return EIO; 363 363 } … … 391 391 if (ftype != fun_inner && ftype != fun_exposed) { 392 392 /* Unknown function type */ 393 log_msg(L VL_ERROR,393 log_msg(LOG_DEFAULT, LVL_ERROR, 394 394 "Unknown function type %d provided by driver.", 395 395 (int) ftype); … … 507 507 if (rc == EOK) { 508 508 loc_service_add_to_cat(fun->service_id, cat_id); 509 log_msg(L VL_NOTE, "Function `%s' added to category `%s'.",509 log_msg(LOG_DEFAULT, LVL_NOTE, "Function `%s' added to category `%s'.", 510 510 fun->pathname, cat_name); 511 511 } else { 512 log_msg(L VL_ERROR, "Failed adding function `%s' to category "512 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed adding function `%s' to category " 513 513 "`%s'.", fun->pathname, cat_name); 514 514 } … … 529 529 int rc; 530 530 531 log_msg(L VL_DEBUG, "devman_drv_fun_online()");531 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_drv_fun_online()"); 532 532 533 533 fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall)); … … 620 620 fibril_rwlock_write_lock(&tree->rwlock); 621 621 622 log_msg(L VL_DEBUG, "devman_remove_function(fun='%s')", fun->pathname);622 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_remove_function(fun='%s')", fun->pathname); 623 623 624 624 /* Check function state */ … … 653 653 /* Verify that driver succeeded and removed all functions */ 654 654 if (gone_rc != EOK || !list_empty(&dev->functions)) { 655 log_msg(L VL_ERROR, "Driver did not remove "655 log_msg(LOG_DEFAULT, LVL_ERROR, "Driver did not remove " 656 656 "functions for device that is gone. " 657 657 "Device node is now defunct."); … … 692 692 rc = loc_service_unregister(fun->service_id); 693 693 if (rc != EOK) { 694 log_msg(L VL_ERROR, "Failed unregistering tree "694 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed unregistering tree " 695 695 "service."); 696 696 fibril_rwlock_write_unlock(&tree->rwlock); … … 712 712 fun_del_ref(fun); 713 713 714 log_msg(L VL_DEBUG, "devman_remove_function() succeeded.");714 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_remove_function() succeeded."); 715 715 async_answer_0(callid, EOK); 716 716 } … … 726 726 727 727 initialize_running_driver(driver, &device_tree); 728 log_msg(L VL_DEBUG, "The `%s` driver was successfully initialized.",728 log_msg(LOG_DEFAULT, LVL_DEBUG, "The `%s` driver was successfully initialized.", 729 729 driver->name); 730 730 return 0; … … 742 742 client = async_get_client_data(); 743 743 if (client == NULL) { 744 log_msg(L VL_ERROR, "Failed to allocate client data.");744 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to allocate client data."); 745 745 return; 746 746 } … … 1229 1229 */ 1230 1230 if (dev == NULL) { 1231 log_msg(L VL_ERROR, "IPC forwarding failed - no device or "1231 log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding failed - no device or " 1232 1232 "function with handle %" PRIun " was found.", handle); 1233 1233 async_answer_0(iid, ENOENT); … … 1236 1236 1237 1237 if (fun == NULL && !drv_to_parent) { 1238 log_msg(L VL_ERROR, NAME ": devman_forward error - cannot "1238 log_msg(LOG_DEFAULT, LVL_ERROR, NAME ": devman_forward error - cannot " 1239 1239 "connect to handle %" PRIun ", refers to a device.", 1240 1240 handle); … … 1264 1264 1265 1265 if (driver == NULL) { 1266 log_msg(L VL_ERROR, "IPC forwarding refused - " \1266 log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding refused - " \ 1267 1267 "the device %" PRIun " is not in usable state.", handle); 1268 1268 async_answer_0(iid, ENOENT); … … 1277 1277 1278 1278 if (!driver->sess) { 1279 log_msg(L VL_ERROR,1279 log_msg(LOG_DEFAULT, LVL_ERROR, 1280 1280 "Could not forward to driver `%s'.", driver->name); 1281 1281 async_answer_0(iid, EINVAL); … … 1284 1284 1285 1285 if (fun != NULL) { 1286 log_msg(L VL_DEBUG,1286 log_msg(LOG_DEFAULT, LVL_DEBUG, 1287 1287 "Forwarding request for `%s' function to driver `%s'.", 1288 1288 fun->pathname, driver->name); 1289 1289 } else { 1290 log_msg(L VL_DEBUG,1290 log_msg(LOG_DEFAULT, LVL_DEBUG, 1291 1291 "Forwarding request for `%s' device to driver `%s'.", 1292 1292 dev->pfun->pathname, driver->name); … … 1320 1320 1321 1321 if (fun == NULL || fun->dev == NULL || fun->dev->drv == NULL) { 1322 log_msg(L VL_WARN, "devman_connection_loc(): function "1322 log_msg(LOG_DEFAULT, LVL_WARN, "devman_connection_loc(): function " 1323 1323 "not found.\n"); 1324 1324 fibril_rwlock_read_unlock(&device_tree.rwlock); … … 1338 1338 async_exchange_end(exch); 1339 1339 1340 log_msg(L VL_DEBUG,1340 log_msg(LOG_DEFAULT, LVL_DEBUG, 1341 1341 "Forwarding loc service request for `%s' function to driver `%s'.", 1342 1342 fun->pathname, driver->name); … … 1394 1394 static bool devman_init(void) 1395 1395 { 1396 log_msg(L VL_DEBUG, "devman_init - looking for available drivers.");1396 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_init - looking for available drivers."); 1397 1397 1398 1398 /* Initialize list of available drivers. */ … … 1400 1400 if (lookup_available_drivers(&drivers_list, 1401 1401 DRIVER_DEFAULT_STORE) == 0) { 1402 log_msg(L VL_FATAL, "No drivers found.");1402 log_msg(LOG_DEFAULT, LVL_FATAL, "No drivers found."); 1403 1403 return false; 1404 1404 } 1405 1405 1406 log_msg(L VL_DEBUG, "devman_init - list of drivers has been initialized.");1406 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_init - list of drivers has been initialized."); 1407 1407 1408 1408 /* Create root device node. */ 1409 1409 if (!init_device_tree(&device_tree, &drivers_list)) { 1410 log_msg(L VL_FATAL, "Failed to initialize device tree.");1410 log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to initialize device tree."); 1411 1411 return false; 1412 1412 } … … 1440 1440 1441 1441 if (!devman_init()) { 1442 log_msg(L VL_ERROR, "Error while initializing service.");1442 log_msg(LOG_DEFAULT, LVL_ERROR, "Error while initializing service."); 1443 1443 return -1; 1444 1444 } … … 1447 1447 rc = service_register(SERVICE_DEVMAN); 1448 1448 if (rc != EOK) { 1449 log_msg(L VL_ERROR, "Failed registering as a service.");1449 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering as a service."); 1450 1450 return rc; 1451 1451 }
Note:
See TracChangeset
for help on using the changeset viewer.
