Changes in / [361e61b:55e388a1] in mainline
- Files:
-
- 8 added
- 8 deleted
- 68 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
r361e61b r55e388a1 9 9 _link.ld 10 10 ./*.iso 11 12 ./tools/__pycache__/ 11 13 12 14 ./Makefile.common … … 139 141 .cproject 140 142 .project 143 .settings 144 .pydevproject 145 -
HelenOS.config
r361e61b r55e388a1 552 552 ! CONFIG_RUN_VIRTUAL_USB_HC (n/y) 553 553 554 % Polling UHCI & OHCI (no interrupts) 555 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (y/n) -
kernel/tools/genmap.py
r361e61b r55e388a1 100 100 for addr, symbol in symbols: 101 101 value = fname + ':' + symbol 102 data = struct.pack(symtabfmt, addr + offset, value[:MAXSTRING]) 102 value_bytes = value.encode('ascii') 103 data = struct.pack(symtabfmt, addr + offset, value_bytes[:MAXSTRING]) 103 104 out.write(data) 104 105 105 out.write(struct.pack(symtabfmt, 0, ''))106 out.write(struct.pack(symtabfmt, 0, b'')) 106 107 107 108 def main(): -
tools/mkfat.py
r361e61b r55e388a1 211 211 dir_entry = xstruct.create(DIR_ENTRY) 212 212 213 dir_entry.name = mangle_fname(name) 214 dir_entry.ext = mangle_ext(name) 213 dir_entry.name = mangle_fname(name).encode('ascii') 214 dir_entry.ext = mangle_ext(name).encode('ascii') 215 215 216 216 if (directory): … … 239 239 240 240 dir_entry.signature = 0x2e 241 dir_entry.name = ' '242 dir_entry.ext = ' '241 dir_entry.name = b' ' 242 dir_entry.ext = b' ' 243 243 dir_entry.attr = 0x10 244 244 … … 258 258 259 259 dir_entry.signature = [0x2e, 0x2e] 260 dir_entry.name = ' '261 dir_entry.ext = ' '260 dir_entry.name = b' ' 261 dir_entry.ext = b' ' 262 262 dir_entry.attr = 0x10 263 263 -
tools/mkhord.py
r361e61b r55e388a1 84 84 payload_size_aligned = align_up(payload_size, align) 85 85 86 header.tag = "HORD"86 header.tag = b"HORD" 87 87 header.version = 1 88 88 header.encoding = HORD_LSB -
tools/mktmpfs.py
r361e61b r55e388a1 80 80 dentry.kind = TMPFS_FILE 81 81 dentry.fname_len = len(name) 82 dentry.fname = name 82 dentry.fname = name.encode('ascii') 83 83 dentry.flen = size 84 84 … … 97 97 dentry.kind = TMPFS_DIRECTORY 98 98 dentry.fname_len = len(name) 99 dentry.fname = name 99 dentry.fname = name.encode('ascii') 100 100 101 101 outf.write(dentry.pack()) … … 122 122 123 123 header = xstruct.create(HEADER) 124 header.tag = "TMPFS"124 header.tag = b"TMPFS" 125 125 126 126 outf.write(header.pack()) -
uspace/app/bdsh/cmds/modules/bdd/bdd.c
r361e61b r55e388a1 70 70 unsigned int i, j; 71 71 devmap_handle_t handle; 72 aoff64_t offset; 72 73 uint8_t *blk; 73 74 size_t size, bytes, rows; … … 120 121 } 121 122 123 offset = ba * block_size; 124 122 125 while (size > 0) { 123 126 rc = block_read_direct(handle, ba, 1, blk); … … 133 136 134 137 for (j = 0; j < rows; j++) { 138 printf("[%06" PRIxOFF64 "] ", offset); 135 139 for (i = 0; i < BPR; i++) { 136 140 if (j * BPR + i < bytes) … … 152 156 } 153 157 } 158 offset += BPR; 154 159 putchar('\n'); 155 160 } -
uspace/app/usbinfo/dev.c
r361e61b r55e388a1 59 59 } 60 60 61 rc = usb_ endpoint_pipe_initialize_default_control(&dev->ctrl_pipe,61 rc = usb_pipe_initialize_default_control(&dev->ctrl_pipe, 62 62 &dev->wire); 63 63 if (rc != EOK) { … … 68 68 } 69 69 70 rc = usb_ endpoint_pipe_probe_default_control(&dev->ctrl_pipe);70 rc = usb_pipe_probe_default_control(&dev->ctrl_pipe); 71 71 if (rc != EOK) { 72 72 fprintf(stderr, … … 76 76 } 77 77 78 rc = usb_ endpoint_pipe_start_session(&dev->ctrl_pipe);78 rc = usb_pipe_start_session(&dev->ctrl_pipe); 79 79 if (rc != EOK) { 80 80 fprintf(stderr, … … 107 107 108 108 leave: 109 if (usb_ endpoint_pipe_is_session_started(&dev->ctrl_pipe)) {110 usb_ endpoint_pipe_end_session(&dev->ctrl_pipe);109 if (usb_pipe_is_session_started(&dev->ctrl_pipe)) { 110 usb_pipe_end_session(&dev->ctrl_pipe); 111 111 } 112 112 … … 118 118 void destroy_device(usbinfo_device_t *dev) 119 119 { 120 usb_ endpoint_pipe_end_session(&dev->ctrl_pipe);120 usb_pipe_end_session(&dev->ctrl_pipe); 121 121 free(dev); 122 122 } -
uspace/app/usbinfo/usbinfo.h
r361e61b r55e388a1 44 44 45 45 typedef struct { 46 usb_ endpoint_pipe_t ctrl_pipe;46 usb_pipe_t ctrl_pipe; 47 47 usb_device_connection_t wire; 48 48 usb_standard_device_descriptor_t device_descriptor; -
uspace/drv/ehci-hcd/main.c
r361e61b r55e388a1 119 119 int main(int argc, char *argv[]) 120 120 { 121 usb_log_enable(USB_LOG_LEVEL_DE BUG, NAME);121 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 122 122 return ddf_driver_main(&ehci_driver); 123 123 } -
uspace/drv/ohci/batch.c
r361e61b r55e388a1 41 41 #include "utils/malloc32.h" 42 42 43 static void batch_call_in_and_dispose( batch_t *instance);44 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); 45 45 46 46 #define DEFAULT_ERROR_COUNT 3 47 batch_t * batch_get(47 usb_transfer_batch_t * batch_get( 48 48 ddf_fun_t *fun, 49 49 usb_target_t target, … … 58 58 usbhc_iface_transfer_out_callback_t func_out, 59 59 void *arg, 60 device_keeper_t *manager60 usb_device_keeper_t *manager 61 61 ) 62 62 { … … 70 70 } else (void)0 71 71 72 batch_t *instance = malloc(sizeof(batch_t));72 usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t)); 73 73 CHECK_NULL_DISPOSE_RETURN(instance, 74 74 "Failed to allocate batch instance.\n"); 75 batch_init(instance, target, transfer_type, speed, max_packet_size,75 usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size, 76 76 buffer, NULL, buffer_size, NULL, setup_size, func_in, 77 77 func_out, arg, fun, NULL); … … 94 94 } 95 95 /*----------------------------------------------------------------------------*/ 96 void batch_dispose( batch_t *instance)96 void batch_dispose(usb_transfer_batch_t *instance) 97 97 { 98 98 assert(instance); … … 102 102 } 103 103 /*----------------------------------------------------------------------------*/ 104 void batch_control_write( batch_t *instance)104 void batch_control_write(usb_transfer_batch_t *instance) 105 105 { 106 106 assert(instance); … … 113 113 } 114 114 /*----------------------------------------------------------------------------*/ 115 void batch_control_read( batch_t *instance)115 void batch_control_read(usb_transfer_batch_t *instance) 116 116 { 117 117 assert(instance); … … 121 121 } 122 122 /*----------------------------------------------------------------------------*/ 123 void batch_interrupt_in( batch_t *instance)123 void batch_interrupt_in(usb_transfer_batch_t *instance) 124 124 { 125 125 assert(instance); … … 130 130 } 131 131 /*----------------------------------------------------------------------------*/ 132 void batch_interrupt_out( batch_t *instance)132 void batch_interrupt_out(usb_transfer_batch_t *instance) 133 133 { 134 134 assert(instance); … … 142 142 } 143 143 /*----------------------------------------------------------------------------*/ 144 void batch_bulk_in( batch_t *instance)144 void batch_bulk_in(usb_transfer_batch_t *instance) 145 145 { 146 146 assert(instance); … … 151 151 } 152 152 /*----------------------------------------------------------------------------*/ 153 void batch_bulk_out( batch_t *instance)153 void batch_bulk_out(usb_transfer_batch_t *instance) 154 154 { 155 155 assert(instance); … … 164 164 * @param[in] instance Batch structure to use. 165 165 */ 166 void batch_call_in_and_dispose( batch_t *instance)166 void batch_call_in_and_dispose(usb_transfer_batch_t *instance) 167 167 { 168 168 assert(instance); 169 batch_call_in(instance);169 usb_transfer_batch_call_in(instance); 170 170 batch_dispose(instance); 171 171 } … … 175 175 * @param[in] instance Batch structure to use. 176 176 */ 177 void batch_call_out_and_dispose( batch_t *instance)177 void batch_call_out_and_dispose(usb_transfer_batch_t *instance) 178 178 { 179 179 assert(instance); 180 batch_call_out(instance);180 usb_transfer_batch_call_out(instance); 181 181 batch_dispose(instance); 182 182 } -
uspace/drv/ohci/batch.h
r361e61b r55e388a1 41 41 #include <usb/host/batch.h> 42 42 43 batch_t * batch_get(43 usb_transfer_batch_t * batch_get( 44 44 ddf_fun_t *fun, 45 45 usb_target_t target, … … 54 54 usbhc_iface_transfer_out_callback_t func_out, 55 55 void *arg, 56 device_keeper_t *manager56 usb_device_keeper_t *manager 57 57 ); 58 58 59 void batch_dispose( batch_t *instance);59 void batch_dispose(usb_transfer_batch_t *instance); 60 60 61 void batch_control_write( batch_t *instance);61 void batch_control_write(usb_transfer_batch_t *instance); 62 62 63 void batch_control_read( batch_t *instance);63 void batch_control_read(usb_transfer_batch_t *instance); 64 64 65 void batch_interrupt_in( batch_t *instance);65 void batch_interrupt_in(usb_transfer_batch_t *instance); 66 66 67 void batch_interrupt_out( batch_t *instance);67 void batch_interrupt_out(usb_transfer_batch_t *instance); 68 68 69 void batch_bulk_in( batch_t *instance);69 void batch_bulk_in(usb_transfer_batch_t *instance); 70 70 71 void batch_bulk_out( batch_t *instance);71 void batch_bulk_out(usb_transfer_batch_t *instance); 72 72 #endif 73 73 /** -
uspace/drv/ohci/hc.c
r361e61b r55e388a1 45 45 #include "hc.h" 46 46 47 static int dummy_reset(int foo, void *arg) 48 { 49 hc_t *hc = (hc_t*)arg; 50 assert(hc); 51 hc->rh.address = 0; 52 return EOK; 53 } 47 static int dummy_reset(int foo, void *arg); 48 static int interrupt_emulator(hc_t *instance); 54 49 /*----------------------------------------------------------------------------*/ 55 50 int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev, … … 65 60 } 66 61 instance->ddf_instance = fun; 67 device_keeper_init(&instance->manager); 62 usb_device_keeper_init(&instance->manager); 63 64 if (!interrupts) { 65 instance->interrupt_emulator = 66 fibril_create((int(*)(void*))interrupt_emulator, instance); 67 fibril_add_ready(instance->interrupt_emulator); 68 } 68 69 69 70 … … 99 100 ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset, 100 101 0, instance, &address, &handle, NULL, NULL, NULL); 101 CHECK_RET_RETURN(ret, "Failed to add rh device.\n"); 102 if (ret != EOK) { 103 usb_log_error("Failed to add rh device.\n"); 104 instance->rh.address = -1; 105 return ret; 106 } 102 107 103 108 ret = usb_hc_connection_close(&conn); … … 106 111 } 107 112 /*----------------------------------------------------------------------------*/ 108 int hc_schedule(hc_t *instance, batch_t *batch)113 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch) 109 114 { 110 115 assert(instance); … … 117 122 } 118 123 /*----------------------------------------------------------------------------*/ 119 void hc_interrupt(hc_t *instance, uint 16_t status)124 void hc_interrupt(hc_t *instance, uint32_t status) 120 125 { 121 126 assert(instance); 122 /* TODO: Check for interrupt cause */ 123 rh_interrupt(&instance->rh); 127 if (status == 0) 128 return; 129 if (status & IS_RHSC) 130 rh_interrupt(&instance->rh); 131 132 /* TODO: Check for further interrupt causes */ 124 133 /* TODO: implement */ 134 } 135 /*----------------------------------------------------------------------------*/ 136 static int dummy_reset(int foo, void *arg) 137 { 138 hc_t *hc = (hc_t*)arg; 139 assert(hc); 140 hc->rh.address = 0; 141 return EOK; 142 } 143 /*----------------------------------------------------------------------------*/ 144 static int interrupt_emulator(hc_t *instance) 145 { 146 assert(instance); 147 usb_log_info("Started interrupt emulator.\n"); 148 while (1) { 149 uint32_t status = instance->registers->interrupt_status; 150 instance->registers->interrupt_status = status; 151 hc_interrupt(instance, status); 152 async_usleep(1000); 153 } 154 return EOK; 125 155 } 126 156 /** -
uspace/drv/ohci/hc.h
r361e61b r55e388a1 53 53 rh_t rh; 54 54 ddf_fun_t *ddf_instance; 55 device_keeper_t manager; 55 usb_device_keeper_t manager; 56 fid_t interrupt_emulator; 56 57 } hc_t; 57 58 … … 61 62 int hc_register_hub(hc_t *instance); 62 63 63 int hc_schedule(hc_t *instance, batch_t *batch);64 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch); 64 65 65 void hc_interrupt(hc_t *instance, uint 16_t status);66 void hc_interrupt(hc_t *instance, uint32_t status); 66 67 67 68 /** Safely dispose host controller internal structures -
uspace/drv/ohci/iface.c
r361e61b r55e388a1 33 33 */ 34 34 #include <ddf/driver.h> 35 #include <ddf/interrupt.h>36 #include <device/hw_res.h>37 35 #include <errno.h> 38 #include <str_error.h> 39 40 #include <usb_iface.h> 41 #include <usb/ddfiface.h> 36 42 37 #include <usb/debug.h> 43 38 … … 60 55 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 61 56 { 62 63 64 65 66 device_keeper_reserve_default(&hc->manager, speed);67 57 assert(fun); 58 hc_t *hc = fun_to_hc(fun); 59 assert(hc); 60 usb_log_debug("Default address request with speed %d.\n", speed); 61 usb_device_keeper_reserve_default_address(&hc->manager, speed); 62 return EOK; 68 63 } 69 64 /*----------------------------------------------------------------------------*/ … … 75 70 static int release_default_address(ddf_fun_t *fun) 76 71 { 77 78 79 80 81 device_keeper_release_default(&hc->manager);82 72 assert(fun); 73 hc_t *hc = fun_to_hc(fun); 74 assert(hc); 75 usb_log_debug("Default address release.\n"); 76 usb_device_keeper_release_default_address(&hc->manager); 77 return EOK; 83 78 } 84 79 /*----------------------------------------------------------------------------*/ … … 90 85 * @return Error code. 91 86 */ 92 static int request_address( ddf_fun_t *fun, usb_speed_t speed,93 usb_address_t *address)94 { 95 96 97 98 99 100 101 *address = device_keeper_request(&hc->manager, speed);102 103 104 105 87 static int request_address( 88 ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address) 89 { 90 assert(fun); 91 hc_t *hc = fun_to_hc(fun); 92 assert(hc); 93 assert(address); 94 95 usb_log_debug("Address request with speed %d.\n", speed); 96 *address = device_keeper_get_free_address(&hc->manager, speed); 97 usb_log_debug("Address request with result: %d.\n", *address); 98 if (*address <= 0) 99 return *address; 100 return EOK; 106 101 } 107 102 /*----------------------------------------------------------------------------*/ … … 113 108 * @return Error code. 114 109 */ 115 static int bind_address( ddf_fun_t *fun,116 usb_address_t address, devman_handle_t handle)117 { 118 119 120 121 122 123 110 static int bind_address( 111 ddf_fun_t *fun, usb_address_t address, devman_handle_t handle) 112 { 113 assert(fun); 114 hc_t *hc = fun_to_hc(fun); 115 assert(hc); 116 usb_log_debug("Address bind %d-%d.\n", address, handle); 117 usb_device_keeper_bind(&hc->manager, address, handle); 118 return EOK; 124 119 } 125 120 /*----------------------------------------------------------------------------*/ … … 132 127 static int release_address(ddf_fun_t *fun, usb_address_t address) 133 128 { 134 135 136 137 138 139 140 } 141 129 assert(fun); 130 hc_t *hc = fun_to_hc(fun); 131 assert(hc); 132 usb_log_debug("Address release %d.\n", address); 133 usb_device_keeper_release(&hc->manager, address); 134 return EOK; 135 } 136 /*----------------------------------------------------------------------------*/ 142 137 /** Register endpoint for bandwidth reservation. 143 138 * … … 151 146 * @return Error code. 152 147 */ 153 static int register_endpoint( ddf_fun_t *fun,154 usb_address_t address, usb_endpoint_t endpoint,148 static int register_endpoint( 149 ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint, 155 150 usb_transfer_type_t transfer_type, usb_direction_t direction, 156 151 size_t max_packet_size, unsigned int interval) … … 160 155 return ENOTSUP; 161 156 } 162 157 /*----------------------------------------------------------------------------*/ 163 158 /** Unregister endpoint (free some bandwidth reservation). 164 159 * … … 169 164 * @return Error code. 170 165 */ 171 static int unregister_endpoint(ddf_fun_t *fun, usb_address_t address, 166 static int unregister_endpoint( 167 ddf_fun_t *fun, usb_address_t address, 172 168 usb_endpoint_t endpoint, usb_direction_t direction) 173 169 { … … 194 190 * @return Error code. 195 191 */ 196 static int interrupt_out(ddf_fun_t *fun, usb_target_t target, 197 size_t max_packet_size, void *data, size_t size, 198 usbhc_iface_transfer_out_callback_t callback, void *arg) 199 { 200 hc_t *hc = fun_to_hc(fun); 201 assert(hc); 202 usb_speed_t speed = device_keeper_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 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; 192 static int interrupt_out( 193 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 194 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 195 { 196 assert(fun); 197 hc_t *hc = fun_to_hc(fun); 198 assert(hc); 199 usb_speed_t speed = 200 usb_device_keeper_get_speed(&hc->manager, target.address); 201 202 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 203 target.address, target.endpoint, size, max_packet_size); 204 205 usb_transfer_batch_t *batch = 206 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 207 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager); 208 if (!batch) 209 return ENOMEM; 210 batch_interrupt_out(batch); 211 const int ret = hc_schedule(hc, batch); 212 if (ret != EOK) { 213 batch_dispose(batch); 214 } 215 return ret; 219 216 } 220 217 /*----------------------------------------------------------------------------*/ … … 236 233 * @return Error code. 237 234 */ 238 static int interrupt_in( ddf_fun_t *fun, usb_target_t target,239 size_t max_packet_size, void *data, size_t size,240 usbhc_iface_transfer_in_callback_t callback, void *arg)241 { 242 243 244 245 usb_speed_t speed = device_keeper_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 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;235 static int interrupt_in( 236 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 237 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 238 { 239 assert(fun); 240 hc_t *hc = fun_to_hc(fun); 241 assert(hc); 242 usb_speed_t speed = 243 usb_device_keeper_get_speed(&hc->manager, target.address); 244 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 245 target.address, target.endpoint, size, max_packet_size); 246 247 usb_transfer_batch_t *batch = 248 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 249 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager); 250 if (!batch) 251 return ENOMEM; 252 batch_interrupt_in(batch); 253 const int ret = hc_schedule(hc, batch); 254 if (ret != EOK) { 255 batch_dispose(batch); 256 } 257 return ret; 261 258 } 262 259 /*----------------------------------------------------------------------------*/ … … 278 275 * @return Error code. 279 276 */ 280 static int bulk_out(ddf_fun_t *fun, usb_target_t target, 281 size_t max_packet_size, void *data, size_t size, 282 usbhc_iface_transfer_out_callback_t callback, void *arg) 283 { 284 assert(fun); 285 hc_t *hc = fun_to_hc(fun); 286 assert(hc); 287 usb_speed_t speed = device_keeper_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 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 277 static int bulk_out( 278 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 279 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 280 { 281 assert(fun); 282 hc_t *hc = fun_to_hc(fun); 283 assert(hc); 284 usb_speed_t speed = 285 usb_device_keeper_get_speed(&hc->manager, target.address); 286 287 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 288 target.address, target.endpoint, size, max_packet_size); 289 290 usb_transfer_batch_t *batch = 291 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 292 data, size, NULL, 0, NULL, callback, arg, &hc->manager); 293 if (!batch) 294 return ENOMEM; 295 batch_bulk_out(batch); 296 const int ret = hc_schedule(hc, batch); 297 if (ret != EOK) { 298 batch_dispose(batch); 299 } 300 return ret; 305 301 } 306 302 /*----------------------------------------------------------------------------*/ … … 322 318 * @return Error code. 323 319 */ 324 static int bulk_in( ddf_fun_t *fun, usb_target_t target,325 size_t max_packet_size, void *data, size_t size,326 usbhc_iface_transfer_in_callback_t callback, void *arg)327 { 328 329 330 331 usb_speed_t speed = device_keeper_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 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;320 static int bulk_in( 321 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 322 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 323 { 324 assert(fun); 325 hc_t *hc = fun_to_hc(fun); 326 assert(hc); 327 usb_speed_t speed = 328 usb_device_keeper_get_speed(&hc->manager, target.address); 329 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 330 target.address, target.endpoint, size, max_packet_size); 331 332 usb_transfer_batch_t *batch = 333 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 334 data, size, NULL, 0, callback, NULL, arg, &hc->manager); 335 if (!batch) 336 return ENOMEM; 337 batch_bulk_in(batch); 338 const int ret = hc_schedule(hc, batch); 339 if (ret != EOK) { 340 batch_dispose(batch); 341 } 342 return ret; 347 343 } 348 344 /*----------------------------------------------------------------------------*/ … … 367 363 * @return Error code. 368 364 */ 369 static int control_write(ddf_fun_t *fun, usb_target_t target, 370 size_t max_packet_size, 371 void *setup_data, size_t setup_size, 372 void *data, size_t size, 365 static int control_write( 366 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 367 void *setup_data, size_t setup_size, void *data, size_t size, 373 368 usbhc_iface_transfer_out_callback_t callback, void *arg) 374 369 { 375 assert(fun); 376 hc_t *hc = fun_to_hc(fun); 377 assert(hc); 378 usb_speed_t speed = device_keeper_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 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 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; 370 assert(fun); 371 hc_t *hc = fun_to_hc(fun); 372 assert(hc); 373 usb_speed_t speed = 374 usb_device_keeper_get_speed(&hc->manager, target.address); 375 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 376 speed, target.address, target.endpoint, size, max_packet_size); 377 378 if (setup_size != 8) 379 return EINVAL; 380 381 usb_transfer_batch_t *batch = 382 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, 383 speed, data, size, setup_data, setup_size, NULL, callback, arg, 384 &hc->manager); 385 if (!batch) 386 return ENOMEM; 387 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 388 batch_control_write(batch); 389 const int ret = hc_schedule(hc, batch); 390 if (ret != EOK) { 391 batch_dispose(batch); 392 } 393 return ret; 398 394 } 399 395 /*----------------------------------------------------------------------------*/ … … 418 414 * @return Error code. 419 415 */ 420 static int control_read(ddf_fun_t *fun, usb_target_t target, 421 size_t max_packet_size, 422 void *setup_data, size_t setup_size, 423 void *data, size_t size, 416 static int control_read( 417 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 418 void *setup_data, size_t setup_size, void *data, size_t size, 424 419 usbhc_iface_transfer_in_callback_t callback, void *arg) 425 420 { 426 assert(fun); 427 hc_t *hc = fun_to_hc(fun); 428 assert(hc); 429 usb_speed_t speed = device_keeper_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 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; 421 assert(fun); 422 hc_t *hc = fun_to_hc(fun); 423 assert(hc); 424 usb_speed_t speed = 425 usb_device_keeper_get_speed(&hc->manager, target.address); 426 427 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 428 speed, target.address, target.endpoint, size, max_packet_size); 429 usb_transfer_batch_t *batch = 430 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, 431 speed, data, size, setup_data, setup_size, callback, NULL, arg, 432 &hc->manager); 433 if (!batch) 434 return ENOMEM; 435 batch_control_read(batch); 436 const int ret = hc_schedule(hc, batch); 437 if (ret != EOK) { 438 batch_dispose(batch); 439 } 440 return ret; 445 441 } 446 442 /*----------------------------------------------------------------------------*/ … … 463 459 464 460 .control_write = control_write, 465 .control_read = control_read 461 .control_read = control_read, 466 462 }; 467 463 -
uspace/drv/ohci/main.c
r361e61b r55e388a1 61 61 { 62 62 assert(fun); 63 device_keeper_t *manager = &fun_to_hc(fun)->manager;64 usb_address_t addr = device_keeper_find(manager, handle);63 usb_device_keeper_t *manager = &fun_to_hc(fun)->manager; 64 usb_address_t addr = usb_device_keeper_find(manager, handle); 65 65 if (addr < 0) { 66 66 return addr; … … 149 149 } 150 150 151 151 152 bool interrupts = false; 153 #ifdef CONFIG_USBHC_NO_INTERRUPTS 154 usb_log_warning("Interrupts disabled in OS config, " \ 155 "falling back to polling.\n"); 156 #else 152 157 ret = pci_enable_interrupts(device); 153 158 if (ret != EOK) { 154 usb_log_warning( 155 "Failed(%d) to enable interrupts, fall back to polling.\n", 156 ret); 159 usb_log_warning("Failed to enable interrupts: %s.\n", 160 str_error(ret)); 161 usb_log_info("HW interrupts not available, " \ 162 "falling back to polling.\n"); 157 163 } else { 158 164 usb_log_debug("Hw interrupts enabled.\n"); 159 165 interrupts = true; 160 166 } 167 #endif 161 168 162 169 ret = hc_init(hcd, hc_fun, device, mem_reg_base, mem_reg_size, interrupts); … … 199 206 int main(int argc, char *argv[]) 200 207 { 201 usb_log_enable(USB_LOG_LEVEL_DE BUG, NAME);208 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 202 209 sleep(5); 203 210 return ddf_driver_main(&ohci_driver); -
uspace/drv/ohci/ohci_regs.h
r361e61b r55e388a1 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
r361e61b r55e388a1 56 56 } 57 57 /*----------------------------------------------------------------------------*/ 58 int rh_request(rh_t *instance, batch_t *request)58 int rh_request(rh_t *instance, usb_transfer_batch_t *request) 59 59 { 60 60 assert(instance); … … 66 66 } 67 67 usb_log_error("Root hub request processing not implemented.\n"); 68 batch_finish(request, ENOTSUP);68 usb_transfer_batch_finish(request, ENOTSUP); 69 69 return EOK; 70 70 } -
uspace/drv/ohci/root_hub.h
r361e61b r55e388a1 49 49 int rh_init(rh_t *instance, ddf_dev_t *dev, ohci_regs_t *regs); 50 50 51 int rh_request(rh_t *instance, batch_t *request);51 int rh_request(rh_t *instance, usb_transfer_batch_t *request); 52 52 53 53 void rh_interrupt(rh_t *instance); -
uspace/drv/uhci-hcd/Makefile
r361e61b r55e388a1 37 37 transfer_list.c \ 38 38 uhci.c \ 39 uhci_hc.c \40 uhci_rh.c \41 uhci_struct/transfer_descriptor.c \39 hc.c \ 40 root_hub.c \ 41 hw_struct/transfer_descriptor.c \ 42 42 pci.c \ 43 43 batch.c -
uspace/drv/uhci-hcd/batch.c
r361e61b r55e388a1 40 40 #include "batch.h" 41 41 #include "transfer_list.h" 42 #include " uhci_hc.h"42 #include "hw_struct/transfer_descriptor.h" 43 43 #include "utils/malloc32.h" 44 #include "uhci_struct/transfer_descriptor.h"45 44 46 45 #define DEFAULT_ERROR_COUNT 3 … … 49 48 qh_t *qh; 50 49 td_t *tds; 51 size_t packets;52 device_keeper_t *manager;50 size_t transfers; 51 usb_device_keeper_t *manager; 53 52 } uhci_batch_t; 54 53 55 static void batch_control( batch_t *instance,54 static void batch_control(usb_transfer_batch_t *instance, 56 55 usb_packet_id data_stage, usb_packet_id status_stage); 57 static void batch_data( batch_t *instance, usb_packet_id pid);58 static void batch_call_in_and_dispose( batch_t *instance);59 static void batch_call_out_and_dispose( batch_t *instance);56 static void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid); 57 static void batch_call_in_and_dispose(usb_transfer_batch_t *instance); 58 static void batch_call_out_and_dispose(usb_transfer_batch_t *instance); 60 59 61 60 … … 65 64 * @param[in] target Device and endpoint target of the transaction. 66 65 * @param[in] transfer_type Interrupt, Control or Bulk. 67 * @param[in] max_packet_size maximum allowed size of data packets.66 * @param[in] max_packet_size maximum allowed size of data transfers. 68 67 * @param[in] speed Speed of the transaction. 69 68 * @param[in] buffer Data source/destination. … … 78 77 * NULL otherwise. 79 78 * 80 * Determines the number of needed packets (TDs). Prepares a transport buffer79 * Determines the number of needed transfers (TDs). Prepares a transport buffer 81 80 * (that is accessible by the hardware). Initializes parameters needed for the 82 81 * transaction and callback. 83 82 */ 84 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,83 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, usb_target_t target, 85 84 usb_transfer_type_t transfer_type, size_t max_packet_size, 86 85 usb_speed_t speed, char *buffer, size_t buffer_size, … … 88 87 usbhc_iface_transfer_in_callback_t func_in, 89 88 usbhc_iface_transfer_out_callback_t func_out, void *arg, 90 device_keeper_t *manager89 usb_device_keeper_t *manager 91 90 ) 92 91 { … … 103 102 } else (void)0 104 103 105 batch_t *instance = malloc(sizeof(batch_t));104 usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t)); 106 105 CHECK_NULL_DISPOSE_RETURN(instance, 107 106 "Failed to allocate batch instance.\n"); 108 batch_init(instance, target, transfer_type, speed, max_packet_size,107 usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size, 109 108 buffer, NULL, buffer_size, NULL, setup_size, func_in, 110 109 func_out, arg, fun, NULL); … … 118 117 instance->private_data = data; 119 118 120 data-> packets = (buffer_size + max_packet_size - 1) / max_packet_size;119 data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size; 121 120 if (transfer_type == USB_TRANSFER_CONTROL) { 122 data-> packets += 2;123 } 124 125 data->tds = malloc32(sizeof(td_t) * data-> packets);121 data->transfers += 2; 122 } 123 124 data->tds = malloc32(sizeof(td_t) * data->transfers); 126 125 CHECK_NULL_DISPOSE_RETURN( 127 126 data->tds, "Failed to allocate transfer descriptors.\n"); 128 bzero(data->tds, sizeof(td_t) * data-> packets);127 bzero(data->tds, sizeof(td_t) * data->transfers); 129 128 130 129 data->qh = malloc32(sizeof(qh_t)); … … 161 160 * is reached. 162 161 */ 163 bool batch_is_complete( batch_t *instance)162 bool batch_is_complete(usb_transfer_batch_t *instance) 164 163 { 165 164 assert(instance); … … 167 166 assert(data); 168 167 169 usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",170 instance, data-> packets);168 usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n", 169 instance, data->transfers); 171 170 instance->transfered_size = 0; 172 171 size_t i = 0; 173 for (;i < data-> packets; ++i) {172 for (;i < data->transfers; ++i) { 174 173 if (td_is_active(&data->tds[i])) { 175 174 return false; … … 182 181 td_print_status(&data->tds[i]); 183 182 184 device_keeper_set_toggle(data->manager,183 usb_device_keeper_set_toggle(data->manager, 185 184 instance->target, instance->direction, 186 185 td_toggle(&data->tds[i])); … … 205 204 * Uses genercir control function with pids OUT and IN. 206 205 */ 207 void batch_control_write( batch_t *instance)206 void batch_control_write(usb_transfer_batch_t *instance) 208 207 { 209 208 assert(instance); … … 222 221 * Uses generic control with pids IN and OUT. 223 222 */ 224 void batch_control_read( batch_t *instance)223 void batch_control_read(usb_transfer_batch_t *instance) 225 224 { 226 225 assert(instance); … … 236 235 * Data transaction with PID_IN. 237 236 */ 238 void batch_interrupt_in( batch_t *instance)237 void batch_interrupt_in(usb_transfer_batch_t *instance) 239 238 { 240 239 assert(instance); … … 251 250 * Data transaction with PID_OUT. 252 251 */ 253 void batch_interrupt_out( batch_t *instance)252 void batch_interrupt_out(usb_transfer_batch_t *instance) 254 253 { 255 254 assert(instance); … … 269 268 * Data transaction with PID_IN. 270 269 */ 271 void batch_bulk_in( batch_t *instance)270 void batch_bulk_in(usb_transfer_batch_t *instance) 272 271 { 273 272 assert(instance); … … 284 283 * Data transaction with PID_OUT. 285 284 */ 286 void batch_bulk_out( batch_t *instance)285 void batch_bulk_out(usb_transfer_batch_t *instance) 287 286 { 288 287 assert(instance); … … 299 298 * 300 299 * @param[in] instance Batch structure to use. 301 * @param[in] pid to use for data packets.300 * @param[in] pid Pid to use for data transfers. 302 301 * 303 302 * Packets with alternating toggle bit and supplied pid value. 304 * The last packetis marked with IOC flag.305 */ 306 void batch_data( batch_t *instance, usb_packet_id pid)303 * The last transfer is marked with IOC flag. 304 */ 305 void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid) 307 306 { 308 307 assert(instance); … … 311 310 312 311 const bool low_speed = instance->speed == USB_SPEED_LOW; 313 int toggle = device_keeper_get_toggle(312 int toggle = usb_device_keeper_get_toggle( 314 313 data->manager, instance->target, instance->direction); 315 314 assert(toggle == 0 || toggle == 1); 316 315 317 size_t packet= 0;316 size_t transfer = 0; 318 317 size_t remain_size = instance->buffer_size; 319 318 while (remain_size > 0) { … … 326 325 remain_size : instance->max_packet_size; 327 326 328 td_t *next_ packet = (packet + 1 < data->packets)329 ? &data->tds[ packet+ 1] : NULL;330 331 assert( packet < data->packets);327 td_t *next_transfer = (transfer + 1 < data->transfers) 328 ? &data->tds[transfer + 1] : NULL; 329 330 assert(transfer < data->transfers); 332 331 assert(packet_size <= remain_size); 333 332 334 333 td_init( 335 &data->tds[ packet], DEFAULT_ERROR_COUNT, packet_size,334 &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size, 336 335 toggle, false, low_speed, instance->target, pid, trans_data, 337 next_ packet);336 next_transfer); 338 337 339 338 340 339 toggle = 1 - toggle; 341 340 remain_size -= packet_size; 342 ++ packet;343 } 344 td_set_ioc(&data->tds[ packet- 1]);345 device_keeper_set_toggle(data->manager, instance->target,341 ++transfer; 342 } 343 td_set_ioc(&data->tds[transfer - 1]); 344 usb_device_keeper_set_toggle(data->manager, instance->target, 346 345 instance->direction, toggle); 347 346 } … … 350 349 * 351 350 * @param[in] instance Batch structure to use. 352 * @param[in] data_stage to use for data packets.353 * @param[in] status_stage to use for data packets.351 * @param[in] data_stage Pid to use for data transfers. 352 * @param[in] status_stage Pid to use for data transfers. 354 353 * 355 354 * Setup stage with toggle 0 and USB_PID_SETUP. 356 355 * Data stage with alternating toggle and pid supplied by parameter. 357 356 * Status stage with toggle 1 and pid supplied by parameter. 358 * The last packetis marked with IOC.359 */ 360 void batch_control( batch_t *instance,357 * The last transfer is marked with IOC. 358 */ 359 void batch_control(usb_transfer_batch_t *instance, 361 360 usb_packet_id data_stage, usb_packet_id status_stage) 362 361 { … … 364 363 uhci_batch_t *data = instance->private_data; 365 364 assert(data); 366 assert(data-> packets >= 2);365 assert(data->transfers >= 2); 367 366 368 367 const bool low_speed = instance->speed == USB_SPEED_LOW; … … 375 374 376 375 /* data stage */ 377 size_t packet= 1;376 size_t transfer = 1; 378 377 size_t remain_size = instance->buffer_size; 379 378 while (remain_size > 0) { … … 389 388 390 389 td_init( 391 &data->tds[ packet], DEFAULT_ERROR_COUNT, packet_size,390 &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size, 392 391 toggle, false, low_speed, instance->target, data_stage, 393 control_data, &data->tds[ packet+ 1]);394 395 ++ packet;396 assert( packet < data->packets);392 control_data, &data->tds[transfer + 1]); 393 394 ++transfer; 395 assert(transfer < data->transfers); 397 396 assert(packet_size <= remain_size); 398 397 remain_size -= packet_size; … … 400 399 401 400 /* status stage */ 402 assert( packet == data->packets - 1);401 assert(transfer == data->transfers - 1); 403 402 404 403 td_init( 405 &data->tds[ packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,404 &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed, 406 405 instance->target, status_stage, NULL, NULL); 407 td_set_ioc(&data->tds[ packet]);406 td_set_ioc(&data->tds[transfer]); 408 407 409 408 usb_log_debug2("Control last TD status: %x.\n", 410 data->tds[ packet].status);411 } 412 /*----------------------------------------------------------------------------*/ 413 qh_t * batch_qh( batch_t *instance)409 data->tds[transfer].status); 410 } 411 /*----------------------------------------------------------------------------*/ 412 qh_t * batch_qh(usb_transfer_batch_t *instance) 414 413 { 415 414 assert(instance); … … 423 422 * @param[in] instance Batch structure to use. 424 423 */ 425 void batch_call_in_and_dispose( batch_t *instance)426 { 427 assert(instance); 428 batch_call_in(instance);424 void batch_call_in_and_dispose(usb_transfer_batch_t *instance) 425 { 426 assert(instance); 427 usb_transfer_batch_call_in(instance); 429 428 batch_dispose(instance); 430 429 } … … 434 433 * @param[in] instance Batch structure to use. 435 434 */ 436 void batch_call_out_and_dispose( batch_t *instance)437 { 438 assert(instance); 439 batch_call_out(instance);435 void batch_call_out_and_dispose(usb_transfer_batch_t *instance) 436 { 437 assert(instance); 438 usb_transfer_batch_call_out(instance); 440 439 batch_dispose(instance); 441 440 } … … 445 444 * @param[in] instance Batch structure to use. 446 445 */ 447 void batch_dispose( batch_t *instance)446 void batch_dispose(usb_transfer_batch_t *instance) 448 447 { 449 448 assert(instance); -
uspace/drv/uhci-hcd/batch.h
r361e61b r55e388a1 42 42 #include <usb/host/batch.h> 43 43 44 #include " uhci_struct/queue_head.h"44 #include "hw_struct/queue_head.h" 45 45 46 batch_t * batch_get(46 usb_transfer_batch_t * batch_get( 47 47 ddf_fun_t *fun, 48 48 usb_target_t target, … … 57 57 usbhc_iface_transfer_out_callback_t func_out, 58 58 void *arg, 59 device_keeper_t *manager59 usb_device_keeper_t *manager 60 60 ); 61 61 62 void batch_dispose( batch_t *instance);62 void batch_dispose(usb_transfer_batch_t *instance); 63 63 64 bool batch_is_complete( batch_t *instance);64 bool batch_is_complete(usb_transfer_batch_t *instance); 65 65 66 void batch_control_write( batch_t *instance);66 void batch_control_write(usb_transfer_batch_t *instance); 67 67 68 void batch_control_read( batch_t *instance);68 void batch_control_read(usb_transfer_batch_t *instance); 69 69 70 void batch_interrupt_in( batch_t *instance);70 void batch_interrupt_in(usb_transfer_batch_t *instance); 71 71 72 void batch_interrupt_out( batch_t *instance);72 void batch_interrupt_out(usb_transfer_batch_t *instance); 73 73 74 void batch_bulk_in( batch_t *instance);74 void batch_bulk_in(usb_transfer_batch_t *instance); 75 75 76 void batch_bulk_out( batch_t *instance);76 void batch_bulk_out(usb_transfer_batch_t *instance); 77 77 78 qh_t * batch_qh( batch_t *instance);78 qh_t * batch_qh(usb_transfer_batch_t *instance); 79 79 #endif 80 80 /** -
uspace/drv/uhci-hcd/iface.c
r361e61b r55e388a1 33 33 */ 34 34 #include <ddf/driver.h> 35 #include < remote_usbhc.h>35 #include <errno.h> 36 36 37 37 #include <usb/debug.h> 38 38 39 #include <errno.h>40 41 39 #include "iface.h" 42 #include " uhci_hc.h"40 #include "hc.h" 43 41 44 42 /** Reserve default address interface function … … 48 46 * @return Error code. 49 47 */ 50 /*----------------------------------------------------------------------------*/51 48 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 52 49 { 53 50 assert(fun); 54 uhci_hc_t *hc = fun_to_uhci_hc(fun);51 hc_t *hc = fun_to_hc(fun); 55 52 assert(hc); 56 53 usb_log_debug("Default address request with speed %d.\n", speed); 57 device_keeper_reserve_default(&hc->device_manager, speed);54 usb_device_keeper_reserve_default_address(&hc->manager, speed); 58 55 return EOK; 59 56 } … … 67 64 { 68 65 assert(fun); 69 uhci_hc_t *hc = fun_to_uhci_hc(fun);66 hc_t *hc = fun_to_hc(fun); 70 67 assert(hc); 71 68 usb_log_debug("Default address release.\n"); 72 device_keeper_release_default(&hc->device_manager);69 usb_device_keeper_release_default_address(&hc->manager); 73 70 return EOK; 74 71 } … … 81 78 * @return Error code. 82 79 */ 83 static int request_address( ddf_fun_t *fun, usb_speed_t speed,84 usb_address_t *address)85 { 86 assert(fun); 87 uhci_hc_t *hc = fun_to_uhci_hc(fun);80 static int request_address( 81 ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address) 82 { 83 assert(fun); 84 hc_t *hc = fun_to_hc(fun); 88 85 assert(hc); 89 86 assert(address); 90 87 91 88 usb_log_debug("Address request with speed %d.\n", speed); 92 *address = device_keeper_ request(&hc->device_manager, speed);89 *address = device_keeper_get_free_address(&hc->manager, speed); 93 90 usb_log_debug("Address request with result: %d.\n", *address); 94 91 if (*address <= 0) 95 92 return *address; 96 93 return EOK; 97 94 } … … 108 105 { 109 106 assert(fun); 110 uhci_hc_t *hc = fun_to_uhci_hc(fun);107 hc_t *hc = fun_to_hc(fun); 111 108 assert(hc); 112 109 usb_log_debug("Address bind %d-%d.\n", address, handle); 113 device_keeper_bind(&hc->device_manager, address, handle);110 usb_device_keeper_bind(&hc->manager, address, handle); 114 111 return EOK; 115 112 } … … 124 121 { 125 122 assert(fun); 126 uhci_hc_t *hc = fun_to_uhci_hc(fun);123 hc_t *hc = fun_to_hc(fun); 127 124 assert(hc); 128 125 usb_log_debug("Address release %d.\n", address); 129 device_keeper_release(&hc->device_manager, address);126 usb_device_keeper_release(&hc->manager, address); 130 127 return EOK; 131 128 } … … 142 139 * @return Error code. 143 140 */ 144 static int interrupt_out(ddf_fun_t *fun, usb_target_t target, 145 size_t max_packet_size, void *data, size_t size, 146 usbhc_iface_transfer_out_callback_t callback, void *arg) 147 { 148 assert(fun); 149 uhci_hc_t *hc = fun_to_uhci_hc(fun); 150 assert(hc); 151 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 141 static int interrupt_out( 142 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 143 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 144 { 145 assert(fun); 146 hc_t *hc = fun_to_hc(fun); 147 assert(hc); 148 usb_speed_t speed = 149 usb_device_keeper_get_speed(&hc->manager, target.address); 152 150 153 151 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 154 152 target.address, target.endpoint, size, max_packet_size); 155 153 156 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,157 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,158 &hc->device_manager);154 usb_transfer_batch_t *batch = 155 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 156 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager); 159 157 if (!batch) 160 158 return ENOMEM; 161 159 batch_interrupt_out(batch); 162 const int ret = uhci_hc_schedule(hc, batch); 163 if (ret != EOK) { 164 batch_dispose(batch); 165 return ret; 166 } 167 return EOK; 160 const int ret = hc_schedule(hc, batch); 161 if (ret != EOK) { 162 batch_dispose(batch); 163 } 164 return ret; 168 165 } 169 166 /*----------------------------------------------------------------------------*/ … … 179 176 * @return Error code. 180 177 */ 181 static int interrupt_in(ddf_fun_t *fun, usb_target_t target, 182 size_t max_packet_size, void *data, size_t size, 183 usbhc_iface_transfer_in_callback_t callback, void *arg) 184 { 185 assert(fun); 186 uhci_hc_t *hc = fun_to_uhci_hc(fun); 187 assert(hc); 188 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 178 static int interrupt_in( 179 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 180 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 181 { 182 assert(fun); 183 hc_t *hc = fun_to_hc(fun); 184 assert(hc); 185 usb_speed_t speed = 186 usb_device_keeper_get_speed(&hc->manager, target.address); 189 187 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 190 188 target.address, target.endpoint, size, max_packet_size); 191 189 192 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,193 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,194 &hc->device_manager);190 usb_transfer_batch_t *batch = 191 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 192 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager); 195 193 if (!batch) 196 194 return ENOMEM; 197 195 batch_interrupt_in(batch); 198 const int ret = uhci_hc_schedule(hc, batch); 199 if (ret != EOK) { 200 batch_dispose(batch); 201 return ret; 202 } 203 return EOK; 196 const int ret = hc_schedule(hc, batch); 197 if (ret != EOK) { 198 batch_dispose(batch); 199 } 200 return ret; 204 201 } 205 202 /*----------------------------------------------------------------------------*/ … … 215 212 * @return Error code. 216 213 */ 217 static int bulk_out(ddf_fun_t *fun, usb_target_t target, 218 size_t max_packet_size, void *data, size_t size, 219 usbhc_iface_transfer_out_callback_t callback, void *arg) 220 { 221 assert(fun); 222 uhci_hc_t *hc = fun_to_uhci_hc(fun); 223 assert(hc); 224 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 214 static int bulk_out( 215 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 216 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 217 { 218 assert(fun); 219 hc_t *hc = fun_to_hc(fun); 220 assert(hc); 221 usb_speed_t speed = 222 usb_device_keeper_get_speed(&hc->manager, target.address); 225 223 226 224 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 227 225 target.address, target.endpoint, size, max_packet_size); 228 226 229 batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,230 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,231 &hc->device_manager);227 usb_transfer_batch_t *batch = 228 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 229 data, size, NULL, 0, NULL, callback, arg, &hc->manager); 232 230 if (!batch) 233 231 return ENOMEM; 234 232 batch_bulk_out(batch); 235 const int ret = uhci_hc_schedule(hc, batch); 236 if (ret != EOK) { 237 batch_dispose(batch); 238 return ret; 239 } 240 return EOK; 233 const int ret = hc_schedule(hc, batch); 234 if (ret != EOK) { 235 batch_dispose(batch); 236 } 237 return ret; 241 238 } 242 239 /*----------------------------------------------------------------------------*/ … … 252 249 * @return Error code. 253 250 */ 254 static int bulk_in(ddf_fun_t *fun, usb_target_t target, 255 size_t max_packet_size, void *data, size_t size, 256 usbhc_iface_transfer_in_callback_t callback, void *arg) 257 { 258 assert(fun); 259 uhci_hc_t *hc = fun_to_uhci_hc(fun); 260 assert(hc); 261 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 251 static int bulk_in( 252 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 253 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 254 { 255 assert(fun); 256 hc_t *hc = fun_to_hc(fun); 257 assert(hc); 258 usb_speed_t speed = 259 usb_device_keeper_get_speed(&hc->manager, target.address); 262 260 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 263 261 target.address, target.endpoint, size, max_packet_size); 264 262 265 batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,266 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,267 &hc->device_manager);263 usb_transfer_batch_t *batch = 264 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 265 data, size, NULL, 0, callback, NULL, arg, &hc->manager); 268 266 if (!batch) 269 267 return ENOMEM; 270 268 batch_bulk_in(batch); 271 const int ret = uhci_hc_schedule(hc, batch); 272 if (ret != EOK) { 273 batch_dispose(batch); 274 return ret; 275 } 276 return EOK; 269 const int ret = hc_schedule(hc, batch); 270 if (ret != EOK) { 271 batch_dispose(batch); 272 } 273 return ret; 277 274 } 278 275 /*----------------------------------------------------------------------------*/ … … 282 279 * @param[in] target USB device to write to. 283 280 * @param[in] max_packet_size maximum size of data packet the device accepts. 284 * @param[in] setup_data Data to send with SETUP packet.285 * @param[in] setup_size Size of data to send with SETUP packet (should be8B).281 * @param[in] setup_data Data to send with SETUP transfer. 282 * @param[in] setup_size Size of data to send with SETUP transfer (always 8B). 286 283 * @param[in] data Source of data. 287 284 * @param[in] size Size of data source. … … 290 287 * @return Error code. 291 288 */ 292 static int control_write( ddf_fun_t *fun, usb_target_t target,293 size_t max_packet_size,289 static int control_write( 290 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 294 291 void *setup_data, size_t setup_size, void *data, size_t size, 295 292 usbhc_iface_transfer_out_callback_t callback, void *arg) 296 293 { 297 294 assert(fun); 298 uhci_hc_t *hc = fun_to_uhci_hc(fun); 299 assert(hc); 300 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 295 hc_t *hc = fun_to_hc(fun); 296 assert(hc); 297 usb_speed_t speed = 298 usb_device_keeper_get_speed(&hc->manager, target.address); 301 299 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 302 300 speed, target.address, target.endpoint, size, max_packet_size); … … 305 303 return EINVAL; 306 304 307 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 308 max_packet_size, speed, data, size, setup_data, setup_size, 309 NULL, callback, arg, &hc->device_manager); 310 if (!batch) 311 return ENOMEM; 312 device_keeper_reset_if_need(&hc->device_manager, target, setup_data); 305 usb_transfer_batch_t *batch = 306 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 307 data, size, setup_data, setup_size, NULL, callback, arg, 308 &hc->manager); 309 if (!batch) 310 return ENOMEM; 311 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 313 312 batch_control_write(batch); 314 const int ret = uhci_hc_schedule(hc, batch); 315 if (ret != EOK) { 316 batch_dispose(batch); 317 return ret; 318 } 319 return EOK; 313 const int ret = hc_schedule(hc, batch); 314 if (ret != EOK) { 315 batch_dispose(batch); 316 } 317 return ret; 320 318 } 321 319 /*----------------------------------------------------------------------------*/ … … 333 331 * @return Error code. 334 332 */ 335 static int control_read( ddf_fun_t *fun, usb_target_t target,336 size_t max_packet_size,333 static int control_read( 334 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 337 335 void *setup_data, size_t setup_size, void *data, size_t size, 338 336 usbhc_iface_transfer_in_callback_t callback, void *arg) 339 337 { 340 338 assert(fun); 341 uhci_hc_t *hc = fun_to_uhci_hc(fun); 342 assert(hc); 343 usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address); 339 hc_t *hc = fun_to_hc(fun); 340 assert(hc); 341 usb_speed_t speed = 342 usb_device_keeper_get_speed(&hc->manager, target.address); 344 343 345 344 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 346 345 speed, target.address, target.endpoint, size, max_packet_size); 347 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 348 max_packet_size, speed, data, size, setup_data, setup_size, callback, 349 NULL, arg, &hc->device_manager); 346 usb_transfer_batch_t *batch = 347 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 348 data, size, setup_data, setup_size, callback, NULL, arg, 349 &hc->manager); 350 350 if (!batch) 351 351 return ENOMEM; 352 352 batch_control_read(batch); 353 const int ret = uhci_hc_schedule(hc, batch); 354 if (ret != EOK) { 355 batch_dispose(batch); 356 return ret; 357 } 358 return EOK; 359 } 360 /*----------------------------------------------------------------------------*/ 361 usbhc_iface_t uhci_hc_iface = { 353 const int ret = hc_schedule(hc, batch); 354 if (ret != EOK) { 355 batch_dispose(batch); 356 } 357 return ret; 358 } 359 /*----------------------------------------------------------------------------*/ 360 usbhc_iface_t hc_iface = { 362 361 .reserve_default_address = reserve_default_address, 363 362 .release_default_address = release_default_address, … … 369 368 .interrupt_in = interrupt_in, 370 369 370 .bulk_out = bulk_out, 371 371 .bulk_in = bulk_in, 372 .bulk_out = bulk_out, 373 372 373 .control_write = control_write, 374 374 .control_read = control_read, 375 .control_write = control_write,376 375 }; 377 376 /** -
uspace/drv/uhci-hcd/iface.h
r361e61b r55e388a1 38 38 #include <usbhc_iface.h> 39 39 40 extern usbhc_iface_t uhci_hc_iface;40 extern usbhc_iface_t hc_iface; 41 41 42 42 #endif -
uspace/drv/uhci-hcd/main.c
r361e61b r55e388a1 62 62 int uhci_add_device(ddf_dev_t *device) 63 63 { 64 usb_log_ info("uhci_add_device() called\n");64 usb_log_debug("uhci_add_device() called\n"); 65 65 assert(device); 66 66 uhci_t *uhci = malloc(sizeof(uhci_t)); … … 72 72 int ret = uhci_init(uhci, device); 73 73 if (ret != EOK) { 74 usb_log_error("Failed to initialzie UHCI driver.\n"); 74 usb_log_error("Failed to initialize UHCI driver: %s.\n", 75 str_error(ret)); 75 76 return ret; 76 77 } 77 78 device->driver_data = uhci; 79 80 usb_log_info("Controlling new UHCI device `%s'.\n", device->name); 81 78 82 return EOK; 79 83 } … … 89 93 int main(int argc, char *argv[]) 90 94 { 95 printf(NAME ": HelenOS UHCI driver.\n"); 96 91 97 sleep(3); /* TODO: remove in final version */ 92 usb_log_enable(USB_LOG_LEVEL_DE BUG, NAME);98 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 93 99 94 100 return ddf_driver_main(&uhci_driver); -
uspace/drv/uhci-hcd/transfer_list.c
r361e61b r55e388a1 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. … … 79 79 if (!instance->queue_head) 80 80 return; 81 /* Set both next and element to point to the same QH*/81 /* Set both queue_head.next to point to the follower */ 82 82 qh_set_next_qh(instance->queue_head, next->queue_head_pa); 83 qh_set_element_qh(instance->queue_head, next->queue_head_pa);84 83 } 85 84 /*----------------------------------------------------------------------------*/ … … 92 91 * The batch is added to the end of the list and queue. 93 92 */ 94 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch) 93 void transfer_list_add_batch( 94 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(batch));101 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);102 103 /* New batch will be added to the end of the current list104 * so set the link accordingly */105 qh_set_next_qh(batch_qh(batch), instance->queue_head->next);106 107 100 fibril_mutex_lock(&instance->guard); 108 101 102 qh_t *last_qh = NULL; 109 103 /* Add to the hardware queue. */ 110 104 if (list_empty(&instance->batch_list)) { 111 105 /* There is nothing scheduled */ 112 qh_t *qh = instance->queue_head; 113 assert(qh->element == qh->next); 114 qh_set_element_qh(qh, pa); 106 last_qh = instance->queue_head; 115 107 } else { 116 108 /* There is something scheduled */ 117 batch_t *last = list_get_instance( 118 instance->batch_list.prev, batch_t, link); 119 qh_set_next_qh(batch_qh(last), pa); 120 } 109 usb_transfer_batch_t *last = list_get_instance( 110 instance->batch_list.prev, usb_transfer_batch_t, link); 111 last_qh = batch_qh(last); 112 } 113 const uint32_t pa = addr_to_phys(batch_qh(batch)); 114 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 115 116 /* keep link */ 117 batch_qh(batch)->next = last_qh->next; 118 qh_set_next_qh(last_qh, pa); 119 121 120 /* Add to the driver list */ 122 121 list_append(&batch->link, &instance->batch_list); 123 122 124 batch_t *first = list_get_instance(125 instance->batch_list.next, batch_t, link);123 usb_transfer_batch_t *first = list_get_instance( 124 instance->batch_list.next, usb_transfer_batch_t, link); 126 125 usb_log_debug("Batch(%p) added to queue %s, first is %p.\n", 127 126 batch, instance->name, first); … … 148 147 while (current != &instance->batch_list) { 149 148 link_t *next = current->next; 150 batch_t *batch = list_get_instance(current, batch_t, link); 149 usb_transfer_batch_t *batch = 150 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 = 165 list_get_instance(item, usb_transfer_batch_t, link); 165 166 batch->next_step(batch); 166 167 } … … 174 175 { 175 176 fibril_mutex_lock(&instance->guard); 176 while ( list_empty(&instance->batch_list)) {177 while (!list_empty(&instance->batch_list)) { 177 178 link_t *current = instance->batch_list.next; 178 batch_t *batch = list_get_instance(current, batch_t, link); 179 usb_transfer_batch_t *batch = 180 list_get_instance(current, usb_transfer_batch_t, link); 179 181 transfer_list_remove_batch(instance, batch); 180 batch_finish(batch, EIO);182 usb_transfer_batch_finish(batch, EIO); 181 183 } 182 184 fibril_mutex_unlock(&instance->guard); … … 191 193 * Does not lock the transfer list, caller is responsible for that. 192 194 */ 193 void transfer_list_remove_batch(transfer_list_t *instance, batch_t *batch) 195 void transfer_list_remove_batch( 196 transfer_list_t *instance, usb_transfer_batch_t *batch) 194 197 { 195 198 assert(instance); … … 197 200 assert(batch); 198 201 assert(batch_qh(batch)); 202 assert(fibril_mutex_is_locked(&instance->guard)); 203 199 204 usb_log_debug2( 200 205 "Queue %s: removing batch(%p).\n", instance->name, batch); 201 206 202 const char * 207 const char *qpos = NULL; 203 208 /* Remove from the hardware queue */ 204 if ( batch->link.prev == &instance->batch_list) {209 if (instance->batch_list.next == &batch->link) { 205 210 /* I'm the first one here */ 206 qh_set_element_qh(instance->queue_head, batch_qh(batch)->next); 207 pos = "FIRST"; 211 assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK) 212 == addr_to_phys(batch_qh(batch))); 213 instance->queue_head->next = batch_qh(batch)->next; 214 qpos = "FIRST"; 208 215 } else { 209 batch_t *prev = 210 list_get_instance(batch->link.prev, batch_t, link); 211 qh_set_next_qh(batch_qh(prev), batch_qh(batch)->next); 212 pos = "NOT FIRST"; 213 } 214 /* Remove from the driver list */ 216 usb_transfer_batch_t *prev = 217 list_get_instance( 218 batch->link.prev, usb_transfer_batch_t, link); 219 assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK) 220 == addr_to_phys(batch_qh(batch))); 221 batch_qh(prev)->next = batch_qh(batch)->next; 222 qpos = "NOT FIRST"; 223 } 224 /* Remove from the batch list */ 215 225 list_remove(&batch->link); 216 usb_log_debug("Batch(%p) removed (%s) from %s, next element%x.\n",217 batch, pos, instance->name, batch_qh(batch)->next);226 usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n", 227 batch, qpos, instance->name, batch_qh(batch)->next); 218 228 } 219 229 /** -
uspace/drv/uhci-hcd/transfer_list.h
r361e61b r55e388a1 37 37 #include <fibril_synch.h> 38 38 39 #include "uhci_struct/queue_head.h"40 41 39 #include "batch.h" 40 #include "hw_struct/queue_head.h" 42 41 43 42 typedef struct transfer_list … … 66 65 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next); 67 66 68 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch);67 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch); 69 68 70 69 void transfer_list_remove_finished(transfer_list_t *instance); -
uspace/drv/uhci-hcd/uhci.c
r361e61b r55e388a1 54 54 { 55 55 assert(dev); 56 uhci_hc_t *hc = &((uhci_t*)dev->driver_data)->hc;56 hc_t *hc = &((uhci_t*)dev->driver_data)->hc; 57 57 uint16_t status = IPC_GET_ARG1(*call); 58 58 assert(hc); 59 uhci_hc_interrupt(hc, status);59 hc_interrupt(hc, status); 60 60 } 61 61 /*----------------------------------------------------------------------------*/ … … 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.manager; 73 74 usb_address_t addr = usb_device_keeper_find(manager, handle); 75 75 if (addr < 0) { 76 76 return addr; … … 107 107 }; 108 108 /*----------------------------------------------------------------------------*/ 109 static ddf_dev_ops_t uhci_hc_ops = {109 static ddf_dev_ops_t hc_ops = { 110 110 .interfaces[USB_DEV_IFACE] = &usb_iface, 111 .interfaces[USBHC_DEV_IFACE] = & uhci_hc_iface, /* see iface.h/c */111 .interfaces[USBHC_DEV_IFACE] = &hc_iface, /* see iface.h/c */ 112 112 }; 113 113 /*----------------------------------------------------------------------------*/ … … 120 120 { 121 121 assert(fun); 122 return &(( uhci_rh_t*)fun->driver_data)->resource_list;122 return &((rh_t*)fun->driver_data)->resource_list; 123 123 } 124 124 /*----------------------------------------------------------------------------*/ … … 128 128 }; 129 129 /*----------------------------------------------------------------------------*/ 130 static ddf_dev_ops_t uhci_rh_ops = {130 static ddf_dev_ops_t rh_ops = { 131 131 .interfaces[USB_DEV_IFACE] = &usb_iface, 132 132 .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface … … 167 167 CHECK_RET_DEST_FUN_RETURN(ret, 168 168 "Failed(%d) to get I/O addresses:.\n", ret, device->handle); 169 usb_log_ info("I/O regs at 0x%X (size %zu), IRQ %d.\n",169 usb_log_debug("I/O regs at 0x%X (size %zu), IRQ %d.\n", 170 170 io_reg_base, io_reg_size, irq); 171 171 … … 175 175 176 176 bool interrupts = false; 177 #ifdef CONFIG_USBHC_NO_INTERRUPTS 178 usb_log_warning("Interrupts disabled in OS config, " \ 179 "falling back to polling.\n"); 180 #else 177 181 ret = pci_enable_interrupts(device); 178 182 if (ret != EOK) { 179 usb_log_warning( 180 "Failed(%d) to enable interrupts, fall back to polling.\n", 181 ret); 183 usb_log_warning("Failed to enable interrupts: %s.\n", 184 str_error(ret)); 185 usb_log_info("HW interrupts not available, " \ 186 "falling back to polling.\n"); 182 187 } else { 183 188 usb_log_debug("Hw interrupts enabled.\n"); 184 189 interrupts = true; 185 190 } 191 #endif 186 192 187 193 instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc"); … … 190 196 "Failed(%d) to create HC function.\n", ret); 191 197 192 ret = uhci_hc_init(&instance->hc, instance->hc_fun,198 ret = hc_init(&instance->hc, instance->hc_fun, 193 199 (void*)io_reg_base, io_reg_size, interrupts); 194 200 CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init uhci-hcd.\n", ret); 195 instance->hc_fun->ops = & uhci_hc_ops;201 instance->hc_fun->ops = &hc_ops; 196 202 instance->hc_fun->driver_data = &instance->hc; 197 203 ret = ddf_fun_bind(instance->hc_fun); … … 208 214 if (instance->rh_fun) \ 209 215 ddf_fun_destroy(instance->rh_fun); \ 210 uhci_hc_fini(&instance->hc); \216 hc_fini(&instance->hc); \ 211 217 return ret; \ 212 218 } … … 223 229 "Failed(%d) to create root hub function.\n", ret); 224 230 225 ret = uhci_rh_init(&instance->rh, instance->rh_fun,231 ret = rh_init(&instance->rh, instance->rh_fun, 226 232 (uintptr_t)instance->hc.registers + 0x10, 4); 227 233 CHECK_RET_FINI_RETURN(ret, 228 234 "Failed(%d) to setup UHCI root hub.\n", ret); 229 235 230 instance->rh_fun->ops = & uhci_rh_ops;236 instance->rh_fun->ops = &rh_ops; 231 237 instance->rh_fun->driver_data = &instance->rh; 232 238 ret = ddf_fun_bind(instance->rh_fun); -
uspace/drv/uhci-hcd/uhci.h
r361e61b r55e388a1 38 38 #include <ddf/driver.h> 39 39 40 #include " uhci_hc.h"41 #include " uhci_rh.h"40 #include "hc.h" 41 #include "root_hub.h" 42 42 43 43 typedef struct uhci { … … 45 45 ddf_fun_t *rh_fun; 46 46 47 uhci_hc_t hc;48 uhci_rh_t rh;47 hc_t hc; 48 rh_t rh; 49 49 } uhci_t; 50 50 -
uspace/drv/uhci-hcd/utils/malloc32.h
r361e61b r55e388a1 50 50 static inline uintptr_t addr_to_phys(void *addr) 51 51 { 52 if (addr == NULL) 53 return 0; 54 52 55 uintptr_t result; 53 56 int ret = as_get_physical_mapping(addr, &result); -
uspace/drv/uhci-rhd/main.c
r361e61b r55e388a1 36 36 #include <device/hw_res.h> 37 37 #include <errno.h> 38 #include <str_error.h> 38 39 #include <usb_iface.h> 39 40 #include <usb/ddfiface.h> … … 86 87 int ret = hc_get_my_registers(device, &io_regs, &io_size); 87 88 if (ret != EOK) { 88 usb_log_error("Failed (%d) to get registers from parent hc.",89 ret);90 } 91 usb_log_ info("I/O regs at %#X (size %zu).\n", io_regs, io_size);89 usb_log_error("Failed to get registers from parent HC: %s.\n", 90 str_error(ret)); 91 } 92 usb_log_debug("I/O regs at %#X (size %zu).\n", io_regs, io_size); 92 93 93 94 uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t)); … … 99 100 ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device); 100 101 if (ret != EOK) { 101 usb_log_error("Failed(%d) to initialize driver instance.\n", ret); 102 usb_log_error("Failed to initialize driver instance: %s.\n", 103 str_error(ret)); 102 104 free(rh); 103 105 return ret; … … 105 107 106 108 device->driver_data = rh; 107 usb_log_info(" Sucessfully initialized driver instance for device:%d.\n",108 device-> handle);109 usb_log_info("Controlling root hub `%s' (%llu).\n", 110 device->name, device->handle); 109 111 return EOK; 110 112 } … … 129 131 int main(int argc, char *argv[]) 130 132 { 131 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 133 printf(NAME ": HelenOS UHCI root hub driver.\n"); 134 135 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 136 132 137 return ddf_driver_main(&uhci_rh_driver); 133 138 } -
uspace/drv/uhci-rhd/port.c
r361e61b r55e388a1 256 256 assert(usb_hc_connection_is_opened(&port->hc_connection)); 257 257 258 usb_log_ info("%s: Detected new device.\n", port->id_string);258 usb_log_debug("%s: Detected new device.\n", port->id_string); 259 259 260 260 usb_address_t dev_addr; … … 270 270 } 271 271 272 usb_log_info(" %s: New device has address %d (handle %zu).\n",273 port-> id_string, dev_addr, port->attached_device);272 usb_log_info("New device at port %u, address %d (handle %llu).\n", 273 port->number, dev_addr, port->attached_device); 274 274 275 275 return EOK; … … 315 315 uhci_port_write_status(port, port_status); 316 316 317 usb_log_ info("%s: %sabled port.\n",317 usb_log_debug("%s: %sabled port.\n", 318 318 port->id_string, enabled ? "En" : "Dis"); 319 319 return EOK; -
uspace/drv/usbflbk/main.c
r361e61b r55e388a1 86 86 int main(int argc, char *argv[]) 87 87 { 88 usb_log_enable(USB_LOG_LEVEL_DE BUG, NAME);88 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 89 89 90 90 return usb_driver_main(&usbfallback_driver); -
uspace/drv/usbhid/hiddev.c
r361e61b r55e388a1 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 */ … … 192 192 assert(hid_dev != NULL); 193 193 194 usb_log_ info("Processing descriptors...\n");194 usb_log_debug("Processing descriptors...\n"); 195 195 196 196 int rc; … … 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 * … … 368 368 usb_endpoint_description_t *poll_ep_desc) 369 369 { 370 usb_log_ info("Initializing HID device structure.\n");370 usb_log_debug("Initializing HID device structure.\n"); 371 371 372 372 if (hid_dev == NULL) { … … 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: " … … 454 454 455 455 hid_dev->initialized = 1; 456 usb_log_ info("HID device structure initialized.\n");456 usb_log_debug("HID device structure initialized.\n"); 457 457 458 458 return EOK; -
uspace/drv/usbhid/hiddev.h
r361e61b r55e388a1 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
r361e61b r55e388a1 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
r361e61b r55e388a1 662 662 int rc; 663 663 664 usb_log_ info("Initializing HID/KBD structure...\n");664 usb_log_debug("Initializing HID/KBD structure...\n"); 665 665 666 666 if (kbd_dev == NULL) { … … 742 742 743 743 kbd_dev->initialized = USBHID_KBD_STATUS_INITIALIZED; 744 usb_log_ info("HID/KBD device structure initialized.\n");744 usb_log_debug("HID/KBD device structure initialized.\n"); 745 745 746 746 return EOK; … … 769 769 size_t actual_size; 770 770 771 usb_log_ info("Polling keyboard...\n");771 usb_log_debug("Polling keyboard...\n"); 772 772 773 773 if (!kbd_dev->initialized) { … … 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 … … 907 907 * Initialize device (get and process descriptors, get address, etc.) 908 908 */ 909 usb_log_ info("Initializing USB/HID KBD device...\n");909 usb_log_debug("Initializing USB/HID KBD device...\n"); 910 910 911 911 usbhid_kbd_t *kbd_dev = usbhid_kbd_new(); … … 926 926 } 927 927 928 usb_log_ info("USB/HID KBD device structure initialized.\n");928 usb_log_debug("USB/HID KBD device structure initialized.\n"); 929 929 930 930 /* … … 937 937 rc = ddf_fun_bind(kbd_fun); 938 938 if (rc != EOK) { 939 usb_log_error("Could not bind DDF function.\n"); 939 usb_log_error("Could not bind DDF function: %s.\n", 940 str_error(rc)); 940 941 // TODO: Can / should I destroy the DDF function? 941 942 ddf_fun_destroy(kbd_fun); … … 946 947 rc = ddf_fun_add_to_class(kbd_fun, "keyboard"); 947 948 if (rc != EOK) { 948 usb_log_error("Could not add DDF function to class 'keyboard'" 949 "\n"); 949 usb_log_error( 950 "Could not add DDF function to class 'keyboard': %s.\n", 951 str_error(rc)); 950 952 // TODO: Can / should I destroy the DDF function? 951 953 ddf_fun_destroy(kbd_fun); … … 959 961 fid_t fid = fibril_create(usbhid_kbd_fibril, kbd_dev); 960 962 if (fid == 0) { 961 usb_log_error("Failed to start fibril for KBD device\n"); 963 usb_log_error("Failed to start fibril for `%s' device.\n", 964 dev->name); 962 965 return ENOMEM; 963 966 } -
uspace/drv/usbhid/main.c
r361e61b r55e388a1 39 39 #include <usb/debug.h> 40 40 #include <errno.h> 41 #include <str_error.h> 41 42 42 43 #include "kbddev.h" … … 64 65 65 66 if (rc != EOK) { 66 usb_log_info("Device is not a supported keyboard.\n"); 67 usb_log_error("Failed to add HID device.\n"); 68 return EREFUSED; 67 usb_log_warning("Device is not a supported keyboard.\n"); 68 usb_log_error("Failed to add HID device: %s.\n", 69 str_error(rc)); 70 return rc; 69 71 } 70 72 73 usb_log_info("Keyboard `%s' ready to use.\n", dev->name); 74 71 75 return EOK; 72 76 } … … 89 93 int main(int argc, char *argv[]) 90 94 { 91 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 95 printf(NAME ": HelenOS USB HID driver.\n"); 96 97 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 98 92 99 return ddf_driver_main(&kbd_driver); 93 100 } -
uspace/drv/usbhub/main.c
r361e61b r55e388a1 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 { 67 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 68 usb_log_info("starting hub driver\n"); 76 printf(NAME ": HelenOS USB hub driver.\n"); 69 77 78 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 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
r361e61b r55e388a1 132 132 return opResult; 133 133 } 134 usb_log_ info("setting port count to %d\n",descriptor->ports_count);134 usb_log_debug("setting port count to %d\n",descriptor->ports_count); 135 135 hub_info->port_count = descriptor->ports_count; 136 136 hub_info->attached_devs = (usb_hc_attached_device_t*) … … 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 } 167 usb_log_info("hub has %d configurations\n", 168 std_descriptor.configuration_count); 169 if(std_descriptor.configuration_count<1){ 159 usb_standard_device_descriptor_t *std_descriptor 160 = &hub_info->usb_device->descriptors.device; 161 usb_log_debug("hub has %d configurations\n", 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 } … … 301 290 //if this hub already uses default address, it cannot request it once more 302 291 if(hub->is_default_address_used) return; 303 usb_log_ info("some connection changed\n");292 usb_log_debug("some connection changed\n"); 304 293 assert(hub->control_pipe->hc_phone); 305 294 int opResult = usb_hub_clear_port_feature(hub->control_pipe, … … 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), … … 344 333 345 334 int opResult; 346 usb_log_ info("finalizing add device\n");335 usb_log_debug("finalizing add device\n"); 347 336 opResult = usb_hub_clear_port_feature(hub->control_pipe, 348 337 port, USB_HUB_FEATURE_C_PORT_RESET); … … 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. */ … … 376 365 return; 377 366 } 378 usb_log_ info("setting new address %d\n",new_device_address);367 usb_log_debug("setting new address %d\n",new_device_address); 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); … … 416 405 return; 417 406 } 418 usb_log_info("new device address %d, handle %zu\n", 407 usb_log_info("Detected new device on `%s' (port %d), " \ 408 "address %d (handle %llu).\n", 409 hub->usb_device->ddf_dev->name, (int) port, 419 410 new_device_address, child_handle); 420 421 411 } 422 412 … … 488 478 usb_log_debug("interrupt at port %d\n", port); 489 479 //determine type of change 490 usb_ endpoint_pipe_t *pipe = hub->control_pipe;480 usb_pipe_t *pipe = hub->control_pipe; 491 481 492 482 int opResult; … … 499 489 //endpoint 0 500 490 501 opResult = usb_ endpoint_pipe_control_read(491 opResult = usb_pipe_control_read( 502 492 pipe, 503 493 &request, sizeof(usb_device_request_setup_packet_t), … … 515 505 if (usb_port_connect_change(&status)) { 516 506 if (usb_port_dev_connected(&status)) { 517 usb_log_ info("some connection changed\n");507 usb_log_debug("some connection changed\n"); 518 508 usb_hub_init_add_device(hub, port, usb_port_speed(&status)); 519 509 } else { … … 527 517 usb_hub_over_current(hub,port); 528 518 }else{ 529 usb_log_ info("over current condition was auto-resolved on port %d\n",519 usb_log_debug("over current condition was auto-resolved on port %d\n", 530 520 port); 531 521 } … … 533 523 //port reset 534 524 if (usb_port_reset_completed(&status)) { 535 usb_log_ info("port reset complete");525 usb_log_debug("port reset complete\n"); 536 526 if (usb_port_enabled(&status)) { 537 527 usb_hub_finalize_add_device(hub, port, usb_port_speed(&status)); … … 560 550 int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){ 561 551 int opResult; 562 opResult = usb_ endpoint_pipe_start_session(552 opResult = usb_pipe_start_session( 563 553 hub_info->status_change_pipe); 564 554 if(opResult != EOK){ … … 578 568 * Send the request. 579 569 */ 580 opResult = usb_ endpoint_pipe_read(570 opResult = usb_pipe_read( 581 571 hub_info->status_change_pipe, 582 572 change_bitmap, byte_length, &actual_size … … 586 576 free(change_bitmap); 587 577 usb_log_warning("something went wrong while getting status of hub\n"); 588 usb_ endpoint_pipe_end_session(hub_info->status_change_pipe);578 usb_pipe_end_session(hub_info->status_change_pipe); 589 579 return opResult; 590 580 } 591 581 unsigned int port; 592 opResult = usb_ endpoint_pipe_start_session(hub_info->control_pipe);582 opResult = usb_pipe_start_session(hub_info->control_pipe); 593 583 if(opResult!=EOK){ 594 584 usb_log_error("could not start control pipe session %d\n", opResult); 595 usb_ endpoint_pipe_end_session(hub_info->status_change_pipe);585 usb_pipe_end_session(hub_info->status_change_pipe); 596 586 return opResult; 597 587 } … … 600 590 usb_log_error("could not start host controller session %d\n", 601 591 opResult); 602 usb_ endpoint_pipe_end_session(hub_info->control_pipe);603 usb_ endpoint_pipe_end_session(hub_info->status_change_pipe);592 usb_pipe_end_session(hub_info->control_pipe); 593 usb_pipe_end_session(hub_info->status_change_pipe); 604 594 return opResult; 605 595 } … … 615 605 } 616 606 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);607 usb_pipe_end_session(hub_info->control_pipe); 608 usb_pipe_end_session(hub_info->status_change_pipe); 619 609 free(change_bitmap); 620 610 return EOK; -
uspace/drv/usbhub/usbhub.h
r361e61b r55e388a1 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
r361e61b r55e388a1 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
r361e61b r55e388a1 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", … … 106 106 printf(NAME ": USB multi interface device driver.\n"); 107 107 108 usb_log_enable(USB_LOG_LEVEL_ INFO, NAME);108 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 109 109 return ddf_driver_main(&mid_driver); 110 110 } -
uspace/drv/usbmid/usbmid.c
r361e61b r55e388a1 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
r361e61b r55e388a1 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
r361e61b r55e388a1 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 -
uspace/drv/usbmouse/main.c
r361e61b r55e388a1 90 90 int main(int argc, char *argv[]) 91 91 { 92 usb_log_enable(USB_LOG_LEVEL_DE BUG, NAME);92 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 93 93 94 94 return usb_driver_main(&mouse_driver); -
uspace/drv/vhc/hcd.c
r361e61b r55e388a1 122 122 //sleep(5); 123 123 124 usb_log_enable(USB_LOG_LEVEL_DE BUG, NAME);124 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 125 125 126 126 printf(NAME ": virtual USB host controller driver.\n"); -
uspace/lib/usb/include/usb/debug.h
r361e61b r55e388a1 79 79 } usb_log_level_t; 80 80 81 /** Default log level. */ 82 #define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_DEBUG 83 81 84 82 85 void usb_log_enable(usb_log_level_t, const char *); -
uspace/lib/usb/include/usb/devdrv.h
r361e61b r55e388a1 38 38 #include <usb/pipes.h> 39 39 40 /** Descriptors for USB device. */ 41 typedef struct { 42 /** Standard device descriptor. */ 43 usb_standard_device_descriptor_t device; 44 /** Full configuration descriptor of current configuration. */ 45 uint8_t *configuration; 46 size_t configuration_size; 47 } usb_device_descriptors_t; 48 40 49 /** USB device structure. */ 41 50 typedef struct { 42 51 /** The default control pipe. */ 43 usb_ endpoint_pipe_t ctrl_pipe;52 usb_pipe_t ctrl_pipe; 44 53 /** Other endpoint pipes. 45 54 * This is an array of other endpoint pipes in the same order as … … 52 61 */ 53 62 int interface_no; 63 64 /** Some useful descriptors. */ 65 usb_device_descriptors_t descriptors; 66 54 67 /** Generic DDF device backing this one. */ 55 68 ddf_dev_t *ddf_dev; -
uspace/lib/usb/include/usb/host/batch.h
r361e61b r55e388a1 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup libusb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver USB transaction structure32 * USB transfer transaction structures. 33 33 */ 34 34 #ifndef LIBUSB_HOST_BATCH_H … … 40 40 #include <usb/usb.h> 41 41 42 typedef struct batch43 {42 typedef struct usb_transfer_batch usb_transfer_batch_t; 43 struct usb_transfer_batch { 44 44 link_t link; 45 45 usb_target_t target; … … 56 56 size_t max_packet_size; 57 57 size_t transfered_size; 58 void (*next_step)( struct batch*);58 void (*next_step)(usb_transfer_batch_t *); 59 59 int error; 60 60 ddf_fun_t *fun; 61 61 void *arg; 62 62 void *private_data; 63 } batch_t;63 }; 64 64 65 void batch_init(66 batch_t *instance,65 void usb_transfer_batch_init( 66 usb_transfer_batch_t *instance, 67 67 usb_target_t target, 68 68 usb_transfer_type_t transfer_type, … … 81 81 ); 82 82 83 static inline batch_t *batch_from_link(link_t *link_ptr)83 static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l) 84 84 { 85 assert(l ink_ptr);86 return list_get_instance(l ink_ptr,batch_t, link);85 assert(l); 86 return list_get_instance(l, usb_transfer_batch_t, link); 87 87 } 88 88 89 void batch_call_in(batch_t *instance); 90 void batch_call_out(batch_t *instance); 91 void batch_finish(batch_t *instance, int error); 89 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance); 90 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance); 91 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error); 92 92 93 #endif 93 94 /** -
uspace/lib/usb/include/usb/host/device_keeper.h
r361e61b r55e388a1 31 31 */ 32 32 /** @file 33 * @brief UHCI driver 33 * Device keeper structure and functions. 34 * 35 * Typical USB host controller needs to keep track of various settings for 36 * each device that is connected to it. 37 * State of toggle bit, device speed etc. etc. 38 * This structure shall simplify the management. 34 39 */ 35 40 #ifndef LIBUSB_HOST_DEVICE_KEEPER_H … … 39 44 #include <usb/usb.h> 40 45 46 /** Number of USB address for array dimensions. */ 41 47 #define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1) 42 48 49 /** Information about attached USB device. */ 43 50 struct usb_device_info { 44 51 usb_speed_t speed; … … 48 55 }; 49 56 50 typedef struct device_keeper { 57 /** Host controller device keeper. 58 * You shall not access members directly but only using functions below. 59 */ 60 typedef struct { 51 61 struct usb_device_info devices[USB_ADDRESS_COUNT]; 52 62 fibril_mutex_t guard; 53 63 fibril_condvar_t default_address_occupied; 54 64 usb_address_t last_address; 55 } device_keeper_t;65 } usb_device_keeper_t; 56 66 57 void device_keeper_init(device_keeper_t *instance);67 void usb_device_keeper_init(usb_device_keeper_t *instance); 58 68 59 void device_keeper_reserve_default(60 device_keeper_t *instance,usb_speed_t speed);69 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance, 70 usb_speed_t speed); 61 71 62 void device_keeper_release_default(device_keeper_t *instance);72 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance); 63 73 64 void device_keeper_reset_if_need(65 device_keeper_t *instance,usb_target_t target,66 const u nsigned char*setup_data);74 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance, 75 usb_target_t target, 76 const uint8_t *setup_data); 67 77 68 int device_keeper_get_toggle(69 device_keeper_t *instance,usb_target_t target, usb_direction_t direction);78 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance, 79 usb_target_t target, usb_direction_t direction); 70 80 71 int device_keeper_set_toggle(device_keeper_t *instance,81 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance, 72 82 usb_target_t target, usb_direction_t direction, bool toggle); 73 83 74 usb_address_t device_keeper_ request(75 device_keeper_t *instance,usb_speed_t speed);84 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance, 85 usb_speed_t speed); 76 86 77 void device_keeper_bind(78 device_keeper_t *instance,usb_address_t address, devman_handle_t handle);87 void usb_device_keeper_bind(usb_device_keeper_t *instance, 88 usb_address_t address, devman_handle_t handle); 79 89 80 void device_keeper_release(device_keeper_t *instance, usb_address_t address); 90 void usb_device_keeper_release(usb_device_keeper_t *instance, 91 usb_address_t address); 81 92 82 usb_address_t device_keeper_find(83 dev ice_keeper_t *instance, devman_handle_t handle);93 usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance, 94 devman_handle_t handle); 84 95 85 usb_speed_t device_keeper_speed( 86 device_keeper_t *instance, usb_address_t address); 96 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 97 usb_address_t address); 98 87 99 #endif 88 100 /** -
uspace/lib/usb/include/usb/pipes.h
r361e61b r55e388a1 80 80 */ 81 81 int hc_phone; 82 } usb_ endpoint_pipe_t;82 } usb_pipe_t; 83 83 84 84 … … 102 102 typedef struct { 103 103 /** Endpoint pipe. */ 104 usb_ endpoint_pipe_t *pipe;104 usb_pipe_t *pipe; 105 105 /** Endpoint description. */ 106 106 const usb_endpoint_description_t *description; … … 125 125 usb_address_t usb_device_get_assigned_address(devman_handle_t); 126 126 127 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *, 128 usb_device_connection_t *, 127 int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *, 129 128 usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t); 130 int usb_ endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *,129 int usb_pipe_initialize_default_control(usb_pipe_t *, 131 130 usb_device_connection_t *); 132 int usb_ endpoint_pipe_probe_default_control(usb_endpoint_pipe_t *);133 int usb_ endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,131 int usb_pipe_probe_default_control(usb_pipe_t *); 132 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *, 134 133 size_t, uint8_t *, size_t, usb_device_connection_t *); 135 int usb_endpoint_pipe_register(usb_endpoint_pipe_t *, unsigned int, 136 usb_hc_connection_t *); 137 int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *, usb_hc_connection_t *); 134 int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *); 135 int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *); 138 136 139 int usb_ endpoint_pipe_start_session(usb_endpoint_pipe_t *);140 int usb_ endpoint_pipe_end_session(usb_endpoint_pipe_t *);141 bool usb_ endpoint_pipe_is_session_started(usb_endpoint_pipe_t *);137 int usb_pipe_start_session(usb_pipe_t *); 138 int usb_pipe_end_session(usb_pipe_t *); 139 bool usb_pipe_is_session_started(usb_pipe_t *); 142 140 143 int usb_ endpoint_pipe_read(usb_endpoint_pipe_t *, void *, size_t, size_t *);144 int usb_ endpoint_pipe_write(usb_endpoint_pipe_t *, void *, size_t);141 int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *); 142 int usb_pipe_write(usb_pipe_t *, void *, size_t); 145 143 146 int usb_ endpoint_pipe_control_read(usb_endpoint_pipe_t *, void *, size_t,144 int usb_pipe_control_read(usb_pipe_t *, void *, size_t, 147 145 void *, size_t, size_t *); 148 int usb_ endpoint_pipe_control_write(usb_endpoint_pipe_t *, void *, size_t,146 int usb_pipe_control_write(usb_pipe_t *, void *, size_t, 149 147 void *, size_t); 150 148 -
uspace/lib/usb/include/usb/recognise.h
r361e61b r55e388a1 48 48 const usb_standard_interface_descriptor_t *, match_id_list_t *); 49 49 50 int usb_device_create_match_ids(usb_ endpoint_pipe_t *, match_id_list_t *);50 int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *); 51 51 52 52 int usb_device_register_child_in_devman(usb_address_t, devman_handle_t, -
uspace/lib/usb/include/usb/request.h
r361e61b r55e388a1 86 86 } __attribute__ ((packed)) usb_device_request_setup_packet_t; 87 87 88 int usb_control_request_set(usb_ endpoint_pipe_t *,88 int usb_control_request_set(usb_pipe_t *, 89 89 usb_request_type_t, usb_request_recipient_t, uint8_t, 90 90 uint16_t, uint16_t, void *, size_t); 91 91 92 int usb_control_request_get(usb_ endpoint_pipe_t *,92 int usb_control_request_get(usb_pipe_t *, 93 93 usb_request_type_t, usb_request_recipient_t, uint8_t, 94 94 uint16_t, uint16_t, void *, size_t, size_t *); 95 95 96 int usb_request_get_status(usb_ endpoint_pipe_t *, usb_request_recipient_t,96 int usb_request_get_status(usb_pipe_t *, usb_request_recipient_t, 97 97 uint16_t, uint16_t *); 98 int usb_request_clear_feature(usb_ endpoint_pipe_t *, usb_request_type_t,98 int usb_request_clear_feature(usb_pipe_t *, usb_request_type_t, 99 99 usb_request_recipient_t, uint16_t, uint16_t); 100 int usb_request_set_feature(usb_ endpoint_pipe_t *, usb_request_type_t,100 int usb_request_set_feature(usb_pipe_t *, usb_request_type_t, 101 101 usb_request_recipient_t, uint16_t, uint16_t); 102 int usb_request_set_address(usb_ endpoint_pipe_t *, usb_address_t);103 int usb_request_get_descriptor(usb_ endpoint_pipe_t *, usb_request_type_t,102 int usb_request_set_address(usb_pipe_t *, usb_address_t); 103 int usb_request_get_descriptor(usb_pipe_t *, usb_request_type_t, 104 104 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t, 105 105 size_t *); 106 int usb_request_get_descriptor_alloc(usb_ endpoint_pipe_t *, usb_request_type_t,106 int usb_request_get_descriptor_alloc(usb_pipe_t *, usb_request_type_t, 107 107 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *); 108 int usb_request_get_device_descriptor(usb_ endpoint_pipe_t *,108 int usb_request_get_device_descriptor(usb_pipe_t *, 109 109 usb_standard_device_descriptor_t *); 110 int usb_request_get_bare_configuration_descriptor(usb_ endpoint_pipe_t *, int,110 int usb_request_get_bare_configuration_descriptor(usb_pipe_t *, int, 111 111 usb_standard_configuration_descriptor_t *); 112 int usb_request_get_full_configuration_descriptor(usb_ endpoint_pipe_t *, int,112 int usb_request_get_full_configuration_descriptor(usb_pipe_t *, int, 113 113 void *, size_t, size_t *); 114 int usb_request_get_full_configuration_descriptor_alloc(usb_ endpoint_pipe_t *,114 int usb_request_get_full_configuration_descriptor_alloc(usb_pipe_t *, 115 115 int, void **, size_t *); 116 int usb_request_set_descriptor(usb_ endpoint_pipe_t *, usb_request_type_t,116 int usb_request_set_descriptor(usb_pipe_t *, usb_request_type_t, 117 117 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t); 118 int usb_request_get_configuration(usb_ endpoint_pipe_t *, uint8_t *);119 int usb_request_set_configuration(usb_ endpoint_pipe_t *, uint8_t);120 int usb_request_get_interface(usb_ endpoint_pipe_t *, uint8_t, uint8_t *);121 int usb_request_set_interface(usb_ endpoint_pipe_t *, uint8_t, uint8_t);118 int usb_request_get_configuration(usb_pipe_t *, uint8_t *); 119 int usb_request_set_configuration(usb_pipe_t *, uint8_t); 120 int usb_request_get_interface(usb_pipe_t *, uint8_t, uint8_t *); 121 int usb_request_set_interface(usb_pipe_t *, uint8_t, uint8_t); 122 122 123 int usb_request_get_supported_languages(usb_ endpoint_pipe_t *,123 int usb_request_get_supported_languages(usb_pipe_t *, 124 124 l18_win_locales_t **, size_t *); 125 int usb_request_get_string(usb_ endpoint_pipe_t *, size_t, l18_win_locales_t,125 int usb_request_get_string(usb_pipe_t *, size_t, l18_win_locales_t, 126 126 char **); 127 127 -
uspace/lib/usb/include/usb/usb.h
r361e61b r55e388a1 61 61 62 62 const char * usb_str_transfer_type(usb_transfer_type_t t); 63 const char * usb_str_transfer_type_short(usb_transfer_type_t t); 63 64 64 65 /** USB data transfer direction. */ … … 78 79 USB_SPEED_HIGH 79 80 } usb_speed_t; 81 82 const char *usb_str_speed(usb_speed_t); 83 80 84 81 85 /** USB request type target. */ -
uspace/lib/usb/src/devdrv.c
r361e61b r55e388a1 126 126 127 127 for (i = 0; i < pipe_count; i++) { 128 dev->pipes[i].pipe = malloc(sizeof(usb_ endpoint_pipe_t));128 dev->pipes[i].pipe = malloc(sizeof(usb_pipe_t)); 129 129 if (dev->pipes[i].pipe == NULL) { 130 130 usb_log_oom(dev->ddf_dev); … … 137 137 } 138 138 139 void *config_descriptor; 140 size_t config_descriptor_size; 141 rc = usb_request_get_full_configuration_descriptor_alloc( 142 &dev->ctrl_pipe, 0, &config_descriptor, &config_descriptor_size); 143 if (rc != EOK) { 144 usb_log_error("Failed retrieving configuration of `%s': %s.\n", 145 dev->ddf_dev->name, str_error(rc)); 146 goto rollback; 147 } 148 149 rc = usb_endpoint_pipe_initialize_from_configuration(dev->pipes, 150 pipe_count, config_descriptor, config_descriptor_size, &dev->wire); 139 rc = usb_pipe_initialize_from_configuration(dev->pipes, pipe_count, 140 dev->descriptors.configuration, dev->descriptors.configuration_size, 141 &dev->wire); 151 142 if (rc != EOK) { 152 143 usb_log_error("Failed initializing USB endpoints: %s.\n", … … 172 163 for (i = 0; i < pipe_count; i++) { 173 164 if (dev->pipes[i].present) { 174 rc = usb_ endpoint_pipe_register(dev->pipes[i].pipe,165 rc = usb_pipe_register(dev->pipes[i].pipe, 175 166 dev->pipes[i].descriptor->poll_interval, 176 167 &hc_conn); … … 219 210 } 220 211 221 rc = usb_ endpoint_pipe_initialize_default_control(&dev->ctrl_pipe,212 rc = usb_pipe_initialize_default_control(&dev->ctrl_pipe, 222 213 &dev->wire); 223 214 if (rc != EOK) { … … 228 219 } 229 220 230 rc = usb_ endpoint_pipe_probe_default_control(&dev->ctrl_pipe);221 rc = usb_pipe_probe_default_control(&dev->ctrl_pipe); 231 222 if (rc != EOK) { 232 223 usb_log_error( … … 237 228 238 229 /* 239 * Initialization of other pipes requires open session on 240 * default control pipe. 230 * For further actions, we need open session on default control pipe. 241 231 */ 242 rc = usb_ endpoint_pipe_start_session(&dev->ctrl_pipe);232 rc = usb_pipe_start_session(&dev->ctrl_pipe); 243 233 if (rc != EOK) { 244 234 usb_log_error("Failed to start an IPC session: %s.\n", 245 235 str_error(rc)); 236 return rc; 237 } 238 239 /* Get the device descriptor. */ 240 rc = usb_request_get_device_descriptor(&dev->ctrl_pipe, 241 &dev->descriptors.device); 242 if (rc != EOK) { 243 usb_log_error("Failed to retrieve device descriptor: %s.\n", 244 str_error(rc)); 245 return rc; 246 } 247 248 /* Get the full configuration descriptor. */ 249 rc = usb_request_get_full_configuration_descriptor_alloc( 250 &dev->ctrl_pipe, 0, (void **) &dev->descriptors.configuration, 251 &dev->descriptors.configuration_size); 252 if (rc != EOK) { 253 usb_log_error("Failed retrieving configuration descriptor: %s.\n", 254 dev->ddf_dev->name, str_error(rc)); 246 255 return rc; 247 256 } … … 252 261 253 262 /* No checking here. */ 254 usb_endpoint_pipe_end_session(&dev->ctrl_pipe); 263 usb_pipe_end_session(&dev->ctrl_pipe); 264 265 /* Rollback actions. */ 266 if (rc != EOK) { 267 if (dev->descriptors.configuration != NULL) { 268 free(dev->descriptors.configuration); 269 } 270 } 255 271 256 272 return rc; … … 283 299 dev->ddf_dev->driver_data = dev; 284 300 dev->driver_data = NULL; 301 dev->descriptors.configuration = NULL; 285 302 286 303 rc = initialize_pipes(dev); -
uspace/lib/usb/src/devpoll.c
r361e61b r55e388a1 64 64 assert(polling_data); 65 65 66 usb_ endpoint_pipe_t *pipe66 usb_pipe_t *pipe 67 67 = polling_data->dev->pipes[polling_data->pipe_index].pipe; 68 68 … … 71 71 int rc; 72 72 73 rc = usb_ endpoint_pipe_start_session(pipe);73 rc = usb_pipe_start_session(pipe); 74 74 if (rc != EOK) { 75 75 failed_attempts++; … … 78 78 79 79 size_t actual_size; 80 rc = usb_ endpoint_pipe_read(pipe, polling_data->buffer,80 rc = usb_pipe_read(pipe, polling_data->buffer, 81 81 polling_data->request_size, &actual_size); 82 82 83 83 /* Quit the session regardless of errors. */ 84 usb_ endpoint_pipe_end_session(pipe);84 usb_pipe_end_session(pipe); 85 85 86 86 if (rc != EOK) { -
uspace/lib/usb/src/hidparser.c
r361e61b r55e388a1 84 84 { 85 85 if(parser == NULL) { 86 return -1;86 return EINVAL; 87 87 } 88 88 … … 115 115 size_t offset_output=0; 116 116 size_t offset_feature=0; 117 118 if(usb_hid_parser_init(parser) != EOK) { 119 return EINVAL; 120 } 117 121 118 122 … … 128 132 129 133 if((i+USB_HID_ITEM_SIZE(data[i]))>= size){ 130 return -1; // TODO ERROR CODE134 return EINVAL; // TODO ERROR CODE 131 135 } 132 136 … … 530 534 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser) 531 535 { 536 if(parser == NULL) { 537 return; 538 } 539 532 540 usb_log_debug("INPUT:\n"); 533 541 usb_hid_descriptor_print_list(&parser->input); … … 615 623 size_t j=0; 616 624 625 if(parser == NULL) { 626 return EINVAL; 627 } 628 629 617 630 // get the size of result keycodes array 618 631 usb_hid_report_path_t path; … … 737 750 int usb_hid_report_input_length(const usb_hid_report_parser_t *parser, 738 751 const usb_hid_report_path_t *path) 739 { 752 { 740 753 int ret = 0; 741 754 link_t *item; 742 755 usb_hid_report_item_t *report_item; 743 756 757 if(parser == NULL) { 758 return EINVAL; 759 } 760 744 761 item = (&parser->input)->next; 745 762 while(&parser->input != item) { -
uspace/lib/usb/src/host/batch.c
r361e61b r55e388a1 30 30 */ 31 31 /** @file 32 * @brief OHCI driver USB transaction structure32 * USB transfer transaction structures (implementation). 33 33 */ 34 34 #include <errno.h> … … 39 39 #include <usb/host/batch.h> 40 40 41 void batch_init(42 batch_t *instance,41 void usb_transfer_batch_init( 42 usb_transfer_batch_t *instance, 43 43 usb_target_t target, 44 44 usb_transfer_type_t transfer_type, … … 85 85 * 86 86 */ 87 void batch_finish(batch_t *instance, int error)87 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error) 88 88 { 89 89 assert(instance); … … 98 98 * parameters. 99 99 */ 100 void batch_call_in(batch_t *instance)100 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance) 101 101 { 102 102 assert(instance); … … 107 107 instance->buffer_size); 108 108 109 int err = instance->error; 110 usb_log_debug("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n", 111 instance, instance->transfer_type, str_error(err), err, 112 instance->transfered_size); 109 usb_log_debug("Batch %p done (T%d.%d, %s %s in, %zuB): %s (%d).\n", 110 instance, 111 instance->target.address, instance->target.endpoint, 112 usb_str_speed(instance->speed), 113 usb_str_transfer_type_short(instance->transfer_type), 114 instance->transfered_size, 115 str_error(instance->error), instance->error); 113 116 114 instance->callback_in( 115 instance-> fun, err, instance->transfered_size, instance->arg);117 instance->callback_in(instance->fun, instance->error, 118 instance->transfered_size, instance->arg); 116 119 } 117 120 /*----------------------------------------------------------------------------*/ … … 120 123 * @param[in] instance Batch structure to use. 121 124 */ 122 void batch_call_out(batch_t *instance)125 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance) 123 126 { 124 127 assert(instance); 125 128 assert(instance->callback_out); 126 129 127 int err = instance->error; 128 usb_log_debug("Batch(%p) callback OUT(type:%d): %s(%d).\n", 129 instance, instance->transfer_type, str_error(err), err); 130 usb_log_debug("Batch %p done (T%d.%d, %s %s out): %s (%d).\n", 131 instance, 132 instance->target.address, instance->target.endpoint, 133 usb_str_speed(instance->speed), 134 usb_str_transfer_type_short(instance->transfer_type), 135 str_error(instance->error), instance->error); 136 130 137 instance->callback_out(instance->fun, 131 err, instance->arg);138 instance->error, instance->arg); 132 139 } 133 140 /** -
uspace/lib/usb/src/host/device_keeper.c
r361e61b r55e388a1 31 31 */ 32 32 /** @file 33 * @brief UHCI driver33 * Device keeper structure and functions (implementation). 34 34 */ 35 35 #include <assert.h> … … 45 45 * Set all values to false/0. 46 46 */ 47 void device_keeper_init(device_keeper_t *instance)47 void usb_device_keeper_init(usb_device_keeper_t *instance) 48 48 { 49 49 assert(instance); … … 65 65 * @param[in] speed Speed of the device requesting default address. 66 66 */ 67 void device_keeper_reserve_default(device_keeper_t *instance, usb_speed_t speed) 67 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance, 68 usb_speed_t speed) 68 69 { 69 70 assert(instance); … … 83 84 * @param[in] speed Speed of the device requesting default address. 84 85 */ 85 void device_keeper_release_default(device_keeper_t *instance)86 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance) 86 87 { 87 88 assert(instance); … … 100 101 * Really ugly one. 101 102 */ 102 void device_keeper_reset_if_need(103 device_keeper_t *instance, usb_target_t target, const unsigned char*data)103 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance, 104 usb_target_t target, const uint8_t *data) 104 105 { 105 106 assert(instance); … … 144 145 * @return Error code 145 146 */ 146 int device_keeper_get_toggle(147 device_keeper_t *instance,usb_target_t target, usb_direction_t direction)147 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance, 148 usb_target_t target, usb_direction_t direction) 148 149 { 149 150 assert(instance); … … 173 174 * @return Error code. 174 175 */ 175 int device_keeper_set_toggle(device_keeper_t *instance,176 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance, 176 177 usb_target_t target, usb_direction_t direction, bool toggle) 177 178 { … … 207 208 * @return Free address, or error code. 208 209 */ 209 usb_address_t device_keeper_request( 210 device_keeper_t *instance, usb_speed_t speed) 211 { 212 assert(instance); 213 fibril_mutex_lock(&instance->guard); 214 215 usb_address_t new_address = instance->last_address + 1; 216 while (instance->devices[new_address].occupied) { 210 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance, 211 usb_speed_t speed) 212 { 213 assert(instance); 214 fibril_mutex_lock(&instance->guard); 215 216 usb_address_t new_address = instance->last_address; 217 do { 218 ++new_address; 219 if (new_address > USB11_ADDRESS_MAX) 220 new_address = 1; 217 221 if (new_address == instance->last_address) { 218 222 fibril_mutex_unlock(&instance->guard); 219 223 return ENOSPC; 220 224 } 221 if (new_address == USB11_ADDRESS_MAX) 222 new_address = 1; 223 ++new_address; 224 } 225 } while (instance->devices[new_address].occupied); 225 226 226 227 assert(new_address != USB_ADDRESS_DEFAULT); … … 241 242 * @param[in] handle Devman handle of the device. 242 243 */ 243 void device_keeper_bind(244 device_keeper_t *instance,usb_address_t address, devman_handle_t handle)244 void usb_device_keeper_bind(usb_device_keeper_t *instance, 245 usb_address_t address, devman_handle_t handle) 245 246 { 246 247 assert(instance); … … 258 259 * @param[in] address Device address 259 260 */ 260 void device_keeper_release(device_keeper_t *instance, usb_address_t address) 261 void usb_device_keeper_release(usb_device_keeper_t *instance, 262 usb_address_t address) 261 263 { 262 264 assert(instance); … … 276 278 * @return USB Address, or error code. 277 279 */ 278 usb_address_t device_keeper_find(279 dev ice_keeper_t *instance, devman_handle_t handle)280 usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance, 281 devman_handle_t handle) 280 282 { 281 283 assert(instance); … … 299 301 * @return USB speed. 300 302 */ 301 usb_speed_t device_keeper_speed(302 device_keeper_t *instance,usb_address_t address)303 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 304 usb_address_t address) 303 305 { 304 306 assert(instance); … … 307 309 return instance->devices[address].speed; 308 310 } 311 309 312 /** 310 313 * @} -
uspace/lib/usb/src/hub.c
r361e61b r55e388a1 228 228 } 229 229 230 usb_ endpoint_pipe_t ctrl_pipe;231 rc = usb_ endpoint_pipe_initialize_default_control(&ctrl_pipe,230 usb_pipe_t ctrl_pipe; 231 rc = usb_pipe_initialize_default_control(&ctrl_pipe, 232 232 &dev_conn); 233 233 if (rc != EOK) { … … 235 235 goto leave_release_default_address; 236 236 } 237 rc = usb_ endpoint_pipe_probe_default_control(&ctrl_pipe);237 rc = usb_pipe_probe_default_control(&ctrl_pipe); 238 238 if (rc != EOK) { 239 239 rc = ENOTCONN; … … 241 241 } 242 242 243 rc = usb_ endpoint_pipe_start_session(&ctrl_pipe);243 rc = usb_pipe_start_session(&ctrl_pipe); 244 244 if (rc != EOK) { 245 245 rc = ENOTCONN; … … 253 253 } 254 254 255 usb_ endpoint_pipe_end_session(&ctrl_pipe);255 usb_pipe_end_session(&ctrl_pipe); 256 256 257 257 /* … … 306 306 307 307 leave_stop_session: 308 usb_ endpoint_pipe_end_session(&ctrl_pipe);308 usb_pipe_end_session(&ctrl_pipe); 309 309 310 310 leave_release_default_address: -
uspace/lib/usb/src/pipes.c
r361e61b r55e388a1 233 233 * A session is something inside what any communication occurs. 234 234 * It is expected that sessions would be started right before the transfer 235 * and ended - see usb_ endpoint_pipe_end_session() - after the last235 * and ended - see usb_pipe_end_session() - after the last 236 236 * transfer. 237 237 * The reason for this is that session actually opens some communication … … 244 244 * @return Error code. 245 245 */ 246 int usb_ endpoint_pipe_start_session(usb_endpoint_pipe_t *pipe)246 int usb_pipe_start_session(usb_pipe_t *pipe) 247 247 { 248 248 assert(pipe); 249 249 250 if (usb_ endpoint_pipe_is_session_started(pipe)) {250 if (usb_pipe_is_session_started(pipe)) { 251 251 return EBUSY; 252 252 } … … 265 265 /** Ends a session on the endpoint pipe. 266 266 * 267 * @see usb_ endpoint_pipe_start_session267 * @see usb_pipe_start_session 268 268 * 269 269 * @param pipe Endpoint pipe to end the session on. 270 270 * @return Error code. 271 271 */ 272 int usb_ endpoint_pipe_end_session(usb_endpoint_pipe_t *pipe)272 int usb_pipe_end_session(usb_pipe_t *pipe) 273 273 { 274 274 assert(pipe); 275 275 276 if (!usb_ endpoint_pipe_is_session_started(pipe)) {276 if (!usb_pipe_is_session_started(pipe)) { 277 277 return ENOENT; 278 278 } … … 296 296 * @return Whether @p pipe has opened a session. 297 297 */ 298 bool usb_ endpoint_pipe_is_session_started(usb_endpoint_pipe_t *pipe)298 bool usb_pipe_is_session_started(usb_pipe_t *pipe) 299 299 { 300 300 return (pipe->hc_phone >= 0); -
uspace/lib/usb/src/pipesinit.c
r361e61b r55e388a1 193 193 } 194 194 195 int rc = usb_ endpoint_pipe_initialize(ep_mapping->pipe, wire,195 int rc = usb_pipe_initialize(ep_mapping->pipe, wire, 196 196 ep_no, description.transfer_type, endpoint->max_packet_size, 197 197 description.direction); … … 276 276 * @return Error code. 277 277 */ 278 int usb_ endpoint_pipe_initialize_from_configuration(278 int usb_pipe_initialize_from_configuration( 279 279 usb_endpoint_mapping_t *mapping, size_t mapping_count, 280 280 uint8_t *configuration_descriptor, size_t configuration_descriptor_size, … … 342 342 * @return Error code. 343 343 */ 344 int usb_ endpoint_pipe_initialize(usb_endpoint_pipe_t *pipe,344 int usb_pipe_initialize(usb_pipe_t *pipe, 345 345 usb_device_connection_t *connection, usb_endpoint_t endpoint_no, 346 346 usb_transfer_type_t transfer_type, size_t max_packet_size, … … 367 367 * @return Error code. 368 368 */ 369 int usb_ endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *pipe,369 int usb_pipe_initialize_default_control(usb_pipe_t *pipe, 370 370 usb_device_connection_t *connection) 371 371 { … … 373 373 assert(connection); 374 374 375 int rc = usb_ endpoint_pipe_initialize(pipe, connection,375 int rc = usb_pipe_initialize(pipe, connection, 376 376 0, USB_TRANSFER_CONTROL, CTRL_PIPE_MIN_PACKET_SIZE, 377 377 USB_DIRECTION_BOTH); … … 390 390 * @return Error code. 391 391 */ 392 int usb_ endpoint_pipe_probe_default_control(usb_endpoint_pipe_t *pipe)392 int usb_pipe_probe_default_control(usb_pipe_t *pipe) 393 393 { 394 394 assert(pipe); … … 408 408 409 409 TRY_LOOP(failed_attempts) { 410 rc = usb_ endpoint_pipe_start_session(pipe);410 rc = usb_pipe_start_session(pipe); 411 411 if (rc == EOK) { 412 412 break; … … 433 433 } 434 434 } 435 usb_ endpoint_pipe_end_session(pipe);435 usb_pipe_end_session(pipe); 436 436 if (rc != EOK) { 437 437 return rc; … … 451 451 * @return Error code. 452 452 */ 453 int usb_ endpoint_pipe_register(usb_endpoint_pipe_t *pipe,453 int usb_pipe_register(usb_pipe_t *pipe, 454 454 unsigned int interval, 455 455 usb_hc_connection_t *hc_connection) … … 479 479 * @return Error code. 480 480 */ 481 int usb_ endpoint_pipe_unregister(usb_endpoint_pipe_t *pipe,481 int usb_pipe_unregister(usb_pipe_t *pipe, 482 482 usb_hc_connection_t *hc_connection) 483 483 { -
uspace/lib/usb/src/pipesio.c
r361e61b r55e388a1 58 58 * @return Error code. 59 59 */ 60 static int usb_ endpoint_pipe_read_no_checks(usb_endpoint_pipe_t *pipe,60 static int usb_pipe_read_no_checks(usb_pipe_t *pipe, 61 61 void *buffer, size_t size, size_t *size_transfered) 62 62 { … … 140 140 * @return Error code. 141 141 */ 142 int usb_ endpoint_pipe_read(usb_endpoint_pipe_t *pipe,142 int usb_pipe_read(usb_pipe_t *pipe, 143 143 void *buffer, size_t size, size_t *size_transfered) 144 144 { … … 153 153 } 154 154 155 if (!usb_ endpoint_pipe_is_session_started(pipe)) {155 if (!usb_pipe_is_session_started(pipe)) { 156 156 return EBADF; 157 157 } … … 168 168 int rc; 169 169 170 rc = usb_ endpoint_pipe_read_no_checks(pipe, buffer, size, &act_size);170 rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size); 171 171 if (rc != EOK) { 172 172 return rc; … … 190 190 * @return Error code. 191 191 */ 192 static int usb_ endpoint_pipe_write_no_check(usb_endpoint_pipe_t *pipe,192 static int usb_pipe_write_no_check(usb_pipe_t *pipe, 193 193 void *buffer, size_t size) 194 194 { … … 247 247 * @return Error code. 248 248 */ 249 int usb_ endpoint_pipe_write(usb_endpoint_pipe_t *pipe,249 int usb_pipe_write(usb_pipe_t *pipe, 250 250 void *buffer, size_t size) 251 251 { … … 260 260 } 261 261 262 if (!usb_ endpoint_pipe_is_session_started(pipe)) {262 if (!usb_pipe_is_session_started(pipe)) { 263 263 return EBADF; 264 264 } … … 272 272 } 273 273 274 int rc = usb_ endpoint_pipe_write_no_check(pipe, buffer, size);274 int rc = usb_pipe_write_no_check(pipe, buffer, size); 275 275 276 276 return rc; … … 289 289 * @return Error code. 290 290 */ 291 static int usb_ endpoint_pipe_control_read_no_check(usb_endpoint_pipe_t *pipe,291 static int usb_pipe_control_read_no_check(usb_pipe_t *pipe, 292 292 void *setup_buffer, size_t setup_buffer_size, 293 293 void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) … … 365 365 * @return Error code. 366 366 */ 367 int usb_ endpoint_pipe_control_read(usb_endpoint_pipe_t *pipe,367 int usb_pipe_control_read(usb_pipe_t *pipe, 368 368 void *setup_buffer, size_t setup_buffer_size, 369 369 void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) … … 379 379 } 380 380 381 if (!usb_ endpoint_pipe_is_session_started(pipe)) {381 if (!usb_pipe_is_session_started(pipe)) { 382 382 return EBADF; 383 383 } … … 389 389 390 390 size_t act_size = 0; 391 int rc = usb_ endpoint_pipe_control_read_no_check(pipe,391 int rc = usb_pipe_control_read_no_check(pipe, 392 392 setup_buffer, setup_buffer_size, 393 393 data_buffer, data_buffer_size, &act_size); … … 414 414 * @return Error code. 415 415 */ 416 static int usb_ endpoint_pipe_control_write_no_check(usb_endpoint_pipe_t *pipe,416 static int usb_pipe_control_write_no_check(usb_pipe_t *pipe, 417 417 void *setup_buffer, size_t setup_buffer_size, 418 418 void *data_buffer, size_t data_buffer_size) … … 473 473 * @return Error code. 474 474 */ 475 int usb_ endpoint_pipe_control_write(usb_endpoint_pipe_t *pipe,475 int usb_pipe_control_write(usb_pipe_t *pipe, 476 476 void *setup_buffer, size_t setup_buffer_size, 477 477 void *data_buffer, size_t data_buffer_size) … … 491 491 } 492 492 493 if (!usb_ endpoint_pipe_is_session_started(pipe)) {493 if (!usb_pipe_is_session_started(pipe)) { 494 494 return EBADF; 495 495 } … … 500 500 } 501 501 502 int rc = usb_ endpoint_pipe_control_write_no_check(pipe,502 int rc = usb_pipe_control_write_no_check(pipe, 503 503 setup_buffer, setup_buffer_size, data_buffer, data_buffer_size); 504 504 -
uspace/lib/usb/src/recognise.c
r361e61b r55e388a1 311 311 * @return Error code. 312 312 */ 313 int usb_device_create_match_ids(usb_ endpoint_pipe_t *ctrl_pipe,313 int usb_device_create_match_ids(usb_pipe_t *ctrl_pipe, 314 314 match_id_list_t *matches) 315 315 { … … 363 363 int rc; 364 364 usb_device_connection_t dev_connection; 365 usb_ endpoint_pipe_t ctrl_pipe;365 usb_pipe_t ctrl_pipe; 366 366 367 367 rc = usb_device_connection_initialize(&dev_connection, hc_handle, address); … … 370 370 } 371 371 372 rc = usb_ endpoint_pipe_initialize_default_control(&ctrl_pipe,372 rc = usb_pipe_initialize_default_control(&ctrl_pipe, 373 373 &dev_connection); 374 374 if (rc != EOK) { 375 375 goto failure; 376 376 } 377 rc = usb_ endpoint_pipe_probe_default_control(&ctrl_pipe);377 rc = usb_pipe_probe_default_control(&ctrl_pipe); 378 378 if (rc != EOK) { 379 379 goto failure; … … 404 404 child->driver_data = dev_data; 405 405 406 rc = usb_ endpoint_pipe_start_session(&ctrl_pipe);406 rc = usb_pipe_start_session(&ctrl_pipe); 407 407 if (rc != EOK) { 408 408 goto failure; … … 414 414 } 415 415 416 rc = usb_ endpoint_pipe_end_session(&ctrl_pipe);416 rc = usb_pipe_end_session(&ctrl_pipe); 417 417 if (rc != EOK) { 418 418 goto failure; -
uspace/lib/usb/src/request.c
r361e61b r55e388a1 42 42 /** Generic wrapper for SET requests using standard control request format. 43 43 * 44 * @see usb_ endpoint_pipe_control_write44 * @see usb_pipe_control_write 45 45 * 46 46 * @param pipe Pipe used for the communication. … … 60 60 * @retval ERANGE Data buffer too large. 61 61 */ 62 int usb_control_request_set(usb_ endpoint_pipe_t *pipe,62 int usb_control_request_set(usb_pipe_t *pipe, 63 63 usb_request_type_t request_type, usb_request_recipient_t recipient, 64 64 uint8_t request, … … 90 90 setup_packet.length = (uint16_t) data_size; 91 91 92 int rc = usb_ endpoint_pipe_control_write(pipe,92 int rc = usb_pipe_control_write(pipe, 93 93 &setup_packet, sizeof(setup_packet), 94 94 data, data_size); … … 99 99 /** Generic wrapper for GET requests using standard control request format. 100 100 * 101 * @see usb_ endpoint_pipe_control_read101 * @see usb_pipe_control_read 102 102 * 103 103 * @param pipe Pipe used for the communication. … … 120 120 * @retval ERANGE Data buffer too large. 121 121 */ 122 int usb_control_request_get(usb_ endpoint_pipe_t *pipe,122 int usb_control_request_get(usb_pipe_t *pipe, 123 123 usb_request_type_t request_type, usb_request_recipient_t recipient, 124 124 uint8_t request, … … 150 150 setup_packet.length = (uint16_t) data_size; 151 151 152 int rc = usb_ endpoint_pipe_control_read(pipe,152 int rc = usb_pipe_control_read(pipe, 153 153 &setup_packet, sizeof(setup_packet), 154 154 data, data_size, actual_data_size); … … 165 165 * @return Error code. 166 166 */ 167 int usb_request_get_status(usb_ endpoint_pipe_t *pipe,167 int usb_request_get_status(usb_pipe_t *pipe, 168 168 usb_request_recipient_t recipient, uint16_t index, 169 169 uint16_t *status) … … 203 203 * @return Error code. 204 204 */ 205 int usb_request_clear_feature(usb_ endpoint_pipe_t *pipe,205 int usb_request_clear_feature(usb_pipe_t *pipe, 206 206 usb_request_type_t request_type, usb_request_recipient_t recipient, 207 207 uint16_t feature_selector, uint16_t index) … … 231 231 * @return Error code. 232 232 */ 233 int usb_request_set_feature(usb_ endpoint_pipe_t *pipe,233 int usb_request_set_feature(usb_pipe_t *pipe, 234 234 usb_request_type_t request_type, usb_request_recipient_t recipient, 235 235 uint16_t feature_selector, uint16_t index) … … 258 258 * @return Error code. 259 259 */ 260 int usb_request_set_address(usb_ endpoint_pipe_t *pipe,260 int usb_request_set_address(usb_pipe_t *pipe, 261 261 usb_address_t new_address) 262 262 { … … 297 297 * @return Error code. 298 298 */ 299 int usb_request_get_descriptor(usb_ endpoint_pipe_t *pipe,299 int usb_request_get_descriptor(usb_pipe_t *pipe, 300 300 usb_request_type_t request_type, usb_request_recipient_t recipient, 301 301 uint8_t descriptor_type, uint8_t descriptor_index, … … 331 331 * @return 332 332 */ 333 int usb_request_get_descriptor_alloc(usb_ endpoint_pipe_t * pipe,333 int usb_request_get_descriptor_alloc(usb_pipe_t * pipe, 334 334 usb_request_type_t request_type, usb_request_recipient_t recipient, 335 335 uint8_t descriptor_type, uint8_t descriptor_index, … … 400 400 * @return Error code. 401 401 */ 402 int usb_request_get_device_descriptor(usb_ endpoint_pipe_t *pipe,402 int usb_request_get_device_descriptor(usb_pipe_t *pipe, 403 403 usb_standard_device_descriptor_t *descriptor) 404 404 { … … 442 442 * @return Error code. 443 443 */ 444 int usb_request_get_bare_configuration_descriptor(usb_ endpoint_pipe_t *pipe,444 int usb_request_get_bare_configuration_descriptor(usb_pipe_t *pipe, 445 445 int index, usb_standard_configuration_descriptor_t *descriptor) 446 446 { … … 488 488 * @return Error code. 489 489 */ 490 int usb_request_get_full_configuration_descriptor(usb_ endpoint_pipe_t *pipe,490 int usb_request_get_full_configuration_descriptor(usb_pipe_t *pipe, 491 491 int index, void *descriptor, size_t descriptor_size, size_t *actual_size) 492 492 { … … 514 514 */ 515 515 int usb_request_get_full_configuration_descriptor_alloc( 516 usb_ endpoint_pipe_t *pipe, int index,516 usb_pipe_t *pipe, int index, 517 517 void **descriptor_ptr, size_t *descriptor_size) 518 518 { … … 578 578 * @return Error code. 579 579 */ 580 int usb_request_set_descriptor(usb_ endpoint_pipe_t *pipe,580 int usb_request_set_descriptor(usb_pipe_t *pipe, 581 581 usb_request_type_t request_type, usb_request_recipient_t recipient, 582 582 uint8_t descriptor_type, uint8_t descriptor_index, … … 607 607 * @return Error code. 608 608 */ 609 int usb_request_get_configuration(usb_ endpoint_pipe_t *pipe,609 int usb_request_get_configuration(usb_pipe_t *pipe, 610 610 uint8_t *configuration_value) 611 611 { … … 639 639 * @return Error code. 640 640 */ 641 int usb_request_set_configuration(usb_ endpoint_pipe_t *pipe,641 int usb_request_set_configuration(usb_pipe_t *pipe, 642 642 uint8_t configuration_value) 643 643 { … … 658 658 * @return Error code. 659 659 */ 660 int usb_request_get_interface(usb_ endpoint_pipe_t *pipe,660 int usb_request_get_interface(usb_pipe_t *pipe, 661 661 uint8_t interface_index, uint8_t *alternate_setting) 662 662 { … … 691 691 * @return Error code. 692 692 */ 693 int usb_request_set_interface(usb_ endpoint_pipe_t *pipe,693 int usb_request_set_interface(usb_pipe_t *pipe, 694 694 uint8_t interface_index, uint8_t alternate_setting) 695 695 { … … 710 710 * @return Error code. 711 711 */ 712 int usb_request_get_supported_languages(usb_ endpoint_pipe_t *pipe,712 int usb_request_get_supported_languages(usb_pipe_t *pipe, 713 713 l18_win_locales_t **languages_ptr, size_t *languages_count) 714 714 { … … 782 782 * @return Error code. 783 783 */ 784 int usb_request_get_string(usb_ endpoint_pipe_t *pipe,784 int usb_request_get_string(usb_pipe_t *pipe, 785 785 size_t index, l18_win_locales_t lang, char **string_ptr) 786 786 { -
uspace/lib/usb/src/usb.c
r361e61b r55e388a1 36 36 #include <errno.h> 37 37 38 #define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) 39 40 static const char *str_speed[] = { 41 "low", 42 "full", 43 "high" 44 }; 45 46 static const char *str_transfer_type[] = { 47 "control", 48 "isochronous", 49 "bulk", 50 "interrupt" 51 }; 52 53 static const char *str_transfer_type_short[] = { 54 "ctrl", 55 "iso", 56 "bulk", 57 "intr" 58 }; 38 59 39 60 /** String representation for USB transfer type. … … 42 63 * @return Transfer type as a string (in English). 43 64 */ 44 const char * 65 const char *usb_str_transfer_type(usb_transfer_type_t t) 45 66 { 46 switch (t) { 47 case USB_TRANSFER_ISOCHRONOUS: 48 return "isochronous"; 49 case USB_TRANSFER_INTERRUPT: 50 return "interrupt"; 51 case USB_TRANSFER_CONTROL: 52 return "control"; 53 case USB_TRANSFER_BULK: 54 return "bulk"; 55 default: 56 return "unknown"; 67 if (t >= ARR_SIZE(str_transfer_type)) { 68 return "invalid"; 57 69 } 70 return str_transfer_type[t]; 71 } 72 73 /** String representation for USB transfer type (short version). 74 * 75 * @param t Transfer type. 76 * @return Transfer type as a short string for debugging messages. 77 */ 78 const char *usb_str_transfer_type_short(usb_transfer_type_t t) 79 { 80 if (t >= ARR_SIZE(str_transfer_type_short)) { 81 return "invl"; 82 } 83 return str_transfer_type_short[t]; 84 } 85 86 /** String representation of USB speed. 87 * 88 * @param s The speed. 89 * @return USB speed as a string (in English). 90 */ 91 const char *usb_str_speed(usb_speed_t s) 92 { 93 if (s >= ARR_SIZE(str_speed)) { 94 return "invalid"; 95 } 96 return str_speed[s]; 58 97 } 59 98
Note:
See TracChangeset
for help on using the changeset viewer.