Changeset 7fc092a in mainline for uspace/lib/usb/include
- Timestamp:
- 2011-01-27T22:09:29Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- db7ed07
- Parents:
- 9ee87f6 (diff), 6265a2b (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/include/usb
- Files:
-
- 14 edited
- 2 moved
-
addrkeep.h (modified) (1 diff, 1 prop)
-
classes/classes.h (modified) (1 diff)
-
classes/hid.h (modified) (7 diffs)
-
classes/hidparser.h (modified) (4 diffs)
-
classes/hidut.h (modified) (1 diff)
-
classes/hidutkbd.h (modified) (1 diff)
-
classes/hub.h (modified) (2 diffs)
-
debug.h (modified) (2 diffs)
-
descriptor.h (modified) (1 diff)
-
devreq.h (modified) (1 diff)
-
dp.h (moved) (moved from uspace/srv/net/il/arp/arp_module.h ) (2 diffs)
-
hcd.h (modified) (1 diff, 1 prop)
-
hcdhubd.h (modified) (1 diff)
-
usb.h (modified) (1 diff)
-
usbdrv.h (modified) (1 diff)
-
usbmem.h (moved) (moved from uspace/srv/net/il/arp/arp_header.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/addrkeep.h
-
Property mode
changed from
100644to120000
r9ee87f6 r7fc092a 1 /* 2 * Copyright (c) 2010 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libusb usb 30 * @{ 31 */ 32 /** @file 33 * @brief HC driver. 34 */ 35 #ifndef LIBUSB_HCD_H_ 36 #define LIBUSB_HCD_H_ 37 38 #include <usb/usb.h> 39 #include <fibril_synch.h> 40 #include <devman.h> 41 42 /** Info about used address. */ 43 typedef struct { 44 /** Linked list member. */ 45 link_t link; 46 /** Address. */ 47 usb_address_t address; 48 /** Corresponding devman handle. */ 49 devman_handle_t devman_handle; 50 } usb_address_keeping_used_t; 51 52 /** Structure for keeping track of free and used USB addresses. */ 53 typedef struct { 54 /** Head of list of used addresses. */ 55 link_t used_addresses; 56 /** Upper bound for USB addresses. */ 57 usb_address_t max_address; 58 /** Mutex protecting used address. */ 59 fibril_mutex_t used_addresses_guard; 60 /** Condition variable for used addresses. */ 61 fibril_condvar_t used_addresses_condvar; 62 63 /** Condition variable mutex for default address. */ 64 fibril_mutex_t default_condvar_guard; 65 /** Condition variable for default address. */ 66 fibril_condvar_t default_condvar; 67 /** Whether is default address available. */ 68 bool default_available; 69 } usb_address_keeping_t; 70 71 void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t); 72 73 void usb_address_keeping_reserve_default(usb_address_keeping_t *); 74 void usb_address_keeping_release_default(usb_address_keeping_t *); 75 76 usb_address_t usb_address_keeping_request(usb_address_keeping_t *); 77 int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t); 78 void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t, 79 devman_handle_t); 80 usb_address_t usb_address_keeping_find(usb_address_keeping_t *, 81 devman_handle_t); 82 83 84 #endif 1 hcd.h -
Property mode
changed from
-
uspace/lib/usb/include/usb/classes/classes.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hid.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 39 39 #include <driver.h> 40 40 #include <usb/classes/hidparser.h> 41 #include <usb/descriptor.h> 41 42 42 43 /** USB/HID device requests. */ … … 63 64 */ 64 65 typedef struct { 65 /** Type of class descriptor (Report or Physical). */66 uint8_t class_descriptor_type;67 /** Length of class descriptor. */68 uint16_t class_descriptor_length;69 } __attribute__ ((packed)) usb_standard_hid_ descriptor_class_item_t;66 /** Type of class-specific descriptor (Report or Physical). */ 67 uint8_t type; 68 /** Length of class-specific descriptor in bytes. */ 69 uint16_t length; 70 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t; 70 71 71 72 /** Standard USB HID descriptor. … … 73 74 * (See HID Specification, p.22) 74 75 * 75 * It is actually only the "header" of the descriptor, as it may have arbitrary 76 * length if more than one class descritor is provided. 76 * It is actually only the "header" of the descriptor, it does not contain 77 * the last two mandatory fields (type and length of the first class-specific 78 * descriptor). 77 79 */ 78 80 typedef struct { 79 /** Size of this descriptor in bytes. */ 81 /** Total size of this descriptor in bytes. 82 * 83 * This includes all class-specific descriptor info - type + length 84 * for each descriptor. 85 */ 80 86 uint8_t length; 81 87 /** Descriptor type (USB_DESCTYPE_HID). */ … … 85 91 /** Country code of localized hardware. */ 86 92 uint8_t country_code; 87 /** Total number of class (i.e. Report and Physical) descriptors. */ 88 uint8_t class_count; 89 /** First mandatory class descriptor info. */ 90 usb_standard_hid_descriptor_class_item_t class_descriptor; 93 /** Total number of class-specific (i.e. Report and Physical) 94 * descriptors. 95 * 96 * @note There is always only one Report descriptor. 97 */ 98 uint8_t class_desc_count; 99 /** First mandatory class descriptor (Report) info. */ 100 usb_standard_hid_class_descriptor_info_t report_desc_info; 91 101 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 92 102 103 /** 104 * 105 */ 106 typedef struct { 107 usb_standard_interface_descriptor_t iface_desc; 108 usb_standard_endpoint_descriptor_t *endpoints; 109 usb_standard_hid_descriptor_t hid_desc; 110 uint8_t *report_desc; 111 //usb_standard_hid_class_descriptor_info_t *class_desc_info; 112 //uint8_t **class_descs; 113 } usb_hid_iface_t; 114 115 /** 116 * 117 */ 118 typedef struct { 119 usb_standard_configuration_descriptor_t config_descriptor; 120 usb_hid_iface_t *interfaces; 121 } usb_hid_configuration_t; 93 122 94 123 /** … … 99 128 typedef struct { 100 129 device_t *device; 130 usb_hid_configuration_t *conf; 101 131 usb_address_t address; 102 132 usb_endpoint_t poll_endpoint; … … 104 134 } usb_hid_dev_kbd_t; 105 135 136 // TODO: more configurations! 137 106 138 #endif 107 139 /** -
uspace/lib/usb/include/usb/classes/hidparser.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 38 38 #include <stdint.h> 39 39 40 /** 41 * Description of report items 42 */ 43 typedef struct { 44 45 uint8_t usage_min; 46 uint8_t usage_max; 47 uint8_t logical_min; 48 uint8_t logical_max; 49 uint8_t size; 50 uint8_t count; 51 uint8_t offset; 52 53 } usb_hid_report_item_t; 54 55 40 56 /** HID report parser structure. */ 41 57 typedef struct { 42 58 } usb_hid_report_parser_t; 59 43 60 44 61 /** HID parser callbacks for IN items. */ … … 50 67 * @param arg Custom argument. 51 68 */ 52 void (*keyboard)(const uint 16_t *key_codes, size_t count, void *arg);69 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t modifiers, void *arg); 53 70 } usb_hid_report_in_callbacks_t; 71 72 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01 73 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02 74 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04 75 #define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08 76 #define USB_HID_BOOT_KEYBOARD_KANA 0x10 77 78 /* 79 * modifiers definitions 80 */ 81 82 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size, 83 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 84 85 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size); 54 86 55 87 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, … … 60 92 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 61 93 94 95 int usb_hid_free_report_parser(usb_hid_report_parser_t *parser); 96 62 97 #endif 63 98 /** -
uspace/lib/usb/include/usb/classes/hidut.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hidutkbd.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hub.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 68 68 * For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2 69 69 */ 70 typedef struct hub_descriptor_type{70 typedef struct usb_hub_descriptor_type { 71 71 /** Number of bytes in this descriptor, including this byte */ 72 72 //uint8_t bDescLength; -
uspace/lib/usb/include/usb/debug.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 35 35 #ifndef LIBUSB_DEBUG_H_ 36 36 #define LIBUSB_DEBUG_H_ 37 #include <stdio.h> 38 #include <usb/usb.h> 37 39 38 40 void usb_dprintf(const char *tag, int level, const char *format, ...); 39 41 void usb_dprintf_enable(const char *tag, int level); 40 42 43 void usb_dump_standard_descriptor(FILE *, const char *, const char *, 44 const uint8_t *, size_t); 41 45 42 46 #endif 47 /** 48 * @} 49 */ 50 -
uspace/lib/usb/include/usb/descriptor.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/devreq.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/dp.h
r9ee87f6 r7fc092a 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup arp29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 /** @file 33 * @brief USB descriptor parser. 34 */ 35 #ifndef LIBUSB_DP_H_ 36 #define LIBUSB_DP_H_ 32 37 33 /** @file 34 * ARP module functions. 35 * The functions are used as ARP module entry points. 36 */ 38 #include <sys/types.h> 39 #include <usb/usb.h> 40 #include <usb/descriptor.h> 37 41 38 #ifndef NET_ARP_MODULE_H_ 39 #define NET_ARP_MODULE_H_ 42 typedef struct { 43 int child; 44 int parent; 45 } usb_dp_descriptor_nesting_t; 40 46 41 #include <ipc/ipc.h> 42 #include <async.h> 47 typedef struct { 48 usb_dp_descriptor_nesting_t *nesting; 49 } usb_dp_parser_t; 43 50 44 extern int arp_initialize(async_client_conn_t); 45 extern int arp_message_standalone(ipc_callid_t, ipc_call_t *, ipc_call_t *, 46 size_t *); 51 typedef struct { 52 uint8_t *data; 53 size_t size; 54 void *arg; 55 } usb_dp_parser_data_t; 56 57 uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *, 58 usb_dp_parser_data_t *, uint8_t *); 59 uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *, 60 usb_dp_parser_data_t *, uint8_t *, uint8_t *); 47 61 48 62 #endif 49 50 /** @}63 /** 64 * @} 51 65 */ -
uspace/lib/usb/include/usb/hcd.h
-
Property mode
changed from
120000to100644
r9ee87f6 r7fc092a 1 addrkeep.h 1 /* 2 * Copyright (c) 2010 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libusb 30 * @{ 31 */ 32 /** @file 33 * @brief HC driver. 34 */ 35 #ifndef LIBUSB_HCD_H_ 36 #define LIBUSB_HCD_H_ 37 38 #include <usb/usb.h> 39 #include <fibril_synch.h> 40 #include <devman.h> 41 42 /** Info about used address. */ 43 typedef struct { 44 /** Linked list member. */ 45 link_t link; 46 /** Address. */ 47 usb_address_t address; 48 /** Corresponding devman handle. */ 49 devman_handle_t devman_handle; 50 } usb_address_keeping_used_t; 51 52 /** Structure for keeping track of free and used USB addresses. */ 53 typedef struct { 54 /** Head of list of used addresses. */ 55 link_t used_addresses; 56 /** Upper bound for USB addresses. */ 57 usb_address_t max_address; 58 /** Mutex protecting used address. */ 59 fibril_mutex_t used_addresses_guard; 60 /** Condition variable for used addresses. */ 61 fibril_condvar_t used_addresses_condvar; 62 63 /** Condition variable mutex for default address. */ 64 fibril_mutex_t default_condvar_guard; 65 /** Condition variable for default address. */ 66 fibril_condvar_t default_condvar; 67 /** Whether is default address available. */ 68 bool default_available; 69 } usb_address_keeping_t; 70 71 void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t); 72 73 void usb_address_keeping_reserve_default(usb_address_keeping_t *); 74 void usb_address_keeping_release_default(usb_address_keeping_t *); 75 76 usb_address_t usb_address_keeping_request(usb_address_keeping_t *); 77 int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t); 78 void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t, 79 devman_handle_t); 80 usb_address_t usb_address_keeping_find(usb_address_keeping_t *, 81 devman_handle_t); 82 83 #endif 84 /** 85 * @} 86 */ -
Property mode
changed from
-
uspace/lib/usb/include/usb/hcdhubd.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/usb.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/usbdrv.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/usbmem.h
r9ee87f6 r7fc092a 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2010 Matus Dekanek 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup arp 30 * @{ 29 #ifndef USBMEM_H 30 #define USBMEM_H 31 32 33 // group should be changed - this is not usb specific 34 /** @addtogroup usb 35 * @{ 31 36 */ 32 33 /** @file 34 * ARP protocol header. 35 * Based on the RFC 826. 37 /** @file definitions of special memory management, used mostly in usb stack 38 * 39 * USB HCD needs traslation between physical and virtual addresses. These 40 * functions implement such functionality. For each allocated virtual address 41 * the memory manager gets also it`s physical translation and remembers it. 42 * Addresses allocated byt this manager can be therefore translated from and to 43 * physical addresses. 44 * Typical use: 45 * void * address = mman_malloc(some_size); 46 * void * physical_address = mman_getPA(address); 47 * void * the_same_address = mman_getVA(physical_address); 48 * void * null_address = mman_getPA(non_existing_address); 49 * mman_free(address); 50 * // physical_address, adress and the_same_address are no longer valid here 51 * 52 * 53 * @note Addresses allocated by this memory manager should be as well 54 * deallocated byt it. 55 * 36 56 */ 37 38 #ifndef NET_ARP_HEADER_H_39 #define NET_ARP_HEADER_H_40 57 41 58 #include <sys/types.h> 42 59 43 /** Type definition of an ARP protocol header. 44 * @see arp_header 45 */ 46 typedef struct arp_header arp_header_t;60 extern void * mman_malloc( 61 size_t size, 62 size_t alignment, 63 unsigned long max_physical_address); 47 64 48 /** ARP protocol header. */ 49 struct arp_header { 50 /** 51 * Hardware type identifier. 52 * @see hardware.h 53 */ 54 uint16_t hardware; 55 56 /** Protocol identifier. */ 57 uint16_t protocol; 58 /** Hardware address length in bytes. */ 59 uint8_t hardware_length; 60 /** Protocol address length in bytes. */ 61 uint8_t protocol_length; 62 63 /** 64 * ARP packet type. 65 * @see arp_oc.h 66 */ 67 uint16_t operation; 68 } __attribute__ ((packed)); 65 extern void * mman_getVA(void * addr); 69 66 70 #endif 67 extern void * mman_getPA(void * addr); 68 69 extern void mman_free(void * addr); 70 71 72 73 74 71 75 72 76 /** @} 73 77 */ 78 79 80 #endif /* USBMEM_H */ 81
Note:
See TracChangeset
for help on using the changeset viewer.
