Changeset 7fc092a in mainline for uspace/lib/usb/include


Ignore:
Timestamp:
2011-01-27T22:09:29Z (15 years ago)
Author:
Jan Vesely <jano.vesely@…>
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.
Message:

Changes from development branch

Location:
uspace/lib/usb/include/usb
Files:
14 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/addrkeep.h

    • Property mode changed from 100644 to 120000
    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
     1hcd.h
  • uspace/lib/usb/include/usb/classes/classes.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/classes/hid.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    3939#include <driver.h>
    4040#include <usb/classes/hidparser.h>
     41#include <usb/descriptor.h>
    4142
    4243/** USB/HID device requests. */
     
    6364 */
    6465typedef 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;
    7071
    7172/** Standard USB HID descriptor.
     
    7374 * (See HID Specification, p.22)
    7475 *
    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).
    7779 */
    7880typedef 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         */
    8086        uint8_t length;
    8187        /** Descriptor type (USB_DESCTYPE_HID). */
     
    8591        /** Country code of localized hardware. */
    8692        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;
    91101} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
    92102
     103/**
     104 *
     105 */
     106typedef 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 */
     118typedef struct {
     119        usb_standard_configuration_descriptor_t config_descriptor;
     120        usb_hid_iface_t *interfaces;
     121} usb_hid_configuration_t;
    93122
    94123/**
     
    99128typedef struct {
    100129        device_t *device;
     130        usb_hid_configuration_t *conf;
    101131        usb_address_t address;
    102132        usb_endpoint_t poll_endpoint;
     
    104134} usb_hid_dev_kbd_t;
    105135
     136// TODO: more configurations!
     137
    106138#endif
    107139/**
  • uspace/lib/usb/include/usb/classes/hidparser.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    3838#include <stdint.h>
    3939
     40/**
     41 * Description of report items
     42 */
     43typedef 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
    4056/** HID report parser structure. */
    4157typedef struct {
    4258} usb_hid_report_parser_t;
     59
    4360
    4461/** HID parser callbacks for IN items. */
     
    5067         * @param arg Custom argument.
    5168         */
    52         void (*keyboard)(const uint16_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);
    5370} 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
     82int 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
     85int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size);
    5486
    5587int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser,
     
    6092    const usb_hid_report_in_callbacks_t *callbacks, void *arg);
    6193
     94
     95int usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
     96
    6297#endif
    6398/**
  • uspace/lib/usb/include/usb/classes/hidut.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/classes/hidutkbd.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/classes/hub.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    6868 *      For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
    6969 */
    70 typedef struct hub_descriptor_type{
     70typedef struct usb_hub_descriptor_type {
    7171    /** Number of bytes in this descriptor, including this byte */
    7272    //uint8_t bDescLength;
  • uspace/lib/usb/include/usb/debug.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    3535#ifndef LIBUSB_DEBUG_H_
    3636#define LIBUSB_DEBUG_H_
     37#include <stdio.h>
     38#include <usb/usb.h>
    3739
    3840void usb_dprintf(const char *tag, int level, const char *format, ...);
    3941void usb_dprintf_enable(const char *tag, int level);
    4042
     43void usb_dump_standard_descriptor(FILE *, const char *, const char *,
     44    const uint8_t *, size_t);
    4145
    4246#endif
     47/**
     48 * @}
     49 */
     50
  • uspace/lib/usb/include/usb/descriptor.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/devreq.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/dp.h

    r9ee87f6 r7fc092a  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup arp
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     32/** @file
     33 * @brief USB descriptor parser.
     34 */
     35#ifndef LIBUSB_DP_H_
     36#define LIBUSB_DP_H_
    3237
    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>
    3741
    38 #ifndef NET_ARP_MODULE_H_
    39 #define NET_ARP_MODULE_H_
     42typedef struct {
     43        int child;
     44        int parent;
     45} usb_dp_descriptor_nesting_t;
    4046
    41 #include <ipc/ipc.h>
    42 #include <async.h>
     47typedef struct {
     48        usb_dp_descriptor_nesting_t *nesting;
     49} usb_dp_parser_t;
    4350
    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 *);
     51typedef struct {
     52        uint8_t *data;
     53        size_t size;
     54        void *arg;
     55} usb_dp_parser_data_t;
     56
     57uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *,
     58    usb_dp_parser_data_t *, uint8_t *);
     59uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *,
     60    usb_dp_parser_data_t *, uint8_t *, uint8_t *);
    4761
    4862#endif
    49 
    50 /** @}
     63/**
     64 * @}
    5165 */
  • uspace/lib/usb/include/usb/hcd.h

    • Property mode changed from 120000 to 100644
    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. */
     43typedef 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. */
     53typedef 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
     71void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t);
     72
     73void usb_address_keeping_reserve_default(usb_address_keeping_t *);
     74void usb_address_keeping_release_default(usb_address_keeping_t *);
     75
     76usb_address_t usb_address_keeping_request(usb_address_keeping_t *);
     77int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t);
     78void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t,
     79    devman_handle_t);
     80usb_address_t usb_address_keeping_find(usb_address_keeping_t *,
     81    devman_handle_t);
     82
     83#endif
     84/**
     85 * @}
     86 */
  • uspace/lib/usb/include/usb/hcdhubd.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/usb.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/usbdrv.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/usbmem.h

    r9ee87f6 r7fc092a  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2010 Matus Dekanek
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    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 * @{
    3136 */
    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 *
    3656 */
    37 
    38 #ifndef NET_ARP_HEADER_H_
    39 #define NET_ARP_HEADER_H_
    4057
    4158#include <sys/types.h>
    4259
    43 /** Type definition of an ARP protocol header.
    44  * @see arp_header
    45  */
    46 typedef struct arp_header arp_header_t;
     60extern void * mman_malloc(
     61                size_t size,
     62                size_t alignment,
     63                unsigned long max_physical_address);
    4764
    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));
     65extern void * mman_getVA(void * addr);
    6966
    70 #endif
     67extern void * mman_getPA(void * addr);
     68
     69extern void mman_free(void * addr);
     70
     71
     72
     73
     74
    7175
    7276/** @}
    7377 */
     78
     79
     80#endif  /* USBMEM_H */
     81
Note: See TracChangeset for help on using the changeset viewer.