request.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011 Vojtech Horky
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #ifndef LIBUSBDEV_REQUEST_H_
00036 #define LIBUSBDEV_REQUEST_H_
00037 
00038 #include <sys/types.h>
00039 #include <l18n/langs.h>
00040 #include <usb/usb.h>
00041 #include <usb/dev/pipes.h>
00042 #include <usb/descriptor.h>
00043 
00045 #define USB_DEVICE_STATUS_SELF_POWERED ((uint16_t)(1 << 0))
00046 
00048 #define USB_DEVICE_STATUS_REMOTE_WAKEUP ((uint16_t)(1 << 1))
00049 
00051 #define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
00052 
00054 #define USB_FEATURE_SELECTOR_ENDPOINT_HALT (0)
00055 
00057 #define USB_FEATURE_SELECTOR_REMOTE_WAKEUP (1)
00058 
00060 typedef enum {
00061         USB_DEVREQ_GET_STATUS = 0,
00062         USB_DEVREQ_CLEAR_FEATURE = 1,
00063         USB_DEVREQ_SET_FEATURE = 3,
00064         USB_DEVREQ_SET_ADDRESS = 5,
00065         USB_DEVREQ_GET_DESCRIPTOR = 6,
00066         USB_DEVREQ_SET_DESCRIPTOR = 7,
00067         USB_DEVREQ_GET_CONFIGURATION = 8,
00068         USB_DEVREQ_SET_CONFIGURATION = 9,
00069         USB_DEVREQ_GET_INTERFACE = 10,
00070         USB_DEVREQ_SET_INTERFACE = 11,
00071         USB_DEVREQ_SYNCH_FRAME = 12,
00072         USB_DEVREQ_LAST_STD
00073 } usb_stddevreq_t;
00074 
00078 typedef struct {
00083         uint8_t request_type;
00085         uint8_t request;
00087         union {
00088                 uint16_t value;
00089                 /* FIXME: add #ifdefs according to host endianness */
00090                 struct {
00091                         uint8_t value_low;
00092                         uint8_t value_high;
00093                 };
00094         };
00098         uint16_t index;
00100         uint16_t length;
00101 } __attribute__ ((packed)) usb_device_request_setup_packet_t;
00102 
00103 int usb_control_request_set(usb_pipe_t *,
00104     usb_request_type_t, usb_request_recipient_t, uint8_t,
00105     uint16_t, uint16_t, void *, size_t);
00106 
00107 int usb_control_request_get(usb_pipe_t *,
00108     usb_request_type_t, usb_request_recipient_t, uint8_t,
00109     uint16_t, uint16_t, void *, size_t, size_t *);
00110 
00111 int usb_request_get_status(usb_pipe_t *, usb_request_recipient_t,
00112     uint16_t, uint16_t *);
00113 int usb_request_clear_feature(usb_pipe_t *, usb_request_type_t,
00114     usb_request_recipient_t, uint16_t, uint16_t);
00115 int usb_request_set_feature(usb_pipe_t *, usb_request_type_t,
00116     usb_request_recipient_t, uint16_t, uint16_t);
00117 int usb_request_set_address(usb_pipe_t *, usb_address_t);
00118 int usb_request_get_descriptor(usb_pipe_t *, usb_request_type_t,
00119     usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t, 
00120     size_t *);
00121 int usb_request_get_descriptor_alloc(usb_pipe_t *, usb_request_type_t,
00122     usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *);
00123 int usb_request_get_device_descriptor(usb_pipe_t *,
00124     usb_standard_device_descriptor_t *);
00125 int usb_request_get_bare_configuration_descriptor(usb_pipe_t *, int,
00126     usb_standard_configuration_descriptor_t *);
00127 int usb_request_get_full_configuration_descriptor(usb_pipe_t *, int,
00128     void *, size_t, size_t *);
00129 int usb_request_get_full_configuration_descriptor_alloc(usb_pipe_t *,
00130     int, void **, size_t *);
00131 int usb_request_set_descriptor(usb_pipe_t *, usb_request_type_t,
00132     usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t);
00133 int usb_request_get_configuration(usb_pipe_t *, uint8_t *);
00134 int usb_request_set_configuration(usb_pipe_t *, uint8_t);
00135 int usb_request_get_interface(usb_pipe_t *, uint8_t, uint8_t *);
00136 int usb_request_set_interface(usb_pipe_t *, uint8_t, uint8_t);
00137 
00138 int usb_request_get_supported_languages(usb_pipe_t *,
00139     l18_win_locales_t **, size_t *);
00140 int usb_request_get_string(usb_pipe_t *, size_t, l18_win_locales_t,
00141     char **);
00142 
00143 int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
00144 int usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *);
00145 int usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
00146 
00147 #endif
00148 

Generated on Thu Jun 2 07:45:48 2011 for HelenOS/USB by  doxygen 1.4.7