Base USB library
[USB]

Common definitions for any driver or application dealing with USB. More...


Files

file  class.c
 Class related functions.
file  classes.h
 USB device classes (generic constants and functions).
file  ddfiface.c
 Implementations of DDF interfaces functions (actual implementation).
file  ddfiface.h
 Implementations of DDF interfaces functions.
file  debug.c
 Debugging and logging support.
file  debug.h
 Debugging related functions.
file  descriptor.h
 Standard USB descriptors.
file  dump.c
 Descriptor dumping.
file  hc.c
 General communication with host controller driver (implementation).
file  hc.h
 General communication with host controller driver.
file  hid_report_items.h
 USB HID Report descriptor item tags.
file  hiddescriptor.h
 USB HID report descriptor and report data parser.
file  hidpath.h
 USB HID report descriptor and report data parser.
file  hidtypes.h
 Basic data structures for USB HID Report descriptor and report parser.
file  hub.h
 USB hub related structures.
file  massstor.h
 USB mass storage related functions and constants.
file  resolve.c
file  usb.c
 Common USB functions.
file  usb.h
 Common USB types and functions.

Data Structures

struct  descriptor_dump_t
 Mapping between descriptor id and dumping function. More...
struct  usb_hc_connection_t
 Connection to the host controller driver. More...
struct  usb_hid_report_description_t
 Description of one concrete report. More...
struct  usb_hid_report_field_t
 Description of one field/item in report. More...
struct  usb_hid_report_item_t
 State table for report descriptor parsing. More...
struct  usb_hid_report_path_t
 USB HID usage path structure. More...
struct  usb_hid_report_t
 Description of all reports described in one report descriptor. More...
struct  usb_hid_report_usage_path_t
 Item of usage path structure. More...
struct  usb_hub_descriptor_header_t
 Header of standard hub descriptor without the "variadic" part. More...
struct  usb_hub_descriptor_type
 usb hub descriptor More...
struct  usb_standard_configuration_descriptor_t
 Standard USB configuration descriptor. More...
struct  usb_standard_device_descriptor_t
 Standard USB device descriptor. More...
struct  usb_standard_endpoint_descriptor_t
 Standard USB endpoint descriptor. More...
struct  usb_standard_hid_class_descriptor_info_t
 Part of standard USB HID descriptor specifying one class descriptor. More...
struct  usb_standard_hid_descriptor_t
 Standard USB HID descriptor. More...
struct  usb_standard_interface_descriptor_t
 Standard USB interface descriptor. More...
struct  usb_target_t
 USB complete address type. More...

Defines

#define ARR_SIZE(arr)   (sizeof(arr)/sizeof(arr[0]))
#define BCD_ARGS(a)   BCD_INT((a)), BCD_FRAC((a))
#define BCD_FMT   "%x.%x"
#define BCD_FRAC(a)   (((unsigned int)(a)) % 256)
#define BCD_INT(a)   (((unsigned int)(a)) / 256)
#define BUFFER_DUMP_GROUP_SIZE   4
 How many bytes to group together.
#define BUFFER_DUMP_LEN   240
 Size of the string for buffer dumps.
#define MAX_DEVICE_PATH   1024
#define PRINTLINE(fmt,)
 Prints single line of USB descriptor dump.
#define REMAINDER_STR_FMT   " (%zu)..."
#define REMAINDER_STR_LEN   (5 + 1 + 10)
#define uint16_host2usb(n)   host2uint16_t_le((n))
 Convert 16bit value from native (host) endianness to USB endianness.
#define uint16_usb2host(n)   uint16_t_le2host((n))
 Convert 16bit value from USB endianness into native (host) one.
#define uint32_host2usb(n)   host2uint32_t_le((n))
 Convert 32bit value from native (host) endianness to USB endianness.
#define uint32_usb2host(n)   uint32_t_le2host((n))
 Convert 32bit value from USB endianness into native (host) one.
#define USB11_ADDRESS_MAX   128
 Maximum address number in USB 1.1.
#define USB11_ENDPOINT_MAX   16
 Maximum endpoint number in USB 1.1.
#define USB_ADDRESS_DEFAULT   0
 Default USB address.
#define USB_HC_DDF_CLASS_NAME   "usbhc"
 Class name for USB host controllers.
#define USB_HID_EXTENDED_USAGE(usage)   (usage & 0xFFFF)
 Cuts usage of the extended usage.
#define USB_HID_EXTENDED_USAGE_PAGE(usage)   ((usage & 0xFFFF0000) >> 16)
 Cuts usage page of the extended usage.
#define USB_HID_INT32_TO_UINT32(x, size)   (((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
 Convert integer from signed format to unsigned.
#define USB_HID_IS_EXTENDED_USAGE(usage)   ((usage & 0xFFFF0000) != 0)
 Recognizes if the given usage is extended (contains also usage page).
#define USB_HID_ITEM_FLAG_BUFFERED(flags)   ((flags & 0x100) == 0x100)
 Indicates that the control emits a fixed-size stream of bytes.
#define USB_HID_ITEM_FLAG_CONSTANT(flags)   ((flags & 0x1) == 0x1)
 Indicates whether the item is data (0) or a constant (1) value.
#define USB_HID_ITEM_FLAG_LINEAR(flags)   ((flags & 0x10) == 0x10)
 Indicates whether the raw data from the device has been processed in some way, and no longer represents a linear relationship between what is measured and the data that is reported.
#define USB_HID_ITEM_FLAG_POSITION(flags)   ((flags & 0x40) == 0x40)
 Indicates whether the control has a state in which it is not sending meaningful data.
#define USB_HID_ITEM_FLAG_PREFERRED(flags)   ((flags & 0x20) == 0x20)
 Indicates whether the control has a preferred state to which it will return when the user is not physically interacting with the control.
#define USB_HID_ITEM_FLAG_RELATIVE(flags)   ((flags & 0x4) == 0x4)
 Indicates whether the data is absolute (0) (based on a fixed origin) or relative (1) (indicating the change in value from the last report).
#define USB_HID_ITEM_FLAG_VARIABLE(flags)   ((flags & 0x2) == 0x2)
 Indicates whether the item creates variable (1) or array (0) data fields in reports.
#define USB_HID_ITEM_FLAG_VOLATILE(flags)   ((flags & 0x80) == 0x80)
 Indicates whether the Feature or Output control's value should be changed by the host or not.
#define USB_HID_ITEM_FLAG_WRAP(flags)   ((flags & 0x8) == 0x8)
 Indicates whether the data “rolls over” when reaching either the extreme high or low value.
#define USB_HID_ITEM_IS_LONG(data)   (data == 0xFE)
 Returns if the item is the short item or long item.
#define USB_HID_ITEM_SIZE(data)   ((uint8_t)(data & 0x3))
 Returns size of item data in bytes.
#define USB_HID_ITEM_TAG(data)   ((uint8_t)((data & 0xF0) >> 4))
 Returns item tag.
#define USB_HID_ITEM_TAG_CLASS(data)   ((uint8_t)((data & 0xC) >> 2))
 Returns class of item tag.
#define USB_HID_MAX_USAGES   0xffff
 Maximum amount of specified usages for one report item.
#define USB_HID_PATH_COMPARE_ANYWHERE   8
 Searched couple of usage page and usage can be anywhere in usage path.
#define USB_HID_PATH_COMPARE_BEGIN   4
 Searched usage page must be prefix of the other one.
#define USB_HID_PATH_COMPARE_END   1
 Wanted usage path must be the suffix in the searched one.
#define USB_HID_PATH_COMPARE_STRICT   0
 Wanted usage path must be exactly the same as the searched one.
#define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY   2
 Only usage page are compared along the usage path.
#define USB_HID_REPORT_TAG_COLLECTION   0xA
 A Collection item identifies a relationship between two or more data (Input, Output, or Feature.
#define USB_HID_REPORT_TAG_DELIMITER   0xA
 Defines the beginning or end of a set of local items (1 = open set, 0 = close set).
#define USB_HID_REPORT_TAG_DESIGNATOR_INDEX   0x3
 Determines the body part used for a control.
#define USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM   0x5
 Defines the index of the ending designator associated with an array or bitmap.
#define USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM   0x4
 Defines the index of the starting designator associated with an array or bitmap.
#define USB_HID_REPORT_TAG_END_COLLECTION   0xC
 While the Collection item opens a collection of data, the End Collection item closes a collection.
#define USB_HID_REPORT_TAG_FEATURE   0xB
 Feature items describe device configuration information that can be sent to the device.
#define USB_HID_REPORT_TAG_INPUT   0x8
 An Input item describes information about the data provided by one or more physical controls.
#define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM   0x2
 Extent value in logical units.
#define USB_HID_REPORT_TAG_LOGICAL_MINIMUM   0x1
 Extent value in logical units.
#define USB_HID_REPORT_TAG_OUTPUT   0x9
 The Output item is used to define an output data field in a report.
#define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM   0x4
 Maximum value for the physical extent of a variable item.
#define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM   0x3
 Minimum value for the physical extent of a variable item.
#define USB_HID_REPORT_TAG_POP   0xB
 Replaces the item state table with the top structure from the stack.
#define USB_HID_REPORT_TAG_PUSH   0xA
 Places a copy of the global item state table on the stack.
#define USB_HID_REPORT_TAG_REPORT_COUNT   0x9
 Unsigned integer specifying the number of data fields for the item; determines how many fields are included in the report for this particular item (and consequently how many bits are added to the report).
#define USB_HID_REPORT_TAG_REPORT_ID   0x8
 Unsigned value that specifies the Report ID.
#define USB_HID_REPORT_TAG_REPORT_SIZE   0x7
 Unsigned integer specifying the size of the report fields in bits.
#define USB_HID_REPORT_TAG_STRING_INDEX   0x7
 String index for a String descriptor; allows a string to be associated with a particular item or control.
#define USB_HID_REPORT_TAG_STRING_MAXIMUM   0x9
 Specifies the last string index when assigning a group of sequential strings to controls in an array or bitmap.
#define USB_HID_REPORT_TAG_STRING_MINIMUM   0x8
 Specifies the first string index when assigning a group of sequential strings to controls in an array or bitmap.
#define USB_HID_REPORT_TAG_UNIT   0x6
 Unit values.
#define USB_HID_REPORT_TAG_UNIT_EXPONENT   0x5
 Value of the unit exponent in base 10.
#define USB_HID_REPORT_TAG_USAGE   0x0
 Usage index for an item usage; represents a suggested usage for the item or collection.
#define USB_HID_REPORT_TAG_USAGE_MAXIMUM   0x2
 Defines the ending usage associated with an array or bitmap.
#define USB_HID_REPORT_TAG_USAGE_MINIMUM   0x1
 Defines the starting usage associated with an array or bitmap.
#define USB_HID_REPORT_TAG_USAGE_PAGE   0x0
 Unsigned integer specifying the current Usage Page.
#define USB_HID_TAG_CLASS_GLOBAL   0x1
 Global items describe rather than define data from a control.
#define USB_HID_TAG_CLASS_LOCAL   0x2
 Local item tags define characteristics of controls.
#define USB_HID_TAG_CLASS_MAIN   0x0
 Main items are used to either define or group certain types of data fields within a Report descriptor.
#define USB_HID_UINT32_TO_INT32(x, size)
 Converts integer from unsigned two's complement format format to signed one.
#define usb_log_debug(format,)   usb_log_printf(USB_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)
 Log debugging message.
#define usb_log_debug2(format,)   usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__)
 Log verbose debugging message.
#define usb_log_error(format,)   usb_log_printf(USB_LOG_LEVEL_ERROR, format, ##__VA_ARGS__)
 Log normal (recoverable) error.
#define usb_log_fatal(format,)   usb_log_printf(USB_LOG_LEVEL_FATAL, format, ##__VA_ARGS__)
 Log fatal error.
#define usb_log_info(format,)   usb_log_printf(USB_LOG_LEVEL_INFO, format, ##__VA_ARGS__)
 Log informational message.
#define USB_LOG_LEVEL_DEFAULT   USB_LOG_LEVEL_DEBUG
 Default log level.
#define usb_log_warning(format,)   usb_log_printf(USB_LOG_LEVEL_WARNING, format, ##__VA_ARGS__)
 Log warning.

Typedefs

typedef int usb_address_t
 USB address type.
typedef int usb_endpoint_t
 USB endpoint number type.
typedef sysarg_t usb_handle_t
 General handle type.
typedef usb_hub_descriptor_type usb_hub_descriptor_t
 usb hub descriptor

Enumerations

enum  usb_class_t
 USB device class.
enum  usb_descriptor_type_t
 Descriptor type.
enum  usb_direction_t
 USB data transfer direction.
enum  usb_hid_modifiers_t
 Enum of the keyboard modifiers.
enum  usb_hid_report_type_t { USB_HID_REPORT_TYPE_INPUT = 1, USB_HID_REPORT_TYPE_OUTPUT = 2, USB_HID_REPORT_TYPE_FEATURE = 3 }
 Enum of report types. More...
enum  usb_hub_bm_request_type_t {
  USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20, USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23, USB_HUB_REQ_TYPE_GET_STATE = 0xA3, USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
  USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0, USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3, USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20, USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
  USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
}
 usb hub specific request types. More...
enum  usb_hub_class_feature_t
 Hub class feature selector. More...
enum  usb_hub_request_t
 these are duplicit to standart descriptors
enum  usb_log_level_t {
  USB_LOG_LEVEL_FATAL, USB_LOG_LEVEL_ERROR, USB_LOG_LEVEL_WARNING, USB_LOG_LEVEL_INFO,
  USB_LOG_LEVEL_DEBUG, USB_LOG_LEVEL_DEBUG2, USB_LOG_LEVEL_MAX
}
 Logging level. More...
enum  usb_massstor_protocol_t { USB_MASSSTOR_PROTOCOL_CBI_CC = 0x00, USB_MASSSTOR_PROTOCOL_CBI = 0x01, USB_MASSSTOR_PROTOCOL_BBB = 0x50, USB_MASSSTOR_PROTOCOL_UAS = 0x62 }
 USB mass storage interface protocols. More...
enum  usb_massstor_subclass_t { , USB_MASSSTOR_SUBCLASS_ATAPI = 0x02 }
 USB mass storage subclasses. More...
enum  usb_packet_id
 USB packet identifier.
enum  usb_request_recipient_t
 USB request recipient.
enum  usb_request_type_t
 USB request type target.
enum  usb_speed_t { USB_SPEED_LOW, USB_SPEED_FULL, USB_SPEED_HIGH, USB_SPEED_MAX }
 USB speeds. More...
enum  usb_transfer_type_t
 USB transfer type.

Functions

static FIBRIL_MUTEX_INITIALIZE (log_serializer)
 Serialization mutex for logging functions.
static int get_device_handle_by_address (devman_handle_t hc_handle, int addr, devman_handle_t *dev_handle)
static const char * log_level_name (usb_log_level_t level)
 Get log level name prefix.
static bool try_parse_bus_and_address (const char *path, char **func_start, devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
int usb_ddf_get_hc_handle_by_class (size_t class_index, devman_handle_t *hc_handle)
 Get host controller handle by its class index.
const char * usb_debug_str_buffer (const uint8_t *buffer, size_t size, size_t dumped_size)
 Dump buffer into string.
static void usb_dump_descriptor_configuration (FILE *, const char *, const char *, const uint8_t *, size_t)
static void usb_dump_descriptor_device (FILE *, const char *, const char *, const uint8_t *, size_t)
static void usb_dump_descriptor_endpoint (FILE *, const char *, const char *, const uint8_t *, size_t)
static void usb_dump_descriptor_generic (FILE *, const char *, const char *, const uint8_t *, size_t)
static void usb_dump_descriptor_hid (FILE *, const char *, const char *, const uint8_t *, size_t)
static void usb_dump_descriptor_hub (FILE *, const char *, const char *, const uint8_t *, size_t)
static void usb_dump_descriptor_interface (FILE *, const char *, const char *, const uint8_t *, size_t)
static void usb_dump_descriptor_string (FILE *, const char *, const char *, const uint8_t *, size_t)
void usb_dump_standard_descriptor (FILE *output, const char *line_prefix, const char *line_suffix, const uint8_t *descriptor, size_t descriptor_length)
 Dumps standard USB descriptor.
int usb_hc_connection_close (usb_hc_connection_t *connection)
 Close connection to the host controller.
int usb_hc_connection_initialize (usb_hc_connection_t *connection, devman_handle_t hc_handle)
 Manually initialize connection to USB host controller.
int usb_hc_connection_initialize_from_device (usb_hc_connection_t *connection, ddf_dev_t *device)
 Initialize connection to USB host controller.
bool usb_hc_connection_is_opened (const usb_hc_connection_t *connection)
 Tells whether connection to host controller is opened.
int usb_hc_connection_open (usb_hc_connection_t *connection)
 Open connection to host controller.
int usb_hc_find (devman_handle_t device_handle, devman_handle_t *hc_handle)
 Find host controller handle that is ancestor of given device.
int usb_hc_get_address_by_handle (devman_handle_t dev_handle)
 Tell USB address assigned to device with given handle.
int usb_hc_get_handle_by_address (usb_hc_connection_t *connection, usb_address_t address, devman_handle_t *handle)
 Get handle of USB device with given address.
void usb_hid_descriptor_print (usb_hid_report_t *report)
 Prints content of given report descriptor in human readable format.
void usb_hid_descriptor_print_list (link_t *head)
 Prints content of given list of report items.
void usb_hid_free_report (usb_hid_report_t *report)
 Frees the HID report descriptor parser structure.
void usb_hid_free_report_list (link_t *head)
 Releases whole linked list of report items.
int usb_hid_parse_report_descriptor (usb_hid_report_t *report, const uint8_t *data, size_t size)
 Parse HID report descriptor.
void usb_hid_print_usage_path (usb_hid_report_path_t *path)
int usb_hid_report_append_fields (usb_hid_report_t *report, usb_hid_report_item_t *report_item)
int usb_hid_report_compare_usage_path (usb_hid_report_path_t *report_path, usb_hid_report_path_t *path, int flags)
 Compares two usage paths structures.
usb_hid_report_description_tusb_hid_report_find_description (const usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type)
 Finds description of report with given report_id and of given type in opaque report structure.
int usb_hid_report_init (usb_hid_report_t *report)
 Initialize the report descriptor parser structure.
usb_hid_report_item_tusb_hid_report_item_clone (const usb_hid_report_item_t *item)
 Clones given state table.
void usb_hid_report_null_last_item (usb_hid_report_path_t *usage_path)
 Nulls last item of the usage path structure.
int usb_hid_report_parse_global_tag (uint8_t tag, const uint8_t *data, size_t item_size, usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
 Parse global tags of report descriptor.
int usb_hid_report_parse_local_tag (uint8_t tag, const uint8_t *data, size_t item_size, usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
 Parse local tags of report descriptor.
int usb_hid_report_parse_main_tag (uint8_t tag, const uint8_t *data, size_t item_size, usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
 Parse main tags of report descriptor.
int usb_hid_report_parse_tag (uint8_t tag, uint8_t class, const uint8_t *data, size_t item_size, usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
 Parse one tag of the report descriptor.
usb_hid_report_path_tusb_hid_report_path (void)
 Allocates and initializes new usage path structure.
int usb_hid_report_path_append_item (usb_hid_report_path_t *usage_path, int32_t usage_page, int32_t usage)
 Appends one item (couple of usage_path and usage) into the usage path structure.
usb_hid_report_path_tusb_hid_report_path_clone (usb_hid_report_path_t *usage_path)
 Clone content of given usage path to the new one.
void usb_hid_report_path_free (usb_hid_report_path_t *path)
 Releases given usage path structure.
int usb_hid_report_path_set_report_id (usb_hid_report_path_t *usage_path, uint8_t report_id)
 Sets report id in usage path structure.
usb_hid_report_path_tusb_hid_report_path_try_insert (usb_hid_report_t *report, usb_hid_report_path_t *cmp_path)
 Checks if given collection path is already present in report structure and inserts it if not.
void usb_hid_report_remove_last_item (usb_hid_report_path_t *usage_path)
 Removes last item from the usage path structure.
void usb_hid_report_reset_local_items (usb_hid_report_item_t *report_item)
 Reset all local items in given state table.
void usb_hid_report_set_last_item (usb_hid_report_path_t *usage_path, int32_t tag, int32_t data)
 Modifies last item of usage path structure by given usage page or usage.
uint32_t usb_hid_report_tag_data_uint32 (const uint8_t *data, size_t size)
 Converts raw data to uint32 (thats the maximum length of short item data).
int usb_iface_get_address_hub_child_impl (ddf_fun_t *fun, devman_handle_t handle, usb_address_t *address)
 Get USB device address, interface implementation for child of a hub driver.
int usb_iface_get_address_hub_impl (ddf_fun_t *fun, devman_handle_t handle, usb_address_t *address)
 Get USB device address, interface implementation for hub driver.
int usb_iface_get_hc_handle_hc_impl (ddf_fun_t *fun, devman_handle_t *handle)
 Get host controller handle, interface implementation for HC driver.
int usb_iface_get_hc_handle_hub_child_impl (ddf_fun_t *fun, devman_handle_t *handle)
 Get host controller handle, interface implementation for child of a hub driver.
int usb_iface_get_hc_handle_hub_impl (ddf_fun_t *fun, devman_handle_t *handle)
 Get host controller handle, interface implementation for hub driver.
void usb_log_enable (usb_log_level_t level, const char *message_prefix)
 Enable logging.
void usb_log_printf (usb_log_level_t level, const char *format,...)
 Print logging message.
int usb_resolve_device_handle (const char *dev_path, devman_handle_t *out_hc_handle, usb_address_t *out_dev_addr, devman_handle_t *out_dev_handle)
 Resolve handle and address of USB device from its path.
const char * usb_str_class (usb_class_t cls)
 Tell string representation of USB class.
const char * usb_str_speed (usb_speed_t s)
 String representation of USB speed.
const char * usb_str_transfer_type (usb_transfer_type_t t)
 String representation for USB transfer type.
const char * usb_str_transfer_type_short (usb_transfer_type_t t)
 String representation for USB transfer type (short version).
static int usb_target_same (usb_target_t a, usb_target_t b)
 Compare USB targets (addresses and endpoints).

Variables

static fibril_local char buffer_dump [2][BUFFER_DUMP_LEN]
 Fibril local storage for the dumped buffer.
static fibril_local int buffer_dump_index = 0
 Fibril local storage for buffer switching.
static descriptor_dump_t descriptor_dumpers []
 Descriptor dumpers mapping.
static usb_log_level_t log_level = USB_LOG_LEVEL_WARNING
 Level of logging messages.
static const char * log_prefix = "usb"
 Prefix for logging messages.
static FILElog_stream = NULL
 File where to store the log.
static const char * str_speed []
static const char * str_transfer_type []
static const char * str_transfer_type_short []
static const usb_hid_modifiers_t usb_hid_modifiers_consts [USB_HID_MOD_COUNT]
size_t USB_HUB_MAX_DESCRIPTOR_SIZE
 Maximum size of usb hub descriptor in bytes.
usb_iface_t usb_iface_hub_child_impl
 DDF interface for USB device, implementation for child of a typical hub.
usb_iface_t usb_iface_hub_child_impl
 DDF interface for USB device, implementation for child of a typical hub.
usb_iface_t usb_iface_hub_impl
 DDF interface for USB device, implementation for typical hub.
usb_iface_t usb_iface_hub_impl
 DDF interface for USB device, implementation for typical hub.

Detailed Description

Common definitions for any driver or application dealing with USB.


Define Documentation

#define PRINTLINE ( fmt   ) 

Value:

fprintf(output, "%s" fmt "%s", \
            line_prefix ? line_prefix : " - ", \
            __VA_ARGS__, \
            line_suffix ? line_suffix : "\n")
Prints single line of USB descriptor dump.

Warning:
This macro abuses heavily the naming conventions used by all dumping functions (i.e. names for output file stream (output) and line prefix and suffix (line_prefix and line_suffix respectively))-
Parameters:
fmt Formatting string.

Definition at line 122 of file dump.c.

#define USB_HID_INT32_TO_UINT32 ( x,
size   )     (((x) < 0 ) ? ((1 << (size)) + (x)) : (x))

Convert integer from signed format to unsigned.

If number is negative the two's complement format is used.

Parameters:
x Number to convert
size Length of result number in bites
Returns:
unsigned int

Definition at line 68 of file hidtypes.h.

#define USB_HID_ITEM_FLAG_BUFFERED ( flags   )     ((flags & 0x100) == 0x100)

Indicates that the control emits a fixed-size stream of bytes.

The contents of the data field are determined by the application. The contents of the buffer are not interpreted as a single numeric quantity. Report data defined by a Buffered Bytes item must be aligned on an 8-bit boundary.

Definition at line 142 of file hid_report_items.h.

#define USB_HID_ITEM_FLAG_CONSTANT ( flags   )     ((flags & 0x1) == 0x1)

Indicates whether the item is data (0) or a constant (1) value.

Data indicates the item is defining report fields that contain modifiable device data. Constant indicates the item is a static read-only field in a report and cannot be modified (written) by the host.

Definition at line 82 of file hid_report_items.h.

#define USB_HID_ITEM_FLAG_POSITION ( flags   )     ((flags & 0x40) == 0x40)

Indicates whether the control has a state in which it is not sending meaningful data.

One possible use of the null state is for controls that require the user to physically interact with the control in order for it to report useful data.

Definition at line 126 of file hid_report_items.h.

#define USB_HID_ITEM_FLAG_PREFERRED ( flags   )     ((flags & 0x20) == 0x20)

Indicates whether the control has a preferred state to which it will return when the user is not physically interacting with the control.

Push buttons (as opposed to toggle buttons) and self- centering joysticks are examples.

Definition at line 118 of file hid_report_items.h.

#define USB_HID_ITEM_FLAG_RELATIVE ( flags   )     ((flags & 0x4) == 0x4)

Indicates whether the data is absolute (0) (based on a fixed origin) or relative (1) (indicating the change in value from the last report).

Mouse devices usually provide relative data, while tablets usually provide absolute data.

Definition at line 96 of file hid_report_items.h.

#define USB_HID_ITEM_FLAG_VOLATILE ( flags   )     ((flags & 0x80) == 0x80)

Indicates whether the Feature or Output control's value should be changed by the host or not.

Volatile output can change with or without host interaction. To avoid synchronization problems, volatile controls should be relative whenever possible.

Definition at line 134 of file hid_report_items.h.

#define USB_HID_ITEM_FLAG_WRAP ( flags   )     ((flags & 0x8) == 0x8)

Indicates whether the data “rolls over” when reaching either the extreme high or low value.

For example, a dial that can spin freely 360 degrees might output values from 0 to 10. If Wrap is indicated, the next value reported after passing the 10 position in the increasing direction would be 0.

Definition at line 104 of file hid_report_items.h.

#define USB_HID_ITEM_IS_LONG ( data   )     (data == 0xFE)

Returns if the item is the short item or long item.

Long items are not supported.

Definition at line 56 of file hid_report_items.h.

#define USB_HID_PATH_COMPARE_ANYWHERE   8

Searched couple of usage page and usage can be anywhere in usage path.

This option is deprecated.

Definition at line 73 of file hidpath.h.

#define USB_HID_PATH_COMPARE_STRICT   0

Wanted usage path must be exactly the same as the searched one.

This option cannot be combined with the others.

Definition at line 51 of file hidpath.h.

#define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY   2

Only usage page are compared along the usage path.

This option can be combined with others.

Definition at line 62 of file hidpath.h.

#define USB_HID_REPORT_TAG_COLLECTION   0xA

A Collection item identifies a relationship between two or more data (Input, Output, or Feature.

)

Definition at line 179 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_DELIMITER   0xA

Defines the beginning or end of a set of local items (1 = open set, 0 = close set).

Usages other than the first (most preferred) usage defined are not accessible by system software.

Definition at line 347 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_DESIGNATOR_INDEX   0x3

Determines the body part used for a control.

Index points to a designator in the Physical descriptor.

Definition at line 308 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_INPUT   0x8

An Input item describes information about the data provided by one or more physical controls.

An application can use this information to interpret the data provided by the device. All data fields defined in a single item share an identical data format.

Definition at line 160 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM   0x2

Extent value in logical units.

This is the maximum value that a variable or array item will report.

Definition at line 217 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_LOGICAL_MINIMUM   0x1

Extent value in logical units.

This is the minimum value that a variable or array item will report. For example, a mouse reporting x position values from 0 to 128 would have a Logical Minimum of 0 and a Logical Maximum of 128.

Definition at line 211 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_OUTPUT   0x9

The Output item is used to define an output data field in a report.

This item is similar to an Input item except it describes data sent to the device—for example, LED states.

Definition at line 167 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM   0x3

Minimum value for the physical extent of a variable item.

This represents the Logical Minimum with units applied to it.

Definition at line 223 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_REPORT_ID   0x8

Unsigned value that specifies the Report ID.

If a Report ID tag is used anywhere in Report descriptor, all data reports for the device are preceded by a single byte ID field. All items succeeding the first Report ID tag but preceding a second Report ID tag are included in a report prefixed by a 1-byte ID. All items succeeding the second but preceding a third Report ID tag are included in a second report prefixed by a second ID, and so on.

Definition at line 255 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_REPORT_SIZE   0x7

Unsigned integer specifying the size of the report fields in bits.

This allows the parser to build an item map for the report handler to use.

Definition at line 245 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_UNIT_EXPONENT   0x5

Value of the unit exponent in base 10.

See the table later in this section for more information.

Definition at line 234 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_USAGE   0x0

Usage index for an item usage; represents a suggested usage for the item or collection.

In the case where an item represents multiple controls, a Usage tag may suggest a usage for every variable or element in an array.

Definition at line 292 of file hid_report_items.h.

#define USB_HID_REPORT_TAG_USAGE_PAGE   0x0

Unsigned integer specifying the current Usage Page.

Since a usage are 32 bit values, Usage Page items can be used to conserve space in a report descriptor by setting the high order 16 bits of a subsequent usages. Any usage that follows which is defines 16 bits or less is interpreted as a Usage ID and concatenated with the Usage Page to form a 32 bit Usage.

Definition at line 203 of file hid_report_items.h.

#define USB_HID_TAG_CLASS_LOCAL   0x2

Local item tags define characteristics of controls.

These items do not carry over to the next Main item. If a Main item defines more than one control, it may be preceded by several similar Local item tags. For example, an Input item may have several Usage tags associated with it, one for each control.

Definition at line 285 of file hid_report_items.h.

#define USB_HID_UINT32_TO_INT32 ( x,
size   ) 

Value:

((((x) & (1 << ((size) - 1))) != 0) ?   \
         -(~((x) - 1) & ((1 << size) - 1)) : (x))
Converts integer from unsigned two's complement format format to signed one.

Parameters:
x Number to convert
size Length of the unsigned number in bites
Returns:
signed int

Definition at line 56 of file hidtypes.h.


Typedef Documentation

typedef int usb_address_t

USB address type.

Negative values could be used to indicate error.

Definition at line 105 of file usb.h.

typedef int usb_endpoint_t

USB endpoint number type.

Negative values could be used to indicate error.

Definition at line 115 of file usb.h.

typedef sysarg_t usb_handle_t

General handle type.

Used by various USB functions as opaque handle.

Definition at line 145 of file usb.h.

typedef struct usb_hub_descriptor_type usb_hub_descriptor_t

usb hub descriptor

For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2


Enumeration Type Documentation

enum usb_hid_report_type_t

Enum of report types.

Enumerator:
USB_HID_REPORT_TYPE_INPUT  Input report.

Data are sent from device to system

USB_HID_REPORT_TYPE_OUTPUT  Output report.

Data are sent from system to device

USB_HID_REPORT_TYPE_FEATURE  Feature report.

Describes device configuration information that can be sent to the device

Definition at line 76 of file hidtypes.h.

enum usb_hub_bm_request_type_t

usb hub specific request types.

For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2

Enumerator:
USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE  This request resets a value reported in the hub status.
USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE  This request resets a value reported in the port status.
USB_HUB_REQ_TYPE_GET_STATE  This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point.
USB_HUB_REQ_TYPE_GET_DESCRIPTOR  This request returns the hub descriptor.
USB_HUB_REQ_TYPE_GET_HUB_STATUS  This request returns the current hub status and the states that have changed since the previous acknowledgment.
USB_HUB_REQ_TYPE_GET_PORT_STATUS  This request returns the current port status and the current value of the port status change bits.
USB_HUB_REQ_TYPE_SET_DESCRIPTOR  This request overwrites the hub descriptor.
USB_HUB_REQ_TYPE_SET_HUB_FEATURE  This request sets a value reported in the hub status.
USB_HUB_REQ_TYPE_SET_PORT_FEATURE  This request sets a value reported in the port status.

Definition at line 173 of file hub.h.

enum usb_hub_class_feature_t

Hub class feature selector.

Warning:
The constants are not unique (feature selectors are used for hub and port).

Definition at line 44 of file hub.h.

enum usb_log_level_t

Logging level.

Enumerator:
USB_LOG_LEVEL_FATAL  Fatal, unrecoverable, error.

Such error prevents the driver from working at all.

USB_LOG_LEVEL_ERROR  Serious but recoverable error Shall be used for errors fatal for single device but not for driver itself.
USB_LOG_LEVEL_WARNING  Warning.

Problems from which the driver is able to recover gracefully.

USB_LOG_LEVEL_INFO  Information message.

This should be the last level that is printed by default to the screen. Typical usage is to inform that new device was found and what are its capabilities. Do not use for repetitive actions (such as device polling).

USB_LOG_LEVEL_DEBUG  Debugging message.
USB_LOG_LEVEL_DEBUG2  More detailed debugging message.
USB_LOG_LEVEL_MAX  Terminating constant for logging levels.

Definition at line 46 of file debug.h.

enum usb_massstor_protocol_t

USB mass storage interface protocols.

Enumerator:
USB_MASSSTOR_PROTOCOL_CBI_CC  CBI transport with command completion interrupt.
USB_MASSSTOR_PROTOCOL_CBI  CBI transport with no command completion interrupt.
USB_MASSSTOR_PROTOCOL_BBB  Bulk only transport.
USB_MASSSTOR_PROTOCOL_UAS  USB attached SCSI.

Definition at line 53 of file massstor.h.

enum usb_massstor_subclass_t

USB mass storage subclasses.

Enumerator:
USB_MASSSTOR_SUBCLASS_ATAPI  Also known as MMC-5.

Definition at line 41 of file massstor.h.

enum usb_speed_t

USB speeds.

Enumerator:
USB_SPEED_LOW  USB 1.1 low speed (1.5Mbits/s).
USB_SPEED_FULL  USB 1.1 full speed (12Mbits/s).
USB_SPEED_HIGH  USB 2.0 high speed (480Mbits/s).
USB_SPEED_MAX  Psuedo-speed serving as a boundary.

Definition at line 73 of file usb.h.


Function Documentation

static const char* log_level_name ( usb_log_level_t  level  )  [static]

Get log level name prefix.

Parameters:
level Log level.
Returns:
String prefix for the message.

Definition at line 79 of file debug.c.

int usb_ddf_get_hc_handle_by_class ( size_t  class_index,
devman_handle_t hc_handle 
)

Get host controller handle by its class index.

Parameters:
class_index Class index for the host controller.
hc_handle Where to store the HC handle (can be NULL for existence test only).
Returns:
Error code.

Definition at line 208 of file hc.c.

const char * usb_debug_str_buffer ( const uint8_t *  buffer,
size_t  size,
size_t  dumped_size 
)

Dump buffer into string.

The function dumps given buffer into hexadecimal format and stores it in a static fibril local string. That means that you do not have to deallocate the string (actually, you can not do that) and you do not have to guard it against concurrent calls to it. The only limitation is that each second call rewrites the buffer again (internally, two buffer are used in cyclic manner). Thus, it is necessary to copy the buffer elsewhere (that includes printing to screen or writing to file). Since this function is expected to be used for debugging prints only, that is not a big limitation.

Warning:
You cannot use this function more than twice in the same printf (see detailed explanation).
Parameters:
buffer Buffer to be printed (can be NULL).
size Size of the buffer in bytes (can be zero).
dumped_size How many bytes to actually dump (zero means all).
Returns:
Dumped buffer as a static (but fibril local) string.

Definition at line 187 of file debug.c.

void usb_dump_standard_descriptor ( FILE output,
const char *  line_prefix,
const char *  line_suffix,
const uint8_t *  descriptor,
size_t  descriptor_length 
)

Dumps standard USB descriptor.

The line_suffix must contain the newline \n character. When line_suffix or line_prefix is NULL, they are substitued with default values ( - for prefix and line termination for suffix).

Parameters:
output Output file stream to dump descriptor to.
line_prefix Prefix for each line of output.
line_suffix Suffix of each line of output.
descriptor Actual descriptor.
descriptor_length Descriptor size.

Definition at line 95 of file dump.c.

int usb_hc_connection_close ( usb_hc_connection_t connection  ) 

Close connection to the host controller.

Parameters:
connection Connection to the host controller.
Returns:
Error code.

Definition at line 128 of file hc.c.

int usb_hc_connection_initialize ( usb_hc_connection_t connection,
devman_handle_t  hc_handle 
)

Manually initialize connection to USB host controller.

Parameters:
connection Connection to be initialized.
hc_handle Devman handle of the host controller.
Returns:
Error code.

Definition at line 77 of file hc.c.

int usb_hc_connection_initialize_from_device ( usb_hc_connection_t connection,
ddf_dev_t device 
)

Initialize connection to USB host controller.

Parameters:
connection Connection to be initialized.
device Device connecting to the host controller.
Returns:
Error code.

Definition at line 51 of file hc.c.

bool usb_hc_connection_is_opened ( const usb_hc_connection_t connection  ) 

Tells whether connection to host controller is opened.

Parameters:
connection Connection to the host controller.
Returns:
Whether connection is opened.

Definition at line 116 of file hc.c.

int usb_hc_connection_open ( usb_hc_connection_t connection  ) 

Open connection to host controller.

Parameters:
connection Connection to the host controller.
Returns:
Error code.

Definition at line 93 of file hc.c.

int usb_hc_find ( devman_handle_t  device_handle,
devman_handle_t hc_handle 
)

Find host controller handle that is ancestor of given device.

Parameters:
[in] device_handle Device devman handle.
[out] hc_handle Where to store handle of host controller controlling device with device_handle handle.
Returns:
Error code.

Definition at line 240 of file hc.c.

usb_address_t usb_hc_get_address_by_handle ( devman_handle_t  dev_handle  ) 

Tell USB address assigned to device with given handle.

Parameters:
dev_handle Devman handle of the USB device in question.
Returns:
USB address or negative error code.

Definition at line 177 of file hc.c.

int usb_hc_get_handle_by_address ( usb_hc_connection_t connection,
usb_address_t  address,
devman_handle_t handle 
)

Get handle of USB device with given address.

Parameters:
[in] connection Opened connection to host controller.
[in] address Address of device in question.
[out] handle Where to write the device handle.
Returns:
Error code.

Definition at line 153 of file hc.c.

void usb_hid_descriptor_print ( usb_hid_report_t report  ) 

Prints content of given report descriptor in human readable format.

Parameters:
parser Parsed descriptor to print
Returns:
void

Definition at line 955 of file hiddescriptor.c.

void usb_hid_descriptor_print_list ( link_t head  ) 

Prints content of given list of report items.

Parameters:
List of report items (usb_hid_report_item_t)
Returns:
void

Definition at line 903 of file hiddescriptor.c.

void usb_hid_free_report ( usb_hid_report_t report  ) 

Frees the HID report descriptor parser structure.

Parameters:
parser Opaque HID report parser structure
Returns:
void

Definition at line 1025 of file hiddescriptor.c.

void usb_hid_free_report_list ( link_t head  ) 

Releases whole linked list of report items.

Parameters:
head Head of list of report descriptor items (usb_hid_report_item_t)
Returns:
void

Definition at line 989 of file hiddescriptor.c.

int usb_hid_parse_report_descriptor ( usb_hid_report_t report,
const uint8_t *  data,
size_t  size 
)

Parse HID report descriptor.

Parameters:
parser Opaque HID report parser structure.
data Data describing the report.
Returns:
Error code.
Return values:
ENOMEM If no more memmory is available
EINVAL If invalid data are founded
EOK If report descriptor is successfully parsed

Definition at line 364 of file hiddescriptor.c.

int usb_hid_report_append_fields ( usb_hid_report_t report,
usb_hid_report_item_t report_item 
)

Parameters:
report Report structure in which the new report items should be stored
report_item Current report descriptor's parsing state table
Returns:
Error code
Return values:
EOK If all fields were successfully append to report
EINVAL If invalid parameters (NULL) was given
ENOMEM If there is no memmory to store new report description

Definition at line 163 of file hiddescriptor.c.

int usb_hid_report_compare_usage_path ( usb_hid_report_path_t report_path,
usb_hid_report_path_t path,
int  flags 
)

Compares two usage paths structures.

Parameters:
report_path usage path structure to compare with
path usage patrh structure to compare
flags Flags determining the mode of comparison
Returns:
EOK if both paths are identical, non zero number otherwise

Definition at line 200 of file hidpath.c.

usb_hid_report_description_t* usb_hid_report_find_description ( const usb_hid_report_t report,
uint8_t  report_id,
usb_hid_report_type_t  type 
)

Finds description of report with given report_id and of given type in opaque report structure.

Parameters:
report Opaque structure containing the parsed report descriptor
report_id ReportId of report we are searching
type Type of report we are searching
Returns:
Pointer to the particular report description
Return values:
NULL If no description is founded

Definition at line 327 of file hiddescriptor.c.

int usb_hid_report_init ( usb_hid_report_t report  ) 

Initialize the report descriptor parser structure.

Parameters:
parser Report descriptor parser structure
Returns:
Error code
Return values:
EINVAL If no report structure was given
EOK If report structure was successfully initialized

Definition at line 135 of file hiddescriptor.c.

usb_hid_report_item_t* usb_hid_report_item_clone ( const usb_hid_report_item_t item  ) 

Clones given state table.

Parameters:
item State table to clone
Returns:
Pointer to the cloned item

Definition at line 510 of file hidparser.c.

void usb_hid_report_null_last_item ( usb_hid_report_path_t usage_path  ) 

Nulls last item of the usage path structure.

Parameters:
usage_path 
Returns:
void

Definition at line 120 of file hidpath.c.

int usb_hid_report_parse_global_tag ( uint8_t  tag,
const uint8_t *  data,
size_t  item_size,
usb_hid_report_item_t report_item,
usb_hid_report_path_t usage_path 
)

Parse global tags of report descriptor.

Parameters:
Tag identifier
Data buffer
Length of data buffer
Current state table
Returns:
Error code

Definition at line 658 of file hiddescriptor.c.

int usb_hid_report_parse_local_tag ( uint8_t  tag,
const uint8_t *  data,
size_t  item_size,
usb_hid_report_item_t report_item,
usb_hid_report_path_t usage_path 
)

Parse local tags of report descriptor.

Parameters:
Tag identifier
Data buffer
Length of data buffer
Current state table
Returns:
Error code

Definition at line 744 of file hiddescriptor.c.

int usb_hid_report_parse_main_tag ( uint8_t  tag,
const uint8_t *  data,
size_t  item_size,
usb_hid_report_item_t report_item,
usb_hid_report_path_t usage_path 
)

Parse main tags of report descriptor.

Parameters:
Tag identifier
Data buffer
Length of data buffer
Current state table
Returns:
Error code

Definition at line 594 of file hiddescriptor.c.

int usb_hid_report_parse_tag ( uint8_t  tag,
uint8_t  class,
const uint8_t *  data,
size_t  item_size,
usb_hid_report_item_t report_item,
usb_hid_report_path_t usage_path 
)

Parse one tag of the report descriptor.

Parameters:
Tag to parse
Report descriptor buffer
Size of data belongs to this tag
Current report item structe
Returns:
Code of action to be done next

Definition at line 550 of file hiddescriptor.c.

usb_hid_report_path_t* usb_hid_report_path ( void   ) 

Allocates and initializes new usage path structure.

Returns:
Initialized usage path structure

Definition at line 365 of file hidpath.c.

int usb_hid_report_path_append_item ( usb_hid_report_path_t usage_path,
int32_t  usage_page,
int32_t  usage 
)

Appends one item (couple of usage_path and usage) into the usage path structure.

Parameters:
usage_path Usage path structure
usage_page Usage page constant
usage Usage constant
Returns:
Error code

Definition at line 75 of file hidpath.c.

usb_hid_report_path_t* usb_hid_report_path_clone ( usb_hid_report_path_t usage_path  ) 

Clone content of given usage path to the new one.

Parameters:
usage_path Usage path structure to clone
Returns:
New copy of given usage path structure

Definition at line 405 of file hidpath.c.

void usb_hid_report_path_free ( usb_hid_report_path_t path  ) 

Releases given usage path structure.

Parameters:
path usage path structure to release
Returns:
void

Definition at line 388 of file hidpath.c.

int usb_hid_report_path_set_report_id ( usb_hid_report_path_t path,
uint8_t  report_id 
)

Sets report id in usage path structure.

Parameters:
path Usage path structure
report_id Report id to set
Returns:
Error code

Definition at line 455 of file hidpath.c.

usb_hid_report_path_t* usb_hid_report_path_try_insert ( usb_hid_report_t report,
usb_hid_report_path_t cmp_path 
)

Checks if given collection path is already present in report structure and inserts it if not.

Parameters:
report Report structure
cmp_path The collection path
Returns:
Pointer to the result collection path in report structure.
Return values:
NULL If some error occurs

Definition at line 90 of file hiddescriptor.c.

void usb_hid_report_remove_last_item ( usb_hid_report_path_t usage_path  ) 

Removes last item from the usage path structure.

Parameters:
usage_path 
Returns:
void

Definition at line 100 of file hidpath.c.

void usb_hid_report_reset_local_items ( usb_hid_report_item_t report_item  ) 

Reset all local items in given state table.

Parameters:
report_item State table containing current state of report descriptor parsing
Returns:
void

Definition at line 643 of file hidparser.c.

void usb_hid_report_set_last_item ( usb_hid_report_path_t usage_path,
int32_t  tag,
int32_t  data 
)

Modifies last item of usage path structure by given usage page or usage.

Parameters:
usage_path Opaque usage path structure
tag Class of currently processed tag (Usage page tag falls into Global class but Usage tag into the Local)
data Value of the processed tag
Returns:
void

Definition at line 142 of file hidpath.c.

uint32_t usb_hid_report_tag_data_uint32 ( const uint8_t *  data,
size_t  size 
)

Converts raw data to uint32 (thats the maximum length of short item data).

Parameters:
Data buffer
Size of buffer
Returns:
Converted int32 number

Definition at line 883 of file hiddescriptor.c.

int usb_iface_get_address_hub_child_impl ( ddf_fun_t fun,
devman_handle_t  handle,
usb_address_t address 
)

Get USB device address, interface implementation for child of a hub driver.

Parameters:
[in] fun Device function the operation is running on.
[in] handle Devman handle of USB device we want address of.
[out] address Storage for USB address of device with handle handle.
Returns:
Error code.

Definition at line 161 of file ddfiface.c.

int usb_iface_get_address_hub_impl ( ddf_fun_t fun,
devman_handle_t  handle,
usb_address_t address 
)

Get USB device address, interface implementation for hub driver.

Parameters:
[in] fun Device function the operation is running on.
[in] handle Devman handle of USB device we want address of.
[out] address Storage for USB address of device with handle handle.
Returns:
Error code.

Definition at line 126 of file ddfiface.c.

int usb_iface_get_hc_handle_hc_impl ( ddf_fun_t fun,
devman_handle_t handle 
)

Get host controller handle, interface implementation for HC driver.

Parameters:
[in] fun Device function the operation is running on.
[out] handle Storage for the host controller handle.
Returns:
Always EOK.

Definition at line 108 of file ddfiface.c.

int usb_iface_get_hc_handle_hub_child_impl ( ddf_fun_t fun,
devman_handle_t handle 
)

Get host controller handle, interface implementation for child of a hub driver.

Parameters:
[in] fun Device function the operation is running on.
[out] handle Storage for the host controller handle.
Returns:
Error code.

Definition at line 76 of file ddfiface.c.

int usb_iface_get_hc_handle_hub_impl ( ddf_fun_t fun,
devman_handle_t handle 
)

Get host controller handle, interface implementation for hub driver.

Parameters:
[in] fun Device function the operation is running on.
[out] handle Storage for the host controller handle.
Returns:
Error code.

Definition at line 63 of file ddfiface.c.

void usb_log_enable ( usb_log_level_t  level,
const char *  message_prefix 
)

Enable logging.

Parameters:
level Maximal enabled level (including this one).
message_prefix Prefix for each printed message.

Definition at line 60 of file debug.c.

void usb_log_printf ( usb_log_level_t  level,
const char *  format,
  ... 
)

Print logging message.

Parameters:
level Verbosity level of the message.
format Formatting directive.

Definition at line 100 of file debug.c.

int usb_resolve_device_handle ( const char *  dev_path,
devman_handle_t out_hc_handle,
usb_address_t out_dev_addr,
devman_handle_t out_dev_handle 
)

Resolve handle and address of USB device from its path.

This is a wrapper working on best effort principle. If the resolving fails, if will not give much details about what is wrong. Typically, error from this function would be reported to the user as "bad device specification" or "device does not exist".

The path can be specified in following format:

Parameters:
[in] dev_path Path to the device.
[out] out_hc_handle Where to store handle of a parent host controller.
[out] out_dev_addr Where to store device (USB) address.
[out] out_dev_handle Where to store device handle.
Returns:
Error code.

Definition at line 114 of file resolve.c.

const char * usb_str_class ( usb_class_t  cls  ) 

Tell string representation of USB class.

Parameters:
cls Class code.
Returns:
String representation.

Definition at line 43 of file class.c.

const char * usb_str_speed ( usb_speed_t  s  ) 

String representation of USB speed.

Parameters:
s The speed.
Returns:
USB speed as a string (in English).

Definition at line 91 of file usb.c.

const char * usb_str_transfer_type ( usb_transfer_type_t  t  ) 

String representation for USB transfer type.

Parameters:
t Transfer type.
Returns:
Transfer type as a string (in English).

Definition at line 65 of file usb.c.

const char * usb_str_transfer_type_short ( usb_transfer_type_t  t  ) 

String representation for USB transfer type (short version).

Parameters:
t Transfer type.
Returns:
Transfer type as a short string for debugging messages.

Definition at line 78 of file usb.c.

static int usb_target_same ( usb_target_t  a,
usb_target_t  b 
) [inline, static]

Compare USB targets (addresses and endpoints).

Parameters:
a First target.
b Second target.
Returns:
Whether a and b points to the same pipe on the same device.

Definition at line 136 of file usb.h.


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