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