Changeset 41ef5b9 in mainline for uspace/drv
- Timestamp:
- 2011-03-21T17:16:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4d0c40b
- Parents:
- fd9f6e4c (diff), 434ef65 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/drv
- Files:
-
- 4 added
- 27 edited
- 5 moved
-
ohci/Makefile (modified) (1 diff)
-
ohci/batch.c (modified) (7 diffs)
-
ohci/batch.h (modified) (2 diffs)
-
ohci/hc.c (added)
-
ohci/hc.h (moved) (moved from uspace/drv/ohci/ohci_hc.h ) (5 diffs)
-
ohci/iface.c (moved) (moved from uspace/drv/ohci/hc_iface.c ) (13 diffs)
-
ohci/iface.h (modified) (1 diff)
-
ohci/main.c (modified) (6 diffs)
-
ohci/ohci_regs.h (modified) (1 diff)
-
ohci/root_hub.c (moved) (moved from uspace/drv/ohci/ohci_rh.c ) (3 diffs)
-
ohci/root_hub.h (moved) (moved from uspace/drv/ohci/ohci_rh.h ) (2 diffs)
-
ohci/utils/malloc32.h (added)
-
uhci-hcd/Makefile (modified) (1 diff)
-
uhci-hcd/batch.c (modified) (24 diffs)
-
uhci-hcd/batch.h (modified) (2 diffs)
-
uhci-hcd/iface.c (modified) (13 diffs)
-
uhci-hcd/transfer_list.c (modified) (10 diffs)
-
uhci-hcd/transfer_list.h (modified) (1 diff)
-
uhci-hcd/uhci.c (modified) (1 diff)
-
uhci-hcd/uhci_hc.c (modified) (3 diffs)
-
uhci-hcd/uhci_hc.h (modified) (3 diffs)
-
usbflbk/Makefile (added)
-
usbflbk/main.c (moved) (moved from uspace/drv/ohci/ohci_hc.c ) (2 diffs)
-
usbflbk/usbflbk.ma (added)
-
usbhid/hiddev.c (modified) (8 diffs)
-
usbhid/hiddev.h (modified) (1 diff)
-
usbhid/hidreq.c (modified) (18 diffs)
-
usbhid/kbddev.c (modified) (2 diffs)
-
usbhub/main.c (modified) (3 diffs)
-
usbhub/usbhub.c (modified) (17 diffs)
-
usbhub/usbhub.h (modified) (3 diffs)
-
usbhub/usbhub_private.h (modified) (2 diffs)
-
usbmid/main.c (modified) (2 diffs)
-
usbmid/usbmid.c (modified) (2 diffs)
-
usbmid/usbmid.h (modified) (1 diff)
-
usbmouse/init.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/Makefile
rfd9f6e4c r41ef5b9 33 33 34 34 SOURCES = \ 35 hc_iface.c \35 iface.c \ 36 36 batch.c \ 37 37 main.c \ 38 ohci_hc.c \39 ohci_rh.c \38 hc.c \ 39 root_hub.c \ 40 40 pci.c 41 41 -
uspace/drv/ohci/batch.c
rfd9f6e4c r41ef5b9 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbohci hc28 /** @addtogroup drvusbohci 29 29 * @{ 30 30 */ … … 39 39 40 40 #include "batch.h" 41 #include "utils/malloc32.h" 41 42 42 static void batch_call_in(batch_t *instance); 43 static void batch_call_out(batch_t *instance); 44 static void batch_call_in_and_dispose(batch_t *instance); 45 static void batch_call_out_and_dispose(batch_t *instance); 43 static void batch_call_in_and_dispose(usb_transfer_batch_t *instance); 44 static void batch_call_out_and_dispose(usb_transfer_batch_t *instance); 46 45 47 /** Allocate memory and initialize internal data structure. 48 * 49 * @param[in] fun DDF function to pass to callback. 50 * @param[in] target Device and endpoint target of the transaction. 51 * @param[in] transfer_type Interrupt, Control or Bulk. 52 * @param[in] max_packet_size maximum allowed size of data packets. 53 * @param[in] speed Speed of the transaction. 54 * @param[in] buffer Data source/destination. 55 * @param[in] size Size of the buffer. 56 * @param[in] setup_buffer Setup data source (if not NULL) 57 * @param[in] setup_size Size of setup_buffer (should be always 8) 58 * @param[in] func_in function to call on inbound transaction completion 59 * @param[in] func_out function to call on outbound transaction completion 60 * @param[in] arg additional parameter to func_in or func_out 61 * @param[in] manager Pointer to toggle management structure. 62 * @return Valid pointer if all substructures were successfully created, 63 * NULL otherwise. 64 * 65 * Determines the number of needed packets (TDs). Prepares a transport buffer 66 * (that is accessible by the hardware). Initializes parameters needed for the 67 * transaction and callback. 68 */ 69 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target, 70 usb_transfer_type_t transfer_type, size_t max_packet_size, 71 usb_speed_t speed, char *buffer, size_t size, 72 char* setup_buffer, size_t setup_size, 46 #define DEFAULT_ERROR_COUNT 3 47 usb_transfer_batch_t * batch_get( 48 ddf_fun_t *fun, 49 usb_target_t target, 50 usb_transfer_type_t transfer_type, 51 size_t max_packet_size, 52 usb_speed_t speed, 53 char *buffer, 54 size_t buffer_size, 55 char *setup_buffer, 56 size_t setup_size, 73 57 usbhc_iface_transfer_in_callback_t func_in, 74 usbhc_iface_transfer_out_callback_t func_out, void *arg 75 ) 58 usbhc_iface_transfer_out_callback_t func_out, 59 void *arg, 60 usb_device_keeper_t *manager 61 ) 76 62 { 77 assert(func_in == NULL || func_out == NULL); 78 assert(func_in != NULL || func_out != NULL); 63 #define CHECK_NULL_DISPOSE_RETURN(ptr, message...) \ 64 if (ptr == NULL) { \ 65 usb_log_error(message); \ 66 if (instance) { \ 67 batch_dispose(instance); \ 68 } \ 69 return NULL; \ 70 } else (void)0 79 71 80 #define CHECK_NULL_DISPOSE_RETURN(ptr, message...) \ 81 if (ptr == NULL) { \ 82 usb_log_error(message); \ 83 if (instance) { \ 84 batch_dispose(instance); \ 85 } \ 86 return NULL; \ 87 } else (void)0 88 89 batch_t *instance = malloc(sizeof(batch_t)); 72 usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t)); 90 73 CHECK_NULL_DISPOSE_RETURN(instance, 91 74 "Failed to allocate batch instance.\n"); 92 bzero(instance, sizeof(batch_t)); 75 usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size, 76 buffer, NULL, buffer_size, NULL, setup_size, func_in, 77 func_out, arg, fun, NULL); 93 78 94 if (size > 0) { 95 /* TODO: use device accessible malloc here */ 96 instance->transport_buffer = malloc(size); 97 CHECK_NULL_DISPOSE_RETURN(instance->transport_buffer, 98 "Failed to allocate device accessible buffer.\n"); 99 } 79 if (buffer_size > 0) { 80 instance->transport_buffer = malloc32(buffer_size); 81 CHECK_NULL_DISPOSE_RETURN(instance->transport_buffer, 82 "Failed to allocate device accessible buffer.\n"); 83 } 100 84 101 if (setup_size > 0) { 102 /* TODO: use device accessible malloc here */ 103 instance->setup_buffer = malloc(setup_size); 104 CHECK_NULL_DISPOSE_RETURN(instance->setup_buffer, 105 "Failed to allocate device accessible setup buffer.\n"); 106 memcpy(instance->setup_buffer, setup_buffer, setup_size); 107 } 85 if (setup_size > 0) { 86 instance->setup_buffer = malloc32(setup_size); 87 CHECK_NULL_DISPOSE_RETURN(instance->setup_buffer, 88 "Failed to allocate device accessible setup buffer.\n"); 89 memcpy(instance->setup_buffer, setup_buffer, setup_size); 90 } 108 91 109 link_initialize(&instance->link);110 92 111 instance->max_packet_size = max_packet_size;112 instance->target = target;113 instance->transfer_type = transfer_type;114 instance->buffer = buffer;115 instance->buffer_size = size;116 instance->setup_size = setup_size;117 instance->fun = fun;118 instance->arg = arg;119 instance->speed = speed;120 instance->callback_out = func_out;121 instance->callback_in = func_in;122 123 usb_log_debug("Batch(%p) %d:%d memory structures ready.\n",124 instance, target.address, target.endpoint);125 93 return instance; 126 94 } 127 95 /*----------------------------------------------------------------------------*/ 128 /** Mark batch as finished and continue with next step. 129 * 130 * @param[in] instance Batch structure to use. 131 * 132 */ 133 void batch_finish(batch_t *instance, int error) 96 void batch_dispose(usb_transfer_batch_t *instance) 134 97 { 135 98 assert(instance); 136 instance->error = error; 137 instance->next_step(instance); 99 free32(instance->transport_buffer); 100 free32(instance->setup_buffer); 101 free(instance); 138 102 } 139 103 /*----------------------------------------------------------------------------*/ 140 /** Check batch TDs for activity. 141 * 142 * @param[in] instance Batch structure to use. 143 * @return False, if there is an active TD, true otherwise. 144 * 145 * Walk all TDs. Stop with false if there is an active one (it is to be 146 * processed). Stop with true if an error is found. Return true if the last TS 147 * is reached. 148 */ 149 bool batch_is_complete(batch_t *instance) 150 { 151 assert(instance); 152 /* TODO: implement */ 153 return true; 154 } 155 /*----------------------------------------------------------------------------*/ 156 /** Prepares control write transaction. 157 * 158 * @param[in] instance Batch structure to use. 159 * 160 * Uses genercir control function with pids OUT and IN. 161 */ 162 void batch_control_write(batch_t *instance) 104 void batch_control_write(usb_transfer_batch_t *instance) 163 105 { 164 106 assert(instance); … … 171 113 } 172 114 /*----------------------------------------------------------------------------*/ 173 /** Prepares control read transaction. 174 * 175 * @param[in] instance Batch structure to use. 176 * 177 * Uses generic control with pids IN and OUT. 178 */ 179 void batch_control_read(batch_t *instance) 115 void batch_control_read(usb_transfer_batch_t *instance) 180 116 { 181 117 assert(instance); 182 118 instance->next_step = batch_call_in_and_dispose; 183 119 /* TODO: implement */ 184 usb_log_debug("Batch(%p) CONTROL READinitialized.\n", instance);120 usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance); 185 121 } 186 122 /*----------------------------------------------------------------------------*/ 187 /** Prepare interrupt in transaction. 188 * 189 * @param[in] instance Batch structure to use. 190 * 191 * Data transaction with PID_IN. 192 */ 193 void batch_interrupt_in(batch_t *instance) 123 void batch_interrupt_in(usb_transfer_batch_t *instance) 194 124 { 195 125 assert(instance); 126 instance->direction = USB_DIRECTION_IN; 127 instance->next_step = batch_call_in_and_dispose; 196 128 /* TODO: implement */ 197 instance->next_step = batch_call_in_and_dispose;198 129 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance); 199 130 } 200 131 /*----------------------------------------------------------------------------*/ 201 /** Prepare interrupt out transaction. 202 * 203 * @param[in] instance Batch structure to use. 204 * 205 * Data transaction with PID_OUT. 206 */ 207 void batch_interrupt_out(batch_t *instance) 132 void batch_interrupt_out(usb_transfer_batch_t *instance) 208 133 { 209 134 assert(instance); 135 instance->direction = USB_DIRECTION_OUT; 210 136 /* We are data out, we are supposed to provide data */ 211 137 memcpy(instance->transport_buffer, instance->buffer, … … 216 142 } 217 143 /*----------------------------------------------------------------------------*/ 218 /** Prepare bulk in transaction. 219 * 220 * @param[in] instance Batch structure to use. 221 * 222 * Data transaction with PID_IN. 223 */ 224 void batch_bulk_in(batch_t *instance) 144 void batch_bulk_in(usb_transfer_batch_t *instance) 225 145 { 226 146 assert(instance); 147 instance->direction = USB_DIRECTION_IN; 227 148 instance->next_step = batch_call_in_and_dispose; 228 149 /* TODO: implement */ … … 230 151 } 231 152 /*----------------------------------------------------------------------------*/ 232 /** Prepare bulk out transaction. 233 * 234 * @param[in] instance Batch structure to use. 235 * 236 * Data transaction with PID_OUT. 237 */ 238 void batch_bulk_out(batch_t *instance) 153 void batch_bulk_out(usb_transfer_batch_t *instance) 239 154 { 240 155 assert(instance); 241 /* We are data out, we are supposed to provide data */ 242 memcpy(instance->transport_buffer, instance->buffer, 243 instance->buffer_size); 244 instance->next_step = batch_call_out_and_dispose; 156 instance->direction = USB_DIRECTION_IN; 157 instance->next_step = batch_call_in_and_dispose; 245 158 /* TODO: implement */ 246 usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance); 247 } 248 /*----------------------------------------------------------------------------*/ 249 /** Prepare data, get error status and call callback in. 250 * 251 * @param[in] instance Batch structure to use. 252 * Copies data from transport buffer, and calls callback with appropriate 253 * parameters. 254 */ 255 void batch_call_in(batch_t *instance) 256 { 257 assert(instance); 258 assert(instance->callback_in); 259 260 /* We are data in, we need data */ 261 memcpy(instance->buffer, instance->transport_buffer, 262 instance->buffer_size); 263 264 int err = instance->error; 265 usb_log_debug("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n", 266 instance, instance->transfer_type, str_error(err), err, 267 instance->transfered_size); 268 269 instance->callback_in( 270 instance->fun, err, instance->transfered_size, instance->arg); 271 } 272 /*----------------------------------------------------------------------------*/ 273 /** Get error status and call callback out. 274 * 275 * @param[in] instance Batch structure to use. 276 */ 277 void batch_call_out(batch_t *instance) 278 { 279 assert(instance); 280 assert(instance->callback_out); 281 282 int err = instance->error; 283 usb_log_debug("Batch(%p) callback OUT(type:%d): %s(%d).\n", 284 instance, instance->transfer_type, str_error(err), err); 285 instance->callback_out(instance->fun, 286 err, instance->arg); 159 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); 287 160 } 288 161 /*----------------------------------------------------------------------------*/ … … 291 164 * @param[in] instance Batch structure to use. 292 165 */ 293 void batch_call_in_and_dispose( batch_t *instance)166 void batch_call_in_and_dispose(usb_transfer_batch_t *instance) 294 167 { 295 168 assert(instance); 296 batch_call_in(instance);169 usb_transfer_batch_call_in(instance); 297 170 batch_dispose(instance); 298 171 } … … 302 175 * @param[in] instance Batch structure to use. 303 176 */ 304 void batch_call_out_and_dispose( batch_t *instance)177 void batch_call_out_and_dispose(usb_transfer_batch_t *instance) 305 178 { 306 179 assert(instance); 307 batch_call_out(instance);180 usb_transfer_batch_call_out(instance); 308 181 batch_dispose(instance); 309 }310 /*----------------------------------------------------------------------------*/311 /** Correctly dispose all used data structures.312 *313 * @param[in] instance Batch structure to use.314 */315 void batch_dispose(batch_t *instance)316 {317 assert(instance);318 usb_log_debug("Batch(%p) disposing.\n", instance);319 if (instance->setup_buffer)320 free(instance->setup_buffer);321 if (instance->transport_buffer)322 free(instance->transport_buffer);323 free(instance);324 182 } 325 183 /** -
uspace/drv/ohci/batch.h
rfd9f6e4c r41ef5b9 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusb uhcihc28 /** @addtogroup drvusbohci 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver USB transaction structure32 * @brief OHCI driver USB transaction structure 33 33 */ 34 #ifndef DRV_ UHCI_BATCH_H35 #define DRV_ UHCI_BATCH_H34 #ifndef DRV_OHCI_BATCH_H 35 #define DRV_OHCI_BATCH_H 36 36 37 #include <adt/list.h>38 37 39 38 #include <usbhc_iface.h> 40 39 #include <usb/usb.h> 40 #include <usb/host/device_keeper.h> 41 #include <usb/host/batch.h> 41 42 42 typedef struct batch 43 { 44 link_t link; 45 usb_speed_t speed; 46 usb_target_t target; 47 usb_transfer_type_t transfer_type; 48 usbhc_iface_transfer_in_callback_t callback_in; 49 usbhc_iface_transfer_out_callback_t callback_out; 50 void *arg; 51 char *transport_buffer; 52 char *setup_buffer; 53 size_t setup_size; 54 char *buffer; 55 size_t buffer_size; 56 size_t max_packet_size; 57 size_t packets; 58 size_t transfered_size; 59 int error; 60 ddf_fun_t *fun; 61 void (*next_step)(struct batch*); 62 } batch_t; 63 64 batch_t * batch_get( 43 usb_transfer_batch_t * batch_get( 65 44 ddf_fun_t *fun, 66 45 usb_target_t target, … … 74 53 usbhc_iface_transfer_in_callback_t func_in, 75 54 usbhc_iface_transfer_out_callback_t func_out, 76 void *arg 55 void *arg, 56 usb_device_keeper_t *manager 77 57 ); 78 58 79 void batch_dispose( batch_t *instance);59 void batch_dispose(usb_transfer_batch_t *instance); 80 60 81 void batch_ finish(batch_t *instance, int error);61 void batch_control_write(usb_transfer_batch_t *instance); 82 62 83 bool batch_is_complete(batch_t *instance);63 void batch_control_read(usb_transfer_batch_t *instance); 84 64 85 void batch_ control_write(batch_t *instance);65 void batch_interrupt_in(usb_transfer_batch_t *instance); 86 66 87 void batch_ control_read(batch_t *instance);67 void batch_interrupt_out(usb_transfer_batch_t *instance); 88 68 89 void batch_ interrupt_in(batch_t *instance);69 void batch_bulk_in(usb_transfer_batch_t *instance); 90 70 91 void batch_interrupt_out(batch_t *instance); 92 93 void batch_bulk_in(batch_t *instance); 94 95 void batch_bulk_out(batch_t *instance); 71 void batch_bulk_out(usb_transfer_batch_t *instance); 96 72 #endif 97 73 /** -
uspace/drv/ohci/hc.h
rfd9f6e4c r41ef5b9 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 /** @addtogroup drvusbohcihc 28 /** @addtogroup drvusbohci 30 29 * @{ 31 30 */ … … 33 32 * @brief OHCI host controller driver structure 34 33 */ 35 #ifndef DRV_OHCI_ OHCI_HC_H36 #define DRV_OHCI_ OHCI_HC_H34 #ifndef DRV_OHCI_HC_H 35 #define DRV_OHCI_HC_H 37 36 38 37 #include <fibril.h> … … 42 41 43 42 #include <usb/usb.h> 43 #include <usb/host/device_keeper.h> 44 44 #include <usbhc_iface.h> 45 45 46 46 #include "batch.h" 47 47 #include "ohci_regs.h" 48 #include " ohci_rh.h"48 #include "root_hub.h" 49 49 50 typedef struct ohci_hc {50 typedef struct hc { 51 51 ohci_regs_t *registers; 52 52 usb_address_t rh_address; 53 ohci_rh_t rh;53 rh_t rh; 54 54 ddf_fun_t *ddf_instance; 55 } ohci_hc_t; 55 usb_device_keeper_t manager; 56 fid_t interrupt_emulator; 57 } hc_t; 56 58 57 int ohci_hc_init(ohci_hc_t *instance, ddf_fun_t *fun,59 int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev, 58 60 uintptr_t regs, size_t reg_size, bool interrupts); 59 61 60 int ohci_hc_schedule(ohci_hc_t *instance, batch_t *batch);62 int hc_register_hub(hc_t *instance); 61 63 62 void ohci_hc_interrupt(ohci_hc_t *instance, uint16_t status); 64 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch); 65 66 void hc_interrupt(hc_t *instance, uint32_t status); 63 67 64 68 /** Safely dispose host controller internal structures … … 66 70 * @param[in] instance Host controller structure to use. 67 71 */ 68 static inline void ohci_hc_fini(ohci_hc_t *instance) { /* TODO: implement*/ };72 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ }; 69 73 70 74 /** Get and cast pointer to the driver data … … 73 77 * @return cast pointer to driver_data 74 78 */ 75 static inline ohci_hc_t * fun_to_ohci_hc(ddf_fun_t *fun)76 { return ( ohci_hc_t*)fun->driver_data; }79 static inline hc_t * fun_to_hc(ddf_fun_t *fun) 80 { return (hc_t*)fun->driver_data; } 77 81 #endif 78 82 /** -
uspace/drv/ohci/iface.c
rfd9f6e4c r41ef5b9 43 43 44 44 #include "iface.h" 45 #include "hc.h" 45 46 46 47 #define UNSUPPORTED(methodname) \ … … 59 60 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 60 61 { 61 UNSUPPORTED("reserve_default_address"); 62 63 return ENOTSUP; 64 } 65 62 assert(fun); 63 hc_t *hc = fun_to_hc(fun); 64 assert(hc); 65 usb_log_debug("Default address request with speed %d.\n", speed); 66 usb_device_keeper_reserve_default_address(&hc->manager, speed); 67 return EOK; 68 } 69 /*----------------------------------------------------------------------------*/ 66 70 /** Release default address. 67 71 * … … 71 75 static int release_default_address(ddf_fun_t *fun) 72 76 { 73 UNSUPPORTED("release_default_address"); 74 75 return ENOTSUP; 76 } 77 77 assert(fun); 78 hc_t *hc = fun_to_hc(fun); 79 assert(hc); 80 usb_log_debug("Default address release.\n"); 81 usb_device_keeper_release_default_address(&hc->manager); 82 return EOK; 83 } 84 /*----------------------------------------------------------------------------*/ 78 85 /** Found free USB address. 79 86 * … … 86 93 usb_address_t *address) 87 94 { 88 UNSUPPORTED("request_address"); 89 90 return ENOTSUP; 91 } 92 95 assert(fun); 96 hc_t *hc = fun_to_hc(fun); 97 assert(hc); 98 assert(address); 99 100 usb_log_debug("Address request with speed %d.\n", speed); 101 *address = device_keeper_get_free_address(&hc->manager, speed); 102 usb_log_debug("Address request with result: %d.\n", *address); 103 if (*address <= 0) 104 return *address; 105 return EOK; 106 } 107 /*----------------------------------------------------------------------------*/ 93 108 /** Bind USB address with device devman handle. 94 109 * … … 101 116 usb_address_t address, devman_handle_t handle) 102 117 { 103 UNSUPPORTED("bind_address"); 104 105 return ENOTSUP; 106 } 107 118 assert(fun); 119 hc_t *hc = fun_to_hc(fun); 120 assert(hc); 121 usb_log_debug("Address bind %d-%d.\n", address, handle); 122 usb_device_keeper_bind(&hc->manager, address, handle); 123 return EOK; 124 } 125 /*----------------------------------------------------------------------------*/ 108 126 /** Release previously requested address. 109 127 * … … 114 132 static int release_address(ddf_fun_t *fun, usb_address_t address) 115 133 { 116 UNSUPPORTED("release_address"); 117 118 return ENOTSUP; 134 assert(fun); 135 hc_t *hc = fun_to_hc(fun); 136 assert(hc); 137 usb_log_debug("Address release %d.\n", address); 138 usb_device_keeper_release(&hc->manager, address); 139 return EOK; 119 140 } 120 141 … … 155 176 return ENOTSUP; 156 177 } 157 178 /*----------------------------------------------------------------------------*/ 158 179 /** Schedule interrupt out transfer. 159 180 * … … 177 198 usbhc_iface_transfer_out_callback_t callback, void *arg) 178 199 { 179 UNSUPPORTED("interrupt_out"); 180 181 return ENOTSUP; 182 } 183 200 hc_t *hc = fun_to_hc(fun); 201 assert(hc); 202 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 203 204 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 205 target.address, target.endpoint, size, max_packet_size); 206 207 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 208 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 209 &hc->manager); 210 if (!batch) 211 return ENOMEM; 212 batch_interrupt_out(batch); 213 const int ret = hc_schedule(hc, batch); 214 if (ret != EOK) { 215 batch_dispose(batch); 216 return ret; 217 } 218 return EOK; 219 } 220 /*----------------------------------------------------------------------------*/ 184 221 /** Schedule interrupt in transfer. 185 222 * … … 203 240 usbhc_iface_transfer_in_callback_t callback, void *arg) 204 241 { 205 UNSUPPORTED("interrupt_in"); 206 207 return ENOTSUP; 208 } 209 242 assert(fun); 243 hc_t *hc = fun_to_hc(fun); 244 assert(hc); 245 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 246 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 247 target.address, target.endpoint, size, max_packet_size); 248 249 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 250 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 251 &hc->manager); 252 if (!batch) 253 return ENOMEM; 254 batch_interrupt_in(batch); 255 const int ret = hc_schedule(hc, batch); 256 if (ret != EOK) { 257 batch_dispose(batch); 258 return ret; 259 } 260 return EOK; 261 } 262 /*----------------------------------------------------------------------------*/ 210 263 /** Schedule bulk out transfer. 211 264 * … … 229 282 usbhc_iface_transfer_out_callback_t callback, void *arg) 230 283 { 231 UNSUPPORTED("bulk_out"); 232 233 return ENOTSUP; 234 } 235 284 assert(fun); 285 hc_t *hc = fun_to_hc(fun); 286 assert(hc); 287 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 288 289 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 290 target.address, target.endpoint, size, max_packet_size); 291 292 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 293 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 294 &hc->manager); 295 if (!batch) 296 return ENOMEM; 297 batch_bulk_out(batch); 298 const int ret = hc_schedule(hc, batch); 299 if (ret != EOK) { 300 batch_dispose(batch); 301 return ret; 302 } 303 return EOK; 304 305 } 306 /*----------------------------------------------------------------------------*/ 236 307 /** Schedule bulk in transfer. 237 308 * … … 255 326 usbhc_iface_transfer_in_callback_t callback, void *arg) 256 327 { 257 UNSUPPORTED("bulk_in"); 258 259 return ENOTSUP; 260 } 261 328 assert(fun); 329 hc_t *hc = fun_to_hc(fun); 330 assert(hc); 331 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 332 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 333 target.address, target.endpoint, size, max_packet_size); 334 335 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 336 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 337 &hc->manager); 338 if (!batch) 339 return ENOMEM; 340 batch_bulk_in(batch); 341 const int ret = hc_schedule(hc, batch); 342 if (ret != EOK) { 343 batch_dispose(batch); 344 return ret; 345 } 346 return EOK; 347 } 348 /*----------------------------------------------------------------------------*/ 262 349 /** Schedule control write transfer. 263 350 * … … 282 369 static int control_write(ddf_fun_t *fun, usb_target_t target, 283 370 size_t max_packet_size, 284 void *setup_ packet, size_t setup_packet_size,285 void *data _buffer, size_t data_buffer_size,371 void *setup_data, size_t setup_size, 372 void *data, size_t size, 286 373 usbhc_iface_transfer_out_callback_t callback, void *arg) 287 374 { 288 UNSUPPORTED("control_write"); 289 290 return ENOTSUP; 291 } 292 375 assert(fun); 376 hc_t *hc = fun_to_hc(fun); 377 assert(hc); 378 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 379 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 380 speed, target.address, target.endpoint, size, max_packet_size); 381 382 if (setup_size != 8) 383 return EINVAL; 384 385 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 386 max_packet_size, speed, data, size, setup_data, setup_size, 387 NULL, callback, arg, &hc->manager); 388 if (!batch) 389 return ENOMEM; 390 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 391 batch_control_write(batch); 392 const int ret = hc_schedule(hc, batch); 393 if (ret != EOK) { 394 batch_dispose(batch); 395 return ret; 396 } 397 return EOK; 398 } 399 /*----------------------------------------------------------------------------*/ 293 400 /** Schedule control read transfer. 294 401 * … … 313 420 static int control_read(ddf_fun_t *fun, usb_target_t target, 314 421 size_t max_packet_size, 315 void *setup_ packet, size_t setup_packet_size,316 void *data _buffer, size_t data_buffer_size,422 void *setup_data, size_t setup_size, 423 void *data, size_t size, 317 424 usbhc_iface_transfer_in_callback_t callback, void *arg) 318 425 { 319 UNSUPPORTED("control_read"); 320 321 return ENOTSUP; 322 } 323 324 /** Host controller interface implementation for EHCI. */ 325 usbhc_iface_t ohci_hc_iface = { 426 assert(fun); 427 hc_t *hc = fun_to_hc(fun); 428 assert(hc); 429 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 430 431 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 432 speed, target.address, target.endpoint, size, max_packet_size); 433 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 434 max_packet_size, speed, data, size, setup_data, setup_size, callback, 435 NULL, arg, &hc->manager); 436 if (!batch) 437 return ENOMEM; 438 batch_control_read(batch); 439 const int ret = hc_schedule(hc, batch); 440 if (ret != EOK) { 441 batch_dispose(batch); 442 return ret; 443 } 444 return EOK; 445 } 446 /*----------------------------------------------------------------------------*/ 447 /** Host controller interface implementation for OHCI. */ 448 usbhc_iface_t hc_iface = { 326 449 .reserve_default_address = reserve_default_address, 327 450 .release_default_address = release_default_address, -
uspace/drv/ohci/iface.h
rfd9f6e4c r41ef5b9 40 40 #define NAME "ohci" 41 41 42 extern usbhc_iface_t ohci_hc_iface;42 extern usbhc_iface_t hc_iface; 43 43 44 44 #endif -
uspace/drv/ohci/main.c
rfd9f6e4c r41ef5b9 45 45 #include "pci.h" 46 46 #include "iface.h" 47 #include " ohci_hc.h"47 #include "hc.h" 48 48 49 49 static int ohci_add_device(ddf_dev_t *device); 50 static int get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle) 51 { 52 assert(handle); 53 assert(fun != NULL); 54 55 *handle = fun->handle; 56 return EOK; 57 } 58 /*----------------------------------------------------------------------------*/ 59 static int get_address( 60 ddf_fun_t *fun, devman_handle_t handle, usb_address_t *address) 61 { 62 assert(fun); 63 usb_device_keeper_t *manager = &fun_to_hc(fun)->manager; 64 usb_address_t addr = usb_device_keeper_find(manager, handle); 65 if (addr < 0) { 66 return addr; 67 } 68 69 if (address != NULL) { 70 *address = addr; 71 } 72 73 return EOK; 74 } 50 75 /*----------------------------------------------------------------------------*/ 51 76 /** IRQ handling callback, identifies device … … 58 83 { 59 84 assert(dev); 60 ohci_hc_t *hc = (ohci_hc_t*)dev->driver_data;85 hc_t *hc = (hc_t*)dev->driver_data; 61 86 assert(hc); 62 ohci_hc_interrupt(hc, 0);87 hc_interrupt(hc, 0); 63 88 } 64 89 /*----------------------------------------------------------------------------*/ … … 71 96 .driver_ops = &ohci_driver_ops 72 97 }; 98 /*----------------------------------------------------------------------------*/ 99 static usb_iface_t hc_usb_iface = { 100 .get_address = get_address, 101 .get_hc_handle = get_hc_handle, 102 }; 103 /*----------------------------------------------------------------------------*/ 73 104 static ddf_dev_ops_t hc_ops = { 74 .interfaces[USB HC_DEV_IFACE] = &ohci_hc_iface,75 }; 76 105 .interfaces[USB_DEV_IFACE] = &hc_usb_iface, 106 .interfaces[USBHC_DEV_IFACE] = &hc_iface, 107 }; 77 108 /*----------------------------------------------------------------------------*/ 78 109 /** Initializes a new ddf driver instance of OHCI hcd. … … 105 136 "Failed(%d) disable legacy USB: %s.\n", ret, str_error(ret)); 106 137 107 ohci_hc_t *hcd = malloc(sizeof(ohci_hc_t));138 hc_t *hcd = malloc(sizeof(hc_t)); 108 139 if (hcd == NULL) { 109 140 usb_log_error("Failed to allocate OHCI driver.\n"); … … 129 160 } 130 161 131 ret = ohci_hc_init(hcd, hc_fun, mem_reg_base, mem_reg_size, interrupts);162 ret = hc_init(hcd, hc_fun, device, mem_reg_base, mem_reg_size, interrupts); 132 163 if (ret != EOK) { 133 164 usb_log_error("Failed to initialize OHCI driver.\n"); … … 148 179 hc_fun->driver_data = hcd; 149 180 150 /* TODO: register interrupt handler */ 181 fid_t later = fibril_create((int(*)(void*))hc_register_hub, hcd); 182 fibril_add_ready(later); 151 183 152 184 usb_log_info("Controlling new OHCI device `%s' (handle %llu).\n", -
uspace/drv/ohci/ohci_regs.h
rfd9f6e4c r41ef5b9 43 43 volatile uint32_t command_status; 44 44 volatile uint32_t interrupt_status; 45 #define IS_SO (1 << 0) 46 #define IS_WDH (1 << 1) 47 #define IS_SF (1 << 2) 48 #define IS_RD (1 << 3) 49 #define IS_UE (1 << 4) 50 #define IS_FNO (1 << 5) 51 #define IS_RHSC (1 << 6) 52 #define IS_OC (1 << 30) 45 53 volatile uint32_t interupt_enable; 46 54 #define IE_SO (1 << 0) -
uspace/drv/ohci/root_hub.c
rfd9f6e4c r41ef5b9 30 30 */ 31 31 /** @file 32 * @brief UHCI driver32 * @brief OHCI driver 33 33 */ 34 34 #include <assert.h> … … 38 38 #include <usb/debug.h> 39 39 40 #include " ohci_rh.h"40 #include "root_hub.h" 41 41 42 42 /** Root hub initialization 43 43 * @return Error code. 44 44 */ 45 int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs)45 int rh_init(rh_t *instance, ddf_dev_t *dev, ohci_regs_t *regs) 46 46 { 47 47 assert(instance); 48 instance->address = 0;48 instance->address = -1; 49 49 instance->registers = regs; 50 instance->device = dev; 50 51 51 52 usb_log_info("OHCI root hub with %d ports.\n", regs->rh_desc_a & 0xff); … … 55 56 } 56 57 /*----------------------------------------------------------------------------*/ 57 void ohci_rh_request(ohci_rh_t *instance,batch_t *request)58 int rh_request(rh_t *instance, usb_transfer_batch_t *request) 58 59 { 60 assert(instance); 61 assert(request); 59 62 /* TODO: implement */ 63 if (request->setup_buffer) { 64 usb_log_info("Root hub got SETUP packet: %s.\n", 65 usb_debug_str_buffer((const uint8_t *)request->setup_buffer, 8, 8)); 66 } 67 usb_log_error("Root hub request processing not implemented.\n"); 68 usb_transfer_batch_finish(request, ENOTSUP); 69 return EOK; 60 70 } 61 71 /*----------------------------------------------------------------------------*/ 62 void ohci_rh_interrupt(ohci_rh_t *instance)72 void rh_interrupt(rh_t *instance) 63 73 { 64 usb_log_ info("Interrupt!!.\n");74 usb_log_error("Root hub interrupt not implemented.\n"); 65 75 /* TODO: implement */ 66 76 } -
uspace/drv/ohci/root_hub.h
rfd9f6e4c r41ef5b9 33 33 * @brief OHCI driver 34 34 */ 35 #ifndef DRV_OHCI_ OHCI_RH_H36 #define DRV_OHCI_ OHCI_RH_H35 #ifndef DRV_OHCI_ROOT_HUB_H 36 #define DRV_OHCI_ROOT_HUB_H 37 37 38 38 #include <usb/usb.h> … … 41 41 #include "batch.h" 42 42 43 typedef struct ohci_rh {43 typedef struct rh { 44 44 ohci_regs_t *registers; 45 45 usb_address_t address; 46 } ohci_rh_t; 46 ddf_dev_t *device; 47 } rh_t; 47 48 48 int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs);49 int rh_init(rh_t *instance, ddf_dev_t *dev, ohci_regs_t *regs); 49 50 50 void ohci_rh_request(ohci_rh_t *instance,batch_t *request);51 int rh_request(rh_t *instance, usb_transfer_batch_t *request); 51 52 52 void ohci_rh_interrupt(ohci_rh_t *instance);53 void rh_interrupt(rh_t *instance); 53 54 #endif 54 55 /** -
uspace/drv/uhci-hcd/Makefile
rfd9f6e4c r41ef5b9 40 40 uhci_rh.c \ 41 41 uhci_struct/transfer_descriptor.c \ 42 utils/device_keeper.c \43 42 pci.c \ 44 43 batch.c -
uspace/drv/uhci-hcd/batch.c
rfd9f6e4c r41ef5b9 42 42 #include "uhci_hc.h" 43 43 #include "utils/malloc32.h" 44 #include "uhci_struct/transfer_descriptor.h" 44 45 45 46 #define DEFAULT_ERROR_COUNT 3 46 47 47 static void batch_control(batch_t *instance, 48 typedef struct uhci_batch { 49 qh_t *qh; 50 td_t *tds; 51 size_t packets; 52 usb_device_keeper_t *manager; 53 } uhci_batch_t; 54 55 static void batch_control(usb_transfer_batch_t *instance, 48 56 usb_packet_id data_stage, usb_packet_id status_stage); 49 static void batch_data(batch_t *instance, usb_packet_id pid); 50 static void batch_call_in(batch_t *instance); 51 static void batch_call_out(batch_t *instance); 52 static void batch_call_in_and_dispose(batch_t *instance); 53 static void batch_call_out_and_dispose(batch_t *instance); 57 static void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid); 58 static void batch_call_in_and_dispose(usb_transfer_batch_t *instance); 59 static void batch_call_out_and_dispose(usb_transfer_batch_t *instance); 54 60 55 61 … … 76 82 * transaction and callback. 77 83 */ 78 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,84 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, usb_target_t target, 79 85 usb_transfer_type_t transfer_type, size_t max_packet_size, 80 usb_speed_t speed, char *buffer, size_t size,86 usb_speed_t speed, char *buffer, size_t buffer_size, 81 87 char* setup_buffer, size_t setup_size, 82 88 usbhc_iface_transfer_in_callback_t func_in, 83 89 usbhc_iface_transfer_out_callback_t func_out, void *arg, 84 device_keeper_t *manager90 usb_device_keeper_t *manager 85 91 ) 86 92 { … … 97 103 } else (void)0 98 104 99 batch_t *instance = malloc(sizeof(batch_t));105 usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t)); 100 106 CHECK_NULL_DISPOSE_RETURN(instance, 101 107 "Failed to allocate batch instance.\n"); 102 bzero(instance, sizeof(batch_t)); 103 104 instance->qh = malloc32(sizeof(qh_t)); 105 CHECK_NULL_DISPOSE_RETURN(instance->qh, 108 usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size, 109 buffer, NULL, buffer_size, NULL, setup_size, func_in, 110 func_out, arg, fun, NULL); 111 112 113 uhci_batch_t *data = malloc(sizeof(uhci_batch_t)); 114 CHECK_NULL_DISPOSE_RETURN(instance, 115 "Failed to allocate batch instance.\n"); 116 bzero(data, sizeof(uhci_batch_t)); 117 data->manager = manager; 118 instance->private_data = data; 119 120 data->packets = (buffer_size + max_packet_size - 1) / max_packet_size; 121 if (transfer_type == USB_TRANSFER_CONTROL) { 122 data->packets += 2; 123 } 124 125 data->tds = malloc32(sizeof(td_t) * data->packets); 126 CHECK_NULL_DISPOSE_RETURN( 127 data->tds, "Failed to allocate transfer descriptors.\n"); 128 bzero(data->tds, sizeof(td_t) * data->packets); 129 130 data->qh = malloc32(sizeof(qh_t)); 131 CHECK_NULL_DISPOSE_RETURN(data->qh, 106 132 "Failed to allocate batch queue head.\n"); 107 qh_init(instance->qh); 108 109 instance->packets = (size + max_packet_size - 1) / max_packet_size; 110 if (transfer_type == USB_TRANSFER_CONTROL) { 111 instance->packets += 2; 112 } 113 114 instance->tds = malloc32(sizeof(td_t) * instance->packets); 115 CHECK_NULL_DISPOSE_RETURN( 116 instance->tds, "Failed to allocate transfer descriptors.\n"); 117 bzero(instance->tds, sizeof(td_t) * instance->packets); 118 119 if (size > 0) { 120 instance->transport_buffer = malloc32(size); 133 qh_init(data->qh); 134 qh_set_element_td(data->qh, addr_to_phys(data->tds)); 135 136 if (buffer_size > 0) { 137 instance->transport_buffer = malloc32(buffer_size); 121 138 CHECK_NULL_DISPOSE_RETURN(instance->transport_buffer, 122 139 "Failed to allocate device accessible buffer.\n"); … … 130 147 } 131 148 132 133 link_initialize(&instance->link);134 135 instance->max_packet_size = max_packet_size;136 instance->target = target;137 instance->transfer_type = transfer_type;138 instance->buffer = buffer;139 instance->buffer_size = size;140 instance->setup_size = setup_size;141 instance->fun = fun;142 instance->arg = arg;143 instance->speed = speed;144 instance->manager = manager;145 instance->callback_out = func_out;146 instance->callback_in = func_in;147 148 qh_set_element_td(instance->qh, addr_to_phys(instance->tds));149 150 149 usb_log_debug("Batch(%p) %d:%d memory structures ready.\n", 151 150 instance, target.address, target.endpoint); … … 153 152 } 154 153 /*----------------------------------------------------------------------------*/ 155 /** Mark batch as failed and continue with next step.156 *157 * @param[in] instance Batch structure to use.158 *159 */160 void batch_abort(batch_t *instance)161 {162 assert(instance);163 instance->error = EIO;164 instance->next_step(instance);165 }166 /*----------------------------------------------------------------------------*/167 154 /** Check batch TDs for activity. 168 155 * … … 174 161 * is reached. 175 162 */ 176 bool batch_is_complete(batch_t *instance) 177 { 178 assert(instance); 163 bool batch_is_complete(usb_transfer_batch_t *instance) 164 { 165 assert(instance); 166 uhci_batch_t *data = instance->private_data; 167 assert(data); 168 179 169 usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n", 180 instance, instance->packets);170 instance, data->packets); 181 171 instance->transfered_size = 0; 182 172 size_t i = 0; 183 for (;i < instance->packets; ++i) {184 if (td_is_active(& instance->tds[i])) {173 for (;i < data->packets; ++i) { 174 if (td_is_active(&data->tds[i])) { 185 175 return false; 186 176 } 187 177 188 instance->error = td_status(& instance->tds[i]);178 instance->error = td_status(&data->tds[i]); 189 179 if (instance->error != EOK) { 190 180 usb_log_debug("Batch(%p) found error TD(%d):%x.\n", 191 instance, i, instance->tds[i].status); 192 td_print_status(&instance->tds[i]); 193 194 device_keeper_set_toggle(instance->manager, 195 instance->target, td_toggle(&instance->tds[i])); 181 instance, i, data->tds[i].status); 182 td_print_status(&data->tds[i]); 183 184 usb_device_keeper_set_toggle(data->manager, 185 instance->target, instance->direction, 186 td_toggle(&data->tds[i])); 196 187 if (i > 0) 197 188 goto substract_ret; … … 199 190 } 200 191 201 instance->transfered_size += td_act_size(& instance->tds[i]);202 if (td_is_short(& instance->tds[i]))192 instance->transfered_size += td_act_size(&data->tds[i]); 193 if (td_is_short(&data->tds[i])) 203 194 goto substract_ret; 204 195 } … … 214 205 * Uses genercir control function with pids OUT and IN. 215 206 */ 216 void batch_control_write( batch_t *instance)207 void batch_control_write(usb_transfer_batch_t *instance) 217 208 { 218 209 assert(instance); … … 231 222 * Uses generic control with pids IN and OUT. 232 223 */ 233 void batch_control_read( batch_t *instance)224 void batch_control_read(usb_transfer_batch_t *instance) 234 225 { 235 226 assert(instance); … … 245 236 * Data transaction with PID_IN. 246 237 */ 247 void batch_interrupt_in(batch_t *instance) 248 { 249 assert(instance); 238 void batch_interrupt_in(usb_transfer_batch_t *instance) 239 { 240 assert(instance); 241 instance->direction = USB_DIRECTION_IN; 250 242 batch_data(instance, USB_PID_IN); 251 243 instance->next_step = batch_call_in_and_dispose; … … 259 251 * Data transaction with PID_OUT. 260 252 */ 261 void batch_interrupt_out(batch_t *instance) 262 { 263 assert(instance); 253 void batch_interrupt_out(usb_transfer_batch_t *instance) 254 { 255 assert(instance); 256 instance->direction = USB_DIRECTION_OUT; 264 257 /* We are data out, we are supposed to provide data */ 265 258 memcpy(instance->transport_buffer, instance->buffer, … … 276 269 * Data transaction with PID_IN. 277 270 */ 278 void batch_bulk_in( batch_t *instance)271 void batch_bulk_in(usb_transfer_batch_t *instance) 279 272 { 280 273 assert(instance); 281 274 batch_data(instance, USB_PID_IN); 275 instance->direction = USB_DIRECTION_IN; 282 276 instance->next_step = batch_call_in_and_dispose; 283 277 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); … … 290 284 * Data transaction with PID_OUT. 291 285 */ 292 void batch_bulk_out(batch_t *instance) 293 { 294 assert(instance); 286 void batch_bulk_out(usb_transfer_batch_t *instance) 287 { 288 assert(instance); 289 instance->direction = USB_DIRECTION_OUT; 295 290 /* We are data out, we are supposed to provide data */ 296 291 memcpy(instance->transport_buffer, instance->buffer, … … 309 304 * The last packet is marked with IOC flag. 310 305 */ 311 void batch_data(batch_t *instance, usb_packet_id pid) 312 { 313 assert(instance); 306 void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid) 307 { 308 assert(instance); 309 uhci_batch_t *data = instance->private_data; 310 assert(data); 311 314 312 const bool low_speed = instance->speed == USB_SPEED_LOW; 315 int toggle = 316 d evice_keeper_get_toggle(instance->manager, instance->target);313 int toggle = usb_device_keeper_get_toggle( 314 data->manager, instance->target, instance->direction); 317 315 assert(toggle == 0 || toggle == 1); 318 316 … … 320 318 size_t remain_size = instance->buffer_size; 321 319 while (remain_size > 0) { 322 char * data =320 char *trans_data = 323 321 instance->transport_buffer + instance->buffer_size 324 322 - remain_size; … … 328 326 remain_size : instance->max_packet_size; 329 327 330 td_t *next_packet = (packet + 1 < instance->packets)331 ? & instance->tds[packet + 1] : NULL;332 333 assert(packet < instance->packets);328 td_t *next_packet = (packet + 1 < data->packets) 329 ? &data->tds[packet + 1] : NULL; 330 331 assert(packet < data->packets); 334 332 assert(packet_size <= remain_size); 335 333 336 334 td_init( 337 & instance->tds[packet], DEFAULT_ERROR_COUNT, packet_size,338 toggle, false, low_speed, instance->target, pid, data,335 &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size, 336 toggle, false, low_speed, instance->target, pid, trans_data, 339 337 next_packet); 340 338 … … 344 342 ++packet; 345 343 } 346 td_set_ioc(&instance->tds[packet - 1]); 347 device_keeper_set_toggle(instance->manager, instance->target, toggle); 344 td_set_ioc(&data->tds[packet - 1]); 345 usb_device_keeper_set_toggle(data->manager, instance->target, 346 instance->direction, toggle); 348 347 } 349 348 /*----------------------------------------------------------------------------*/ … … 359 358 * The last packet is marked with IOC. 360 359 */ 361 void batch_control( batch_t *instance,360 void batch_control(usb_transfer_batch_t *instance, 362 361 usb_packet_id data_stage, usb_packet_id status_stage) 363 362 { 364 363 assert(instance); 364 uhci_batch_t *data = instance->private_data; 365 assert(data); 366 assert(data->packets >= 2); 365 367 366 368 const bool low_speed = instance->speed == USB_SPEED_LOW; 367 369 int toggle = 0; 368 370 /* setup stage */ 369 td_init(instance->tds, DEFAULT_ERROR_COUNT, 370 instance->setup_size, toggle, false, low_speed, instance->target, 371 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); 371 td_init( 372 data->tds, DEFAULT_ERROR_COUNT, instance->setup_size, toggle, false, 373 low_speed, instance->target, USB_PID_SETUP, instance->setup_buffer, 374 &data->tds[1]); 372 375 373 376 /* data stage */ … … 375 378 size_t remain_size = instance->buffer_size; 376 379 while (remain_size > 0) { 377 char * data =380 char *control_data = 378 381 instance->transport_buffer + instance->buffer_size 379 382 - remain_size; … … 386 389 387 390 td_init( 388 & instance->tds[packet], DEFAULT_ERROR_COUNT, packet_size,391 &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size, 389 392 toggle, false, low_speed, instance->target, data_stage, 390 data, &instance->tds[packet + 1]);393 control_data, &data->tds[packet + 1]); 391 394 392 395 ++packet; 393 assert(packet < instance->packets);396 assert(packet < data->packets); 394 397 assert(packet_size <= remain_size); 395 398 remain_size -= packet_size; … … 397 400 398 401 /* status stage */ 399 assert(packet == instance->packets - 1); 400 td_init(&instance->tds[packet], DEFAULT_ERROR_COUNT, 401 0, 1, false, low_speed, instance->target, status_stage, NULL, NULL); 402 403 td_set_ioc(&instance->tds[packet]); 402 assert(packet == data->packets - 1); 403 404 td_init( 405 &data->tds[packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed, 406 instance->target, status_stage, NULL, NULL); 407 td_set_ioc(&data->tds[packet]); 408 404 409 usb_log_debug2("Control last TD status: %x.\n", 405 instance->tds[packet].status); 406 } 407 /*----------------------------------------------------------------------------*/ 408 /** Prepare data, get error status and call callback in. 409 * 410 * @param[in] instance Batch structure to use. 411 * Copies data from transport buffer, and calls callback with appropriate 412 * parameters. 413 */ 414 void batch_call_in(batch_t *instance) 415 { 416 assert(instance); 417 assert(instance->callback_in); 418 419 /* We are data in, we need data */ 420 memcpy(instance->buffer, instance->transport_buffer, 421 instance->buffer_size); 422 423 int err = instance->error; 424 usb_log_debug("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n", 425 instance, instance->transfer_type, str_error(err), err, 426 instance->transfered_size); 427 428 instance->callback_in( 429 instance->fun, err, instance->transfered_size, instance->arg); 430 } 431 /*----------------------------------------------------------------------------*/ 432 /** Get error status and call callback out. 433 * 434 * @param[in] instance Batch structure to use. 435 */ 436 void batch_call_out(batch_t *instance) 437 { 438 assert(instance); 439 assert(instance->callback_out); 440 441 int err = instance->error; 442 usb_log_debug("Batch(%p) callback OUT(type:%d): %s(%d).\n", 443 instance, instance->transfer_type, str_error(err), err); 444 instance->callback_out(instance->fun, 445 err, instance->arg); 410 data->tds[packet].status); 411 } 412 /*----------------------------------------------------------------------------*/ 413 qh_t * batch_qh(usb_transfer_batch_t *instance) 414 { 415 assert(instance); 416 uhci_batch_t *data = instance->private_data; 417 assert(data); 418 return data->qh; 446 419 } 447 420 /*----------------------------------------------------------------------------*/ … … 450 423 * @param[in] instance Batch structure to use. 451 424 */ 452 void batch_call_in_and_dispose( batch_t *instance)453 { 454 assert(instance); 455 batch_call_in(instance);425 void batch_call_in_and_dispose(usb_transfer_batch_t *instance) 426 { 427 assert(instance); 428 usb_transfer_batch_call_in(instance); 456 429 batch_dispose(instance); 457 430 } … … 461 434 * @param[in] instance Batch structure to use. 462 435 */ 463 void batch_call_out_and_dispose( batch_t *instance)464 { 465 assert(instance); 466 batch_call_out(instance);436 void batch_call_out_and_dispose(usb_transfer_batch_t *instance) 437 { 438 assert(instance); 439 usb_transfer_batch_call_out(instance); 467 440 batch_dispose(instance); 468 441 } … … 472 445 * @param[in] instance Batch structure to use. 473 446 */ 474 void batch_dispose(batch_t *instance) 475 { 476 assert(instance); 447 void batch_dispose(usb_transfer_batch_t *instance) 448 { 449 assert(instance); 450 uhci_batch_t *data = instance->private_data; 451 assert(data); 477 452 usb_log_debug("Batch(%p) disposing.\n", instance); 478 453 /* free32 is NULL safe */ 479 free32( instance->tds);480 free32( instance->qh);454 free32(data->tds); 455 free32(data->qh); 481 456 free32(instance->setup_buffer); 482 457 free32(instance->transport_buffer); 458 free(data); 483 459 free(instance); 484 460 } -
uspace/drv/uhci-hcd/batch.h
rfd9f6e4c r41ef5b9 39 39 #include <usbhc_iface.h> 40 40 #include <usb/usb.h> 41 #include <usb/host/device_keeper.h> 42 #include <usb/host/batch.h> 41 43 42 #include "uhci_struct/transfer_descriptor.h"43 44 #include "uhci_struct/queue_head.h" 44 #include "utils/device_keeper.h"45 45 46 typedef struct batch 47 { 48 link_t link; 49 usb_speed_t speed; 50 usb_target_t target; 51 usb_transfer_type_t transfer_type; 52 usbhc_iface_transfer_in_callback_t callback_in; 53 usbhc_iface_transfer_out_callback_t callback_out; 54 void *arg; 55 char *transport_buffer; 56 char *setup_buffer; 57 size_t setup_size; 58 char *buffer; 59 size_t buffer_size; 60 size_t max_packet_size; 61 size_t packets; 62 size_t transfered_size; 63 int error; 64 ddf_fun_t *fun; 65 qh_t *qh; 66 td_t *tds; 67 void (*next_step)(struct batch*); 68 device_keeper_t *manager; 69 } batch_t; 70 71 batch_t * batch_get( 46 usb_transfer_batch_t * batch_get( 72 47 ddf_fun_t *fun, 73 48 usb_target_t target, … … 82 57 usbhc_iface_transfer_out_callback_t func_out, 83 58 void *arg, 84 device_keeper_t *manager59 usb_device_keeper_t *manager 85 60 ); 86 61 87 void batch_dispose( batch_t *instance);62 void batch_dispose(usb_transfer_batch_t *instance); 88 63 89 void batch_abort(batch_t *instance);64 bool batch_is_complete(usb_transfer_batch_t *instance); 90 65 91 bool batch_is_complete(batch_t *instance);66 void batch_control_write(usb_transfer_batch_t *instance); 92 67 93 void batch_control_ write(batch_t *instance);68 void batch_control_read(usb_transfer_batch_t *instance); 94 69 95 void batch_ control_read(batch_t *instance);70 void batch_interrupt_in(usb_transfer_batch_t *instance); 96 71 97 void batch_interrupt_ in(batch_t *instance);72 void batch_interrupt_out(usb_transfer_batch_t *instance); 98 73 99 void batch_ interrupt_out(batch_t *instance);74 void batch_bulk_in(usb_transfer_batch_t *instance); 100 75 101 void batch_bulk_ in(batch_t *instance);76 void batch_bulk_out(usb_transfer_batch_t *instance); 102 77 103 void batch_bulk_out(batch_t *instance);78 qh_t * batch_qh(usb_transfer_batch_t *instance); 104 79 #endif 105 80 /** -
uspace/drv/uhci-hcd/iface.c
rfd9f6e4c r41ef5b9 41 41 #include "iface.h" 42 42 #include "uhci_hc.h" 43 #include "utils/device_keeper.h"44 43 45 44 /** Reserve default address interface function … … 56 55 assert(hc); 57 56 usb_log_debug("Default address request with speed %d.\n", speed); 58 device_keeper_reserve_default(&hc->device_manager, speed);57 usb_device_keeper_reserve_default_address(&hc->device_manager, speed); 59 58 return EOK; 60 59 } … … 71 70 assert(hc); 72 71 usb_log_debug("Default address release.\n"); 73 device_keeper_release_default(&hc->device_manager);72 usb_device_keeper_release_default_address(&hc->device_manager); 74 73 return EOK; 75 74 } … … 91 90 92 91 usb_log_debug("Address request with speed %d.\n", speed); 93 *address = device_keeper_ request(&hc->device_manager, speed);92 *address = device_keeper_get_free_address(&hc->device_manager, speed); 94 93 usb_log_debug("Address request with result: %d.\n", *address); 95 94 if (*address <= 0) … … 112 111 assert(hc); 113 112 usb_log_debug("Address bind %d-%d.\n", address, handle); 114 device_keeper_bind(&hc->device_manager, address, handle);113 usb_device_keeper_bind(&hc->device_manager, address, handle); 115 114 return EOK; 116 115 } … … 128 127 assert(hc); 129 128 usb_log_debug("Address release %d.\n", address); 130 device_keeper_release(&hc->device_manager, address);129 usb_device_keeper_release(&hc->device_manager, address); 131 130 return EOK; 132 131 } … … 150 149 uhci_hc_t *hc = fun_to_uhci_hc(fun); 151 150 assert(hc); 152 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);151 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 153 152 154 153 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 155 154 target.address, target.endpoint, size, max_packet_size); 156 155 157 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,156 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 158 157 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 159 158 &hc->device_manager); … … 187 186 uhci_hc_t *hc = fun_to_uhci_hc(fun); 188 187 assert(hc); 189 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);188 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 190 189 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 191 190 target.address, target.endpoint, size, max_packet_size); 192 191 193 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,192 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 194 193 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 195 194 &hc->device_manager); … … 223 222 uhci_hc_t *hc = fun_to_uhci_hc(fun); 224 223 assert(hc); 225 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);224 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 226 225 227 226 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 228 227 target.address, target.endpoint, size, max_packet_size); 229 228 230 batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,229 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 231 230 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 232 231 &hc->device_manager); … … 260 259 uhci_hc_t *hc = fun_to_uhci_hc(fun); 261 260 assert(hc); 262 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);261 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 263 262 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 264 263 target.address, target.endpoint, size, max_packet_size); 265 264 266 batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,265 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 267 266 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 268 267 &hc->device_manager); … … 299 298 uhci_hc_t *hc = fun_to_uhci_hc(fun); 300 299 assert(hc); 301 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);300 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 302 301 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 303 302 speed, target.address, target.endpoint, size, max_packet_size); … … 306 305 return EINVAL; 307 306 308 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,307 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 309 308 max_packet_size, speed, data, size, setup_data, setup_size, 310 309 NULL, callback, arg, &hc->device_manager); 311 310 if (!batch) 312 311 return ENOMEM; 313 device_keeper_reset_if_need(&hc->device_manager, target, setup_data);312 usb_device_keeper_reset_if_need(&hc->device_manager, target, setup_data); 314 313 batch_control_write(batch); 315 314 const int ret = uhci_hc_schedule(hc, batch); … … 342 341 uhci_hc_t *hc = fun_to_uhci_hc(fun); 343 342 assert(hc); 344 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);343 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 345 344 346 345 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 347 346 speed, target.address, target.endpoint, size, max_packet_size); 348 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,347 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 349 348 max_packet_size, speed, data, size, setup_data, setup_size, callback, 350 349 NULL, arg, &hc->device_manager); -
uspace/drv/uhci-hcd/transfer_list.c
rfd9f6e4c r41ef5b9 38 38 39 39 static void transfer_list_remove_batch( 40 transfer_list_t *instance, batch_t *batch);40 transfer_list_t *instance, usb_transfer_batch_t *batch); 41 41 /*----------------------------------------------------------------------------*/ 42 42 /** Initialize transfer list structures. … … 92 92 * The batch is added to the end of the list and queue. 93 93 */ 94 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch)94 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch) 95 95 { 96 96 assert(instance); … … 98 98 usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch); 99 99 100 const uint32_t pa = addr_to_phys(batch ->qh);100 const uint32_t pa = addr_to_phys(batch_qh(batch)); 101 101 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 102 102 103 103 /* New batch will be added to the end of the current list 104 104 * so set the link accordingly */ 105 qh_set_next_qh(batch ->qh, instance->queue_head->next);105 qh_set_next_qh(batch_qh(batch), instance->queue_head->next); 106 106 107 107 fibril_mutex_lock(&instance->guard); … … 115 115 } else { 116 116 /* There is something scheduled */ 117 batch_t *last = list_get_instance(118 instance->batch_list.prev, batch_t, link);119 qh_set_next_qh( last->qh, pa);117 usb_transfer_batch_t *last = list_get_instance( 118 instance->batch_list.prev, usb_transfer_batch_t, link); 119 qh_set_next_qh(batch_qh(last), pa); 120 120 } 121 121 /* Add to the driver list */ 122 122 list_append(&batch->link, &instance->batch_list); 123 123 124 batch_t *first = list_get_instance(125 instance->batch_list.next, batch_t, link);124 usb_transfer_batch_t *first = list_get_instance( 125 instance->batch_list.next, usb_transfer_batch_t, link); 126 126 usb_log_debug("Batch(%p) added to queue %s, first is %p.\n", 127 127 batch, instance->name, first); … … 148 148 while (current != &instance->batch_list) { 149 149 link_t *next = current->next; 150 batch_t *batch = list_get_instance(current,batch_t, link);150 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); 151 151 152 152 if (batch_is_complete(batch)) { … … 162 162 link_t *item = done.next; 163 163 list_remove(item); 164 batch_t *batch = list_get_instance(item,batch_t, link);164 usb_transfer_batch_t *batch = list_get_instance(item, usb_transfer_batch_t, link); 165 165 batch->next_step(batch); 166 166 } … … 176 176 while (list_empty(&instance->batch_list)) { 177 177 link_t *current = instance->batch_list.next; 178 batch_t *batch = list_get_instance(current,batch_t, link);178 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); 179 179 transfer_list_remove_batch(instance, batch); 180 batch_abort(batch);180 usb_transfer_batch_finish(batch, EIO); 181 181 } 182 182 fibril_mutex_unlock(&instance->guard); … … 191 191 * Does not lock the transfer list, caller is responsible for that. 192 192 */ 193 void transfer_list_remove_batch(transfer_list_t *instance, batch_t *batch) 194 { 195 assert(instance); 193 void transfer_list_remove_batch(transfer_list_t *instance, usb_transfer_batch_t *batch) 194 { 195 assert(instance); 196 assert(instance->queue_head); 196 197 assert(batch); 197 assert(instance->queue_head); 198 assert(batch->qh); 198 assert(batch_qh(batch)); 199 199 usb_log_debug2( 200 200 "Queue %s: removing batch(%p).\n", instance->name, batch); … … 204 204 if (batch->link.prev == &instance->batch_list) { 205 205 /* I'm the first one here */ 206 qh_set_element_qh(instance->queue_head, batch ->qh->next);206 qh_set_element_qh(instance->queue_head, batch_qh(batch)->next); 207 207 pos = "FIRST"; 208 208 } else { 209 batch_t *prev =210 list_get_instance(batch->link.prev, batch_t, link);211 qh_set_next_qh( prev->qh, batch->qh->next);209 usb_transfer_batch_t *prev = 210 list_get_instance(batch->link.prev, usb_transfer_batch_t, link); 211 qh_set_next_qh(batch_qh(prev), batch_qh(batch)->next); 212 212 pos = "NOT FIRST"; 213 213 } … … 215 215 list_remove(&batch->link); 216 216 usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n", 217 batch, pos, instance->name, batch ->qh->next);217 batch, pos, instance->name, batch_qh(batch)->next); 218 218 } 219 219 /** -
uspace/drv/uhci-hcd/transfer_list.h
rfd9f6e4c r41ef5b9 66 66 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next); 67 67 68 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch);68 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch); 69 69 70 70 void transfer_list_remove_finished(transfer_list_t *instance); -
uspace/drv/uhci-hcd/uhci.c
rfd9f6e4c r41ef5b9 70 70 { 71 71 assert(fun); 72 device_keeper_t *manager = &((uhci_t*)fun->dev->driver_data)->hc.device_manager;73 74 usb_address_t addr = device_keeper_find(manager, handle);72 usb_device_keeper_t *manager = &((uhci_t*)fun->dev->driver_data)->hc.device_manager; 73 74 usb_address_t addr = usb_device_keeper_find(manager, handle); 75 75 if (addr < 0) { 76 76 return addr; -
uspace/drv/uhci-hcd/uhci_hc.c
rfd9f6e4c r41ef5b9 121 121 fibril_create(uhci_hc_interrupt_emulator, instance); 122 122 fibril_add_ready(instance->cleaner); 123 } else { 124 /* TODO: enable interrupts here */ 123 125 } 124 126 … … 234 236 235 237 /* Init device keeper*/ 236 device_keeper_init(&instance->device_manager);238 usb_device_keeper_init(&instance->device_manager); 237 239 usb_log_debug("Initialized device manager.\n"); 238 240 … … 316 318 * Checks for bandwidth availability and appends the batch to the proper queue. 317 319 */ 318 int uhci_hc_schedule(uhci_hc_t *instance, batch_t *batch)320 int uhci_hc_schedule(uhci_hc_t *instance, usb_transfer_batch_t *batch) 319 321 { 320 322 assert(instance); -
uspace/drv/uhci-hcd/uhci_hc.h
rfd9f6e4c r41ef5b9 42 42 43 43 #include <usbhc_iface.h> 44 #include <usb/host/device_keeper.h> 44 45 45 46 #include "batch.h" 46 47 #include "transfer_list.h" 47 #include "utils/device_keeper.h"48 48 49 49 typedef struct uhci_regs { … … 83 83 84 84 typedef struct uhci_hc { 85 device_keeper_t device_manager;85 usb_device_keeper_t device_manager; 86 86 87 87 regs_t *registers; … … 109 109 void *regs, size_t reg_size, bool interupts); 110 110 111 int uhci_hc_schedule(uhci_hc_t *instance, batch_t *batch);111 int uhci_hc_schedule(uhci_hc_t *instance, usb_transfer_batch_t *batch); 112 112 113 113 void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status); -
uspace/drv/usbflbk/main.c
rfd9f6e4c r41ef5b9 1 1 /* 2 * Copyright (c) 2011 Jan Vesely2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbohcihc 28 29 /** @addtogroup drvusbfallback 29 30 * @{ 30 31 */ 31 /** @file 32 * @brief OHCI Host controller driver routines 32 /** 33 * @file 34 * Main routines of USB fallback driver. 33 35 */ 36 #include <usb/devdrv.h> 37 #include <usb/debug.h> 34 38 #include <errno.h> 35 39 #include <str_error.h> 36 #include <adt/list.h>37 #include <libarch/ddi.h>38 40 39 #include <usb/debug.h> 40 #include <usb/usb.h> 41 #include <usb/ddfiface.h> 42 #include <usb_iface.h> 41 #define NAME "usbflbk" 43 42 44 #include "ohci_hc.h" 43 /** Callback when new device is attached and recognized by DDF. 44 * 45 * @param dev Representation of a generic DDF device. 46 * @return Error code. 47 */ 48 static int usbfallback_add_device(usb_device_t *dev) 49 { 50 int rc; 51 const char *fun_name = "ctl"; 45 52 46 int ohci_hc_init(ohci_hc_t *instance, ddf_fun_t *fun, 47 uintptr_t regs, size_t reg_size, bool interrupts) 48 { 49 assert(instance); 50 int ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers); 51 if (ret != EOK) { 52 usb_log_error("Failed to gain access to device registers.\n"); 53 return ret; 53 ddf_fun_t *ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, 54 fun_name); 55 if (ctl_fun == NULL) { 56 usb_log_error("Failed to create control function.\n"); 57 return ENOMEM; 54 58 } 55 instance->registers->interrupt_disable = 0; 56 /* enable interrupt on root hub status change */ 57 instance->registers->interupt_enable |= IE_RHSC | IE_MIE; 59 rc = ddf_fun_bind(ctl_fun); 60 if (rc != EOK) { 61 usb_log_error("Failed to bind control function: %s.\n", 62 str_error(rc)); 63 return rc; 64 } 58 65 66 usb_log_info("Pretending to control %s `%s'" \ 67 " (node `%s', handle %llu).\n", 68 dev->interface_no < 0 ? "device" : "interface", 69 dev->ddf_dev->name, fun_name, dev->ddf_dev->handle); 59 70 60 ohci_rh_init(&instance->rh, instance->registers);61 /* TODO: implement */62 /* TODO: register root hub */63 71 return EOK; 64 72 } 65 /*----------------------------------------------------------------------------*/ 66 int ohci_hc_schedule(ohci_hc_t *instance, batch_t *batch) 73 74 /** USB fallback driver ops. */ 75 static usb_driver_ops_t usbfallback_driver_ops = { 76 .add_device = usbfallback_add_device, 77 }; 78 79 /** USB fallback driver. */ 80 static usb_driver_t usbfallback_driver = { 81 .name = NAME, 82 .ops = &usbfallback_driver_ops, 83 .endpoints = NULL 84 }; 85 86 int main(int argc, char *argv[]) 67 87 { 68 assert(instance); 69 assert(batch); 70 if (batch->target.address == instance->rh.address) { 71 ohci_rh_request(&instance->rh, batch); 72 return EOK; 73 } 74 /* TODO: implement */ 75 return EOK; 88 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 89 90 return usb_driver_main(&usbfallback_driver); 76 91 } 77 /*----------------------------------------------------------------------------*/ 78 void ohci_hc_interrupt(ohci_hc_t *instance, uint16_t status) 79 { 80 assert(instance); 81 /* TODO: Check for interrupt cause */ 82 ohci_rh_interrupt(&instance->rh); 83 /* TODO: implement */ 84 } 92 85 93 /** 86 94 * @} -
uspace/drv/usbhid/hiddev.c
rfd9f6e4c r41ef5b9 184 184 * successfuly initialize the structure. 185 185 * 186 * @sa usb_ endpoint_pipe_initialize_from_configuration(),186 * @sa usb_pipe_initialize_from_configuration(), 187 187 * usbhid_dev_get_report_descriptor() 188 188 */ … … 218 218 }; 219 219 220 rc = usb_ endpoint_pipe_initialize_from_configuration(220 rc = usb_pipe_initialize_from_configuration( 221 221 endpoint_mapping, 1, descriptors, descriptors_size, 222 222 &hid_dev->wire); … … 359 359 * @return Other value inherited from one of functions 360 360 * usb_device_connection_initialize_from_device(), 361 * usb_ endpoint_pipe_initialize_default_control(),362 * usb_ endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),361 * usb_pipe_initialize_default_control(), 362 * usb_pipe_start_session(), usb_pipe_end_session(), 363 363 * usbhid_dev_process_descriptors(). 364 364 * … … 404 404 * Initialize device pipes. 405 405 */ 406 rc = usb_ endpoint_pipe_initialize_default_control(&hid_dev->ctrl_pipe,406 rc = usb_pipe_initialize_default_control(&hid_dev->ctrl_pipe, 407 407 &hid_dev->wire); 408 408 if (rc != EOK) { … … 411 411 return rc; 412 412 } 413 rc = usb_ endpoint_pipe_probe_default_control(&hid_dev->ctrl_pipe);413 rc = usb_pipe_probe_default_control(&hid_dev->ctrl_pipe); 414 414 if (rc != EOK) { 415 415 usb_log_error("Probing default control pipe failed: %s.\n", … … 430 430 * Get descriptors, parse descriptors and save endpoints. 431 431 */ 432 rc = usb_ endpoint_pipe_start_session(&hid_dev->ctrl_pipe);432 rc = usb_pipe_start_session(&hid_dev->ctrl_pipe); 433 433 if (rc != EOK) { 434 434 usb_log_error("Failed to start session on the control pipe: %s" … … 440 440 if (rc != EOK) { 441 441 /* TODO: end session?? */ 442 usb_ endpoint_pipe_end_session(&hid_dev->ctrl_pipe);442 usb_pipe_end_session(&hid_dev->ctrl_pipe); 443 443 usb_log_error("Failed to process descriptors: %s.\n", 444 444 str_error(rc)); … … 446 446 } 447 447 448 rc = usb_ endpoint_pipe_end_session(&hid_dev->ctrl_pipe);448 rc = usb_pipe_end_session(&hid_dev->ctrl_pipe); 449 449 if (rc != EOK) { 450 450 usb_log_warning("Failed to start session on the control pipe: " -
uspace/drv/usbhid/hiddev.h
rfd9f6e4c r41ef5b9 68 68 usb_device_connection_t wire; 69 69 /** USB pipe corresponding to the default Control endpoint. */ 70 usb_ endpoint_pipe_t ctrl_pipe;70 usb_pipe_t ctrl_pipe; 71 71 /** USB pipe corresponding to the Interrupt In (polling) pipe. */ 72 usb_ endpoint_pipe_t poll_pipe;72 usb_pipe_t poll_pipe; 73 73 74 74 /** Polling interval retreived from the Interface descriptor. */ -
uspace/drv/usbhid/hidreq.c
rfd9f6e4c r41ef5b9 57 57 * @retval EINVAL if no HID device is given. 58 58 * @return Other value inherited from one of functions 59 * usb_ endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),59 * usb_pipe_start_session(), usb_pipe_end_session(), 60 60 * usb_control_request_set(). 61 61 */ … … 76 76 int rc, sess_rc; 77 77 78 sess_rc = usb_ endpoint_pipe_start_session(&hid_dev->ctrl_pipe);78 sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe); 79 79 if (sess_rc != EOK) { 80 80 usb_log_warning("Failed to start a session: %s.\n", … … 92 92 USB_HIDREQ_SET_REPORT, value, hid_dev->iface, buffer, buf_size); 93 93 94 sess_rc = usb_ endpoint_pipe_end_session(&hid_dev->ctrl_pipe);94 sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe); 95 95 96 96 if (rc != EOK) { … … 119 119 * @retval EINVAL if no HID device is given. 120 120 * @return Other value inherited from one of functions 121 * usb_ endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),121 * usb_pipe_start_session(), usb_pipe_end_session(), 122 122 * usb_control_request_set(). 123 123 */ … … 137 137 int rc, sess_rc; 138 138 139 sess_rc = usb_ endpoint_pipe_start_session(&hid_dev->ctrl_pipe);139 sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe); 140 140 if (sess_rc != EOK) { 141 141 usb_log_warning("Failed to start a session: %s.\n", … … 151 151 USB_HIDREQ_SET_PROTOCOL, protocol, hid_dev->iface, NULL, 0); 152 152 153 sess_rc = usb_ endpoint_pipe_end_session(&hid_dev->ctrl_pipe);153 sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe); 154 154 155 155 if (rc != EOK) { … … 179 179 * @retval EINVAL if no HID device is given. 180 180 * @return Other value inherited from one of functions 181 * usb_ endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),181 * usb_pipe_start_session(), usb_pipe_end_session(), 182 182 * usb_control_request_set(). 183 183 */ … … 197 197 int rc, sess_rc; 198 198 199 sess_rc = usb_ endpoint_pipe_start_session(&hid_dev->ctrl_pipe);199 sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe); 200 200 if (sess_rc != EOK) { 201 201 usb_log_warning("Failed to start a session: %s.\n", … … 213 213 USB_HIDREQ_SET_IDLE, value, hid_dev->iface, NULL, 0); 214 214 215 sess_rc = usb_ endpoint_pipe_end_session(&hid_dev->ctrl_pipe);215 sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe); 216 216 217 217 if (rc != EOK) { … … 244 244 * @retval EINVAL if no HID device is given. 245 245 * @return Other value inherited from one of functions 246 * usb_ endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),246 * usb_pipe_start_session(), usb_pipe_end_session(), 247 247 * usb_control_request_set(). 248 248 */ … … 263 263 int rc, sess_rc; 264 264 265 sess_rc = usb_ endpoint_pipe_start_session(&hid_dev->ctrl_pipe);265 sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe); 266 266 if (sess_rc != EOK) { 267 267 usb_log_warning("Failed to start a session: %s.\n", … … 280 280 actual_size); 281 281 282 sess_rc = usb_ endpoint_pipe_end_session(&hid_dev->ctrl_pipe);282 sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe); 283 283 284 284 if (rc != EOK) { … … 307 307 * @retval EINVAL if no HID device is given. 308 308 * @return Other value inherited from one of functions 309 * usb_ endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),309 * usb_pipe_start_session(), usb_pipe_end_session(), 310 310 * usb_control_request_set(). 311 311 */ … … 325 325 int rc, sess_rc; 326 326 327 sess_rc = usb_ endpoint_pipe_start_session(&hid_dev->ctrl_pipe);327 sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe); 328 328 if (sess_rc != EOK) { 329 329 usb_log_warning("Failed to start a session: %s.\n", … … 342 342 USB_HIDREQ_GET_PROTOCOL, 0, hid_dev->iface, buffer, 1, &actual_size); 343 343 344 sess_rc = usb_ endpoint_pipe_end_session(&hid_dev->ctrl_pipe);344 sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe); 345 345 346 346 if (rc != EOK) { … … 378 378 * @retval EINVAL if no HID device is given. 379 379 * @return Other value inherited from one of functions 380 * usb_ endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(),380 * usb_pipe_start_session(), usb_pipe_end_session(), 381 381 * usb_control_request_set(). 382 382 */ … … 396 396 int rc, sess_rc; 397 397 398 sess_rc = usb_ endpoint_pipe_start_session(&hid_dev->ctrl_pipe);398 sess_rc = usb_pipe_start_session(&hid_dev->ctrl_pipe); 399 399 if (sess_rc != EOK) { 400 400 usb_log_warning("Failed to start a session: %s.\n", … … 415 415 &actual_size); 416 416 417 sess_rc = usb_ endpoint_pipe_end_session(&hid_dev->ctrl_pipe);417 sess_rc = usb_pipe_end_session(&hid_dev->ctrl_pipe); 418 418 419 419 if (rc != EOK) { -
uspace/drv/usbhid/kbddev.c
rfd9f6e4c r41ef5b9 780 780 781 781 while (true) { 782 sess_rc = usb_ endpoint_pipe_start_session(782 sess_rc = usb_pipe_start_session( 783 783 &kbd_dev->hid_dev->poll_pipe); 784 784 if (sess_rc != EOK) { … … 788 788 } 789 789 790 rc = usb_ endpoint_pipe_read(&kbd_dev->hid_dev->poll_pipe,790 rc = usb_pipe_read(&kbd_dev->hid_dev->poll_pipe, 791 791 buffer, BOOTP_BUFFER_SIZE, &actual_size); 792 792 793 sess_rc = usb_ endpoint_pipe_end_session(793 sess_rc = usb_pipe_end_session( 794 794 &kbd_dev->hid_dev->poll_pipe); 795 795 -
uspace/drv/usbhub/main.c
rfd9f6e4c r41ef5b9 42 42 #include "usbhub_private.h" 43 43 44 45 usb_endpoint_description_t hub_status_change_endpoint_description = { 44 /** Hub status-change endpoint description. 45 * 46 * For more information see section 11.15.1 of USB 1.1 specification. 47 */ 48 static usb_endpoint_description_t hub_status_change_endpoint_description = { 46 49 .transfer_type = USB_TRANSFER_INTERRUPT, 47 50 .direction = USB_DIRECTION_IN, … … 57 60 }; 58 61 62 static usb_endpoint_description_t *usb_hub_endpoints[] = { 63 &hub_status_change_endpoint_description, 64 NULL 65 }; 66 59 67 static usb_driver_t usb_hub_driver = { 60 .name = "usbhub", 61 .ops = &usb_hub_driver_ops 68 .name = NAME, 69 .ops = &usb_hub_driver_ops, 70 .endpoints = usb_hub_endpoints 62 71 }; 63 72 … … 65 74 int main(int argc, char *argv[]) 66 75 { 76 printf(NAME ": HelenOS USB hub driver.\n"); 77 67 78 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 68 usb_log_info("starting hub driver\n");69 70 79 71 usb_hub_driver.endpoints = (usb_endpoint_description_t**)72 malloc(2 * sizeof(usb_endpoint_description_t*));73 usb_hub_driver.endpoints[0] = &hub_status_change_endpoint_description;74 usb_hub_driver.endpoints[1] = NULL;75 76 80 return usb_driver_main(&usb_hub_driver); 77 81 } -
uspace/drv/usbhub/usbhub.c
rfd9f6e4c r41ef5b9 157 157 static int usb_hub_set_configuration(usb_hub_info_t * hub_info){ 158 158 //device descriptor 159 usb_standard_device_descriptor_t std_descriptor; 160 int opResult = usb_request_get_device_descriptor( 161 &hub_info->usb_device->ctrl_pipe, 162 &std_descriptor); 163 if(opResult!=EOK){ 164 usb_log_error("could not get device descriptor, %d\n",opResult); 165 return opResult; 166 } 159 usb_standard_device_descriptor_t *std_descriptor 160 = &hub_info->usb_device->descriptors.device; 167 161 usb_log_info("hub has %d configurations\n", 168 std_descriptor.configuration_count);169 if(std_descriptor .configuration_count<1){162 std_descriptor->configuration_count); 163 if(std_descriptor->configuration_count<1){ 170 164 usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE\n"); 171 165 //shouldn`t I return? 172 } 173 174 /* Retrieve full configuration descriptor. */ 175 uint8_t *descriptors = NULL; 176 size_t descriptors_size = 0; 177 opResult = usb_request_get_full_configuration_descriptor_alloc( 178 &hub_info->usb_device->ctrl_pipe, 0, 179 (void **) &descriptors, &descriptors_size); 180 if (opResult != EOK) { 181 usb_log_error("Could not get configuration descriptor: %s.\n", 182 str_error(opResult)); 183 return opResult; 184 } 166 //definitely 167 return EINVAL; 168 } 169 185 170 usb_standard_configuration_descriptor_t *config_descriptor 186 = (usb_standard_configuration_descriptor_t *) descriptors; 171 = (usb_standard_configuration_descriptor_t *) 172 hub_info->usb_device->descriptors.configuration; 187 173 188 174 /* Set configuration. */ 189 opResult = usb_request_set_configuration(&hub_info->usb_device->ctrl_pipe, 175 int opResult = usb_request_set_configuration( 176 &hub_info->usb_device->ctrl_pipe, 190 177 config_descriptor->configuration_number); 191 178 … … 197 184 usb_log_debug("\tused configuration %d\n", 198 185 config_descriptor->configuration_number); 199 free(descriptors); 186 200 187 return EOK; 201 188 } … … 224 211 } 225 212 226 usb_ endpoint_pipe_start_session(hub_info->control_pipe);213 usb_pipe_start_session(hub_info->control_pipe); 227 214 //set hub configuration 228 215 opResult = usb_hub_set_configuration(hub_info); … … 239 226 return opResult; 240 227 } 241 usb_ endpoint_pipe_end_session(hub_info->control_pipe);228 usb_pipe_end_session(hub_info->control_pipe); 242 229 243 230 244 231 /// \TODO what is this? 245 usb_log_debug(" adding to ddf");232 usb_log_debug("Creating `hub' function.\n"); 246 233 ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev, 247 234 fun_exposed, "hub"); … … 257 244 fid_t fid = fibril_create(usb_hub_control_loop, hub_info); 258 245 if (fid == 0) { 259 usb_log_error("failed to start monitoring fibril for new hub ");246 usb_log_error("failed to start monitoring fibril for new hub.\n"); 260 247 return ENOMEM; 261 248 } 262 249 fibril_add_ready(fid); 263 usb_log_debug("hub fibril created"); 264 usb_log_debug("has %d ports ",hub_info->port_count); 250 usb_log_debug("Hub fibril created.\n"); 251 252 usb_log_info("Controlling hub `%s' (%d ports).\n", 253 hub_info->usb_device->ddf_dev->name, hub_info->port_count); 265 254 return EOK; 266 255 } … … 321 310 //reset port 322 311 usb_hub_set_reset_port_request(&request, port); 323 opResult = usb_ endpoint_pipe_control_write(312 opResult = usb_pipe_control_write( 324 313 hub->control_pipe, 325 314 &request,sizeof(usb_device_request_setup_packet_t), … … 354 343 } 355 344 //create connection to device 356 usb_ endpoint_pipe_t new_device_pipe;345 usb_pipe_t new_device_pipe; 357 346 usb_device_connection_t new_device_connection; 358 347 usb_device_connection_initialize_on_default_address( … … 360 349 &hub->connection 361 350 ); 362 usb_ endpoint_pipe_initialize_default_control(351 usb_pipe_initialize_default_control( 363 352 &new_device_pipe, 364 353 &new_device_connection); 365 usb_ endpoint_pipe_probe_default_control(&new_device_pipe);354 usb_pipe_probe_default_control(&new_device_pipe); 366 355 367 356 /* Request address from host controller. */ … … 379 368 //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 380 369 // new_device_address); 381 usb_ endpoint_pipe_start_session(&new_device_pipe);370 usb_pipe_start_session(&new_device_pipe); 382 371 opResult = usb_request_set_address(&new_device_pipe,new_device_address); 383 usb_ endpoint_pipe_end_session(&new_device_pipe);372 usb_pipe_end_session(&new_device_pipe); 384 373 if (opResult != EOK) { 385 374 usb_log_error("could not set address for new device %d\n",opResult); … … 488 477 usb_log_debug("interrupt at port %d\n", port); 489 478 //determine type of change 490 usb_ endpoint_pipe_t *pipe = hub->control_pipe;479 usb_pipe_t *pipe = hub->control_pipe; 491 480 492 481 int opResult; … … 499 488 //endpoint 0 500 489 501 opResult = usb_ endpoint_pipe_control_read(490 opResult = usb_pipe_control_read( 502 491 pipe, 503 492 &request, sizeof(usb_device_request_setup_packet_t), … … 533 522 //port reset 534 523 if (usb_port_reset_completed(&status)) { 535 usb_log_info("port reset complete ");524 usb_log_info("port reset complete\n"); 536 525 if (usb_port_enabled(&status)) { 537 526 usb_hub_finalize_add_device(hub, port, usb_port_speed(&status)); … … 560 549 int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){ 561 550 int opResult; 562 opResult = usb_ endpoint_pipe_start_session(551 opResult = usb_pipe_start_session( 563 552 hub_info->status_change_pipe); 564 553 if(opResult != EOK){ … … 578 567 * Send the request. 579 568 */ 580 opResult = usb_ endpoint_pipe_read(569 opResult = usb_pipe_read( 581 570 hub_info->status_change_pipe, 582 571 change_bitmap, byte_length, &actual_size … … 586 575 free(change_bitmap); 587 576 usb_log_warning("something went wrong while getting status of hub\n"); 588 usb_ endpoint_pipe_end_session(hub_info->status_change_pipe);577 usb_pipe_end_session(hub_info->status_change_pipe); 589 578 return opResult; 590 579 } 591 580 unsigned int port; 592 opResult = usb_ endpoint_pipe_start_session(hub_info->control_pipe);581 opResult = usb_pipe_start_session(hub_info->control_pipe); 593 582 if(opResult!=EOK){ 594 583 usb_log_error("could not start control pipe session %d\n", opResult); 595 usb_ endpoint_pipe_end_session(hub_info->status_change_pipe);584 usb_pipe_end_session(hub_info->status_change_pipe); 596 585 return opResult; 597 586 } … … 600 589 usb_log_error("could not start host controller session %d\n", 601 590 opResult); 602 usb_ endpoint_pipe_end_session(hub_info->control_pipe);603 usb_ endpoint_pipe_end_session(hub_info->status_change_pipe);591 usb_pipe_end_session(hub_info->control_pipe); 592 usb_pipe_end_session(hub_info->status_change_pipe); 604 593 return opResult; 605 594 } … … 615 604 } 616 605 usb_hc_connection_close(&hub_info->connection); 617 usb_ endpoint_pipe_end_session(hub_info->control_pipe);618 usb_ endpoint_pipe_end_session(hub_info->status_change_pipe);606 usb_pipe_end_session(hub_info->control_pipe); 607 usb_pipe_end_session(hub_info->status_change_pipe); 619 608 free(change_bitmap); 620 609 return EOK; -
uspace/drv/usbhub/usbhub.h
rfd9f6e4c r41ef5b9 48 48 49 49 50 /** Hub status-change endpoint description51 *52 * For more see usb hub specification in 11.15.1 of53 */54 extern usb_endpoint_description_t hub_status_change_endpoint_description;55 56 57 58 /* Hub endpoints. */59 /*typedef struct {60 usb_endpoint_pipe_t control;61 usb_endpoint_pipe_t status_change;62 } usb_hub_endpoints_t;63 */64 65 66 50 /** Information about attached hub. */ 67 51 typedef struct { … … 88 72 * searched again and again for the 'right pipe'. 89 73 */ 90 usb_ endpoint_pipe_t * status_change_pipe;74 usb_pipe_t * status_change_pipe; 91 75 92 76 /** convenience pointer to control pipe … … 96 80 * searched again and again for the 'right pipe'. 97 81 */ 98 usb_ endpoint_pipe_t * control_pipe;82 usb_pipe_t * control_pipe; 99 83 100 84 /** generic usb device data*/ -
uspace/drv/usbhub/usbhub_private.h
rfd9f6e4c r41ef5b9 95 95 * @return Operation result 96 96 */ 97 static inline int usb_hub_clear_port_feature(usb_ endpoint_pipe_t *pipe,97 static inline int usb_hub_clear_port_feature(usb_pipe_t *pipe, 98 98 int port_index, 99 99 usb_hub_class_feature_t feature) { … … 106 106 }; 107 107 clear_request.value = feature; 108 return usb_ endpoint_pipe_control_write(pipe, &clear_request,108 return usb_pipe_control_write(pipe, &clear_request, 109 109 sizeof(clear_request), NULL, 0); 110 110 } -
uspace/drv/usbmid/main.c
rfd9f6e4c r41ef5b9 61 61 int rc; 62 62 63 rc = usb_ endpoint_pipe_start_session(&dev->ctrl_pipe);63 rc = usb_pipe_start_session(&dev->ctrl_pipe); 64 64 if (rc != EOK) { 65 65 usb_log_error("Failed to start session on control pipe: %s.\n", … … 70 70 bool accept = usbmid_explore_device(dev); 71 71 72 rc = usb_ endpoint_pipe_end_session(&dev->ctrl_pipe);72 rc = usb_pipe_end_session(&dev->ctrl_pipe); 73 73 if (rc != EOK) { 74 74 usb_log_warning("Failed to end session on control pipe: %s.\n", -
uspace/drv/usbmid/usbmid.c
rfd9f6e4c r41ef5b9 108 108 } 109 109 110 rc = usb_ endpoint_pipe_initialize_default_control(&mid->ctrl_pipe,110 rc = usb_pipe_initialize_default_control(&mid->ctrl_pipe, 111 111 &mid->wire); 112 112 if (rc != EOK) { … … 116 116 return NULL; 117 117 } 118 rc = usb_ endpoint_pipe_probe_default_control(&mid->ctrl_pipe);118 rc = usb_pipe_probe_default_control(&mid->ctrl_pipe); 119 119 if (rc != EOK) { 120 120 usb_log_error("Probing default control pipe failed: %s.\n", -
uspace/drv/usbmid/usbmid.h
rfd9f6e4c r41ef5b9 52 52 usb_device_connection_t wire; 53 53 /** Default control pipe. */ 54 usb_ endpoint_pipe_t ctrl_pipe;54 usb_pipe_t ctrl_pipe; 55 55 } usbmid_device_t; 56 56 -
uspace/drv/usbmouse/init.c
rfd9f6e4c r41ef5b9 126 126 127 127 /* Open the control pipe. */ 128 rc = usb_ endpoint_pipe_start_session(&dev->ctrl_pipe);128 rc = usb_pipe_start_session(&dev->ctrl_pipe); 129 129 if (rc != EOK) { 130 130 goto leave; … … 141 141 142 142 /* Close the control pipe (ignore errors). */ 143 usb_ endpoint_pipe_end_session(&dev->ctrl_pipe);143 usb_pipe_end_session(&dev->ctrl_pipe); 144 144 145 145
Note:
See TracChangeset
for help on using the changeset viewer.
