Changes in / [dcaf819:9a7e5b4] in mainline
- Location:
- uspace
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/hc.h
rdcaf819 r9a7e5b4 48 48 #include "ohci_regs.h" 49 49 #include "root_hub.h" 50 #include "hw_struct/hcca.h" 50 51 51 52 typedef struct hc { -
uspace/drv/ohci/hw_struct/endpoint_descriptor.h
rdcaf819 r9a7e5b4 32 32 * @brief OHCI driver 33 33 */ 34 #ifndef DRV_OHCI_ ENDPOINT_DESCRIPTOR_H35 #define DRV_OHCI_ ENDPOINT_DESCRIPTOR_H34 #ifndef DRV_OHCI_HW_STRUCT_ENDPOINT_DESCRIPTOR_H 35 #define DRV_OHCI_HW_STRUCT_ENDPOINT_DESCRIPTOR_H 36 36 37 37 #include <stdint.h> 38 39 #include "completion_codes.h" 38 40 39 41 typedef struct ed { -
uspace/drv/ohci/hw_struct/iso_transfer_descriptor.h
rdcaf819 r9a7e5b4 32 32 * @brief OHCI driver 33 33 */ 34 #ifndef DRV_OHCI_ ISO_TRANSFER_DESCRIPTOR_H35 #define DRV_OHCI_ ISO_TRANSFER_DESCRIPTOR_H34 #ifndef DRV_OHCI_HW_STRUCT_ISO_TRANSFER_DESCRIPTOR_H 35 #define DRV_OHCI_HW_STRUCT_ISO_TRANSFER_DESCRIPTOR_H 36 36 37 37 #include <stdint.h> 38 39 #include "completion_codes.h" 38 40 39 41 typedef struct itd { -
uspace/drv/ohci/hw_struct/transfer_descriptor.h
rdcaf819 r9a7e5b4 32 32 * @brief OHCI driver 33 33 */ 34 #ifndef DRV_OHCI_ TRANSFER_DESCRIPTOR_H35 #define DRV_OHCI_ TRANSFER_DESCRIPTOR_H34 #ifndef DRV_OHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H 35 #define DRV_OHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H 36 36 37 37 #include <stdint.h> 38 39 #include "completion_codes.h" 38 40 39 41 typedef struct td { … … 66 68 * @} 67 69 */ 68 -
uspace/drv/ohci/iface.c
rdcaf819 r9a7e5b4 163 163 usb_str_speed(speed), direction, size, max_packet_size, interval); 164 164 // TODO use real endpoint here! 165 return usb_endpoint_manager_register_ep(&hc->ep_manager, 166 address, endpoint, direction, NULL, 0); 165 return usb_endpoint_manager_register_ep(&hc->ep_manager,NULL, 0); 167 166 } 168 167 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-hcd/iface.c
rdcaf819 r9a7e5b4 168 168 if (ep == NULL) 169 169 return ENOMEM; 170 ret = endpoint_init(ep, transfer_type, speed, max_packet_size); 170 ret = endpoint_init(ep, address, endpoint, direction, 171 transfer_type, speed, max_packet_size); 171 172 if (ret != EOK) { 172 173 free(ep); … … 178 179 usb_str_speed(speed), direction, size, max_packet_size, interval); 179 180 180 ret = usb_endpoint_manager_register_ep(&hc->ep_manager, 181 address, endpoint, direction, ep, size); 181 ret = usb_endpoint_manager_register_ep(&hc->ep_manager, ep, size); 182 182 if (ret != EOK) { 183 183 endpoint_destroy(ep); -
uspace/lib/usb/include/usb/host/endpoint.h
rdcaf819 r9a7e5b4 42 42 43 43 typedef struct endpoint { 44 link_t same_device_eps; 44 usb_address_t address; 45 usb_endpoint_t endpoint; 46 usb_direction_t direction; 45 47 usb_transfer_type_t transfer_type; 46 48 usb_speed_t speed; … … 48 50 bool active; 49 51 unsigned toggle:1; 52 link_t same_device_eps; 50 53 } endpoint_t; 51 54 52 int endpoint_init(endpoint_t *instance, usb_transfer_type_t transfer_type, 53 usb_speed_t speed, size_t max_packet_size); 55 int endpoint_init(endpoint_t *instance, usb_address_t address, 56 usb_endpoint_t endpoint, usb_direction_t direction, 57 usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size); 54 58 55 59 void endpoint_destroy(endpoint_t *instance); … … 61 65 void endpoint_toggle_reset(link_t *ep); 62 66 67 void endpoint_toggle_reset_filtered(link_t *ep, usb_endpoint_t epn); 63 68 64 69 #endif -
uspace/lib/usb/include/usb/host/usb_endpoint_manager.h
rdcaf819 r9a7e5b4 64 64 65 65 int usb_endpoint_manager_register_ep(usb_endpoint_manager_t *instance, 66 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,67 66 endpoint_t *ep, size_t data_size); 68 67 -
uspace/lib/usb/src/host/device_keeper.c
rdcaf819 r9a7e5b4 128 128 /* recipient is endpoint, value is zero (ENDPOINT_STALL) */ 129 129 if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) { 130 while (current != 131 &instance->devices[target.address].endpoints) 132 { 130 133 /* endpoint number is < 16, thus first byte is enough */ 131 assert(!"NOT IMPLEMENTED!"); 134 endpoint_toggle_reset_filtered( 135 current, data[4]); 136 current = current->next; 137 } 132 138 } 133 139 break; -
uspace/lib/usb/src/host/endpoint.c
rdcaf819 r9a7e5b4 37 37 #include <usb/host/endpoint.h> 38 38 39 int endpoint_init(endpoint_t *instance, usb_transfer_type_t transfer_type, 40 usb_speed_t speed, size_t max_packet_size) 39 int endpoint_init(endpoint_t *instance, usb_address_t address, 40 usb_endpoint_t endpoint, usb_direction_t direction, 41 usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size) 41 42 { 42 43 assert(instance); 43 link_initialize(&instance->same_device_eps); 44 instance->transfer_type = transfer_type; 44 instance->address = address; 45 instance->endpoint = endpoint; 46 instance->direction = direction; 47 instance->transfer_type = type; 45 48 instance->speed = speed; 46 49 instance->max_packet_size = max_packet_size; 47 50 instance->toggle = 0; 51 link_initialize(&instance->same_device_eps); 48 52 return EOK; 49 53 } … … 76 80 instance->toggle = 0; 77 81 } 82 /*----------------------------------------------------------------------------*/ 83 void endpoint_toggle_reset_filtered(link_t *ep, usb_endpoint_t epn) 84 { 85 endpoint_t *instance = 86 list_get_instance(ep, endpoint_t, same_device_eps); 87 assert(instance); 88 if (instance->endpoint == epn) 89 instance->toggle = 0; 90 } 78 91 /** 79 92 * @} -
uspace/lib/usb/src/host/usb_endpoint_manager.c
rdcaf819 r9a7e5b4 35 35 #define BUCKET_COUNT 7 36 36 37 typedef struct { 38 usb_address_t address; 39 usb_endpoint_t endpoint; 40 usb_direction_t direction; 41 } __attribute__((aligned (sizeof(unsigned long)))) id_t; 42 #define MAX_KEYS (sizeof(id_t) / sizeof(unsigned long)) 37 #define MAX_KEYS (3) 43 38 typedef struct { 44 union {45 id_t id;46 unsigned long key[MAX_KEYS];47 };48 39 link_t link; 49 40 size_t bw; … … 66 57 assert(item); 67 58 node_t *node = hash_table_get_instance(item, node_t, link); 68 hash_count_t i = 0; 69 for (; i < keys; ++i) { 70 if (key[i] != node->key[i]) 71 return false; 72 } 73 return true; 59 assert(node); 60 assert(node->ep); 61 bool match = true; 62 switch (keys) { 63 case 3: 64 match = match && (key[2] == node->ep->direction); 65 case 2: 66 match = match && (key[1] == (unsigned long)node->ep->endpoint); 67 case 1: 68 match = match && (key[0] == (unsigned long)node->ep->address); 69 break; 70 default: 71 match = false; 72 } 73 return match; 74 74 } 75 75 /*----------------------------------------------------------------------------*/ … … 142 142 /*----------------------------------------------------------------------------*/ 143 143 int usb_endpoint_manager_register_ep(usb_endpoint_manager_t *instance, 144 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,145 144 endpoint_t *ep, size_t data_size) 146 145 { … … 150 149 assert(instance); 151 150 152 id_t id = { 153 .address = address, 154 .endpoint = endpoint, 155 .direction = direction, 156 }; 151 unsigned long key[MAX_KEYS] = 152 {ep->address, ep->endpoint, ep->direction}; 157 153 fibril_mutex_lock(&instance->guard); 158 154 159 155 link_t *item = 160 hash_table_find(&instance->ep_table, (unsigned long*)&id);156 hash_table_find(&instance->ep_table, key); 161 157 if (item != NULL) { 162 158 fibril_mutex_unlock(&instance->guard); … … 175 171 } 176 172 177 node->id = id;178 173 node->bw = bw; 179 174 node->ep = ep; 180 175 link_initialize(&node->link); 181 176 182 hash_table_insert(&instance->ep_table, 183 (unsigned long*)&id, &node->link); 177 hash_table_insert(&instance->ep_table, key, &node->link); 184 178 instance->free_bw -= bw; 185 179 fibril_mutex_unlock(&instance->guard); … … 192 186 { 193 187 assert(instance); 194 id_t id = { 195 .address = address, 196 .endpoint = endpoint, 197 .direction = direction, 198 }; 188 unsigned long key[MAX_KEYS] = {address, endpoint, direction}; 189 199 190 fibril_mutex_lock(&instance->guard); 200 link_t *item = 201 hash_table_find(&instance->ep_table, (unsigned long*)&id); 191 link_t *item = hash_table_find(&instance->ep_table, key); 202 192 if (item == NULL) { 203 193 fibril_mutex_unlock(&instance->guard); … … 207 197 node_t *node = hash_table_get_instance(item, node_t, link); 208 198 instance->free_bw += node->bw; 209 hash_table_remove(&instance->ep_table, (unsigned long*)&id, MAX_KEYS);199 hash_table_remove(&instance->ep_table, key, MAX_KEYS); 210 200 211 201 fibril_mutex_unlock(&instance->guard); … … 219 209 { 220 210 assert(instance); 221 id_t id = { 222 .address = address, 223 .endpoint = endpoint, 224 .direction = direction, 225 }; 211 unsigned long key[MAX_KEYS] = {address, endpoint, direction}; 212 226 213 fibril_mutex_lock(&instance->guard); 227 link_t *item = 228 hash_table_find(&instance->ep_table, (unsigned long*)&id); 214 link_t *item = hash_table_find(&instance->ep_table, key); 229 215 if (item == NULL) { 230 216 fibril_mutex_unlock(&instance->guard);
Note:
See TracChangeset
for help on using the changeset viewer.