iPXE
usbhub.h File Reference

USB hubs. More...

#include <ipxe/usb.h>
#include <ipxe/list.h>
#include <ipxe/process.h>

Go to the source code of this file.

Data Structures

struct  usb_hub_descriptor_basic
 A basic USB hub descriptor. More...
struct  usb_hub_descriptor_enhanced
 An enhanced USB hub descriptor. More...
union  usb_hub_descriptor
 A USB hub descriptor. More...
struct  usb_hub_port_status
 Port status. More...
struct  usb_hub_device
 A USB hub device. More...

Macros

#define USB_HUB_RECIP_PORT   ( 3 << 0 )
 Request recipient is a port.
#define USB_HUB_DESCRIPTOR   41
 A basic USB hub descriptor.
#define USB_HUB_DESCRIPTOR_ENHANCED   42
 An enhanced USB hub descriptor.
#define USB_HUB_PORT_CONNECTION   0
 Current connect status feature.
#define USB_HUB_PORT_ENABLE   1
 Port enabled/disabled feature.
#define USB_HUB_PORT_RESET   4
 Port reset feature.
#define USB_HUB_PORT_POWER   8
 Port power feature.
#define USB_HUB_PORT_LOW_SPEED   9
 Low-speed device attached.
#define USB_HUB_PORT_HIGH_SPEED   10
 High-speed device attached.
#define USB_HUB_C_PORT_CONNECTION   16
 Connect status changed.
#define USB_HUB_C_PORT_ENABLE   17
 Port enable/disable changed.
#define USB_HUB_C_PORT_SUSPEND   18
 Suspend changed.
#define USB_HUB_C_PORT_OVER_CURRENT   19
 Over-current indicator changed.
#define USB_HUB_C_PORT_RESET   20
 Reset changed.
#define USB_HUB_C_PORT_LINK_STATE   25
 Link state changed.
#define USB_HUB_C_PORT_CONFIG_ERROR   26
 Configuration error.
#define USB_HUB_C_FEATURE(bit)
 Calculate feature from change bit number.
#define USB_HUB_FEATURES
 USB features.
#define USB_HUB_FEATURES_ENHANCED
 USB features for enhanced hubs.
#define USB_HUB_SET_HUB_DEPTH
 Set hub depth.
#define USB_HUB_CLEAR_TT_BUFFER
 Clear transaction translator buffer.
#define USB_HUB_TT_SINGLE   1
 Transaction translator port value for single-TT hubs.
#define USB_HUB_SLOW_START   0x0001
 Hub requires additional settling delay.
#define USB_HUB_SLOW_START_DELAY_MS   500
 Additional setting delay for out-of-spec hubs.
#define USB_HUB_INTR_FILL   4
 Interrupt ring fill level.
#define USB_HUB_ENABLE_MAX_WAIT_MS   100
 Maximum time to wait for port to become enabled.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int usb_hub_get_descriptor (struct usb_device *usb, int enhanced, union usb_hub_descriptor *data)
 Get hub descriptor.
static int usb_hub_get_port_status (struct usb_device *usb, unsigned int port, struct usb_hub_port_status *status)
 Get port status.
static int usb_hub_clear_port_feature (struct usb_device *usb, unsigned int port, unsigned int feature, unsigned int index)
 Clear port feature.
static int usb_hub_set_port_feature (struct usb_device *usb, unsigned int port, unsigned int feature, unsigned int index)
 Set port feature.
static int usb_hub_set_hub_depth (struct usb_device *usb, unsigned int depth)
 Set hub depth.
static int usb_hub_clear_tt_buffer (struct usb_device *usb, unsigned int device, unsigned int endpoint, unsigned int attributes, unsigned int tt_port)
 Clear transaction translator buffer.

Detailed Description

USB hubs.

Definition in file usbhub.h.

Macro Definition Documentation

◆ USB_HUB_RECIP_PORT

#define USB_HUB_RECIP_PORT   ( 3 << 0 )

Request recipient is a port.

Definition at line 18 of file usbhub.h.

Referenced by usb_hub_clear_port_feature(), usb_hub_get_port_status(), and usb_hub_set_port_feature().

◆ USB_HUB_DESCRIPTOR

#define USB_HUB_DESCRIPTOR   41

A basic USB hub descriptor.

Definition at line 35 of file usbhub.h.

Referenced by usb_hub_get_descriptor().

◆ USB_HUB_DESCRIPTOR_ENHANCED

#define USB_HUB_DESCRIPTOR_ENHANCED   42

An enhanced USB hub descriptor.

Definition at line 50 of file usbhub.h.

Referenced by usb_hub_get_descriptor().

◆ USB_HUB_PORT_CONNECTION

#define USB_HUB_PORT_CONNECTION   0

Current connect status feature.

Definition at line 71 of file usbhub.h.

Referenced by hub_speed().

◆ USB_HUB_PORT_ENABLE

#define USB_HUB_PORT_ENABLE   1

Port enabled/disabled feature.

Definition at line 74 of file usbhub.h.

Referenced by hub_disable(), and hub_enable().

◆ USB_HUB_PORT_RESET

#define USB_HUB_PORT_RESET   4

Port reset feature.

Definition at line 77 of file usbhub.h.

Referenced by hub_enable().

◆ USB_HUB_PORT_POWER

#define USB_HUB_PORT_POWER   8

Port power feature.

Definition at line 80 of file usbhub.h.

Referenced by hub_open().

◆ USB_HUB_PORT_LOW_SPEED

#define USB_HUB_PORT_LOW_SPEED   9

Low-speed device attached.

Definition at line 83 of file usbhub.h.

Referenced by hub_speed().

◆ USB_HUB_PORT_HIGH_SPEED

#define USB_HUB_PORT_HIGH_SPEED   10

High-speed device attached.

Definition at line 86 of file usbhub.h.

Referenced by hub_speed().

◆ USB_HUB_C_PORT_CONNECTION

#define USB_HUB_C_PORT_CONNECTION   16

Connect status changed.

Definition at line 89 of file usbhub.h.

◆ USB_HUB_C_PORT_ENABLE

#define USB_HUB_C_PORT_ENABLE   17

Port enable/disable changed.

Definition at line 92 of file usbhub.h.

◆ USB_HUB_C_PORT_SUSPEND

#define USB_HUB_C_PORT_SUSPEND   18

Suspend changed.

Definition at line 95 of file usbhub.h.

◆ USB_HUB_C_PORT_OVER_CURRENT

#define USB_HUB_C_PORT_OVER_CURRENT   19

Over-current indicator changed.

Definition at line 98 of file usbhub.h.

◆ USB_HUB_C_PORT_RESET

#define USB_HUB_C_PORT_RESET   20

Reset changed.

Definition at line 101 of file usbhub.h.

◆ USB_HUB_C_PORT_LINK_STATE

#define USB_HUB_C_PORT_LINK_STATE   25

Link state changed.

Definition at line 104 of file usbhub.h.

◆ USB_HUB_C_PORT_CONFIG_ERROR

#define USB_HUB_C_PORT_CONFIG_ERROR   26

Configuration error.

Definition at line 107 of file usbhub.h.

◆ USB_HUB_C_FEATURE

#define USB_HUB_C_FEATURE ( bit)
Value:
( 16 + (bit) )
static unsigned int unsigned int bit
Definition bigint.h:392

Calculate feature from change bit number.

Definition at line 110 of file usbhub.h.

Referenced by hub_clear_changes().

◆ USB_HUB_FEATURES

#define USB_HUB_FEATURES
Value:
( 1 << USB_HUB_C_PORT_ENABLE ) | \
#define USB_HUB_C_PORT_OVER_CURRENT
Over-current indicator changed.
Definition usbhub.h:98
#define USB_HUB_C_PORT_SUSPEND
Suspend changed.
Definition usbhub.h:95
#define USB_HUB_C_PORT_CONNECTION
Connect status changed.
Definition usbhub.h:89
#define USB_HUB_C_PORT_RESET
Reset changed.
Definition usbhub.h:101
#define USB_HUB_C_PORT_ENABLE
Port enable/disable changed.
Definition usbhub.h:92

USB features.

Definition at line 113 of file usbhub.h.

113#define USB_HUB_FEATURES \
114 ( ( 1 << USB_HUB_C_PORT_CONNECTION ) | \
115 ( 1 << USB_HUB_C_PORT_ENABLE ) | \
116 ( 1 << USB_HUB_C_PORT_SUSPEND ) | \
117 ( 1 << USB_HUB_C_PORT_OVER_CURRENT ) | \
118 ( 1 << USB_HUB_C_PORT_RESET ) )

Referenced by hub_probe().

◆ USB_HUB_FEATURES_ENHANCED

#define USB_HUB_FEATURES_ENHANCED
Value:
( 1 << USB_HUB_C_PORT_RESET ) | \
#define USB_HUB_C_PORT_LINK_STATE
Link state changed.
Definition usbhub.h:104
#define USB_HUB_C_PORT_CONFIG_ERROR
Configuration error.
Definition usbhub.h:107

USB features for enhanced hubs.

Definition at line 121 of file usbhub.h.

121#define USB_HUB_FEATURES_ENHANCED \
122 ( ( 1 << USB_HUB_C_PORT_CONNECTION ) | \
123 ( 1 << USB_HUB_C_PORT_OVER_CURRENT ) | \
124 ( 1 << USB_HUB_C_PORT_RESET ) | \
125 ( 1 << USB_HUB_C_PORT_LINK_STATE ) | \
126 ( 1 << USB_HUB_C_PORT_CONFIG_ERROR ) )

Referenced by hub_probe().

◆ USB_HUB_SET_HUB_DEPTH

#define USB_HUB_SET_HUB_DEPTH
Value:
USB_REQUEST_TYPE ( 12 ) )
#define USB_RECIP_DEVICE
Request recipient is the device.
Definition usb.h:113
#define USB_DIR_OUT
Data transfer is from host to device.
Definition usb.h:95
#define USB_TYPE_CLASS
Class-specific request type.
Definition usb.h:104

Set hub depth.

Definition at line 129 of file usbhub.h.

129#define USB_HUB_SET_HUB_DEPTH \
130 ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE | \
131 USB_REQUEST_TYPE ( 12 ) )

Referenced by usb_hub_set_hub_depth().

◆ USB_HUB_CLEAR_TT_BUFFER

#define USB_HUB_CLEAR_TT_BUFFER
Value:
USB_REQUEST_TYPE ( 8 ) )
#define USB_HUB_RECIP_PORT
Request recipient is a port.
Definition usbhub.h:18

Clear transaction translator buffer.

Definition at line 134 of file usbhub.h.

134#define USB_HUB_CLEAR_TT_BUFFER \
135 ( USB_DIR_OUT | USB_TYPE_CLASS | USB_HUB_RECIP_PORT | \
136 USB_REQUEST_TYPE ( 8 ) )

Referenced by usb_hub_clear_tt_buffer().

◆ USB_HUB_TT_SINGLE

#define USB_HUB_TT_SINGLE   1

Transaction translator port value for single-TT hubs.

Definition at line 249 of file usbhub.h.

Referenced by hub_clear_tt().

◆ USB_HUB_SLOW_START

#define USB_HUB_SLOW_START   0x0001

Hub requires additional settling delay.

Definition at line 271 of file usbhub.h.

Referenced by hub_open().

◆ USB_HUB_SLOW_START_DELAY_MS

#define USB_HUB_SLOW_START_DELAY_MS   500

Additional setting delay for out-of-spec hubs.

Definition at line 274 of file usbhub.h.

Referenced by hub_open().

◆ USB_HUB_INTR_FILL

#define USB_HUB_INTR_FILL   4

Interrupt ring fill level.

This is a policy decision.

Definition at line 280 of file usbhub.h.

Referenced by hub_probe().

◆ USB_HUB_ENABLE_MAX_WAIT_MS

#define USB_HUB_ENABLE_MAX_WAIT_MS   100

Maximum time to wait for port to become enabled.

This is a policy decision.

Definition at line 286 of file usbhub.h.

Referenced by hub_enable().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ usb_hub_get_descriptor()

int usb_hub_get_descriptor ( struct usb_device * usb,
int enhanced,
union usb_hub_descriptor * data )
inlinestatic

Get hub descriptor.

Parameters
usbUSB device
enhancedHub is an enhanced hub
dataHub descriptor to fill in
Return values
rcReturn status code

Definition at line 147 of file usbhub.h.

148 {
149 unsigned int desc;
150 size_t len;
151
152 /* Determine descriptor type and length */
154 len = ( enhanced ? sizeof ( data->enhanced ) : sizeof ( data->basic ) );
155
156 return usb_get_descriptor ( usb, USB_TYPE_CLASS, desc, 0, 0,
157 &data->header, len );
158}
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
static int usb_get_descriptor(struct usb_device *usb, unsigned int type, unsigned int desc, unsigned int index, unsigned int language, struct usb_descriptor_header *data, size_t len)
Get USB descriptor.
Definition usb.h:1177
#define USB_HUB_DESCRIPTOR
A basic USB hub descriptor.
Definition usbhub.h:35
#define USB_HUB_DESCRIPTOR_ENHANCED
An enhanced USB hub descriptor.
Definition usbhub.h:50

References data, desc, len, usb_get_descriptor(), USB_HUB_DESCRIPTOR, USB_HUB_DESCRIPTOR_ENHANCED, and USB_TYPE_CLASS.

Referenced by hub_probe().

◆ usb_hub_get_port_status()

int usb_hub_get_port_status ( struct usb_device * usb,
unsigned int port,
struct usb_hub_port_status * status )
inlinestatic

Get port status.

Parameters
usbUSB device
portPort address
statusPort status descriptor to fill in
Return values
rcReturn status code

Definition at line 169 of file usbhub.h.

170 {
171
173 port, status, sizeof ( *status ) );
174}
u8 port
Port number.
Definition CIB_PRM.h:3
uint8_t status
Status.
Definition ena.h:5
static int usb_get_status(struct usb_device *usb, unsigned int type, unsigned int index, void *data, size_t len)
Get status.
Definition usb.h:1110

References port, status, usb_get_status(), USB_HUB_RECIP_PORT, and USB_TYPE_CLASS.

Referenced by hub_enable(), and hub_speed().

◆ usb_hub_clear_port_feature()

int usb_hub_clear_port_feature ( struct usb_device * usb,
unsigned int port,
unsigned int feature,
unsigned int index )
inlinestatic

Clear port feature.

Parameters
usbUSB device
portPort address
featureFeature to clear
indexIndex (when clearing a port indicator)
Return values
rcReturn status code

Definition at line 186 of file usbhub.h.

187 {
188
190 feature, ( ( index << 8 ) | port ) );
191}
long index
Definition bigint.h:65
static int usb_clear_feature(struct usb_device *usb, unsigned int type, unsigned int feature, unsigned int index)
Clear feature.
Definition usb.h:1127
A named feature.
Definition features.h:79

References index, port, usb_clear_feature(), USB_HUB_RECIP_PORT, and USB_TYPE_CLASS.

Referenced by hub_clear_changes(), and hub_disable().

◆ usb_hub_set_port_feature()

int usb_hub_set_port_feature ( struct usb_device * usb,
unsigned int port,
unsigned int feature,
unsigned int index )
inlinestatic

Set port feature.

Parameters
usbUSB device
portPort address
featureFeature to clear
indexIndex (when clearing a port indicator)
Return values
rcReturn status code

Definition at line 203 of file usbhub.h.

204 {
205
207 feature, ( ( index << 8 ) | port ) );
208}
static int usb_set_feature(struct usb_device *usb, unsigned int type, unsigned int feature, unsigned int index)
Set feature.
Definition usb.h:1144

References index, port, USB_HUB_RECIP_PORT, usb_set_feature(), and USB_TYPE_CLASS.

Referenced by hub_enable(), and hub_open().

◆ usb_hub_set_hub_depth()

int usb_hub_set_hub_depth ( struct usb_device * usb,
unsigned int depth )
inlinestatic

Set hub depth.

Parameters
usbUSB device
depthHub depth
Return values
rcReturn status code

Definition at line 218 of file usbhub.h.

218 {
219
220 return usb_control ( usb, USB_HUB_SET_HUB_DEPTH, depth, 0, NULL, 0 );
221}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
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
#define USB_HUB_SET_HUB_DEPTH
Set hub depth.
Definition usbhub.h:129

References NULL, usb_control(), and USB_HUB_SET_HUB_DEPTH.

Referenced by hub_probe().

◆ usb_hub_clear_tt_buffer()

int usb_hub_clear_tt_buffer ( struct usb_device * usb,
unsigned int device,
unsigned int endpoint,
unsigned int attributes,
unsigned int tt_port )
inlinestatic

Clear transaction translator buffer.

Parameters
usbUSB device
deviceDevice address
endpointEndpoint address
attributesEndpoint attributes
tt_portTransaction translator port (or 1 for single-TT hubs)
Return values
rcReturn status code

Definition at line 234 of file usbhub.h.

236 {
237 unsigned int value;
238
239 /* Calculate value */
240 value = ( ( ( endpoint & USB_ENDPOINT_MAX ) << 0 ) | ( device << 4 ) |
241 ( ( attributes & USB_ENDPOINT_ATTR_TYPE_MASK ) << 11 ) |
242 ( ( endpoint & USB_ENDPOINT_IN ) << 8 ) );
243
245 tt_port, NULL, 0 );
246}
pseudo_bit_t value[0x00020]
Definition arbel.h:2
#define USB_ENDPOINT_MAX
Maximum endpoint number.
Definition usb.h:522
#define USB_ENDPOINT_IN
Endpoint direction is in.
Definition usb.h:525
#define USB_ENDPOINT_ATTR_TYPE_MASK
Endpoint attribute transfer type mask.
Definition usb.h:281
A hardware device.
Definition device.h:77
#define USB_HUB_CLEAR_TT_BUFFER
Clear transaction translator buffer.
Definition usbhub.h:134

References NULL, usb_control(), USB_ENDPOINT_ATTR_TYPE_MASK, USB_ENDPOINT_IN, USB_ENDPOINT_MAX, USB_HUB_CLEAR_TT_BUFFER, and value.

Referenced by hub_clear_tt().