Changes in uspace/lib/drv/generic/driver.c [26fa82bc:79ae36dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r26fa82bc r79ae36dd 285 285 async_answer_0(iid, EOK); 286 286 287 bool cont = true; 288 while (cont) { 287 while (true) { 289 288 ipc_call_t call; 290 289 ipc_callid_t callid = async_get_call(&call); 291 290 291 if (!IPC_GET_IMETHOD(call)) 292 break; 293 292 294 switch (IPC_GET_IMETHOD(call)) { 293 case IPC_M_PHONE_HUNGUP:294 cont = false;295 continue;296 295 case DRIVER_ADD_DEVICE: 297 296 driver_add_device(callid, &call); … … 303 302 } 304 303 305 /** 306 * Generic client connection handler both for applications and drivers.307 * 308 * @param drv True for driver client, false for other clients309 * (applications, services etc.).304 /** Generic client connection handler both for applications and drivers. 305 * 306 * @param drv True for driver client, false for other clients 307 * (applications, services, etc.). 308 * 310 309 */ 311 310 static void driver_connection_gen(ipc_callid_t iid, ipc_call_t *icall, bool drv) … … 317 316 devman_handle_t handle = IPC_GET_ARG2(*icall); 318 317 ddf_fun_t *fun = driver_get_function(&functions, handle); 319 318 320 319 if (fun == NULL) { 321 320 printf("%s: driver_connection_gen error - no function with handle" … … 325 324 } 326 325 327 328 326 /* 329 327 * TODO - if the client is not a driver, check whether it is allowed to … … 340 338 return; 341 339 342 while ( 1) {340 while (true) { 343 341 ipc_callid_t callid; 344 342 ipc_call_t call; 345 343 callid = async_get_call(&call); 346 344 sysarg_t method = IPC_GET_IMETHOD(call); 347 int iface_idx; 348 349 switch (method) { 350 case IPC_M_PHONE_HUNGUP: 345 346 if (!method) { 351 347 /* Close device function */ 352 348 if (fun->ops != NULL && fun->ops->close != NULL) … … 354 350 async_answer_0(callid, EOK); 355 351 return; 356 default: 357 /* convert ipc interface id to interface index */ 358 359 iface_idx = DEV_IFACE_IDX(method); 360 361 if (!is_valid_iface_idx(iface_idx)) { 362 remote_handler_t *default_handler = 363 function_get_default_handler(fun); 364 if (default_handler != NULL) { 365 (*default_handler)(fun, callid, &call); 366 break; 367 } 368 369 /* 370 * Function has no such interface and 371 * default handler is not provided. 372 */ 373 printf("%s: driver_connection_gen error - " 374 "invalid interface id %d.", 375 driver->name, iface_idx); 376 async_answer_0(callid, ENOTSUP); 377 break; 378 } 379 380 /* calling one of the function's interfaces */ 381 382 /* Get the interface ops structure. */ 383 void *ops = function_get_ops(fun, iface_idx); 384 if (ops == NULL) { 385 printf("%s: driver_connection_gen error - ", 386 driver->name); 387 printf("Function with handle %" PRIun " has no interface " 388 "with id %d.\n", handle, iface_idx); 389 async_answer_0(callid, ENOTSUP); 352 } 353 354 /* Convert ipc interface id to interface index */ 355 356 int iface_idx = DEV_IFACE_IDX(method); 357 358 if (!is_valid_iface_idx(iface_idx)) { 359 remote_handler_t *default_handler = 360 function_get_default_handler(fun); 361 if (default_handler != NULL) { 362 (*default_handler)(fun, callid, &call); 390 363 break; 391 364 } 392 365 393 366 /* 394 * Get the corresponding interface for remote request395 * handling ("remote interface").367 * Function has no such interface and 368 * default handler is not provided. 396 369 */ 397 remote_iface_t *rem_iface = get_remote_iface(iface_idx); 398 assert(rem_iface != NULL); 399 400 /* get the method of the remote interface */ 401 sysarg_t iface_method_idx = IPC_GET_ARG1(call); 402 remote_iface_func_ptr_t iface_method_ptr = 403 get_remote_method(rem_iface, iface_method_idx); 404 if (iface_method_ptr == NULL) { 405 /* The interface has not such method */ 406 printf("%s: driver_connection_gen error - " 407 "invalid interface method.", driver->name); 408 async_answer_0(callid, ENOTSUP); 409 break; 410 } 411 412 /* 413 * Call the remote interface's method, which will 414 * receive parameters from the remote client and it will 415 * pass it to the corresponding local interface method 416 * associated with the function by its driver. 417 */ 418 (*iface_method_ptr)(fun, ops, callid, &call); 370 printf("%s: driver_connection_gen error - " 371 "invalid interface id %d.", 372 driver->name, iface_idx); 373 async_answer_0(callid, ENOTSUP); 419 374 break; 420 375 } 376 377 /* Calling one of the function's interfaces */ 378 379 /* Get the interface ops structure. */ 380 void *ops = function_get_ops(fun, iface_idx); 381 if (ops == NULL) { 382 printf("%s: driver_connection_gen error - ", driver->name); 383 printf("Function with handle %" PRIun " has no interface " 384 "with id %d.\n", handle, iface_idx); 385 async_answer_0(callid, ENOTSUP); 386 break; 387 } 388 389 /* 390 * Get the corresponding interface for remote request 391 * handling ("remote interface"). 392 */ 393 remote_iface_t *rem_iface = get_remote_iface(iface_idx); 394 assert(rem_iface != NULL); 395 396 /* get the method of the remote interface */ 397 sysarg_t iface_method_idx = IPC_GET_ARG1(call); 398 remote_iface_func_ptr_t iface_method_ptr = 399 get_remote_method(rem_iface, iface_method_idx); 400 if (iface_method_ptr == NULL) { 401 /* The interface has not such method */ 402 printf("%s: driver_connection_gen error - " 403 "invalid interface method.", driver->name); 404 async_answer_0(callid, ENOTSUP); 405 break; 406 } 407 408 /* 409 * Call the remote interface's method, which will 410 * receive parameters from the remote client and it will 411 * pass it to the corresponding local interface method 412 * associated with the function by its driver. 413 */ 414 (*iface_method_ptr)(fun, ops, callid, &call); 415 break; 421 416 } 422 417 }
Note:
See TracChangeset
for help on using the changeset viewer.