iPXE
cdc.h
Go to the documentation of this file.
1 #ifndef _IPXE_CDC_H
2 #define _IPXE_CDC_H
3 
4 /** @file
5  *
6  * USB Communications Device Class (CDC)
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <ipxe/usb.h>
13 
14 /** Class code for communications devices */
15 #define USB_CLASS_CDC 2
16 
17 /** Send encapsulated command */
18 #define CDC_SEND_ENCAPSULATED_COMMAND \
19  ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
20  USB_REQUEST_TYPE ( 0x00 ) )
21 
22 /** Get encapsulated response */
23 #define CDC_GET_ENCAPSULATED_RESPONSE \
24  ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
25  USB_REQUEST_TYPE ( 0x01 ) )
26 
27 /** Union functional descriptor */
29  /** Descriptor header */
31  /** Descriptor subtype */
33  /** Interfaces (variable-length) */
35 } __attribute__ (( packed ));
36 
37 /** Union functional descriptor subtype */
38 #define CDC_SUBTYPE_UNION 6
39 
40 /** Ethernet descriptor subtype */
41 #define CDC_SUBTYPE_ETHERNET 15
42 
43 /** Response available */
44 #define CDC_RESPONSE_AVAILABLE \
45  ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
46  USB_REQUEST_TYPE ( 0x01 ) )
47 
48 /** Network connection notification */
49 #define CDC_NETWORK_CONNECTION \
50  ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
51  USB_REQUEST_TYPE ( 0x00 ) )
52 
53 /** Connection speed change notification */
54 #define CDC_CONNECTION_SPEED_CHANGE \
55  ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
56  USB_REQUEST_TYPE ( 0x2a ) )
57 
58 /** Connection speed change notification */
60  /** Downlink bit rate, in bits per second */
62  /** Uplink bit rate, in bits per second */
64 } __attribute__ (( packed ));
65 
66 extern struct cdc_union_descriptor *
69 
70 /**
71  * Send encapsulated command
72  *
73  * @v usb USB device
74  * @v interface Interface number
75  * @v data Command
76  * @v len Length of command
77  * @ret rc Return status code
78  */
79 static inline __attribute__ (( always_inline )) int
81  void *data, size_t len ) {
82 
84  data, len );
85 }
86 
87 /**
88 * Get encapsulated response
89 *
90 * @v usb USB device
91 * @v interface Interface number
92 * @v data Response buffer
93 * @v len Length of response buffer
94 * @ret rc Return status code
95 */
96 static inline __attribute__ (( always_inline )) int
98  void *data, size_t len ) {
99 
101  data, len );
102 }
103 
104 #endif /* _IPXE_CDC_H */
#define __attribute__(x)
Definition: compiler.h:10
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint32_t down
Downlink bit rate, in bits per second.
Definition: cdc.h:61
uint32_t up
Uplink bit rate, in bits per second.
Definition: cdc.h:63
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
Definition: usb.c:783
A USB interface descriptor.
Definition: usb.h:230
An object interface.
Definition: interface.h:124
static int cdc_get_encapsulated_response(struct usb_device *usb, unsigned int interface, void *data, size_t len)
Get encapsulated response.
Definition: cdc.h:97
struct usb_descriptor_header header
Descriptor header.
Definition: cdc.h:30
Union functional descriptor.
Definition: cdc.h:28
static int cdc_send_encapsulated_command(struct usb_device *usb, unsigned int interface, void *data, size_t len)
Send encapsulated command.
Definition: cdc.h:80
uint8_t subtype
Descriptor subtype.
Definition: cdc.h:32
A USB device.
Definition: usb.h:708
unsigned char uint8_t
Definition: stdint.h:10
struct cdc_union_descriptor * cdc_union_descriptor(struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface)
Locate CDC union functional descriptor.
Definition: cdc.c:44
unsigned int uint32_t
Definition: stdint.h:12
#define CDC_SEND_ENCAPSULATED_COMMAND
Send encapsulated command.
Definition: cdc.h:18
A USB descriptor header.
Definition: usb.h:158
A USB configuration descriptor.
Definition: usb.h:195
uint32_t len
Length.
Definition: ena.h:14
Universal Serial Bus (USB)
uint8_t data[48]
Additional event data.
Definition: ena.h:22
Connection speed change notification.
Definition: cdc.h:59
#define CDC_GET_ENCAPSULATED_RESPONSE
Get encapsulated response.
Definition: cdc.h:23