Changes in / [05e21ffc:4a7a8d4] in mainline
- Location:
- uspace
- Files:
-
- 55 added
- 51 deleted
- 60 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r05e21ffc r4a7a8d4 179 179 ifeq ($(UARCH),amd64) 180 180 LIBS += lib/usb 181 LIBS += lib/usbhost 182 LIBS += lib/usbdev 183 LIBS += lib/usbhid 181 184 LIBS += lib/usbvirt 182 185 endif … … 184 187 ifeq ($(UARCH),ia32) 185 188 LIBS += lib/usb 189 LIBS += lib/usbhost 190 LIBS += lib/usbdev 191 LIBS += lib/usbhid 186 192 LIBS += lib/usbvirt 187 193 endif -
uspace/Makefile.common
r05e21ffc r4a7a8d4 88 88 89 89 LIBUSB_PREFIX = $(LIB_PREFIX)/usb 90 LIBUSBHOST_PREFIX = $(LIB_PREFIX)/usbhost 91 LIBUSBDEV_PREFIX = $(LIB_PREFIX)/usbdev 92 LIBUSBHID_PREFIX = $(LIB_PREFIX)/usbhid 90 93 LIBUSBVIRT_PREFIX = $(LIB_PREFIX)/usbvirt 91 94 LIBDRV_PREFIX = $(LIB_PREFIX)/drv -
uspace/app/lsusb/Makefile
r05e21ffc r4a7a8d4 30 30 BINARY = lsusb 31 31 32 LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBDRV_PREFIX)/libdrv.a 33 EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include 32 LIBS = \ 33 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 34 $(LIBUSB_PREFIX)/libusb.a \ 35 $(LIBDRV_PREFIX)/libdrv.a 36 EXTRA_CFLAGS = \ 37 -I$(LIBUSB_PREFIX)/include \ 38 -I$(LIBUSBDEV_PREFIX)/include \ 39 -I$(LIBDRV_PREFIX)/include 34 40 35 41 SOURCES = \ -
uspace/app/lsusb/main.c
r05e21ffc r4a7a8d4 44 44 #include <devman.h> 45 45 #include <devmap.h> 46 #include <usb/hub.h> 46 47 #include <usb/host.h> 47 48 48 49 #define NAME "lsusb" 49 50 50 #define MAX_FAILED_ATTEMPTS 451 #define MAX_FAILED_ATTEMPTS 10 51 52 #define MAX_PATH_LENGTH 1024 53 54 static void print_found_hc(size_t class_index, const char *path) 55 { 56 // printf(NAME ": host controller %zu is `%s'.\n", class_index, path); 57 printf("Bus %02zu: %s\n", class_index, path); 58 } 59 static void print_found_dev(usb_address_t addr, const char *path) 60 { 61 // printf(NAME ": device with address %d is `%s'.\n", addr, path); 62 printf(" Device %02d: %s\n", addr, path); 63 } 64 65 static void print_hc_devices(devman_handle_t hc_handle) 66 { 67 int rc; 68 usb_hc_connection_t conn; 69 70 usb_hc_connection_initialize(&conn, hc_handle); 71 rc = usb_hc_connection_open(&conn); 72 if (rc != EOK) { 73 printf(NAME ": failed to connect to HC: %s.\n", 74 str_error(rc)); 75 return; 76 } 77 usb_address_t addr; 78 for (addr = 1; addr < 5; addr++) { 79 devman_handle_t dev_handle; 80 rc = usb_hc_get_handle_by_address(&conn, addr, &dev_handle); 81 if (rc != EOK) { 82 continue; 83 } 84 char path[MAX_PATH_LENGTH]; 85 rc = devman_get_device_path(dev_handle, path, MAX_PATH_LENGTH); 86 if (rc != EOK) { 87 continue; 88 } 89 print_found_dev(addr, path); 90 } 91 usb_hc_connection_close(&conn); 92 } 52 93 53 94 int main(int argc, char *argv[]) … … 69 110 continue; 70 111 } 71 print f(NAME ": host controller %zu is `%s'.\n",72 class_index, path);112 print_found_hc(class_index, path); 113 print_hc_devices(hc_handle); 73 114 } 74 115 -
uspace/app/tester/Makefile
r05e21ffc r4a7a8d4 31 31 BINARY = tester 32 32 33 LIBS += $(LIBUSB_PREFIX)/libusb.a34 EXTRA_CFLAGS += -I$(LIBUSB_PREFIX)/include35 36 33 SOURCES = \ 37 34 tester.c \ 38 adt/usbaddrkeep.c \39 35 thread/thread1.c \ 40 36 print/print1.c \ -
uspace/app/tester/tester.c
r05e21ffc r4a7a8d4 64 64 #include "mm/mapping1.def" 65 65 #include "hw/serial/serial1.def" 66 #include "adt/usbaddrkeep.def"67 66 #include "hw/misc/virtchar1.def" 68 67 #include "devs/devman1.def" -
uspace/app/tester/tester.h
r05e21ffc r4a7a8d4 80 80 extern const char *test_mapping1(void); 81 81 extern const char *test_serial1(void); 82 extern const char *test_usbaddrkeep(void);83 82 extern const char *test_virtchar1(void); 84 83 extern const char *test_devman1(void); -
uspace/app/usbinfo/Makefile
r05e21ffc r4a7a8d4 30 30 BINARY = usbinfo 31 31 32 LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBDRV_PREFIX)/libdrv.a 33 EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include 32 LIBS = \ 33 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 34 $(LIBUSB_PREFIX)/libusb.a \ 35 $(LIBDRV_PREFIX)/libdrv.a 36 EXTRA_CFLAGS = \ 37 -I$(LIBUSB_PREFIX)/include \ 38 -I$(LIBUSBDEV_PREFIX)/include \ 39 -I$(LIBDRV_PREFIX)/include 34 40 35 41 SOURCES = \ -
uspace/app/usbinfo/dev.c
r05e21ffc r4a7a8d4 40 40 #include "usbinfo.h" 41 41 42 usbinfo_device_t *prepare_device( devman_handle_t hc_handle,43 usb_address_t dev_addr)42 usbinfo_device_t *prepare_device(const char *name, 43 devman_handle_t hc_handle, usb_address_t dev_addr) 44 44 { 45 45 usbinfo_device_t *dev = malloc(sizeof(usbinfo_device_t)); … … 55 55 if (rc != EOK) { 56 56 fprintf(stderr, 57 NAME ": failed to create connection to the device: %s.\n",58 str_error(rc));57 NAME ": failed to create connection to device %s: %s.\n", 58 name, str_error(rc)); 59 59 goto leave; 60 60 } … … 64 64 if (rc != EOK) { 65 65 fprintf(stderr, 66 NAME ": failed to create default control pipe : %s.\n",67 str_error(rc));66 NAME ": failed to create default control pipe to %s: %s.\n", 67 name, str_error(rc)); 68 68 goto leave; 69 69 } … … 71 71 rc = usb_pipe_probe_default_control(&dev->ctrl_pipe); 72 72 if (rc != EOK) { 73 fprintf(stderr, 74 NAME ": probing default control pipe failed: %s.\n", 75 str_error(rc)); 73 if (rc == ENOENT) { 74 fprintf(stderr, NAME ": " \ 75 "device %s not present or malfunctioning.\n", 76 name); 77 } else { 78 fprintf(stderr, NAME ": " \ 79 "probing default control pipe of %s failed: %s.\n", 80 name, str_error(rc)); 81 } 76 82 goto leave; 77 83 } … … 84 90 if (rc != EOK) { 85 91 fprintf(stderr, 86 NAME ": failed to retrieve device descriptor : %s.\n",87 str_error(rc));92 NAME ": failed to retrieve device descriptor of %s: %s.\n", 93 name, str_error(rc)); 88 94 goto leave; 89 95 } … … 93 99 &dev->full_configuration_descriptor_size); 94 100 if (rc != EOK) { 95 fprintf(stderr, 96 NAME ": failed to retrieve configuration descriptor: %s.\n",97 str_error(rc));101 fprintf(stderr, NAME ": " \ 102 "failed to retrieve configuration descriptor of %s: %s.\n", 103 name, str_error(rc)); 98 104 goto leave; 99 105 } -
uspace/app/usbinfo/info.c
r05e21ffc r4a7a8d4 41 41 #include <usb/request.h> 42 42 #include <usb/classes/classes.h> 43 #include <usb/classes/hid.h>44 43 #include <usb/classes/hub.h> 45 44 #include "usbinfo.h" -
uspace/app/usbinfo/main.c
r05e21ffc r4a7a8d4 46 46 #include <usb/pipes.h> 47 47 #include <usb/host.h> 48 #include <usb/driver.h> 48 49 #include "usbinfo.h" 49 50 … … 308 309 } 309 310 310 usbinfo_device_t *dev = prepare_device(hc_handle, dev_addr); 311 usbinfo_device_t *dev = prepare_device(devpath, 312 hc_handle, dev_addr); 311 313 if (dev == NULL) { 312 314 continue; -
uspace/app/usbinfo/usbinfo.h
r05e21ffc r4a7a8d4 71 71 } 72 72 73 usbinfo_device_t *prepare_device( devman_handle_t, usb_address_t);73 usbinfo_device_t *prepare_device(const char *, devman_handle_t, usb_address_t); 74 74 void destroy_device(usbinfo_device_t *); 75 75 -
uspace/app/vuhid/Makefile
r05e21ffc r4a7a8d4 34 34 LIBS = \ 35 35 $(LIBUSBVIRT_PREFIX)/libusbvirt.a \ 36 $(LIBUSBHID_PREFIX)/libusbhid.a \ 37 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 36 38 $(LIBUSB_PREFIX)/libusb.a 37 39 EXTRA_CFLAGS = \ 38 40 -I$(LIBUSB_PREFIX)/include \ 41 -I$(LIBUSBDEV_PREFIX)/include \ 42 -I$(LIBUSBHID_PREFIX)/include \ 39 43 -I$(LIBUSBVIRT_PREFIX)/include \ 40 44 -I$(LIBDRV_PREFIX)/include -
uspace/drv/ehci-hcd/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I. 30 31 LIBS = \ 32 $(LIBUSBHOST_PREFIX)/libusbhost.a \ 33 $(LIBUSB_PREFIX)/libusb.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 35 EXTRA_CFLAGS += \ 36 -I$(LIBUSB_PREFIX)/include \ 37 -I$(LIBUSBHOST_PREFIX)/include \ 38 -I$(LIBDRV_PREFIX)/include 39 32 40 BINARY = ehci-hcd 33 41 -
uspace/drv/ehci-hcd/hc_iface.c
r05e21ffc r4a7a8d4 106 106 } 107 107 108 /** Find device handle by USB address. 109 * 110 * @param[in] fun DDF function that was called. 111 * @param[in] address Address in question. 112 * @param[out] handle Where to store device handle if found. 113 * @return Error code. 114 */ 115 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 116 devman_handle_t *handle) 117 { 118 UNSUPPORTED("find_by_address"); 119 120 return ENOTSUP; 121 } 122 108 123 /** Release previously requested address. 109 124 * … … 321 336 .request_address = request_address, 322 337 .bind_address = bind_address, 338 .find_by_address = find_by_address, 323 339 .release_address = release_address, 324 340 -
uspace/drv/ehci-hcd/pci.c
r05e21ffc r4a7a8d4 54 54 55 55 #define CMD_OFFSET 0x0 56 #define CONFIGFLAG_OFFSET 0x40 56 #define STS_OFFSET 0x4 57 #define CFG_OFFSET 0x40 57 58 58 59 #define USBCMD_RUN 1 … … 264 265 * It would prevent pre-OS code from interfering. */ 265 266 ret = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), 266 IPC_M_CONFIG_SPACE_WRITE_32, eecp + USBLEGCTLSTS_OFFSET, 0); 267 IPC_M_CONFIG_SPACE_WRITE_32, eecp + USBLEGCTLSTS_OFFSET, 268 0xe0000000); 267 269 CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) zero USBLEGCTLSTS.\n", ret); 268 usb_log_debug("Zeroed USBLEGCTLSTS register.\n");269 270 270 271 /* Read again Legacy Support and Control register */ … … 291 292 volatile uint32_t *usbcmd = 292 293 (uint32_t*)((uint8_t*)registers + operation_offset + CMD_OFFSET); 294 volatile uint32_t *usbsts = 295 (uint32_t*)((uint8_t*)registers + operation_offset + STS_OFFSET); 293 296 volatile uint32_t *usbconfigured = 294 (uint32_t*)((uint8_t*)registers + operation_offset 295 + CONFIGFLAG_OFFSET); 297 (uint32_t*)((uint8_t*)registers + operation_offset + CFG_OFFSET); 296 298 usb_log_debug("USBCMD value: %x.\n", *usbcmd); 297 299 if (*usbcmd & USBCMD_RUN) { 298 300 *usbcmd = 0; 301 while (!(*usbsts & (1 << 12))); /*wait until hc is halted */ 299 302 *usbconfigured = 0; 300 303 usb_log_info("EHCI turned off.\n"); … … 302 305 usb_log_info("EHCI was not running.\n"); 303 306 } 307 usb_log_debug("Registers: %x(0x00080000):%x(0x00001000):%x(0x0).\n", 308 *usbcmd, *usbsts, *usbconfigured); 304 309 305 310 async_hangup(parent_phone); -
uspace/drv/ohci/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I. 30 31 LIBS = \ 32 $(LIBUSBHOST_PREFIX)/libusbhost.a \ 33 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 34 $(LIBUSB_PREFIX)/libusb.a \ 35 $(LIBDRV_PREFIX)/libdrv.a 36 EXTRA_CFLAGS += \ 37 -I$(LIBUSB_PREFIX)/include \ 38 -I$(LIBUSBDEV_PREFIX)/include \ 39 -I$(LIBUSBHOST_PREFIX)/include \ 40 -I$(LIBDRV_PREFIX)/include 41 32 42 BINARY = ohci 33 43 -
uspace/drv/ohci/hc.c
r05e21ffc r4a7a8d4 40 40 #include <usb/usb.h> 41 41 #include <usb/ddfiface.h> 42 #include <usb/usbdevice.h>43 42 44 43 #include "hc.h" … … 95 94 } 96 95 /*----------------------------------------------------------------------------*/ 97 int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev, 98 uintptr_t regs, size_t reg_size, bool interrupts) 96 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts) 99 97 { 100 98 assert(instance); -
uspace/drv/ohci/hc.h
r05e21ffc r4a7a8d4 77 77 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 78 78 79 int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev, 80 uintptr_t regs, size_t reg_size, bool interrupts); 79 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts); 81 80 82 81 void hc_start_hw(hc_t *instance); -
uspace/drv/ohci/hw_struct/endpoint_descriptor.h
r05e21ffc r4a7a8d4 40 40 #include <usb/host/endpoint.h> 41 41 42 #include " utils/malloc32.h"42 #include "../utils/malloc32.h" 43 43 #include "transfer_descriptor.h" 44 44 -
uspace/drv/ohci/hw_struct/transfer_descriptor.c
r05e21ffc r4a7a8d4 33 33 */ 34 34 #include <usb/usb.h> 35 #include "utils/malloc32.h"36 37 35 #include "transfer_descriptor.h" 38 36 -
uspace/drv/ohci/hw_struct/transfer_descriptor.h
r05e21ffc r4a7a8d4 37 37 #include <bool.h> 38 38 #include <stdint.h> 39 #include " utils/malloc32.h"39 #include "../utils/malloc32.h" 40 40 41 41 #include "completion_codes.h" -
uspace/drv/ohci/iface.c
r05e21ffc r4a7a8d4 122 122 return EOK; 123 123 } 124 125 126 /** Find device handle by address interface function. 127 * 128 * @param[in] fun DDF function that was called. 129 * @param[in] address Address in question. 130 * @param[out] handle Where to store device handle if found. 131 * @return Error code. 132 */ 133 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 134 devman_handle_t *handle) 135 { 136 assert(fun); 137 hc_t *hc = fun_to_hc(fun); 138 assert(hc); 139 bool found = 140 usb_device_keeper_find_by_address(&hc->manager, address, handle); 141 return found ? EOK : ENOENT; 142 } 143 124 144 /*----------------------------------------------------------------------------*/ 125 145 /** Release address interface function … … 402 422 .request_address = request_address, 403 423 .bind_address = bind_address, 424 .find_by_address = find_by_address, 404 425 .release_address = release_address, 405 426 -
uspace/drv/ohci/main.c
r05e21ffc r4a7a8d4 43 43 #define NAME "ohci" 44 44 45 static int ohci_add_device(ddf_dev_t *device); 45 /** Initializes a new ddf driver instance of OHCI hcd. 46 * 47 * @param[in] device DDF instance of the device to initialize. 48 * @return Error code. 49 */ 50 static int ohci_add_device(ddf_dev_t *device) 51 { 52 usb_log_debug("ohci_add_device() called\n"); 53 assert(device); 54 55 int ret = device_setup_ohci(device); 56 if (ret != EOK) { 57 usb_log_error("Failed to initialize OHCI driver: %s.\n", 58 str_error(ret)); 59 return ret; 60 } 61 usb_log_info("Controlling new OHCI device '%s'.\n", device->name); 62 63 return EOK; 64 } 46 65 /*----------------------------------------------------------------------------*/ 47 66 static driver_ops_t ohci_driver_ops = { … … 53 72 .driver_ops = &ohci_driver_ops 54 73 }; 55 /*----------------------------------------------------------------------------*/56 /** Initializes a new ddf driver instance of OHCI hcd.57 *58 * @param[in] device DDF instance of the device to initialize.59 * @return Error code.60 */61 int ohci_add_device(ddf_dev_t *device)62 {63 usb_log_debug("ohci_add_device() called\n");64 assert(device);65 ohci_t *ohci = malloc(sizeof(ohci_t));66 if (ohci == NULL) {67 usb_log_error("Failed to allocate OHCI driver.\n");68 return ENOMEM;69 }70 71 int ret = ohci_init(ohci, device);72 if (ret != EOK) {73 usb_log_error("Failed to initialize OHCI driver: %s.\n",74 str_error(ret));75 return ret;76 }77 // device->driver_data = ohci;78 hc_register_hub(&ohci->hc, ohci->rh_fun);79 80 usb_log_info("Controlling new OHCI device `%s'.\n", device->name);81 82 return EOK;83 }84 74 /*----------------------------------------------------------------------------*/ 85 75 /** Initializes global driver structures (NONE). -
uspace/drv/ohci/ohci.c
r05e21ffc r4a7a8d4 44 44 #include "iface.h" 45 45 #include "pci.h" 46 #include "hc.h" 47 #include "root_hub.h" 48 49 typedef struct ohci { 50 ddf_fun_t *hc_fun; 51 ddf_fun_t *rh_fun; 52 53 hc_t hc; 54 rh_t rh; 55 } ohci_t; 56 57 static inline ohci_t * dev_to_ohci(ddf_dev_t *dev) 58 { 59 assert(dev); 60 assert(dev->driver_data); 61 return dev->driver_data; 62 } 46 63 47 64 /** IRQ handling callback, identifies device … … 53 70 static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call) 54 71 { 55 assert(dev); 56 assert(dev->driver_data); 57 hc_t *hc = &((ohci_t*)dev->driver_data)->hc; 58 uint16_t status = IPC_GET_ARG1(*call); 72 hc_t *hc = &dev_to_ohci(dev)->hc; 59 73 assert(hc); 74 const uint16_t status = IPC_GET_ARG1(*call); 60 75 hc_interrupt(hc, status); 61 76 } … … 71 86 { 72 87 assert(fun); 73 usb_device_keeper_t *manager = & ((ohci_t*)fun->dev->driver_data)->hc.manager;88 usb_device_keeper_t *manager = &dev_to_ohci(fun->dev)->hc.manager; 74 89 75 90 usb_address_t addr = usb_device_keeper_find(manager, handle); … … 94 109 ddf_fun_t *fun, devman_handle_t *handle) 95 110 { 96 assert(handle); 97 ddf_fun_t *hc_fun = ((ohci_t*)fun->dev->driver_data)->hc_fun; 98 assert(hc_fun != NULL); 99 100 *handle = hc_fun->handle; 111 assert(fun); 112 ddf_fun_t *hc_fun = dev_to_ohci(fun->dev)->hc_fun; 113 assert(hc_fun); 114 115 if (handle != NULL) 116 *handle = hc_fun->handle; 101 117 return EOK; 102 118 } 103 119 /*----------------------------------------------------------------------------*/ 104 /** This iface is generic for both RH and HC.*/120 /** Root hub USB interface */ 105 121 static usb_iface_t usb_iface = { 106 122 .get_hc_handle = usb_iface_get_hc_handle, … … 108 124 }; 109 125 /*----------------------------------------------------------------------------*/ 126 /** Standard USB HC options (HC interface) */ 110 127 static ddf_dev_ops_t hc_ops = { 111 128 .interfaces[USBHC_DEV_IFACE] = &hc_iface, /* see iface.h/c */ 112 129 }; 113 130 /*----------------------------------------------------------------------------*/ 131 /** Standard USB RH options (RH interface) */ 114 132 static ddf_dev_ops_t rh_ops = { 115 133 .interfaces[USB_DEV_IFACE] = &usb_iface, … … 118 136 /** Initialize hc and rh ddf structures and their respective drivers. 119 137 * 138 * @param[in] device DDF instance of the device to use. 120 139 * @param[in] instance OHCI structure to use. 121 * @param[in] device DDF instance of the device to use.122 140 * 123 141 * This function does all the preparatory work for hc and rh drivers: … … 127 145 * - registers interrupt handler 128 146 */ 129 int ohci_init(ohci_t *instance, ddf_dev_t *device) 130 { 131 assert(instance); 132 instance->hc_fun = NULL; 147 int device_setup_ohci(ddf_dev_t *device) 148 { 149 ohci_t *instance = malloc(sizeof(ohci_t)); 150 if (instance == NULL) { 151 usb_log_error("Failed to allocate OHCI driver.\n"); 152 return ENOMEM; 153 } 154 155 #define CHECK_RET_DEST_FREE_RETURN(ret, message...) \ 156 if (ret != EOK) { \ 157 if (instance->hc_fun) { \ 158 instance->hc_fun->ops = NULL; \ 159 instance->hc_fun->driver_data = NULL; \ 160 ddf_fun_destroy(instance->hc_fun); \ 161 } \ 162 if (instance->rh_fun) { \ 163 instance->rh_fun->ops = NULL; \ 164 instance->rh_fun->driver_data = NULL; \ 165 ddf_fun_destroy(instance->rh_fun); \ 166 } \ 167 free(instance); \ 168 usb_log_error(message); \ 169 return ret; \ 170 } else (void)0 171 133 172 instance->rh_fun = NULL; 134 #define CHECK_RET_DEST_FUN_RETURN(ret, message...) \ 135 if (ret != EOK) { \ 136 usb_log_error(message); \ 137 if (instance->hc_fun) \ 138 ddf_fun_destroy(instance->hc_fun); \ 139 if (instance->rh_fun) \ 140 ddf_fun_destroy(instance->rh_fun); \ 141 return ret; \ 142 } 143 144 uintptr_t mem_reg_base = 0; 145 size_t mem_reg_size = 0; 173 instance->hc_fun = ddf_fun_create(device, fun_exposed, "ohci-hc"); 174 int ret = instance->hc_fun ? EOK : ENOMEM; 175 CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create OHCI HC function.\n"); 176 instance->hc_fun->ops = &hc_ops; 177 instance->hc_fun->driver_data = &instance->hc; 178 179 instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci-rh"); 180 ret = instance->rh_fun ? EOK : ENOMEM; 181 CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create OHCI RH function.\n"); 182 instance->rh_fun->ops = &rh_ops; 183 184 uintptr_t reg_base = 0; 185 size_t reg_size = 0; 146 186 int irq = 0; 147 187 148 int ret = 149 pci_get_my_registers(device, &mem_reg_base, &mem_reg_size, &irq); 150 CHECK_RET_DEST_FUN_RETURN(ret, 188 ret = pci_get_my_registers(device, ®_base, ®_size, &irq); 189 CHECK_RET_DEST_FREE_RETURN(ret, 151 190 "Failed to get memory addresses for %" PRIun ": %s.\n", 152 191 device->handle, str_error(ret)); 153 192 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n", 154 (void *) mem_reg_base, mem_reg_size, irq);193 (void *) reg_base, reg_size, irq); 155 194 156 195 bool interrupts = false; 157 196 #ifdef CONFIG_USBHC_NO_INTERRUPTS 158 usb_log_warning("Interrupts disabled in OS config, " \197 usb_log_warning("Interrupts disabled in OS config, " 159 198 "falling back to polling.\n"); 160 199 #else … … 163 202 usb_log_warning("Failed to enable interrupts: %s.\n", 164 203 str_error(ret)); 165 usb_log_info("HW interrupts not available, " \204 usb_log_info("HW interrupts not available, " 166 205 "falling back to polling.\n"); 167 206 } else { … … 171 210 #endif 172 211 173 instance->hc_fun = ddf_fun_create(device, fun_exposed, "ohci-hc"); 174 ret = (instance->hc_fun == NULL) ? ENOMEM : EOK; 175 CHECK_RET_DEST_FUN_RETURN(ret, 176 "Failed(%d) to create HC function.\n", ret); 177 178 ret = hc_init(&instance->hc, instance->hc_fun, device, 179 mem_reg_base, mem_reg_size, interrupts); 180 CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init ohci-hcd.\n", ret); 181 instance->hc_fun->ops = &hc_ops; 182 instance->hc_fun->driver_data = &instance->hc; 183 ret = ddf_fun_bind(instance->hc_fun); 184 CHECK_RET_DEST_FUN_RETURN(ret, 185 "Failed(%d) to bind OHCI device function: %s.\n", 186 ret, str_error(ret)); 187 ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME); 188 CHECK_RET_DEST_FUN_RETURN(ret, 189 "Failed to add OHCI to HC class: %s.\n", str_error(ret)); 190 191 #undef CHECK_RET_HC_RETURN 212 ret = hc_init(&instance->hc, reg_base, reg_size, interrupts); 213 CHECK_RET_DEST_FREE_RETURN(ret, "Failed(%d) to init ohci-hcd.\n", ret); 192 214 193 215 #define CHECK_RET_FINI_RETURN(ret, message...) \ 194 216 if (ret != EOK) { \ 195 usb_log_error(message); \196 if (instance->hc_fun) \197 ddf_fun_destroy(instance->hc_fun); \198 if (instance->rh_fun) \199 ddf_fun_destroy(instance->rh_fun); \200 217 hc_fini(&instance->hc); \ 201 return ret; \202 } 218 CHECK_RET_DEST_FREE_RETURN(ret, message); \ 219 } else (void)0 203 220 204 221 /* It does no harm if we register this on polling */ … … 208 225 "Failed(%d) to register interrupt handler.\n", ret); 209 226 210 instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci-rh"); 211 ret = (instance->rh_fun == NULL) ? ENOMEM : EOK; 227 ret = ddf_fun_bind(instance->hc_fun); 212 228 CHECK_RET_FINI_RETURN(ret, 213 "Failed(%d) to create root hub function.\n", ret); 214 215 216 instance->rh_fun->ops = &rh_ops; 217 instance->rh_fun->driver_data = NULL; 218 229 "Failed(%d) to bind OHCI device function: %s.\n", 230 ret, str_error(ret)); 231 232 ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME); 233 CHECK_RET_FINI_RETURN(ret, 234 "Failed to add OHCI to HC class: %s.\n", str_error(ret)); 235 219 236 device->driver_data = instance; 220 237 221 238 hc_start_hw(&instance->hc); 239 hc_register_hub(&instance->hc, instance->rh_fun); 222 240 return EOK; 241 242 #undef CHECK_RET_DEST_FUN_RETURN 223 243 #undef CHECK_RET_FINI_RETURN 224 244 } -
uspace/drv/ohci/ohci.h
r05e21ffc r4a7a8d4 38 38 #include <ddf/driver.h> 39 39 40 #include "hc.h" 41 #include "root_hub.h" 42 43 typedef struct ohci { 44 ddf_fun_t *hc_fun; 45 ddf_fun_t *rh_fun; 46 47 hc_t hc; 48 rh_t rh; 49 } ohci_t; 50 51 int ohci_init(ohci_t *instance, ddf_dev_t *device); 40 int device_setup_ohci(ddf_dev_t *device); 52 41 53 42 #endif -
uspace/drv/ohci/pci.c
r05e21ffc r4a7a8d4 58 58 uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no) 59 59 { 60 assert(dev != NULL); 60 assert(dev); 61 assert(mem_reg_address); 62 assert(mem_reg_size); 63 assert(irq_no); 61 64 62 65 int parent_phone = devman_parent_device_connect(dev->handle, -
uspace/drv/ohci/root_hub.c
r05e21ffc r4a7a8d4 237 237 return ENOMEM; 238 238 239 usb_log_info("OHCI root hub with % dports initialized.\n",239 usb_log_info("OHCI root hub with %zu ports initialized.\n", 240 240 instance->port_count); 241 241 -
uspace/drv/uhci-hcd/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I. 30 31 LIBS = \ 32 $(LIBUSBHOST_PREFIX)/libusbhost.a \ 33 $(LIBUSB_PREFIX)/libusb.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 35 EXTRA_CFLAGS += \ 36 -I$(LIBUSB_PREFIX)/include \ 37 -I$(LIBUSBHOST_PREFIX)/include \ 38 -I$(LIBDRV_PREFIX)/include 39 32 40 BINARY = uhci-hcd 33 41 -
uspace/drv/uhci-hcd/hc.c
r05e21ffc r4a7a8d4 60 60 * 61 61 * @param[in] instance Memory place to initialize. 62 * @param[in] fun DDF function.63 62 * @param[in] regs Address of I/O control registers. 64 63 * @param[in] size Size of I/O control registers. … … 69 68 * interrupt fibrils. 70 69 */ 71 int hc_init(hc_t *instance, ddf_fun_t *fun, 72 void *regs, size_t reg_size, bool interrupts) 70 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts) 73 71 { 74 72 assert(reg_size >= sizeof(regs_t)); -
uspace/drv/uhci-hcd/hc.h
r05e21ffc r4a7a8d4 136 136 } hc_t; 137 137 138 int hc_init(hc_t *instance, ddf_fun_t *fun, 139 void *regs, size_t reg_size, bool interupts); 138 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interupts); 140 139 141 140 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch); -
uspace/drv/uhci-hcd/hw_struct/queue_head.h
r05e21ffc r4a7a8d4 38 38 #include "link_pointer.h" 39 39 #include "transfer_descriptor.h" 40 #include " utils/malloc32.h"40 #include "../utils/malloc32.h" 41 41 42 42 /** This structure is defined in UHCI design guide p. 31 */ -
uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.c
r05e21ffc r4a7a8d4 36 36 37 37 #include "transfer_descriptor.h" 38 #include " utils/malloc32.h"38 #include "../utils/malloc32.h" 39 39 40 40 /** Initialize Transfer Descriptor -
uspace/drv/uhci-hcd/iface.c
r05e21ffc r4a7a8d4 122 122 return EOK; 123 123 } 124 125 /** Find device handle by address interface function. 126 * 127 * @param[in] fun DDF function that was called. 128 * @param[in] address Address in question. 129 * @param[out] handle Where to store device handle if found. 130 * @return Error code. 131 */ 132 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 133 devman_handle_t *handle) 134 { 135 assert(fun); 136 hc_t *hc = fun_to_hc(fun); 137 assert(hc); 138 bool found = 139 usb_device_keeper_find_by_address(&hc->manager, address, handle); 140 return found ? EOK : ENOENT; 141 } 142 124 143 /*----------------------------------------------------------------------------*/ 125 144 /** Release address interface function … … 352 371 .request_address = request_address, 353 372 .bind_address = bind_address, 373 .find_by_address = find_by_address, 354 374 .release_address = release_address, 355 375 -
uspace/drv/uhci-hcd/main.c
r05e21ffc r4a7a8d4 64 64 assert(device); 65 65 66 uhci_t *uhci = malloc(sizeof(uhci_t)); 67 if (uhci == NULL) { 68 usb_log_error("Failed to allocate UHCI driver.\n"); 69 return ENOMEM; 70 } 71 72 int ret = uhci_init(uhci, device); 66 int ret = device_setup_uhci(device); 73 67 if (ret != EOK) { 74 68 usb_log_error("Failed to initialize UHCI driver: %s.\n", … … 76 70 return ret; 77 71 } 78 device->driver_data = uhci;79 80 72 usb_log_info("Controlling new UHCI device '%s'.\n", device->name); 81 73 -
uspace/drv/uhci-hcd/uhci.c
r05e21ffc r4a7a8d4 44 44 #include "pci.h" 45 45 46 #include "hc.h" 47 #include "root_hub.h" 48 49 /** Structure representing both functions of UHCI hc, USB host controller 50 * and USB root hub */ 51 typedef struct uhci { 52 /** Pointer to DDF represenation of UHCI host controller */ 53 ddf_fun_t *hc_fun; 54 /** Pointer to DDF represenation of UHCI root hub */ 55 ddf_fun_t *rh_fun; 56 57 /** Internal driver's represenation of UHCI host controller */ 58 hc_t hc; 59 /** Internal driver's represenation of UHCI root hub */ 60 rh_t rh; 61 } uhci_t; 62 63 static inline uhci_t * dev_to_uhci(ddf_dev_t *dev) 64 { 65 assert(dev); 66 assert(dev->driver_data); 67 return dev->driver_data; 68 } 69 /*----------------------------------------------------------------------------*/ 46 70 /** IRQ handling callback, forward status from call to diver structure. 47 71 * … … 69 93 { 70 94 assert(fun); 71 usb_device_keeper_t *manager = 72 &((uhci_t*)fun->dev->driver_data)->hc.manager; 73 95 usb_device_keeper_t *manager = &dev_to_uhci(fun->dev)->hc.manager; 74 96 usb_address_t addr = usb_device_keeper_find(manager, handle); 97 75 98 if (addr < 0) { 76 99 return addr; … … 93 116 ddf_fun_t *fun, devman_handle_t *handle) 94 117 { 95 assert(handle); 96 ddf_fun_t *hc_fun = ((uhci_t*)fun->dev->driver_data)->hc_fun; 97 assert(hc_fun != NULL); 98 99 *handle = hc_fun->handle; 118 assert(fun); 119 ddf_fun_t *hc_fun = dev_to_uhci(fun->dev)->hc_fun; 120 assert(hc_fun); 121 122 if (handle != NULL) 123 *handle = hc_fun->handle; 100 124 return EOK; 101 125 } … … 126 150 static hw_res_ops_t hw_res_iface = { 127 151 .get_resource_list = get_resource_list, 128 .enable_interrupt = NULL 152 .enable_interrupt = NULL, 129 153 }; 130 154 /*----------------------------------------------------------------------------*/ … … 146 170 * - registers interrupt handler 147 171 */ 148 int uhci_init(uhci_t *instance, ddf_dev_t *device) 149 { 150 assert(instance); 151 instance->hc_fun = NULL; 172 int device_setup_uhci(ddf_dev_t *device) 173 { 174 assert(device); 175 uhci_t *instance = malloc(sizeof(uhci_t)); 176 if (instance == NULL) { 177 usb_log_error("Failed to allocate OHCI driver.\n"); 178 return ENOMEM; 179 } 180 181 #define CHECK_RET_DEST_FREE_RETURN(ret, message...) \ 182 if (ret != EOK) { \ 183 if (instance->hc_fun) \ 184 instance->hc_fun->ops = NULL; \ 185 instance->hc_fun->driver_data = NULL; \ 186 ddf_fun_destroy(instance->hc_fun); \ 187 if (instance->rh_fun) {\ 188 instance->rh_fun->ops = NULL; \ 189 instance->rh_fun->driver_data = NULL; \ 190 ddf_fun_destroy(instance->rh_fun); \ 191 } \ 192 free(instance); \ 193 usb_log_error(message); \ 194 return ret; \ 195 } else (void)0 196 152 197 instance->rh_fun = NULL; 153 #define CHECK_RET_DEST_FUN_RETURN(ret, message...) \ 154 if (ret != EOK) { \ 155 usb_log_error(message); \ 156 if (instance->hc_fun) \ 157 ddf_fun_destroy(instance->hc_fun); \ 158 if (instance->rh_fun) \ 159 ddf_fun_destroy(instance->rh_fun); \ 160 return ret; \ 161 } 162 163 uintptr_t io_reg_base = 0; 164 size_t io_reg_size = 0; 198 instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc"); 199 int ret = (instance->hc_fun == NULL) ? ENOMEM : EOK; 200 CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI HC function.\n"); 201 instance->hc_fun->ops = &hc_ops; 202 instance->hc_fun->driver_data = &instance->hc; 203 204 instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci-rh"); 205 ret = (instance->rh_fun == NULL) ? ENOMEM : EOK; 206 CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI RH function.\n"); 207 instance->rh_fun->ops = &rh_ops; 208 instance->rh_fun->driver_data = &instance->rh; 209 210 uintptr_t reg_base = 0; 211 size_t reg_size = 0; 165 212 int irq = 0; 166 213 167 int ret = 168 pci_get_my_registers(device, &io_reg_base, &io_reg_size, &irq); 169 CHECK_RET_DEST_FUN_RETURN(ret, 214 ret = pci_get_my_registers(device, ®_base, ®_size, &irq); 215 CHECK_RET_DEST_FREE_RETURN(ret, 170 216 "Failed to get I/O addresses for %" PRIun ": %s.\n", 171 217 device->handle, str_error(ret)); 172 218 usb_log_debug("I/O regs at 0x%p (size %zu), IRQ %d.\n", 173 (void *) io_reg_base, io_reg_size, irq);219 (void *) reg_base, reg_size, irq); 174 220 175 221 ret = pci_disable_legacy(device); 176 CHECK_RET_DEST_F UN_RETURN(ret,222 CHECK_RET_DEST_FREE_RETURN(ret, 177 223 "Failed(%d) to disable legacy USB: %s.\n", ret, str_error(ret)); 178 224 … … 194 240 #endif 195 241 196 instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc"); 197 ret = (instance->hc_fun == NULL) ? ENOMEM : EOK; 198 CHECK_RET_DEST_FUN_RETURN(ret, 199 "Failed(%d) to create HC function: %s.\n", ret, str_error(ret)); 200 201 ret = hc_init(&instance->hc, instance->hc_fun, 202 (void*)io_reg_base, io_reg_size, interrupts); 203 CHECK_RET_DEST_FUN_RETURN(ret, 242 243 ret = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts); 244 CHECK_RET_DEST_FREE_RETURN(ret, 204 245 "Failed(%d) to init uhci-hcd: %s.\n", ret, str_error(ret)); 205 206 instance->hc_fun->ops = &hc_ops;207 instance->hc_fun->driver_data = &instance->hc;208 ret = ddf_fun_bind(instance->hc_fun);209 CHECK_RET_DEST_FUN_RETURN(ret,210 "Failed(%d) to bind UHCI device function: %s.\n",211 ret, str_error(ret));212 ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME);213 CHECK_RET_DEST_FUN_RETURN(ret,214 "Failed to add UHCI to HC class: %s.\n", str_error(ret));215 216 #undef CHECK_RET_HC_RETURN217 246 218 247 #define CHECK_RET_FINI_RETURN(ret, message...) \ 219 248 if (ret != EOK) { \ 220 usb_log_error(message); \221 if (instance->hc_fun) \222 ddf_fun_destroy(instance->hc_fun); \223 if (instance->rh_fun) \224 ddf_fun_destroy(instance->rh_fun); \225 249 hc_fini(&instance->hc); \ 250 CHECK_RET_DEST_FREE_RETURN(ret, message); \ 226 251 return ret; \ 227 } 252 } else (void)0 228 253 229 254 /* It does no harm if we register this on polling */ … … 234 259 ret, str_error(ret)); 235 260 236 instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci-rh"); 237 ret = (instance->rh_fun == NULL) ? ENOMEM : EOK; 238 CHECK_RET_FINI_RETURN(ret, 239 "Failed(%d) to create root hub function: %s.\n", 261 ret = ddf_fun_bind(instance->hc_fun); 262 CHECK_RET_FINI_RETURN(ret, 263 "Failed(%d) to bind UHCI device function: %s.\n", 240 264 ret, str_error(ret)); 265 266 ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME); 267 CHECK_RET_FINI_RETURN(ret, 268 "Failed to add UHCI to HC class: %s.\n", str_error(ret)); 241 269 242 270 ret = rh_init(&instance->rh, instance->rh_fun, … … 245 273 "Failed(%d) to setup UHCI root hub: %s.\n", ret, str_error(ret)); 246 274 247 instance->rh_fun->ops = &rh_ops;248 instance->rh_fun->driver_data = &instance->rh;249 275 ret = ddf_fun_bind(instance->rh_fun); 250 276 CHECK_RET_FINI_RETURN(ret, 251 277 "Failed(%d) to register UHCI root hub: %s.\n", ret, str_error(ret)); 252 278 279 device->driver_data = instance; 253 280 return EOK; 254 281 #undef CHECK_RET_FINI_RETURN -
uspace/drv/uhci-hcd/uhci.h
r05e21ffc r4a7a8d4 38 38 #include <ddf/driver.h> 39 39 40 #include "hc.h" 41 #include "root_hub.h" 42 43 /** Structure representing both functions of UHCI hc, USB host controller 44 * and USB root hub */ 45 typedef struct uhci { 46 /** Pointer to DDF represenation of UHCI host controller */ 47 ddf_fun_t *hc_fun; 48 /** Pointer to DDF represenation of UHCI root hub */ 49 ddf_fun_t *rh_fun; 50 51 /** Internal driver's represenation of UHCI host controller */ 52 hc_t hc; 53 /** Internal driver's represenation of UHCI root hub */ 54 rh_t rh; 55 } uhci_t; 56 57 int uhci_init(uhci_t *instance, ddf_dev_t *device); 40 int device_setup_uhci(ddf_dev_t *device); 58 41 #endif 59 42 /** -
uspace/drv/uhci-rhd/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I. 30 31 LIBS = \ 32 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 33 $(LIBUSB_PREFIX)/libusb.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 35 EXTRA_CFLAGS += \ 36 -I$(LIBUSB_PREFIX)/include \ 37 -I$(LIBUSBDEV_PREFIX)/include \ 38 -I$(LIBDRV_PREFIX)/include 39 32 40 BINARY = uhci-rhd 33 41 -
uspace/drv/uhci-rhd/port.c
r05e21ffc r4a7a8d4 32 32 * @brief UHCI root hub port routines 33 33 */ 34 #include <libarch/ddi.h> /* pio_read and pio_write */ 34 #include <libarch/ddi.h> /* pio_read and pio_write */ 35 #include <fibril_synch.h> /* async_usleep */ 35 36 #include <errno.h> 36 37 #include <str_error.h> 37 #include <fibril_synch.h>38 38 39 39 #include <usb/usb.h> /* usb_address_t */ 40 #include <usb/hub.h> 40 #include <usb/hub.h> /* usb_hc_new_device_wrapper */ 41 41 #include <usb/debug.h> 42 42 … … 212 212 213 213 /* 214 * The host then waits for at least 100 ms to allow completion of 215 * an insertion process and for power at the device to become stable. 216 */ 217 async_usleep(100000); 218 219 /* 220 * Resets from root ports should be nominally 50ms 214 * Resets from root ports should be nominally 50ms (USB spec 7.1.7.3) 221 215 */ 222 216 { … … 229 223 port_status &= ~STATUS_IN_RESET; 230 224 uhci_port_write_status(port, port_status); 231 usb_log_debug("%s: Reset Signal stop.\n", port->id_string);232 }233 234 /* the reset recovery time 10ms */235 async_usleep(10000);236 225 while (uhci_port_read_status(port) & STATUS_IN_RESET); 226 // TODO: find a better way to waste time (it should be less than 227 // 10ms, if we reschedule it takes too much time (random 228 // interrupts can be solved by multiple attempts). 229 usb_log_debug2("%s: Reset Signal stop.\n", port->id_string); 230 } 237 231 /* Enable the port. */ 238 232 uhci_port_set_enabled(port, true); 233 234 /* Reset recovery period, 235 * devices do not have to respond during this period 236 */ 237 async_usleep(10000); 239 238 return EOK; 240 239 } … … 255 254 usb_log_debug("%s: Detected new device.\n", port->id_string); 256 255 256 int ret, count = 0; 257 257 usb_address_t dev_addr; 258 int ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection, 259 speed, uhci_port_reset_enable, port->number, port, 260 &dev_addr, &port->attached_device, NULL, NULL, NULL); 258 do { 259 ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection, 260 speed, uhci_port_reset_enable, port->number, port, 261 &dev_addr, &port->attached_device, NULL, NULL, NULL); 262 } while (ret != EOK && ++count < 4); 261 263 262 264 if (ret != EOK) { … … 313 315 /* Wait for port to become enabled */ 314 316 do { 315 async_usleep(1000);316 317 port_status = uhci_port_read_status(port); 317 318 } while ((port_status & STATUS_CONNECTED) && -
uspace/drv/usbflbk/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include 30 31 LIBS = \ 32 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 33 $(LIBUSB_PREFIX)/libusb.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 35 EXTRA_CFLAGS += \ 36 -I$(LIBUSB_PREFIX)/include \ 37 -I$(LIBUSBDEV_PREFIX)/include \ 38 -I$(LIBDRV_PREFIX)/include 39 32 40 BINARY = usbflbk 33 41 -
uspace/drv/usbhid/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I. 30 31 LIBS = \ 32 $(LIBUSBHID_PREFIX)/libusbhid.a \ 33 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 34 $(LIBUSB_PREFIX)/libusb.a \ 35 $(LIBDRV_PREFIX)/libdrv.a 36 EXTRA_CFLAGS += \ 37 -I. \ 38 -I$(LIBUSB_PREFIX)/include \ 39 -I$(LIBUSBDEV_PREFIX)/include \ 40 -I$(LIBUSBHID_PREFIX)/include \ 41 -I$(LIBDRV_PREFIX)/include 42 32 43 BINARY = usbhid 33 44 -
uspace/drv/usbhub/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include 30 31 LIBS = \ 32 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 33 $(LIBUSB_PREFIX)/libusb.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 35 EXTRA_CFLAGS += \ 36 -I$(LIBUSB_PREFIX)/include \ 37 -I$(LIBUSBDEV_PREFIX)/include \ 38 -I$(LIBDRV_PREFIX)/include 39 32 40 BINARY = usbhub 33 41 -
uspace/drv/usbkbd/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I. 30 31 LIBS = \ 32 $(LIBUSBHID_PREFIX)/libusbhid.a \ 33 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 34 $(LIBUSB_PREFIX)/libusb.a \ 35 $(LIBDRV_PREFIX)/libdrv.a 36 EXTRA_CFLAGS += \ 37 -I. \ 38 -I$(LIBUSB_PREFIX)/include \ 39 -I$(LIBUSBDEV_PREFIX)/include \ 40 -I$(LIBUSBHID_PREFIX)/include \ 41 -I$(LIBDRV_PREFIX)/include 42 32 43 BINARY = usbkbd 33 44 -
uspace/drv/usbmast/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include 30 31 LIBS = \ 32 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 33 $(LIBUSB_PREFIX)/libusb.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 35 EXTRA_CFLAGS += \ 36 -I$(LIBUSB_PREFIX)/include \ 37 -I$(LIBUSBDEV_PREFIX)/include \ 38 -I$(LIBDRV_PREFIX)/include 39 32 40 BINARY = usbmast 33 41 34 42 SOURCES = \ 43 inquiry.c \ 35 44 main.c \ 36 45 mast.c -
uspace/drv/usbmast/main.c
r05e21ffc r4a7a8d4 75 75 }; 76 76 77 #define BITS_GET_MASK(type, bitcount) (((type)(1 << (bitcount)))-1)78 #define BITS_GET_MID_MASK(type, bitcount, offset) \79 ((type)( BITS_GET_MASK(type, (bitcount) + (offset)) - BITS_GET_MASK(type, bitcount) ))80 #define BITS_GET(type, number, bitcount, offset) \81 ((type)( (number) & (BITS_GET_MID_MASK(type, bitcount, offset)) ) >> (offset))82 83 #define INQUIRY_RESPONSE_LENGTH 3584 85 static void try_inquiry(usb_device_t *dev)86 {87 scsi_cmd_inquiry_t inquiry = {88 .op_code = 0x12,89 .lun_evpd = 0,90 .page_code = 0,91 .alloc_length = INQUIRY_RESPONSE_LENGTH,92 .ctrl = 093 };94 size_t response_len;95 uint8_t response[INQUIRY_RESPONSE_LENGTH];96 97 int rc;98 99 rc = usb_massstor_data_in(GET_BULK_IN(dev), GET_BULK_OUT(dev),100 0xDEADBEEF, 0, (uint8_t *) &inquiry, sizeof(inquiry),101 response, INQUIRY_RESPONSE_LENGTH, &response_len);102 103 if (rc != EOK) {104 usb_log_error("Failed to probe device %s using %s: %s.\n",105 dev->ddf_dev->name, "SCSI:INQUIRY", str_error(rc));106 return;107 }108 109 if (response_len < 8) {110 usb_log_error("The SCSI response is too short.\n");111 return;112 }113 114 /*115 * This is an ugly part of the code. We will parse the returned116 * data by hand and try to get as many useful data as possible.117 */118 int device_type = BITS_GET(uint8_t, response[0], 5, 0);119 int removable = BITS_GET(uint8_t, response[1], 1, 7);120 121 usb_log_info("SCSI information for device `%s':\n", dev->ddf_dev->name);122 usb_log_info(" - peripheral device type: %d\n", device_type);123 usb_log_info(" - removable: %s\n", removable ? "yes" : "no");124 125 if (response_len < 32) {126 return;127 }128 129 char dev_vendor[9];130 str_ncpy(dev_vendor, 9, (const char *) &response[8], 8);131 usb_log_info(" - vendor: '%s'\n", dev_vendor);132 133 char dev_product[9];134 str_ncpy(dev_product, 9, (const char *) &response[16], 8);135 usb_log_info(" - product: '%s'\n", dev_vendor);136 }137 138 77 /** Callback when new device is attached and recognized as a mass storage. 139 78 * … … 168 107 (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size); 169 108 170 try_inquiry(dev); 109 size_t lun_count = usb_masstor_get_lun_count(dev); 110 111 usb_massstor_inquiry_result_t inquiry; 112 rc = usb_massstor_inquiry(dev, BULK_IN_EP, BULK_OUT_EP, &inquiry); 113 if (rc != EOK) { 114 usb_log_warning("Failed to inquiry device `%s': %s.\n", 115 dev->ddf_dev->name, str_error(rc)); 116 return EOK; 117 } 118 119 usb_log_info("Mass storage `%s': " \ 120 "`%s' by `%s' is %s (%s), %zu LUN(s).\n", 121 dev->ddf_dev->name, 122 inquiry.product_and_revision, inquiry.vendor_id, 123 usb_str_masstor_scsi_peripheral_device_type(inquiry.peripheral_device_type), 124 inquiry.removable ? "removable" : "non-removable", 125 lun_count); 171 126 172 127 return EOK; -
uspace/drv/usbmast/mast.c
r05e21ffc r4a7a8d4 40 40 #include <str_error.h> 41 41 #include <usb/debug.h> 42 #include <usb/request.h> 42 43 43 44 bool usb_mast_verbose = true; … … 63 64 * @return Error code. 64 65 */ 65 int usb_massstor_data_in(usb_pipe_t *bulk_in_pipe, usb_pipe_t *bulk_out_pipe, 66 int usb_massstor_data_in(usb_device_t *dev, 67 size_t bulk_in_pipe_index, size_t bulk_out_pipe_index, 66 68 uint32_t tag, uint8_t lun, void *cmd, size_t cmd_size, 67 69 void *in_buffer, size_t in_buffer_size, size_t *received_size) … … 69 71 int rc; 70 72 size_t act_size; 73 usb_pipe_t *bulk_in_pipe = dev->pipes[bulk_in_pipe_index].pipe; 74 usb_pipe_t *bulk_out_pipe = dev->pipes[bulk_out_pipe_index].pipe; 71 75 72 76 /* Prepare CBW - command block wrapper */ … … 135 139 } 136 140 141 /** Perform bulk-only mass storage reset. 142 * 143 * @param dev Device to be reseted. 144 * @return Error code. 145 */ 146 int usb_massstor_reset(usb_device_t *dev) 147 { 148 return usb_control_request_set(&dev->ctrl_pipe, 149 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 150 0xFF, 0, dev->interface_no, NULL, 0); 151 } 152 153 /** Perform complete reset recovery of bulk-only mass storage. 154 * 155 * Notice that no error is reported because if this fails, the error 156 * would reappear on next transaction somehow. 157 * 158 * @param dev Device to be reseted. 159 * @param bulk_in_idx Index of bulk in pipe. 160 * @param bulk_out_idx Index of bulk out pipe. 161 */ 162 void usb_massstor_reset_recovery(usb_device_t *dev, 163 size_t bulk_in_idx, size_t bulk_out_idx) 164 { 165 /* We would ignore errors here because if this fails 166 * we are doomed anyway and any following transaction would fail. 167 */ 168 usb_massstor_reset(dev); 169 usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_in_idx].pipe); 170 usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_out_idx].pipe); 171 } 172 173 /** Get max LUN of a mass storage device. 174 * 175 * @see usb_masstor_get_lun_count 176 * 177 * @warning Error from this command does not necessarily indicate malfunction 178 * of the device. Device does not need to support this request. 179 * You shall rather use usb_masstor_get_lun_count. 180 * 181 * @param dev Mass storage device. 182 * @return Error code of maximum LUN (index, not count). 183 */ 184 int usb_massstor_get_max_lun(usb_device_t *dev) 185 { 186 uint8_t max_lun; 187 size_t data_recv_len; 188 int rc = usb_control_request_get(&dev->ctrl_pipe, 189 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 190 0xFE, 0, dev->interface_no, &max_lun, 1, &data_recv_len); 191 if (rc != EOK) { 192 return rc; 193 } 194 if (data_recv_len != 1) { 195 return EEMPTY; 196 } 197 return (int) max_lun; 198 } 199 200 /** Get number of LUNs supported by mass storage device. 201 * 202 * @warning This function hides any error during the request 203 * (typically that shall not be a problem). 204 * 205 * @param dev Mass storage device. 206 * @return Number of LUNs. 207 */ 208 size_t usb_masstor_get_lun_count(usb_device_t *dev) 209 { 210 int max_lun = usb_massstor_get_max_lun(dev); 211 if (max_lun < 0) { 212 max_lun = 1; 213 } else { 214 max_lun++; 215 } 216 217 return (size_t) max_lun; 218 } 219 137 220 /** 138 221 * @} -
uspace/drv/usbmast/mast.h
r05e21ffc r4a7a8d4 40 40 #include <usb/usb.h> 41 41 #include <usb/pipes.h> 42 #include <usb/devdrv.h> 42 43 43 int usb_massstor_data_in(usb_pipe_t *, usb_pipe_t *, uint32_t, uint8_t, 44 void *, size_t, void *, size_t, size_t *); 44 /** Result of SCSI INQUIRY command. 45 * This is already parsed structure, not the original buffer returned by 46 * the device. 47 */ 48 typedef struct { 49 /** SCSI peripheral device type. */ 50 int peripheral_device_type; 51 /** Whether the device is removable. */ 52 bool removable; 53 /** Vendor ID string. */ 54 char vendor_id[9]; 55 /** Product ID and product revision string. */ 56 char product_and_revision[12]; 57 } usb_massstor_inquiry_result_t; 58 59 int usb_massstor_data_in(usb_device_t *dev, size_t, size_t, 60 uint32_t, uint8_t, void *, size_t, void *, size_t, size_t *); 61 int usb_massstor_reset(usb_device_t *); 62 void usb_massstor_reset_recovery(usb_device_t *, size_t, size_t); 63 int usb_massstor_get_max_lun(usb_device_t *); 64 size_t usb_masstor_get_lun_count(usb_device_t *); 65 int usb_massstor_inquiry(usb_device_t *, size_t, size_t, 66 usb_massstor_inquiry_result_t *); 67 const char *usb_str_masstor_scsi_peripheral_device_type(int); 45 68 46 69 #endif -
uspace/drv/usbmid/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include 30 31 LIBS = \ 32 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 33 $(LIBUSB_PREFIX)/libusb.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 35 EXTRA_CFLAGS += \ 36 -I$(LIBUSB_PREFIX)/include \ 37 -I$(LIBUSBDEV_PREFIX)/include \ 38 -I$(LIBDRV_PREFIX)/include 39 32 40 BINARY = usbmid 33 41 -
uspace/drv/usbmouse/Makefile
r05e21ffc r4a7a8d4 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I. 30 31 LIBS = \ 32 $(LIBUSBHID_PREFIX)/libusbhid.a \ 33 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 34 $(LIBUSB_PREFIX)/libusb.a \ 35 $(LIBDRV_PREFIX)/libdrv.a 36 EXTRA_CFLAGS += \ 37 -I$(LIBUSB_PREFIX)/include \ 38 -I$(LIBUSBDEV_PREFIX)/include \ 39 -I$(LIBUSBHID_PREFIX)/include \ 40 -I$(LIBDRV_PREFIX)/include 32 41 33 42 BINARY = usbmouse -
uspace/drv/vhc/Makefile
r05e21ffc r4a7a8d4 29 29 USPACE_PREFIX = ../.. 30 30 LIBS = \ 31 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 32 $(LIBUSBHOST_PREFIX)/libusbhost.a \ 31 33 $(LIBUSB_PREFIX)/libusb.a \ 32 34 $(LIBUSBVIRT_PREFIX)/libusbvirt.a \ … … 34 36 EXTRA_CFLAGS += \ 35 37 -I$(LIBUSBVIRT_PREFIX)/include \ 38 -I$(LIBUSBDEV_PREFIX)/include \ 39 -I$(LIBUSBHOST_PREFIX)/include \ 36 40 -I$(LIBUSB_PREFIX)/include \ 37 41 -I$(LIBDRV_PREFIX)/include -
uspace/drv/vhc/connhost.c
r05e21ffc r4a7a8d4 94 94 } 95 95 96 /** Find device handle by address interface function. 97 * 98 * @param[in] fun DDF function that was called. 99 * @param[in] address Address in question. 100 * @param[out] handle Where to store device handle if found. 101 * @return Error code. 102 */ 103 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 104 devman_handle_t *handle) 105 { 106 VHC_DATA(vhc, fun); 107 bool found = 108 usb_device_keeper_find_by_address(&vhc->dev_keeper, address, handle); 109 return found ? EOK : ENOENT; 110 } 111 96 112 /** Release previously requested address. 97 113 * … … 444 460 .request_address = request_address, 445 461 .bind_address = bind_address, 462 .find_by_address = find_by_address, 446 463 .release_address = release_address, 447 464 -
uspace/lib/drv/generic/remote_usbhc.c
r05e21ffc r4a7a8d4 52 52 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 53 53 static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 54 static void remote_usbhc_find_by_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 54 55 static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 55 56 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 61 62 remote_usbhc_request_address, 62 63 remote_usbhc_bind_address, 64 remote_usbhc_find_by_address, 63 65 remote_usbhc_release_address, 64 66 … … 163 165 } 164 166 167 void remote_usbhc_find_by_address(ddf_fun_t *fun, void *iface, 168 ipc_callid_t callid, ipc_call_t *call) 169 { 170 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 171 172 if (!usb_iface->find_by_address) { 173 async_answer_0(callid, ENOTSUP); 174 return; 175 } 176 177 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 178 devman_handle_t handle; 179 int rc = usb_iface->find_by_address(fun, address, &handle); 180 181 if (rc == EOK) { 182 async_answer_1(callid, EOK, handle); 183 } else { 184 async_answer_0(callid, rc); 185 } 186 } 187 165 188 void remote_usbhc_release_address(ddf_fun_t *fun, void *iface, 166 189 ipc_callid_t callid, ipc_call_t *call) … … 302 325 async_transaction_t *trans = async_transaction_create(callid); 303 326 if (trans == NULL) { 327 async_answer_0(data_callid, ENOMEM); 304 328 async_answer_0(callid, ENOMEM); 305 329 return; … … 314 338 315 339 if (rc != EOK) { 340 async_answer_0(data_callid, rc); 316 341 async_answer_0(callid, rc); 317 342 async_transaction_destroy(trans); … … 460 485 async_transaction_t *trans = async_transaction_create(callid); 461 486 if (trans == NULL) { 487 async_answer_0(data_callid, ENOMEM); 462 488 async_answer_0(callid, ENOMEM); 463 489 free(setup_packet); … … 469 495 trans->buffer = malloc(data_len); 470 496 if (trans->buffer == NULL) { 497 async_answer_0(data_callid, ENOMEM); 471 498 async_answer_0(callid, ENOMEM); 472 499 async_transaction_destroy(trans); … … 480 507 481 508 if (rc != EOK) { 509 async_answer_0(data_callid, rc); 482 510 async_answer_0(callid, rc); 483 511 async_transaction_destroy(trans); -
uspace/lib/drv/include/usb_iface.h
r05e21ffc r4a7a8d4 49 49 * - arbitrary error code if returned by remote implementation 50 50 * - EOK - handle found, first parameter contains the USB address 51 * 52 * The handle must be the one used for binding USB address with 53 * it (IPC_M_USBHC_BIND_ADDRESS), otherwise the host controller 54 * (that this request would eventually reach) would not be able 55 * to find it. 56 * The problem is that this handle is actually assigned to the 57 * function inside driver of the parent device (usually hub driver). 58 * To bypass this problem, the initial caller specify handle as 59 * zero and the first parent assigns the actual value. 60 * See usb_iface_get_address_hub_child_impl() implementation 61 * that could be assigned to device ops of a child device of in a 62 * hub driver. 63 * For example, the USB multi interface device driver (MID) 64 * passes this initial zero without any modification because the 65 * handle must be resolved by its parent. 51 66 */ 52 67 IPC_M_USB_GET_ADDRESS, -
uspace/lib/drv/include/usbhc_iface.h
r05e21ffc r4a7a8d4 105 105 IPC_M_USBHC_BIND_ADDRESS, 106 106 107 /** Get handle binded with given USB address. 108 * Parameters 109 * - USB address 110 * Answer: 111 * - EOK - address binded, first parameter is the devman handle 112 * - ENOENT - address is not in use at the moment 113 */ 114 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, 115 107 116 /** Release address in use. 108 117 * Arguments: … … 207 216 int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *); 208 217 int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t); 218 int (*find_by_address)(ddf_fun_t *, usb_address_t, devman_handle_t *); 209 219 int (*release_address)(ddf_fun_t *, usb_address_t); 210 220 -
uspace/lib/usb/Makefile
r05e21ffc r4a7a8d4 29 29 USPACE_PREFIX = ../.. 30 30 LIBRARY = libusb 31 LIBS = $(LIBDRV_PREFIX)/libdrv.a 32 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -Iinclude 31 EXTRA_CFLAGS += \ 32 -I$(LIBDRV_PREFIX)/include \ 33 -Iinclude 33 34 34 35 SOURCES = \ 35 src/addrkeep.c \36 src/altiface.c \37 36 src/class.c \ 38 37 src/ddfiface.c \ 39 38 src/debug.c \ 40 src/devdrv.c \ 41 src/devpoll.c \ 42 src/dp.c \ 39 src/driver.c \ 43 40 src/dump.c \ 44 src/hidiface.c \45 src/hidpath.c \46 src/hidparser.c \47 src/hiddescriptor.c \48 41 src/host.c \ 49 src/hub.c \ 50 src/pipepriv.c \ 51 src/pipes.c \ 52 src/pipesinit.c \ 53 src/pipesio.c \ 54 src/recognise.c \ 55 src/request.c \ 56 src/usb.c \ 57 src/usbdevice.c \ 58 src/hidreq.c \ 59 src/hidreport.c \ 60 src/host/device_keeper.c \ 61 src/host/batch.c \ 62 src/host/endpoint.c \ 63 src/host/usb_endpoint_manager.c 42 src/usb.c 64 43 65 44 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/usb/include/usb/ddfiface.h
r05e21ffc r4a7a8d4 37 37 38 38 #include <sys/types.h> 39 #include <usb/usbdevice.h>40 39 #include <usb_iface.h> 41 40 -
uspace/lib/usb/include/usb/descriptor.h
r05e21ffc r4a7a8d4 167 167 } __attribute__ ((packed)) usb_standard_endpoint_descriptor_t; 168 168 169 /** Part of standard USB HID descriptor specifying one class descriptor. 170 * 171 * (See HID Specification, p.22) 172 */ 173 typedef struct { 174 /** Type of class-specific descriptor (Report or Physical). */ 175 uint8_t type; 176 /** Length of class-specific descriptor in bytes. */ 177 uint16_t length; 178 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t; 179 180 /** Standard USB HID descriptor. 181 * 182 * (See HID Specification, p.22) 183 * 184 * It is actually only the "header" of the descriptor, it does not contain 185 * the last two mandatory fields (type and length of the first class-specific 186 * descriptor). 187 */ 188 typedef struct { 189 /** Total size of this descriptor in bytes. 190 * 191 * This includes all class-specific descriptor info - type + length 192 * for each descriptor. 193 */ 194 uint8_t length; 195 /** Descriptor type (USB_DESCTYPE_HID). */ 196 uint8_t descriptor_type; 197 /** HID Class Specification release. */ 198 uint16_t spec_release; 199 /** Country code of localized hardware. */ 200 uint8_t country_code; 201 /** Total number of class-specific (i.e. Report and Physical) 202 * descriptors. 203 * 204 * @note There is always only one Report descriptor. 205 */ 206 uint8_t class_desc_count; 207 /** First mandatory class descriptor (Report) info. */ 208 usb_standard_hid_class_descriptor_info_t report_desc_info; 209 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 210 169 211 #endif 170 212 /** -
uspace/lib/usb/src/ddfiface.c
r05e21ffc r4a7a8d4 37 37 #include <async.h> 38 38 #include <usb/ddfiface.h> 39 #include <usb/driver.h> 39 40 #include <usb/debug.h> 40 41 #include <errno.h> -
uspace/lib/usb/src/dump.c
r05e21ffc r4a7a8d4 41 41 #include <usb/descriptor.h> 42 42 #include <usb/classes/classes.h> 43 #include <usb/classes/hid.h>44 43 45 44 /** Mapping between descriptor id and dumping function. */ -
uspace/lib/usbvirt/Makefile
r05e21ffc r4a7a8d4 30 30 LIBRARY = libusbvirt 31 31 32 EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include -Iinclude 32 EXTRA_CFLAGS = \ 33 -I$(LIBDRV_PREFIX)/include \ 34 -I$(LIBUSB_PREFIX)/include \ 35 -I$(LIBUSBDEV_PREFIX)/include \ 36 -Iinclude 33 37 34 38 SOURCES = \
Note:
See TracChangeset
for help on using the changeset viewer.