iPXE
Macros | Functions | Variables
usbio.c File Reference

EFI_USB_IO_PROTOCOL pseudo Host Controller Interface driver. More...

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_utils.h>
#include <ipxe/efi/Protocol/UsbIo.h>
#include <ipxe/usb.h>
#include "usbio.h"

Go to the source code of this file.

Macros

#define ENOTSUP_MORONIC_SPECIFICATION   __einfo_error ( EINFO_ENOTSUP_MORONIC_SPECIFICATION )
 
#define EINFO_ENOTSUP_MORONIC_SPECIFICATION
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int usbio_interface (struct usbio_device *usbio, struct usb_endpoint *ep)
 Determine endpoint interface number. More...
 
static int usbio_open (struct usbio_device *usbio, unsigned int interface)
 Open USB I/O interface. More...
 
static void usbio_close (struct usbio_device *usbio, unsigned int interface)
 Close USB I/O interface. More...
 
static int usbio_control_open (struct usbio_endpoint *endpoint __unused)
 Open control endpoint. More...
 
static void usbio_control_close (struct usbio_endpoint *endpoint __unused)
 Close control endpoint. More...
 
static void usbio_control_poll (struct usbio_endpoint *endpoint)
 Poll control endpoint. More...
 
static int usbio_bulk_in_open (struct usbio_endpoint *endpoint __unused)
 Open bulk IN endpoint. More...
 
static void usbio_bulk_in_close (struct usbio_endpoint *endpoint __unused)
 Close bulk IN endpoint. More...
 
static void usbio_bulk_in_poll (struct usbio_endpoint *endpoint)
 Poll bulk IN endpoint. More...
 
static int usbio_bulk_out_open (struct usbio_endpoint *endpoint __unused)
 Open bulk OUT endpoint. More...
 
static void usbio_bulk_out_close (struct usbio_endpoint *endpoint __unused)
 Close bulk OUT endpoint. More...
 
static void usbio_bulk_out_poll (struct usbio_endpoint *endpoint)
 Poll bulk OUT endpoint. More...
 
static EFI_STATUS EFIAPI usbio_interrupt_callback (VOID *data, UINTN len, VOID *context, UINT32 status)
 Interrupt endpoint callback. More...
 
static int usbio_interrupt_open (struct usbio_endpoint *endpoint)
 Open interrupt endpoint. More...
 
static void usbio_interrupt_close (struct usbio_endpoint *endpoint)
 Close interrupt endpoint. More...
 
static void usbio_interrupt_poll (struct usbio_endpoint *endpoint)
 Poll interrupt endpoint. More...
 
static int usbio_endpoint_open (struct usb_endpoint *ep)
 Open endpoint. More...
 
static void usbio_endpoint_close (struct usb_endpoint *ep)
 Close endpoint. More...
 
static int usbio_endpoint_reset (struct usb_endpoint *ep __unused)
 Reset endpoint. More...
 
static int usbio_endpoint_mtu (struct usb_endpoint *ep __unused)
 Update MTU. More...
 
static int usbio_endpoint_enqueue (struct usb_endpoint *ep, struct io_buffer *iobuf, unsigned int flags)
 Enqueue transfer. More...
 
static int usbio_endpoint_message (struct usb_endpoint *ep, struct io_buffer *iobuf)
 Enqueue message transfer. More...
 
static int usbio_endpoint_stream (struct usb_endpoint *ep, struct io_buffer *iobuf, int zlp)
 Enqueue stream transfer. More...
 
static void usbio_endpoint_poll (struct usbio_endpoint *endpoint)
 Poll for completions. More...
 
static int usbio_device_open (struct usb_device *usb)
 Open device. More...
 
static void usbio_device_close (struct usb_device *usb __unused)
 Close device. More...
 
static int usbio_device_address (struct usb_device *usb __unused)
 Assign device address. More...
 
static int usbio_hub_open (struct usb_hub *hub)
 Open hub. More...
 
static void usbio_hub_close (struct usb_hub *hub __unused)
 Close hub. More...
 
static int usbio_root_open (struct usb_hub *hub __unused)
 Open root hub. More...
 
static void usbio_root_close (struct usb_hub *hub __unused)
 Close root hub. More...
 
static int usbio_root_enable (struct usb_hub *hub __unused, struct usb_port *port __unused)
 Enable port. More...
 
static int usbio_root_disable (struct usb_hub *hub __unused, struct usb_port *port __unused)
 Disable port. More...
 
static int usbio_root_speed (struct usb_hub *hub __unused, struct usb_port *port)
 Update root hub port speed. More...
 
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. More...
 
static int usbio_bus_open (struct usb_bus *bus __unused)
 Open USB bus. More...
 
static void usbio_bus_close (struct usb_bus *bus __unused)
 Close USB bus. More...
 
static void usbio_bus_poll (struct usb_bus *bus)
 Poll USB bus. More...
 
static int usbio_supported (EFI_HANDLE handle)
 Check to see if driver supports a device. More...
 
static int usbio_config (struct usbio_device *usbio)
 Fetch configuration descriptor. More...
 
static int usbio_path (struct usbio_device *usbio)
 Construct device path for opening other interfaces. More...
 
static int usbio_interfaces (struct usbio_device *usbio)
 Construct interface list. More...
 
static int usbio_start (struct efi_device *efidev)
 Attach driver to device. More...
 
static void usbio_stop (struct efi_device *efidev)
 Detach driver from device. More...
 
struct efi_driver usbio_driver __efi_driver (EFI_DRIVER_NORMAL)
 EFI USB I/O driver. More...
 

Variables

static struct usbio_operations usbio_control_operations
 Control endpoint operations. More...
 
static struct usbio_operations usbio_bulk_in_operations
 Bulk endpoint operations. More...
 
static struct usbio_operations usbio_bulk_out_operations
 Bulk endpoint operations. More...
 
static struct usbio_operations usbio_interrupt_operations
 Interrupt endpoint operations. More...
 
static struct usb_host_operations usbio_operations
 USB I/O host controller driver operations. More...
 

Detailed Description

EFI_USB_IO_PROTOCOL pseudo Host Controller Interface driver.

The EFI_USB_IO_PROTOCOL is an almost unbelievably poorly designed abstraction of a USB device. It would be just about forgivable for an API to support only synchronous operation for bulk OUT endpoints. It is imbecilic to support only synchronous operation for bulk IN endpoints. This apparently intern-designed API throttles a typical NIC down to 1.5% of its maximum throughput. That isn't a typo. It really is that slow.

We can't even work around this stupidity by talking to the host controller abstraction directly, because an identical limitation exists in the EFI_USB2_HC_PROTOCOL.

Unless you derive therapeutic value from watching download progress indicators lethargically creep through every single integer from 0 to 100, you should use iPXE's native USB host controller drivers instead. (Or just upgrade from UEFI to "legacy" BIOS, which will produce a similar speed increase.)

For added excitement, the EFI_USB_IO_PROTOCOL makes the (demonstrably incorrect) assumption that a USB driver needs to attach to exactly one interface within a USB device, and provides a helper method to retrieve "the" interface descriptor. Since pretty much every USB network device requires binding to a pair of control+data interfaces, this aspect of EFI_USB_IO_PROTOCOL is of no use to us.

We have our own existing code for reading USB descriptors, so we don't actually care that the UsbGetInterfaceDescriptor() method provided by EFI_USB_IO_PROTOCOL is useless for network devices. We can read the descriptors ourselves (via UsbControlTransfer()) and get all of the information we need this way. We can even work around the fact that EFI_USB_IO_PROTOCOL provides separate handles for each of the two interfaces comprising our network device.

However, if we discover that we need to select an alternative device configuration (e.g. for devices exposing both RNDIS and ECM), then all hell breaks loose. EFI_USB_IO_PROTOCOL starts to panic because its cached interface and endpoint descriptors will no longer be valid. As mentioned above, the cached descriptors are useless for network devices anyway so we really don't care about this, but EFI_USB_IO_PROTOCOL certainly cares. It prints out a manic warning message containing no fewer than six exclamation marks and then literally commits seppuku in the middle of the UsbControlTransfer() method by attempting to uninstall itself. Quite how the caller is supposed to react when asked to stop using the EFI_USB_IO_PROTOCOL instance while in the middle of an uninterruptible call to said instance is left as an exercise for the interested reader.

There is no sensible way to work around this, so we just preemptively fail if asked to change the device configuration, on the basis that reporting a sarcastic error message is often preferable to jumping through a NULL pointer and crashing the system.

Definition in file usbio.c.

Macro Definition Documentation

◆ ENOTSUP_MORONIC_SPECIFICATION

#define ENOTSUP_MORONIC_SPECIFICATION   __einfo_error ( EINFO_ENOTSUP_MORONIC_SPECIFICATION )

Definition at line 100 of file usbio.c.

◆ EINFO_ENOTSUP_MORONIC_SPECIFICATION

#define EINFO_ENOTSUP_MORONIC_SPECIFICATION
Value:
"EFI_USB_IO_PROTOCOL was designed by morons" )
#define EINFO_ENOTSUP
Definition: errno.h:590
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:180

Definition at line 102 of file usbio.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ usbio_interface()

static int usbio_interface ( struct usbio_device usbio,
struct usb_endpoint ep 
)
static

Determine endpoint interface number.

Parameters
usbioUSB I/O device
epUSB Endpoint
Return values
interfaceInterface number, or negative error

Definition at line 120 of file usbio.c.

121  {
122  EFI_HANDLE handle = usbio->handle;
123  struct usb_device *usb = ep->usb;
127  struct usb_function *func;
128  unsigned int i;
129 
130  /* The control endpoint is not part of a described interface */
131  if ( ep->address == USB_EP0_ADDRESS )
132  return 0;
133 
134  /* Iterate over all interface descriptors looking for a match */
135  config = usbio->config;
137 
138  /* Skip non-interface descriptors */
139  if ( interface->header.type != USB_INTERFACE_DESCRIPTOR )
140  continue;
141 
142  /* Iterate over all endpoint descriptors looking for a match */
143  for_each_interface_descriptor ( endpoint, config, interface ) {
144 
145  /* Skip non-endpoint descriptors */
146  if ( endpoint->header.type != USB_ENDPOINT_DESCRIPTOR )
147  continue;
148 
149  /* Check endpoint address */
150  if ( endpoint->endpoint != ep->address )
151  continue;
152 
153  /* Check interface belongs to this function */
154  list_for_each_entry ( func, &usb->functions, list ) {
155 
156  /* Skip non-matching functions */
157  if ( func->interface[0] != usbio->first )
158  continue;
159 
160  /* Iterate over all interfaces for a match */
161  for ( i = 0 ; i < func->desc.count ; i++ ) {
162  if ( interface->interface ==
163  func->interface[i] )
164  return interface->interface;
165  }
166  }
167  }
168  }
169 
170  DBGC ( usbio, "USBIO %s cannot find interface for %s",
172  return -ENOENT;
173 }
uint8_t interface[0]
List of interface numbers.
Definition: usb.h:680
unsigned int count
Number of interfaces.
Definition: usb.h:648
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
Standard Interface Descriptor USB 2.0 spec, Section 9.6.5.
Definition: Usb.h:147
#define for_each_interface_descriptor(desc, config, interface)
Iterate over all configuration descriptors within an interface descriptor.
Definition: usb.h:379
#define for_each_config_descriptor(desc, config)
Iterate over all configuration descriptors.
Definition: usb.h:371
uint8_t endpoint
Endpoint address.
Definition: usb.h:253
A USB interface descriptor.
Definition: usb.h:230
An object interface.
Definition: interface.h:109
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
A USB device.
Definition: usb.h:706
uint8_t type
Descriptor type.
Definition: usb.h:162
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
uint8_t first
First interface number.
Definition: usbio.h:143
Standard Endpoint Descriptor USB 2.0 spec, Section 9.6.6.
Definition: Usb.h:163
struct usb_device * usb
USB device.
Definition: usb.h:661
struct usb_configuration_descriptor * config
Configuration descriptor.
Definition: usbio.h:135
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
Definition: usb.c:220
A USB configuration descriptor.
Definition: usb.h:195
A USB endpoint descriptor.
Definition: usb.h:249
uint8_t config
Configuration value.
Definition: usb.h:203
struct usb_endpoint * ep[32]
Endpoint list.
Definition: usb.h:728
struct usb_descriptor_header header
Descriptor header.
Definition: usb.h:251
struct usb_function_descriptor desc
Function descriptor.
Definition: usb.h:663
struct usb_device * usb
USB device.
Definition: usb.h:391
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
A USB function.
Definition: usb.h:657
struct list_head functions
List of functions.
Definition: usb.h:720
uint16_t handle
Handle.
Definition: smbios.h:16
#define USB_EP0_ADDRESS
Control endpoint address.
Definition: usb.h:486
struct list_head list
List of functions within this USB device.
Definition: usb.h:667
uint8_t interface
Interface number.
Definition: usb.h:234
unsigned int address
Endpoint address.
Definition: usb.h:393
Definition: efi.h:55

References usb_endpoint::address, usbio_device::config, usb_configuration_descriptor::config, usb_function_descriptor::count, DBGC, usb_function::desc, efi_handle_name(), usb_endpoint_descriptor::endpoint, ENOENT, usb_device::ep, usbio_device::first, for_each_config_descriptor, for_each_interface_descriptor, usb_device::functions, handle, usbio_device::handle, usb_endpoint_descriptor::header, usb_interface_descriptor::interface, usb_function::interface, usb_function::list, list_for_each_entry, usb_descriptor_header::type, usb_endpoint::usb, usb_function::usb, usb_endpoint_name(), and USB_EP0_ADDRESS.

◆ usbio_open()

static int usbio_open ( struct usbio_device usbio,
unsigned int  interface 
)
static

Open USB I/O interface.

Parameters
usbioUSB I/O device
interfaceInterface number
Return values
rcReturn status code

Definition at line 182 of file usbio.c.

182  {
184  EFI_HANDLE handle = usbio->handle;
185  struct usbio_interface *intf = &usbio->interface[interface];
188  USB_DEVICE_PATH *usbpath;
189  union {
190  void *interface;
192  } u;
193  EFI_STATUS efirc;
194  int rc;
195 
196  /* Sanity check */
197  assert ( interface < usbio->config->interfaces );
198 
199  /* If interface is already open, just increment the usage count */
200  if ( intf->count ) {
201  intf->count++;
202  return 0;
203  }
204 
205  /* Construct device path for this interface */
206  path = usbio->path;
207  usbpath = usbio->usbpath;
208  usbpath->InterfaceNumber = interface;
209  end = efi_devpath_end ( path );
210 
211  /* Locate handle for this endpoint's interface */
212  if ( ( efirc = bs->LocateDevicePath ( &efi_usb_io_protocol_guid, &path,
213  &intf->handle ) ) != 0 ) {
214  rc = -EEFI ( efirc );
215  DBGC ( usbio, "USBIO %s could not locate ",
216  efi_handle_name ( handle ) );
217  DBGC ( usbio, "%s: %s\n",
218  efi_devpath_text ( usbio->path ), strerror ( rc ) );
219  return rc;
220  }
221 
222  /* Check that expected path was located */
223  if ( path != end ) {
224  DBGC ( usbio, "USBIO %s located incomplete ",
225  efi_handle_name ( handle ) );
226  DBGC ( usbio, "%s\n", efi_handle_name ( intf->handle ) );
227  return -EXDEV;
228  }
229 
230  /* Open USB I/O protocol on this handle */
231  if ( ( efirc = bs->OpenProtocol ( intf->handle,
233  &u.interface, efi_image_handle,
234  intf->handle,
237  rc = -EEFI ( efirc );
238  DBGC ( usbio, "USBIO %s cannot open ",
239  efi_handle_name ( handle ) );
240  DBGC ( usbio, "%s: %s\n",
241  efi_handle_name ( intf->handle ), strerror ( rc ) );
242  DBGC_EFI_OPENERS ( usbio, intf->handle,
244  return rc;
245  }
246  intf->io = u.io;
247 
248  /* Increment usage count */
249  intf->count++;
250 
251  return 0;
252 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
A USB I/O protocol interface.
Definition: usbio.h:112
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
#define DBGC(...)
Definition: compiler.h:505
#define EFI_OPEN_PROTOCOL_BY_DRIVER
Definition: UefiSpec.h:1274
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
#define EFI_OPEN_PROTOCOL_EXCLUSIVE
Definition: UefiSpec.h:1275
#define DBGC_EFI_OPENERS(...)
Definition: efi.h:262
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:116
#define EXDEV
Improper link.
Definition: errno.h:684
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An object interface.
Definition: interface.h:109
unsigned int count
Usage count.
Definition: usbio.h:118
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:366
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI_GUID efi_usb_io_protocol_guid
USB I/O protocol GUID.
Definition: efi_guid.c:296
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:33
UINT8 InterfaceNumber
USB Interface Number.
Definition: DevicePath.h:422
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
Definition: usbio.h:138
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition: usbio.h:145
USB_DEVICE_PATH * usbpath
Final component of USB device path.
Definition: usbio.h:140
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
union @17 u
uint32_t end
Ending offset.
Definition: netvsc.h:18
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:114
uint16_t handle
Handle.
Definition: smbios.h:16
Definition: efi.h:55
EFI_LOCATE_DEVICE_PATH LocateDevicePath
Definition: UefiSpec.h:1877
EFI_DEVICE_PATH_PROTOCOL * efi_devpath_end(EFI_DEVICE_PATH_PROTOCOL *path)
Find end of device path.
Definition: efi_utils.c:41

References assert(), EFI_SYSTEM_TABLE::BootServices, usbio_interface::count, DBGC, DBGC_EFI_OPENERS, EEFI, efi_devpath_end(), efi_devpath_text(), efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_BY_DRIVER, EFI_OPEN_PROTOCOL_EXCLUSIVE, efi_systab, efi_usb_io_protocol_guid, end, EXDEV, handle, usbio_interface::handle, usbio_device::handle, usbio_device::interface, USB_DEVICE_PATH::InterfaceNumber, usbio_interface::io, EFI_BOOT_SERVICES::LocateDevicePath, EFI_BOOT_SERVICES::OpenProtocol, usbio_device::path, rc, strerror(), u, and usbio_device::usbpath.

Referenced by usbio_control_poll(), and usbio_endpoint_open().

◆ usbio_close()

static void usbio_close ( struct usbio_device usbio,
unsigned int  interface 
)
static

Close USB I/O interface.

Parameters
usbioUSB I/O device
interfaceInterface number

Definition at line 260 of file usbio.c.

260  {
262  struct usbio_interface *intf = &usbio->interface[interface];
263 
264  /* Sanity checks */
265  assert ( interface < usbio->config->interfaces );
266  assert ( intf->count > 0 );
267 
268  /* Decrement usage count */
269  intf->count--;
270 
271  /* Do nothing if interface is still in use */
272  if ( intf->count )
273  return;
274 
275  /* Close USB I/O protocol */
277  efi_image_handle, intf->handle );
278 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
A USB I/O protocol interface.
Definition: usbio.h:112
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An object interface.
Definition: interface.h:109
unsigned int count
Usage count.
Definition: usbio.h:118
EFI_GUID efi_usb_io_protocol_guid
USB I/O protocol GUID.
Definition: efi_guid.c:296
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:33
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition: usbio.h:145
EFI_SYSTEM_TABLE * efi_systab
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:114

References assert(), EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, usbio_interface::count, efi_image_handle, efi_systab, efi_usb_io_protocol_guid, usbio_interface::handle, and usbio_device::interface.

Referenced by usbio_control_poll(), usbio_endpoint_close(), and usbio_endpoint_open().

◆ usbio_control_open()

static int usbio_control_open ( struct usbio_endpoint *endpoint  __unused)
static

Open control endpoint.

Parameters
endpointEndpoint
Return values
rcReturn status code

Definition at line 293 of file usbio.c.

293  {
294 
295  /* Nothing to do */
296  return 0;
297 }

◆ usbio_control_close()

static void usbio_control_close ( struct usbio_endpoint *endpoint  __unused)
static

Close control endpoint.

Parameters
endpointEndpoint

Definition at line 304 of file usbio.c.

304  {
305 
306  /* Nothing to do */
307 }

◆ usbio_control_poll()

static void usbio_control_poll ( struct usbio_endpoint endpoint)
static

Poll control endpoint.

Parameters
endpointEndpoint

Definition at line 314 of file usbio.c.

314  {
315  struct usbio_device *usbio = endpoint->usbio;
316  struct usb_endpoint *ep = endpoint->ep;
317  EFI_HANDLE handle = usbio->handle;
319  union {
320  struct usb_setup_packet setup;
322  } *msg;
324  struct io_buffer *iobuf;
325  unsigned int index;
326  unsigned int flags;
327  unsigned int recipient;
328  unsigned int interface;
330  void *data;
331  size_t len;
332  UINT32 status;
333  EFI_STATUS efirc;
334  int rc;
335 
336  /* Do nothing if ring is empty */
337  if ( endpoint->cons == endpoint->prod )
338  return;
339 
340  /* Consume next transfer */
341  index = ( endpoint->cons++ % USBIO_RING_COUNT );
342  iobuf = endpoint->iobuf[index];
343  flags = endpoint->flags[index];
344 
345  /* Sanity check */
346  if ( ! ( flags & USBIO_MESSAGE ) ) {
347  DBGC ( usbio, "USBIO %s %s non-message transfer\n",
349  rc = -ENOTSUP;
350  goto err_not_message;
351  }
352 
353  /* Construct transfer */
354  msg = iob_push ( iobuf, sizeof ( *msg ) );
355  iob_pull ( iobuf, sizeof ( *msg ) );
356  request = le16_to_cpu ( msg->setup.request );
357  len = iob_len ( iobuf );
358  if ( len ) {
359  data = iobuf->data;
360  direction = ( ( request & USB_DIR_IN ) ?
362  } else {
363  data = NULL;
365  }
366 
367  /* Determine interface for this transfer */
368  recipient = ( request & USB_RECIP_MASK );
369  if ( recipient == USB_RECIP_INTERFACE ) {
370  /* Recipient is an interface: use interface number directly */
371  interface = le16_to_cpu ( msg->setup.index );
372  } else {
373  /* Route all other requests through the first interface */
374  interface = 0;
375  }
376 
377  /* Open interface */
378  if ( ( rc = usbio_open ( usbio, interface ) ) != 0 )
379  goto err_open;
380  io = usbio->interface[interface].io;
381 
382  /* Due to the design of EFI_USB_IO_PROTOCOL, attempting to set
383  * the configuration to a non-default value is basically a
384  * self-destruct button.
385  */
386  if ( ( request == USB_SET_CONFIGURATION ) &&
387  ( le16_to_cpu ( msg->setup.value ) != usbio->config->config ) ) {
389  DBGC ( usbio, "USBIO %s cannot change configuration: %s\n",
390  efi_handle_name ( handle ), strerror ( rc ) );
391  goto err_moronic_specification;
392  }
393 
394  /* Submit transfer */
395  if ( ( efirc = io->UsbControlTransfer ( io, &msg->efi, direction, 0,
396  data, len, &status ) ) != 0 ) {
397  rc = -EEFI ( efirc );
398  DBGC ( usbio, "USBIO %s %s could not submit control transfer ",
400  DBGC ( usbio, "via %s: %s (status %04x)\n",
402  strerror ( rc ), status );
403  goto err_transfer;
404  }
405 
406  /* Close interface */
407  usbio_close ( usbio, interface );
408 
409  /* Complete transfer */
410  usb_complete ( ep, iobuf );
411 
412  return;
413 
414  err_transfer:
415  err_moronic_specification:
416  usbio_close ( usbio, interface );
417  err_open:
418  err_not_message:
419  usb_complete_err ( ep, iobuf, rc );
420 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:98
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
#define USB_RECIP_MASK
Request recipient mask.
Definition: usb.h:95
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
#define USB_RECIP_INTERFACE
Request recipient is an interface.
Definition: usb.h:101
#define iob_push(iobuf, len)
Definition: iobuf.h:80
#define DBGC(...)
Definition: compiler.h:505
unsigned int UINT32
Definition: ProcessorBind.h:56
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
uint8_t direction
Direction.
Definition: ena.h:14
EFI_USB_DATA_DIRECTION
USB data transfer direction.
Definition: UsbIo.h:52
static void usbio_close(struct usbio_device *usbio, unsigned int interface)
Close USB I/O interface.
Definition: usbio.c:260
#define USBIO_RING_COUNT
USB I/O ring buffer size.
Definition: usbio.h:50
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:116
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
uint8_t flags[USBIO_RING_COUNT]
Flags.
Definition: usbio.h:77
uint8_t status
Status.
Definition: ena.h:16
A USB endpoint.
Definition: usb.h:389
Format of Setup Data for USB Device Requests USB 2.0 spec, Section 9.3.
Definition: Usb.h:99
An object interface.
Definition: interface.h:109
#define USB_DIR_IN
Data transfer is from device to host.
Definition: usb.h:83
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
#define le16_to_cpu(value)
Definition: byteswap.h:112
A USB setup data packet.
Definition: usb.h:68
struct usb_configuration_descriptor * config
Configuration descriptor.
Definition: usbio.h:135
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
Definition: usb.c:220
EFI_USB_IO_CONTROL_TRANSFER UsbControlTransfer
Definition: UsbIo.h:489
unsigned int prod
Producer counter.
Definition: usbio.h:71
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition: usbio.h:145
uint32_t len
Length.
Definition: ena.h:14
uint8_t config
Configuration value.
Definition: usb.h:203
unsigned int cons
Consumer counter.
Definition: usbio.h:73
static void usb_complete(struct usb_endpoint *ep, struct io_buffer *iobuf)
Complete transfer (without error)
Definition: usb.h:1064
void * data
Start of data.
Definition: iobuf.h:44
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
u8 request[0]
List of IEs requested.
Definition: ieee80211.h:16
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
A USB I/O protocol device.
Definition: usbio.h:126
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:114
uint16_t handle
Handle.
Definition: smbios.h:16
#define USB_SET_CONFIGURATION
Set configuration.
Definition: usb.h:131
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static int usbio_open(struct usbio_device *usbio, unsigned int interface)
Open USB I/O interface.
Definition: usbio.c:182
This is a message transfer.
Definition: usbio.h:86
struct io_buffer * iobuf[USBIO_RING_COUNT]
I/O buffers.
Definition: usbio.h:75
Definition: efi.h:55
void usb_complete_err(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer (possibly with error)
Definition: usb.c:569
#define ENOTSUP_MORONIC_SPECIFICATION
Definition: usbio.c:100
A persistent I/O buffer.
Definition: iobuf.h:32
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285
uint8_t flags
Flags.
Definition: ena.h:18

References usbio_device::config, usb_configuration_descriptor::config, usbio_endpoint::cons, data, io_buffer::data, DBGC, direction, EEFI, efi_handle_name(), EfiUsbDataIn, EfiUsbDataOut, EfiUsbNoData, ENOTSUP, ENOTSUP_MORONIC_SPECIFICATION, usbio_endpoint::ep, flags, usbio_endpoint::flags, handle, usbio_interface::handle, usbio_device::handle, index, usbio_device::interface, usbio_interface::io, iob_len(), iob_pull, iob_push, usbio_endpoint::iobuf, le16_to_cpu, len, msg(), NULL, usbio_endpoint::prod, rc, request, status, strerror(), usb_complete(), usb_complete_err(), USB_DIR_IN, usb_endpoint_name(), USB_RECIP_INTERFACE, USB_RECIP_MASK, USB_SET_CONFIGURATION, _EFI_USB_IO_PROTOCOL::UsbControlTransfer, usbio_endpoint::usbio, usbio_close(), USBIO_MESSAGE, usbio_open(), and USBIO_RING_COUNT.

◆ usbio_bulk_in_open()

static int usbio_bulk_in_open ( struct usbio_endpoint *endpoint  __unused)
static

Open bulk IN endpoint.

Parameters
endpointEndpoint
Return values
rcReturn status code

Definition at line 442 of file usbio.c.

442  {
443 
444  /* Nothing to do */
445  return 0;
446 }

◆ usbio_bulk_in_close()

static void usbio_bulk_in_close ( struct usbio_endpoint *endpoint  __unused)
static

Close bulk IN endpoint.

Parameters
endpointEndpoint

Definition at line 453 of file usbio.c.

453  {
454 
455  /* Nothing to do */
456 }

◆ usbio_bulk_in_poll()

static void usbio_bulk_in_poll ( struct usbio_endpoint endpoint)
static

Poll bulk IN endpoint.

Parameters
endpointEndpoint

Definition at line 463 of file usbio.c.

463  {
464  struct usbio_device *usbio = endpoint->usbio;
465  struct usb_endpoint *ep = endpoint->ep;
466  EFI_USB_IO_PROTOCOL *io = endpoint->io;
467  EFI_HANDLE handle = usbio->handle;
468  struct io_buffer *iobuf;
469  unsigned int index;
470  UINTN len;
471  UINT32 status;
472  EFI_STATUS efirc;
473  int rc;
474 
475  /* Do nothing if ring is empty */
476  if ( endpoint->cons == endpoint->prod )
477  return;
478 
479  /* Attempt (but do not yet consume) next transfer */
480  index = ( endpoint->cons % USBIO_RING_COUNT );
481  iobuf = endpoint->iobuf[index];
482 
483  /* Construct transfer */
484  len = iob_len ( iobuf );
485 
486  /* Upon being turned on, the EFI_USB_IO_PROTOCOL did nothing
487  * for several minutes before firing a small ARP packet a few
488  * millimetres into the ether.
489  */
490  efirc = io->UsbBulkTransfer ( io, ep->address, iobuf->data,
491  &len, 1, &status );
492  if ( efirc == EFI_TIMEOUT )
493  return;
494 
495  /* Consume transfer */
496  endpoint->cons++;
497 
498  /* Check for failure */
499  if ( efirc != 0 ) {
500  rc = -EEFI ( efirc );
501  DBGC2 ( usbio, "USBIO %s %s could not submit bulk IN transfer: "
502  "%s (status %04x)\n", efi_handle_name ( handle ),
503  usb_endpoint_name ( ep ), strerror ( rc ), status );
504  usb_complete_err ( ep, iobuf, rc );
505  return;
506  }
507 
508  /* Update length */
509  iob_put ( iobuf, ( len - iob_len ( iobuf ) ) );
510 
511  /* Complete transfer */
512  usb_complete ( ep, iobuf );
513 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:116
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
unsigned int UINT32
Definition: ProcessorBind.h:56
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
#define USBIO_RING_COUNT
USB I/O ring buffer size.
Definition: usbio.h:50
uint8_t status
Status.
Definition: ena.h:16
A USB endpoint.
Definition: usb.h:389
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:68
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
UINT64 UINTN
Unsigned value of native width.
Definition: ProcessorBind.h:71
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
Definition: usb.c:220
unsigned int prod
Producer counter.
Definition: usbio.h:71
EFI_USB_IO_BULK_TRANSFER UsbBulkTransfer
Definition: UsbIo.h:490
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
unsigned int cons
Consumer counter.
Definition: usbio.h:73
static void usb_complete(struct usb_endpoint *ep, struct io_buffer *iobuf)
Complete transfer (without error)
Definition: usb.h:1064
void * data
Start of data.
Definition: iobuf.h:44
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
A USB I/O protocol device.
Definition: usbio.h:126
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
uint16_t handle
Handle.
Definition: smbios.h:16
unsigned int address
Endpoint address.
Definition: usb.h:393
struct io_buffer * iobuf[USBIO_RING_COUNT]
I/O buffers.
Definition: usbio.h:75
Definition: efi.h:55
void usb_complete_err(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer (possibly with error)
Definition: usb.c:569
#define EFI_TIMEOUT
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:138
A persistent I/O buffer.
Definition: iobuf.h:32

References usb_endpoint::address, usbio_endpoint::cons, io_buffer::data, DBGC2, EEFI, efi_handle_name(), EFI_TIMEOUT, usbio_endpoint::ep, handle, usbio_device::handle, index, usbio_endpoint::io, iob_len(), iob_put, usbio_endpoint::iobuf, len, usbio_endpoint::prod, rc, status, strerror(), usb_complete(), usb_complete_err(), usb_endpoint_name(), _EFI_USB_IO_PROTOCOL::UsbBulkTransfer, usbio_endpoint::usbio, and USBIO_RING_COUNT.

◆ usbio_bulk_out_open()

static int usbio_bulk_out_open ( struct usbio_endpoint *endpoint  __unused)
static

Open bulk OUT endpoint.

Parameters
endpointEndpoint
Return values
rcReturn status code

Definition at line 535 of file usbio.c.

535  {
536 
537  /* Nothing to do */
538  return 0;
539 }

◆ usbio_bulk_out_close()

static void usbio_bulk_out_close ( struct usbio_endpoint *endpoint  __unused)
static

Close bulk OUT endpoint.

Parameters
endpointEndpoint

Definition at line 546 of file usbio.c.

546  {
547 
548  /* Nothing to do */
549 }

◆ usbio_bulk_out_poll()

static void usbio_bulk_out_poll ( struct usbio_endpoint endpoint)
static

Poll bulk OUT endpoint.

Parameters
endpointEndpoint

Definition at line 556 of file usbio.c.

556  {
557  struct usbio_device *usbio = endpoint->usbio;
558  struct usb_endpoint *ep = endpoint->ep;
559  EFI_USB_IO_PROTOCOL *io = endpoint->io;
560  EFI_HANDLE handle = usbio->handle;
561  struct io_buffer *iobuf;
562  unsigned int index;
563  unsigned int flags;
564  UINTN len;
565  UINT32 status;
566  EFI_STATUS efirc;
567  int rc;
568 
569  /* Do nothing if ring is empty */
570  if ( endpoint->cons == endpoint->prod )
571  return;
572 
573  /* Consume next transfer */
574  index = ( endpoint->cons++ % USBIO_RING_COUNT );
575  iobuf = endpoint->iobuf[index];
576  flags = endpoint->flags[index];
577 
578  /* Construct transfer */
579  len = iob_len ( iobuf );
580 
581  /* Submit transfer */
582  if ( ( efirc = io->UsbBulkTransfer ( io, ep->address, iobuf->data,
583  &len, 0, &status ) ) != 0 ) {
584  rc = -EEFI ( efirc );
585  DBGC ( usbio, "USBIO %s %s could not submit bulk OUT transfer: "
586  "%s (status %04x)\n", efi_handle_name ( handle ),
587  usb_endpoint_name ( ep ), strerror ( rc ), status );
588  goto err;
589  }
590 
591  /* Update length */
592  iob_put ( iobuf, ( len - iob_len ( iobuf ) ) );
593 
594  /* Submit zero-length transfer if required */
595  len = 0;
596  if ( ( flags & USBIO_ZLEN ) &&
597  ( efirc = io->UsbBulkTransfer ( io, ep->address, NULL, &len, 0,
598  &status ) ) != 0 ) {
599  rc = -EEFI ( efirc );
600  DBGC ( usbio, "USBIO %s %s could not submit zero-length "
601  "transfer: %s (status %04x)\n",
603  strerror ( rc ), status );
604  goto err;
605  }
606 
607  /* Complete transfer */
608  usb_complete ( ep, iobuf );
609 
610  return;
611 
612  err:
613  usb_complete_err ( ep, iobuf, rc );
614 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:116
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
#define DBGC(...)
Definition: compiler.h:505
unsigned int UINT32
Definition: ProcessorBind.h:56
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
#define USBIO_RING_COUNT
USB I/O ring buffer size.
Definition: usbio.h:50
uint8_t flags[USBIO_RING_COUNT]
Flags.
Definition: usbio.h:77
uint8_t status
Status.
Definition: ena.h:16
A USB endpoint.
Definition: usb.h:389
This transfer requires zero-length packet termination.
Definition: usbio.h:88
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:68
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
UINT64 UINTN
Unsigned value of native width.
Definition: ProcessorBind.h:71
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
Definition: usb.c:220
unsigned int prod
Producer counter.
Definition: usbio.h:71
EFI_USB_IO_BULK_TRANSFER UsbBulkTransfer
Definition: UsbIo.h:490
uint32_t len
Length.
Definition: ena.h:14
unsigned int cons
Consumer counter.
Definition: usbio.h:73
static void usb_complete(struct usb_endpoint *ep, struct io_buffer *iobuf)
Complete transfer (without error)
Definition: usb.h:1064
void * data
Start of data.
Definition: iobuf.h:44
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
A USB I/O protocol device.
Definition: usbio.h:126
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned int address
Endpoint address.
Definition: usb.h:393
struct io_buffer * iobuf[USBIO_RING_COUNT]
I/O buffers.
Definition: usbio.h:75
Definition: efi.h:55
void usb_complete_err(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer (possibly with error)
Definition: usb.c:569
A persistent I/O buffer.
Definition: iobuf.h:32
uint8_t flags
Flags.
Definition: ena.h:18

References usb_endpoint::address, usbio_endpoint::cons, io_buffer::data, DBGC, EEFI, efi_handle_name(), usbio_endpoint::ep, flags, usbio_endpoint::flags, handle, usbio_device::handle, index, usbio_endpoint::io, iob_len(), iob_put, usbio_endpoint::iobuf, len, NULL, usbio_endpoint::prod, rc, status, strerror(), usb_complete(), usb_complete_err(), usb_endpoint_name(), _EFI_USB_IO_PROTOCOL::UsbBulkTransfer, usbio_endpoint::usbio, USBIO_RING_COUNT, and USBIO_ZLEN.

◆ usbio_interrupt_callback()

static EFI_STATUS EFIAPI usbio_interrupt_callback ( VOID data,
UINTN  len,
VOID context,
UINT32  status 
)
static

Interrupt endpoint callback.

Parameters
dataReceived data
lenLength of received data
contextCallback context
statusTransfer status
Return values
efircEFI status code

Definition at line 663 of file usbio.c.

665  {
666  struct usbio_interrupt_ring *intr = context;
667  struct usbio_endpoint *endpoint = intr->endpoint;
668  struct usbio_device *usbio = endpoint->usbio;
669  struct usb_endpoint *ep = endpoint->ep;
670  EFI_HANDLE handle = usbio->handle;
671  unsigned int fill;
672  unsigned int index;
673 
674  /* Sanity check */
675  assert ( len <= ep->mtu );
676 
677  /* Do nothing if ring is empty */
678  fill = ( intr->prod - intr->cons );
679  if ( fill >= USBIO_INTR_COUNT ) {
680  DBGC ( usbio, "USBIO %s %s dropped interrupt completion\n",
682  return 0;
683  }
684 
685  /* Do nothing if transfer was unsuccessful */
686  if ( status != 0 ) {
687  DBGC ( usbio, "USBIO %s %s interrupt completion status %04x\n",
689  status );
690  return 0; /* Unclear what failure actually means here */
691  }
692 
693  /* Copy data to buffer and increment producer counter */
694  index = ( intr->prod % USBIO_INTR_COUNT );
695  memcpy ( intr->data[index], data, len );
696  intr->len[index] = len;
697  intr->prod++;
698 
699  return 0;
700 }
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
#define DBGC(...)
Definition: compiler.h:505
A USB interrupt ring buffer.
Definition: usbio.h:33
uint8_t status
Status.
Definition: ena.h:16
A USB endpoint.
Definition: usb.h:389
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint8_t intr
Interrupts enabled.
Definition: ena.h:14
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
Definition: usb.c:220
A USB I/O endpoint.
Definition: usbio.h:53
#define USBIO_INTR_COUNT
USB I/O interrupt ring buffer size.
Definition: usbio.h:30
uint32_t len
Length.
Definition: ena.h:14
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
uint8_t fill
Length pair.
Definition: deflate.h:12
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
A USB I/O protocol device.
Definition: usbio.h:126
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
uint16_t handle
Handle.
Definition: smbios.h:16
Definition: efi.h:55

References assert(), data, DBGC, efi_handle_name(), usbio_endpoint::ep, fill, handle, usbio_device::handle, index, intr, len, memcpy(), mtu, status, usb_endpoint_name(), usbio_endpoint::usbio, and USBIO_INTR_COUNT.

Referenced by usbio_interrupt_open().

◆ usbio_interrupt_open()

static int usbio_interrupt_open ( struct usbio_endpoint endpoint)
static

Open interrupt endpoint.

Parameters
endpointEndpoint
Return values
rcReturn status code

Definition at line 708 of file usbio.c.

708  {
709  struct usbio_device *usbio = endpoint->usbio;
710  struct usbio_interrupt_ring *intr;
711  struct usb_endpoint *ep = endpoint->ep;
712  EFI_USB_IO_PROTOCOL *io = endpoint->io;
713  EFI_HANDLE handle = usbio->handle;
714  unsigned int interval;
715  unsigned int i;
716  void *data;
717  EFI_STATUS efirc;
718  int rc;
719 
720  /* Allocate interrupt ring buffer */
721  intr = zalloc ( sizeof ( *intr ) + ( USBIO_INTR_COUNT * ep->mtu ) );
722  if ( ! intr ) {
723  rc = -ENOMEM;
724  goto err_alloc;
725  }
726  endpoint->intr = intr;
727  intr->endpoint = endpoint;
728  data = ( ( ( void * ) intr ) + sizeof ( *intr ) );
729  for ( i = 0 ; i < USBIO_INTR_COUNT ; i++ ) {
730  intr->data[i] = data;
731  data += ep->mtu;
732  }
733 
734  /* Determine polling interval */
735  interval = ( ep->interval >> 3 /* microframes -> milliseconds */ );
736  if ( ! interval )
737  interval = 1; /* May not be zero */
738 
739  /* Add to periodic schedule */
740  if ( ( efirc = io->UsbAsyncInterruptTransfer ( io, ep->address, TRUE,
741  interval, ep->mtu,
743  intr ) ) != 0 ) {
744  rc = -EEFI ( efirc );
745  DBGC ( usbio, "USBIO %s %s could not schedule interrupt "
746  "transfer: %s\n", efi_handle_name ( handle ),
747  usb_endpoint_name ( ep ), strerror ( rc ) );
748  goto err_schedule;
749  }
750 
751  return 0;
752 
753  io->UsbAsyncInterruptTransfer ( io, ep->address, FALSE, 0, 0,
754  NULL, NULL );
755  err_schedule:
756  free ( intr );
757  err_alloc:
758  return rc;
759 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct usbio_interrupt_ring * intr
Interrupt ring buffer (if applicable)
Definition: usbio.h:80
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER UsbAsyncInterruptTransfer
Definition: UsbIo.h:491
#define DBGC(...)
Definition: compiler.h:505
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
A USB interrupt ring buffer.
Definition: usbio.h:33
#define ENOMEM
Not enough space.
Definition: errno.h:534
A USB endpoint.
Definition: usb.h:389
uint8_t intr
Interrupts enabled.
Definition: ena.h:14
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:68
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
Definition: usb.c:220
#define TRUE
Definition: tlan.h:46
size_t mtu
Maximum transfer size.
Definition: usb.h:397
#define USBIO_INTR_COUNT
USB I/O interrupt ring buffer size.
Definition: usbio.h:30
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
unsigned int interval
Interval (in microframes)
Definition: usb.h:401
#define FALSE
Definition: tlan.h:45
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
static EFI_STATUS EFIAPI usbio_interrupt_callback(VOID *data, UINTN len, VOID *context, UINT32 status)
Interrupt endpoint callback.
Definition: usbio.c:663
A USB I/O protocol device.
Definition: usbio.h:126
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned int address
Endpoint address.
Definition: usb.h:393
Definition: efi.h:55

References usb_endpoint::address, data, DBGC, EEFI, efi_handle_name(), ENOMEM, usbio_endpoint::ep, FALSE, free, handle, usbio_device::handle, usb_endpoint::interval, intr, usbio_endpoint::intr, usbio_endpoint::io, usb_endpoint::mtu, NULL, rc, strerror(), TRUE, usb_endpoint_name(), _EFI_USB_IO_PROTOCOL::UsbAsyncInterruptTransfer, usbio_endpoint::usbio, usbio_interrupt_callback(), USBIO_INTR_COUNT, and zalloc().

◆ usbio_interrupt_close()

static void usbio_interrupt_close ( struct usbio_endpoint endpoint)
static

Close interrupt endpoint.

Parameters
endpointEndpoint

Definition at line 766 of file usbio.c.

766  {
767  struct usb_endpoint *ep = endpoint->ep;
768  EFI_USB_IO_PROTOCOL *io = endpoint->io;
769 
770  /* Remove from periodic schedule */
771  io->UsbAsyncInterruptTransfer ( io, ep->address, FALSE, 0, 0,
772  NULL, NULL );
773 
774  /* Free interrupt ring buffer */
775  free ( endpoint->intr );
776 }
struct usbio_interrupt_ring * intr
Interrupt ring buffer (if applicable)
Definition: usbio.h:80
EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER UsbAsyncInterruptTransfer
Definition: UsbIo.h:491
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
A USB endpoint.
Definition: usb.h:389
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:68
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define FALSE
Definition: tlan.h:45
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned int address
Endpoint address.
Definition: usb.h:393

References usb_endpoint::address, usbio_endpoint::ep, FALSE, free, usbio_endpoint::intr, usbio_endpoint::io, NULL, and _EFI_USB_IO_PROTOCOL::UsbAsyncInterruptTransfer.

◆ usbio_interrupt_poll()

static void usbio_interrupt_poll ( struct usbio_endpoint endpoint)
static

Poll interrupt endpoint.

Parameters
endpointEndpoint

Definition at line 783 of file usbio.c.

783  {
785  struct usb_endpoint *ep = endpoint->ep;
786  struct io_buffer *iobuf;
787  unsigned int index;
788  unsigned int intr_index;
789  size_t len;
790 
791  /* Do nothing if ring is empty */
792  if ( endpoint->cons == endpoint->prod )
793  return;
794 
795  /* Do nothing if interrupt ring is empty */
796  if ( intr->cons == intr->prod )
797  return;
798 
799  /* Consume next transfer */
800  index = ( endpoint->cons++ % USBIO_RING_COUNT );
801  iobuf = endpoint->iobuf[index];
802 
803  /* Populate I/O buffer */
804  intr_index = ( intr->cons++ % USBIO_INTR_COUNT );
805  len = intr->len[intr_index];
806  assert ( len <= iob_len ( iobuf ) );
807  iob_put ( iobuf, ( len - iob_len ( iobuf ) ) );
808  memcpy ( iobuf->data, intr->data[intr_index], len );
809 
810  /* Complete transfer */
811  usb_complete ( ep, iobuf );
812 }
struct usbio_interrupt_ring * intr
Interrupt ring buffer (if applicable)
Definition: usbio.h:80
#define iob_put(iobuf, len)
Definition: iobuf.h:116
#define USBIO_RING_COUNT
USB I/O ring buffer size.
Definition: usbio.h:50
A USB interrupt ring buffer.
Definition: usbio.h:33
A USB endpoint.
Definition: usb.h:389
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint8_t intr
Interrupts enabled.
Definition: ena.h:14
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
struct usbio_endpoint * endpoint
USB I/O endpoint.
Definition: usbio.h:35
unsigned int prod
Producer counter.
Definition: usbio.h:71
#define USBIO_INTR_COUNT
USB I/O interrupt ring buffer size.
Definition: usbio.h:30
uint32_t len
Length.
Definition: ena.h:14
unsigned int cons
Consumer counter.
Definition: usbio.h:73
static void usb_complete(struct usb_endpoint *ep, struct io_buffer *iobuf)
Complete transfer (without error)
Definition: usb.h:1064
void * data
Start of data.
Definition: iobuf.h:44
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
struct io_buffer * iobuf[USBIO_RING_COUNT]
I/O buffers.
Definition: usbio.h:75
A persistent I/O buffer.
Definition: iobuf.h:32

References assert(), usbio_endpoint::cons, io_buffer::data, usbio_interrupt_ring::endpoint, usbio_endpoint::ep, index, intr, usbio_endpoint::intr, iob_len(), iob_put, usbio_endpoint::iobuf, len, memcpy(), usbio_endpoint::prod, usb_complete(), USBIO_INTR_COUNT, and USBIO_RING_COUNT.

◆ usbio_endpoint_open()

static int usbio_endpoint_open ( struct usb_endpoint ep)
static

Open endpoint.

Parameters
epUSB endpoint
Return values
rcReturn status code

Definition at line 834 of file usbio.c.

834  {
835  struct usb_bus *bus = ep->usb->port->hub->bus;
836  struct usbio_device *usbio = usb_bus_get_hostdata ( bus );
837  struct usbio_endpoint *endpoint;
839  unsigned int attr = ( ep->attributes & USB_ENDPOINT_ATTR_TYPE_MASK );
840  int interface;
841  int rc;
842 
843  /* Allocate and initialise structure */
844  endpoint = zalloc ( sizeof ( *endpoint ) );
845  if ( ! endpoint ) {
846  rc = -ENOMEM;
847  goto err_alloc;
848  }
849  usb_endpoint_set_hostdata ( ep, endpoint );
850  endpoint->usbio = usbio;
851  endpoint->ep = ep;
852 
853  /* Identify endpoint operations */
854  if ( attr == USB_ENDPOINT_ATTR_CONTROL ) {
855  endpoint->op = &usbio_control_operations;
856  } else if ( attr == USB_ENDPOINT_ATTR_BULK ) {
857  endpoint->op = ( ( ep->address & USB_DIR_IN ) ?
860  } else if ( attr == USB_ENDPOINT_ATTR_INTERRUPT ) {
861  endpoint->op = &usbio_interrupt_operations;
862  } else {
863  rc = -ENOTSUP;
864  goto err_operations;
865  }
866 
867  /* Identify interface for this endpoint */
868  interface = usbio_interface ( usbio, ep );
869  if ( interface < 0 ) {
870  rc = interface;
871  goto err_interface;
872  }
873  endpoint->interface = interface;
874 
875  /* Open interface */
876  if ( ( rc = usbio_open ( usbio, interface ) ) != 0 )
877  goto err_open_interface;
878  endpoint->handle = usbio->interface[interface].handle;
879  endpoint->io = usbio->interface[interface].io;
880  DBGC ( usbio, "USBIO %s %s using ",
882  DBGC ( usbio, "%s\n", efi_handle_name ( endpoint->handle ) );
883 
884  /* Open endpoint */
885  if ( ( rc = endpoint->op->open ( endpoint ) ) != 0 )
886  goto err_open_endpoint;
887 
888  /* Add to list of endpoints */
889  list_add_tail ( &endpoint->list, &usbio->endpoints );
890 
891  return 0;
892 
893  list_del ( &endpoint->list );
894  endpoint->op->close ( endpoint );
895  err_open_endpoint:
896  usbio_close ( usbio, interface );
897  err_open_interface:
898  err_interface:
899  err_operations:
900  free ( endpoint );
901  err_alloc:
902  return rc;
903 }
static void usb_endpoint_set_hostdata(struct usb_endpoint *ep, void *priv)
Set USB endpoint host controller private data.
Definition: usb.h:561
A USB I/O protocol interface.
Definition: usbio.h:112
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
#define USB_ENDPOINT_ATTR_TYPE_MASK
Endpoint attribute transfer type mask.
Definition: usb.h:266
uint8_t attr
Type and attributes.
Definition: librm.h:256
#define DBGC(...)
Definition: compiler.h:505
static struct usbio_operations usbio_control_operations
Control endpoint operations.
Definition: usbio.c:423
#define USB_ENDPOINT_ATTR_BULK
Bulk endpoint transfer type.
Definition: usb.h:275
static void usbio_close(struct usbio_device *usbio, unsigned int interface)
Close USB I/O interface.
Definition: usbio.c:260
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:116
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int interface
Containing interface number.
Definition: usbio.h:64
struct usb_port * port
USB port.
Definition: usb.h:710
An object interface.
Definition: interface.h:109
EFI_HANDLE handle
EFI handle.
Definition: usbio.h:66
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head endpoints
List of endpoints.
Definition: usbio.h:150
static struct usbio_operations usbio_bulk_in_operations
Bulk endpoint operations.
Definition: usbio.c:516
#define USB_DIR_IN
Data transfer is from device to host.
Definition: usb.h:83
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:68
#define USB_ENDPOINT_ATTR_INTERRUPT
Interrupt endpoint transfer type.
Definition: usb.h:278
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
void(* close)(struct usbio_endpoint *endpoint)
Close endpoint.
Definition: usbio.h:103
struct usbio_operations * op
USB I/O endpoint operations.
Definition: usbio.h:61
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
Definition: usb.c:220
A USB I/O endpoint.
Definition: usbio.h:53
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition: usbio.h:145
static void * usb_bus_get_hostdata(struct usb_bus *bus)
Get USB bus host controller private data.
Definition: usb.h:1039
struct usb_hub * hub
USB hub.
Definition: usb.h:798
int(* open)(struct usbio_endpoint *endpoint)
Open endpoint.
Definition: usbio.h:98
static struct usbio_operations usbio_interrupt_operations
Interrupt endpoint operations.
Definition: usbio.c:815
#define USB_ENDPOINT_ATTR_CONTROL
Control endpoint transfer type.
Definition: usb.h:272
struct list_head list
List of endpoints.
Definition: usbio.h:59
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
struct usb_device * usb
USB device.
Definition: usb.h:391
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
static struct usbio_operations usbio_bulk_out_operations
Bulk endpoint operations.
Definition: usbio.c:617
struct usb_bus * bus
USB bus.
Definition: usb.h:828
A USB I/O protocol device.
Definition: usbio.h:126
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:114
uint16_t handle
Handle.
Definition: smbios.h:16
A USB bus.
Definition: usb.h:949
unsigned int attributes
Attributes.
Definition: usb.h:395
static int usbio_open(struct usbio_device *usbio, unsigned int interface)
Open USB I/O interface.
Definition: usbio.c:182
uint8_t bus
Bus.
Definition: edd.h:14
unsigned int address
Endpoint address.
Definition: usb.h:393
Definition: efi.h:55

References usb_endpoint::address, attr, usb_endpoint::attributes, bus, usb_hub::bus, usbio_operations::close, DBGC, efi_handle_name(), ENOMEM, ENOTSUP, usbio_endpoint::ep, free, handle, usbio_endpoint::handle, usbio_interface::handle, usbio_device::handle, usb_port::hub, usbio_endpoint::interface, usbio_endpoint::io, usbio_interface::io, usbio_endpoint::list, list_add_tail, list_del, usbio_endpoint::op, usbio_operations::open, usb_device::port, rc, usb_endpoint::usb, usb_bus_get_hostdata(), USB_DIR_IN, USB_ENDPOINT_ATTR_BULK, USB_ENDPOINT_ATTR_CONTROL, USB_ENDPOINT_ATTR_INTERRUPT, USB_ENDPOINT_ATTR_TYPE_MASK, usb_endpoint_name(), usb_endpoint_set_hostdata(), usbio_endpoint::usbio, usbio_bulk_in_operations, usbio_bulk_out_operations, usbio_close(), usbio_control_operations, usbio_interrupt_operations, usbio_open(), and zalloc().

◆ usbio_endpoint_close()

static void usbio_endpoint_close ( struct usb_endpoint ep)
static

Close endpoint.

Parameters
epUSB endpoint

Definition at line 910 of file usbio.c.

910  {
911  struct usbio_endpoint *endpoint = usb_endpoint_get_hostdata ( ep );
912  struct usbio_device *usbio = endpoint->usbio;
913  struct io_buffer *iobuf;
914  unsigned int index;
915 
916  /* Remove from list of endpoints */
917  list_del ( &endpoint->list );
918 
919  /* Close endpoint */
920  endpoint->op->close ( endpoint );
921 
922  /* Close interface */
923  usbio_close ( usbio, endpoint->interface );
924 
925  /* Cancel any incomplete transfers */
926  while ( endpoint->cons != endpoint->prod ) {
927  index = ( endpoint->cons++ % USBIO_RING_COUNT );
928  iobuf = endpoint->iobuf[index];
929  usb_complete_err ( ep, iobuf, -ECANCELED );
930  }
931 
932  /* Free endpoint */
933  free ( endpoint );
934 }
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
static void usbio_close(struct usbio_device *usbio, unsigned int interface)
Close USB I/O interface.
Definition: usbio.c:260
#define USBIO_RING_COUNT
USB I/O ring buffer size.
Definition: usbio.h:50
#define ECANCELED
Operation canceled.
Definition: errno.h:343
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
unsigned int interface
Containing interface number.
Definition: usbio.h:64
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void(* close)(struct usbio_endpoint *endpoint)
Close endpoint.
Definition: usbio.h:103
struct usbio_operations * op
USB I/O endpoint operations.
Definition: usbio.h:61
unsigned int prod
Producer counter.
Definition: usbio.h:71
A USB I/O endpoint.
Definition: usbio.h:53
unsigned int cons
Consumer counter.
Definition: usbio.h:73
struct list_head list
List of endpoints.
Definition: usbio.h:59
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
A USB I/O protocol device.
Definition: usbio.h:126
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
struct io_buffer * iobuf[USBIO_RING_COUNT]
I/O buffers.
Definition: usbio.h:75
void usb_complete_err(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer (possibly with error)
Definition: usb.c:569
static void * usb_endpoint_get_hostdata(struct usb_endpoint *ep)
Get USB endpoint host controller private data.
Definition: usb.h:572
A persistent I/O buffer.
Definition: iobuf.h:32

References usbio_operations::close, usbio_endpoint::cons, ECANCELED, usbio_endpoint::ep, free, index, usbio_endpoint::interface, usbio_endpoint::iobuf, usbio_endpoint::list, list_del, usbio_endpoint::op, usbio_endpoint::prod, usb_complete_err(), usb_endpoint_get_hostdata(), usbio_endpoint::usbio, usbio_close(), and USBIO_RING_COUNT.

◆ usbio_endpoint_reset()

static int usbio_endpoint_reset ( struct usb_endpoint *ep  __unused)
static

Reset endpoint.

Parameters
epUSB endpoint
Return values
rcReturn status code

Definition at line 942 of file usbio.c.

942  {
943 
944  /* Nothing to do */
945  return 0;
946 }

◆ usbio_endpoint_mtu()

static int usbio_endpoint_mtu ( struct usb_endpoint *ep  __unused)
static

Update MTU.

Parameters
epUSB endpoint
Return values
rcReturn status code

Definition at line 954 of file usbio.c.

954  {
955 
956  /* Nothing to do */
957  return 0;
958 }

◆ usbio_endpoint_enqueue()

static int usbio_endpoint_enqueue ( struct usb_endpoint ep,
struct io_buffer iobuf,
unsigned int  flags 
)
static

Enqueue transfer.

Parameters
epUSB endpoint
iobufI/O buffer
flagsTransfer flags
Return values
rcReturn status code

Definition at line 968 of file usbio.c.

970  {
971  struct usbio_endpoint *endpoint = usb_endpoint_get_hostdata ( ep );
972  unsigned int fill;
973  unsigned int index;
974 
975  /* Fail if shutdown is in progress */
977  return -ECANCELED;
978 
979  /* Fail if transfer ring is full */
980  fill = ( endpoint->prod - endpoint->cons );
981  if ( fill >= USBIO_RING_COUNT )
982  return -ENOBUFS;
983 
984  /* Add to ring */
985  index = ( endpoint->prod++ % USBIO_RING_COUNT );
986  endpoint->iobuf[index] = iobuf;
987  endpoint->flags[index] = flags;
988 
989  return 0;
990 }
#define USBIO_RING_COUNT
USB I/O ring buffer size.
Definition: usbio.h:50
#define ECANCELED
Operation canceled.
Definition: errno.h:343
uint8_t flags[USBIO_RING_COUNT]
Flags.
Definition: usbio.h:77
unsigned int prod
Producer counter.
Definition: usbio.h:71
A USB I/O endpoint.
Definition: usbio.h:53
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
unsigned int cons
Consumer counter.
Definition: usbio.h:73
uint8_t fill
Length pair.
Definition: deflate.h:12
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
struct io_buffer * iobuf[USBIO_RING_COUNT]
I/O buffers.
Definition: usbio.h:75
static void * usb_endpoint_get_hostdata(struct usb_endpoint *ep)
Get USB endpoint host controller private data.
Definition: usb.h:572
int efi_shutdown_in_progress
EFI shutdown is in progress.
Definition: efi_init.c:51
uint8_t flags
Flags.
Definition: ena.h:18

References usbio_endpoint::cons, ECANCELED, efi_shutdown_in_progress, ENOBUFS, usbio_endpoint::ep, fill, flags, usbio_endpoint::flags, index, usbio_endpoint::iobuf, usbio_endpoint::prod, usb_endpoint_get_hostdata(), and USBIO_RING_COUNT.

Referenced by usbio_endpoint_message(), and usbio_endpoint_stream().

◆ usbio_endpoint_message()

static int usbio_endpoint_message ( struct usb_endpoint ep,
struct io_buffer iobuf 
)
static

Enqueue message transfer.

Parameters
epUSB endpoint
iobufI/O buffer
Return values
rcReturn status code

Definition at line 999 of file usbio.c.

1000  {
1001  struct usb_setup_packet *setup;
1002 
1003  /* Adjust I/O buffer to start of data payload */
1004  assert ( iob_len ( iobuf ) >= sizeof ( *setup ) );
1005  iob_pull ( iobuf, sizeof ( *setup ) );
1006 
1007  /* Enqueue transfer */
1008  return usbio_endpoint_enqueue ( ep, iobuf, USBIO_MESSAGE );
1009 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:98
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.
Definition: usbio.c:968
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
A USB setup data packet.
Definition: usb.h:68
This is a message transfer.
Definition: usbio.h:86

References assert(), iob_len(), iob_pull, usbio_endpoint_enqueue(), and USBIO_MESSAGE.

◆ usbio_endpoint_stream()

static int usbio_endpoint_stream ( struct usb_endpoint ep,
struct io_buffer iobuf,
int  zlp 
)
static

Enqueue stream transfer.

Parameters
epUSB endpoint
iobufI/O buffer
zlpAppend a zero-length packet
Return values
rcReturn status code

Definition at line 1019 of file usbio.c.

1020  {
1021 
1022  /* Enqueue transfer */
1023  return usbio_endpoint_enqueue ( ep, iobuf, ( zlp ? USBIO_ZLEN : 0 ) );
1024 }
static int usbio_endpoint_enqueue(struct usb_endpoint *ep, struct io_buffer *iobuf, unsigned int flags)
Enqueue transfer.
Definition: usbio.c:968
This transfer requires zero-length packet termination.
Definition: usbio.h:88

References usbio_endpoint_enqueue(), and USBIO_ZLEN.

◆ usbio_endpoint_poll()

static void usbio_endpoint_poll ( struct usbio_endpoint endpoint)
static

Poll for completions.

Parameters
endpointEndpoint

Definition at line 1031 of file usbio.c.

1031  {
1032 
1033  /* Do nothing if shutdown is in progress */
1035  return;
1036 
1037  /* Poll endpoint */
1038  endpoint->op->poll ( endpoint );
1039 }
void(* poll)(struct usbio_endpoint *endpoint)
Poll endpoint.
Definition: usbio.h:108
struct usbio_operations * op
USB I/O endpoint operations.
Definition: usbio.h:61
int efi_shutdown_in_progress
EFI shutdown is in progress.
Definition: efi_init.c:51

References efi_shutdown_in_progress, usbio_endpoint::op, and usbio_operations::poll.

Referenced by usbio_bus_poll().

◆ usbio_device_open()

static int usbio_device_open ( struct usb_device usb)
static

Open device.

Parameters
usbUSB device
Return values
rcReturn status code

Definition at line 1054 of file usbio.c.

1054  {
1055  struct usbio_device *usbio =
1056  usb_bus_get_hostdata ( usb->port->hub->bus );
1057 
1058  usb_set_hostdata ( usb, usbio );
1059  return 0;
1060 }
static void usb_set_hostdata(struct usb_device *usb, void *priv)
Set USB device host controller private data.
Definition: usb.h:767
struct usb_port * port
USB port.
Definition: usb.h:710
static void * usb_bus_get_hostdata(struct usb_bus *bus)
Get USB bus host controller private data.
Definition: usb.h:1039
struct usb_hub * hub
USB hub.
Definition: usb.h:798
struct usb_bus * bus
USB bus.
Definition: usb.h:828
A USB I/O protocol device.
Definition: usbio.h:126

References usb_hub::bus, usb_port::hub, usb_device::port, usb_bus_get_hostdata(), and usb_set_hostdata().

◆ usbio_device_close()

static void usbio_device_close ( struct usb_device *usb  __unused)
static

Close device.

Parameters
usbUSB device

Definition at line 1067 of file usbio.c.

1067  {
1068 
1069  /* Nothing to do */
1070 }

◆ usbio_device_address()

static int usbio_device_address ( struct usb_device *usb  __unused)
static

Assign device address.

Parameters
usbUSB device
Return values
rcReturn status code

Definition at line 1078 of file usbio.c.

1078  {
1079 
1080  /* Nothing to do */
1081  return 0;
1082 }

◆ usbio_hub_open()

static int usbio_hub_open ( struct usb_hub hub)
static

Open hub.

Parameters
hubUSB hub
Return values
rcReturn status code

Definition at line 1097 of file usbio.c.

1097  {
1098 
1099  /* Disallow non-root hubs */
1100  if ( hub->usb )
1101  return -ENOTSUP;
1102 
1103  /* Nothing to do */
1104  return 0;
1105 }
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
struct usb_device * usb
Underlying USB device, if any.
Definition: usb.h:830

References ENOTSUP, and usb_hub::usb.

◆ usbio_hub_close()

static void usbio_hub_close ( struct usb_hub *hub  __unused)
static

Close hub.

Parameters
hubUSB hub

Definition at line 1112 of file usbio.c.

1112  {
1113 
1114  /* Nothing to do */
1115 }

◆ usbio_root_open()

static int usbio_root_open ( struct usb_hub *hub  __unused)
static

Open root hub.

Parameters
hubUSB hub
Return values
rcReturn status code

Definition at line 1130 of file usbio.c.

1130  {
1131 
1132  /* Nothing to do */
1133  return 0;
1134 }

◆ usbio_root_close()

static void usbio_root_close ( struct usb_hub *hub  __unused)
static

Close root hub.

Parameters
hubUSB hub

Definition at line 1141 of file usbio.c.

1141  {
1142 
1143  /* Nothing to do */
1144 }

◆ usbio_root_enable()

static int usbio_root_enable ( struct usb_hub *hub  __unused,
struct usb_port *port  __unused 
)
static

Enable port.

Parameters
hubUSB hub
portUSB port
Return values
rcReturn status code

Definition at line 1153 of file usbio.c.

1154  {
1155 
1156  /* Nothing to do */
1157  return 0;
1158 }

◆ usbio_root_disable()

static int usbio_root_disable ( struct usb_hub *hub  __unused,
struct usb_port *port  __unused 
)
static

Disable port.

Parameters
hubUSB hub
portUSB port
Return values
rcReturn status code

Definition at line 1167 of file usbio.c.

1168  {
1169 
1170  /* Nothing to do */
1171  return 0;
1172 }

◆ usbio_root_speed()

static int usbio_root_speed ( struct usb_hub *hub  __unused,
struct usb_port port 
)
static

Update root hub port speed.

Parameters
hubUSB hub
portUSB port
Return values
rcReturn status code

Definition at line 1181 of file usbio.c.

1182  {
1183 
1184  /* Not actually exposed via EFI_USB_IO_PROTOCOL */
1185  port->speed = USB_SPEED_HIGH;
1186  return 0;
1187 }
u8 port
Port number.
Definition: CIB_PRM.h:31
High speed (480Mbps)
Definition: usb.h:52

References port, and USB_SPEED_HIGH.

◆ usbio_root_clear_tt()

static int usbio_root_clear_tt ( struct usb_hub *hub  __unused,
struct usb_port *port  __unused,
struct usb_endpoint *ep  __unused 
)
static

Clear transaction translator buffer.

Parameters
hubUSB hub
portUSB port
epUSB endpoint
Return values
rcReturn status code

Definition at line 1197 of file usbio.c.

1199  {
1200 
1201  /* Should never be called; this is a root hub */
1202  return -ENOTSUP;
1203 }
#define ENOTSUP
Operation not supported.
Definition: errno.h:589

References ENOTSUP.

◆ usbio_bus_open()

static int usbio_bus_open ( struct usb_bus *bus  __unused)
static

Open USB bus.

Parameters
busUSB bus
Return values
rcReturn status code

Definition at line 1218 of file usbio.c.

1218  {
1219 
1220  /* Nothing to do */
1221  return 0;
1222 }

◆ usbio_bus_close()

static void usbio_bus_close ( struct usb_bus *bus  __unused)
static

Close USB bus.

Parameters
busUSB bus

Definition at line 1229 of file usbio.c.

1229  {
1230 
1231  /* Nothing to do */
1232 }

◆ usbio_bus_poll()

static void usbio_bus_poll ( struct usb_bus bus)
static

Poll USB bus.

Parameters
busUSB bus

Definition at line 1239 of file usbio.c.

1239  {
1240  struct usbio_device *usbio = usb_bus_get_hostdata ( bus );
1241  struct usbio_endpoint *endpoint;
1242 
1243  /* Poll all endpoints. We trust that completion handlers are
1244  * minimal and will not do anything that could plausibly
1245  * affect the endpoint list itself.
1246  */
1247  list_for_each_entry ( endpoint, &usbio->endpoints, list )
1248  usbio_endpoint_poll ( endpoint );
1249 }
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
static void usbio_endpoint_poll(struct usbio_endpoint *endpoint)
Poll for completions.
Definition: usbio.c:1031
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct list_head endpoints
List of endpoints.
Definition: usbio.h:150
A USB I/O endpoint.
Definition: usbio.h:53
static void * usb_bus_get_hostdata(struct usb_bus *bus)
Get USB bus host controller private data.
Definition: usb.h:1039
struct list_head list
List of endpoints.
Definition: usbio.h:59
A USB I/O protocol device.
Definition: usbio.h:126
uint8_t bus
Bus.
Definition: edd.h:14

References bus, usbio_device::endpoints, usbio_endpoint::list, list_for_each_entry, usb_bus_get_hostdata(), usbio_endpoint::usbio, and usbio_endpoint_poll().

◆ usbio_supported()

static int usbio_supported ( EFI_HANDLE  handle)
static

Check to see if driver supports a device.

Parameters
handleEFI device handle
Return values
rcReturn status code

Definition at line 1298 of file usbio.c.

1298  {
1302  struct usb_function_descriptor desc;
1303  struct usb_driver *driver;
1304  struct usb_device_id *id;
1305  union {
1306  void *interface;
1307  EFI_USB_IO_PROTOCOL *io;
1308  } usb;
1309  EFI_STATUS efirc;
1310  int rc;
1311 
1312  /* Get protocol */
1313  if ( ( efirc = bs->OpenProtocol ( handle, &efi_usb_io_protocol_guid,
1314  &usb.interface, efi_image_handle,
1315  handle,
1317  rc = -EEFI ( efirc );
1318  DBGCP ( handle, "USB %s is not a USB device\n",
1319  efi_handle_name ( handle ) );
1320  goto err_open_protocol;
1321  }
1322 
1323  /* Get device descriptor */
1324  if ( ( efirc = usb.io->UsbGetDeviceDescriptor ( usb.io,
1325  &device ) ) != 0 ) {
1326  rc = -EEFI ( efirc );
1327  DBGC ( handle, "USB %s could not get device descriptor: "
1328  "%s\n", efi_handle_name ( handle ), strerror ( rc ) );
1329  goto err_get_device_descriptor;
1330  }
1331  memset ( &desc, 0, sizeof ( desc ) );
1332  desc.vendor = device.IdVendor;
1333  desc.product = device.IdProduct;
1334 
1335  /* Get interface descriptor */
1336  if ( ( efirc = usb.io->UsbGetInterfaceDescriptor ( usb.io,
1337  &interface ) ) !=0){
1338  rc = -EEFI ( efirc );
1339  DBGC ( handle, "USB %s could not get interface descriptor: "
1340  "%s\n", efi_handle_name ( handle ), strerror ( rc ) );
1341  goto err_get_interface_descriptor;
1342  }
1343  desc.class.class.class = interface.InterfaceClass;
1344  desc.class.class.subclass = interface.InterfaceSubClass;
1345  desc.class.class.protocol = interface.InterfaceProtocol;
1346 
1347  /* Look for a driver for this interface */
1348  driver = usb_find_driver ( &desc, &id );
1349  if ( ! driver ) {
1350  rc = -ENOTSUP;
1351  goto err_unsupported;
1352  }
1353 
1354  /* Success */
1355  rc = 0;
1356 
1357  err_unsupported:
1358  err_get_interface_descriptor:
1359  err_get_device_descriptor:
1362  err_open_protocol:
1363  return rc;
1364 }
A USB driver.
Definition: usb.h:1363
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A USB device ID.
Definition: usb.h:1317
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
#define DBGC(...)
Definition: compiler.h:505
Standard Interface Descriptor USB 2.0 spec, Section 9.6.5.
Definition: Usb.h:147
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
uint16_t device
Device ID.
Definition: ena.h:24
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
A hardware device.
Definition: device.h:73
unsigned int interface
Containing interface number.
Definition: usbio.h:64
A USB function descriptor.
Definition: usb.h:640
struct usb_driver * usb_find_driver(struct usb_function_descriptor *desc, struct usb_device_id **id)
Find USB device driver.
Definition: usb.c:1130
An object interface.
Definition: interface.h:109
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1271
uint8_t id
Request identifier.
Definition: ena.h:12
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI_GUID efi_usb_io_protocol_guid
USB I/O protocol GUID.
Definition: efi_guid.c:296
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:33
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
#define DBGCP(...)
Definition: compiler.h:539
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
uint16_t handle
Handle.
Definition: smbios.h:16
Standard Device Descriptor USB 2.0 spec, Section 9.6.1.
Definition: Usb.h:111
void * memset(void *dest, int character, size_t len) __nonnull

References EFI_SYSTEM_TABLE::BootServices, usb_class::class, usb_class_descriptor::class, usb_function_descriptor::class, EFI_BOOT_SERVICES::CloseProtocol, DBGC, DBGCP, device, EEFI, efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, efi_usb_io_protocol_guid, ENOTSUP, handle, id, memset(), EFI_BOOT_SERVICES::OpenProtocol, usb_function_descriptor::product, usb_class::protocol, rc, strerror(), usb_class::subclass, usb_find_driver(), and usb_function_descriptor::vendor.

◆ usbio_config()

static int usbio_config ( struct usbio_device usbio)
static

Fetch configuration descriptor.

Parameters
usbioUSB I/O device
Return values
rcReturn status code

Definition at line 1372 of file usbio.c.

1372  {
1373  EFI_HANDLE handle = usbio->handle;
1374  EFI_USB_IO_PROTOCOL *io = usbio->io;
1376  EFI_USB_CONFIG_DESCRIPTOR partial;
1377  union {
1378  struct usb_setup_packet setup;
1380  } msg;
1381  UINT32 status;
1382  size_t len;
1383  unsigned int count;
1384  unsigned int value;
1385  unsigned int i;
1386  EFI_STATUS efirc;
1387  int rc;
1388 
1389  /* Get device descriptor */
1390  if ( ( efirc = io->UsbGetDeviceDescriptor ( io, &device ) ) != 0 ) {
1391  rc = -EEFI ( efirc );
1392  DBGC ( usbio, "USB %s could not get device descriptor: "
1393  "%s\n", efi_handle_name ( handle ), strerror ( rc ) );
1394  goto err_get_device_descriptor;
1395  }
1396  count = device.NumConfigurations;
1397 
1398  /* Get current partial configuration descriptor */
1399  if ( ( efirc = io->UsbGetConfigDescriptor ( io, &partial ) ) != 0 ) {
1400  rc = -EEFI ( efirc );
1401  DBGC ( usbio, "USB %s could not get partial configuration "
1402  "descriptor: %s\n", efi_handle_name ( handle ),
1403  strerror ( rc ) );
1404  goto err_get_configuration_descriptor;
1405  }
1406  len = le16_to_cpu ( partial.TotalLength );
1407 
1408  /* Allocate configuration descriptor */
1409  usbio->config = malloc ( len );
1410  if ( ! usbio->config ) {
1411  rc = -ENOMEM;
1412  goto err_alloc;
1413  }
1414 
1415  /* There is, naturally, no way to retrieve the entire device
1416  * configuration descriptor via EFI_USB_IO_PROTOCOL. Worse,
1417  * there is no way to even retrieve the index of the current
1418  * configuration descriptor. We have to iterate over all
1419  * possible configuration descriptors looking for the
1420  * descriptor that matches the current configuration value.
1421  */
1422  for ( i = 0 ; i < count ; i++ ) {
1423 
1424  /* Construct request */
1425  msg.setup.request = cpu_to_le16 ( USB_GET_DESCRIPTOR );
1426  value = ( ( USB_CONFIGURATION_DESCRIPTOR << 8 ) | i );
1427  msg.setup.value = cpu_to_le16 ( value );
1428  msg.setup.index = 0;
1429  msg.setup.len = cpu_to_le16 ( len );
1430 
1431  /* Get full configuration descriptor */
1432  if ( ( efirc = io->UsbControlTransfer ( io, &msg.efi,
1433  EfiUsbDataIn, 0,
1434  usbio->config, len,
1435  &status ) ) != 0 ) {
1436  rc = -EEFI ( efirc );
1437  DBGC ( usbio, "USB %s could not get configuration %d "
1438  "descriptor: %s\n", efi_handle_name ( handle ),
1439  i, strerror ( rc ) );
1440  goto err_control_transfer;
1441  }
1442 
1443  /* Ignore unless this is the current configuration */
1444  if ( usbio->config->config != partial.ConfigurationValue )
1445  continue;
1446 
1447  /* Check length */
1448  if ( le16_to_cpu ( usbio->config->len ) != len ) {
1449  DBGC ( usbio, "USB %s configuration descriptor length "
1450  "mismatch\n", efi_handle_name ( handle ) );
1451  rc = -EINVAL;
1452  goto err_len;
1453  }
1454 
1455  return 0;
1456  }
1457 
1458  /* No match found */
1459  DBGC ( usbio, "USB %s could not find current configuration "
1460  "descriptor\n", efi_handle_name ( handle ) );
1461  rc = -ENOENT;
1462 
1463  err_len:
1464  err_control_transfer:
1465  free ( usbio->config );
1466  err_alloc:
1467  err_get_configuration_descriptor:
1468  err_get_device_descriptor:
1469  return rc;
1470 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
#define USB_GET_DESCRIPTOR
Get descriptor.
Definition: usb.h:122
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
unsigned int UINT32
Definition: ProcessorBind.h:56
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
uint16_t device
Device ID.
Definition: ena.h:24
uint8_t status
Status.
Definition: ena.h:16
#define ENOMEM
Not enough space.
Definition: errno.h:534
A hardware device.
Definition: device.h:73
Format of Setup Data for USB Device Requests USB 2.0 spec, Section 9.3.
Definition: Usb.h:99
#define USB_CONFIGURATION_DESCRIPTOR
A USB configuration descriptor.
Definition: usb.h:213
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define le16_to_cpu(value)
Definition: byteswap.h:112
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
A USB setup data packet.
Definition: usb.h:68
struct usb_configuration_descriptor * config
Configuration descriptor.
Definition: usbio.h:135
EFI_USB_IO_CONTROL_TRANSFER UsbControlTransfer
Definition: UsbIo.h:489
UINT16 TotalLength
Definition: Usb.h:135
uint32_t len
Length.
Definition: ena.h:14
uint8_t config
Configuration value.
Definition: usb.h:203
EFI_USB_IO_GET_DEVICE_DESCRIPTOR UsbGetDeviceDescriptor
Definition: UsbIo.h:499
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:130
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
uint16_t count
Number of entries.
Definition: ena.h:22
UINT8 ConfigurationValue
Definition: Usb.h:137
#define cpu_to_le16(value)
Definition: byteswap.h:106
Standard Configuration Descriptor USB 2.0 spec, Section 9.6.3.
Definition: Usb.h:132
uint16_t len
Total length.
Definition: usb.h:199
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
uint16_t handle
Handle.
Definition: smbios.h:16
Standard Device Descriptor USB 2.0 spec, Section 9.6.1.
Definition: Usb.h:111
Definition: efi.h:55
EFI_USB_IO_GET_CONFIG_DESCRIPTOR UsbGetConfigDescriptor
Definition: UsbIo.h:500
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References usbio_device::config, usb_configuration_descriptor::config, USB_CONFIG_DESCRIPTOR::ConfigurationValue, count, cpu_to_le16, DBGC, device, EEFI, efi_handle_name(), EfiUsbDataIn, EINVAL, ENOENT, ENOMEM, free, handle, usbio_device::handle, usbio_device::io, le16_to_cpu, len, usb_configuration_descriptor::len, malloc(), msg(), rc, status, strerror(), USB_CONFIG_DESCRIPTOR::TotalLength, USB_CONFIGURATION_DESCRIPTOR, USB_GET_DESCRIPTOR, _EFI_USB_IO_PROTOCOL::UsbControlTransfer, _EFI_USB_IO_PROTOCOL::UsbGetConfigDescriptor, _EFI_USB_IO_PROTOCOL::UsbGetDeviceDescriptor, and value.

Referenced by usbio_start().

◆ usbio_path()

static int usbio_path ( struct usbio_device usbio)
static

Construct device path for opening other interfaces.

Parameters
usbioUSB I/O device
Return values
rcReturn status code

Definition at line 1478 of file usbio.c.

1478  {
1480  EFI_HANDLE handle = usbio->handle;
1483  USB_DEVICE_PATH *usbpath;
1484  union {
1485  void *interface;
1487  } u;
1488  size_t len;
1489  EFI_STATUS efirc;
1490  int rc;
1491 
1492  /* Open device path protocol */
1493  if ( ( efirc = bs->OpenProtocol ( handle,
1495  &u.interface, efi_image_handle,
1496  handle,
1498  rc = -EEFI ( efirc );
1499  DBGC ( usbio, "USBIO %s cannot open device path protocol: "
1500  "%s\n", efi_handle_name ( handle ), strerror ( rc ) );
1501  goto err_open_protocol;
1502  }
1503  path = u.interface;
1504 
1505  /* Locate end of device path and sanity check */
1506  len = efi_devpath_len ( path );
1507  if ( len < sizeof ( *usbpath ) ) {
1508  DBGC ( usbio, "USBIO %s underlength device path\n",
1509  efi_handle_name ( handle ) );
1510  rc = -EINVAL;
1511  goto err_underlength;
1512  }
1513  usbpath = ( ( ( void * ) path ) + len - sizeof ( *usbpath ) );
1514  if ( ! ( ( usbpath->Header.Type == MESSAGING_DEVICE_PATH ) &&
1515  ( usbpath->Header.SubType == MSG_USB_DP ) ) ) {
1516  DBGC ( usbio, "USBIO %s not a USB device path: ",
1517  efi_handle_name ( handle ) );
1518  DBGC ( usbio, "%s\n", efi_devpath_text ( path ) );
1519  rc = -EINVAL;
1520  goto err_non_usb;
1521  }
1522 
1523  /* Allocate copy of device path */
1524  usbio->path = malloc ( len + sizeof ( *end ) );
1525  if ( ! usbio->path ) {
1526  rc = -ENOMEM;
1527  goto err_alloc;
1528  }
1529  memcpy ( usbio->path, path, ( len + sizeof ( *end ) ) );
1530  usbio->usbpath = ( ( ( void * ) usbio->path ) + len -
1531  sizeof ( *usbpath ) );
1532 
1533  /* Close protocol */
1536 
1537  return 0;
1538 
1539  free ( usbio->path );
1540  err_alloc:
1541  err_non_usb:
1542  err_underlength:
1545  err_open_protocol:
1546  return rc;
1547 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
#define DBGC(...)
Definition: compiler.h:505
size_t efi_devpath_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_utils.c:59
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
An object interface.
Definition: interface.h:109
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:366
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1271
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:414
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:33
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
Definition: usbio.h:138
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:132
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
USB_DEVICE_PATH * usbpath
Final component of USB device path.
Definition: usbio.h:140
uint32_t len
Length.
Definition: ena.h:14
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
UINT8 SubType
Varies by Type 0xFF End Entire Device Path, or 0x01 End This Instance of a Device Path and start a ne...
Definition: DevicePath.h:59
union @17 u
uint32_t end
Ending offset.
Definition: netvsc.h:18
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
uint16_t handle
Handle.
Definition: smbios.h:16
#define MSG_USB_DP
USB Device Path SubType.
Definition: DevicePath.h:412
Definition: efi.h:55

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, EEFI, efi_device_path_protocol_guid, efi_devpath_len(), efi_devpath_text(), efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, EINVAL, end, ENOMEM, free, handle, usbio_device::handle, USB_DEVICE_PATH::Header, len, malloc(), memcpy(), MESSAGING_DEVICE_PATH, MSG_USB_DP, EFI_BOOT_SERVICES::OpenProtocol, usbio_device::path, rc, strerror(), EFI_DEVICE_PATH_PROTOCOL::SubType, EFI_DEVICE_PATH_PROTOCOL::Type, u, and usbio_device::usbpath.

Referenced by usbio_start().

◆ usbio_interfaces()

static int usbio_interfaces ( struct usbio_device usbio)
static

Construct interface list.

Parameters
usbioUSB I/O device
Return values
rcReturn status code

Definition at line 1555 of file usbio.c.

1555  {
1556  EFI_HANDLE handle = usbio->handle;
1557  EFI_USB_IO_PROTOCOL *io = usbio->io;
1559  unsigned int first;
1560  unsigned int count;
1561  EFI_STATUS efirc;
1562  int rc;
1563 
1564  /* Get interface descriptor */
1565  if ( ( efirc = io->UsbGetInterfaceDescriptor ( io, &interface ) ) != 0){
1566  rc = -EEFI ( efirc );
1567  DBGC ( usbio, "USB %s could not get interface descriptor: "
1568  "%s\n", efi_handle_name ( handle ), strerror ( rc ) );
1569  goto err_get_interface_descriptor;
1570  }
1571 
1572  /* Record first interface number */
1573  first = interface.InterfaceNumber;
1574  count = usbio->config->interfaces;
1575  assert ( first < count );
1576  usbio->first = first;
1577 
1578  /* Allocate interface list */
1579  usbio->interface = zalloc ( count * sizeof ( usbio->interface[0] ) );
1580  if ( ! usbio->interface ) {
1581  rc = -ENOMEM;
1582  goto err_alloc;
1583  }
1584 
1585  /* Use already-opened protocol for control transfers and for
1586  * the first interface.
1587  */
1588  usbio->interface[0].handle = handle;
1589  usbio->interface[0].io = io;
1590  usbio->interface[0].count = 1;
1591  usbio->interface[first].handle = handle;
1592  usbio->interface[first].io = io;
1593  usbio->interface[first].count = 1;
1594 
1595  return 0;
1596 
1597  free ( usbio->interface );
1598  err_alloc:
1599  err_get_interface_descriptor:
1600  return rc;
1601 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
#define DBGC(...)
Definition: compiler.h:505
Standard Interface Descriptor USB 2.0 spec, Section 9.6.5.
Definition: Usb.h:147
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
uint8_t interfaces
Number of interfaces.
Definition: usb.h:201
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:116
#define ENOMEM
Not enough space.
Definition: errno.h:534
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An object interface.
Definition: interface.h:109
unsigned int count
Usage count.
Definition: usbio.h:118
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
uint8_t first
First interface number.
Definition: usbio.h:143
struct usb_configuration_descriptor * config
Configuration descriptor.
Definition: usbio.h:135
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition: usbio.h:145
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:130
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
uint16_t count
Number of entries.
Definition: ena.h:22
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:114
uint16_t handle
Handle.
Definition: smbios.h:16
EFI_USB_IO_GET_INTERFACE_DESCRIPTOR UsbGetInterfaceDescriptor
Definition: UsbIo.h:501
uint32_t first
Length to skip in first segment.
Definition: pccrc.h:23
Definition: efi.h:55

References assert(), usbio_device::config, count, usbio_interface::count, DBGC, EEFI, efi_handle_name(), ENOMEM, first, usbio_device::first, free, handle, usbio_interface::handle, usbio_device::handle, usbio_device::interface, usb_configuration_descriptor::interfaces, usbio_interface::io, usbio_device::io, rc, strerror(), _EFI_USB_IO_PROTOCOL::UsbGetInterfaceDescriptor, and zalloc().

Referenced by usbio_start().

◆ usbio_start()

static int usbio_start ( struct efi_device efidev)
static

Attach driver to device.

Parameters
efidevEFI device
Return values
rcReturn status code

Definition at line 1609 of file usbio.c.

1609  {
1611  EFI_HANDLE handle = efidev->device;
1612  struct usbio_device *usbio;
1613  struct usb_port *port;
1614  union {
1615  void *interface;
1616  EFI_USB_IO_PROTOCOL *io;
1617  } u;
1618  EFI_STATUS efirc;
1619  int rc;
1620 
1621  /* Allocate and initialise structure */
1622  usbio = zalloc ( sizeof ( *usbio ) );
1623  if ( ! usbio ) {
1624  rc = -ENOMEM;
1625  goto err_alloc;
1626  }
1627  efidev_set_drvdata ( efidev, usbio );
1628  usbio->handle = handle;
1629  INIT_LIST_HEAD ( &usbio->endpoints );
1630 
1631  /* Open USB I/O protocol */
1632  if ( ( efirc = bs->OpenProtocol ( handle, &efi_usb_io_protocol_guid,
1633  &u.interface, efi_image_handle,
1634  handle,
1637  rc = -EEFI ( efirc );
1638  DBGC ( usbio, "USBIO %s cannot open USB I/O protocol: %s\n",
1639  efi_handle_name ( handle ), strerror ( rc ) );
1641  goto err_open_usbio;
1642  }
1643  usbio->io = u.io;
1644 
1645  /* Describe generic device */
1646  efi_device_info ( handle, "USB", &usbio->dev );
1647  usbio->dev.parent = &efidev->dev;
1648  list_add ( &usbio->dev.siblings, &efidev->dev.children );
1649  INIT_LIST_HEAD ( &usbio->dev.children );
1650 
1651  /* Fetch configuration descriptor */
1652  if ( ( rc = usbio_config ( usbio ) ) != 0 )
1653  goto err_config;
1654 
1655  /* Construct device path */
1656  if ( ( rc = usbio_path ( usbio ) ) != 0 )
1657  goto err_path;
1658 
1659  /* Construct interface list */
1660  if ( ( rc = usbio_interfaces ( usbio ) ) != 0 )
1661  goto err_interfaces;
1662 
1663  /* Allocate USB bus */
1664  usbio->bus = alloc_usb_bus ( &usbio->dev, 1 /* single "port" */,
1666  if ( ! usbio->bus ) {
1667  rc = -ENOMEM;
1668  goto err_alloc_bus;
1669  }
1670  usb_bus_set_hostdata ( usbio->bus, usbio );
1671  usb_hub_set_drvdata ( usbio->bus->hub, usbio );
1672 
1673  /* Set port protocol */
1674  port = usb_port ( usbio->bus->hub, 1 );
1675  port->protocol = USB_PROTO_2_0;
1676 
1677  /* Register USB bus */
1678  if ( ( rc = register_usb_bus ( usbio->bus ) ) != 0 )
1679  goto err_register;
1680 
1681  return 0;
1682 
1683  unregister_usb_bus ( usbio->bus );
1684  err_register:
1685  free_usb_bus ( usbio->bus );
1686  err_alloc_bus:
1687  free ( usbio->interface );
1688  err_interfaces:
1689  free ( usbio->path );
1690  err_path:
1691  free ( usbio->config );
1692  err_config:
1693  list_del ( &usbio->dev.siblings );
1696  err_open_usbio:
1697  free ( usbio );
1698  err_alloc:
1699  return rc;
1700 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
struct device dev
Generic device.
Definition: usbio.h:132
static int usbio_path(struct usbio_device *usbio)
Construct device path for opening other interfaces.
Definition: usbio.c:1478
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
struct usb_bus * alloc_usb_bus(struct device *dev, unsigned int ports, size_t mtu, struct usb_host_operations *op)
Allocate USB bus.
Definition: usb.c:2033
USB 2.0.
Definition: usb.h:22
#define DBGC(...)
Definition: compiler.h:505
#define EFI_OPEN_PROTOCOL_BY_DRIVER
Definition: UefiSpec.h:1274
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
#define EFI_OPEN_PROTOCOL_EXCLUSIVE
Definition: UefiSpec.h:1275
#define DBGC_EFI_OPENERS(...)
Definition: efi.h:262
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:21
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
struct device * parent
Bus device.
Definition: device.h:85
static void usb_bus_set_hostdata(struct usb_bus *bus, void *priv)
Set USB bus host controller private data.
Definition: usb.h:1028
#define USBIO_MTU
USB I/O maximum transfer size.
Definition: usbio.h:24
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
A USB port.
Definition: usb.h:796
#define ENOMEM
Not enough space.
Definition: errno.h:534
u8 port
Port number.
Definition: CIB_PRM.h:31
void unregister_usb_bus(struct usb_bus *bus)
Unregister USB bus.
Definition: usb.c:2104
An object interface.
Definition: interface.h:109
struct list_head endpoints
List of endpoints.
Definition: usbio.h:150
static int usbio_config(struct usbio_device *usbio)
Fetch configuration descriptor.
Definition: usbio.c:1372
struct usb_bus * bus
USB bus.
Definition: usbio.h:148
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI_GUID efi_usb_io_protocol_guid
USB I/O protocol GUID.
Definition: efi_guid.c:296
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:33
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
Definition: usbio.h:138
struct usb_configuration_descriptor * config
Configuration descriptor.
Definition: usbio.h:135
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition: usbio.h:145
int register_usb_bus(struct usb_bus *bus)
Register USB bus.
Definition: usb.c:2069
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:130
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
struct list_head children
Devices attached to this device.
Definition: device.h:83
union @17 u
struct usb_hub * hub
Root hub.
Definition: usb.h:972
static void usb_hub_set_drvdata(struct usb_hub *hub, void *priv)
Set USB hub driver private data.
Definition: usb.h:920
static struct usb_port * usb_port(struct usb_hub *hub, unsigned int address)
Get USB port.
Definition: usb.h:943
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
Definition: efi_driver.h:72
A USB I/O protocol device.
Definition: usbio.h:126
USB I/O endpoint operations.
Definition: usbio.h:92
struct device dev
Generic device.
Definition: efi_driver.h:19
uint16_t handle
Handle.
Definition: smbios.h:16
static int usbio_interfaces(struct usbio_device *usbio)
Construct interface list.
Definition: usbio.c:1555
void free_usb_bus(struct usb_bus *bus)
Free USB bus.
Definition: usb.c:2128
Definition: efi.h:55
void efi_device_info(EFI_HANDLE device, const char *prefix, struct device *dev)
Get underlying device information.
Definition: efi_utils.c:211

References alloc_usb_bus(), EFI_SYSTEM_TABLE::BootServices, usbio_device::bus, device::children, EFI_BOOT_SERVICES::CloseProtocol, usbio_device::config, DBGC, DBGC_EFI_OPENERS, efi_device::dev, usbio_device::dev, efi_device::device, EEFI, efi_device_info(), efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_BY_DRIVER, EFI_OPEN_PROTOCOL_EXCLUSIVE, efi_systab, efi_usb_io_protocol_guid, efidev_set_drvdata(), usbio_device::endpoints, ENOMEM, free, free_usb_bus(), handle, usbio_device::handle, usb_bus::hub, INIT_LIST_HEAD, usbio_device::interface, usbio_device::io, list_add, list_del, EFI_BOOT_SERVICES::OpenProtocol, device::parent, usbio_device::path, port, rc, register_usb_bus(), device::siblings, strerror(), u, unregister_usb_bus(), usb_bus_set_hostdata(), usb_hub_set_drvdata(), usb_port(), USB_PROTO_2_0, usbio_config(), usbio_interfaces(), USBIO_MTU, usbio_path(), and zalloc().

◆ usbio_stop()

static void usbio_stop ( struct efi_device efidev)
static

Detach driver from device.

Parameters
efidevEFI device

Definition at line 1707 of file usbio.c.

1707  {
1709  EFI_HANDLE handle = efidev->device;
1710  struct usbio_device *usbio = efidev_get_drvdata ( efidev );
1711 
1712  unregister_usb_bus ( usbio->bus );
1713  free_usb_bus ( usbio->bus );
1714  free ( usbio->interface );
1715  free ( usbio->path );
1716  free ( usbio->config );
1717  list_del ( &usbio->dev.siblings );
1720  free ( usbio );
1721 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct device dev
Generic device.
Definition: usbio.h:132
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:21
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
void unregister_usb_bus(struct usb_bus *bus)
Unregister USB bus.
Definition: usb.c:2104
struct usb_bus * bus
USB bus.
Definition: usbio.h:148
EFI_GUID efi_usb_io_protocol_guid
USB I/O protocol GUID.
Definition: efi_guid.c:296
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:33
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
Definition: efi_driver.h:83
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
Definition: usbio.h:138
struct usb_configuration_descriptor * config
Configuration descriptor.
Definition: usbio.h:135
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition: usbio.h:145
EFI_SYSTEM_TABLE * efi_systab
A USB I/O protocol device.
Definition: usbio.h:126
uint16_t handle
Handle.
Definition: smbios.h:16
void free_usb_bus(struct usb_bus *bus)
Free USB bus.
Definition: usb.c:2128
Definition: efi.h:55

References EFI_SYSTEM_TABLE::BootServices, usbio_device::bus, EFI_BOOT_SERVICES::CloseProtocol, usbio_device::config, usbio_device::dev, efi_device::device, efi_image_handle, efi_systab, efi_usb_io_protocol_guid, efidev_get_drvdata(), free, free_usb_bus(), handle, usbio_device::interface, list_del, usbio_device::path, device::siblings, and unregister_usb_bus().

◆ __efi_driver()

struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_NORMAL  )

EFI USB I/O driver.

Variable Documentation

◆ usbio_control_operations

struct usbio_operations usbio_control_operations
static
Initial value:
= {
}
static void usbio_control_close(struct usbio_endpoint *endpoint __unused)
Close control endpoint.
Definition: usbio.c:304
static int usbio_control_open(struct usbio_endpoint *endpoint __unused)
Open control endpoint.
Definition: usbio.c:293
static void usbio_control_poll(struct usbio_endpoint *endpoint)
Poll control endpoint.
Definition: usbio.c:314

Control endpoint operations.

Definition at line 423 of file usbio.c.

Referenced by usbio_endpoint_open().

◆ usbio_bulk_in_operations

struct usbio_operations usbio_bulk_in_operations
static
Initial value:
= {
}
static void usbio_bulk_in_close(struct usbio_endpoint *endpoint __unused)
Close bulk IN endpoint.
Definition: usbio.c:453
static void usbio_bulk_in_poll(struct usbio_endpoint *endpoint)
Poll bulk IN endpoint.
Definition: usbio.c:463
static int usbio_bulk_in_open(struct usbio_endpoint *endpoint __unused)
Open bulk IN endpoint.
Definition: usbio.c:442

Bulk endpoint operations.

Definition at line 516 of file usbio.c.

Referenced by usbio_endpoint_open().

◆ usbio_bulk_out_operations

struct usbio_operations usbio_bulk_out_operations
static
Initial value:
= {
}
static void usbio_bulk_out_poll(struct usbio_endpoint *endpoint)
Poll bulk OUT endpoint.
Definition: usbio.c:556
static int usbio_bulk_out_open(struct usbio_endpoint *endpoint __unused)
Open bulk OUT endpoint.
Definition: usbio.c:535
static void usbio_bulk_out_close(struct usbio_endpoint *endpoint __unused)
Close bulk OUT endpoint.
Definition: usbio.c:546

Bulk endpoint operations.

Definition at line 617 of file usbio.c.

Referenced by usbio_endpoint_open().

◆ usbio_interrupt_operations

struct usbio_operations usbio_interrupt_operations
static
Initial value:
= {
}
static void usbio_interrupt_poll(struct usbio_endpoint *endpoint)
Poll interrupt endpoint.
Definition: usbio.c:783
static void usbio_interrupt_close(struct usbio_endpoint *endpoint)
Close interrupt endpoint.
Definition: usbio.c:766
static int usbio_interrupt_open(struct usbio_endpoint *endpoint)
Open interrupt endpoint.
Definition: usbio.c:708

Interrupt endpoint operations.

Definition at line 815 of file usbio.c.

Referenced by usbio_endpoint_open().

◆ usbio_operations

USB I/O host controller driver operations.

Definition at line 1259 of file usbio.c.