Changeset 7969087 in mainline
- Timestamp:
- 2013-09-11T10:35:49Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 43dd8028
- Parents:
- e5556e4a
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/devctl/devctl.c
re5556e4a r7969087 199 199 } 200 200 201 static int drv_load(const char *drvname) 202 { 203 int rc; 204 devman_handle_t drvh; 205 206 rc = devman_driver_get_handle(drvname, &drvh); 207 if (rc != EOK) { 208 printf("Failed resolving driver '%s' (%d).\n", drvname, rc); 209 return rc; 210 } 211 212 rc = devman_driver_load(drvh); 213 if (rc != EOK) { 214 printf("Failed loading driver '%s' (%d).\n", drvname, rc); 215 return rc; 216 } 217 218 return EOK; 219 } 220 201 221 static void print_syntax(void) 202 222 { … … 206 226 printf("\tdevctl offline <function>]\n"); 207 227 printf("\tdevctl list-drv\n"); 228 printf("\tdevctl load-drv <driver-name>\n"); 208 229 } 209 230 … … 242 263 if (rc != EOK) 243 264 return 2; 265 } else if (str_cmp(argv[1], "load-drv") == 0) { 266 if (argc < 3) { 267 printf(NAME ": Argument missing.\n"); 268 print_syntax(); 269 return 1; 270 } 271 272 rc = drv_load(argv[2]); 273 if (rc != EOK) 274 return 2; 244 275 } else { 245 276 printf(NAME ": Invalid argument '%s'.\n", argv[1]); -
uspace/lib/c/generic/devman.c
re5556e4a r7969087 598 598 } 599 599 600 int devman_driver_get_handle(const char *drvname, devman_handle_t *handle) 601 { 602 async_exch_t *exch; 603 604 exch = devman_exchange_begin(DEVMAN_CLIENT); 605 if (exch == NULL) 606 return ENOMEM; 607 608 ipc_call_t answer; 609 aid_t req = async_send_0(exch, DEVMAN_DRIVER_GET_HANDLE, &answer); 610 sysarg_t retval = async_data_write_start(exch, drvname, 611 str_size(drvname)); 612 613 devman_exchange_end(exch); 614 615 if (retval != EOK) { 616 async_forget(req); 617 return retval; 618 } 619 620 async_wait_for(req, &retval); 621 622 if (retval != EOK) { 623 if (handle != NULL) 624 *handle = (devman_handle_t) -1; 625 626 return retval; 627 } 628 629 if (handle != NULL) 630 *handle = (devman_handle_t) IPC_GET_ARG1(answer); 631 632 return retval; 633 } 634 600 635 int devman_driver_get_name(devman_handle_t handle, char *buf, size_t buf_size) 601 636 { … … 622 657 } 623 658 659 int devman_driver_load(devman_handle_t drvh) 660 { 661 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 662 if (exch == NULL) 663 return ENOMEM; 664 665 int rc = async_req_1_0(exch, DEVMAN_DRIVER_LOAD, drvh); 666 667 devman_exchange_end(exch); 668 return rc; 669 } 670 624 671 /** @} 625 672 */ -
uspace/lib/c/include/devman.h
re5556e4a r7969087 72 72 extern int devman_fun_sid_to_handle(service_id_t, devman_handle_t *); 73 73 extern int devman_get_drivers(devman_handle_t **, size_t *); 74 extern int devman_driver_get_handle(const char *, devman_handle_t *); 74 75 extern int devman_driver_get_name(devman_handle_t, char *, size_t); 75 76 extern int devman_driver_get_state(devman_handle_t, driver_state_t *); 77 extern int devman_driver_load(devman_handle_t); 76 78 77 79 #endif -
uspace/lib/c/include/ipc/devman.h
re5556e4a r7969087 177 177 DEVMAN_FUN_SID_TO_HANDLE, 178 178 DEVMAN_GET_DRIVERS, 179 DEVMAN_DRIVER_GET_HANDLE, 179 180 DEVMAN_DRIVER_GET_NAME, 180 DEVMAN_DRIVER_GET_STATE 181 DEVMAN_DRIVER_GET_STATE, 182 DEVMAN_DRIVER_LOAD 181 183 } client_to_devman_t; 182 184 -
uspace/srv/devman/client_conn.c
re5556e4a r7969087 450 450 } 451 451 452 /** Find driver by name. */ 453 static void devman_driver_get_handle(ipc_callid_t iid, ipc_call_t *icall) 454 { 455 char *drvname; 456 457 int rc = async_data_write_accept((void **) &drvname, true, 0, 0, 0, 0); 458 if (rc != EOK) { 459 async_answer_0(iid, rc); 460 return; 461 } 462 463 driver_t *driver = driver_find_by_name(&drivers_list, drvname); 464 465 free(drvname); 466 467 if (driver == NULL) { 468 async_answer_0(iid, ENOENT); 469 return; 470 } 471 472 async_answer_1(iid, EOK, driver->handle); 473 } 474 452 475 /** Get driver name. */ 453 476 static void devman_driver_get_name(ipc_callid_t iid, ipc_call_t *icall) … … 502 525 503 526 async_answer_1(iid, EOK, (sysarg_t) drv->state); 527 } 528 529 /** Forcibly load a driver. */ 530 static void devman_driver_load(ipc_callid_t iid, ipc_call_t *icall) 531 { 532 driver_t *drv; 533 int rc; 534 535 drv = driver_find(&drivers_list, IPC_GET_ARG1(*icall)); 536 if (drv == NULL) { 537 async_answer_0(iid, ENOENT); 538 return; 539 } 540 541 fibril_mutex_lock(&drv->driver_mutex); 542 rc = start_driver(drv) ? EOK : EIO; 543 fibril_mutex_unlock(&drv->driver_mutex); 544 545 async_answer_0(iid, rc); 504 546 } 505 547 … … 548 590 devman_get_drivers(callid, &call); 549 591 break; 592 case DEVMAN_DRIVER_GET_HANDLE: 593 devman_driver_get_handle(callid, &call); 594 break; 550 595 case DEVMAN_DRIVER_GET_NAME: 551 596 devman_driver_get_name(callid, &call); … … 553 598 case DEVMAN_DRIVER_GET_STATE: 554 599 devman_driver_get_state(callid, &call); 600 break; 601 case DEVMAN_DRIVER_LOAD: 602 devman_driver_load(callid, &call); 555 603 break; 556 604 default:
Note:
See TracChangeset
for help on using the changeset viewer.