iPXE
Data Structures | Macros | Functions
cdc.h File Reference

USB Communications Device Class (CDC) More...

#include <ipxe/usb.h>

Go to the source code of this file.

Data Structures

struct  cdc_union_descriptor
 Union functional descriptor. More...
 
struct  cdc_connection_speed_change
 Connection speed change notification. More...
 

Macros

#define USB_CLASS_CDC   2
 Class code for communications devices. More...
 
#define CDC_SEND_ENCAPSULATED_COMMAND
 Send encapsulated command. More...
 
#define CDC_GET_ENCAPSULATED_RESPONSE
 Get encapsulated response. More...
 
#define CDC_SUBTYPE_UNION   6
 Union functional descriptor subtype. More...
 
#define CDC_SUBTYPE_ETHERNET   15
 Ethernet descriptor subtype. More...
 
#define CDC_RESPONSE_AVAILABLE
 Response available. More...
 
#define CDC_NETWORK_CONNECTION
 Network connection notification. More...
 
#define CDC_CONNECTION_SPEED_CHANGE
 Connection speed change notification. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
struct cdc_union_descriptorcdc_union_descriptor (struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface)
 Locate CDC union functional descriptor. More...
 
static int cdc_send_encapsulated_command (struct usb_device *usb, unsigned int interface, void *data, size_t len)
 Send encapsulated command. More...
 
static int cdc_get_encapsulated_response (struct usb_device *usb, unsigned int interface, void *data, size_t len)
 Get encapsulated response. More...
 

Detailed Description

USB Communications Device Class (CDC)

Definition in file cdc.h.

Macro Definition Documentation

◆ USB_CLASS_CDC

#define USB_CLASS_CDC   2

Class code for communications devices.

Definition at line 15 of file cdc.h.

◆ CDC_SEND_ENCAPSULATED_COMMAND

#define CDC_SEND_ENCAPSULATED_COMMAND
Value:
USB_REQUEST_TYPE ( 0x00 ) )
#define USB_RECIP_INTERFACE
Request recipient is an interface.
Definition: usb.h:101
#define USB_DIR_OUT
Data transfer is from host to device.
Definition: usb.h:80
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89

Send encapsulated command.

Definition at line 18 of file cdc.h.

◆ CDC_GET_ENCAPSULATED_RESPONSE

#define CDC_GET_ENCAPSULATED_RESPONSE
Value:
USB_REQUEST_TYPE ( 0x01 ) )
#define USB_RECIP_INTERFACE
Request recipient is an interface.
Definition: usb.h:101
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89
#define USB_DIR_IN
Data transfer is from device to host.
Definition: usb.h:83

Get encapsulated response.

Definition at line 23 of file cdc.h.

◆ CDC_SUBTYPE_UNION

#define CDC_SUBTYPE_UNION   6

Union functional descriptor subtype.

Definition at line 38 of file cdc.h.

◆ CDC_SUBTYPE_ETHERNET

#define CDC_SUBTYPE_ETHERNET   15

Ethernet descriptor subtype.

Definition at line 41 of file cdc.h.

◆ CDC_RESPONSE_AVAILABLE

#define CDC_RESPONSE_AVAILABLE
Value:
USB_REQUEST_TYPE ( 0x01 ) )
#define USB_RECIP_INTERFACE
Request recipient is an interface.
Definition: usb.h:101
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89
#define USB_DIR_IN
Data transfer is from device to host.
Definition: usb.h:83

Response available.

Definition at line 44 of file cdc.h.

◆ CDC_NETWORK_CONNECTION

#define CDC_NETWORK_CONNECTION
Value:
USB_REQUEST_TYPE ( 0x00 ) )
#define USB_RECIP_INTERFACE
Request recipient is an interface.
Definition: usb.h:101
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89
#define USB_DIR_IN
Data transfer is from device to host.
Definition: usb.h:83

Network connection notification.

Definition at line 49 of file cdc.h.

◆ CDC_CONNECTION_SPEED_CHANGE

#define CDC_CONNECTION_SPEED_CHANGE
Value:
USB_REQUEST_TYPE ( 0x2a ) )
#define USB_RECIP_INTERFACE
Request recipient is an interface.
Definition: usb.h:101
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89
#define USB_DIR_IN
Data transfer is from device to host.
Definition: usb.h:83

Connection speed change notification.

Definition at line 54 of file cdc.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ cdc_union_descriptor()

Locate CDC union functional descriptor.

Parameters
configConfiguration descriptor
interfaceInterface descriptor
Return values
descUnion functional descriptor, or NULL if not found

Definition at line 44 of file cdc.c.

45  {
46  struct cdc_union_descriptor *desc;
47 
48  for_each_interface_descriptor ( desc, config, interface ) {
49  if ( ( desc->header.type == USB_CS_INTERFACE_DESCRIPTOR ) &&
50  ( desc->subtype == CDC_SUBTYPE_UNION ) )
51  return desc;
52  }
53  return NULL;
54 }
#define CDC_SUBTYPE_UNION
Union functional descriptor subtype.
Definition: cdc.h:38
#define for_each_interface_descriptor(desc, config, interface)
Iterate over all configuration descriptors within an interface descriptor.
Definition: usb.h:379
An object interface.
Definition: interface.h:109
struct usb_descriptor_header header
Descriptor header.
Definition: cdc.h:30
Union functional descriptor.
Definition: cdc.h:28
uint8_t subtype
Descriptor subtype.
Definition: cdc.h:32
#define USB_CS_INTERFACE_DESCRIPTOR
A class-specific interface descriptor.
Definition: usb.h:331
uint8_t type
Descriptor type.
Definition: usb.h:162
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References CDC_SUBTYPE_UNION, for_each_interface_descriptor, cdc_union_descriptor::header, NULL, cdc_union_descriptor::subtype, usb_descriptor_header::type, and USB_CS_INTERFACE_DESCRIPTOR.

◆ cdc_send_encapsulated_command()

static int cdc_send_encapsulated_command ( struct usb_device usb,
unsigned int  interface,
void *  data,
size_t  len 
)
inlinestatic

Send encapsulated command.

Parameters
usbUSB device
interfaceInterface number
dataCommand
lenLength of command
Return values
rcReturn status code

Definition at line 80 of file cdc.h.

81  {
82 
84  data, len );
85 }
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:753
An object interface.
Definition: interface.h:109
#define CDC_SEND_ENCAPSULATED_COMMAND
Send encapsulated command.
Definition: cdc.h:18
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References CDC_SEND_ENCAPSULATED_COMMAND, data, len, and usb_control().

Referenced by acm_control_transmit().

◆ cdc_get_encapsulated_response()

static int cdc_get_encapsulated_response ( struct usb_device usb,
unsigned int  interface,
void *  data,
size_t  len 
)
inlinestatic

Get encapsulated response.

Parameters
usbUSB device
interfaceInterface number
dataResponse buffer
lenLength of response buffer
Return values
rcReturn status code

Definition at line 97 of file cdc.h.

98  {
99 
101  data, len );
102 }
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:753
An object interface.
Definition: interface.h:109
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define CDC_GET_ENCAPSULATED_RESPONSE
Get encapsulated response.
Definition: cdc.h:23

References CDC_GET_ENCAPSULATED_RESPONSE, data, len, and usb_control().

Referenced by acm_control_receive().