Changes in / [36bcf84f:ef75332] in mainline
- Location:
- uspace/lib
- Files:
-
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r36bcf84f ref75332 46 46 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 47 47 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); 48 static void remote_usbhc_control_write_setup(device_t *, void *, ipc_callid_t, ipc_call_t *); 49 static void remote_usbhc_control_write_data(device_t *, void *, ipc_callid_t, ipc_call_t *); 50 static void remote_usbhc_control_write_status(device_t *, void *, ipc_callid_t, ipc_call_t *); 51 static void remote_usbhc_control_read_setup(device_t *, void *, ipc_callid_t, ipc_call_t *); 52 static void remote_usbhc_control_read_data(device_t *, void *, ipc_callid_t, ipc_call_t *); 53 static void remote_usbhc_control_read_status(device_t *, void *, ipc_callid_t, ipc_call_t *); 54 //static void remote_usbhc(device_t *, void *, ipc_callid_t, ipc_call_t *); 48 //static void remote_usb(device_t *, void *, ipc_callid_t, ipc_call_t *); 55 49 56 50 /** Remote USB interface operations. */ … … 59 53 remote_usbhc_get_buffer, 60 54 remote_usbhc_interrupt_out, 61 remote_usbhc_interrupt_in, 62 remote_usbhc_control_write_setup, 63 remote_usbhc_control_write_data, 64 remote_usbhc_control_write_status, 65 remote_usbhc_control_read_setup, 66 remote_usbhc_control_read_data, 67 remote_usbhc_control_read_status 55 remote_usbhc_interrupt_in 68 56 }; 69 57 … … 233 221 } 234 222 235 void remote_usbhc_control_write_setup(device_t *device, void *iface,236 ipc_callid_t callid, ipc_call_t *call)237 {238 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;239 240 size_t expected_len = IPC_GET_ARG3(*call);241 usb_target_t target = {242 .address = IPC_GET_ARG1(*call),243 .endpoint = IPC_GET_ARG2(*call)244 };245 246 size_t len = 0;247 void *buffer = NULL;248 if (expected_len > 0) {249 int rc = async_data_write_accept(&buffer, false,250 1, USB_MAX_PAYLOAD_SIZE,251 0, &len);252 253 if (rc != EOK) {254 ipc_answer_0(callid, rc);255 return;256 }257 }258 259 if (!usb_iface->control_write_setup) {260 ipc_answer_0(callid, ENOTSUP);261 return;262 }263 264 async_transaction_t *trans = malloc(sizeof(async_transaction_t));265 trans->caller = callid;266 trans->buffer = NULL;267 trans->size = 0;268 269 int rc = usb_iface->control_write_setup(device, target, buffer, len,270 callback_out, trans);271 272 if (rc != EOK) {273 ipc_answer_0(callid, rc);274 free(trans);275 }276 }277 278 void remote_usbhc_control_write_data(device_t *device, void *iface,279 ipc_callid_t callid, ipc_call_t *call)280 {281 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;282 283 size_t expected_len = IPC_GET_ARG3(*call);284 usb_target_t target = {285 .address = IPC_GET_ARG1(*call),286 .endpoint = IPC_GET_ARG2(*call)287 };288 289 size_t len = 0;290 void *buffer = NULL;291 if (expected_len > 0) {292 int rc = async_data_write_accept(&buffer, false,293 1, USB_MAX_PAYLOAD_SIZE,294 0, &len);295 296 if (rc != EOK) {297 ipc_answer_0(callid, rc);298 return;299 }300 }301 302 if (!usb_iface->control_write_data) {303 ipc_answer_0(callid, ENOTSUP);304 return;305 }306 307 async_transaction_t *trans = malloc(sizeof(async_transaction_t));308 trans->caller = callid;309 trans->buffer = NULL;310 trans->size = 0;311 312 int rc = usb_iface->control_write_data(device, target, buffer, len,313 callback_out, trans);314 315 if (rc != EOK) {316 ipc_answer_0(callid, rc);317 free(trans);318 }319 }320 321 void remote_usbhc_control_write_status(device_t *device, void *iface,322 ipc_callid_t callid, ipc_call_t *call)323 {324 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;325 326 usb_target_t target = {327 .address = IPC_GET_ARG1(*call),328 .endpoint = IPC_GET_ARG2(*call)329 };330 331 if (!usb_iface->control_write_status) {332 ipc_answer_0(callid, ENOTSUP);333 return;334 }335 336 async_transaction_t *trans = malloc(sizeof(async_transaction_t));337 trans->caller = callid;338 trans->buffer = NULL;339 trans->size = 0;340 341 int rc = usb_iface->control_write_status(device, target,342 callback_in, trans);343 344 if (rc != EOK) {345 ipc_answer_0(callid, rc);346 free(trans);347 }348 }349 350 void remote_usbhc_control_read_setup(device_t *device, void *iface,351 ipc_callid_t callid, ipc_call_t *call)352 {353 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;354 355 size_t expected_len = IPC_GET_ARG3(*call);356 usb_target_t target = {357 .address = IPC_GET_ARG1(*call),358 .endpoint = IPC_GET_ARG2(*call)359 };360 361 size_t len = 0;362 void *buffer = NULL;363 if (expected_len > 0) {364 int rc = async_data_write_accept(&buffer, false,365 1, USB_MAX_PAYLOAD_SIZE,366 0, &len);367 368 if (rc != EOK) {369 ipc_answer_0(callid, rc);370 return;371 }372 }373 374 if (!usb_iface->control_read_setup) {375 ipc_answer_0(callid, ENOTSUP);376 return;377 }378 379 async_transaction_t *trans = malloc(sizeof(async_transaction_t));380 trans->caller = callid;381 trans->buffer = NULL;382 trans->size = 0;383 384 int rc = usb_iface->control_read_setup(device, target, buffer, len,385 callback_out, trans);386 387 if (rc != EOK) {388 ipc_answer_0(callid, rc);389 free(trans);390 }391 }392 393 void remote_usbhc_control_read_data(device_t *device, void *iface,394 ipc_callid_t callid, ipc_call_t *call)395 {396 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;397 398 size_t len = IPC_GET_ARG3(*call);399 usb_target_t target = {400 .address = IPC_GET_ARG1(*call),401 .endpoint = IPC_GET_ARG2(*call)402 };403 404 if (!usb_iface->control_read_data) {405 ipc_answer_0(callid, ENOTSUP);406 return;407 }408 409 async_transaction_t *trans = malloc(sizeof(async_transaction_t));410 trans->caller = callid;411 trans->buffer = malloc(len);412 trans->size = len;413 414 int rc = usb_iface->control_read_data(device, target, trans->buffer, len,415 callback_in, trans);416 417 if (rc != EOK) {418 ipc_answer_0(callid, rc);419 free(trans->buffer);420 free(trans);421 }422 }423 424 void remote_usbhc_control_read_status(device_t *device, void *iface,425 ipc_callid_t callid, ipc_call_t *call)426 {427 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;428 429 usb_target_t target = {430 .address = IPC_GET_ARG1(*call),431 .endpoint = IPC_GET_ARG2(*call)432 };433 434 if (!usb_iface->control_read_status) {435 ipc_answer_0(callid, ENOTSUP);436 return;437 }438 439 async_transaction_t *trans = malloc(sizeof(async_transaction_t));440 trans->caller = callid;441 trans->buffer = NULL;442 trans->size = 0;443 444 int rc = usb_iface->control_read_status(device, target,445 callback_out, trans);446 447 if (rc != EOK) {448 ipc_answer_0(callid, rc);449 free(trans);450 }451 }452 453 454 223 455 224 /** -
uspace/lib/drv/include/usbhc_iface.h
r36bcf84f ref75332 169 169 typedef struct { 170 170 int (*tell_address)(device_t *, devman_handle_t, usb_address_t *); 171 172 171 int (*interrupt_out)(device_t *, usb_target_t, 173 172 void *, size_t, … … 176 175 void *, size_t, 177 176 usbhc_iface_transfer_in_callback_t, void *); 178 179 int (*control_write_setup)(device_t *, usb_target_t,180 void *, size_t,181 usbhc_iface_transfer_out_callback_t, void *);182 int (*control_write_data)(device_t *, usb_target_t,183 void *, size_t,184 usbhc_iface_transfer_out_callback_t, void *);185 int (*control_write_status)(device_t *, usb_target_t,186 usbhc_iface_transfer_in_callback_t, void *);187 188 int (*control_read_setup)(device_t *, usb_target_t,189 void *, size_t,190 usbhc_iface_transfer_out_callback_t, void *);191 int (*control_read_data)(device_t *, usb_target_t,192 void *, size_t,193 usbhc_iface_transfer_in_callback_t, void *);194 int (*control_read_status)(device_t *, usb_target_t,195 usbhc_iface_transfer_out_callback_t, void *);196 177 } usbhc_iface_t; 197 178 -
uspace/lib/usb/Makefile
r36bcf84f ref75332 37 37 src/hubdrv.c \ 38 38 src/localdrv.c \ 39 src/remotedrv.c \40 39 src/usb.c \ 41 40 src/usbdrv.c -
uspace/lib/usb/include/usb/usbdrv.h
r36bcf84f ref75332 48 48 void *, size_t, size_t *, usb_handle_t *); 49 49 50 int usb_drv_async_control_write_setup(int, usb_target_t,51 void *, size_t, usb_handle_t *);52 int usb_drv_async_control_write_data(int, usb_target_t,53 void *, size_t, usb_handle_t *);54 int usb_drv_async_control_write_status(int, usb_target_t,55 usb_handle_t *);56 57 int usb_drv_async_control_read_setup(int, usb_target_t,58 void *, size_t, usb_handle_t *);59 int usb_drv_async_control_read_data(int, usb_target_t,60 void *, size_t, size_t *, usb_handle_t *);61 int usb_drv_async_control_read_status(int, usb_target_t,62 usb_handle_t *);63 64 50 int usb_drv_async_wait_for(usb_handle_t); 65 51 -
uspace/lib/usb/src/hcdhubd.c
r36bcf84f ref75332 205 205 } 206 206 207 /** Tell USB address of given device.208 *209 * @param handle Devman handle of the device.210 * @return USB device address or error code.211 */212 usb_address_t usb_get_address_by_handle(devman_handle_t handle)213 {214 /* TODO: search list of attached devices. */215 return ENOENT;216 }217 218 207 /** 219 208 * @} -
uspace/lib/usb/src/hcdhubd_private.h
r36bcf84f ref75332 42 42 extern usb_hc_driver_t *hc_driver; 43 43 44 extern usbhc_iface_t usbhc_interface;45 46 usb_address_t usb_get_address_by_handle(devman_handle_t);47 44 int usb_add_hc_device(device_t *); 48 45 int usb_add_hub_device(device_t *); -
uspace/lib/usb/src/hcdrv.c
r36bcf84f ref75332 50 50 usb_hc_driver_t *hc_driver = NULL; 51 51 52 static usbhc_iface_t usb_interface = { 53 .interrupt_out = NULL, 54 .interrupt_in = NULL 55 }; 56 52 57 static device_ops_t usb_device_ops = { 53 .interfaces[USBHC_DEV_IFACE] = &usb hc_interface58 .interfaces[USBHC_DEV_IFACE] = &usb_interface 54 59 }; 55 60 -
uspace/lib/usb/src/usbdrv.c
r36bcf84f ref75332 345 345 } 346 346 347 /** Start control write transfer. */348 int usb_drv_async_control_write_setup(int phone, usb_target_t target,349 void *buffer, size_t size,350 usb_handle_t *handle)351 {352 return async_send_buffer(phone,353 IPC_M_USBHC_CONTROL_WRITE_SETUP,354 target,355 buffer, size,356 handle);357 }358 359 /** Send data during control write transfer. */360 int usb_drv_async_control_write_data(int phone, usb_target_t target,361 void *buffer, size_t size,362 usb_handle_t *handle)363 {364 return async_send_buffer(phone,365 IPC_M_USBHC_CONTROL_WRITE_DATA,366 target,367 buffer, size,368 handle);369 }370 371 /** Finalize control write transfer. */372 int usb_drv_async_control_write_status(int phone, usb_target_t target,373 usb_handle_t *handle)374 {375 return async_recv_buffer(phone,376 IPC_M_USBHC_CONTROL_WRITE_STATUS,377 target,378 NULL, 0, NULL,379 handle);380 }381 382 /** Start control read transfer. */383 int usb_drv_async_control_read_setup(int phone, usb_target_t target,384 void *buffer, size_t size,385 usb_handle_t *handle)386 {387 return async_send_buffer(phone,388 IPC_M_USBHC_CONTROL_READ_SETUP,389 target,390 buffer, size,391 handle);392 }393 394 /** Read data during control read transfer. */395 int usb_drv_async_control_read_data(int phone, usb_target_t target,396 void *buffer, size_t size, size_t *actual_size,397 usb_handle_t *handle)398 {399 return async_recv_buffer(phone,400 IPC_M_USBHC_CONTROL_READ_DATA,401 target,402 buffer, size, actual_size,403 handle);404 }405 406 /** Finalize control read transfer. */407 int usb_drv_async_control_read_status(int phone, usb_target_t target,408 usb_handle_t *handle)409 {410 return async_send_buffer(phone,411 IPC_M_USBHC_CONTROL_READ_STATUS,412 target,413 NULL, 0,414 handle);415 }416 417 347 /** 418 348 * @}
Note:
See TracChangeset
for help on using the changeset viewer.