From a92fb8d9a53ab9e534af4a9f4abe68f1160e99da Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 16 Feb 2015 14:05:45 +0000 Subject: [usb] Add generic USB network device framework Signed-off-by: Michael Brown --- src/include/ipxe/errfile.h | 1 + src/include/ipxe/usbnet.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/include/ipxe/usbnet.h (limited to 'src/include/ipxe') diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 087475494..353d8ca3a 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -163,6 +163,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define ERRFILE_netvsc ( ERRFILE_DRIVER | 0x006b0000 ) #define ERRFILE_ecm ( ERRFILE_DRIVER | 0x006c0000 ) #define ERRFILE_ncm ( ERRFILE_DRIVER | 0x006d0000 ) +#define ERRFILE_usbnet ( ERRFILE_DRIVER | 0x006e0000 ) #define ERRFILE_scsi ( ERRFILE_DRIVER | 0x00700000 ) #define ERRFILE_arbel ( ERRFILE_DRIVER | 0x00710000 ) diff --git a/src/include/ipxe/usbnet.h b/src/include/ipxe/usbnet.h new file mode 100644 index 000000000..b5c1e882c --- /dev/null +++ b/src/include/ipxe/usbnet.h @@ -0,0 +1,62 @@ +#ifndef _IPXE_USBNET_H +#define _IPXE_USBNET_H + +/** @file + * + * USB network devices + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include + +/** A USB network device */ +struct usbnet_device { + /** USB function */ + struct usb_function *func; + + /** Communications interface */ + unsigned int comms; + /** Data interface */ + unsigned int data; + /** Alternate setting for data interface */ + unsigned int alternate; + + /** Interrupt endpoint */ + struct usb_endpoint intr; + /** Bulk IN endpoint */ + struct usb_endpoint in; + /** Bulk OUT endpoint */ + struct usb_endpoint out; +}; + +/** + * Initialise USB network device + * + * @v usbnet USB network device + * @v func USB function + * @v intr Interrupt endpoint operations + * @v in Bulk IN endpoint operations + * @v out Bulk OUT endpoint operations + */ +static inline __attribute__ (( always_inline )) 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 ) { + struct usb_device *usb = func->usb; + + usbnet->func = func; + usb_endpoint_init ( &usbnet->intr, usb, intr ); + usb_endpoint_init ( &usbnet->in, usb, in ); + usb_endpoint_init ( &usbnet->out, usb, out ); +} + +extern int usbnet_open ( struct usbnet_device *usbnet ); +extern void usbnet_close ( struct usbnet_device *usbnet ); +extern int usbnet_refill ( struct usbnet_device *usbnet ); +extern int usbnet_describe ( struct usbnet_device *usbnet, + struct usb_configuration_descriptor *config ); + +#endif /* _IPXE_USBNET_H */ -- cgit v1.2.3-55-g7522