Changeset a35b458 in mainline for uspace/lib/drv
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- uspace/lib/drv
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r3061bc1 ra35b458 97 97 { 98 98 assert(fibril_mutex_is_locked(&devices_mutex)); 99 99 100 100 list_foreach(devices, link, ddf_dev_t, dev) { 101 101 if (dev->handle == handle) 102 102 return dev; 103 103 } 104 104 105 105 return NULL; 106 106 } … … 109 109 { 110 110 assert(fibril_mutex_is_locked(&functions_mutex)); 111 111 112 112 list_foreach(functions, link, ddf_fun_t, fun) { 113 113 if (fun->handle == handle) 114 114 return fun; 115 115 } 116 116 117 117 return NULL; 118 118 } … … 122 122 devman_handle_t dev_handle = IPC_GET_ARG1(*icall); 123 123 devman_handle_t parent_fun_handle = IPC_GET_ARG2(*icall); 124 124 125 125 char *dev_name = NULL; 126 126 errno_t rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0); … … 129 129 return; 130 130 } 131 131 132 132 fibril_rwlock_read_lock(&stopping_lock); 133 133 … … 137 137 return; 138 138 } 139 139 140 140 ddf_dev_t *dev = create_device(); 141 141 if (!dev) { … … 145 145 return; 146 146 } 147 147 148 148 /* Add one reference that will be dropped by driver_dev_remove() */ 149 149 dev_add_ref(dev); 150 150 dev->handle = dev_handle; 151 151 dev->name = dev_name; 152 152 153 153 /* 154 154 * Currently not used, parent fun handle is stored in context … … 156 156 */ 157 157 (void) parent_fun_handle; 158 158 159 159 errno_t res = driver->driver_ops->dev_add(dev); 160 160 161 161 if (res != EOK) { 162 162 fibril_rwlock_read_unlock(&stopping_lock); … … 165 165 return; 166 166 } 167 167 168 168 fibril_mutex_lock(&devices_mutex); 169 169 list_append(&dev->link, &devices); 170 170 fibril_mutex_unlock(&devices_mutex); 171 171 fibril_rwlock_read_unlock(&stopping_lock); 172 172 173 173 async_answer_0(iid, res); 174 174 } … … 177 177 { 178 178 devman_handle_t devh = IPC_GET_ARG1(*icall); 179 179 180 180 fibril_mutex_lock(&devices_mutex); 181 181 ddf_dev_t *dev = driver_get_device(devh); … … 183 183 dev_add_ref(dev); 184 184 fibril_mutex_unlock(&devices_mutex); 185 185 186 186 if (dev == NULL) { 187 187 async_answer_0(iid, ENOENT); 188 188 return; 189 189 } 190 190 191 191 errno_t rc; 192 192 193 193 if (driver->driver_ops->dev_remove != NULL) 194 194 rc = driver->driver_ops->dev_remove(dev); 195 195 else 196 196 rc = ENOTSUP; 197 197 198 198 if (rc == EOK) { 199 199 fibril_mutex_lock(&devices_mutex); … … 202 202 dev_del_ref(dev); 203 203 } 204 204 205 205 dev_del_ref(dev); 206 206 async_answer_0(iid, rc); … … 210 210 { 211 211 devman_handle_t devh = IPC_GET_ARG1(*icall); 212 212 213 213 fibril_mutex_lock(&devices_mutex); 214 214 ddf_dev_t *dev = driver_get_device(devh); … … 216 216 dev_add_ref(dev); 217 217 fibril_mutex_unlock(&devices_mutex); 218 218 219 219 if (dev == NULL) { 220 220 async_answer_0(iid, ENOENT); 221 221 return; 222 222 } 223 223 224 224 errno_t rc; 225 225 226 226 if (driver->driver_ops->dev_gone != NULL) 227 227 rc = driver->driver_ops->dev_gone(dev); 228 228 else 229 229 rc = ENOTSUP; 230 230 231 231 if (rc == EOK) { 232 232 fibril_mutex_lock(&devices_mutex); … … 235 235 dev_del_ref(dev); 236 236 } 237 237 238 238 dev_del_ref(dev); 239 239 async_answer_0(iid, rc); … … 243 243 { 244 244 devman_handle_t funh = IPC_GET_ARG1(*icall); 245 245 246 246 /* 247 247 * Look the function up. Bump reference count so that … … 250 250 */ 251 251 fibril_mutex_lock(&functions_mutex); 252 252 253 253 ddf_fun_t *fun = driver_get_function(funh); 254 254 if (fun != NULL) 255 255 fun_add_ref(fun); 256 256 257 257 fibril_mutex_unlock(&functions_mutex); 258 258 259 259 if (fun == NULL) { 260 260 async_answer_0(iid, ENOENT); 261 261 return; 262 262 } 263 263 264 264 /* Call driver entry point */ 265 265 errno_t rc; 266 266 267 267 if (driver->driver_ops->fun_online != NULL) 268 268 rc = driver->driver_ops->fun_online(fun); 269 269 else 270 270 rc = ENOTSUP; 271 271 272 272 fun_del_ref(fun); 273 273 274 274 async_answer_0(iid, rc); 275 275 } … … 278 278 { 279 279 devman_handle_t funh = IPC_GET_ARG1(*icall); 280 280 281 281 /* 282 282 * Look the function up. Bump reference count so that … … 285 285 */ 286 286 fibril_mutex_lock(&functions_mutex); 287 287 288 288 ddf_fun_t *fun = driver_get_function(funh); 289 289 if (fun != NULL) 290 290 fun_add_ref(fun); 291 291 292 292 fibril_mutex_unlock(&functions_mutex); 293 293 294 294 if (fun == NULL) { 295 295 async_answer_0(iid, ENOENT); 296 296 return; 297 297 } 298 298 299 299 /* Call driver entry point */ 300 300 errno_t rc; 301 301 302 302 if (driver->driver_ops->fun_offline != NULL) 303 303 rc = driver->driver_ops->fun_offline(fun); 304 304 else 305 305 rc = ENOTSUP; 306 306 307 307 async_answer_0(iid, rc); 308 308 } … … 342 342 /* Accept connection */ 343 343 async_answer_0(iid, EOK); 344 344 345 345 while (true) { 346 346 ipc_call_t call; 347 347 ipc_callid_t callid = async_get_call(&call); 348 348 349 349 if (!IPC_GET_IMETHOD(call)) 350 350 break; 351 351 352 352 switch (IPC_GET_IMETHOD(call)) { 353 353 case DRIVER_DEV_ADD: … … 394 394 fun_add_ref(fun); 395 395 fibril_mutex_unlock(&functions_mutex); 396 396 397 397 if (fun == NULL) { 398 398 printf("%s: driver_connection_gen error - no function with handle" … … 401 401 return; 402 402 } 403 403 404 404 if (fun->conn_handler != NULL) { 405 405 /* Driver has a custom connection handler. */ … … 408 408 return; 409 409 } 410 410 411 411 /* 412 412 * TODO - if the client is not a driver, check whether it is allowed to 413 413 * use the device. 414 414 */ 415 415 416 416 errno_t ret = EOK; 417 417 /* Open device function */ 418 418 if (fun->ops != NULL && fun->ops->open != NULL) 419 419 ret = (*fun->ops->open)(fun); 420 420 421 421 async_answer_0(iid, ret); 422 422 if (ret != EOK) { … … 424 424 return; 425 425 } 426 426 427 427 while (true) { 428 428 ipc_callid_t callid; … … 430 430 callid = async_get_call(&call); 431 431 sysarg_t method = IPC_GET_IMETHOD(call); 432 432 433 433 if (!method) { 434 434 /* Close device function */ … … 439 439 return; 440 440 } 441 441 442 442 /* Convert ipc interface id to interface index */ 443 443 444 444 int iface_idx = DEV_IFACE_IDX(method); 445 445 446 446 if (!is_valid_iface_idx(iface_idx)) { 447 447 remote_handler_t *default_handler = … … 451 451 continue; 452 452 } 453 453 454 454 /* 455 455 * Function has no such interface and … … 462 462 continue; 463 463 } 464 464 465 465 /* Calling one of the function's interfaces */ 466 466 467 467 /* Get the interface ops structure. */ 468 468 void *ops = function_get_ops(fun, iface_idx); … … 474 474 continue; 475 475 } 476 476 477 477 /* 478 478 * Get the corresponding interface for remote request … … 481 481 const remote_iface_t *rem_iface = get_remote_iface(iface_idx); 482 482 assert(rem_iface != NULL); 483 483 484 484 /* get the method of the remote interface */ 485 485 sysarg_t iface_method_idx = IPC_GET_ARG1(call); … … 493 493 continue; 494 494 } 495 495 496 496 /* 497 497 * Call the remote interface's method, which will … … 624 624 { 625 625 assert(dev->driver_data == NULL); 626 626 627 627 void *data = calloc(1, size); 628 628 if (data == NULL) 629 629 return NULL; 630 630 631 631 dev->driver_data = data; 632 632 return data; … … 732 732 if (fun == NULL) 733 733 return NULL; 734 734 735 735 /* Add one reference that will be dropped by ddf_fun_destroy() */ 736 736 fun->dev = dev; 737 737 fun_add_ref(fun); 738 738 739 739 fun->bound = false; 740 740 fun->ftype = ftype; 741 741 742 742 if (name != NULL) { 743 743 fun->name = str_dup(name); … … 747 747 } 748 748 } 749 749 750 750 return fun; 751 751 } … … 756 756 assert(fun->bound == false); 757 757 assert(fun->driver_data == NULL); 758 758 759 759 void *data = calloc(1, size); 760 760 if (data == NULL) 761 761 return NULL; 762 762 763 763 fun->driver_data = data; 764 764 return data; … … 792 792 { 793 793 assert(fun->bound == false); 794 794 795 795 /* 796 796 * Drop the reference added by ddf_fun_create(). This will deallocate … … 807 807 if (fun->ops == NULL) 808 808 return NULL; 809 809 810 810 return fun->ops->interfaces[idx]; 811 811 } … … 830 830 assert(fun->name != NULL); 831 831 assert(fun->dev != NULL); 832 832 833 833 add_to_functions_list(fun); 834 834 errno_t res = devman_add_function(fun->name, fun->ftype, &fun->match_ids, … … 838 838 return res; 839 839 } 840 840 841 841 fun->bound = true; 842 842 return res; … … 856 856 { 857 857 assert(fun->bound == true); 858 858 859 859 errno_t res = devman_remove_function(fun->handle); 860 860 if (res != EOK) 861 861 return res; 862 862 863 863 remove_from_functions_list(fun); 864 864 865 865 fun->bound = false; 866 866 return EOK; … … 877 877 { 878 878 assert(fun->bound == true); 879 879 880 880 errno_t res = devman_drv_fun_online(fun->handle); 881 881 if (res != EOK) 882 882 return res; 883 883 884 884 return EOK; 885 885 } … … 895 895 { 896 896 assert(fun->bound == true); 897 897 898 898 errno_t res = devman_drv_fun_offline(fun->handle); 899 899 if (res != EOK) 900 900 return res; 901 901 902 902 return EOK; 903 903 } … … 921 921 assert(fun->bound == false); 922 922 assert(fun->ftype == fun_inner); 923 923 924 924 match_id_t *match_id = create_match_id(); 925 925 if (match_id == NULL) 926 926 return ENOMEM; 927 927 928 928 match_id->id = str_dup(match_id_str); 929 929 match_id->score = match_score; 930 930 931 931 add_match_id(&fun->match_ids, match_id); 932 932 return EOK; … … 967 967 assert(fun->bound == true); 968 968 assert(fun->ftype == fun_exposed); 969 969 970 970 return devman_add_device_to_category(fun->handle, cat_name); 971 971 } … … 978 978 */ 979 979 driver = drv; 980 980 981 981 /* 982 982 * Register driver with device manager using generic handler for … … 990 990 return rc; 991 991 } 992 992 993 993 rc = async_create_port(INTERFACE_DDF_DEVMAN, driver_connection_devman, 994 994 NULL, &port); … … 997 997 return rc; 998 998 } 999 999 1000 1000 async_set_fallback_port_handler(driver_connection_client, NULL); 1001 1001 1002 1002 rc = devman_driver_register(driver->name); 1003 1003 if (rc != EOK) { … … 1005 1005 "(%s).\n", (rc == EEXIST) ? "driver already started" : 1006 1006 str_error(rc)); 1007 1007 1008 1008 return rc; 1009 1009 } 1010 1010 1011 1011 /* Return success from the task since server has started. */ 1012 1012 rc = task_retval(0); … … 1015 1015 return rc; 1016 1016 } 1017 1017 1018 1018 async_manager(); 1019 1019 1020 1020 /* Never reached. */ 1021 1021 return EOK; -
uspace/lib/drv/generic/log.c
r3061bc1 ra35b458 56 56 { 57 57 va_list args; 58 58 59 59 va_start(args, fmt); 60 60 log_msgv(LOG_DEFAULT, level, fmt, args); -
uspace/lib/drv/generic/private/driver.h
r3061bc1 ra35b458 49 49 */ 50 50 devman_handle_t handle; 51 51 52 52 /** Reference count */ 53 53 atomic_t refcnt; 54 54 55 55 /** Session with the parent device driver */ 56 56 async_sess_t *parent_sess; 57 57 58 58 /** Device name */ 59 59 char *name; 60 60 61 61 /** Driver-specific data associated with this device */ 62 62 void *driver_data; 63 63 64 64 /** Link in the list of devices handled by the driver */ 65 65 link_t link; … … 70 70 /** True if bound to the device manager */ 71 71 bool bound; 72 72 73 73 /** Function indentifier (asigned by device manager) */ 74 74 devman_handle_t handle; 75 75 76 76 /** Reference count */ 77 77 atomic_t refcnt; 78 78 79 79 /** Device which this function belogs to */ 80 80 struct ddf_dev *dev; 81 81 82 82 /** Function type */ 83 83 fun_type_t ftype; 84 84 85 85 /** Function name */ 86 86 char *name; 87 87 88 88 /** List of device ids for driver matching */ 89 89 match_id_list_t match_ids; 90 90 91 91 /** Driver-specific data associated with this function */ 92 92 void *driver_data; 93 93 94 94 /** Implementation of operations provided by this function */ 95 95 const ddf_dev_ops_t *ops; 96 96 97 97 /** Connection handler or @c NULL to use the DDF default handler. */ 98 98 async_port_handler_t conn_handler; 99 99 100 100 /** Link in the list of functions handled by the driver */ 101 101 link_t link; -
uspace/lib/drv/generic/remote_ahci.c
r3061bc1 ra35b458 62 62 { 63 63 // FIXME: Use a better way than substring match 64 64 65 65 *name = NULL; 66 66 67 67 char devn[MAX_NAME_LENGTH]; 68 68 errno_t rc = devman_fun_get_name(funh, devn, MAX_NAME_LENGTH); 69 69 if (rc != EOK) 70 70 return NULL; 71 71 72 72 size_t devn_size = str_size(devn); 73 73 74 74 if ((devn_size > 5) && (str_lcmp(devn, "ahci_", 5) == 0)) { 75 75 async_sess_t *sess = devman_device_connect(funh, IPC_FLAG_BLOCKING); 76 76 77 77 if (sess) { 78 78 *name = str_dup(devn); … … 80 80 } 81 81 } 82 82 83 83 return NULL; 84 84 } … … 90 90 if (!exch) 91 91 return EINVAL; 92 92 93 93 aid_t req = async_send_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 94 94 IPC_M_AHCI_GET_SATA_DEVICE_NAME, sata_dev_name_length, NULL); 95 95 96 96 async_data_read_start(exch, sata_dev_name, sata_dev_name_length); 97 97 98 98 errno_t rc; 99 99 async_wait_for(req, &rc); 100 100 101 101 return rc; 102 102 } … … 107 107 if (!exch) 108 108 return EINVAL; 109 109 110 110 sysarg_t blocks_hi; 111 111 sysarg_t blocks_lo; 112 112 errno_t rc = async_req_1_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 113 113 IPC_M_AHCI_GET_NUM_BLOCKS, &blocks_hi, &blocks_lo); 114 114 115 115 async_exchange_end(exch); 116 116 117 117 if (rc == EOK) { 118 118 *blocks = (((uint64_t) blocks_hi) << 32) 119 119 | (((uint64_t) blocks_lo) & 0xffffffff); 120 120 } 121 121 122 122 return rc; 123 123 } … … 128 128 if (!exch) 129 129 return EINVAL; 130 130 131 131 sysarg_t bs; 132 132 errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 133 133 IPC_M_AHCI_GET_BLOCK_SIZE, &bs); 134 134 135 135 async_exchange_end(exch); 136 136 137 137 if (rc == EOK) 138 138 *blocks_size = (size_t) bs; 139 139 140 140 return rc; 141 141 } … … 147 147 if (!exch) 148 148 return EINVAL; 149 149 150 150 aid_t req; 151 151 req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 152 152 IPC_M_AHCI_READ_BLOCKS, HI(blocknum), LO(blocknum), count, NULL); 153 153 154 154 async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE); 155 155 156 156 async_exchange_end(exch); 157 157 158 158 errno_t rc; 159 159 async_wait_for(req, &rc); 160 160 161 161 return rc; 162 162 } … … 168 168 if (!exch) 169 169 return EINVAL; 170 170 171 171 aid_t req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE), 172 172 IPC_M_AHCI_WRITE_BLOCKS, HI(blocknum), LO(blocknum), count, NULL); 173 173 174 174 async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE); 175 175 176 176 async_exchange_end(exch); 177 177 178 178 errno_t rc; 179 179 async_wait_for(req, &rc); 180 180 181 181 return rc; 182 182 } … … 213 213 { 214 214 const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface; 215 215 216 216 if (ahci_iface->get_sata_device_name == NULL) { 217 217 async_answer_0(callid, ENOTSUP); 218 218 return; 219 219 } 220 220 221 221 const size_t sata_dev_name_length = 222 222 (size_t) DEV_IPC_GET_ARG1(*call); 223 223 224 224 char* sata_dev_name = malloc(sata_dev_name_length); 225 225 if (sata_dev_name == NULL) { … … 227 227 return; 228 228 } 229 229 230 230 const errno_t ret = ahci_iface->get_sata_device_name(fun, 231 231 sata_dev_name_length, sata_dev_name); 232 232 233 233 size_t real_size; 234 234 ipc_callid_t cid; … … 236 236 (real_size == sata_dev_name_length)) 237 237 async_data_read_finalize(cid, sata_dev_name, sata_dev_name_length); 238 238 239 239 free(sata_dev_name); 240 240 async_answer_0(callid, ret); … … 245 245 { 246 246 const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface; 247 247 248 248 if (ahci_iface->get_num_blocks == NULL) { 249 249 async_answer_0(callid, ENOTSUP); 250 250 return; 251 251 } 252 252 253 253 uint64_t blocks; 254 254 const errno_t ret = ahci_iface->get_num_blocks(fun, &blocks); 255 255 256 256 if (ret != EOK) 257 257 async_answer_0(callid, ret); … … 264 264 { 265 265 const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface; 266 266 267 267 if (ahci_iface->get_block_size == NULL) { 268 268 async_answer_0(callid, ENOTSUP); 269 269 return; 270 270 } 271 271 272 272 size_t blocks; 273 273 const errno_t ret = ahci_iface->get_block_size(fun, &blocks); 274 274 275 275 if (ret != EOK) 276 276 async_answer_0(callid, ret); … … 283 283 { 284 284 const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface; 285 285 286 286 if (ahci_iface->read_blocks == NULL) { 287 287 async_answer_0(callid, ENOTSUP); 288 288 return; 289 289 } 290 290 291 291 size_t maxblock_size; 292 292 unsigned int flags; 293 293 294 294 ipc_callid_t cid; 295 295 async_share_out_receive(&cid, &maxblock_size, &flags); 296 296 297 297 void *buf; 298 298 async_share_out_finalize(cid, &buf); 299 299 300 300 const uint64_t blocknum = 301 301 (((uint64_t) (DEV_IPC_GET_ARG1(*call))) << 32) | 302 302 (((uint64_t) (DEV_IPC_GET_ARG2(*call))) & 0xffffffff); 303 303 const size_t cnt = (size_t) DEV_IPC_GET_ARG3(*call); 304 304 305 305 const errno_t ret = ahci_iface->read_blocks(fun, blocknum, cnt, buf); 306 306 307 307 async_answer_0(callid, ret); 308 308 } … … 312 312 { 313 313 const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface; 314 314 315 315 if (ahci_iface->read_blocks == NULL) { 316 316 async_answer_0(callid, ENOTSUP); 317 317 return; 318 318 } 319 319 320 320 size_t maxblock_size; 321 321 unsigned int flags; 322 322 323 323 ipc_callid_t cid; 324 324 async_share_out_receive(&cid, &maxblock_size, &flags); 325 325 326 326 void *buf; 327 327 async_share_out_finalize(cid, &buf); 328 328 329 329 const uint64_t blocknum = 330 330 (((uint64_t)(DEV_IPC_GET_ARG1(*call))) << 32) | 331 331 (((uint64_t)(DEV_IPC_GET_ARG2(*call))) & 0xffffffff); 332 332 const size_t cnt = (size_t) DEV_IPC_GET_ARG3(*call); 333 333 334 334 const errno_t ret = ahci_iface->write_blocks(fun, blocknum, cnt, buf); 335 335 336 336 async_answer_0(callid, ret); 337 337 } -
uspace/lib/drv/generic/remote_audio_pcm.c
r3061bc1 ra35b458 318 318 319 319 async_exch_t *exch = async_exchange_begin(sess); 320 320 321 321 errno_t ret = async_req_1_0(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), 322 322 IPC_M_AUDIO_PCM_REGISTER_EVENTS); … … 326 326 event_callback, arg, &port); 327 327 } 328 328 329 329 async_exchange_end(exch); 330 330 return ret; -
uspace/lib/drv/generic/remote_hw_res.c
r3061bc1 ra35b458 72 72 { 73 73 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 74 74 75 75 if (hw_res_ops->enable_interrupt == NULL) { 76 76 async_answer_0(callid, ENOTSUP); 77 77 return; 78 78 } 79 79 80 80 const int irq = DEV_IPC_GET_ARG1(*call); 81 81 const errno_t ret = hw_res_ops->enable_interrupt(fun, irq); … … 87 87 { 88 88 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 89 89 90 90 if (hw_res_ops->disable_interrupt == NULL) { 91 91 async_answer_0(callid, ENOTSUP); 92 92 return; 93 93 } 94 94 95 95 const int irq = DEV_IPC_GET_ARG1(*call); 96 96 const errno_t ret = hw_res_ops->disable_interrupt(fun, irq); … … 102 102 { 103 103 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 104 104 105 105 if (hw_res_ops->clear_interrupt == NULL) { 106 106 async_answer_0(callid, ENOTSUP); 107 107 return; 108 108 } 109 109 110 110 const int irq = DEV_IPC_GET_ARG1(*call); 111 111 const errno_t ret = hw_res_ops->enable_interrupt(fun, irq); … … 122 122 return; 123 123 } 124 124 125 125 hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(fun); 126 126 if (hw_resources == NULL){ … … 128 128 return; 129 129 } 130 130 131 131 async_answer_1(callid, EOK, hw_resources->count); 132 132 -
uspace/lib/drv/generic/remote_ieee80211.c
r3061bc1 ra35b458 66 66 { 67 67 assert(results); 68 68 69 69 async_exch_t *exch = async_exchange_begin(dev_sess); 70 70 71 71 aid_t aid = async_send_2(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE), 72 72 IEEE80211_GET_SCAN_RESULTS, now, NULL); … … 74 74 sizeof(ieee80211_scan_results_t)); 75 75 async_exchange_end(exch); 76 76 77 77 errno_t res; 78 78 async_wait_for(aid, &res); 79 79 80 80 if(res != EOK) 81 81 return (errno_t) res; 82 82 83 83 return rc; 84 84 } … … 90 90 return false; 91 91 } 92 92 93 93 return true; 94 94 } … … 99 99 inet_link_info_t link_info; 100 100 size_t count; 101 101 102 102 errno_t rc = inetcfg_get_link_list(&link_list, &count); 103 103 if (rc != EOK) 104 104 return -1; 105 105 106 106 for (size_t i = 0; i < count; i++) { 107 107 rc = inetcfg_link_get(link_list[i], &link_info); 108 108 if (rc != EOK) 109 109 return -1; 110 110 111 111 if (mac_matches(mac, link_info.mac_addr)) 112 112 return link_list[i]; 113 113 } 114 114 115 115 return -1; 116 116 } … … 129 129 { 130 130 assert(ssid_start); 131 131 132 132 errno_t rc_orig; 133 133 134 134 async_exch_t *exch = async_exchange_begin(dev_sess); 135 135 136 136 aid_t aid = async_send_1(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE), 137 137 IEEE80211_CONNECT, NULL); 138 138 139 139 errno_t rc = async_data_write_start(exch, ssid_start, 140 140 str_size(ssid_start) + 1); … … 142 142 async_exchange_end(exch); 143 143 async_wait_for(aid, &rc_orig); 144 144 145 145 if (rc_orig == EOK) 146 146 return (errno_t) rc; 147 147 148 148 return (errno_t) rc_orig; 149 149 } 150 150 151 151 // FIXME: Typecasting string literal 152 152 if (password == NULL) 153 153 password = (char *) ""; 154 154 155 155 rc = async_data_write_start(exch, password, str_size(password) + 1); 156 156 if (rc != EOK) { 157 157 async_exchange_end(exch); 158 158 async_wait_for(aid, &rc_orig); 159 159 160 160 if (rc_orig == EOK) 161 161 return (errno_t) rc; 162 162 163 163 return (errno_t) rc_orig; 164 164 } 165 165 166 166 async_exchange_end(exch); 167 167 168 168 async_wait_for(aid, &rc); 169 169 if (rc != EOK) 170 170 return rc; 171 171 172 172 /* Send DHCP discover. */ 173 173 nic_address_t wifi_mac; … … 175 175 if (rc != EOK) 176 176 return rc; 177 177 178 178 sysarg_t link_id = get_link_id(wifi_mac.address); 179 179 if (link_id == ((sysarg_t) -1)) 180 180 return EINVAL; 181 181 182 182 rc = dhcp_discover(link_id); 183 183 184 184 return (errno_t) rc; 185 185 } … … 199 199 IEEE80211_DISCONNECT); 200 200 async_exchange_end(exch); 201 202 if (rc != EOK) 203 return rc; 204 201 202 if (rc != EOK) 203 return rc; 204 205 205 nic_address_t wifi_mac; 206 206 rc = nic_get_address(dev_sess, &wifi_mac); 207 207 if (rc != EOK) 208 208 return rc; 209 209 210 210 inet_link_info_t link_info; 211 211 inet_addr_info_t addr_info; … … 214 214 sysarg_t *route_list; 215 215 size_t count; 216 216 217 217 /* Remove previous DHCP address. */ 218 218 rc = inetcfg_get_addr_list(&addr_list, &count); 219 219 if (rc != EOK) 220 220 return rc; 221 221 222 222 for (size_t i = 0; i < count; i++) { 223 223 rc = inetcfg_addr_get(addr_list[i], &addr_info); 224 224 if (rc != EOK) 225 225 return rc; 226 226 227 227 rc = inetcfg_link_get(addr_info.ilink, &link_info); 228 228 if (rc != EOK) 229 229 return rc; 230 230 231 231 if (mac_matches(wifi_mac.address, link_info.mac_addr)) { 232 232 if (str_test_prefix(addr_info.name, "dhcp")) { … … 234 234 if (rc != EOK) 235 235 return rc; 236 236 237 237 break; 238 238 } 239 239 } 240 240 } 241 241 242 242 /* 243 243 * TODO: At this moment there can be only one DHCP route, … … 249 249 if (rc != EOK) 250 250 return rc; 251 251 252 252 for (size_t i = 0; i < count; i++) { 253 253 rc = inetcfg_sroute_get(route_list[i], &route_info); 254 254 if (rc != EOK) 255 255 return rc; 256 256 257 257 if (str_test_prefix(route_info.name, "dhcp")) { 258 258 rc = inetcfg_sroute_delete(route_list[i]); 259 259 if (rc != EOK) 260 260 return rc; 261 261 262 262 break; 263 263 } 264 264 } 265 265 266 266 return rc; 267 267 } … … 272 272 ieee80211_iface_t *ieee80211_iface = (ieee80211_iface_t *) iface; 273 273 assert(ieee80211_iface->get_scan_results); 274 274 275 275 ieee80211_scan_results_t scan_results; 276 276 memset(&scan_results, 0, sizeof(ieee80211_scan_results_t)); 277 277 278 278 bool now = IPC_GET_ARG2(*call); 279 279 280 280 errno_t rc = ieee80211_iface->get_scan_results(fun, &scan_results, now); 281 281 if (rc == EOK) { … … 287 287 return; 288 288 } 289 289 290 290 if (max_len < sizeof(ieee80211_scan_results_t)) { 291 291 async_answer_0(data_callid, ELIMIT); … … 293 293 return; 294 294 } 295 295 296 296 async_data_read_finalize(data_callid, &scan_results, 297 297 sizeof(ieee80211_scan_results_t)); 298 298 } 299 299 300 300 async_answer_0(callid, rc); 301 301 } … … 306 306 ieee80211_iface_t *ieee80211_iface = (ieee80211_iface_t *) iface; 307 307 assert(ieee80211_iface->connect); 308 308 309 309 char ssid_start[MAX_STRING_SIZE]; 310 310 char password[MAX_STRING_SIZE]; 311 311 312 312 ipc_callid_t data_callid; 313 313 size_t len; … … 317 317 return; 318 318 } 319 319 320 320 if (len > MAX_STRING_SIZE) { 321 321 async_answer_0(data_callid, EINVAL); … … 323 323 return; 324 324 } 325 325 326 326 errno_t rc = async_data_write_finalize(data_callid, ssid_start, len); 327 327 if (rc != EOK) { … … 330 330 return; 331 331 } 332 332 333 333 if (!async_data_write_receive(&data_callid, &len)) { 334 334 async_answer_0(data_callid, EINVAL); … … 336 336 return; 337 337 } 338 338 339 339 if (len > MAX_STRING_SIZE) { 340 340 async_answer_0(data_callid, EINVAL); … … 342 342 return; 343 343 } 344 344 345 345 rc = async_data_write_finalize(data_callid, password, len); 346 346 if (rc != EOK) { … … 349 349 return; 350 350 } 351 351 352 352 rc = ieee80211_iface->connect(fun, ssid_start, password); 353 353 354 354 async_answer_0(callid, rc); 355 355 } -
uspace/lib/drv/generic/remote_led_dev.c
r3061bc1 ra35b458 71 71 led_dev_ops_t *led_dev_ops = (led_dev_ops_t *) ops; 72 72 pixel_t color = DEV_IPC_GET_ARG1(*call); 73 73 74 74 if (!led_dev_ops->color_set) { 75 75 async_answer_0(callid, ENOTSUP); 76 76 return; 77 77 } 78 78 79 79 errno_t rc = (*led_dev_ops->color_set)(fun, color); 80 80 async_answer_0(callid, rc); -
uspace/lib/drv/generic/remote_nic.c
r3061bc1 ra35b458 101 101 { 102 102 async_exch_t *exch = async_exchange_begin(dev_sess); 103 103 104 104 ipc_call_t answer; 105 105 aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 106 106 NIC_SEND_MESSAGE, &answer); 107 107 errno_t retval = async_data_write_start(exch, data, size); 108 109 async_exchange_end(exch); 110 108 109 async_exchange_end(exch); 110 111 111 if (retval != EOK) { 112 112 async_forget(req); … … 132 132 errno_t rc; 133 133 errno_t retval; 134 134 135 135 async_exch_t *exch = async_exchange_begin(dev_sess); 136 136 aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 137 137 NIC_CALLBACK_CREATE, &answer); 138 138 139 139 port_id_t port; 140 140 rc = async_create_callback_port(exch, INTERFACE_NIC_CB, 0, 0, … … 145 145 } 146 146 async_exchange_end(exch); 147 147 148 148 async_wait_for(req, &retval); 149 149 return retval; … … 161 161 { 162 162 assert(state); 163 163 164 164 sysarg_t _state; 165 165 166 166 async_exch_t *exch = async_exchange_begin(dev_sess); 167 167 errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 168 168 NIC_GET_STATE, &_state); 169 169 async_exchange_end(exch); 170 170 171 171 *state = (nic_device_state_t) _state; 172 172 173 173 return rc; 174 174 } … … 188 188 NIC_SET_STATE, state); 189 189 async_exchange_end(exch); 190 190 191 191 return rc; 192 192 } … … 203 203 { 204 204 assert(address); 205 205 206 206 async_exch_t *exch = async_exchange_begin(dev_sess); 207 207 aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), … … 209 209 errno_t rc = async_data_read_start(exch, address, sizeof(nic_address_t)); 210 210 async_exchange_end(exch); 211 211 212 212 errno_t res; 213 213 async_wait_for(aid, &res); 214 214 215 215 if (rc != EOK) 216 216 return rc; 217 217 218 218 return res; 219 219 } … … 230 230 { 231 231 assert(address); 232 232 233 233 async_exch_t *exch = async_exchange_begin(dev_sess); 234 234 aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), … … 236 236 errno_t rc = async_data_write_start(exch, address, sizeof(nic_address_t)); 237 237 async_exchange_end(exch); 238 238 239 239 errno_t res; 240 240 async_wait_for(aid, &res); 241 241 242 242 if (rc != EOK) 243 243 return rc; 244 244 245 245 return res; 246 246 } … … 257 257 { 258 258 assert(stats); 259 260 async_exch_t *exch = async_exchange_begin(dev_sess); 261 259 260 async_exch_t *exch = async_exchange_begin(dev_sess); 261 262 262 errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 263 263 NIC_GET_STATS); … … 266 266 return rc; 267 267 } 268 268 269 269 rc = async_data_read_start(exch, stats, sizeof(nic_device_stats_t)); 270 271 async_exchange_end(exch); 272 270 271 async_exchange_end(exch); 272 273 273 return rc; 274 274 } … … 287 287 { 288 288 assert(device_info); 289 290 async_exch_t *exch = async_exchange_begin(dev_sess); 291 289 290 async_exch_t *exch = async_exchange_begin(dev_sess); 291 292 292 aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 293 293 NIC_GET_DEVICE_INFO, NULL); … … 297 297 errno_t res; 298 298 async_wait_for(aid, &res); 299 299 300 300 if (rc != EOK) 301 301 return rc; 302 302 303 303 return res; 304 304 } … … 315 315 { 316 316 assert(cable_state); 317 317 318 318 sysarg_t _cable_state; 319 319 320 320 async_exch_t *exch = async_exchange_begin(dev_sess); 321 321 errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 322 322 NIC_GET_CABLE_STATE, &_cable_state); 323 323 async_exchange_end(exch); 324 324 325 325 *cable_state = (nic_cable_state_t) _cable_state; 326 326 327 327 return rc; 328 328 } … … 344 344 sysarg_t _duplex; 345 345 sysarg_t _role; 346 346 347 347 async_exch_t *exch = async_exchange_begin(dev_sess); 348 348 errno_t rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 349 349 NIC_GET_OPERATION_MODE, &_speed, &_duplex, &_role); 350 350 async_exchange_end(exch); 351 351 352 352 if (speed) 353 353 *speed = (int) _speed; 354 354 355 355 if (duplex) 356 356 *duplex = (nic_channel_mode_t) _duplex; 357 357 358 358 if (role) 359 359 *role = (nic_role_t) _role; 360 360 361 361 return rc; 362 362 } … … 383 383 (sysarg_t) role); 384 384 async_exchange_end(exch); 385 385 386 386 return rc; 387 387 } … … 406 406 NIC_AUTONEG_ENABLE, (sysarg_t) advertisement); 407 407 async_exchange_end(exch); 408 408 409 409 return rc; 410 410 } … … 423 423 NIC_AUTONEG_DISABLE); 424 424 async_exchange_end(exch); 425 425 426 426 return rc; 427 427 } … … 452 452 sysarg_t _result; 453 453 sysarg_t _their_result; 454 454 455 455 async_exch_t *exch = async_exchange_begin(dev_sess); 456 456 errno_t rc = async_req_1_4(exch, DEV_IFACE_ID(NIC_DEV_IFACE), … … 458 458 &_result, &_their_result); 459 459 async_exchange_end(exch); 460 460 461 461 if (our_advertisement) 462 462 *our_advertisement = (uint32_t) _our_advertisement; 463 463 464 464 if (*their_advertisement) 465 465 *their_advertisement = (uint32_t) _their_advertisement; 466 466 467 467 if (result) 468 468 *result = (nic_result_t) _result; 469 469 470 470 if (their_result) 471 471 *their_result = (nic_result_t) _their_result; 472 472 473 473 return rc; 474 474 } … … 487 487 NIC_AUTONEG_RESTART); 488 488 async_exchange_end(exch); 489 489 490 490 return rc; 491 491 } … … 507 507 sysarg_t _we_receive; 508 508 sysarg_t _pause; 509 509 510 510 async_exch_t *exch = async_exchange_begin(dev_sess); 511 511 errno_t rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 512 512 NIC_GET_PAUSE, &_we_send, &_we_receive, &_pause); 513 513 async_exchange_end(exch); 514 514 515 515 if (we_send) 516 516 *we_send = _we_send; 517 517 518 518 if (we_receive) 519 519 *we_receive = _we_receive; 520 520 521 521 if (pause) 522 522 *pause = _pause; 523 523 524 524 return rc; 525 525 } … … 546 546 NIC_SET_PAUSE, allow_send, allow_receive, pause); 547 547 async_exchange_end(exch); 548 548 549 549 return rc; 550 550 } … … 570 570 { 571 571 assert(mode); 572 572 573 573 sysarg_t _mode; 574 574 sysarg_t _address_count; 575 575 576 576 if (!address_list) 577 577 max_count = 0; 578 579 async_exch_t *exch = async_exchange_begin(dev_sess); 580 578 579 async_exch_t *exch = async_exchange_begin(dev_sess); 580 581 581 errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 582 582 NIC_UNICAST_GET_MODE, max_count, &_mode, &_address_count); … … 585 585 return rc; 586 586 } 587 587 588 588 *mode = (nic_unicast_mode_t) _mode; 589 589 if (address_count) 590 590 *address_count = (size_t) _address_count; 591 591 592 592 if ((max_count) && (_address_count)) 593 593 rc = async_data_read_start(exch, address_list, 594 594 max_count * sizeof(nic_address_t)); 595 596 async_exchange_end(exch); 597 595 596 async_exchange_end(exch); 597 598 598 return rc; 599 599 } … … 614 614 if (address_list == NULL) 615 615 address_count = 0; 616 617 async_exch_t *exch = async_exchange_begin(dev_sess); 618 616 617 async_exch_t *exch = async_exchange_begin(dev_sess); 618 619 619 aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 620 620 NIC_UNICAST_SET_MODE, (sysarg_t) mode, address_count, NULL); 621 621 622 622 errno_t rc; 623 623 if (address_count) … … 626 626 else 627 627 rc = EOK; 628 629 async_exchange_end(exch); 630 628 629 async_exchange_end(exch); 630 631 631 errno_t res; 632 632 async_wait_for(message_id, &res); 633 633 634 634 if (rc != EOK) 635 635 return rc; 636 636 637 637 return res; 638 638 } … … 659 659 { 660 660 assert(mode); 661 661 662 662 sysarg_t _mode; 663 663 664 664 if (!address_list) 665 665 max_count = 0; 666 667 async_exch_t *exch = async_exchange_begin(dev_sess); 668 666 667 async_exch_t *exch = async_exchange_begin(dev_sess); 668 669 669 sysarg_t ac; 670 670 errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), … … 674 674 return rc; 675 675 } 676 676 677 677 *mode = (nic_multicast_mode_t) _mode; 678 678 if (address_count) 679 679 *address_count = (size_t) ac; 680 680 681 681 if ((max_count) && (ac)) 682 682 rc = async_data_read_start(exch, address_list, 683 683 max_count * sizeof(nic_address_t)); 684 684 685 685 async_exchange_end(exch); 686 686 return rc; … … 702 702 if (address_list == NULL) 703 703 address_count = 0; 704 705 async_exch_t *exch = async_exchange_begin(dev_sess); 706 704 705 async_exch_t *exch = async_exchange_begin(dev_sess); 706 707 707 aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 708 708 NIC_MULTICAST_SET_MODE, (sysarg_t) mode, address_count, NULL); 709 709 710 710 errno_t rc; 711 711 if (address_count) … … 714 714 else 715 715 rc = EOK; 716 717 async_exchange_end(exch); 718 716 717 async_exchange_end(exch); 718 719 719 errno_t res; 720 720 async_wait_for(message_id, &res); 721 721 722 722 if (rc != EOK) 723 723 return rc; 724 724 725 725 return res; 726 726 } … … 737 737 { 738 738 assert(mode); 739 739 740 740 sysarg_t _mode; 741 741 742 742 async_exch_t *exch = async_exchange_begin(dev_sess); 743 743 errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 744 744 NIC_BROADCAST_GET_MODE, &_mode); 745 745 async_exchange_end(exch); 746 746 747 747 *mode = (nic_broadcast_mode_t) _mode; 748 748 749 749 return rc; 750 750 } … … 764 764 NIC_BROADCAST_SET_MODE, mode); 765 765 async_exchange_end(exch); 766 766 767 767 return rc; 768 768 } … … 779 779 { 780 780 assert(mode); 781 781 782 782 sysarg_t _mode; 783 783 784 784 async_exch_t *exch = async_exchange_begin(dev_sess); 785 785 errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 786 786 NIC_DEFECTIVE_GET_MODE, &_mode); 787 787 async_exchange_end(exch); 788 788 789 789 *mode = (uint32_t) _mode; 790 790 791 791 return rc; 792 792 } … … 806 806 NIC_DEFECTIVE_SET_MODE, mode); 807 807 async_exchange_end(exch); 808 808 809 809 return rc; 810 810 } … … 827 827 if (!address_list) 828 828 max_count = 0; 829 830 async_exch_t *exch = async_exchange_begin(dev_sess); 831 829 830 async_exch_t *exch = async_exchange_begin(dev_sess); 831 832 832 sysarg_t ac; 833 833 errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), … … 837 837 return rc; 838 838 } 839 839 840 840 if (address_count) 841 841 *address_count = (size_t) ac; 842 842 843 843 if ((max_count) && (ac)) 844 844 rc = async_data_read_start(exch, address_list, 845 845 max_count * sizeof(nic_address_t)); 846 846 847 847 async_exchange_end(exch); 848 848 return rc; … … 863 863 if (address_list == NULL) 864 864 address_count = 0; 865 866 async_exch_t *exch = async_exchange_begin(dev_sess); 867 865 866 async_exch_t *exch = async_exchange_begin(dev_sess); 867 868 868 aid_t message_id = async_send_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 869 869 NIC_BLOCKED_SOURCES_SET, address_count, NULL); 870 870 871 871 errno_t rc; 872 872 if (address_count) … … 875 875 else 876 876 rc = EOK; 877 878 async_exchange_end(exch); 879 877 878 async_exchange_end(exch); 879 880 880 errno_t res; 881 881 async_wait_for(message_id, &res); 882 882 883 883 if (rc != EOK) 884 884 return rc; 885 885 886 886 return res; 887 887 } … … 898 898 { 899 899 assert(mask); 900 900 901 901 async_exch_t *exch = async_exchange_begin(dev_sess); 902 902 errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), … … 906 906 return rc; 907 907 } 908 908 909 909 rc = async_data_read_start(exch, mask, sizeof(nic_vlan_mask_t)); 910 910 async_exchange_end(exch); 911 911 912 912 return rc; 913 913 } … … 926 926 { 927 927 async_exch_t *exch = async_exchange_begin(dev_sess); 928 928 929 929 aid_t message_id = async_send_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 930 930 NIC_VLAN_SET_MASK, mask != NULL, NULL); 931 931 932 932 errno_t rc; 933 933 if (mask != NULL) … … 935 935 else 936 936 rc = EOK; 937 938 async_exchange_end(exch); 939 937 938 async_exchange_end(exch); 939 940 940 errno_t res; 941 941 async_wait_for(message_id, &res); 942 942 943 943 if (rc != EOK) 944 944 return rc; 945 945 946 946 return res; 947 947 } … … 969 969 NIC_VLAN_SET_TAG, (sysarg_t) tag, (sysarg_t) add, (sysarg_t) strip); 970 970 async_exchange_end(exch); 971 971 972 972 return rc; 973 973 } … … 989 989 { 990 990 assert(id); 991 991 992 992 bool send_data = ((data != NULL) && (length != 0)); 993 993 async_exch_t *exch = async_exchange_begin(dev_sess); 994 994 995 995 ipc_call_t result; 996 996 aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 997 997 NIC_WOL_VIRTUE_ADD, (sysarg_t) type, send_data, &result); 998 998 999 999 errno_t res; 1000 1000 if (send_data) { … … 1006 1006 } 1007 1007 } 1008 1008 1009 1009 async_exchange_end(exch); 1010 1010 async_wait_for(message_id, &res); 1011 1011 1012 1012 *id = IPC_GET_ARG1(result); 1013 1013 return res; … … 1028 1028 NIC_WOL_VIRTUE_REMOVE, (sysarg_t) id); 1029 1029 async_exchange_end(exch); 1030 1030 1031 1031 return rc; 1032 1032 } … … 1050 1050 sysarg_t _type; 1051 1051 sysarg_t _length; 1052 1052 1053 1053 if (data == NULL) 1054 1054 max_length = 0; 1055 1056 async_exch_t *exch = async_exchange_begin(dev_sess); 1057 1055 1056 async_exch_t *exch = async_exchange_begin(dev_sess); 1057 1058 1058 errno_t rc = async_req_3_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1059 1059 NIC_WOL_VIRTUE_PROBE, (sysarg_t) id, max_length, … … 1063 1063 return rc; 1064 1064 } 1065 1065 1066 1066 if (type) 1067 1067 *type = _type; 1068 1068 1069 1069 if (length) 1070 1070 *length = _length; 1071 1071 1072 1072 if ((max_length) && (_length != 0)) 1073 1073 rc = async_data_read_start(exch, data, max_length); 1074 1074 1075 1075 async_exchange_end(exch); 1076 1076 return rc; … … 1100 1100 if (id_list == NULL) 1101 1101 max_count = 0; 1102 1103 async_exch_t *exch = async_exchange_begin(dev_sess); 1104 1102 1103 async_exch_t *exch = async_exchange_begin(dev_sess); 1104 1105 1105 sysarg_t count; 1106 1106 errno_t rc = async_req_3_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1107 1107 NIC_WOL_VIRTUE_LIST, (sysarg_t) type, max_count, &count); 1108 1108 1109 1109 if (id_count) 1110 1110 *id_count = (size_t) count; 1111 1111 1112 1112 if ((rc != EOK) || (!max_count)) { 1113 1113 async_exchange_end(exch); 1114 1114 return rc; 1115 1115 } 1116 1116 1117 1117 rc = async_data_read_start(exch, id_list, 1118 1118 max_count * sizeof(nic_wv_id_t)); 1119 1119 1120 1120 async_exchange_end(exch); 1121 1121 return rc; … … 1139 1139 { 1140 1140 assert(count); 1141 1141 1142 1142 sysarg_t _count; 1143 1143 1144 1144 async_exch_t *exch = async_exchange_begin(dev_sess); 1145 1145 errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1146 1146 NIC_WOL_VIRTUE_GET_CAPS, (sysarg_t) type, &_count); 1147 1147 async_exchange_end(exch); 1148 1148 1149 1149 *count = (int) _count; 1150 1150 return rc; … … 1177 1177 { 1178 1178 assert(matched_type); 1179 1179 1180 1180 sysarg_t _matched_type; 1181 1181 sysarg_t _frame_length; 1182 1182 1183 1183 if (frame == NULL) 1184 1184 max_length = 0; 1185 1186 async_exch_t *exch = async_exchange_begin(dev_sess); 1187 1185 1186 async_exch_t *exch = async_exchange_begin(dev_sess); 1187 1188 1188 errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1189 1189 NIC_WOL_LOAD_INFO, max_length, &_matched_type, &_frame_length); … … 1192 1192 return rc; 1193 1193 } 1194 1194 1195 1195 *matched_type = (nic_wv_type_t) _matched_type; 1196 1196 if (frame_length) 1197 1197 *frame_length = (size_t) _frame_length; 1198 1198 1199 1199 if ((max_length != 0) && (_frame_length != 0)) 1200 1200 rc = async_data_read_start(exch, frame, max_length); 1201 1201 1202 1202 async_exchange_end(exch); 1203 1203 return rc; … … 1218 1218 assert(supported); 1219 1219 assert(active); 1220 1220 1221 1221 sysarg_t _supported; 1222 1222 sysarg_t _active; 1223 1223 1224 1224 async_exch_t *exch = async_exchange_begin(dev_sess); 1225 1225 errno_t rc = async_req_1_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1226 1226 NIC_OFFLOAD_PROBE, &_supported, &_active); 1227 1227 async_exchange_end(exch); 1228 1228 1229 1229 *supported = (uint32_t) _supported; 1230 1230 *active = (uint32_t) _active; … … 1247 1247 NIC_AUTONEG_RESTART, (sysarg_t) mask, (sysarg_t) active); 1248 1248 async_exchange_end(exch); 1249 1249 1250 1250 return rc; 1251 1251 } … … 1265 1265 { 1266 1266 assert(mode); 1267 1267 1268 1268 sysarg_t _mode; 1269 1270 async_exch_t *exch = async_exchange_begin(dev_sess); 1271 1269 1270 async_exch_t *exch = async_exchange_begin(dev_sess); 1271 1272 1272 errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1273 1273 NIC_POLL_GET_MODE, period != NULL, &_mode); … … 1276 1276 return rc; 1277 1277 } 1278 1278 1279 1279 *mode = (nic_poll_mode_t) _mode; 1280 1280 1281 1281 if (period != NULL) 1282 1282 rc = async_data_read_start(exch, period, sizeof(struct timeval)); 1283 1283 1284 1284 async_exchange_end(exch); 1285 1285 return rc; … … 1299 1299 { 1300 1300 async_exch_t *exch = async_exchange_begin(dev_sess); 1301 1301 1302 1302 aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 1303 1303 NIC_POLL_SET_MODE, (sysarg_t) mode, period != NULL, NULL); 1304 1304 1305 1305 errno_t rc; 1306 1306 if (period) … … 1308 1308 else 1309 1309 rc = EOK; 1310 1311 async_exchange_end(exch); 1312 1310 1311 async_exchange_end(exch); 1312 1313 1313 errno_t res; 1314 1314 async_wait_for(message_id, &res); 1315 1315 1316 1316 if (rc != EOK) 1317 1317 return rc; 1318 1318 1319 1319 return res; 1320 1320 } … … 1332 1332 errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), NIC_POLL_NOW); 1333 1333 async_exchange_end(exch); 1334 1334 1335 1335 return rc; 1336 1336 } … … 1341 1341 nic_iface_t *nic_iface = (nic_iface_t *) iface; 1342 1342 assert(nic_iface->send_frame); 1343 1343 1344 1344 void *data; 1345 1345 size_t size; 1346 1346 errno_t rc; 1347 1347 1348 1348 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 1349 1349 if (rc != EOK) { … … 1351 1351 return; 1352 1352 } 1353 1353 1354 1354 rc = nic_iface->send_frame(dev, data, size); 1355 1355 async_answer_0(callid, rc); … … 1362 1362 nic_iface_t *nic_iface = (nic_iface_t *) iface; 1363 1363 assert(nic_iface->callback_create); 1364 1364 1365 1365 errno_t rc = nic_iface->callback_create(dev); 1366 1366 async_answer_0(callid, rc); … … 1372 1372 nic_iface_t *nic_iface = (nic_iface_t *) iface; 1373 1373 assert(nic_iface->get_state); 1374 1374 1375 1375 nic_device_state_t state = NIC_STATE_MAX; 1376 1376 1377 1377 errno_t rc = nic_iface->get_state(dev, &state); 1378 1378 async_answer_1(callid, rc, state); … … 1384 1384 nic_iface_t *nic_iface = (nic_iface_t *) iface; 1385 1385 assert(nic_iface->set_state); 1386 1386 1387 1387 nic_device_state_t state = (nic_device_state_t) IPC_GET_ARG2(*call); 1388 1388 1389 1389 errno_t rc = nic_iface->set_state(dev, state); 1390 1390 async_answer_0(callid, rc); … … 1396 1396 nic_iface_t *nic_iface = (nic_iface_t *) iface; 1397 1397 assert(nic_iface->get_address); 1398 1398 1399 1399 nic_address_t address; 1400 1400 memset(&address, 0, sizeof(nic_address_t)); 1401 1401 1402 1402 errno_t rc = nic_iface->get_address(dev, &address); 1403 1403 if (rc == EOK) { 1404 1404 size_t max_len; 1405 1405 ipc_callid_t data_callid; 1406 1406 1407 1407 /* All errors will be translated into EPARTY anyway */ 1408 1408 if (!async_data_read_receive(&data_callid, &max_len)) { … … 1411 1411 return; 1412 1412 } 1413 1413 1414 1414 if (max_len != sizeof(nic_address_t)) { 1415 1415 async_answer_0(data_callid, ELIMIT); … … 1417 1417 return; 1418 1418 } 1419 1419 1420 1420 async_data_read_finalize(data_callid, &address, 1421 1421 sizeof(nic_address_t)); 1422 1422 } 1423 1423 1424 1424 async_answer_0(callid, rc); 1425 1425 } … … 1429 1429 { 1430 1430 nic_iface_t *nic_iface = (nic_iface_t *) iface; 1431 1431 1432 1432 size_t length; 1433 1433 ipc_callid_t data_callid; … … 1437 1437 return; 1438 1438 } 1439 1439 1440 1440 if (length > sizeof(nic_address_t)) { 1441 1441 async_answer_0(data_callid, ELIMIT); … … 1443 1443 return; 1444 1444 } 1445 1445 1446 1446 nic_address_t address; 1447 1447 if (async_data_write_finalize(data_callid, &address, length) != EOK) { … … 1449 1449 return; 1450 1450 } 1451 1451 1452 1452 if (nic_iface->set_address != NULL) { 1453 1453 errno_t rc = nic_iface->set_address(dev, &address); … … 1465 1465 return; 1466 1466 } 1467 1467 1468 1468 nic_device_stats_t stats; 1469 1469 memset(&stats, 0, sizeof(nic_device_stats_t)); 1470 1470 1471 1471 errno_t rc = nic_iface->get_stats(dev, &stats); 1472 1472 if (rc == EOK) { … … 1478 1478 return; 1479 1479 } 1480 1480 1481 1481 if (max_len < sizeof(nic_device_stats_t)) { 1482 1482 async_answer_0(data_callid, ELIMIT); … … 1484 1484 return; 1485 1485 } 1486 1486 1487 1487 async_data_read_finalize(data_callid, &stats, 1488 1488 sizeof(nic_device_stats_t)); 1489 1489 } 1490 1490 1491 1491 async_answer_0(callid, rc); 1492 1492 } … … 1500 1500 return; 1501 1501 } 1502 1502 1503 1503 nic_device_info_t info; 1504 1504 memset(&info, 0, sizeof(nic_device_info_t)); 1505 1505 1506 1506 errno_t rc = nic_iface->get_device_info(dev, &info); 1507 1507 if (rc == EOK) { … … 1513 1513 return; 1514 1514 } 1515 1515 1516 1516 if (max_len < sizeof (nic_device_info_t)) { 1517 1517 async_answer_0(data_callid, ELIMIT); … … 1519 1519 return; 1520 1520 } 1521 1521 1522 1522 async_data_read_finalize(data_callid, &info, 1523 1523 sizeof(nic_device_info_t)); 1524 1524 } 1525 1525 1526 1526 async_answer_0(callid, rc); 1527 1527 } … … 1535 1535 return; 1536 1536 } 1537 1537 1538 1538 nic_cable_state_t cs = NIC_CS_UNKNOWN; 1539 1539 1540 1540 errno_t rc = nic_iface->get_cable_state(dev, &cs); 1541 1541 async_answer_1(callid, rc, (sysarg_t) cs); … … 1550 1550 return; 1551 1551 } 1552 1552 1553 1553 int speed = 0; 1554 1554 nic_channel_mode_t duplex = NIC_CM_UNKNOWN; 1555 1555 nic_role_t role = NIC_ROLE_UNKNOWN; 1556 1556 1557 1557 errno_t rc = nic_iface->get_operation_mode(dev, &speed, &duplex, &role); 1558 1558 async_answer_3(callid, rc, (sysarg_t) speed, (sysarg_t) duplex, … … 1568 1568 return; 1569 1569 } 1570 1570 1571 1571 int speed = (int) IPC_GET_ARG2(*call); 1572 1572 nic_channel_mode_t duplex = (nic_channel_mode_t) IPC_GET_ARG3(*call); 1573 1573 nic_role_t role = (nic_role_t) IPC_GET_ARG4(*call); 1574 1574 1575 1575 errno_t rc = nic_iface->set_operation_mode(dev, speed, duplex, role); 1576 1576 async_answer_0(callid, rc); … … 1585 1585 return; 1586 1586 } 1587 1587 1588 1588 uint32_t advertisement = (uint32_t) IPC_GET_ARG2(*call); 1589 1589 1590 1590 errno_t rc = nic_iface->autoneg_enable(dev, advertisement); 1591 1591 async_answer_0(callid, rc); … … 1600 1600 return; 1601 1601 } 1602 1602 1603 1603 errno_t rc = nic_iface->autoneg_disable(dev); 1604 1604 async_answer_0(callid, rc); … … 1613 1613 return; 1614 1614 } 1615 1615 1616 1616 uint32_t our_adv = 0; 1617 1617 uint32_t their_adv = 0; 1618 1618 nic_result_t result = NIC_RESULT_NOT_AVAILABLE; 1619 1619 nic_result_t their_result = NIC_RESULT_NOT_AVAILABLE; 1620 1620 1621 1621 errno_t rc = nic_iface->autoneg_probe(dev, &our_adv, &their_adv, &result, 1622 1622 &their_result); … … 1633 1633 return; 1634 1634 } 1635 1635 1636 1636 errno_t rc = nic_iface->autoneg_restart(dev); 1637 1637 async_answer_0(callid, rc); … … 1646 1646 return; 1647 1647 } 1648 1648 1649 1649 nic_result_t we_send; 1650 1650 nic_result_t we_receive; 1651 1651 uint16_t pause; 1652 1652 1653 1653 errno_t rc = nic_iface->get_pause(dev, &we_send, &we_receive, &pause); 1654 1654 async_answer_3(callid, rc, we_send, we_receive, pause); … … 1663 1663 return; 1664 1664 } 1665 1665 1666 1666 int allow_send = (int) IPC_GET_ARG2(*call); 1667 1667 int allow_receive = (int) IPC_GET_ARG3(*call); 1668 1668 uint16_t pause = (uint16_t) IPC_GET_ARG4(*call); 1669 1669 1670 1670 errno_t rc = nic_iface->set_pause(dev, allow_send, allow_receive, 1671 1671 pause); … … 1681 1681 return; 1682 1682 } 1683 1683 1684 1684 size_t max_count = IPC_GET_ARG2(*call); 1685 1685 nic_address_t *address_list = NULL; 1686 1686 1687 1687 if (max_count != 0) { 1688 1688 address_list = malloc(max_count * sizeof (nic_address_t)); … … 1692 1692 } 1693 1693 } 1694 1694 1695 1695 memset(address_list, 0, max_count * sizeof(nic_address_t)); 1696 1696 nic_unicast_mode_t mode = NIC_UNICAST_DEFAULT; 1697 1697 size_t address_count = 0; 1698 1698 1699 1699 errno_t rc = nic_iface->unicast_get_mode(dev, &mode, max_count, address_list, 1700 1700 &address_count); 1701 1701 1702 1702 if ((rc != EOK) || (max_count == 0) || (address_count == 0)) { 1703 1703 free(address_list); … … 1705 1705 return; 1706 1706 } 1707 1707 1708 1708 ipc_callid_t data_callid; 1709 1709 size_t max_len; … … 1714 1714 return; 1715 1715 } 1716 1716 1717 1717 if (max_len > address_count * sizeof(nic_address_t)) 1718 1718 max_len = address_count * sizeof(nic_address_t); 1719 1719 1720 1720 if (max_len > max_count * sizeof(nic_address_t)) 1721 1721 max_len = max_count * sizeof(nic_address_t); 1722 1722 1723 1723 async_data_read_finalize(data_callid, address_list, max_len); 1724 1724 async_answer_0(data_callid, EINVAL); 1725 1725 1726 1726 free(address_list); 1727 1727 async_answer_2(callid, rc, mode, address_count); … … 1732 1732 { 1733 1733 nic_iface_t *nic_iface = (nic_iface_t *) iface; 1734 1734 1735 1735 size_t length; 1736 1736 nic_unicast_mode_t mode = IPC_GET_ARG2(*call); 1737 1737 size_t address_count = IPC_GET_ARG3(*call); 1738 1738 nic_address_t *address_list = NULL; 1739 1739 1740 1740 if (address_count) { 1741 1741 ipc_callid_t data_callid; … … 1745 1745 return; 1746 1746 } 1747 1747 1748 1748 if (length != address_count * sizeof(nic_address_t)) { 1749 1749 async_answer_0(data_callid, ELIMIT); … … 1751 1751 return; 1752 1752 } 1753 1753 1754 1754 address_list = malloc(length); 1755 1755 if (address_list == NULL) { … … 1758 1758 return; 1759 1759 } 1760 1760 1761 1761 if (async_data_write_finalize(data_callid, address_list, 1762 1762 length) != EOK) { … … 1766 1766 } 1767 1767 } 1768 1768 1769 1769 if (nic_iface->unicast_set_mode != NULL) { 1770 1770 errno_t rc = nic_iface->unicast_set_mode(dev, mode, address_list, … … 1773 1773 } else 1774 1774 async_answer_0(callid, ENOTSUP); 1775 1775 1776 1776 free(address_list); 1777 1777 } … … 1785 1785 return; 1786 1786 } 1787 1787 1788 1788 size_t max_count = IPC_GET_ARG2(*call); 1789 1789 nic_address_t *address_list = NULL; 1790 1790 1791 1791 if (max_count != 0) { 1792 1792 address_list = malloc(max_count * sizeof(nic_address_t)); … … 1796 1796 } 1797 1797 } 1798 1798 1799 1799 memset(address_list, 0, max_count * sizeof(nic_address_t)); 1800 1800 nic_multicast_mode_t mode = NIC_MULTICAST_BLOCKED; 1801 1801 size_t address_count = 0; 1802 1802 1803 1803 errno_t rc = nic_iface->multicast_get_mode(dev, &mode, max_count, address_list, 1804 1804 &address_count); 1805 1806 1805 1806 1807 1807 if ((rc != EOK) || (max_count == 0) || (address_count == 0)) { 1808 1808 free(address_list); … … 1810 1810 return; 1811 1811 } 1812 1812 1813 1813 ipc_callid_t data_callid; 1814 1814 size_t max_len; … … 1819 1819 return; 1820 1820 } 1821 1821 1822 1822 if (max_len > address_count * sizeof(nic_address_t)) 1823 1823 max_len = address_count * sizeof(nic_address_t); 1824 1824 1825 1825 if (max_len > max_count * sizeof(nic_address_t)) 1826 1826 max_len = max_count * sizeof(nic_address_t); 1827 1827 1828 1828 async_data_read_finalize(data_callid, address_list, max_len); 1829 1829 1830 1830 free(address_list); 1831 1831 async_answer_2(callid, rc, mode, address_count); … … 1836 1836 { 1837 1837 nic_iface_t *nic_iface = (nic_iface_t *) iface; 1838 1838 1839 1839 nic_multicast_mode_t mode = IPC_GET_ARG2(*call); 1840 1840 size_t address_count = IPC_GET_ARG3(*call); 1841 1841 nic_address_t *address_list = NULL; 1842 1842 1843 1843 if (address_count) { 1844 1844 ipc_callid_t data_callid; … … 1849 1849 return; 1850 1850 } 1851 1851 1852 1852 if (length != address_count * sizeof (nic_address_t)) { 1853 1853 async_answer_0(data_callid, ELIMIT); … … 1855 1855 return; 1856 1856 } 1857 1857 1858 1858 address_list = malloc(length); 1859 1859 if (address_list == NULL) { … … 1862 1862 return; 1863 1863 } 1864 1864 1865 1865 if (async_data_write_finalize(data_callid, address_list, 1866 1866 length) != EOK) { … … 1870 1870 } 1871 1871 } 1872 1872 1873 1873 if (nic_iface->multicast_set_mode != NULL) { 1874 1874 errno_t rc = nic_iface->multicast_set_mode(dev, mode, address_list, … … 1877 1877 } else 1878 1878 async_answer_0(callid, ENOTSUP); 1879 1879 1880 1880 free(address_list); 1881 1881 } … … 1889 1889 return; 1890 1890 } 1891 1891 1892 1892 nic_broadcast_mode_t mode = NIC_BROADCAST_ACCEPTED; 1893 1893 1894 1894 errno_t rc = nic_iface->broadcast_get_mode(dev, &mode); 1895 1895 async_answer_1(callid, rc, mode); … … 1904 1904 return; 1905 1905 } 1906 1906 1907 1907 nic_broadcast_mode_t mode = IPC_GET_ARG2(*call); 1908 1908 1909 1909 errno_t rc = nic_iface->broadcast_set_mode(dev, mode); 1910 1910 async_answer_0(callid, rc); … … 1919 1919 return; 1920 1920 } 1921 1921 1922 1922 uint32_t mode = 0; 1923 1923 1924 1924 errno_t rc = nic_iface->defective_get_mode(dev, &mode); 1925 1925 async_answer_1(callid, rc, mode); … … 1934 1934 return; 1935 1935 } 1936 1936 1937 1937 uint32_t mode = IPC_GET_ARG2(*call); 1938 1938 1939 1939 errno_t rc = nic_iface->defective_set_mode(dev, mode); 1940 1940 async_answer_0(callid, rc); … … 1949 1949 return; 1950 1950 } 1951 1951 1952 1952 size_t max_count = IPC_GET_ARG2(*call); 1953 1953 nic_address_t *address_list = NULL; 1954 1954 1955 1955 if (max_count != 0) { 1956 1956 address_list = malloc(max_count * sizeof(nic_address_t)); … … 1960 1960 } 1961 1961 } 1962 1962 1963 1963 memset(address_list, 0, max_count * sizeof(nic_address_t)); 1964 1964 size_t address_count = 0; 1965 1965 1966 1966 errno_t rc = nic_iface->blocked_sources_get(dev, max_count, address_list, 1967 1967 &address_count); 1968 1968 1969 1969 if ((rc != EOK) || (max_count == 0) || (address_count == 0)) { 1970 1970 async_answer_1(callid, rc, address_count); … … 1972 1972 return; 1973 1973 } 1974 1974 1975 1975 ipc_callid_t data_callid; 1976 1976 size_t max_len; … … 1981 1981 return; 1982 1982 } 1983 1983 1984 1984 if (max_len > address_count * sizeof(nic_address_t)) 1985 1985 max_len = address_count * sizeof(nic_address_t); 1986 1986 1987 1987 if (max_len > max_count * sizeof(nic_address_t)) 1988 1988 max_len = max_count * sizeof(nic_address_t); 1989 1989 1990 1990 async_data_read_finalize(data_callid, address_list, max_len); 1991 1991 async_answer_0(data_callid, EINVAL); 1992 1992 1993 1993 free(address_list); 1994 1994 async_answer_1(callid, rc, address_count); … … 1999 1999 { 2000 2000 nic_iface_t *nic_iface = (nic_iface_t *) iface; 2001 2001 2002 2002 size_t length; 2003 2003 size_t address_count = IPC_GET_ARG2(*call); 2004 2004 nic_address_t *address_list = NULL; 2005 2005 2006 2006 if (address_count) { 2007 2007 ipc_callid_t data_callid; … … 2011 2011 return; 2012 2012 } 2013 2013 2014 2014 if (length != address_count * sizeof(nic_address_t)) { 2015 2015 async_answer_0(data_callid, ELIMIT); … … 2017 2017 return; 2018 2018 } 2019 2019 2020 2020 address_list = malloc(length); 2021 2021 if (address_list == NULL) { … … 2024 2024 return; 2025 2025 } 2026 2026 2027 2027 if (async_data_write_finalize(data_callid, address_list, 2028 2028 length) != EOK) { … … 2032 2032 } 2033 2033 } 2034 2034 2035 2035 if (nic_iface->blocked_sources_set != NULL) { 2036 2036 errno_t rc = nic_iface->blocked_sources_set(dev, address_list, … … 2039 2039 } else 2040 2040 async_answer_0(callid, ENOTSUP); 2041 2041 2042 2042 free(address_list); 2043 2043 } … … 2051 2051 return; 2052 2052 } 2053 2053 2054 2054 nic_vlan_mask_t vlan_mask; 2055 2055 memset(&vlan_mask, 0, sizeof(nic_vlan_mask_t)); 2056 2056 2057 2057 errno_t rc = nic_iface->vlan_get_mask(dev, &vlan_mask); 2058 2058 if (rc == EOK) { … … 2064 2064 return; 2065 2065 } 2066 2066 2067 2067 if (max_len != sizeof(nic_vlan_mask_t)) { 2068 2068 async_answer_0(data_callid, EINVAL); … … 2070 2070 return; 2071 2071 } 2072 2072 2073 2073 async_data_read_finalize(data_callid, &vlan_mask, max_len); 2074 2074 } 2075 2075 2076 2076 async_answer_0(callid, rc); 2077 2077 } … … 2081 2081 { 2082 2082 nic_iface_t *nic_iface = (nic_iface_t *) iface; 2083 2083 2084 2084 nic_vlan_mask_t vlan_mask; 2085 2085 nic_vlan_mask_t *vlan_mask_pointer = NULL; 2086 2086 bool vlan_mask_set = (bool) IPC_GET_ARG2(*call); 2087 2087 2088 2088 if (vlan_mask_set) { 2089 2089 ipc_callid_t data_callid; … … 2094 2094 return; 2095 2095 } 2096 2096 2097 2097 if (length != sizeof(nic_vlan_mask_t)) { 2098 2098 async_answer_0(data_callid, ELIMIT); … … 2100 2100 return; 2101 2101 } 2102 2102 2103 2103 if (async_data_write_finalize(data_callid, &vlan_mask, 2104 2104 length) != EOK) { … … 2106 2106 return; 2107 2107 } 2108 2108 2109 2109 vlan_mask_pointer = &vlan_mask; 2110 2110 } 2111 2111 2112 2112 if (nic_iface->vlan_set_mask != NULL) { 2113 2113 errno_t rc = nic_iface->vlan_set_mask(dev, vlan_mask_pointer); … … 2121 2121 { 2122 2122 nic_iface_t *nic_iface = (nic_iface_t *) iface; 2123 2123 2124 2124 if (nic_iface->vlan_set_tag == NULL) { 2125 2125 async_answer_0(callid, ENOTSUP); 2126 2126 return; 2127 2127 } 2128 2128 2129 2129 uint16_t tag = (uint16_t) IPC_GET_ARG2(*call); 2130 2130 bool add = (int) IPC_GET_ARG3(*call); 2131 2131 bool strip = (int) IPC_GET_ARG4(*call); 2132 2132 2133 2133 errno_t rc = nic_iface->vlan_set_tag(dev, tag, add, strip); 2134 2134 async_answer_0(callid, rc); … … 2139 2139 { 2140 2140 nic_iface_t *nic_iface = (nic_iface_t *) iface; 2141 2141 2142 2142 int send_data = (int) IPC_GET_ARG3(*call); 2143 2143 ipc_callid_t data_callid; 2144 2144 2145 2145 if (nic_iface->wol_virtue_add == NULL) { 2146 2146 if (send_data) { … … 2148 2148 async_answer_0(data_callid, ENOTSUP); 2149 2149 } 2150 2151 async_answer_0(callid, ENOTSUP); 2152 } 2153 2150 2151 async_answer_0(callid, ENOTSUP); 2152 } 2153 2154 2154 size_t length = 0; 2155 2155 void *data = NULL; 2156 2156 2157 2157 if (send_data) { 2158 2158 if (!async_data_write_receive(&data_callid, &length)) { … … 2161 2161 return; 2162 2162 } 2163 2163 2164 2164 data = malloc(length); 2165 2165 if (data == NULL) { … … 2168 2168 return; 2169 2169 } 2170 2170 2171 2171 if (async_data_write_finalize(data_callid, data, 2172 2172 length) != EOK) { … … 2176 2176 } 2177 2177 } 2178 2178 2179 2179 nic_wv_id_t id = 0; 2180 2180 nic_wv_type_t type = (nic_wv_type_t) IPC_GET_ARG2(*call); 2181 2181 2182 2182 errno_t rc = nic_iface->wol_virtue_add(dev, type, data, length, &id); 2183 2183 async_answer_1(callid, rc, (sysarg_t) id); … … 2189 2189 { 2190 2190 nic_iface_t *nic_iface = (nic_iface_t *) iface; 2191 2191 2192 2192 if (nic_iface->wol_virtue_remove == NULL) { 2193 2193 async_answer_0(callid, ENOTSUP); 2194 2194 return; 2195 2195 } 2196 2196 2197 2197 nic_wv_id_t id = (nic_wv_id_t) IPC_GET_ARG2(*call); 2198 2198 2199 2199 errno_t rc = nic_iface->wol_virtue_remove(dev, id); 2200 2200 async_answer_0(callid, rc); … … 2205 2205 { 2206 2206 nic_iface_t *nic_iface = (nic_iface_t *) iface; 2207 2207 2208 2208 if (nic_iface->wol_virtue_probe == NULL) { 2209 2209 async_answer_0(callid, ENOTSUP); 2210 2210 return; 2211 2211 } 2212 2212 2213 2213 nic_wv_id_t id = (nic_wv_id_t) IPC_GET_ARG2(*call); 2214 2214 size_t max_length = IPC_GET_ARG3(*call); … … 2217 2217 ipc_callid_t data_callid; 2218 2218 void *data = NULL; 2219 2219 2220 2220 if (max_length != 0) { 2221 2221 data = malloc(max_length); … … 2225 2225 } 2226 2226 } 2227 2227 2228 2228 memset(data, 0, max_length); 2229 2229 2230 2230 errno_t rc = nic_iface->wol_virtue_probe(dev, id, &type, max_length, 2231 2231 data, &length); 2232 2232 2233 2233 if ((max_length != 0) && (length != 0)) { 2234 2234 size_t req_length; … … 2239 2239 return; 2240 2240 } 2241 2241 2242 2242 if (req_length > length) 2243 2243 req_length = length; 2244 2244 2245 2245 if (req_length > max_length) 2246 2246 req_length = max_length; 2247 2247 2248 2248 async_data_read_finalize(data_callid, data, req_length); 2249 2249 } 2250 2250 2251 2251 async_answer_2(callid, rc, (sysarg_t) type, (sysarg_t) length); 2252 2252 free(data); … … 2261 2261 return; 2262 2262 } 2263 2263 2264 2264 nic_wv_type_t type = (nic_wv_type_t) IPC_GET_ARG2(*call); 2265 2265 size_t max_count = IPC_GET_ARG3(*call); … … 2267 2267 nic_wv_id_t *id_list = NULL; 2268 2268 ipc_callid_t data_callid; 2269 2269 2270 2270 if (max_count != 0) { 2271 2271 id_list = malloc(max_count * sizeof(nic_wv_id_t)); … … 2275 2275 } 2276 2276 } 2277 2277 2278 2278 memset(id_list, 0, max_count * sizeof (nic_wv_id_t)); 2279 2279 2280 2280 errno_t rc = nic_iface->wol_virtue_list(dev, type, max_count, id_list, 2281 2281 &count); 2282 2282 2283 2283 if ((max_count != 0) && (count != 0)) { 2284 2284 size_t req_length; … … 2289 2289 return; 2290 2290 } 2291 2291 2292 2292 if (req_length > count * sizeof(nic_wv_id_t)) 2293 2293 req_length = count * sizeof(nic_wv_id_t); 2294 2294 2295 2295 if (req_length > max_count * sizeof(nic_wv_id_t)) 2296 2296 req_length = max_count * sizeof(nic_wv_id_t); 2297 2297 2298 2298 rc = async_data_read_finalize(data_callid, id_list, req_length); 2299 2299 } 2300 2300 2301 2301 async_answer_1(callid, rc, (sysarg_t) count); 2302 2302 free(id_list); … … 2311 2311 return; 2312 2312 } 2313 2313 2314 2314 int count = -1; 2315 2315 nic_wv_type_t type = (nic_wv_type_t) IPC_GET_ARG2(*call); 2316 2316 2317 2317 errno_t rc = nic_iface->wol_virtue_get_caps(dev, type, &count); 2318 2318 async_answer_1(callid, rc, (sysarg_t) count); … … 2327 2327 return; 2328 2328 } 2329 2329 2330 2330 size_t max_length = (size_t) IPC_GET_ARG2(*call); 2331 2331 size_t frame_length = 0; 2332 2332 nic_wv_type_t type = NIC_WV_NONE; 2333 2333 uint8_t *data = NULL; 2334 2334 2335 2335 if (max_length != 0) { 2336 2336 data = malloc(max_length); … … 2340 2340 } 2341 2341 } 2342 2342 2343 2343 memset(data, 0, max_length); 2344 2344 2345 2345 errno_t rc = nic_iface->wol_load_info(dev, &type, max_length, data, 2346 2346 &frame_length); … … 2354 2354 return; 2355 2355 } 2356 2356 2357 2357 req_length = req_length > max_length ? max_length : req_length; 2358 2358 req_length = req_length > frame_length ? frame_length : req_length; 2359 2359 async_data_read_finalize(data_callid, data, req_length); 2360 2360 } 2361 2361 2362 2362 async_answer_2(callid, rc, (sysarg_t) type, (sysarg_t) frame_length); 2363 2363 free(data); … … 2372 2372 return; 2373 2373 } 2374 2374 2375 2375 uint32_t supported = 0; 2376 2376 uint32_t active = 0; 2377 2377 2378 2378 errno_t rc = nic_iface->offload_probe(dev, &supported, &active); 2379 2379 async_answer_2(callid, rc, supported, active); … … 2388 2388 return; 2389 2389 } 2390 2390 2391 2391 uint32_t mask = (uint32_t) IPC_GET_ARG2(*call); 2392 2392 uint32_t active = (uint32_t) IPC_GET_ARG3(*call); 2393 2393 2394 2394 errno_t rc = nic_iface->offload_set(dev, mask, active); 2395 2395 async_answer_0(callid, rc); … … 2404 2404 return; 2405 2405 } 2406 2406 2407 2407 nic_poll_mode_t mode = NIC_POLL_IMMEDIATE; 2408 2408 int request_data = IPC_GET_ARG2(*call); … … 2411 2411 .tv_usec = 0 2412 2412 }; 2413 2413 2414 2414 errno_t rc = nic_iface->poll_get_mode(dev, &mode, &period); 2415 2415 if ((rc == EOK) && (request_data)) { 2416 2416 size_t max_len; 2417 2417 ipc_callid_t data_callid; 2418 2418 2419 2419 if (!async_data_read_receive(&data_callid, &max_len)) { 2420 2420 async_answer_0(data_callid, EINVAL); … … 2422 2422 return; 2423 2423 } 2424 2424 2425 2425 if (max_len != sizeof(struct timeval)) { 2426 2426 async_answer_0(data_callid, ELIMIT); … … 2428 2428 return; 2429 2429 } 2430 2430 2431 2431 async_data_read_finalize(data_callid, &period, 2432 2432 sizeof(struct timeval)); 2433 2433 } 2434 2434 2435 2435 async_answer_1(callid, rc, (sysarg_t) mode); 2436 2436 } … … 2440 2440 { 2441 2441 nic_iface_t *nic_iface = (nic_iface_t *) iface; 2442 2442 2443 2443 nic_poll_mode_t mode = IPC_GET_ARG2(*call); 2444 2444 int has_period = IPC_GET_ARG3(*call); … … 2446 2446 struct timeval *period = NULL; 2447 2447 size_t length; 2448 2448 2449 2449 if (has_period) { 2450 2450 ipc_callid_t data_callid; … … 2454 2454 return; 2455 2455 } 2456 2456 2457 2457 if (length != sizeof(struct timeval)) { 2458 2458 async_answer_0(data_callid, ELIMIT); … … 2460 2460 return; 2461 2461 } 2462 2462 2463 2463 period = &period_buf; 2464 2464 if (async_data_write_finalize(data_callid, period, … … 2468 2468 } 2469 2469 } 2470 2470 2471 2471 if (nic_iface->poll_set_mode != NULL) { 2472 2472 errno_t rc = nic_iface->poll_set_mode(dev, mode, period); … … 2484 2484 return; 2485 2485 } 2486 2486 2487 2487 errno_t rc = nic_iface->poll_now(dev); 2488 2488 async_answer_0(callid, rc); -
uspace/lib/drv/generic/remote_pci.c
r3061bc1 ra35b458 54 54 { 55 55 sysarg_t res = 0; 56 56 57 57 async_exch_t *exch = async_exchange_begin(sess); 58 58 errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 59 59 IPC_M_CONFIG_SPACE_READ_8, address, &res); 60 60 async_exchange_end(exch); 61 61 62 62 *val = (uint8_t) res; 63 63 return rc; … … 68 68 { 69 69 sysarg_t res = 0; 70 70 71 71 async_exch_t *exch = async_exchange_begin(sess); 72 72 errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 73 73 IPC_M_CONFIG_SPACE_READ_16, address, &res); 74 74 async_exchange_end(exch); 75 75 76 76 *val = (uint16_t) res; 77 77 return rc; … … 82 82 { 83 83 sysarg_t res = 0; 84 84 85 85 async_exch_t *exch = async_exchange_begin(sess); 86 86 errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 87 87 IPC_M_CONFIG_SPACE_READ_32, address, &res); 88 88 async_exchange_end(exch); 89 89 90 90 *val = (uint32_t) res; 91 91 return rc; … … 98 98 IPC_M_CONFIG_SPACE_WRITE_8, address, val); 99 99 async_exchange_end(exch); 100 100 101 101 return rc; 102 102 } … … 109 109 IPC_M_CONFIG_SPACE_WRITE_16, address, val); 110 110 async_exchange_end(exch); 111 111 112 112 return rc; 113 113 } … … 120 120 IPC_M_CONFIG_SPACE_WRITE_32, address, val); 121 121 async_exchange_end(exch); 122 122 123 123 return rc; 124 124 } -
uspace/lib/drv/generic/remote_pio_window.c
r3061bc1 ra35b458 62 62 return; 63 63 } 64 64 65 65 pio_window_t *pio_window = pio_win_ops->get_pio_window(fun); 66 66 if (!pio_window) { … … 68 68 return; 69 69 } 70 70 71 71 async_answer_0(callid, EOK); 72 72 -
uspace/lib/drv/generic/remote_usbdiag.c
r3061bc1 ra35b458 188 188 return; 189 189 } 190 190 191 191 if (async_data_read_finalize(data_callid, &results, size) != EOK) { 192 192 async_answer_0(callid, EINVAL); … … 242 242 return; 243 243 } 244 244 245 245 if (async_data_read_finalize(data_callid, &results, size) != EOK) { 246 246 async_answer_0(callid, EINVAL); -
uspace/lib/drv/generic/remote_usbhid.c
r3061bc1 ra35b458 67 67 */ 68 68 IPC_M_USBHID_GET_EVENT, 69 69 70 70 /** Get the size of the report descriptor from the HID device. 71 71 * … … 78 78 */ 79 79 IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, 80 80 81 81 /** Get the report descriptor from the HID device. 82 82 * … … 101 101 if (!dev_sess) 102 102 return EINVAL; 103 103 104 104 async_exch_t *exch = async_exchange_begin(dev_sess); 105 105 106 106 sysarg_t len; 107 107 errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE), 108 108 IPC_M_USBHID_GET_EVENT_LENGTH, &len); 109 109 110 110 async_exchange_end(exch); 111 111 112 112 if (rc == EOK) { 113 113 if (size != NULL) 114 114 *size = (size_t) len; 115 115 } 116 116 117 117 return rc; 118 118 } … … 137 137 if (!dev_sess) 138 138 return EINVAL; 139 139 140 140 if (buf == NULL) 141 141 return ENOMEM; 142 142 143 143 if (size == 0) 144 144 return EINVAL; 145 145 146 146 size_t buffer_size = size; 147 147 uint8_t *buffer = malloc(buffer_size); 148 148 if (buffer == NULL) 149 149 return ENOMEM; 150 150 151 151 async_exch_t *exch = async_exchange_begin(dev_sess); 152 152 153 153 ipc_call_t opening_request_call; 154 154 aid_t opening_request = async_send_2(exch, 155 155 DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_EVENT, 156 156 flags, &opening_request_call); 157 157 158 158 if (opening_request == 0) { 159 159 async_exchange_end(exch); … … 161 161 return ENOMEM; 162 162 } 163 163 164 164 ipc_call_t data_request_call; 165 165 aid_t data_request = async_data_read(exch, buffer, buffer_size, 166 166 &data_request_call); 167 167 168 168 async_exchange_end(exch); 169 169 170 170 if (data_request == 0) { 171 171 async_forget(opening_request); … … 173 173 return ENOMEM; 174 174 } 175 175 176 176 errno_t data_request_rc; 177 177 errno_t opening_request_rc; 178 178 async_wait_for(data_request, &data_request_rc); 179 179 async_wait_for(opening_request, &opening_request_rc); 180 180 181 181 if (data_request_rc != EOK) { 182 182 /* Prefer return code of the opening request. */ … … 186 186 return (errno_t) data_request_rc; 187 187 } 188 188 189 189 if (opening_request_rc != EOK) 190 190 return (errno_t) opening_request_rc; 191 191 192 192 size_t act_size = IPC_GET_ARG2(data_request_call); 193 193 194 194 /* Copy the individual items. */ 195 195 memcpy(buf, buffer, act_size); 196 196 197 197 if (actual_size != NULL) 198 198 *actual_size = act_size; 199 199 200 200 if (event_nr != NULL) 201 201 *event_nr = IPC_GET_ARG1(opening_request_call); 202 202 203 203 return EOK; 204 204 } … … 209 209 if (!dev_sess) 210 210 return EINVAL; 211 211 212 212 async_exch_t *exch = async_exchange_begin(dev_sess); 213 213 214 214 sysarg_t arg_size; 215 215 errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE), 216 216 IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, &arg_size); 217 217 218 218 async_exchange_end(exch); 219 219 220 220 if (rc == EOK) { 221 221 if (size != NULL) 222 222 *size = (size_t) arg_size; 223 223 } 224 224 225 225 return rc; 226 226 } … … 231 231 if (!dev_sess) 232 232 return EINVAL; 233 233 234 234 if (buf == NULL) 235 235 return ENOMEM; 236 236 237 237 if (size == 0) 238 238 return EINVAL; 239 239 240 240 async_exch_t *exch = async_exchange_begin(dev_sess); 241 241 242 242 aid_t opening_request = async_send_1(exch, 243 243 DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_REPORT_DESCRIPTOR, … … 247 247 return ENOMEM; 248 248 } 249 249 250 250 ipc_call_t data_request_call; 251 251 aid_t data_request = async_data_read(exch, buf, size, 252 252 &data_request_call); 253 253 254 254 async_exchange_end(exch); 255 255 256 256 if (data_request == 0) { 257 257 async_forget(opening_request); 258 258 return ENOMEM; 259 259 } 260 260 261 261 errno_t data_request_rc; 262 262 errno_t opening_request_rc; 263 263 async_wait_for(data_request, &data_request_rc); 264 264 async_wait_for(opening_request, &opening_request_rc); 265 265 266 266 if (data_request_rc != EOK) { 267 267 /* Prefer return code of the opening request. */ … … 271 271 return (errno_t) data_request_rc; 272 272 } 273 273 274 274 if (opening_request_rc != EOK) 275 275 return (errno_t) opening_request_rc; 276 276 277 277 size_t act_size = IPC_GET_ARG2(data_request_call); 278 278 279 279 if (actual_size != NULL) 280 280 *actual_size = act_size; 281 281 282 282 return EOK; 283 283 } … … 312 312 { 313 313 printf("remote_usbhid_get_event_length()\n"); 314 314 315 315 usbhid_iface_t *hid_iface = (usbhid_iface_t *) iface; 316 316 … … 326 326 // } 327 327 async_answer_1(callid, EOK, len); 328 328 329 329 // if (len < 0) { 330 330 // async_answer_0(callid, len); -
uspace/lib/drv/include/ddf/driver.h
r3061bc1 ra35b458 57 57 */ 58 58 errno_t (*open)(ddf_fun_t *); 59 59 60 60 /** 61 61 * Optional callback function called when a client is disconnecting from … … 63 63 */ 64 64 void (*close)(ddf_fun_t *); 65 65 66 66 /** The table of standard interfaces implemented by the device. */ 67 67 void *interfaces[DEV_IFACE_COUNT]; 68 68 69 69 /** 70 70 * The default handler of remote client requests. If the client's remote … … 89 89 /** Callback method for passing a new device to the device driver */ 90 90 errno_t (*dev_add)(ddf_dev_t *); 91 91 92 92 /** Ask driver to remove a device */ 93 93 errno_t (*dev_remove)(ddf_dev_t *); 94 94 95 95 /** Inform driver a device disappeared */ 96 96 errno_t (*dev_gone)(ddf_dev_t *); 97 97 98 98 /** Ask driver to online a specific function */ 99 99 errno_t (*fun_online)(ddf_fun_t *); 100 100 101 101 /** Ask driver to offline a specific function */ 102 102 errno_t (*fun_offline)(ddf_fun_t *); -
uspace/lib/drv/include/ops/ieee80211.h
r3061bc1 ra35b458 52 52 */ 53 53 errno_t (*get_scan_results)(ddf_fun_t *, ieee80211_scan_results_t *, bool); 54 54 55 55 /** Connect IEEE 802.11 device to specified network. 56 56 * … … 63 63 */ 64 64 errno_t (*connect)(ddf_fun_t *, char *, char *); 65 65 66 66 /** Disconnect IEEE 802.11 device from network. 67 67 * -
uspace/lib/drv/include/ops/nic.h
r3061bc1 ra35b458 49 49 errno_t (*set_state)(ddf_fun_t *, nic_device_state_t); 50 50 errno_t (*get_address)(ddf_fun_t *, nic_address_t *); 51 51 52 52 /** Optional methods */ 53 53 errno_t (*set_address)(ddf_fun_t *, const nic_address_t *); … … 55 55 errno_t (*get_device_info)(ddf_fun_t *, nic_device_info_t *); 56 56 errno_t (*get_cable_state)(ddf_fun_t *, nic_cable_state_t *); 57 57 58 58 errno_t (*get_operation_mode)(ddf_fun_t *, int *, nic_channel_mode_t *, 59 59 nic_role_t *); … … 68 68 uint16_t *); 69 69 errno_t (*set_pause)(ddf_fun_t *, int, int, uint16_t); 70 70 71 71 errno_t (*unicast_get_mode)(ddf_fun_t *, nic_unicast_mode_t *, size_t, 72 72 nic_address_t *, size_t *); … … 84 84 size_t *); 85 85 errno_t (*blocked_sources_set)(ddf_fun_t *, const nic_address_t *, size_t); 86 86 87 87 errno_t (*vlan_get_mask)(ddf_fun_t *, nic_vlan_mask_t *); 88 88 errno_t (*vlan_set_mask)(ddf_fun_t *, const nic_vlan_mask_t *); 89 89 errno_t (*vlan_set_tag)(ddf_fun_t *, uint16_t, bool, bool); 90 90 91 91 errno_t (*wol_virtue_add)(ddf_fun_t *, nic_wv_type_t, const void *, 92 92 size_t, nic_wv_id_t *); … … 99 99 errno_t (*wol_load_info)(ddf_fun_t *, nic_wv_type_t *, size_t, 100 100 uint8_t *, size_t *); 101 101 102 102 errno_t (*offload_probe)(ddf_fun_t *, uint32_t *, uint32_t *); 103 103 errno_t (*offload_set)(ddf_fun_t *, uint32_t, uint32_t); 104 104 105 105 errno_t (*poll_get_mode)(ddf_fun_t *, nic_poll_mode_t *, 106 106 struct timeval *); -
uspace/lib/drv/include/usbhid_iface.h
r3061bc1 ra35b458 65 65 errno_t (*get_event)(ddf_fun_t *fun, uint8_t *buffer, size_t size, 66 66 size_t *act_size, int *event_nr, unsigned int flags); 67 67 68 68 /** Get size of the report descriptor in bytes. 69 69 * … … 72 72 */ 73 73 size_t (*get_report_descriptor_length)(ddf_fun_t *fun); 74 74 75 75 /** Get the report descriptor from the HID device. 76 76 *
Note:
See TracChangeset
for help on using the changeset viewer.