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 
10 FILE_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 */
57  struct usb_endpoint *ep;
58  /** List of endpoints */
59  struct list_head list;
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 */
86  USBIO_MESSAGE = 0x01,
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  */
126 struct usbio_device {
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 */
A USB I/O protocol interface.
Definition: usbio.h:112
struct usbio_interrupt_ring * intr
Interrupt ring buffer (if applicable)
Definition: usbio.h:80
struct usbio_device * usbio
USB I/O device.
Definition: usbio.h:55
struct device dev
Generic device.
Definition: usbio.h:132
The device path protocol as defined in UEFI 2.0.
The EFI_USB_IO_PROTOCOL provides four basic transfers types described in the USB 1....
Definition: UsbIo.h:485
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
unsigned int cons
Consumer counter.
Definition: usbio.h:39
#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
A doubly-linked list entry (or list head)
Definition: list.h:18
A USB interrupt ring buffer.
Definition: usbio.h:33
uint8_t flags[USBIO_RING_COUNT]
Flags.
Definition: usbio.h:77
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A hardware device.
Definition: device.h:73
A USB endpoint.
Definition: usb.h:389
size_t len[USBIO_INTR_COUNT]
Lengths.
Definition: usbio.h:43
unsigned int interface
Containing interface number.
Definition: usbio.h:64
void(* poll)(struct usbio_endpoint *endpoint)
Poll endpoint.
Definition: usbio.h:108
EFI_HANDLE handle
EFI handle.
Definition: usbio.h:66
This transfer requires zero-length packet termination.
Definition: usbio.h:88
struct list_head endpoints
List of endpoints.
Definition: usbio.h:150
unsigned int count
Usage count.
Definition: usbio.h:118
struct usb_bus * bus
USB bus.
Definition: usbio.h:148
Linked lists.
unsigned int prod
Producer counter.
Definition: usbio.h:37
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:68
uint8_t first
First interface number.
Definition: usbio.h:143
void(* close)(struct usbio_endpoint *endpoint)
Close endpoint.
Definition: usbio.h:103
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
Definition: usbio.h:138
unsigned char uint8_t
Definition: stdint.h:10
struct usbio_operations * op
USB I/O endpoint operations.
Definition: usbio.h:61
struct usb_configuration_descriptor * config
Configuration descriptor.
Definition: usbio.h:135
struct usbio_endpoint * endpoint
USB I/O endpoint.
Definition: usbio.h:35
EFI API.
unsigned int prod
Producer counter.
Definition: usbio.h:71
EFI Usb I/O Protocol as defined in UEFI specification.
A USB I/O endpoint.
Definition: usbio.h:53
A USB configuration descriptor.
Definition: usb.h:195
struct usbio_interface * interface
USB I/O protocol interfaces.
Definition: usbio.h:145
#define USBIO_INTR_COUNT
USB I/O interrupt ring buffer size.
Definition: usbio.h:30
USB_DEVICE_PATH * usbpath
Final component of USB device path.
Definition: usbio.h:140
Universal Serial Bus (USB)
EFI_USB_IO_PROTOCOL * io
USB I/O protocol.
Definition: usbio.h:130
unsigned int cons
Consumer counter.
Definition: usbio.h:73
int(* open)(struct usbio_endpoint *endpoint)
Open endpoint.
Definition: usbio.h:98
struct list_head list
List of endpoints.
Definition: usbio.h:59
Device model.
struct usb_endpoint * ep
USB endpoint.
Definition: usbio.h:57
void * data[USBIO_INTR_COUNT]
Data buffers.
Definition: usbio.h:41
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:128
A USB I/O protocol device.
Definition: usbio.h:126
USB I/O endpoint operations.
Definition: usbio.h:92
EFI_HANDLE handle
EFI device handle.
Definition: usbio.h:114
A USB bus.
Definition: usb.h:949
usbio_flags
USB I/O transfer flags.
Definition: usbio.h:84
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
A persistent I/O buffer.
Definition: iobuf.h:32