Changeset b5f813c in mainline for uspace/lib
- Timestamp:
- 2015-07-04T03:28:02Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 55346870
- Parents:
- 2dbfe44
- Location:
- uspace/lib/usbhost
- Files:
-
- 4 edited
-
include/usb/host/ddf_helpers.h (modified) (1 diff)
-
include/usb/host/hcd.h (modified) (4 diffs)
-
src/ddf_helpers.c (modified) (4 diffs)
-
src/hcd.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
r2dbfe44 rb5f813c 51 51 52 52 typedef struct { 53 hc _driver_t ops;53 hcd_ops_t ops; 54 54 claim_t claim; 55 55 usb_speed_t hc_speed; -
uspace/lib/usbhost/include/usb/host/hcd.h
r2dbfe44 rb5f813c 55 55 56 56 typedef struct { 57 /** Device specific driver data. */58 void *data;59 57 /** Transfer scheduling, implement in device driver. */ 60 58 schedule_hook_t schedule; … … 67 65 /** Periodic polling hook */ 68 66 status_hook_t status_hook; 69 } hc _driver_t;67 } hcd_ops_t; 70 68 71 69 /** Generic host controller driver structure. */ … … 74 72 usb_bus_t bus; 75 73 76 /** Driver implementation */77 hc_driver_t driver;78 79 74 /** Interrupt replacement fibril */ 80 75 fid_t polling_fibril; 76 77 /** Driver implementation */ 78 hcd_ops_t ops; 79 /** Device specific driver data. */ 80 void * driver_data; 81 81 }; 82 82 … … 85 85 86 86 static inline void hcd_set_implementation(hcd_t *hcd, void *data, 87 schedule_hook_t schedule, ep_add_hook_t add_hook, ep_remove_hook_t rem_hook, 88 interrupt_hook_t irq_hook, status_hook_t status_hook) 87 const hcd_ops_t *ops) 89 88 { 90 89 assert(hcd); 91 hcd->driver.data = data; 92 hcd->driver.schedule = schedule; 93 hcd->driver.ep_add_hook = add_hook; 94 hcd->driver.ep_remove_hook = rem_hook; 95 hcd->driver.irq_hook = irq_hook; 96 hcd->driver.status_hook = status_hook; 90 if (ops) { 91 hcd->driver_data = data; 92 hcd->ops = *ops; 93 } else { 94 memset(&hcd->ops, 0, sizeof(hcd->ops)); 95 } 96 } 97 98 static inline void * hcd_get_driver_data(hcd_t *hcd) 99 { 100 assert(hcd); 101 return hcd->driver_data; 97 102 } 98 103 -
uspace/lib/usbhost/src/ddf_helpers.c
r2dbfe44 rb5f813c 690 690 } 691 691 692 //TODO: Move this to generic ddf? 692 693 int hcd_ddf_get_registers(ddf_dev_t *device, hw_res_list_parsed_t *hw_res) 693 694 { … … 779 780 assert(dev); 780 781 hcd_t *hcd = dev_to_hcd(dev); 781 if (!hcd || !hcd-> driver.irq_hook) {782 if (!hcd || !hcd->ops.irq_hook) { 782 783 usb_log_error("Interrupt on not yet initialized device.\n"); 783 784 return; 784 785 } 785 786 const uint32_t status = IPC_GET_ARG1(*call); 786 hcd-> driver.irq_hook(hcd, status);787 hcd->ops.irq_hook(hcd, status); 787 788 } 788 789 … … 791 792 hcd_t *hcd = arg; 792 793 assert(hcd); 793 if (!hcd-> driver.status_hook || !hcd->driver.irq_hook)794 if (!hcd->ops.status_hook || !hcd->ops.irq_hook) 794 795 return ENOTSUP; 795 796 uint32_t status = 0; 796 while (hcd-> driver.status_hook(hcd, &status) == EOK) {797 hcd-> driver.irq_hook(hcd, status);797 while (hcd->ops.status_hook(hcd, &status) == EOK) { 798 hcd->ops.irq_hook(hcd, status); 798 799 status = 0; 799 800 /* We should wait 1 frame - 1ms here, but this polling is a … … 885 886 886 887 /* Need working irq replacement to setup root hub */ 887 if ((irq < 0) && hcd-> driver.status_hook) {888 if ((irq < 0) && hcd->ops.status_hook) { 888 889 hcd->polling_fibril = fibril_create(interrupt_polling, hcd); 889 890 if (hcd->polling_fibril == 0) { -
uspace/lib/usbhost/src/hcd.c
r2dbfe44 rb5f813c 54 54 assert(ep); 55 55 assert(hcd); 56 if (hcd-> driver.ep_add_hook)57 return hcd-> driver.ep_add_hook(hcd, ep);56 if (hcd->ops.ep_add_hook) 57 return hcd->ops.ep_add_hook(hcd, ep); 58 58 return EOK; 59 59 } … … 68 68 assert(ep); 69 69 assert(hcd); 70 if (hcd-> driver.ep_remove_hook)71 hcd-> driver.ep_remove_hook(hcd, ep);70 if (hcd->ops.ep_remove_hook) 71 hcd->ops.ep_remove_hook(hcd, ep); 72 72 } 73 73 … … 99 99 usb_bus_init(&hcd->bus, bandwidth, bw_count, max_speed); 100 100 101 hcd->driver.data = NULL; 102 hcd->driver.schedule = NULL; 103 hcd->driver.ep_add_hook = NULL; 104 hcd->driver.ep_remove_hook = NULL; 101 hcd_set_implementation(hcd, NULL, NULL); 105 102 } 106 103 … … 127 124 assert(hcd); 128 125 usb_address_t address = 0; 129 return usb_bus_request_address( 130 &hcd->bus, &address, true, speed); 126 return usb_bus_request_address(&hcd->bus, &address, true, speed); 131 127 } 132 128 … … 209 205 return ENOSPC; 210 206 } 211 if (!hcd-> driver.schedule) {207 if (!hcd->ops.schedule) { 212 208 usb_log_error("HCD does not implement scheduler.\n"); 213 209 return ENOTSUP; … … 241 237 } 242 238 243 const int ret = hcd-> driver.schedule(hcd, batch);239 const int ret = hcd->ops.schedule(hcd, batch); 244 240 if (ret != EOK) 245 241 usb_transfer_batch_destroy(batch);
Note:
See TracChangeset
for help on using the changeset viewer.
