Changeset 2cc6e97 in mainline for uspace/drv/ohci/batch.c
- Timestamp:
- 2011-04-12T14:07:02Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3d932af6
- Parents:
- 910ca3f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/batch.c
r910ca3f r2cc6e97 43 43 #include "hw_struct/transfer_descriptor.h" 44 44 45 typedef struct ohci_ batch {45 typedef struct ohci_transfer_batch { 46 46 ed_t *ed; 47 47 td_t *tds; 48 48 size_t td_count; 49 } ohci_batch_t; 49 } ohci_transfer_batch_t; 50 51 static void ohci_transfer_batch_dispose(void *ohci_batch) 52 { 53 //TODO: add buffer disposal 54 ohci_transfer_batch_t *instance = ohci_batch; 55 assert(instance); 56 free32(instance->ed); 57 free32(instance->tds); 58 } 50 59 51 60 static void batch_control(usb_transfer_batch_t *instance, 52 61 usb_direction_t data_dir, usb_direction_t status_dir); 53 62 static void batch_data(usb_transfer_batch_t *instance); 54 static void batch_call_in_and_dispose(usb_transfer_batch_t *instance);55 static void batch_call_out_and_dispose(usb_transfer_batch_t *instance);56 63 57 64 #define DEFAULT_ERROR_COUNT 3 … … 65 72 usb_log_error(message); \ 66 73 if (instance) { \ 67 batch_dispose(instance); \74 usb_transfer_batch_dispose(instance); \ 68 75 } \ 69 76 return NULL; \ … … 74 81 "Failed to allocate batch instance.\n"); 75 82 usb_transfer_batch_init(instance, ep, buffer, NULL, buffer_size, 76 NULL, setup_size, func_in, func_out, arg, fun, NULL); 77 78 ohci_batch_t *data = malloc(sizeof(ohci_batch_t)); 83 NULL, setup_size, func_in, func_out, arg, fun, NULL, 84 ohci_transfer_batch_dispose); 85 86 ohci_transfer_batch_t *data = malloc(sizeof(ohci_transfer_batch_t)); 79 87 CHECK_NULL_DISPOSE_RETURN(data, "Failed to allocate batch data.\n"); 80 bzero(data, sizeof(ohci_ batch_t));88 bzero(data, sizeof(ohci_transfer_batch_t)); 81 89 instance->private_data = data; 82 90 … … 113 121 } 114 122 /*----------------------------------------------------------------------------*/ 115 void batch_dispose(usb_transfer_batch_t *instance)116 {117 assert(instance);118 ohci_batch_t *data = instance->private_data;119 assert(data);120 free32(data->ed);121 free32(data->tds);122 free32(instance->setup_buffer);123 free32(instance->data_buffer);124 free(data);125 free(instance);126 }127 /*----------------------------------------------------------------------------*/128 123 bool batch_is_complete(usb_transfer_batch_t *instance) 129 124 { 130 125 assert(instance); 131 ohci_ batch_t *data = instance->private_data;126 ohci_transfer_batch_t *data = instance->private_data; 132 127 assert(data); 133 128 size_t tds = data->td_count - 1; … … 163 158 /* We are data out, we are supposed to provide data */ 164 159 memcpy(instance->data_buffer, instance->buffer, instance->buffer_size); 165 instance->next_step = batch_call_out_and_dispose;160 instance->next_step = usb_transfer_batch_call_out_and_dispose; 166 161 batch_control(instance, USB_DIRECTION_OUT, USB_DIRECTION_IN); 167 162 usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance); … … 171 166 { 172 167 assert(instance); 173 instance->next_step = batch_call_in_and_dispose;168 instance->next_step = usb_transfer_batch_call_in_and_dispose; 174 169 batch_control(instance, USB_DIRECTION_IN, USB_DIRECTION_OUT); 175 170 usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance); … … 179 174 { 180 175 assert(instance); 181 instance->next_step = batch_call_in_and_dispose;176 instance->next_step = usb_transfer_batch_call_in_and_dispose; 182 177 batch_data(instance); 183 178 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance); … … 189 184 /* We are data out, we are supposed to provide data */ 190 185 memcpy(instance->data_buffer, instance->buffer, instance->buffer_size); 191 instance->next_step = batch_call_out_and_dispose;186 instance->next_step = usb_transfer_batch_call_out_and_dispose; 192 187 batch_data(instance); 193 188 usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance); … … 197 192 { 198 193 assert(instance); 199 instance->next_step = batch_call_in_and_dispose;194 instance->next_step = usb_transfer_batch_call_in_and_dispose; 200 195 batch_data(instance); 201 196 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); … … 205 200 { 206 201 assert(instance); 207 instance->next_step = batch_call_in_and_dispose;202 instance->next_step = usb_transfer_batch_call_in_and_dispose; 208 203 batch_data(instance); 209 204 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); … … 213 208 { 214 209 assert(instance); 215 ohci_ batch_t *data = instance->private_data;210 ohci_transfer_batch_t *data = instance->private_data; 216 211 assert(data); 217 212 return data->ed; … … 222 217 { 223 218 assert(instance); 224 ohci_ batch_t *data = instance->private_data;219 ohci_transfer_batch_t *data = instance->private_data; 225 220 assert(data); 226 221 ed_init(data->ed, instance->ep); … … 270 265 { 271 266 assert(instance); 272 ohci_ batch_t *data = instance->private_data;267 ohci_transfer_batch_t *data = instance->private_data; 273 268 assert(data); 274 269 ed_init(data->ed, instance->ep); … … 299 294 } 300 295 } 301 /*----------------------------------------------------------------------------*/302 /** Helper function calls callback and correctly disposes of batch structure.303 *304 * @param[in] instance Batch structure to use.305 */306 void batch_call_in_and_dispose(usb_transfer_batch_t *instance)307 {308 assert(instance);309 usb_transfer_batch_call_in(instance);310 batch_dispose(instance);311 }312 /*----------------------------------------------------------------------------*/313 /** Helper function calls callback and correctly disposes of batch structure.314 *315 * @param[in] instance Batch structure to use.316 */317 void batch_call_out_and_dispose(usb_transfer_batch_t *instance)318 {319 assert(instance);320 usb_transfer_batch_call_out(instance);321 batch_dispose(instance);322 }323 296 /** 324 297 * @}
Note:
See TracChangeset
for help on using the changeset viewer.