FreeBSD kernel usb device Code
uark.c File Reference
#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 <dev/usb/usbhid.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 uark.c:

Go to the source code of this file.

Data Structures

struct  uark_softc
 

Macros

#define USB_DEBUG_VAR   usb_debug
 
#define UARK_BUF_SIZE   1024 /* bytes */
 
#define UARK_SET_DATA_BITS(x)   ((x) - 5)
 
#define UARK_PARITY_NONE   0x00
 
#define UARK_PARITY_ODD   0x08
 
#define UARK_PARITY_EVEN   0x18
 
#define UARK_STOP_BITS_1   0x00
 
#define UARK_STOP_BITS_2   0x04
 
#define UARK_BAUD_REF   3000000
 
#define UARK_WRITE   0x40
 
#define UARK_READ   0xc0
 
#define UARK_REQUEST   0xfe
 
#define UARK_CONFIG_INDEX   0
 
#define UARK_IFACE_INDEX   0
 

Enumerations

enum  { UARK_BULK_DT_WR , UARK_BULK_DT_RD , UARK_N_TRANSFER }
 

Functions

static void uark_free_softc (struct uark_softc *)
 
static void uark_free (struct ucom_softc *)
 
static void uark_start_read (struct ucom_softc *)
 
static void uark_stop_read (struct ucom_softc *)
 
static void uark_start_write (struct ucom_softc *)
 
static void uark_stop_write (struct ucom_softc *)
 
static int uark_pre_param (struct ucom_softc *, struct termios *)
 
static void uark_cfg_param (struct ucom_softc *, struct termios *)
 
static void uark_cfg_get_status (struct ucom_softc *, uint8_t *, uint8_t *)
 
static void uark_cfg_set_break (struct ucom_softc *, uint8_t)
 
static void uark_cfg_write (struct uark_softc *, uint16_t, uint16_t)
 
static void uark_poll (struct ucom_softc *ucom)
 
 DRIVER_MODULE (uark, uhub, uark_driver, uark_devclass, NULL, 0)
 
 MODULE_DEPEND (uark, ucom, 1, 1, 1)
 
 MODULE_DEPEND (uark, usb, 1, 1, 1)
 
 MODULE_VERSION (uark, 1)
 
 USB_PNP_HOST_INFO (uark_devs)
 
static int uark_probe (device_t dev)
 
static int uark_attach (device_t dev)
 
static int uark_detach (device_t dev)
 
 UCOM_UNLOAD_DRAIN (uark)
 
static void uark_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void uark_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error)
 

Variables

static device_probe_t uark_probe
 
static device_attach_t uark_attach
 
static device_detach_t uark_detach
 
static usb_callback_t uark_bulk_write_callback
 
static usb_callback_t uark_bulk_read_callback
 
static const struct usb_config uark_xfer_config [UARK_N_TRANSFER]
 
static const struct ucom_callback uark_callback
 
static device_method_t uark_methods []
 
static devclass_t uark_devclass
 
static driver_t uark_driver
 
static const STRUCT_USB_HOST_ID uark_devs []
 

Macro Definition Documentation

◆ UARK_BAUD_REF

#define UARK_BAUD_REF   3000000

Definition at line 68 of file uark.c.

◆ UARK_BUF_SIZE

#define UARK_BUF_SIZE   1024 /* bytes */

Definition at line 57 of file uark.c.

◆ UARK_CONFIG_INDEX

#define UARK_CONFIG_INDEX   0

Definition at line 75 of file uark.c.

◆ UARK_IFACE_INDEX

#define UARK_IFACE_INDEX   0

Definition at line 76 of file uark.c.

◆ UARK_PARITY_EVEN

#define UARK_PARITY_EVEN   0x18

Definition at line 63 of file uark.c.

◆ UARK_PARITY_NONE

#define UARK_PARITY_NONE   0x00

Definition at line 61 of file uark.c.

◆ UARK_PARITY_ODD

#define UARK_PARITY_ODD   0x08

Definition at line 62 of file uark.c.

◆ UARK_READ

#define UARK_READ   0xc0

Definition at line 71 of file uark.c.

◆ UARK_REQUEST

#define UARK_REQUEST   0xfe

Definition at line 73 of file uark.c.

◆ UARK_SET_DATA_BITS

#define UARK_SET_DATA_BITS (   x)    ((x) - 5)

Definition at line 59 of file uark.c.

◆ UARK_STOP_BITS_1

#define UARK_STOP_BITS_1   0x00

Definition at line 65 of file uark.c.

◆ UARK_STOP_BITS_2

#define UARK_STOP_BITS_2   0x04

Definition at line 66 of file uark.c.

◆ UARK_WRITE

#define UARK_WRITE   0x40

Definition at line 70 of file uark.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   usb_debug

Definition at line 51 of file uark.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UARK_BULK_DT_WR 
UARK_BULK_DT_RD 
UARK_N_TRANSFER 

Definition at line 78 of file uark.c.

Function Documentation

◆ DRIVER_MODULE()

DRIVER_MODULE ( uark  ,
uhub  ,
uark_driver  ,
uark_devclass  ,
NULL  ,
 
)

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( uark  ,
ucom  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

MODULE_DEPEND ( uark  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( uark  ,
 
)

◆ uark_attach()

◆ uark_bulk_read_callback()

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

◆ uark_bulk_write_callback()

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

◆ uark_cfg_get_status()

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

Definition at line 423 of file uark.c.

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

◆ uark_cfg_param()

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

Definition at line 373 of file uark.c.

References data, ucom_softc::sc_parent, UARK_BAUD_REF, uark_cfg_write(), UARK_PARITY_EVEN, UARK_PARITY_NONE, UARK_PARITY_ODD, UARK_SET_DATA_BITS, UARK_STOP_BITS_1, and UARK_STOP_BITS_2.

Here is the call graph for this function:

◆ uark_cfg_set_break()

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

Definition at line 433 of file uark.c.

References DPRINTF, ucom_softc::sc_parent, and uark_cfg_write().

Here is the call graph for this function:

◆ uark_cfg_write()

static void uark_cfg_write ( struct uark_softc sc,
uint16_t  index,
uint16_t  value 
)
static

Definition at line 443 of file uark.c.

References index, req, uark_softc::sc_ucom, uark_softc::sc_udev, UARK_REQUEST, UARK_WRITE, ucom_cfg_do_request, usbd_errstr(), USETW, and value.

Referenced by uark_cfg_param(), and uark_cfg_set_break().

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

◆ uark_detach()

static int uark_detach ( device_t  dev)
static

Definition at line 242 of file uark.c.

References dev, uark_softc::sc_super_ucom, uark_softc::sc_ucom, uark_softc::sc_xfer, uark_free_softc(), UARK_N_TRANSFER, ucom_detach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ uark_free()

static void uark_free ( struct ucom_softc ucom)
static

Definition at line 268 of file uark.c.

References ucom_softc::sc_parent, and uark_free_softc().

Here is the call graph for this function:

◆ uark_free_softc()

static void uark_free_softc ( struct uark_softc sc)
static

Definition at line 259 of file uark.c.

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

Referenced by uark_detach(), and uark_free().

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

◆ uark_poll()

static void uark_poll ( struct ucom_softc ucom)
static

Definition at line 463 of file uark.c.

References ucom_softc::sc_parent, uark_softc::sc_xfer, UARK_N_TRANSFER, and usbd_transfer_poll().

Here is the call graph for this function:

◆ uark_pre_param()

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

Definition at line 365 of file uark.c.

◆ uark_probe()

static int uark_probe ( device_t  dev)
static

◆ uark_start_read()

static void uark_start_read ( struct ucom_softc ucom)
static

Definition at line 333 of file uark.c.

References ucom_softc::sc_parent, uark_softc::sc_xfer, UARK_BULK_DT_RD, and usbd_transfer_start().

Here is the call graph for this function:

◆ uark_start_write()

static void uark_start_write ( struct ucom_softc ucom)
static

Definition at line 349 of file uark.c.

References ucom_softc::sc_parent, uark_softc::sc_xfer, UARK_BULK_DT_WR, and usbd_transfer_start().

Here is the call graph for this function:

◆ uark_stop_read()

static void uark_stop_read ( struct ucom_softc ucom)
static

Definition at line 341 of file uark.c.

References ucom_softc::sc_parent, uark_softc::sc_xfer, UARK_BULK_DT_RD, and usbd_transfer_stop().

Here is the call graph for this function:

◆ uark_stop_write()

static void uark_stop_write ( struct ucom_softc ucom)
static

Definition at line 357 of file uark.c.

References ucom_softc::sc_parent, uark_softc::sc_xfer, UARK_BULK_DT_WR, and usbd_transfer_stop().

Here is the call graph for this function:

◆ UCOM_UNLOAD_DRAIN()

UCOM_UNLOAD_DRAIN ( uark  )

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( uark_devs  )

Variable Documentation

◆ uark_attach

device_attach_t uark_attach
static

Definition at line 99 of file uark.c.

◆ uark_bulk_read_callback

usb_callback_t uark_bulk_read_callback
static

Definition at line 104 of file uark.c.

◆ uark_bulk_write_callback

usb_callback_t uark_bulk_write_callback
static

Definition at line 103 of file uark.c.

◆ uark_callback

const struct ucom_callback uark_callback
static
Initial value:
= {
.ucom_cfg_get_status = &uark_cfg_get_status,
.ucom_cfg_set_break = &uark_cfg_set_break,
.ucom_cfg_param = &uark_cfg_param,
.ucom_pre_param = &uark_pre_param,
.ucom_start_read = &uark_start_read,
.ucom_stop_read = &uark_stop_read,
.ucom_start_write = &uark_start_write,
.ucom_stop_write = &uark_stop_write,
.ucom_poll = &uark_poll,
.ucom_free = &uark_free,
}
static void uark_cfg_param(struct ucom_softc *, struct termios *)
Definition: uark.c:373
static void uark_stop_write(struct ucom_softc *)
Definition: uark.c:357
static void uark_start_read(struct ucom_softc *)
Definition: uark.c:333
static void uark_start_write(struct ucom_softc *)
Definition: uark.c:349
static void uark_free(struct ucom_softc *)
Definition: uark.c:268
static void uark_poll(struct ucom_softc *ucom)
Definition: uark.c:463
static void uark_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *)
Definition: uark.c:423
static void uark_cfg_set_break(struct ucom_softc *, uint8_t)
Definition: uark.c:433
static int uark_pre_param(struct ucom_softc *, struct termios *)
Definition: uark.c:365
static void uark_stop_read(struct ucom_softc *)
Definition: uark.c:341

Definition at line 140 of file uark.c.

Referenced by uark_attach().

◆ uark_detach

device_detach_t uark_detach
static

Definition at line 100 of file uark.c.

Referenced by uark_attach().

◆ uark_devclass

devclass_t uark_devclass
static

Definition at line 161 of file uark.c.

◆ uark_devs

const STRUCT_USB_HOST_ID uark_devs[]
static
Initial value:
= {
{USB_VPI(USB_VENDOR_ARKMICRO, USB_PRODUCT_ARKMICRO_ARK3116, 0)},
}
#define USB_VPI(vend, prod, info)
Definition: usbdi.h:367

Definition at line 169 of file uark.c.

Referenced by uark_probe().

◆ uark_driver

driver_t uark_driver
static
Initial value:
= {
.name = "uark",
.methods = uark_methods,
.size = sizeof(struct uark_softc),
}
static device_method_t uark_methods[]
Definition: uark.c:153

Definition at line 163 of file uark.c.

◆ uark_methods

device_method_t uark_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, uark_probe),
DEVMETHOD(device_attach, uark_attach),
DEVMETHOD(device_detach, uark_detach),
DEVMETHOD_END
}
static device_detach_t uark_detach
Definition: uark.c:100
static device_probe_t uark_probe
Definition: uark.c:98
static device_attach_t uark_attach
Definition: uark.c:99

Definition at line 153 of file uark.c.

◆ uark_probe

device_probe_t uark_probe
static

Definition at line 98 of file uark.c.

◆ uark_xfer_config

const struct usb_config uark_xfer_config[UARK_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.bufsize = UARK_BUF_SIZE,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = UARK_BUF_SIZE,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
},
}
#define UARK_BUF_SIZE
Definition: uark.c:57
static usb_callback_t uark_bulk_write_callback
Definition: uark.c:103
static usb_callback_t uark_bulk_read_callback
Definition: uark.c:104
@ UARK_BULK_DT_RD
Definition: uark.c:80
@ UARK_BULK_DT_WR
Definition: uark.c:79
#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 120 of file uark.c.

Referenced by uark_attach().