Changeset 34586183 in mainline
- 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
- Location:
- uspace/lib/usb
- Files:
-
- 2 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 * @} -
uspace/lib/usb/hcd.h
r6c741e1d r34586183 56 56 } usb_transaction_outcome_t; 57 57 58 /** USB packet identifier. */ 59 typedef enum { 60 #define _MAKE_PID_NIBBLE(tag, type) \ 61 ((uint8_t)(((tag) << 2) | (type))) 62 #define _MAKE_PID(tag, type) \ 63 ( \ 64 _MAKE_PID_NIBBLE(tag, type) \ 65 | ((~_MAKE_PID_NIBBLE(tag, type)) << 4) \ 66 ) 67 USB_PID_OUT = _MAKE_PID(0, 1), 68 USB_PID_IN = _MAKE_PID(2, 1), 69 USB_PID_SOF = _MAKE_PID(1, 1), 70 USB_PID_SETUP = _MAKE_PID(3, 1), 71 72 USB_PID_DATA0 = _MAKE_PID(0 ,3), 73 USB_PID_DATA1 = _MAKE_PID(2 ,3), 74 75 USB_PID_ACK = _MAKE_PID(0 ,2), 76 USB_PID_NAK = _MAKE_PID(2 ,2), 77 USB_PID_STALL = _MAKE_PID(3 ,2), 78 79 USB_PID_PRE = _MAKE_PID(3 ,0), 80 /* USB_PID_ = _MAKE_PID( ,), */ 81 #undef _MAKE_PID 82 #undef _MAKE_PID_NIBBLE 83 } usb_packet_id; 84 58 85 const char * usb_str_transaction_outcome(usb_transaction_outcome_t o); 59 86 … … 116 143 * - buffer size (in bytes): 117 144 */ 118 IPC_M_USB_HCD_TRANSACTION_SIZE 145 IPC_M_USB_HCD_TRANSACTION_SIZE, 146 147 148 IPC_M_USB_HCD_INTERRUPT_OUT, 149 IPC_M_USB_HCD_INTERRUPT_IN, 150 151 IPC_M_USB_HCD_CONTROL_WRITE_SETUP, 152 IPC_M_USB_HCD_CONTROL_WRITE_DATA, 153 IPC_M_USB_HCD_CONTROL_WRITE_STATUS, 154 155 IPC_M_USB_HCD_CONTROL_READ_SETUP, 156 IPC_M_USB_HCD_CONTROL_READ_DATA, 157 IPC_M_USB_HCD_CONTROL_READ_STATUS, 158 /* IPC_M_USB_HCD_ */ 119 159 } usb_hcd_method_t; 120 160 … … 143 183 /** Notification about a serious trouble with HC. 144 184 */ 145 IPC_M_USB_HCD_CONTROLLER_FAILURE 185 IPC_M_USB_HCD_CONTROLLER_FAILURE, 186 187 188 IPC_M_USB_HCD_INTERRUPT_OUT_DONE, 189 IPC_M_USB_HCD_INTERRUPT_IN_DONE, 190 191 IPC_M_USB_HCD_CONTROL_WRITE_SETUP_DONE, 192 IPC_M_USB_HCD_CONTROL_WRITE_DATA_DONE, 193 IPC_M_USB_HCD_CONTROL_WRITE_STATUS_DONE, 194 195 IPC_M_USB_HCD_CONTROL_READ_SETUP_DONE, 196 IPC_M_USB_HCD_CONTROL_READ_DATA_DONE, 197 IPC_M_USB_HCD_CONTROL_READ_STATUS_DONE, 198 199 /* IPC_M_USB_HCD_ */ 146 200 } usb_hcd_callback_method_t; 147 201 … … 152 206 int usb_hcd_prepare_data_reception(int, usb_target_t, usb_transfer_type_t, 153 207 size_t, usb_transaction_handle_t *); 208 209 210 int usb_hcd_transfer_interrupt_out(int, usb_target_t, 211 void *, size_t, usb_transaction_handle_t *); 212 int usb_hcd_transfer_interrupt_in(int, usb_target_t, 213 size_t, usb_transaction_handle_t *); 214 215 int usb_hcd_transfer_control_write_setup(int, usb_target_t, 216 void *, size_t, usb_transaction_handle_t *); 217 int usb_hcd_transfer_control_write_data(int, usb_target_t, 218 void *, size_t, usb_transaction_handle_t *); 219 int usb_hcd_transfer_control_write_status(int, usb_target_t, 220 usb_transaction_handle_t *); 221 222 int usb_hcd_transfer_control_read_setup(int, usb_target_t, 223 void *, size_t, usb_transaction_handle_t *); 224 int usb_hcd_transfer_control_read_data(int, usb_target_t, 225 size_t, usb_transaction_handle_t *); 226 int usb_hcd_transfer_control_read_status(int, usb_target_t, 227 usb_transaction_handle_t *); 154 228 155 229 #endif
Note:
See TracChangeset
for help on using the changeset viewer.