Changes in / [474d08e:80fdffe] in mainline
- Location:
- uspace/drv/uhci-hcd
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/drv/uhci-hcd/batch.c ¶
r474d08e r80fdffe 47 47 static int batch_schedule(batch_t *instance); 48 48 49 static void batch_control( batch_t *instance,50 usb_packet_id data_stage, usb_packet_idstatus_stage);51 static void batch_data(batch_t *instance, usb_packet_idpid);49 static void batch_control( 50 batch_t *instance, int data_stage, int status_stage); 51 static void batch_data(batch_t *instance, int pid); 52 52 static void batch_call_in(batch_t *instance); 53 53 static void batch_call_out(batch_t *instance); … … 84 84 } 85 85 86 instance->tds = malloc32(sizeof(t d_t) * instance->packets);86 instance->tds = malloc32(sizeof(transfer_descriptor_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 d_t) * instance->packets);93 bzero(instance->tds, sizeof(transfer_descriptor_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 d_is_active(&instance->tds[i])) {154 if (transfer_descriptor_is_active(&instance->tds[i])) { 155 155 return false; 156 156 } 157 158 instance->error = td_status(&instance->tds[i]); 157 instance->error = transfer_descriptor_status(&instance->tds[i]); 159 158 if (instance->error != EOK) { 159 if (i > 0) 160 instance->transfered_size -= instance->setup_size; 160 161 usb_log_debug("Batch(%p) found error TD(%d):%x.\n", 161 instance, i, instance->tds[i].status); 162 if (i > 0) 163 goto substract_ret; 162 instance, i, instance->tds[i].status); 164 163 return true; 165 164 } 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: 165 instance->transfered_size += 166 transfer_descriptor_actual_size(&instance->tds[i]); 167 } 172 168 instance->transfered_size -= instance->setup_size; 173 169 return true; … … 232 228 } 233 229 /*----------------------------------------------------------------------------*/ 234 static void batch_data(batch_t *instance, usb_packet_idpid)230 static void batch_data(batch_t *instance, int pid) 235 231 { 236 232 assert(instance); … … 251 247 remain_size : instance->max_packet_size; 252 248 253 t d_init(&instance->tds[packet],249 transfer_descriptor_init(&instance->tds[packet], 254 250 DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed, 255 251 instance->target, pid, data, … … 266 262 } 267 263 /*----------------------------------------------------------------------------*/ 268 static void batch_control( batch_t *instance,269 usb_packet_id data_stage, usb_packet_idstatus_stage)264 static void batch_control( 265 batch_t *instance, int data_stage, int status_stage) 270 266 { 271 267 assert(instance); … … 274 270 int toggle = 0; 275 271 /* setup stage */ 276 t d_init(instance->tds, DEFAULT_ERROR_COUNT,272 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT, 277 273 instance->setup_size, toggle, false, low_speed, instance->target, 278 274 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); … … 292 288 remain_size : instance->max_packet_size; 293 289 294 t d_init(&instance->tds[packet],290 transfer_descriptor_init(&instance->tds[packet], 295 291 DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed, 296 292 instance->target, data_stage, data, … … 305 301 /* status stage */ 306 302 assert(packet == instance->packets - 1); 307 t d_init(&instance->tds[packet], DEFAULT_ERROR_COUNT,303 transfer_descriptor_init(&instance->tds[packet], DEFAULT_ERROR_COUNT, 308 304 0, 1, false, low_speed, instance->target, status_stage, NULL, NULL); 309 305 -
TabularUnified uspace/drv/uhci-hcd/batch.h ¶
r474d08e r80fdffe 65 65 ddf_fun_t *fun; 66 66 queue_head_t *qh; 67 t d_t *tds;67 transfer_descriptor_t *tds; 68 68 void (*next_step)(struct batch*); 69 69 } batch_t; -
TabularUnified uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c ¶
r474d08e r80fdffe 38 38 #include "utils/malloc32.h" 39 39 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, usb_packet_id pid, void *buffer, td_t *next) 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) 42 43 { 43 44 assert(instance); 44 assert(size < 1024);45 assert((pid == USB_PID_SETUP) || (pid == USB_PID_IN) || (pid == USB_PID_OUT));46 45 47 46 instance->next = 0 … … 50 49 51 50 instance->status = 0 52 | ((err_count & TD_STATUS_ERROR_COUNT_MASK) << TD_STATUS_ERROR_COUNT_POS) 53 | (low_speed ? TD_STATUS_LOW_SPEED_FLAG : 0) 54 | (iso ? TD_STATUS_ISOCHRONOUS_FLAG : 0) 55 | TD_STATUS_ERROR_ACTIVE; 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; 56 54 57 if (pid == USB_PID_IN && !iso) { 58 instance->status |= TD_STATUS_SPD_FLAG; 59 } 60 55 assert(size < 1024); 61 56 instance->device = 0 62 63 64 65 66 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); 67 62 68 63 instance->buffer_ptr = 0; … … 73 68 74 69 usb_log_debug2("Created TD: %X:%X:%X:%X(%p).\n", 75 76 70 instance->next, instance->status, instance->device, 71 instance->buffer_ptr, buffer); 77 72 } 78 73 /*----------------------------------------------------------------------------*/ 79 int t d_status(td_t *instance)74 int transfer_descriptor_status(transfer_descriptor_t *instance) 80 75 { 81 76 assert(instance); -
TabularUnified uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h ¶
r474d08e r80fdffe 88 88 * we don't use it anyway 89 89 */ 90 } __attribute__((packed)) t d_t;90 } __attribute__((packed)) transfer_descriptor_t; 91 91 92 92 93 void t d_init(td_t *instance, int error_count, size_t size, bool toggle, bool iso,94 bool low_speed, usb_target_t target, usb_packet_id pid, void *buffer,95 td_t *next);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); 96 96 97 int t d_status(td_t *instance);97 int transfer_descriptor_status(transfer_descriptor_t *instance); 98 98 99 static inline size_t td_act_size(td_t *instance) 99 static inline size_t transfer_descriptor_actual_size( 100 transfer_descriptor_t *instance) 100 101 { 101 102 assert(instance); 102 103 return 103 ((instance->status >> TD_STATUS_ACTLEN_POS) + 1) 104 & TD_STATUS_ACTLEN_MASK; 104 ((instance->status >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK; 105 105 } 106 106 107 static inline bool td_is_short(td_t *instance) 108 { 109 const size_t act_size = td_act_size(instance); 110 const size_t max_size = 111 ((instance->device >> TD_DEVICE_MAXLEN_POS) + 1) 112 & TD_DEVICE_MAXLEN_MASK; 113 return 114 (instance->status | TD_STATUS_SPD_FLAG) && act_size < max_size; 115 } 116 117 static inline bool td_is_active(td_t *instance) 107 static inline bool transfer_descriptor_is_active( 108 transfer_descriptor_t *instance) 118 109 { 119 110 assert(instance);
Note:
See TracChangeset
for help on using the changeset viewer.