Changeset 0511549 in mainline for uspace/srv/devman/client_conn.c
- Timestamp:
- 2013-09-10T23:11:34Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- de3d15b4
- Parents:
- 5df1963
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/client_conn.c
r5df1963 r0511549 317 317 } 318 318 319 320 319 /** Get handle for child device of a function. */ 321 320 static void devman_fun_get_child(ipc_callid_t iid, ipc_call_t *icall) … … 417 416 } 418 417 418 /** Get list of all registered drivers. */ 419 static void devman_get_drivers(ipc_callid_t iid, ipc_call_t *icall) 420 { 421 ipc_callid_t callid; 422 size_t size; 423 size_t act_size; 424 int rc; 425 426 if (!async_data_read_receive(&callid, &size)) { 427 async_answer_0(callid, EREFUSED); 428 async_answer_0(iid, EREFUSED); 429 return; 430 } 431 432 devman_handle_t *hdl_buf = (devman_handle_t *) malloc(size); 433 if (hdl_buf == NULL) { 434 async_answer_0(callid, ENOMEM); 435 async_answer_0(iid, ENOMEM); 436 return; 437 } 438 439 rc = driver_get_list(&drivers_list, hdl_buf, size, &act_size); 440 if (rc != EOK) { 441 async_answer_0(callid, rc); 442 async_answer_0(iid, rc); 443 return; 444 } 445 446 sysarg_t retval = async_data_read_finalize(callid, hdl_buf, size); 447 free(hdl_buf); 448 449 async_answer_1(iid, retval, act_size); 450 } 451 452 /** Get driver name. */ 453 static void devman_driver_get_name(ipc_callid_t iid, ipc_call_t *icall) 454 { 455 devman_handle_t handle = IPC_GET_ARG1(*icall); 456 457 driver_t *drv = driver_find(&drivers_list, handle); 458 if (drv == NULL) { 459 async_answer_0(iid, ENOMEM); 460 return; 461 } 462 463 ipc_callid_t data_callid; 464 size_t data_len; 465 if (!async_data_read_receive(&data_callid, &data_len)) { 466 async_answer_0(iid, EINVAL); 467 return; 468 } 469 470 void *buffer = malloc(data_len); 471 if (buffer == NULL) { 472 async_answer_0(data_callid, ENOMEM); 473 async_answer_0(iid, ENOMEM); 474 return; 475 } 476 477 fibril_mutex_lock(&drv->driver_mutex); 478 479 size_t sent_length = str_size(drv->name); 480 if (sent_length > data_len) { 481 sent_length = data_len; 482 } 483 484 async_data_read_finalize(data_callid, drv->name, sent_length); 485 async_answer_0(iid, EOK); 486 487 fibril_mutex_unlock(&drv->driver_mutex); 488 489 free(buffer); 490 } 491 419 492 /** Function for handling connections from a client to the device manager. */ 420 493 void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall) … … 441 514 break; 442 515 case DEVMAN_FUN_GET_NAME: 516 printf("devman_fun_get_name\n"); 443 517 devman_fun_get_name(callid, &call); 444 518 break; … … 457 531 case DEVMAN_FUN_SID_TO_HANDLE: 458 532 devman_fun_sid_to_handle(callid, &call); 533 break; 534 case DEVMAN_GET_DRIVERS: 535 devman_get_drivers(callid, &call); 536 break; 537 case DEVMAN_DRIVER_GET_NAME: 538 printf("devman_get_driver_name\n"); 539 devman_driver_get_name(callid, &call); 459 540 break; 460 541 default:
Note:
See TracChangeset
for help on using the changeset viewer.