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

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int usb_hub_get_descriptor (struct usb_device *usb, int enhanced, union usb_hub_descriptor *data)
 Get hub descriptor. More...
 
static int usb_hub_get_port_status (struct usb_device *usb, unsigned int port, struct usb_hub_port_status *status)
 Get port status. More...
 
static int usb_hub_clear_port_feature (struct usb_device *usb, unsigned int port, unsigned int feature, unsigned int index)
 Clear port feature. More...
 
static int usb_hub_set_port_feature (struct usb_device *usb, unsigned int port, unsigned int feature, unsigned int index)
 Set port feature. More...
 
static int usb_hub_set_hub_depth (struct usb_device *usb, unsigned int depth)
 Set hub depth. More...
 
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. More...
 

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 17 of file usbhub.h.

◆ USB_HUB_DESCRIPTOR

#define USB_HUB_DESCRIPTOR   41

A basic USB hub descriptor.

Definition at line 34 of file usbhub.h.

◆ USB_HUB_DESCRIPTOR_ENHANCED

#define USB_HUB_DESCRIPTOR_ENHANCED   42

An enhanced USB hub descriptor.

Definition at line 49 of file usbhub.h.

◆ USB_HUB_PORT_CONNECTION

#define USB_HUB_PORT_CONNECTION   0

Current connect status feature.

Definition at line 70 of file usbhub.h.

◆ USB_HUB_PORT_ENABLE

#define USB_HUB_PORT_ENABLE   1

Port enabled/disabled feature.

Definition at line 73 of file usbhub.h.

◆ USB_HUB_PORT_RESET

#define USB_HUB_PORT_RESET   4

Port reset feature.

Definition at line 76 of file usbhub.h.

◆ USB_HUB_PORT_POWER

#define USB_HUB_PORT_POWER   8

Port power feature.

Definition at line 79 of file usbhub.h.

◆ USB_HUB_PORT_LOW_SPEED

#define USB_HUB_PORT_LOW_SPEED   9

Low-speed device attached.

Definition at line 82 of file usbhub.h.

◆ USB_HUB_PORT_HIGH_SPEED

#define USB_HUB_PORT_HIGH_SPEED   10

High-speed device attached.

Definition at line 85 of file usbhub.h.

◆ USB_HUB_C_PORT_CONNECTION

#define USB_HUB_C_PORT_CONNECTION   16

Connect status changed.

Definition at line 88 of file usbhub.h.

◆ USB_HUB_C_PORT_ENABLE

#define USB_HUB_C_PORT_ENABLE   17

Port enable/disable changed.

Definition at line 91 of file usbhub.h.

◆ USB_HUB_C_PORT_SUSPEND

#define USB_HUB_C_PORT_SUSPEND   18

Suspend changed.

Definition at line 94 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 97 of file usbhub.h.

◆ USB_HUB_C_PORT_RESET

#define USB_HUB_C_PORT_RESET   20

Reset changed.

Definition at line 100 of file usbhub.h.

◆ USB_HUB_C_PORT_LINK_STATE

#define USB_HUB_C_PORT_LINK_STATE   25

Link state changed.

Definition at line 103 of file usbhub.h.

◆ USB_HUB_C_PORT_CONFIG_ERROR

#define USB_HUB_C_PORT_CONFIG_ERROR   26

Configuration error.

Definition at line 106 of file usbhub.h.

◆ USB_HUB_C_FEATURE

#define USB_HUB_C_FEATURE (   bit)    ( 16 + (bit) )

Calculate feature from change bit number.

Definition at line 109 of file usbhub.h.

◆ USB_HUB_FEATURES

#define USB_HUB_FEATURES
Value:
( 1 << USB_HUB_C_PORT_ENABLE ) | \
#define USB_HUB_C_PORT_RESET
Reset changed.
Definition: usbhub.h:100
#define USB_HUB_C_PORT_CONNECTION
Connect status changed.
Definition: usbhub.h:88
#define USB_HUB_C_PORT_OVER_CURRENT
Over-current indicator changed.
Definition: usbhub.h:97
#define USB_HUB_C_PORT_ENABLE
Port enable/disable changed.
Definition: usbhub.h:91
#define USB_HUB_C_PORT_SUSPEND
Suspend changed.
Definition: usbhub.h:94

USB features.

Definition at line 112 of file usbhub.h.

◆ USB_HUB_FEATURES_ENHANCED

#define USB_HUB_FEATURES_ENHANCED
Value:
( 1 << USB_HUB_C_PORT_RESET ) | \
#define USB_HUB_C_PORT_RESET
Reset changed.
Definition: usbhub.h:100
#define USB_HUB_C_PORT_CONNECTION
Connect status changed.
Definition: usbhub.h:88
#define USB_HUB_C_PORT_OVER_CURRENT
Over-current indicator changed.
Definition: usbhub.h:97
#define USB_HUB_C_PORT_CONFIG_ERROR
Configuration error.
Definition: usbhub.h:106
#define USB_HUB_C_PORT_LINK_STATE
Link state changed.
Definition: usbhub.h:103

USB features for enhanced hubs.

Definition at line 120 of file usbhub.h.

◆ USB_HUB_SET_HUB_DEPTH

#define USB_HUB_SET_HUB_DEPTH
Value:
USB_REQUEST_TYPE ( 12 ) )
#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
#define USB_RECIP_DEVICE
Request recipient is the device.
Definition: usb.h:98

Set hub depth.

Definition at line 128 of file usbhub.h.

◆ USB_HUB_CLEAR_TT_BUFFER

#define USB_HUB_CLEAR_TT_BUFFER
Value:
USB_REQUEST_TYPE ( 8 ) )
#define USB_DIR_OUT
Data transfer is from host to device.
Definition: usb.h:80
#define USB_HUB_RECIP_PORT
Request recipient is a port.
Definition: usbhub.h:17
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89

Clear transaction translator buffer.

Definition at line 133 of file usbhub.h.

◆ USB_HUB_TT_SINGLE

#define USB_HUB_TT_SINGLE   1

Transaction translator port value for single-TT hubs.

Definition at line 248 of file usbhub.h.

◆ USB_HUB_SLOW_START

#define USB_HUB_SLOW_START   0x0001

Hub requires additional settling delay.

Definition at line 270 of file usbhub.h.

◆ 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 273 of file usbhub.h.

◆ USB_HUB_INTR_FILL

#define USB_HUB_INTR_FILL   4

Interrupt ring fill level.

This is a policy decision.

Definition at line 279 of file usbhub.h.

◆ 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 285 of file usbhub.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ usb_hub_get_descriptor()

static 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 146 of file usbhub.h.

147  {
148  unsigned int desc;
149  size_t len;
150 
151  /* Determine descriptor type and length */
153  len = ( enhanced ? sizeof ( data->enhanced ) : sizeof ( data->basic ) );
154 
155  return usb_get_descriptor ( usb, USB_TYPE_CLASS, desc, 0, 0,
156  &data->header, len );
157 }
#define USB_HUB_DESCRIPTOR
A basic USB hub descriptor.
Definition: usbhub.h:34
uint64_t desc
Microcode descriptor list physical address.
Definition: ucode.h:12
struct usb_device * usb
Currently attached device (if in use)
Definition: usb.h:820
#define USB_HUB_DESCRIPTOR_ENHANCED
An enhanced USB hub descriptor.
Definition: usbhub.h:49
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89
uint32_t len
Length.
Definition: ena.h:14
uint8_t data[48]
Additional event data.
Definition: ena.h:22
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:1156

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()

static 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 168 of file usbhub.h.

169  {
170 
172  port, status, sizeof ( *status ) );
173 }
struct usb_device * usb
Currently attached device (if in use)
Definition: usb.h:820
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
#define USB_HUB_RECIP_PORT
Request recipient is a port.
Definition: usbhub.h:17
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89
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:1089

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()

static 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 185 of file usbhub.h.

186  {
187 
189  feature, ( ( index << 8 ) | port ) );
190 }
struct usb_device * usb
Currently attached device (if in use)
Definition: usb.h:820
u8 port
Port number.
Definition: CIB_PRM.h:31
static int usb_clear_feature(struct usb_device *usb, unsigned int type, unsigned int feature, unsigned int index)
Clear feature.
Definition: usb.h:1106
#define USB_HUB_RECIP_PORT
Request recipient is a port.
Definition: usbhub.h:17
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89
A named feature.
Definition: features.h:78
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

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()

static 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 202 of file usbhub.h.

203  {
204 
206  feature, ( ( index << 8 ) | port ) );
207 }
struct usb_device * usb
Currently attached device (if in use)
Definition: usb.h:820
u8 port
Port number.
Definition: CIB_PRM.h:31
#define USB_HUB_RECIP_PORT
Request recipient is a port.
Definition: usbhub.h:17
#define USB_TYPE_CLASS
Class-specific request type.
Definition: usb.h:89
static int usb_set_feature(struct usb_device *usb, unsigned int type, unsigned int feature, unsigned int index)
Set feature.
Definition: usb.h:1123
A named feature.
Definition: features.h:78
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

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()

static 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 217 of file usbhub.h.

217  {
218 
219  return usb_control ( usb, USB_HUB_SET_HUB_DEPTH, depth, 0, NULL, 0 );
220 }
#define USB_HUB_SET_HUB_DEPTH
Set hub depth.
Definition: usbhub.h:128
struct usb_device * usb
Currently attached device (if in use)
Definition: usb.h:820
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
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References NULL, usb_control(), and USB_HUB_SET_HUB_DEPTH.

Referenced by hub_probe().

◆ usb_hub_clear_tt_buffer()

static 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 233 of file usbhub.h.

235  {
236  unsigned int value;
237 
238  /* Calculate value */
239  value = ( ( ( endpoint & USB_ENDPOINT_MAX ) << 0 ) | ( device << 4 ) |
240  ( ( attributes & USB_ENDPOINT_ATTR_TYPE_MASK ) << 11 ) |
241  ( ( endpoint & USB_ENDPOINT_IN ) << 8 ) );
242 
244  tt_port, NULL, 0 );
245 }
#define USB_ENDPOINT_ATTR_TYPE_MASK
Endpoint attribute transfer type mask.
Definition: usb.h:266
#define USB_ENDPOINT_MAX
Maximum endpoint number.
Definition: usb.h:507
struct usb_device * usb
Currently attached device (if in use)
Definition: usb.h:820
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 hardware device.
Definition: device.h:73
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define USB_ENDPOINT_IN
Endpoint direction is in.
Definition: usb.h:510
#define USB_HUB_CLEAR_TT_BUFFER
Clear transaction translator buffer.
Definition: usbhub.h:133
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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().