FreeBSD kernel usb device Code
usb_device.h File Reference
Include dependency graph for usb_device.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  usb_udev_msg
 
struct  usb_host_endpoint
 
struct  usb_host_interface
 
struct  usb_device_flags
 
struct  usb_power_save
 
struct  usb_hw_ep_scratch_sub
 
struct  usb_hw_ep_scratch
 
struct  usb_temp_setup
 
union  usb_device_scratch
 
struct  usb_device_statistics
 
struct  usb_device
 

Macros

#define USB_CTRL_XFER_MAX   2
 
#define USB_CFG_ALLOC   0
 
#define USB_CFG_FREE   1
 
#define USB_CFG_INIT   2
 
#define USB_UNCFG_FLAG_NONE   0x00
 
#define USB_UNCFG_FLAG_FREE_EP0   0x02 /* endpoint zero is freed */
 
#define USB_DEV_REF_MAX   0xffff
 
#define USB_RE_ENUM_DONE   0
 
#define USB_RE_ENUM_START   1
 
#define USB_RE_ENUM_PWR_OFF   2
 
#define USB_RE_ENUM_SET_CONFIG   3
 

Functions

struct usb_host_endpoint __aligned (USB_HOST_ALIGN)
 
 TAILQ_HEAD (, urb) bsd_urb_list
 
const char * usb_statestr (enum usb_dev_state state)
 
struct usb_deviceusb_alloc_device (device_t parent_dev, struct usb_bus *bus, struct usb_device *parent_hub, uint8_t depth, uint8_t port_index, uint8_t port_no, enum usb_dev_speed speed, enum usb_hc_mode mode)
 
usb_error_t usb_probe_and_attach (struct usb_device *udev, uint8_t iface_index)
 
void usb_detach_device (struct usb_device *, uint8_t, uint8_t)
 
usb_error_t usb_reset_iface_endpoints (struct usb_device *udev, uint8_t iface_index)
 
usb_error_t usbd_set_config_index (struct usb_device *udev, uint8_t index)
 
usb_error_t usbd_set_endpoint_stall (struct usb_device *udev, struct usb_endpoint *ep, uint8_t do_stall)
 
usb_error_t usb_suspend_resume (struct usb_device *udev, uint8_t do_suspend)
 
void usb_devinfo (struct usb_device *udev, char *dst_ptr, uint16_t dst_len)
 
void usb_free_device (struct usb_device *, uint8_t)
 
void usb_linux_free_device (struct usb_device *dev)
 
uint8_t usb_peer_can_wakeup (struct usb_device *udev)
 
struct usb_endpointusb_endpoint_foreach (struct usb_device *udev, struct usb_endpoint *ep)
 
void usb_set_device_state (struct usb_device *, enum usb_dev_state)
 
enum usb_dev_state usb_get_device_state (struct usb_device *)
 
void usb_set_device_strings (struct usb_device *)
 
void usb_get_langid (struct usb_device *)
 
uint8_t usbd_enum_lock (struct usb_device *)
 
void usbd_enum_unlock (struct usb_device *)
 
void usbd_sr_lock (struct usb_device *)
 
void usbd_sr_unlock (struct usb_device *)
 
uint8_t usbd_ctrl_lock (struct usb_device *)
 
void usbd_ctrl_unlock (struct usb_device *)
 
uint8_t usbd_enum_is_locked (struct usb_device *)
 
uint8_t uhub_count_active_host_ports (struct usb_device *, enum usb_dev_speed)
 

Variables

struct usb_endpoint_descriptor desc
 
struct usb_xferbsd_xfer [2]
 
uint8_t * extra
 
usb_frlength_t fbsd_buf_size
 
uint16_t extralen
 
uint8_t bsd_iface_index
 
struct usb_host_endpointendpoint
 
const char * string
 
struct usb_device_flags __aligned
 
int usb_template
 

Macro Definition Documentation

◆ USB_CFG_ALLOC

#define USB_CFG_ALLOC   0

Definition at line 49 of file usb_device.h.

◆ USB_CFG_FREE

#define USB_CFG_FREE   1

Definition at line 50 of file usb_device.h.

◆ USB_CFG_INIT

#define USB_CFG_INIT   2

Definition at line 51 of file usb_device.h.

◆ USB_CTRL_XFER_MAX

#define USB_CTRL_XFER_MAX   2

Definition at line 45 of file usb_device.h.

◆ USB_DEV_REF_MAX

#define USB_DEV_REF_MAX   0xffff

Definition at line 237 of file usb_device.h.

◆ USB_RE_ENUM_DONE

#define USB_RE_ENUM_DONE   0

Definition at line 257 of file usb_device.h.

◆ USB_RE_ENUM_PWR_OFF

#define USB_RE_ENUM_PWR_OFF   2

Definition at line 259 of file usb_device.h.

◆ USB_RE_ENUM_SET_CONFIG

#define USB_RE_ENUM_SET_CONFIG   3

Definition at line 260 of file usb_device.h.

◆ USB_RE_ENUM_START

#define USB_RE_ENUM_START   1

Definition at line 258 of file usb_device.h.

◆ USB_UNCFG_FLAG_FREE_EP0

#define USB_UNCFG_FLAG_FREE_EP0   0x02 /* endpoint zero is freed */

Definition at line 56 of file usb_device.h.

◆ USB_UNCFG_FLAG_NONE

#define USB_UNCFG_FLAG_NONE   0x00

Definition at line 55 of file usb_device.h.

Function Documentation

◆ __aligned()

struct usb_host_endpoint __aligned ( USB_HOST_ALIGN  )

◆ TAILQ_HEAD()

__aligned::TAILQ_HEAD ( urb  )

Referenced by dwc_otg_update_host_transfer_schedule_locked().

Here is the caller graph for this function:

◆ uhub_count_active_host_ports()

uint8_t uhub_count_active_host_ports ( struct usb_device udev,
enum  usb_dev_speed 
)

Definition at line 386 of file usb_hub.c.

References usb_device::bus, child, usb_device::hub, usb_hub::hubsoftc, usb_hub::nports, usb_hub::ports, usb_bus_port_get_device(), and USB_MODE_HOST.

Referenced by usbd_req_re_enumerate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_alloc_device()

struct usb_device * usb_alloc_device ( device_t  parent_dev,
struct usb_bus bus,
struct usb_device parent_hub,
uint8_t  depth,
uint8_t  port_index,
uint8_t  port_no,
enum usb_dev_speed  speed,
enum usb_hc_mode  mode 
)

Definition at line 1737 of file usb_device.c.

References usb_device::address, usb_endpoint_descriptor::bDescriptorType, usb_endpoint_ss_comp_descriptor::bDescriptorType, usb_bus::bdev, usb_endpoint_descriptor::bEndpointAddress, usb_endpoint_descriptor::bInterval, usb_endpoint_descriptor::bLength, usb_endpoint_ss_comp_descriptor::bLength, usb_endpoint_descriptor::bmAttributes, usb_device_descriptor::bMaxPacketSize, usb_device_descriptor::bNumConfigurations, usb_config_descriptor::bNumInterface, usb_device::bus, usb_device::cdesc, usb_device::cs_msg, usb_device::ctrl_ep, usb_device::ctrl_ep_comp_desc, usb_device::ctrl_ep_desc, usb_device::ctrl_sx, usb_device::ctrlreq_cv, usb_device::curr_config_index, usb_device::curr_config_no, usb_device::ddesc, usb_device::depth, usb_device::device_index, usb_bus_methods::device_init, usb_device::device_mtx, usb_bus::devices, usb_bus::devices_max, DPRINTF, usb_device::enum_sx, usb_device::flags, usb_udev_msg::hdr, usb_device::hs_hub_addr, usb_device::hs_port_no, usb_device::hub, usb_power_save::last_xfer_time, usb_bus::methods, usb_device_flags::no_strings, usb_device::parent_dev, usb_device::parent_hs_hub, usb_device::parent_hub, usb_device::plugtime, usb_proc_msg::pm_callback, usb_device::port_index, usb_device::port_no, usb_hub::ports, usb_device::power, usb_device::power_mode, usb_device::pwr_save, usb_device::ref_cv, usb_device::refcount, usb_device_flags::self_powered, usb_device::speed, usb_device::sr_sx, UDESC_ENDPOINT, UDESC_ENDPOINT_SS_COMP, usb_udev_msg::udev, UE_CONTROL, UQ_BUS_POWERED, usb_device_flags::uq_bus_powered, UQ_CFG_INDEX_0, UQ_CFG_INDEX_1, UQ_CFG_INDEX_2, UQ_CFG_INDEX_3, UQ_CFG_INDEX_4, UQ_MSC_NO_GETMAXLUN, UQ_MSC_NO_PREVENT_ALLOW, UQ_MSC_NO_START_STOP, UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_TEST_UNIT_READY, UQ_NO_STRINGS, usb_alloc_symlink(), usb_bus_port_set_device(), USB_CONTROL_ENDPOINT, usb_free_device(), USB_GENERIC_NAME, usb_get_langid(), usb_get_manufacturer(), usb_get_product(), usb_iface_is_cdrom(), usb_init_attach_arg(), usb_init_endpoint(), USB_MAX_IPACKET, USB_MIN_POWER, usb_device_flags::usb_mode, USB_MODE_DEVICE, USB_MODE_HOST, usb_msc_auto_quirk(), USB_POWER_MODE_ON, USB_ROOT_HUB_ADDR, usb_set_device_state(), usb_set_device_strings(), USB_SPEED_HIGH, USB_START_ADDR, USB_STATE_ADDRESSED, USB_STATE_POWERED, usb_temp_setup_by_index_p, usb_template, usb_test_quirk(), USB_UNCONFIG_INDEX, USB_UNCONFIG_NO, usbd_clear_stall_proc, usbd_errstr(), usbd_filter_power_mode(), usbd_get_no_descriptors(), usbd_req_re_enumerate(), usbd_req_set_address(), usbd_set_config_index(), usbd_setup_device_desc(), and usb_endpoint_descriptor::wMaxPacketSize.

Referenced by uhub_reattach_port(), and usb_bus_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_detach_device()

void usb_detach_device ( struct usb_device udev,
uint8_t  iface_index,
uint8_t  flag 
)

Definition at line 1264 of file usb_device.c.

References usb_device::enum_sx, usb_interface::pnpinfo, usb_interface::subdev, usb_detach_device_sub(), USB_IFACE_INDEX_ANY, USB_IFACE_MAX, and usbd_get_iface().

Referenced by bbb_attach(), and usb_unconfigure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_devinfo()

void usb_devinfo ( struct usb_device udev,
char *  dst_ptr,
uint16_t  dst_len 
)

◆ usb_endpoint_foreach()

struct usb_endpoint * usb_endpoint_foreach ( struct usb_device udev,
struct usb_endpoint ep 
)

◆ usb_free_device()

◆ usb_get_device_state()

enum usb_dev_state usb_get_device_state ( struct usb_device udev)

Definition at line 2877 of file usb_device.c.

References usb_device::state, and USB_STATE_DETACHED.

Referenced by xhci_device_state_change().

Here is the caller graph for this function:

◆ usb_get_langid()

◆ usb_linux_free_device()

void usb_linux_free_device ( struct usb_device dev)

◆ usb_peer_can_wakeup()

uint8_t usb_peer_can_wakeup ( struct usb_device udev)

◆ usb_probe_and_attach()

◆ usb_reset_iface_endpoints()

usb_error_t usb_reset_iface_endpoints ( struct usb_device udev,
uint8_t  iface_index 
)

Definition at line 1178 of file usb_device.c.

References usb_endpoint::edesc, usb_device::endpoints, usb_device::endpoints_max, usb_endpoint::iface_index, and usbd_set_endpoint_stall().

Referenced by usb_handle_iface_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_set_device_state()

void usb_set_device_state ( struct usb_device udev,
enum  usb_dev_state 
)

Definition at line 2857 of file usb_device.c.

References usb_device::bus, usb_bus_methods::device_state_change, DPRINTF, usb_bus::methods, usb_device::state, state, usb_ref_lock, USB_STATE_MAX, and usb_statestr().

Referenced by usb_alloc_device(), usb_free_device(), usbd_req_re_enumerate(), and usbd_set_config_index().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_set_device_strings()

◆ usb_statestr()

const char * usb_statestr ( enum usb_dev_state  state)

Definition at line 275 of file usb_device.c.

References usb_device::state, statestr, and USB_STATE_MAX.

Referenced by usb_set_device_state().

Here is the caller graph for this function:

◆ usb_suspend_resume()

usb_error_t usb_suspend_resume ( struct usb_device udev,
uint8_t  do_suspend 
)

Definition at line 1586 of file usb_device.c.

References usb_device::bus, usb_device::flags, usb_device_flags::peer_suspended, usb_device::sr_sx, usb_interface::subdev, USB_BUS_LOCK, USB_BUS_UNLOCK, USB_IFACE_MAX, usb_suspend_resume_sub(), and usbd_get_iface().

Referenced by usb_dev_resume_peer(), and usb_dev_suspend_peer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usbd_ctrl_lock()

uint8_t usbd_ctrl_lock ( struct usb_device udev)

Definition at line 2983 of file usb_device.c.

References usb_device::ctrl_sx, usbd_enum_is_locked(), and usbd_sr_unlock().

Referenced by device_set_usb_desc(), uhub_child_pnpinfo(), usb_get_langid(), usb_set_device_strings(), usb_temp_setup(), usbd_do_request_flags(), and usbd_transfer_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usbd_ctrl_unlock()

void usbd_ctrl_unlock ( struct usb_device udev)

Definition at line 2999 of file usb_device.c.

References usb_device::ctrl_sx, usbd_enum_is_locked(), and usbd_sr_lock().

Referenced by device_set_usb_desc(), uhub_child_pnpinfo(), usb_get_langid(), usb_set_device_strings(), usb_temp_setup(), usbd_do_request_flags(), and usbd_transfer_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usbd_enum_is_locked()

uint8_t usbd_enum_is_locked ( struct usb_device udev)

Definition at line 2972 of file usb_device.c.

References usb_device::enum_sx.

Referenced by usbd_ctrl_lock(), and usbd_ctrl_unlock().

Here is the caller graph for this function:

◆ usbd_enum_lock()

◆ usbd_enum_unlock()

◆ usbd_set_config_index()

◆ usbd_set_endpoint_stall()

◆ usbd_sr_lock()

void usbd_sr_lock ( struct usb_device udev)

Definition at line 2946 of file usb_device.c.

References usb_device::sr_sx.

Referenced by usb_dev_resume_peer(), usb_dev_suspend_peer(), and usbd_ctrl_unlock().

Here is the caller graph for this function:

◆ usbd_sr_unlock()

void usbd_sr_unlock ( struct usb_device udev)

Definition at line 2960 of file usb_device.c.

References usb_device::sr_sx.

Referenced by usb_dev_resume_peer(), usb_dev_suspend_peer(), and usbd_ctrl_lock().

Here is the caller graph for this function:

Variable Documentation

◆ __aligned

struct usb_device_flags __aligned

◆ bsd_iface_index

uint8_t bsd_iface_index

Definition at line 6 of file usb_device.h.

◆ bsd_xfer

struct usb_xfer* bsd_xfer[2]

Definition at line 2 of file usb_device.h.

◆ desc

◆ endpoint

struct usb_host_endpoint* endpoint

Definition at line 2 of file usb_device.h.

Referenced by usbd_req_clear_tt_buffer().

◆ extra

uint8_t * extra

Definition at line 3 of file usb_device.h.

◆ extralen

uint16_t extralen

Definition at line 5 of file usb_device.h.

◆ fbsd_buf_size

usb_frlength_t fbsd_buf_size

Definition at line 4 of file usb_device.h.

◆ string

const char* string

Definition at line 3 of file usb_device.h.

◆ usb_template

int usb_template
extern

Definition at line 120 of file usb_device.c.

Referenced by sysctl_hw_usb_template(), and usb_alloc_device().