Changes in / [14e7959:5499a8b] in mainline
- Files:
-
- 8 added
- 3 deleted
- 30 edited
-
.bzrignore (modified) (1 diff)
-
uspace/Makefile.common (modified) (1 diff)
-
uspace/app/lsusb/main.c (modified) (1 diff)
-
uspace/app/mkbd/main.c (modified) (2 diffs)
-
uspace/app/usbinfo/main.c (modified) (2 diffs)
-
uspace/drv/ohci/hc.c (modified) (1 diff)
-
uspace/drv/uhci-hcd/Makefile (modified) (1 diff)
-
uspace/drv/uhci-hcd/batch.h (modified) (1 diff)
-
uspace/drv/uhci-hcd/hc.c (modified) (6 diffs)
-
uspace/drv/uhci-hcd/hc.h (modified) (2 diffs)
-
uspace/drv/uhci-hcd/iface.c (modified) (11 diffs)
-
uspace/drv/uhci-hcd/pci.c (modified) (8 diffs)
-
uspace/drv/uhci-hcd/pci.h (modified) (1 diff)
-
uspace/drv/uhci-hcd/root_hub.c (modified) (1 diff)
-
uspace/drv/uhci-hcd/root_hub.h (modified) (1 diff)
-
uspace/drv/uhci-hcd/transfer_list.c (modified) (6 diffs)
-
uspace/drv/uhci-hcd/transfer_list.h (modified) (1 diff)
-
uspace/drv/uhci-hcd/uhci.c (modified) (2 diffs)
-
uspace/drv/uhci-hcd/uhci.h (modified) (1 diff)
-
uspace/drv/uhci-hcd/utils/malloc32.h (modified) (5 diffs)
-
uspace/drv/uhci-hcd/utils/slab.c (added)
-
uspace/drv/uhci-hcd/utils/slab.h (added)
-
uspace/drv/uhci-rhd/main.c (modified) (4 diffs)
-
uspace/drv/uhci-rhd/port.c (modified) (12 diffs)
-
uspace/drv/uhci-rhd/port.h (modified) (2 diffs)
-
uspace/lib/usb/Makefile (modified) (1 diff)
-
uspace/lib/usb/include/usb/driver.h (added)
-
uspace/lib/usb/include/usb/hc.h (deleted)
-
uspace/lib/usb/include/usb/host.h (added)
-
uspace/lib/usb/src/ddfiface.c (modified) (1 diff)
-
uspace/lib/usb/src/driver.c (added)
-
uspace/lib/usb/src/hc.c (deleted)
-
uspace/lib/usb/src/host.c (added)
-
uspace/lib/usb/src/resolve.c (deleted)
-
uspace/lib/usbdev/Makefile (modified) (1 diff)
-
uspace/lib/usbdev/include/usb/dev/hc.h (added)
-
uspace/lib/usbdev/include/usb/dev/hub.h (modified) (2 diffs)
-
uspace/lib/usbdev/include/usb/dev/pipes.h (modified) (2 diffs)
-
uspace/lib/usbdev/src/hub.c (modified) (1 diff)
-
uspace/lib/usbdev/src/pipes.c (modified) (2 diffs)
-
uspace/lib/usbdev/src/usbdevice.c (added)
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
r14e7959 r5499a8b 7 7 *.map 8 8 *.disasm 9 *.lo10 *.la11 *.so.*12 *.so013 9 _link.ld 14 10 ./*.iso -
uspace/Makefile.common
r14e7959 r5499a8b 131 131 endif 132 132 endif 133 # Build static whenever we use libusb because that library uses134 # thread local variables135 ifneq ($(findstring usb, $(LIBS)),)136 STATIC_BUILD = y137 endif138 133 139 134 ifeq ($(STATIC_BUILD), y) -
uspace/app/lsusb/main.c
r14e7959 r5499a8b 45 45 #include <devmap.h> 46 46 #include <usb/dev/hub.h> 47 #include <usb/h c.h>47 #include <usb/host.h> 48 48 49 49 #define NAME "lsusb" -
uspace/app/mkbd/main.c
r14e7959 r5499a8b 45 45 #include <devmap.h> 46 46 #include <usb/dev/hub.h> 47 #include <usb/hc.h> 47 #include <usb/host.h> 48 #include <usb/driver.h> 48 49 #include <usb/dev/pipes.h> 49 50 … … 172 173 /* Try to get its address. */ 173 174 if (!addr_found) { 174 addr = usb_ hc_get_address_by_handle(dev_handle);175 addr = usb_device_get_assigned_address(dev_handle); 175 176 if (addr >= 0) { 176 177 addr_found = true; -
uspace/app/usbinfo/main.c
r14e7959 r5499a8b 43 43 #include <devman.h> 44 44 #include <devmap.h> 45 #include <usb/ hc.h>45 #include <usb/dev/hc.h> 46 46 #include <usb/dev/pipes.h> 47 #include <usb/host.h> 48 #include <usb/driver.h> 47 49 #include "usbinfo.h" 50 51 static bool try_parse_class_and_address(const char *path, 52 devman_handle_t *out_hc_handle, usb_address_t *out_device_address) 53 { 54 size_t class_index; 55 size_t address; 56 int rc; 57 char *ptr; 58 59 rc = str_size_t(path, &ptr, 10, false, &class_index); 60 if (rc != EOK) { 61 return false; 62 } 63 if ((*ptr == ':') || (*ptr == '.')) { 64 ptr++; 65 } else { 66 return false; 67 } 68 rc = str_size_t(ptr, NULL, 10, true, &address); 69 if (rc != EOK) { 70 return false; 71 } 72 rc = usb_ddf_get_hc_handle_by_class(class_index, out_hc_handle); 73 if (rc != EOK) { 74 return false; 75 } 76 if (out_device_address != NULL) { 77 *out_device_address = (usb_address_t) address; 78 } 79 return true; 80 } 81 82 static bool resolve_hc_handle_and_dev_addr(const char *devpath, 83 devman_handle_t *out_hc_handle, usb_address_t *out_device_address) 84 { 85 int rc; 86 87 /* Hack for QEMU to save-up on typing ;-). */ 88 if (str_cmp(devpath, "qemu") == 0) { 89 devpath = "/hw/pci0/00:01.2/uhci-rh/usb00_a1"; 90 } 91 92 /* Hack for virtual keyboard. */ 93 if (str_cmp(devpath, "virt") == 0) { 94 devpath = "/virt/usbhc/usb00_a1/usb00_a2"; 95 } 96 97 if (try_parse_class_and_address(devpath, 98 out_hc_handle, out_device_address)) { 99 return true; 100 } 101 102 char *path = str_dup(devpath); 103 if (path == NULL) { 104 return ENOMEM; 105 } 106 107 devman_handle_t hc = 0; 108 bool hc_found = false; 109 usb_address_t addr = 0; 110 bool addr_found = false; 111 112 /* Remove suffixes and hope that we will encounter device node. */ 113 while (str_length(path) > 0) { 114 /* Get device handle first. */ 115 devman_handle_t dev_handle; 116 rc = devman_device_get_handle(path, &dev_handle, 0); 117 if (rc != EOK) { 118 free(path); 119 return false; 120 } 121 122 /* Try to find its host controller. */ 123 if (!hc_found) { 124 rc = usb_hc_find(dev_handle, &hc); 125 if (rc == EOK) { 126 hc_found = true; 127 } 128 } 129 /* Try to get its address. */ 130 if (!addr_found) { 131 addr = usb_device_get_assigned_address(dev_handle); 132 if (addr >= 0) { 133 addr_found = true; 134 } 135 } 136 137 /* Speed-up. */ 138 if (hc_found && addr_found) { 139 break; 140 } 141 142 /* Remove the last suffix. */ 143 char *slash_pos = str_rchr(path, '/'); 144 if (slash_pos != NULL) { 145 *slash_pos = 0; 146 } 147 } 148 149 free(path); 150 151 if (hc_found && addr_found) { 152 if (out_hc_handle != NULL) { 153 *out_hc_handle = hc; 154 } 155 if (out_device_address != NULL) { 156 *out_device_address = addr; 157 } 158 return true; 159 } else { 160 return false; 161 } 162 } 48 163 49 164 static void print_usage(char *app_name) … … 185 300 devman_handle_t hc_handle = 0; 186 301 usb_address_t dev_addr = 0; 187 int rc = usb_resolve_device_handle(devpath,188 &hc_handle, &dev_addr , NULL);189 if ( rc != EOK) {302 bool found = resolve_hc_handle_and_dev_addr(devpath, 303 &hc_handle, &dev_addr); 304 if (!found) { 190 305 fprintf(stderr, NAME ": device `%s' not found " 191 306 "or not of USB kind, skipping.\n", -
uspace/drv/ohci/hc.c
r14e7959 r5499a8b 565 565 bzero(&instance->rh, sizeof(instance->rh)); 566 566 /* Init queues */ 567 const int ret = hc_init_transfer_lists(instance); 568 if (ret != EOK) { 569 return ret; 570 } 567 hc_init_transfer_lists(instance); 571 568 572 569 /*Init HCCA */ -
uspace/drv/uhci-hcd/Makefile
r14e7959 r5499a8b 48 48 root_hub.c \ 49 49 hw_struct/transfer_descriptor.c \ 50 utils/slab.c \ 50 51 pci.c \ 51 52 batch.c -
uspace/drv/uhci-hcd/batch.h
r14e7959 r5499a8b 35 35 #define DRV_UHCI_BATCH_H 36 36 37 #include <usbhc_iface.h> 38 #include <usb/usb.h> 39 #include <usb/host/device_keeper.h> 40 #include <usb/host/endpoint.h> 37 41 #include <usb/host/batch.h> 38 42 -
uspace/drv/uhci-hcd/hc.c
r14e7959 r5499a8b 39 39 #include <usb/debug.h> 40 40 #include <usb/usb.h> 41 #include <usb/ddfiface.h> 42 #include <usb_iface.h> 41 43 42 44 #include "hc.h" … … 83 85 /* allow access to hc control registers */ 84 86 regs_t *io; 85 ret = pio_enable(regs, reg_size, (void **)&io);87 ret = pio_enable(regs, reg_size, (void**)&io); 86 88 CHECK_RET_RETURN(ret, 87 89 "Failed(%d) to gain access to registers at %p: %s.\n", … … 141 143 } 142 144 143 constuint16_t status = pio_read_16(®isters->usbcmd);145 uint16_t status = pio_read_16(®isters->usbcmd); 144 146 if (status != 0) 145 147 usb_log_warning("Previous command value: %x.\n", status); … … 210 212 /* Init USB frame list page*/ 211 213 instance->frame_list = get_page(); 212 ret = instance ->frame_list? EOK : ENOMEM;214 ret = instance ? EOK : ENOMEM; 213 215 CHECK_RET_RETURN(ret, "Failed to get frame list page.\n"); 214 216 usb_log_debug("Initialized frame list at %p.\n", instance->frame_list); … … 275 277 &instance->transfers_control_slow); 276 278 277 /*FSBR, This feature is not needed (adds no benefit) and is supposedly 278 * buggy on certain hw, enable at your own risk. */ 279 /*FSBR*/ 279 280 #ifdef FSBR 280 281 transfer_list_set_next(&instance->transfers_bulk_full, … … 427 428 } 428 429 429 constuintptr_t frame_list =430 uintptr_t frame_list = 430 431 pio_read_32(&instance->registers->flbaseadd) & ~0xfff; 431 432 if (frame_list != addr_to_phys(instance->frame_list)) { -
uspace/drv/uhci-hcd/hc.h
r14e7959 r5499a8b 37 37 38 38 #include <fibril.h> 39 #include <fibril_synch.h> 40 #include <adt/list.h> 39 41 #include <ddi.h> 40 42 43 #include <usbhc_iface.h> 41 44 #include <usb/host/device_keeper.h> 42 45 #include <usb/host/usb_endpoint_manager.h> 43 #include <usb/host/batch.h>44 46 47 #include "batch.h" 45 48 #include "transfer_list.h" 46 49 … … 151 154 */ 152 155 static inline hc_t * fun_to_hc(ddf_fun_t *fun) 153 { 154 assert(fun); 155 return fun->driver_data; 156 } 156 { return (hc_t*)fun->driver_data; } 157 157 #endif 158 158 /** -
uspace/drv/uhci-hcd/iface.c
r14e7959 r5499a8b 39 39 40 40 #include "iface.h" 41 #include "batch.h"42 41 #include "hc.h" 43 42 … … 123 122 return EOK; 124 123 } 125 /*----------------------------------------------------------------------------*/ 124 126 125 /** Find device handle by address interface function. 127 126 * … … 137 136 hc_t *hc = fun_to_hc(fun); 138 137 assert(hc); 139 constbool found =138 bool found = 140 139 usb_device_keeper_find_by_address(&hc->manager, address, handle); 141 140 return found ? EOK : ENOENT; 142 141 } 142 143 143 /*----------------------------------------------------------------------------*/ 144 144 /** Release address interface function … … 164 164 size_t max_packet_size, unsigned int interval) 165 165 { 166 assert(fun);167 166 hc_t *hc = fun_to_hc(fun); 168 167 assert(hc); … … 184 183 usb_endpoint_t endpoint, usb_direction_t direction) 185 184 { 186 assert(fun);187 185 hc_t *hc = fun_to_hc(fun); 188 186 assert(hc); … … 213 211 if (ret != EOK) 214 212 return ret; 215 assert(batch);216 assert(hc);217 213 batch_interrupt_out(batch); 218 214 ret = hc_schedule(hc, batch); … … 243 239 if (ret != EOK) 244 240 return ret; 245 assert(batch);246 assert(hc);247 241 batch_interrupt_in(batch); 248 242 ret = hc_schedule(hc, batch); … … 273 267 if (ret != EOK) 274 268 return ret; 275 assert(batch);276 assert(hc);277 269 batch_bulk_out(batch); 278 270 ret = hc_schedule(hc, batch); … … 303 295 if (ret != EOK) 304 296 return ret; 305 assert(batch);306 assert(hc);307 297 batch_bulk_in(batch); 308 298 ret = hc_schedule(hc, batch); … … 337 327 if (ret != EOK) 338 328 return ret; 339 assert(batch);340 assert(hc);341 329 usb_endpoint_manager_reset_if_need(&hc->ep_manager, target, setup_data); 342 330 batch_control_write(batch); … … 372 360 if (ret != EOK) 373 361 return ret; 374 assert(batch);375 assert(hc);376 362 batch_control_read(batch); 377 363 ret = hc_schedule(hc, batch); -
uspace/drv/uhci-hcd/pci.c
r14e7959 r5499a8b 52 52 * @return Error code. 53 53 */ 54 int pci_get_my_registers( constddf_dev_t *dev,54 int pci_get_my_registers(ddf_dev_t *dev, 55 55 uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no) 56 56 { 57 assert(dev); 58 assert(io_reg_address); 59 assert(io_reg_size); 60 assert(irq_no); 57 assert(dev != NULL); 61 58 62 59 int parent_phone = … … 69 66 int rc = hw_res_get_resource_list(parent_phone, &hw_resources); 70 67 if (rc != EOK) { 71 async_hangup(parent_phone); 72 return rc; 68 goto leave; 73 69 } 74 70 … … 82 78 size_t i; 83 79 for (i = 0; i < hw_resources.count; i++) { 84 consthw_resource_t *res = &hw_resources.resources[i];80 hw_resource_t *res = &hw_resources.resources[i]; 85 81 switch (res->type) 86 82 { … … 103 99 } 104 100 } 105 async_hangup(parent_phone);106 101 107 if (!io_found || !irq_found) 108 return ENOENT; 102 if (!io_found || !irq_found) { 103 rc = ENOENT; 104 goto leave; 105 } 109 106 110 107 *io_reg_address = io_address; … … 112 109 *irq_no = irq; 113 110 114 return EOK; 111 rc = EOK; 112 leave: 113 async_hangup(parent_phone); 114 return rc; 115 115 } 116 116 /*----------------------------------------------------------------------------*/ … … 120 120 * @return Error code. 121 121 */ 122 int pci_enable_interrupts( constddf_dev_t *device)122 int pci_enable_interrupts(ddf_dev_t *device) 123 123 { 124 const int parent_phone = 125 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 126 if (parent_phone < 0) { 127 return parent_phone; 128 } 129 const bool enabled = hw_res_enable_interrupt(parent_phone); 124 int parent_phone = devman_parent_device_connect(device->handle, 125 IPC_FLAG_BLOCKING); 126 bool enabled = hw_res_enable_interrupt(parent_phone); 130 127 async_hangup(parent_phone); 131 128 return enabled ? EOK : EIO; … … 137 134 * @return Error code. 138 135 */ 139 int pci_disable_legacy( constddf_dev_t *device)136 int pci_disable_legacy(ddf_dev_t *device) 140 137 { 141 138 assert(device); 142 constint parent_phone =139 int parent_phone = 143 140 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 144 141 if (parent_phone < 0) { … … 148 145 /* See UHCI design guide for these values p.45, 149 146 * write all WC bits in USB legacy register */ 150 constsysarg_t address = 0xc0;151 constsysarg_t value = 0xaf00;147 sysarg_t address = 0xc0; 148 sysarg_t value = 0xaf00; 152 149 153 constint rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),150 int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), 154 151 IPC_M_CONFIG_SPACE_WRITE_16, address, value); 155 152 async_hangup(parent_phone); -
uspace/drv/uhci-hcd/pci.h
r14e7959 r5499a8b 38 38 #include <ddf/driver.h> 39 39 40 int pci_get_my_registers( constddf_dev_t *, uintptr_t *, size_t *, int *);41 int pci_enable_interrupts( constddf_dev_t *);42 int pci_disable_legacy( constddf_dev_t *);40 int pci_get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *); 41 int pci_enable_interrupts(ddf_dev_t *); 42 int pci_disable_legacy(ddf_dev_t *); 43 43 44 44 #endif -
uspace/drv/uhci-hcd/root_hub.c
r14e7959 r5499a8b 60 60 return ret; 61 61 } 62 assert(match_str);63 62 64 63 ret = ddf_fun_add_match_id(fun, match_str, 100); -
uspace/drv/uhci-hcd/root_hub.h
r14e7959 r5499a8b 43 43 /** List of resources available to the root hub. */ 44 44 hw_resource_list_t resource_list; 45 /** The only resource in the RH resource list */45 /** The only resource in the above list */ 46 46 hw_resource_t io_regs; 47 47 } rh_t; -
uspace/drv/uhci-hcd/transfer_list.c
r14e7959 r5499a8b 36 36 #include <arch/barrier.h> 37 37 38 39 38 #include "transfer_list.h" 40 #include "batch.h"41 39 42 40 static void transfer_list_remove_batch( … … 60 58 return ENOMEM; 61 59 } 62 constuint32_t queue_head_pa = addr_to_phys(instance->queue_head);60 uint32_t queue_head_pa = addr_to_phys(instance->queue_head); 63 61 usb_log_debug2("Transfer list %s setup with QH: %p (%#" PRIx32" ).\n", 64 62 name, instance->queue_head, queue_head_pa); … … 92 90 { 93 91 assert(instance); 94 assert(instance->queue_head);95 92 assert(next); 93 if (!instance->queue_head) 94 return; 96 95 /* Set queue_head.next to point to the follower */ 97 96 qh_set_next_qh(instance->queue_head, next->queue_head); … … 138 137 write_barrier(); 139 138 140 /* Add to the driver 'slist */139 /* Add to the driver list */ 141 140 list_append(&batch->link, &instance->batch_list); 142 141 … … 161 160 link_t *current = instance->batch_list.next; 162 161 while (current != &instance->batch_list) { 163 link_t * constnext = current->next;162 link_t *next = current->next; 164 163 usb_transfer_batch_t *batch = 165 164 usb_transfer_batch_from_link(current); … … 183 182 fibril_mutex_lock(&instance->guard); 184 183 while (!list_empty(&instance->batch_list)) { 185 link_t * constcurrent = instance->batch_list.next;184 link_t *current = instance->batch_list.next; 186 185 usb_transfer_batch_t *batch = 187 186 usb_transfer_batch_from_link(current); -
uspace/drv/uhci-hcd/transfer_list.h
r14e7959 r5499a8b 36 36 37 37 #include <fibril_synch.h> 38 #include <usb/host/batch.h>39 38 39 #include "batch.h" 40 40 #include "hw_struct/queue_head.h" 41 41 -
uspace/drv/uhci-hcd/uhci.c
r14e7959 r5499a8b 77 77 { 78 78 assert(dev); 79 uhci_t *uhci = dev->driver_data; 80 assert(uhci); 81 hc_t *hc = &uhci->hc; 79 hc_t *hc = &((uhci_t*)dev->driver_data)->hc; 82 80 uint16_t status = IPC_GET_ARG1(*call); 83 81 assert(hc); … … 146 144 { 147 145 assert(fun); 148 rh_t *rh = fun->driver_data; 149 assert(rh); 150 return &rh->resource_list; 146 return &((rh_t*)fun->driver_data)->resource_list; 151 147 } 152 148 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-hcd/uhci.h
r14e7959 r5499a8b 35 35 #ifndef DRV_UHCI_UHCI_H 36 36 #define DRV_UHCI_UHCI_H 37 #include <ddi.h> 37 38 #include <ddf/driver.h> 38 39 -
uspace/drv/uhci-hcd/utils/malloc32.h
r14e7959 r5499a8b 41 41 #include <as.h> 42 42 43 #include "slab.h" 44 43 45 #define UHCI_STRCUTURES_ALIGNMENT 16 44 46 #define UHCI_REQUIRED_PAGE_SIZE 4096 … … 57 59 uintptr_t result; 58 60 const int ret = as_get_physical_mapping(addr, &result); 61 assert(ret == EOK); 62 59 63 if (ret != EOK) 60 64 return 0; … … 68 72 */ 69 73 static inline void * malloc32(size_t size) { 70 /* This works only when the host has less than 4GB of memory as 71 * physical address needs to fit into 32 bits */ 72 73 /* If we need more than one page there is no guarantee that the 74 * memory will be continuous */ 75 if (size > PAGE_SIZE) 76 return NULL; 77 /* Calculate alignment to make sure the block won't cross page 78 * boundary */ 79 size_t alignment = UHCI_STRCUTURES_ALIGNMENT; 80 while (alignment < size) 81 alignment *= 2; 82 return memalign(alignment, size); 74 if (size <= SLAB_ELEMENT_SIZE) 75 return slab_malloc_g(); 76 usb_log_warning("Requested %zu bytes, current allocator can't handle " 77 "that amount, pray that the standard malloc will suffice.", size); 78 return memalign(UHCI_STRCUTURES_ALIGNMENT, size); 83 79 } 84 80 /*----------------------------------------------------------------------------*/ … … 90 86 if (!addr) 91 87 return; 88 if (slab_in_range_g(addr)) 89 return slab_free_g(addr); 92 90 free(addr); 93 91 } … … 100 98 { 101 99 void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 100 assert(free_address); /* TODO: remove this assert */ 102 101 if (free_address == 0) 103 102 return NULL; -
uspace/drv/uhci-rhd/main.c
r14e7959 r5499a8b 37 37 #include <errno.h> 38 38 #include <str_error.h> 39 40 39 #include <usb_iface.h> 41 40 #include <usb/ddfiface.h> … … 46 45 #define NAME "uhci-rhd" 47 46 48 static int hc_get_my_registers( constddf_dev_t *dev,47 static int hc_get_my_registers(ddf_dev_t *dev, 49 48 uintptr_t *io_reg_address, size_t *io_reg_size); 50 49 /*----------------------------------------------------------------------------*/ … … 131 130 */ 132 131 int hc_get_my_registers( 133 constddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)132 ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size) 134 133 { 135 assert(dev );134 assert(dev != NULL); 136 135 137 constint parent_phone = devman_parent_device_connect(dev->handle,136 int parent_phone = devman_parent_device_connect(dev->handle, 138 137 IPC_FLAG_BLOCKING); 139 138 if (parent_phone < 0) { … … 142 141 143 142 hw_resource_list_t hw_resources; 144 constint ret = hw_res_get_resource_list(parent_phone, &hw_resources);143 int ret = hw_res_get_resource_list(parent_phone, &hw_resources); 145 144 if (ret != EOK) { 146 145 async_hangup(parent_phone); -
uspace/drv/uhci-rhd/port.c
r14e7959 r5499a8b 36 36 #include <errno.h> 37 37 #include <str_error.h> 38 #include <time.h> 38 39 #include <async.h> 39 40 … … 81 82 * @param[in] number Port number. 82 83 * @param[in] usec Polling interval. 83 * @param[in] rh Pointer to ddf instance ofthe root hub driver.84 * @param[in] rh Pointer to ddf instance fo the root hub driver. 84 85 * @return Error code. 85 86 * … … 90 91 { 91 92 assert(port); 92 char *id_string; 93 asprintf(&id_string, "Port (%p - %u)", port, number); 94 if (id_string == NULL) { 93 asprintf(&port->id_string, "Port (%p - %u)", port, number); 94 if (port->id_string == NULL) { 95 95 return ENOMEM; 96 96 } 97 97 98 port->id_string = id_string;99 98 port->address = address; 100 99 port->number = number; … … 106 105 usb_hc_connection_initialize_from_device(&port->hc_connection, rh); 107 106 if (ret != EOK) { 108 usb_log_error("%s: failed to initialize connection to HC.", 109 port->id_string); 110 free(id_string); 107 usb_log_error("Failed to initialize connection to HC."); 111 108 return ret; 112 109 } … … 116 113 usb_log_error("%s: failed to create polling fibril.", 117 114 port->id_string); 118 free(id_string);119 115 return ENOMEM; 120 116 } … … 136 132 assert(port); 137 133 free(port->id_string); 138 / / TODO: Kill fibril here134 /* TODO: Kill fibril here */ 139 135 return; 140 136 } … … 154 150 155 151 /* Read register value */ 156 const port_status_t port_status = 157 uhci_port_read_status(instance); 152 port_status_t port_status = uhci_port_read_status(instance); 158 153 159 154 /* Print the value if it's interesting */ … … 166 161 usb_log_debug("%s: Connected change detected: %x.\n", 167 162 instance->id_string, port_status); 163 164 int rc = 165 usb_hc_connection_open(&instance->hc_connection); 166 if (rc != EOK) { 167 usb_log_error("%s: Failed to connect to HC.", 168 instance->id_string); 169 continue; 170 } 168 171 169 172 /* Remove any old device */ … … 172 175 instance->id_string); 173 176 uhci_port_remove_device(instance); 174 }175 176 int ret =177 usb_hc_connection_open(&instance->hc_connection);178 if (ret != EOK) {179 usb_log_error("%s: Failed to connect to HC.",180 instance->id_string);181 continue;182 177 } 183 178 … … 195 190 } 196 191 197 r et= usb_hc_connection_close(&instance->hc_connection);198 if (r et!= EOK) {192 rc = usb_hc_connection_close(&instance->hc_connection); 193 if (rc != EOK) { 199 194 usb_log_error("%s: Failed to disconnect.", 200 195 instance->id_string); … … 214 209 int uhci_port_reset_enable(int portno, void *arg) 215 210 { 216 uhci_port_t *port = arg; 217 assert(port); 211 uhci_port_t *port = (uhci_port_t *) arg; 218 212 219 213 usb_log_debug2("%s: new_device_enable_port.\n", port->id_string); … … 289 283 usb_log_error("%s: Don't know how to remove device %" PRIun ".\n", 290 284 port->id_string, port->attached_device); 291 port->attached_device = 0;292 285 return ENOTSUP; 293 286 } -
uspace/drv/uhci-rhd/port.h
r14e7959 r5499a8b 38 38 #include <fibril.h> 39 39 #include <ddf/driver.h> 40 #include <usb/ hc.h> /* usb_hc_connection_t */40 #include <usb/dev/hc.h> /* usb_hc_connection_t */ 41 41 42 42 typedef uint16_t port_status_t; … … 57 57 typedef struct uhci_port 58 58 { 59 c onst char *id_string;59 char *id_string; 60 60 port_status_t *address; 61 61 unsigned number; -
uspace/lib/usb/Makefile
r14e7959 r5499a8b 37 37 src/ddfiface.c \ 38 38 src/debug.c \ 39 src/driver.c \ 39 40 src/dump.c \ 40 src/hc.c \ 41 src/resolve.c \ 41 src/host.c \ 42 42 src/usb.c 43 43 -
uspace/lib/usb/src/ddfiface.c
r14e7959 r5499a8b 37 37 #include <async.h> 38 38 #include <usb/ddfiface.h> 39 #include <usb/ hc.h>39 #include <usb/driver.h> 40 40 #include <usb/debug.h> 41 41 #include <errno.h> -
uspace/lib/usbdev/Makefile
r14e7959 r5499a8b 46 46 src/pipesio.c \ 47 47 src/recognise.c \ 48 src/request.c 48 src/request.c \ 49 src/usbdevice.c 49 50 50 51 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/usbdev/include/usb/dev/hub.h
r14e7959 r5499a8b 39 39 40 40 #include <sys/types.h> 41 #include <usb/ hc.h>41 #include <usb/dev/hc.h> 42 42 43 43 int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t, … … 63 63 const usb_hc_attached_device_t *); 64 64 int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t); 65 int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t, 66 devman_handle_t *); 65 67 66 68 #endif -
uspace/lib/usbdev/include/usb/dev/pipes.h
r14e7959 r5499a8b 38 38 #include <sys/types.h> 39 39 #include <usb/usb.h> 40 #include <usb/ hc.h>40 #include <usb/dev/hc.h> 41 41 #include <usb/descriptor.h> 42 42 #include <ipc/devman.h> … … 163 163 164 164 int usb_device_get_assigned_interface(ddf_dev_t *); 165 usb_address_t usb_device_get_assigned_address(devman_handle_t); 165 166 166 167 int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *, -
uspace/lib/usbdev/src/hub.c
r14e7959 r5499a8b 120 120 } 121 121 122 /** Get handle of USB device with given address. 123 * 124 * @param[in] connection Opened connection to host controller. 125 * @param[in] address Address of device in question. 126 * @param[out] handle Where to write the device handle. 127 * @return Error code. 128 */ 129 int usb_hc_get_handle_by_address(usb_hc_connection_t *connection, 130 usb_address_t address, devman_handle_t *handle) 131 { 132 CHECK_CONNECTION(connection); 133 134 sysarg_t tmp; 135 int rc = async_req_2_1(connection->hc_phone, 136 DEV_IFACE_ID(USBHC_DEV_IFACE), 137 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, 138 address, &tmp); 139 if ((rc == EOK) && (handle != NULL)) { 140 *handle = tmp; 141 } 142 143 return rc; 144 } 122 145 123 146 static void unregister_control_endpoint_on_default_address( -
uspace/lib/usbdev/src/pipes.c
r14e7959 r5499a8b 36 36 #include <usb/dev/pipes.h> 37 37 #include <usb/debug.h> 38 #include <usb/ hc.h>38 #include <usb/driver.h> 39 39 #include <usbhc_iface.h> 40 40 #include <usb_iface.h> … … 97 97 98 98 return (int) iface_no; 99 } 100 101 /** Tell USB address assigned to given device. 102 * 103 * @param dev_handle Devman handle of the USB device in question. 104 * @return USB address or negative error code. 105 */ 106 usb_address_t usb_device_get_assigned_address(devman_handle_t dev_handle) 107 { 108 int parent_phone = devman_parent_device_connect(dev_handle, 109 IPC_FLAG_BLOCKING); 110 if (parent_phone < 0) { 111 return parent_phone; 112 } 113 114 sysarg_t address; 115 116 int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 117 IPC_M_USB_GET_ADDRESS, 118 dev_handle, &address); 119 120 if (rc != EOK) { 121 return rc; 122 } 123 124 async_hangup(parent_phone); 125 126 return (usb_address_t) address; 99 127 } 100 128
Note:
See TracChangeset
for help on using the changeset viewer.
