Changeset 32fb6bce in mainline for uspace/lib/usbhost/include/usb/host/hcd.h
- Timestamp:
- 2017-12-18T22:50:21Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7f70d1c
- Parents:
- 1ea0bbf
- git-author:
- Ondřej Hlavatý <aearsis@…> (2017-12-18 22:04:50)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2017-12-18 22:50:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/hcd.h
r1ea0bbf r32fb6bce 37 37 #define LIBUSBHOST_HOST_HCD_H 38 38 39 #include <assert.h> 40 #include <mem.h> 41 #include <stddef.h> 42 #include <stdint.h> 43 #include <usb/usb.h> 44 #include <usbhc_iface.h> 39 #include <ddf/driver.h> 40 #include <usb/request.h> 45 41 46 typedef struct h cd hcd_t;42 typedef struct hw_resource_list_parsed hw_res_list_parsed_t; 47 43 typedef struct bus bus_t; 48 44 typedef struct device device_t; 49 typedef struct usb_transfer_batch usb_transfer_batch_t;50 45 51 typedef int (*schedule_hook_t)(hcd_t *, usb_transfer_batch_t *); 52 typedef void (*interrupt_hook_t)(hcd_t *, uint32_t); 53 typedef int (*status_hook_t)(hcd_t *, uint32_t *); 46 /* Treat this header as read-only in driver code. 47 * It could be opaque, but why to complicate matters. 48 */ 49 typedef struct hc_device { 50 /* Bus instance */ 51 bus_t *bus; 54 52 55 typedef struct { 56 /** Transfer scheduling, implement in device driver. */ 57 schedule_hook_t schedule; 58 /** Hook to be called on device interrupt, passes ARG1 */ 59 interrupt_hook_t irq_hook; 60 /** Periodic polling hook */ 61 status_hook_t status_hook; 62 } hcd_ops_t; 53 /* Managed DDF device */ 54 ddf_dev_t *ddf_dev; 63 55 64 /** Generic host controller driver structure. */ 65 struct hcd { 66 /** Endpoint manager. */ 67 bus_t *bus; 56 /* Control function */ 57 ddf_fun_t *ctl_fun; 58 59 /* Result of enabling HW IRQs */ 60 int irq_cap; 68 61 69 62 /** Interrupt replacement fibril */ 70 63 fid_t polling_fibril; 71 64 72 /* * Driver implementation*/73 hcd_ops_t ops;65 /* This structure is meant to be extended by driver code. */ 66 } hc_device_t; 74 67 75 /** Device specific driver data. */ 76 void * driver_data; 77 }; 68 typedef struct hc_driver { 69 const char *name; 78 70 79 extern void hcd_init(hcd_t *); 71 /** Size of the device data to be allocated, and passed as the 72 * hc_device_t. */ 73 size_t hc_device_size; 80 74 81 static inline void hcd_set_implementation(hcd_t *hcd, void *data, 82 const hcd_ops_t *ops, bus_t *bus) 83 { 84 assert(hcd); 85 if (ops) { 86 hcd->driver_data = data; 87 hcd->ops = *ops; 88 hcd->bus = bus; 89 } else { 90 memset(&hcd->ops, 0, sizeof(hcd->ops)); 91 } 75 /** Initialize device structures. */ 76 int (*hc_add)(hc_device_t *, const hw_res_list_parsed_t *); 77 78 /** Generate IRQ code to handle interrupts. */ 79 int (*irq_code_gen)(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *); 80 81 /** Claim device from BIOS. */ 82 int (*claim)(hc_device_t *); 83 84 /** Start the host controller. */ 85 int (*start)(hc_device_t *); 86 87 /** Setup the virtual roothub. */ 88 int (*setup_root_hub)(hc_device_t *); 89 90 /** Stop the host controller (after start has been called) */ 91 int (*stop)(hc_device_t *); 92 93 /** HC was asked to be removed (after hc_add has been called) */ 94 int (*hc_remove)(hc_device_t *); 95 96 /** HC is gone. */ 97 int (*hc_gone)(hc_device_t *); 98 } hc_driver_t; 99 100 /* Drivers should call this before leaving hc_add */ 101 static inline void hc_device_setup(hc_device_t *hcd, bus_t *bus) { 102 hcd->bus = bus; 92 103 } 93 104 94 static inline void * hcd_get_driver_data(hcd_t *hcd)105 static inline hc_device_t *dev_to_hcd(ddf_dev_t *dev) 95 106 { 96 assert(hcd); 97 return hcd->driver_data; 107 return ddf_dev_data_get(dev); 98 108 } 99 109 100 extern int hcd_get_ep0_max_packet_size(uint16_t *, hcd_t *, device_t *); 110 int hc_driver_main(const hc_driver_t *); 111 112 /* TODO: These are a kind of utility functions, they should probably go 113 * somewhere else. 114 */ 115 extern int hcd_get_ep0_max_packet_size(uint16_t *, bus_t *, device_t *); 101 116 extern void hcd_setup_device_tt(device_t *); 102 103 extern int hcd_send_batch(hcd_t *, device_t *, usb_target_t,104 usb_direction_t direction, char *, size_t, uint64_t,105 usbhc_iface_transfer_callback_t, void *, const char *);106 107 extern ssize_t hcd_send_batch_sync(hcd_t *, device_t *, usb_target_t,108 usb_direction_t direction, char *, size_t, uint64_t,109 const char *);110 117 111 118 /** How many toggles need to be reset */ … … 116 123 } toggle_reset_mode_t; 117 124 125 extern toggle_reset_mode_t hcd_get_request_toggle_reset_mode( 126 const usb_device_request_setup_packet_t *request); 127 118 128 #endif 119 129
Note:
See TracChangeset
for help on using the changeset viewer.