iPXE
|
Universal Serial Bus (USB) More...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/usb.h>
#include <ipxe/cdc.h>
Go to the source code of this file.
Data Structures | |
struct | usb_control_pseudo_header |
USB control transfer pseudo-header. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static const char * | usb_speed_name (unsigned int speed) |
Get USB speed name (for debugging) More... | |
static const char * | usb_bcd (uint16_t bcd) |
Transcribe USB BCD-coded value (for debugging) More... | |
static struct usb_interface_association_descriptor * | usb_interface_association_descriptor (struct usb_configuration_descriptor *config, unsigned int first) |
Locate USB interface association descriptor. More... | |
struct usb_interface_descriptor * | usb_interface_descriptor (struct usb_configuration_descriptor *config, unsigned int interface, unsigned int alternate) |
Locate USB interface descriptor. More... | |
struct usb_endpoint_descriptor * | usb_endpoint_descriptor (struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface, unsigned int type, unsigned int index) |
Locate USB endpoint descriptor. More... | |
struct usb_endpoint_companion_descriptor * | usb_endpoint_companion_descriptor (struct usb_configuration_descriptor *config, struct usb_endpoint_descriptor *desc) |
Locate USB endpoint companion descriptor. More... | |
const char * | usb_endpoint_name (struct usb_endpoint *ep) |
Get USB endpoint name (for debugging) More... | |
int | usb_endpoint_described (struct usb_endpoint *ep, struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface, unsigned int type, unsigned int index) |
Describe USB endpoint from device configuration. More... | |
int | usb_endpoint_open (struct usb_endpoint *ep) |
Open USB endpoint. More... | |
static int | usb_endpoint_clear_tt (struct usb_endpoint *ep) |
Clear transaction translator (if applicable) More... | |
int | usb_endpoint_clear_halt (struct usb_endpoint *ep) |
Clear endpoint halt (if applicable) More... | |
void | usb_endpoint_close (struct usb_endpoint *ep) |
Close USB endpoint. More... | |
static int | usb_endpoint_reset (struct usb_endpoint *ep) |
Reset USB endpoint. More... | |
static int | usb_endpoint_mtu (struct usb_endpoint *ep, size_t mtu) |
Update endpoint MTU. More... | |
int | usb_message (struct usb_endpoint *ep, unsigned int request, unsigned int value, unsigned int index, struct io_buffer *iobuf) |
Enqueue USB message transfer. More... | |
int | usb_stream (struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate) |
Enqueue USB stream transfer. More... | |
void | usb_complete_err (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete transfer (possibly with error) More... | |
int | usb_prefill (struct usb_endpoint *ep) |
Prefill endpoint recycled buffer list. More... | |
int | usb_refill_limit (struct usb_endpoint *ep, unsigned int max) |
Refill endpoint up to specified limit. More... | |
int | usb_refill (struct usb_endpoint *ep) |
Refill endpoint. More... | |
void | usb_flush (struct usb_endpoint *ep) |
Discard endpoint recycled buffer list. More... | |
static void | usb_control_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete USB control transfer. More... | |
int | usb_control (struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len) |
Issue USB control transaction. More... | |
static unsigned int | usb_get_default_language (struct usb_device *usb) |
Get default language ID. More... | |
int | usb_get_string_descriptor (struct usb_device *usb, unsigned int index, unsigned int language, char *buf, size_t len) |
Get USB string descriptor. More... | |
static int | usb_config_descriptor (struct usb_device *usb, unsigned int index, struct usb_configuration_descriptor **config) |
Get USB configuration descriptor. More... | |
static int | usb_describe (struct usb_device *usb, struct usb_configuration_descriptor *config, unsigned int first, uint8_t *interfaces, struct usb_function_descriptor *desc) |
Describe USB function. More... | |
static int | usb_used (struct usb_device *usb, unsigned int count, uint8_t *interface, uint8_t *used) |
Update list of used interface. More... | |
struct usb_driver * | usb_find_driver (struct usb_function_descriptor *desc, struct usb_device_id **id) |
Find USB device driver. More... | |
static int | usb_score (struct usb_device *usb, struct usb_configuration_descriptor *config) |
Get USB device configuration score. More... | |
static int | usb_probe (struct usb_function *func, struct usb_configuration_descriptor *config) |
Probe USB device driver. More... | |
static void | usb_remove (struct usb_function *func) |
Remove USB device driver. More... | |
static void | usb_probe_all (struct usb_device *usb, struct usb_configuration_descriptor *config) |
Probe all USB device drivers. More... | |
static void | usb_remove_all (struct usb_device *usb) |
Remove all device drivers. More... | |
static void | usb_deconfigure (struct usb_device *usb) |
Clear USB device configuration. More... | |
static int | usb_autoconfigure (struct usb_device *usb) |
Choose our preferred USB device configuration. More... | |
static struct usb_device * | alloc_usb (struct usb_port *port) |
Allocate USB device. More... | |
static int | register_usb (struct usb_device *usb) |
Register USB device. More... | |
static void | unregister_usb (struct usb_device *usb) |
Unregister USB device. More... | |
static void | free_usb (struct usb_device *usb) |
Free USB device. More... | |
struct usb_device * | find_usb (struct usb_bus *bus, unsigned int address) |
Find USB device by address. More... | |
static int | usb_attached (struct usb_port *port) |
Handle newly attached USB device. More... | |
static void | usb_detached (struct usb_port *port) |
Handle newly detached USB device. More... | |
static int | usb_hotplugged (struct usb_port *port) |
Handle newly attached or detached USB device. More... | |
void | usb_port_changed (struct usb_port *port) |
Report port status change. More... | |
static void | usb_hotplug (void) |
Handle newly attached or detached USB device. More... | |
static void | usb_step (struct process *process __unused) |
USB process. More... | |
PERMANENT_PROCESS (usb_process, usb_step) | |
USB process. More... | |
struct usb_hub * | alloc_usb_hub (struct usb_bus *bus, struct usb_device *usb, unsigned int ports, struct usb_hub_driver_operations *driver) |
Allocate USB hub. More... | |
int | register_usb_hub (struct usb_hub *hub) |
Register USB hub. More... | |
void | unregister_usb_hub (struct usb_hub *hub) |
Unregister USB hub. More... | |
void | free_usb_hub (struct usb_hub *hub) |
Free USB hub. More... | |
struct usb_bus * | alloc_usb_bus (struct device *dev, unsigned int ports, size_t mtu, struct usb_host_operations *op) |
Allocate USB bus. More... | |
int | register_usb_bus (struct usb_bus *bus) |
Register USB bus. More... | |
void | unregister_usb_bus (struct usb_bus *bus) |
Unregister USB bus. More... | |
void | free_usb_bus (struct usb_bus *bus) |
Free USB bus. More... | |
struct usb_bus * | find_usb_bus (unsigned int address) |
Find USB bus by address. More... | |
struct usb_bus * | find_usb_bus_by_location (unsigned int bus_type, unsigned int location) |
Find USB bus by device location. More... | |
int | usb_alloc_address (struct usb_bus *bus) |
Allocate device address. More... | |
void | usb_free_address (struct usb_bus *bus, unsigned int address) |
Free device address. More... | |
int | usb_find_next (struct usb_device **usb, uint16_t *busdev) |
Find next USB device. More... | |
unsigned int | usb_route_string (struct usb_device *usb) |
Get USB route string. More... | |
struct usb_port * | usb_root_hub_port (struct usb_device *usb) |
Get USB root hub port. More... | |
struct usb_port * | usb_transaction_translator (struct usb_device *usb) |
Get USB transaction translator. More... | |
REQUIRING_SYMBOL (register_usb_bus) | |
REQUIRE_OBJECT (config_usb) | |
REQUIRE_OBJECT (usbhub) | |
Variables | |
struct list_head | usb_buses = LIST_HEAD_INIT ( usb_buses ) |
List of USB buses. More... | |
static struct list_head | usb_changed = LIST_HEAD_INIT ( usb_changed ) |
List of changed ports. More... | |
static struct list_head | usb_halted = LIST_HEAD_INIT ( usb_halted ) |
List of halted endpoints. More... | |
static struct usb_endpoint_driver_operations | usb_control_operations |
USB control endpoint driver operations. More... | |
Universal Serial Bus (USB)
Definition in file usb.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Get USB speed name (for debugging)
speed | Speed |
name | Speed name |
Definition at line 65 of file usb.c.
References snprintf(), USB_SPEED_EXPONENT, USB_SPEED_FULL, USB_SPEED_HIGH, USB_SPEED_LOW, USB_SPEED_MANTISSA, USB_SPEED_NONE, and USB_SPEED_SUPER.
Referenced by register_usb().
|
inlinestatic |
Transcribe USB BCD-coded value (for debugging)
bcd | BCD-coded value |
string | Transcribed value |
Definition at line 95 of file usb.c.
References high, low, and snprintf().
Referenced by register_usb().
|
static |
Locate USB interface association descriptor.
config | Configuraton descriptor |
first | First interface number |
desc | Interface association descriptor, or NULL if not found |
Definition at line 119 of file usb.c.
References desc, first, for_each_config_descriptor, and NULL.
Referenced by usb_describe().
struct usb_interface_descriptor* usb_interface_descriptor | ( | struct usb_configuration_descriptor * | config, |
unsigned int | interface, | ||
unsigned int | alternate | ||
) |
Locate USB interface descriptor.
config | Configuraton descriptor |
interface | Interface number |
alternate | Alternate setting |
desc | Interface descriptor, or NULL if not found |
Definition at line 143 of file usb.c.
References alternate, desc, for_each_config_descriptor, and NULL.
Referenced by ecm_probe(), efi_usb_get_interface_descriptor(), ncm_probe(), usbblk_probe(), usbhid_describe(), usbnet_comms_describe(), and usbnet_data_describe().
struct usb_endpoint_descriptor* usb_endpoint_descriptor | ( | struct usb_configuration_descriptor * | config, |
struct usb_interface_descriptor * | interface, | ||
unsigned int | type, | ||
unsigned int | index | ||
) |
Locate USB endpoint descriptor.
config | Configuration descriptor |
interface | Interface descriptor |
type | Endpoint (internal) type |
index | Endpoint index |
desc | Descriptor, or NULL if not found |
Definition at line 167 of file usb.c.
References usb_endpoint_descriptor::attributes, desc, direction, for_each_interface_descriptor, index, NULL, type, USB_DIR_IN, and USB_ENDPOINT_ATTR_TYPE_MASK.
Referenced by usb_endpoint_described().
struct usb_endpoint_companion_descriptor* usb_endpoint_companion_descriptor | ( | struct usb_configuration_descriptor * | config, |
struct usb_endpoint_descriptor * | desc | ||
) |
Locate USB endpoint companion descriptor.
config | Configuration descriptor |
desc | Endpoint descriptor |
descx | Companion descriptor, or NULL if not found |
Definition at line 194 of file usb.c.
References container_of, desc, header, usb_endpoint_companion_descriptor::header, NULL, usb_descriptor_header::type, USB_ENDPOINT_COMPANION_DESCRIPTOR, usb_is_within_config(), and usb_next_descriptor().
Referenced by usb_endpoint_described().
const char* usb_endpoint_name | ( | struct usb_endpoint * | ep | ) |
Get USB endpoint name (for debugging)
ep | USB endpoint |
name | Endpoint name |
Definition at line 220 of file usb.c.
References address, usb_endpoint::address, snprintf(), USB_ENDPOINT_IN, and USB_ENDPOINT_MAX.
Referenced by efi_usb_async_start(), efi_usb_close(), efi_usb_open(), efi_usb_sync_transfer(), ehci_endpoint_close(), ehci_endpoint_poll(), ehci_root_clear_tt(), uhci_endpoint_poll(), uhci_root_clear_tt(), usb_complete_err(), usb_endpoint_clear_halt(), usb_endpoint_clear_tt(), usb_endpoint_mtu(), usb_endpoint_open(), usb_endpoint_reset(), usb_message(), usb_stream(), usbio_bulk_in_poll(), usbio_bulk_out_poll(), usbio_control_poll(), usbio_endpoint_open(), usbio_interface(), usbio_interrupt_callback(), usbio_interrupt_open(), usbkbd_probe(), and xhci_root_clear_tt().
int usb_endpoint_described | ( | struct usb_endpoint * | ep, |
struct usb_configuration_descriptor * | config, | ||
struct usb_interface_descriptor * | interface, | ||
unsigned int | type, | ||
unsigned int | index | ||
) |
Describe USB endpoint from device configuration.
ep | USB endpoint |
config | Configuration descriptor |
interface | Interface descriptor |
type | Endpoint (internal) type |
index | Endpoint index |
rc | Return status code |
Definition at line 241 of file usb.c.
References usb_endpoint_companion_descriptor::burst, desc, ENOENT, usb_device::ep, index, le16_to_cpu, mtu, usb_device::speed, type, usb_endpoint::usb, USB_ENDPOINT_ATTR_INTERRUPT, USB_ENDPOINT_ATTR_TYPE_MASK, USB_ENDPOINT_BURST, usb_endpoint_companion_descriptor(), usb_endpoint_describe(), usb_endpoint_descriptor(), USB_ENDPOINT_MTU, and USB_SPEED_HIGH.
Referenced by hub_probe(), usbblk_probe(), usbhid_describe(), usbnet_comms_describe(), and usbnet_data_describe().
int usb_endpoint_open | ( | struct usb_endpoint * | ep | ) |
Open USB endpoint.
ep | USB endpoint |
rc | Return status code |
Definition at line 293 of file usb.c.
References usb_endpoint::address, usb_endpoint::burst, usb_hub::bus, usb_endpoint_host_operations::close, DBGC, DBGC2, EALREADY, usb_host_operations::endpoint, usb_device::ep, usb_endpoint::halted, usb_endpoint::host, usb_port::hub, INIT_LIST_HEAD, usb_endpoint::interval, usb_endpoint::max, usb_endpoint::mtu, usb_device::name, NULL, usb_bus::op, usb_endpoint::open, usb_endpoint_host_operations::open, usb_device::port, rc, strerror(), usb_endpoint::usb, USB_ENDPOINT_IDX, usb_endpoint_name(), and usb_flush().
Referenced by efi_usb_open(), hub_open(), register_usb(), usbblk_open(), usbhid_open(), and usbnet_open().
|
static |
Clear transaction translator (if applicable)
ep | USB endpoint |
rc | Return status code |
Definition at line 340 of file usb.c.
References usb_endpoint::attributes, usb_hub_driver_operations::clear_tt, DBGC, usb_hub::driver, usb_device::ep, usb_port::hub, usb_device::name, rc, strerror(), usb_endpoint::usb, usb_port::usb, USB_ENDPOINT_ATTR_PERIODIC, usb_endpoint_name(), and usb_transaction_translator().
Referenced by usb_endpoint_clear_halt(), and usb_endpoint_close().
int usb_endpoint_clear_halt | ( | struct usb_endpoint * | ep | ) |
Clear endpoint halt (if applicable)
ep | USB endpoint |
rc | Return status code |
Definition at line 371 of file usb.c.
References usb_endpoint::address, usb_endpoint::attributes, DBGC, usb_device::ep, usb_device::name, rc, strerror(), type, usb_endpoint::usb, usb_clear_feature(), USB_ENDPOINT_ATTR_CONTROL, USB_ENDPOINT_ATTR_TYPE_MASK, usb_endpoint_clear_tt(), USB_ENDPOINT_HALT, usb_endpoint_name(), and USB_RECIP_ENDPOINT.
Referenced by usb_endpoint_reset(), and usbblk_open().
void usb_endpoint_close | ( | struct usb_endpoint * | ep | ) |
Close USB endpoint.
ep | USB endpoint |
Definition at line 399 of file usb.c.
References usb_endpoint::address, assert(), usb_endpoint_host_operations::close, usb_device::ep, usb_endpoint::fill, usb_endpoint::halted, usb_endpoint::host, list_del, usb_endpoint::max, NULL, usb_endpoint::open, usb_endpoint::usb, usb_endpoint_clear_tt(), USB_ENDPOINT_IDX, and usb_flush().
Referenced by efi_usb_close(), efi_usb_open(), hub_close(), hub_open(), register_usb(), unregister_usb(), usbblk_close(), usbblk_open(), usbhid_close(), usbhid_open(), usbnet_close(), and usbnet_open().
|
static |
Reset USB endpoint.
ep | USB endpoint |
rc | Return status code |
Definition at line 429 of file usb.c.
References assert(), DBGC, usb_device::ep, usb_endpoint::halted, usb_endpoint::host, INIT_LIST_HEAD, list_del, list_empty, usb_device::name, rc, usb_endpoint_host_operations::reset, strerror(), usb_endpoint::usb, usb_endpoint_clear_halt(), and usb_endpoint_name().
Referenced by usb_control(), usb_message(), usb_step(), and usb_stream().
|
static |
Update endpoint MTU.
ep | USB endpoint |
mtu | New MTU |
rc | Return status code |
Definition at line 463 of file usb.c.
References DBGC, usb_device::ep, usb_endpoint::host, mtu, usb_endpoint::mtu, usb_endpoint_host_operations::mtu, usb_device::name, rc, strerror(), usb_endpoint::usb, and usb_endpoint_name().
Referenced by register_usb().
int usb_message | ( | struct usb_endpoint * | ep, |
unsigned int | request, | ||
unsigned int | value, | ||
unsigned int | index, | ||
struct io_buffer * | iobuf | ||
) |
Enqueue USB message transfer.
ep | USB endpoint |
request | Request |
value | Value parameter |
index | Index parameter |
iobuf | I/O buffer |
rc | Return status code |
The I/O buffer must have sufficient headroom to contain a setup packet.
Definition at line 491 of file usb.c.
References assert(), cpu_to_le16, io_buffer::data, DBGC, ENODEV, usb_device::ep, usb_endpoint::fill, usb_endpoint::halted, usb_endpoint::host, index, usb_setup_packet::index, iob_headroom(), iob_len(), iob_push, len, usb_setup_packet::len, list_empty, memset(), usb_endpoint_host_operations::message, usb_device::name, port, usb_device::port, rc, request, usb_setup_packet::request, strerror(), usb_endpoint::usb, usb_port::usb, USB_DIR_IN, usb_endpoint_name(), usb_endpoint_reset(), value, and usb_setup_packet::value.
Referenced by usb_control().
int usb_stream | ( | struct usb_endpoint * | ep, |
struct io_buffer * | iobuf, | ||
int | terminate | ||
) |
Enqueue USB stream transfer.
ep | USB endpoint |
iobuf | I/O buffer |
terminate | Terminate using a short packet |
rc | Return status code |
Definition at line 545 of file usb.c.
References DBGC, ENODEV, usb_device::ep, usb_endpoint::fill, usb_endpoint::halted, usb_endpoint::host, iob_len(), list_empty, usb_endpoint::mtu, usb_device::name, port, usb_device::port, rc, usb_endpoint_host_operations::stream, strerror(), usb_endpoint::usb, usb_port::usb, usb_endpoint_name(), and usb_endpoint_reset().
Referenced by acm_out_transmit(), axge_out_transmit(), dm96xx_out_transmit(), ecm_out_transmit(), efi_usb_sync_transfer(), imux_tx(), iphone_out_transmit(), ncm_out_transmit(), smsc75xx_out_transmit(), smsc95xx_out_transmit(), usb_refill_limit(), usbblk_out_command(), and usbblk_out_data().
void usb_complete_err | ( | struct usb_endpoint * | ep, |
struct io_buffer * | iobuf, | ||
int | rc | ||
) |
Complete transfer (possibly with error)
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 586 of file usb.c.
References assert(), usb_endpoint_driver_operations::complete, DBGC, usb_endpoint::driver, usb_device::ep, usb_endpoint::fill, usb_endpoint::halted, list_add_tail, list_del, usb_device::name, usb_endpoint::open, rc, strerror(), usb_endpoint::usb, usb_endpoint_name(), and usb_halted.
Referenced by ehci_endpoint_close(), ehci_endpoint_poll(), uhci_endpoint_close(), uhci_endpoint_poll(), usb_complete(), usbio_bulk_in_poll(), usbio_bulk_out_poll(), usbio_control_poll(), usbio_endpoint_close(), xhci_endpoint_close(), and xhci_transfer().
int usb_prefill | ( | struct usb_endpoint * | ep | ) |
Prefill endpoint recycled buffer list.
ep | USB endpoint |
rc | Return status code |
Definition at line 619 of file usb.c.
References alloc_iob(), assert(), ENOMEM, fill, usb_endpoint::fill, iob_reserve, len, usb_endpoint::len, io_buffer::list, list_add_tail, list_empty, usb_endpoint::max, usb_endpoint::mtu, rc, usb_endpoint::recycled, usb_endpoint::reserve, and usb_flush().
Referenced by efi_usb_async_start(), and ncm_in_prefill().
int usb_refill_limit | ( | struct usb_endpoint * | ep, |
unsigned int | max | ||
) |
Refill endpoint up to specified limit.
ep | USB endpoint |
max | Fill limit |
rc | Return status code |
Definition at line 660 of file usb.c.
References alloc_iob(), assert(), ENOMEM, usb_endpoint::fill, iob_len(), iob_put, iob_reserve, len, usb_endpoint::len, io_buffer::list, list_add, list_del, list_empty, list_first_entry, max, usb_endpoint::max, usb_endpoint::mtu, NULL, usb_endpoint::open, rc, usb_endpoint::recycled, usb_endpoint::reserve, and usb_stream().
Referenced by usb_refill(), and usbblk_in_refill().
int usb_refill | ( | struct usb_endpoint * | ep | ) |
Refill endpoint.
ep | USB endpoint |
rc | Return status code |
Definition at line 710 of file usb.c.
References usb_endpoint::max, and usb_refill_limit().
Referenced by efi_usb_timer(), hub_refill(), usbhid_open(), usbhid_refill(), usbkbd_iskey(), usbnet_open(), and usbnet_refill().
void usb_flush | ( | struct usb_endpoint * | ep | ) |
Discard endpoint recycled buffer list.
ep | USB endpoint |
Definition at line 719 of file usb.c.
References assert(), free_iob(), io_buffer::list, list_del, list_for_each_entry_safe, usb_endpoint::max, usb_endpoint::open, usb_endpoint::recycled, and tmp.
Referenced by ncm_open(), usb_endpoint_close(), usb_endpoint_open(), and usb_prefill().
|
static |
Complete USB control transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 754 of file usb.c.
References usb_device::complete, usb_device::ep, iob_push, io_buffer::list, list_add_tail, rc, usb_control_pseudo_header::rc, and usb_endpoint::usb.
int usb_control | ( | struct usb_device * | usb, |
unsigned int | request, | ||
unsigned int | value, | ||
unsigned int | index, | ||
void * | data, | ||
size_t | len | ||
) |
Issue USB control transaction.
usb | USB device |
request | Request |
value | Value parameter |
index | Index parameter |
data | Data buffer (if any) |
len | Length of data |
rc | Return status code |
Definition at line 783 of file usb.c.
References alloc_iob(), assert(), bus, usb_hub::bus, usb_device::complete, usb_device::control, data, io_buffer::data, DBGC, DBGC_HDA, ENOMEM, ETIMEDOUT, free_iob(), usb_port::hub, index, iob_len(), iob_pull, iob_put, iob_reserve, len, io_buffer::list, list_del, list_first_entry, mdelay(), memcpy(), memset(), usb_device::name, usb_device::port, rc, usb_control_pseudo_header::rc, request, strerror(), usb_endpoint::usb, USB_CONTROL_MAX_WAIT_MS, USB_DIR_IN, usb_endpoint_reset(), usb_message(), usb_poll(), and value.
Referenced by axge_read_register(), axge_write_register(), cdc_get_encapsulated_response(), cdc_send_encapsulated_command(), dm96xx_read_registers(), dm96xx_write_register(), dm96xx_write_registers(), ecm_open(), efi_usb_control_transfer(), iphone_check_link(), iphone_probe(), ncm_open(), ncm_probe(), smscusb_raw_readl(), smscusb_raw_writel(), usb_clear_feature(), usb_get_descriptor(), usb_get_status(), usb_hub_clear_tt_buffer(), usb_hub_set_hub_depth(), usb_set_address(), usb_set_configuration(), usb_set_feature(), usb_set_interface(), usbblk_open(), usbhid_set_idle(), usbhid_set_protocol(), and usbhid_set_report().
|
static |
Get default language ID.
usb | USB device |
language | Language ID |
Definition at line 883 of file usb.c.
References __attribute__, DBGC, DBGC2, desc, header, le16_to_cpu, usb_device::name, rc, strerror(), usb_get_descriptor(), USB_LANG_ENGLISH, and USB_STRING_DESCRIPTOR.
Referenced by usb_get_string_descriptor().
int usb_get_string_descriptor | ( | struct usb_device * | usb, |
unsigned int | index, | ||
unsigned int | language, | ||
char * | buf, | ||
size_t | len | ||
) |
Get USB string descriptor.
usb | USB device |
index | String index |
language | Language ID, or 0 to use default |
buf | Data buffer |
len | Length of buffer |
len | String length (excluding NUL), or negative error |
Definition at line 915 of file usb.c.
References __attribute__, desc, EINVAL, ENOMEM, free, header, index, usb_device::language, le16_to_cpu, len, usb_descriptor_header::len, malloc(), memset(), rc, usb_get_default_language(), usb_get_descriptor(), and USB_STRING_DESCRIPTOR.
Referenced by ecm_fetch_mac(), and usb_settings_fetch().
|
static |
Get USB configuration descriptor.
usb | USB device |
index | Configuration index |
config | Configuration descriptor |
rc | Return status code |
The configuration descriptor is dynamically allocated and must eventually be freed by the caller.
Definition at line 989 of file usb.c.
References usb_configuration_descriptor::config, DBGC, EINVAL, ENOMEM, free, index, le16_to_cpu, len, usb_configuration_descriptor::len, malloc(), usb_device::name, rc, strerror(), and usb_get_config_descriptor().
Referenced by usb_autoconfigure().
|
static |
Describe USB function.
usb | USB device |
config | Configuration descriptor |
first | First interface number |
interfaces | Interface list to fill in |
desc | Function descriptor to fill in |
rc | Return status code |
Definition at line 1052 of file usb.c.
References assert(), usb_interface_association_descriptor::class, usb_interface_association_descriptor::count, DBGC, desc, usb_device::device, ENOENT, ERANGE, first, usb_interface_association_descriptor::first, cdc_union_descriptor::header, cdc_union_descriptor::interface, usb_interface_descriptor::interface, interfaces, usb_configuration_descriptor::interfaces, le16_to_cpu, usb_descriptor_header::len, memcpy(), memset(), usb_device::name, offsetof, usb_device_descriptor::product, typeof(), USB_CLASS_CDC, usb_interface_association_descriptor(), and usb_device_descriptor::vendor.
Referenced by usb_probe_all(), and usb_score().
|
static |
Update list of used interface.
usb | USB device |
count | Number of interfaces |
interface | List of interfaces |
used | List of already-used interfaces |
rc | Return status code |
Definition at line 1144 of file usb.c.
References count, DBGC, EINVAL, and usb_device::name.
Referenced by usb_probe_all(), and usb_score().
struct usb_driver* usb_find_driver | ( | struct usb_function_descriptor * | desc, |
struct usb_device_id ** | id | ||
) |
Find USB device driver.
desc | Function descriptor |
id | USB device ID, or NULL |
driver | USB device driver, or NULL |
Definition at line 1166 of file usb.c.
References usb_class_id::class, usb_driver::class, desc, for_each_table_entry, usb_driver::id_count, usb_driver::ids, usb_class_id::mask, NULL, usb_class_descriptor::scalar, USB_ANY_ID, and USB_DRIVERS.
Referenced by usb_probe(), usb_score(), and usbio_supported().
|
static |
Get USB device configuration score.
usb | USB device |
config | Configuration descriptor |
score | Device configuration score, or negative error |
Definition at line 1202 of file usb.c.
References desc, first, id, usb_configuration_descriptor::interfaces, memset(), rc, usb_driver::score, usb_describe(), usb_find_driver(), and usb_used().
Referenced by usb_autoconfigure().
|
static |
Probe USB device driver.
func | USB function |
config | Configuration descriptor |
rc | Return status code |
Definition at line 1247 of file usb.c.
References usb_class::class, usb_class_descriptor::class, usb_function_descriptor::class, DBGC, usb_function::desc, usb_function::dev, usb_function::driver, device::driver_name, ENOENT, id, usb_function::id, usb_function::name, usb_driver::probe, usb_function_descriptor::product, usb_class::protocol, rc, strerror(), usb_class::subclass, usb_function::usb, usb_find_driver(), and usb_function_descriptor::vendor.
Referenced by usb_probe_all().
|
static |
Remove USB device driver.
func | USB function |
Definition at line 1285 of file usb.c.
References usb_function::driver, and usb_driver::remove.
Referenced by usb_probe_all(), and usb_remove_all().
|
static |
Probe all USB device drivers.
usb | USB device |
config | Configuration descriptor |
Definition at line 1298 of file usb.c.
References usb_device::address, assert(), bus, usb_hub::bus, device_description::bus_type, BUS_TYPE_USB, device::children, usb_class::class, usb_class_descriptor::class, usb_function_descriptor::class, usb_configuration_descriptor::config, usb_function_descriptor::count, DBGC, device::desc, usb_function::desc, usb_function::dev, device_description::device, usb_device::device, device::driver_name, first, free, usb_device::functions, usb_port::hub, INIT_LIST_HEAD, usb_function::interface, usb_configuration_descriptor::interfaces, le16_to_cpu, usb_function::list, list_add_tail, list_del, device_description::location, memset(), device::name, usb_function::name, usb_device::name, device::parent, usb_device::port, usb_device_descriptor::product, usb_function_descriptor::product, usb_class::protocol, rc, device::siblings, snprintf(), usb_class::subclass, usb_function::usb, USB_BUSDEV, usb_describe(), usb_probe(), usb_remove(), usb_used(), device_description::vendor, usb_device_descriptor::vendor, usb_function_descriptor::vendor, and zalloc().
Referenced by usb_autoconfigure().
|
static |
Remove all device drivers.
usb | USB device |
Definition at line 1381 of file usb.c.
References assert(), device::children, usb_function::dev, free, usb_device::functions, usb_function::list, list_del, list_empty, list_for_each_entry_safe, device::siblings, tmp, usb_function::usb, and usb_remove().
Referenced by usb_autoconfigure(), and usb_deconfigure().
|
static |
Clear USB device configuration.
usb | USB device |
Definition at line 1408 of file usb.c.
References assert(), usb_device::ep, NULL, usb_function::usb, USB_ENDPOINT_IDX, USB_EP0_ADDRESS, usb_remove_all(), and usb_set_configuration().
Referenced by register_usb(), and unregister_usb().
|
static |
Choose our preferred USB device configuration.
usb | USB device |
rc | Return status code |
Definition at line 1430 of file usb.c.
References usb_configuration_descriptor::config, usb_device_descriptor::configurations, DBGC, DBGC2, usb_device::device, free, index, usb_device::name, NULL, rc, strerror(), usb_config_descriptor(), usb_probe_all(), usb_remove_all(), usb_score(), and usb_set_configuration().
Referenced by register_usb().
|
static |
Allocate USB device.
port | USB port |
usb | USB device, or NULL on allocation failure |
Definition at line 1511 of file usb.c.
References bus, usb_hub::bus, usb_device::complete, usb_device::control, usb_device::functions, usb_device::host, usb_bus::hub, INIT_LIST_HEAD, usb_device::name, usb_hub::name, NULL, port, usb_device::port, snprintf(), usb_hub::usb, usb_control_operations, usb_endpoint_init(), and zalloc().
Referenced by usb_attached().
|
static |
Register USB device.
usb | USB device |
rc | Return status code |
Definition at line 1537 of file usb.c.
References usb_device::address, usb_device_host_operations::address, assert(), bus, usb_hub::bus, usb_class::class, usb_device_descriptor::class, usb_device_host_operations::close, usb_device::control, DBGC, DBGC2, usb_device::device, usb_hub::driver, EALREADY, usb_hub_driver_operations::enable, usb_device::host, usb_bus::hub, le16_to_cpu, usb_device::list, list_add_tail, list_del, mdelay(), mtu, usb_device_descriptor::mtu, usb_endpoint::mtu, usb_device::name, usb_hub::name, NULL, usb_device_host_operations::open, port, usb_device::port, usb_device_descriptor::product, protocol, usb_class::protocol, usb_device_descriptor::protocol, rc, usb_device::speed, usb_hub_driver_operations::speed, strerror(), usb_class::subclass, usb_port::usb, usb_autoconfigure(), usb_bcd(), usb_deconfigure(), usb_endpoint_close(), usb_endpoint_describe(), usb_endpoint_mtu(), usb_endpoint_open(), USB_EP0_ADDRESS, USB_EP0_ATTRIBUTES, USB_EP0_BURST, USB_EP0_DEFAULT_MTU, USB_EP0_INTERVAL, usb_get_device_descriptor(), usb_get_mtu(), USB_PROTO_3_0, USB_RESET_RECOVER_DELAY_MS, USB_SET_ADDRESS_RECOVER_DELAY_MS, usb_speed_name(), and usb_device_descriptor::vendor.
Referenced by usb_attached().
|
static |
Unregister USB device.
usb | USB device |
Definition at line 1670 of file usb.c.
References usb_device::address, assert(), usb_class::class, usb_device_descriptor::class, usb_device_host_operations::close, usb_device::complete, usb_device::control, DBGC, usb_device::device, usb_hub_driver_operations::disable, usb_hub::driver, free_iob(), usb_device::host, le16_to_cpu, io_buffer::list, usb_device::list, list_del, list_for_each_entry_safe, usb_device::name, NULL, port, usb_device::port, usb_device_descriptor::product, usb_class::protocol, usb_class::subclass, tmp, usb_port::usb, usb_deconfigure(), usb_endpoint_close(), and usb_device_descriptor::vendor.
Referenced by usb_attached(), and usb_detached().
|
static |
Free USB device.
usb | USB device |
Definition at line 1714 of file usb.c.
References assert(), usb_device::complete, usb_device::ep, free, usb_device::functions, list_empty, and NULL.
Referenced by usb_attached(), and usb_detached().
struct usb_device* find_usb | ( | struct usb_bus * | bus, |
unsigned int | address | ||
) |
Find USB device by address.
bus | USB bus |
address | Device address |
usb | USB device, or NULL if not found |
Definition at line 1734 of file usb.c.
References address, usb_device::address, bus, usb_device::list, list_for_each_entry, and NULL.
Referenced by usb_find_next(), and usb_settings_fetch().
|
static |
Handle newly attached USB device.
port | USB port |
rc | Return status code |
Definition at line 1759 of file usb.c.
References alloc_usb(), assert(), ENOMEM, free_usb(), NULL, port, rc, register_usb(), and unregister_usb().
Referenced by usb_hotplugged().
|
static |
Handle newly detached USB device.
port | USB port |
Definition at line 1794 of file usb.c.
References free_usb(), port, and unregister_usb().
Referenced by unregister_usb_hub(), and usb_hotplugged().
|
static |
Handle newly attached or detached USB device.
port | USB port |
rc | Return status code |
Definition at line 1817 of file usb.c.
References DBGC, usb_hub::driver, usb_hub::name, port, rc, usb_hub_driver_operations::speed, strerror(), usb_attached(), usb_detached(), and USB_SPEED_NONE.
Referenced by usb_hotplug().
void usb_port_changed | ( | struct usb_port * | port | ) |
Report port status change.
port | USB port |
Definition at line 1857 of file usb.c.
References list_add_tail, list_del, port, and usb_changed.
Referenced by ehci_root_poll(), hub_complete(), register_usb_hub(), uhci_root_poll(), and xhci_port_status().
|
static |
Handle newly attached or detached USB device.
Definition at line 1868 of file usb.c.
References assert(), usb_port::changed, INIT_LIST_HEAD, list_del, list_empty, list_first_entry, NULL, port, usb_changed, and usb_hotplugged().
Referenced by register_usb_bus(), and usb_step().
USB process.
process | USB process |
Definition at line 1895 of file usb.c.
References bus, for_each_usb_bus, usb_endpoint::halted, list_first_entry, NULL, usb_endpoint_reset(), usb_halted, usb_hotplug(), and usb_poll().
PERMANENT_PROCESS | ( | usb_process | , |
usb_step | |||
) |
USB process.
struct usb_hub* alloc_usb_hub | ( | struct usb_bus * | bus, |
struct usb_device * | usb, | ||
unsigned int | ports, | ||
struct usb_hub_driver_operations * | driver | ||
) |
Allocate USB hub.
bus | USB bus |
usb | Underlying USB device, if any |
ports | Number of ports |
driver | Hub driver operations |
hub | USB hub, or NULL on allocation failure |
Definition at line 1936 of file usb.c.
References bus, usb_hub::bus, usb_hub::driver, usb_hub::host, usb_port::hub, INIT_LIST_HEAD, usb_device::name, usb_hub::name, NULL, port, usb_device::port, usb_hub::port, usb_hub::ports, usb_port::protocol, usb_hub::protocol, usb_port::usb, usb_hub::usb, usb_port(), and zalloc().
Referenced by alloc_usb_bus(), and hub_probe().
int register_usb_hub | ( | struct usb_hub * | hub | ) |
Register USB hub.
hub | USB hub |
rc | Return status code |
Definition at line 1975 of file usb.c.
References bus, usb_hub::bus, usb_hub_host_operations::close, usb_hub_driver_operations::close, DBGC, usb_hub::driver, usb_hub::host, usb_port::hub, usb_bus::hub, usb_hub::list, list_add_tail, list_del, mdelay(), usb_hub::name, usb_hub_host_operations::open, usb_hub_driver_operations::open, port, usb_hub::ports, rc, strerror(), usb_poll(), usb_port(), usb_port_changed(), and USB_PORT_DELAY_MS.
Referenced by hub_probe(), and register_usb_bus().
void unregister_usb_hub | ( | struct usb_hub * | hub | ) |
Unregister USB hub.
hub | USB hub |
Definition at line 2029 of file usb.c.
References usb_hub_host_operations::close, usb_hub_driver_operations::close, usb_hub::driver, usb_hub::host, usb_port::hub, INIT_LIST_HEAD, usb_hub::list, list_del, port, usb_hub::ports, usb_detached(), and usb_port().
Referenced by hub_probe(), hub_remove(), register_usb_bus(), and unregister_usb_bus().
void free_usb_hub | ( | struct usb_hub * | hub | ) |
Free USB hub.
hub | USB hub |
Definition at line 2062 of file usb.c.
References assert(), free, usb_port::hub, list_empty, NULL, port, usb_hub::ports, and usb_port().
Referenced by alloc_usb_bus(), free_usb_bus(), hub_probe(), and hub_remove().
struct usb_bus* alloc_usb_bus | ( | struct device * | dev, |
unsigned int | ports, | ||
size_t | mtu, | ||
struct usb_host_operations * | op | ||
) |
Allocate USB bus.
dev | Underlying hardware device |
ports | Number of root hub ports |
mtu | Largest transfer allowed on the bus |
op | Host controller operations |
bus | USB bus, or NULL on allocation failure |
Definition at line 2094 of file usb.c.
References alloc_usb_hub(), bus, usb_bus::dev, free, free_usb_hub(), INIT_LIST_HEAD, mtu, device::name, NULL, op, and zalloc().
Referenced by ehci_probe(), uhci_probe(), usbio_start(), and xhci_probe().
int register_usb_bus | ( | struct usb_bus * | bus | ) |
Register USB bus.
bus | USB bus |
rc | Return status code |
Definition at line 2130 of file usb.c.
References assert(), bus, find_usb_bus(), list_add_tail, list_del, NULL, rc, register_usb_hub(), unregister_usb_hub(), usb_buses, and usb_hotplug().
Referenced by ehci_probe(), uhci_probe(), usbio_start(), and xhci_probe().
void unregister_usb_bus | ( | struct usb_bus * | bus | ) |
Unregister USB bus.
bus | USB bus |
Definition at line 2170 of file usb.c.
References assert(), bus, list_del, list_empty, NULL, and unregister_usb_hub().
Referenced by ehci_probe(), ehci_remove(), uhci_probe(), uhci_remove(), usbio_start(), usbio_stop(), xhci_probe(), and xhci_remove().
void free_usb_bus | ( | struct usb_bus * | bus | ) |
Free USB bus.
bus | USB bus |
Definition at line 2194 of file usb.c.
References assert(), bus, usb_hub::bus, usb_port::changed, free, free_usb_hub(), usb_port::hub, list_empty, list_for_each_entry, port, usb_device::port, usb_endpoint::usb, usb_changed, and usb_halted.
Referenced by ehci_probe(), ehci_remove(), uhci_probe(), uhci_remove(), usbio_start(), usbio_stop(), xhci_probe(), and xhci_remove().
struct usb_bus* find_usb_bus | ( | unsigned int | address | ) |
Find USB bus by address.
address | Bus address |
bus | USB bus, or NULL |
Definition at line 2219 of file usb.c.
References address, bus, for_each_usb_bus, and NULL.
Referenced by register_usb_bus(), usb_find_next(), and usb_settings_fetch().
struct usb_bus* find_usb_bus_by_location | ( | unsigned int | bus_type, |
unsigned int | location | ||
) |
Find USB bus by device location.
bus_type | Bus type |
location | Bus location |
bus | USB bus, or NULL |
Definition at line 2237 of file usb.c.
References bus, for_each_usb_bus, and NULL.
Referenced by uhci_root_speed().
int usb_alloc_address | ( | struct usb_bus * | bus | ) |
Allocate device address.
bus | USB bus |
address | Device address, or negative error |
Definition at line 2263 of file usb.c.
References address, bus, ENOENT, and ffsll.
Referenced by ehci_device_address(), and uhci_device_address().
void usb_free_address | ( | struct usb_bus * | bus, |
unsigned int | address | ||
) |
Free device address.
bus | USB bus |
address | Device address |
Definition at line 2283 of file usb.c.
References address, assert(), and bus.
Referenced by ehci_device_address(), ehci_device_close(), uhci_device_address(), and uhci_device_close().
int usb_find_next | ( | struct usb_device ** | usb, |
uint16_t * | busdev | ||
) |
Find next USB device.
usb | USB device to fill in |
busdev | Starting bus:dev address |
busdev | Bus:dev address of next USB device |
rc | Return status code |
Definition at line 2301 of file usb.c.
References bus, ENODEV, find_usb(), find_usb_bus(), USB_BUS, and USB_DEV.
Referenced by usbscan_exec().
unsigned int usb_route_string | ( | struct usb_device * | usb | ) |
Get USB route string.
usb | USB device |
route | USB route string |
Definition at line 2335 of file usb.c.
References usb_port::address, usb_port::hub, usb_device::port, route(), and usb_hub::usb.
Referenced by xhci_device_address().
struct usb_port* usb_root_hub_port | ( | struct usb_device * | usb | ) |
Get USB root hub port.
usb | USB device |
port | Root hub port |
Definition at line 2355 of file usb.c.
References usb_port::hub, usb_device::port, and usb_hub::usb.
Referenced by xhci_device_address().
struct usb_port* usb_transaction_translator | ( | struct usb_device * | usb | ) |
Get USB transaction translator.
usb | USB device |
port | Transaction translator port, or NULL |
Definition at line 2371 of file usb.c.
References usb_port::hub, NULL, usb_device::port, usb_device::speed, usb_hub::usb, and USB_SPEED_FULL.
Referenced by ehci_endpoint_capabilities(), usb_endpoint_clear_tt(), and xhci_device_open().
REQUIRING_SYMBOL | ( | register_usb_bus | ) |
REQUIRE_OBJECT | ( | config_usb | ) |
REQUIRE_OBJECT | ( | usbhub | ) |
struct list_head usb_buses = LIST_HEAD_INIT ( usb_buses ) |
|
static |
List of changed ports.
Definition at line 47 of file usb.c.
Referenced by free_usb_bus(), usb_hotplug(), and usb_port_changed().
|
static |
List of halted endpoints.
Definition at line 50 of file usb.c.
Referenced by free_usb_bus(), usb_complete_err(), and usb_step().
|
static |
USB control endpoint driver operations.
Definition at line 768 of file usb.c.
Referenced by alloc_usb().