Changeset bbce2c2 in mainline
- Timestamp:
- 2011-09-14T20:27:33Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f58ef61
- Parents:
- bdd8ad2f
- Location:
- uspace/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
rbdd8ad2f rbbce2c2 48 48 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 49 49 static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 50 static void remote_usbhc_control_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 51 static void remote_usbhc_control_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 52 static void remote_usbhc_data_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 53 static void remote_usbhc_data_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 50 static void remote_usbhc_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 51 static void remote_usbhc_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 54 52 //static void remote_usbhc(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 55 53 … … 64 62 [IPC_M_USBHC_UNREGISTER_ENDPOINT] = remote_usbhc_unregister_endpoint, 65 63 66 [IPC_M_USBHC_CONTROL_WRITE] = remote_usbhc_control_write, 67 [IPC_M_USBHC_CONTROL_READ] = remote_usbhc_control_read, 68 69 [IPC_M_USBHC_DATA_READ] = remote_usbhc_data_read, 70 [IPC_M_USBHC_DATA_WRITE] = remote_usbhc_data_write, 64 [IPC_M_USBHC_READ] = remote_usbhc_read, 65 [IPC_M_USBHC_WRITE] = remote_usbhc_write, 71 66 }; 72 67 … … 226 221 async_transaction_destroy(trans); 227 222 } 228 229 void remote_usbhc_control_write(ddf_fun_t *fun, void *iface,230 ipc_callid_t callid, ipc_call_t *call)231 {232 assert(false);233 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;234 assert(usb_iface != NULL);235 236 if (!usb_iface->write) {237 async_answer_0(callid, ENOTSUP);238 return;239 }240 241 const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };242 size_t data_buffer_len = DEV_IPC_GET_ARG2(*call);243 244 int rc;245 246 void *setup_packet = NULL;247 void *data_buffer = NULL;248 size_t setup_packet_len = 0;249 250 rc = async_data_write_accept(&setup_packet, false,251 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len);252 if (rc != EOK) {253 async_answer_0(callid, rc);254 return;255 }256 257 if (data_buffer_len > 0) {258 rc = async_data_write_accept(&data_buffer, false,259 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len);260 if (rc != EOK) {261 async_answer_0(callid, rc);262 free(setup_packet);263 return;264 }265 }266 267 async_transaction_t *trans = async_transaction_create(callid);268 if (trans == NULL) {269 async_answer_0(callid, ENOMEM);270 free(setup_packet);271 free(data_buffer);272 return;273 }274 trans->buffer = data_buffer;275 trans->size = data_buffer_len;276 277 assert(setup_packet_len == 8);278 uint64_t setup_buffer;279 memcpy(&setup_buffer, setup_packet, 8);280 free(setup_packet);281 rc = usb_iface->write(fun, target, setup_buffer, trans->buffer,282 trans->size, callback_out, trans);283 284 if (rc != EOK) {285 async_answer_0(callid, rc);286 async_transaction_destroy(trans);287 }288 }289 290 291 void remote_usbhc_control_read(ddf_fun_t *fun, void *iface,292 ipc_callid_t callid, ipc_call_t *call)293 {294 assert(false);295 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;296 assert(usb_iface != NULL);297 298 if (!usb_iface->read) {299 async_answer_0(callid, ENOTSUP);300 return;301 }302 303 const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };304 305 int rc;306 307 void *setup_packet = NULL;308 size_t setup_packet_len = 0;309 size_t data_len = 0;310 311 rc = async_data_write_accept(&setup_packet, false,312 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len);313 if (rc != EOK) {314 async_answer_0(callid, rc);315 return;316 }317 318 ipc_callid_t data_callid;319 if (!async_data_read_receive(&data_callid, &data_len)) {320 async_answer_0(callid, EPARTY);321 free(setup_packet);322 return;323 }324 325 async_transaction_t *trans = async_transaction_create(callid);326 if (trans == NULL) {327 async_answer_0(data_callid, ENOMEM);328 async_answer_0(callid, ENOMEM);329 free(setup_packet);330 return;331 }332 trans->data_caller = data_callid;333 trans->size = data_len;334 trans->buffer = malloc(data_len);335 if (trans->buffer == NULL) {336 async_answer_0(data_callid, ENOMEM);337 async_answer_0(callid, ENOMEM);338 async_transaction_destroy(trans);339 return;340 }341 342 assert(setup_packet_len == 8);343 uint64_t setup_buffer;344 memcpy(&setup_buffer, setup_packet, 8);345 free(setup_packet);346 rc = usb_iface->read(fun, target, setup_buffer, trans->buffer,347 trans->size, callback_in, trans);348 if (rc != EOK) {349 async_answer_0(data_callid, rc);350 async_answer_0(callid, rc);351 async_transaction_destroy(trans);352 }353 }354 355 223 356 224 void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface, … … 396 264 } 397 265 398 399 266 void remote_usbhc_unregister_endpoint(ddf_fun_t *fun, void *iface, 400 267 ipc_callid_t callid, ipc_call_t *call) … … 417 284 } 418 285 419 static void remote_usbhc_data_read(286 void remote_usbhc_read( 420 287 ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 421 288 { … … 464 331 } 465 332 466 static void remote_usbhc_data_write(333 void remote_usbhc_write( 467 334 ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 468 335 { -
uspace/lib/drv/include/usbhc_iface.h
rbdd8ad2f rbbce2c2 150 150 IPC_M_USBHC_UNREGISTER_ENDPOINT, 151 151 152 /** Issue control WRITE transfer.153 * See explanation at usb_iface_funcs_t (OUT transaction) for154 * call parameters.155 * This call is immediately followed by two IPC data writes156 * from the caller (setup packet and actual data).157 */158 IPC_M_USBHC_CONTROL_WRITE,159 160 /** Issue control READ transfer.161 * See explanation at usb_iface_funcs_t (IN transaction) for162 * call parameters.163 * This call is immediately followed by IPC data write from the caller164 * (setup packet) and IPC data read (buffer that was read).165 */166 IPC_M_USBHC_CONTROL_READ,167 168 152 /** Get data from device. 169 153 * See explanation at usb_iface_funcs_t (IN transaction). 170 154 */ 171 IPC_M_USBHC_ DATA_READ,155 IPC_M_USBHC_READ, 172 156 173 157 /** Send data to device. 174 158 * See explanation at usb_iface_funcs_t (OUT transaction). 175 159 */ 176 IPC_M_USBHC_ DATA_WRITE,160 IPC_M_USBHC_WRITE, 177 161 } usbhc_iface_funcs_t; 178 162 179 163 /** Callback for outgoing transfer. */ 180 typedef void (*usbhc_iface_transfer_out_callback_t)(ddf_fun_t *, 181 int, void *); 164 typedef void (*usbhc_iface_transfer_out_callback_t)(ddf_fun_t *, int, void *); 182 165 183 166 /** Callback for incoming transfer. */ -
uspace/lib/usbdev/src/pipesio.c
rbdd8ad2f rbbce2c2 81 81 */ 82 82 aid_t opening_request = async_send_2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 83 IPC_M_USBHC_ DATA_READ, target.packed, NULL);83 IPC_M_USBHC_READ, target.packed, NULL); 84 84 85 85 if (opening_request == 0) { … … 220 220 */ 221 221 aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 222 IPC_M_USBHC_ DATA_WRITE, target.packed, size, NULL);222 IPC_M_USBHC_WRITE, target.packed, size, NULL); 223 223 224 224 if (opening_request == 0) { … … 345 345 async_exch_t *exch = async_exchange_begin(pipe->hc_sess); 346 346 aid_t opening_request = async_send_4(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 347 IPC_M_USBHC_ DATA_READ, target.packed,347 IPC_M_USBHC_READ, target.packed, 348 348 (setup_packet & UINT32_MAX), (setup_packet >> 32), NULL); 349 349 … … 486 486 async_exch_t *exch = async_exchange_begin(pipe->hc_sess); 487 487 aid_t opening_request = async_send_5(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 488 IPC_M_USBHC_ DATA_WRITE, target.packed, data_buffer_size,488 IPC_M_USBHC_WRITE, target.packed, data_buffer_size, 489 489 (setup_packet & UINT32_MAX), (setup_packet >> 32), NULL); 490 490
Note:
See TracChangeset
for help on using the changeset viewer.