6 * EFI_USB_IO_PROTOCOL pseudo Host Controller Interface driver
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL
);
12 #include <ipxe/list.h>
13 #include <ipxe/device.h>
14 #include <ipxe/efi/efi.h>
15 #include <ipxe/efi/Protocol/UsbIo.h>
16 #include <ipxe/efi/Protocol/DevicePath.h>
19 /** USB I/O maximum transfer size
21 * The API provides no way to discover the maximum transfer size.
22 * Assume the 16kB supported by EHCI.
24 #define USBIO_MTU 16384
26 /** USB I/O interrupt ring buffer size
28 * This is a policy decision.
30 #define USBIO_INTR_COUNT 4
32 /** A USB interrupt ring buffer */
33 struct usbio_interrupt_ring
{
34 /** USB I/O endpoint */
35 struct usbio_endpoint
*endpoint
;
36 /** Producer counter */
38 /** Consumer counter */
41 void *data
[USBIO_INTR_COUNT
];
43 size_t len
[USBIO_INTR_COUNT
];
46 /** USB I/O ring buffer size
48 * This is a policy decision.
50 #define USBIO_RING_COUNT 64
52 /** A USB I/O endpoint */
53 struct usbio_endpoint
{
55 struct usbio_device
*usbio
;
57 struct usb_endpoint
*ep
;
58 /** List of endpoints */
59 struct list_head list
;
60 /** USB I/O endpoint operations */
61 struct usbio_operations
*op
;
63 /** Containing interface number */
64 unsigned int interface
;
67 /** USB I/O protocol */
68 EFI_USB_IO_PROTOCOL
*io
;
70 /** Producer counter */
72 /** Consumer counter */
75 struct io_buffer
*iobuf
[USBIO_RING_COUNT
];
77 uint8_t flags
[USBIO_RING_COUNT
];
79 /** Interrupt ring buffer (if applicable) */
80 struct usbio_interrupt_ring
*intr
;
83 /** USB I/O transfer flags */
85 /** This is a message transfer */
87 /** This transfer requires zero-length packet termination */
91 /** USB I/O endpoint operations */
92 struct usbio_operations
{
95 * @v endpoint Endpoint
96 * @ret rc Return status code
98 int ( * open
) ( struct usbio_endpoint
*endpoint
);
101 * @v endpoint Endpoint
103 void ( * close
) ( struct usbio_endpoint
*endpoint
);
106 * @v endpoint Endpoint
108 void ( * poll
) ( struct usbio_endpoint
*endpoint
);
111 /** A USB I/O protocol interface */
112 struct usbio_interface
{
113 /** EFI device handle */
115 /** USB I/O protocol */
116 EFI_USB_IO_PROTOCOL
*io
;
121 /** A USB I/O protocol device
123 * We model each externally-provided USB I/O protocol device as a host
124 * controller containing a root hub with a single port.
126 struct usbio_device
{
127 /** EFI device handle */
129 /** USB I/O protocol */
130 EFI_USB_IO_PROTOCOL
*io
;
131 /** Generic device */
134 /** Configuration descriptor */
135 struct usb_configuration_descriptor
*config
;
138 EFI_DEVICE_PATH_PROTOCOL
*path
;
139 /** Final component of USB device path */
140 USB_DEVICE_PATH
*usbpath
;
142 /** First interface number */
144 /** USB I/O protocol interfaces */
145 struct usbio_interface
*interface
;
149 /** List of endpoints */
150 struct list_head endpoints
;
153 #endif /* _USBIO_H */