Changeset 34586183 in mainline for uspace/lib/usb/hcd.c
- Timestamp:
- 2010-10-22T12:38:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b791e3e
- Parents:
- 6c741e1d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/hcd.c
r6c741e1d r34586183 211 211 } 212 212 213 214 static int send_buffer(int phone, ipcarg_t method, usb_target_t target, 215 void *buffer, size_t size, usb_transaction_handle_t * transaction_handle) 216 { 217 if (phone < 0) { 218 return EINVAL; 219 } 220 221 if ((buffer == NULL) && (size > 0)) { 222 return EINVAL; 223 } 224 225 ipc_call_t answer_data; 226 ipcarg_t answer_rc; 227 aid_t req; 228 int rc; 229 230 req = async_send_3(phone, 231 method, 232 target.address, target.endpoint, 233 size, 234 &answer_data); 235 236 if (size > 0) { 237 rc = async_data_write_start(phone, buffer, size); 238 if (rc != EOK) { 239 async_wait_for(req, NULL); 240 return rc; 241 } 242 } 243 244 async_wait_for(req, &answer_rc); 245 rc = (int)answer_rc; 246 if (rc != EOK) { 247 return rc; 248 } 249 250 if (transaction_handle != NULL) { 251 *transaction_handle = IPC_GET_ARG1(answer_data); 252 } 253 254 return EOK; 255 } 256 257 258 static int prep_receive_data(int phone, ipcarg_t method, usb_target_t target, 259 size_t size, usb_transaction_handle_t * transaction_handle) 260 { 261 if (phone < 0) { 262 return EINVAL; 263 } 264 265 usb_transaction_handle_t handle; 266 267 int rc = ipc_call_sync_3_1(phone, 268 method, 269 target.address, target.endpoint, 270 size, 271 &handle); 272 273 if (rc != EOK) { 274 return rc; 275 } 276 277 if (transaction_handle != NULL) { 278 *transaction_handle = handle; 279 } 280 281 return EOK; 282 } 283 284 285 int usb_hcd_transfer_interrupt_out(int hcd_phone, usb_target_t target, 286 void *buffer, size_t size, usb_transaction_handle_t *handle) 287 { 288 return send_buffer(hcd_phone, IPC_M_USB_HCD_INTERRUPT_OUT, 289 target, buffer, size, handle); 290 } 291 292 int usb_hcd_transfer_interrupt_in(int hcd_phone, usb_target_t target, 293 size_t size, usb_transaction_handle_t *handle) 294 { 295 return prep_receive_data(hcd_phone, IPC_M_USB_HCD_INTERRUPT_IN, 296 target, size, handle); 297 } 298 299 int usb_hcd_transfer_control_write_setup(int hcd_phone, usb_target_t target, 300 void *buffer, size_t size, usb_transaction_handle_t *handle) 301 { 302 return send_buffer(hcd_phone, IPC_M_USB_HCD_CONTROL_WRITE_SETUP, 303 target, buffer, size, handle); 304 } 305 306 int usb_hcd_transfer_control_write_data(int hcd_phone, usb_target_t target, 307 void *buffer, size_t size, usb_transaction_handle_t *handle) 308 { 309 return send_buffer(hcd_phone, IPC_M_USB_HCD_CONTROL_WRITE_DATA, 310 target, buffer, size, handle); 311 312 } 313 int usb_hcd_transfer_control_write_status(int hcd_phone, usb_target_t target, 314 usb_transaction_handle_t *handle) 315 { 316 usb_transaction_handle_t h; 317 int rc = ipc_call_sync_2_1(hcd_phone, 318 IPC_M_USB_HCD_CONTROL_WRITE_STATUS, 319 target.address, target.endpoint, 320 &h); 321 if (rc != EOK) { 322 return rc; 323 } 324 325 if (handle != NULL) { 326 *handle = h; 327 } 328 329 return rc; 330 } 331 332 int usb_hcd_transfer_control_read_setup(int hcd_phone, usb_target_t target, 333 void *buffer, size_t size, usb_transaction_handle_t *handle) 334 { 335 return send_buffer(hcd_phone, IPC_M_USB_HCD_CONTROL_READ_SETUP, 336 target, buffer, size, handle); 337 } 338 int usb_hcd_transfer_control_read_data(int hcd_phone, usb_target_t target, 339 size_t size, usb_transaction_handle_t *handle) 340 { 341 return prep_receive_data(hcd_phone, IPC_M_USB_HCD_CONTROL_READ_DATA, 342 target, size, handle); 343 } 344 int usb_hcd_transfer_control_read_status(int hcd_phone, usb_target_t target, 345 usb_transaction_handle_t *handle) 346 { 347 usb_transaction_handle_t h; 348 int rc = ipc_call_sync_2_1(hcd_phone, 349 IPC_M_USB_HCD_CONTROL_READ_STATUS, 350 target.address, target.endpoint, 351 &h); 352 if (rc != EOK) { 353 return rc; 354 } 355 356 if (handle != NULL) { 357 *handle = h; 358 } 359 360 return rc; 361 } 362 363 364 213 365 /** 214 366 * @}
Note:
See TracChangeset
for help on using the changeset viewer.