Changeset 6843a9c in mainline for uspace/lib/drv/generic
- Timestamp:
- 2012-06-29T13:02:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 722912e
- Parents:
- ba72f2b (diff), 0bbd13e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/lib/drv/generic
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
rba72f2b r6843a9c 70 70 FIBRIL_MUTEX_INITIALIZE(functions_mutex); 71 71 72 /** Interrupts */73 static interrupt_context_list_t interrupt_contexts;74 75 static irq_cmd_t default_cmds[] = {76 {77 .cmd = CMD_ACCEPT78 }79 };80 81 static irq_code_t default_pseudocode = {82 sizeof(default_cmds) / sizeof(irq_cmd_t),83 default_cmds84 };85 86 72 static ddf_dev_t *create_device(void); 87 73 static void delete_device(ddf_dev_t *); … … 93 79 static void *function_get_ops(ddf_fun_t *, dev_inferface_idx_t); 94 80 95 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)96 {97 int id = (int)IPC_GET_IMETHOD(*icall);98 interrupt_context_t *ctx;99 100 ctx = find_interrupt_context_by_id(&interrupt_contexts, id);101 if (ctx != NULL && ctx->handler != NULL)102 (*ctx->handler)(ctx->dev, iid, icall);103 }104 105 interrupt_context_t *create_interrupt_context(void)106 {107 interrupt_context_t *ctx;108 109 ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));110 if (ctx != NULL)111 memset(ctx, 0, sizeof(interrupt_context_t));112 113 return ctx;114 }115 116 void delete_interrupt_context(interrupt_context_t *ctx)117 {118 if (ctx != NULL)119 free(ctx);120 }121 122 void init_interrupt_context_list(interrupt_context_list_t *list)123 {124 memset(list, 0, sizeof(interrupt_context_list_t));125 fibril_mutex_initialize(&list->mutex);126 list_initialize(&list->contexts);127 }128 129 void130 add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx)131 {132 fibril_mutex_lock(&list->mutex);133 ctx->id = list->curr_id++;134 list_append(&ctx->link, &list->contexts);135 fibril_mutex_unlock(&list->mutex);136 }137 138 void remove_interrupt_context(interrupt_context_list_t *list,139 interrupt_context_t *ctx)140 {141 fibril_mutex_lock(&list->mutex);142 list_remove(&ctx->link);143 fibril_mutex_unlock(&list->mutex);144 }145 146 interrupt_context_t *147 find_interrupt_context_by_id(interrupt_context_list_t *list, int id)148 {149 interrupt_context_t *ctx;150 151 fibril_mutex_lock(&list->mutex);152 153 list_foreach(list->contexts, link) {154 ctx = list_get_instance(link, interrupt_context_t, link);155 if (ctx->id == id) {156 fibril_mutex_unlock(&list->mutex);157 return ctx;158 }159 }160 161 fibril_mutex_unlock(&list->mutex);162 return NULL;163 }164 165 interrupt_context_t *166 find_interrupt_context(interrupt_context_list_t *list, ddf_dev_t *dev, int irq)167 {168 interrupt_context_t *ctx;169 170 fibril_mutex_lock(&list->mutex);171 172 list_foreach(list->contexts, link) {173 ctx = list_get_instance(link, interrupt_context_t, link);174 if (ctx->irq == irq && ctx->dev == dev) {175 fibril_mutex_unlock(&list->mutex);176 return ctx;177 }178 }179 180 fibril_mutex_unlock(&list->mutex);181 return NULL;182 }183 184 185 int186 register_interrupt_handler(ddf_dev_t *dev, int irq, interrupt_handler_t *handler,187 irq_code_t *pseudocode)188 {189 interrupt_context_t *ctx = create_interrupt_context();190 191 ctx->dev = dev;192 ctx->irq = irq;193 ctx->handler = handler;194 195 add_interrupt_context(&interrupt_contexts, ctx);196 197 if (pseudocode == NULL)198 pseudocode = &default_pseudocode;199 200 int res = register_irq(irq, dev->handle, ctx->id, pseudocode);201 if (res != EOK) {202 remove_interrupt_context(&interrupt_contexts, ctx);203 delete_interrupt_context(ctx);204 }205 206 return res;207 }208 209 int unregister_interrupt_handler(ddf_dev_t *dev, int irq)210 {211 interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts,212 dev, irq);213 int res = unregister_irq(irq, dev->handle);214 215 if (ctx != NULL) {216 remove_interrupt_context(&interrupt_contexts, ctx);217 delete_interrupt_context(ctx);218 }219 220 return res;221 }222 223 81 static void add_to_functions_list(ddf_fun_t *fun) 224 82 { … … 267 125 static void driver_dev_add(ipc_callid_t iid, ipc_call_t *icall) 268 126 { 269 char *dev_name = NULL;270 int res;271 272 127 devman_handle_t dev_handle = IPC_GET_ARG1(*icall); 273 128 devman_handle_t parent_fun_handle = IPC_GET_ARG2(*icall); 274 129 275 130 ddf_dev_t *dev = create_device(); 276 131 277 132 /* Add one reference that will be dropped by driver_dev_remove() */ 278 133 dev_add_ref(dev); 279 134 dev->handle = dev_handle; 280 135 136 char *dev_name = NULL; 281 137 async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0); 282 138 dev->name = dev_name; 283 139 284 140 /* 285 141 * Currently not used, parent fun handle is stored in context … … 288 144 (void) parent_fun_handle; 289 145 290 res = driver->driver_ops->add_device(dev);146 int res = driver->driver_ops->dev_add(dev); 291 147 292 148 if (res != EOK) { … … 303 159 } 304 160 305 static void driver_dev_added(ipc_callid_t iid, ipc_call_t *icall) 306 { 161 static void driver_dev_remove(ipc_callid_t iid, ipc_call_t *icall) 162 { 163 devman_handle_t devh = IPC_GET_ARG1(*icall); 164 307 165 fibril_mutex_lock(&devices_mutex); 308 ddf_dev_t *dev = driver_get_device(IPC_GET_ARG1(*icall)); 309 fibril_mutex_unlock(&devices_mutex); 310 311 if (dev != NULL && driver->driver_ops->device_added != NULL) 312 driver->driver_ops->device_added(dev); 313 } 314 315 static void driver_dev_remove(ipc_callid_t iid, ipc_call_t *icall) 316 { 317 devman_handle_t devh; 318 ddf_dev_t *dev; 319 int rc; 320 321 devh = IPC_GET_ARG1(*icall); 322 323 fibril_mutex_lock(&devices_mutex); 324 dev = driver_get_device(devh); 166 ddf_dev_t *dev = driver_get_device(devh); 325 167 if (dev != NULL) 326 168 dev_add_ref(dev); … … 331 173 return; 332 174 } 175 176 int rc; 333 177 334 178 if (driver->driver_ops->dev_remove != NULL) … … 345 189 static void driver_dev_gone(ipc_callid_t iid, ipc_call_t *icall) 346 190 { 347 devman_handle_t devh; 348 ddf_dev_t *dev; 349 int rc; 350 351 devh = IPC_GET_ARG1(*icall); 191 devman_handle_t devh = IPC_GET_ARG1(*icall); 352 192 353 193 fibril_mutex_lock(&devices_mutex); 354 d ev = driver_get_device(devh);194 ddf_dev_t *dev = driver_get_device(devh); 355 195 if (dev != NULL) 356 196 dev_add_ref(dev); … … 361 201 return; 362 202 } 203 204 int rc; 363 205 364 206 if (driver->driver_ops->dev_gone != NULL) … … 375 217 static void driver_fun_online(ipc_callid_t iid, ipc_call_t *icall) 376 218 { 377 devman_handle_t funh; 378 ddf_fun_t *fun; 379 int rc; 380 381 funh = IPC_GET_ARG1(*icall); 219 devman_handle_t funh = IPC_GET_ARG1(*icall); 382 220 383 221 /* … … 388 226 fibril_mutex_lock(&functions_mutex); 389 227 390 fun = driver_get_function(funh);228 ddf_fun_t *fun = driver_get_function(funh); 391 229 if (fun != NULL) 392 230 fun_add_ref(fun); … … 400 238 401 239 /* Call driver entry point */ 240 int rc; 241 402 242 if (driver->driver_ops->fun_online != NULL) 403 243 rc = driver->driver_ops->fun_online(fun); … … 412 252 static void driver_fun_offline(ipc_callid_t iid, ipc_call_t *icall) 413 253 { 414 devman_handle_t funh; 415 ddf_fun_t *fun; 416 int rc; 417 418 funh = IPC_GET_ARG1(*icall); 254 devman_handle_t funh = IPC_GET_ARG1(*icall); 419 255 420 256 /* … … 425 261 fibril_mutex_lock(&functions_mutex); 426 262 427 fun = driver_get_function(funh);263 ddf_fun_t *fun = driver_get_function(funh); 428 264 if (fun != NULL) 429 265 fun_add_ref(fun); … … 437 273 438 274 /* Call driver entry point */ 275 int rc; 276 439 277 if (driver->driver_ops->fun_offline != NULL) 440 278 rc = driver->driver_ops->fun_offline(fun); … … 460 298 case DRIVER_DEV_ADD: 461 299 driver_dev_add(callid, &call); 462 break;463 case DRIVER_DEV_ADDED:464 async_answer_0(callid, EOK);465 driver_dev_added(callid, &call);466 300 break; 467 301 case DRIVER_DEV_REMOVE: … … 751 585 752 586 /** Allocate driver-specific device data. */ 753 extern void *ddf_dev_data_alloc(ddf_dev_t *dev, size_t size) 754 { 755 void *data; 756 587 void *ddf_dev_data_alloc(ddf_dev_t *dev, size_t size) 588 { 757 589 assert(dev->driver_data == NULL); 758 759 data = calloc(1, size);590 591 void *data = calloc(1, size); 760 592 if (data == NULL) 761 593 return NULL; 762 594 763 595 dev->driver_data = data; 764 596 return data; … … 790 622 ddf_fun_t *ddf_fun_create(ddf_dev_t *dev, fun_type_t ftype, const char *name) 791 623 { 792 ddf_fun_t *fun; 793 794 fun = create_function(); 624 ddf_fun_t *fun = create_function(); 795 625 if (fun == NULL) 796 626 return NULL; 797 627 798 628 /* Add one reference that will be dropped by ddf_fun_destroy() */ 799 629 fun->dev = dev; 800 630 fun_add_ref(fun); 801 631 802 632 fun->bound = false; 803 633 fun->ftype = ftype; 804 634 805 635 fun->name = str_dup(name); 806 636 if (fun->name == NULL) { … … 808 638 return NULL; 809 639 } 810 640 811 641 return fun; 812 642 } 813 643 814 644 /** Allocate driver-specific function data. */ 815 extern void *ddf_fun_data_alloc(ddf_fun_t *fun, size_t size) 816 { 817 void *data; 818 645 void *ddf_fun_data_alloc(ddf_fun_t *fun, size_t size) 646 { 819 647 assert(fun->bound == false); 820 648 assert(fun->driver_data == NULL); 821 822 data = calloc(1, size);649 650 void *data = calloc(1, size); 823 651 if (data == NULL) 824 652 return NULL; 825 653 826 654 fun->driver_data = data; 827 655 return data; … … 833 661 * must not be bound. 834 662 * 835 * @param fun Function to destroy 663 * @param fun Function to destroy 664 * 836 665 */ 837 666 void ddf_fun_destroy(ddf_fun_t *fun) 838 667 { 839 668 assert(fun->bound == false); 840 669 841 670 /* 842 671 * Drop the reference added by ddf_fun_create(). This will deallocate … … 853 682 if (fun->ops == NULL) 854 683 return NULL; 684 855 685 return fun->ops->interfaces[idx]; 856 686 } … … 865 695 * the same name. 866 696 * 867 * @param fun Function to bind 868 * @return EOK on success or negative error code 697 * @param fun Function to bind 698 * 699 * @return EOK on success or negative error code 700 * 869 701 */ 870 702 int ddf_fun_bind(ddf_fun_t *fun) … … 873 705 assert(fun->name != NULL); 874 706 875 int res;876 877 707 add_to_functions_list(fun); 878 res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,708 int res = devman_add_function(fun->name, fun->ftype, &fun->match_ids, 879 709 fun->dev->handle, &fun->handle); 880 710 if (res != EOK) { … … 892 722 * the function invisible to the system. 893 723 * 894 * @param fun Function to unbind 895 * @return EOK on success or negative error code 724 * @param fun Function to unbind 725 * 726 * @return EOK on success or negative error code 727 * 896 728 */ 897 729 int ddf_fun_unbind(ddf_fun_t *fun) 898 730 { 899 int res;900 901 731 assert(fun->bound == true); 902 732 903 res = devman_remove_function(fun->handle);733 int res = devman_remove_function(fun->handle); 904 734 if (res != EOK) 905 735 return res; 906 736 907 737 remove_from_functions_list(fun); 908 738 … … 913 743 /** Online function. 914 744 * 915 * @param fun Function to online 916 * @return EOK on success or negative error code 745 * @param fun Function to online 746 * 747 * @return EOK on success or negative error code 748 * 917 749 */ 918 750 int ddf_fun_online(ddf_fun_t *fun) 919 751 { 920 int res;921 922 752 assert(fun->bound == true); 923 753 924 res = devman_drv_fun_online(fun->handle);754 int res = devman_drv_fun_online(fun->handle); 925 755 if (res != EOK) 926 756 return res; … … 931 761 /** Offline function. 932 762 * 933 * @param fun Function to offline 934 * @return EOK on success or negative error code 763 * @param fun Function to offline 764 * 765 * @return EOK on success or negative error code 766 * 935 767 */ 936 768 int ddf_fun_offline(ddf_fun_t *fun) 937 769 { 938 int res;939 940 770 assert(fun->bound == true); 941 771 942 res = devman_drv_fun_offline(fun->handle);772 int res = devman_drv_fun_offline(fun->handle); 943 773 if (res != EOK) 944 774 return res; … … 952 782 * Cannot be called when the function node is bound. 953 783 * 954 * @param fun Function 955 * @param match_id_str Match string 956 * @param match_score Match score 957 * @return EOK on success, ENOMEM if out of memory. 784 * @param fun Function 785 * @param match_id_str Match string 786 * @param match_score Match score 787 * 788 * @return EOK on success. 789 * @return ENOMEM if out of memory. 790 * 958 791 */ 959 792 int ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str, 960 793 int match_score) 961 794 { 962 match_id_t *match_id;963 964 795 assert(fun->bound == false); 965 796 assert(fun->ftype == fun_inner); 966 797 967 match_id = create_match_id();798 match_id_t *match_id = create_match_id(); 968 799 if (match_id == NULL) 969 800 return ENOMEM; 970 801 971 802 match_id->id = str_dup(match_id_str); 972 match_id->score = 90;803 match_id->score = match_score; 973 804 974 805 add_match_id(&fun->match_ids, match_id); … … 987 818 * 988 819 * Must only be called when the function is bound. 820 * 989 821 */ 990 822 int ddf_fun_add_to_category(ddf_fun_t *fun, const char *cat_name) … … 998 830 int ddf_driver_main(driver_t *drv) 999 831 { 1000 int rc;1001 1002 832 /* 1003 833 * Remember the driver structure - driver_ops will be called by generic … … 1006 836 driver = drv; 1007 837 1008 /* Initialize the list of interrupt contexts. */ 1009 init_interrupt_context_list(&interrupt_contexts); 1010 1011 /* Set generic interrupt handler. */ 1012 async_set_interrupt_received(driver_irq_handler); 838 /* Initialize interrupt module */ 839 interrupt_init(); 1013 840 1014 841 /* … … 1016 843 * incoming connections. 1017 844 */ 1018 rc = devman_driver_register(driver->name, driver_connection); 845 async_set_client_connection(driver_connection); 846 int rc = devman_driver_register(driver->name); 1019 847 if (rc != EOK) { 1020 848 printf("Error: Failed to register driver with device manager " … … 1022 850 str_error(rc)); 1023 851 1024 return 1;852 return rc; 1025 853 } 1026 854 … … 1028 856 rc = task_retval(0); 1029 857 if (rc != EOK) 1030 return 1;1031 858 return rc; 859 1032 860 async_manager(); 1033 861 1034 862 /* Never reached. */ 1035 return 0;863 return EOK; 1036 864 } 1037 865 -
uspace/lib/drv/generic/log.c
rba72f2b r6843a9c 33 33 #include <io/log.h> 34 34 #include <stdarg.h> 35 36 35 #include <ddf/log.h> 37 36 38 37 /** Initialize the logging system. 39 38 * 40 * @param drv_name Driver name, will be printed as part of message 41 * @param level Minimum message level to print 39 * @param drv_name Driver name, will be printed as part of message 40 * @param level Minimum message level to print 41 * 42 42 */ 43 43 int ddf_log_init(const char *drv_name, log_level_t level) … … 48 48 /** Log a driver message. 49 49 * 50 * @param level Message verbosity level. Message is only printed 51 * if verbosity is less than or equal to current 52 * reporting level. 53 * @param fmt Format string (no trailing newline) 50 * @param level Message verbosity level. Message is only printed 51 * if verbosity is less than or equal to current 52 * reporting level. 53 * @param fmt Format string (no trailing newline) 54 * 54 55 */ 55 56 void ddf_msg(log_level_t level, const char *fmt, ...) 56 57 { 57 58 va_list args; 58 59 59 60 va_start(args, fmt); 60 61 log_msgv(level, fmt, args); -
uspace/lib/drv/generic/logbuf.c
rba72f2b r6843a9c 35 35 #include <ddf/log.h> 36 36 #include <assert.h> 37 #include <unistd.h> 37 38 38 39 /** Formatting string for printing number of not-printed items. */ -
uspace/lib/drv/generic/remote_nic.c
rba72f2b r6843a9c 39 39 #include <errno.h> 40 40 #include <ipc/services.h> 41 #include <adt/measured_strings.h>42 41 #include <sys/time.h> 43 42 #include "ops/nic.h" 44 43 45 static void remote_nic_send_message(ddf_fun_t *dev, void *iface, 46 ipc_callid_t callid, ipc_call_t *call) 47 { 48 nic_iface_t *nic_iface = (nic_iface_t *) iface; 49 assert(nic_iface->send_message); 50 51 packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); 52 53 int rc = nic_iface->send_message(dev, packet_id); 54 async_answer_0(callid, rc); 55 } 56 57 static void remote_nic_connect_to_nil(ddf_fun_t *dev, void *iface, 58 ipc_callid_t callid, ipc_call_t *call) 59 { 60 nic_iface_t *nic_iface = (nic_iface_t *) iface; 61 assert(nic_iface->connect_to_nil); 62 63 services_t nil_service = (services_t) IPC_GET_ARG2(*call); 64 nic_device_id_t device_id = (nic_device_id_t) IPC_GET_ARG3(*call); 65 66 int rc = nic_iface->connect_to_nil(dev, nil_service, device_id); 44 static void remote_nic_send_frame(ddf_fun_t *dev, void *iface, 45 ipc_callid_t callid, ipc_call_t *call) 46 { 47 nic_iface_t *nic_iface = (nic_iface_t *) iface; 48 assert(nic_iface->send_frame); 49 50 void *data; 51 size_t size; 52 int rc; 53 54 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 55 if (rc != EOK) { 56 async_answer_0(callid, EINVAL); 57 return; 58 } 59 60 rc = nic_iface->send_frame(dev, data, size); 61 async_answer_0(callid, rc); 62 free(data); 63 } 64 65 static void remote_nic_callback_create(ddf_fun_t *dev, void *iface, 66 ipc_callid_t callid, ipc_call_t *call) 67 { 68 nic_iface_t *nic_iface = (nic_iface_t *) iface; 69 assert(nic_iface->callback_create); 70 71 int rc = nic_iface->callback_create(dev); 67 72 async_answer_0(callid, rc); 68 73 } … … 829 834 830 835 uint16_t tag = (uint16_t) IPC_GET_ARG2(*call); 831 intadd = (int) IPC_GET_ARG3(*call);832 intstrip = (int) IPC_GET_ARG4(*call);836 bool add = (int) IPC_GET_ARG3(*call); 837 bool strip = (int) IPC_GET_ARG4(*call); 833 838 834 839 int rc = nic_iface->vlan_set_tag(dev, tag, add, strip); … … 1194 1199 */ 1195 1200 static remote_iface_func_ptr_t remote_nic_iface_ops[] = { 1196 &remote_nic_send_ message,1197 &remote_nic_c onnect_to_nil,1201 &remote_nic_send_frame, 1202 &remote_nic_callback_create, 1198 1203 &remote_nic_get_state, 1199 1204 &remote_nic_set_state, -
uspace/lib/drv/generic/remote_pci.c
rba72f2b r6843a9c 32 32 /** @file 33 33 */ 34 34 35 #include <assert.h> 35 36 #include <async.h> -
uspace/lib/drv/generic/remote_usb.c
rba72f2b r6843a9c 1 1 /* 2 2 * Copyright (c) 2010 Vojtech Horky 3 * Copyright (c) 2011 Jan Vesely 3 4 * All rights reserved. 4 5 * … … 39 40 #include "ddf/driver.h" 40 41 42 typedef enum { 43 IPC_M_USB_GET_MY_ADDRESS, 44 IPC_M_USB_GET_MY_INTERFACE, 45 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, 46 } usb_iface_funcs_t; 41 47 42 static void remote_usb_get_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 43 static void remote_usb_get_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 48 /** Tell USB address assigned to device. 49 * @param exch Vaid IPC exchange 50 * @param address Pointer to address storage place. 51 * @return Error code. 52 * 53 * Exch param is an open communication to device implementing usb_iface. 54 */ 55 int usb_get_my_address(async_exch_t *exch, usb_address_t *address) 56 { 57 if (!exch) 58 return EINVAL; 59 sysarg_t addr; 60 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 61 IPC_M_USB_GET_MY_ADDRESS, &addr); 62 63 if (ret == EOK && address != NULL) 64 *address = (usb_address_t) addr; 65 return ret; 66 } 67 /*----------------------------------------------------------------------------*/ 68 /** Tell interface number given device can use. 69 * @param[in] exch IPC communication exchange 70 * @param[in] handle Id of the device 71 * @param[out] usb_iface Assigned USB interface 72 * @return Error code. 73 */ 74 int usb_get_my_interface(async_exch_t *exch, int *usb_iface) 75 { 76 if (!exch) 77 return EINVAL; 78 sysarg_t iface_no; 79 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 80 IPC_M_USB_GET_MY_INTERFACE, &iface_no); 81 if (ret == EOK && usb_iface) 82 *usb_iface = (int)iface_no; 83 return ret; 84 } 85 /*----------------------------------------------------------------------------*/ 86 /** Tell devman handle of device host controller. 87 * @param[in] exch IPC communication exchange 88 * @param[out] hc_handle devman handle of the HC used by the target device. 89 * @return Error code. 90 */ 91 int usb_get_hc_handle(async_exch_t *exch, devman_handle_t *hc_handle) 92 { 93 if (!exch) 94 return EINVAL; 95 devman_handle_t h; 96 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 97 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h); 98 if (ret == EOK && hc_handle) 99 *hc_handle = (devman_handle_t)h; 100 return ret; 101 } 102 103 104 static void remote_usb_get_my_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 105 static void remote_usb_get_my_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 44 106 static void remote_usb_get_hc_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 45 //static void remote_usb(device_t *, void *, ipc_callid_t, ipc_call_t *);46 107 47 108 /** Remote USB interface operations. */ 48 109 static remote_iface_func_ptr_t remote_usb_iface_ops [] = { 49 remote_usb_get_address,50 remote_usb_get_interface,51 remote_usb_get_hc_handle110 [IPC_M_USB_GET_MY_ADDRESS] = remote_usb_get_my_address, 111 [IPC_M_USB_GET_MY_INTERFACE] = remote_usb_get_my_interface, 112 [IPC_M_USB_GET_HOST_CONTROLLER_HANDLE] = remote_usb_get_hc_handle, 52 113 }; 53 114 … … 60 121 }; 61 122 62 63 void remote_usb_get_ address(ddf_fun_t *fun, void *iface,123 /*----------------------------------------------------------------------------*/ 124 void remote_usb_get_my_address(ddf_fun_t *fun, void *iface, 64 125 ipc_callid_t callid, ipc_call_t *call) 65 126 { 66 usb_iface_t *usb_iface = (usb_iface_t *) iface;127 const usb_iface_t *usb_iface = (usb_iface_t *) iface; 67 128 68 if (usb_iface->get_ address == NULL) {129 if (usb_iface->get_my_address == NULL) { 69 130 async_answer_0(callid, ENOTSUP); 70 131 return; 71 132 } 72 133 73 devman_handle_t handle = DEV_IPC_GET_ARG1(*call);74 75 134 usb_address_t address; 76 int rc = usb_iface->get_address(fun, handle, &address);77 if (r c!= EOK) {78 async_answer_0(callid, r c);135 const int ret = usb_iface->get_my_address(fun, &address); 136 if (ret != EOK) { 137 async_answer_0(callid, ret); 79 138 } else { 80 139 async_answer_1(callid, EOK, address); 81 140 } 82 141 } 83 84 void remote_usb_get_ interface(ddf_fun_t *fun, void *iface,142 /*----------------------------------------------------------------------------*/ 143 void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface, 85 144 ipc_callid_t callid, ipc_call_t *call) 86 145 { 87 usb_iface_t *usb_iface = (usb_iface_t *) iface;146 const usb_iface_t *usb_iface = (usb_iface_t *) iface; 88 147 89 if (usb_iface->get_ interface == NULL) {148 if (usb_iface->get_my_interface == NULL) { 90 149 async_answer_0(callid, ENOTSUP); 91 150 return; 92 151 } 93 152 94 devman_handle_t handle = DEV_IPC_GET_ARG1(*call);95 96 153 int iface_no; 97 int rc = usb_iface->get_interface(fun, handle, &iface_no);98 if (r c!= EOK) {99 async_answer_0(callid, r c);154 const int ret = usb_iface->get_my_interface(fun, &iface_no); 155 if (ret != EOK) { 156 async_answer_0(callid, ret); 100 157 } else { 101 158 async_answer_1(callid, EOK, iface_no); 102 159 } 103 160 } 104 161 /*----------------------------------------------------------------------------*/ 105 162 void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface, 106 163 ipc_callid_t callid, ipc_call_t *call) 107 164 { 108 usb_iface_t *usb_iface = (usb_iface_t *) iface;165 const usb_iface_t *usb_iface = (usb_iface_t *) iface; 109 166 110 167 if (usb_iface->get_hc_handle == NULL) { … … 114 171 115 172 devman_handle_t handle; 116 int rc= usb_iface->get_hc_handle(fun, &handle);117 if (r c!= EOK) {118 async_answer_0(callid, r c);173 const int ret = usb_iface->get_hc_handle(fun, &handle); 174 if (ret != EOK) { 175 async_answer_0(callid, ret); 119 176 } 120 177 121 178 async_answer_1(callid, EOK, (sysarg_t) handle); 122 179 } 123 124 125 126 180 /** 127 181 * @} -
uspace/lib/drv/generic/remote_usbhc.c
rba72f2b r6843a9c 1 1 /* 2 2 * Copyright (c) 2010-2011 Vojtech Horky 3 * Copyright (c) 2011 Jan Vesely 3 4 * All rights reserved. 4 5 * … … 42 43 #define USB_MAX_PAYLOAD_SIZE 1020 43 44 45 /** IPC methods for communication with HC through DDF interface. 46 * 47 * Notes for async methods: 48 * 49 * Methods for sending data to device (OUT transactions) 50 * - e.g. IPC_M_USBHC_INTERRUPT_OUT - 51 * always use the same semantics: 52 * - first, IPC call with given method is made 53 * - argument #1 is target address 54 * - argument #2 is target endpoint 55 * - argument #3 is max packet size of the endpoint 56 * - this call is immediately followed by IPC data write (from caller) 57 * - the initial call (and the whole transaction) is answer after the 58 * transaction is scheduled by the HC and acknowledged by the device 59 * or immediately after error is detected 60 * - the answer carries only the error code 61 * 62 * Methods for retrieving data from device (IN transactions) 63 * - e.g. IPC_M_USBHC_INTERRUPT_IN - 64 * also use the same semantics: 65 * - first, IPC call with given method is made 66 * - argument #1 is target address 67 * - argument #2 is target endpoint 68 * - this call is immediately followed by IPC data read (async version) 69 * - the call is not answered until the device returns some data (or until 70 * error occurs) 71 * 72 * Some special methods (NO-DATA transactions) do not send any data. These 73 * might behave as both OUT or IN transactions because communication parts 74 * where actual buffers are exchanged are omitted. 75 ** 76 * For all these methods, wrap functions exists. Important rule: functions 77 * for IN transactions have (as parameters) buffers where retrieved data 78 * will be stored. These buffers must be already allocated and shall not be 79 * touch until the transaction is completed 80 * (e.g. not before calling usb_wait_for() with appropriate handle). 81 * OUT transactions buffers can be freed immediately after call is dispatched 82 * (i.e. after return from wrapping function). 83 * 84 */ 85 typedef enum { 86 /** Asks for address assignment by host controller. 87 * Answer: 88 * - ELIMIT - host controller run out of address 89 * - EOK - address assigned 90 * Answer arguments: 91 * - assigned address 92 * 93 * The address must be released by via IPC_M_USBHC_RELEASE_ADDRESS. 94 */ 95 IPC_M_USBHC_REQUEST_ADDRESS, 96 97 /** Bind USB address with devman handle. 98 * Parameters: 99 * - USB address 100 * - devman handle 101 * Answer: 102 * - EOK - address binded 103 * - ENOENT - address is not in use 104 */ 105 IPC_M_USBHC_BIND_ADDRESS, 106 107 /** Get handle binded with given USB address. 108 * Parameters 109 * - USB address 110 * Answer: 111 * - EOK - address binded, first parameter is the devman handle 112 * - ENOENT - address is not in use at the moment 113 */ 114 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, 115 116 /** Release address in use. 117 * Arguments: 118 * - address to be released 119 * Answer: 120 * - ENOENT - address not in use 121 * - EPERM - trying to release default USB address 122 */ 123 IPC_M_USBHC_RELEASE_ADDRESS, 124 125 /** Register endpoint attributes at host controller. 126 * This is used to reserve portion of USB bandwidth. 127 * When speed is invalid, speed of the device is used. 128 * Parameters: 129 * - USB address + endpoint number 130 * - packed as ADDR << 16 + EP 131 * - speed + transfer type + direction 132 * - packed as ( SPEED << 8 + TYPE ) << 8 + DIR 133 * - maximum packet size + interval (in milliseconds) 134 * - packed as MPS << 16 + INT 135 * Answer: 136 * - EOK - reservation successful 137 * - ELIMIT - not enough bandwidth to satisfy the request 138 */ 139 IPC_M_USBHC_REGISTER_ENDPOINT, 140 141 /** Revert endpoint registration. 142 * Parameters: 143 * - USB address 144 * - endpoint number 145 * - data direction 146 * Answer: 147 * - EOK - endpoint unregistered 148 * - ENOENT - unknown endpoint 149 */ 150 IPC_M_USBHC_UNREGISTER_ENDPOINT, 151 152 /** Get data from device. 153 * See explanation at usb_iface_funcs_t (IN transaction). 154 */ 155 IPC_M_USBHC_READ, 156 157 /** Send data to device. 158 * See explanation at usb_iface_funcs_t (OUT transaction). 159 */ 160 IPC_M_USBHC_WRITE, 161 } usbhc_iface_funcs_t; 162 163 int usbhc_request_address(async_exch_t *exch, usb_address_t *address, 164 bool strict, usb_speed_t speed) 165 { 166 if (!exch || !address) 167 return EINVAL; 168 sysarg_t new_address; 169 const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 170 IPC_M_USBHC_REQUEST_ADDRESS, *address, strict, speed, &new_address); 171 if (ret == EOK) 172 *address = (usb_address_t)new_address; 173 return ret; 174 } 175 /*----------------------------------------------------------------------------*/ 176 int usbhc_bind_address(async_exch_t *exch, usb_address_t address, 177 devman_handle_t handle) 178 { 179 if (!exch) 180 return EINVAL; 181 return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 182 IPC_M_USBHC_BIND_ADDRESS, address, handle); 183 } 184 /*----------------------------------------------------------------------------*/ 185 int usbhc_get_handle(async_exch_t *exch, usb_address_t address, 186 devman_handle_t *handle) 187 { 188 if (!exch) 189 return EINVAL; 190 sysarg_t h; 191 const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 192 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, address, &h); 193 if (ret == EOK && handle) 194 *handle = (devman_handle_t)h; 195 return ret; 196 } 197 /*----------------------------------------------------------------------------*/ 198 int usbhc_release_address(async_exch_t *exch, usb_address_t address) 199 { 200 if (!exch) 201 return EINVAL; 202 return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 203 IPC_M_USBHC_RELEASE_ADDRESS, address); 204 } 205 /*----------------------------------------------------------------------------*/ 206 int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address, 207 usb_endpoint_t endpoint, usb_transfer_type_t type, 208 usb_direction_t direction, size_t mps, unsigned interval) 209 { 210 if (!exch) 211 return EINVAL; 212 const usb_target_t target = 213 {{ .address = address, .endpoint = endpoint }}; 214 #define _PACK2(high, low) (((high & 0xffff) << 16) | (low & 0xffff)) 215 216 return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 217 IPC_M_USBHC_REGISTER_ENDPOINT, target.packed, 218 _PACK2(type, direction), _PACK2(mps, interval)); 219 220 #undef _PACK2 221 } 222 /*----------------------------------------------------------------------------*/ 223 int usbhc_unregister_endpoint(async_exch_t *exch, usb_address_t address, 224 usb_endpoint_t endpoint, usb_direction_t direction) 225 { 226 if (!exch) 227 return EINVAL; 228 return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 229 IPC_M_USBHC_UNREGISTER_ENDPOINT, address, endpoint, direction); 230 } 231 /*----------------------------------------------------------------------------*/ 232 int usbhc_read(async_exch_t *exch, usb_address_t address, 233 usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size, 234 size_t *rec_size) 235 { 236 if (size == 0 && setup == 0) 237 return EOK; 238 239 if (!exch) 240 return EINVAL; 241 const usb_target_t target = 242 {{ .address = address, .endpoint = endpoint }}; 243 244 /* Make call identifying target USB device and type of transfer. */ 245 aid_t opening_request = async_send_4(exch, 246 DEV_IFACE_ID(USBHC_DEV_IFACE), 247 IPC_M_USBHC_READ, target.packed, 248 (setup & UINT32_MAX), (setup >> 32), NULL); 249 250 if (opening_request == 0) { 251 return ENOMEM; 252 } 253 254 /* Retrieve the data. */ 255 ipc_call_t data_request_call; 256 aid_t data_request = 257 async_data_read(exch, data, size, &data_request_call); 258 259 if (data_request == 0) { 260 // FIXME: How to let the other side know that we want to abort? 261 async_forget(opening_request); 262 return ENOMEM; 263 } 264 265 /* Wait for the answer. */ 266 sysarg_t data_request_rc; 267 sysarg_t opening_request_rc; 268 async_wait_for(data_request, &data_request_rc); 269 async_wait_for(opening_request, &opening_request_rc); 270 271 if (data_request_rc != EOK) { 272 /* Prefer the return code of the opening request. */ 273 if (opening_request_rc != EOK) { 274 return (int) opening_request_rc; 275 } else { 276 return (int) data_request_rc; 277 } 278 } 279 if (opening_request_rc != EOK) { 280 return (int) opening_request_rc; 281 } 282 283 *rec_size = IPC_GET_ARG2(data_request_call); 284 return EOK; 285 } 286 /*----------------------------------------------------------------------------*/ 287 int usbhc_write(async_exch_t *exch, usb_address_t address, 288 usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size) 289 { 290 if (size == 0 && setup == 0) 291 return EOK; 292 293 if (!exch) 294 return EINVAL; 295 const usb_target_t target = 296 {{ .address = address, .endpoint = endpoint }}; 297 298 aid_t opening_request = async_send_5(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 299 IPC_M_USBHC_WRITE, target.packed, size, 300 (setup & UINT32_MAX), (setup >> 32), NULL); 301 302 if (opening_request == 0) { 303 return ENOMEM; 304 } 305 306 /* Send the data if any. */ 307 if (size > 0) { 308 const int ret = async_data_write_start(exch, data, size); 309 if (ret != EOK) { 310 async_forget(opening_request); 311 return ret; 312 } 313 } 314 315 /* Wait for the answer. */ 316 sysarg_t opening_request_rc; 317 async_wait_for(opening_request, &opening_request_rc); 318 319 return (int) opening_request_rc; 320 } 321 /*----------------------------------------------------------------------------*/ 322 44 323 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 45 324 static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 46 static void remote_usbhc_ find_by_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);325 static void remote_usbhc_get_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 47 326 static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 48 327 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 55 334 static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = { 56 335 [IPC_M_USBHC_REQUEST_ADDRESS] = remote_usbhc_request_address, 336 [IPC_M_USBHC_RELEASE_ADDRESS] = remote_usbhc_release_address, 57 337 [IPC_M_USBHC_BIND_ADDRESS] = remote_usbhc_bind_address, 58 [IPC_M_USBHC_GET_HANDLE_BY_ADDRESS] = remote_usbhc_find_by_address, 59 [IPC_M_USBHC_RELEASE_ADDRESS] = remote_usbhc_release_address, 338 [IPC_M_USBHC_GET_HANDLE_BY_ADDRESS] = remote_usbhc_get_handle, 60 339 61 340 [IPC_M_USBHC_REGISTER_ENDPOINT] = remote_usbhc_register_endpoint, … … 78 357 ipc_callid_t data_caller; 79 358 void *buffer; 80 size_t size;81 359 } async_transaction_t; 82 360 … … 103 381 trans->data_caller = 0; 104 382 trans->buffer = NULL; 105 trans->size = 0;106 383 107 384 return trans; 108 385 } 109 386 /*----------------------------------------------------------------------------*/ 110 387 void remote_usbhc_request_address(ddf_fun_t *fun, void *iface, 111 388 ipc_callid_t callid, ipc_call_t *call) 112 389 { 113 usbhc_iface_t *usb_iface = (usbhc_iface_t *)iface;390 const usbhc_iface_t *usb_iface = iface; 114 391 115 392 if (!usb_iface->request_address) { … … 118 395 } 119 396 120 usb_speed_t speed = DEV_IPC_GET_ARG1(*call); 121 122 usb_address_t address; 123 int rc = usb_iface->request_address(fun, speed, &address); 397 usb_address_t address = DEV_IPC_GET_ARG1(*call); 398 const bool strict = DEV_IPC_GET_ARG2(*call); 399 const usb_speed_t speed = DEV_IPC_GET_ARG3(*call); 400 401 const int rc = usb_iface->request_address(fun, &address, strict, speed); 124 402 if (rc != EOK) { 125 403 async_answer_0(callid, rc); … … 128 406 } 129 407 } 130 408 /*----------------------------------------------------------------------------*/ 131 409 void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface, 132 410 ipc_callid_t callid, ipc_call_t *call) 133 411 { 134 usbhc_iface_t *usb_iface = (usbhc_iface_t *)iface;412 const usbhc_iface_t *usb_iface = iface; 135 413 136 414 if (!usb_iface->bind_address) { … … 139 417 } 140 418 141 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 142 devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call); 143 144 int rc = usb_iface->bind_address(fun, address, handle); 145 146 async_answer_0(callid, rc); 147 } 148 149 void remote_usbhc_find_by_address(ddf_fun_t *fun, void *iface, 419 const usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 420 const devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call); 421 422 const int ret = usb_iface->bind_address(fun, address, handle); 423 async_answer_0(callid, ret); 424 } 425 /*----------------------------------------------------------------------------*/ 426 void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface, 150 427 ipc_callid_t callid, ipc_call_t *call) 151 428 { 152 usbhc_iface_t *usb_iface = (usbhc_iface_t *)iface;153 154 if (!usb_iface-> find_by_address) {155 async_answer_0(callid, ENOTSUP); 156 return; 157 } 158 159 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);429 const usbhc_iface_t *usb_iface = iface; 430 431 if (!usb_iface->get_handle) { 432 async_answer_0(callid, ENOTSUP); 433 return; 434 } 435 436 const usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 160 437 devman_handle_t handle; 161 int rc = usb_iface->find_by_address(fun, address, &handle);162 163 if (r c== EOK) {164 async_answer_1(callid, EOK, handle);438 const int ret = usb_iface->get_handle(fun, address, &handle); 439 440 if (ret == EOK) { 441 async_answer_1(callid, ret, handle); 165 442 } else { 166 async_answer_0(callid, r c);167 } 168 } 169 443 async_answer_0(callid, ret); 444 } 445 } 446 /*----------------------------------------------------------------------------*/ 170 447 void remote_usbhc_release_address(ddf_fun_t *fun, void *iface, 171 448 ipc_callid_t callid, ipc_call_t *call) 172 449 { 173 usbhc_iface_t *usb_iface = (usbhc_iface_t *)iface;450 const usbhc_iface_t *usb_iface = iface; 174 451 175 452 if (!usb_iface->release_address) { … … 178 455 } 179 456 180 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 181 182 int rc = usb_iface->release_address(fun, address); 183 184 async_answer_0(callid, rc); 185 } 186 187 457 const usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 458 459 const int ret = usb_iface->release_address(fun, address); 460 async_answer_0(callid, ret); 461 } 462 /*----------------------------------------------------------------------------*/ 188 463 static void callback_out(ddf_fun_t *fun, 189 464 int outcome, void *arg) 190 465 { 191 async_transaction_t *trans = (async_transaction_t *)arg;466 async_transaction_t *trans = arg; 192 467 193 468 async_answer_0(trans->caller, outcome); … … 195 470 async_transaction_destroy(trans); 196 471 } 197 472 /*----------------------------------------------------------------------------*/ 198 473 static void callback_in(ddf_fun_t *fun, 199 474 int outcome, size_t actual_size, void *arg) … … 210 485 } 211 486 212 trans->size = actual_size;213 214 487 if (trans->data_caller) { 215 488 async_data_read_finalize(trans->data_caller, … … 221 494 async_transaction_destroy(trans); 222 495 } 223 496 /*----------------------------------------------------------------------------*/ 224 497 void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface, 225 498 ipc_callid_t callid, ipc_call_t *call) … … 233 506 234 507 #define _INIT_FROM_HIGH_DATA2(type, var, arg_no) \ 235 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / (1 <<16)508 type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) >> 16) 236 509 #define _INIT_FROM_LOW_DATA2(type, var, arg_no) \ 237 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 16) 238 #define _INIT_FROM_HIGH_DATA3(type, var, arg_no) \ 239 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / (1 << 16) 240 #define _INIT_FROM_MIDDLE_DATA3(type, var, arg_no) \ 241 type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) / (1 << 8)) % (1 << 8) 242 #define _INIT_FROM_LOW_DATA3(type, var, arg_no) \ 243 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 8) 510 type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) & 0xffff) 244 511 245 512 const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) }; 246 513 247 _INIT_FROM_HIGH_DATA3(usb_speed_t, speed, 2); 248 _INIT_FROM_MIDDLE_DATA3(usb_transfer_type_t, transfer_type, 2); 249 _INIT_FROM_LOW_DATA3(usb_direction_t, direction, 2); 514 _INIT_FROM_HIGH_DATA2(usb_transfer_type_t, transfer_type, 2); 515 _INIT_FROM_LOW_DATA2(usb_direction_t, direction, 2); 250 516 251 517 _INIT_FROM_HIGH_DATA2(size_t, max_packet_size, 3); … … 254 520 #undef _INIT_FROM_HIGH_DATA2 255 521 #undef _INIT_FROM_LOW_DATA2 256 #undef _INIT_FROM_HIGH_DATA3 257 #undef _INIT_FROM_MIDDLE_DATA3 258 #undef _INIT_FROM_LOW_DATA3 259 260 int rc = usb_iface->register_endpoint(fun, target.address, speed, 522 523 int rc = usb_iface->register_endpoint(fun, target.address, 261 524 target.endpoint, transfer_type, direction, max_packet_size, interval); 262 525 … … 309 572 } 310 573 311 if (!async_data_read_receive(&trans->data_caller, &trans->size)) { 574 size_t size = 0; 575 if (!async_data_read_receive(&trans->data_caller, &size)) { 312 576 async_answer_0(callid, EPARTY); 313 577 return; 314 578 } 315 579 316 trans->buffer = malloc( trans->size);580 trans->buffer = malloc(size); 317 581 if (trans->buffer == NULL) { 318 582 async_answer_0(trans->data_caller, ENOMEM); … … 322 586 323 587 const int rc = hc_iface->read( 324 fun, target, setup, trans->buffer, trans->size, callback_in, trans);588 fun, target, setup, trans->buffer, size, callback_in, trans); 325 589 326 590 if (rc != EOK) { … … 330 594 } 331 595 } 332 596 /*----------------------------------------------------------------------------*/ 333 597 void remote_usbhc_write( 334 598 ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) … … 357 621 } 358 622 623 size_t size = 0; 359 624 if (data_buffer_len > 0) { 360 int rc = async_data_write_accept(&trans->buffer, false,625 const int rc = async_data_write_accept(&trans->buffer, false, 361 626 1, USB_MAX_PAYLOAD_SIZE, 362 0, & trans->size);627 0, &size); 363 628 364 629 if (rc != EOK) { … … 369 634 } 370 635 371 int rc = hc_iface->write(372 fun, target, setup, trans->buffer, trans->size, callback_out, trans);636 const int rc = hc_iface->write( 637 fun, target, setup, trans->buffer, size, callback_out, trans); 373 638 374 639 if (rc != EOK) { … … 377 642 } 378 643 } 379 380 381 644 /** 382 645 * @}
Note:
See TracChangeset
for help on using the changeset viewer.