Changeset b8a3cda in mainline for uspace/srv/hw/bus/usb/hcd/virtual/connhost.c
- Timestamp:
- 2010-10-22T14:57:03Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7a7bfeb3
- Parents:
- 954ea70
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/bus/usb/hcd/virtual/connhost.c
r954ea70 rb8a3cda 84 84 &answer_data); 85 85 86 rc = async_data_write_start(trans->phone, buffer, len); 87 if (rc != EOK) { 88 async_wait_for(req, NULL); 89 goto leave; 86 if (len > 0) { 87 rc = async_data_write_start(trans->phone, buffer, len); 88 if (rc != EOK) { 89 async_wait_for(req, NULL); 90 goto leave; 91 } 90 92 } 91 93 … … 98 100 leave: 99 101 free(trans); 100 free(buffer); 102 if (buffer != NULL) { 103 free(buffer); 104 } 101 105 } 102 106 103 107 /** Handle data from host to function. 104 108 */ 105 static void handle_data_to_function(ipc_callid_t iid, ipc_call_t icall, int callback_phone) 106 { 107 usb_transfer_type_t transf_type = IPC_GET_ARG3(icall); 109 static void handle_data_to_function(ipc_callid_t iid, ipc_call_t icall, 110 bool setup_transaction, int callback_phone) 111 { 112 size_t expected_len = IPC_GET_ARG3(icall); 108 113 usb_target_t target = { 109 114 .address = IPC_GET_ARG1(icall), … … 111 116 }; 112 117 113 dprintf("pretending transfer to function (dev=%d:%d, type=%s)", 114 target.address, target.endpoint, 115 usb_str_transfer_type(transf_type)); 118 dprintf("pretending transfer to function (dev=%d:%d)", 119 target.address, target.endpoint); 116 120 117 121 if (callback_phone == -1) { … … 123 127 = create_transaction_handle(callback_phone); 124 128 125 size_t len; 126 void * buffer; 127 int rc = async_data_write_accept(&buffer, false, 128 1, USB_MAX_PAYLOAD_SIZE, 129 0, &len); 130 131 if (rc != EOK) { 132 ipc_answer_0(iid, rc); 133 return; 129 size_t len = 0; 130 void * buffer = NULL; 131 if (expected_len > 0) { 132 int rc = async_data_write_accept(&buffer, false, 133 1, USB_MAX_PAYLOAD_SIZE, 134 0, &len); 135 136 if (rc != EOK) { 137 ipc_answer_0(iid, rc); 138 return; 139 } 134 140 } 135 141 … … 139 145 140 146 dprintf("adding transaction to HC", NAME); 141 hc_add_transaction_to_device( transf_type, target,147 hc_add_transaction_to_device(setup_transaction, target, 142 148 buffer, len, 143 149 out_callback, trans); … … 151 157 static void handle_data_from_function(ipc_callid_t iid, ipc_call_t icall, int callback_phone) 152 158 { 153 usb_transfer_type_t transf_type = IPC_GET_ARG3(icall);154 159 usb_target_t target = { 155 160 .address = IPC_GET_ARG1(icall), 156 161 .endpoint = IPC_GET_ARG2(icall) 157 162 }; 158 size_t len = IPC_GET_ARG4(icall); 159 160 dprintf("pretending transfer from function (dev=%d:%d, type=%s)", 161 target.address, target.endpoint, 162 usb_str_transfer_type(transf_type)); 163 size_t len = IPC_GET_ARG3(icall); 164 165 dprintf("pretending transfer from function (dev=%d:%d)", 166 target.address, target.endpoint); 163 167 164 168 if (callback_phone == -1) { … … 170 174 = create_transaction_handle(callback_phone); 171 175 172 void * buffer = malloc(len); 176 void * buffer = NULL; 177 if (len > 0) { 178 buffer = malloc(len); 179 } 173 180 174 181 transaction_details_t * trans = malloc(sizeof(transaction_details_t)); … … 177 184 178 185 dprintf("adding transaction to HC", NAME); 179 hc_add_transaction_from_device(t ransf_type, target,186 hc_add_transaction_from_device(target, 180 187 buffer, len, 181 188 in_callback, trans); … … 219 226 220 227 case IPC_M_USB_HCD_SEND_DATA: 221 handle_data_to_function(callid, call, host_phone); 228 handle_data_to_function(callid, call, 229 false, host_phone); 222 230 break; 223 231 … … 230 238 break; 231 239 240 241 case IPC_M_USB_HCD_INTERRUPT_OUT: 242 handle_data_to_function(callid, call, 243 false, host_phone); 244 break; 245 246 case IPC_M_USB_HCD_INTERRUPT_IN: 247 handle_data_from_function(callid, call, host_phone); 248 break; 249 250 case IPC_M_USB_HCD_CONTROL_WRITE_SETUP: 251 handle_data_to_function(callid, call, 252 true, host_phone); 253 break; 254 255 case IPC_M_USB_HCD_CONTROL_WRITE_DATA: 256 handle_data_to_function(callid, call, 257 false, host_phone); 258 break; 259 260 case IPC_M_USB_HCD_CONTROL_WRITE_STATUS: 261 handle_data_from_function(callid, call, host_phone); 262 break; 263 264 case IPC_M_USB_HCD_CONTROL_READ_SETUP: 265 handle_data_to_function(callid, call, 266 true, host_phone); 267 break; 268 269 case IPC_M_USB_HCD_CONTROL_READ_DATA: 270 case IPC_M_USB_HCD_CONTROL_READ_STATUS: 271 232 272 default: 233 273 ipc_answer_0(callid, EINVAL);
Note:
See TracChangeset
for help on using the changeset viewer.