Changeset a81a1d09 in mainline for uspace/lib/usb
- Timestamp:
- 2011-05-11T16:49:28Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 19387b61
- Parents:
- e1dbcbc (diff), 9212f8a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/usb
- Files:
-
- 2 deleted
- 6 edited
- 4 moved
-
Makefile (modified) (1 diff)
-
include/usb/classes/hid.h (deleted)
-
include/usb/ddfiface.h (modified) (1 diff)
-
include/usb/descriptor.h (modified) (1 diff)
-
include/usb/driver.h (moved) (moved from uspace/app/virtusbkbd/stdreq.h ) (2 diffs)
-
include/usb/host.h (moved) (moved from uspace/app/virtusbkbd/descriptor.h ) (2 diffs)
-
include/usb/usb.h (modified) (1 diff)
-
src/ddfiface.c (modified) (1 diff)
-
src/driver.c (moved) (moved from uspace/app/tester/adt/usbaddrkeep.c ) (2 diffs)
-
src/dump.c (modified) (1 diff)
-
src/hidparser.c (deleted)
-
src/host.c (moved) (moved from uspace/app/virtusbkbd/stdreq.c ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/Makefile
re1dbcbc ra81a1d09 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/hidparser.c \ 46 src/hub.c \ 47 src/pipepriv.c \ 48 src/pipes.c \ 49 src/pipesinit.c \ 50 src/pipesio.c \ 51 src/recognise.c \ 52 src/request.c \ 53 src/usb.c \ 54 src/usbdevice.c \ 55 src/hidreq.c \ 56 src/hidreport.c \ 57 src/host/device_keeper.c \ 58 src/host/batch.c \ 59 src/host/endpoint.c \ 60 src/host/usb_endpoint_manager.c 41 src/host.c \ 42 src/usb.c 61 43 62 44 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/usb/include/usb/ddfiface.h
re1dbcbc ra81a1d09 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
re1dbcbc ra81a1d09 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/include/usb/driver.h
re1dbcbc ra81a1d09 1 1 /* 2 * Copyright (c) 201 0Vojtech Horky2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup usbvirtkbd29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief Standard device request handlers.33 * Common definitions for USB drivers. 34 34 */ 35 #ifndef VUK_STDREQ_H_36 #define VUK_STDREQ_H_35 #ifndef LIBUSB_DRIVER_H_ 36 #define LIBUSB_DRIVER_H_ 37 37 38 #include <usbvirt/device.h> 38 #include <sys/types.h> 39 #include <ipc/devman.h> 39 40 40 int req_get_descriptor(usbvirt_device_t *device, 41 const usb_device_request_setup_packet_t *setup_packet, 42 uint8_t *data, size_t *act_size); 41 int usb_hc_find(devman_handle_t, devman_handle_t *); 43 42 44 43 #endif -
uspace/lib/usb/include/usb/host.h
re1dbcbc ra81a1d09 1 1 /* 2 * Copyright (c) 201 0Vojtech Horky2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup usbvirtkbd29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief USB keyboard descriptors.33 * Host controller common functions. 34 34 */ 35 #ifndef VUK_DESCRIPTOR_H_36 #define VUK_DESCRIPTOR_H_35 #ifndef LIBUSB_HOST_H_ 36 #define LIBUSB_HOST_H_ 37 37 38 typedef struct { 39 uint8_t length; 40 uint8_t type; 41 uint16_t hid_spec_release; 42 uint8_t country_code; 43 uint8_t descriptor_count; 44 uint8_t descriptor1_type; 45 uint16_t descriptor1_length; 46 } __attribute__ ((packed)) hid_descriptor_t; 38 #include <sys/types.h> 39 #include <ipc/devman.h> 40 41 int usb_ddf_get_hc_handle_by_class(size_t, devman_handle_t *); 47 42 48 43 #endif -
uspace/lib/usb/include/usb/usb.h
re1dbcbc ra81a1d09 172 172 } usb_packet_id; 173 173 174 /** Class name for USB host controllers. */ 175 #define USB_HC_DDF_CLASS_NAME "usbhc" 176 174 177 #endif 175 178 /** -
uspace/lib/usb/src/ddfiface.c
re1dbcbc ra81a1d09 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/driver.c
re1dbcbc ra81a1d09 1 1 /* 2 * Copyright (c) 201 0Vojtech Horky2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <usb/addrkeep.h> 29 /** @addtogroup libusb 30 * @{ 31 */ 32 /** @file 33 * 34 */ 35 #include <devman.h> 36 #include <dev_iface.h> 37 #include <usb_iface.h> 38 #include <usb/driver.h> 32 39 #include <errno.h> 33 #include "../tester.h"34 35 #define MAX_ADDRESS 536 40 37 41 38 const char *test_usbaddrkeep(void) 42 /** Find host controller handle that is ancestor of given device. 43 * 44 * @param[in] device_handle Device devman handle. 45 * @param[out] hc_handle Where to store handle of host controller 46 * controlling device with @p device_handle handle. 47 * @return Error code. 48 */ 49 int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle) 39 50 { 40 int rc; 41 usb_address_keeping_t addresses; 42 43 TPRINTF("Initializing addresses keeping structure...\n"); 44 usb_address_keeping_init(&addresses, MAX_ADDRESS); 45 46 TPRINTF("Requesting address...\n"); 47 usb_address_t addr = usb_address_keeping_request(&addresses); 48 TPRINTF("Address assigned: %d\n", (int) addr); 49 if (addr != 1) { 50 return "have not received expected address 1"; 51 int parent_phone = devman_parent_device_connect(device_handle, 52 IPC_FLAG_BLOCKING); 53 if (parent_phone < 0) { 54 return parent_phone; 51 55 } 52 56 53 TPRINTF("Releasing not assigned address...\n"); 54 rc = usb_address_keeping_release(&addresses, 2); 55 if (rc != ENOENT) { 56 return "have not received expected ENOENT"; 57 devman_handle_t h; 58 int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 59 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h); 60 61 async_hangup(parent_phone); 62 63 if (rc != EOK) { 64 return rc; 57 65 } 58 66 59 TPRINTF("Releasing acquired address...\n"); 60 rc = usb_address_keeping_release(&addresses, addr); 61 if (rc != EOK) { 62 return "have not received expected EOK"; 67 if (hc_handle != NULL) { 68 *hc_handle = h; 63 69 } 64 70 65 return NULL;71 return EOK; 66 72 } 73 74 /** 75 * @} 76 */ -
uspace/lib/usb/src/dump.c
re1dbcbc ra81a1d09 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/usb/src/host.c
re1dbcbc ra81a1d09 1 1 /* 2 * Copyright (c) 201 0Vojtech Horky2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup usbvirtkbd29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** 33 33 * @file 34 * @brief Keyboard configuration.34 * Host controller common functions (implementation). 35 35 */ 36 #include <stdio.h> 37 #include <str_error.h> 36 38 #include <errno.h> 39 #include <assert.h> 40 #include <bool.h> 41 #include <usb/host.h> 37 42 #include <usb/descriptor.h> 38 #include "stdreq.h" 39 #include "kbdconfig.h" 43 #include <devman.h> 40 44 41 int req_get_descriptor(usbvirt_device_t *device, 42 const usb_device_request_setup_packet_t *setup_packet, 43 uint8_t *data, size_t *act_size) 45 /** Get host controller handle by its class index. 46 * 47 * @param class_index Class index for the host controller. 48 * @param hc_handle Where to store the HC handle 49 * (can be NULL for existence test only). 50 * @return Error code. 51 */ 52 int usb_ddf_get_hc_handle_by_class(size_t class_index, 53 devman_handle_t *hc_handle) 44 54 { 45 if (setup_packet->value_high == USB_DESCTYPE_HID_REPORT) { 46 /* 47 * For simplicity, always return the same 48 * report descriptor. 49 */ 50 usbvirt_control_reply_helper(setup_packet, 51 data, act_size, 52 report_descriptor, report_descriptor_size); 55 char *class_index_str; 56 devman_handle_t hc_handle_tmp; 57 int rc; 53 58 54 return EOK; 59 rc = asprintf(&class_index_str, "%zu", class_index); 60 if (rc < 0) { 61 return ENOMEM; 55 62 } 56 57 /* Let the framework handle all the rest. */ 58 return EFORWARD; 63 rc = devman_device_get_handle_by_class("usbhc", class_index_str, 64 &hc_handle_tmp, 0); 65 free(class_index_str); 66 if (rc != EOK) { 67 return rc; 68 } 69 70 if (hc_handle != NULL) { 71 *hc_handle = hc_handle_tmp; 72 } 73 74 return EOK; 59 75 } 60 61 62 76 63 77 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.
