iPXE
usbnet.h
Go to the documentation of this file.
1#ifndef _IPXE_USBNET_H
2#define _IPXE_USBNET_H
3
4/** @file
5 *
6 * USB network devices
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/usb.h>
14
15/** A USB network device */
17 /** USB function */
19
20 /** Communications interface */
21 unsigned int comms;
22 /** Data interface */
23 unsigned int data;
24 /** Alternate setting for data interface */
25 unsigned int alternate;
26
27 /** Interrupt endpoint */
29 /** Bulk IN endpoint */
31 /** Bulk OUT endpoint */
33};
34
35/**
36 * Initialise USB network device
37 *
38 * @v usbnet USB network device
39 * @v func USB function
40 * @v intr Interrupt endpoint operations, or NULL
41 * @v in Bulk IN endpoint operations
42 * @v out Bulk OUT endpoint operations
43 */
44static inline __attribute__ (( always_inline )) void
45usbnet_init ( struct usbnet_device *usbnet, struct usb_function *func,
49 struct usb_device *usb = func->usb;
50
51 usbnet->func = func;
52 usb_endpoint_init ( &usbnet->intr, usb, intr );
53 usb_endpoint_init ( &usbnet->in, usb, in );
54 usb_endpoint_init ( &usbnet->out, usb, out );
55}
56
57/**
58 * Check if USB network device has an interrupt endpoint
59 *
60 * @v usbnet USB network device
61 * @ret has_intr Device has an interrupt endpoint
62 */
63static inline __attribute__ (( always_inline )) int
64usbnet_has_intr ( struct usbnet_device *usbnet ) {
65
66 return ( usbnet->intr.driver != NULL );
67}
68
69extern int usbnet_open ( struct usbnet_device *usbnet );
70extern void usbnet_close ( struct usbnet_device *usbnet );
71extern int usbnet_refill ( struct usbnet_device *usbnet );
72extern int usbnet_describe ( struct usbnet_device *usbnet,
73 struct usb_configuration_descriptor *config );
74
75#endif /* _IPXE_USBNET_H */
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
__be32 in[4]
Definition CIB_PRM.h:7
__be32 out[4]
Definition CIB_PRM.h:8
uint8_t intr
Interrupts enabled.
Definition ena.h:3
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
Universal Serial Bus (USB)
static void usb_endpoint_init(struct usb_endpoint *ep, struct usb_device *usb, struct usb_endpoint_driver_operations *driver)
Initialise USB endpoint.
Definition usb.h:540
A USB configuration descriptor.
Definition usb.h:210
A USB device.
Definition usb.h:723
USB endpoint driver operations.
Definition usb.h:489
A USB endpoint.
Definition usb.h:404
struct usb_endpoint_driver_operations * driver
Driver operations.
Definition usb.h:431
A USB function.
Definition usb.h:674
struct usb_device * usb
USB device.
Definition usb.h:678
A USB network device.
Definition usbnet.h:16
unsigned int alternate
Alternate setting for data interface.
Definition usbnet.h:25
struct usb_function * func
USB function.
Definition usbnet.h:18
struct usb_endpoint out
Bulk OUT endpoint.
Definition usbnet.h:32
struct usb_endpoint intr
Interrupt endpoint.
Definition usbnet.h:28
unsigned int comms
Communications interface.
Definition usbnet.h:21
struct usb_endpoint in
Bulk IN endpoint.
Definition usbnet.h:30
unsigned int data
Data interface.
Definition usbnet.h:23
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
Definition usbnet.c:152
static int usbnet_has_intr(struct usbnet_device *usbnet)
Check if USB network device has an interrupt endpoint.
Definition usbnet.h:64
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition usbnet.c:55
static void usbnet_init(struct usbnet_device *usbnet, struct usb_function *func, struct usb_endpoint_driver_operations *intr, struct usb_endpoint_driver_operations *in, struct usb_endpoint_driver_operations *out)
Initialise USB network device.
Definition usbnet.h:45
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition usbnet.c:128
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition usbnet.c:278