Changeset 8dc762e0 in mainline
- Timestamp:
- 2011-04-06T21:12:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f567bcf
- Parents:
- 1e70157
- Location:
- uspace
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/Makefile
r1e70157 r8dc762e0 37 37 transfer_list.c \ 38 38 uhci.c \ 39 endpoint.c \40 39 hc.c \ 41 40 root_hub.c \ -
uspace/drv/uhci-hcd/batch.h
r1e70157 r8dc762e0 35 35 #define DRV_UHCI_BATCH_H 36 36 37 #include <adt/list.h>38 39 37 #include <usbhc_iface.h> 40 38 #include <usb/usb.h> 41 39 #include <usb/host/device_keeper.h> 40 #include <usb/host/endpoint.h> 42 41 #include <usb/host/batch.h> 43 42 -
uspace/drv/uhci-hcd/iface.c
r1e70157 r8dc762e0 36 36 37 37 #include <usb/debug.h> 38 39 #include "endpoint.h" 38 #include <usb/host/endpoint.h> 39 40 40 #include "iface.h" 41 41 #include "hc.h" … … 159 159 const usb_speed_t speed = 160 160 usb_device_keeper_get_speed(&hc->manager, address); 161 const size_t size = max_packet_size; 161 const size_t size = 162 (transfer_type == USB_TRANSFER_INTERRUPT 163 || transfer_type == USB_TRANSFER_ISOCHRONOUS) ? 164 max_packet_size : 0; 162 165 int ret; 163 166 … … 175 178 usb_str_speed(speed), direction, size, max_packet_size, interval); 176 179 177 const size_t bw =178 (transfer_type == USB_TRANSFER_INTERRUPT179 || transfer_type == USB_TRANSFER_ISOCHRONOUS) ?180 bandwidth_count_usb11(speed, transfer_type, size, max_packet_size) :181 0;182 183 180 ret = usb_endpoint_manager_register_ep(&hc->ep_manager, 184 address, endpoint, direction, ep, endpoint_destroy, bw);181 address, endpoint, direction, ep, size); 185 182 if (ret != EOK) { 186 183 endpoint_destroy(ep); … … 226 223 227 224 size_t res_bw; 228 endpoint_t *ep = usb_endpoint_manager_get_ep _data(&hc->ep_manager,225 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 229 226 target.address, target.endpoint, USB_DIRECTION_OUT, &res_bw); 230 227 if (ep == NULL) { … … 283 280 284 281 size_t res_bw; 285 endpoint_t *ep = usb_endpoint_manager_get_ep _data(&hc->ep_manager,282 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 286 283 target.address, target.endpoint, USB_DIRECTION_IN, &res_bw); 287 284 if (ep == NULL) { … … 340 337 target.address, target.endpoint, size, max_packet_size); 341 338 342 endpoint_t *ep = usb_endpoint_manager_get_ep _data(&hc->ep_manager,339 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 343 340 target.address, target.endpoint, USB_DIRECTION_OUT, NULL); 344 341 if (ep == NULL) { … … 387 384 target.address, target.endpoint, size, max_packet_size); 388 385 389 endpoint_t *ep = usb_endpoint_manager_get_ep _data(&hc->ep_manager,386 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 390 387 target.address, target.endpoint, USB_DIRECTION_IN, NULL); 391 388 if (ep == NULL) { … … 438 435 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 439 436 speed, target.address, target.endpoint, size, max_packet_size); 440 endpoint_t *ep = usb_endpoint_manager_get_ep _data(&hc->ep_manager,437 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 441 438 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL); 442 439 if (ep == NULL) { … … 489 486 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 490 487 speed, target.address, target.endpoint, size, max_packet_size); 491 endpoint_t *ep = usb_endpoint_manager_get_ep _data(&hc->ep_manager,488 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 492 489 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL); 493 490 if (ep == NULL) { -
uspace/lib/usb/Makefile
r1e70157 r8dc762e0 54 54 src/host/device_keeper.c \ 55 55 src/host/batch.c \ 56 src/host/endpoint.c \ 56 57 src/host/usb_endpoint_manager.c 57 58 -
uspace/lib/usb/include/usb/host/endpoint.h
r1e70157 r8dc762e0 27 27 */ 28 28 29 /** @addtogroup drvusbuhcihc29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief UHCI host controller driver structure33 * 34 34 */ 35 #ifndef DRV_UHCI_UHCI_ENDPOINT_H36 #define DRV_UHCI_UHCI_ENDPOINT_H35 #ifndef LIBUSB_HOST_ENDPOINT_H 36 #define LIBUSB_HOST_ENDPOINT_H 37 37 38 38 #include <assert.h> … … 40 40 #include <adt/list.h> 41 41 #include <usb/usb.h> 42 43 #include "hw_struct/queue_head.h"44 42 45 43 typedef struct endpoint { … … 50 48 bool active; 51 49 int toggle:1; 52 qh_t *qh;53 50 } endpoint_t; 54 51 … … 56 53 usb_speed_t speed, size_t max_packet_size); 57 54 58 void endpoint_destroy( void *ep);55 void endpoint_destroy(endpoint_t *instance); 59 56 60 57 void endpoint_toggle_reset(link_t *ep); -
uspace/lib/usb/include/usb/host/usb_endpoint_manager.h
r1e70157 r8dc762e0 43 43 #include <fibril_synch.h> 44 44 #include <usb/usb.h> 45 #include <usb/host/endpoint.h> 45 46 46 47 #define BANDWIDTH_TOTAL_USB11 12000000 … … 63 64 64 65 int usb_endpoint_manager_register_ep(usb_endpoint_manager_t *instance, 65 usb_address_t address, usb_endpoint_t e p, usb_direction_t direction,66 void *data, void (*data_remove_callback)(void* data), size_t bw);66 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction, 67 endpoint_t *ep, size_t data_size); 67 68 68 69 int usb_endpoint_manager_register_ep_wait(usb_endpoint_manager_t *instance, … … 74 75 usb_address_t address, usb_endpoint_t ep, usb_direction_t direction); 75 76 76 void * usb_endpoint_manager_get_ep_data(usb_endpoint_manager_t *instance,77 endpoint_t * usb_endpoint_manager_get_ep(usb_endpoint_manager_t *instance, 77 78 usb_address_t address, usb_endpoint_t ep, usb_direction_t direction, 78 79 size_t *bw); -
uspace/lib/usb/src/host/device_keeper.c
r1e70157 r8dc762e0 63 63 /*----------------------------------------------------------------------------*/ 64 64 void usb_device_keeper_add_ep( 65 usb_device_keeper_t *instance, usb_address_t address, link_t *ep); 65 usb_device_keeper_t *instance, usb_address_t address, link_t *ep) 66 { 67 assert(instance); 68 fibril_mutex_lock(&instance->guard); 69 assert(instance->devices[address].occupied); 70 list_append(ep, &instance->devices[address].endpoints); 71 fibril_mutex_unlock(&instance->guard); 72 } 66 73 /*----------------------------------------------------------------------------*/ 67 74 /** Attempt to obtain address 0, blocks. -
uspace/lib/usb/src/host/endpoint.c
r1e70157 r8dc762e0 36 36 #include <errno.h> 37 37 38 #include "endpoint.h" 39 #include "utils/malloc32.h" 38 #include <usb/host/endpoint.h> 40 39 41 40 int endpoint_init(endpoint_t *instance, usb_transfer_type_t transfer_type, … … 48 47 instance->max_packet_size = max_packet_size; 49 48 instance->toggle = 0; 50 instance->qh = malloc32(sizeof(qh_t));51 if (instance->qh == NULL)52 return ENOMEM;53 49 return EOK; 54 50 } 55 51 /*----------------------------------------------------------------------------*/ 56 void endpoint_destroy( void *ep)52 void endpoint_destroy(endpoint_t *instance) 57 53 { 58 endpoint_t *instance = ep;59 54 assert(instance); 60 55 list_remove(&instance->same_device_eps); 61 free32(instance->qh);62 56 free(instance); 63 57 } -
uspace/lib/usb/src/host/usb_endpoint_manager.c
r1e70157 r8dc762e0 48 48 link_t link; 49 49 size_t bw; 50 void *data; 51 void (*data_remove_callback)(void* data); 52 } ep_t; 53 /*----------------------------------------------------------------------------*/ 54 static hash_index_t ep_hash(unsigned long key[]) 50 endpoint_t *ep; 51 } node_t; 52 /*----------------------------------------------------------------------------*/ 53 static hash_index_t node_hash(unsigned long key[]) 55 54 { 56 55 hash_index_t hash = 0; … … 63 62 } 64 63 /*----------------------------------------------------------------------------*/ 65 static int ep_compare(unsigned long key[], hash_count_t keys, link_t *item)64 static int node_compare(unsigned long key[], hash_count_t keys, link_t *item) 66 65 { 67 66 assert(item); 68 ep_t *ep = hash_table_get_instance(item, ep_t, link);67 node_t *node = hash_table_get_instance(item, node_t, link); 69 68 hash_count_t i = 0; 70 69 for (; i < keys; ++i) { 71 if (key[i] != ep->key[i])70 if (key[i] != node->key[i]) 72 71 return false; 73 72 } … … 75 74 } 76 75 /*----------------------------------------------------------------------------*/ 77 static void ep_remove(link_t *item)76 static void node_remove(link_t *item) 78 77 { 79 78 assert(item); 80 ep_t *ep = 81 hash_table_get_instance(item, ep_t, link); 82 ep->data_remove_callback(ep->data); 83 free(ep); 79 node_t *node = hash_table_get_instance(item, node_t, link); 80 endpoint_destroy(node->ep); 81 free(node); 84 82 } 85 83 /*----------------------------------------------------------------------------*/ 86 84 static hash_table_operations_t op = { 87 .hash = ep_hash,88 .compare = ep_compare,89 .remove_callback = ep_remove,85 .hash = node_hash, 86 .compare = node_compare, 87 .remove_callback = node_remove, 90 88 }; 91 89 /*----------------------------------------------------------------------------*/ … … 145 143 int usb_endpoint_manager_register_ep(usb_endpoint_manager_t *instance, 146 144 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction, 147 void *data, void (*data_remove_callback)(void* data), size_t bw) 148 { 145 endpoint_t *ep, size_t data_size) 146 { 147 assert(ep); 148 size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type, 149 data_size, ep->max_packet_size); 149 150 assert(instance); 150 151 … … 168 169 } 169 170 170 ep_t *ep = malloc(sizeof(ep_t));171 if ( ep== NULL) {171 node_t *node = malloc(sizeof(node_t)); 172 if (node == NULL) { 172 173 fibril_mutex_unlock(&instance->guard); 173 174 return ENOMEM; 174 175 } 175 176 176 ep->id = id; 177 ep->bw = bw; 178 ep->data = data; 179 link_initialize(&ep->link); 180 181 hash_table_insert(&instance->ep_table, (unsigned long*)&id, &ep->link); 177 node->id = id; 178 node->bw = bw; 179 node->ep = ep; 180 link_initialize(&node->link); 181 182 hash_table_insert(&instance->ep_table, 183 (unsigned long*)&id, &node->link); 182 184 instance->free_bw -= bw; 183 185 fibril_mutex_unlock(&instance->guard); … … 203 205 } 204 206 205 ep_t *ep = hash_table_get_instance(item, ep_t, link);206 instance->free_bw += ep->bw;207 node_t *node = hash_table_get_instance(item, node_t, link); 208 instance->free_bw += node->bw; 207 209 hash_table_remove(&instance->ep_table, (unsigned long*)&id, MAX_KEYS); 208 210 … … 212 214 } 213 215 /*----------------------------------------------------------------------------*/ 214 void * usb_endpoint_manager_get_ep_data(usb_endpoint_manager_t *instance,216 endpoint_t * usb_endpoint_manager_get_ep(usb_endpoint_manager_t *instance, 215 217 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction, 216 218 size_t *bw) … … 229 231 return NULL; 230 232 } 231 ep_t *ep = hash_table_get_instance(item, ep_t, link);233 node_t *node = hash_table_get_instance(item, node_t, link); 232 234 if (bw) 233 *bw = ep->bw;235 *bw = node->bw; 234 236 235 237 fibril_mutex_unlock(&instance->guard); 236 return ep->data;237 } 238 return node->ep; 239 }
Note:
See TracChangeset
for help on using the changeset viewer.