FreeBSD kernel usb device Code
umct.c File Reference
#include <sys/cdefs.h>
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include "usbdevs.h"
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/serial/usb_serial.h>
Include dependency graph for umct.c:

Go to the source code of this file.

Data Structures

struct  umct_softc
 

Macros

#define USB_DEBUG_VAR   usb_debug
 
#define UMCT_GET_MSR   2 /* Get Modem Status Register */
 
#define UMCT_GET_MSR_SIZE   1
 
#define UMCT_GET_LCR   6 /* Get Line Control Register */
 
#define UMCT_GET_LCR_SIZE   1
 
#define UMCT_SET_BAUD   5 /* Set the Baud Rate Divisor */
 
#define UMCT_SET_BAUD_SIZE   4
 
#define UMCT_SET_LCR   7 /* Set Line Control Register */
 
#define UMCT_SET_LCR_SIZE   1
 
#define UMCT_SET_MCR   10 /* Set Modem Control Register */
 
#define UMCT_SET_MCR_SIZE   1
 
#define UMCT_MSR_CTS_CHG   0x01
 
#define UMCT_MSR_DSR_CHG   0x02
 
#define UMCT_MSR_RI_CHG   0x04
 
#define UMCT_MSR_CD_CHG   0x08
 
#define UMCT_MSR_CTS   0x10
 
#define UMCT_MSR_RTS   0x20
 
#define UMCT_MSR_RI   0x40
 
#define UMCT_MSR_CD   0x80
 
#define UMCT_INTR_INTERVAL   100
 
#define UMCT_IFACE_INDEX   0
 
#define UMCT_CONFIG_INDEX   0
 

Enumerations

enum  { UMCT_BULK_DT_WR , UMCT_BULK_DT_RD , UMCT_INTR_DT_RD , UMCT_N_TRANSFER }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void umct_free_softc (struct umct_softc *)
 
static void umct_cfg_do_request (struct umct_softc *sc, uint8_t request, uint16_t len, uint32_t value)
 
static void umct_free (struct ucom_softc *)
 
static void umct_cfg_get_status (struct ucom_softc *, uint8_t *, uint8_t *)
 
static void umct_cfg_set_break (struct ucom_softc *, uint8_t)
 
static void umct_cfg_set_dtr (struct ucom_softc *, uint8_t)
 
static void umct_cfg_set_rts (struct ucom_softc *, uint8_t)
 
static uint8_t umct_calc_baud (uint32_t)
 
static int umct_pre_param (struct ucom_softc *, struct termios *)
 
static void umct_cfg_param (struct ucom_softc *, struct termios *)
 
static void umct_start_read (struct ucom_softc *)
 
static void umct_stop_read (struct ucom_softc *)
 
static void umct_start_write (struct ucom_softc *)
 
static void umct_stop_write (struct ucom_softc *)
 
static void umct_poll (struct ucom_softc *ucom)
 
 DRIVER_MODULE (umct, uhub, umct_driver, umct_devclass, NULL, 0)
 
 MODULE_DEPEND (umct, ucom, 1, 1, 1)
 
 MODULE_DEPEND (umct, usb, 1, 1, 1)
 
 MODULE_VERSION (umct, 1)
 
 USB_PNP_HOST_INFO (umct_devs)
 
static int umct_probe (device_t dev)
 
static int umct_attach (device_t dev)
 
static int umct_detach (device_t dev)
 
 UCOM_UNLOAD_DRAIN (umct)
 
static void umct_intr_callback_sub (struct usb_xfer *xfer, usb_error_t error)
 
static void umct_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void umct_intr_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void umct_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void umct_read_callback_sub (struct usb_xfer *xfer, usb_error_t error)
 

Variables

static device_probe_t umct_probe
 
static device_attach_t umct_attach
 
static device_detach_t umct_detach
 
static usb_callback_t umct_intr_callback
 
static usb_callback_t umct_intr_callback_sub
 
static usb_callback_t umct_read_callback
 
static usb_callback_t umct_read_callback_sub
 
static usb_callback_t umct_write_callback
 
static const struct usb_config umct_config [UMCT_N_TRANSFER]
 
static const struct ucom_callback umct_callback
 
static const STRUCT_USB_HOST_ID umct_devs []
 
static device_method_t umct_methods []
 
static devclass_t umct_devclass
 
static driver_t umct_driver
 

Macro Definition Documentation

◆ UMCT_CONFIG_INDEX

#define UMCT_CONFIG_INDEX   0

Definition at line 102 of file umct.c.

◆ UMCT_GET_LCR

#define UMCT_GET_LCR   6 /* Get Line Control Register */

Definition at line 82 of file umct.c.

◆ UMCT_GET_LCR_SIZE

#define UMCT_GET_LCR_SIZE   1

Definition at line 83 of file umct.c.

◆ UMCT_GET_MSR

#define UMCT_GET_MSR   2 /* Get Modem Status Register */

Definition at line 80 of file umct.c.

◆ UMCT_GET_MSR_SIZE

#define UMCT_GET_MSR_SIZE   1

Definition at line 81 of file umct.c.

◆ UMCT_IFACE_INDEX

#define UMCT_IFACE_INDEX   0

Definition at line 101 of file umct.c.

◆ UMCT_INTR_INTERVAL

#define UMCT_INTR_INTERVAL   100

Definition at line 100 of file umct.c.

◆ UMCT_MSR_CD

#define UMCT_MSR_CD   0x80

Definition at line 98 of file umct.c.

◆ UMCT_MSR_CD_CHG

#define UMCT_MSR_CD_CHG   0x08

Definition at line 94 of file umct.c.

◆ UMCT_MSR_CTS

#define UMCT_MSR_CTS   0x10

Definition at line 95 of file umct.c.

◆ UMCT_MSR_CTS_CHG

#define UMCT_MSR_CTS_CHG   0x01

Definition at line 91 of file umct.c.

◆ UMCT_MSR_DSR_CHG

#define UMCT_MSR_DSR_CHG   0x02

Definition at line 92 of file umct.c.

◆ UMCT_MSR_RI

#define UMCT_MSR_RI   0x40

Definition at line 97 of file umct.c.

◆ UMCT_MSR_RI_CHG

#define UMCT_MSR_RI_CHG   0x04

Definition at line 93 of file umct.c.

◆ UMCT_MSR_RTS

#define UMCT_MSR_RTS   0x20

Definition at line 96 of file umct.c.

◆ UMCT_SET_BAUD

#define UMCT_SET_BAUD   5 /* Set the Baud Rate Divisor */

Definition at line 84 of file umct.c.

◆ UMCT_SET_BAUD_SIZE

#define UMCT_SET_BAUD_SIZE   4

Definition at line 85 of file umct.c.

◆ UMCT_SET_LCR

#define UMCT_SET_LCR   7 /* Set Line Control Register */

Definition at line 86 of file umct.c.

◆ UMCT_SET_LCR_SIZE

#define UMCT_SET_LCR_SIZE   1

Definition at line 87 of file umct.c.

◆ UMCT_SET_MCR

#define UMCT_SET_MCR   10 /* Set Modem Control Register */

Definition at line 88 of file umct.c.

◆ UMCT_SET_MCR_SIZE

#define UMCT_SET_MCR_SIZE   1

Definition at line 89 of file umct.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   usb_debug

Definition at line 73 of file umct.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UMCT_BULK_DT_WR 
UMCT_BULK_DT_RD 
UMCT_INTR_DT_RD 
UMCT_N_TRANSFER 

Definition at line 104 of file umct.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( umct  ,
uhub  ,
umct_driver  ,
umct_devclass  ,
NULL  ,
 
)

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( umct  ,
ucom  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

MODULE_DEPEND ( umct  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( umct  ,
 
)

◆ UCOM_UNLOAD_DRAIN()

UCOM_UNLOAD_DRAIN ( umct  )

◆ umct_attach()

◆ umct_calc_baud()

static uint8_t umct_calc_baud ( uint32_t  baud)
static

Definition at line 478 of file umct.c.

Referenced by umct_cfg_param().

Here is the caller graph for this function:

◆ umct_cfg_do_request()

static void umct_cfg_do_request ( struct umct_softc sc,
uint8_t  request,
uint16_t  len,
uint32_t  value 
)
static

Definition at line 351 of file umct.c.

References len, req, umct_softc::sc_iface_no, umct_softc::sc_ucom, umct_softc::sc_udev, ucom_cfg_do_request, usbd_errstr(), USETDW, USETW, UT_WRITE_VENDOR_DEVICE, and value.

Referenced by umct_cfg_param(), umct_cfg_set_break(), umct_cfg_set_dtr(), and umct_cfg_set_rts().

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

◆ umct_cfg_get_status()

static void umct_cfg_get_status ( struct ucom_softc ucom,
uint8_t *  lsr,
uint8_t *  msr 
)
static

Definition at line 430 of file umct.c.

References umct_softc::sc_lsr, umct_softc::sc_msr, and ucom_softc::sc_parent.

◆ umct_cfg_param()

static void umct_cfg_param ( struct ucom_softc ucom,
struct termios *  t 
)
static

Definition at line 515 of file umct.c.

References umct_softc::sc_lcr, ucom_softc::sc_parent, umct_calc_baud(), umct_cfg_do_request(), UMCT_SET_BAUD, UMCT_SET_BAUD_SIZE, UMCT_SET_LCR, UMCT_SET_LCR_SIZE, and value.

Here is the call graph for this function:

◆ umct_cfg_set_break()

static void umct_cfg_set_break ( struct ucom_softc ucom,
uint8_t  onoff 
)
static

Definition at line 439 of file umct.c.

References umct_softc::sc_lcr, ucom_softc::sc_parent, umct_cfg_do_request(), UMCT_SET_LCR, and UMCT_SET_LCR_SIZE.

Here is the call graph for this function:

◆ umct_cfg_set_dtr()

static void umct_cfg_set_dtr ( struct ucom_softc ucom,
uint8_t  onoff 
)
static

Definition at line 452 of file umct.c.

References umct_softc::sc_mcr, ucom_softc::sc_parent, umct_cfg_do_request(), UMCT_SET_MCR, and UMCT_SET_MCR_SIZE.

Here is the call graph for this function:

◆ umct_cfg_set_rts()

static void umct_cfg_set_rts ( struct ucom_softc ucom,
uint8_t  onoff 
)
static

Definition at line 465 of file umct.c.

References umct_softc::sc_mcr, ucom_softc::sc_parent, umct_cfg_do_request(), UMCT_SET_MCR, and UMCT_SET_MCR_SIZE.

Here is the call graph for this function:

◆ umct_detach()

static int umct_detach ( device_t  dev)
static

Definition at line 319 of file umct.c.

References dev, umct_softc::sc_super_ucom, umct_softc::sc_ucom, umct_softc::sc_xfer, ucom_detach(), umct_free_softc(), UMCT_N_TRANSFER, and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ umct_free()

static void umct_free ( struct ucom_softc ucom)
static

Definition at line 345 of file umct.c.

References ucom_softc::sc_parent, and umct_free_softc().

Here is the call graph for this function:

◆ umct_free_softc()

static void umct_free_softc ( struct umct_softc sc)
static

Definition at line 336 of file umct.c.

References umct_softc::sc_mtx, umct_softc::sc_super_ucom, and ucom_unref().

Referenced by umct_detach(), and umct_free().

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

◆ umct_intr_callback()

static void umct_intr_callback ( struct usb_xfer xfer,
usb_error_t  error 
)
static

Definition at line 607 of file umct.c.

References error, umct_softc::sc_swap_cb, umct_intr_callback_sub, umct_read_callback_sub, and usbd_xfer_softc().

Here is the call graph for this function:

◆ umct_intr_callback_sub()

◆ umct_poll()

static void umct_poll ( struct ucom_softc ucom)
static

Definition at line 677 of file umct.c.

References ucom_softc::sc_parent, umct_softc::sc_xfer, UMCT_N_TRANSFER, and usbd_transfer_poll().

Here is the call graph for this function:

◆ umct_pre_param()

static int umct_pre_param ( struct ucom_softc ucom,
struct termios *  t 
)
static

Definition at line 509 of file umct.c.

◆ umct_probe()

static int umct_probe ( device_t  dev)
static

◆ umct_read_callback()

static void umct_read_callback ( struct usb_xfer xfer,
usb_error_t  error 
)
static

Definition at line 596 of file umct.c.

References error, umct_softc::sc_swap_cb, umct_intr_callback_sub, umct_read_callback_sub, and usbd_xfer_softc().

Here is the call graph for this function:

◆ umct_read_callback_sub()

static void umct_read_callback_sub ( struct usb_xfer xfer,
usb_error_t  error 
)
static

◆ umct_start_read()

static void umct_start_read ( struct ucom_softc ucom)
static

Definition at line 556 of file umct.c.

References ucom_softc::sc_parent, umct_softc::sc_xfer, UMCT_BULK_DT_RD, UMCT_INTR_DT_RD, and usbd_transfer_start().

Here is the call graph for this function:

◆ umct_start_write()

static void umct_start_write ( struct ucom_softc ucom)
static

Definition at line 580 of file umct.c.

References ucom_softc::sc_parent, umct_softc::sc_xfer, UMCT_BULK_DT_WR, and usbd_transfer_start().

Here is the call graph for this function:

◆ umct_stop_read()

static void umct_stop_read ( struct ucom_softc ucom)
static

Definition at line 568 of file umct.c.

References ucom_softc::sc_parent, umct_softc::sc_xfer, UMCT_BULK_DT_RD, UMCT_INTR_DT_RD, and usbd_transfer_stop().

Here is the call graph for this function:

◆ umct_stop_write()

static void umct_stop_write ( struct ucom_softc ucom)
static

Definition at line 588 of file umct.c.

References ucom_softc::sc_parent, umct_softc::sc_xfer, UMCT_BULK_DT_WR, and usbd_transfer_stop().

Here is the call graph for this function:

◆ umct_write_callback()

static void umct_write_callback ( struct usb_xfer xfer,
usb_error_t  error 
)
static

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( umct_devs  )

Variable Documentation

◆ umct_attach

device_attach_t umct_attach
static

Definition at line 134 of file umct.c.

◆ umct_callback

const struct ucom_callback umct_callback
static
Initial value:
= {
.ucom_cfg_get_status = &umct_cfg_get_status,
.ucom_cfg_set_dtr = &umct_cfg_set_dtr,
.ucom_cfg_set_rts = &umct_cfg_set_rts,
.ucom_cfg_set_break = &umct_cfg_set_break,
.ucom_cfg_param = &umct_cfg_param,
.ucom_pre_param = &umct_pre_param,
.ucom_start_read = &umct_start_read,
.ucom_stop_read = &umct_stop_read,
.ucom_start_write = &umct_start_write,
.ucom_stop_write = &umct_stop_write,
.ucom_poll = &umct_poll,
.ucom_free = &umct_free,
}
static int umct_pre_param(struct ucom_softc *, struct termios *)
Definition: umct.c:509
static void umct_poll(struct ucom_softc *ucom)
Definition: umct.c:677
static void umct_stop_read(struct ucom_softc *)
Definition: umct.c:568
static void umct_free(struct ucom_softc *)
Definition: umct.c:345
static void umct_cfg_set_break(struct ucom_softc *, uint8_t)
Definition: umct.c:439
static void umct_cfg_set_dtr(struct ucom_softc *, uint8_t)
Definition: umct.c:452
static void umct_cfg_param(struct ucom_softc *, struct termios *)
Definition: umct.c:515
static void umct_cfg_set_rts(struct ucom_softc *, uint8_t)
Definition: umct.c:465
static void umct_start_write(struct ucom_softc *)
Definition: umct.c:580
static void umct_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *)
Definition: umct.c:430
static void umct_start_read(struct ucom_softc *)
Definition: umct.c:556
static void umct_stop_write(struct ucom_softc *)
Definition: umct.c:588

Definition at line 192 of file umct.c.

Referenced by umct_attach().

◆ umct_config

const struct usb_config umct_config[UMCT_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.bufsize = 0,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.callback = &umct_write_callback,
},
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.bufsize = 0,
.callback = &umct_read_callback,
.ep_index = 0,
},
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.bufsize = 0,
.callback = &umct_intr_callback,
.ep_index = 1,
},
}
static usb_callback_t umct_write_callback
Definition: umct.c:142
@ UMCT_BULK_DT_RD
Definition: umct.c:106
@ UMCT_BULK_DT_WR
Definition: umct.c:105
@ UMCT_INTR_DT_RD
Definition: umct.c:107
static usb_callback_t umct_intr_callback
Definition: umct.c:138
static usb_callback_t umct_read_callback
Definition: umct.c:140
#define UE_INTERRUPT
Definition: usb.h:544
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UE_DIR_IN
Definition: usb.h:531
#define UE_DIR_OUT
Definition: usb.h:532

Definition at line 161 of file umct.c.

Referenced by umct_attach().

◆ umct_detach

device_detach_t umct_detach
static

Definition at line 135 of file umct.c.

Referenced by umct_attach().

◆ umct_devclass

devclass_t umct_devclass
static

Definition at line 222 of file umct.c.

◆ umct_devs

const STRUCT_USB_HOST_ID umct_devs[]
static
Initial value:
= {
{USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_USB232, 0)},
{USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_SITECOM_USB232, 0)},
{USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_DU_H3SP_USB232, 0)},
{USB_VPI(USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U109, 0)},
{USB_VPI(USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U409, 0)},
}
#define USB_VPI(vend, prod, info)
Definition: usbdi.h:367

Definition at line 207 of file umct.c.

Referenced by umct_probe().

◆ umct_driver

driver_t umct_driver
static
Initial value:
= {
.name = "umct",
.methods = umct_methods,
.size = sizeof(struct umct_softc),
}
static device_method_t umct_methods[]
Definition: umct.c:215

Definition at line 224 of file umct.c.

◆ umct_intr_callback

usb_callback_t umct_intr_callback
static

Definition at line 138 of file umct.c.

◆ umct_intr_callback_sub

usb_callback_t umct_intr_callback_sub
static

Definition at line 139 of file umct.c.

Referenced by umct_intr_callback(), and umct_read_callback().

◆ umct_methods

device_method_t umct_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, umct_probe),
DEVMETHOD(device_attach, umct_attach),
DEVMETHOD(device_detach, umct_detach),
DEVMETHOD_END
}
static device_detach_t umct_detach
Definition: umct.c:135
static device_attach_t umct_attach
Definition: umct.c:134
static device_probe_t umct_probe
Definition: umct.c:133

Definition at line 215 of file umct.c.

◆ umct_probe

device_probe_t umct_probe
static

Definition at line 133 of file umct.c.

◆ umct_read_callback

usb_callback_t umct_read_callback
static

Definition at line 140 of file umct.c.

◆ umct_read_callback_sub

usb_callback_t umct_read_callback_sub
static

Definition at line 141 of file umct.c.

Referenced by umct_intr_callback(), and umct_read_callback().

◆ umct_write_callback

usb_callback_t umct_write_callback
static

Definition at line 142 of file umct.c.