您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

usbnet.h 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _IPXE_USBNET_H
  2. #define _IPXE_USBNET_H
  3. /** @file
  4. *
  5. * USB network devices
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <ipxe/usb.h>
  10. /** A USB network device */
  11. struct usbnet_device {
  12. /** USB function */
  13. struct usb_function *func;
  14. /** Communications interface */
  15. unsigned int comms;
  16. /** Data interface */
  17. unsigned int data;
  18. /** Alternate setting for data interface */
  19. unsigned int alternate;
  20. /** Interrupt endpoint */
  21. struct usb_endpoint intr;
  22. /** Bulk IN endpoint */
  23. struct usb_endpoint in;
  24. /** Bulk OUT endpoint */
  25. struct usb_endpoint out;
  26. };
  27. /**
  28. * Initialise USB network device
  29. *
  30. * @v usbnet USB network device
  31. * @v func USB function
  32. * @v intr Interrupt endpoint operations, or NULL
  33. * @v in Bulk IN endpoint operations
  34. * @v out Bulk OUT endpoint operations
  35. */
  36. static inline __attribute__ (( always_inline )) void
  37. usbnet_init ( struct usbnet_device *usbnet, struct usb_function *func,
  38. struct usb_endpoint_driver_operations *intr,
  39. struct usb_endpoint_driver_operations *in,
  40. struct usb_endpoint_driver_operations *out ) {
  41. struct usb_device *usb = func->usb;
  42. usbnet->func = func;
  43. usb_endpoint_init ( &usbnet->intr, usb, intr );
  44. usb_endpoint_init ( &usbnet->in, usb, in );
  45. usb_endpoint_init ( &usbnet->out, usb, out );
  46. }
  47. /**
  48. * Check if USB network device has an interrupt endpoint
  49. *
  50. * @v usbnet USB network device
  51. * @ret has_intr Device has an interrupt endpoint
  52. */
  53. static inline __attribute__ (( always_inline )) int
  54. usbnet_has_intr ( struct usbnet_device *usbnet ) {
  55. return ( usbnet->intr.driver != NULL );
  56. }
  57. extern int usbnet_open ( struct usbnet_device *usbnet );
  58. extern void usbnet_close ( struct usbnet_device *usbnet );
  59. extern int usbnet_refill ( struct usbnet_device *usbnet );
  60. extern int usbnet_describe ( struct usbnet_device *usbnet,
  61. struct usb_configuration_descriptor *config );
  62. #endif /* _IPXE_USBNET_H */