acadia/rust/sys/voyageurs/src/xhci/data_structures/slot_context.rs

133 lines
7 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use bitfield_struct::bitfield;
#[bitfield(u128)]
pub struct SlotContextFields {
/// Route String. This field is used by hubs to route packets to the correct downstream port. The
/// format of the Route String is defined in section 8.9 the USB3 specification.
/// As Input, this field shall be set for all USB devices, irrespective of their speed, to indicate their
/// location in the USB topology.
#[bits(20)]
pub route_string: u32,
/// Speed. This field is deprecated in this version of the specification and shall be Reserved.
/// This field indicates the speed of the device. Refer to the PORTSC Port Speed field in Table 5-27
/// for the definition of the valid values
#[bits(4)]
pub speed: u8,
__: bool,
/// Multi-TT (MTT). This flag is set to '1' by software if this is a High-speed hub that supports
/// Multiple TTs and the Multiple TT Interface has been enabled by software, or if this is a Low-
/// /Full-speed device or Full-speed hub and connected to the xHC through a parent108 High-speed
/// hub that supports Multiple TTs and the Multiple TT Interface of the parent hub has been
/// enabled by software, or 0 if not.
pub multi_tt: bool,
/// Hub. This flag is set to '1' by software if this device is a USB hub, or '0' if it is a USB function
pub hub: bool,
/// Context Entries. This field identifies the index of the last valid Endpoint Context within this
/// Device Context structure. The value of 0 is Reserved and is not a valid entry for this field. Valid
/// entries for this field shall be in the range of 1-31. This field indicates the size of the Device
/// Context structure. For example, ((Context Entries+1) * 32 bytes) = Total bytes for this structure.
///
/// Note, Output Context Entries values are written by the xHC, and Input Context Entries values are
/// written by software.
#[bits(5)]
pub context_entries: u8,
/// Max Exit Latency. The Maximum Exit Latency is in microseconds, and indicates the worst case
/// time it takes to wake up all the links in the path to the device, given the current USB link level
/// power management settings.
///
/// Refer to section 4.23.5.2 for more information on the use of this field.
pub max_exit_latency: u16,
/// Root Hub Port Number. This field identifies the Root Hub Port Number used to access the USB
/// device. Refer to section 4.19.7 for port numbering information.
///
/// Note: Ports are numbered from 1 to MaxPorts
pub root_hub_port_number: u8,
/// Number of Ports. If this device is a hub (Hub = 1), then this field is set by software to identify
/// the number of downstream facing ports supported by the hub. Refer to the bNbrPorts field
/// description in the Hub Descriptor (Table 11-13) of the USB2 spec. If this device is not a hub (Hub
/// = 0), then this field shall be 0
pub number_of_ports: u8,
/// Parent Hub Slot ID. If this device is Low-/Full-speed and connected through a High-speed hub,
/// then this field shall contain the Slot ID of the parent High-speed hub109.
///
/// For SS and SSP bus instance, if this device is connected through a higher rank hub110 then this
/// field shall contain the Slot ID of the parent hub. For example, a Gen1 x1 connected behind a
/// Gen1 x2 hub, or Gen1 x2 device connected behind Gen2 x2 hub.
///
/// This field shall be 0 if any of the following are true:
/// Device is attached to a Root Hub port
/// Device is a High-Speed device
/// Device is the highest rank SS/SSP device supported by xHCI
pub parent_hub_slot_id: u8,
/// Parent Port Number. If this device is Low-/Full-speed and connected through a High-speed
/// hub, then this field shall contain the number of the downstream facing port of the parent High-
/// speed hub109.
/// For SS and SSP bus instance, if this device is connected through a higher rank hub110 then this
/// field shall contain the number of the downstream facing port of the parent hub. For example, a
/// Gen1 x1 connected behind a Gen1 x2 hub, or Gen1 x2 device connected behind Gen2 x2 hub.
/// This field shall be 0 if any of the following are true:
/// Device is attached to a Root Hub port
/// Device is a High-Speed device
/// Device is the highest rank SS/SSP device supported by xH
pub parent_port_number: u8,
/// TT Think Time (TTT). If this is a High-speed hub (Hub = 1 and Speed = High-Speed), then this
/// field shall be set by software to identify the time the TT of the hub requires to proceed to the
/// next full-/low-speed transaction.
/// Value Think Time
/// 0 TT requires at most 8 FS bit times of inter-transaction gap on a full-/low-speed
/// downstream bus.
/// 1 TT requires at most 16 FS bit times.
/// 2 TT requires at most 24 FS bit times.
/// 3 TT requires at most 32 FS bit times.
/// Refer to the TT Think Time sub-field of the wHubCharacteristics field description in the Hub
/// Descriptor (Table 11-13) and section 11.18.2 of the USB2 spec for more information on TT
/// Think Time. If this device is not a High-speed hub (Hub = 0 or Speed != High-speed), then this
/// field shall be 0.
#[bits(2)]
pub tt_think_time: u8,
#[bits(4)]
__: u8,
/// Interrupter Target. This field defines the index of the Interrupter that will receive Bandwidth
/// Request Events and Device Notification Events generated by this slot, or when a Ring Underrun
/// or Ring Overrun condition is reported (refer to section 4.10.3.1). Valid values are between 0 and
/// MaxIntrs-1
#[bits(10)]
pub interrupter_target: u16,
/// USB Device Address. This field identifies the address assigned to the USB device by the xHC,
/// and is set upon the successful completion of a Set Address Command. Refer to the USB2 spec
/// for a more detailed description.
///
/// As Output, this field is invalid if the Slot State = Disabled or Default.
/// As Input, software shall initialize the field to 0.
pub usb_device_address: u8,
#[bits(19)]
__: u32,
/// Slot State. This field is updated by the xHC when a Device Slot transitions from one state to
/// another.
/// Value Slot State
/// 0 Disabled/Enabled
/// 1 Default
/// 2 Addressed
/// 3 Configured
/// 31-4 Reserved
///
/// Slot States are defined in section 4.5.3.
///
/// As Output, since software initializes all fields of the Device Context data structure to 0, this field
/// shall initially indicate the Disabled state.
///
/// As Input, software shall initialize the field to 0.
/// Refer to section 4.5.3 for more information on Slot State.
#[bits(5)]
pub slot_state: u8,
}
#[repr(C)]
pub struct SlotContext {
pub fields: SlotContextFields,
__: u128,
}
const _: () = assert!(size_of::<SlotContext>() == 0x20);