Changeset c5b93dc in mainline
- Timestamp:
- 2011-03-05T00:12:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eae83aa
- Parents:
- 0e06a14
- Location:
- uspace/drv/uhci-hcd
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
r0e06a14 rc5b93dc 84 84 } 85 85 86 instance->tds = malloc32(sizeof(t ransfer_descriptor_t) * instance->packets);86 instance->tds = malloc32(sizeof(td_t) * instance->packets); 87 87 if (instance->tds == NULL) { 88 88 usb_log_error("Failed to allocate transfer descriptors.\n"); … … 91 91 return NULL; 92 92 } 93 bzero(instance->tds, sizeof(t ransfer_descriptor_t) * instance->packets);93 bzero(instance->tds, sizeof(td_t) * instance->packets); 94 94 95 95 const size_t transport_size = max_packet_size * instance->packets; … … 152 152 size_t i = 0; 153 153 for (;i < instance->packets; ++i) { 154 if (t ransfer_descriptor_is_active(&instance->tds[i])) {154 if (td_is_active(&instance->tds[i])) { 155 155 return false; 156 156 } 157 instance->error = transfer_descriptor_status(&instance->tds[i]); 157 158 instance->error = td_status(&instance->tds[i]); 158 159 if (instance->error != EOK) { 160 usb_log_debug("Batch(%p) found error TD(%d):%x.\n", 161 instance, i, instance->tds[i].status); 159 162 if (i > 0) 160 instance->transfered_size -= instance->setup_size; 161 usb_log_debug("Batch(%p) found error TD(%d):%x.\n", 162 instance, i, instance->tds[i].status); 163 goto substract_ret; 163 164 return true; 164 165 } 165 instance->transfered_size += 166 transfer_descriptor_actual_size(&instance->tds[i]); 167 } 166 167 instance->transfered_size += td_act_size(&instance->tds[i]); 168 if (td_is_short(&instance->tds[i])) 169 goto substract_ret; 170 } 171 substract_ret: 168 172 instance->transfered_size -= instance->setup_size; 169 173 return true; … … 247 251 remain_size : instance->max_packet_size; 248 252 249 t ransfer_descriptor_init(&instance->tds[packet],253 td_init(&instance->tds[packet], 250 254 DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed, 251 255 instance->target, pid, data, … … 270 274 int toggle = 0; 271 275 /* setup stage */ 272 t ransfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,276 td_init(instance->tds, DEFAULT_ERROR_COUNT, 273 277 instance->setup_size, toggle, false, low_speed, instance->target, 274 278 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); … … 288 292 remain_size : instance->max_packet_size; 289 293 290 t ransfer_descriptor_init(&instance->tds[packet],294 td_init(&instance->tds[packet], 291 295 DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed, 292 296 instance->target, data_stage, data, … … 301 305 /* status stage */ 302 306 assert(packet == instance->packets - 1); 303 t ransfer_descriptor_init(&instance->tds[packet], DEFAULT_ERROR_COUNT,307 td_init(&instance->tds[packet], DEFAULT_ERROR_COUNT, 304 308 0, 1, false, low_speed, instance->target, status_stage, NULL, NULL); 305 309 -
uspace/drv/uhci-hcd/batch.h
r0e06a14 rc5b93dc 65 65 ddf_fun_t *fun; 66 66 queue_head_t *qh; 67 t ransfer_descriptor_t *tds;67 td_t *tds; 68 68 void (*next_step)(struct batch*); 69 69 } batch_t; -
uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c
r0e06a14 rc5b93dc 38 38 #include "utils/malloc32.h" 39 39 40 void transfer_descriptor_init(transfer_descriptor_t *instance, 41 int error_count, size_t size, bool toggle, bool isochronous, bool low_speed, 42 usb_target_t target, int pid, void *buffer, transfer_descriptor_t *next) 40 void td_init(td_t *instance, int err_count, size_t size, bool toggle, bool iso, 41 bool low_speed, usb_target_t target, int pid, void *buffer, td_t *next) 43 42 { 44 43 assert(instance); 44 assert(size < 1024); 45 45 46 46 instance->next = 0 … … 49 49 50 50 instance->status = 0 51 | ((error_count & TD_STATUS_ERROR_COUNT_MASK) << TD_STATUS_ERROR_COUNT_POS) 52 | (low_speed ? TD_STATUS_LOW_SPEED_FLAG : 0) 53 | TD_STATUS_ERROR_ACTIVE; 51 | ((err_count & TD_STATUS_ERROR_COUNT_MASK) << TD_STATUS_ERROR_COUNT_POS) 52 | (low_speed ? TD_STATUS_LOW_SPEED_FLAG : 0) 53 | (iso ? TD_STATUS_ISOCHRONOUS_FLAG : 0) 54 | TD_STATUS_ERROR_ACTIVE; 54 55 55 assert(size < 1024);56 56 instance->device = 0 57 58 59 60 61 57 | (((size - 1) & TD_DEVICE_MAXLEN_MASK) << TD_DEVICE_MAXLEN_POS) 58 | (toggle ? TD_DEVICE_DATA_TOGGLE_ONE_FLAG : 0) 59 | ((target.address & TD_DEVICE_ADDRESS_MASK) << TD_DEVICE_ADDRESS_POS) 60 | ((target.endpoint & TD_DEVICE_ENDPOINT_MASK) << TD_DEVICE_ENDPOINT_POS) 61 | ((pid & TD_DEVICE_PID_MASK) << TD_DEVICE_PID_POS); 62 62 63 63 instance->buffer_ptr = 0; … … 68 68 69 69 usb_log_debug2("Created TD: %X:%X:%X:%X(%p).\n", 70 71 instance->buffer_ptr, buffer);70 instance->next, instance->status, instance->device, 71 instance->buffer_ptr, buffer); 72 72 } 73 73 /*----------------------------------------------------------------------------*/ 74 int t ransfer_descriptor_status(transfer_descriptor_t *instance)74 int td_status(td_t *instance) 75 75 { 76 76 assert(instance); -
uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h
r0e06a14 rc5b93dc 88 88 * we don't use it anyway 89 89 */ 90 } __attribute__((packed)) t ransfer_descriptor_t;90 } __attribute__((packed)) td_t; 91 91 92 92 93 void transfer_descriptor_init(transfer_descriptor_t *instance, 94 int error_count, size_t size, bool toggle, bool isochronous, bool low_speed, 95 usb_target_t target, int pid, void *buffer, transfer_descriptor_t * next); 93 void td_init(td_t *instance, int error_count, size_t size, bool toggle, bool iso, 94 bool low_speed, usb_target_t target, int pid, void *buffer, td_t * next); 96 95 97 int t ransfer_descriptor_status(transfer_descriptor_t *instance);96 int td_status(td_t *instance); 98 97 99 static inline size_t transfer_descriptor_actual_size( 100 transfer_descriptor_t *instance) 98 static inline size_t td_act_size(td_t *instance) 101 99 { 102 100 assert(instance); 103 101 return 104 ((instance->status >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK; 102 ((instance->status >> TD_STATUS_ACTLEN_POS) + 1) 103 & TD_STATUS_ACTLEN_MASK; 105 104 } 106 105 107 static inline bool transfer_descriptor_is_active( 108 transfer_descriptor_t *instance) 106 static inline bool td_is_short(td_t *instance) 107 { 108 const size_t act_size = td_act_size(instance); 109 const size_t max_size = 110 ((instance->device >> TD_DEVICE_MAXLEN_POS) + 1) 111 & TD_DEVICE_MAXLEN_MASK; 112 return 113 (instance->status | TD_STATUS_SPD_FLAG) && act_size < max_size; 114 } 115 116 static inline bool td_is_active(td_t *instance) 109 117 { 110 118 assert(instance);
Note:
See TracChangeset
for help on using the changeset viewer.