Changeset c4ba29c7 in mainline
- Timestamp:
- 2010-11-21T22:51:16Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8f62b0f
- Parents:
- 4d31d58
- Location:
- uspace/drv/vhc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/connhost.c
r4d31d58 rc4ba29c7 41 41 #include "hc.h" 42 42 43 typedef struct { 44 usb_direction_t direction; 45 usb_hcd_transfer_callback_out_t out_callback; 46 usb_hcd_transfer_callback_in_t in_callback; 47 usb_hc_device_t *hc; 48 void *arg; 49 } transfer_info_t; 50 51 static void universal_callback(void *buffer, size_t size, 52 usb_transaction_outcome_t outcome, void *arg) 53 { 54 transfer_info_t *transfer = (transfer_info_t *) arg; 55 56 switch (transfer->direction) { 57 case USB_DIRECTION_IN: 58 transfer->in_callback(transfer->hc, 59 size, outcome, 60 transfer->arg); 61 break; 62 case USB_DIRECTION_OUT: 63 transfer->out_callback(transfer->hc, 64 outcome, 65 transfer->arg); 66 break; 67 default: 68 assert(false && "unreachable"); 69 break; 70 } 71 72 free(transfer); 73 } 74 75 static transfer_info_t *create_transfer_info(usb_hc_device_t *hc, 76 usb_direction_t direction, void *arg) 77 { 78 transfer_info_t *transfer = malloc(sizeof(transfer_info_t)); 79 80 transfer->direction = direction; 81 transfer->in_callback = NULL; 82 transfer->out_callback = NULL; 83 transfer->arg = arg; 84 transfer->hc = hc; 85 86 return transfer; 87 } 88 43 89 static int enqueue_transfer_out(usb_hc_device_t *hc, 44 90 usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint, … … 50 96 usb_str_transfer_type(endpoint->transfer_type), 51 97 size); 52 return ENOTSUP; 98 99 transfer_info_t *transfer 100 = create_transfer_info(hc, USB_DIRECTION_OUT, arg); 101 transfer->out_callback = callback; 102 103 usb_target_t target = { 104 .address = dev->address, 105 .endpoint = endpoint->endpoint 106 }; 107 108 hc_add_transaction_to_device(false, target, buffer, size, 109 universal_callback, transfer); 110 111 return EOK; 53 112 } 54 113 … … 62 121 usb_str_transfer_type(endpoint->transfer_type), 63 122 size); 64 return ENOTSUP; 123 124 transfer_info_t *transfer 125 = create_transfer_info(hc, USB_DIRECTION_OUT, arg); 126 transfer->out_callback = callback; 127 128 usb_target_t target = { 129 .address = dev->address, 130 .endpoint = endpoint->endpoint 131 }; 132 133 hc_add_transaction_to_device(true, target, buffer, size, 134 universal_callback, transfer); 135 136 return EOK; 65 137 } 66 138 … … 74 146 usb_str_transfer_type(endpoint->transfer_type), 75 147 size); 76 return ENOTSUP; 148 149 transfer_info_t *transfer 150 = create_transfer_info(hc, USB_DIRECTION_IN, arg); 151 transfer->in_callback = callback; 152 153 usb_target_t target = { 154 .address = dev->address, 155 .endpoint = endpoint->endpoint 156 }; 157 158 hc_add_transaction_from_device(target, buffer, size, 159 universal_callback, transfer); 160 161 return EOK; 77 162 } 78 163 -
uspace/drv/vhc/hc.c
r4d31d58 rc4ba29c7 131 131 132 132 process_transaction_with_outcome(transaction, outcome); 133 133 134 134 free(transaction); 135 135 } -
uspace/drv/vhc/hc.h
r4d31d58 rc4ba29c7 79 79 hc_transaction_done_callback_t callback, void * arg); 80 80 81 int hc_fillin_transaction_from_device(usb_target_t target,82 void * buffer, size_t len);83 81 84 82 #endif -
uspace/drv/vhc/hcd.c
r4d31d58 rc4ba29c7 69 69 70 70 /* 71 * Announce that we have some root hub present.71 * Initialize our hub and announce its presence. 72 72 */ 73 hub_init(); 73 74 usb_hcd_add_root_hub(dev); 74 75 … … 83 84 }; 84 85 86 /** Fibril wrapper for HC transaction manager. 87 * 88 * @param arg Not used. 89 * @return Nothing, return argument is unreachable. 90 */ 91 static int hc_manager_fibril(void *arg) 92 { 93 hc_manager(); 94 return EOK; 95 } 96 85 97 int main(int argc, char * argv[]) 86 98 { 87 99 printf("%s: virtual USB host controller driver.\n", NAME); 88 100 89 debug_level = 5; 101 debug_level = 10; 102 103 fid_t fid = fibril_create(hc_manager_fibril, NULL); 104 if (fid == 0) { 105 printf("%s: failed to start HC manager fibril\n", NAME); 106 return ENOMEM; 107 } 108 fibril_add_ready(fid); 90 109 91 110 return usb_hcd_main(&vhc_driver);
Note:
See TracChangeset
for help on using the changeset viewer.