Changes in uspace/drv/uhci-hcd/batch.c [bdc8ab1:0e06a14] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
rbdc8ab1 r0e06a14 49 49 static void batch_control( 50 50 batch_t *instance, int data_stage, int status_stage); 51 static void batch_data(batch_t *instance, int pid); 51 52 static void batch_call_in(batch_t *instance); 52 53 static void batch_call_out(batch_t *instance); … … 192 193 { 193 194 assert(instance); 194 195 batch_data(instance, USB_PID_IN); 196 instance->next_step = batch_call_in_and_dispose; 197 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance); 198 batch_schedule(instance); 199 } 200 /*----------------------------------------------------------------------------*/ 201 void batch_interrupt_out(batch_t *instance) 202 { 203 assert(instance); 204 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 205 batch_data(instance, USB_PID_OUT); 206 instance->next_step = batch_call_out_and_dispose; 207 usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance); 208 batch_schedule(instance); 209 } 210 /*----------------------------------------------------------------------------*/ 211 void batch_bulk_in(batch_t *instance) 212 { 213 assert(instance); 214 batch_data(instance, USB_PID_IN); 215 instance->next_step = batch_call_in_and_dispose; 216 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); 217 batch_schedule(instance); 218 } 219 /*----------------------------------------------------------------------------*/ 220 void batch_bulk_out(batch_t *instance) 221 { 222 assert(instance); 223 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 224 batch_data(instance, USB_PID_OUT); 225 instance->next_step = batch_call_out_and_dispose; 226 usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance); 227 batch_schedule(instance); 228 } 229 /*----------------------------------------------------------------------------*/ 230 static void batch_data(batch_t *instance, int pid) 231 { 232 assert(instance); 195 233 const bool low_speed = instance->speed == USB_SPEED_LOW; 196 234 int toggle = 1; 197 size_t i = 0; 198 for (;i < instance->packets; ++i) { 235 236 size_t packet = 0; 237 size_t remain_size = instance->buffer_size; 238 while (remain_size > 0) { 199 239 char *data = 200 instance->transport_buffer + (i * instance->max_packet_size);201 transfer_descriptor_t *next = (i + 1) < instance->packets ?202 &instance->tds[i + 1] : NULL; 240 instance->transport_buffer + instance->buffer_size 241 - remain_size; 242 203 243 toggle = 1 - toggle; 204 244 205 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 206 instance->max_packet_size, toggle, false, low_speed, 207 instance->target, USB_PID_IN, data, next); 208 } 209 210 instance->tds[i - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG; 211 212 instance->next_step = batch_call_in_and_dispose; 213 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance); 214 batch_schedule(instance); 215 } 216 /*----------------------------------------------------------------------------*/ 217 void batch_interrupt_out(batch_t *instance) 218 { 219 assert(instance); 220 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 221 222 const bool low_speed = instance->speed == USB_SPEED_LOW; 223 int toggle = 1; 224 size_t i = 0; 225 for (;i < instance->packets; ++i) { 226 char *data = 227 instance->transport_buffer + (i * instance->max_packet_size); 228 transfer_descriptor_t *next = (i + 1) < instance->packets ? 229 &instance->tds[i + 1] : NULL; 230 toggle = 1 - toggle; 231 232 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 233 instance->max_packet_size, toggle++, false, low_speed, 234 instance->target, USB_PID_OUT, data, next); 235 } 236 237 instance->tds[i - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG; 238 239 instance->next_step = batch_call_out_and_dispose; 240 usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance); 241 batch_schedule(instance); 245 const size_t packet_size = 246 (instance->max_packet_size > remain_size) ? 247 remain_size : instance->max_packet_size; 248 249 transfer_descriptor_init(&instance->tds[packet], 250 DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed, 251 instance->target, pid, data, 252 &instance->tds[packet + 1]); 253 254 ++packet; 255 assert(packet <= instance->packets); 256 assert(packet_size <= remain_size); 257 remain_size -= packet_size; 258 } 259 260 instance->tds[packet - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG; 261 instance->tds[packet - 1].next = 0 | LINK_POINTER_TERMINATE_FLAG; 242 262 } 243 263 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.