Changeset e2976bb in mainline
- Timestamp:
- 2011-08-25T11:34:19Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4f0e510
- Parents:
- 27873be
- Location:
- uspace/drv/bus/usb/ohci
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/batch.c
r27873be re2976bb 66 66 * @param[in] ohci_batch Instance to destroy. 67 67 */ 68 static void ohci_ transfer_batch_dispose(void *ohci_batch)68 static void ohci_batch_dispose(void *ohci_batch) 69 69 { 70 70 ohci_transfer_batch_t *instance = ohci_batch; … … 83 83 } 84 84 /*----------------------------------------------------------------------------*/ 85 int batch_init_ohci(usb_transfer_batch_t *batch) 86 { 87 assert(batch); 88 #define CHECK_NULL_DISPOSE_RETURN(ptr, message...) \ 89 if (ptr == NULL) { \ 90 usb_log_error(message); \ 91 if (data) { \ 92 ohci_batch_dispose(data); \ 93 } \ 94 return ENOMEM; \ 95 } else (void)0 96 97 const hcd_endpoint_t *hcd_ep = hcd_endpoint_get(batch->ep); 98 assert(hcd_ep); 99 100 ohci_transfer_batch_t *data = calloc(sizeof(ohci_transfer_batch_t), 1); 101 CHECK_NULL_DISPOSE_RETURN(data, "Failed to allocate batch data.\n"); 102 103 data->td_count = ((batch->buffer_size + OHCI_TD_MAX_TRANSFER - 1) 104 / OHCI_TD_MAX_TRANSFER); 105 /* Control transfer need Setup and Status stage */ 106 if (batch->ep->transfer_type == USB_TRANSFER_CONTROL) { 107 data->td_count += 2; 108 } 109 110 /* We need an extra place for TD that is currently assigned to hcd_ep*/ 111 data->tds = calloc(sizeof(td_t*), data->td_count + 1); 112 CHECK_NULL_DISPOSE_RETURN(data->tds, 113 "Failed to allocate transfer descriptors.\n"); 114 115 /* Add TD left over by the previous transfer */ 116 data->tds[0] = hcd_ep->td; 117 data->leave_td = 0; 118 unsigned i = 1; 119 for (; i <= data->td_count; ++i) { 120 data->tds[i] = malloc32(sizeof(td_t)); 121 CHECK_NULL_DISPOSE_RETURN(data->tds[i], 122 "Failed to allocate TD %d.\n", i ); 123 } 124 125 data->ed = hcd_ep->ed; 126 batch->private_data = data; 127 batch->private_data_dtor = ohci_batch_dispose; 128 129 /* NOTE: OHCI is capable of handling buffer that crosses page boundaries 130 * it is, however, not capable of handling buffer that occupies more 131 * than two pages (the first page is computed using start pointer, the 132 * other using the end pointer) */ 133 if (batch->setup_size + batch->buffer_size > 0) { 134 data->device_buffer = 135 malloc32(batch->setup_size + batch->buffer_size); 136 CHECK_NULL_DISPOSE_RETURN(data->device_buffer, 137 "Failed to allocate device accessible buffer.\n"); 138 memcpy(data->device_buffer, batch->setup_buffer, 139 batch->setup_size); 140 batch->data_buffer = data->device_buffer + batch->setup_size; 141 } 142 143 return EOK; 144 #undef CHECK_NULL_DISPOSE_RETURN 145 } 146 /*----------------------------------------------------------------------------*/ 85 147 /** Allocate memory initialize internal structures 86 148 * … … 119 181 usb_transfer_batch_init(instance, ep, buffer, NULL, buffer_size, 120 182 NULL, setup_size, func_in, func_out, arg, fun, NULL, 121 ohci_ transfer_batch_dispose);183 ohci_batch_dispose); 122 184 123 185 const hcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep); -
uspace/drv/bus/usb/ohci/batch.h
r27873be re2976bb 48 48 void *arg); 49 49 50 bool batch_is_complete(usb_transfer_batch_t *instance); 50 int batch_init_ohci(usb_transfer_batch_t *batch); 51 52 bool batch_is_complete(usb_transfer_batch_t *batch); 51 53 52 54 void batch_commit(usb_transfer_batch_t *instance); -
uspace/drv/bus/usb/ohci/hc.c
r27873be re2976bb 193 193 CHECK_RET_RETURN(ret, "Failed to initialize endpoint manager: %s.\n", 194 194 str_error(ret)); 195 196 ret = hcd_init(&instance->generic, BANDWIDTH_AVAILABLE_USB11); 197 instance->generic.schedule = NULL; 198 instance->generic.batch_init_hook = batch_init_ohci; 199 instance->generic.ep_add_hook = NULL; 195 200 196 201 ret = hc_init_memory(instance); -
uspace/drv/bus/usb/ohci/hc.h
r27873be re2976bb 43 43 #include <usb/host/device_keeper.h> 44 44 #include <usb/host/usb_endpoint_manager.h> 45 #include <usb hc_iface.h>45 #include <usb/host/hcd.h> 46 46 47 47 #include "batch.h" … … 57 57 /** USB bus driver, endpoints */ 58 58 usb_endpoint_manager_t ep_manager; 59 60 /** Generic USB hc driver */ 61 hcd_t generic; 59 62 60 63 /** Memory mapped I/O registers area */
Note:
See TracChangeset
for help on using the changeset viewer.