iPXE
usbnet.h
Go to the documentation of this file.
00001 #ifndef _IPXE_USBNET_H
00002 #define _IPXE_USBNET_H
00003 
00004 /** @file
00005  *
00006  * USB network devices
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <ipxe/usb.h>
00013 
00014 /** A USB network device */
00015 struct usbnet_device {
00016         /** USB function */
00017         struct usb_function *func;
00018 
00019         /** Communications interface */
00020         unsigned int comms;
00021         /** Data interface */
00022         unsigned int data;
00023         /** Alternate setting for data interface */
00024         unsigned int alternate;
00025 
00026         /** Interrupt endpoint */
00027         struct usb_endpoint intr;
00028         /** Bulk IN endpoint */
00029         struct usb_endpoint in;
00030         /** Bulk OUT endpoint */
00031         struct usb_endpoint out;
00032 };
00033 
00034 /**
00035  * Initialise USB network device
00036  *
00037  * @v usbnet            USB network device
00038  * @v func              USB function
00039  * @v intr              Interrupt endpoint operations, or NULL
00040  * @v in                Bulk IN endpoint operations
00041  * @v out               Bulk OUT endpoint operations
00042  */
00043 static inline __attribute__ (( always_inline )) void
00044 usbnet_init ( struct usbnet_device *usbnet, struct usb_function *func,
00045               struct usb_endpoint_driver_operations *intr,
00046               struct usb_endpoint_driver_operations *in,
00047               struct usb_endpoint_driver_operations *out ) {
00048         struct usb_device *usb = func->usb;
00049 
00050         usbnet->func = func;
00051         usb_endpoint_init ( &usbnet->intr, usb, intr );
00052         usb_endpoint_init ( &usbnet->in, usb, in );
00053         usb_endpoint_init ( &usbnet->out, usb, out );
00054 }
00055 
00056 /**
00057  * Check if USB network device has an interrupt endpoint
00058  *
00059  * @v usbnet            USB network device
00060  * @ret has_intr        Device has an interrupt endpoint
00061  */
00062 static inline __attribute__ (( always_inline )) int
00063 usbnet_has_intr ( struct usbnet_device *usbnet ) {
00064 
00065         return ( usbnet->intr.driver != NULL );
00066 }
00067 
00068 extern int usbnet_open ( struct usbnet_device *usbnet );
00069 extern void usbnet_close ( struct usbnet_device *usbnet );
00070 extern int usbnet_refill ( struct usbnet_device *usbnet );
00071 extern int usbnet_describe ( struct usbnet_device *usbnet,
00072                              struct usb_configuration_descriptor *config );
00073 
00074 #endif /* _IPXE_USBNET_H */