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
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/usb.h>
14
15/** Class code for communications devices */
16#define USB_CLASS_CDC 2
17
18/** Send encapsulated command */
19#define CDC_SEND_ENCAPSULATED_COMMAND \
20 ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
21 USB_REQUEST_TYPE ( 0x00 ) )
22
23/** Get encapsulated response */
24#define CDC_GET_ENCAPSULATED_RESPONSE \
25 ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
26 USB_REQUEST_TYPE ( 0x01 ) )
27
28/** Union functional descriptor */
30 /** Descriptor header */
32 /** Descriptor subtype */
34 /** Interfaces (variable-length) */
36} __attribute__ (( packed ));
37
38/** Union functional descriptor subtype */
39#define CDC_SUBTYPE_UNION 6
40
41/** Ethernet descriptor subtype */
42#define CDC_SUBTYPE_ETHERNET 15
43
44/** Response available */
45#define CDC_RESPONSE_AVAILABLE \
46 ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
47 USB_REQUEST_TYPE ( 0x01 ) )
48
49/** Network connection notification */
50#define CDC_NETWORK_CONNECTION \
51 ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
52 USB_REQUEST_TYPE ( 0x00 ) )
53
54/** Connection speed change notification */
55#define CDC_CONNECTION_SPEED_CHANGE \
56 ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
57 USB_REQUEST_TYPE ( 0x2a ) )
58
59/** Connection speed change notification */
61 /** Downlink bit rate, in bits per second */
63 /** Uplink bit rate, in bits per second */
65} __attribute__ (( packed ));
66
67extern struct cdc_union_descriptor *
70
71/**
72 * Send encapsulated command
73 *
74 * @v usb USB device
75 * @v interface Interface number
76 * @v data Command
77 * @v len Length of command
78 * @ret rc Return status code
79 */
80static inline __attribute__ (( always_inline )) int
82 void *data, size_t len ) {
83
85 data, len );
86}
87
88/**
89* Get encapsulated response
90*
91* @v usb USB device
92* @v interface Interface number
93* @v data Response buffer
94* @v len Length of response buffer
95* @ret rc Return status code
96*/
97static inline __attribute__ (( always_inline )) int
99 void *data, size_t len ) {
100
102 data, len );
103}
104
105#endif /* _IPXE_CDC_H */
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
#define CDC_GET_ENCAPSULATED_RESPONSE
Get encapsulated response.
Definition cdc.h:24
#define CDC_SEND_ENCAPSULATED_COMMAND
Send encapsulated command.
Definition cdc.h:19
static int cdc_get_encapsulated_response(struct usb_device *usb, unsigned int interface, void *data, size_t len)
Get encapsulated response.
Definition cdc.h:98
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:45
static int cdc_send_encapsulated_command(struct usb_device *usb, unsigned int interface, void *data, size_t len)
Send encapsulated command.
Definition cdc.h:81
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
#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)
Connection speed change notification.
Definition cdc.h:60
uint32_t down
Downlink bit rate, in bits per second.
Definition cdc.h:62
uint32_t up
Uplink bit rate, in bits per second.
Definition cdc.h:64
Union functional descriptor.
Definition cdc.h:29
uint8_t subtype
Descriptor subtype.
Definition cdc.h:33
uint8_t interface[1]
Interfaces (variable-length)
Definition cdc.h:35
struct usb_descriptor_header header
Descriptor header.
Definition cdc.h:31
An object interface.
Definition interface.h:125
A USB configuration descriptor.
Definition usb.h:210
A USB descriptor header.
Definition usb.h:173
A USB device.
Definition usb.h:723
A USB interface descriptor.
Definition usb.h:245
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:784