Changeset 058fd76 in mainline
- Timestamp:
- 2011-09-16T10:22:11Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 790318e
- Parents:
- 25d224c6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/ohci_batch.c
r25d224c6 r058fd76 42 42 #include "utils/malloc32.h" 43 43 44 void (*const batch_setup[4][3])(ohci_transfer_batch_t*);44 static void (*const batch_setup[4][3])(ohci_transfer_batch_t*, usb_direction_t); 45 45 /*----------------------------------------------------------------------------*/ 46 46 /** Safely destructs ohci_transfer_batch_t structure … … 136 136 ohci_batch->usb_batch = usb_batch; 137 137 138 assert( 139 batch_setup[usb_batch->ep->transfer_type][usb_batch->ep->direction]); 140 batch_setup[usb_batch->ep->transfer_type][usb_batch->ep->direction]( 141 ohci_batch); 138 const usb_direction_t dir = usb_transfer_batch_direction(usb_batch); 139 assert(batch_setup[usb_batch->ep->transfer_type][dir]); 140 batch_setup[usb_batch->ep->transfer_type][dir](ohci_batch, dir); 142 141 143 142 return ohci_batch; … … 224 223 * 225 224 * @param[in] ohci_batch Batch structure to use. 226 * @param[in] data_dir Direction to use for data stage. 227 * @param[in] status_dir Direction to use for status stage. 225 * @param[in] dir Communication direction 228 226 * 229 227 * Setup stage with toggle 0 and direction BOTH(SETUP_PID) … … 231 229 * Status stage with toggle 1 and direction supplied by parameter. 232 230 */ 233 static void batch_control(ohci_transfer_batch_t *ohci_batch, 234 usb_direction_t data_dir, usb_direction_t status_dir) 231 static void batch_control(ohci_transfer_batch_t *ohci_batch, usb_direction_t dir) 235 232 { 236 233 assert(ohci_batch); 237 234 assert(ohci_batch->usb_batch); 235 assert(dir == USB_DIRECTION_IN || dir == USB_DIRECTION_OUT); 238 236 usb_log_debug("Using ED(%p): %x:%x:%x:%x.\n", ohci_batch->ed, 239 237 ohci_batch->ed->status, ohci_batch->ed->td_tail, 240 238 ohci_batch->ed->td_head, ohci_batch->ed->next); 239 static const usb_direction_t reverse_dir[] = { 240 [USB_DIRECTION_IN] = USB_DIRECTION_OUT, 241 [USB_DIRECTION_OUT] = USB_DIRECTION_IN, 242 }; 241 243 242 244 int toggle = 0; 243 char* buffer = ohci_batch->device_buffer; 245 const char* buffer = ohci_batch->device_buffer; 246 const usb_direction_t data_dir = dir; 247 const usb_direction_t status_dir = reverse_dir[dir]; 244 248 245 249 /* setup stage */ … … 287 291 ohci_batch->tds[td_current]->next, 288 292 ohci_batch->tds[td_current]->be); 293 usb_log_debug2( 294 "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.\n", \ 295 ohci_batch->usb_batch, 296 usb_str_transfer_type(ohci_batch->usb_batch->ep->transfer_type), 297 usb_str_direction(dir), 298 USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch)); 289 299 } 290 300 /*----------------------------------------------------------------------------*/ … … 292 302 * 293 303 * @param[in] ohci_batch Batch structure to use. 304 * @paramp[in] dir Communication direction. 294 305 * 295 306 * Direction is supplied by the associated ep and toggle is maintained by the 296 307 * OHCI hw in ED. 297 308 */ 298 static void batch_data(ohci_transfer_batch_t *ohci_batch) 299 { 300 assert(ohci_batch); 309 static void batch_data(ohci_transfer_batch_t *ohci_batch, usb_direction_t dir) 310 { 311 assert(ohci_batch); 312 assert(ohci_batch->usb_batch); 313 assert(dir == USB_DIRECTION_IN || dir == USB_DIRECTION_OUT); 301 314 usb_log_debug("Using ED(%p): %x:%x:%x:%x.\n", ohci_batch->ed, 302 315 ohci_batch->ed->status, ohci_batch->ed->td_tail, 303 316 ohci_batch->ed->td_head, ohci_batch->ed->next); 304 317 305 const usb_direction_t direction = ohci_batch->usb_batch->ep->direction;306 318 size_t td_current = 0; 307 319 size_t remain_size = ohci_batch->usb_batch->buffer_size; … … 311 323 ? OHCI_TD_MAX_TRANSFER : remain_size; 312 324 313 td_init(ohci_batch->tds[td_current], dir ection,314 buffer,transfer_size, -1);325 td_init(ohci_batch->tds[td_current], dir, buffer, 326 transfer_size, -1); 315 327 td_set_next(ohci_batch->tds[td_current], 316 328 ohci_batch->tds[td_current + 1]); 329 317 330 usb_log_debug("Created DATA TD: %x:%x:%x:%x.\n", 318 331 ohci_batch->tds[td_current]->status, … … 330 343 ohci_batch->usb_batch, 331 344 usb_str_transfer_type(ohci_batch->usb_batch->ep->transfer_type), 332 usb_str_direction( ohci_batch->usb_batch->ep->direction),345 usb_str_direction(dir), 333 346 USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch)); 334 347 } 335 348 /*----------------------------------------------------------------------------*/ 336 static void setup_control(ohci_transfer_batch_t *ohci_batch) 337 { 338 // TODO Find a better way to do this 339 /* Check first bit of the first setup request byte 340 * (it signals hc-> dev or dev->hc communication) */ 341 const char *direction; 342 if (ohci_batch->device_buffer[0] & (1 << 7)) { 343 batch_control(ohci_batch, USB_DIRECTION_IN, USB_DIRECTION_OUT); 344 direction = "read"; 345 } else { 346 batch_control(ohci_batch, USB_DIRECTION_OUT, USB_DIRECTION_IN); 347 direction = "write"; 348 } 349 usb_log_debug2( 350 "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.\n", \ 351 ohci_batch->usb_batch, 352 usb_str_transfer_type(ohci_batch->usb_batch->ep->transfer_type), 353 direction, USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch)); 354 } 355 /*----------------------------------------------------------------------------*/ 356 void (*const batch_setup[4][3])(ohci_transfer_batch_t*) = 357 { 358 { NULL, NULL, setup_control }, 349 static void (*const batch_setup[4][3])(ohci_transfer_batch_t*, usb_direction_t) = 350 { 351 { batch_control, batch_control, NULL }, 359 352 { NULL, NULL, NULL }, 360 353 { batch_data, batch_data, NULL },
Note:
See TracChangeset
for help on using the changeset viewer.