FreeBSD kernel usb device Code
uvisor.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 "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 uvisor.c:

Go to the source code of this file.

Data Structures

struct  uvisor_connection_info
 
struct  uvisor_palm_connection_info
 
struct  uvisor_softc
 

Macros

#define USB_DEBUG_VAR   uvisor_debug
 
#define UVISOR_CONFIG_INDEX   0
 
#define UVISOR_IFACE_INDEX   0
 
#define UVISORIBUFSIZE   0 /* Use wMaxPacketSize */
 
#define UVISOROBUFSIZE   32 /* bytes */
 
#define UVISOROFRAMES   32 /* units */
 
#define UVISOR_REQUEST_BYTES_AVAILABLE   0x01
 
#define UVISOR_CLOSE_NOTIFICATION   0x02
 
#define UVISOR_GET_CONNECTION_INFORMATION   0x03
 
#define UVISOR_MAX_CONN   8
 
#define UVISOR_CONNECTION_INFO_SIZE   18
 
#define UVISOR_ENDPOINT_1   0x01
 
#define UVISOR_ENDPOINT_2   0x02
 
#define UVISOR_FUNCTION_GENERIC   0x00
 
#define UVISOR_FUNCTION_DEBUGGER   0x01
 
#define UVISOR_FUNCTION_HOTSYNC   0x02
 
#define UVISOR_FUNCTION_CONSOLE   0x03
 
#define UVISOR_FUNCTION_REMOTE_FILE_SYS   0x04
 
#define UVISOR_GET_PALM_INFORMATION   0x04
 
#define UVISOR_GET_PALM_INFORMATION_LEN   0x44
 
#define UVISOR_FLAG_PALM4   0x0001
 
#define UVISOR_FLAG_VISOR   0x0002
 
#define UVISOR_FLAG_PALM35   0x0004
 
#define UVISOR_FLAG_SEND_NOTIFY   0x0008
 
#define UVISOR_DEV(v, p, i)   { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
 

Enumerations

enum  { UVISOR_BULK_DT_WR , UVISOR_BULK_DT_RD , UVISOR_N_TRANSFER }
 

Functions

static void uvisor_free_softc (struct uvisor_softc *)
 
static usb_error_t uvisor_init (struct uvisor_softc *, struct usb_device *, struct usb_config *)
 
static void uvisor_free (struct ucom_softc *)
 
static void uvisor_cfg_open (struct ucom_softc *)
 
static void uvisor_cfg_close (struct ucom_softc *)
 
static void uvisor_start_read (struct ucom_softc *)
 
static void uvisor_stop_read (struct ucom_softc *)
 
static void uvisor_start_write (struct ucom_softc *)
 
static void uvisor_stop_write (struct ucom_softc *)
 
 DRIVER_MODULE (uvisor, uhub, uvisor_driver, uvisor_devclass, NULL, 0)
 
 MODULE_DEPEND (uvisor, ucom, 1, 1, 1)
 
 MODULE_DEPEND (uvisor, usb, 1, 1, 1)
 
 MODULE_VERSION (uvisor, 1)
 
 USB_PNP_HOST_INFO (uvisor_devs)
 
static int uvisor_probe (device_t dev)
 
static int uvisor_attach (device_t dev)
 
static int uvisor_detach (device_t dev)
 
 UCOM_UNLOAD_DRAIN (uvisor)
 
static void uvisor_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void uvisor_read_callback (struct usb_xfer *xfer, usb_error_t error)
 

Variables

struct uvisor_connection_info __packed
 
static device_probe_t uvisor_probe
 
static device_attach_t uvisor_attach
 
static device_detach_t uvisor_detach
 
static usb_callback_t uvisor_write_callback
 
static usb_callback_t uvisor_read_callback
 
static const struct usb_config uvisor_config [UVISOR_N_TRANSFER]
 
static const struct ucom_callback uvisor_callback
 
static device_method_t uvisor_methods []
 
static devclass_t uvisor_devclass
 
static driver_t uvisor_driver
 
static const STRUCT_USB_HOST_ID uvisor_devs []
 

Macro Definition Documentation

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   uvisor_debug

Definition at line 76 of file uvisor.c.

◆ UVISOR_CLOSE_NOTIFICATION

#define UVISOR_CLOSE_NOTIFICATION   0x02

Definition at line 115 of file uvisor.c.

◆ UVISOR_CONFIG_INDEX

#define UVISOR_CONFIG_INDEX   0

Definition at line 91 of file uvisor.c.

◆ UVISOR_CONNECTION_INFO_SIZE

#define UVISOR_CONNECTION_INFO_SIZE   18

Definition at line 135 of file uvisor.c.

◆ UVISOR_DEV

#define UVISOR_DEV (   v,
  p,
 
)    { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }

◆ UVISOR_ENDPOINT_1

#define UVISOR_ENDPOINT_1   0x01

Definition at line 138 of file uvisor.c.

◆ UVISOR_ENDPOINT_2

#define UVISOR_ENDPOINT_2   0x02

Definition at line 139 of file uvisor.c.

◆ UVISOR_FLAG_PALM35

#define UVISOR_FLAG_PALM35   0x0004

Definition at line 183 of file uvisor.c.

◆ UVISOR_FLAG_PALM4

#define UVISOR_FLAG_PALM4   0x0001

Definition at line 181 of file uvisor.c.

◆ UVISOR_FLAG_SEND_NOTIFY

#define UVISOR_FLAG_SEND_NOTIFY   0x0008

Definition at line 184 of file uvisor.c.

◆ UVISOR_FLAG_VISOR

#define UVISOR_FLAG_VISOR   0x0002

Definition at line 182 of file uvisor.c.

◆ UVISOR_FUNCTION_CONSOLE

#define UVISOR_FUNCTION_CONSOLE   0x03

Definition at line 145 of file uvisor.c.

◆ UVISOR_FUNCTION_DEBUGGER

#define UVISOR_FUNCTION_DEBUGGER   0x01

Definition at line 143 of file uvisor.c.

◆ UVISOR_FUNCTION_GENERIC

#define UVISOR_FUNCTION_GENERIC   0x00

Definition at line 142 of file uvisor.c.

◆ UVISOR_FUNCTION_HOTSYNC

#define UVISOR_FUNCTION_HOTSYNC   0x02

Definition at line 144 of file uvisor.c.

◆ UVISOR_FUNCTION_REMOTE_FILE_SYS

#define UVISOR_FUNCTION_REMOTE_FILE_SYS   0x04

Definition at line 146 of file uvisor.c.

◆ UVISOR_GET_CONNECTION_INFORMATION

#define UVISOR_GET_CONNECTION_INFORMATION   0x03

Definition at line 121 of file uvisor.c.

◆ UVISOR_GET_PALM_INFORMATION

#define UVISOR_GET_PALM_INFORMATION   0x04

Definition at line 151 of file uvisor.c.

◆ UVISOR_GET_PALM_INFORMATION_LEN

#define UVISOR_GET_PALM_INFORMATION_LEN   0x44

Definition at line 152 of file uvisor.c.

◆ UVISOR_IFACE_INDEX

#define UVISOR_IFACE_INDEX   0

Definition at line 92 of file uvisor.c.

◆ UVISOR_MAX_CONN

#define UVISOR_MAX_CONN   8

Definition at line 126 of file uvisor.c.

◆ UVISOR_REQUEST_BYTES_AVAILABLE

#define UVISOR_REQUEST_BYTES_AVAILABLE   0x01

Definition at line 109 of file uvisor.c.

◆ UVISORIBUFSIZE

#define UVISORIBUFSIZE   0 /* Use wMaxPacketSize */

Definition at line 99 of file uvisor.c.

◆ UVISOROBUFSIZE

#define UVISOROBUFSIZE   32 /* bytes */

Definition at line 100 of file uvisor.c.

◆ UVISOROFRAMES

#define UVISOROFRAMES   32 /* units */

Definition at line 101 of file uvisor.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UVISOR_BULK_DT_WR 
UVISOR_BULK_DT_RD 
UVISOR_N_TRANSFER 

Definition at line 166 of file uvisor.c.

Function Documentation

◆ DRIVER_MODULE()

DRIVER_MODULE ( uvisor  ,
uhub  ,
uvisor_driver  ,
uvisor_devclass  ,
NULL  ,
 
)

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( uvisor  ,
ucom  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

MODULE_DEPEND ( uvisor  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( uvisor  ,
 
)

◆ UCOM_UNLOAD_DRAIN()

UCOM_UNLOAD_DRAIN ( uvisor  )

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( uvisor_devs  )

◆ uvisor_attach()

◆ uvisor_cfg_close()

static void uvisor_cfg_close ( struct ucom_softc ucom)
static

◆ uvisor_cfg_open()

static void uvisor_cfg_open ( struct ucom_softc ucom)
static

Definition at line 550 of file uvisor.c.

◆ uvisor_detach()

static int uvisor_detach ( device_t  dev)
static

◆ uvisor_free()

static void uvisor_free ( struct ucom_softc ucom)
static

Definition at line 395 of file uvisor.c.

References ucom_softc::sc_parent, and uvisor_free_softc().

Here is the call graph for this function:

◆ uvisor_free_softc()

static void uvisor_free_softc ( struct uvisor_softc sc)
static

Definition at line 386 of file uvisor.c.

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

Referenced by uvisor_detach(), and uvisor_free().

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

◆ uvisor_init()

◆ uvisor_probe()

static int uvisor_probe ( device_t  dev)
static

◆ uvisor_read_callback()

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

◆ uvisor_start_read()

static void uvisor_start_read ( struct ucom_softc ucom)
static

Definition at line 578 of file uvisor.c.

References ucom_softc::sc_parent, uvisor_softc::sc_xfer, usbd_transfer_start(), and UVISOR_BULK_DT_RD.

Here is the call graph for this function:

◆ uvisor_start_write()

static void uvisor_start_write ( struct ucom_softc ucom)
static

Definition at line 594 of file uvisor.c.

References ucom_softc::sc_parent, uvisor_softc::sc_xfer, usbd_transfer_start(), and UVISOR_BULK_DT_WR.

Here is the call graph for this function:

◆ uvisor_stop_read()

static void uvisor_stop_read ( struct ucom_softc ucom)
static

Definition at line 586 of file uvisor.c.

References ucom_softc::sc_parent, uvisor_softc::sc_xfer, usbd_transfer_stop(), and UVISOR_BULK_DT_RD.

Here is the call graph for this function:

◆ uvisor_stop_write()

static void uvisor_stop_write ( struct ucom_softc ucom)
static

Definition at line 602 of file uvisor.c.

References ucom_softc::sc_parent, uvisor_softc::sc_xfer, usbd_transfer_stop(), and UVISOR_BULK_DT_WR.

Here is the call graph for this function:

◆ uvisor_write_callback()

Variable Documentation

◆ __packed

◆ uvisor_attach

device_attach_t uvisor_attach
static

Definition at line 193 of file uvisor.c.

◆ uvisor_callback

const struct ucom_callback uvisor_callback
static
Initial value:
= {
.ucom_cfg_open = &uvisor_cfg_open,
.ucom_cfg_close = &uvisor_cfg_close,
.ucom_start_read = &uvisor_start_read,
.ucom_stop_read = &uvisor_stop_read,
.ucom_start_write = &uvisor_start_write,
.ucom_stop_write = &uvisor_stop_write,
.ucom_free = &uvisor_free,
}
static void uvisor_cfg_open(struct ucom_softc *)
Definition: uvisor.c:550
static void uvisor_stop_read(struct ucom_softc *)
Definition: uvisor.c:586
static void uvisor_start_write(struct ucom_softc *)
Definition: uvisor.c:594
static void uvisor_stop_write(struct ucom_softc *)
Definition: uvisor.c:602
static void uvisor_cfg_close(struct ucom_softc *)
Definition: uvisor.c:556
static void uvisor_free(struct ucom_softc *)
Definition: uvisor.c:395
static void uvisor_start_read(struct ucom_softc *)
Definition: uvisor.c:578

Definition at line 231 of file uvisor.c.

Referenced by uvisor_attach().

◆ uvisor_config

const struct usb_config uvisor_config[UVISOR_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.frames = UVISOROFRAMES,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.callback = &uvisor_write_callback,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = UVISORIBUFSIZE,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.callback = &uvisor_read_callback,
},
}
#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
#define UVISORIBUFSIZE
Definition: uvisor.c:99
#define UVISOROBUFSIZE
Definition: uvisor.c:100
@ UVISOR_BULK_DT_RD
Definition: uvisor.c:168
@ UVISOR_BULK_DT_WR
Definition: uvisor.c:167
#define UVISOROFRAMES
Definition: uvisor.c:101
static usb_callback_t uvisor_read_callback
Definition: uvisor.c:198
static usb_callback_t uvisor_write_callback
Definition: uvisor.c:197

Definition at line 210 of file uvisor.c.

Referenced by uvisor_attach().

◆ uvisor_detach

device_detach_t uvisor_detach
static

Definition at line 194 of file uvisor.c.

Referenced by uvisor_attach().

◆ uvisor_devclass

devclass_t uvisor_devclass
static

Definition at line 248 of file uvisor.c.

◆ uvisor_devs

const STRUCT_USB_HOST_ID uvisor_devs[]
static

Definition at line 256 of file uvisor.c.

Referenced by uvisor_probe().

◆ uvisor_driver

driver_t uvisor_driver
static
Initial value:
= {
.name = "uvisor",
.methods = uvisor_methods,
.size = sizeof(struct uvisor_softc),
}
static device_method_t uvisor_methods[]
Definition: uvisor.c:241

Definition at line 250 of file uvisor.c.

◆ uvisor_methods

device_method_t uvisor_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, uvisor_probe),
DEVMETHOD(device_attach, uvisor_attach),
DEVMETHOD(device_detach, uvisor_detach),
DEVMETHOD_END
}
static device_attach_t uvisor_attach
Definition: uvisor.c:193
static device_detach_t uvisor_detach
Definition: uvisor.c:194
static device_probe_t uvisor_probe
Definition: uvisor.c:192

Definition at line 241 of file uvisor.c.

◆ uvisor_probe

device_probe_t uvisor_probe
static

Definition at line 192 of file uvisor.c.

◆ uvisor_read_callback

usb_callback_t uvisor_read_callback
static

Definition at line 198 of file uvisor.c.

◆ uvisor_write_callback

usb_callback_t uvisor_write_callback
static

Definition at line 197 of file uvisor.c.