101 #define ENOTSUP_MORONIC_SPECIFICATION \ 102 __einfo_error ( EINFO_ENOTSUP_MORONIC_SPECIFICATION ) 103 #define EINFO_ENOTSUP_MORONIC_SPECIFICATION \ 104 __einfo_uniqify ( EINFO_ENOTSUP, 0x01, \ 105 "EFI_USB_IO_PROTOCOL was designed by morons" ) 162 for ( i = 0 ; i < func->
desc.
count ; i++ ) {
171 DBGC ( usbio,
"USBIO %s cannot find interface for %s",
214 &intf->
handle ) ) != 0 ) {
216 DBGC ( usbio,
"USBIO %s could not locate ",
218 DBGC ( usbio,
"%s: %s\n",
225 DBGC ( usbio,
"USBIO %s located incomplete ",
239 DBGC ( usbio,
"USBIO %s cannot open ",
241 DBGC ( usbio,
"%s: %s\n",
328 unsigned int recipient;
338 if ( endpoint->
cons == endpoint->
prod )
348 DBGC ( usbio,
"USBIO %s %s non-message transfer\n",
351 goto err_not_message;
390 DBGC ( usbio,
"USBIO %s cannot change configuration: %s\n",
392 goto err_moronic_specification;
399 DBGC ( usbio,
"USBIO %s %s could not submit control transfer ",
401 DBGC ( usbio,
"via %s: %s (status %04x)\n",
416 err_moronic_specification:
477 if ( endpoint->
cons == endpoint->
prod )
502 DBGC2 ( usbio,
"USBIO %s %s could not submit bulk IN transfer: " 571 if ( endpoint->
cons == endpoint->
prod )
586 DBGC ( usbio,
"USBIO %s %s could not submit bulk OUT transfer: " 601 DBGC ( usbio,
"USBIO %s %s could not submit zero-length " 602 "transfer: %s (status %04x)\n",
681 DBGC ( usbio,
"USBIO %s %s dropped interrupt completion\n",
688 DBGC ( usbio,
"USBIO %s %s interrupt completion status %04x\n",
728 intr->endpoint = endpoint;
729 data = ( ( (
void * )
intr ) +
sizeof ( *intr ) );
746 DBGC ( usbio,
"USBIO %s %s could not schedule interrupt " 789 unsigned int intr_index;
793 if ( endpoint->
cons == endpoint->
prod )
845 endpoint =
zalloc (
sizeof ( *endpoint ) );
878 goto err_open_interface;
881 DBGC ( usbio,
"USBIO %s %s using ",
886 if ( (
rc = endpoint->
op->
open ( endpoint ) ) != 0 )
887 goto err_open_endpoint;
895 endpoint->
op->
close ( endpoint );
921 endpoint->
op->
close ( endpoint );
927 while ( endpoint->
cons != endpoint->
prod ) {
971 unsigned int flags ) {
1006 iob_pull ( iobuf,
sizeof ( *setup ) );
1039 endpoint->
op->
poll ( endpoint );
1321 goto err_open_protocol;
1325 if ( ( efirc = usb.io->UsbGetDeviceDescriptor ( usb.io,
1328 DBGC (
handle,
"USB %s could not get device descriptor: " 1330 goto err_get_device_descriptor;
1337 if ( ( efirc = usb.io->UsbGetInterfaceDescriptor ( usb.io,
1340 DBGC (
handle,
"USB %s could not get interface descriptor: " 1342 goto err_get_interface_descriptor;
1352 goto err_unsupported;
1359 err_get_interface_descriptor:
1360 err_get_device_descriptor:
1393 DBGC ( usbio,
"USB %s could not get device descriptor: " 1395 goto err_get_device_descriptor;
1402 DBGC ( usbio,
"USB %s could not get partial configuration " 1405 goto err_get_configuration_descriptor;
1423 for ( i = 0 ; i <
count ; i++ ) {
1429 msg.setup.index = 0;
1438 DBGC ( usbio,
"USB %s could not get configuration %d " 1441 goto err_control_transfer;
1450 DBGC ( usbio,
"USB %s configuration descriptor length " 1460 DBGC ( usbio,
"USB %s could not find current configuration " 1465 err_control_transfer:
1468 err_get_configuration_descriptor:
1469 err_get_device_descriptor:
1500 DBGC ( usbio,
"USBIO %s cannot open device path protocol: " 1502 goto err_open_protocol;
1508 if (
len <
sizeof ( *usbpath ) ) {
1509 DBGC ( usbio,
"USBIO %s underlength device path\n",
1512 goto err_underlength;
1514 usbpath = ( ( (
void * ) path ) +
len -
sizeof ( *usbpath ) );
1517 DBGC ( usbio,
"USBIO %s not a USB device path: ",
1526 if ( ! usbio->
path ) {
1532 sizeof ( *usbpath ) );
1568 DBGC ( usbio,
"USB %s could not get interface descriptor: " 1570 goto err_get_interface_descriptor;
1600 err_get_interface_descriptor:
1623 usbio =
zalloc (
sizeof ( *usbio ) );
1639 DBGC ( usbio,
"USBIO %s cannot open USB I/O protocol: %s\n",
1642 goto err_open_usbio;
1662 goto err_interfaces;
1667 if ( ! usbio->
bus ) {
#define iob_pull(iobuf, len)
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
#define EINVAL
Invalid argument.
static void usbio_bulk_out_poll(struct usbio_endpoint *endpoint)
Poll bulk OUT endpoint.
static void usb_endpoint_set_hostdata(struct usb_endpoint *ep, void *priv)
Set USB endpoint host controller private data.
A USB I/O protocol interface.
struct arbelprm_rc_send_wqe rc
static int usbio_root_open(struct usb_hub *hub __unused)
Open root hub.
struct usbio_interrupt_ring * intr
Interrupt ring buffer (if applicable)
static int usbio_device_address(struct usb_device *usb __unused)
Assign device address.
#define iob_put(iobuf, len)
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
#define USB_RECIP_MASK
Request recipient mask.
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
struct usbio_device * usbio
USB I/O device.
static void usbio_interrupt_poll(struct usbio_endpoint *endpoint)
Poll interrupt endpoint.
struct device dev
Generic device.
static int usbio_endpoint_open(struct usb_endpoint *ep)
Open endpoint.
uint8_t interface[0]
List of interface numbers.
static void usbio_bus_close(struct usb_bus *bus __unused)
Close USB bus.
#define USB_RECIP_INTERFACE
Request recipient is an interface.
static int usbio_path(struct usbio_device *usbio)
Construct device path for opening other interfaces.
unsigned int count
Number of interfaces.
#define list_add(new, head)
Add a new entry to the head of a list.
uint32_t first
First block in range.
struct usb_bus * alloc_usb_bus(struct device *dev, unsigned int ports, size_t mtu, struct usb_host_operations *op)
Allocate USB bus.
#define USB_GET_DESCRIPTOR
Get descriptor.
#define USB_ENDPOINT_ATTR_TYPE_MASK
Endpoint attribute transfer type mask.
#define iob_push(iobuf, len)
static void usbio_device_close(struct usb_device *usb __unused)
Close device.
static void usb_set_hostdata(struct usb_device *usb, void *priv)
Set USB device host controller private data.
uint8_t attr
Type and attributes.
static void usbio_control_close(struct usbio_endpoint *endpoint __unused)
Close control endpoint.
static void usbio_root_close(struct usb_hub *hub __unused)
Close root hub.
static void usbio_bulk_in_close(struct usbio_endpoint *endpoint __unused)
Close bulk IN endpoint.
EFI_USB_IO_PROTOCOL pseudo Host Controller Interface driver.
static int usbio_interface(struct usbio_device *usbio, struct usb_endpoint *ep)
Determine endpoint interface number.
EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER UsbAsyncInterruptTransfer
uint64_t desc
Microcode descriptor list physical address.
static void usbio_hub_close(struct usb_hub *hub __unused)
Close hub.
static struct usbio_operations usbio_control_operations
Control endpoint operations.
static int usbio_start(struct efi_device *efidev)
Attach driver to device.
#define ENOENT
No such file or directory.
Standard Interface Descriptor USB 2.0 spec, Section 9.6.5.
#define EFI_OPEN_PROTOCOL_BY_DRIVER
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
#define for_each_interface_descriptor(desc, config, interface)
Iterate over all configuration descriptors within an interface descriptor.
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
uint8_t interfaces
Number of interfaces.
static void usbio_endpoint_close(struct usb_endpoint *ep)
Close endpoint.
#define for_each_config_descriptor(desc, config)
Iterate over all configuration descriptors.
#define EFI_OPEN_PROTOCOL_EXCLUSIVE
uint8_t direction
Direction.
#define USB_ENDPOINT_ATTR_BULK
Bulk endpoint transfer type.
uint8_t endpoint
Endpoint address.
#define DBGC_EFI_OPENERS(...)
EFI_HANDLE device
EFI device handle.
This protocol can be used on any device handle to obtain generic path/location information concerning...
uint16_t device
Device ID.
EFI_USB_DATA_DIRECTION
USB data transfer direction.
static void usbio_close(struct usbio_device *usbio, unsigned int interface)
Close USB I/O interface.
EFI_CLOSE_PROTOCOL CloseProtocol
static int usbio_bus_open(struct usb_bus *bus __unused)
Open USB bus.
#define USBIO_RING_COUNT
USB I/O ring buffer size.
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
struct device * parent
Bus device.
struct efi_driver usbio_driver __efi_driver(EFI_DRIVER_NORMAL)
EFI USB I/O driver.
#define EXDEV
Improper link.
static int usbio_endpoint_reset(struct usb_endpoint *ep __unused)
Reset endpoint.
static void usbio_bus_poll(struct usb_bus *bus)
Poll USB bus.
#define ECANCELED
Operation canceled.
#define ENOTSUP
Operation not supported.
static void usbio_interrupt_close(struct usbio_endpoint *endpoint)
Close interrupt endpoint.
static void usbio_bulk_in_poll(struct usbio_endpoint *endpoint)
Poll bulk IN endpoint.
A USB interrupt ring buffer.
uint8_t flags[USBIO_RING_COUNT]
Flags.
static void usb_bus_set_hostdata(struct usb_bus *bus, void *priv)
Set USB bus host controller private data.
#define USBIO_MTU
USB I/O maximum transfer size.
static void usbio_endpoint_poll(struct usbio_endpoint *endpoint)
Poll for completions.
#define list_del(list)
Delete an entry from a list.
static int usbio_root_speed(struct usb_hub *hub __unused, struct usb_port *port)
Update root hub port speed.
#define ENOMEM
Not enough space.
struct usb_device * usb
Underlying USB device, if any.
unsigned int interface
Containing interface number.
void(* poll)(struct usbio_endpoint *endpoint)
Poll endpoint.
static int usbio_endpoint_message(struct usb_endpoint *ep, struct io_buffer *iobuf)
Enqueue message transfer.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
A USB interface descriptor.
A USB function descriptor.
static int usbio_interrupt_open(struct usbio_endpoint *endpoint)
Open interrupt endpoint.
void unregister_usb_bus(struct usb_bus *bus)
Unregister USB bus.
Format of Setup Data for USB Device Requests USB 2.0 spec, Section 9.3.
struct usb_port * port
USB port.
struct usb_driver * usb_find_driver(struct usb_function_descriptor *desc, struct usb_device_id **id)
Find USB device driver.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static int usbio_endpoint_enqueue(struct usb_endpoint *ep, struct io_buffer *iobuf, unsigned int flags)
Enqueue transfer.
EFI_HANDLE handle
EFI handle.
uint8_t intr
Interrupts enabled.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
pseudo_bit_t value[0x00020]
This transfer requires zero-length packet termination.
#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 usbio_control_open(struct usbio_endpoint *endpoint __unused)
Open control endpoint.
struct list_head endpoints
List of endpoints.
static struct usbio_operations usbio_bulk_in_operations
Bulk endpoint operations.
unsigned int count
Usage count.
static int usbio_config(struct usbio_device *usbio)
Fetch configuration descriptor.
uint16_t count
Number of entries.
static int usbio_endpoint_mtu(struct usb_endpoint *ep __unused)
Update MTU.
#define USB_DIR_IN
Data transfer is from device to host.
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
#define USB_CONFIGURATION_DESCRIPTOR
A USB configuration descriptor.
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
uint8_t id
Request identifier.
struct usb_bus * bus
USB bus.
EFI_DEVICE_PATH_PROTOCOL Header
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
#define USB_ENDPOINT_ATTR_INTERRUPT
Interrupt endpoint transfer type.
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))
static int usbio_supported(EFI_HANDLE handle)
Check to see if driver supports a device.
void * zalloc(size_t size)
Allocate cleared memory.
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
uint8_t first
First interface number.
void(* close)(struct usbio_endpoint *endpoint)
Close endpoint.
UINT8 InterfaceNumber
USB Interface Number.
struct list_head siblings
Devices on the same bus.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
static int usbio_bulk_in_open(struct usbio_endpoint *endpoint __unused)
Open bulk IN endpoint.
static void usbio_control_poll(struct usbio_endpoint *endpoint)
Poll control endpoint.
UINT64 UINTN
Unsigned value of native width.
Standard Endpoint Descriptor USB 2.0 spec, Section 9.6.6.
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
struct usbio_operations * op
USB I/O endpoint operations.
struct usb_device * usb
USB device.
#define le16_to_cpu(value)
#define VOID
Undeclared type.
void * malloc(size_t size)
Allocate memory.
struct usb_configuration_descriptor * config
Configuration descriptor.
struct usbio_endpoint * endpoint
USB I/O endpoint.
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
static int usbio_hub_open(struct usb_hub *hub)
Open hub.
EFI_USB_IO_CONTROL_TRANSFER UsbControlTransfer
unsigned int prod
Producer counter.
EFI_USB_IO_BULK_TRANSFER UsbBulkTransfer
size_t mtu
Maximum transfer size.
EFI Usb I/O Protocol as defined in UEFI specification.
static int usbio_endpoint_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int zlp)
Enqueue stream transfer.
#define INIT_LIST_HEAD(list)
Initialise a list head.
A USB configuration descriptor.
struct usbio_interface * interface
USB I/O protocol interfaces.
#define USBIO_INTR_COUNT
USB I/O interrupt ring buffer size.
A USB endpoint descriptor.
static void * usb_bus_get_hostdata(struct usb_bus *bus)
Get USB bus host controller private data.
static int usbio_bulk_out_open(struct usbio_endpoint *endpoint __unused)
Open bulk OUT endpoint.
USB_DEVICE_PATH * usbpath
Final component of USB device path.
uint8_t config
Configuration value.
#define ENOBUFS
No buffer space available.
EFI_USB_IO_GET_DEVICE_DESCRIPTOR UsbGetDeviceDescriptor
static int usbio_device_open(struct usb_device *usb)
Open device.
Universal Serial Bus (USB)
int register_usb_bus(struct usb_bus *bus)
Register USB bus.
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
unsigned int cons
Consumer counter.
static void usb_complete(struct usb_endpoint *ep, struct io_buffer *iobuf)
Complete transfer (without error)
void * data
Start of data.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
static int usbio_root_disable(struct usb_hub *hub __unused, struct usb_port *port __unused)
Disable port.
struct list_head children
Devices attached to this device.
struct usb_hub * hub
USB hub.
UINT8 SubType
Varies by Type 0xFF End Entire Device Path, or 0x01 End This Instance of a Device Path and start a ne...
int(* open)(struct usbio_endpoint *endpoint)
Open endpoint.
struct usb_endpoint * ep[32]
Endpoint list.
unsigned int interval
Interval (in microframes)
u8 request[0]
List of IEs requested.
#define cpu_to_le16(value)
static struct usbio_operations usbio_interrupt_operations
Interrupt endpoint operations.
Standard Configuration Descriptor USB 2.0 spec, Section 9.6.3.
uint32_t end
Ending offset.
uint8_t data[48]
Additional event data.
USB host controller operations.
#define USB_ENDPOINT_ATTR_CONTROL
Control endpoint transfer type.
struct list_head list
List of endpoints.
struct usb_descriptor_header header
Descriptor header.
struct usb_hub * hub
Root hub.
struct usb_endpoint * ep
USB endpoint.
uint16_t len
Total length.
UINT8 Type
0x01 Hardware Device Path.
struct usb_function_descriptor desc
Function descriptor.
static void usb_hub_set_drvdata(struct usb_hub *hub, void *priv)
Set USB hub driver private data.
struct usb_device * usb
USB device.
static void usbio_stop(struct efi_device *efidev)
Detach driver from device.
static struct usb_port * usb_port(struct usb_hub *hub, unsigned int address)
Get USB port.
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
static int usbio_root_clear_tt(struct usb_hub *hub __unused, struct usb_port *port __unused, struct usb_endpoint *ep __unused)
Clear transaction translator buffer.
EFI_HANDLE handle
EFI device handle.
static EFI_STATUS EFIAPI usbio_interrupt_callback(VOID *data, UINTN len, VOID *context, UINT32 status)
Interrupt endpoint callback.
static struct usbio_operations usbio_bulk_out_operations
Bulk endpoint operations.
struct usb_bus * bus
USB bus.
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
A USB I/O protocol device.
USB I/O endpoint operations.
struct device dev
Generic device.
struct list_head functions
List of functions.
EFI_HANDLE handle
EFI device handle.
#define USB_EP0_ADDRESS
Control endpoint address.
static int usbio_root_enable(struct usb_hub *hub __unused, struct usb_port *port __unused)
Enable port.
#define USB_SET_CONFIGURATION
Set configuration.
static int usbio_interfaces(struct usbio_device *usbio)
Construct interface list.
#define NULL
NULL pointer (VOID *)
EFI_USB_IO_GET_INTERFACE_DESCRIPTOR UsbGetInterfaceDescriptor
Standard Device Descriptor USB 2.0 spec, Section 9.6.1.
struct list_head list
List of functions within this USB device.
unsigned int attributes
Attributes.
static int usbio_open(struct usbio_device *usbio, unsigned int interface)
Open USB I/O interface.
EFI_DEVICE_PATH_PROTOCOL * efi_path_end(EFI_DEVICE_PATH_PROTOCOL *path)
Find end of device path.
uint8_t interface
Interface number.
unsigned int address
Endpoint address.
This is a message transfer.
void free_usb_bus(struct usb_bus *bus)
Free USB bus.
#define MSG_USB_DP
USB Device Path SubType.
struct io_buffer * iobuf[USBIO_RING_COUNT]
I/O buffers.
void usb_complete_err(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer (possibly with error)
static void usbio_bulk_out_close(struct usbio_endpoint *endpoint __unused)
Close bulk OUT endpoint.
EFI_LOCATE_DEVICE_PATH LocateDevicePath
void efi_device_info(EFI_HANDLE device, const char *prefix, struct device *dev)
Get underlying device information.
#define EFI_TIMEOUT
Enumeration of EFI_STATUS.
static void * usb_endpoint_get_hostdata(struct usb_endpoint *ep)
Get USB endpoint host controller private data.
EFI_USB_IO_GET_CONFIG_DESCRIPTOR UsbGetConfigDescriptor
void * memset(void *dest, int character, size_t len) __nonnull
#define ENOTSUP_MORONIC_SPECIFICATION
#define EFI_DRIVER_NORMAL
Normal drivers.
int efi_shutdown_in_progress
EFI shutdown is in progress.