Changes in uspace/lib/drv/generic/driver.c [79ae36dd:26fa82bc] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r79ae36dd r26fa82bc 285 285 async_answer_0(iid, EOK); 286 286 287 while (true) { 287 bool cont = true; 288 while (cont) { 288 289 ipc_call_t call; 289 290 ipc_callid_t callid = async_get_call(&call); 290 291 291 if (!IPC_GET_IMETHOD(call))292 break;293 294 292 switch (IPC_GET_IMETHOD(call)) { 293 case IPC_M_PHONE_HUNGUP: 294 cont = false; 295 continue; 295 296 case DRIVER_ADD_DEVICE: 296 297 driver_add_device(callid, &call); … … 302 303 } 303 304 304 /** Generic client connection handler both for applications and drivers.305 * 306 * @param drv True for driver client, false for other clients307 * (applications, services, etc.).308 * 305 /** 306 * Generic client connection handler both for applications and drivers. 307 * 308 * @param drv True for driver client, false for other clients 309 * (applications, services etc.). 309 310 */ 310 311 static void driver_connection_gen(ipc_callid_t iid, ipc_call_t *icall, bool drv) … … 316 317 devman_handle_t handle = IPC_GET_ARG2(*icall); 317 318 ddf_fun_t *fun = driver_get_function(&functions, handle); 318 319 319 320 if (fun == NULL) { 320 321 printf("%s: driver_connection_gen error - no function with handle" … … 324 325 } 325 326 327 326 328 /* 327 329 * TODO - if the client is not a driver, check whether it is allowed to … … 338 340 return; 339 341 340 while ( true) {342 while (1) { 341 343 ipc_callid_t callid; 342 344 ipc_call_t call; 343 345 callid = async_get_call(&call); 344 346 sysarg_t method = IPC_GET_IMETHOD(call); 347 int iface_idx; 345 348 346 if (!method) { 349 switch (method) { 350 case IPC_M_PHONE_HUNGUP: 347 351 /* Close device function */ 348 352 if (fun->ops != NULL && fun->ops->close != NULL) … … 350 354 async_answer_0(callid, EOK); 351 355 return; 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); 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); 363 390 break; 364 391 } 365 392 366 393 /* 367 * Function has no such interface and368 * default handler is not provided.394 * Get the corresponding interface for remote request 395 * handling ("remote interface"). 369 396 */ 370 printf("%s: driver_connection_gen error - " 371 "invalid interface id %d.", 372 driver->name, iface_idx); 373 async_answer_0(callid, ENOTSUP); 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); 374 419 break; 375 420 } 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 request391 * 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 will410 * receive parameters from the remote client and it will411 * pass it to the corresponding local interface method412 * associated with the function by its driver.413 */414 (*iface_method_ptr)(fun, ops, callid, &call);415 break;416 421 } 417 422 }
Note:
See TracChangeset
for help on using the changeset viewer.