Changeset d09f3720 in mainline for uspace/drv
- Timestamp:
- 2011-05-19T15:20:48Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4939490
- Parents:
- df44fa2 (diff), 7941bd6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/drv
- Files:
-
- 68 edited
-
ohci/batch.c (modified) (19 diffs)
-
ohci/batch.h (modified) (3 diffs)
-
ohci/endpoint_list.c (modified) (7 diffs)
-
ohci/endpoint_list.h (modified) (3 diffs)
-
ohci/hc.c (modified) (21 diffs)
-
ohci/hc.h (modified) (4 diffs)
-
ohci/hcd_endpoint.c (modified) (4 diffs)
-
ohci/hcd_endpoint.h (modified) (2 diffs)
-
ohci/hw_struct/transfer_descriptor.c (modified) (1 diff)
-
ohci/hw_struct/transfer_descriptor.h (modified) (1 diff)
-
ohci/iface.h (modified) (1 diff)
-
ohci/ohci.h (modified) (1 diff)
-
ohci/ohci_regs.h (modified) (2 diffs)
-
ohci/pci.h (modified) (1 diff)
-
ohci/root_hub.c (modified) (7 diffs)
-
ohci/root_hub.h (modified) (2 diffs)
-
ohci/utils/malloc32.h (modified) (4 diffs)
-
uhci-hcd/batch.c (modified) (5 diffs)
-
uhci-hcd/batch.h (modified) (2 diffs)
-
uhci-hcd/hc.c (modified) (1 diff)
-
uhci-hcd/hc.h (modified) (2 diffs)
-
uhci-hcd/hw_struct/link_pointer.h (modified) (1 diff)
-
uhci-hcd/hw_struct/queue_head.h (modified) (4 diffs)
-
uhci-hcd/hw_struct/transfer_descriptor.h (modified) (1 diff)
-
uhci-hcd/root_hub.h (modified) (1 diff)
-
uhci-hcd/transfer_list.c (modified) (4 diffs)
-
uhci-hcd/transfer_list.h (modified) (1 diff)
-
uhci-hcd/uhci.c (modified) (2 diffs)
-
uhci-hcd/utils/malloc32.h (modified) (3 diffs)
-
uhci-hcd/utils/slab.c (modified) (1 diff)
-
uhci-hcd/utils/slab.h (modified) (2 diffs)
-
uhci-rhd/port.c (modified) (4 diffs)
-
uhci-rhd/port.h (modified) (1 diff)
-
usbflbk/main.c (modified) (1 diff)
-
usbhid/generic/hiddev.h (modified) (1 diff)
-
usbhid/kbd/kbddev.c (modified) (1 diff)
-
usbhid/kbd/kbddev.h (modified) (1 diff)
-
usbhid/kbd/main.c (modified) (1 diff)
-
usbhid/main.c (modified) (2 diffs)
-
usbhid/mouse/mousedev.c (modified) (1 diff)
-
usbhid/mouse/mousedev.h (modified) (1 diff)
-
usbhid/multimedia/multimedia.c (modified) (1 diff)
-
usbhid/multimedia/multimedia.h (modified) (1 diff)
-
usbhid/subdrivers.c (modified) (1 diff)
-
usbhid/usbhid.c (modified) (1 diff)
-
usbhid/usbhid.h (modified) (1 diff)
-
usbhub/main.c (modified) (1 diff)
-
usbhub/port_status.h (modified) (1 diff)
-
usbhub/ports.h (modified) (1 diff)
-
usbhub/usbhub.c (modified) (5 diffs)
-
usbhub/usbhub.h (modified) (1 diff)
-
usbhub/usbhub_private.h (modified) (1 diff)
-
usbmast/inquiry.c (modified) (1 diff)
-
usbmast/main.c (modified) (1 diff)
-
usbmast/mast.c (modified) (1 diff)
-
usbmast/mast.h (modified) (1 diff)
-
usbmid/dump.c (modified) (1 diff)
-
usbmid/explore.c (modified) (1 diff)
-
usbmid/main.c (modified) (1 diff)
-
usbmid/usbmid.c (modified) (1 diff)
-
usbmid/usbmid.h (modified) (1 diff)
-
usbmouse/init.c (modified) (1 diff)
-
usbmouse/main.c (modified) (1 diff)
-
usbmouse/mouse.h (modified) (1 diff)
-
vhc/conndev.c (modified) (3 diffs)
-
vhc/connhost.c (modified) (1 diff)
-
vhc/hub.c (modified) (1 diff)
-
vhc/transfer.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/batch.c
rdf44fa2 rd09f3720 44 44 #include "hw_struct/transfer_descriptor.h" 45 45 46 /** OHCI specific data required for USB transfer */ 46 47 typedef struct ohci_transfer_batch { 48 /** Endpoint descriptor of the target endpoint. */ 47 49 ed_t *ed; 50 /** List of TDs needed for the transfer */ 48 51 td_t **tds; 52 /** Number of TDs used by the transfer */ 49 53 size_t td_count; 54 /** Dummy TD to be left at the ED and used by the next transfer */ 50 55 size_t leave_td; 51 char *device_buffer; 56 /** Data buffer, must be accessible byb the OHCI hw. */ 57 void *device_buffer; 52 58 } ohci_transfer_batch_t; 53 59 /*----------------------------------------------------------------------------*/ 60 static void batch_control(usb_transfer_batch_t *instance, 61 usb_direction_t data_dir, usb_direction_t status_dir); 62 static void batch_data(usb_transfer_batch_t *instance); 63 /*----------------------------------------------------------------------------*/ 64 /** Safely destructs ohci_transfer_batch_t structure 65 * 66 * @param[in] ohci_batch Instance to destroy. 67 */ 54 68 static void ohci_transfer_batch_dispose(void *ohci_batch) 55 69 { … … 69 83 } 70 84 /*----------------------------------------------------------------------------*/ 71 static void batch_control(usb_transfer_batch_t *instance, 72 usb_direction_t data_dir, usb_direction_t status_dir); 73 static void batch_data(usb_transfer_batch_t *instance); 74 /*----------------------------------------------------------------------------*/ 85 /** Allocate memory initialize internal structures 86 * 87 * @param[in] fun DDF function to pass to callback. 88 * @param[in] ep Communication target 89 * @param[in] buffer Data source/destination. 90 * @param[in] buffer_size Size of the buffer. 91 * @param[in] setup_buffer Setup data source (if not NULL) 92 * @param[in] setup_size Size of setup_buffer (should be always 8) 93 * @param[in] func_in function to call on inbound transfer completion 94 * @param[in] func_out function to call on outbound transfer completion 95 * @param[in] arg additional parameter to func_in or func_out 96 * @return Valid pointer if all structures were successfully created, 97 * NULL otherwise. 98 * 99 * Allocates and initializes structures needed by the OHCI hw for the transfer. 100 */ 75 101 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep, 76 char *buffer, size_t buffer_size, char* setup_buffer, size_t setup_size, 102 char *buffer, size_t buffer_size, 103 const char *setup_buffer, size_t setup_size, 77 104 usbhc_iface_transfer_in_callback_t func_in, 78 105 usbhc_iface_transfer_out_callback_t func_out, void *arg) … … 94 121 ohci_transfer_batch_dispose); 95 122 96 hcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep);123 const hcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep); 97 124 assert(hcd_ep); 98 125 … … 103 130 data->td_count = 104 131 ((buffer_size + OHCI_TD_MAX_TRANSFER - 1) / OHCI_TD_MAX_TRANSFER); 132 /* Control transfer need Setup and Status stage */ 105 133 if (ep->transfer_type == USB_TRANSFER_CONTROL) { 106 134 data->td_count += 2; 107 135 } 108 136 109 /* we need one extra place for tdthat is currently assigned to hcd_ep*/137 /* We need an extra place for TD that is currently assigned to hcd_ep*/ 110 138 data->tds = calloc(sizeof(td_t*), data->td_count + 1); 111 139 CHECK_NULL_DISPOSE_RETURN(data->tds, 112 140 "Failed to allocate transfer descriptors.\n"); 113 141 142 /* Add TD left over by the previous transfer */ 114 143 data->tds[0] = hcd_ep->td; 115 144 data->leave_td = 0; … … 123 152 data->ed = hcd_ep->ed; 124 153 154 /* NOTE: OHCI is capable of handling buffer that crosses page boundaries 155 * it is, however, not capable of handling buffer that occupies more 156 * than two pages (the first page is computed using start pointer, the 157 * other using the end pointer) */ 125 158 if (setup_size + buffer_size > 0) { 126 159 data->device_buffer = malloc32(setup_size + buffer_size); … … 135 168 } 136 169 /*----------------------------------------------------------------------------*/ 170 /** Check batch TDs' status. 171 * 172 * @param[in] instance Batch structure to use. 173 * @return False, if there is an active TD, true otherwise. 174 * 175 * Walk all TDs (usually there is just one). Stop with false if there is an 176 * active TD. Stop with true if an error is found. Return true if the walk 177 * completes with the last TD. 178 */ 137 179 bool batch_is_complete(usb_transfer_batch_t *instance) 138 180 { … … 140 182 ohci_transfer_batch_t *data = instance->private_data; 141 183 assert(data); 142 size_t tds = data->td_count;143 184 usb_log_debug("Batch(%p) checking %zu td(s) for completion.\n", 144 instance, tds);185 instance, data->td_count); 145 186 usb_log_debug("ED: %x:%x:%x:%x.\n", 146 187 data->ed->status, data->ed->td_head, data->ed->td_tail, … … 148 189 size_t i = 0; 149 190 instance->transfered_size = instance->buffer_size; 150 for (; i < tds; ++i) {191 for (; i < data->td_count; ++i) { 151 192 assert(data->tds[i] != NULL); 152 193 usb_log_debug("TD %zu: %x:%x:%x:%x.\n", i, … … 173 214 assert(hcd_ep); 174 215 hcd_ep->td = data->tds[i]; 175 if (i > 0) 176 instance->transfered_size -= td_remain_size(data->tds[i - 1]); 216 assert(i > 0); 217 for (--i;i < data->td_count; ++i) 218 instance->transfered_size -= td_remain_size(data->tds[i]); 177 219 178 220 /* Clear possible ED HALT */ 179 221 data->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG; 180 uint32_t pa = addr_to_phys(hcd_ep->td);222 const uint32_t pa = addr_to_phys(hcd_ep->td); 181 223 assert(pa == (data->ed->td_head & ED_TDHEAD_PTR_MASK)); 182 224 assert(pa == (data->ed->td_tail & ED_TDTAIL_PTR_MASK)); … … 185 227 } 186 228 /*----------------------------------------------------------------------------*/ 229 /** Starts execution of the TD list 230 * 231 * @param[in] instance Batch structure to use 232 */ 187 233 void batch_commit(usb_transfer_batch_t *instance) 188 234 { … … 193 239 } 194 240 /*----------------------------------------------------------------------------*/ 241 /** Prepares control write transfer. 242 * 243 * @param[in] instance Batch structure to use. 244 * 245 * Uses generic control transfer using direction OUT(data stage) and 246 * IN(status stage). 247 */ 195 248 void batch_control_write(usb_transfer_batch_t *instance) 196 249 { … … 203 256 } 204 257 /*----------------------------------------------------------------------------*/ 258 /** Prepares control read transfer. 259 * 260 * @param[in] instance Batch structure to use. 261 * 262 * Uses generic control transfer using direction IN(data stage) and 263 * OUT(status stage). 264 */ 205 265 void batch_control_read(usb_transfer_batch_t *instance) 206 266 { … … 211 271 } 212 272 /*----------------------------------------------------------------------------*/ 273 /** Prepare interrupt in transfer. 274 * 275 * @param[in] instance Batch structure to use. 276 * 277 * Data transfer. 278 */ 213 279 void batch_interrupt_in(usb_transfer_batch_t *instance) 214 280 { … … 219 285 } 220 286 /*----------------------------------------------------------------------------*/ 287 /** Prepare interrupt out transfer. 288 * 289 * @param[in] instance Batch structure to use. 290 * 291 * Data transfer. 292 */ 221 293 void batch_interrupt_out(usb_transfer_batch_t *instance) 222 294 { … … 229 301 } 230 302 /*----------------------------------------------------------------------------*/ 303 /** Prepare bulk in transfer. 304 * 305 * @param[in] instance Batch structure to use. 306 * 307 * Data transfer. 308 */ 231 309 void batch_bulk_in(usb_transfer_batch_t *instance) 232 310 { … … 237 315 } 238 316 /*----------------------------------------------------------------------------*/ 317 /** Prepare bulk out transfer. 318 * 319 * @param[in] instance Batch structure to use. 320 * 321 * Data transfer. 322 */ 239 323 void batch_bulk_out(usb_transfer_batch_t *instance) 240 324 { … … 247 331 } 248 332 /*----------------------------------------------------------------------------*/ 249 ed_t * batch_ed(usb_transfer_batch_t *instance) 250 { 251 assert(instance); 252 ohci_transfer_batch_t *data = instance->private_data; 253 assert(data); 254 return data->ed; 255 } 256 /*----------------------------------------------------------------------------*/ 333 /** Prepare generic control transfer 334 * 335 * @param[in] instance Batch structure to use. 336 * @param[in] data_dir Direction to use for data stage. 337 * @param[in] status_dir Direction to use for status stage. 338 * 339 * Setup stage with toggle 0 and direction BOTH(SETUP_PID) 340 * Data stage with alternating toggle and direction supplied by parameter. 341 * Status stage with toggle 1 and direction supplied by parameter. 342 */ 257 343 void batch_control(usb_transfer_batch_t *instance, 258 344 usb_direction_t data_dir, usb_direction_t status_dir) … … 303 389 } 304 390 /*----------------------------------------------------------------------------*/ 391 /** Prepare generic data transfer 392 * 393 * @param[in] instance Batch structure to use. 394 * 395 * Direction is supplied by the associated ep and toggle is maintained by the 396 * OHCI hw in ED. 397 */ 305 398 void batch_data(usb_transfer_batch_t *instance) 306 399 { … … 316 409 char *buffer = instance->data_buffer; 317 410 while (remain_size > 0) { 318 size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ?319 OHCI_TD_MAX_TRANSFER : remain_size;411 const size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER 412 ? OHCI_TD_MAX_TRANSFER : remain_size; 320 413 321 414 td_init(data->tds[td_current], instance->ep->direction, -
uspace/drv/ohci/batch.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusb uhcihc28 /** @addtogroup drvusbohci 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver USB transaction structure32 * @brief OHCI driver USB transaction structure 33 33 */ 34 #ifndef DRV_ UHCI_BATCH_H35 #define DRV_ UHCI_BATCH_H34 #ifndef DRV_OHCI_BATCH_H 35 #define DRV_OHCI_BATCH_H 36 36 37 37 #include <usbhc_iface.h> … … 41 41 #include <usb/host/batch.h> 42 42 43 #include "hw_struct/endpoint_descriptor.h"44 45 43 usb_transfer_batch_t * batch_get( 46 44 ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size, 47 c har *setup_buffer, size_t setup_size,45 const char *setup_buffer, size_t setup_size, 48 46 usbhc_iface_transfer_in_callback_t func_in, 49 47 usbhc_iface_transfer_out_callback_t func_out, … … 65 63 66 64 void batch_bulk_out(usb_transfer_batch_t *instance); 67 68 ed_t * batch_ed(usb_transfer_batch_t *instance);69 65 #endif 70 66 /** -
uspace/drv/ohci/endpoint_list.c
rdf44fa2 rd09f3720 34 34 #include <errno.h> 35 35 #include <usb/debug.h> 36 #include <arch/barrier.h> 36 37 37 38 #include "endpoint_list.h" … … 43 44 * @return Error code 44 45 * 45 * Allocates memory for internal qh_t structure.46 * Allocates memory for internal ed_t structure. 46 47 */ 47 48 int endpoint_list_init(endpoint_list_t *instance, const char *name) … … 68 69 * @param[in] instance List to lead. 69 70 * @param[in] next List to append. 70 * @return Error code71 71 * 72 * Does not check whether this replaces an existing list .72 * Does not check whether this replaces an existing list. 73 73 */ 74 74 void endpoint_list_set_next(endpoint_list_t *instance, endpoint_list_t *next) … … 79 79 } 80 80 /*----------------------------------------------------------------------------*/ 81 /** Submit transferendpoint to the list and queue.81 /** Add endpoint to the list and queue. 82 82 * 83 83 * @param[in] instance List to use. 84 * @param[in] endpoint Transfer endpoint to submit. 85 * @return Error code 84 * @param[in] endpoint Endpoint to add. 86 85 * 87 86 * The endpoint is added to the end of the list and queue. … … 99 98 /* Add to the hardware queue. */ 100 99 if (list_empty(&instance->endpoint_list)) { 101 /* There is nothing scheduled*/100 /* There are no active EDs */ 102 101 last_ed = instance->list_head; 103 102 } else { 104 /* There is something scheduled*/103 /* There are active EDs, get the last one */ 105 104 hcd_endpoint_t *last = list_get_instance( 106 105 instance->endpoint_list.prev, hcd_endpoint_t, link); 106 assert(last); 107 107 last_ed = last->ed; 108 108 } 109 /* keep link */109 /* Keep link */ 110 110 hcd_ep->ed->next = last_ed->next; 111 /* Make sure ED is written to the memory */ 112 write_barrier(); 113 114 /* Add ed to the hw queue */ 111 115 ed_append_ed(last_ed, hcd_ep->ed); 116 /* Make sure ED is updated */ 117 write_barrier(); 112 118 113 asm volatile ("": : :"memory"); 114 115 /* Add to the driver list */ 119 /* Add to the sw list */ 116 120 list_append(&hcd_ep->link, &instance->endpoint_list); 117 121 … … 129 133 } 130 134 /*----------------------------------------------------------------------------*/ 131 #if 0 132 /** Create list for finished endpoints. 135 /** Remove endpoint from the list and queue. 133 136 * 134 137 * @param[in] instance List to use. 135 * @param[in] done list to fill 136 */ 137 void endpoint_list_remove_finished(endpoint_list_t *instance, link_t *done) 138 { 139 assert(instance); 140 assert(done); 141 142 fibril_mutex_lock(&instance->guard); 143 usb_log_debug2("Checking list %s for completed endpointes(%d).\n", 144 instance->name, list_count(&instance->endpoint_list)); 145 link_t *current = instance->endpoint_list.next; 146 while (current != &instance->endpoint_list) { 147 link_t *next = current->next; 148 hcd_endpoint_t *endpoint = 149 list_get_instance(current, hcd_endpoint_t, link); 150 151 if (endpoint_is_complete(endpoint)) { 152 /* Save for post-processing */ 153 endpoint_list_remove_endpoint(instance, endpoint); 154 list_append(current, done); 155 } 156 current = next; 157 } 158 fibril_mutex_unlock(&instance->guard); 159 } 160 /*----------------------------------------------------------------------------*/ 161 /** Walk the list and abort all endpointes. 162 * 163 * @param[in] instance List to use. 164 */ 165 void endpoint_list_abort_all(endpoint_list_t *instance) 166 { 167 fibril_mutex_lock(&instance->guard); 168 while (!list_empty(&instance->endpoint_list)) { 169 link_t *current = instance->endpoint_list.next; 170 hcd_endpoint_t *endpoint = 171 list_get_instance(current, hcd_endpoint_t, link); 172 endpoint_list_remove_endpoint(instance, endpoint); 173 hcd_endpoint_finish_error(endpoint, EIO); 174 } 175 fibril_mutex_unlock(&instance->guard); 176 } 177 #endif 178 /*----------------------------------------------------------------------------*/ 179 /** Remove a transfer endpoint from the list and queue. 180 * 181 * @param[in] instance List to use. 182 * @param[in] endpoint Transfer endpoint to remove. 183 * @return Error code 184 * 185 * Does not lock the transfer list, caller is responsible for that. 138 * @param[in] endpoint Endpoint to remove. 186 139 */ 187 140 void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep) … … 212 165 assert((prev_ed->next & ED_NEXT_PTR_MASK) == addr_to_phys(hcd_ep->ed)); 213 166 prev_ed->next = hcd_ep->ed->next; 167 /* Make sure ED is updated */ 168 write_barrier(); 214 169 215 asm volatile ("": : :"memory");216 170 usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x.\n", 217 171 hcd_ep, qpos, instance->name, hcd_ep->ed->next); -
uspace/drv/ohci/endpoint_list.h
rdf44fa2 rd09f3720 41 41 #include "utils/malloc32.h" 42 42 43 typedef struct endpoint_list 44 { 43 /** Structure maintains both OHCI queue and software list of active endpoints.*/ 44 typedef struct endpoint_list { 45 /** Guard against add/remove races */ 45 46 fibril_mutex_t guard; 47 /** OHCI hw structure at the beginning of the queue */ 46 48 ed_t *list_head; 49 /** Physical address of the first(dummy) ED */ 47 50 uint32_t list_head_pa; 51 /** Assigned name, provides nicer debug output */ 48 52 const char *name; 53 /** Sw list of all active EDs */ 49 54 link_t endpoint_list; 50 55 } endpoint_list_t; … … 54 59 * @param[in] instance Memory place to use. 55 60 * 56 * Frees memory for internal qh_t structure.61 * Frees memory of the internal ed_t structure. 57 62 */ 58 63 static inline void endpoint_list_fini(endpoint_list_t *instance) … … 63 68 64 69 int endpoint_list_init(endpoint_list_t *instance, const char *name); 65 66 70 void endpoint_list_set_next(endpoint_list_t *instance, endpoint_list_t *next); 67 68 71 void endpoint_list_add_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep); 69 70 72 void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep); 71 #if 072 void endpoint_list_remove_finished(endpoint_list_t *instance, link_t *done);73 74 void endpoint_list_abort_all(endpoint_list_t *instance);75 #endif76 73 #endif 77 74 /** -
uspace/drv/ohci/hc.c
rdf44fa2 rd09f3720 51 51 static int hc_init_memory(hc_t *instance); 52 52 /*----------------------------------------------------------------------------*/ 53 /** Announce OHCI root hub to the DDF 54 * 55 * @param[in] instance OHCI driver intance 56 * @param[in] hub_fun DDF fuction representing OHCI root hub 57 * @return Error code 58 */ 53 59 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun) 54 60 { … … 56 62 assert(hub_fun); 57 63 58 int ret; 59 60 usb_address_t hub_address = 64 const usb_address_t hub_address = 61 65 device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL); 62 66 if (hub_address <= 0) { 63 usb_log_error("Failed to get OHCI root hub address.\n"); 67 usb_log_error("Failed(%d) to get OHCI root hub address.\n", 68 hub_address); 64 69 return hub_address; 65 70 } … … 68 73 &instance->manager, hub_address, hub_fun->handle); 69 74 70 ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL, 75 #define CHECK_RET_RELEASE(ret, message...) \ 76 if (ret != EOK) { \ 77 usb_log_error(message); \ 78 hc_remove_endpoint(instance, hub_address, 0, USB_DIRECTION_BOTH); \ 79 usb_device_keeper_release(&instance->manager, hub_address); \ 80 return ret; \ 81 } else (void)0 82 83 int ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL, 71 84 USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH, 64, 0, 0); 72 if (ret != EOK) { 73 usb_log_error("Failed to add OHCI rh endpoint 0.\n"); 74 usb_device_keeper_release(&instance->manager, hub_address); 75 return ret; 76 } 85 CHECK_RET_RELEASE(ret, "Failed(%d) to add OHCI rh endpoint 0.\n", ret); 77 86 78 87 char *match_str = NULL; 79 88 /* DDF needs heap allocated string */ 80 89 ret = asprintf(&match_str, "usb&class=hub"); 81 if (ret < 0) { 82 usb_log_error( 83 "Failed(%d) to create root hub match-id string.\n", ret); 84 usb_device_keeper_release(&instance->manager, hub_address); 85 return ret; 86 } 90 ret = ret > 0 ? 0 : ret; 91 CHECK_RET_RELEASE(ret, "Failed(%d) to create match-id string.\n", ret); 87 92 88 93 ret = ddf_fun_add_match_id(hub_fun, match_str, 100); 89 if (ret != EOK) { 90 usb_log_error("Failed add root hub match-id.\n"); 91 } 94 CHECK_RET_RELEASE(ret, "Failed(%d) add root hub match-id.\n", ret); 95 92 96 ret = ddf_fun_bind(hub_fun); 93 return ret; 94 } 95 /*----------------------------------------------------------------------------*/ 97 CHECK_RET_RELEASE(ret, "Failed(%d) to bind root hub function.\n", ret); 98 99 return EOK; 100 #undef CHECK_RET_RELEASE 101 } 102 /*----------------------------------------------------------------------------*/ 103 /** Initialize OHCI hc driver structure 104 * 105 * @param[in] instance Memory place for the structure. 106 * @param[in] regs Address of the memory mapped I/O registers. 107 * @param[in] reg_size Size of the memory mapped area. 108 * @param[in] interrupts True if w interrupts should be used 109 * @return Error code 110 */ 96 111 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts) 97 112 { … … 121 136 #undef CHECK_RET_RETURN 122 137 123 124 // hc_init_hw(instance); 138 fibril_mutex_initialize(&instance->guard); 125 139 hc_gain_control(instance); 126 fibril_mutex_initialize(&instance->guard);127 140 128 141 rh_init(&instance->rh, instance->registers); … … 137 150 } 138 151 /*----------------------------------------------------------------------------*/ 152 /** Create end register endpoint structures 153 * 154 * @param[in] instance OHCI driver structure. 155 * @param[in] address USB address of the device. 156 * @param[in] endpoint USB endpoint number. 157 * @param[in] speed Communication speeed of the device. 158 * @param[in] type Endpoint's transfer type. 159 * @param[in] direction Endpoint's direction. 160 * @param[in] mps Maximum packet size the endpoint accepts. 161 * @param[in] size Maximum allowed buffer size. 162 * @param[in] interval Time between transfers(interrupt transfers only). 163 * @return Error code 164 */ 139 165 int hc_add_endpoint( 140 166 hc_t *instance, usb_address_t address, usb_endpoint_t endpoint, … … 194 220 } 195 221 /*----------------------------------------------------------------------------*/ 222 /** Dequeue and delete endpoint structures 223 * 224 * @param[in] instance OHCI hc driver structure. 225 * @param[in] address USB address of the device. 226 * @param[in] endpoint USB endpoint number. 227 * @param[in] direction Direction of the endpoint. 228 * @return Error code 229 */ 196 230 int hc_remove_endpoint(hc_t *instance, usb_address_t address, 197 231 usb_endpoint_t endpoint, usb_direction_t direction) … … 244 278 } 245 279 /*----------------------------------------------------------------------------*/ 280 /** Get access to endpoint structures 281 * 282 * @param[in] instance OHCI hc driver structure. 283 * @param[in] address USB address of the device. 284 * @param[in] endpoint USB endpoint number. 285 * @param[in] direction Direction of the endpoint. 286 * @param[out] bw Reserved bandwidth. 287 * @return Error code 288 */ 246 289 endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address, 247 290 usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw) … … 255 298 } 256 299 /*----------------------------------------------------------------------------*/ 300 /** Add USB transfer to the schedule. 301 * 302 * @param[in] instance OHCI hc driver structure. 303 * @param[in] batch Batch representing the transfer. 304 * @return Error code. 305 */ 257 306 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch) 258 307 { … … 261 310 assert(batch->ep); 262 311 263 /* check for root hub communication */312 /* Check for root hub communication */ 264 313 if (batch->ep->address == instance->rh.address) { 265 314 return rh_request(&instance->rh, batch); … … 269 318 list_append(&batch->link, &instance->pending_batches); 270 319 batch_commit(batch); 271 switch (batch->ep->transfer_type) { 320 321 /* Control and bulk schedules need a kick to start working */ 322 switch (batch->ep->transfer_type) 323 { 272 324 case USB_TRANSFER_CONTROL: 273 325 instance->registers->command_status |= CS_CLF; … … 279 331 break; 280 332 } 281 282 333 fibril_mutex_unlock(&instance->guard); 283 334 return EOK; 284 335 } 285 336 /*----------------------------------------------------------------------------*/ 337 /** Interrupt handling routine 338 * 339 * @param[in] instance OHCI hc driver structure. 340 * @param[in] status Value of the status register at the time of interrupt. 341 */ 286 342 void hc_interrupt(hc_t *instance, uint32_t status) 287 343 { … … 292 348 if (status & I_RHSC) 293 349 rh_interrupt(&instance->rh); 294 295 350 296 351 if (status & I_WDH) { … … 316 371 fibril_mutex_unlock(&instance->guard); 317 372 } 318 } 319 /*----------------------------------------------------------------------------*/ 373 374 if (status & I_UE) { 375 hc_start_hw(instance); 376 } 377 378 } 379 /*----------------------------------------------------------------------------*/ 380 /** Check status register regularly 381 * 382 * @param[in] instance OHCI hc driver structure. 383 * @return Error code 384 */ 320 385 int interrupt_emulator(hc_t *instance) 321 386 { … … 326 391 instance->registers->interrupt_status = status; 327 392 hc_interrupt(instance, status); 328 async_usleep( 50000);393 async_usleep(10000); 329 394 } 330 395 return EOK; 331 396 } 332 397 /*----------------------------------------------------------------------------*/ 398 /** Turn off any (BIOS)driver that might be in control of the device. 399 * 400 * @param[in] instance OHCI hc driver structure. 401 */ 333 402 void hc_gain_control(hc_t *instance) 334 403 { … … 380 449 } 381 450 /*----------------------------------------------------------------------------*/ 451 /** OHCI hw initialization routine. 452 * 453 * @param[in] instance OHCI hc driver structure. 454 */ 382 455 void hc_start_hw(hc_t *instance) 383 456 { … … 447 520 } 448 521 /*----------------------------------------------------------------------------*/ 522 /** Initialize schedule queues 523 * 524 * @param[in] instance OHCI hc driver structure 525 * @return Error code 526 */ 449 527 int hc_init_transfer_lists(hc_t *instance) 450 528 { 451 529 assert(instance); 452 453 530 #define SETUP_ENDPOINT_LIST(type) \ 454 531 do { \ … … 458 535 usb_log_error("Failed(%d) to setup %s endpoint list.\n", \ 459 536 ret, name); \ 460 endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]); \537 endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]);\ 461 538 endpoint_list_fini(&instance->lists[USB_TRANSFER_INTERRUPT]); \ 462 539 endpoint_list_fini(&instance->lists[USB_TRANSFER_CONTROL]); \ 463 540 endpoint_list_fini(&instance->lists[USB_TRANSFER_BULK]); \ 541 return ret; \ 464 542 } \ 465 543 } while (0) … … 476 554 } 477 555 /*----------------------------------------------------------------------------*/ 556 /** Initialize memory structures used by the OHCI hcd. 557 * 558 * @param[in] instance OHCI hc driver structure. 559 * @return Error code. 560 */ 478 561 int hc_init_memory(hc_t *instance) 479 562 { … … 502 585 /* Init interrupt code */ 503 586 instance->interrupt_code.cmds = instance->interrupt_commands; 587 instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS; 504 588 { 505 589 /* Read status register */ … … 521 605 instance->interrupt_commands[2].srcarg = 2; 522 606 523 /* Write clean status register */607 /* Write-clean status register */ 524 608 instance->interrupt_commands[3].cmd = CMD_MEM_WRITE_A_32; 525 609 instance->interrupt_commands[3].srcarg = 1; … … 529 613 /* Accept interrupt */ 530 614 instance->interrupt_commands[4].cmd = CMD_ACCEPT; 531 532 instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS;533 615 } 534 616 -
uspace/drv/ohci/hc.h
rdf44fa2 rd09f3720 53 53 #define OHCI_NEEDED_IRQ_COMMANDS 5 54 54 55 /** Main OHCI drier structure */ 55 56 typedef struct hc { 57 /** USB bus driver, devices and addresses */ 58 usb_device_keeper_t manager; 59 /** USB bus driver, endpoints */ 60 usb_endpoint_manager_t ep_manager; 61 62 /** Memory mapped I/O registers area */ 56 63 ohci_regs_t *registers; 64 /** Host controller communication area structure */ 57 65 hcca_t *hcca; 58 66 59 usb_address_t rh_address; 60 rh_t rh; 61 67 /** Transfer schedules */ 62 68 endpoint_list_t lists[4]; 69 /** List of active transfers */ 63 70 link_t pending_batches; 64 71 65 usb_device_keeper_t manager; 66 usb_endpoint_manager_t ep_manager; 72 /** Fibril for periodic checks if interrupts can't be used */ 67 73 fid_t interrupt_emulator; 74 75 /** Guards schedule and endpoint manipulation */ 68 76 fibril_mutex_t guard; 69 77 … … 73 81 /** Commands that form interrupt code */ 74 82 irq_cmd_t interrupt_commands[OHCI_NEEDED_IRQ_COMMANDS]; 83 84 /** USB hub emulation structure */ 85 rh_t rh; 75 86 } hc_t; 76 87 77 88 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 78 79 89 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts); 80 81 90 void hc_start_hw(hc_t *instance); 82 91 … … 85 94 * @param[in] instance Host controller structure to use. 86 95 */ 87 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ }; 96 static inline void hc_fini(hc_t *instance) 97 { /* TODO: implement*/ }; 88 98 89 99 int hc_add_endpoint(hc_t *instance, usb_address_t address, usb_endpoint_t ep, 90 100 usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction, 91 101 size_t max_packet_size, size_t size, unsigned interval); 92 93 102 int hc_remove_endpoint(hc_t *instance, usb_address_t address, 94 103 usb_endpoint_t endpoint, usb_direction_t direction); 95 96 104 endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address, 97 105 usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw); 98 106 99 107 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch); 100 101 108 void hc_interrupt(hc_t *instance, uint32_t status); 102 109 … … 107 114 */ 108 115 static inline hc_t * fun_to_hc(ddf_fun_t *fun) 109 { return (hc_t*)fun->driver_data; }116 { return fun->driver_data; } 110 117 #endif 111 118 /** -
uspace/drv/ohci/hcd_endpoint.c
rdf44fa2 rd09f3720 35 35 #include "hcd_endpoint.h" 36 36 37 /** Callback to set toggle on ED. 38 * 39 * @param[in] hcd_ep hcd endpoint structure 40 * @param[in] toggle new value of toggle bit 41 */ 37 42 static void hcd_ep_toggle_set(void *hcd_ep, int toggle) 38 43 { … … 42 47 ed_toggle_set(instance->ed, toggle); 43 48 } 49 /*----------------------------------------------------------------------------*/ 50 /** Callback to get value of toggle bit. 51 * 52 * @param[in] hcd_ep hcd endpoint structure 53 * @return Current value of toggle bit. 54 */ 44 55 static int hcd_ep_toggle_get(void *hcd_ep) 45 56 { … … 49 60 return ed_toggle_get(instance->ed); 50 61 } 51 52 62 /*----------------------------------------------------------------------------*/ 63 /** Creates new hcd endpoint representation. 64 * 65 * @param[in] ep USBD endpoint structure 66 * @return pointer to a new hcd endpoint structure, NULL on failure. 67 */ 53 68 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep) 54 69 { … … 78 93 } 79 94 /*----------------------------------------------------------------------------*/ 80 hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep) 81 { 82 assert(ep); 83 return ep->hc_data.data; 84 } 85 /*----------------------------------------------------------------------------*/ 95 /** Disposes assigned hcd endpoint structure 96 * 97 * @param[in] ep USBD endpoint structure 98 */ 86 99 void hcd_endpoint_clear(endpoint_t *ep) 87 100 { -
uspace/drv/ohci/hcd_endpoint.h
rdf44fa2 rd09f3720 37 37 #include <assert.h> 38 38 #include <adt/list.h> 39 40 39 #include <usb/host/endpoint.h> 41 40 … … 43 42 #include "hw_struct/transfer_descriptor.h" 44 43 44 /** Connector structure linking ED to to prepared TD. */ 45 45 typedef struct hcd_endpoint { 46 /** OHCI endpoint descriptor */ 46 47 ed_t *ed; 48 /** Currently enqueued transfer descriptor */ 47 49 td_t *td; 50 /** Linked list used by driver software */ 48 51 link_t link; 49 52 } hcd_endpoint_t; 50 53 51 54 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep); 55 void hcd_endpoint_clear(endpoint_t *ep); 52 56 53 hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep); 57 /** Get and convert assigned hcd_endpoint_t structure 58 * @param[in] ep USBD endpoint structure. 59 * @return Pointer to assigned hcd endpoint structure 60 */ 61 static inline hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep) 62 { 63 assert(ep); 64 return ep->hc_data.data; 65 } 54 66 55 void hcd_endpoint_clear(endpoint_t *ep);56 67 #endif 57 68 /** -
uspace/drv/ohci/hw_struct/transfer_descriptor.c
rdf44fa2 rd09f3720 44 44 assert(instance); 45 45 bzero(instance, sizeof(td_t)); 46 instance-> status = 046 instance->status = 0 47 47 | ((dp[dir] & TD_STATUS_DP_MASK) << TD_STATUS_DP_SHIFT) 48 48 | ((CC_NOACCESS2 & TD_STATUS_CC_MASK) << TD_STATUS_CC_SHIFT); -
uspace/drv/ohci/hw_struct/transfer_descriptor.h
rdf44fa2 rd09f3720 41 41 #include "completion_codes.h" 42 42 43 /* OHCI TDs can handle up to 8KB buffers */ 44 #define OHCI_TD_MAX_TRANSFER (8 * 1024) 43 /* OHCI TDs can handle up to 8KB buffers, however, it can use max 2 pages. 44 * Using 4KB buffers guarantees the page count condition. 45 * (OHCI assumes 4KB pages) */ 46 #define OHCI_TD_MAX_TRANSFER (4 * 1024) 45 47 46 48 typedef struct td { -
uspace/drv/ohci/iface.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 28 /** @addtogroup drvusbohci 30 29 * @{ -
uspace/drv/ohci/ohci.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 28 /** @addtogroup drvusbohci 30 29 * @{ -
uspace/drv/ohci/ohci_regs.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 28 /** @addtogroup drvusbohcihc 30 29 * @{ … … 37 36 #include <stdint.h> 38 37 39 typedef struct ohci_regs 40 {38 /** OHCI memory mapped registers structure */ 39 typedef struct ohci_regs { 41 40 const volatile uint32_t revision; 42 41 volatile uint32_t control; -
uspace/drv/ohci/pci.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 28 /** @addtogroup drvusbohci 30 29 * @{ -
uspace/drv/ohci/root_hub.c
rdf44fa2 rd09f3720 39 39 40 40 #include "root_hub.h" 41 #include "usb/classes/classes.h" 42 #include "usb/devdrv.h" 43 #include <usb/request.h> 41 #include <usb/classes/classes.h> 42 #include <usb/dev/driver.h> 43 #include "ohci_regs.h" 44 45 #include <usb/dev/request.h> 44 46 #include <usb/classes/hub.h> 45 47 … … 109 111 */ 110 112 static const uint32_t hub_clear_feature_valid_mask = 111 (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER)|112 (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);113 RHS_OCIC_FLAG | 114 RHS_CLEAR_PORT_POWER; 113 115 114 116 /** … … 116 118 */ 117 119 static const uint32_t hub_clear_feature_by_writing_one_mask = 118 1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER; 120 RHS_CLEAR_PORT_POWER; 121 // 1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER; 119 122 120 123 /** … … 122 125 */ 123 126 static const uint32_t hub_set_feature_valid_mask = 124 (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) | 125 (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER); 127 RHS_LPSC_FLAG | 128 RHS_OCIC_FLAG; 129 //(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) | 130 //(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER); 126 131 127 132 /** … … 129 134 */ 130 135 static const uint32_t hub_set_feature_direct_mask = 131 (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT); 136 RHS_SET_PORT_POWER; 137 //(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT); 132 138 133 139 /** … … 135 141 */ 136 142 static const uint32_t port_set_feature_valid_mask = 137 (1 << USB_HUB_FEATURE_PORT_ENABLE)|138 (1 << USB_HUB_FEATURE_PORT_SUSPEND)|139 (1 << USB_HUB_FEATURE_PORT_RESET)|140 (1 << USB_HUB_FEATURE_PORT_POWER);143 RHPS_SET_PORT_ENABLE | 144 RHPS_SET_PORT_SUSPEND | 145 RHPS_SET_PORT_RESET | 146 RHPS_SET_PORT_POWER; 141 147 142 148 /** … … 144 150 */ 145 151 static const uint32_t port_clear_feature_valid_mask = 152 RHPS_CCS_FLAG | 153 RHPS_SET_PORT_SUSPEND | 154 RHPS_POCI_FLAG | 155 RHPS_SET_PORT_POWER | 156 RHPS_CSC_FLAG | 157 RHPS_PESC_FLAG | 158 RHPS_PSSC_FLAG | 159 RHPS_OCIC_FLAG | 160 RHPS_PRSC_FLAG; 161 162 /* 163 146 164 (1 << USB_HUB_FEATURE_PORT_CONNECTION) | 147 (1 << USB_HUB_FEATURE_PORT_SUSPEND) | 148 (1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) | 149 (1 << USB_HUB_FEATURE_PORT_POWER) | 150 (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) | 151 (1 << USB_HUB_FEATURE_C_PORT_ENABLE) | 152 (1 << USB_HUB_FEATURE_C_PORT_SUSPEND) | 153 (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) | 154 (1 << USB_HUB_FEATURE_C_PORT_RESET); 165 (1 << USB_HUB_FEATURE_PORT_SUSPEND) | 166 (1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) | 167 (1 << USB_HUB_FEATURE_PORT_POWER) | 168 (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) | 169 (1 << USB_HUB_FEATURE_C_PORT_ENABLE) | 170 (1 << USB_HUB_FEATURE_C_PORT_SUSPEND) | 171 (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) | 172 (1 << USB_HUB_FEATURE_C_PORT_RESET); 173 */ 155 174 //note that USB_HUB_FEATURE_PORT_POWER bit is translated into 156 //USB_HUB_FEATURE_PORT_LOW_SPEED 175 //USB_HUB_FEATURE_PORT_LOW_SPEED for port set feature request 157 176 158 177 /** 159 178 * bitmask with port status changes 160 179 */ 161 static const uint32_t port_status_change_mask = 162 (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |163 (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |164 (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |165 (1 << USB_HUB_FEATURE_C_PORT_RESET) |166 (1 << USB_HUB_FEATURE_C_PORT_SUSPEND);167 180 static const uint32_t port_status_change_mask = RHPS_CHANGE_WC_MASK; 181 /* (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) | 182 (1 << USB_HUB_FEATURE_C_PORT_ENABLE) | 183 (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) | 184 (1 << USB_HUB_FEATURE_C_PORT_RESET) | 185 (1 << USB_HUB_FEATURE_C_PORT_SUSPEND); 186 */ 168 187 169 188 static int create_serialized_hub_descriptor(rh_t *instance); -
uspace/drv/ohci/root_hub.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 28 /** @addtogroup drvusbohci 30 29 * @{ … … 37 36 38 37 #include <usb/usb.h> 39 #include <usb/dev drv.h>38 #include <usb/dev/driver.h> 40 39 41 40 #include "ohci_regs.h" -
uspace/drv/ohci/utils/malloc32.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbohci 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver32 * @brief OHCI driver 33 33 */ 34 #ifndef DRV_ UHCI_TRANSLATOR_H35 #define DRV_ UHCI_TRANSLATOR_H34 #ifndef DRV_OHCI_UTILS_MALLOC32_H 35 #define DRV_OHCI_UTILS_MALLOC32_H 36 36 37 37 #include <assert.h> … … 40 40 #include <mem.h> 41 41 #include <as.h> 42 43 #define UHCI_REQUIRED_PAGE_SIZE 409644 42 45 43 /** Get physical address translation … … 61 59 * 62 60 * @param[in] size Size of the required memory space 63 * @return Address of the al ligned and big enough memory place, NULL on failure.61 * @return Address of the aligned and big enough memory place, NULL on failure. 64 62 */ 65 63 static inline void * malloc32(size_t size) … … 72 70 static inline void free32(void *addr) 73 71 { if (addr) free(addr); } 74 /*----------------------------------------------------------------------------*/75 /** Create 4KB page mapping76 *77 * @return Address of the mapped page, NULL on failure.78 */79 static inline void * get_page(void)80 {81 void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);82 assert(free_address);83 if (free_address == 0)84 return NULL;85 void* ret =86 as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,87 AS_AREA_READ | AS_AREA_WRITE);88 if (ret != free_address)89 return NULL;90 return ret;91 }92 93 72 #endif 94 73 /** -
uspace/drv/uhci-hcd/batch.c
rdf44fa2 rd09f3720 45 45 #define DEFAULT_ERROR_COUNT 3 46 46 47 /** UHCI specific data required for USB transfer */ 47 48 typedef struct uhci_transfer_batch { 49 /** Queue head 50 * This QH is used to maintain UHCI schedule structure and the element 51 * pointer points to the first TD of this batch. 52 */ 48 53 qh_t *qh; 54 /** List of TDs needed for the transfer */ 49 55 td_t *tds; 56 /** Number of TDs used by the transfer */ 57 size_t td_count; 58 /** Data buffer, must be accessible by the UHCI hw */ 50 59 void *device_buffer; 51 size_t td_count;52 60 } uhci_transfer_batch_t; 53 61 /*----------------------------------------------------------------------------*/ 54 static void uhci_transfer_batch_dispose(void *uhci_batch)55 {56 uhci_transfer_batch_t *instance = uhci_batch;57 assert(instance);58 free32(instance->device_buffer);59 free(instance);60 }61 /*----------------------------------------------------------------------------*/62 63 62 static void batch_control(usb_transfer_batch_t *instance, 64 63 usb_packet_id data_stage, usb_packet_id status_stage); 65 64 static void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid); 66 65 /*----------------------------------------------------------------------------*/ 66 /** Safely destructs uhci_transfer_batch_t structure 67 * 68 * @param[in] uhci_batch Instance to destroy. 69 */ 70 static void uhci_transfer_batch_dispose(void *uhci_batch) 71 { 72 uhci_transfer_batch_t *instance = uhci_batch; 73 assert(instance); 74 free32(instance->device_buffer); 75 free(instance); 76 } 77 /*----------------------------------------------------------------------------*/ 67 78 /** Allocate memory and initialize internal data structure. 68 79 * … … 70 81 * @param[in] ep Communication target 71 82 * @param[in] buffer Data source/destination. 72 * @param[in] size Size of the buffer.83 * @param[in] buffer_size Size of the buffer. 73 84 * @param[in] setup_buffer Setup data source (if not NULL) 74 85 * @param[in] setup_size Size of setup_buffer (should be always 8) … … 84 95 */ 85 96 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep, 86 char *buffer, size_t buffer_size, char* setup_buffer, size_t setup_size, 97 char *buffer, size_t buffer_size, 98 const char* setup_buffer, size_t setup_size, 87 99 usbhc_iface_transfer_in_callback_t func_in, 88 100 usbhc_iface_transfer_out_callback_t func_out, void *arg) … … 173 185 instance->error = td_status(&data->tds[i]); 174 186 if (instance->error != EOK) { 175 usb_log_debug("Batch(%p) found error TD(%zu):%" PRIx32 ".\n",176 instance, i, data->tds[i].status);187 usb_log_debug("Batch(%p) found error TD(%zu):%" 188 PRIx32 ".\n", instance, i, data->tds[i].status); 177 189 td_print_status(&data->tds[i]); 178 190 … … 397 409 /*----------------------------------------------------------------------------*/ 398 410 /** Provides access to QH data structure. 411 * 399 412 * @param[in] instance Batch pointer to use. 400 413 * @return Pointer to the QH used by the batch. -
uspace/drv/uhci-hcd/batch.h
rdf44fa2 rd09f3720 45 45 usb_transfer_batch_t * batch_get( 46 46 ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size, 47 c har *setup_buffer, size_t setup_size,47 const char *setup_buffer, size_t setup_size, 48 48 usbhc_iface_transfer_in_callback_t func_in, 49 49 usbhc_iface_transfer_out_callback_t func_out, … … 55 55 56 56 void batch_control_write(usb_transfer_batch_t *instance); 57 58 57 void batch_control_read(usb_transfer_batch_t *instance); 59 58 60 59 void batch_interrupt_in(usb_transfer_batch_t *instance); 61 62 60 void batch_interrupt_out(usb_transfer_batch_t *instance); 63 61 64 62 void batch_bulk_in(usb_transfer_batch_t *instance); 65 66 63 void batch_bulk_out(usb_transfer_batch_t *instance); 67 64 -
uspace/drv/uhci-hcd/hc.c
rdf44fa2 rd09f3720 57 57 static int hc_debug_checker(void *arg); 58 58 /*----------------------------------------------------------------------------*/ 59 /** Initialize UHCI hc ddriver structure59 /** Initialize UHCI hc driver structure 60 60 * 61 61 * @param[in] instance Memory place to initialize. 62 62 * @param[in] regs Address of I/O control registers. 63 * @param[in] size Size of I/O control registers. 63 * @param[in] reg_size Size of I/O control registers. 64 * @param[in] interrupts True if hw interrupts should be used. 64 65 * @return Error code. 65 66 * @note Should be called only once on any structure. -
uspace/drv/uhci-hcd/hc.h
rdf44fa2 rd09f3720 33 33 * @brief UHCI host controller driver structure 34 34 */ 35 #ifndef DRV_UHCI_ UHCI_HC_H36 #define DRV_UHCI_ UHCI_HC_H35 #ifndef DRV_UHCI_HC_H 36 #define DRV_UHCI_HC_H 37 37 38 38 #include <fibril.h> … … 95 95 #define UHCI_NEEDED_IRQ_COMMANDS 5 96 96 97 /* Main HCdriver structure */97 /** Main UHCI driver structure */ 98 98 typedef struct hc { 99 99 /** USB bus driver, devices and addresses */ -
uspace/drv/uhci-hcd/hw_struct/link_pointer.h
rdf44fa2 rd09f3720 32 32 * @brief UHCI driver 33 33 */ 34 #ifndef DRV_UHCI_ LINK_POINTER_H35 #define DRV_UHCI_ LINK_POINTER_H34 #ifndef DRV_UHCI_HW_STRUCT_LINK_POINTER_H 35 #define DRV_UHCI_HW_STRUCT_LINK_POINTER_H 36 36 37 37 /* UHCI link pointer, used by many data structures */ -
uspace/drv/uhci-hcd/hw_struct/queue_head.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drv usbuhcihc28 /** @addtogroup drvusbuhcihc 29 29 * @{ 30 30 */ … … 32 32 * @brief UHCI driver 33 33 */ 34 #ifndef DRV_UHCI_ QH_H35 #define DRV_UHCI_ QH_H34 #ifndef DRV_UHCI_HW_STRUCT_QH_H 35 #define DRV_UHCI_HW_STRUCT_QH_H 36 36 #include <assert.h> 37 37 … … 65 65 * 66 66 * @param[in] instance qh_t structure to use. 67 * @param[in] pa Physical address of the next queue head.67 * @param[in] next Address of the next queue. 68 68 * 69 69 * Adds proper flag. If the pointer is NULL, sets next to terminal NULL. … … 81 81 /** Set queue head element pointer 82 82 * 83 * @param[in] instance qh_t structure to initialize.84 * @param[in] pa Physical address of the TD structure.83 * @param[in] instance qh_t structure to use. 84 * @param[in] td Transfer descriptor to set as the first element. 85 85 * 86 86 * Adds proper flag. If the pointer is NULL, sets element to terminal NULL. -
uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.h
rdf44fa2 rd09f3720 32 32 * @brief UHCI driver 33 33 */ 34 #ifndef DRV_UHCI_ TRANSFER_DESCRIPTOR_H35 #define DRV_UHCI_ TRANSFER_DESCRIPTOR_H34 #ifndef DRV_UHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H 35 #define DRV_UHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H 36 36 37 37 #include <mem.h> -
uspace/drv/uhci-hcd/root_hub.h
rdf44fa2 rd09f3720 33 33 * @brief UHCI driver 34 34 */ 35 #ifndef DRV_UHCI_ UHCI_RH_H36 #define DRV_UHCI_ UHCI_RH_H35 #ifndef DRV_UHCI_RH_H 36 #define DRV_UHCI_RH_H 37 37 38 38 #include <ddf/driver.h> -
uspace/drv/uhci-hcd/transfer_list.c
rdf44fa2 rd09f3720 34 34 #include <errno.h> 35 35 #include <usb/debug.h> 36 #include <arch/barrier.h> 36 37 37 38 #include "transfer_list.h" … … 71 72 * @param[in] instance Memory place to use. 72 73 * 73 * Frees memory forinternal qh_t structure.74 * Frees memory of the internal qh_t structure. 74 75 */ 75 76 void transfer_list_fini(transfer_list_t *instance) … … 126 127 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 127 128 129 /* Make sure all data in the batch are written */ 130 write_barrier(); 131 128 132 /* keep link */ 129 133 batch_qh(batch)->next = last_qh->next; 130 134 qh_set_next_qh(last_qh, batch_qh(batch)); 131 135 132 asm volatile ("": : :"memory"); 136 /* Make sure the pointer is updated */ 137 write_barrier(); 133 138 134 139 /* Add to the driver list */ … … 222 227 == addr_to_phys(batch_qh(batch))); 223 228 prev_qh->next = batch_qh(batch)->next; 224 asm volatile ("": : :"memory"); 229 230 /* Make sure the pointer is updated */ 231 write_barrier(); 232 225 233 /* Remove from the batch list */ 226 234 list_remove(&batch->link); -
uspace/drv/uhci-hcd/transfer_list.h
rdf44fa2 rd09f3720 43 43 * of currently executed transfers 44 44 */ 45 typedef struct transfer_list 46 { 45 typedef struct transfer_list { 47 46 /** Guard against multiple add/remove races */ 48 47 fibril_mutex_t guard; -
uspace/drv/uhci-hcd/uhci.c
rdf44fa2 rd09f3720 161 161 /** Initialize hc and rh DDF structures and their respective drivers. 162 162 * 163 * @param[in] instance UHCI structure to use.164 163 * @param[in] device DDF instance of the device to use. 165 164 * … … 167 166 * - gets device's hw resources 168 167 * - disables UHCI legacy support (PCI config space) 169 * - a sks for interrupt168 * - attempts to enable interrupts 170 169 * - registers interrupt handler 171 170 */ -
uspace/drv/uhci-hcd/utils/malloc32.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbuhci 29 29 * @{ 30 30 */ … … 32 32 * @brief UHCI driver 33 33 */ 34 #ifndef DRV_UHCI_ TRANSLATOR_H35 #define DRV_UHCI_ TRANSLATOR_H34 #ifndef DRV_UHCI_UTILS_MALLOC32_H 35 #define DRV_UHCI_UTILS_MALLOC32_H 36 36 37 37 #include <assert.h> … … 74 74 if (size <= SLAB_ELEMENT_SIZE) 75 75 return slab_malloc_g(); 76 assert(false); 76 usb_log_warning("Requested %zu bytes, current allocator can't handle " 77 "that amount, pray that the standard malloc will suffice.", size); 77 78 return memalign(UHCI_STRCUTURES_ALIGNMENT, size); 78 79 } -
uspace/drv/uhci-hcd/utils/slab.c
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbuhcihc 29 29 * @{ 30 30 */ -
uspace/drv/uhci-hcd/utils/slab.h
rdf44fa2 rd09f3720 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbuhcihc 29 29 * @{ 30 30 */ … … 32 32 * @brief UHCI driver 33 33 */ 34 #ifndef DRV_UHCI_ SLAB_H35 #define DRV_UHCI_ SLAB_H34 #ifndef DRV_UHCI_UTILS_SLAB_H 35 #define DRV_UHCI_UTILS_SLAB_H 36 36 37 37 #include <bool.h> -
uspace/drv/uhci-rhd/port.c
rdf44fa2 rd09f3720 36 36 #include <errno.h> 37 37 #include <str_error.h> 38 #include <time.h> 39 #include <async.h> 38 40 39 41 #include <usb/usb.h> /* usb_address_t */ 40 #include <usb/ hub.h> /* usb_hc_new_device_wrapper */42 #include <usb/dev/hub.h> /* usb_hc_new_device_wrapper */ 41 43 #include <usb/debug.h> 42 44 … … 65 67 * 66 68 * @param[in] port Structure to use. 67 * @param[in] val ueNew register value.69 * @param[in] val New register value. 68 70 * @return Error code. (Always EOK) 69 71 */ … … 77 79 * 78 80 * @param[in] port Memory structure to use. 79 * @param[in] addr Address of I/O register.81 * @param[in] address Address of I/O register. 80 82 * @param[in] number Port number. 81 83 * @param[in] usec Polling interval. … … 224 226 uhci_port_write_status(port, port_status); 225 227 while (uhci_port_read_status(port) & STATUS_IN_RESET); 226 // TODO: find a better way to waste time (it should be less than 227 // 10ms, if we reschedule it takes too much time (random 228 // interrupts can be solved by multiple attempts). 229 usb_log_debug2("%s: Reset Signal stop.\n", port->id_string); 230 } 228 } 229 /* PIO delay, should not be longer than 3ms as the device might 230 * enter suspend state. */ 231 udelay(10); 231 232 /* Enable the port. */ 232 233 uhci_port_set_enabled(port, true); 233 234 /* Reset recovery period,235 * devices do not have to respond during this period236 */237 async_usleep(10000);238 234 return EOK; 239 235 } -
uspace/drv/uhci-rhd/port.h
rdf44fa2 rd09f3720 38 38 #include <fibril.h> 39 39 #include <ddf/driver.h> 40 #include <usb/ usbdevice.h> /* usb_hc_connection_t */40 #include <usb/dev/hc.h> /* usb_hc_connection_t */ 41 41 42 42 typedef uint16_t port_status_t; -
uspace/drv/usbflbk/main.c
rdf44fa2 rd09f3720 34 34 * Main routines of USB fallback driver. 35 35 */ 36 #include <usb/dev drv.h>36 #include <usb/dev/driver.h> 37 37 #include <usb/debug.h> 38 38 #include <errno.h> -
uspace/drv/usbhid/generic/hiddev.h
rdf44fa2 rd09f3720 37 37 #define USB_HID_HIDDDEV_H_ 38 38 39 #include <usb/dev drv.h>39 #include <usb/dev/driver.h> 40 40 41 41 struct usb_hid_dev; -
uspace/drv/usbhid/kbd/kbddev.c
rdf44fa2 rd09f3720 46 46 47 47 #include <usb/usb.h> 48 #include <usb/d p.h>49 #include <usb/ request.h>50 #include <usb/ classes/hid.h>51 #include <usb/ pipes.h>48 #include <usb/dev/dp.h> 49 #include <usb/dev/request.h> 50 #include <usb/hid/hid.h> 51 #include <usb/dev/pipes.h> 52 52 #include <usb/debug.h> 53 #include <usb/ classes/hidparser.h>53 #include <usb/hid/hidparser.h> 54 54 #include <usb/classes/classes.h> 55 #include <usb/ classes/hidut.h>56 #include <usb/ classes/hidreq.h>57 #include <usb/ classes/hidreport.h>58 #include <usb/ classes/hid/utled.h>59 60 #include <usb/dev drv.h>55 #include <usb/hid/usages/core.h> 56 #include <usb/hid/request.h> 57 #include <usb/hid/hidreport.h> 58 #include <usb/hid/usages/led.h> 59 60 #include <usb/dev/driver.h> 61 61 62 62 #include "kbddev.h" -
uspace/drv/usbhid/kbd/kbddev.h
rdf44fa2 rd09f3720 41 41 #include <fibril_synch.h> 42 42 43 #include <usb/ classes/hid.h>44 #include <usb/ classes/hidparser.h>43 #include <usb/hid/hid.h> 44 #include <usb/hid/hidparser.h> 45 45 #include <ddf/driver.h> 46 #include <usb/ pipes.h>47 #include <usb/dev drv.h>46 #include <usb/dev/pipes.h> 47 #include <usb/dev/driver.h> 48 48 49 49 #include "kbdrepeat.h" -
uspace/drv/usbhid/kbd/main.c
rdf44fa2 rd09f3720 41 41 #include <str_error.h> 42 42 43 #include <usb/dev drv.h>43 #include <usb/dev/driver.h> 44 44 45 45 #include "kbddev.h" -
uspace/drv/usbhid/main.c
rdf44fa2 rd09f3720 41 41 #include <str_error.h> 42 42 43 #include <usb/dev drv.h>44 #include <usb/dev poll.h>43 #include <usb/dev/driver.h> 44 #include <usb/dev/poll.h> 45 45 46 46 #include "usbhid.h" … … 202 202 printf(NAME ": HelenOS USB HID driver.\n"); 203 203 204 usb_log_enable(USB_LOG_LEVEL_DE BUG, NAME);204 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 205 205 206 206 return usb_driver_main(&usb_hid_driver); -
uspace/drv/usbhid/mouse/mousedev.c
rdf44fa2 rd09f3720 37 37 #include <usb/debug.h> 38 38 #include <usb/classes/classes.h> 39 #include <usb/ classes/hid.h>40 #include <usb/ classes/hidreq.h>41 #include <usb/ classes/hidut.h>39 #include <usb/hid/hid.h> 40 #include <usb/hid/request.h> 41 #include <usb/hid/usages/core.h> 42 42 #include <errno.h> 43 43 #include <str_error.h> -
uspace/drv/usbhid/mouse/mousedev.h
rdf44fa2 rd09f3720 37 37 #define USB_HID_MOUSEDEV_H_ 38 38 39 #include <usb/dev drv.h>39 #include <usb/dev/driver.h> 40 40 41 41 struct usb_hid_dev; -
uspace/drv/usbhid/multimedia/multimedia.c
rdf44fa2 rd09f3720 40 40 #include "keymap.h" 41 41 42 #include <usb/ classes/hidparser.h>42 #include <usb/hid/hidparser.h> 43 43 #include <usb/debug.h> 44 #include <usb/ classes/hidut.h>44 #include <usb/hid/usages/core.h> 45 45 46 46 #include <errno.h> -
uspace/drv/usbhid/multimedia/multimedia.h
rdf44fa2 rd09f3720 37 37 #define USB_HID_MULTIMEDIA_H_ 38 38 39 #include <usb/dev drv.h>39 #include <usb/dev/driver.h> 40 40 41 41 struct usb_hid_dev; -
uspace/drv/usbhid/subdrivers.c
rdf44fa2 rd09f3720 35 35 36 36 #include "subdrivers.h" 37 #include "usb/classes/hidut.h"38 #include "usb/classes/hidpath.h"37 #include <usb/hid/usages/core.h> 38 #include <usb/hid/hidpath.h> 39 39 40 40 #include "multimedia/multimedia.h" -
uspace/drv/usbhid/usbhid.c
rdf44fa2 rd09f3720 37 37 #include <usb/debug.h> 38 38 #include <usb/classes/classes.h> 39 #include <usb/ classes/hid.h>40 #include <usb/ classes/hidparser.h>41 #include <usb/ classes/hidreport.h>42 #include <usb/ classes/hidreq.h>39 #include <usb/hid/hid.h> 40 #include <usb/hid/hidparser.h> 41 #include <usb/hid/hidreport.h> 42 #include <usb/hid/request.h> 43 43 #include <errno.h> 44 44 #include <str_error.h> -
uspace/drv/usbhid/usbhid.h
rdf44fa2 rd09f3720 39 39 #include <stdint.h> 40 40 41 #include <usb/ classes/hidparser.h>41 #include <usb/hid/hidparser.h> 42 42 #include <ddf/driver.h> 43 #include <usb/ pipes.h>44 #include <usb/dev drv.h>45 #include <usb/ classes/hid.h>43 #include <usb/dev/pipes.h> 44 #include <usb/dev/driver.h> 45 #include <usb/hid/hid.h> 46 46 #include <bool.h> 47 47 -
uspace/drv/usbhub/main.c
rdf44fa2 rd09f3720 36 36 #include <stdio.h> 37 37 38 #include <usb/dev drv.h>38 #include <usb/dev/driver.h> 39 39 #include <usb/classes/classes.h> 40 40 -
uspace/drv/usbhub/port_status.h
rdf44fa2 rd09f3720 35 35 #include <bool.h> 36 36 #include <sys/types.h> 37 #include <usb/ request.h>37 #include <usb/dev/request.h> 38 38 #include "usbhub_private.h" 39 39 -
uspace/drv/usbhub/ports.h
rdf44fa2 rd09f3720 36 36 #define DRV_USBHUB_PORTS_H 37 37 38 #include <usb/dev drv.h>39 #include <usb/ hub.h>38 #include <usb/dev/driver.h> 39 #include <usb/dev/hub.h> 40 40 41 41 typedef struct usb_hub_info_t usb_hub_info_t; -
uspace/drv/usbhub/usbhub.c
rdf44fa2 rd09f3720 42 42 #include <usb/ddfiface.h> 43 43 #include <usb/descriptor.h> 44 #include <usb/ recognise.h>45 #include <usb/ request.h>44 #include <usb/dev/recognise.h> 45 #include <usb/dev/request.h> 46 46 #include <usb/classes/hub.h> 47 #include <usb/dev poll.h>47 #include <usb/dev/poll.h> 48 48 #include <stdio.h> 49 49 … … 51 51 #include "usbhub_private.h" 52 52 #include "port_status.h" 53 #include "usb/usb.h"54 #include "usb/pipes.h"55 #include "usb/classes/classes.h"53 #include <usb/usb.h> 54 #include <usb/dev/pipes.h> 55 #include <usb/classes/classes.h> 56 56 57 57 … … 71 71 72 72 static void usb_hub_process_global_interrupt(usb_hub_info_t * hub_info); 73 74 static void usb_hub_polling_terminted_callback(usb_device_t * device, 75 bool was_error, void * data); 73 76 74 77 … … 351 354 rc = usb_device_auto_poll(hub_info->usb_device, 0, 352 355 hub_port_changes_callback, ((hub_info->port_count + 1) / 8) + 1, 353 NULL, hub_info);356 usb_hub_polling_terminted_callback, hub_info); 354 357 if (rc != EOK) { 355 358 usb_log_error("Failed to create polling fibril: %s.\n", … … 489 492 490 493 /** 494 * callback called from hub polling fibril when the fibril terminates 495 * 496 * Should perform a cleanup - deletes hub_info. 497 * @param device usb device afected 498 * @param was_error indicates that the fibril is stoped due to an error 499 * @param data pointer to usb_hub_info_t structure 500 */ 501 static void usb_hub_polling_terminted_callback(usb_device_t * device, 502 bool was_error, void * data){ 503 usb_hub_info_t * hub_info = data; 504 if(!hub_info) return; 505 free(hub_info->ports); 506 free(hub_info); 507 } 508 509 510 511 512 /** 491 513 * @} 492 514 */ -
uspace/drv/usbhub/usbhub.h
rdf44fa2 rd09f3720 39 39 #include <ddf/driver.h> 40 40 41 #include <usb/ hub.h>41 #include <usb/dev/hub.h> 42 42 #include <usb/classes/hub.h> 43 43 44 #include <usb/ pipes.h>45 #include <usb/dev drv.h>44 #include <usb/dev/pipes.h> 45 #include <usb/dev/driver.h> 46 46 47 47 #include <fibril_synch.h> -
uspace/drv/usbhub/usbhub_private.h
rdf44fa2 rd09f3720 47 47 #include <usb/usb.h> 48 48 #include <usb/debug.h> 49 #include <usb/ request.h>49 #include <usb/dev/request.h> 50 50 51 51 //************ -
uspace/drv/usbmast/inquiry.c
rdf44fa2 rd09f3720 34 34 * Main routines of USB mass storage driver. 35 35 */ 36 #include <usb/dev drv.h>36 #include <usb/dev/driver.h> 37 37 #include <usb/debug.h> 38 38 #include <usb/classes/classes.h> -
uspace/drv/usbmast/main.c
rdf44fa2 rd09f3720 34 34 * Main routines of USB mass storage driver. 35 35 */ 36 #include <usb/dev drv.h>36 #include <usb/dev/driver.h> 37 37 #include <usb/debug.h> 38 38 #include <usb/classes/classes.h> -
uspace/drv/usbmast/mast.c
rdf44fa2 rd09f3720 40 40 #include <str_error.h> 41 41 #include <usb/debug.h> 42 #include <usb/ request.h>42 #include <usb/dev/request.h> 43 43 44 44 bool usb_mast_verbose = true; -
uspace/drv/usbmast/mast.h
rdf44fa2 rd09f3720 39 39 #include <sys/types.h> 40 40 #include <usb/usb.h> 41 #include <usb/ pipes.h>42 #include <usb/dev drv.h>41 #include <usb/dev/pipes.h> 42 #include <usb/dev/driver.h> 43 43 44 44 /** Result of SCSI INQUIRY command. -
uspace/drv/usbmid/dump.c
rdf44fa2 rd09f3720 37 37 #include <str_error.h> 38 38 #include <stdlib.h> 39 #include <usb/ pipes.h>40 #include <usb/d p.h>39 #include <usb/dev/pipes.h> 40 #include <usb/dev/dp.h> 41 41 #include <usb/classes/classes.h> 42 42 #include "usbmid.h" -
uspace/drv/usbmid/explore.c
rdf44fa2 rd09f3720 38 38 #include <stdlib.h> 39 39 #include <usb/classes/classes.h> 40 #include <usb/ request.h>41 #include <usb/d p.h>40 #include <usb/dev/request.h> 41 #include <usb/dev/dp.h> 42 42 #include <usb/ddfiface.h> 43 43 #include "usbmid.h" -
uspace/drv/usbmid/main.c
rdf44fa2 rd09f3720 38 38 #include <usb/debug.h> 39 39 #include <usb/classes/classes.h> 40 #include <usb/ request.h>40 #include <usb/dev/request.h> 41 41 #include <usb/descriptor.h> 42 #include <usb/ pipes.h>42 #include <usb/dev/pipes.h> 43 43 44 44 #include "usbmid.h" -
uspace/drv/usbmid/usbmid.c
rdf44fa2 rd09f3720 39 39 #include <usb_iface.h> 40 40 #include <usb/ddfiface.h> 41 #include <usb/ pipes.h>41 #include <usb/dev/pipes.h> 42 42 #include <usb/classes/classes.h> 43 #include <usb/ recognise.h>43 #include <usb/dev/recognise.h> 44 44 #include "usbmid.h" 45 45 -
uspace/drv/usbmid/usbmid.h
rdf44fa2 rd09f3720 40 40 #include <ddf/driver.h> 41 41 #include <usb/usb.h> 42 #include <usb/ pipes.h>42 #include <usb/dev/pipes.h> 43 43 #include <usb/debug.h> 44 #include <usb/dev drv.h>44 #include <usb/dev/driver.h> 45 45 46 46 #define NAME "usbmid" -
uspace/drv/usbmouse/init.c
rdf44fa2 rd09f3720 37 37 #include <usb/debug.h> 38 38 #include <usb/classes/classes.h> 39 #include <usb/ classes/hid.h>40 #include <usb/ request.h>39 #include <usb/hid/hid.h> 40 #include <usb/dev/request.h> 41 41 #include <errno.h> 42 42 -
uspace/drv/usbmouse/main.c
rdf44fa2 rd09f3720 36 36 #include "mouse.h" 37 37 #include <usb/debug.h> 38 #include <usb/dev poll.h>38 #include <usb/dev/poll.h> 39 39 #include <errno.h> 40 40 #include <str_error.h> -
uspace/drv/usbmouse/mouse.h
rdf44fa2 rd09f3720 37 37 #define USBMOUSE_MOUSE_H_ 38 38 39 #include <usb/dev drv.h>40 #include <usb/ pipes.h>39 #include <usb/dev/driver.h> 40 #include <usb/dev/pipes.h> 41 41 #include <time.h> 42 42 -
uspace/drv/vhc/conndev.c
rdf44fa2 rd09f3720 37 37 #include <errno.h> 38 38 #include <ddf/driver.h> 39 #include <usbvirt/ipc.h> 39 40 #include "conn.h" 40 41 41 42 static fibril_local uintptr_t plugged_device_handle = 0; 43 #define PLUGGED_DEVICE_NAME_MAXLEN 256 44 static fibril_local char plugged_device_name[PLUGGED_DEVICE_NAME_MAXLEN + 1] = "<unknown>"; 45 46 /** Receive device name. 47 * 48 * @warning Errors are silently ignored. 49 * 50 * @param phone Phone to the virtual device. 51 */ 52 static void receive_device_name(int phone) 53 { 54 aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL); 55 if (opening_request == 0) { 56 return; 57 } 58 59 60 ipc_call_t data_request_call; 61 aid_t data_request = async_data_read(phone, 62 plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN, 63 &data_request_call); 64 65 if (data_request == 0) { 66 async_wait_for(opening_request, NULL); 67 return; 68 } 69 70 sysarg_t data_request_rc; 71 sysarg_t opening_request_rc; 72 async_wait_for(data_request, &data_request_rc); 73 async_wait_for(opening_request, &opening_request_rc); 74 75 if ((data_request_rc != EOK) || (opening_request_rc != EOK)) { 76 return; 77 } 78 79 size_t len = IPC_GET_ARG2(data_request_call); 80 plugged_device_name[len] = 0; 81 } 42 82 43 83 /** Default handler for IPC methods not handled by DDF. … … 65 105 async_answer_0(icallid, EOK); 66 106 67 usb_log_info("New virtual device `%s' (id = %" PRIxn ").\n", 68 rc == EOK ? "XXX" : "<unknown>", plugged_device_handle); 107 receive_device_name(callback); 108 109 usb_log_info("New virtual device `%s' (id: %" PRIxn ").\n", 110 plugged_device_name, plugged_device_handle); 69 111 70 112 return; … … 85 127 86 128 if (plugged_device_handle != 0) { 87 usb_log_info("Virtual device disconnected (id =%" PRIxn ").\n",88 plugged_device_ handle);129 usb_log_info("Virtual device `%s' disconnected (id: %" PRIxn ").\n", 130 plugged_device_name, plugged_device_handle); 89 131 vhc_virtdev_unplug(vhc, plugged_device_handle); 90 132 } -
uspace/drv/vhc/connhost.c
rdf44fa2 rd09f3720 36 36 #include <errno.h> 37 37 #include <usb/usb.h> 38 #include <usb/addrkeep.h>39 38 #include <usb/ddfiface.h> 40 39 #include <usb/debug.h> -
uspace/drv/vhc/hub.c
rdf44fa2 rd09f3720 40 40 #include <ddf/driver.h> 41 41 #include <devman.h> 42 #include <usb/ hub.h>43 #include <usb/ recognise.h>42 #include <usb/dev/hub.h> 43 #include <usb/dev/recognise.h> 44 44 45 45 #include "hub.h" -
uspace/drv/vhc/transfer.c
rdf44fa2 rd09f3720 4 4 #include <usbvirt/ipc.h> 5 5 #include "vhcd.h" 6 7 #define list_foreach(pos, head) \8 for (pos = (head)->next; pos != (head); \9 pos = pos->next)10 6 11 7 vhc_transfer_t *vhc_transfer_create(usb_address_t address, usb_endpoint_t ep, … … 67 63 fibril_mutex_lock(&vhc->guard); 68 64 69 link_t *pos;70 65 bool target_found = false; 71 list_foreach( pos, &vhc->devices) {66 list_foreach(vhc->devices, pos) { 72 67 vhc_virtdev_t *dev = list_get_instance(pos, vhc_virtdev_t, link); 73 68 fibril_mutex_lock(&dev->guard); … … 161 156 } 162 157 158 static vhc_transfer_t *dequeue_first_transfer(vhc_virtdev_t *dev) 159 { 160 assert(fibril_mutex_is_locked(&dev->guard)); 161 assert(!list_empty(&dev->transfer_queue)); 162 163 vhc_transfer_t *transfer = list_get_instance(dev->transfer_queue.next, 164 vhc_transfer_t, link); 165 list_remove(&transfer->link); 166 167 return transfer; 168 } 169 170 171 static void execute_transfer_callback_and_free(vhc_transfer_t *transfer, 172 size_t data_transfer_size, int outcome) 173 { 174 assert(outcome != ENAK); 175 176 usb_log_debug2("Transfer %p ended: %s.\n", 177 transfer, str_error(outcome)); 178 179 if (transfer->direction == USB_DIRECTION_IN) { 180 transfer->callback_in(transfer->ddf_fun, outcome, 181 data_transfer_size, transfer->callback_arg); 182 } else { 183 assert(transfer->direction == USB_DIRECTION_OUT); 184 transfer->callback_out(transfer->ddf_fun, outcome, 185 transfer->callback_arg); 186 } 187 188 free(transfer); 189 } 163 190 164 191 int vhc_transfer_queue_processor(void *arg) … … 174 201 } 175 202 176 vhc_transfer_t *transfer = list_get_instance(dev->transfer_queue.next, 177 vhc_transfer_t, link); 178 list_remove(&transfer->link); 203 vhc_transfer_t *transfer = dequeue_first_transfer(dev); 179 204 fibril_mutex_unlock(&dev->guard); 180 205 … … 214 239 215 240 if (rc != ENAK) { 216 usb_log_debug2("Transfer %p ended: %s.\n", 217 transfer, str_error(rc)); 218 if (transfer->direction == USB_DIRECTION_IN) { 219 transfer->callback_in(transfer->ddf_fun, rc, 220 data_transfer_size, transfer->callback_arg); 221 } else { 222 assert(transfer->direction == USB_DIRECTION_OUT); 223 transfer->callback_out(transfer->ddf_fun, rc, 224 transfer->callback_arg); 225 } 226 free(transfer); 241 execute_transfer_callback_and_free(transfer, 242 data_transfer_size, rc); 227 243 } 228 244 … … 231 247 } 232 248 249 /* Immediately fail all remaining transfers. */ 250 while (!list_empty(&dev->transfer_queue)) { 251 vhc_transfer_t *transfer = dequeue_first_transfer(dev); 252 execute_transfer_callback_and_free(transfer, 0, EBADCHECKSUM); 253 } 254 233 255 fibril_mutex_unlock(&dev->guard); 234 256 235 // TODO - destroy pending transfers236 237 257 return EOK; 238 258 }
Note:
See TracChangeset
for help on using the changeset viewer.
