Changeset d017cea in mainline
- Timestamp:
- 2011-04-12T10:09:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 508a0ca
- Parents:
- f13381b
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/batch.c
rf13381b rd017cea 73 73 CHECK_NULL_DISPOSE_RETURN(instance, 74 74 "Failed to allocate batch instance.\n"); 75 usb_target_t target = 76 { .address = ep->address, .endpoint = ep->endpoint }; 77 usb_transfer_batch_init(instance, target, ep->transfer_type, ep->speed, 78 ep->max_packet_size, buffer, NULL, buffer_size, NULL, setup_size, 79 func_in, func_out, arg, fun, ep, NULL); 75 usb_transfer_batch_init(instance, ep, buffer, NULL, buffer_size, 76 NULL, setup_size, func_in, func_out, arg, fun, NULL); 80 77 81 78 ohci_batch_t *data = malloc(sizeof(ohci_batch_t)); … … 101 98 102 99 if (buffer_size > 0) { 103 instance-> transport_buffer = malloc32(buffer_size);104 CHECK_NULL_DISPOSE_RETURN(instance-> transport_buffer,100 instance->data_buffer = malloc32(buffer_size); 101 CHECK_NULL_DISPOSE_RETURN(instance->data_buffer, 105 102 "Failed to allocate device accessible buffer.\n"); 106 103 } … … 124 121 free32(data->tds); 125 122 free32(instance->setup_buffer); 126 free32(instance-> transport_buffer);123 free32(instance->data_buffer); 127 124 free(data); 128 125 free(instance); … … 165 162 assert(instance); 166 163 /* We are data out, we are supposed to provide data */ 167 memcpy(instance->transport_buffer, instance->buffer, 168 instance->buffer_size); 164 memcpy(instance->data_buffer, instance->buffer, instance->buffer_size); 169 165 instance->next_step = batch_call_out_and_dispose; 170 166 batch_control(instance, USB_DIRECTION_OUT, USB_DIRECTION_IN); … … 183 179 { 184 180 assert(instance); 185 assert(instance->direction == USB_DIRECTION_IN);186 181 instance->next_step = batch_call_in_and_dispose; 187 182 batch_data(instance); … … 192 187 { 193 188 assert(instance); 194 assert(instance->direction == USB_DIRECTION_OUT);195 189 /* We are data out, we are supposed to provide data */ 196 memcpy(instance->transport_buffer, instance->buffer, 197 instance->buffer_size); 190 memcpy(instance->data_buffer, instance->buffer, instance->buffer_size); 198 191 instance->next_step = batch_call_out_and_dispose; 199 192 batch_data(instance); … … 204 197 { 205 198 assert(instance); 206 instance->direction = USB_DIRECTION_IN;207 199 instance->next_step = batch_call_in_and_dispose; 208 200 batch_data(instance); … … 213 205 { 214 206 assert(instance); 215 instance->direction = USB_DIRECTION_IN;216 207 instance->next_step = batch_call_in_and_dispose; 217 208 batch_data(instance); … … 249 240 size_t td_current = 1; 250 241 size_t remain_size = instance->buffer_size; 251 char * transfer_buffer = instance->transport_buffer;242 char *buffer = instance->data_buffer; 252 243 while (remain_size > 0) { 253 244 size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ? … … 255 246 toggle = 1 - toggle; 256 247 257 td_init(&data->tds[td_current], data_dir, transfer_buffer,248 td_init(&data->tds[td_current], data_dir, buffer, 258 249 transfer_size, toggle); 259 250 td_set_next(&data->tds[td_current], &data->tds[td_current + 1]); … … 262 253 data->tds[td_current].next, data->tds[td_current].be); 263 254 264 transfer_buffer += transfer_size;255 buffer += transfer_size; 265 256 remain_size -= transfer_size; 266 257 assert(td_current < data->td_count - 2); … … 290 281 size_t td_current = 0; 291 282 size_t remain_size = instance->buffer_size; 292 char * transfer_buffer = instance->transport_buffer;283 char *buffer = instance->data_buffer; 293 284 while (remain_size > 0) { 294 285 size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ? … … 296 287 297 288 td_init(&data->tds[td_current], instance->ep->direction, 298 transfer_buffer, transfer_size, -1);289 buffer, transfer_size, -1); 299 290 td_set_next(&data->tds[td_current], &data->tds[td_current + 1]); 300 291 usb_log_debug("Created DATA TD: %x:%x:%x:%x.\n", … … 302 293 data->tds[td_current].next, data->tds[td_current].be); 303 294 304 transfer_buffer += transfer_size;295 buffer += transfer_size; 305 296 remain_size -= transfer_size; 306 297 assert(td_current < data->td_count); -
uspace/drv/ohci/hc.c
rf13381b rd017cea 130 130 assert(instance); 131 131 assert(batch); 132 assert(batch->ep); 132 133 133 134 /* check for root hub communication */ 134 if (batch-> target.address == instance->rh.address) {135 if (batch->ep->address == instance->rh.address) { 135 136 return rh_request(&instance->rh, batch); 136 137 } 137 138 138 139 fibril_mutex_lock(&instance->guard); 139 switch (batch-> transfer_type) {140 switch (batch->ep->transfer_type) { 140 141 case USB_TRANSFER_CONTROL: 141 142 instance->registers->control &= ~C_CLE; 142 143 transfer_list_add_batch( 143 instance->transfers[batch-> transfer_type], batch);144 instance->transfers[batch->ep->transfer_type], batch); 144 145 instance->registers->command_status |= CS_CLF; 145 146 usb_log_debug2("Set CS control transfer filled: %x.\n", … … 151 152 instance->registers->control &= ~C_BLE; 152 153 transfer_list_add_batch( 153 instance->transfers[batch-> transfer_type], batch);154 instance->transfers[batch->ep->transfer_type], batch); 154 155 instance->registers->command_status |= CS_BLF; 155 156 usb_log_debug2("Set bulk transfer filled: %x.\n", … … 161 162 instance->registers->control &= (~C_PLE & ~C_IE); 162 163 transfer_list_add_batch( 163 instance->transfers[batch-> transfer_type], batch);164 instance->transfers[batch->ep->transfer_type], batch); 164 165 instance->registers->control |= C_PLE | C_IE; 165 166 usb_log_debug2("Added periodic transfer: %x.\n", -
uspace/drv/ohci/root_hub.c
rf13381b rd017cea 237 237 assert(request); 238 238 int opResult; 239 if (request-> transfer_type == USB_TRANSFER_CONTROL) {239 if (request->ep->transfer_type == USB_TRANSFER_CONTROL) { 240 240 usb_log_info("Root hub got CONTROL packet\n"); 241 241 opResult = process_ctrl_request(instance, request); 242 } else if (request-> transfer_type == USB_TRANSFER_INTERRUPT) {242 } else if (request->ep->transfer_type == USB_TRANSFER_INTERRUPT) { 243 243 usb_log_info("Root hub got INTERRUPT packet\n"); 244 244 void * buffer; 245 245 create_interrupt_mask(instance, &buffer, 246 246 &(request->transfered_size)); 247 memcpy(request-> transport_buffer, buffer,247 memcpy(request->data_buffer, buffer, 248 248 request->transfered_size); 249 249 opResult = EOK; … … 374 374 if (port < 1 || port > instance->port_count) 375 375 return EINVAL; 376 uint32_t * uint32_buffer = (uint32_t*) request-> transport_buffer;376 uint32_t * uint32_buffer = (uint32_t*) request->data_buffer; 377 377 request->transfered_size = 4; 378 378 uint32_buffer[0] = instance->registers->rh_port_status[port - 1]; … … 400 400 static int process_get_hub_status_request(rh_t *instance, 401 401 usb_transfer_batch_t * request) { 402 uint32_t * uint32_buffer = (uint32_t*) request-> transport_buffer;402 uint32_t * uint32_buffer = (uint32_t*) request->data_buffer; 403 403 request->transfered_size = 4; 404 404 //bits, 0,1,16,17 … … 550 550 } 551 551 request->transfered_size = size; 552 memcpy(request-> transport_buffer, result_descriptor, size);552 memcpy(request->data_buffer, result_descriptor, size); 553 553 if (del) 554 554 free(result_descriptor); … … 571 571 if (request->buffer_size != 1) 572 572 return EINVAL; 573 request-> transport_buffer[0] = 1;573 request->data_buffer[0] = 1; 574 574 request->transfered_size = 1; 575 575 return EOK; -
uspace/drv/uhci-hcd/batch.c
rf13381b rd017cea 103 103 usb_target_t target = 104 104 { .address = ep->address, .endpoint = ep->endpoint }; 105 usb_transfer_batch_init(instance, target, ep->transfer_type, ep->speed,106 ep->max_packet_size,buffer, NULL, buffer_size, NULL, setup_size,107 func_in, func_out, arg, fun, ep,NULL);105 usb_transfer_batch_init(instance, ep, 106 buffer, NULL, buffer_size, NULL, setup_size, 107 func_in, func_out, arg, fun, NULL); 108 108 109 109 … … 131 131 132 132 if (buffer_size > 0) { 133 instance-> transport_buffer = malloc32(buffer_size);134 CHECK_NULL_DISPOSE_RETURN(instance-> transport_buffer,133 instance->data_buffer = malloc32(buffer_size); 134 CHECK_NULL_DISPOSE_RETURN(instance->data_buffer, 135 135 "Failed to allocate device accessible buffer.\n"); 136 136 } … … 205 205 assert(instance); 206 206 /* We are data out, we are supposed to provide data */ 207 memcpy(instance->transport_buffer, instance->buffer, 208 instance->buffer_size); 207 memcpy(instance->data_buffer, instance->buffer, instance->buffer_size); 209 208 batch_control(instance, USB_PID_OUT, USB_PID_IN); 210 209 instance->next_step = batch_call_out_and_dispose; … … 235 234 { 236 235 assert(instance); 237 instance->direction = USB_DIRECTION_IN;236 // instance->direction = USB_DIRECTION_IN; 238 237 batch_data(instance, USB_PID_IN); 239 238 instance->next_step = batch_call_in_and_dispose; … … 250 249 { 251 250 assert(instance); 252 instance->direction = USB_DIRECTION_OUT;253 251 /* We are data out, we are supposed to provide data */ 254 memcpy(instance->transport_buffer, instance->buffer, 255 instance->buffer_size); 252 memcpy(instance->data_buffer, instance->buffer, instance->buffer_size); 256 253 batch_data(instance, USB_PID_OUT); 257 254 instance->next_step = batch_call_out_and_dispose; … … 269 266 assert(instance); 270 267 batch_data(instance, USB_PID_IN); 271 instance->direction = USB_DIRECTION_IN;272 268 instance->next_step = batch_call_in_and_dispose; 273 269 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); … … 283 279 { 284 280 assert(instance); 285 instance->direction = USB_DIRECTION_OUT;286 281 /* We are data out, we are supposed to provide data */ 287 memcpy(instance-> transport_buffer, instance->buffer,282 memcpy(instance->data_buffer, instance->buffer, 288 283 instance->buffer_size); 289 284 batch_data(instance, USB_PID_OUT); … … 306 301 assert(data); 307 302 308 const bool low_speed = instance-> speed == USB_SPEED_LOW;303 const bool low_speed = instance->ep->speed == USB_SPEED_LOW; 309 304 int toggle = endpoint_toggle_get(instance->ep); 310 305 assert(toggle == 0 || toggle == 1); … … 314 309 while (remain_size > 0) { 315 310 char *trans_data = 316 instance-> transport_buffer + instance->buffer_size311 instance->data_buffer + instance->buffer_size 317 312 - remain_size; 318 313 319 314 const size_t packet_size = 320 (instance-> max_packet_size > remain_size) ?321 remain_size : instance-> max_packet_size;315 (instance->ep->max_packet_size > remain_size) ? 316 remain_size : instance->ep->max_packet_size; 322 317 323 318 td_t *next_transfer = (transfer + 1 < data->transfers) … … 326 321 assert(transfer < data->transfers); 327 322 assert(packet_size <= remain_size); 323 usb_target_t target = 324 { instance->ep->address, instance->ep->endpoint }; 328 325 329 326 td_init( 330 327 &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size, 331 toggle, false, low_speed, instance->target, pid, trans_data,328 toggle, false, low_speed, target, pid, trans_data, 332 329 next_transfer); 333 330 … … 360 357 assert(data->transfers >= 2); 361 358 362 const bool low_speed = instance-> speed == USB_SPEED_LOW;359 const bool low_speed = instance->ep->speed == USB_SPEED_LOW; 363 360 int toggle = 0; 361 const usb_target_t target = 362 { instance->ep->address, instance->ep->endpoint }; 363 364 364 /* setup stage */ 365 365 td_init( 366 366 data->tds, DEFAULT_ERROR_COUNT, instance->setup_size, toggle, false, 367 low_speed, instance->target, USB_PID_SETUP, instance->setup_buffer,367 low_speed, target, USB_PID_SETUP, instance->setup_buffer, 368 368 &data->tds[1]); 369 369 … … 373 373 while (remain_size > 0) { 374 374 char *control_data = 375 instance-> transport_buffer + instance->buffer_size375 instance->data_buffer + instance->buffer_size 376 376 - remain_size; 377 377 … … 379 379 380 380 const size_t packet_size = 381 (instance-> max_packet_size > remain_size) ?382 remain_size : instance-> max_packet_size;381 (instance->ep->max_packet_size > remain_size) ? 382 remain_size : instance->ep->max_packet_size; 383 383 384 384 td_init( 385 385 &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size, 386 toggle, false, low_speed, instance->target, data_stage,386 toggle, false, low_speed, target, data_stage, 387 387 control_data, &data->tds[transfer + 1]); 388 388 … … 398 398 td_init( 399 399 &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed, 400 instance->target, status_stage, NULL, NULL);400 target, status_stage, NULL, NULL); 401 401 td_set_ioc(&data->tds[transfer]); 402 402 … … 449 449 free32(data->qh); 450 450 free32(instance->setup_buffer); 451 free32(instance-> transport_buffer);451 free32(instance->data_buffer); 452 452 free(data); 453 453 free(instance); -
uspace/drv/uhci-hcd/hc.c
rf13381b rd017cea 329 329 330 330 transfer_list_t *list = 331 instance->transfers[batch-> speed][batch->transfer_type];331 instance->transfers[batch->ep->speed][batch->ep->transfer_type]; 332 332 assert(list); 333 333 transfer_list_add_batch(list, batch); -
uspace/lib/usb/include/usb/host/batch.h
rf13381b rd017cea 43 43 typedef struct usb_transfer_batch usb_transfer_batch_t; 44 44 struct usb_transfer_batch { 45 endpoint_t *ep; 45 46 link_t link; 46 usb_target_t target;47 usb_transfer_type_t transfer_type;48 usb_speed_t speed;49 usb_direction_t direction;50 47 usbhc_iface_transfer_in_callback_t callback_in; 51 48 usbhc_iface_transfer_out_callback_t callback_out; 49 void *arg; 52 50 char *buffer; 53 char * transport_buffer;51 char *data_buffer; 54 52 size_t buffer_size; 55 53 char *setup_buffer; 56 54 size_t setup_size; 57 size_t max_packet_size;58 55 size_t transfered_size; 59 56 void (*next_step)(usb_transfer_batch_t *); 60 57 int error; 61 58 ddf_fun_t *fun; 62 void *arg;63 endpoint_t *ep;64 59 void *private_data; 65 60 }; … … 67 62 void usb_transfer_batch_init( 68 63 usb_transfer_batch_t *instance, 69 usb_target_t target, 70 usb_transfer_type_t transfer_type, 71 usb_speed_t speed, 72 size_t max_packet_size, 64 endpoint_t *ep, 73 65 char *buffer, 74 char * transport_buffer,66 char *data_buffer, 75 67 size_t buffer_size, 76 68 char *setup_buffer, … … 80 72 void *arg, 81 73 ddf_fun_t *fun, 82 endpoint_t *ep,83 74 void *private_data 84 75 ); -
uspace/lib/usb/src/host/batch.c
rf13381b rd017cea 41 41 void usb_transfer_batch_init( 42 42 usb_transfer_batch_t *instance, 43 usb_target_t target, 44 usb_transfer_type_t transfer_type, 45 usb_speed_t speed, 46 size_t max_packet_size, 43 endpoint_t *ep, 47 44 char *buffer, 48 char * transport_buffer,45 char *data_buffer, 49 46 size_t buffer_size, 50 47 char *setup_buffer, … … 54 51 void *arg, 55 52 ddf_fun_t *fun, 56 endpoint_t *ep,57 53 void *private_data 58 54 ) … … 60 56 assert(instance); 61 57 link_initialize(&instance->link); 62 instance->target = target; 63 instance->transfer_type = transfer_type; 64 instance->speed = speed; 65 instance->direction = ep->direction; 58 instance->ep = ep; 66 59 instance->callback_in = func_in; 67 60 instance->callback_out = func_out; 68 61 instance->arg = arg; 69 62 instance->buffer = buffer; 70 instance-> transport_buffer = transport_buffer;63 instance->data_buffer = data_buffer; 71 64 instance->buffer_size = buffer_size; 72 65 instance->setup_buffer = setup_buffer; 73 66 instance->setup_size = setup_size; 74 instance->max_packet_size = max_packet_size;75 67 instance->fun = fun; 76 68 instance->private_data = private_data; … … 78 70 instance->next_step = NULL; 79 71 instance->error = EOK; 80 instance->ep = ep;81 72 endpoint_use(instance->ep); 82 73 } … … 105 96 assert(instance); 106 97 assert(instance->callback_in); 98 assert(instance->ep); 107 99 108 100 /* We are data in, we need data */ 109 memcpy(instance->buffer, instance->transport_buffer, 110 instance->buffer_size); 101 memcpy(instance->buffer, instance->data_buffer, instance->buffer_size); 111 102 112 103 usb_log_debug("Batch %p done (T%d.%d, %s %s in, %zuB): %s (%d).\n", 113 instance, 114 instance->target.address, instance->target.endpoint, 115 usb_str_speed(instance->speed), 116 usb_str_transfer_type_short(instance->transfer_type), 117 instance->transfered_size, 118 str_error(instance->error), instance->error); 104 instance, instance->ep->address, instance->ep->endpoint, 105 usb_str_speed(instance->ep->speed), 106 usb_str_transfer_type_short(instance->ep->transfer_type), 107 instance->transfered_size, str_error(instance->error), instance->error); 119 108 120 109 instance->callback_in(instance->fun, instance->error, … … 132 121 133 122 usb_log_debug("Batch %p done (T%d.%d, %s %s out): %s (%d).\n", 134 instance, 135 instance->target.address, instance->target.endpoint, 136 usb_str_speed(instance->speed), 137 usb_str_transfer_type_short(instance->transfer_type), 123 instance, instance->ep->address, instance->ep->endpoint, 124 usb_str_speed(instance->ep->speed), 125 usb_str_transfer_type_short(instance->ep->transfer_type), 138 126 str_error(instance->error), instance->error); 139 127
Note:
See TracChangeset
for help on using the changeset viewer.