Files | |
file | altiface.c |
Handling alternate interface settings. | |
file | devdrv.c |
USB device driver framework. | |
file | devpoll.c |
USB device driver framework - automatic interrupt polling. | |
file | dp.c |
USB descriptor parser (implementation). | |
file | dp.h |
USB descriptor parser. | |
file | driver.h |
USB device driver framework. | |
file | hub.c |
Functions needed by hub drivers. | |
file | hub.h |
Functions needed by hub drivers. | |
file | pipepriv.c |
Library internal functions on USB pipes (implementation). | |
file | pipepriv.h |
Library internal functions on USB pipes. | |
file | pipes.c |
USB endpoint pipes miscellaneous functions. | |
file | pipes.h |
USB pipes representation. | |
file | pipesinit.c |
Initialization of endpoint pipes. | |
file | pipesio.c |
Input and output functions (reads and writes) on endpoint pipes. | |
file | poll.h |
USB device polling functions. | |
file | recognise.c |
Functions for recognition of attached devices. | |
file | recognise.h |
USB device recognition. | |
file | request.c |
Standard USB requests (implementation). | |
file | request.h |
Standard USB requests. | |
Data Structures | |
struct | polling_data_t |
Data needed for polling. More... | |
struct | usb_alternate_interface_descriptors_t |
Wrapper for data related to alternate interface setting. More... | |
struct | usb_alternate_interfaces_t |
Alternate interface settings. More... | |
struct | usb_device_auto_polling_t |
struct | usb_device_connection_t |
Abstraction of a physical connection to the device. More... | |
struct | usb_device_descriptors_t |
Descriptors for USB device. More... | |
struct | usb_device_request_setup_packet_t |
Device request setup packet. More... | |
struct | usb_device_t |
USB device structure. More... | |
struct | usb_dp_descriptor_nesting_t |
USB descriptors nesting. More... | |
struct | usb_dp_parser_data_t |
Descriptor parser data. More... | |
struct | usb_dp_parser_t |
Descriptor parser structure. More... | |
struct | usb_driver_ops_t |
USB driver ops. More... | |
struct | usb_driver_t |
USB driver structure. More... | |
struct | usb_endpoint_description_t |
Description of endpoint characteristics. More... | |
struct | usb_endpoint_mapping_t |
Mapping of endpoint pipes and endpoint descriptions. More... | |
struct | usb_hc_attached_device_t |
Info about device attached to host controller. More... | |
struct | usb_pipe_t |
Abstraction of a logical connection to USB device endpoint. More... | |
Defines | |
#define | ADD_MATCHID_OR_RETURN(match_ids, score, format,) |
Add match id to list or return with error code. | |
#define | BCD_ARGS(a) BCD_INT((a)), BCD_FRAC((a)) |
Arguments to printf for BCD coded number. | |
#define | BCD_FMT "%x.%x" |
Format for BCD coded number to be used in printf. | |
#define | BCD_FRAC(a) (((unsigned int)(a)) % 256) |
Get fraction part from BCD coded number (as an integer, no less). | |
#define | BCD_INT(a) (((unsigned int)(a)) / 256) |
Get integer part from BCD coded number. | |
#define | CHECK_CONNECTION(conn) |
Check that HC connection is alright. | |
#define | CTRL_PIPE_MIN_PACKET_SIZE 8 |
#define | DEV_DESCR_MAX_PACKET_SIZE_OFFSET 7 |
#define | ENDPOINT_0_0_REGISTER_ATTEMPT_DELAY_USEC (1000 * (10 + 2)) |
How much time to wait between attempts to register endpoint 0:0. | |
#define | IPC_AGAIN_DELAY (1000 * 2) |
#define | LAST_NESTING { -1, -1 } |
#define | LAST_NESTING { -1, -1 } |
#define | MATCH_STRING_MAX 256 |
#define | MAX_DATA_LENGTH ((size_t)(0xFFFF)) |
#define | MAX_FAILED_ATTEMPTS 3 |
Maximum number of failed consecutive requests before announcing failure. | |
#define | NESTING(parentname, childname) |
#define | NESTING(parentname, childname) |
#define | USB_DEVICE_STATUS_REMOTE_WAKEUP ((uint16_t)(1 << 1)) |
USB device status - remote wake-up signaling is enabled. | |
#define | USB_DEVICE_STATUS_SELF_POWERED ((uint16_t)(1 << 0)) |
USB device status - device is self powered (opposed to bus powered). | |
#define | USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0)) |
USB endpoint status - endpoint is halted (stalled). | |
#define | USB_FEATURE_SELECTOR_ENDPOINT_HALT (0) |
USB feature selector - endpoint halt (stall). | |
#define | USB_FEATURE_SELECTOR_REMOTE_WAKEUP (1) |
USB feature selector - device remote wake-up. | |
Typedefs | |
typedef bool(*) | usb_polling_callback_t (usb_device_t *, uint8_t *, size_t, void *) |
typedef void(*) | usb_polling_terminted_callback_t (usb_device_t *, bool, void *) |
Enumerations | |
enum | usb_stddevreq_t |
Standard device request. | |
Functions | |
static void | clear_self_endpoint_halt (usb_pipe_t *pipe) |
Try to clear endpoint halt of default control pipe. | |
static size_t | count_other_pipes (usb_endpoint_description_t **endpoints) |
Count number of pipes the driver expects. | |
static int | destroy_current_pipes (usb_device_t *dev) |
Destroy existing pipes of a USB device. | |
static bool | endpoint_fits_description (const usb_endpoint_description_t *wanted, usb_endpoint_description_t *found) |
Tells whether found endpoint corresponds to endpoint described by user. | |
static | FIBRIL_MUTEX_INITIALIZE (device_name_index_mutex) |
Mutex guard for device_name_index. | |
static usb_endpoint_mapping_t * | find_endpoint_mapping (usb_endpoint_mapping_t *mapping, size_t mapping_count, usb_endpoint_description_t *found_endpoint, int interface_number, int interface_setting) |
Find endpoint mapping for a found endpoint. | |
static int | generic_add_device (ddf_dev_t *gen_dev) |
Callback when new device is supposed to be controlled by this driver. | |
static int | get_descriptor_type (usb_dp_parser_data_t *data, uint8_t *start) |
Get descriptor type. | |
static usb_address_t | get_my_address (int phone, ddf_dev_t *dev) |
Tell USB address assigned to given device. | |
static uint8_t * | get_next_descriptor (usb_dp_parser_data_t *data, uint8_t *current) |
Get next descriptor regardless of the nesting. | |
static int | init_wire_and_ctrl_pipe (usb_device_t *dev, const char **errmsg) |
Initialize control pipe in a device. | |
static int | initialize_other_pipes (usb_endpoint_description_t **endpoints, usb_device_t *dev, int alternate_setting) |
Initialize endpoint pipes, excluding default control one. | |
static bool | is_endpoint_descriptor (uint8_t *descriptor) |
Tells whether given descriptor is of endpoint type. | |
static bool | is_nested_descriptor (usb_dp_parser_t *parser, usb_dp_parser_data_t *data, uint8_t *child, uint8_t *parent) |
Tells whether descriptors could be nested. | |
static bool | is_nested_descriptor_type (usb_dp_parser_t *parser, int child, int parent) |
Tells whether descriptors could be nested. | |
static bool | is_valid_descriptor_pointer (usb_dp_parser_data_t *data, uint8_t *ptr) |
Tells whether pointer points inside descriptor data. | |
void | pipe_acquire (usb_pipe_t *pipe) |
Ensure exclusive access to the pipe as a whole. | |
int | pipe_add_ref (usb_pipe_t *pipe, bool hide_failure) |
Add reference of active transfers over the pipe. | |
void | pipe_drop_ref (usb_pipe_t *pipe) |
Drop active transfer reference on the pipe. | |
void | pipe_end_transaction (usb_pipe_t *pipe) |
Terminate exclusive access to the IPC phone of given pipe. | |
void | pipe_release (usb_pipe_t *pipe) |
Terminate exclusive access to the pipe as a whole. | |
void | pipe_start_transaction (usb_pipe_t *pipe) |
Ensure exclusive access to the IPC phone of given pipe. | |
static int | polling_fibril (void *arg) |
Polling fibril. | |
static int | process_endpoint (usb_endpoint_mapping_t *mapping, size_t mapping_count, usb_standard_interface_descriptor_t *interface, usb_standard_endpoint_descriptor_t *endpoint, usb_device_connection_t *wire) |
Process endpoint descriptor. | |
static int | process_interface (usb_endpoint_mapping_t *mapping, size_t mapping_count, usb_dp_parser_t *parser, usb_dp_parser_data_t *parser_data, uint8_t *interface_descriptor) |
Process whole USB interface. | |
static uint8_t * | skip_nested_descriptors (usb_dp_parser_t *parser, usb_dp_parser_data_t *data, uint8_t *parent) |
Skip all nested descriptors. | |
static void | unregister_control_endpoint_on_default_address (usb_hc_connection_t *connection) |
static int | usb_add_match_id (match_id_list_t *matches, int score, const char *format,...) |
Add formatted match id. | |
int | usb_alternate_interfaces_create (uint8_t *config_descr, size_t config_descr_size, int interface_number, usb_alternate_interfaces_t **alternates_ptr) |
Create alternate interface representation structure. | |
int | usb_control_request_get (usb_pipe_t *pipe, usb_request_type_t request_type, usb_request_recipient_t recipient, uint8_t request, uint16_t value, uint16_t index, void *data, size_t data_size, size_t *actual_data_size) |
Generic wrapper for GET requests using standard control request format. | |
int | usb_control_request_set (usb_pipe_t *pipe, usb_request_type_t request_type, usb_request_recipient_t recipient, uint8_t request, uint16_t value, uint16_t index, void *data, size_t data_size) |
Generic wrapper for SET requests using standard control request format. | |
int | usb_device_auto_poll (usb_device_t *dev, size_t pipe_index, usb_polling_callback_t callback, size_t request_size, usb_polling_terminted_callback_t terminated_callback, void *arg) |
Start automatic device polling over interrupt in pipe. | |
int | usb_device_auto_polling (usb_device_t *dev, size_t pipe_index, usb_device_auto_polling_t *polling, size_t request_size, void *arg) |
Start automatic device polling over interrupt in pipe. | |
int | usb_device_connection_initialize (usb_device_connection_t *connection, devman_handle_t host_controller_handle, usb_address_t device_address) |
Initialize connection to USB device. | |
int | usb_device_connection_initialize_from_device (usb_device_connection_t *connection, ddf_dev_t *dev) |
Initialize connection to USB device. | |
int | usb_device_connection_initialize_on_default_address (usb_device_connection_t *dev_connection, usb_hc_connection_t *hc_connection) |
Initialize connection to USB device on default address. | |
int | usb_device_create (ddf_dev_t *ddf_dev, usb_endpoint_description_t **endpoints, usb_device_t **dev_ptr, const char **errstr_ptr) |
Create new instance of USB device. | |
int | usb_device_create_match_ids (usb_pipe_t *ctrl_pipe, match_id_list_t *matches) |
Create match ids describing attached device. | |
int | usb_device_create_match_ids_from_device_descriptor (const usb_standard_device_descriptor_t *device_descriptor, match_id_list_t *matches) |
Create DDF match ids from USB device descriptor. | |
int | usb_device_create_match_ids_from_interface (const usb_standard_device_descriptor_t *desc_device, const usb_standard_interface_descriptor_t *desc_interface, match_id_list_t *matches) |
Create device match ids based on its interface. | |
int | usb_device_create_pipes (ddf_dev_t *dev, usb_device_connection_t *wire, usb_endpoint_description_t **endpoints, uint8_t *config_descr, size_t config_descr_size, int interface_no, int interface_setting, usb_endpoint_mapping_t **pipes_ptr, size_t *pipes_count_ptr) |
Create pipes for a device. | |
void | usb_device_destroy (usb_device_t *dev) |
Destroy instance of a USB device. | |
int | usb_device_destroy_pipes (ddf_dev_t *dev, usb_endpoint_mapping_t *pipes, size_t pipes_count) |
Destroy pipes previously created by usb_device_create_pipes. | |
int | usb_device_get_assigned_interface (ddf_dev_t *device) |
Tell USB interface assigned to given device. | |
int | usb_device_register_child_in_devman (usb_address_t address, devman_handle_t hc_handle, ddf_dev_t *parent, devman_handle_t *child_handle, ddf_dev_ops_t *dev_ops, void *dev_data, ddf_fun_t **child_fun) |
Probe for device kind and register it in devman. | |
int | usb_device_retrieve_descriptors (usb_pipe_t *ctrl_pipe, usb_device_descriptors_t *descriptors) |
Retrieve basic descriptors from the device. | |
int | usb_device_select_interface (usb_device_t *dev, uint8_t alternate_setting, usb_endpoint_description_t **endpoints) |
Change interface setting of a device. | |
static void | usb_dp_browse_simple_internal (usb_dp_parser_t *parser, usb_dp_parser_data_t *data, uint8_t *root, size_t depth, void(*callback)(uint8_t *, size_t, void *), void *arg) |
Browser of the descriptor tree. | |
uint8_t * | usb_dp_get_nested_descriptor (usb_dp_parser_t *parser, usb_dp_parser_data_t *data, uint8_t *parent) |
Find first nested descriptor of given parent. | |
uint8_t * | usb_dp_get_sibling_descriptor (usb_dp_parser_t *parser, usb_dp_parser_data_t *data, uint8_t *parent, uint8_t *sibling) |
Get sibling descriptor. | |
void | usb_dp_walk_simple (uint8_t *descriptors, size_t descriptors_size, usb_dp_descriptor_nesting_t *descriptor_nesting, void(*callback)(uint8_t *, size_t, void *), void *arg) |
Browse flatten descriptor tree. | |
int | usb_driver_main (usb_driver_t *drv) |
Main routine of USB device driver. | |
int | usb_hc_new_device_wrapper (ddf_dev_t *parent, usb_hc_connection_t *connection, usb_speed_t dev_speed, int(*enable_port)(int port_no, void *arg), int port_no, void *arg, usb_address_t *assigned_address, devman_handle_t *assigned_handle, ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun) |
Wrapper for registering attached device to the hub. | |
int | usb_hc_register_device (usb_hc_connection_t *connection, const usb_hc_attached_device_t *attached_device) |
Inform host controller about new device. | |
usb_address_t | usb_hc_request_address (usb_hc_connection_t *connection, usb_speed_t speed) |
Ask host controller for free address assignment. | |
int | usb_hc_unregister_device (usb_hc_connection_t *connection, usb_address_t address) |
Inform host controller about device removal. | |
size_t | usb_interface_count_alternates (uint8_t *config_descr, size_t config_descr_size, uint8_t interface_no) |
Count number of alternate settings of a interface. | |
int | usb_pipe_clear_halt (usb_pipe_t *ctrl_pipe, usb_pipe_t *target_pipe) |
Clear halt bit of an endpoint pipe (after pipe stall). | |
int | usb_pipe_control_read (usb_pipe_t *pipe, void *setup_buffer, size_t setup_buffer_size, void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) |
Request a control read transfer on an endpoint pipe. | |
static int | usb_pipe_control_read_no_check (usb_pipe_t *pipe, void *setup_buffer, size_t setup_buffer_size, void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) |
Request a control read transfer, no checking of input parameters. | |
int | usb_pipe_control_write (usb_pipe_t *pipe, void *setup_buffer, size_t setup_buffer_size, void *data_buffer, size_t data_buffer_size) |
Request a control write transfer on an endpoint pipe. | |
static int | usb_pipe_control_write_no_check (usb_pipe_t *pipe, void *setup_buffer, size_t setup_buffer_size, void *data_buffer, size_t data_buffer_size) |
Request a control write transfer, no checking of input parameters. | |
void | usb_pipe_end_long_transfer (usb_pipe_t *pipe) |
Terminate a long transfer on a pipe. | |
int | usb_pipe_initialize (usb_pipe_t *pipe, usb_device_connection_t *connection, usb_endpoint_t endpoint_no, usb_transfer_type_t transfer_type, size_t max_packet_size, usb_direction_t direction) |
Initialize USB endpoint pipe. | |
int | usb_pipe_initialize_default_control (usb_pipe_t *pipe, usb_device_connection_t *connection) |
Initialize USB endpoint pipe as the default zero control pipe. | |
int | usb_pipe_initialize_from_configuration (usb_endpoint_mapping_t *mapping, size_t mapping_count, uint8_t *configuration_descriptor, size_t configuration_descriptor_size, usb_device_connection_t *connection) |
Initialize endpoint pipes from configuration descriptor. | |
int | usb_pipe_probe_default_control (usb_pipe_t *pipe) |
Probe default control pipe for max packet size. | |
int | usb_pipe_read (usb_pipe_t *pipe, void *buffer, size_t size, size_t *size_transfered) |
Request a read (in) transfer on an endpoint pipe. | |
static int | usb_pipe_read_no_checks (usb_pipe_t *pipe, void *buffer, size_t size, size_t *size_transfered) |
Request an in transfer, no checking of input parameters. | |
int | usb_pipe_register (usb_pipe_t *pipe, unsigned int interval, usb_hc_connection_t *hc_connection) |
Register endpoint with the host controller. | |
int | usb_pipe_register_with_speed (usb_pipe_t *pipe, usb_speed_t speed, unsigned int interval, usb_hc_connection_t *hc_connection) |
Register endpoint with a speed at the host controller. | |
void | usb_pipe_start_long_transfer (usb_pipe_t *pipe) |
Prepare pipe for a long transfer. | |
int | usb_pipe_unregister (usb_pipe_t *pipe, usb_hc_connection_t *hc_connection) |
Revert endpoint registration with the host controller. | |
int | usb_pipe_write (usb_pipe_t *pipe, void *buffer, size_t size) |
Request a write (out) transfer on an endpoint pipe. | |
static int | usb_pipe_write_no_check (usb_pipe_t *pipe, void *buffer, size_t size) |
Request an out transfer, no checking of input parameters. | |
int | usb_request_clear_endpoint_halt (usb_pipe_t *pipe, uint16_t ep_index) |
Clear halt bit of an endpoint pipe (after pipe stall). | |
int | usb_request_clear_feature (usb_pipe_t *pipe, usb_request_type_t request_type, usb_request_recipient_t recipient, uint16_t feature_selector, uint16_t index) |
Clear or disable specific device feature. | |
int | usb_request_get_bare_configuration_descriptor (usb_pipe_t *pipe, int index, usb_standard_configuration_descriptor_t *descriptor) |
Retrieve configuration descriptor of a USB device. | |
int | usb_request_get_configuration (usb_pipe_t *pipe, uint8_t *configuration_value) |
Get current configuration value of USB device. | |
int | usb_request_get_descriptor (usb_pipe_t *pipe, usb_request_type_t request_type, usb_request_recipient_t recipient, uint8_t descriptor_type, uint8_t descriptor_index, uint16_t language, void *buffer, size_t size, size_t *actual_size) |
Retrieve USB descriptor of a USB device. | |
int | usb_request_get_descriptor_alloc (usb_pipe_t *pipe, usb_request_type_t request_type, usb_request_recipient_t recipient, uint8_t descriptor_type, uint8_t descriptor_index, uint16_t language, void **buffer_ptr, size_t *buffer_size) |
Retrieve USB descriptor, allocate space for it. | |
int | usb_request_get_device_descriptor (usb_pipe_t *pipe, usb_standard_device_descriptor_t *descriptor) |
Retrieve standard device descriptor of a USB device. | |
int | usb_request_get_endpoint_status (usb_pipe_t *ctrl_pipe, usb_pipe_t *pipe, uint16_t *status) |
Get endpoint status. | |
int | usb_request_get_full_configuration_descriptor (usb_pipe_t *pipe, int index, void *descriptor, size_t descriptor_size, size_t *actual_size) |
Retrieve full configuration descriptor of a USB device. | |
int | usb_request_get_full_configuration_descriptor_alloc (usb_pipe_t *pipe, int index, void **descriptor_ptr, size_t *descriptor_size) |
Retrieve full configuration descriptor, allocate space for it. | |
int | usb_request_get_interface (usb_pipe_t *pipe, uint8_t interface_index, uint8_t *alternate_setting) |
Get selected alternate setting for USB interface. | |
int | usb_request_get_status (usb_pipe_t *pipe, usb_request_recipient_t recipient, uint16_t index, uint16_t *status) |
Retrieve status of a USB device. | |
int | usb_request_get_string (usb_pipe_t *pipe, size_t index, l18_win_locales_t lang, char **string_ptr) |
Get string (descriptor) from USB device. | |
int | usb_request_get_supported_languages (usb_pipe_t *pipe, l18_win_locales_t **languages_ptr, size_t *languages_count) |
Get list of supported languages by USB device. | |
int | usb_request_set_address (usb_pipe_t *pipe, usb_address_t new_address) |
Change address of connected device. | |
int | usb_request_set_configuration (usb_pipe_t *pipe, uint8_t configuration_value) |
Set configuration of USB device. | |
int | usb_request_set_descriptor (usb_pipe_t *pipe, usb_request_type_t request_type, usb_request_recipient_t recipient, uint8_t descriptor_type, uint8_t descriptor_index, uint16_t language, void *buffer, size_t size) |
Update existing or add new USB descriptor to a USB device. | |
int | usb_request_set_feature (usb_pipe_t *pipe, usb_request_type_t request_type, usb_request_recipient_t recipient, uint16_t feature_selector, uint16_t index) |
Set or enable specific device feature. | |
int | usb_request_set_interface (usb_pipe_t *pipe, uint8_t interface_index, uint8_t alternate_setting) |
Select alternate setting for USB interface. | |
Variables | |
ddf_dev_ops_t | child_ops |
DDF operations of child devices. | |
static usb_dp_descriptor_nesting_t | descriptor_nesting [] |
Nesting pairs of standard descriptors. | |
static size_t | device_name_index = 0 |
Index to append after device name for uniqueness. | |
static usb_driver_t * | driver = NULL |
static driver_t | generic_driver |
static driver_ops_t | generic_driver_ops |
usb_dp_descriptor_nesting_t | usb_dp_standard_descriptor_nesting [] |
Nesting of standard USB descriptors. | |
usb_dp_descriptor_nesting_t | usb_dp_standard_descriptor_nesting [] |
Nesting of standard USB descriptors. |
#define ADD_MATCHID_OR_RETURN | ( | match_ids, | |||
score, | |||||
format | ) |
Value:
do { \ int __rc = usb_add_match_id((match_ids), (score), \ format, ##__VA_ARGS__); \ if (__rc != EOK) { \ return __rc; \ } \ } while (0)
match_ids | List of match ids. | |
score | Match id score. | |
format | Format of the matching string | |
... | Arguments for the format. |
Definition at line 129 of file recognise.c.
#define CHECK_CONNECTION | ( | conn | ) |
Value:
do { \ assert((conn)); \ if (!usb_hc_connection_is_opened((conn))) { \ return ENOENT; \ } \ } while (false)
conn | Connection to be checked. |
#define ENDPOINT_0_0_REGISTER_ATTEMPT_DELAY_USEC (1000 * (10 + 2)) |
static void clear_self_endpoint_halt | ( | usb_pipe_t * | pipe | ) | [static] |
static size_t count_other_pipes | ( | usb_endpoint_description_t ** | endpoints | ) | [static] |
static int destroy_current_pipes | ( | usb_device_t * | dev | ) | [static] |
static bool endpoint_fits_description | ( | const usb_endpoint_description_t * | wanted, | |
usb_endpoint_description_t * | found | |||
) | [static] |
Tells whether found endpoint corresponds to endpoint described by user.
wanted | Endpoint description as entered by driver author. | |
found | Endpoint description obtained from endpoint descriptor. |
found
descriptor fits the wanted
descriptor. Definition at line 81 of file pipesinit.c.
static usb_endpoint_mapping_t* find_endpoint_mapping | ( | usb_endpoint_mapping_t * | mapping, | |
size_t | mapping_count, | |||
usb_endpoint_description_t * | found_endpoint, | |||
int | interface_number, | |||
int | interface_setting | |||
) | [static] |
Find endpoint mapping for a found endpoint.
mapping | Endpoint mapping list. | |
mapping_count | Number of endpoint mappings in mapping . | |
found_endpoint | Description of found endpoint. | |
interface_number | Number of currently processed interface. |
found_endpoint
. NULL | No corresponding endpoint found. |
Definition at line 120 of file pipesinit.c.
int generic_add_device | ( | ddf_dev_t * | gen_dev | ) | [static] |
static int get_descriptor_type | ( | usb_dp_parser_data_t * | data, | |
uint8_t * | start | |||
) | [static] |
Get descriptor type.
data | Parser data. | |
start | Pointer to start of the descriptor. |
-1 | Invalid input. |
static usb_address_t get_my_address | ( | int | phone, | |
ddf_dev_t * | dev | |||
) | [static] |
static uint8_t* get_next_descriptor | ( | usb_dp_parser_data_t * | data, | |
uint8_t * | current | |||
) | [static] |
static int init_wire_and_ctrl_pipe | ( | usb_device_t * | dev, | |
const char ** | errmsg | |||
) | [static] |
static int initialize_other_pipes | ( | usb_endpoint_description_t ** | endpoints, | |
usb_device_t * | dev, | |||
int | alternate_setting | |||
) | [static] |
static bool is_endpoint_descriptor | ( | uint8_t * | descriptor | ) | [inline, static] |
Tells whether given descriptor is of endpoint type.
descriptor | Descriptor in question. |
Definition at line 70 of file pipesinit.c.
static bool is_nested_descriptor | ( | usb_dp_parser_t * | parser, | |
usb_dp_parser_data_t * | data, | |||
uint8_t * | child, | |||
uint8_t * | parent | |||
) | [static] |
static bool is_nested_descriptor_type | ( | usb_dp_parser_t * | parser, | |
int | child, | |||
int | parent | |||
) | [static] |
static bool is_valid_descriptor_pointer | ( | usb_dp_parser_data_t * | data, | |
uint8_t * | ptr | |||
) | [static] |
void pipe_acquire | ( | usb_pipe_t * | pipe | ) |
Ensure exclusive access to the pipe as a whole.
pipe | Pipe to be exclusively accessed. |
Definition at line 62 of file pipepriv.c.
int pipe_add_ref | ( | usb_pipe_t * | pipe, | |
bool | hide_failure | |||
) |
Add reference of active transfers over the pipe.
pipe | The USB pipe. | |
hide_failure | Whether to hide failure when adding reference (use soft refcount). |
EOK | Currently always. |
Definition at line 84 of file pipepriv.c.
void pipe_drop_ref | ( | usb_pipe_t * | pipe | ) |
Drop active transfer reference on the pipe.
pipe | The USB pipe. |
Definition at line 116 of file pipepriv.c.
void pipe_end_transaction | ( | usb_pipe_t * | pipe | ) |
Terminate exclusive access to the IPC phone of given pipe.
pipe | Pipe to be released from exclusive usage. |
Definition at line 53 of file pipepriv.c.
void pipe_release | ( | usb_pipe_t * | pipe | ) |
Terminate exclusive access to the pipe as a whole.
pipe | Pipe to be released from exclusive usage. |
Definition at line 71 of file pipepriv.c.
void pipe_start_transaction | ( | usb_pipe_t * | pipe | ) |
Ensure exclusive access to the IPC phone of given pipe.
pipe | Pipe to be exclusively accessed. |
Definition at line 44 of file pipepriv.c.
static int polling_fibril | ( | void * | arg | ) | [static] |
static int process_endpoint | ( | usb_endpoint_mapping_t * | mapping, | |
size_t | mapping_count, | |||
usb_standard_interface_descriptor_t * | interface, | |||
usb_standard_endpoint_descriptor_t * | endpoint, | |||
usb_device_connection_t * | wire | |||
) | [static] |
Process endpoint descriptor.
mapping | Endpoint mapping list. | |
mapping_count | Number of endpoint mappings in mapping . | |
interface | Interface descriptor under which belongs the endpoint . | |
endpoint | Endpoint descriptor. | |
wire | Connection backing the endpoint pipes. |
Definition at line 156 of file pipesinit.c.
static int process_interface | ( | usb_endpoint_mapping_t * | mapping, | |
size_t | mapping_count, | |||
usb_dp_parser_t * | parser, | |||
usb_dp_parser_data_t * | parser_data, | |||
uint8_t * | interface_descriptor | |||
) | [static] |
Process whole USB interface.
mapping | Endpoint mapping list. | |
mapping_count | Number of endpoint mappings in mapping . | |
parser | Descriptor parser. | |
parser_data | Descriptor parser data. | |
interface_descriptor | Interface descriptor. |
Definition at line 224 of file pipesinit.c.
static uint8_t* skip_nested_descriptors | ( | usb_dp_parser_t * | parser, | |
usb_dp_parser_data_t * | data, | |||
uint8_t * | parent | |||
) | [static] |
static int usb_add_match_id | ( | match_id_list_t * | matches, | |
int | score, | |||
const char * | format, | |||
... | ||||
) | [static] |
Add formatted match id.
matches | List of match ids where to add to. | |
score | Score of the match. | |
format | Printf-like format |
Definition at line 76 of file recognise.c.
int usb_alternate_interfaces_create | ( | uint8_t * | config_descr, | |
size_t | config_descr_size, | |||
int | interface_number, | |||
usb_alternate_interfaces_t ** | alternates_ptr | |||
) |
Create alternate interface representation structure.
[in] | config_descr | Configuration descriptor. |
[in] | config_descr_size | Size of configuration descriptor. |
[in] | interface_number | Interface number. |
[out] | alternates_ptr | Where to store pointer to allocated structure. |
Definition at line 92 of file altiface.c.
int usb_control_request_get | ( | usb_pipe_t * | pipe, | |
usb_request_type_t | request_type, | |||
usb_request_recipient_t | recipient, | |||
uint8_t | request, | |||
uint16_t | value, | |||
uint16_t | index, | |||
void * | data, | |||
size_t | data_size, | |||
size_t * | actual_data_size | |||
) |
Generic wrapper for GET requests using standard control request format.
pipe | Pipe used for the communication. | |
request_type | Request type (standard/class/vendor). | |
recipient | Request recipient (e.g. device or endpoint). | |
request | Actual request (e.g. GET_DESCRIPTOR). | |
value | Value of wValue field of setup packet (must be in USB endianness). | |
index | Value of wIndex field of setup packet (must be in USB endianness). | |
data | Buffer where to store data accepted during the DATA stage. (they will come in USB endianness). | |
data_size | Size of the data buffer (in native endianness). | |
actual_data_size | Actual size of transfered data (in native endianness). |
EBADMEM | pipe is NULL. | |
EBADMEM | data is NULL and data_size is not zero. | |
ERANGE | Data buffer too large. |
int usb_control_request_set | ( | usb_pipe_t * | pipe, | |
usb_request_type_t | request_type, | |||
usb_request_recipient_t | recipient, | |||
uint8_t | request, | |||
uint16_t | value, | |||
uint16_t | index, | |||
void * | data, | |||
size_t | data_size | |||
) |
Generic wrapper for SET requests using standard control request format.
pipe | Pipe used for the communication. | |
request_type | Request type (standard/class/vendor). | |
recipient | Request recipient (e.g. device or endpoint). | |
request | Actual request (e.g. GET_DESCRIPTOR). | |
value | Value of wValue field of setup packet (must be in USB endianness). | |
index | Value of wIndex field of setup packet (must be in USB endianness). | |
data | Data to be sent during DATA stage (expected to be in USB endianness). | |
data_size | Size of the data buffer (in native endianness). |
EBADMEM | pipe is NULL. | |
EBADMEM | data is NULL and data_size is not zero. | |
ERANGE | Data buffer too large. |
int usb_device_auto_poll | ( | usb_device_t * | dev, | |
size_t | pipe_index, | |||
usb_polling_callback_t | callback, | |||
size_t | request_size, | |||
usb_polling_terminted_callback_t | terminated_callback, | |||
void * | arg | |||
) |
Start automatic device polling over interrupt in pipe.
There is no guarantee when the request to the device will be sent for the first time (it is possible that this first request would be executed prior to return from this function).
dev | Device to be periodically polled. | |
pipe_index | Index of the endpoint pipe used for polling. | |
callback | Callback when data are available. | |
request_size | How many bytes to ask for in each request. | |
terminated_callback | Callback when polling is terminated. | |
arg | Custom argument (passed as is to the callbacks). |
EOK | New fibril polling the device was already started. |
int usb_device_auto_polling | ( | usb_device_t * | dev, | |
size_t | pipe_index, | |||
usb_device_auto_polling_t * | polling, | |||
size_t | request_size, | |||
void * | arg | |||
) |
Start automatic device polling over interrupt in pipe.
The polling settings is copied thus it is okay to destroy the structure after this function returns.
dev | Device to be periodically polled. | |
pipe_index | Index of the endpoint pipe used for polling. | |
polling | Polling settings. | |
request_size | How many bytes to ask for in each request. | |
arg | Custom argument (passed as is to the callbacks). |
EOK | New fibril polling the device was already started. |
int usb_device_connection_initialize | ( | usb_device_connection_t * | connection, | |
devman_handle_t | host_controller_handle, | |||
usb_address_t | device_address | |||
) |
int usb_device_connection_initialize_from_device | ( | usb_device_connection_t * | connection, | |
ddf_dev_t * | dev | |||
) |
int usb_device_connection_initialize_on_default_address | ( | usb_device_connection_t * | dev_connection, | |
usb_hc_connection_t * | hc_connection | |||
) |
int usb_device_create | ( | ddf_dev_t * | ddf_dev, | |
usb_endpoint_description_t ** | endpoints, | |||
usb_device_t ** | dev_ptr, | |||
const char ** | errstr_ptr | |||
) |
Create new instance of USB device.
[in] | ddf_dev | Generic DDF device backing the USB one. |
[in] | endpoints | NULL terminated array of endpoints (NULL for none). |
[out] | dev_ptr | Where to store pointer to the new device. |
[out] | errstr_ptr | Where to store description of context (in case error occurs). |
int usb_device_create_match_ids | ( | usb_pipe_t * | ctrl_pipe, | |
match_id_list_t * | matches | |||
) |
Create match ids describing attached device.
matches
may change even when function exits with error.ctrl_pipe | Control pipe to given device (session must be already started). | |
matches | Initialized list of match ids. |
Definition at line 313 of file recognise.c.
int usb_device_create_match_ids_from_device_descriptor | ( | const usb_standard_device_descriptor_t * | device_descriptor, | |
match_id_list_t * | matches | |||
) |
Create DDF match ids from USB device descriptor.
matches | List of match ids to extend. | |
device_descriptor | Device descriptor returned by given device. |
Definition at line 262 of file recognise.c.
int usb_device_create_match_ids_from_interface | ( | const usb_standard_device_descriptor_t * | desc_device, | |
const usb_standard_interface_descriptor_t * | desc_interface, | |||
match_id_list_t * | matches | |||
) |
Create device match ids based on its interface.
[in] | desc_device | Device descriptor. |
[in] | desc_interface | Interface descriptor. |
[out] | matches | Initialized list of match ids. |
EINVAL | Invalid input parameters (expects non NULL pointers). | |
ENOENT | Device class is not "use interface". |
Definition at line 147 of file recognise.c.
int usb_device_create_pipes | ( | ddf_dev_t * | dev, | |
usb_device_connection_t * | wire, | |||
usb_endpoint_description_t ** | endpoints, | |||
uint8_t * | config_descr, | |||
size_t | config_descr_size, | |||
int | interface_no, | |||
int | interface_setting, | |||
usb_endpoint_mapping_t ** | pipes_ptr, | |||
size_t * | pipes_count_ptr | |||
) |
Create pipes for a device.
This is more or less a wrapper that does following actions:
[in] | dev | Generic DDF device backing the USB one. |
[in] | wire | Initialized backing connection to the host controller. |
[in] | endpoints | Endpoints description, NULL terminated. |
[in] | config_descr | Configuration descriptor of active configuration. |
[in] | config_descr_size | Size of config_descr in bytes. |
[in] | interface_no | Interface to map from. |
[in] | interface_setting | Interface setting (default is usually 0). |
[out] | pipes_ptr | Where to store array of created pipes (not NULL terminated). |
[out] | pipes_count_ptr | Where to store number of pipes (set to if you wish to ignore the count). |
void usb_device_destroy | ( | usb_device_t * | dev | ) |
int usb_device_destroy_pipes | ( | ddf_dev_t * | dev, | |
usb_endpoint_mapping_t * | pipes, | |||
size_t | pipes_count | |||
) |
int usb_device_get_assigned_interface | ( | ddf_dev_t * | device | ) |
int usb_device_register_child_in_devman | ( | usb_address_t | address, | |
devman_handle_t | hc_handle, | |||
ddf_dev_t * | parent, | |||
devman_handle_t * | child_handle, | |||
ddf_dev_ops_t * | dev_ops, | |||
void * | dev_data, | |||
ddf_fun_t ** | child_fun | |||
) |
Probe for device kind and register it in devman.
[in] | address | Address of the (unknown) attached device. |
[in] | hc_handle | Handle of the host controller. |
[in] | parent | Parent device. |
[out] | child_handle | Handle of the child device. |
[in] | dev_ops | Child device ops. |
[in] | dev_data | Arbitrary pointer to be stored in the child as driver_data . |
[out] | child_fun | Storage where pointer to allocated child function will be written. |
Definition at line 349 of file recognise.c.
int usb_device_retrieve_descriptors | ( | usb_pipe_t * | ctrl_pipe, | |
usb_device_descriptors_t * | descriptors | |||
) |
int usb_device_select_interface | ( | usb_device_t * | dev, | |
uint8_t | alternate_setting, | |||
usb_endpoint_description_t ** | endpoints | |||
) |
Change interface setting of a device.
This function selects new alternate setting of an interface by issuing proper USB command to the device and also creates new USB pipes under dev->pipes
.
This is a wrapper function that does several operations that can fail and that cannot be rollbacked easily. That means that a failure during the SET_INTERFACE request would result in having a device with no pipes at all (except the default control one). That is because the old pipes needs to be unregistered at HC first and the new ones could not be created.
dev | USB device. | |
alternate_setting | Alternate setting to choose. | |
endpoints | New endpoint descriptions. |
static void usb_dp_browse_simple_internal | ( | usb_dp_parser_t * | parser, | |
usb_dp_parser_data_t * | data, | |||
uint8_t * | root, | |||
size_t | depth, | |||
void(*)(uint8_t *, size_t, void *) | callback, | |||
void * | arg | |||
) | [static] |
Browser of the descriptor tree.
parser | Descriptor parser. | |
data | Data for descriptor parser. | |
root | Pointer to current root of the tree. | |
depth | Current nesting depth. | |
callback | Callback for each found descriptor. | |
arg | Custom (user) argument. |
uint8_t * usb_dp_get_nested_descriptor | ( | usb_dp_parser_t * | parser, | |
usb_dp_parser_data_t * | data, | |||
uint8_t * | parent | |||
) |
Find first nested descriptor of given parent.
parser | Parser. | |
data | Parser data. | |
parent | Pointer to the beginning of parent descriptor. |
NULL | No child descriptor found. | |
NULL | Invalid input. |
uint8_t * usb_dp_get_sibling_descriptor | ( | usb_dp_parser_t * | parser, | |
usb_dp_parser_data_t * | data, | |||
uint8_t * | parent, | |||
uint8_t * | sibling | |||
) |
void usb_dp_walk_simple | ( | uint8_t * | descriptors, | |
size_t | descriptors_size, | |||
usb_dp_descriptor_nesting_t * | descriptor_nesting, | |||
void(*)(uint8_t *, size_t, void *) | callback, | |||
void * | arg | |||
) |
Browse flatten descriptor tree.
The callback is called with following arguments: pointer to the start of the descriptor (somewhere inside descriptors
), depth of the nesting (starting from 0 for the first descriptor) and the custom argument. Note that the size of the descriptor is not passed because it can be read from the first byte of the descriptor.
descriptors | Descriptor data. | |
descriptors_size | Size of descriptor data (in bytes). | |
descriptor_nesting | Possible descriptor nesting. | |
callback | Callback for each found descriptor. | |
arg | Custom (user) argument. |
int usb_driver_main | ( | usb_driver_t * | drv | ) |
int usb_hc_new_device_wrapper | ( | ddf_dev_t * | parent, | |
usb_hc_connection_t * | connection, | |||
usb_speed_t | dev_speed, | |||
int(*)(int port_no, void *arg) | enable_port, | |||
int | port_no, | |||
void * | arg, | |||
usb_address_t * | assigned_address, | |||
devman_handle_t * | assigned_handle, | |||
ddf_dev_ops_t * | dev_ops, | |||
void * | new_dev_data, | |||
ddf_fun_t ** | new_fun | |||
) |
Wrapper for registering attached device to the hub.
The enable_port
function is expected to enable signaling on given port. The two arguments to it can have arbitrary meaning (the port_no
is only a suggestion) and are not touched at all by this function (they are passed as is to the enable_port
function).
If the enable_port
fails (i.e. does not return EOK), the device addition is canceled. The return value is then returned (it is good idea to use different error codes than those listed as return codes by this function itself).
The connection
representing connection with host controller does not need to be started. This function duplicates the connection to allow simultaneous calls of this function (i.e. from different fibrils).
[in] | parent | Parent device (i.e. the hub device). |
[in] | connection | Connection to host controller. |
[in] | dev_speed | New device speed. |
[in] | enable_port | Function for enabling signaling through the port the device is attached to. |
[in] | port_no | Port number (passed through to enable_port ). |
[in] | arg | Any data argument to enable_port . |
[out] | assigned_address | USB address of the device. |
[out] | assigned_handle | Devman handle of the new device. |
[in] | dev_ops | Child device ops. |
[in] | new_dev_data | Arbitrary pointer to be stored in the child as driver_data . |
[out] | new_fun | Storage where pointer to allocated child function will be written. |
ENOENT | Connection to HC not opened. | |
EADDRNOTAVAIL | Failed retrieving free address from host controller. | |
EBUSY | Failed reserving default USB address. | |
ENOTCONN | Problem connecting to the host controller via USB pipe. | |
ESTALL | Problem communication with device (either SET_ADDRESS request or requests for descriptors when creating match ids). |
int usb_hc_register_device | ( | usb_hc_connection_t * | connection, | |
const usb_hc_attached_device_t * | attached_device | |||
) |
usb_address_t usb_hc_request_address | ( | usb_hc_connection_t * | connection, | |
usb_speed_t | speed | |||
) |
int usb_hc_unregister_device | ( | usb_hc_connection_t * | connection, | |
usb_address_t | address | |||
) |
size_t usb_interface_count_alternates | ( | uint8_t * | config_descr, | |
size_t | config_descr_size, | |||
uint8_t | interface_no | |||
) |
Count number of alternate settings of a interface.
config_descr | Full configuration descriptor. | |
config_descr_size | Size of config_descr in bytes. | |
interface_no | Interface number. |
interface_no
interface. Definition at line 50 of file altiface.c.
int usb_pipe_clear_halt | ( | usb_pipe_t * | ctrl_pipe, | |
usb_pipe_t * | target_pipe | |||
) |
int usb_pipe_control_read | ( | usb_pipe_t * | pipe, | |
void * | setup_buffer, | |||
size_t | setup_buffer_size, | |||
void * | data_buffer, | |||
size_t | data_buffer_size, | |||
size_t * | data_transfered_size | |||
) |
Request a control read transfer on an endpoint pipe.
This function encapsulates all three stages of a control transfer.
[in] | pipe | Pipe used for the transfer. |
[in] | setup_buffer | Buffer with the setup packet. |
[in] | setup_buffer_size | Size of the setup packet (in bytes). |
[out] | data_buffer | Buffer for incoming data. |
[in] | data_buffer_size | Size of the buffer for incoming data (in bytes). |
[out] | data_transfered_size | Number of bytes that were actually transfered during the DATA stage. |
static int usb_pipe_control_read_no_check | ( | usb_pipe_t * | pipe, | |
void * | setup_buffer, | |||
size_t | setup_buffer_size, | |||
void * | data_buffer, | |||
size_t | data_buffer_size, | |||
size_t * | data_transfered_size | |||
) | [static] |
Request a control read transfer, no checking of input parameters.
[in] | pipe | Pipe used for the transfer. |
[in] | setup_buffer | Buffer with the setup packet. |
[in] | setup_buffer_size | Size of the setup packet (in bytes). |
[out] | data_buffer | Buffer for incoming data. |
[in] | data_buffer_size | Size of the buffer for incoming data (in bytes). |
[out] | data_transfered_size | Number of bytes that were actually transfered during the DATA stage. |
int usb_pipe_control_write | ( | usb_pipe_t * | pipe, | |
void * | setup_buffer, | |||
size_t | setup_buffer_size, | |||
void * | data_buffer, | |||
size_t | data_buffer_size | |||
) |
Request a control write transfer on an endpoint pipe.
This function encapsulates all three stages of a control transfer.
[in] | pipe | Pipe used for the transfer. |
[in] | setup_buffer | Buffer with the setup packet. |
[in] | setup_buffer_size | Size of the setup packet (in bytes). |
[in] | data_buffer | Buffer with data to be sent. |
[in] | data_buffer_size | Size of the buffer with outgoing data (in bytes). |
static int usb_pipe_control_write_no_check | ( | usb_pipe_t * | pipe, | |
void * | setup_buffer, | |||
size_t | setup_buffer_size, | |||
void * | data_buffer, | |||
size_t | data_buffer_size | |||
) | [static] |
Request a control write transfer, no checking of input parameters.
[in] | pipe | Pipe used for the transfer. |
[in] | setup_buffer | Buffer with the setup packet. |
[in] | setup_buffer_size | Size of the setup packet (in bytes). |
[in] | data_buffer | Buffer with data to be sent. |
[in] | data_buffer_size | Size of the buffer with outgoing data (in bytes). |
void usb_pipe_end_long_transfer | ( | usb_pipe_t * | pipe | ) |
Terminate a long transfer on a pipe.
pipe | Pipe where to end the long transfer. |
int usb_pipe_initialize | ( | usb_pipe_t * | pipe, | |
usb_device_connection_t * | connection, | |||
usb_endpoint_t | endpoint_no, | |||
usb_transfer_type_t | transfer_type, | |||
size_t | max_packet_size, | |||
usb_direction_t | direction | |||
) |
Initialize USB endpoint pipe.
pipe | Endpoint pipe to be initialized. | |
connection | Connection to the USB device backing this pipe (the wire). | |
endpoint_no | Endpoint number (in USB 1.1 in range 0 to 15). | |
transfer_type | Transfer type (e.g. interrupt or bulk). | |
max_packet_size | Maximum packet size in bytes. | |
direction | Endpoint direction (in/out). |
Definition at line 350 of file pipesinit.c.
int usb_pipe_initialize_default_control | ( | usb_pipe_t * | pipe, | |
usb_device_connection_t * | connection | |||
) |
Initialize USB endpoint pipe as the default zero control pipe.
pipe | Endpoint pipe to be initialized. | |
connection | Connection to the USB device backing this pipe (the wire). |
Definition at line 380 of file pipesinit.c.
int usb_pipe_initialize_from_configuration | ( | usb_endpoint_mapping_t * | mapping, | |
size_t | mapping_count, | |||
uint8_t * | configuration_descriptor, | |||
size_t | configuration_descriptor_size, | |||
usb_device_connection_t * | connection | |||
) |
Initialize endpoint pipes from configuration descriptor.
The mapping array is expected to conform to following rules:
pipe
must point to already allocated structure with uninitialized pipedescription
must point to prepared endpoint descriptiondescriptor
does not need to be initialized (will be overwritten)interface
does not need to be initialized (will be overwritten)present
does not need to be initialized (will be overwritten)After processing the configuration descriptor, the mapping is updated in the following fashion:
present
will be set to true
when the endpoint was found in the configurationdescriptor
will point inside the configuration descriptor to endpoint corresponding to given description (or NULL for not found descriptor)interface
will point inside the configuration descriptor to interface descriptor the endpoint descriptor
belongs to (or NULL for not found descriptor)pipe
will be initialized when found, otherwise left untoucheddescription
will be untouched under all circumstances
mapping | Endpoint mapping list. | |
mapping_count | Number of endpoint mappings in mapping . | |
configuration_descriptor | Full configuration descriptor (is expected to be in USB endianness: i.e. as-is after being retrieved from the device). | |
configuration_descriptor_size | Size of configuration_descriptor in bytes. | |
connection | Connection backing the endpoint pipes. |
Definition at line 284 of file pipesinit.c.
int usb_pipe_probe_default_control | ( | usb_pipe_t * | pipe | ) |
Probe default control pipe for max packet size.
The function tries to get the correct value of max packet size several time before giving up.
The session on the pipe shall not be started.
pipe | Default control pipe. |
Definition at line 405 of file pipesinit.c.
int usb_pipe_read | ( | usb_pipe_t * | pipe, | |
void * | buffer, | |||
size_t | size, | |||
size_t * | size_transfered | |||
) |
Request a read (in) transfer on an endpoint pipe.
[in] | pipe | Pipe used for the transfer. |
[out] | buffer | Buffer where to store the data. |
[in] | size | Size of the buffer (in bytes). |
[out] | size_transfered | Number of bytes that were actually transfered. |
static int usb_pipe_read_no_checks | ( | usb_pipe_t * | pipe, | |
void * | buffer, | |||
size_t | size, | |||
size_t * | size_transfered | |||
) | [static] |
Request an in transfer, no checking of input parameters.
[in] | pipe | Pipe used for the transfer. |
[out] | buffer | Buffer where to store the data. |
[in] | size | Size of the buffer (in bytes). |
[out] | size_transfered | Number of bytes that were actually transfered. |
int usb_pipe_register | ( | usb_pipe_t * | pipe, | |
unsigned int | interval, | |||
usb_hc_connection_t * | hc_connection | |||
) |
Register endpoint with the host controller.
pipe | Pipe to be registered. | |
interval | Polling interval. | |
hc_connection | Connection to the host controller (must be opened). |
Definition at line 457 of file pipesinit.c.
int usb_pipe_register_with_speed | ( | usb_pipe_t * | pipe, | |
usb_speed_t | speed, | |||
unsigned int | interval, | |||
usb_hc_connection_t * | hc_connection | |||
) |
Register endpoint with a speed at the host controller.
You will rarely need to use this function because it is needed only if the registered endpoint is of address 0 and there is no other way to tell speed of the device at address 0.
pipe | Pipe to be registered. | |
speed | Speed of the device (invalid speed means use previously specified one). | |
interval | Polling interval. | |
hc_connection | Connection to the host controller (must be opened). |
Definition at line 478 of file pipesinit.c.
void usb_pipe_start_long_transfer | ( | usb_pipe_t * | pipe | ) |
Prepare pipe for a long transfer.
By a long transfer is mean transfer consisting of several requests to the HC. Calling such function is optional and it has positive effect of improved performance because IPC session is initiated only once.
pipe | Pipe over which the transfer will happen. |
int usb_pipe_unregister | ( | usb_pipe_t * | pipe, | |
usb_hc_connection_t * | hc_connection | |||
) |
Revert endpoint registration with the host controller.
pipe | Pipe to be unregistered. | |
hc_connection | Connection to the host controller (must be opened). |
Definition at line 508 of file pipesinit.c.
int usb_pipe_write | ( | usb_pipe_t * | pipe, | |
void * | buffer, | |||
size_t | size | |||
) |
static int usb_pipe_write_no_check | ( | usb_pipe_t * | pipe, | |
void * | buffer, | |||
size_t | size | |||
) | [static] |
int usb_request_clear_endpoint_halt | ( | usb_pipe_t * | pipe, | |
uint16_t | ep_index | |||
) |
int usb_request_clear_feature | ( | usb_pipe_t * | pipe, | |
usb_request_type_t | request_type, | |||
usb_request_recipient_t | recipient, | |||
uint16_t | feature_selector, | |||
uint16_t | index | |||
) |
Clear or disable specific device feature.
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | request_type | Request type (standard/class/vendor). |
[in] | recipient | Recipient of the CLEAR_FEATURE request. |
[in] | feature_selector | Feature selector (in native endianness). |
[in] | index | Recipient index (in native endianness). |
int usb_request_get_bare_configuration_descriptor | ( | usb_pipe_t * | pipe, | |
int | index, | |||
usb_standard_configuration_descriptor_t * | descriptor | |||
) |
Retrieve configuration descriptor of a USB device.
The function does not retrieve additional data binded with configuration descriptor (such as its interface and endpoint descriptors) - use usb_request_get_full_configuration_descriptor() instead.
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | index | Descriptor index. |
[out] | descriptor | Storage for the device descriptor. |
int usb_request_get_configuration | ( | usb_pipe_t * | pipe, | |
uint8_t * | configuration_value | |||
) |
int usb_request_get_descriptor | ( | usb_pipe_t * | pipe, | |
usb_request_type_t | request_type, | |||
usb_request_recipient_t | recipient, | |||
uint8_t | descriptor_type, | |||
uint8_t | descriptor_index, | |||
uint16_t | language, | |||
void * | buffer, | |||
size_t | size, | |||
size_t * | actual_size | |||
) |
Retrieve USB descriptor of a USB device.
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | request_type | Request type (standard/class/vendor). |
[in] | recipient | Request recipient (device/interface/endpoint). |
[in] | descriptor_type | Descriptor type (device/configuration/HID/...). |
[in] | descriptor_index | Descriptor index. |
[in] | language | Language index. |
[out] | buffer | Buffer where to store the retrieved descriptor. |
[in] | size | Size of the buffer . |
[out] | actual_size | Number of bytes actually transferred. |
int usb_request_get_descriptor_alloc | ( | usb_pipe_t * | pipe, | |
usb_request_type_t | request_type, | |||
usb_request_recipient_t | recipient, | |||
uint8_t | descriptor_type, | |||
uint8_t | descriptor_index, | |||
uint16_t | language, | |||
void ** | buffer_ptr, | |||
size_t * | buffer_size | |||
) |
Retrieve USB descriptor, allocate space for it.
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | request_type | Request type (standard/class/vendor). |
[in] | recipient | Request recipient (device/interface/endpoint). |
[in] | descriptor_type | Descriptor type (device/configuration/HID/...). |
[in] | descriptor_index | Descriptor index. |
[in] | language | Language index. |
[out] | buffer_ptr | Where to store pointer to allocated buffer. |
[out] | buffer_size | Where to store the size of the descriptor. |
int usb_request_get_device_descriptor | ( | usb_pipe_t * | pipe, | |
usb_standard_device_descriptor_t * | descriptor | |||
) |
int usb_request_get_endpoint_status | ( | usb_pipe_t * | ctrl_pipe, | |
usb_pipe_t * | pipe, | |||
uint16_t * | status | |||
) |
int usb_request_get_full_configuration_descriptor | ( | usb_pipe_t * | pipe, | |
int | index, | |||
void * | descriptor, | |||
size_t | descriptor_size, | |||
size_t * | actual_size | |||
) |
Retrieve full configuration descriptor of a USB device.
buffer
might be touched (i.e. its contents changed) even when error occurs.[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | index | Descriptor index. |
[out] | descriptor | Storage for the device descriptor. |
[in] | descriptor_size | Size of descriptor buffer. |
[out] | actual_size | Number of bytes actually transferred. |
int usb_request_get_full_configuration_descriptor_alloc | ( | usb_pipe_t * | pipe, | |
int | index, | |||
void ** | descriptor_ptr, | |||
size_t * | descriptor_size | |||
) |
Retrieve full configuration descriptor, allocate space for it.
The function takes care that full configuration descriptor is returned (i.e. the function will fail when less data then descriptor.totalLength is returned).
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | index | Configuration index. |
[out] | descriptor_ptr | Where to store pointer to allocated buffer. |
[out] | descriptor_size | Where to store the size of the descriptor. |
int usb_request_get_interface | ( | usb_pipe_t * | pipe, | |
uint8_t | interface_index, | |||
uint8_t * | alternate_setting | |||
) |
int usb_request_get_status | ( | usb_pipe_t * | pipe, | |
usb_request_recipient_t | recipient, | |||
uint16_t | index, | |||
uint16_t * | status | |||
) |
Retrieve status of a USB device.
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | index | Recipient index (in native endianness). |
[in] | recipient | Recipient of the GET_STATUS request. |
[out] | status | Recipient status (in native endianness). |
int usb_request_get_string | ( | usb_pipe_t * | pipe, | |
size_t | index, | |||
l18_win_locales_t | lang, | |||
char ** | string_ptr | |||
) |
Get string (descriptor) from USB device.
The string is returned in native encoding of the operating system. For HelenOS, that is UTF-8.
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | index | String index (in native endianness), first index has number 1 (index from descriptors can be used directly). |
[in] | lang | String language (in native endianness). |
[out] | string_ptr | Where to store allocated string in native encoding. |
int usb_request_get_supported_languages | ( | usb_pipe_t * | pipe, | |
l18_win_locales_t ** | languages_ptr, | |||
size_t * | languages_count | |||
) |
Get list of supported languages by USB device.
[in] | pipe | Control endpoint pipe (session must be already started). |
[out] | languages_ptr | Where to store pointer to allocated array of supported languages. |
[out] | languages_count | Number of supported languages. |
int usb_request_set_address | ( | usb_pipe_t * | pipe, | |
usb_address_t | new_address | |||
) |
Change address of connected device.
This function automatically updates the backing connection to point to the new address.
pipe | Control endpoint pipe (session must be already started). | |
new_address | New USB address to be set (in native endianness). |
int usb_request_set_configuration | ( | usb_pipe_t * | pipe, | |
uint8_t | configuration_value | |||
) |
int usb_request_set_descriptor | ( | usb_pipe_t * | pipe, | |
usb_request_type_t | request_type, | |||
usb_request_recipient_t | recipient, | |||
uint8_t | descriptor_type, | |||
uint8_t | descriptor_index, | |||
uint16_t | language, | |||
void * | buffer, | |||
size_t | size | |||
) |
Update existing or add new USB descriptor to a USB device.
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | request_type | Request type (standard/class/vendor). |
[in] | recipient | Request recipient (device/interface/endpoint). |
[in] | descriptor_type | Descriptor type (device/configuration/HID/...). |
[in] | descriptor_index | Descriptor index. |
[in] | language | Language index (in native endianness). |
[in] | buffer | Buffer with the new descriptor (in USB endianness). |
[in] | size | Size of the buffer in bytes (in native endianness). |
int usb_request_set_feature | ( | usb_pipe_t * | pipe, | |
usb_request_type_t | request_type, | |||
usb_request_recipient_t | recipient, | |||
uint16_t | feature_selector, | |||
uint16_t | index | |||
) |
Set or enable specific device feature.
[in] | pipe | Control endpoint pipe (session must be already started). |
[in] | request_type | Request type (standard/class/vendor). |
[in] | recipient | Recipient of the SET_FEATURE request. |
[in] | feature_selector | Feature selector (in native endianness). |
[in] | index | Recipient index (in native endianness). |
int usb_request_set_interface | ( | usb_pipe_t * | pipe, | |
uint8_t | interface_index, | |||
uint8_t | alternate_setting | |||
) |