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

Go to the source code of this file.

Data Structures

struct  ubser_softc
 

Macros

#define USB_DEBUG_VAR   ubser_debug
 
#define UBSER_UNIT_MAX   32
 
#define VENDOR_GET_NUMSER   0x01
 
#define VENDOR_SET_BREAK   0x02
 
#define VENDOR_CLEAR_BREAK   0x03
 

Enumerations

enum  { UBSER_BULK_DT_WR , UBSER_BULK_DT_RD , UBSER_N_TRANSFER }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void ubser_free_softc (struct ubser_softc *)
 
static void ubser_free (struct ucom_softc *)
 
static int ubser_pre_param (struct ucom_softc *, struct termios *)
 
static void ubser_cfg_set_break (struct ucom_softc *, uint8_t)
 
static void ubser_cfg_get_status (struct ucom_softc *, uint8_t *, uint8_t *)
 
static void ubser_start_read (struct ucom_softc *)
 
static void ubser_stop_read (struct ucom_softc *)
 
static void ubser_start_write (struct ucom_softc *)
 
static void ubser_stop_write (struct ucom_softc *)
 
static void ubser_poll (struct ucom_softc *ucom)
 
 DRIVER_MODULE (ubser, uhub, ubser_driver, ubser_devclass, NULL, 0)
 
 MODULE_DEPEND (ubser, ucom, 1, 1, 1)
 
 MODULE_DEPEND (ubser, usb, 1, 1, 1)
 
 MODULE_VERSION (ubser, 1)
 
static int ubser_probe (device_t dev)
 
static int ubser_attach (device_t dev)
 
static int ubser_detach (device_t dev)
 
 UCOM_UNLOAD_DRAIN (ubser)
 
static __inline void ubser_inc_tx_unit (struct ubser_softc *sc)
 
static void ubser_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void ubser_read_callback (struct usb_xfer *xfer, usb_error_t error)
 

Variables

static device_probe_t ubser_probe
 
static device_attach_t ubser_attach
 
static device_detach_t ubser_detach
 
static usb_callback_t ubser_write_callback
 
static usb_callback_t ubser_read_callback
 
static const struct usb_config ubser_config [UBSER_N_TRANSFER]
 
static const struct ucom_callback ubser_callback
 
static device_method_t ubser_methods []
 
static devclass_t ubser_devclass
 
static driver_t ubser_driver
 

Macro Definition Documentation

◆ UBSER_UNIT_MAX

#define UBSER_UNIT_MAX   32

Definition at line 104 of file ubser.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   ubser_debug

Definition at line 98 of file ubser.c.

◆ VENDOR_CLEAR_BREAK

#define VENDOR_CLEAR_BREAK   0x03

Definition at line 109 of file ubser.c.

◆ VENDOR_GET_NUMSER

#define VENDOR_GET_NUMSER   0x01

Definition at line 107 of file ubser.c.

◆ VENDOR_SET_BREAK

#define VENDOR_SET_BREAK   0x02

Definition at line 108 of file ubser.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UBSER_BULK_DT_WR 
UBSER_BULK_DT_RD 
UBSER_N_TRANSFER 

Definition at line 120 of file ubser.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( ubser  ,
uhub  ,
ubser_driver  ,
ubser_devclass  ,
NULL  ,
 
)

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( ubser  ,
ucom  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

MODULE_DEPEND ( ubser  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( ubser  ,
 
)

◆ ubser_attach()

◆ ubser_cfg_get_status()

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

Definition at line 513 of file ubser.c.

◆ ubser_cfg_set_break()

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

◆ ubser_detach()

static int ubser_detach ( device_t  dev)
static

Definition at line 309 of file ubser.c.

References dev, DPRINTF, ubser_softc::sc_super_ucom, ubser_softc::sc_ucom, ubser_softc::sc_xfer, ubser_free_softc(), UBSER_N_TRANSFER, ucom_detach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ ubser_free()

static void ubser_free ( struct ucom_softc ucom)
static

Definition at line 337 of file ubser.c.

References ucom_softc::sc_parent, and ubser_free_softc().

Here is the call graph for this function:

◆ ubser_free_softc()

static void ubser_free_softc ( struct ubser_softc sc)
static

Definition at line 328 of file ubser.c.

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

Referenced by ubser_detach(), and ubser_free().

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

◆ ubser_inc_tx_unit()

static __inline void ubser_inc_tx_unit ( struct ubser_softc sc)
static

Definition at line 392 of file ubser.c.

References ubser_softc::sc_curr_tx_unit, and ubser_softc::sc_numser.

Referenced by ubser_write_callback().

Here is the caller graph for this function:

◆ ubser_poll()

static void ubser_poll ( struct ucom_softc ucom)
static

Definition at line 553 of file ubser.c.

References ucom_softc::sc_parent, ubser_softc::sc_xfer, UBSER_N_TRANSFER, and usbd_transfer_poll().

Here is the call graph for this function:

◆ ubser_pre_param()

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

Definition at line 343 of file ubser.c.

References DPRINTF.

◆ ubser_probe()

static int ubser_probe ( device_t  dev)
static

◆ ubser_read_callback()

◆ ubser_start_read()

static void ubser_start_read ( struct ucom_softc ucom)
static

Definition at line 521 of file ubser.c.

References ucom_softc::sc_parent, ubser_softc::sc_xfer, UBSER_BULK_DT_RD, and usbd_transfer_start().

Here is the call graph for this function:

◆ ubser_start_write()

static void ubser_start_write ( struct ucom_softc ucom)
static

Definition at line 537 of file ubser.c.

References ucom_softc::sc_parent, ubser_softc::sc_xfer, UBSER_BULK_DT_WR, and usbd_transfer_start().

Here is the call graph for this function:

◆ ubser_stop_read()

static void ubser_stop_read ( struct ucom_softc ucom)
static

Definition at line 529 of file ubser.c.

References ucom_softc::sc_parent, ubser_softc::sc_xfer, UBSER_BULK_DT_RD, and usbd_transfer_stop().

Here is the call graph for this function:

◆ ubser_stop_write()

static void ubser_stop_write ( struct ucom_softc ucom)
static

Definition at line 545 of file ubser.c.

References ucom_softc::sc_parent, ubser_softc::sc_xfer, UBSER_BULK_DT_WR, and usbd_transfer_stop().

Here is the call graph for this function:

◆ ubser_write_callback()

◆ UCOM_UNLOAD_DRAIN()

UCOM_UNLOAD_DRAIN ( ubser  )

Variable Documentation

◆ ubser_attach

device_attach_t ubser_attach
static

Definition at line 145 of file ubser.c.

◆ ubser_callback

const struct ucom_callback ubser_callback
static
Initial value:
= {
.ucom_cfg_set_break = &ubser_cfg_set_break,
.ucom_cfg_get_status = &ubser_cfg_get_status,
.ucom_pre_param = &ubser_pre_param,
.ucom_start_read = &ubser_start_read,
.ucom_stop_read = &ubser_stop_read,
.ucom_start_write = &ubser_start_write,
.ucom_stop_write = &ubser_stop_write,
.ucom_poll = &ubser_poll,
.ucom_free = &ubser_free,
}
static void ubser_stop_read(struct ucom_softc *)
Definition: ubser.c:529
static void ubser_cfg_set_break(struct ucom_softc *, uint8_t)
Definition: ubser.c:487
static void ubser_free(struct ucom_softc *)
Definition: ubser.c:337
static void ubser_start_write(struct ucom_softc *)
Definition: ubser.c:537
static int ubser_pre_param(struct ucom_softc *, struct termios *)
Definition: ubser.c:343
static void ubser_stop_write(struct ucom_softc *)
Definition: ubser.c:545
static void ubser_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *)
Definition: ubser.c:513
static void ubser_start_read(struct ucom_softc *)
Definition: ubser.c:521
static void ubser_poll(struct ucom_softc *ucom)
Definition: ubser.c:553

Definition at line 183 of file ubser.c.

Referenced by ubser_attach().

◆ ubser_config

const struct usb_config ubser_config[UBSER_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 = &ubser_write_callback,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = 0,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.callback = &ubser_read_callback,
},
}
static usb_callback_t ubser_write_callback
Definition: ubser.c:149
static usb_callback_t ubser_read_callback
Definition: ubser.c:150
@ UBSER_BULK_DT_WR
Definition: ubser.c:121
@ UBSER_BULK_DT_RD
Definition: ubser.c:122
#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 163 of file ubser.c.

Referenced by ubser_attach().

◆ ubser_detach

device_detach_t ubser_detach
static

Definition at line 146 of file ubser.c.

Referenced by ubser_attach().

◆ ubser_devclass

devclass_t ubser_devclass
static

Definition at line 202 of file ubser.c.

◆ ubser_driver

driver_t ubser_driver
static
Initial value:
= {
.name = "ubser",
.methods = ubser_methods,
.size = sizeof(struct ubser_softc),
}
static device_method_t ubser_methods[]
Definition: ubser.c:195

Definition at line 204 of file ubser.c.

◆ ubser_methods

device_method_t ubser_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ubser_probe),
DEVMETHOD(device_attach, ubser_attach),
DEVMETHOD(device_detach, ubser_detach),
DEVMETHOD_END
}
static device_probe_t ubser_probe
Definition: ubser.c:144
static device_attach_t ubser_attach
Definition: ubser.c:145
static device_detach_t ubser_detach
Definition: ubser.c:146

Definition at line 195 of file ubser.c.

◆ ubser_probe

device_probe_t ubser_probe
static

Definition at line 144 of file ubser.c.

◆ ubser_read_callback

usb_callback_t ubser_read_callback
static

Definition at line 150 of file ubser.c.

◆ ubser_write_callback

usb_callback_t ubser_write_callback
static

Definition at line 149 of file ubser.c.