iPXE
usbio.h
Go to the documentation of this file.
1#ifndef _USBIO_H
2#define _USBIO_H
3
4/** @file
5 *
6 * EFI_USB_IO_PROTOCOL pseudo Host Controller Interface driver
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12#include <ipxe/list.h>
13#include <ipxe/device.h>
14#include <ipxe/efi/efi.h>
17#include <ipxe/usb.h>
18
19/** USB I/O maximum transfer size
20 *
21 * The API provides no way to discover the maximum transfer size.
22 * Assume the 16kB supported by EHCI.
23 */
24#define USBIO_MTU 16384
25
26/** USB I/O interrupt ring buffer size
27 *
28 * This is a policy decision.
29 */
30#define USBIO_INTR_COUNT 4
31
32/** A USB interrupt ring buffer */
34 /** USB I/O endpoint */
36 /** Producer counter */
37 unsigned int prod;
38 /** Consumer counter */
39 unsigned int cons;
40 /** Data buffers */
42 /** Lengths */
44};
45
46/** USB I/O ring buffer size
47 *
48 * This is a policy decision.
49 */
50#define USBIO_RING_COUNT 64
51
52/** A USB I/O endpoint */
54 /** USB I/O device */
56 /** USB endpoint */
58 /** List of endpoints */
60 /** USB I/O endpoint operations */
62
63 /** Containing interface number */
64 unsigned int interface;
65 /** EFI handle */
67 /** USB I/O protocol */
69
70 /** Producer counter */
71 unsigned int prod;
72 /** Consumer counter */
73 unsigned int cons;
74 /** I/O buffers */
76 /** Flags */
78
79 /** Interrupt ring buffer (if applicable) */
81};
82
83/** USB I/O transfer flags */
85 /** This is a message transfer */
87 /** This transfer requires zero-length packet termination */
88 USBIO_ZLEN = 0x02,
89};
90
91/** USB I/O endpoint operations */
93 /** Open endpoint
94 *
95 * @v endpoint Endpoint
96 * @ret rc Return status code
97 */
98 int ( * open ) ( struct usbio_endpoint *endpoint );
99 /** Close endpoint
100 *
101 * @v endpoint Endpoint
102 */
103 void ( * close ) ( struct usbio_endpoint *endpoint );
104 /** Poll endpoint
105 *
106 * @v endpoint Endpoint
107 */
108 void ( * poll ) ( struct usbio_endpoint *endpoint );
109};
110
111/** A USB I/O protocol interface */
113 /** EFI device handle */
115 /** USB I/O protocol */
117 /** Usage count */
118 unsigned int count;
119};
120
121/** A USB I/O protocol device
122 *
123 * We model each externally-provided USB I/O protocol device as a host
124 * controller containing a root hub with a single port.
125 */
127 /** EFI device handle */
129 /** USB I/O protocol */
131 /** Generic device */
132 struct device dev;
133
134 /** Configuration descriptor */
136
137 /** Device path */
139 /** Final component of USB device path */
141
142 /** First interface number */
144 /** USB I/O protocol interfaces */
146
147 /** USB bus */
148 struct usb_bus *bus;
149 /** List of endpoints */
151};
152
153#endif /* _USBIO_H */
The device path protocol as defined in UEFI 2.0.
EFI Usb I/O Protocol as defined in UEFI specification.
struct _EFI_USB_IO_PROTOCOL EFI_USB_IO_PROTOCOL
Definition UsbIo.h:29
unsigned char uint8_t
Definition stdint.h:10
Device model.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
EFI API.
#define EFI_HANDLE
Definition efi.h:53
Universal Serial Bus (USB)
Linked lists.
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition DevicePath.h:46
A hardware device.
Definition device.h:77
A persistent I/O buffer.
Definition iobuf.h:38
A doubly-linked list entry (or list head)
Definition list.h:19
A USB bus.
Definition usb.h:966
A USB configuration descriptor.
Definition usb.h:210
A USB endpoint.
Definition usb.h:404
A USB I/O protocol device.
Definition usbio.h:126
uint8_t first
First interface number.
Definition usbio.h:143
struct list_head endpoints
List of endpoints.
Definition usbio.h:150
struct usb_bus * bus
USB bus.
Definition usbio.h:148
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition usbio.h:145
struct device dev
Generic device.
Definition usbio.h:132
EFI_HANDLE handle
EFI device handle.
Definition usbio.h:128
USB_DEVICE_PATH * usbpath
Final component of USB device path.
Definition usbio.h:140
struct usb_configuration_descriptor * config
Configuration descriptor.
Definition usbio.h:135
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
Definition usbio.h:138
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition usbio.h:130
A USB I/O endpoint.
Definition usbio.h:53
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition usbio.h:68
EFI_HANDLE handle
EFI handle.
Definition usbio.h:66
struct usbio_interrupt_ring * intr
Interrupt ring buffer (if applicable)
Definition usbio.h:80
unsigned int cons
Consumer counter.
Definition usbio.h:73
struct usb_endpoint * ep
USB endpoint.
Definition usbio.h:57
struct io_buffer * iobuf[USBIO_RING_COUNT]
I/O buffers.
Definition usbio.h:75
struct usbio_operations * op
USB I/O endpoint operations.
Definition usbio.h:61
struct usbio_device * usbio
USB I/O device.
Definition usbio.h:55
unsigned int interface
Containing interface number.
Definition usbio.h:64
struct list_head list
List of endpoints.
Definition usbio.h:59
unsigned int prod
Producer counter.
Definition usbio.h:71
uint8_t flags[USBIO_RING_COUNT]
Flags.
Definition usbio.h:77
A USB I/O protocol interface.
Definition usbio.h:112
unsigned int count
Usage count.
Definition usbio.h:118
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition usbio.h:116
EFI_HANDLE handle
EFI device handle.
Definition usbio.h:114
A USB interrupt ring buffer.
Definition usbio.h:33
unsigned int prod
Producer counter.
Definition usbio.h:37
unsigned int cons
Consumer counter.
Definition usbio.h:39
void * data[USBIO_INTR_COUNT]
Data buffers.
Definition usbio.h:41
struct usbio_endpoint * endpoint
USB I/O endpoint.
Definition usbio.h:35
size_t len[USBIO_INTR_COUNT]
Lengths.
Definition usbio.h:43
USB I/O endpoint operations.
Definition usbio.h:92
void(* close)(struct usbio_endpoint *endpoint)
Close endpoint.
Definition usbio.h:103
int(* open)(struct usbio_endpoint *endpoint)
Open endpoint.
Definition usbio.h:98
void(* poll)(struct usbio_endpoint *endpoint)
Poll endpoint.
Definition usbio.h:108
usbio_flags
USB I/O transfer flags.
Definition usbio.h:84
@ USBIO_MESSAGE
This is a message transfer.
Definition usbio.h:86
@ USBIO_ZLEN
This transfer requires zero-length packet termination.
Definition usbio.h:88
#define USBIO_RING_COUNT
USB I/O ring buffer size.
Definition usbio.h:50
#define USBIO_INTR_COUNT
USB I/O interrupt ring buffer size.
Definition usbio.h:30