57 default:
return "<UNKNOWN>";
95 unsigned int endpoint ) {
105 DBGC ( usbdev,
"USBDEV %s alt %d has no interface descriptor\n",
113 (
desc->endpoint == endpoint ) )
117 DBGC ( usbdev,
"USBDEV %s alt %d ep %02x has no descriptor\n",
130 unsigned int endpoint ) {
134 return ( usbep && usbep->
ep.
open );
148 unsigned int endpoint,
unsigned int attributes,
149 unsigned int interval,
166 usbep =
zalloc (
sizeof ( *usbep ) );
189 DBGC ( usbdev,
"USBDEV %s %s could not open: %s\n",
194 DBGC ( usbdev,
"USBDEV %s %s opened\n",
200 &usbep->
event ) ) != 0 ) {
202 DBGC ( usbdev,
"USBDEV %s %s could not create event: %s\n",
239 DBGC ( usbdev,
"USBDEV %s %s closed\n",
255 if ( usbep && usbep->
ep.
open )
313 unsigned int endpoint,
314 unsigned int attributes,
347 DBGC ( usbdev,
"USBDEV %s %s could not enqueue: %s\n",
372 DBGC ( usbdev,
"USBDEV %s %s failed: %s\n", usbintf->
name,
450 unsigned int endpoint,
unsigned int interval,
479 DBGC ( usbdev,
"USBDEV %s %s could not prefill: %s\n",
487 ( interval * 10000 ) ) ) != 0 ) {
489 DBGC ( usbdev,
"USBDEV %s %s could not set timer: %s\n",
514 unsigned int endpoint ) {
567 DBGC2 ( usbdev,
"USBDEV %s control %04x:%04x:%04x:%04x %s %dms " 571 ( (
size_t )
len ) );
585 DBGC ( usbdev,
"USBDEV %s cannot set configuration %d: not " 586 "logically possible\n", usbintf->
name,
index );
588 goto err_change_config;
601 DBGC ( usbdev,
"USBDEV %s control %04x:%04x:%04x:%04x %p+%zx " 612 DBGC ( usbdev,
"USBDEV %s alt %d selected\n",
639 size_t actual = *
len;
643 DBGC2 ( usbdev,
"USBDEV %s bulk %s %p+%zx %dms\n", usbintf->
name,
645 ( (
size_t ) *
len ), ( (
unsigned int )
timeout ) );
656 data, &actual ) ) != 0 ) {
685 size_t actual = *
len;
689 DBGC2 ( usbdev,
"USBDEV %s sync intr %s %p+%zx %dms\n", usbintf->
name,
691 ( (
size_t ) *
len ), ( (
unsigned int )
timeout ) );
736 DBGC2 ( usbdev,
"USBDEV %s async intr %s len %#zx int %d %p/%p\n",
739 ( (
size_t )
len ), ( (
unsigned int ) interval ),
786 DBGC2 ( usbdev,
"USBDEV %s sync iso %s %p+%zx\n", usbintf->
name,
788 ( (
size_t )
len ) );
818 DBGC2 ( usbdev,
"USBDEV %s async iso %s %p+%zx %p/%p\n", usbintf->
name,
820 ( (
size_t )
len ), callback, context );
840 DBGC2 ( usbdev,
"USBDEV %s get device descriptor\n", usbintf->
name );
862 DBGC2 ( usbdev,
"USBDEV %s get configuration descriptor\n",
866 memcpy ( efidesc, usbdev->
config, sizeof ( *efidesc ) );
886 DBGC2 ( usbdev,
"USBDEV %s get interface descriptor\n", usbintf->
name );
892 DBGC ( usbdev,
"USBDEV %s alt %d has no interface descriptor\n",
898 memcpy ( efidesc,
desc,
sizeof ( *efidesc ) );
920 DBGC2 ( usbdev,
"USBDEV %s get endpoint %d descriptor\n",
928 DBGC ( usbdev,
"USBDEV %s alt %d has no interface descriptor\n",
937 memcpy ( efidesc,
desc,
sizeof ( *efidesc ) );
967 DBGC2 ( usbdev,
"USBDEV %s get string %d:%d descriptor\n",
977 sizeof (
header ) ) ) != 0 ) {
978 DBGC ( usbdev,
"USBDEV %s could not get string %d:%d " 979 "descriptor header: %s\n", usbintf->
name, language,
985 DBGC ( usbdev,
"USBDEV %s underlength string %d:%d\n",
1002 DBGC ( usbdev,
"USBDEV %s could not get string %d:%d " 1003 "descriptor: %s\n", usbintf->
name, language,
1005 goto err_get_descriptor;
1044 DBGC2 ( usbdev,
"USBDEV %s get supported languages\n", usbintf->
name );
1047 *languages = usbdev->
lang;
1065 DBGC2 ( usbdev,
"USBDEV %s reset port\n", usbintf->
name );
1117 usbintf =
zalloc (
sizeof ( *usbintf ) );
1127 sizeof ( usbintf->
usbio ) );
1131 if ( ! usbintf->
path ) {
1146 DBGC (
usbdev,
"USBDEV %s could not install protocols: %s\n",
1148 goto err_install_protocol;
1151 DBGC (
usbdev,
"USBDEV %s installed as %s\n",
1160 DBGC (
usbdev,
"USBDEV %s could not uninstall: %s\n",
1165 err_install_protocol:
1176 DBGC (
usbdev,
"USBDEV %s nullified and leaked\n",
1193 DBGC ( usbdev,
"USBDEV %s uninstalling %s\n",
1210 DBGC ( usbdev,
"USBDEV %s could not uninstall: %s\n",
1233 DBGC ( usbdev,
"USBDEV %s nullified and leaked\n",
1287 usbdev =
zalloc (
sizeof ( *usbdev ) + config_len +
1288 sizeof ( *lang ) + lang_len );
1295 usbdev->
func = func;
1296 usbdev->
config = ( ( (
void * ) usbdev ) +
sizeof ( *usbdev ) );
1298 lang = ( ( (
void * ) usbdev->
config ) + config_len );
1299 usbdev->
lang = ( ( (
void * ) lang ) +
sizeof ( *lang ) );
1306 0, 0, lang,
header.len ) ) != 0 ) ) {
1307 DBGC ( usbdev,
"USBDEV %s could not get supported languages: " 1309 goto err_get_languages;
1313 for ( i = 0 ; i < func->
desc.
count ; i++ ) {
uint16_t * lang
Supported languages.
static void efi_usb_async_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete asynchronous transfer.
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
#define EINVAL
Invalid argument.
static EFI_USB_IO_PROTOCOL efi_usb_io_protocol
USB I/O protocol.
static void efi_usb_close(struct efi_usb_endpoint *usbep)
Close endpoint.
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
struct arbelprm_rc_send_wqe rc
#define EFI_USB_ASYNC_FILL
Asynchronous transfer fill level.
static EFI_STATUS EFIAPI efi_usb_get_interface_descriptor(EFI_USB_IO_PROTOCOL *usbio, EFI_USB_INTERFACE_DESCRIPTOR *efidesc)
Get interface descriptor.
#define iob_put(iobuf, len)
size_t lang_len
Length of supported languages.
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
unsigned int alternate
Alternate setting.
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
An event is to be signaled periodically at a specified interval from the current time.
static EFI_STATUS EFIAPI efi_usb_get_config_descriptor(EFI_USB_IO_PROTOCOL *usbio, EFI_USB_CONFIG_DESCRIPTOR *efidesc)
Get configuration descriptor.
static void usb_endpoint_describe(struct usb_endpoint *ep, unsigned int address, unsigned int attributes, size_t mtu, unsigned int burst, unsigned int interval)
Describe USB endpoint.
uint8_t interface[0]
List of interface numbers.
static void efi_usb_close_all(struct efi_usb_interface *usbintf)
Close all endpoints.
static EFI_STATUS EFIAPI efi_usb_sync_interrupt_transfer(EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data, UINTN *len, UINTN timeout, UINT32 *status)
Perform synchronous interrupt transfer.
static EFI_STATUS EFIAPI efi_usb_port_reset(EFI_USB_IO_PROTOCOL *usbio)
Reset port.
struct usb_function * func
The underlying USB function.
static struct usb_endpoint_driver_operations efi_usb_sync_driver
Synchronous endpoint operations.
unsigned int count
Number of interfaces.
#define USB_STRING_DESCRIPTOR
A USB string descriptor.
void efi_raise_tpl(struct efi_saved_tpl *tpl)
Raise task priority level to internal level.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
VOID * EFI_EVENT
Handle to an event structure.
static void efi_usb_async_stop(struct efi_usb_interface *usbintf, unsigned int endpoint)
Stop asynchronous transfer.
static EFI_STATUS EFIAPI efi_usb_control_transfer(EFI_USB_IO_PROTOCOL *usbio, EFI_USB_DEVICE_REQUEST *packet, EFI_USB_DATA_DIRECTION direction, UINT32 timeout, VOID *data, UINTN len, UINT32 *status)
Perform control transfer.
static EFI_STATUS EFIAPI efi_usb_async_isochronous_transfer(EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data, UINTN len, EFI_ASYNC_USB_TRANSFER_CALLBACK callback, VOID *context)
Perform asynchronous isochronous transfers.
static VOID EFIAPI efi_usb_timer(EFI_EVENT event __unused, VOID *context)
Poll USB bus (from endpoint event timer)
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
uint64_t desc
Microcode descriptor list physical address.
static struct usb_endpoint_driver_operations efi_usb_async_driver
Asynchronous endpoint operations.
#define ENOENT
No such file or directory.
Standard Interface Descriptor USB 2.0 spec, Section 9.6.5.
static void efi_usb_remove(struct usb_function *func)
Remove device.
static EFI_STATUS EFIAPI efi_usb_get_string_descriptor(EFI_USB_IO_PROTOCOL *usbio, UINT16 language, UINT8 index, CHAR16 **string)
Get string descriptor.
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
int usb_prefill(struct usb_endpoint *ep)
Prefill endpoint recycled buffer list.
int usb_endpoint_open(struct usb_endpoint *ep)
Open USB endpoint.
#define for_each_interface_descriptor(desc, config, interface)
Iterate over all configuration descriptors within an interface descriptor.
EFI_CLOSE_EVENT CloseEvent
uint8_t direction
Direction.
#define USB_ENDPOINT_ATTR_BULK
Bulk endpoint transfer type.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
EFI_USB_DATA_DIRECTION
USB data transfer direction.
void usb_endpoint_close(struct usb_endpoint *ep)
Close USB endpoint.
int open
Endpoint is open.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
static EFI_STATUS EFIAPI efi_usb_get_endpoint_descriptor(EFI_USB_IO_PROTOCOL *usbio, UINT8 index, EFI_USB_ENDPOINT_DESCRIPTOR *efidesc)
Get endpoint descriptor.
int usb_refill(struct usb_endpoint *ep)
Refill endpoint.
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.
static struct usb_device_id efi_usb_ids[]
USB I/O protocol device IDs.
struct efi_usb_endpoint * endpoint[32]
Opened endpoints.
#define ENOTSUP
Operation not supported.
static EFI_STATUS EFIAPI efi_usb_isochronous_transfer(EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data, UINTN len, UINT32 *status)
Perform synchronous isochronous transfer.
#define EFI_USB_ERR_SYSTEM
uint32_t start
Starting offset.
#define list_empty(list)
Test whether a list is empty.
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
#define list_del(list)
Delete an entry from a list.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ENOMEM
Not enough space.
An EFI USB device interface.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
An event's timer settings is to be cancelled and not trigger time is to be set/.
A USB interface descriptor.
Format of Setup Data for USB Device Requests USB 2.0 spec, Section 9.3.
struct usb_port * port
USB port.
static void usb_recycle(struct usb_endpoint *ep, struct io_buffer *iobuf)
Recycle I/O buffer.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
static int efi_usb_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
void efi_nullify_usbio(EFI_USB_IO_PROTOCOL *usbio)
Nullify USB I/O protocol.
static const char * efi_usb_direction_name(EFI_USB_DATA_DIRECTION direction)
Transcribe data direction (for debugging)
struct ib_cm_path alternate
Alternate path.
EFI_EVENT event
Asynchronous timer event.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
pseudo_bit_t value[0x00020]
#define __unused
Declare a variable or data structure as unused.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
static int efi_usb_async_start(struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int interval, size_t len, EFI_ASYNC_USB_TRANSFER_CALLBACK callback, void *context)
Start asynchronous transfer.
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
EFI_CREATE_EVENT CreateEvent
int rc
Most recent synchronous completion status.
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
void * context
Asynchronous callback context.
struct list_head interfaces
List of interfaces.
struct efi_usb_interface * usbintf
EFI USB device interface.
EFI_ASYNC_USB_TRANSFER_CALLBACK callback
Asynchronous callback handler.
static int efi_usb_is_open(struct efi_usb_interface *usbintf, unsigned int endpoint)
Check if endpoint is open.
static void efi_usb_sync_complete(struct usb_endpoint *ep, struct io_buffer *iobuf __unused, int rc)
Complete synchronous transfer.
struct usb_interface_descriptor * usb_interface_descriptor(struct usb_configuration_descriptor *config, unsigned int interface, unsigned int alternate)
Locate USB interface descriptor.
#define EINPROGRESS
Operation in progress.
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
#define USB_ENDPOINT_IN
Endpoint direction is in.
#define USB_ENDPOINT_ATTR_INTERRUPT
Interrupt endpoint transfer type.
unsigned int interface
Interface number.
#define USB_SET_INTERFACE
Set interface.
static void efi_usb_uninstall(struct efi_usb_interface *usbintf)
Uninstall interface.
char * strerror(int errno)
Retrieve string representation of error number.
EFI_GUID efi_usb_io_protocol_guid
USB I/O protocol GUID.
static void(* free)(struct refcnt *refcnt))
EFI_DEVICE_PATH_PROTOCOL * efi_usb_path(struct usb_function *func)
Construct EFI device path for USB function.
static int efi_usb_open(struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int attributes, unsigned int interval, struct usb_endpoint_driver_operations *driver)
Open endpoint.
An EFI USB device endpoint.
void * zalloc(size_t size)
Allocate cleared memory.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
struct usb_driver usbio_driver __usb_fallback_driver
USB I/O protocol driver.
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
EFI_CONNECT_CONTROLLER ConnectController
#define ENODEV
No such device.
#define EFI_USB_ERR_TIMEOUT
struct usb_configuration_descriptor * config
Configuration descriptor.
UINT64 UINTN
Unsigned value of native width.
#define EVT_NOTIFY_SIGNAL
static void efi_usb_free_all(struct efi_usb_interface *usbintf)
Free all endpoints.
uint8_t name
Interface name.
static void efi_usb_uninstall_all(struct efi_usb_device *efiusb)
Uninstall all interfaces.
static int efi_usb_sync_transfer(struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int attributes, unsigned int timeout, void *data, size_t *len)
Perform synchronous transfer.
#define EFI_INVALID_PARAMETER
Enumeration of EFI_STATUS.
struct usb_device_descriptor device
Device descriptor.
Standard Endpoint Descriptor USB 2.0 spec, Section 9.6.6.
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
struct usb_device * usb
USB device.
static void usb_endpoint_init(struct usb_endpoint *ep, struct usb_device *usb, struct usb_endpoint_driver_operations *driver)
Initialise USB endpoint.
#define le16_to_cpu(value)
#define VOID
Undeclared type.
#define USB_ENDPOINT_IDX(address)
Construct endpoint index from endpoint address.
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
void * memmove(void *dest, const void *src, size_t len) __nonnull
struct usb_endpoint ep
USB endpoint.
EFI_USB_IO_CONTROL_TRANSFER UsbControlTransfer
EFI_USB_IO_PROTOCOL usbio
USB I/O protocol.
#define USB_REQUEST_TYPE(type)
Construct USB request type.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
#define INIT_LIST_HEAD(list)
Initialise a list head.
A USB configuration descriptor.
static EFI_STATUS EFIAPI efi_usb_get_device_descriptor(EFI_USB_IO_PROTOCOL *usbio, EFI_USB_DEVICE_DESCRIPTOR *efidesc)
Get device descriptor.
A USB endpoint descriptor.
uint8_t alternate
Alternate setting.
An EFI saved task priority level.
struct list_head list
List of interfaces.
static int efi_usb_mtu(struct efi_usb_interface *usbintf, unsigned int endpoint)
Get endpoint MTU.
uint8_t config
Configuration value.
#define USB_ANY_ID
Match-anything ID.
Universal Serial Bus (USB)
void * data
Start of data.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
struct usb_hub * hub
USB hub.
static int efi_usb_install(struct efi_usb_device *usbdev, unsigned int interface)
Install interface.
EFI_HANDLE handle
EFI handle.
struct ena_aq_header header
Header.
u8 request[0]
List of IEs requested.
Standard Configuration Descriptor USB 2.0 spec, Section 9.6.3.
uint8_t data[48]
Additional event data.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
uint16_t len
Total length.
struct usb_function_descriptor desc
Function descriptor.
EFI_SYSTEM_TABLE * efi_systab
#define USB_ENDPOINT_MTU(sizes)
USB endpoint MTU.
static int usb_get_descriptor(struct usb_device *usb, unsigned int type, unsigned int desc, unsigned int index, unsigned int language, struct usb_descriptor_header *data, size_t len)
Get USB descriptor.
The data portions of a loaded Boot Serves Driver, and the default data allocation type used by a Boot...
USB endpoint driver operations.
struct efi_usb_device * usbdev
Containing USB device.
struct usb_bus * bus
USB bus.
Fallback driver (has no effect on overall score)
static EFI_STATUS EFIAPI efi_usb_bulk_transfer(EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data, UINTN *len, UINTN timeout, UINT32 *status)
Perform bulk transfer.
#define USB_SET_CONFIGURATION
Set configuration.
void efi_restore_tpl(struct efi_saved_tpl *tpl)
Restore task priority level.
#define NULL
NULL pointer (VOID *)
static EFI_STATUS EFIAPI efi_usb_get_supported_languages(EFI_USB_IO_PROTOCOL *usbio, UINT16 **languages, UINT16 *len)
Get supported languages.
Standard Device Descriptor USB 2.0 spec, Section 9.6.1.
#define ETIMEDOUT
Connection timed out.
uint8_t interface
Interface number.
unsigned int address
Endpoint address.
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
EFI_STATUS(EFIAPI * EFI_ASYNC_USB_TRANSFER_CALLBACK)(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
Async USB transfer callback routine.
static EFI_STATUS EFIAPI efi_usb_async_interrupt_transfer(EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, BOOLEAN start, UINTN interval, UINTN len, EFI_ASYNC_USB_TRANSFER_CALLBACK callback, VOID *context)
Perform asynchronous interrupt transfer.
struct usb_device_id * ids
USB ID table.
EFI_ALLOCATE_POOL AllocatePool
void * memset(void *dest, int character, size_t len) __nonnull
int efi_shutdown_in_progress
EFI shutdown is in progress.
EFI_DISCONNECT_CONTROLLER DisconnectController