svn commit: r186964 - in projects/vap7: etc/mtree include lib
lib/libusb20 share/man/man7 share/mk sys/conf
sys/dev/sound/pcm sys/dev/usb sys/dev/usb2 sys/dev/usb2/core
sys/dev/usb2/serial sys/i386...
Andrew Thompson
thompsa at FreeBSD.org
Fri Jan 9 19:45:08 UTC 2009
Author: thompsa
Date: Fri Jan 9 19:45:06 2009
New Revision: 186964
URL: http://svn.freebsd.org/changeset/base/186964
Log:
Bring in USB2, libusb20 and usbconfig from HEAD.
Added:
projects/vap7/lib/libusb20/ (props changed)
- copied from r186961, head/lib/libusb20/
projects/vap7/sys/dev/usb2/ (props changed)
- copied from r186961, head/sys/dev/usb2/
projects/vap7/sys/i386/conf/USB2 (contents, props changed)
- copied, changed from r186962, head/sys/i386/conf/USB2
projects/vap7/sys/modules/usb2/ (props changed)
- copied from r186961, head/sys/modules/usb2/
projects/vap7/usr.sbin/usbconfig/ (props changed)
- copied from r186962, head/usr.sbin/usbconfig/
Modified:
projects/vap7/etc/mtree/BSD.include.dist
projects/vap7/include/Makefile
projects/vap7/lib/Makefile
projects/vap7/share/man/man7/hier.7
projects/vap7/share/mk/bsd.libnames.mk
projects/vap7/sys/conf/files
projects/vap7/sys/conf/kmod.mk
projects/vap7/sys/dev/sound/pcm/channel.c
projects/vap7/sys/dev/sound/pcm/channel.h
projects/vap7/sys/dev/sound/pcm/mixer.c
projects/vap7/sys/dev/sound/pcm/mixer.h
projects/vap7/sys/dev/usb/rio500_usb.h
projects/vap7/sys/dev/usb2/core/usb2_dev.c
projects/vap7/sys/dev/usb2/serial/usb2_serial.c
projects/vap7/sys/modules/Makefile
projects/vap7/usr.sbin/Makefile
Modified: projects/vap7/etc/mtree/BSD.include.dist
==============================================================================
--- projects/vap7/etc/mtree/BSD.include.dist Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/etc/mtree/BSD.include.dist Fri Jan 9 19:45:06 2009 (r186964)
@@ -120,6 +120,10 @@
..
usb
..
+ usb2
+ include
+ ..
+ ..
utopia
..
vkbd
Modified: projects/vap7/include/Makefile
==============================================================================
--- projects/vap7/include/Makefile Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/include/Makefile Fri Jan 9 19:45:06 2009 (r186964)
@@ -57,7 +57,7 @@ LSUBDIRS= cam/scsi \
security/mac_mls security/mac_partition \
ufs/ffs ufs/ufs
-LSUBSUBDIRS= dev/mpt/mpilib
+LSUBSUBDIRS= dev/mpt/mpilib dev/usb2/include
.if ${MACHINE_ARCH} == "powerpc"
_dev_powermac_nvram= dev/powermac_nvram
Modified: projects/vap7/lib/Makefile
==============================================================================
--- projects/vap7/lib/Makefile Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/lib/Makefile Fri Jan 9 19:45:06 2009 (r186964)
@@ -37,7 +37,8 @@ SUBDIR= ${_csu} libc libbsm libcom_err l
libpmc libproc ${_libkse} librt ${_libsdp} ${_libsm} ${_libsmb} \
${_libsmdb} \
${_libsmutil} libstand libtelnet ${_libthr} libthread_db libufs \
- libugidfw ${_libusbhid} ${_libvgl} libwrap liby libz ${_bind}
+ libugidfw ${_libusbhid} ${_libusb20} ${_libvgl} libwrap liby libz \
+ ${_bind}
.if exists(${.CURDIR}/csu/${MACHINE_ARCH}-elf)
_csu=csu/${MACHINE_ARCH}-elf
@@ -112,6 +113,7 @@ _libthr= libthr
.if ${MK_USB} != "no"
_libusbhid= libusbhid
+_libusb20= libusb20
.endif
.if ${MK_NIS} != "no"
Modified: projects/vap7/share/man/man7/hier.7
==============================================================================
--- projects/vap7/share/man/man7/hier.7 Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/share/man/man7/hier.7 Fri Jan 9 19:45:06 2009 (r186964)
@@ -236,6 +236,8 @@ see
.Xr ppbus 4
.It Pa usb/
The USB subsystem
+.It Pa usb2/include
+The USB subsystem
.It Pa utopia/
Physical chip driver for ATM interfaces;
see
Modified: projects/vap7/share/mk/bsd.libnames.mk
==============================================================================
--- projects/vap7/share/mk/bsd.libnames.mk Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/share/mk/bsd.libnames.mk Fri Jan 9 19:45:06 2009 (r186964)
@@ -145,6 +145,7 @@ LIBUFS?= ${DESTDIR}${LIBDIR}/libufs.a
LIBUGIDFW?= ${DESTDIR}${LIBDIR}/libugidfw.a
LIBUMEM?= ${DESTDIR}${LIBDIR}/libumem.a
LIBUSBHID?= ${DESTDIR}${LIBDIR}/libusbhid.a
+LIBUSB20?= ${DESTDIR}${LIBDIR}/libusb20.a
LIBUTIL?= ${DESTDIR}${LIBDIR}/libutil.a
LIBUUTIL?= ${DESTDIR}${LIBDIR}/libuutil.a
LIBVGL?= ${DESTDIR}${LIBDIR}/libvgl.a
Modified: projects/vap7/sys/conf/files
==============================================================================
--- projects/vap7/sys/conf/files Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/sys/conf/files Fri Jan 9 19:45:06 2009 (r186964)
@@ -1315,6 +1315,146 @@ dev/usb/uscanner.c optional uscanner
dev/usb/uslcom.c optional uslcom
dev/usb/uvisor.c optional uvisor
dev/usb/uvscom.c optional uvscom
+#
+# USB2 controller drivers
+#
+dev/usb2/controller/at91dci.c optional usb2_core usb2_controller usb2_controller_at91dci
+dev/usb2/controller/at91dci_atmelarm.c optional usb2_core usb2_controller usb2_controller_at91dci at91rm9200
+dev/usb2/controller/musb2_otg.c optional usb2_core usb2_controller usb2_controller_musb
+dev/usb2/controller/musb2_otg_atmelarm.c optional usb2_core usb2_controller usb2_controller_musb at91rm9200
+dev/usb2/controller/ehci2.c optional usb2_core usb2_controller usb2_controller_ehci
+dev/usb2/controller/ehci2_pci.c optional usb2_core usb2_controller usb2_controller_ehci pci
+dev/usb2/controller/ohci2.c optional usb2_core usb2_controller usb2_controller_ohci
+dev/usb2/controller/ohci2_atmelarm.c optional usb2_core usb2_controller usb2_controller_ohci at91rm9200
+dev/usb2/controller/ohci2_pci.c optional usb2_core usb2_controller usb2_controller_ohci pci
+dev/usb2/controller/uhci2.c optional usb2_core usb2_controller usb2_controller_uhci
+dev/usb2/controller/uhci2_pci.c optional usb2_core usb2_controller usb2_controller_uhci pci
+dev/usb2/controller/uss820dci.c optional usb2_core usb2_controller usb2_controller_uss820dci
+dev/usb2/controller/uss820dci_atmelarm.c optional usb2_core usb2_controller usb2_controller_uss820dci at91rm9200
+dev/usb2/controller/usb2_controller.c optional usb2_core usb2_controller
+#
+# USB2 storage drivers
+#
+dev/usb2/storage/ata-usb2.c optional usb2_core usb2_storage usb2_storage_ata
+dev/usb2/storage/umass2.c optional usb2_core usb2_storage usb2_storage_mass
+dev/usb2/storage/urio2.c optional usb2_core usb2_storage usb2_storage_rio
+dev/usb2/storage/usb2_storage.c optional usb2_core usb2_storage
+dev/usb2/storage/ustorage2_fs.c optional usb2_core usb2_storage usb2_storage_fs
+#
+# USB2 NDIS driver
+#
+dev/usb2/ndis/if_ndis_usb2.c optional usb2_core usb2_ndis
+dev/usb2/ndis/usb2_ndis.c optional usb2_core usb2_ndis
+#
+# USB2 core
+#
+dev/usb2/core/usb2_busdma.c optional usb2_core
+dev/usb2/core/usb2_compat_linux.c optional usb2_core
+dev/usb2/core/usb2_config_td.c optional usb2_core
+dev/usb2/core/usb2_core.c optional usb2_core
+dev/usb2/core/usb2_debug.c optional usb2_core
+dev/usb2/core/usb2_dev.c optional usb2_core
+dev/usb2/core/usb2_device.c optional usb2_core
+dev/usb2/core/usb2_dynamic.c optional usb2_core
+dev/usb2/core/usb2_error.c optional usb2_core
+dev/usb2/core/usb2_generic.c optional usb2_core
+dev/usb2/core/usb2_handle_request.c optional usb2_core
+dev/usb2/core/usb2_hid.c optional usb2_core
+dev/usb2/core/usb2_hub.c optional usb2_core
+dev/usb2/core/usb2_if.m optional usb2_core
+dev/usb2/core/usb2_lookup.c optional usb2_core
+dev/usb2/core/usb2_mbuf.c optional usb2_core
+dev/usb2/core/usb2_msctest.c optional usb2_core
+dev/usb2/core/usb2_parse.c optional usb2_core
+dev/usb2/core/usb2_process.c optional usb2_core
+dev/usb2/core/usb2_request.c optional usb2_core
+dev/usb2/core/usb2_sw_transfer.c optional usb2_core
+dev/usb2/core/usb2_transfer.c optional usb2_core
+dev/usb2/core/usb2_util.c optional usb2_core
+#
+# USB2 ethernet drivers
+#
+dev/usb2/ethernet/if_aue2.c optional usb2_core usb2_ethernet usb2_ethernet_aue
+dev/usb2/ethernet/if_axe2.c optional usb2_core usb2_ethernet usb2_ethernet_axe
+dev/usb2/ethernet/if_cdce2.c optional usb2_core usb2_ethernet usb2_ethernet_cdce
+dev/usb2/ethernet/if_cue2.c optional usb2_core usb2_ethernet usb2_ethernet_cue
+dev/usb2/ethernet/if_kue2.c optional usb2_core usb2_ethernet usb2_ethernet_kue
+dev/usb2/ethernet/if_rue2.c optional usb2_core usb2_ethernet usb2_ethernet_rue
+dev/usb2/ethernet/if_udav2.c optional usb2_core usb2_ethernet usb2_ethernet_dav
+dev/usb2/ethernet/usb2_ethernet.c optional usb2_core usb2_ethernet
+#
+# USB2 WLAN drivers
+#
+dev/usb2/wlan/if_rum2.c optional usb2_core usb2_wlan usb2_wlan_rum
+dev/usb2/wlan/if_ural2.c optional usb2_core usb2_wlan usb2_wlan_ral
+dev/usb2/wlan/if_zyd2.c optional usb2_core usb2_wlan usb2_wlan_zyd
+dev/usb2/wlan/usb2_wlan.c optional usb2_core usb2_wlan
+#
+# USB2 serial and parallel port drivers
+#
+dev/usb2/serial/uark2.c optional usb2_core usb2_serial usb2_serial_ark
+dev/usb2/serial/ubsa2.c optional usb2_core usb2_serial usb2_serial_bsa
+dev/usb2/serial/ubser2.c optional usb2_core usb2_serial usb2_serial_bser
+dev/usb2/serial/uchcom2.c optional usb2_core usb2_serial usb2_serial_chcom
+dev/usb2/serial/ucycom2.c optional usb2_core usb2_serial usb2_serial_cycom
+dev/usb2/serial/ufoma2.c optional usb2_core usb2_serial usb2_serial_foma
+dev/usb2/serial/uftdi2.c optional usb2_core usb2_serial usb2_serial_ftdi
+dev/usb2/serial/ugensa2.c optional usb2_core usb2_serial usb2_serial_gensa
+dev/usb2/serial/uipaq2.c optional usb2_core usb2_serial usb2_serial_ipaq
+dev/usb2/serial/ulpt2.c optional usb2_core usb2_serial usb2_serial_lpt
+dev/usb2/serial/umct2.c optional usb2_core usb2_serial usb2_serial_mct
+dev/usb2/serial/umodem2.c optional usb2_core usb2_serial usb2_serial_modem
+dev/usb2/serial/umoscom2.c optional usb2_core usb2_serial usb2_serial_moscom
+dev/usb2/serial/uplcom2.c optional usb2_core usb2_serial usb2_serial_plcom
+dev/usb2/serial/usb2_serial.c optional usb2_core usb2_serial
+dev/usb2/serial/uvisor2.c optional usb2_core usb2_serial usb2_serial_visor
+dev/usb2/serial/uvscom2.c optional usb2_core usb2_serial usb2_serial_vscom
+dev/usb2/serial/u3g2.c optional usb2_core usb2_serial usb2_serial_3g
+#
+# USB2 bluetooth drivers
+#
+dev/usb2/bluetooth/usb2_bluetooth.c optional usb2_core usb2_bluetooth
+dev/usb2/bluetooth/ng_ubt2.c optional usb2_core usb2_bluetooth usb2_bluetooth_ng
+dev/usb2/bluetooth/ubtbcmfw2.c optional usb2_core usb2_bluetooth usb2_bluetooth_fw
+
+#
+# USB2 misc drivers
+#
+dev/usb2/misc/usb2_misc.c optional usb2_core usb2_misc
+dev/usb2/misc/ufm2.c optional usb2_core usb2_misc usb2_misc_fm
+dev/usb2/misc/udbp2.c optional usb2_core usb2_misc usb2_misc_dbp
+#
+# USB2 input drivers
+#
+dev/usb2/input/uhid2.c optional usb2_core usb2_input usb2_input_hid
+dev/usb2/input/ukbd2.c optional usb2_core usb2_input usb2_input_kbd
+dev/usb2/input/ums2.c optional usb2_core usb2_input usb2_input_ms
+dev/usb2/input/usb2_input.c optional usb2_core usb2_input
+#
+# USB2 quirks
+#
+dev/usb2/quirk/usb2_quirk.c optional usb2_core usb2_quirk
+#
+# USB2 templates
+#
+dev/usb2/template/usb2_template.c optional usb2_core usb2_template
+dev/usb2/template/usb2_template_cdce.c optional usb2_core usb2_template
+dev/usb2/template/usb2_template_msc.c optional usb2_core usb2_template
+dev/usb2/template/usb2_template_mtp.c optional usb2_core usb2_template
+#
+# USB2 image drivers
+#
+dev/usb2/image/usb2_image.c optional usb2_core usb2_image
+dev/usb2/image/uscanner2.c optional usb2_core usb2_image usb2_scanner
+#
+# USB2 sound and MIDI drivers
+#
+dev/usb2/sound/usb2_sound.c optional usb2_core usb2_sound
+dev/usb2/sound/uaudio2.c optional usb2_core usb2_sound
+dev/usb2/sound/uaudio2_pcm.c optional usb2_core usb2_sound
+#
+# USB2 END
+#
dev/utopia/idtphy.c optional utopia
dev/utopia/suni.c optional utopia
dev/utopia/utopia.c optional utopia
Modified: projects/vap7/sys/conf/kmod.mk
==============================================================================
--- projects/vap7/sys/conf/kmod.mk Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/sys/conf/kmod.mk Fri Jan 9 19:45:06 2009 (r186964)
@@ -331,6 +331,7 @@ MFILES?= dev/acpica/acpi_if.m dev/ata/at
dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
dev/sound/midi/mpu_if.m dev/sound/midi/mpufoi_if.m \
dev/sound/midi/synth_if.m dev/usb/usb_if.m isa/isa_if.m \
+ dev/usb2/core/usb2_if.m \
kern/bus_if.m kern/cpufreq_if.m kern/device_if.m kern/serdev_if.m \
libkern/iconv_converter_if.m opencrypto/cryptodev_if.m \
pc98/pc98/canbus_if.m pci/agp_if.m
Modified: projects/vap7/sys/dev/sound/pcm/channel.c
==============================================================================
--- projects/vap7/sys/dev/sound/pcm/channel.c Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/sys/dev/sound/pcm/channel.c Fri Jan 9 19:45:06 2009 (r186964)
@@ -570,13 +570,26 @@ chn_read(struct pcm_channel *c, struct u
void
chn_intr(struct pcm_channel *c)
{
- CHN_LOCK(c);
+ uint8_t do_unlock;
+ if (CHN_LOCK_OWNED(c)) {
+ /*
+ * Allow sound drivers to call this function with
+ * "CHN_LOCK()" locked:
+ */
+ do_unlock = 0;
+ } else {
+ do_unlock = 1;
+ CHN_LOCK(c);
+ }
c->interrupts++;
if (c->direction == PCMDIR_PLAY)
chn_wrintr(c);
else
chn_rdintr(c);
- CHN_UNLOCK(c);
+ if (do_unlock) {
+ CHN_UNLOCK(c);
+ }
+ return;
}
u_int32_t
Modified: projects/vap7/sys/dev/sound/pcm/channel.h
==============================================================================
--- projects/vap7/sys/dev/sound/pcm/channel.h Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/sys/dev/sound/pcm/channel.h Fri Jan 9 19:45:06 2009 (r186964)
@@ -258,11 +258,13 @@ int chn_getpeaks(struct pcm_channel *c,
#endif
#ifdef USING_MUTEX
+#define CHN_LOCK_OWNED(c) mtx_owned((struct mtx *)((c)->lock))
#define CHN_LOCK(c) mtx_lock((struct mtx *)((c)->lock))
#define CHN_UNLOCK(c) mtx_unlock((struct mtx *)((c)->lock))
#define CHN_TRYLOCK(c) mtx_trylock((struct mtx *)((c)->lock))
#define CHN_LOCKASSERT(c) mtx_assert((struct mtx *)((c)->lock), MA_OWNED)
#else
+#define CHN_LOCK_OWNED(c) 0
#define CHN_LOCK(c)
#define CHN_UNLOCK(c)
#define CHN_TRYLOCK(c)
Modified: projects/vap7/sys/dev/sound/pcm/mixer.c
==============================================================================
--- projects/vap7/sys/dev/sound/pcm/mixer.c Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/sys/dev/sound/pcm/mixer.c Fri Jan 9 19:45:06 2009 (r186964)
@@ -589,7 +589,7 @@ mixer_delete(struct snd_mixer *m)
KASSERT(m->type == MIXER_TYPE_SECONDARY,
("%s(): illegal mixer type=%d", __func__, m->type));
- snd_mtxlock(m->lock);
+ /* mixer uninit can sleep --hps */
MIXER_UNINIT(m);
@@ -704,14 +704,24 @@ mixer_uninit(device_t dev)
return EBUSY;
}
+ /* destroy dev can sleep --hps */
+
+ snd_mtxunlock(m->lock);
+
pdev->si_drv1 = NULL;
destroy_dev(pdev);
+ snd_mtxlock(m->lock);
+
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
mixer_set(m, i, 0);
mixer_setrecsrc(m, SOUND_MASK_MIC);
+ snd_mtxunlock(m->lock);
+
+ /* mixer uninit can sleep --hps */
+
MIXER_UNINIT(m);
snd_mtxfree(m->lock);
@@ -1280,3 +1290,16 @@ mixer_oss_mixerinfo(struct cdev *i_dev,
return (EINVAL);
}
+
+/*
+ * Allow the sound driver to use the mixer lock to protect its mixer
+ * data:
+ */
+struct mtx *
+mixer_get_lock(struct snd_mixer *m)
+{
+ if (m->lock == NULL) {
+ return (&Giant);
+ }
+ return (m->lock);
+}
Modified: projects/vap7/sys/dev/sound/pcm/mixer.h
==============================================================================
--- projects/vap7/sys/dev/sound/pcm/mixer.h Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/sys/dev/sound/pcm/mixer.h Fri Jan 9 19:45:06 2009 (r186964)
@@ -56,6 +56,7 @@ void mix_setrealdev(struct snd_mixer *m,
u_int32_t mix_getparent(struct snd_mixer *m, u_int32_t dev);
u_int32_t mix_getchild(struct snd_mixer *m, u_int32_t dev);
void *mix_getdevinfo(struct snd_mixer *m);
+struct mtx *mixer_get_lock(struct snd_mixer *m);
extern int mixer_count;
Modified: projects/vap7/sys/dev/usb/rio500_usb.h
==============================================================================
--- projects/vap7/sys/dev/usb/rio500_usb.h Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/sys/dev/usb/rio500_usb.h Fri Jan 9 19:45:06 2009 (r186964)
@@ -32,7 +32,7 @@
struct RioCommand
{
- u_int16_t length;
+ uint16_t length;
int request;
int requesttype;
int value;
Modified: projects/vap7/sys/dev/usb2/core/usb2_dev.c
==============================================================================
--- head/sys/dev/usb2/core/usb2_dev.c Fri Jan 9 17:21:22 2009 (r186961)
+++ projects/vap7/sys/dev/usb2/core/usb2_dev.c Fri Jan 9 19:45:06 2009 (r186964)
@@ -1306,8 +1306,14 @@ usb2_fdopen(struct cdev *dev, int xxx_of
* Take over the file so that we get all the callbacks
* directly and don't have to create another device:
*/
+#if __FreeBSD_version < 800009
+ fp->f_ops = &usb2_ops_f;
+ fp->f_type = DTYPE_VNODE;
+ fp->f_data = ((uint8_t *)0) + devloc;
+#else
finit(fp, fp->f_flag, DTYPE_VNODE,
((uint8_t *)0) + devloc, &usb2_ops_f);
+#endif
usb2_unref_device(&loc);
Modified: projects/vap7/sys/dev/usb2/serial/usb2_serial.c
==============================================================================
--- head/sys/dev/usb2/serial/usb2_serial.c Fri Jan 9 17:21:22 2009 (r186961)
+++ projects/vap7/sys/dev/usb2/serial/usb2_serial.c Fri Jan 9 19:45:06 2009 (r186964)
@@ -125,28 +125,17 @@ static void usb2_com_queue_command(struc
usb2_config_td_command_t *, int);
static void usb2_com_shutdown(struct usb2_com_softc *);
static void usb2_com_start_transfers(struct usb2_com_softc *);
-static void usb2_com_break(struct usb2_com_softc *, uint8_t);
+static int usb2_com_open(struct tty *, struct cdev *);
+static void usb2_com_close(struct tty *);
+static int usb2_com_ioctl(struct tty *, u_long, void *, int,
+ struct thread *);
+static int usb2_com_modem(struct tty *, int, int);
+static void usb2_com_break(struct tty *, int);
static void usb2_com_dtr(struct usb2_com_softc *, uint8_t);
static void usb2_com_rts(struct usb2_com_softc *, uint8_t);
-
-static tsw_open_t usb2_com_open;
-static tsw_close_t usb2_com_close;
-static tsw_ioctl_t usb2_com_ioctl;
-static tsw_modem_t usb2_com_modem;
-static tsw_param_t usb2_com_param;
-static tsw_outwakeup_t usb2_com_start_write;
-static tsw_free_t usb2_com_free;
-
-static struct ttydevsw usb2_com_class = {
- .tsw_flags = TF_INITLOCK | TF_CALLOUT,
- .tsw_open = usb2_com_open,
- .tsw_close = usb2_com_close,
- .tsw_outwakeup = usb2_com_start_write,
- .tsw_ioctl = usb2_com_ioctl,
- .tsw_param = usb2_com_param,
- .tsw_modem = usb2_com_modem,
- .tsw_free = usb2_com_free,
-};
+static int usb2_com_param(struct tty *, struct termios *);
+static void usb2_com_start_write(struct tty *);
+static void usb2_com_stop_write(struct tty *, int);
MODULE_DEPEND(usb2_serial, usb2_core, 1, 1, 1);
MODULE_VERSION(usb2_serial, 1);
@@ -242,7 +231,8 @@ usb2_com_attach(struct usb2_com_super_so
uint32_t root_unit;
int error = 0;
- if ((sc == NULL) ||
+ if ((p_mtx != &Giant) || /* XXX TTY layer requires Giant */
+ (sc == NULL) ||
(sub_units == 0) ||
(sub_units > UCOM_SUB_UNIT_MAX) ||
(callback == NULL)) {
@@ -309,11 +299,23 @@ usb2_com_attach_sub(struct usb2_com_soft
int error = 0;
char buf[32]; /* temporary TTY device name buffer */
- tp = tty_alloc(&usb2_com_class, sc, sc->sc_parent_mtx);
+ mtx_lock(&Giant); /* XXX TTY layer */
+ tp = ttyalloc();
+
if (tp == NULL) {
error = ENOMEM;
goto done;
}
+ tp->t_sc = sc;
+ tp->t_oproc = usb2_com_start_write;
+ tp->t_param = usb2_com_param;
+ tp->t_stop = usb2_com_stop_write;
+ tp->t_break = usb2_com_break;
+ tp->t_open = usb2_com_open;
+ tp->t_close = usb2_com_close;
+ tp->t_modem = usb2_com_modem;
+ tp->t_ioctl = usb2_com_ioctl;
+
DPRINTF("tp = %p, unit = %d\n", tp, sc->sc_unit);
buf[0] = 0; /* set some default value */
@@ -325,46 +327,49 @@ usb2_com_attach_sub(struct usb2_com_soft
}
if (buf[0] == 0) {
/* Use default TTY name */
- if (snprintf(buf, sizeof(buf), "U%u", sc->sc_unit)) {
+ if (snprintf(buf, sizeof(buf), "ttyU%u", sc->sc_unit)) {
/* ignore */
}
}
- tty_makedev(tp, NULL, "%s", buf);
+#if !(defined(TS_CALLOUT) || (__FreeBSD_version >= 700022))
+#define TS_CALLOUT NULL, sc->sc_unit, MINOR_CALLOUT /* compile fix for
+ * FreeBSD 6.x */
+#endif
+ error = ttycreate(tp, TS_CALLOUT, buf);
+ if (error) {
+ ttyfree(tp);
+ goto done;
+ }
sc->sc_tty = tp;
DPRINTF("ttycreate: %s\n", buf);
- usb2_cv_init(&sc->sc_cv, "usb2_com");
done:
+ mtx_unlock(&Giant); /* XXX TTY layer */
return (error);
}
-static void
+void
usb2_com_detach_sub(struct usb2_com_softc *sc)
{
struct tty *tp = sc->sc_tty;
+ mtx_lock(&Giant); /* XXX TTY layer */
DPRINTF("sc = %p, tp = %p\n", sc, sc->sc_tty);
- /* the config thread has been stopped when we get here */
+ /* the config thread is stopped when we get here */
- mtx_lock(sc->sc_parent_mtx);
sc->sc_flag |= UCOM_FLAG_GONE;
sc->sc_flag &= ~(UCOM_FLAG_HL_READY |
UCOM_FLAG_LL_READY);
- mtx_unlock(sc->sc_parent_mtx);
if (tp) {
- tty_lock(tp);
-
- usb2_com_close(tp); /* close, if any */
- tty_rel_gone(tp);
+ ttygone(tp);
- mtx_lock(sc->sc_parent_mtx);
- /* Wait for the callback after the TTY is torn down */
- while (sc->sc_ttyfreed == 0)
- usb2_cv_wait(&sc->sc_cv, sc->sc_parent_mtx);
+ if (tp->t_state & TS_ISOPEN) {
+ usb2_com_close(tp);
+ }
/*
* make sure that read and write transfers are stopped
*/
@@ -374,9 +379,9 @@ usb2_com_detach_sub(struct usb2_com_soft
if (sc->sc_callback->usb2_com_stop_write) {
(sc->sc_callback->usb2_com_stop_write) (sc);
}
- mtx_unlock(sc->sc_parent_mtx);
+ ttyfree(tp);
}
- usb2_cv_destroy(&sc->sc_cv);
+ mtx_unlock(&Giant); /* XXX TTY layer */
}
static void
@@ -414,7 +419,7 @@ usb2_com_shutdown(struct usb2_com_softc
/*
* Hang up if necessary:
*/
- if (tp->t_termios.c_cflag & HUPCL) {
+ if (tp->t_cflag & HUPCL) {
usb2_com_modem(tp, 0, SER_DTR);
}
}
@@ -515,9 +520,9 @@ usb2_com_cfg_open(struct usb2_com_softc
}
static int
-usb2_com_open(struct tty *tp)
+usb2_com_open(struct tty *tp, struct cdev *dev)
{
- struct usb2_com_softc *sc = tty_softc(tp);
+ struct usb2_com_softc *sc = tp->t_sc;
int error;
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
@@ -556,7 +561,7 @@ usb2_com_open(struct tty *tp)
usb2_com_modem(tp, SER_DTR | SER_RTS, 0);
- usb2_com_break(sc, 0);
+ usb2_com_break(tp, 0);
usb2_com_status_change(sc);
@@ -587,21 +592,17 @@ usb2_com_cfg_close(struct usb2_com_softc
static void
usb2_com_close(struct tty *tp)
{
- struct usb2_com_softc *sc = tty_softc(tp);
- struct usb2_com_super_softc *ssc = sc->sc_super;
-
+ struct usb2_com_softc *sc = tp->t_sc;
+
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
DPRINTF("tp=%p\n", tp);
- if (!(sc->sc_flag & UCOM_FLAG_HL_READY)) {
- DPRINTF("tp=%p already closed\n", tp);
- return;
- }
+ tp->t_state &= ~TS_BUSY;
+
usb2_com_shutdown(sc);
usb2_com_queue_command(sc, &usb2_com_cfg_close, 0);
- usb2_config_td_sync(&ssc->sc_config_td);
sc->sc_flag &= ~(UCOM_FLAG_HL_READY |
UCOM_FLAG_WR_START |
@@ -616,9 +617,10 @@ usb2_com_close(struct tty *tp)
}
static int
-usb2_com_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
+usb2_com_ioctl(struct tty *tp, u_long cmd, void *data,
+ int flag, struct thread *td)
{
- struct usb2_com_softc *sc = tty_softc(tp);
+ struct usb2_com_softc *sc = tp->t_sc;
int error;
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
@@ -628,23 +630,9 @@ usb2_com_ioctl(struct tty *tp, u_long cm
}
DPRINTF("cmd = 0x%08lx\n", cmd);
- switch (cmd) {
- case TIOCSBRK:
- usb2_com_break(sc, 1);
- error = 0;
- break;
- case TIOCCBRK:
- usb2_com_break(sc, 0);
- error = 0;
- break;
- default:
- if (sc->sc_callback->usb2_com_ioctl) {
- error = (sc->sc_callback->usb2_com_ioctl)
- (sc, cmd, data, 0, td);
- } else {
- error = ENOIOCTL;
- }
- break;
+ error = ENOTTY;
+ if (sc->sc_callback->usb2_com_ioctl) {
+ error = (sc->sc_callback->usb2_com_ioctl) (sc, cmd, data, flag, td);
}
return (error);
}
@@ -652,7 +640,7 @@ usb2_com_ioctl(struct tty *tp, u_long cm
static int
usb2_com_modem(struct tty *tp, int sigon, int sigoff)
{
- struct usb2_com_softc *sc = tty_softc(tp);
+ struct usb2_com_softc *sc = tp->t_sc;
uint8_t onoff;
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
@@ -720,8 +708,10 @@ usb2_com_cfg_break(struct usb2_com_softc
}
static void
-usb2_com_break(struct usb2_com_softc *sc, uint8_t onoff)
+usb2_com_break(struct tty *tp, int onoff)
{
+ struct usb2_com_softc *sc = tp->t_sc;
+
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
if (!(sc->sc_flag & UCOM_FLAG_HL_READY)) {
@@ -791,8 +781,8 @@ usb2_com_rts(struct usb2_com_softc *sc,
}
static void
-usb2_com_cfg_status_change(struct usb2_com_softc *sc,
- struct usb2_com_config_copy *cc, uint16_t refcount)
+usb2_com_cfg_status_change(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
+ uint16_t refcount)
{
struct tty *tp;
@@ -803,8 +793,6 @@ usb2_com_cfg_status_change(struct usb2_c
sc = cc->cc_softc;
tp = sc->sc_tty;
- mtx_assert(sc->sc_parent_mtx, MA_OWNED);
-
if (!(sc->sc_flag & UCOM_FLAG_LL_READY)) {
return;
}
@@ -833,7 +821,7 @@ usb2_com_cfg_status_change(struct usb2_c
DPRINTF("DCD changed to %d\n", onoff);
- ttydisc_modem(tp, onoff);
+ ttyld_modem(tp, onoff);
}
}
@@ -875,7 +863,7 @@ usb2_com_cfg_param(struct usb2_com_softc
static int
usb2_com_param(struct tty *tp, struct termios *t)
{
- struct usb2_com_softc *sc = tty_softc(tp);
+ struct usb2_com_softc *sc = tp->t_sc;
uint8_t opened;
int error;
@@ -888,7 +876,7 @@ usb2_com_param(struct tty *tp, struct te
/* XXX the TTY layer should call "open()" first! */
- error = usb2_com_open(tp);
+ error = usb2_com_open(tp, NULL);
if (error) {
goto done;
}
@@ -907,7 +895,20 @@ usb2_com_param(struct tty *tp, struct te
error = EINVAL;
goto done;
}
- t->c_ispeed = t->c_ospeed;
+ /*
+ * If there were no changes, don't do anything. This avoids dropping
+ * input and improves performance when all we did was frob things like
+ * VMIN and VTIME.
+ */
+ if ((tp->t_ospeed == t->c_ospeed) &&
+ (tp->t_cflag == t->c_cflag)) {
+ error = 0;
+ goto done;
+ }
+ /* And copy to tty. */
+ tp->t_ispeed = 0;
+ tp->t_ospeed = t->c_ospeed;
+ tp->t_cflag = t->c_cflag;
if (sc->sc_callback->usb2_com_pre_param) {
/* Let the lower layer verify the parameters */
@@ -929,12 +930,16 @@ usb2_com_param(struct tty *tp, struct te
/* Queue transfer enable command last */
usb2_com_start_transfers(sc);
+ ttsetwater(tp);
+
if (t->c_cflag & CRTS_IFLOW) {
sc->sc_flag |= UCOM_FLAG_RTS_IFLOW;
} else if (sc->sc_flag & UCOM_FLAG_RTS_IFLOW) {
sc->sc_flag &= ~UCOM_FLAG_RTS_IFLOW;
usb2_com_modem(tp, SER_RTS, 0);
}
+ ttyldoptim(tp);
+
done:
if (error) {
if (opened) {
@@ -947,28 +952,62 @@ done:
static void
usb2_com_start_write(struct tty *tp)
{
- struct usb2_com_softc *sc = tty_softc(tp);
+ struct usb2_com_softc *sc = tp->t_sc;
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
DPRINTF("sc = %p\n", sc);
+ if (tp->t_outq.c_cc == 0) {
+ /*
+ * The TTY layer does not expect TS_BUSY to be set
+ * when there are no characters to output.
+ */
+ return;
+ }
if (!(sc->sc_flag & UCOM_FLAG_HL_READY)) {
/* The higher layer is not ready */
return;
}
+ tp->t_state |= TS_BUSY;
+
sc->sc_flag |= UCOM_FLAG_WR_START;
usb2_com_start_transfers(sc);
}
-/*------------------------------------------------------------------------*
- * usb2_com_get_data
- *
- * Return values:
- * 0: No data is available.
- * Else: Data is available.
- *------------------------------------------------------------------------*/
+static void
+usb2_com_stop_write(struct tty *tp, int fflags)
+{
+ struct usb2_com_softc *sc = tp->t_sc;
+
+ mtx_assert(sc->sc_parent_mtx, MA_OWNED);
+
+ if (!(sc->sc_flag & UCOM_FLAG_HL_READY)) {
+ return;
+ }
+ DPRINTF("fflags=%d\n", fflags);
+
+ if (fflags & FWRITE) {
+ DPRINTF("write\n");
+ if (tp->t_state & TS_BUSY) {
+ /* XXX do what? */
+ if (!(tp->t_state & TS_TTSTOP)) {
+ tp->t_state |= TS_FLUSH;
+ }
+ }
+ }
+ /* Flush out any leftover data */
+ usb2_com_start_write(tp);
+
+ DPRINTF("done\n");
+}
+
+/*
+ * the following function returns
+ * 1 if data is available, else 0
+ */
+
uint8_t
usb2_com_get_data(struct usb2_com_softc *sc, struct usb2_page_cache *pc,
uint32_t offset, uint32_t len, uint32_t *actlen)
@@ -980,12 +1019,32 @@ usb2_com_get_data(struct usb2_com_softc
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
+ actlen[0] = 0;
+
if ((!(sc->sc_flag & UCOM_FLAG_HL_READY)) ||
(!(sc->sc_flag & UCOM_FLAG_GP_DATA)) ||
(!(sc->sc_flag & UCOM_FLAG_WR_START))) {
- actlen[0] = 0;
return (0); /* multiport device polling */
}
+ if (tp->t_state & TS_TBLOCK) {
+ if ((sc->sc_mcr & SER_RTS) &&
+ (sc->sc_flag & UCOM_FLAG_RTS_IFLOW)) {
+ DPRINTF("clear RTS\n");
+ usb2_com_modem(tp, 0, SER_RTS);
+ }
+ } else {
+ if (!(sc->sc_mcr & SER_RTS) &&
+ (tp->t_rawq.c_cc <= tp->t_ilowat) &&
+ (sc->sc_flag & UCOM_FLAG_RTS_IFLOW)) {
+ DPRINTF("set RTS\n");
+ usb2_com_modem(tp, SER_RTS, 0);
+ }
+ }
+
+ if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
+ DPRINTF("stopped\n");
+ goto done;
+ }
offset_orig = offset;
while (len != 0) {
@@ -995,8 +1054,7 @@ usb2_com_get_data(struct usb2_com_softc
if (res.length > len) {
res.length = len;
}
- /* copy data directly into USB buffer */
- cnt = ttydisc_getc(tp, res.buffer, res.length);
+ cnt = q_to_b(&tp->t_outq, res.buffer, res.length);
offset += cnt;
len -= cnt;
@@ -1012,9 +1070,18 @@ usb2_com_get_data(struct usb2_com_softc
DPRINTF("cnt=%d\n", actlen[0]);
if (actlen[0] == 0) {
- return (0);
+ goto done;
}
+ ttwwakeup(tp);
+
return (1);
+
+done:
+ tp->t_state &= ~(TS_BUSY | TS_FLUSH);
+
+ ttwwakeup(tp);
+
+ return (0);
}
void
@@ -1023,7 +1090,6 @@ usb2_com_put_data(struct usb2_com_softc
{
struct usb2_page_search res;
struct tty *tp = sc->sc_tty;
- char *buf;
uint32_t cnt;
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
@@ -1032,9 +1098,6 @@ usb2_com_put_data(struct usb2_com_softc
(!(sc->sc_flag & UCOM_FLAG_GP_DATA))) {
return; /* multiport device polling */
}
- if (len == 0)
- return; /* no data */
-
/* set a flag to prevent recursation ? */
while (len > 0) {
@@ -1047,41 +1110,56 @@ usb2_com_put_data(struct usb2_com_softc
len -= res.length;
offset += res.length;
- /* pass characters to tty layer */
+ if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
+
+ if (((tp->t_rawq.c_cc + res.length) > tp->t_ihiwat) &&
+ ((sc->sc_flag & UCOM_FLAG_RTS_IFLOW) ||
+ (tp->t_iflag & IXOFF)) &&
+ (!(tp->t_state & TS_TBLOCK))) {
+ ttyblock(tp);
+ }
+ cnt = b_to_q(res.buffer, res.length, &(tp->t_rawq));
- buf = res.buffer;
- cnt = res.length;
+ tp->t_rawcc += res.length;
- /* first check if we can pass the buffer directly */
+ ttwakeup(tp);
- if (ttydisc_can_bypass(tp)) {
- if (ttydisc_rint_bypass(tp, buf, cnt) != cnt) {
- DPRINTF("tp=%p, data lost\n", tp);
+ if ((tp->t_state & TS_TTSTOP) &&
+ ((tp->t_iflag & IXANY) ||
+ (tp->t_cc[VSTART] == tp->t_cc[VSTOP]))) {
+ tp->t_state &= ~TS_TTSTOP;
+ tp->t_lflag &= ~FLUSHO;
+ usb2_com_start_write(tp);
}
- continue;
- }
- /* need to loop */
+ if (cnt > 0) {
+ DPRINTF("tp=%p, lost %d "
+ "chars\n", tp, cnt);
+ }
+ } else {
- for (cnt = 0; cnt != res.length; cnt++) {
- if (ttydisc_rint(tp, buf[cnt], 0) == -1) {
- /* XXX what should we do? */
+ uint8_t *buf;
- DPRINTF("tp=%p, lost %d "
- "chars\n", tp, res.length - cnt);
- break;
+ /* pass characters to tty layer */
+
+ buf = res.buffer;
+
+ for (cnt = 0; cnt != res.length; cnt++) {
+
+ if (ttyld_rint(tp, buf[cnt]) == -1) {
+
+ /* XXX what should we do? */
+
+ DPRINTF("tp=%p, lost %d "
+ "chars\n", tp, res.length - cnt);
+ break;
+ }
}
}
}
- ttydisc_rint_done(tp);
-}
-static void
-usb2_com_free(void *xsc)
-{
- struct usb2_com_softc *sc = xsc;
-
- mtx_lock(sc->sc_parent_mtx);
- sc->sc_ttyfreed = 1;
- usb2_cv_signal(&sc->sc_cv);
- mtx_unlock(sc->sc_parent_mtx);
+ if ((sc->sc_flag & UCOM_FLAG_RTS_IFLOW) &&
+ (!(sc->sc_mcr & SER_RTS)) &&
+ (!(tp->t_state & TS_TBLOCK))) {
+ usb2_com_modem(tp, SER_RTS, 0);
+ }
}
Copied and modified: projects/vap7/sys/i386/conf/USB2 (from r186962, head/sys/i386/conf/USB2)
==============================================================================
--- head/sys/i386/conf/USB2 Fri Jan 9 18:08:50 2009 (r186962, copy source)
+++ projects/vap7/sys/i386/conf/USB2 Fri Jan 9 19:45:06 2009 (r186964)
@@ -29,6 +29,7 @@ nodevice ucom
nodevice u3g
nodevice uark
nodevice ubsa
+nodevice ubser
nodevice uftdi
nodevice uipaq
nodevice uplcom
Modified: projects/vap7/sys/modules/Makefile
==============================================================================
--- projects/vap7/sys/modules/Makefile Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/sys/modules/Makefile Fri Jan 9 19:45:06 2009 (r186964)
@@ -301,6 +301,7 @@ SUBDIR= ${_3dfx} \
ural \
urio \
usb \
+ usb2 \
uscanner \
uslcom \
utopia \
Modified: projects/vap7/usr.sbin/Makefile
==============================================================================
--- projects/vap7/usr.sbin/Makefile Fri Jan 9 18:38:57 2009 (r186963)
+++ projects/vap7/usr.sbin/Makefile Fri Jan 9 19:45:06 2009 (r186964)
@@ -182,6 +182,7 @@ SUBDIR= ac \
tzsetup \
ugidfw \
${_usbdevs} \
+ ${_usbconfig} \
vidcontrol \
vipw \
watch \
@@ -291,6 +292,7 @@ _sendmail= sendmail
.if ${MK_USB} != "no"
_usbdevs= usbdevs
+_usbconfig= usbconfig
.endif
.if ${MACHINE_ARCH} == "arm"
More information about the svn-src-projects
mailing list