[OpenIndiana-discuss] USB still doesn't work as root user, plus CURRENT SRC DIFFS SNAPSHOT __/__ Re: Running Martin's Virtualbox pkg, failing to compile keymap while using vncserver
Мартин Бохниг
opensxce at mail.ru
Thu Sep 22 19:28:32 UTC 2016
G'evening (or deep night to down under),
thanks to you for having asked and to Alan for already having delivered the correct response (xkb and fonts).
Let me only add the following:
* as I was busy with Qt5.5 and a new Vbox-USB bug, I still didn't add the server-oriented headless features to none of the two test packages
( --enable-webservice enable the webservice stuff
--enable-vnc enable the VNC server)
* USB *still* doesn't work (even if run as root).
The diff I created 2 days ago makes the
host's:
/platform/i86pc/kernel/drv/amd64/vboxusbmon
/platform/i86pc/kernel/drv/amd64/vboxusb
load and attach fine on the machine running Vbox5, and in the Vbox GUI all the host's usb devices do get shown for attachment, *but* when actually enabling USB in a VM's settings and firing up that VM, unfortunately pop-up errors appear, that the USB proxy device couldn't get created and hence the device fails to get attached to the respective VM.
Originally I was in the strong belief that the overall time for Vbox5 would never increase 2 days.
That was 2 weeks or so ago.
Back then I promised 100 times to publish the src diffs "in a few hours" (I did post a set of diffs 1 week or so ago, but now it has grown significantly).
As I don't want to work behind some firewall, here once again the current diffs.
But as said: USB needs to be reworked.
This only for the records.
For VNC you can of course start vncserver on your guest VM, but if you wait 1 or more days until I enabled
--enable-webservice enable the webservice stuff
--enable-vnc enable the VNC server
then you can expect a much better support for headless machines.
My gsoap diffs for gsoap 2.8.35 are mostly complete now, so I can finally enable webservices.
To activate --enable-vnc, although one would not have expected it, Hipster is also still missing a dependency.
But more on that in 1 or 2 days.
Here first the current diffs (for Vbox alone, add to that Qt5.5 [which currently is unusable due to the input problem, as also reported by Aurelien]).
gdiff -Nurb VirtualBox-5.1.6/src/VBox/Installer/solaris/checkinstall.sh VirtualBox-5.1.6/src/VBox/Installer/solaris/checkinstall.sh
--- VirtualBox-5.1.6/src/VBox/Installer/solaris/checkinstall.sh 2016-09-12 16:18:39.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/Installer/solaris/checkinstall.sh 2016-09-17 03:54:06.404271317 +0000
@@ -160,22 +160,6 @@
infoprint "Checking package dependencies..."
-if test -x "$BIN_PKG"; then
- checkdep_ips_either "runtime/python-26" "runtime/python-27"
- checkdep_ips_either "system/library/iconv/utf-8" "system/library/iconv/iconv-core"
- checkdep_ips_either "system/library/gcc/gcc-c++-runtime" "system/library/gcc-45-runtime"
- checkdep_ips_either "system/library/gcc/gcc-c-runtime" "system/library/gcc-45-runtime"
-else
- PKG_MISSING_IPS="runtime/python-26 system/library/iconv/utf-8 system/library/gcc/gcc-c++-runtime system/library/gcc/gcc-c-runtime"
-fi
-if test -x "$BIN_PKGINFO"; then
- checkdep_svr4 "SUNWPython"
- checkdep_svr4 "SUNWPython-devel"
- checkdep_svr4 "SUNWuiu8"
-else
- PKG_MISSING_SVR4="SUNWPython SUNWPython-devel SUNWuiu8"
-fi
-
if test "x$PKG_MISSING_IPS" != "x" && test "x$PKG_MISSING_SVR4" != "x"; then
if test ! -x "$BIN_PKG" && test ! -x "$BIN_PKGINFO"; then
errorprint "Missing or non-executable binaries: pkg ($BIN_PKG) and pkginfo ($BIN_PKGINFO)."
gdiff -Nub VirtualBox-5.1.6/Config.kmk VirtualBox-5.1.6/Config.kmk
--- VirtualBox-5.1.6/Config.kmk 2016-08-16 19:55:20.000000000 +0000
+++ VirtualBox-5.1.6/Config.kmk 2016-09-12 20:56:29.095415061 +0000
@@ -756,29 +756,6 @@
# Enables VMMR0.r0 (++) loading using the native loader on solaris.
# Good for debugging and analysis. Experimental.
#VBOX_WITH_NATIVE_SOLARIS_LOADING = 1
-# Set this to enable user mode dtrace probes.
-if1of ($(KBUILD_TARGET), darwin linux solaris)
- VBOX_WITH_DTRACE_R3 = 1
- VBOX_WITH_DTRACE_R3_MAIN = 1
-endif
-# Set this to enable kernel driver dtrace probes.
-if1of ($(KBUILD_TARGET), darwin solaris)
- VBOX_WITH_DTRACE_R0DRV = 1
-endif
-# Set this to enable dtrace probes in platform agnostic kernel code.
-ifn1of ($(KBUILD_TARGET), os2)
- VBOX_WITH_DTRACE_R0 = 1
-endif
-# Set this to enable dtrace probes raw-mode context code.
-if1of ($(KBUILD_TARGET), linux solaris)
- VBOX_WITH_DTRACE_RC = 1
-endif
-# Set this to enable support for dtrace probes in guest code.
-#VBOX_WITH_DTRACE_GST = 1
-# Set this to indicate that the host ships with DTrace.
-if1of ($(KBUILD_TARGET), darwin solaris)
- VBOX_WITH_NATIVE_DTRACE = 1
-endif
# Makes it possible to run some of the testcases and tools on older
# windows versions (only define when buildling win.x86).
#VBOX_WITH_MORE_NT4_COMPAT_BINARIES = 1
gdiff -Nub VirtualBox-5.1.6/Config.kmk VirtualBox-5.1.6/Config.kmk
--- VirtualBox-5.1.6/Config.kmk 2016-09-16 11:41:22.013702279 +0000
+++ VirtualBox-5.1.6/Config.kmk 2016-09-16 12:09:50.428711465 +0000
@@ -591,11 +591,6 @@
VBOX_WITH_WEBSERVICES_SSL = 1
# The Qt GUI.
VBOX_WITH_QTGUI = 1
-if1of ($(KBUILD_TARGET), linux win solaris)
- VBOX_WITH_QTGUI_V5 = 1 # r=bird: s/VBOX_WITH_QTGUI_V5/VBOX_WITH_QT5/g - our we released version 5.0 of the VirtualBox GUI last year, remember?
-else if "$(KBUILD_TARGET)" == "darwin" && $(KBUILD_HOST_VERSION_MAJOR) >= 13 # (OS X 10.9 Mavericks)
- VBOX_WITH_QTGUI_V5 = 1
-endif
# Indicates the Qt is Cocoa based on the Mac.
ifeq ($(KBUILD_TARGET),darwin)
VBOX_WITH_COCOA_QT = 1
@@ -5678,12 +5673,12 @@
ifndef VBOX_WITH_QTGUI_V5
VBOX_PATH_QT := $(lastword $(sort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v4*)))
else
- VBOX_PATH_QT := $(lastword $(sort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v5*)))
+ VBOX_PATH_QT := $(lastword $(sort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v4*)))
endif
ifeq ($(VBOX_PATH_QT),)
ifneq ($(wildcard /Library/Frameworks/QtCore.framework),)
# Using the global installation (for OSE).
- VBOX_PATH_QT ?= /usr
+ VBOX_PATH_QT ?= /usr/lib/qt/4.8
VBOX_PATH_QT_FRAMEWORKS ?= /Library/Frameworks
endif
endif
@@ -5730,22 +5725,9 @@
QtCore QtGui QtWidgets QtPrintSupport QtMacExtras \
$(if $(VBOX_GUI_USE_QGL),QtOpenGL,)
else if1of ($(KBUILD_TARGET), linux freebsd netbsd openbsd solaris win)
- VBOX_QT_MOD += \
- Qt5Core Qt5Gui Qt5Widgets Qt5PrintSupport \
- $(if $(VBOX_GUI_USE_QGL),Qt5OpenGL,)
- if1of ($(KBUILD_TARGET), linux freebsd netbsd openbsd solaris)
- VBOX_QT_MOD += \
- Qt5DBus Qt5XcbQpa Qt5X11Extras
- # legacy libraries required to be installed on EL5
- VBOX_QT_LEGACY_LIBS = \
- $(if $(VBOX_LD_HAS_LIBXCB),,libxcb.so.1 libX11.so.6 libX11-xcb.so.1)
- VBOX_QT_PLUGINS = plugins/platforms/libqxcb.so
- else ifeq ($(KBUILD_TARGET), win)
- VBOX_QT_MOD += \
- Qt5WinExtras
- endif # win
- endif # linux freebsd netbsd openbsd solaris win
- endif # VBOX_WITH_QTGUI_V5
+ VBOX_QT_MOD = QtCore QtGui $(if $(VBOX_GUI_USE_QGL),QtOpenGL,)
+endif # linux freebsd netbsd openbsd solaris win
+endif # VBOX_WITH_QTGUI_V5
VBOX_QT_MOD_NAMES = $(foreach qtmod,$(VBOX_QT_MOD),$(qtmod)$(VBOX_QT_INFIX))
@@ -5770,13 +5752,13 @@
TEMPLATE_VBOXQTGUIEXE_LRCTOOL = QT4
TEMPLATE_VBOXQTGUIEXE_SDKS = QT4
else # VBOX_WITH_QTGUI_V5
- TEMPLATE_VBOXQTGUIEXE_USES = qt5
- TEMPLATE_VBOXQTGUIEXE_QTTOOL = QT5
- TEMPLATE_VBOXQTGUIEXE_MOCTOOL = QT5
- TEMPLATE_VBOXQTGUIEXE_UICTOOL = QT5
- TEMPLATE_VBOXQTGUIEXE_RCCTOOL = QT5
- TEMPLATE_VBOXQTGUIEXE_LRCTOOL = QT5
- TEMPLATE_VBOXQTGUIEXE_SDKS = QT5
+ TEMPLATE_VBOXQTGUIEXE_USES = qt4
+ TEMPLATE_VBOXQTGUIEXE_QTTOOL = QT4
+ TEMPLATE_VBOXQTGUIEXE_MOCTOOL = QT4
+ TEMPLATE_VBOXQTGUIEXE_UICTOOL = QT4
+ TEMPLATE_VBOXQTGUIEXE_RCCTOOL = QT4
+ TEMPLATE_VBOXQTGUIEXE_LRCTOOL = QT4
+ TEMPLATE_VBOXQTGUIEXE_SDKS = QT4
endif # VBOX_WITH_QTGUI_V5
TEMPLATE_VBOXQTGUIEXE_QT_INFIX = $(VBOX_QT_INFIX)
TEMPLATE_VBOXQTGUIEXE_DEFS = IN_RING3 QT_NO_DEBUG QT_THREAD_SUPPORT QT_SHARED HAVE_CONFIG_H $(ARCH_BITS_DEFS)
diff -Nurb VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/include/usbai_private.h VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/include/usbai_private.h
--- VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/include/usbai_private.h 2016-09-12 16:18:33.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/include/usbai_private.h 2016-07-18 11:56:23.000000000 +0000
@@ -26,6 +26,7 @@
#ifndef _SYS_USB_USBA_USBAI_PRIVATE_H
#define _SYS_USB_USBA_USBAI_PRIVATE_H
+
/*
* Unstable interfaces not part of USBAI but used by Solaris client drivers.
* These interfaces may not be present in future releases and are highly
@@ -49,6 +50,151 @@
uint_t usb_get_current_cfgidx(dev_info_t *);
/*
+ * **************************************************************************
+ * Error and status definitions, and reporting functions
+ * **************************************************************************
+ */
+
+
+/*
+ * convenience functions to get string corresponding to value
+ * usb_cb_flags_name requires a workbuffer of sufficient length
+ * for the concatenation of all strings as usb_cb_flags_t is a bit
+ * mask
+ *
+ * Status: C and D
+ */
+const char *usb_str_cr(usb_cr_t cr);
+char *usb_str_cb_flags(usb_cb_flags_t cb_flags,
+ char *buffer, size_t length);
+const char *usb_str_pipe_state(usb_pipe_state_t state);
+const char *usb_str_dev_state(int state);
+const char *usb_str_rval(int rval);
+
+/* function convert a USB return value to an errno */
+int usb_rval2errno(int rval);
+
+/*
+ * **************************************************************************
+ * Transfer-related definitions and functions
+ * **************************************************************************
+ */
+
+/* Status C and D for whole section. */
+
+/* Serialize callbacks per interface or device. */
+#define USB_FLAGS_SERIALIZED_CB 0x8000
+
+/* default timeout for control requests (in seconds) */
+#define USB_PIPE_TIMEOUT 3
+
+/*
+ * usb_pipe_sync_ctrl_xfer():
+ * for simple synchronous control transactions this wrapper function
+ * will perform the allocation, xfer, and deallocation.
+ * USB_ATTRS_AUTOCLEARING will be enabled
+ *
+ * ARGUMENTS:
+ * dip - pointer to clients devinfo.
+ * pipe_handle - control pipe pipehandle (obtained via usb_pipe_open().
+ * bmRequestType - characteristics of request.
+ * bRequest - specific request.
+ * wValue - varies according to request.
+ * wIndex - index or offset.
+ * wLength - number of bytes to xfer.
+ * data - pointer to pointer to data
+ * IN: HCD will allocate data
+ * OUT: clients driver allocates data.
+ * attrs - required request attributes.
+ * completion_reason - completion status.
+ * cb_flags - request completions flags.
+ * flags - none.
+ *
+ * RETURN VALUES:
+ * USB_SUCCESS - request successfully executed.
+ * USB_FAILURE - request failed.
+ *
+ * NOTES:
+ * - in the case of failure, the client should check completion_reason and
+ * and cb_flags and determine further recovery action
+ * - the client should check data and if non-zero, free the data on
+ * completion
+ */
+int usb_pipe_sync_ctrl_xfer(
+ dev_info_t *dip,
+ usb_pipe_handle_t pipe_handle,
+ uchar_t bmRequestType,
+ uchar_t bRequest,
+ uint16_t wValue,
+ uint16_t wIndex,
+ uint16_t wLength,
+ mblk_t **data,
+ usb_req_attrs_t attrs,
+ usb_cr_t *completion_reason,
+ usb_cb_flags_t *cb_flags,
+ usb_flags_t flags);
+
+/*
+ * **************************************************************************
+ * Event registration / pre-suspend and post-resume handling
+ * **************************************************************************
+ */
+
+/* Status: C and D for whole section. */
+
+/*
+ * Event registration info for both hotplug and pre-suspend/post-resume
+ * callbacks. Eventually pre-suspend and post-resume callbacks will not be
+ * needed, so this is for this OS release only and will go away in a
+ * subsequent release.
+ */
+typedef struct usb_event {
+ /* device disconnected/unplugged */
+ int (*disconnect_event_handler)(dev_info_t *dip);
+
+ /* device reconnected */
+ int (*reconnect_event_handler)(dev_info_t *dip);
+
+ /* notification that system is about to checkpoint */
+ int (*pre_suspend_event_handler)(dev_info_t *dip);
+
+ /* notification that system resumed after a checkpoint */
+ int (*post_resume_event_handler)(dev_info_t *dip);
+} usb_event_t;
+
+/*
+ * Event callbacks
+ * the callbacks should always return USB_SUCCESS.
+ */
+int usb_register_event_cbs(
+ dev_info_t *dip,
+ usb_event_t *usb_evt_data,
+ usb_flags_t flags);
+
+void usb_unregister_event_cbs(
+ dev_info_t *dip,
+ usb_event_t *usb_evt_data);
+
+/*
+ * USB CPR support
+ * A client driver must call this function in pre-suspend event handler
+ * to inform the USBA framework that it can't suspend because
+ * driver instance or device could not be quiesced.
+ */
+void usb_fail_checkpoint(
+ dev_info_t *dip,
+ usb_flags_t flags);
+
+
+/*
+ * **************************************************************************
+ * Logging functions remaining Contracted Consolidation Private
+ * **************************************************************************
+ */
+
+/* Status: C and D for whole section. */
+
+/*
* Usb logging, debug and console message handling.
*/
typedef struct usb_log_handle *usb_log_handle_t;
@@ -59,13 +205,108 @@
#define USB_LOG_L3 3 /* interesting data, debug only */
#define USB_LOG_L4 4 /* tracing, debug only */
+#ifdef DEBUG
+#define USB_DPRINTF_L4 usb_dprintf4
+#define USB_DPRINTF_L3 usb_dprintf3
+
+/*PRINTFLIKE3*/
+void usb_dprintf4(
+ uint_t mask,
+ usb_log_handle_t handle,
+ char *fmt, ...);
+/*PRINTFLIKE3*/
+void usb_dprintf3(
+ uint_t mask,
+ usb_log_handle_t handle,
+ char *fmt, ...);
+#else
+#define USB_DPRINTF_L4 0 &&
+#define USB_DPRINTF_L3 0 &&
+#endif
+
+#define USB_DPRINTF_L2 usb_dprintf2
+#define USB_DPRINTF_L1 usb_dprintf1
+#define USB_DPRINTF_L0 usb_dprintf0
+
+/*PRINTFLIKE3*/
+void usb_dprintf2(
+ uint_t mask,
+ usb_log_handle_t handle,
+ char *fmt, ...);
+/*PRINTFLIKE3*/
+void usb_dprintf1(
+ uint_t mask,
+ usb_log_handle_t handle,
+ char *fmt, ...);
+/*PRINTFLIKE3*/
+void usb_dprintf0(
+ uint_t mask,
+ usb_log_handle_t handle,
+ char *fmt, ...);
+
+usb_log_handle_t usb_alloc_log_hdl(
+ dev_info_t *dip,
+ char *name,
+ uint_t *errlevel,
+ uint_t *mask,
+ uint_t *instance_filter,
+ usb_flags_t flags);
+
+/* free the log handle */
+void usb_free_log_hdl(
+ usb_log_handle_t handle);
+
+/* log message */
+/*PRINTFLIKE4*/
+int usb_log(
+ usb_log_handle_t handle,
+ uint_t level,
+ uint_t mask,
+ char *fmt, ...);
+
+/*
+ * usb_check_same_device:
+ * Check if the device connected to the port is the same as
+ * the previous device that was in the port. The previous device is
+ * represented by the dip on record for the port. Print a message
+ * if the device is different. If device_string arg is not NULL, it is
+ * included in the message. Can block.
+ *
+ * Arguments:
+ * dip - pointer to devinfo of the client
+ * log_handle - handle to which messages are logged
+ * log_level - one of USB_LOG_*
+ * log_mask - logging mask
+ * check_mask - one mask containing things to check:
+ * USB_CHK_BASIC: empty mask;
+ * these checks are always done.
+ * USB_CHK_SERIAL: check match on device
+ * serial number.
+ * USB_CHK_CFG: compare config clouds
+ * byte by byte
+ * USB_CHK_VIDPID: compare product
+ * and vendor ID
+ * USB_CHK_ALL: perform all checks
+ *
+ * NOTE: descr length and content always checked
+ * device_string - Device string to appear in error message
+ *
+ * return values:
+ * USB_SUCCESS: same device
+ * USB_INVALID_VERSION not same device
+ * USB_FAILURE: Failure processing request
+ * USB_INVALID_ARG: dip is invalid
+ */
+
+/* Checking bits for checks made by usb_check_same_device */
#define USB_CHK_BASIC 0 /* Empty mask. Basics always done. */
#define USB_CHK_SERIAL 0x00000001 /* Compare device serial numbers. */
#define USB_CHK_CFG 0x00000002 /* Compare raw config clouds. */
#define USB_CHK_VIDPID 0x00000004 /* Compare product and vendor ID. */
#define USB_CHK_ALL 0xFFFFFFFF /* Perform maximum checking. */
-int usb_check_same_device(dev_info_t *dip,
+int usb_check_same_device(
+ dev_info_t *dip,
usb_log_handle_t log_handle,
int log_level,
int log_mask,
@@ -74,6 +315,74 @@
/*
* **************************************************************************
+ * Power management functions remaining Contracted Consolidation Private
+ * **************************************************************************
+ */
+
+/*
+ * usb wrapper around pm_raise_power & pm_lower_power to allow for
+ * non blocking behavior
+ *
+ * Arguments:
+ * dip - pointer to devinfo node of client.
+ * comp - component.
+ * level - power level.
+ * flags - USB_FLAGS_SLEEP:
+ * wait for completion.
+ * cb - function called on completion, may be NULL.
+ * arg - callback argument.
+ * rval - USB_SUCCESS or USB_FAILURE.
+ *
+ * Return Values:
+ * USB_SUCCESS - if no USB_FLAGS_SLEEP has been specified, the request
+ * has been queued for async execution. If
+ * USB_FLAGS_SLEEP has been specified, the raising or
+ * lowering of power
+ * succeeded.
+ * USB_FAILURE - request could not be queued or raising or lowering
+ * of power failed.
+ */
+
+/* Status: C and D */
+int usb_req_raise_power(
+ dev_info_t *dip,
+ int comp,
+ int level,
+ void (*cb)(void *arg, int rval),
+ void *arg,
+ usb_flags_t flags);
+
+/* Status: D */
+int usb_req_lower_power(
+ dev_info_t *dip,
+ int comp,
+ int level,
+ void (*cb)(void *arg, int rval),
+ void *arg,
+ usb_flags_t flags);
+
+/*
+ * USB wrapper functions to set usb device power level.
+ * Note : Power levels indicated here are USB power levels
+ * and not OS power levels.
+ *
+ * Note that these were never implemented, and are noops. However, they are
+ * included here as the skeleton driver in DDK 0.8 and 0.9 mentioned them.
+ *
+ * Status: C and D.
+ */
+int usb_set_device_pwrlvl0(
+ dev_info_t *dip);
+int usb_set_device_pwrlvl1(
+ dev_info_t *dip);
+int usb_set_device_pwrlvl2(
+ dev_info_t *dip);
+int usb_set_device_pwrlvl3(
+ dev_info_t *dip);
+
+
+/*
+ * **************************************************************************
* Serialization functions remaining Contracted Consolidation Private
* **************************************************************************
*/
@@ -95,21 +404,25 @@
* ARGUMENTS:
* s_dip - devinfo pointer
* flag - USB_INIT_SER_CHECK_SAME_THREAD
- * when set, usb_release_access() will verify that the same
- * thread releases access. If not, a console warning will
- * be issued but access will be released anyways.
+ * when set, usb_release_access() will
+ * verify that the same thread releases
+ * access. If not, a console warning will
+ * be issued but access will be released
+ * anyways.
*
* RETURNS:
* usb_serialization handle
*
*/
-usb_serialization_t usb_init_serialization(dev_info_t *s_dip,
+usb_serialization_t usb_init_serialization(
+ dev_info_t *s_dip,
uint_t flag);
#define USB_INIT_SER_CHECK_SAME_THREAD 1
/* fini for serialization */
-void usb_fini_serialization(usb_serialization_t usb_serp);
+void usb_fini_serialization(
+ usb_serialization_t usb_serp);
/*
* Various ways of calling usb_serialize_access. These correspond to
@@ -123,7 +436,6 @@
/*
* usb_serialize_access:
* acquire serialized access
- *
* ARGUMENTS:
* usb_serp - usb_serialization handle
* how_to_wait - Which cv_*wait* function to wait for condition.
@@ -140,11 +452,26 @@
* For calls where a timeout or signal could be expected, use this value
* to tell whether a kill(2) signal or timeout occurred.
*/
-int usb_serialize_access(usb_serialization_t usb_serp,
+int usb_serialize_access(
+ usb_serialization_t usb_serp,
uint_t how_to_wait,
uint_t delta_timeout);
/*
+ * usb_try_serialize_access:
+ * try acquiring serialized access
+ *
+ * ARGUMENTS:
+ * usb_serp - usb_serialization handle
+ * flag - unused
+ *
+ * RETURNS:
+ * USB_SUCCESS - access has been acquired
+ * USB_FAILURE - access has not been acquired
+ */
+int usb_try_serialize_access(usb_serialization_t usb_serp, uint_t flag);
+
+/*
* usb_release_access:
* release serialized access
*
@@ -153,9 +480,122 @@
*/
void usb_release_access(usb_serialization_t usb_serp);
+
+/*
+ * **************************************************************************
+ * Asynchronous functions remaining Contracted Consolidation Private
+ * **************************************************************************
+ */
+
+/* This whole section: status: C and D. */
+
+/* For async_req functions. */
+#define USB_FLAGS_NOQUEUE 0x200
+
+/*
+ * Issue a request to the asynchronous request service
+ * All async request functions return USB_SUCCESS or USB_FAILURE
+ * Arguments:
+ * dip - pointer to devinfo node
+ * func - pointer of function to execute asynchronously
+ * arg - argument to function
+ * flag - USB_FLAGS_SLEEP or USB_FLAGS_NOSLEEP or
+ * USB_FLAGS_NOQUEUE
+ * Return Values:
+ * USB_SUCCESS - function was scheduled
+ * USB_FAILURE - function could not be scheduled
+ *
+ * Flag combinations:
+ * SLEEP - block waiting for resources. always succeeds
+ * NOSLEEP - do not wait for resources, may fail.
+ * NOSLEEP+NOQUEUE - do not wait for resources, do not queue
+ * SLEEP+NOQUEUE - block waiting for resources but may still fail
+ * if no thread available
+ */
+int usb_async_req(
+ dev_info_t *dip,
+ void (*func)(void *),
+ void *arg,
+ usb_flags_t flag);
+
+
+/*
+ * index for getting to usb_pipehandle_list in usba_device
+ */
+uchar_t usb_get_ep_index(uint8_t ep_addr);
+
+/*
+ * **************************************************************************
+ * USB device driver registration and callback functions remaining
+ * Contracted Project Private (for VirtualBox USB Device Capture)
+ * **************************************************************************
+ */
+
+#if 0 /* Uncomment this section if usbai.h doesn't have this these bits (required for snv < 123) */
+
+/*
+ * getting the device strings of manufacturer, product and serial number
+ */
+typedef struct usb_dev_str {
+ char *usb_mfg; /* manufacturer string */
+ char *usb_product; /* product string */
+ char *usb_serialno; /* serial number string */
+} usb_dev_str_t;
+
+/*
+ * It is the callback function type for capture driver.
+ * Arguments:
+ * dev_descr - pointer to device descriptor
+ * dev_str - pointer to device strings
+ * path - pointer to device physical path
+ * bus - USB bus address
+ * port - USB port number
+ * drv - capture driver name.
+ * It is returned by the callback func.
+ * Return Values:
+ * USB_SUCCESS - VirtualBox will capture the device
+ * USB_FAILURE - VirtualBox will not capture the device
+ */
+typedef int (*usb_dev_driver_callback_t)(
+ usb_dev_descr_t *dev_descr,
+ usb_dev_str_t *dev_str,
+ char *path,
+ int bus,
+ int port,
+ char **drv,
+ void *reserved);
+
+/*
+ * Register the callback function in the usba.
+ * Argument:
+ * dip - client driver's devinfo pointer
+ * cb - callback function
+ *
+ * Return Values:
+ * USB_SUCCESS - the registration was successful
+ * USB_FAILURE - the registration failed
+ */
+int usb_register_dev_driver(
+ dev_info_t *dip,
+ usb_dev_driver_callback_t cb);
+
+/*
+ * Unregister the callback function in the usba.
+ */
+void usb_unregister_dev_driver(dev_info_t *dip);
+#endif
+
+
+#ifdef ALLOCB_TEST
+#define allocb(s, p) usba_test_allocb(s, p)
+mblk_t *usba_test_allocb(size_t, uint_t);
+#endif /* ALLOCB_TEST */
+
+/* create an USB style M_CTL message */
+mblk_t *usba_mk_mctl(struct iocblk, void *, size_t);
+
#ifdef __cplusplus
}
#endif
#endif /* _SYS_USB_USBA_USBAI_PRIVATE_H */
-
diff -Nurb VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/Makefile.kmk VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/Makefile.kmk
--- VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/Makefile.kmk 2016-09-12 16:18:33.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/Makefile.kmk 2016-07-18 11:56:23.000000000 +0000
@@ -4,7 +4,7 @@
#
#
-# Copyright (C) 2008-2016 Oracle Corporation
+# Copyright (C) 2008-2015 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
diff -Nurb VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/USBLib-solaris.cpp VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/USBLib-solaris.cpp
--- VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/USBLib-solaris.cpp 2016-09-12 16:18:33.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/USBLib-solaris.cpp 2016-07-18 11:56:23.000000000 +0000
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008-2016 Oracle Corporation
+ * Copyright (C) 2008-2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -209,18 +209,13 @@
{
LogFlow((USBLIBR3 ":USBLibResetDevice pszDevicePath=%s\n", pszDevicePath));
- size_t cbPath = strlen(pszDevicePath) + 1;
- size_t cbReq = sizeof(VBOXUSBREQ_RESET_DEVICE) + cbPath;
+ size_t cbReq = sizeof(VBOXUSBREQ_RESET_DEVICE) + strlen(pszDevicePath);
VBOXUSBREQ_RESET_DEVICE *pReq = (VBOXUSBREQ_RESET_DEVICE *)RTMemTmpAllocZ(cbReq);
if (RT_UNLIKELY(!pReq))
return VERR_NO_MEMORY;
pReq->fReattach = fReattach;
- if (strlcpy(pReq->szDevicePath, pszDevicePath, cbPath) >= cbPath)
- {
- LogRel((USBLIBR3 ":USBLibResetDevice buffer overflow. cbPath=%u pszDevicePath=%s\n", cbPath, pszDevicePath));
- return VERR_BUFFER_OVERFLOW;
- }
+ strcpy(pReq->szDevicePath, pszDevicePath);
int rc = usblibDoIOCtl(VBOXUSBMON_IOCTL_RESET_DEVICE, pReq, cbReq);
if (RT_FAILURE(rc))
diff -Nurb VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSB-solaris.c VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSB-solaris.c
--- VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSB-solaris.c 2016-09-12 16:18:33.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSB-solaris.c 2016-07-18 11:56:23.000000000 +0000
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008-2016 Oracle Corporation
+ * Copyright (C) 2008-2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -44,13 +44,17 @@
#include <iprt/string.h>
#include <iprt/path.h>
#include <iprt/thread.h>
-#include <iprt/dbg.h>
#define USBDRV_MAJOR_VER 2
#define USBDRV_MINOR_VER 0
#include <sys/usb/usba.h>
#include <sys/strsun.h>
#include "usbai_private.h"
+#include <sys/archsystm.h>
+#include <sys/disp.h>
+
+/** @todo review the locking here, verify assumptions about code executed
+ * without the vboxusb_state_t::Mtx mutex */
/*********************************************************************************************************************************
@@ -61,36 +65,47 @@
/** The module description as seen in 'modinfo'. */
#define DEVICE_DESC_DRV "VirtualBox USB"
+/** Endpoint states */
+#define VBOXUSB_EP_INITIALIZED 0xa1fa1fa
+#define VBOXUSB_EP_STATE_NONE RT_BIT(0)
+#define VBOXUSB_EP_STATE_CLOSED RT_BIT(1)
+#define VBOXUSB_EP_STATE_OPENED RT_BIT(2)
+/** Polling states */
+#define VBOXUSB_POLL_OFF RT_BIT(0)
+#define VBOXUSB_POLL_ON RT_BIT(1)
+#define VBOXUSB_POLL_REAP_PENDING RT_BIT(2)
+#define VBOXUSB_POLL_DEV_UNPLUGGED RT_BIT(3)
+
/** -=-=-=-=-=-=- Standard Specifics -=-=-=-=-=-=- */
-/** Max. supported endpoints. */
+/** Max. supported endpoints */
#define VBOXUSB_MAX_ENDPOINTS 32
-/** Size of USB Ctrl Xfer Header in bytes. */
-#define VBOXUSB_CTRL_XFER_SIZE 8
+/** Size of USB Ctrl Xfer Header */
+#define VBOXUSB_CTRL_XFER_SIZE 0x08
/**
* USB2.0 (Sec. 9-13) Bits 10..0 is the max packet size; for high speed Isoc/Intr, bits 12..11 is
* number of additional transaction opportunities per microframe.
*/
#define VBOXUSB_PKT_SIZE(pkt) (pkt & 0x07FF) * (1 + ((pkt >> 11) & 3))
-/** Endpoint Xfer Type. */
+/** Endpoint Xfer Type */
#define VBOXUSB_XFER_TYPE(endp) ((endp)->EpDesc.bmAttributes & USB_EP_ATTR_MASK)
-/** Endpoint Xfer Direction. */
+/** Endpoint Xfer Direction */
#define VBOXUSB_XFER_DIR(endp) ((endp)->EpDesc.bEndpointAddress & USB_EP_DIR_IN)
-/** Create an Endpoint index from an Endpoint address. */
-#define VBOXUSB_GET_EP_INDEX(epaddr) (((epaddr) & USB_EP_NUM_MASK) + \
- (((epaddr) & USB_EP_DIR_MASK) ? 16 : 0))
-
/** -=-=-=-=-=-=- Tunable Parameters -=-=-=-=-=-=- */
/** Time to wait while draining inflight UBRs on suspend, in seconds. */
#define VBOXUSB_DRAIN_TIME 20
/** Ctrl Xfer timeout in seconds. */
-#define VBOXUSB_CTRL_XFER_TIMEOUT 15
+#define VBOXUSB_CTRL_XFER_TIMEOUT 10
+/** Bulk Xfer timeout in seconds. */
+#define VBOXUSB_BULK_XFER_TIMEOUT 10
+/** Intr Xfer timeout in seconds. */
+#define VBOXUSB_INTR_XFER_TIMEOUT 10
/** Maximum URB queue length. */
-#define VBOXUSB_URB_QUEUE_SIZE 512
-/** Maximum asynchronous requests per pipe. */
+#define VBOXUSB_URB_QUEUE_SIZE 64
+/** Maximum asynchronous requests per pipe */
#define VBOXUSB_MAX_PIPE_ASYNC_REQS 2
-/** For enabling global symbols while debugging. **/
+/** For enabling global symbols while debugging **/
#if defined(DEBUG_ramshankar)
# define LOCAL
#else
@@ -185,8 +200,12 @@
*/
typedef struct vboxusb_ep_t
{
- bool fInitialized; /* Whether this Endpoint is initialized */
+ uint_t fInitialized; /* Whether this Endpoint is initialized */
+ uint_t EpState; /* Endpoint state */
usb_ep_descr_t EpDesc; /* Endpoint descriptor */
+ uchar_t uCfgValue; /* Configuration value */
+ uchar_t uInterface; /* Interface number */
+ uchar_t uAlt; /* Alternate number */
usb_pipe_handle_t pPipe; /* Endpoint pipe handle */
usb_pipe_policy_t PipePolicy; /* Endpoint policy */
bool fIsocPolling; /* Whether Isoc. IN polling is enabled */
@@ -228,13 +247,13 @@
VUSBXFERTYPE enmType; /* Xfer type */
VUSBDIRECTION enmDir; /* Xfer direction */
VUSBSTATUS enmStatus; /* URB status */
- bool fShortOk; /* Whether receiving less data than requested is acceptable */
+ bool fShortOk; /* Whether receiving less data than requested is acceptable. */
RTR3PTR pvDataR3; /* Userspace address of the original data buffer */
size_t cbDataR3; /* Size of the data buffer */
mblk_t *pMsg; /* Pointer to the data buffer */
uint32_t cIsocPkts; /* Number of Isoc pkts */
VUSBISOC_PKT_DESC aIsocPkts[8]; /* Array of Isoc pkt descriptors */
- VBOXUSB_URB_STATE enmState; /* URB state (free/in-flight/landed). */
+ VBOXUSB_URB_STATE enmState; /* Whether free/in-flight etc. */
struct vboxusb_state_t *pState; /* Pointer to the device instance */
list_node_t hListLink; /* List node link handle */
} vboxusb_urb_t;
@@ -245,7 +264,7 @@
typedef struct vboxusb_power_t
{
uint_t PowerStates; /* Bit mask of the power states */
- int PowerBusy; /* Busy reference counter */
+ int PowerBusy; /* Busy counter */
bool fPowerWakeup; /* Whether remote power wakeup is enabled */
bool fPowerRaise; /* Whether to raise the power level */
uint8_t PowerLevel; /* Current power level */
@@ -259,86 +278,83 @@
dev_info_t *pDip; /* Per instance device info. */
usb_client_dev_data_t *pDevDesc; /* Parsed & complete device descriptor */
uint8_t DevState; /* Current USB Device state */
- bool fDefaultPipeOpen; /* Whether the device (default control pipe) is closed */
- bool fPollPending; /* Whether the userland process' poll is pending */
+ bool fClosed; /* Whether the device (default control pipe) is closed */
+ bool fRestoreCfg; /* Whether we changed configs to restore while tearing down */
+ bool fGetCfgReqDone; /* First GET_CONFIG request has been circumvented */
kmutex_t Mtx; /* Mutex state protection */
usb_serialization_t StateMulti; /* State serialization */
size_t cbMaxBulkXfer; /* Maximum bulk xfer size */
- vboxusb_ep_t aEps[VBOXUSB_MAX_ENDPOINTS]; /* Array of all endpoints structures */
- list_t hFreeUrbs; /* List of free URBs */
- list_t hInflightUrbs; /* List of inflight URBs */
- list_t hLandedUrbs; /* List of landed URBs */
- uint32_t cFreeUrbs; /* Number of free URBs */
- uint32_t cInflightUrbs; /* Number of inflight URBs */
- uint32_t cLandedUrbs; /* Number of landed URBs */
+ vboxusb_ep_t aEps[VBOXUSB_MAX_ENDPOINTS]; /* All endpoints structures */
+ list_t hUrbs; /* Handle to list of free/inflight URBs */
+ list_t hLandedUrbs; /* Handle to list of landed URBs */
+ uint16_t cInflightUrbs; /* Number of inflight URBs. */
pollhead_t PollHead; /* Handle to pollhead for waking polling processes */
- RTPROCESS Process; /* The process (pid) of the user session */
+ int fPoll; /* Polling status flag */
+ RTPROCESS Process; /* The process (id) of the session */
VBOXUSBREQ_CLIENT_INFO ClientInfo; /* Registration data */
vboxusb_power_t *pPower; /* Power Management */
- char szMfg[255]; /* Parsed manufacturer string */
- char szProduct[255]; /* Parsed product string */
} vboxusb_state_t;
-AssertCompileMemberSize(vboxusb_state_t, szMfg, USB_MAXSTRINGLEN);
-AssertCompileMemberSize(vboxusb_state_t, szProduct, USB_MAXSTRINGLEN);
/*********************************************************************************************************************************
* Internal Functions *
*********************************************************************************************************************************/
-LOCAL int vboxUsbSolarisInitEp(vboxusb_state_t *pState, usb_ep_data_t *pEpData);
-LOCAL int vboxUsbSolarisInitEpsForCfg(vboxusb_state_t *pState);
-LOCAL int vboxUsbSolarisInitEpsForIfAlt(vboxusb_state_t *pState, uint8_t bIf, uint8_t bAlt);
-LOCAL void vboxUsbSolarisDestroyAllEps(vboxusb_state_t *pState);
-LOCAL void vboxUsbSolarisDestroyEp(vboxusb_state_t *pState, vboxusb_ep_t *pEp);
-LOCAL void vboxUsbSolarisCloseAllPipes(vboxusb_state_t *pState, bool fControlPipe);
-LOCAL int vboxUsbSolarisOpenPipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp);
-LOCAL void vboxUsbSolarisClosePipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp);
-LOCAL int vboxUsbSolarisCtrlXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb);
-LOCAL void vboxUsbSolarisCtrlXferCompleted(usb_pipe_handle_t pPipe, usb_ctrl_req_t *pReq);
-LOCAL int vboxUsbSolarisBulkXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *purb);
-LOCAL void vboxUsbSolarisBulkXferCompleted(usb_pipe_handle_t pPipe, usb_bulk_req_t *pReq);
-LOCAL int vboxUsbSolarisIntrXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb);
-LOCAL void vboxUsbSolarisIntrXferCompleted(usb_pipe_handle_t pPipe, usb_intr_req_t *pReq);
-LOCAL int vboxUsbSolarisIsocXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb);
-LOCAL void vboxUsbSolarisIsocInXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq);
-LOCAL void vboxUsbSolarisIsocInXferError(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq);
-LOCAL void vboxUsbSolarisIsocOutXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq);
-LOCAL vboxusb_urb_t *vboxUsbSolarisGetIsocInUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq);
-LOCAL vboxusb_urb_t *vboxUsbSolarisQueueUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, mblk_t *pMsg);
-LOCAL VUSBSTATUS vboxUsbSolarisGetUrbStatus(usb_cr_t Status);
-LOCAL void vboxUsbSolarisConcatMsg(vboxusb_urb_t *pUrb);
-LOCAL void vboxUsbSolarisDeQueueUrb(vboxusb_urb_t *pUrb, int URBStatus);
-LOCAL void vboxUsbSolarisNotifyComplete(vboxusb_state_t *pState);
-LOCAL int vboxUsbSolarisProcessIOCtl(int iFunction, void *pvState, int Mode, PVBOXUSBREQ pUSBReq, void *pvBuf,
+LOCAL int vboxUSBSolarisInitEndPoint(vboxusb_state_t *pState, usb_ep_data_t *pEpData, uchar_t uCfgValue,
+ uchar_t uInterface, uchar_t uAlt);
+LOCAL int vboxUSBSolarisInitAllEndPoints(vboxusb_state_t *pState);
+LOCAL int vboxUSBSolarisInitEndPointsForConfig(vboxusb_state_t *pState, uint8_t uCfgIndex);
+LOCAL int vboxUSBSolarisInitEndPointsForInterfaceAlt(vboxusb_state_t *pState, uint8_t uInterface, uint8_t uAlt);
+LOCAL void vboxUSBSolarisDestroyAllEndPoints(vboxusb_state_t *pState);
+LOCAL void vboxUSBSolarisDestroyEndPoint(vboxusb_state_t *pState, vboxusb_ep_t *pEp);
+LOCAL void vboxUSBSolarisCloseAllPipes(vboxusb_state_t *pState, bool fControlPipe);
+LOCAL int vboxUSBSolarisOpenPipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp);
+LOCAL void vboxUSBSolarisClosePipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp);
+LOCAL int vboxUSBSolarisCtrlXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb);
+LOCAL void vboxUSBSolarisCtrlXferCompleted(usb_pipe_handle_t pPipe, usb_ctrl_req_t *pReq);
+LOCAL int vboxUSBSolarisBulkXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *purb);
+LOCAL void vboxUSBSolarisBulkXferCompleted(usb_pipe_handle_t pPipe, usb_bulk_req_t *pReq);
+LOCAL int vboxUSBSolarisIntrXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb);
+LOCAL void vboxUSBSolarisIntrXferCompleted(usb_pipe_handle_t pPipe, usb_intr_req_t *pReq);
+LOCAL int vboxUSBSolarisIsocXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb);
+LOCAL void vboxUSBSolarisIsocInXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq);
+LOCAL void vboxUSBSolarisIsocInXferError(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq);
+LOCAL void vboxUSBSolarisIsocOutXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq);
+LOCAL vboxusb_urb_t *vboxUSBSolarisGetIsocInURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq);
+LOCAL vboxusb_urb_t *vboxUSBSolarisQueueURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, mblk_t *pMsg);
+LOCAL inline void vboxUSBSolarisConcatMsg(vboxusb_urb_t *pUrb);
+LOCAL inline VUSBSTATUS vboxUSBSolarisGetUrbStatus(usb_cr_t Status);
+LOCAL inline void vboxUSBSolarisDeQueueURB(vboxusb_urb_t *pUrb, int URBStatus);
+LOCAL inline void vboxUSBSolarisNotifyComplete(vboxusb_state_t *pState);
+LOCAL int vboxUSBSolarisProcessIOCtl(int iFunction, void *pvState, int Mode, PVBOXUSBREQ pUSBReq, void *pvBuf,
size_t *pcbDataOut);
-LOCAL bool vboxUsbSolarisIsUSBDevice(dev_info_t *pDip);
+LOCAL bool vboxUSBSolarisIsUSBDevice(dev_info_t *pDip);
/** @name Device Operation Hooks
* @{ */
-LOCAL int vboxUsbSolarisSendUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode);
-LOCAL int vboxUsbSolarisReapUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode);
-LOCAL int vboxUsbSolarisClearEndPoint(vboxusb_state_t *pState, uint8_t bEndpoint);
-LOCAL int vboxUsbSolarisSetConfig(vboxusb_state_t *pState, uint8_t bCfgValue);
-LOCAL int vboxUsbSolarisGetConfig(vboxusb_state_t *pState, uint8_t *pCfgValue);
-LOCAL int vboxUsbSolarisSetInterface(vboxusb_state_t *pState, uint8_t bIf, uint8_t bAlt);
-LOCAL int vboxUsbSolarisCloseDevice(vboxusb_state_t *pState, VBOXUSB_RESET_LEVEL enmReset);
-LOCAL int vboxUsbSolarisAbortPipe(vboxusb_state_t *pState, uint8_t bEndpoint);
-LOCAL int vboxUsbSolarisGetConfigIndex(vboxusb_state_t *pState, uint_t bCfgValue);
+LOCAL int vboxUSBSolarisSendURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode);
+LOCAL int vboxUSBSolarisReapURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode);
+LOCAL int vboxUSBSolarisClearEndPoint(vboxusb_state_t *pState, uint8_t bEndpoint);
+LOCAL int vboxUSBSolarisSetConfig(vboxusb_state_t *pState, uint8_t bCfgValue);
+LOCAL int vboxUSBSolarisGetConfig(vboxusb_state_t *pState, uint8_t *pCfgValue);
+LOCAL int vboxUSBSolarisSetInterface(vboxusb_state_t *pState, uint8_t uInterface, uint8_t uAlt);
+LOCAL int vboxUSBSolarisCloseDevice(vboxusb_state_t *pState, VBOXUSB_RESET_LEVEL enmReset);
+LOCAL int vboxUSBSolarisAbortPipe(vboxusb_state_t *pState, uint8_t bEndpoint);
+LOCAL int vboxUSBSolarisGetConfigIndex(vboxusb_state_t *pState, uint_t uCfgValue);
/** @} */
/** @name Hotplug & Power Management Hooks
* @{ */
-LOCAL void vboxUsbSolarisNotifyUnplug(vboxusb_state_t *pState);
-LOCAL int vboxUsbSolarisDeviceDisconnected(dev_info_t *pDip);
-LOCAL int vboxUsbSolarisDeviceReconnected(dev_info_t *pDip);
-
-LOCAL int vboxUsbSolarisInitPower(vboxusb_state_t *pState);
-LOCAL void vboxUsbSolarisDestroyPower(vboxusb_state_t *pState);
-LOCAL int vboxUsbSolarisDeviceSuspend(vboxusb_state_t *pState);
-LOCAL void vboxUsbSolarisDeviceResume(vboxusb_state_t *pState);
-LOCAL void vboxUsbSolarisDeviceRestore(vboxusb_state_t *pState);
-LOCAL void vboxUsbSolarisPowerBusy(vboxusb_state_t *pState);
-LOCAL void vboxUsbSolarisPowerIdle(vboxusb_state_t *pState);
+LOCAL inline void vboxUSBSolarisNotifyHotplug(vboxusb_state_t *pState);
+LOCAL int vboxUSBSolarisDeviceDisconnected(dev_info_t *pDip);
+LOCAL int vboxUSBSolarisDeviceReconnected(dev_info_t *pDip);
+
+LOCAL int vboxUSBSolarisInitPower(vboxusb_state_t *pState);
+LOCAL void vboxUSBSolarisDestroyPower(vboxusb_state_t *pState);
+LOCAL int vboxUSBSolarisDeviceSuspend(vboxusb_state_t *pState);
+LOCAL void vboxUSBSolarisDeviceResume(vboxusb_state_t *pState);
+LOCAL void vboxUSBSolarisDeviceRestore(vboxusb_state_t *pState);
+LOCAL void vboxUSBSolarisPowerBusy(vboxusb_state_t *pState);
+LOCAL void vboxUSBSolarisPowerIdle(vboxusb_state_t *pState);
/** @} */
/** @name Monitor Hooks
@@ -349,7 +365,7 @@
/** @name Callbacks from Monitor
* @{ */
-LOCAL int vboxUsbSolarisSetConsumerCredentials(RTPROCESS Process, int Instance, void *pvReserved);
+LOCAL int vboxUSBSolarisSetConsumerCredentials(RTPROCESS Process, int Instance, void *pvReserved);
/** @} */
@@ -360,129 +376,16 @@
static void *g_pVBoxUSBSolarisState;
/** The default endpoint descriptor */
-static usb_ep_descr_t g_VBoxUSBSolarisDefaultEpDesc = { 7, 5, 0, USB_EP_ATTR_CONTROL, 8, 0 };
-
-/** Size of the usb_ep_data_t struct (used to index into data). */
-static size_t g_cbUsbEpData = ~0UL;
+static usb_ep_descr_t g_VBoxUSBSolarisDefaultEpDesc = {7, 5, 0, USB_EP_ATTR_CONTROL, 8, 0};
-/** The offset of usb_ep_data_t::ep_desc. */
-static size_t g_offUsbEpDataDescr = ~0UL;
-
-
-#ifdef LOG_ENABLED
-/**
- * Gets the description of an Endpoint's transfer type.
- *
- * @param pEp The Endpoint.
- * @returns The type of the Endpoint.
- */
-static const char *vboxUsbSolarisEpType(vboxusb_ep_t *pEp)
+/** Hotplug events */
+static usb_event_t g_VBoxUSBSolarisEvents =
{
- uint8_t uType = VBOXUSB_XFER_TYPE(pEp);
- switch (uType)
- {
- case 0: return "CTRL";
- case 1: return "ISOC";
- case 2: return "BULK";
- default: return "INTR";
- }
-}
-
-
-/**
- * Gets the description of an Endpoint's direction.
- *
- * @param pEp The Endpoint.
- * @returns The direction of the Endpoint.
- */
-static const char *vboxUsbSolarisEpDir(vboxusb_ep_t *pEp)
-{
- return VBOXUSB_XFER_DIR(pEp) == USB_EP_DIR_IN ? "IN " : "OUT";
-}
-#endif
-
-
-/**
- * Caches device strings from the parsed device descriptors.
- *
- * @param pState The USB device instance.
- *
- * @remarks Must only be called after usb_get_dev_data().
- */
-static void vboxUsbSolarisGetDeviceStrings(vboxusb_state_t *pState)
-{
- AssertReturnVoid(pState);
- AssertReturnVoid(pState->pDevDesc);
-
- if (pState->pDevDesc->dev_product)
- strlcpy(&pState->szMfg[0], pState->pDevDesc->dev_mfg, sizeof(pState->szMfg));
- else
- strlcpy(&pState->szMfg[0], "<Unknown Manufacturer>", sizeof(pState->szMfg));
-
- if (pState->pDevDesc->dev_product)
- strlcpy(&pState->szProduct[0], pState->pDevDesc->dev_product, sizeof(pState->szProduct));
- else
- strlcpy(&pState->szProduct[0], "<Unnamed USB device>", sizeof(pState->szProduct));
-}
-
-
-/**
- * Queries the necessary symbols at runtime.
- *
- * @returns VBox status code.
- */
-LOCAL int vboxUsbSolarisQuerySymbols(void)
-{
- RTDBGKRNLINFO hKrnlDbgInfo;
- int rc = RTR0DbgKrnlInfoOpen(&hKrnlDbgInfo, 0 /* fFlags */);
- if (RT_SUCCESS(rc))
- {
- /*
- * Query and sanitize the size of usb_ep_data_t struct.
- */
- size_t cbPrevUsbEpData = g_cbUsbEpData;
- rc = RTR0DbgKrnlInfoQuerySize(hKrnlDbgInfo, "usba", "usb_ep_data_t", &g_cbUsbEpData);
- if (RT_FAILURE(rc))
- {
- LogRel(("Failed to query size of \"usb_ep_data_t\" in the \"usba\" module, rc=%Rrc\n", rc));
- return rc;
- }
- if (g_cbUsbEpData > _4K)
- {
- LogRel(("Size of \"usb_ep_data_t\" (%u bytes) seems implausible, too paranoid to continue\n", g_cbUsbEpData));
- return VERR_MISMATCH;
- }
-
- /*
- * Query and sanitizie the offset of usb_ep_data_t::ep_descr.
- */
- size_t offPrevUsbEpDataDescr = g_offUsbEpDataDescr;
- rc = RTR0DbgKrnlInfoQueryMember(hKrnlDbgInfo, "usba", "usb_ep_data_t", "ep_descr", &g_offUsbEpDataDescr);
- if (RT_FAILURE(rc))
- {
- LogRel(("Failed to query offset of usb_ep_data_t::ep_descr, rc=%Rrc\n", rc));
- return rc;
- }
- if (g_offUsbEpDataDescr > _4K - sizeof(usb_ep_descr_t))
- {
- LogRel(("Offset of \"ep_desrc\" (%u) seems implausible, too paranoid to continue\n", g_offUsbEpDataDescr));
- return VERR_MISMATCH;
- }
-
- /*
- * Log only when it changes / first time, since _init() seems to be called often (e.g. on failed attaches).
- * cmn_err, CE_CONT and '!' is used to not show the message on console during boot each time.
- */
- if ( cbPrevUsbEpData != g_cbUsbEpData
- || offPrevUsbEpDataDescr != g_offUsbEpDataDescr)
- {
- cmn_err(CE_CONT, "!usba_ep_data_t is %lu bytes\n", g_cbUsbEpData);
- cmn_err(CE_CONT, "!usba_ep_data_t::ep_descr @ 0x%lx (%ld)\n", g_offUsbEpDataDescr, g_offUsbEpDataDescr);
- }
-
- RTR0DbgKrnlInfoRelease(hKrnlDbgInfo);
- }
-}
+ vboxUSBSolarisDeviceDisconnected,
+ vboxUSBSolarisDeviceReconnected,
+ NULL, /* presuspend */
+ NULL /* postresume */
+};
/**
@@ -490,7 +393,7 @@
*/
int _init(void)
{
- LogFunc((DEVICE_NAME ": _init\n"));
+ LogFunc((DEVICE_NAME ":_init\n"));
/*
* Prevent module autounloading.
@@ -499,7 +402,7 @@
if (pModCtl)
pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD;
else
- LogRel((DEVICE_NAME ": _init: failed to disable autounloading!\n"));
+ LogRel((DEVICE_NAME ":failed to disable autounloading!\n"));
/*
* Initialize IPRT R0 driver, which internally calls OS-specific r0 init.
@@ -507,10 +410,6 @@
int rc = RTR0Init(0);
if (RT_SUCCESS(rc))
{
- rc = vboxUsbSolarisQuerySymbols();
- if (RT_FAILURE(rc))
- return EINVAL;
-
rc = ddi_soft_state_init(&g_pVBoxUSBSolarisState, sizeof(vboxusb_state_t), 4 /* pre-alloc */);
if (!rc)
{
@@ -518,16 +417,16 @@
if (!rc)
return rc;
- LogRel((DEVICE_NAME ": _init: mod_install failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":mod_install failed! rc=%d\n", rc));
ddi_soft_state_fini(&g_pVBoxUSBSolarisState);
}
else
- LogRel((DEVICE_NAME ": _init: failed to initialize soft state\n"));
+ LogRel((DEVICE_NAME ":failed to initialize soft state.\n"));
RTR0Term();
}
else
- LogRel((DEVICE_NAME ": _init: RTR0Init failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":RTR0Init failed! rc=%d\n", rc));
return RTErrConvertToErrno(rc);
}
@@ -536,7 +435,7 @@
{
int rc;
- LogFunc((DEVICE_NAME ": _fini\n"));
+ LogFunc((DEVICE_NAME ":_fini\n"));
rc = mod_remove(&g_VBoxUSBSolarisModLinkage);
if (!rc)
@@ -551,7 +450,7 @@
int _info(struct modinfo *pModInfo)
{
- LogFunc((DEVICE_NAME ": _info\n"));
+ LogFunc((DEVICE_NAME ":_info\n"));
return mod_info(&g_VBoxUSBSolarisModLinkage, pModInfo);
}
@@ -563,11 +462,11 @@
* @param pDip The module structure instance.
* @param enmCmd Attach type (ddi_attach_cmd_t)
*
- * @returns Solaris error code.
+ * @returns corresponding solaris error code.
*/
int VBoxUSBSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisAttach: pDip=%p enmCmd=%d\n", pDip, enmCmd));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisAttach pDip=%p enmCmd=%d\n", pDip, enmCmd));
int rc;
int instance = ddi_get_instance(pDip);
@@ -585,22 +484,22 @@
{
pState->pDip = pDip;
pState->pDevDesc = NULL;
- pState->fPollPending = false;
+ pState->fClosed = false;
+ pState->fRestoreCfg = false;
+ pState->fGetCfgReqDone = false;
+ bzero(pState->aEps, sizeof(pState->aEps));
+ list_create(&pState->hUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink));
+ list_create(&pState->hLandedUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink));
pState->cInflightUrbs = 0;
- pState->cFreeUrbs = 0;
- pState->cLandedUrbs = 0;
+ pState->fPoll = VBOXUSB_POLL_OFF;
pState->Process = NIL_RTPROCESS;
pState->pPower = NULL;
- bzero(pState->aEps, sizeof(pState->aEps));
- list_create(&pState->hFreeUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink));
- list_create(&pState->hInflightUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink));
- list_create(&pState->hLandedUrbs, sizeof(vboxusb_urb_t), offsetof(vboxusb_urb_t, hListLink));
/*
* There is a bug in usb_client_attach() as of Nevada 120 which panics when we bind to
* a non-USB device. So check if we are really binding to a USB device or not.
*/
- if (vboxUsbSolarisIsUSBDevice(pState->pDip))
+ if (vboxUSBSolarisIsUSBDevice(pState->pDip))
{
/*
* Here starts the USB specifics.
@@ -608,18 +507,12 @@
rc = usb_client_attach(pState->pDip, USBDRV_VERSION, 0);
if (rc == USB_SUCCESS)
{
- pState->fDefaultPipeOpen = true;
-
/*
* Parse out the entire descriptor.
*/
rc = usb_get_dev_data(pState->pDip, &pState->pDevDesc, USB_PARSE_LVL_ALL, 0 /* Unused */);
if (rc == USB_SUCCESS)
{
- /*
- * Cache some device descriptor strings.
- */
- vboxUsbSolarisGetDeviceStrings(pState);
#ifdef DEBUG_ramshankar
usb_print_descr_tree(pState->pDip, pState->pDevDesc);
#endif
@@ -636,12 +529,12 @@
rc = usb_pipe_get_max_bulk_transfer_size(pState->pDip, &pState->cbMaxBulkXfer);
if (rc == USB_SUCCESS)
{
- Log((DEVICE_NAME ": VBoxUSBSolarisAttach: cbMaxBulkXfer=%d\n", pState->cbMaxBulkXfer));
+ Log((DEVICE_NAME ":VBoxUSBSolarisAttach cbMaxBulkXfer=%d\n", pState->cbMaxBulkXfer));
/*
- * Initialize the default endpoint.
+ * Initialize all endpoints.
*/
- rc = vboxUsbSolarisInitEp(pState, NULL /* pEp */);
+ rc = vboxUSBSolarisInitAllEndPoints(pState);
if (RT_SUCCESS(rc))
{
/*
@@ -652,14 +545,13 @@
/*
* Initialize power management for the device.
*/
- rc = vboxUsbSolarisInitPower(pState);
+ rc = vboxUSBSolarisInitPower(pState);
if (RT_SUCCESS(rc))
{
/*
- * Initialize endpoints for the current config.
+ * Update endpoints (descriptors) for the current config.
*/
- rc = vboxUsbSolarisInitEpsForCfg(pState);
- AssertRC(rc);
+ vboxUSBSolarisInitEndPointsForConfig(pState, usb_get_current_cfgidx(pState->pDip));
/*
* Publish the minor node.
@@ -671,8 +563,7 @@
/*
* Register hotplug callbacks.
*/
- rc = usb_register_hotplug_cbs(pState->pDip, &vboxUsbSolarisDeviceDisconnected,
- &vboxUsbSolarisDeviceReconnected);
+ rc = usb_register_event_cbs(pState->pDip, &g_VBoxUSBSolarisEvents, 0 /* flags */);
if (RT_LIKELY(rc == USB_SUCCESS))
{
/*
@@ -683,7 +574,8 @@
ddi_pathname(pState->pDip, szDevicePath);
RTStrPrintf(pState->ClientInfo.szClientPath,
sizeof(pState->ClientInfo.szClientPath),
- "/devices%s:%s", szDevicePath, DEVICE_NAME);
+ "/devices%s:%s", szDevicePath,DEVICE_NAME);
+ RTPathStripFilename(szDevicePath);
RTStrPrintf(pState->ClientInfo.szDeviceIdent,
sizeof(pState->ClientInfo.szDeviceIdent),
"%#x:%#x:%d:%s",
@@ -691,73 +583,84 @@
pState->pDevDesc->dev_descr->idProduct,
pState->pDevDesc->dev_descr->bcdDevice, szDevicePath);
pState->ClientInfo.Instance = instance;
- pState->ClientInfo.pfnSetConsumerCredentials = &vboxUsbSolarisSetConsumerCredentials;
+ pState->ClientInfo.pfnSetConsumerCredentials = &vboxUSBSolarisSetConsumerCredentials;
rc = VBoxUSBMonSolarisRegisterClient(pState->pDip, &pState->ClientInfo);
if (RT_SUCCESS(rc))
{
-#if 0
- LogRel((DEVICE_NAME ": Captured %s %s (Ident=%s)\n", pState->szMfg,
- pState->szProduct, pState->ClientInfo.szDeviceIdent));
-#else
- /* Until IPRT R0 logging is fixed. See @bugref{6657#c7} */
- cmn_err(CE_CONT, "Captured %s %s (Ident=%s)\n", pState->szMfg,
- pState->szProduct, pState->ClientInfo.szDeviceIdent);
-#endif
+ LogRel((DEVICE_NAME ": Captured %s %#x:%#x:%d:%s\n",
+ pState->pDevDesc->dev_product ? pState->pDevDesc->dev_product
+ : "<Unnamed USB device>",
+ pState->pDevDesc->dev_descr->idVendor,
+ pState->pDevDesc->dev_descr->idProduct,
+ pState->pDevDesc->dev_descr->bcdDevice,
+ pState->ClientInfo.szClientPath));
+
return DDI_SUCCESS;
}
-
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisRegisterClient failed! rc=%d "
+ else
+ {
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisRegisterClient failed! rc=%d "
"path=%s instance=%d\n", rc, pState->ClientInfo.szClientPath,
instance));
+ }
- usb_unregister_hotplug_cbs(pState->pDip);
+ usb_unregister_event_cbs(pState->pDip, &g_VBoxUSBSolarisEvents);
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to register hotplug callbacks! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach failed to register hotplug "
+ "callbacks! rc=%d\n", rc));
ddi_remove_minor_node(pState->pDip, NULL);
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: ddi_create_minor_node failed! rc=%d\n", rc));
-
- mutex_enter(&pState->Mtx);
- vboxUsbSolarisDestroyPower(pState);
- mutex_exit(&pState->Mtx);
+ {
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach ddi_create_minor_node failed! rc=%d\n",
+ rc));
+ }
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to init power management! rc=%d\n", rc));
+ {
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach failed to initialize power management! "
+ "rc=%d\n", rc));
+ }
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: vboxUsbSolarisInitEp failed! rc=%d\n", rc));
+ {
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach vboxUSBSolarisInitAllEndPoints failed! "
+ "rc=%d\n"));
+ }
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: usb_pipe_get_max_bulk_transfer_size failed! rc=%d\n", rc));
+ {
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach usb_pipe_get_max_bulk_transfer_size failed! "
+ "rc=%d\n", rc));
+ }
usb_fini_serialization(pState->StateMulti);
mutex_destroy(&pState->Mtx);
usb_free_dev_data(pState->pDip, pState->pDevDesc);
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to get device descriptor. rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach failed to get device descriptor. rc=%d\n", rc));
usb_client_detach(pState->pDip, NULL);
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: usb_client_attach failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach usb_client_attach failed! rc=%d\n", rc));
}
else
{
/* This would appear on every boot if it were LogRel() */
- Log((DEVICE_NAME ": VBoxUSBSolarisAttach: Not a USB device\n"));
+ Log((DEVICE_NAME ":VBoxUSBSolarisAttach not a USB device.\n"));
}
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to get soft state\n", sizeof(*pState)));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach failed to get soft state\n", sizeof(*pState)));
ddi_soft_state_free(g_pVBoxUSBSolarisState, instance);
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: Failed to alloc soft state. rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach failed to alloc soft state. rc=%d\n", rc));
return DDI_FAILURE;
}
@@ -767,11 +670,11 @@
pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
if (RT_UNLIKELY(!pState))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisAttach: DDI_RESUME failed to get soft state on detach\n"));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisAttach DDI_RESUME: failed to get soft state on detach.\n"));
return DDI_FAILURE;
}
- vboxUsbSolarisDeviceResume(pState);
+ vboxUSBSolarisDeviceResume(pState);
return DDI_SUCCESS;
}
@@ -787,17 +690,17 @@
* @param pDip The module structure instance.
* @param enmCmd Attach type (ddi_attach_cmd_t)
*
- * @returns Solaris error code.
+ * @returns corresponding solaris error code.
*/
int VBoxUSBSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisDetach: pDip=%p enmCmd=%d\n", pDip, enmCmd));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisDetach pDip=%p enmCmd=%d\n", pDip, enmCmd));
int instance = ddi_get_instance(pDip);
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
if (RT_UNLIKELY(!pState))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisDetach: Failed to get soft state on detach\n"));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisDetach failed to get soft state on detach.\n"));
return DDI_FAILURE;
}
@@ -814,64 +717,53 @@
/*
* Notify userland if any that we're gone (while resetting device held by us).
*/
- mutex_enter(&pState->Mtx);
- pState->DevState = USB_DEV_DISCONNECTED;
- vboxUsbSolarisNotifyUnplug(pState);
- mutex_exit(&pState->Mtx);
-
+ vboxUSBSolarisNotifyHotplug(pState);
/*
* Unregister hotplug callback events first without holding the mutex as the callbacks
* would otherwise block on the mutex.
*/
- usb_unregister_hotplug_cbs(pDip);
+ usb_unregister_event_cbs(pDip, &g_VBoxUSBSolarisEvents);
+
/*
* Serialize: paranoid; drain other driver activity.
*/
- usb_serialize_access(pState->StateMulti, USB_WAIT, 0 /* timeout */);
+ usb_serialize_access(pState->StateMulti, USB_WAIT, 0);
usb_release_access(pState->StateMulti);
mutex_enter(&pState->Mtx);
/*
- * Close all pipes.
+ * Close all endpoints.
*/
- vboxUsbSolarisCloseAllPipes(pState, true /* ControlPipe */);
- Assert(!pState->fDefaultPipeOpen);
+ vboxUSBSolarisCloseAllPipes(pState, true /* ControlPipe */);
+ pState->fClosed = true;
/*
- * Deinitialize power, destroy all endpoints.
+ * Deinitialize power, destroy endpoints.
*/
- vboxUsbSolarisDestroyPower(pState);
- vboxUsbSolarisDestroyAllEps(pState);
+ vboxUSBSolarisDestroyPower(pState);
+ vboxUSBSolarisDestroyAllEndPoints(pState);
/*
- * Free up all URB lists.
+ * Free up all URBs.
*/
vboxusb_urb_t *pUrb = NULL;
- while ((pUrb = list_remove_head(&pState->hFreeUrbs)) != NULL)
- {
- if (pUrb->pMsg)
- freemsg(pUrb->pMsg);
- RTMemFree(pUrb);
- }
- while ((pUrb = list_remove_head(&pState->hInflightUrbs)) != NULL)
+ while ((pUrb = list_remove_head(&pState->hUrbs)) != NULL)
{
if (pUrb->pMsg)
freemsg(pUrb->pMsg);
RTMemFree(pUrb);
}
+
while ((pUrb = list_remove_head(&pState->hLandedUrbs)) != NULL)
{
if (pUrb->pMsg)
freemsg(pUrb->pMsg);
RTMemFree(pUrb);
}
- pState->cFreeUrbs = 0;
- pState->cLandedUrbs = 0;
pState->cInflightUrbs = 0;
- list_destroy(&pState->hFreeUrbs);
- list_destroy(&pState->hInflightUrbs);
+ list_destroy(&pState->hUrbs);
list_destroy(&pState->hLandedUrbs);
/*
@@ -891,22 +783,19 @@
ddi_remove_minor_node(pState->pDip, NULL);
-#if 0
- LogRel((DEVICE_NAME ": Released %s %s (Ident=%s)\n", pState->szMfg, pState->szProduct,
+ LogRel((DEVICE_NAME ": Released %s %s\n",
+ pState->pDevDesc->dev_product ? pState->pDevDesc->dev_product : "<Unnamed USB device>",
pState->ClientInfo.szDeviceIdent));
-#else
- /* Until IPRT R0 logging is fixed. See @bugref{6657#c7} */
- cmn_err(CE_CONT, "Released %s %s (Ident=%s)\n", pState->szMfg, pState->szProduct, pState->ClientInfo.szDeviceIdent);
-#endif
ddi_soft_state_free(g_pVBoxUSBSolarisState, instance);
pState = NULL;
+
return DDI_SUCCESS;
}
case DDI_SUSPEND:
{
- int rc = vboxUsbSolarisDeviceSuspend(pState);
+ int rc = vboxUSBSolarisDeviceSuspend(pState);
if (RT_SUCCESS(rc))
return DDI_SUCCESS;
@@ -927,11 +816,11 @@
* @param pvArg Type specific argument.
* @param ppvResult Where to store the requested info.
*
- * @returns Solaris error code.
+ * @returns corresponding solaris error code.
*/
int VBoxUSBSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisGetInfo\n"));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisGetInfo\n"));
vboxusb_state_t *pState = NULL;
int instance = getminor((dev_t)pvArg);
@@ -950,7 +839,7 @@
return DDI_SUCCESS;
}
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisGetInfo: Failed to get device state\n"));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisGetInfo failed to get device state.\n"));
return DDI_FAILURE;
}
@@ -967,11 +856,9 @@
/**
- * Callback invoked from the VirtualBox USB Monitor driver when a VM process
- * tries to access this USB client instance.
- *
- * This determines which VM process will be allowed to open and access this USB
- * device.
+ * Callback invoked from the Monitor driver when a VM process tries to access
+ * this client instance. This determines which VM process will be allowed to
+ * open and access the USB device.
*
* @returns VBox status code.
*
@@ -980,13 +867,13 @@
* ourselves to the Monitor driver)
* @param pvReserved Reserved for future, unused.
*/
-LOCAL int vboxUsbSolarisSetConsumerCredentials(RTPROCESS Process, int Instance, void *pvReserved)
+LOCAL int vboxUSBSolarisSetConsumerCredentials(RTPROCESS Process, int Instance, void *pvReserved)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisSetConsumerCredentials: Process=%u Instance=%d\n", Process, Instance));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisSetConsumerCredentials Process=%u Instance=%d\n", Process, Instance));
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, Instance);
if (!pState)
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSetConsumerCredentials: Failed to get device state for instance %d\n", Instance));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSetConsumerCredentials failed to get device state for instance %d\n", Instance));
return VERR_INVALID_STATE;
}
@@ -997,7 +884,7 @@
pState->Process = Process;
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSetConsumerCredentials: Failed! Process %u already has client open\n",
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSetConsumerCredentials failed! Process %u already has client open.\n",
pState->Process));
rc = VERR_RESOURCE_BUSY;
}
@@ -1010,7 +897,7 @@
int VBoxUSBSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisOpen: pDev=%p fFlag=%d fType=%d pCred=%p\n", pDev, fFlag, fType, pCred));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisOpen pDev=%p fFlag=%d fType=%d pCred=%p\n", pDev, fFlag, fType, pCred));
/*
* Verify we are being opened as a character device
@@ -1025,7 +912,7 @@
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
if (!pState)
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen: Failed to get device state for instance %d\n", instance));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisOpen failed to get device state for instance %d\n", instance));
return ENXIO;
}
@@ -1037,14 +924,16 @@
if (pState->Process != RTProcSelf())
{
if (pState->Process == NIL_RTPROCESS)
- LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen: No prior information about authorized process\n"));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisOpen No prior information about authorized process.\n"));
else
- LogRel((DEVICE_NAME ": VBoxUSBSolarisOpen: Process %u is already using this device instance\n", pState->Process));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisOpen Process %u is already using this device instance.\n", pState->Process));
mutex_exit(&pState->Mtx);
return EPERM;
}
+ pState->fPoll = VBOXUSB_POLL_ON;
+
mutex_exit(&pState->Mtx);
NOREF(fFlag);
@@ -1056,18 +945,18 @@
int VBoxUSBSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisClose: Dev=%d fFlag=%d fType=%d pCred=%p\n", Dev, fFlag, fType, pCred));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisClose Dev=%d fFlag=%d fType=%d pCred=%p\n", Dev, fFlag, fType, pCred));
int instance = getminor((dev_t)Dev);
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
if (RT_UNLIKELY(!pState))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisClose: Failed to get device state for instance %d\n", instance));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisClose failed to get device state for instance %d\n", instance));
return ENXIO;
}
mutex_enter(&pState->Mtx);
- pState->fPollPending = false;
+ pState->fPoll = VBOXUSB_POLL_OFF;
pState->Process = NIL_RTPROCESS;
mutex_exit(&pState->Mtx);
@@ -1077,21 +966,21 @@
int VBoxUSBSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisRead\n"));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisRead\n"));
return ENOTSUP;
}
int VBoxUSBSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisWrite\n"));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisWrite\n"));
return ENOTSUP;
}
int VBoxUSBSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisPoll: Dev=%d fEvents=%d fAnyYet=%d pReqEvents=%p\n", Dev, fEvents, fAnyYet, pReqEvents));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisPoll Dev=%d fEvents=%d fAnyYet=%d pReqEvents=%p\n", Dev, fEvents, fAnyYet, pReqEvents));
/*
* Get the device state (one to one mapping).
@@ -1100,29 +989,37 @@
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
if (RT_UNLIKELY(!pState))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisPoll: No state data for %d\n", instance));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisPoll: no state data for %d\n", instance));
return ENXIO;
}
mutex_enter(&pState->Mtx);
/*
- * Disconnect event (POLLHUP) is invalid in "fEvents".
+ * "fEvents" HAS to be POLLIN. We won't bother to test it. The caller
+ * must always requests input events. Disconnect event (POLLHUP) is invalid in "fEvents".
*/
- if (pState->DevState == USB_DEV_DISCONNECTED)
- *pReqEvents |= POLLHUP;
- else if (pState->cLandedUrbs)
- *pReqEvents |= POLLIN;
- else
+ fEvents = 0;
+ if (pState->fPoll & VBOXUSB_POLL_DEV_UNPLUGGED)
+ {
+ fEvents |= POLLHUP;
+ pState->fPoll &= ~VBOXUSB_POLL_DEV_UNPLUGGED;
+ }
+
+ if (pState->fPoll & VBOXUSB_POLL_REAP_PENDING)
{
- *pReqEvents = 0;
- if (!fAnyYet)
+ fEvents |= POLLIN;
+ pState->fPoll &= ~VBOXUSB_POLL_REAP_PENDING;
+ }
+
+ if ( !fEvents
+ && !fAnyYet)
{
*ppPollHead = &pState->PollHead;
- pState->fPollPending = true;
- }
}
+ *pReqEvents = fEvents;
+
mutex_exit(&pState->Mtx);
return 0;
@@ -1131,13 +1028,13 @@
int VBoxUSBSolarisPower(dev_info_t *pDip, int Component, int Level)
{
- LogFunc((DEVICE_NAME ": VBoxUSBSolarisPower: pDip=%p Component=%d Level=%d\n", pDip, Component, Level));
+ LogFunc((DEVICE_NAME ":VBoxUSBSolarisPower pDip=%p Component=%d Level=%d\n", pDip, Component, Level));
int instance = ddi_get_instance(pDip);
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
if (RT_UNLIKELY(!pState))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisPower: Failed! State Gone\n"));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisPower Failed! missing state.\n"));
return DDI_FAILURE;
}
@@ -1167,7 +1064,7 @@
*/
pState->pPower->PowerLevel = USB_DEV_OS_PWR_OFF;
mutex_exit(&pState->Mtx);
- rc = USB_SUCCESS; /* usb_set_device_pwrlvl3(pDip); */
+ rc = usb_set_device_pwrlvl3(pDip);
mutex_enter(&pState->Mtx);
break;
}
@@ -1179,7 +1076,7 @@
*/
pState->pPower->PowerLevel = USB_DEV_OS_FULL_PWR;
mutex_exit(&pState->Mtx);
- rc = USB_SUCCESS; /* usb_set_device_pwrlvl0(pDip); */
+ rc = usb_set_device_pwrlvl0(pDip);
mutex_enter(&pState->Mtx);
break;
}
@@ -1189,7 +1086,7 @@
}
}
else
- Log((DEVICE_NAME ": VBoxUSBSolarisPower: USB_DEV_PWRSTATE_OK failed\n"));
+ Log((DEVICE_NAME ":USB_DEV_PWRSTATE_OK failed.\n"));
}
else
rc = USB_SUCCESS;
@@ -1210,7 +1107,7 @@
int VBoxUSBSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal)
{
- /* LogFunc((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Dev=%d Cmd=%d pArg=%p Mode=%d\n", Dev, Cmd, pArg)); */
+/* LogFunc((DEVICE_NAME ":VBoxUSBSolarisIOCtl Dev=%d Cmd=%d pArg=%p Mode=%d\n", Dev, Cmd, pArg)); */
/*
* Get the device state (one to one mapping).
@@ -1219,7 +1116,7 @@
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
if (RT_UNLIKELY(!pState))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: No state data for %d\n", instance));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisIOCtl: no state data for %d\n", instance));
return EINVAL;
}
@@ -1229,7 +1126,7 @@
VBOXUSBREQ ReqWrap;
if (IOCPARM_LEN(Cmd) != sizeof(ReqWrap))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd),
+ LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd),
sizeof(ReqWrap)));
return ENOTTY;
}
@@ -1237,19 +1134,19 @@
int rc = ddi_copyin((void *)pArg, &ReqWrap, sizeof(ReqWrap), Mode);
if (RT_UNLIKELY(rc))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d\n", pArg, Cmd, rc));
+ LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d.\n", pArg, Cmd, rc));
return EINVAL;
}
if (ReqWrap.u32Magic != VBOXUSB_MAGIC)
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Bad magic %#x; pArg=%p Cmd=%d\n", ReqWrap.u32Magic, pArg, Cmd));
+ LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: bad magic %#x; pArg=%p Cmd=%d.\n", ReqWrap.u32Magic, pArg, Cmd));
return EINVAL;
}
if (RT_UNLIKELY( ReqWrap.cbData == 0
|| ReqWrap.cbData > _1M*16))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Bad size %#x; pArg=%p Cmd=%d\n", ReqWrap.cbData, pArg, Cmd));
+ LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: bad size %#x; pArg=%p Cmd=%d.\n", ReqWrap.cbData, pArg, Cmd));
return EINVAL;
}
@@ -1259,7 +1156,7 @@
void *pvBuf = RTMemTmpAlloc(ReqWrap.cbData);
if (RT_UNLIKELY(!pvBuf))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes\n", ReqWrap.cbData));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap.cbData));
return ENOMEM;
}
@@ -1267,14 +1164,14 @@
if (RT_UNLIKELY(rc))
{
RTMemTmpFree(pvBuf);
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyin failed! pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisIOCtl: ddi_copyin failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc));
return EFAULT;
}
if (RT_UNLIKELY( ReqWrap.cbData == 0
|| pvBuf == NULL))
{
RTMemTmpFree(pvBuf);
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Invalid request! pvBuf=%p cbData=%d\n", pvBuf, ReqWrap.cbData));
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisIOCtl: invalid request pvBuf=%p cbData=%d\n", pvBuf, ReqWrap.cbData));
return EINVAL;
}
@@ -1282,13 +1179,13 @@
* Process the IOCtl.
*/
size_t cbDataOut = 0;
- rc = vboxUsbSolarisProcessIOCtl(Cmd, pState, Mode, &ReqWrap, pvBuf, &cbDataOut);
+ rc = vboxUSBSolarisProcessIOCtl(Cmd, pState, Mode, &ReqWrap, pvBuf, &cbDataOut);
ReqWrap.rc = rc;
rc = 0;
if (RT_UNLIKELY(cbDataOut > ReqWrap.cbData))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: Too much output data %d expected %d Truncating!\n", cbDataOut,
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisIOCtl: too much output data %d expected %d Truncating!\n", cbDataOut,
ReqWrap.cbData));
cbDataOut = ReqWrap.cbData;
}
@@ -1309,7 +1206,7 @@
rc = ddi_copyout(pvBuf, (void *)(uintptr_t)ReqWrap.pvDataR3, cbDataOut, Mode);
if (RT_UNLIKELY(rc))
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyout failed! pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg,
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisIOCtl: ddi_copyout failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg,
Cmd, rc));
rc = EFAULT;
}
@@ -1317,7 +1214,7 @@
}
else
{
- LogRel((DEVICE_NAME ": VBoxUSBSolarisIOCtl: ddi_copyout(1)failed! pReqWrap=%p pArg=%p Cmd=%d. rc=%d\n", &ReqWrap, pArg,
+ LogRel((DEVICE_NAME ":VBoxUSBSolarisIOCtl: ddi_copyout(1)failed; pReqWrap=%p pArg=%p Cmd=%d. rc=%d\n", &ReqWrap, pArg,
Cmd, rc));
rc = EFAULT;
}
@@ -1340,10 +1237,9 @@
* @param pvBuf Pointer to the ring-3 URB.
* @param pcbDataOut Where to store the IOCtl OUT data size.
*/
-LOCAL int vboxUsbSolarisProcessIOCtl(int iFunction, void *pvState, int Mode, PVBOXUSBREQ pUSBReq, void *pvBuf,
- size_t *pcbDataOut)
+LOCAL int vboxUSBSolarisProcessIOCtl(int iFunction, void *pvState, int Mode, PVBOXUSBREQ pUSBReq, void *pvBuf, size_t *pcbDataOut)
{
- /* LogFunc((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: iFunction=%d pvState=%p pUSBReq=%p\n", iFunction, pvState, pUSBReq)); */
+// LogFunc((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl iFunction=%d pvState=%p pUSBReq=%p\n", iFunction, pvState, pUSBReq));
AssertPtrReturn(pvState, VERR_INVALID_PARAMETER);
vboxusb_state_t *pState = (vboxusb_state_t *)pvState;
@@ -1354,13 +1250,13 @@
do { \
if (cbData < (cbMin)) \
{ \
- LogRel((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: " mnemonic ": cbData=%#zx (%zu) min is %#zx (%zu)\n", \
+ LogRel((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: " mnemonic ": cbData=%#zx (%zu) min is %#zx (%zu)\n", \
cbData, cbData, (size_t)(cbMin), (size_t)(cbMin))); \
return VERR_BUFFER_OVERFLOW; \
} \
if ((cbMin) != 0 && !VALID_PTR(pvBuf)) \
{ \
- LogRel((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: " mnemonic ": Invalid pointer %p\n", pvBuf)); \
+ LogRel((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: " mnemonic ": Invalid pointer %p\n", pvBuf)); \
return VERR_INVALID_PARAMETER; \
} \
} while (0)
@@ -1372,9 +1268,9 @@
CHECKRET_MIN_SIZE("SEND_URB", sizeof(VBOXUSBREQ_URB));
PVBOXUSBREQ_URB pUrbReq = (PVBOXUSBREQ_URB)pvBuf;
- rc = vboxUsbSolarisSendUrb(pState, pUrbReq, Mode);
+ rc = vboxUSBSolarisSendURB(pState, pUrbReq, Mode);
*pcbDataOut = 0;
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: SEND_URB returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: SEND_URB returned %d\n", rc));
break;
}
@@ -1383,9 +1279,9 @@
CHECKRET_MIN_SIZE("REAP_URB", sizeof(VBOXUSBREQ_URB));
PVBOXUSBREQ_URB pUrbReq = (PVBOXUSBREQ_URB)pvBuf;
- rc = vboxUsbSolarisReapUrb(pState, pUrbReq, Mode);
+ rc = vboxUSBSolarisReapURB(pState, pUrbReq, Mode);
*pcbDataOut = sizeof(VBOXUSBREQ_URB);
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: REAP_URB returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: REAP_URB returned %d\n", rc));
break;
}
@@ -1394,9 +1290,9 @@
CHECKRET_MIN_SIZE("CLEAR_EP", sizeof(VBOXUSBREQ_CLEAR_EP));
PVBOXUSBREQ_CLEAR_EP pClearEpReq = (PVBOXUSBREQ_CLEAR_EP)pvBuf;
- rc = vboxUsbSolarisClearEndPoint(pState, pClearEpReq->bEndpoint);
+ rc = vboxUSBSolarisClearEndPoint(pState, pClearEpReq->bEndpoint);
*pcbDataOut = 0;
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: CLEAR_EP returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: CLEAR_EP returned %d\n", rc));
break;
}
@@ -1405,9 +1301,9 @@
CHECKRET_MIN_SIZE("SET_CONFIG", sizeof(VBOXUSBREQ_SET_CONFIG));
PVBOXUSBREQ_SET_CONFIG pSetCfgReq = (PVBOXUSBREQ_SET_CONFIG)pvBuf;
- rc = vboxUsbSolarisSetConfig(pState, pSetCfgReq->bConfigValue);
+ rc = vboxUSBSolarisSetConfig(pState, pSetCfgReq->bConfigValue);
*pcbDataOut = 0;
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: SET_CONFIG returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: SET_CONFIG returned %d\n", rc));
break;
}
@@ -1416,9 +1312,9 @@
CHECKRET_MIN_SIZE("SET_INTERFACE", sizeof(VBOXUSBREQ_SET_INTERFACE));
PVBOXUSBREQ_SET_INTERFACE pSetInterfaceReq = (PVBOXUSBREQ_SET_INTERFACE)pvBuf;
- rc = vboxUsbSolarisSetInterface(pState, pSetInterfaceReq->bInterface, pSetInterfaceReq->bAlternate);
+ rc = vboxUSBSolarisSetInterface(pState, pSetInterfaceReq->bInterface, pSetInterfaceReq->bAlternate);
*pcbDataOut = 0;
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: SET_INTERFACE returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: SET_INTERFACE returned %d\n", rc));
break;
}
@@ -1427,18 +1323,9 @@
CHECKRET_MIN_SIZE("CLOSE_DEVICE", sizeof(VBOXUSBREQ_CLOSE_DEVICE));
PVBOXUSBREQ_CLOSE_DEVICE pCloseDeviceReq = (PVBOXUSBREQ_CLOSE_DEVICE)pvBuf;
- if ( pCloseDeviceReq->ResetLevel != VBOXUSB_RESET_LEVEL_REATTACH
- || (Mode & FKIOCTL))
- {
- rc = vboxUsbSolarisCloseDevice(pState, pCloseDeviceReq->ResetLevel);
- }
- else
- {
- /* Userland IOCtls are not allowed to perform a reattach of the device. */
- rc = VERR_NOT_SUPPORTED;
- }
+ rc = vboxUSBSolarisCloseDevice(pState, pCloseDeviceReq->ResetLevel);
*pcbDataOut = 0;
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: CLOSE_DEVICE returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: CLOSE_DEVICE returned %d\n", rc));
break;
}
@@ -1447,9 +1334,9 @@
CHECKRET_MIN_SIZE("ABORT_PIPE", sizeof(VBOXUSBREQ_ABORT_PIPE));
PVBOXUSBREQ_ABORT_PIPE pAbortPipeReq = (PVBOXUSBREQ_ABORT_PIPE)pvBuf;
- rc = vboxUsbSolarisAbortPipe(pState, pAbortPipeReq->bEndpoint);
+ rc = vboxUSBSolarisAbortPipe(pState, pAbortPipeReq->bEndpoint);
*pcbDataOut = 0;
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: ABORT_PIPE returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: ABORT_PIPE returned %d\n", rc));
break;
}
@@ -1458,9 +1345,9 @@
CHECKRET_MIN_SIZE("GET_CONFIG", sizeof(VBOXUSBREQ_GET_CONFIG));
PVBOXUSBREQ_GET_CONFIG pGetCfgReq = (PVBOXUSBREQ_GET_CONFIG)pvBuf;
- rc = vboxUsbSolarisGetConfig(pState, &pGetCfgReq->bConfigValue);
+ rc = vboxUSBSolarisGetConfig(pState, &pGetCfgReq->bConfigValue);
*pcbDataOut = sizeof(VBOXUSBREQ_GET_CONFIG);
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: GET_CONFIG returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: GET_CONFIG returned %d\n", rc));
break;
}
@@ -1473,13 +1360,13 @@
pGetVersionReq->u32Minor = VBOXUSB_VERSION_MINOR;
*pcbDataOut = sizeof(VBOXUSBREQ_GET_VERSION);
rc = VINF_SUCCESS;
- Log((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: GET_VERSION returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisProcessIOCtl: GET_VERSION returned %d\n", rc));
break;
}
default:
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisProcessIOCtl: Unknown request %#x\n", iFunction));
+ LogRel((DEVICE_NAME ":solarisUSBProcessIOCtl: Unknown request %#x\n", iFunction));
rc = VERR_NOT_SUPPORTED;
*pcbDataOut = 0;
break;
@@ -1492,20 +1379,20 @@
/**
- * Initializes device power management.
+ * Initialize device power management functions.
*
* @param pState The USB device instance.
*
* @returns VBox status code.
*/
-LOCAL int vboxUsbSolarisInitPower(vboxusb_state_t *pState)
+LOCAL int vboxUSBSolarisInitPower(vboxusb_state_t *pState)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisInitPower: pState=%p\n", pState));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisInitPower pState=%p\n", pState));
int rc = usb_handle_remote_wakeup(pState->pDip, USB_REMOTE_WAKEUP_ENABLE);
if (rc == USB_SUCCESS)
{
- vboxusb_power_t *pPower = RTMemAllocZ(sizeof(vboxusb_power_t));
+ vboxusb_power_t *pPower = RTMemAlloc(sizeof(vboxusb_power_t));
if (RT_LIKELY(pPower))
{
mutex_enter(&pState->Mtx);
@@ -1525,12 +1412,12 @@
if (rc != DDI_SUCCESS)
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisInitPower: Failed to raise power level usb(%#x,%#x)\n",
+ LogRel((DEVICE_NAME ":vboxUSBSolarisInitPower failed to raise power level usb(%#x,%#x).\n",
pState->pDevDesc->dev_descr->idVendor, pState->pDevDesc->dev_descr->idProduct));
}
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisInitPower: Failed to create power components\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisInitPower failed to create power components.\n"));
return VINF_SUCCESS;
}
@@ -1539,7 +1426,7 @@
}
else
{
- Log((DEVICE_NAME ": vboxUsbSolarisInitPower: Failed to enable remote wakeup, No PM!\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisInitPower failed to enable remote wakeup. No PM.\n"));
rc = VINF_SUCCESS;
}
@@ -1548,21 +1435,21 @@
/**
- * Destroys device power management.
+ * Destroy device power management functions.
*
* @param pState The USB device instance.
* @remarks Requires the device state mutex to be held.
*
* @returns VBox status code.
*/
-LOCAL void vboxUsbSolarisDestroyPower(vboxusb_state_t *pState)
+LOCAL void vboxUSBSolarisDestroyPower(vboxusb_state_t *pState)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDestroyPower: pState=%p\n", pState));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDestroyPower pState=%p\n", pState));
if (pState->pPower)
{
mutex_exit(&pState->Mtx);
- vboxUsbSolarisPowerBusy(pState);
+ vboxUSBSolarisPowerBusy(pState);
mutex_enter(&pState->Mtx);
int rc = -1;
@@ -1572,20 +1459,20 @@
mutex_exit(&pState->Mtx);
rc = pm_raise_power(pState->pDip, 0 /* component */, USB_DEV_OS_FULL_PWR);
if (rc != DDI_SUCCESS)
- Log((DEVICE_NAME ": vboxUsbSolarisDestroyPower: Raising power failed! rc=%d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisDestroyPower raising power failed! rc=%d\n", rc));
rc = usb_handle_remote_wakeup(pState->pDip, USB_REMOTE_WAKEUP_DISABLE);
if (rc != DDI_SUCCESS)
- Log((DEVICE_NAME ": vboxUsbSolarisDestroyPower: Failed to disable remote wakeup\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisDestroyPower failed to disable remote wakeup.\n"));
}
else
mutex_exit(&pState->Mtx);
rc = pm_lower_power(pState->pDip, 0 /* component */, USB_DEV_OS_PWR_OFF);
if (rc != DDI_SUCCESS)
- Log((DEVICE_NAME ": vboxUsbSolarisDestroyPower: Lowering power failed! rc=%d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisDestroyPower lowering power failed! rc=%d\n", rc));
- vboxUsbSolarisPowerIdle(pState);
+ vboxUSBSolarisPowerIdle(pState);
mutex_enter(&pState->Mtx);
RTMemFree(pState->pPower);
pState->pPower = NULL;
@@ -1594,13 +1481,13 @@
/**
- * Converts Solaris' USBA URB status to VBox's USB URB status.
+ * Convert Solaris' USBA URB status to VBox's USB URB status.
*
* @param Status Solaris USBA USB URB status.
*
* @returns VBox USB URB status.
*/
-LOCAL VUSBSTATUS vboxUsbSolarisGetUrbStatus(usb_cr_t Status)
+LOCAL inline VUSBSTATUS vboxUSBSolarisGetUrbStatus(usb_cr_t Status)
{
switch (Status)
{
@@ -1634,13 +1521,13 @@
/**
- * Converts Solaris' USBA error code to VBox's error code.
+ * Convert Solaris' USBA error code to VBox's error code.
*
* @param UsbRc Solaris USBA error code.
*
* @returns VBox error code.
*/
-static int vboxUsbSolarisToVBoxRC(int UsbRc)
+static inline int vboxUSBSolarisToVBoxRC(int UsbRc)
{
switch (UsbRc)
{
@@ -1669,13 +1556,13 @@
/**
- * Converts Solaris' USBA device state to VBox's error code.
+ * Convert Solaris' USBA device state to VBox's error code.
*
* @param uDeviceState The USB device state to convert.
*
* @returns VBox error code.
*/
-static int vboxUsbSolarisDeviceState(uint8_t uDeviceState)
+static inline int vboxUSBSolarisDeviceState(uint8_t uDeviceState)
{
switch (uDeviceState)
{
@@ -1689,13 +1576,13 @@
/**
- * Checks if the device is a USB device.
+ * Check if the device is a USB device.
*
* @param pDip Pointer to this device info. structure.
*
* @returns If this is really a USB device returns true, otherwise false.
*/
-LOCAL bool vboxUsbSolarisIsUSBDevice(dev_info_t *pDip)
+LOCAL bool vboxUSBSolarisIsUSBDevice(dev_info_t *pDip)
{
int rc = DDI_FAILURE;
@@ -1709,10 +1596,10 @@
{
while (cCompatible--)
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Compatible[%d]=%s\n", cCompatible, ppszCompatible[cCompatible]));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsUSBDevice compatible[%d]=%s\n", cCompatible, ppszCompatible[cCompatible]));
if (!strncmp(ppszCompatible[cCompatible], "usb", 3))
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Verified device as USB. pszCompatible=%s\n",
+ Log((DEVICE_NAME ":vboxUSBSolarisIsUSBDevice verified device as USB. pszCompatible=%s\n",
ppszCompatible[cCompatible]));
ddi_prop_free(ppszCompatible);
return true;
@@ -1723,7 +1610,7 @@
ppszCompatible = NULL;
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: USB property lookup failed, rc=%d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsUSBDevice USB property lookup failed. rc=%d\n", rc));
/*
* Check parent for "usb" compatible property.
@@ -1737,11 +1624,11 @@
{
while (cCompatible--)
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Parent compatible[%d]=%s\n", cCompatible,
+ Log((DEVICE_NAME ":vboxUSBSolarisIsUSBDevice parent compatible[%d]=%s\n", cCompatible,
ppszCompatible[cCompatible]));
if (!strncmp(ppszCompatible[cCompatible], "usb", 3))
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Verified device as USB. parent pszCompatible=%s\n",
+ Log((DEVICE_NAME ":vboxUSBSolarisIsUSBDevice verified device as USB. parent pszCompatible=%s\n",
ppszCompatible[cCompatible]));
ddi_prop_free(ppszCompatible);
return true;
@@ -1752,17 +1639,17 @@
ppszCompatible = NULL;
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: USB parent property lookup failed. rc=%d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsUSBDevice USB parent property lookup failed. rc=%d\n", rc));
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisIsUSBDevice: Failed to obtain parent device for property lookup\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsUSBDevice failed to obtain parent device for property lookup.\n"));
return false;
}
/**
- * Submits a URB.
+ * Submit a URB.
*
* @param pState The USB device instance.
* @param pUrbReq Pointer to the VBox USB URB.
@@ -1770,23 +1657,18 @@
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisSendUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode)
+LOCAL int vboxUSBSolarisSendURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode)
{
- int iEpIndex = VBOXUSB_GET_EP_INDEX(pUrbReq->bEndpoint);
- Assert(iEpIndex >= 0 && iEpIndex < RT_ELEMENTS(pState->aEps));
- vboxusb_ep_t *pEp = &pState->aEps[iEpIndex];
+ uchar_t EndPtIndex = usb_get_ep_index(pUrbReq->bEndpoint);
+ vboxusb_ep_t *pEp = &pState->aEps[EndPtIndex];
AssertPtrReturn(pEp, VERR_INVALID_POINTER);
- Assert(pUrbReq);
-#if 0
- LogFunc((DEVICE_NAME ": vboxUsbSolarisSendUrb: pState=%p pUrbReq=%p bEndpoint=%#x[%d] enmDir=%#x enmType=%#x "
- "cbData=%d pvData=%p\n", pState, pUrbReq, pUrbReq->bEndpoint, iEpIndex, pUrbReq->enmDir,
- pUrbReq->enmType, pUrbReq->cbData, pUrbReq->pvData));
-#endif
+ /* LogFunc((DEVICE_NAME ":vboxUSBSolarisSendUrb pState=%p pUrbReq=%p bEndpoint=%#x[%d] enmDir=%#x enmType=%#x cbData=%d pvData=%p\n",
+ pState, pUrbReq, pUrbReq->bEndpoint, EndPtIndex, pUrbReq->enmDir, pUrbReq->enmType, pUrbReq->cbData, pUrbReq->pvData)); */
if (RT_UNLIKELY(!pUrbReq->pvData))
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: Invalid request - No data\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSendUrb Invalid request. No data.\n"));
return VERR_INVALID_POINTER;
}
@@ -1802,14 +1684,14 @@
pMsg = allocb(pUrbReq->cbData, BPRI_HI);
if (RT_UNLIKELY(!pMsg))
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: Failed to allocate %u bytes\n", pUrbReq->cbData));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSendUrb: failed to allocate %d bytes\n", pUrbReq->cbData));
return VERR_NO_MEMORY;
}
rc = ddi_copyin(pUrbReq->pvData, pMsg->b_wptr, pUrbReq->cbData, Mode);
if (RT_UNLIKELY(rc))
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: ddi_copyin failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSendUrb: ddi_copyin failed! rc=%d\n", rc));
freemsg(pMsg);
return VERR_NO_MEMORY;
}
@@ -1818,20 +1700,22 @@
}
mutex_enter(&pState->Mtx);
- rc = vboxUsbSolarisDeviceState(pState->DevState);
- if (!pState->fDefaultPipeOpen) /* Required for Isoc. IN Xfers which don't Xfer through the pipe after polling starts */
+ rc = vboxUSBSolarisDeviceState(pState->DevState);
+
+ if (pState->fClosed) /* Required for Isoc. IN Xfers which don't Xfer through the pipe after polling starts */
rc = VERR_VUSB_DEVICE_NOT_ATTACHED;
+
if (RT_SUCCESS(rc))
{
/*
* Open the pipe if needed.
*/
- rc = vboxUsbSolarisOpenPipe(pState, pEp);
+ rc = vboxUSBSolarisOpenPipe(pState, pEp);
if (RT_UNLIKELY(RT_FAILURE(rc)))
{
mutex_exit(&pState->Mtx);
freemsg(pMsg);
- LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: OpenPipe failed! pState=%p pUrbReq=%p bEndpoint=%#x enmDir=%#x "
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSendUrb OpenPipe failed. pState=%p pUrbReq=%p bEndpoint=%#x enmDir=%#x "
"enmType=%#x cbData=%d pvData=%p rc=%d\n", pState, pUrbReq, pUrbReq->bEndpoint, pUrbReq->enmDir,
pUrbReq->enmType, pUrbReq->cbData, pUrbReq->pvData, rc));
return VERR_BAD_PIPE;
@@ -1842,9 +1726,9 @@
vboxusb_urb_t *pUrb = NULL;
if ( pUrbReq->enmType == VUSBXFERTYPE_ISOC
&& pUrbReq->enmDir == VUSBDIRECTION_IN)
- pUrb = vboxUsbSolarisGetIsocInUrb(pState, pUrbReq);
+ pUrb = vboxUSBSolarisGetIsocInURB(pState, pUrbReq);
else
- pUrb = vboxUsbSolarisQueueUrb(pState, pUrbReq, pMsg);
+ pUrb = vboxUSBSolarisQueueURB(pState, pUrbReq, pMsg);
if (RT_LIKELY(pUrb))
{
@@ -1852,31 +1736,30 @@
{
case VUSBXFERTYPE_MSG:
{
- rc = vboxUsbSolarisCtrlXfer(pState, pEp, pUrb);
+ rc = vboxUSBSolarisCtrlXfer(pState, pEp, pUrb);
break;
}
case VUSBXFERTYPE_BULK:
{
- rc = vboxUsbSolarisBulkXfer(pState, pEp, pUrb);
+ rc = vboxUSBSolarisBulkXfer(pState, pEp, pUrb);
break;
}
case VUSBXFERTYPE_INTR:
{
- rc = vboxUsbSolarisIntrXfer(pState, pEp, pUrb);
+ rc = vboxUSBSolarisIntrXfer(pState, pEp, pUrb);
break;
}
case VUSBXFERTYPE_ISOC:
{
- rc = vboxUsbSolarisIsocXfer(pState, pEp, pUrb);
+ rc = vboxUSBSolarisIsocXfer(pState, pEp, pUrb);
break;
}
default:
{
- LogRelMax(5, (DEVICE_NAME ": vboxUsbSolarisSendUrb: URB type unsupported %d\n", pUrb->enmType));
rc = VERR_NOT_SUPPORTED;
break;
}
@@ -1884,10 +1767,16 @@
if (RT_FAILURE(rc))
{
+ /** @todo We share the state mutex for protecting concurrent accesses to both
+ * the inflight URB list as well as pUrb->pMsg (data). Probably make this
+ * more fine grained later by having a different mutex for the URB if
+ * it's really worth the trouble. */
mutex_enter(&pState->Mtx);
+ if (pUrb->pMsg)
+ {
freemsg(pUrb->pMsg);
pUrb->pMsg = NULL;
- pMsg = NULL;
+ }
if ( pUrb->enmType == VUSBXFERTYPE_ISOC
&& pUrb->enmDir == VUSBDIRECTION_IN)
@@ -1897,26 +1786,28 @@
}
else
{
- /*
- * Xfer failed, move URB back to the free list.
- */
- list_remove(&pState->hInflightUrbs, pUrb);
- Assert(pState->cInflightUrbs > 0);
- --pState->cInflightUrbs;
-
+ pUrb->pMsg = NULL;
pUrb->enmState = VBOXUSB_URB_STATE_FREE;
- Assert(!pUrb->pMsg);
- list_insert_head(&pState->hFreeUrbs, pUrb);
- ++pState->cFreeUrbs;
}
mutex_exit(&pState->Mtx);
}
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSendUrb: Failed to queue URB\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSendUrb failed to queue URB.\n"));
rc = VERR_NO_MEMORY;
- freemsg(pMsg);
+ }
+
+ if ( RT_FAILURE(rc)
+ && pUrb)
+ {
+ if ( pUrb->enmType != VUSBXFERTYPE_ISOC
+ || pUrb->enmDir != VUSBDIRECTION_IN)
+ {
+ mutex_enter(&pState->Mtx);
+ pState->cInflightUrbs--;
+ mutex_exit(&pState->Mtx);
+ }
}
}
else
@@ -1930,7 +1821,7 @@
/**
- * Reaps a completed URB.
+ * Reap a completed/error'd URB.
*
* @param pState The USB device instance.
* @param pUrbReq Pointer to the VBox USB URB.
@@ -1938,25 +1829,20 @@
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisReapUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode)
+LOCAL int vboxUSBSolarisReapURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, int Mode)
{
- /* LogFunc((DEVICE_NAME ": vboxUsbSolarisReapUrb: pState=%p pUrbReq=%p\n", pState, pUrbReq)); */
+// LogFunc((DEVICE_NAME ":vboxUSBSolarisReapUrb pState=%p pUrbReq=%p\n", pState, pUrbReq));
AssertPtrReturn(pUrbReq, VERR_INVALID_POINTER);
int rc = VINF_SUCCESS;
mutex_enter(&pState->Mtx);
- rc = vboxUsbSolarisDeviceState(pState->DevState);
- if (!pState->fDefaultPipeOpen)
+ rc = vboxUSBSolarisDeviceState(pState->DevState);
+ if (pState->fClosed)
rc = VERR_VUSB_DEVICE_NOT_ATTACHED;
if (RT_SUCCESS(rc))
{
vboxusb_urb_t *pUrb = list_remove_head(&pState->hLandedUrbs);
- if (pUrb)
- {
- Assert(pState->cLandedUrbs > 0);
- --pState->cLandedUrbs;
- }
/*
* It is safe to access pUrb->pMsg outside the state mutex because this is from the landed URB list
@@ -1973,55 +1859,90 @@
pUrbReq->enmType = pUrb->enmType;
pUrbReq->enmDir = pUrb->enmDir;
pUrbReq->enmStatus = pUrb->enmStatus;
- pUrbReq->pvData = (void *)pUrb->pvDataR3;
- pUrbReq->cbData = pUrb->cbDataR3;
if (RT_LIKELY(pUrb->pMsg))
{
/*
- * Copy the message back into the user buffer.
+ * Chain copy the message back into the user buffer.
*/
if (RT_LIKELY(pUrb->pvDataR3 != NIL_RTR3PTR))
{
- Assert(!pUrb->pMsg->b_cont); /* We really should have a single message block always. */
- size_t cbData = RT_MIN(MBLKL(pUrb->pMsg), pUrb->cbDataR3);
+ size_t cbData = RT_MIN(msgdsize(pUrb->pMsg), pUrb->cbDataR3);
pUrbReq->cbData = cbData;
+ pUrbReq->pvData = (void *)pUrb->pvDataR3;
- if (RT_LIKELY(cbData))
+ /*
+ * Paranoia: we should have a single message block almost always.
+ */
+ if (RT_LIKELY( !pUrb->pMsg->b_cont
+ && cbData))
{
rc = ddi_copyout(pUrb->pMsg->b_rptr, (void *)pUrbReq->pvData, cbData, Mode);
if (RT_UNLIKELY(rc))
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisReapUrb: ddi_copyout failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisReapUrb ddi_copyout failed! rc=%d\n", rc));
+ pUrbReq->enmStatus = VUSBSTATUS_INVALID;
+ }
+ }
+ else
+ {
+ RTR3PTR pvDataR3 = pUrb->pvDataR3;
+ mblk_t *pMsg = pUrb->pMsg;
+ while (pMsg)
+ {
+ size_t cbMsg = MBLKL(pMsg);
+ if (cbMsg > 0)
+ {
+ rc = ddi_copyout(pMsg->b_rptr, (void *)pvDataR3, cbMsg, Mode);
+ if (RT_UNLIKELY(rc != 0))
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisReapUrb ddi_copyout (2) failed! rc=%d\n", rc));
pUrbReq->enmStatus = VUSBSTATUS_INVALID;
+ break;
+ }
+ }
+
+ pMsg = pMsg->b_cont;
+ pvDataR3 += cbMsg;
+ if ((pvDataR3 - pUrb->pvDataR3) >= cbData)
+ break;
}
}
- Log((DEVICE_NAME ": vboxUsbSolarisReapUrb: pvUrbR3=%p pvDataR3=%p cbData=%d\n", pUrbReq->pvUrbR3,
+ Log((DEVICE_NAME ":vboxUSBSolarisReapUrb pvUrbR3=%p pvDataR3=%p cbData=%d\n", pUrbReq->pvUrbR3,
pUrbReq->pvData, pUrbReq->cbData));
}
else
{
pUrbReq->cbData = 0;
rc = VERR_INVALID_POINTER;
- LogRel((DEVICE_NAME ": vboxUsbSolarisReapUrb: Missing pvDataR3!!\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisReapUrb missing pvDataR3!!\n"));
}
/*
- * Free buffer allocated in vboxUsbSolarisSendUrb or vboxUsbSolaris[Ctrl|Bulk|Intr]Xfer().
+ * Free buffer allocated in VBOXUSB_IOCTL_SEND_URB.
*/
freemsg(pUrb->pMsg);
pUrb->pMsg = NULL;
}
else
{
- if ( pUrb->enmType == VUSBXFERTYPE_ISOC
- && pUrb->enmDir == VUSBDIRECTION_IN)
+ if (pUrb->enmType == VUSBXFERTYPE_ISOC)
+ {
+ if (pUrb->enmDir == VUSBDIRECTION_OUT)
+ pUrbReq->cbData = pUrb->cbDataR3;
+ else
{
pUrbReq->enmStatus = VUSBSTATUS_INVALID;
pUrbReq->cbData = 0;
}
}
+ else
+ {
+ Log((DEVICE_NAME ":vboxUSBSolarisReapUrb missing message.\n"));
+ pUrbReq->cbData = 0;
+ }
+ }
/*
* Copy Isoc packet descriptors.
@@ -2048,25 +1969,18 @@
if (pUrb)
{
/*
- * Add URB back to the free list.
+ * Add URB back to the head of the free/inflight list.
*/
- Assert(!pUrb->pMsg);
pUrb->cbDataR3 = 0;
pUrb->pvDataR3 = NIL_RTR3PTR;
pUrb->enmState = VBOXUSB_URB_STATE_FREE;
mutex_enter(&pState->Mtx);
- list_insert_head(&pState->hFreeUrbs, pUrb);
- ++pState->cFreeUrbs;
+ list_insert_head(&pState->hUrbs, pUrb);
mutex_exit(&pState->Mtx);
}
}
else
- {
pUrbReq->pvUrbR3 = NULL;
- pUrbReq->cbData = 0;
- pUrbReq->pvData = NULL;
- pUrbReq->enmStatus = VUSBSTATUS_INVALID;
- }
}
else
mutex_exit(&pState->Mtx);
@@ -2076,24 +1990,26 @@
/**
- * Clears a pipe (CLEAR_FEATURE).
+ * Clear a pipe (CLEAR_FEATURE).
*
* @param pState The USB device instance.
* @param bEndpoint The Endpoint address.
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisClearEndPoint(vboxusb_state_t *pState, uint8_t bEndpoint)
+LOCAL int vboxUSBSolarisClearEndPoint(vboxusb_state_t *pState, uint8_t bEndpoint)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: pState=%p bEndpoint=%#x\n", pState, bEndpoint));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisClearEndPoint pState=%p bEndpoint=%#x\n", pState, bEndpoint));
+ /*
+ * Serialize access: single threaded per Endpoint, one request at a time.
+ */
mutex_enter(&pState->Mtx);
- int rc = vboxUsbSolarisDeviceState(pState->DevState);
+ int rc = vboxUSBSolarisDeviceState(pState->DevState);
if (RT_SUCCESS(rc))
{
- int iEpIndex = VBOXUSB_GET_EP_INDEX(bEndpoint);
- Assert(iEpIndex >= 0 && iEpIndex < RT_ELEMENTS(pState->aEps));
- vboxusb_ep_t *pEp = &pState->aEps[iEpIndex];
+ uchar_t EndPtIndex = usb_get_ep_index(bEndpoint);
+ vboxusb_ep_t *pEp = &pState->aEps[EndPtIndex];
if (RT_LIKELY(pEp))
{
/*
@@ -2102,7 +2018,15 @@
if (pEp->pPipe)
{
mutex_exit(&pState->Mtx);
-
+#if 0
+ /*
+ * Asynchronous clear pipe.
+ */
+ rc = usb_clr_feature(pState->pDip, USB_DEV_REQ_RCPT_EP, USB_EP_HALT, bEndpoint,
+ USB_FLAGS_NOSLEEP, /* Asynchronous */
+ NULL, /* Completion callback */
+ NULL); /* Exception callback */
+#endif
/*
* Synchronous reset pipe.
*/
@@ -2113,25 +2037,26 @@
mutex_enter(&pState->Mtx);
- Log((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: bEndpoint=%#x[%d] returns %d\n", bEndpoint, iEpIndex, rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisClearEndPoint bEndpoint=%#x[%d] returns %d\n", bEndpoint, EndPtIndex, rc));
rc = VINF_SUCCESS;
}
else
{
- Log((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: Not opened to be cleared. Faking success. bEndpoint=%#x\n",
+ Log((DEVICE_NAME ":vboxUSBSolarisClearEndPoint not opened to be cleared. Faking success. bEndpoint=%#x.\n",
bEndpoint));
rc = VINF_SUCCESS;
}
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: Endpoint missing! bEndpoint=%#x[%d]\n", bEndpoint, iEpIndex));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisClearEndPoint Endpoint missing!! bEndpoint=%#x EndPtIndex=%d.\n", bEndpoint,
+ EndPtIndex));
rc = VERR_GENERAL_FAILURE;
}
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisClearEndPoint: Device not online, state=%d\n", pState->DevState));
+ Log((DEVICE_NAME ":vboxUSBSolarisClearEndPoint device state=%d not online.\n", pState->DevState));
mutex_exit(&pState->Mtx);
return rc;
@@ -2139,26 +2064,28 @@
/**
- * Sets configuration (SET_CONFIGURATION)
+ * Set configuration (SET_CONFIGURATION)
*
* @param pState The USB device instance.
- * @param bConfig The Configuration.
+ * @param bCfgValue The Configuration value.
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisSetConfig(vboxusb_state_t *pState, uint8_t bConfig)
+LOCAL int vboxUSBSolarisSetConfig(vboxusb_state_t *pState, uint8_t bCfgValue)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisSetConfig: pState=%p bConfig=%u\n", pState, bConfig));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisSetConfig pState=%p bCfgValue=%#x\n", pState, bCfgValue));
+ /*
+ * Serialize access: single threaded per Endpoint, one request at a time.
+ */
mutex_enter(&pState->Mtx);
- int rc = vboxUsbSolarisDeviceState(pState->DevState);
+ int rc = vboxUSBSolarisDeviceState(pState->DevState);
if (RT_SUCCESS(rc))
{
- vboxUsbSolarisCloseAllPipes(pState, false /* ControlPipe */);
- int iCfgIndex = vboxUsbSolarisGetConfigIndex(pState, bConfig);
+ vboxUSBSolarisCloseAllPipes(pState, false /* ControlPipe */);
+ int iCfgIndex = vboxUSBSolarisGetConfigIndex(pState, bCfgValue);
- if ( iCfgIndex >= 0
- && iCfgIndex < pState->pDevDesc->dev_n_cfg)
+ if (iCfgIndex >= 0)
{
/*
* Switch Config synchronously.
@@ -2169,21 +2096,21 @@
if (rc == USB_SUCCESS)
{
- int rc2 = vboxUsbSolarisInitEpsForCfg(pState);
- AssertRC(rc2); NOREF(rc2);
+ pState->fRestoreCfg = true;
+ vboxUSBSolarisInitEndPointsForConfig(pState, iCfgIndex);
rc = VINF_SUCCESS;
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSetConfig: usb_set_cfg failed for iCfgIndex=%#x bConfig=%u rc=%d\n",
- iCfgIndex, bConfig, rc));
- rc = vboxUsbSolarisToVBoxRC(rc);
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSetConfig usb_set_cfg failed for iCfgIndex=%#x bCfgValue=%#x rc=%d\n",
+ iCfgIndex, bCfgValue, rc));
+ rc = vboxUSBSolarisToVBoxRC(rc);
}
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSetConfig: Invalid iCfgIndex=%d bConfig=%u\n", iCfgIndex, bConfig));
- rc = VERR_OUT_OF_RANGE;
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSetConfig invalid iCfgIndex=%d bCfgValue=%#x\n", iCfgIndex, bCfgValue));
+ rc = VERR_INVALID_HANDLE;
}
}
@@ -2194,74 +2121,95 @@
/**
- * Gets configuration (GET_CONFIGURATION)
+ * Get configuration (GET_CONFIGURATION)
*
* @param pState The USB device instance.
- * @param pbConfig Where to store the Configuration.
+ * @param pCfgValue Where to store the configuration value.
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisGetConfig(vboxusb_state_t *pState, uint8_t *pbConfig)
+LOCAL int vboxUSBSolarisGetConfig(vboxusb_state_t *pState, uint8_t *pCfgValue)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisGetConfig: pState=%p pbConfig=%p\n", pState, pbConfig));
- AssertPtrReturn(pbConfig, VERR_INVALID_POINTER);
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisGetConfig pState=%p pCfgValue=%p\n", pState, pCfgValue));
+ AssertPtrReturn(pCfgValue, VERR_INVALID_POINTER);
+
+ /*
+ * Solaris keeps the currently active configuration for the first time. Thus for the first request
+ * we simply pass the cached configuration back to the user.
+ */
+ if (!pState->fGetCfgReqDone)
+ {
+ pState->fGetCfgReqDone = true;
+ AssertPtrReturn(pState->pDevDesc, VERR_GENERAL_FAILURE);
+ usb_cfg_data_t *pCurrCfg = pState->pDevDesc->dev_curr_cfg;
+ if (pCurrCfg)
+ {
+ *pCfgValue = pCurrCfg->cfg_descr.bConfigurationValue;
+ Log((DEVICE_NAME ":vboxUSBSolarisGetConfig cached config returned. CfgValue=%d\n", *pCfgValue));
+ return VINF_SUCCESS;
+ }
+ }
/*
* Get Config synchronously.
*/
- uint_t bConfig;
- int rc = usb_get_cfg(pState->pDip, &bConfig, USB_FLAGS_SLEEP);
+ uint_t bCfgValue;
+ int rc = usb_get_cfg(pState->pDip, &bCfgValue, USB_FLAGS_SLEEP);
if (RT_LIKELY(rc == USB_SUCCESS))
{
- *pbConfig = bConfig;
+ *pCfgValue = bCfgValue;
rc = VINF_SUCCESS;
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisGetConfig: Failed, rc=%d\n", rc));
- rc = vboxUsbSolarisToVBoxRC(rc);
+ LogRel((DEVICE_NAME ":vboxUSBSolarisGetConfig failed. rc=%d\n", rc));
+ rc = vboxUSBSolarisToVBoxRC(rc);
}
- Log((DEVICE_NAME ": vboxUsbSolarisGetConfig: Returns %d bConfig=%u\n", rc, *pbConfig));
+ Log((DEVICE_NAME ":vboxUSBSolarisGetConfig returns %d CfgValue=%d\n", rc, *pCfgValue));
return rc;
}
/**
- * Sets interface (SET_INTERFACE) and alternate.
+ * Set interface (SET_INTERFACE)
*
* @param pState The USB device instance.
- * @param bIf The Interface.
- * @param bAlt The Alternate setting.
+ * @param uInterface The Interface number.
+ * @param uAlt The Alternate setting number.
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisSetInterface(vboxusb_state_t *pState, uint8_t bIf, uint8_t bAlt)
+LOCAL int vboxUSBSolarisSetInterface(vboxusb_state_t *pState, uint8_t uInterface, uint8_t uAlt)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisSetInterface: pState=%p bIf=%#x bAlt=%#x\n", pState, bIf, bAlt));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisSetInterface pState=%p uInterface=%#x uAlt=%#x\n", pState, uInterface, uAlt));
+ /*
+ * Serialize access: single threaded per Endpoint, one request at a time.
+ */
mutex_enter(&pState->Mtx);
- int rc = vboxUsbSolarisDeviceState(pState->DevState);
+ int rc = vboxUSBSolarisDeviceState(pState->DevState);
if (RT_SUCCESS(rc))
{
+ vboxUSBSolarisCloseAllPipes(pState, false /* ControlPipe */);
+
/*
* Set Interface & Alt setting synchronously.
*/
mutex_exit(&pState->Mtx);
- rc = usb_set_alt_if(pState->pDip, bIf, bAlt, USB_FLAGS_SLEEP, NULL /* callback */, NULL /* callback data */);
+ rc = usb_set_alt_if(pState->pDip, uInterface, uAlt, USB_FLAGS_SLEEP, NULL /* callback */, NULL /* callback data */);
mutex_enter(&pState->Mtx);
if (rc == USB_SUCCESS)
{
- Log((DEVICE_NAME ": vboxUsbSolarisSetInterface: Success, bIf=%#x bAlt=%#x\n", bIf, bAlt, rc));
- int rc2 = vboxUsbSolarisInitEpsForIfAlt(pState, bIf, bAlt);
- AssertRC(rc2); NOREF(rc2);
+ vboxUSBSolarisInitEndPointsForInterfaceAlt(pState, uInterface, uAlt);
rc = VINF_SUCCESS;
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisSetInterface: usb_set_alt_if failed for bIf=%#x bAlt=%#x rc=%d\n", bIf, bAlt, rc));
- rc = vboxUsbSolarisToVBoxRC(rc);
+ LogRel((DEVICE_NAME ":vboxUSBSolarisSetInterface usb_set_alt_if failed for uInterface=%#x bAlt=%#x rc=%d\n",
+ uInterface, uAlt, rc));
+ rc = vboxUSBSolarisToVBoxRC(rc);
}
}
@@ -2272,24 +2220,31 @@
/**
- * Closes the USB device and optionally resets it.
+ * Close the USB device and reset it if required.
*
* @param pState The USB device instance.
* @param enmReset The reset level.
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisCloseDevice(vboxusb_state_t *pState, VBOXUSB_RESET_LEVEL enmReset)
+LOCAL int vboxUSBSolarisCloseDevice(vboxusb_state_t *pState, VBOXUSB_RESET_LEVEL enmReset)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisCloseDevice: pState=%p enmReset=%d\n", pState, enmReset));
+ Log((DEVICE_NAME ":vboxUSBSolarisCloseDevice pState=%p enmReset=%d\n", pState, enmReset));
+ /*
+ * Serialize access: single threaded per Endpoint, one request at a time.
+ */
mutex_enter(&pState->Mtx);
- int rc = vboxUsbSolarisDeviceState(pState->DevState);
+ int rc = vboxUSBSolarisDeviceState(pState->DevState);
if (enmReset == VBOXUSB_RESET_LEVEL_CLOSE)
- vboxUsbSolarisCloseAllPipes(pState, true /* ControlPipe */);
+ {
+ vboxUSBSolarisCloseAllPipes(pState, true /* ControlPipe */);
+ pState->fClosed = true;
+ }
else
- vboxUsbSolarisCloseAllPipes(pState, false /* ControlPipe */);
+ vboxUSBSolarisCloseAllPipes(pState, false /* ControlPipe */);
+
mutex_exit(&pState->Mtx);
@@ -2310,128 +2265,140 @@
break;
}
- rc = vboxUsbSolarisToVBoxRC(rc);
+ rc = vboxUSBSolarisToVBoxRC(rc);
}
- Log((DEVICE_NAME ": vboxUsbSolarisCloseDevice: Returns %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisCloseDevice returns %d\n", rc));
return rc;
}
/**
- * Aborts pending requests and reset the pipe.
+ * Abort pending requests and reset the pipe.
*
* @param pState The USB device instance.
* @param bEndpoint The Endpoint address.
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisAbortPipe(vboxusb_state_t *pState, uint8_t bEndpoint)
+LOCAL int vboxUSBSolarisAbortPipe(vboxusb_state_t *pState, uint8_t bEndpoint)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisAbortPipe: pState=%p bEndpoint=%#x\n", pState, bEndpoint));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisAbortPipe pState=%p bEndpoint=%#x\n", pState, bEndpoint));
+ /*
+ * Serialize access: single threaded per Endpoint, one request at a time.
+ */
mutex_enter(&pState->Mtx);
- int rc = vboxUsbSolarisDeviceState(pState->DevState);
+ int rc = vboxUSBSolarisDeviceState(pState->DevState);
if (RT_SUCCESS(rc))
{
- int iEpIndex = VBOXUSB_GET_EP_INDEX(bEndpoint);
- Assert(iEpIndex >= 0 && iEpIndex < RT_ELEMENTS(pState->aEps));
- vboxusb_ep_t *pEp = &pState->aEps[iEpIndex];
+ uchar_t EndPtIndex = usb_get_ep_index(bEndpoint);
+ vboxusb_ep_t *pEp = &pState->aEps[EndPtIndex];
if (RT_LIKELY(pEp))
{
if (pEp->pPipe)
{
/*
- * Aborting requests not supported for the default control pipe.
+ * Default Endpoint; aborting requests not supported, fake success.
*/
if ((pEp->EpDesc.bEndpointAddress & USB_EP_NUM_MASK) == 0)
{
mutex_exit(&pState->Mtx);
- LogRel((DEVICE_NAME ": vboxUsbSolarisAbortPipe: Cannot reset default control pipe\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisAbortPipe Cannot reset control pipe.\n"));
return VERR_NOT_SUPPORTED;
}
+ /*
+ * Serialize access: single threaded per Endpoint, one request at a time.
+ */
mutex_exit(&pState->Mtx);
usb_pipe_reset(pState->pDip, pEp->pPipe,
USB_FLAGS_SLEEP, /* Synchronous */
NULL, /* Completion callback */
- NULL); /* Callback's parameter */
+ NULL); /* Callback data */
/*
* Allow pending async requests to complete.
*/
- /** @todo this is most likely not required. */
rc = usb_pipe_drain_reqs(pState->pDip, pEp->pPipe,
USB_FLAGS_SLEEP, /* Synchronous */
5, /* Timeout (seconds) */
NULL, /* Completion callback */
- NULL); /* Callback's parameter */
+ NULL); /* Callback data*/
mutex_enter(&pState->Mtx);
- Log((DEVICE_NAME ": vboxUsbSolarisAbortPipe: usb_pipe_drain_reqs returns %d\n", rc));
- rc = vboxUsbSolarisToVBoxRC(rc);
+ Log((DEVICE_NAME ":usb_pipe_drain_reqs returns %d\n", rc));
+ rc = vboxUSBSolarisToVBoxRC(rc);
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisAbortPipe: pipe not open. bEndpoint=%#x\n", bEndpoint));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisAbortPipe pipe not open. bEndpoint=%#x\n", bEndpoint));
rc = VERR_PIPE_IO_ERROR;
}
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisAbortPipe: Invalid pipe bEndpoint=%#x[%d]\n", bEndpoint, iEpIndex));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisAbortPipe invalid pipe index %d bEndpoint=%#x\n", EndPtIndex, bEndpoint));
rc = VERR_INVALID_HANDLE;
}
}
mutex_exit(&pState->Mtx);
- LogFunc((DEVICE_NAME ": vboxUsbSolarisAbortPipe: Returns %d\n", rc));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisAbortPipe returns %d\n", rc));
return rc;
}
/**
- * Initializes an Endpoint.
+ * Initialize an endpoint.
*
* @param pState The USB device instance.
- * @param pEpData The Endpoint data (NULL implies the default
- * endpoint).
+ * @param pEpData The Endpoint data.
+ * @param uCfgValue The Configuration value.
+ * @param uInterface The Interface.
+ * @param uAlt The Alternate setting.
*
* @returns VBox error code.
*/
-LOCAL int vboxUsbSolarisInitEp(vboxusb_state_t *pState, usb_ep_data_t *pEpData)
+LOCAL int vboxUSBSolarisInitEndPoint(vboxusb_state_t *pState, usb_ep_data_t *pEpData, uchar_t uCfgValue,
+ uchar_t uInterface, uchar_t uAlt)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisInitEp: pState=%p pEpData=%p", pState, pEpData));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisInitEndPoint pState=%p pEpData=%p CfgVal=%d Iface=%d Alt=%d", pState,
+ pEpData, uCfgValue, uInterface, uAlt));
/*
* Is this the default endpoint?
*/
usb_ep_descr_t *pEpDesc = NULL;
vboxusb_ep_t *pEp = NULL;
- int iEpIndex;
+ int EpIndex = 0;
if (!pEpData)
{
- iEpIndex = 0;
+ EpIndex = 0;
pEpDesc = &g_VBoxUSBSolarisDefaultEpDesc;
}
else
{
- iEpIndex = VBOXUSB_GET_EP_INDEX(pEpData->ep_descr.bEndpointAddress);
- pEpDesc = (usb_ep_descr_t *)((uint8_t *)pEpData + g_offUsbEpDataDescr);
+ EpIndex = usb_get_ep_index(pEpData->ep_descr.bEndpointAddress);
+ pEpDesc = &pEpData->ep_descr;
}
- Assert(iEpIndex >= 0 && iEpIndex < RT_ELEMENTS(pState->aEps));
- pEp = &pState->aEps[iEpIndex];
+ pEp = &pState->aEps[EpIndex];
+ AssertRelease(pEp);
/*
- * Initialize the endpoint.
+ * Initialize the endpoint data structure.
*/
pEp->EpDesc = *pEpDesc;
- if (!pEp->fInitialized)
+ pEp->uCfgValue = uCfgValue;
+ pEp->uInterface = uInterface;
+ pEp->uAlt = uAlt;
+ if (pEp->fInitialized != VBOXUSB_EP_INITIALIZED)
{
pEp->pPipe = NULL;
+ pEp->EpState = VBOXUSB_EP_STATE_CLOSED;
bzero(&pEp->PipePolicy, sizeof(pEp->PipePolicy));
pEp->PipePolicy.pp_max_async_reqs = VBOXUSB_MAX_PIPE_ASYNC_REQS;
pEp->fIsocPolling = false;
@@ -2440,63 +2407,87 @@
list_create(&pEp->hIsocInLandedReqs, sizeof(vboxusb_isoc_req_t), offsetof(vboxusb_isoc_req_t, hListLink));
pEp->cbIsocInLandedReqs = 0;
pEp->cbMaxIsocData = 0;
- pEp->fInitialized = true;
+ pEp->fInitialized = VBOXUSB_EP_INITIALIZED;
}
-
- Log((DEVICE_NAME ": vboxUsbSolarisInitEp: Success, %s[%2d] %s %s bEndpoint=%#x\n", !pEpData ? "Default " : "Endpoint",
- iEpIndex, vboxUsbSolarisEpType(pEp), vboxUsbSolarisEpDir(pEp), pEp->EpDesc.bEndpointAddress));
+ Log((DEVICE_NAME ":vboxUSBSolarisInitEndPoint done. %s:[%d] bEndpoint=%#x\n", !pEpData ? "Default " : "Endpoint",
+ EpIndex, pEp->EpDesc.bEndpointAddress));
return VINF_SUCCESS;
}
/**
- * Initializes Endpoints for the current configuration, all interfaces and
- * alternate setting 0 for each interface.
+ * Initialize all Endpoint structures.
*
* @param pState The USB device instance.
*
* @returns VBox status code.
*/
-LOCAL int vboxUsbSolarisInitEpsForCfg(vboxusb_state_t *pState)
+LOCAL int vboxUSBSolarisInitAllEndPoints(vboxusb_state_t *pState)
{
- uint_t uCfgIndex = usb_get_current_cfgidx(pState->pDip);
- if (uCfgIndex >= pState->pDevDesc->dev_n_cfg)
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisInitAllEndPoints pState=%p\n", pState));
+
+ /*
+ * Initialize all Endpoints for all Alternate settings of all Interfaces of all Configs.
+ */
+ int rc = vboxUSBSolarisInitEndPoint(pState, NULL /* pEp */, 0 /* uCfgValue */, 0 /* uInterface */, 0 /* uAlt */);
+
+ if (RT_SUCCESS(rc))
+ {
+ /*
+ * Initialize all Endpoints for all Alternate settings of all Interfaces of all Configs.
+ */
+ for (uchar_t uCfgIndex = 0; uCfgIndex < pState->pDevDesc->dev_n_cfg; uCfgIndex++)
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisInitEpsForCfg: Invalid current config index %u\n", uCfgIndex));
- return VERR_OUT_OF_RANGE;
+ rc = vboxUSBSolarisInitEndPointsForConfig(pState, uCfgIndex);
+ if (RT_FAILURE(rc))
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisInitAllEndPoints: vboxUSBSolarisInitEndPoints uCfgIndex=%d failed. rc=%d\n",
+ uCfgIndex, rc));
+ return rc;
+ }
}
+ }
+ else
+ LogRel((DEVICE_NAME ":vboxUSBSolarisInitAllEndPoints default Endpoint initialization failed!\n"));
- usb_cfg_data_t *pConfig = &pState->pDevDesc->dev_cfg[uCfgIndex];
- uchar_t bConfig = pConfig->cfg_descr.bConfigurationValue;
+ return rc;
+}
- LogFunc((DEVICE_NAME ": vboxUsbSolarisInitEpsForCfg: pState=%p bConfig=%u uCfgIndex=%u\n", pState, bConfig, uCfgIndex));
- const uint_t cIfs = pConfig->cfg_n_if;
- for (uchar_t uIf = 0; uIf < cIfs; uIf++)
- {
- usb_if_data_t *pIf = &pConfig->cfg_if[uIf];
- const uint_t cAlts = pIf->if_n_alt;
- for (uchar_t uAlt = 0; uAlt < cAlts; uAlt++)
+/**
+ * Initialize Endpoints structures for the given Config.
+ *
+ * @param pState The USB device instance.
+ * @param uCfgIndex The current Config. index.
+ *
+ * @returns VBox status code.
+ */
+LOCAL int vboxUSBSolarisInitEndPointsForConfig(vboxusb_state_t *pState, uint8_t uCfgIndex)
+{
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForConfig pState=%p uCfgIndex=%d\n", pState, uCfgIndex));
+ usb_cfg_data_t *pConfig = &pState->pDevDesc->dev_cfg[uCfgIndex];
+ uchar_t uCfgValue = pConfig->cfg_descr.bConfigurationValue;
+
+ for (uchar_t uInterface = 0; uInterface < pConfig->cfg_n_if; uInterface++)
{
- usb_alt_if_data_t *pAlt = &pIf->if_alt[uAlt];
- if (pAlt->altif_descr.bAlternateSetting == 0) /* Refer USB 2.0 spec 9.6.5 "Interface" */
+ usb_if_data_t *pInterface = &pConfig->cfg_if[uInterface];
+
+ for (uchar_t uAlt = 0; uAlt < pInterface->if_n_alt; uAlt++)
{
- const uint_t cEps = pAlt->altif_n_ep;
- for (uchar_t uEp = 0; uEp < cEps; uEp++)
+ usb_alt_if_data_t *pAlt = &pInterface->if_alt[uAlt];
+
+ for (uchar_t uEp = 0; uEp < pAlt->altif_n_ep; uEp++)
{
- uint8_t *pbEpData = (uint8_t *)&pAlt->altif_ep[0];
- usb_ep_data_t *pEpData = (usb_ep_data_t *)(pbEpData + uEp * g_cbUsbEpData);
- int rc = vboxUsbSolarisInitEp(pState, pEpData);
+ usb_ep_data_t *pEpData = &pAlt->altif_ep[uEp];
+
+ int rc = vboxUSBSolarisInitEndPoint(pState, pEpData, uCfgValue, uInterface, uAlt);
if (RT_FAILURE(rc))
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisInitEpsForCfg: Failed to init endpoint! "
- "bConfig=%u bIf=%#x bAlt=%#x\n", bConfig, pAlt->altif_descr.bInterfaceNumber,
- pAlt->altif_descr.bAlternateSetting));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForConfig: vboxUSBSolarisInitEndPoint failed! pEp=%p "
+ "uCfgValue=%u uCfgIndex=%u uInterface=%u, uAlt=%u\n", uCfgValue, uCfgIndex, uInterface, uAlt));
return rc;
}
}
- break; /* move on to next interface. */
- }
}
}
return VINF_SUCCESS;
@@ -2504,95 +2495,104 @@
/**
- * Initializes Endpoints for the given Interface & Alternate setting.
+ * Initialize Endpoints structures for the given Interface & Alternate setting.
*
* @param pState The USB device instance.
- * @param bIf The Interface.
- * @param bAlt The Alterate.
+ * @param uInterface The interface being switched to.
+ * @param uAlt The alt being switched to.
*
* @returns VBox status code.
*/
-LOCAL int vboxUsbSolarisInitEpsForIfAlt(vboxusb_state_t *pState, uint8_t bIf, uint8_t bAlt)
+LOCAL int vboxUSBSolarisInitEndPointsForInterfaceAlt(vboxusb_state_t *pState, uint8_t uInterface, uint8_t uAlt)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisInitEpsForIfAlt: pState=%p bIf=%d uAlt=%d\n", pState, bIf, bAlt));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt pState=%p uInterface=%d uAlt=%d\n", pState, uInterface,
+ uAlt));
/* Doesn't hurt to be paranoid */
uint_t uCfgIndex = usb_get_current_cfgidx(pState->pDip);
- if (uCfgIndex >= pState->pDevDesc->dev_n_cfg)
+ if (RT_UNLIKELY(uCfgIndex >= pState->pDevDesc->dev_n_cfg))
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisInitEpsForIfAlt: Invalid current config index %d\n", uCfgIndex));
- return VERR_OUT_OF_RANGE;
+ LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt invalid current config index %d\n", uCfgIndex));
+ return VERR_GENERAL_FAILURE;
}
usb_cfg_data_t *pConfig = &pState->pDevDesc->dev_cfg[uCfgIndex];
- for (uchar_t uIf = 0; uIf < pConfig->cfg_n_if; uIf++)
- {
- usb_if_data_t *pInterface = &pConfig->cfg_if[uIf];
- const uint_t cAlts = pInterface->if_n_alt;
- for (uchar_t uAlt = 0; uAlt < cAlts; uAlt++)
+ uchar_t uCfgValue = pConfig->cfg_descr.bConfigurationValue;
+ usb_if_data_t *pInterface = &pConfig->cfg_if[uInterface];
+
+ int rc = VINF_SUCCESS;
+ if (RT_LIKELY(pInterface))
{
usb_alt_if_data_t *pAlt = &pInterface->if_alt[uAlt];
- if ( pAlt->altif_descr.bInterfaceNumber == bIf
- && pAlt->altif_descr.bAlternateSetting == bAlt)
+ if (RT_LIKELY(pAlt))
{
- const uint_t cEps = pAlt->altif_n_ep;
- for (uchar_t uEp = 0; uEp < cEps; uEp++)
+ for (uchar_t uEp = 0; uEp < pAlt->altif_n_ep; uEp++)
{
- uint8_t *pbEpData = (uint8_t *)&pAlt->altif_ep[0];
- usb_ep_data_t *pEpData = (usb_ep_data_t *)(pbEpData + uEp * g_cbUsbEpData);
- int rc = vboxUsbSolarisInitEp(pState, pEpData);
+ usb_ep_data_t *pEpData = &pAlt->altif_ep[uEp];
+ rc = vboxUSBSolarisInitEndPoint(pState, pEpData, uCfgValue, uInterface, uAlt);
if (RT_FAILURE(rc))
{
- uint8_t bCfgValue = pConfig->cfg_descr.bConfigurationValue;
- LogRel((DEVICE_NAME ": vboxUsbSolarisInitEpsForIfAlt: Failed to init endpoint! "
- "bCfgValue=%u bIf=%#x bAlt=%#x\n", bCfgValue, bIf, bAlt));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt: vboxUSBSolarisInitEndPoint failed! pEp=%p "
+ "uCfgValue=%u uCfgIndex=%u uInterface=%u, uAlt=%u\n", uCfgValue, uCfgIndex, uInterface, uAlt));
return rc;
}
}
- return VINF_SUCCESS;
+ }
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt missing alternate.\n"));
+ rc = VERR_INVALID_POINTER;
}
}
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt missing interface.\n"));
+ rc = VERR_INVALID_POINTER;
}
- return VERR_NOT_FOUND;
+
+ Log((DEVICE_NAME ":vboxUSBSolarisInitEndPointsForInterfaceAlt returns %d\n", rc));
+ return rc;
}
/**
- * Destroys all Endpoints.
+ * Destroy all Endpoint Xfer structures.
*
* @param pState The USB device instance.
- *
* @remarks Requires the state mutex to be held.
* Call only from Detach() or similar as callbacks
*/
-LOCAL void vboxUsbSolarisDestroyAllEps(vboxusb_state_t *pState)
+LOCAL void vboxUSBSolarisDestroyAllEndPoints(vboxusb_state_t *pState)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDestroyAllEps: pState=%p\n", pState));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDestroyAllEndPoints pState=%p\n", pState));
Assert(mutex_owned(&pState->Mtx));
for (unsigned i = 0; i < VBOXUSB_MAX_ENDPOINTS; i++)
{
vboxusb_ep_t *pEp = &pState->aEps[i];
- if (pEp->fInitialized)
- vboxUsbSolarisDestroyEp(pState, pEp);
+ if (pEp)
+ {
+ vboxUSBSolarisDestroyEndPoint(pState, pEp);
+ pEp = NULL;
+ }
}
}
/**
- * Destroys an Endpoint.
+ * Destroy an Endpoint.
*
* @param pState The USB device instance.
* @param pEp The Endpoint.
- *
* @remarks Requires the state mutex to be held.
*/
-LOCAL void vboxUsbSolarisDestroyEp(vboxusb_state_t *pState, vboxusb_ep_t *pEp)
+LOCAL void vboxUSBSolarisDestroyEndPoint(vboxusb_state_t *pState, vboxusb_ep_t *pEp)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDestroyEp: pState=%p pEp=%p\n", pState, pEp));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDestroyEndPoint pState=%p pEp=%p\n", pState, pEp));
- Assert(pEp->fInitialized);
Assert(mutex_owned(&pState->Mtx));
+ if (pEp->fInitialized == VBOXUSB_EP_INITIALIZED)
+ {
vboxusb_urb_t *pUrb = list_remove_head(&pEp->hIsocInUrbs);
while (pUrb)
{
@@ -2613,21 +2613,22 @@
pEp->cbIsocInLandedReqs = 0;
list_destroy(&pEp->hIsocInLandedReqs);
- pEp->fInitialized = false;
+ pEp->fInitialized = 0;
+ }
}
/**
- * Closes all non-default pipes and drains the default pipe.
+ * Close all non-default Endpoints and drains the default pipe.
*
* @param pState The USB device instance.
* @param fDefault Whether to close the default control pipe.
*
* @remarks Requires the device state mutex to be held.
*/
-LOCAL void vboxUsbSolarisCloseAllPipes(vboxusb_state_t *pState, bool fDefault)
+LOCAL void vboxUSBSolarisCloseAllPipes(vboxusb_state_t *pState, bool fDefault)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisCloseAllPipes: pState=%p\n", pState));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisCloseAllPipes pState=%p\n", pState));
for (int i = 1; i < VBOXUSB_MAX_ENDPOINTS; i++)
{
@@ -2635,8 +2636,8 @@
if ( pEp
&& pEp->pPipe)
{
- Log((DEVICE_NAME ": vboxUsbSolarisCloseAllPipes: Closing[%d]\n", i));
- vboxUsbSolarisClosePipe(pState, pEp);
+ Log((DEVICE_NAME ":vboxUSBSolarisCloseAllPipes closing[%d]\n", i));
+ vboxUSBSolarisClosePipe(pState, pEp);
}
}
@@ -2646,15 +2647,15 @@
if ( pEp
&& pEp->pPipe)
{
- vboxUsbSolarisClosePipe(pState, pEp);
- Log((DEVICE_NAME ": vboxUsbSolarisCloseAllPipes: Closed default pipe\n"));
+ vboxUSBSolarisClosePipe(pState, pEp);
+ Log((DEVICE_NAME ":vboxUSBSolarisCloseAllPipes closed default pipe.\n"));
}
}
}
/**
- * Opens the pipe associated with an Endpoint.
+ * Open the pipe for an Endpoint.
*
* @param pState The USB device instance.
* @param pEp The Endpoint.
@@ -2662,7 +2663,7 @@
*
* @returns VBox status code.
*/
-LOCAL int vboxUsbSolarisOpenPipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp)
+LOCAL int vboxUSBSolarisOpenPipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp)
{
Assert(mutex_owned(&pState->Mtx));
@@ -2672,13 +2673,15 @@
if (pEp->pPipe)
return VINF_SUCCESS;
+
/*
* Default Endpoint; already opened just copy the pipe handle.
*/
if ((pEp->EpDesc.bEndpointAddress & USB_EP_NUM_MASK) == 0)
{
pEp->pPipe = pState->pDevDesc->dev_default_ph;
- Log((DEVICE_NAME ": vboxUsbSolarisOpenPipe: Default pipe opened\n"));
+ pEp->EpState |= VBOXUSB_EP_STATE_OPENED;
+ Log((DEVICE_NAME ":vboxUSBSolarisOpenPipe default pipe opened.\n"));
return VINF_SUCCESS;
}
@@ -2690,7 +2693,7 @@
mutex_enter(&pState->Mtx);
if (rc == USB_SUCCESS)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisOpenPipe: Opened pipe, pState=%p pEp=%p\n", pState, pEp));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisOpenPipe: Opened pipe. pState=%p pEp=%p\n", pState, pEp));
usb_pipe_set_private(pEp->pPipe, (usb_opaque_t)pEp);
/*
@@ -2715,15 +2718,15 @@
/* Buffer about 400 milliseconds of data for highspeed high-bandwidth endpoints. */
pEp->cbMaxIsocData = 400 * cbMax * 8;
}
- Log((DEVICE_NAME ": vboxUsbSolarisOpenPipe: bEndpoint=%#x cbMaxIsocData=%u\n", pEp->EpDesc.bEndpointAddress,
- pEp->cbMaxIsocData));
+ Log((DEVICE_NAME ":vboxUSBSolarisOpenPipe pEp=%p cbMaxIsocData=%u\n", pEp->cbMaxIsocData));
}
+ pEp->EpState |= VBOXUSB_EP_STATE_OPENED;
rc = VINF_SUCCESS;
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisOpenPipe: Failed! rc=%d pState=%p pEp=%p\n", rc, pState, pEp));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisOpenPipe failed! rc=%d pState=%p pEp=%p\n", rc, pState, pEp));
rc = VERR_BAD_PIPE;
}
@@ -2732,20 +2735,22 @@
/**
- * Closes the pipe associated with an Endpoint.
+ * Close the pipe of the Endpoint.
*
* @param pState The USB device instance.
* @param pEp The Endpoint.
*
* @remarks Requires the device state mutex to be held.
*/
-LOCAL void vboxUsbSolarisClosePipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp)
+LOCAL void vboxUSBSolarisClosePipe(vboxusb_state_t *pState, vboxusb_ep_t *pEp)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisClosePipe: pState=%p pEp=%p\n", pState, pEp));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisClosePipe pState=%p pEp=%p\n", pState, pEp));
AssertPtr(pEp);
if (pEp->pPipe)
{
+ pEp->EpState &= ~(VBOXUSB_EP_STATE_OPENED);
+
/*
* Default pipe: allow completion of pending requests.
*/
@@ -2754,8 +2759,7 @@
mutex_exit(&pState->Mtx);
usb_pipe_drain_reqs(pState->pDip, pEp->pPipe, 0, USB_FLAGS_SLEEP, NULL /* callback */, NULL /* callback arg. */);
mutex_enter(&pState->Mtx);
- Log((DEVICE_NAME ": vboxUsbSolarisClosePipe: Closed default pipe\n"));
- pState->fDefaultPipeOpen = false;
+ Log((DEVICE_NAME ":vboxUSBSolarisClosePipe closed default pipe\n"));
}
else
{
@@ -2773,7 +2777,7 @@
/*
* Non-default pipe: close it.
*/
- Log((DEVICE_NAME ": vboxUsbSolarisClosePipe: Pipe bmAttributes=%#x bEndpoint=%#x\n", pEp->EpDesc.bmAttributes,
+ Log((DEVICE_NAME ":vboxUSBSolarisClosePipe pipe bmAttributes=%#x bEndpointAddress=%#x\n", pEp->EpDesc.bmAttributes,
pEp->EpDesc.bEndpointAddress));
mutex_exit(&pState->Mtx);
usb_pipe_close(pState->pDip, pEp->pPipe, USB_FLAGS_SLEEP, NULL /* callback */, NULL /* callback arg. */);
@@ -2785,7 +2789,7 @@
*/
pEp->pPipe = NULL;
- Log((DEVICE_NAME ": vboxUsbSolarisClosePipe: Success, bEndpoint=%#x\n", pEp->EpDesc.bEndpointAddress));
+ Log((DEVICE_NAME ":vboxUSBSolarisClosePipe successful. pEp=%p\n", pEp));
}
Assert(pEp->pPipe == NULL);
@@ -2793,19 +2797,19 @@
/**
- * Finds the Configuration index for the passed in Configuration value.
+ * Find the Configuration index for the passed in Configuration value.
*
* @param pState The USB device instance.
- * @param bConfig The Configuration.
+ * @param uCfgValue The Configuration value.
*
* @returns The configuration index if found, otherwise -1.
*/
-LOCAL int vboxUsbSolarisGetConfigIndex(vboxusb_state_t *pState, uint_t bConfig)
+LOCAL int vboxUSBSolarisGetConfigIndex(vboxusb_state_t *pState, uint_t uCfgValue)
{
for (int CfgIndex = 0; CfgIndex < pState->pDevDesc->dev_n_cfg; CfgIndex++)
{
usb_cfg_data_t *pConfig = &pState->pDevDesc->dev_cfg[CfgIndex];
- if (pConfig->cfg_descr.bConfigurationValue == bConfig)
+ if (pConfig->cfg_descr.bConfigurationValue == uCfgValue)
return CfgIndex;
}
@@ -2821,7 +2825,7 @@
*
* @returns The allocated Isoc. In URB to be used.
*/
-LOCAL vboxusb_urb_t *vboxUsbSolarisGetIsocInUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq)
+LOCAL vboxusb_urb_t *vboxUSBSolarisGetIsocInURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq)
{
/*
* Isoc. In URBs are not queued into the Inflight list like every other URBs.
@@ -2851,7 +2855,7 @@
}
}
else
- LogRel((DEVICE_NAME ": vboxUsbSolarisGetIsocInUrb: Failed to alloc %d bytes\n", sizeof(vboxusb_urb_t)));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisGetIsocInURB failed to alloc %d bytes.\n", sizeof(vboxusb_urb_t)));
return pUrb;
}
@@ -2865,68 +2869,64 @@
*
* @returns The allocated URB to be used, or NULL upon failure.
*/
-LOCAL vboxusb_urb_t *vboxUsbSolarisQueueUrb(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, mblk_t *pMsg)
+LOCAL vboxusb_urb_t *vboxUSBSolarisQueueURB(vboxusb_state_t *pState, PVBOXUSBREQ_URB pUrbReq, mblk_t *pMsg)
{
- Assert(pUrbReq);
- LogFunc((DEVICE_NAME ": vboxUsbSolarisQueueUrb: pState=%p pUrbReq=%p\n", pState, pUrbReq));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisQueueURB pState=%p pUrbReq=%p\n", pState, pUrbReq));
mutex_enter(&pState->Mtx);
/*
- * Grab a URB from the free list.
+ * Discard oldest queued URB if we've queued max URBs and none of them have completed.
*/
- vboxusb_urb_t *pUrb = list_remove_head(&pState->hFreeUrbs);
- if (pUrb)
+ if (pState->cInflightUrbs >= VBOXUSB_URB_QUEUE_SIZE)
{
- Assert(pUrb->enmState == VBOXUSB_URB_STATE_FREE);
- Assert(!pUrb->pMsg);
- Assert(pState->cFreeUrbs > 0);
- --pState->cFreeUrbs;
- }
- else
+ vboxusb_urb_t *pUrb = list_head(&pState->hUrbs);
+ if (RT_LIKELY(pUrb))
{
- /*
- * We can't discard "old" URBs. For instance, INTR IN URBs that don't complete as
- * they don't have a timeout can essentially take arbitrarily long to complete depending
- * on the device and it's not safe to discard them in case they -do- complete. However,
- * we also have to reasonably assume a device doesn't have too many pending URBs always.
- *
- * Thus we just use a large queue and simply refuse further transfers. This is not
- * a situation which normally ever happens as usually there are at most than 4 or 5 URBs
- * in-flight until we reap them.
- */
- uint32_t const cTotalUrbs = pState->cInflightUrbs + pState->cFreeUrbs + pState->cLandedUrbs;
- if (cTotalUrbs >= VBOXUSB_URB_QUEUE_SIZE)
+ if (pUrb->pMsg)
{
- mutex_exit(&pState->Mtx);
- LogRelMax(5, (DEVICE_NAME ": vboxUsbSolarisQueueUrb: Max queue size %u reached, refusing further transfers",
- cTotalUrbs));
- return NULL;
+ freemsg(pUrb->pMsg);
+ pUrb->pMsg = NULL;
+ }
+ pUrb->enmState = VBOXUSB_URB_STATE_FREE;
+ }
}
- /*
- * Allocate a new URB as we have no free URBs.
- */
+ vboxusb_urb_t *pUrb = list_head(&pState->hUrbs);
+ if ( !pUrb
+ || ( pUrb
+ && pUrb->enmState != VBOXUSB_URB_STATE_FREE))
+ {
mutex_exit(&pState->Mtx);
pUrb = RTMemAllocZ(sizeof(vboxusb_urb_t));
if (RT_UNLIKELY(!pUrb))
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisQueueUrb: Failed to alloc %d bytes\n", sizeof(vboxusb_urb_t)));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisQueueURB failed to alloc %d bytes.\n", sizeof(vboxusb_urb_t)));
return NULL;
}
mutex_enter(&pState->Mtx);
}
-
+ else
+ {
/*
- * Add the URB to the inflight list.
+ * Remove from head and move to tail so that when several URBs are reaped continuously we get to use
+ * up each one free 'head'.
*/
- list_insert_tail(&pState->hInflightUrbs, pUrb);
+ Assert(pUrb && pUrb->enmState == VBOXUSB_URB_STATE_FREE);
+ list_remove_head(&pState->hUrbs);
+ }
+
+ list_insert_tail(&pState->hUrbs, pUrb);
++pState->cInflightUrbs;
- Assert(!pUrb->pMsg);
- pUrb->pMsg = pMsg;
- pUrb->pState = pState;
pUrb->enmState = VBOXUSB_URB_STATE_INFLIGHT;
+
+ Assert(pUrb->pMsg == NULL);
+ pUrb->pState = pState;
+ Log((DEVICE_NAME ":vboxUSBSolarisQueueURB cInflightUrbs=%d\n", pState->cInflightUrbs));
+
+ if (RT_LIKELY(pUrbReq))
+ {
pUrb->pvUrbR3 = pUrbReq->pvUrbR3;
pUrb->bEndpoint = pUrbReq->bEndpoint;
pUrb->enmType = pUrbReq->enmType;
@@ -2936,13 +2936,18 @@
pUrb->pvDataR3 = (RTR3PTR)pUrbReq->pvData;
pUrb->cbDataR3 = pUrbReq->cbData;
pUrb->cIsocPkts = pUrbReq->cIsocPkts;
+
if (pUrbReq->enmType == VUSBXFERTYPE_ISOC)
{
for (unsigned i = 0; i < pUrbReq->cIsocPkts; i++)
pUrb->aIsocPkts[i].cbPkt = pUrbReq->aIsocPkts[i].cbPkt;
}
+ pUrb->pMsg = pMsg;
+ }
+
mutex_exit(&pState->Mtx);
+
return pUrb;
}
@@ -2955,14 +2960,12 @@
*
* @remarks All pipes could be closed at this point (e.g. Device disconnected during inflight URBs)
*/
-LOCAL void vboxUsbSolarisDeQueueUrb(vboxusb_urb_t *pUrb, int URBStatus)
+LOCAL inline void vboxUSBSolarisDeQueueURB(vboxusb_urb_t *pUrb, int URBStatus)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDeQueue: pUrb=%p\n", pUrb));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDeQueue pUrb=%p\n", pUrb));
AssertPtrReturnVoid(pUrb);
- pUrb->enmStatus = vboxUsbSolarisGetUrbStatus(URBStatus);
- if (pUrb->enmStatus != VUSBSTATUS_OK)
- Log((DEVICE_NAME ": vboxUsbSolarisDeQueueUrb: URB failed! URBStatus=%d bEndpoint=%#x\n", URBStatus, pUrb->bEndpoint));
+ pUrb->enmStatus = vboxUSBSolarisGetUrbStatus(URBStatus);
vboxusb_state_t *pState = pUrb->pState;
if (RT_LIKELY(pState))
@@ -2971,26 +2974,22 @@
pUrb->enmState = VBOXUSB_URB_STATE_LANDED;
/*
- * Remove it from the inflight list & move it to the landed list.
+ * Remove it from the inflight list & move it to landed list.
*/
- list_remove(&pState->hInflightUrbs, pUrb);
- Assert(pState->cInflightUrbs > 0);
+ list_remove(&pState->hUrbs, pUrb);
--pState->cInflightUrbs;
-
list_insert_tail(&pState->hLandedUrbs, pUrb);
- ++pState->cLandedUrbs;
- vboxUsbSolarisNotifyComplete(pUrb->pState);
+ vboxUSBSolarisNotifyComplete(pUrb->pState);
mutex_exit(&pState->Mtx);
- return;
}
-
- /* Well, let's at least not leak memory... */
+ else
+ {
+ Log((DEVICE_NAME ":vboxUSBSolarisDeQueue State Gone.\n"));
freemsg(pUrb->pMsg);
pUrb->pMsg = NULL;
pUrb->enmStatus = VUSBSTATUS_INVALID;
-
- LogRel((DEVICE_NAME ": vboxUsbSolarisDeQueue: State Gone\n"));
+ }
}
@@ -2999,7 +2998,7 @@
*
* @param pUrb The URB to move.
*/
-LOCAL void vboxUsbSolarisConcatMsg(vboxusb_urb_t *pUrb)
+LOCAL inline void vboxUSBSolarisConcatMsg(vboxusb_urb_t *pUrb)
{
/*
* Concatenate the whole message rather than doing a chained copy while reaping.
@@ -3013,24 +3012,22 @@
freemsg(pUrb->pMsg);
pUrb->pMsg = pFullMsg;
}
- else
- LogRel((DEVICE_NAME ": vboxUsbSolarisConcatMsg: Failed. Expect glitches due to truncated data!\n"));
}
}
/**
- * Wakes up a user process signalling URB completion.
+ * User process poll wake up wrapper for asynchronous URB completion.
*
* @param pState The USB device instance.
* @remarks Requires the device state mutex to be held.
*/
-LOCAL void vboxUsbSolarisNotifyComplete(vboxusb_state_t *pState)
+LOCAL inline void vboxUSBSolarisNotifyComplete(vboxusb_state_t *pState)
{
- if (pState->fPollPending)
+ if (pState->fPoll & VBOXUSB_POLL_ON)
{
pollhead_t *pPollHead = &pState->PollHead;
- pState->fPollPending = false;
+ pState->fPoll |= VBOXUSB_POLL_REAP_PENDING;
mutex_exit(&pState->Mtx);
pollwakeup(pPollHead, POLLIN);
mutex_enter(&pState->Mtx);
@@ -3039,17 +3036,17 @@
/**
- * Wakes up a user process signalling a device unplug events.
+ * User process poll wake up wrapper for hotplug events.
*
* @param pState The USB device instance.
* @remarks Requires the device state mutex to be held.
*/
-LOCAL void vboxUsbSolarisNotifyUnplug(vboxusb_state_t *pState)
+LOCAL inline void vboxUSBSolarisNotifyHotplug(vboxusb_state_t *pState)
{
- if (pState->fPollPending)
+ if (pState->fPoll & VBOXUSB_POLL_ON)
{
pollhead_t *pPollHead = &pState->PollHead;
- pState->fPollPending = false;
+ pState->fPoll |= VBOXUSB_POLL_DEV_UNPLUGGED;
mutex_exit(&pState->Mtx);
pollwakeup(pPollHead, POLLHUP);
mutex_enter(&pState->Mtx);
@@ -3058,30 +3055,31 @@
/**
- * Performs a Control Xfer.
+ * Perform a Control Xfer.
*
* @param pState The USB device instance.
* @param pEp The Endpoint for the Xfer.
* @param pUrb The VBox USB URB.
*
* @returns VBox status code.
+ * @remarks Any errors, the caller should free pUrb->pMsg.
*/
-LOCAL int vboxUsbSolarisCtrlXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)
+LOCAL int vboxUSBSolarisCtrlXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisCtrlXfer: pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb,
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisCtrlXfer pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb,
pUrb->enmDir, pUrb->cbDataR3));
AssertPtrReturn(pUrb->pMsg, VERR_INVALID_PARAMETER);
- const size_t cbData = pUrb->cbDataR3 > VBOXUSB_CTRL_XFER_SIZE ? pUrb->cbDataR3 - VBOXUSB_CTRL_XFER_SIZE : 0;
+ uchar_t *pSetupData = pUrb->pMsg->b_rptr;
+ size_t cbData = pUrb->cbDataR3 > VBOXUSB_CTRL_XFER_SIZE ? pUrb->cbDataR3 - VBOXUSB_CTRL_XFER_SIZE : 0;
/*
* Allocate a wrapper request.
*/
- usb_ctrl_req_t *pReq = usb_alloc_ctrl_req(pState->pDip, cbData, USB_FLAGS_SLEEP);
+ int rc = VINF_SUCCESS;
+ usb_ctrl_req_t *pReq = usb_alloc_ctrl_req(pState->pDip, cbData, USB_FLAGS_NOSLEEP);
if (RT_LIKELY(pReq))
{
- uchar_t *pSetupData = pUrb->pMsg->b_rptr;
-
/*
* Initialize the Ctrl Xfer Header.
*/
@@ -3094,7 +3092,8 @@
if ( pUrb->enmDir == VUSBDIRECTION_OUT
&& cbData)
{
- bcopy(pSetupData + VBOXUSB_CTRL_XFER_SIZE, pReq->ctrl_data->b_wptr, cbData);
+ pUrb->pMsg->b_rptr += VBOXUSB_CTRL_XFER_SIZE;
+ bcopy(pUrb->pMsg->b_rptr, pReq->ctrl_data->b_wptr, cbData);
pReq->ctrl_data->b_wptr += cbData;
}
@@ -3104,27 +3103,45 @@
/*
* Initialize callbacks and timeouts.
*/
- pReq->ctrl_cb = vboxUsbSolarisCtrlXferCompleted;
- pReq->ctrl_exc_cb = vboxUsbSolarisCtrlXferCompleted;
+ usb_req_attrs_t fAttributes = USB_ATTRS_AUTOCLEARING;
+ if ( pUrb->enmDir == VUSBDIRECTION_IN
+ && pUrb->fShortOk)
+ {
+ fAttributes |= USB_ATTRS_SHORT_XFER_OK;
+ }
+ pReq->ctrl_cb = vboxUSBSolarisCtrlXferCompleted;
+ pReq->ctrl_exc_cb = vboxUSBSolarisCtrlXferCompleted;
pReq->ctrl_timeout = VBOXUSB_CTRL_XFER_TIMEOUT;
- pReq->ctrl_attributes = USB_ATTRS_AUTOCLEARING | USB_ATTRS_SHORT_XFER_OK;
+ pReq->ctrl_attributes = fAttributes;
+
pReq->ctrl_client_private = (usb_opaque_t)pUrb;
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisCtrlXfer ctrl_wLength=%#RX16 cbData=%#zx fShortOk=%RTbool\n", pReq->ctrl_wLength,
+ cbData, !!(fAttributes & USB_ATTRS_SHORT_XFER_OK)));
+ Log((DEVICE_NAME ":vboxUSBSolarisCtrlXfer %.*Rhxd\n", VBOXUSB_CTRL_XFER_SIZE, pSetupData));
+
/*
* Submit the request.
*/
- int rc = usb_pipe_ctrl_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP);
+ rc = usb_pipe_ctrl_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP);
+
if (RT_LIKELY(rc == USB_SUCCESS))
return VINF_SUCCESS;
-
- LogRel((DEVICE_NAME ": vboxUsbSolarisCtrlXfer: Request failed! bEndpoint=%#x rc=%d\n", pUrb->bEndpoint, rc));
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisCtrlXfer usb_pipe_ctrl_xfer failed! rc=%d\n", rc));
+ rc = VERR_PIPE_IO_ERROR;
+ }
usb_free_ctrl_req(pReq);
- return VERR_PIPE_IO_ERROR;
+ }
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisCtrlXfer failed to alloc request.\n"));
+ rc = VERR_NO_MEMORY;
}
- LogRel((DEVICE_NAME ": vboxUsbSolarisCtrlXfer: Failed to alloc request for %u bytes\n", cbData));
- return VERR_NO_MEMORY;
+ return rc;
}
@@ -3134,18 +3151,17 @@
* @param pPipe The Ctrl pipe handle.
* @param pReq The Ctrl request.
*/
-LOCAL void vboxUsbSolarisCtrlXferCompleted(usb_pipe_handle_t pPipe, usb_ctrl_req_t *pReq)
+LOCAL void vboxUSBSolarisCtrlXferCompleted(usb_pipe_handle_t pPipe, usb_ctrl_req_t *pReq)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisCtrlXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq));
- Assert(pReq);
- Assert(!(pReq->ctrl_cb_flags & USB_CB_INTR_CONTEXT));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisCtrlXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq));
vboxusb_urb_t *pUrb = (vboxusb_urb_t *)pReq->ctrl_client_private;
if (RT_LIKELY(pUrb))
{
/*
* Funky stuff: We need to reconstruct the header for control transfers.
- * Let us chain along the data and concatenate the entire message.
+ * Let us chain along the data and while we dequeue the URB we attempt to
+ * concatenate the entire message there.
*/
mblk_t *pSetupMsg = allocb(sizeof(VUSBSETUP), BPRI_MED);
if (RT_LIKELY(pSetupMsg))
@@ -3156,40 +3172,48 @@
SetupData.wValue = pReq->ctrl_wValue;
SetupData.wIndex = pReq->ctrl_wIndex;
SetupData.wLength = pReq->ctrl_wLength;
-
bcopy(&SetupData, pSetupMsg->b_wptr, sizeof(VUSBSETUP));
pSetupMsg->b_wptr += sizeof(VUSBSETUP);
/*
- * Should be safe to update pMsg here without the state mutex as typically nobody else
- * touches this URB in the inflight list.
- *
- * The reason we choose to use vboxUsbSolarisConcatMsg here is that we don't assume the
- * message returned by Solaris is one contiguous chunk in 'pMsg->b_rptr'.
+ * Should be safe to update pMsg here without the state mutex, see vboxUSBSolarisSendURB()
+ * and vboxUSBSolarisQueueURB() as the URB state is (still) not VBOXUSB_URB_STATE_FREE.
*/
- Assert(!pUrb->pMsg);
pUrb->pMsg = pSetupMsg;
pUrb->pMsg->b_cont = pReq->ctrl_data;
pReq->ctrl_data = NULL;
- vboxUsbSolarisConcatMsg(pUrb);
+ vboxUSBSolarisConcatMsg(pUrb);
+
+#ifdef DEBUG_ramshankar
+ if ( pUrb->pMsg
+ && pUrb->pMsg->b_cont == NULL) /* Concat succeeded */
+ {
+ Log((DEVICE_NAME ":vboxUSBSolarisCtrlXferCompleted prepended header rc=%d cbData=%d.\n",
+ pReq->ctrl_completion_reason, MBLKL(pUrb->pMsg)));
+ Log((DEVICE_NAME ":%.*Rhxd\n", MBLKL(pUrb->pMsg), pUrb->pMsg->b_rptr));
}
- else
- LogRel((DEVICE_NAME ": vboxUsbSolarisCtrlXferCompleted: Failed to alloc %u bytes for header\n", sizeof(VUSBSETUP)));
+#endif
/*
* Update the URB and move to landed list for reaping.
*/
- vboxUsbSolarisDeQueueUrb(pUrb, pReq->ctrl_completion_reason);
+ vboxUSBSolarisDeQueueURB(pUrb, pReq->ctrl_completion_reason);
+ }
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisCtrlXferCompleted failed to alloc %d bytes for Setup Header.\n",
+ sizeof(VUSBSETUP)));
+ }
}
else
- LogRel((DEVICE_NAME ": vboxUsbSolarisCtrlXferCompleted: Extreme error! missing private data\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisCtrlXferCompleted Extreme error! missing private data.\n"));
usb_free_ctrl_req(pReq);
}
/**
- * Performs a Bulk Xfer.
+ * Perform a Bulk Xfer.
*
* @param pState The USB device instance.
* @param pEp The Endpoint for the Xfer.
@@ -3198,16 +3222,17 @@
* @returns VBox status code.
* @remarks Any errors, the caller should free pUrb->pMsg.
*/
-LOCAL int vboxUsbSolarisBulkXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)
+LOCAL int vboxUSBSolarisBulkXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisBulkXfer: pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb,
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisBulkXfer pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb,
pUrb->enmDir, pUrb->cbDataR3));
/*
* Allocate a wrapper request.
*/
- size_t const cbAlloc = pUrb->enmDir == VUSBDIRECTION_IN ? pUrb->cbDataR3 : 0;
- usb_bulk_req_t *pReq = usb_alloc_bulk_req(pState->pDip, cbAlloc, USB_FLAGS_SLEEP);
+ int rc = VINF_SUCCESS;
+ usb_bulk_req_t *pReq = usb_alloc_bulk_req(pState->pDip, pUrb->enmDir == VUSBDIRECTION_IN ? pUrb->cbDataR3 : 0,
+ USB_FLAGS_NOSLEEP);
if (RT_LIKELY(pReq))
{
/*
@@ -3215,47 +3240,53 @@
*/
usb_req_attrs_t fAttributes = USB_ATTRS_AUTOCLEARING;
if (pUrb->enmDir == VUSBDIRECTION_OUT)
- {
pReq->bulk_data = pUrb->pMsg;
- pUrb->pMsg = NULL;
- }
else if ( pUrb->enmDir == VUSBDIRECTION_IN
&& pUrb->fShortOk)
{
fAttributes |= USB_ATTRS_SHORT_XFER_OK;
}
- Assert(!pUrb->pMsg);
pReq->bulk_len = pUrb->cbDataR3;
- pReq->bulk_cb = vboxUsbSolarisBulkXferCompleted;
- pReq->bulk_exc_cb = vboxUsbSolarisBulkXferCompleted;
- pReq->bulk_timeout = 0;
+ pReq->bulk_cb = vboxUSBSolarisBulkXferCompleted;
+ pReq->bulk_exc_cb = vboxUSBSolarisBulkXferCompleted;
+ pReq->bulk_timeout = VBOXUSB_BULK_XFER_TIMEOUT;
pReq->bulk_attributes = fAttributes;
pReq->bulk_client_private = (usb_opaque_t)pUrb;
/* Don't obtain state lock here, we're just reading unchanging data... */
if (RT_UNLIKELY(pUrb->cbDataR3 > pState->cbMaxBulkXfer))
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisBulkXfer: Requesting %d bytes when only %d bytes supported by device\n",
+ LogRel((DEVICE_NAME ":vboxUSBSolarisBulkXfer requesting %d bytes when only %d bytes supported by device\n",
pUrb->cbDataR3, pState->cbMaxBulkXfer));
}
/*
* Submit the request.
*/
- int rc = usb_pipe_bulk_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP);
+ rc = usb_pipe_bulk_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP);
+
if (RT_LIKELY(rc == USB_SUCCESS))
return VINF_SUCCESS;
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisBulkXfer usb_pipe_bulk_xfer enmDir=%#x Ep=%#x failed! rc=%d\n", pUrb->enmDir,
+ pUrb->bEndpoint, rc));
+ rc = VERR_PIPE_IO_ERROR;
+ }
- LogRel((DEVICE_NAME ": vboxUsbSolarisBulkXfer: Request failed! Ep=%#x rc=%d cbData=%u\n", pUrb->bEndpoint, rc,
- pReq->bulk_len));
+ if (pUrb->enmDir == VUSBDIRECTION_OUT) /* pUrb->pMsg freed by caller */
+ pReq->bulk_data = NULL;
usb_free_bulk_req(pReq);
- return VERR_PIPE_IO_ERROR;
+ }
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisBulkXfer failed to alloc bulk request.\n"));
+ rc = VERR_NO_MEMORY;
}
- LogRel((DEVICE_NAME ": vboxUsbSolarisBulkXfer: Failed to alloc bulk request\n"));
- return VERR_NO_MEMORY;
+ return rc;
}
@@ -3265,12 +3296,9 @@
* @param pPipe The Bulk pipe handle.
* @param pReq The Bulk request.
*/
-LOCAL void vboxUsbSolarisBulkXferCompleted(usb_pipe_handle_t pPipe, usb_bulk_req_t *pReq)
+LOCAL void vboxUSBSolarisBulkXferCompleted(usb_pipe_handle_t pPipe, usb_bulk_req_t *pReq)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisBulkXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq));
-
- Assert(pReq);
- Assert(!(pReq->bulk_cb_flags & USB_CB_INTR_CONTEXT));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisBulkXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq));
vboxusb_ep_t *pEp = (vboxusb_ep_t *)usb_pipe_get_private(pPipe);
if (RT_LIKELY(pEp))
@@ -3278,32 +3306,41 @@
vboxusb_urb_t *pUrb = (vboxusb_urb_t *)pReq->bulk_client_private;
if (RT_LIKELY(pUrb))
{
- Assert(!pUrb->pMsg);
- if ( pUrb->enmDir == VUSBDIRECTION_IN
- && pReq->bulk_data)
+ if (pUrb->enmDir == VUSBDIRECTION_OUT)
+ pReq->bulk_data = NULL;
+ else
+ {
+ if (pReq->bulk_completion_reason == USB_CR_OK)
{
pUrb->pMsg = pReq->bulk_data;
pReq->bulk_data = NULL;
- vboxUsbSolarisConcatMsg(pUrb);
+ vboxUSBSolarisConcatMsg(pUrb);
}
+ }
+
+ Log((DEVICE_NAME ":vboxUSBSolarisBulkXferCompleted %s. rc=%d cbData=%d\n",
+ pReq->bulk_completion_reason != USB_CR_OK ? "failed URB" : "success",
+ pReq->bulk_completion_reason, pUrb->pMsg ? MBLKL(pUrb->pMsg) : 0));
/*
* Update the URB and move to tail for reaping.
*/
- vboxUsbSolarisDeQueueUrb(pUrb, pReq->bulk_completion_reason);
+ vboxUSBSolarisDeQueueURB(pUrb, pReq->bulk_completion_reason);
+ usb_free_bulk_req(pReq);
+ return;
}
else
- LogRel((DEVICE_NAME ": vboxUsbSolarisBulkXferCompleted: Extreme error! private request data missing!\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisBulkXferCompleted Extreme error! private request data missing.\n"));
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisBulkXferCompleted: Pipe Gone!\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisBulkXferCompleted Pipe Gone.\n"));
usb_free_bulk_req(pReq);
}
/**
- * Performs an Interrupt Xfer.
+ * Perform an Interrupt Xfer.
*
* @param pState The USB device instance.
* @param pEp The Endpoint for the Xfer.
@@ -3312,54 +3349,59 @@
* @returns VBox status code.
* @remarks Any errors, the caller should free pUrb->pMsg.
*/
-LOCAL int vboxUsbSolarisIntrXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)
+LOCAL int vboxUSBSolarisIntrXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisIntrXfer: pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb,
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisIntrXfer pState=%p pEp=%p pUrb=%p enmDir=%d cbData=%d\n", pState, pEp, pUrb,
pUrb->enmDir, pUrb->cbDataR3));
- usb_intr_req_t *pReq = usb_alloc_intr_req(pState->pDip, 0 /* length */, USB_FLAGS_SLEEP);
+ int rc = VINF_SUCCESS;
+ usb_intr_req_t *pReq = usb_alloc_intr_req(pState->pDip, 0 /* length */, USB_FLAGS_NOSLEEP);
if (RT_LIKELY(pReq))
{
/*
* Initialize Intr Xfer, callbacks & timeouts.
*/
- usb_req_attrs_t fAttributes = USB_ATTRS_AUTOCLEARING;
if (pUrb->enmDir == VUSBDIRECTION_OUT)
{
pReq->intr_data = pUrb->pMsg;
- pUrb->pMsg = NULL;
+ pReq->intr_attributes = USB_ATTRS_AUTOCLEARING;
}
else
{
Assert(pUrb->enmDir == VUSBDIRECTION_IN);
- fAttributes |= USB_ATTRS_ONE_XFER;
- if (pUrb->fShortOk)
- fAttributes |= USB_ATTRS_SHORT_XFER_OK;
+ pReq->intr_data = NULL;
+ pReq->intr_attributes = USB_ATTRS_AUTOCLEARING | USB_ATTRS_ONE_XFER | (pUrb->fShortOk ? USB_ATTRS_SHORT_XFER_OK : 0);
}
- Assert(!pUrb->pMsg);
pReq->intr_len = pUrb->cbDataR3; /* Not pEp->EpDesc.wMaxPacketSize */
- pReq->intr_cb = vboxUsbSolarisIntrXferCompleted;
- pReq->intr_exc_cb = vboxUsbSolarisIntrXferCompleted;
- pReq->intr_timeout = 0;
- pReq->intr_attributes = fAttributes;
+ pReq->intr_cb = vboxUSBSolarisIntrXferCompleted;
+ pReq->intr_exc_cb = vboxUSBSolarisIntrXferCompleted;
+ pReq->intr_timeout = VBOXUSB_INTR_XFER_TIMEOUT;
pReq->intr_client_private = (usb_opaque_t)pUrb;
/*
* Submit the request.
*/
- int rc = usb_pipe_intr_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP);
+ rc = usb_pipe_intr_xfer(pEp->pPipe, pReq, USB_FLAGS_NOSLEEP);
+
if (RT_LIKELY(rc == USB_SUCCESS))
return VINF_SUCCESS;
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIntrXfer usb_pipe_intr_xfer failed! rc=%d\n", rc));
+ rc = VERR_PIPE_IO_ERROR;
+ }
- LogRel((DEVICE_NAME ": vboxUsbSolarisIntrXfer: usb_pipe_intr_xfer failed! rc=%d bEndpoint=%#x\n", rc, pUrb->bEndpoint));
-
+ pReq->intr_data = NULL;
usb_free_intr_req(pReq);
- return VERR_PIPE_IO_ERROR;
+ }
+ else
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIntrXfer failed to alloc intr request.\n"));
+ rc = VERR_NO_MEMORY;
}
- LogRel((DEVICE_NAME ": vboxUsbSolarisIntrXfer: Failed to alloc intr request\n"));
- return VERR_NO_MEMORY;
+ return rc;
}
@@ -3369,38 +3411,49 @@
* @param pPipe The Intr pipe handle.
* @param pReq The Intr request.
*/
-LOCAL void vboxUsbSolarisIntrXferCompleted(usb_pipe_handle_t pPipe, usb_intr_req_t *pReq)
+LOCAL void vboxUSBSolarisIntrXferCompleted(usb_pipe_handle_t pPipe, usb_intr_req_t *pReq)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisIntrXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq));
-
- Assert(pReq);
- Assert(!(pReq->intr_cb_flags & USB_CB_INTR_CONTEXT));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisIntrXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq));
+ vboxusb_ep_t *pEp = (vboxusb_ep_t *)usb_pipe_get_private(pPipe);
+ if (RT_LIKELY(pEp))
+ {
vboxusb_urb_t *pUrb = (vboxusb_urb_t *)pReq->intr_client_private;
if (RT_LIKELY(pUrb))
{
- if ( pUrb->enmDir == VUSBDIRECTION_IN
- && pReq->intr_data)
+ if (pUrb->enmDir == VUSBDIRECTION_OUT)
+ pReq->intr_data = NULL;
+ else
+ {
+ if (pReq->intr_completion_reason == USB_CR_OK)
{
pUrb->pMsg = pReq->intr_data;
pReq->intr_data = NULL;
- vboxUsbSolarisConcatMsg(pUrb);
+ }
}
+ Log((DEVICE_NAME ":vboxUSBSolarisIntrXferCompleted rc=%d pMsg=%p enmDir=%#x\n", pReq->intr_completion_reason,
+ pUrb->pMsg, pUrb->enmDir));
+
/*
* Update the URB and move to landed list for reaping.
*/
- vboxUsbSolarisDeQueueUrb(pUrb, pReq->intr_completion_reason);
+ vboxUSBSolarisDeQueueURB(pUrb, pReq->intr_completion_reason);
+ usb_free_intr_req(pReq);
+ return;
+ }
+ else
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIntrXferCompleted Extreme error! private request data missing.\n"));
}
else
- LogRel((DEVICE_NAME ": vboxUsbSolarisIntrXferCompleted: Extreme error! private request data missing\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIntrXferCompleted Pipe Gone.\n"));
usb_free_intr_req(pReq);
}
/**
- * Performs an Isochronous Xfer.
+ * Perform an Isochronous Xfer.
*
* @param pState The USB device instance.
* @param pEp The Endpoint for the Xfer.
@@ -3409,9 +3462,9 @@
* @returns VBox status code.
* @remarks Any errors, the caller should free pUrb->pMsg.
*/
-LOCAL int vboxUsbSolarisIsocXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)
+LOCAL int vboxUSBSolarisIsocXfer(vboxusb_state_t *pState, vboxusb_ep_t *pEp, vboxusb_urb_t *pUrb)
{
- /* LogFunc((DEVICE_NAME ": vboxUsbSolarisIsocXfer: pState=%p pEp=%p pUrb=%p\n", pState, pEp, pUrb)); */
+// LogFunc((DEVICE_NAME ":vboxUSBSolarisIsocXfer pState=%p pEp=%p pUrb=%p\n", pState, pEp, pUrb));
/*
* For Isoc. IN transfers we perform one request and USBA polls the device continuously
@@ -3420,7 +3473,7 @@
size_t cbData = (pUrb->enmDir == VUSBDIRECTION_IN ? pUrb->cIsocPkts * pUrb->aIsocPkts[0].cbPkt : 0);
if (pUrb->enmDir == VUSBDIRECTION_IN)
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsocXfer: Isoc. IN - Queueing\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocXfer Isoc. In queueing.\n"));
mutex_enter(&pState->Mtx);
if (pEp->fIsocPolling)
@@ -3431,7 +3484,7 @@
if (pEp->cbIsocInLandedReqs + cbData > pEp->cbMaxIsocData)
{
mutex_exit(&pState->Mtx);
- Log((DEVICE_NAME ": vboxUsbSolarisIsocXfer: Max Isoc. data %d bytes queued\n", pEp->cbMaxIsocData));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocXfer Max Isoc. data %d bytes queued\n", pEp->cbMaxIsocData));
return VERR_TOO_MUCH_DATA;
}
@@ -3446,7 +3499,7 @@
int rc = VINF_SUCCESS;
usb_isoc_req_t *pReq = usb_alloc_isoc_req(pState->pDip, pUrb->cIsocPkts, cbData, USB_FLAGS_NOSLEEP);
- Log((DEVICE_NAME ": vboxUsbSolarisIsocXfer: enmDir=%#x cIsocPkts=%d aIsocPkts[0]=%d cbDataR3=%d\n", pUrb->enmDir,
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocXfer enmDir=%#x cIsocPkts=%d aIsocPkts[0]=%d cbDataR3=%d\n", pUrb->enmDir,
pUrb->cIsocPkts, pUrb->aIsocPkts[0].cbPkt, pUrb->cbDataR3));
if (RT_LIKELY(pReq))
{
@@ -3460,15 +3513,15 @@
{
pReq->isoc_data = pUrb->pMsg;
pReq->isoc_attributes = USB_ATTRS_AUTOCLEARING | USB_ATTRS_ISOC_XFER_ASAP;
- pReq->isoc_cb = vboxUsbSolarisIsocOutXferCompleted;
- pReq->isoc_exc_cb = vboxUsbSolarisIsocOutXferCompleted;
+ pReq->isoc_cb = vboxUSBSolarisIsocOutXferCompleted;
+ pReq->isoc_exc_cb = vboxUSBSolarisIsocOutXferCompleted;
pReq->isoc_client_private = (usb_opaque_t)pUrb;
}
else
{
pReq->isoc_attributes = USB_ATTRS_AUTOCLEARING | USB_ATTRS_ISOC_XFER_ASAP | USB_ATTRS_SHORT_XFER_OK;
- pReq->isoc_cb = vboxUsbSolarisIsocInXferCompleted;
- pReq->isoc_exc_cb = vboxUsbSolarisIsocInXferError;
+ pReq->isoc_cb = vboxUSBSolarisIsocInXferCompleted;
+ pReq->isoc_exc_cb = vboxUSBSolarisIsocInXferError;
pReq->isoc_client_private = (usb_opaque_t)pState;
}
pReq->isoc_pkts_count = pUrb->cIsocPkts;
@@ -3496,7 +3549,7 @@
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisIsocXfer: usb_pipe_isoc_xfer failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIsocXfer usb_pipe_isoc_xfer failed! rc=%d\n", rc));
rc = VERR_PIPE_IO_ERROR;
if (pUrb->enmDir == VUSBDIRECTION_IN)
@@ -3513,17 +3566,14 @@
}
}
- if (pUrb->enmDir == VUSBDIRECTION_OUT)
- {
- freemsg(pUrb->pMsg);
- pUrb->pMsg = NULL;
- }
+ if (pUrb->enmDir == VUSBDIRECTION_OUT) /* pUrb->pMsg freed by caller */
+ pReq->isoc_data = NULL;
usb_free_isoc_req(pReq);
}
else
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisIsocXfer: Failed to alloc isoc req for %d packets\n", pUrb->cIsocPkts));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIsocXfer failed to alloc isoc req for %d packets\n", pUrb->cIsocPkts));
rc = VERR_NO_MEMORY;
}
@@ -3539,9 +3589,9 @@
*
* @remarks Completion callback executes in interrupt context!
*/
-LOCAL void vboxUsbSolarisIsocInXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)
+LOCAL void vboxUSBSolarisIsocInXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)
{
- /* LogFunc((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq)); */
+// LogFunc((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq));
vboxusb_state_t *pState = (vboxusb_state_t *)pReq->isoc_client_private;
if (RT_LIKELY(pState))
@@ -3556,7 +3606,7 @@
*/
if (pReq->isoc_error_count == pReq->isoc_pkts_count)
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: Stopping polling! Too many errors\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted stopping polling! Too many errors.\n"));
mutex_exit(&pState->Mtx);
usb_pipe_stop_isoc_polling(pPipe, USB_FLAGS_NOSLEEP);
mutex_enter(&pState->Mtx);
@@ -3564,11 +3614,11 @@
}
#endif
- /** @todo Query and verify this at runtime. */
AssertCompile(sizeof(VUSBISOC_PKT_DESC) == sizeof(usb_isoc_pkt_descr_t));
+
if (RT_LIKELY(pReq->isoc_data))
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: cIsocInUrbs=%d cbIsocInLandedReqs=%d\n", pEp->cIsocInUrbs,
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted cIsocInUrbs=%d cbIsocInLandedReqs=%d\n", pEp->cIsocInUrbs,
pEp->cbIsocInLandedReqs));
mutex_enter(&pState->Mtx);
@@ -3588,7 +3638,7 @@
for (unsigned i = 0; i < pReq->isoc_pkts_count; i++)
{
pUrb->aIsocPkts[i].cbActPkt = pReq->isoc_pkt_descr[i].isoc_pkt_actual_length;
- pUrb->aIsocPkts[i].enmStatus = vboxUsbSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status);
+ pUrb->aIsocPkts[i].enmStatus = vboxUSBSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status);
}
pUrb->pMsg = pReq->isoc_data;
@@ -3599,15 +3649,14 @@
*/
mutex_enter(&pState->Mtx);
list_insert_tail(&pState->hLandedUrbs, pUrb);
- ++pState->cLandedUrbs;
- vboxUsbSolarisNotifyComplete(pState);
+ vboxUSBSolarisNotifyComplete(pState);
}
else
{
/* Huh!? cIsocInUrbs is wrong then! Should never happen unless we decide to decrement cIsocInUrbs in
Reap time */
pEp->cIsocInUrbs = 0;
- LogRel((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: Extreme error! Isoc. counter borked!\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted Extreme error! Isoc. counter b0rked!\n"));
}
mutex_exit(&pState->Mtx);
@@ -3615,16 +3664,108 @@
return;
}
+#if 0
+ /*
+ * If the maximum buffer size is reached, discard the oldest data.
+ */
+ if (pEp->cbIsocInLandedReqs + MBLKL(pReq->isoc_data) > pEp->cbMaxIsocData)
+ {
+ vboxusb_isoc_req_t *pOldReq = list_remove_head(&pEp->hIsocInLandedReqs);
+ if (RT_LIKELY(pOldReq))
+ {
+ pEp->cbIsocInLandedReqs -= MBLKL(pOldReq->pMsg);
+ kmem_free(pOldReq, sizeof(vboxusb_isoc_req_t));
+ }
+ }
+
+ mutex_exit(&pState->Mtx);
+
+ /*
+ * Buffer incoming data if the guest has not yet queued any Input URBs.
+ */
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted Buffering\n"));
+ vboxusb_isoc_req_t *pIsocReq = kmem_alloc(sizeof(vboxusb_isoc_req_t), KM_NOSLEEP);
+ if (RT_LIKELY(pIsocReq))
+ {
+ pIsocReq->pMsg = pReq->isoc_data;
+ pReq->isoc_data = NULL;
+ pIsocReq->cIsocPkts = pReq->isoc_pkts_count;
+#if 0
+ for (unsigned i = 0; i < pReq->isoc_pkts_count; i++)
+ {
+ pIsocReq->aIsocPkts[i].cbActPkt = pReq->isoc_pkt_descr[i].isoc_pkt_actual_length;
+ pIsocReq->aIsocPkts[i].enmStatus = vboxUSBSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status);
+ }
+#else
+ bcopy(pReq->isoc_pkt_descr, pIsocReq->aIsocPkts, pReq->isoc_pkts_count * sizeof(VUSBISOC_PKT_DESC));
+#endif
+
+ mutex_enter(&pState->Mtx);
+ list_insert_tail(&pEp->hIsocInLandedReqs, pIsocReq);
+ pEp->cbIsocInLandedReqs += MBLKL(pIsocReq->pMsg);
mutex_exit(&pState->Mtx);
}
else
- LogRel((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: Data missing\n"));
+ {
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted failed to alloc %d bytes for Isoc. queueing\n",
+ sizeof(vboxusb_isoc_req_t)));
+ }
+
+ /*
+ * Drain the input URB buffer with the device buffer, queueing them with the landed URBs.
+ */
+ mutex_enter(&pState->Mtx);
+ while (pEp->cIsocInUrbs)
+ {
+ vboxusb_urb_t *pUrb = list_remove_head(&pEp->hIsocInUrbs);
+ if (RT_UNLIKELY(!pUrb))
+ break;
+
+ vboxusb_isoc_req_t *pBuffReq = list_remove_head(&pEp->hIsocInLandedReqs);
+ if (!pBuffReq)
+ {
+ list_insert_head(&pEp->hIsocInUrbs, pUrb);
+ break;
+ }
+
+ --pEp->cIsocInUrbs;
+ pEp->cbIsocInLandedReqs -= MBLKL(pBuffReq->pMsg);
+ mutex_exit(&pState->Mtx);
+
+#if 0
+ for (unsigned i = 0; i < pBuffReq->cIsocPkts; i++)
+ {
+ pUrb->aIsocPkts[i].cbActPkt = pBuffReq->aIsocPkts[i].cbActPkt;
+ pUrb->aIsocPkts[i].enmStatus = pBuffReq->aIsocPkts[i].enmStatus;
+ }
+#else
+ bcopy(pBuffReq->aIsocPkts, pUrb->aIsocPkts, pBuffReq->cIsocPkts * sizeof(VUSBISOC_PKT_DESC));
+#endif
+ pUrb->pMsg = pBuffReq->pMsg;
+ pBuffReq->pMsg = NULL;
+ kmem_free(pBuffReq, sizeof(vboxusb_isoc_req_t));
+
+ /*
+ * Move to landed list
+ */
+ mutex_enter(&pState->Mtx);
+ list_insert_tail(&pState->hLandedUrbs, pUrb);
+ vboxUSBSolarisNotifyComplete(pState);
+ }
+#endif
+
+ mutex_exit(&pState->Mtx);
+ usb_free_isoc_req(pReq);
+ return;
}
else
- LogRel((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: Pipe Gone\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted data missing.\n"));
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferCompleted: State Gone\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted Pipe Gone.\n"));
+ }
+ else
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferCompleted State Gone.\n"));
usb_free_isoc_req(pReq);
}
@@ -3637,14 +3778,14 @@
* @param pReq The Intr request.
* @remarks Completion callback executes in interrupt context!
*/
-LOCAL void vboxUsbSolarisIsocInXferError(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)
+LOCAL void vboxUSBSolarisIsocInXferError(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: pPipe=%p pReq=%p\n", pPipe, pReq));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisIsocInXferError pPipe=%p pReq=%p\n", pPipe, pReq));
vboxusb_state_t *pState = (vboxusb_state_t *)pReq->isoc_client_private;
if (RT_UNLIKELY(!pState))
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: State Gone\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferError State Gone.\n"));
usb_free_isoc_req(pReq);
return;
}
@@ -3653,7 +3794,7 @@
vboxusb_ep_t *pEp = (vboxusb_ep_t *)usb_pipe_get_private(pPipe);
if (RT_UNLIKELY(!pEp))
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: Pipe Gone\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferError Pipe Gone.\n"));
mutex_exit(&pState->Mtx);
usb_free_isoc_req(pReq);
return;
@@ -3669,7 +3810,9 @@
*/
mutex_exit(&pState->Mtx);
usb_pipe_isoc_xfer(pPipe, pReq, USB_FLAGS_NOSLEEP);
- Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: Resubmitted Isoc. IN request due to unavailable resources\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferError resubmitted Isoc. IN request due to immediately unavailable "
+ "resources.\n"));
+
return;
}
@@ -3684,7 +3827,7 @@
default:
{
- Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: Stopping Isoc. IN polling due to rc=%d\n",
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferError stopping Isoc. In. polling due to rc=%d\n",
pReq->isoc_completion_reason));
pEp->fIsocPolling = false;
mutex_exit(&pState->Mtx);
@@ -3702,10 +3845,10 @@
if (pUrb)
{
--pEp->cIsocInUrbs;
- Log((DEVICE_NAME ": vboxUsbSolarisIsocInXferError: Deleting last queued URB as it failed\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocInXferError Deleting last queued URB as it failed.\n"));
freemsg(pUrb->pMsg);
RTMemFree(pUrb);
- vboxUsbSolarisNotifyComplete(pState);
+ vboxUSBSolarisNotifyComplete(pState);
}
mutex_exit(&pState->Mtx);
@@ -3719,9 +3862,9 @@
* @param pReq The Intr request.
* @remarks Completion callback executes in interrupt context!
*/
-LOCAL void vboxUsbSolarisIsocOutXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)
+LOCAL void vboxUSBSolarisIsocOutXferCompleted(usb_pipe_handle_t pPipe, usb_isoc_req_t *pReq)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisIsocOutXferCompleted: pPipe=%p pReq=%p\n", pPipe, pReq));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisIsocOutXferCompleted pPipe=%p pReq=%p\n", pPipe, pReq));
vboxusb_ep_t *pEp = (vboxusb_ep_t *)usb_pipe_get_private(pPipe);
if (RT_LIKELY(pEp))
@@ -3734,10 +3877,10 @@
{
cbActPkt += pReq->isoc_pkt_descr[i].isoc_pkt_actual_length;
pUrb->aIsocPkts[i].cbActPkt = pReq->isoc_pkt_descr[i].isoc_pkt_actual_length;
- pUrb->aIsocPkts[i].enmStatus = vboxUsbSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status);
+ pUrb->aIsocPkts[i].enmStatus = vboxUSBSolarisGetUrbStatus(pReq->isoc_pkt_descr[i].isoc_pkt_status);
}
- Log((DEVICE_NAME ": vboxUsbSolarisIsocOutXferCompleted: cIsocPkts=%d cbData=%d cbActPkt=%d\n", pUrb->cIsocPkts,
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocOutXferCompleted cIsocPkts=%d cbData=%d cbActPkt=%d\n", pUrb->cIsocPkts,
pUrb->cbDataR3, cbActPkt));
if (pReq->isoc_completion_reason == USB_CR_OK)
@@ -3756,13 +3899,15 @@
/*
* Update the URB and move to landed list for reaping.
*/
- vboxUsbSolarisDeQueueUrb(pUrb, pReq->isoc_completion_reason);
+ vboxUSBSolarisDeQueueURB(pUrb, pReq->isoc_completion_reason);
+ usb_free_isoc_req(pReq);
+ return;
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisIsocOutXferCompleted: Missing private data!?! Dropping OUT pUrb\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocOutXferCompleted missing private data!?! Dropping OUT pUrb.\n"));
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisIsocOutXferCompleted: Pipe Gone\n"));
+ Log((DEVICE_NAME ":vboxUSBSolarisIsocOutXferCompleted Pipe Gone.\n"));
usb_free_isoc_req(pReq);
}
@@ -3775,9 +3920,9 @@
*
* @returns Solaris USB error code.
*/
-LOCAL int vboxUsbSolarisDeviceDisconnected(dev_info_t *pDip)
+LOCAL int vboxUSBSolarisDeviceDisconnected(dev_info_t *pDip)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceDisconnected: pDip=%p\n", pDip));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDeviceDisconnected pDip=%p\n", pDip));
int instance = ddi_get_instance(pDip);
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
@@ -3792,8 +3937,8 @@
pState->DevState = USB_DEV_DISCONNECTED;
- vboxUsbSolarisCloseAllPipes(pState, true /* ControlPipe */);
- vboxUsbSolarisNotifyUnplug(pState);
+ vboxUSBSolarisCloseAllPipes(pState, true /* ControlPipe */);
+ vboxUSBSolarisNotifyHotplug(pState);
mutex_exit(&pState->Mtx);
usb_release_access(pState->StateMulti);
@@ -3801,7 +3946,7 @@
return USB_SUCCESS;
}
- LogRel((DEVICE_NAME ": vboxUsbSolarisDeviceDisconnected: Failed to get device state!\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisDeviceDisconnected failed to get device state!\n"));
return USB_FAILURE;
}
@@ -3813,38 +3958,38 @@
*
* @returns Solaris USB error code.
*/
-LOCAL int vboxUsbSolarisDeviceReconnected(dev_info_t *pDip)
+LOCAL int vboxUSBSolarisDeviceReconnected(dev_info_t *pDip)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceReconnected: pDip=%p\n", pDip));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDeviceReconnected pDip=%p\n", pDip));
int instance = ddi_get_instance(pDip);
vboxusb_state_t *pState = ddi_get_soft_state(g_pVBoxUSBSolarisState, instance);
if (RT_LIKELY(pState))
{
- vboxUsbSolarisDeviceRestore(pState);
+ vboxUSBSolarisDeviceRestore(pState);
return USB_SUCCESS;
}
- LogRel((DEVICE_NAME ": vboxUsbSolarisDeviceReconnected: Failed to get device state!\n"));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisDeviceReconnected failed to get device state!\n"));
return USB_FAILURE;
}
/**
- * Restores device state after a reconnect or resume.
+ * Restore device state after a reconnect or resume.
*
* @param pState The USB device instance.
*/
-LOCAL void vboxUsbSolarisDeviceRestore(vboxusb_state_t *pState)
+LOCAL void vboxUSBSolarisDeviceRestore(vboxusb_state_t *pState)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceRestore: pState=%p\n", pState));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDeviceRestore pState=%p\n", pState));
AssertPtrReturnVoid(pState);
/*
* Raise device power.
*/
- vboxUsbSolarisPowerBusy(pState);
+ vboxUSBSolarisPowerBusy(pState);
int rc = pm_raise_power(pState->pDip, 0 /* component */, USB_DEV_OS_FULL_PWR);
/*
@@ -3864,8 +4009,8 @@
mutex_exit(&pState->Mtx);
/* Do we need to inform userland here? */
- vboxUsbSolarisPowerIdle(pState);
- Log((DEVICE_NAME ": vboxUsbSolarisDeviceRestore: Not the same device\n"));
+ vboxUSBSolarisPowerIdle(pState);
+ Log((DEVICE_NAME ":vboxUSBSolarisDeviceRestore not the same device.\n"));
return;
}
@@ -3883,20 +4028,20 @@
mutex_exit(&pState->Mtx);
usb_release_access(pState->StateMulti);
- vboxUsbSolarisPowerIdle(pState);
+ vboxUSBSolarisPowerIdle(pState);
}
/**
- * Restores device state after a reconnect or resume.
+ * Restore device state after a reconnect or resume.
*
* @param pState The USB device instance.
*
* @returns VBox status code.
*/
-LOCAL int vboxUsbSolarisDeviceSuspend(vboxusb_state_t *pState)
+LOCAL int vboxUSBSolarisDeviceSuspend(vboxusb_state_t *pState)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceSuspend: pState=%p\n", pState));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDeviceSuspend pState=%p\n", pState));
int rc = VERR_VUSB_DEVICE_IS_SUSPENDED;
mutex_enter(&pState->Mtx);
@@ -3905,7 +4050,7 @@
{
case USB_DEV_SUSPENDED:
{
- LogRel((DEVICE_NAME ": vboxUsbSolarisDeviceSuspend: Invalid device state %d\n", pState->DevState));
+ LogRel((DEVICE_NAME ":vboxUSBSolarisDeviceSuspend: Invalid device state %d\n", pState->DevState));
break;
}
@@ -3916,8 +4061,6 @@
int PreviousState = pState->DevState;
pState->DevState = USB_DEV_DISCONNECTED;
- /** @todo this doesn't make sense when for e.g. an INTR IN URB with infinite
- * timeout is pending on the device. Fix suspend logic later. */
/*
* Drain pending URBs.
*/
@@ -3937,8 +4080,7 @@
if (pState->cInflightUrbs > 0)
{
pState->DevState = PreviousState;
- LogRel((DEVICE_NAME ": Cannot suspend %s %s (Ident=%s), %d inflight URBs\n", pState->szMfg, pState->szProduct,
- pState->ClientInfo.szDeviceIdent, pState->cInflightUrbs));
+ LogRel((DEVICE_NAME ":Cannot suspend, still have %d inflight URBs.\n", pState->cInflightUrbs));
mutex_exit(&pState->Mtx);
return VERR_RESOURCE_BUSY;
@@ -3954,44 +4096,41 @@
usb_serialize_access(pState->StateMulti, USB_WAIT, 0);
mutex_enter(&pState->Mtx);
- vboxUsbSolarisCloseAllPipes(pState, true /* default pipe */);
- vboxUsbSolarisNotifyUnplug(pState);
+ vboxUSBSolarisCloseAllPipes(pState, true /* default pipe */);
+ vboxUSBSolarisNotifyHotplug(pState);
mutex_exit(&pState->Mtx);
usb_release_access(pState->StateMulti);
-
- LogRel((DEVICE_NAME ": Suspended %s %s (Ident=%s)\n", pState->szMfg, pState->szProduct,
- pState->ClientInfo.szDeviceIdent));
return VINF_SUCCESS;
}
}
mutex_exit(&pState->Mtx);
- Log((DEVICE_NAME ": vboxUsbSolarisDeviceSuspend: Returns %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisDeviceSuspend returns %d\n", rc));
return rc;
}
/**
- * Restores device state after a reconnect or resume.
+ * Restore device state after a reconnect or resume.
*
* @param pState The USB device instance.
*/
-LOCAL void vboxUsbSolarisDeviceResume(vboxusb_state_t *pState)
+LOCAL void vboxUSBSolarisDeviceResume(vboxusb_state_t *pState)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisDeviceResume: pState=%p\n", pState));
- return vboxUsbSolarisDeviceRestore(pState);
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisDeviceResume pState=%p\n", pState));
+ return vboxUSBSolarisDeviceRestore(pState);
}
/**
- * Flags the PM component as busy so the system will not manage it's power.
+ * Flag the PM component as busy so the system will not manage it's power.
*
* @param pState The USB device instance.
*/
-LOCAL void vboxUsbSolarisPowerBusy(vboxusb_state_t *pState)
+LOCAL void vboxUSBSolarisPowerBusy(vboxusb_state_t *pState)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisPowerBusy: pState=%p\n", pState));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisPowerBusy pState=%p\n", pState));
AssertPtrReturnVoid(pState);
mutex_enter(&pState->Mtx);
@@ -4003,7 +4142,7 @@
int rc = pm_busy_component(pState->pDip, 0 /* component */);
if (rc != DDI_SUCCESS)
{
- Log((DEVICE_NAME ": vboxUsbSolarisPowerBusy: Busy component failed! rc=%d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisPowerBusy busy component failed! rc=%d\n", rc));
mutex_enter(&pState->Mtx);
pState->pPower->PowerBusy--;
mutex_exit(&pState->Mtx);
@@ -4015,13 +4154,13 @@
/**
- * Flags the PM component as idle so its power managed by the system.
+ * Flag the PM component as idle so its power managed by the system.
*
* @param pState The USB device instance.
*/
-LOCAL void vboxUsbSolarisPowerIdle(vboxusb_state_t *pState)
+LOCAL void vboxUSBSolarisPowerIdle(vboxusb_state_t *pState)
{
- LogFunc((DEVICE_NAME ": vboxUsbSolarisPowerIdle: pState=%p\n", pState));
+ LogFunc((DEVICE_NAME ":vboxUSBSolarisPowerIdle pState=%p\n", pState));
AssertPtrReturnVoid(pState);
if (pState->pPower)
@@ -4035,7 +4174,7 @@
mutex_exit(&pState->Mtx);
}
else
- Log((DEVICE_NAME ": vboxUsbSolarisPowerIdle: Idle component failed! rc=%d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBSolarisPowerIdle idle component failed! rc=%d\n", rc));
}
}
diff -Nurb VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSBMon-solaris.c VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSBMon-solaris.c
--- VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSBMon-solaris.c 2016-09-12 16:18:33.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/HostDrivers/VBoxUSB/solaris/VBoxUSBMon-solaris.c 2016-07-18 11:56:23.000000000 +0000
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008-2016 Oracle Corporation
+ * Copyright (C) 2008-2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -171,6 +171,8 @@
static dev_info_t *g_pDip = NULL;
/** Global Mutex. */
static kmutex_t g_VBoxUSBMonSolarisMtx;
+/** Number of userland clients that have kept us open. */
+static uint64_t g_cVBoxUSBMonSolarisClient = 0;
/** Global list of client drivers registered with us. */
vboxusbmon_client_t *g_pVBoxUSBMonSolarisClients = NULL;
/** Opaque pointer to list of soft states. */
@@ -201,7 +203,7 @@
{
int rc;
- LogFunc((DEVICE_NAME ": _init\n"));
+ LogFunc((DEVICE_NAME ":_init\n"));
g_pDip = NULL;
@@ -212,7 +214,7 @@
if (pModCtl)
pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD;
else
- LogRel((DEVICE_NAME ": _init: Failed to disable autounloading!\n"));
+ LogRel((DEVICE_NAME ":failed to disable autounloading!\n"));
/*
* Initialize IPRT R0 driver, which internally calls OS-specific r0 init.
@@ -234,20 +236,20 @@
if (!rc)
return rc;
- LogRel((DEVICE_NAME ": _init: mod_install failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":mod_install failed! rc=%d\n", rc));
ddi_soft_state_fini(&g_pVBoxUSBMonSolarisState);
}
else
- LogRel((DEVICE_NAME ": _init: ddi_soft_state_init failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":ddi_soft_state_init failed! rc=%d\n", rc));
}
else
- LogRel((DEVICE_NAME ": _init: VBoxUSBFilterInit failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":VBoxUSBFilterInit failed! rc=%d\n", rc));
mutex_destroy(&g_VBoxUSBMonSolarisMtx);
RTR0Term();
}
else
- LogRel((DEVICE_NAME ": _init: RTR0Init failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":RTR0Init failed! rc=%d\n", rc));
return -1;
}
@@ -257,7 +259,7 @@
{
int rc;
- LogFunc((DEVICE_NAME ": _fini\n"));
+ LogFunc((DEVICE_NAME ":_fini\n"));
rc = mod_remove(&g_VBoxUSBMonSolarisModLinkage);
if (!rc)
@@ -274,7 +276,7 @@
int _info(struct modinfo *pModInfo)
{
- LogFunc((DEVICE_NAME ": _info\n"));
+ LogFunc((DEVICE_NAME ":_info\n"));
return mod_info(&g_VBoxUSBMonSolarisModLinkage, pModInfo);
}
@@ -290,14 +292,14 @@
*/
static int VBoxUSBMonSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd)
{
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisAttach: pDip=%p enmCmd=%d\n", pDip, enmCmd));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisAttach pDip=%p enmCmd=%d\n", pDip, enmCmd));
switch (enmCmd)
{
case DDI_ATTACH:
{
if (RT_UNLIKELY(g_pDip))
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisAttach: Global instance already initialized\n"));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisAttach global instance already initialized.\n"));
return DDI_FAILURE;
}
@@ -307,17 +309,11 @@
"none", "none", 0660);
if (rc == DDI_SUCCESS)
{
- rc = usb_register_dev_driver(g_pDip, VBoxUSBMonSolarisElectDriver);
- if (rc == DDI_SUCCESS)
- {
ddi_report_dev(pDip);
- return DDI_SUCCESS;
- }
-
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisAttach: Failed to register driver election callback! rc=%d\n", rc));
+ return rc;
}
else
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisAttach: ddi_create_minor_node failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisAttach ddi_create_minor_node failed! rc=%d\n", rc));
return DDI_FAILURE;
}
@@ -343,7 +339,7 @@
*/
static int VBoxUSBMonSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)
{
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisDetach\n"));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisDetach\n"));
switch (enmCmd)
{
@@ -362,8 +358,6 @@
}
mutex_exit(&g_VBoxUSBMonSolarisMtx);
- usb_unregister_dev_driver(g_pDip);
-
ddi_remove_minor_node(pDip, NULL);
g_pDip = NULL;
return DDI_SUCCESS;
@@ -395,7 +389,7 @@
{
int rc = DDI_SUCCESS;
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisGetInfo\n"));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisGetInfo\n"));
switch (enmCmd)
{
@@ -420,7 +414,7 @@
vboxusbmon_state_t *pState = NULL;
unsigned iOpenInstance;
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisOpen\n"));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisOpen\n"));
/*
* Verify we are being opened as a character device.
@@ -433,10 +427,26 @@
*/
if (!g_pDip)
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisOpen: Invalid state for opening\n"));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisOpen invalid state for opening.\n"));
return ENXIO;
}
+ mutex_enter(&g_VBoxUSBMonSolarisMtx);
+ if (!g_cVBoxUSBMonSolarisClient)
+ {
+ mutex_exit(&g_VBoxUSBMonSolarisMtx);
+ int rc = usb_register_dev_driver(g_pDip, VBoxUSBMonSolarisElectDriver);
+ if (RT_UNLIKELY(rc != DDI_SUCCESS))
+ {
+ LogRel((DEVICE_NAME ":Failed to register driver election callback with USBA rc=%d\n", rc));
+ return EINVAL;
+ }
+ Log((DEVICE_NAME ":Successfully registered election callback with USBA\n"));
+ mutex_enter(&g_VBoxUSBMonSolarisMtx);
+ }
+ g_cVBoxUSBMonSolarisClient++;
+ mutex_exit(&g_VBoxUSBMonSolarisMtx);
+
for (iOpenInstance = 0; iOpenInstance < 4096; iOpenInstance++)
{
if ( !ddi_get_soft_state(g_pVBoxUSBMonSolarisState, iOpenInstance) /* faster */
@@ -448,7 +458,10 @@
}
if (!pState)
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisOpen: Too many open instances"));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisOpen: too many open instances."));
+ mutex_enter(&g_VBoxUSBMonSolarisMtx);
+ g_cVBoxUSBMonSolarisClient--;
+ mutex_exit(&g_VBoxUSBMonSolarisMtx);
return ENXIO;
}
@@ -465,15 +478,35 @@
static int VBoxUSBMonSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred)
{
vboxusbmon_state_t *pState = NULL;
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisClose\n"));
+
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisClose\n"));
pState = ddi_get_soft_state(g_pVBoxUSBMonSolarisState, getminor(Dev));
if (!pState)
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisClose: Failed to get state\n"));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisClose: failed to get pState.\n"));
return EFAULT;
}
+ mutex_enter(&g_VBoxUSBMonSolarisMtx);
+ g_cVBoxUSBMonSolarisClient--;
+ if (!g_cVBoxUSBMonSolarisClient)
+ {
+ if (RT_LIKELY(g_pDip))
+ {
+ mutex_exit(&g_VBoxUSBMonSolarisMtx);
+ usb_unregister_dev_driver(g_pDip);
+ Log((DEVICE_NAME ":Successfully deregistered driver election callback\n"));
+ }
+ else
+ {
+ mutex_exit(&g_VBoxUSBMonSolarisMtx);
+ LogRel((DEVICE_NAME ":Extreme error! Missing device info during close.\n"));
+ }
+ }
+ else
+ mutex_exit(&g_VBoxUSBMonSolarisMtx);
+
/*
* Remove all filters for this client process.
*/
@@ -492,14 +525,14 @@
static int VBoxUSBMonSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred)
{
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisRead\n"));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisRead\n"));
return 0;
}
static int VBoxUSBMonSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred)
{
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisWrite\n"));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisWrite\n"));
return 0;
}
@@ -514,7 +547,7 @@
static int VBoxUSBMonSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal)
{
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: Dev=%d Cmd=%d pArg=%p Mode=%d\n", Dev, Cmd, pArg));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl Dev=%d Cmd=%d pArg=%p Mode=%d\n", Dev, Cmd, pArg));
/*
* Get the session from the soft state item.
@@ -522,7 +555,7 @@
vboxusbmon_state_t *pState = ddi_get_soft_state(g_pVBoxUSBMonSolarisState, getminor(Dev));
if (!pState)
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: No state data for minor instance %d\n", getminor(Dev)));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: no state data for %d\n", getminor(Dev)));
return EINVAL;
}
@@ -533,27 +566,26 @@
VBOXUSBREQ ReqWrap;
if (IOCPARM_LEN(Cmd) != sizeof(ReqWrap))
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd),
- sizeof(ReqWrap)));
+ LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd), sizeof(ReqWrap)));
return ENOTTY;
}
int rc = ddi_copyin((void *)pArg, &ReqWrap, sizeof(ReqWrap), Mode);
if (RT_UNLIKELY(rc))
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d\n", pArg, Cmd, rc));
+ LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d.\n", pArg, Cmd, rc));
return EINVAL;
}
if (ReqWrap.u32Magic != VBOXUSBMON_MAGIC)
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: Bad magic %#x; pArg=%p Cmd=%d\n", ReqWrap.u32Magic, pArg, Cmd));
+ LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: bad magic %#x; pArg=%p Cmd=%d.\n", ReqWrap.u32Magic, pArg, Cmd));
return EINVAL;
}
if (RT_UNLIKELY( ReqWrap.cbData == 0
|| ReqWrap.cbData > _1M*16))
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: Bad size %#x; pArg=%p Cmd=%d\n", ReqWrap.cbData, pArg, Cmd));
+ LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: bad size %#x; pArg=%p Cmd=%d.\n", ReqWrap.cbData, pArg, Cmd));
return EINVAL;
}
@@ -563,7 +595,7 @@
void *pvBuf = RTMemTmpAlloc(ReqWrap.cbData);
if (RT_UNLIKELY(!pvBuf))
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes\n", ReqWrap.cbData));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap.cbData));
return ENOMEM;
}
@@ -571,18 +603,17 @@
if (RT_UNLIKELY(rc))
{
RTMemTmpFree(pvBuf);
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyin failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd,
- rc));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: ddi_copyin failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc));
return EFAULT;
}
if (RT_UNLIKELY( ReqWrap.cbData != 0
&& !VALID_PTR(pvBuf)))
{
RTMemTmpFree(pvBuf);
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: pvBuf Invalid pointer %p\n", pvBuf));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: pvBuf invalid pointer %p\n", pvBuf));
return EINVAL;
}
- Log((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: pid=%d\n", (int)RTProcSelf()));
+ Log((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: pid=%d.\n", (int)RTProcSelf()));
/*
* Process the IOCtl.
@@ -594,7 +625,7 @@
if (RT_UNLIKELY(cbDataReturned > ReqWrap.cbData))
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: Too much output data %d expected %d\n", cbDataReturned, ReqWrap.cbData));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap.cbData));
cbDataReturned = ReqWrap.cbData;
}
@@ -614,15 +645,14 @@
rc = ddi_copyout(pvBuf, (void *)(uintptr_t)ReqWrap.pvDataR3, cbDataReturned, Mode);
if (RT_UNLIKELY(rc))
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyout failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf,
- pArg, Cmd, rc));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: ddi_copyout failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc));
rc = EFAULT;
}
}
}
else
{
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisIOCtl: ddi_copyout(1) failed pArg=%p Cmd=%d\n", pArg, Cmd));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisIOCtl: ddi_copyout(1) failed pArg=%p Cmd=%d\n", pArg, Cmd));
rc = EFAULT;
}
@@ -648,7 +678,7 @@
*/
static int vboxUSBMonSolarisProcessIOCtl(int iFunction, void *pvState, void *pvData, size_t cbData, size_t *pcbReturnedData)
{
- LogFunc((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: iFunction=%d pvBuf=%p cbBuf=%zu\n", iFunction, pvData, cbData));
+ LogFunc((DEVICE_NAME ":solarisUSBProcessIOCtl iFunction=%d pvBuf=%p cbBuf=%zu\n", iFunction, pvData, cbData));
AssertPtrReturn(pvState, VERR_INVALID_POINTER);
vboxusbmon_state_t *pState = (vboxusbmon_state_t *)pvState;
@@ -678,8 +708,7 @@
VBOXUSBREQ_ADD_FILTER *pReq = (VBOXUSBREQ_ADD_FILTER *)pvData;
PUSBFILTER pFilter = (PUSBFILTER)&pReq->Filter;
- Log(("vboxUSBMonSolarisProcessIOCtl: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x "
- "bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x\n",
+ Log(("vboxUSBMonSolarisProcessIOCtl: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x\n",
USBFilterGetNum(pFilter, USBFILTERIDX_VENDOR_ID),
USBFilterGetNum(pFilter, USBFILTERIDX_PRODUCT_ID),
USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_REV),
@@ -697,7 +726,7 @@
rc = VBoxUSBFilterAdd(pFilter, pState->Process, &pReq->uId);
*pcbReturnedData = cbData;
- Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: ADD_FILTER (Process:%d) returned %d\n", pState->Process, rc));
+ Log((DEVICE_NAME ":vboxUSBMonSolarisProcessIOCtl: ADD_FILTER (Process:%d) returned %d\n", pState->Process, rc));
break;
}
@@ -708,7 +737,7 @@
VBOXUSBREQ_REMOVE_FILTER *pReq = (VBOXUSBREQ_REMOVE_FILTER *)pvData;
rc = VBoxUSBFilterRemove(pState->Process, (uintptr_t)pReq->uId);
*pcbReturnedData = 0;
- Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: REMOVE_FILTER (Process:%d) returned %d\n", pState->Process, rc));
+ Log((DEVICE_NAME ":vboxUSBMonSolarisProcessIOCtl: REMOVE_FILTER (Process:%d) returned %d\n", pState->Process, rc));
break;
}
@@ -719,7 +748,7 @@
VBOXUSBREQ_RESET_DEVICE *pReq = (VBOXUSBREQ_RESET_DEVICE *)pvData;
rc = vboxUSBMonSolarisResetDevice(pReq->szDevicePath, pReq->fReattach);
*pcbReturnedData = 0;
- Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: RESET_DEVICE (Process:%d) returned %d\n", pState->Process, rc));
+ Log((DEVICE_NAME ":vboxUSBMonSolarisProcessIOCtl: RESET_DEVICE (Process:%d) returned %d\n", pState->Process, rc));
break;
}
@@ -730,7 +759,7 @@
VBOXUSBREQ_CLIENT_INFO *pReq = (VBOXUSBREQ_CLIENT_INFO *)pvData;
rc = vboxUSBMonSolarisClientInfo(pState, pReq);
*pcbReturnedData = cbData;
- Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: CLIENT_INFO (Process:%d) returned %d\n", pState->Process, rc));
+ Log((DEVICE_NAME ":vboxUSBMonSolarisProcessIOCtl: CLIENT_INFO (Process:%d) returned %d\n", pState->Process, rc));
break;
}
@@ -743,14 +772,13 @@
pGetVersionReq->u32Minor = VBOXUSBMON_VERSION_MINOR;
*pcbReturnedData = sizeof(VBOXUSBREQ_GET_VERSION);
rc = VINF_SUCCESS;
- Log((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: GET_VERSION returned %d\n", rc));
+ Log((DEVICE_NAME ":vboxUSBMonSolarisProcessIOCtl: GET_VERSION returned %d\n", rc));
break;
}
default:
{
- LogRel((DEVICE_NAME ": vboxUSBMonSolarisProcessIOCtl: Unknown request (Process:%d) %#x\n", pState->Process,
- iFunction));
+ LogRel((DEVICE_NAME ":vboxUSBMonSolarisProcessIOCtl: Unknown request (Process:%d) %#x\n", pState->Process, iFunction));
*pcbReturnedData = 0;
rc = VERR_NOT_SUPPORTED;
break;
@@ -764,7 +792,7 @@
{
int rc = VERR_GENERAL_FAILURE;
- LogFunc((DEVICE_NAME ": vboxUSBMonSolarisResetDevice: pszDevicePath=%s fReattach=%d\n", pszDevicePath, fReattach));
+ LogFunc((DEVICE_NAME ":vboxUSBMonSolarisResetDevice pszDevicePath=%s fReattach=%d\n", pszDevicePath, fReattach));
/*
* Try grabbing the dev_info_t.
@@ -783,7 +811,7 @@
pTmpDeviceInfo = ddi_get_parent(pDeviceInfo);
if (!pTmpDeviceInfo)
{
- LogRel((DEVICE_NAME ":vboxUSBMonSolarisResetDevice: Failed to get parent device info for %s\n", pszDevicePath));
+ LogRel((DEVICE_NAME ":vboxUSBMonSolarisResetDevice failed to get parent device info for %s\n", pszDevicePath));
return VERR_GENERAL_FAILURE;
}
@@ -797,9 +825,7 @@
* Try re-enumerating the device.
*/
rc = usb_reset_device(pDeviceInfo, fReattach ? USB_RESET_LVL_REATTACH : USB_RESET_LVL_DEFAULT);
- Log((DEVICE_NAME ": vboxUSBMonSolarisResetDevice: usb_reset_device for %s level=%s rc=%d\n", pszDevicePath,
- fReattach ? "ReAttach" : "Default", rc));
-
+ Log((DEVICE_NAME ":usb_reset_device for %s level=%s returned %d\n", pszDevicePath, fReattach ? "ReAttach" : "Default", rc));
switch (rc)
{
case USB_SUCCESS: rc = VINF_SUCCESS; break;
@@ -815,7 +841,7 @@
else
{
rc = VERR_INVALID_HANDLE;
- LogRel((DEVICE_NAME ": vboxUSBMonSolarisResetDevice: Cannot obtain device info for %s\n", pszDevicePath));
+ LogRel((DEVICE_NAME ":vboxUSBMonSolarisResetDevice Cannot obtain device info for %s\n", pszDevicePath));
}
return rc;
@@ -832,7 +858,7 @@
*/
static int vboxUSBMonSolarisClientInfo(vboxusbmon_state_t *pState, PVBOXUSB_CLIENT_INFO pClientInfo)
{
- LogFunc((DEVICE_NAME ": vboxUSBMonSolarisClientInfo: pState=%p pClientInfo=%p\n", pState, pClientInfo));
+ LogFunc((DEVICE_NAME ":vboxUSBMonSolarisClientInfo pState=%p pClientInfo=%p\n", pState, pClientInfo));
AssertPtrReturn(pState, VERR_INVALID_POINTER);
AssertPtrReturn(pClientInfo, VERR_INVALID_POINTER);
@@ -855,14 +881,14 @@
{
rc = pCur->Info.pfnSetConsumerCredentials(pState->Process, pCur->Info.Instance, NULL /* pvReserved */);
if (RT_FAILURE(rc))
- LogRel((DEVICE_NAME ": vboxUSBMonSolarisClientInfo: pfnSetConsumerCredentials failed! rc=%d\n", rc));
+ LogRel((DEVICE_NAME ":vboxUSBMonSolarisClientInfo pfnSetConsumerCredentials failed. rc=%d\n", rc));
}
else
rc = VERR_INVALID_FUNCTION;
mutex_exit(&g_VBoxUSBMonSolarisMtx);
- Log((DEVICE_NAME ": vboxUSBMonSolarisClientInfo: Found %s, rc=%d\n", pClientInfo->szDeviceIdent, rc));
+ Log((DEVICE_NAME ":vboxUSBMonSolarisClientInfo found. %s rc=%d\n", pClientInfo->szDeviceIdent, rc));
return rc;
}
pPrev = pCur;
@@ -871,7 +897,7 @@
mutex_exit(&g_VBoxUSBMonSolarisMtx);
- LogRel((DEVICE_NAME ": vboxUSBMonSolarisClientInfo: Failed to find client %s\n", pClientInfo->szDeviceIdent));
+ LogRel((DEVICE_NAME ":vboxUSBMonSolarisClientInfo Failed to find client %s\n", pClientInfo->szDeviceIdent));
return VERR_NOT_FOUND;
}
@@ -883,7 +909,7 @@
*/
int VBoxUSBMonSolarisRegisterClient(dev_info_t *pClientDip, PVBOXUSB_CLIENT_INFO pClientInfo)
{
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisRegisterClient: pClientDip=%p pClientInfo=%p\n", pClientDip, pClientInfo));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisRegisterClient pClientDip=%p pClientInfo=%p\n", pClientDip, pClientInfo));
AssertPtrReturn(pClientInfo, VERR_INVALID_PARAMETER);
if (RT_LIKELY(g_pDip))
@@ -902,8 +928,9 @@
g_pVBoxUSBMonSolarisClients = pClient;
mutex_exit(&g_VBoxUSBMonSolarisMtx);
- Log((DEVICE_NAME ": Client registered (ClientPath=%s Ident=%s)\n", pClient->Info.szClientPath,
- pClient->Info.szDeviceIdent));
+ Log((DEVICE_NAME ":VBoxUSBMonSolarisRegisterClient registered. %d %s %s\n",
+ pClient->Info.Instance, pClient->Info.szClientPath, pClient->Info.szDeviceIdent));
+
return VINF_SUCCESS;
}
return VERR_NO_MEMORY;
@@ -919,7 +946,7 @@
*/
int VBoxUSBMonSolarisUnregisterClient(dev_info_t *pClientDip)
{
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisUnregisterClient: pClientDip=%p\n", pClientDip));
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisUnregisterClient pClientDip=%p\n", pClientDip));
AssertReturn(pClientDip, VERR_INVALID_PARAMETER);
if (RT_LIKELY(g_pDip))
@@ -939,9 +966,10 @@
mutex_exit(&g_VBoxUSBMonSolarisMtx);
- Log((DEVICE_NAME ": Client unregistered (ClientPath=%s Ident=%s)\n", pCur->Info.szClientPath,
- pCur->Info.szDeviceIdent));
+ Log((DEVICE_NAME ":VBoxUSBMonSolarisUnregisterClient unregistered. %d %s %s\n",
+ pCur->Info.Instance, pCur->Info.szClientPath, pCur->Info.szDeviceIdent));
RTMemFree(pCur);
+ pCur = NULL;
return VINF_SUCCESS;
}
pPrev = pCur;
@@ -950,7 +978,7 @@
mutex_exit(&g_VBoxUSBMonSolarisMtx);
- LogRel((DEVICE_NAME ": VBoxUSBMonSolarisUnregisterClient: Failed to find registered client %p\n", pClientDip));
+ LogRel((DEVICE_NAME ":VBoxUSBMonSolarisUnregisterClient Failed to find registered client %p\n", pClientDip));
return VERR_NOT_FOUND;
}
return VERR_INVALID_STATE;
@@ -972,7 +1000,7 @@
int VBoxUSBMonSolarisElectDriver(usb_dev_descr_t *pDevDesc, usb_dev_str_t *pDevStrings, char *pszDevicePath, int Bus, int Port,
char **ppszDrv, void *pvReserved)
{
- LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: pDevDesc=%p pDevStrings=%p pszDevicePath=%s Bus=%d Port=%d\n", pDevDesc,
+ LogFunc((DEVICE_NAME ":VBoxUSBMonSolarisElectDriver pDevDesc=%p pDevStrings=%p pszDevicePath=%s Bus=%d Port=%d\n", pDevDesc,
pDevStrings, pszDevicePath, Bus, Port));
AssertPtrReturn(pDevDesc, USB_FAILURE);
@@ -1001,8 +1029,7 @@
/* This doesn't work like it should (USBFilterMatch fails on matching field (6) i.e. Bus despite this. Investigate later. */
USBFilterSetMustBePresent(&Filter, USBFILTERIDX_BUS, false /* fMustBePresent */);
- Log((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x "
- "bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x\n",
+ Log((DEVICE_NAME ":VBoxUSBMonSolarisElectDriver: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x\n",
USBFilterGetNum(&Filter, USBFILTERIDX_VENDOR_ID),
USBFilterGetNum(&Filter, USBFILTERIDX_PRODUCT_ID),
USBFilterGetNum(&Filter, USBFILTERIDX_DEVICE_REV),
@@ -1011,7 +1038,7 @@
USBFilterGetNum(&Filter, USBFILTERIDX_DEVICE_PROTOCOL),
USBFilterGetNum(&Filter, USBFILTERIDX_BUS),
USBFilterGetNum(&Filter, USBFILTERIDX_PORT)));
- Log((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: Manufacturer=%s Product=%s Serial=%s\n",
+ Log((DEVICE_NAME ":VBoxUSBMonSolarisElectDriver: Manufacturer=%s Product=%s Serial=%s\n",
USBFilterGetString(&Filter, USBFILTERIDX_MANUFACTURER_STR) ? USBFilterGetString(&Filter, USBFILTERIDX_MANUFACTURER_STR) : "<null>",
USBFilterGetString(&Filter, USBFILTERIDX_PRODUCT_STR) ? USBFilterGetString(&Filter, USBFILTERIDX_PRODUCT_STR) : "<null>",
USBFilterGetString(&Filter, USBFILTERIDX_SERIAL_NUMBER_STR) ? USBFilterGetString(&Filter, USBFILTERIDX_SERIAL_NUMBER_STR) : "<null>"));
@@ -1024,24 +1051,13 @@
USBFilterDelete(&Filter);
if (Owner == NIL_RTPROCESS)
{
- Log((DEVICE_NAME ": VBoxUSBMonSolarisElectDriver: No matching filters, device %#x:%#x uninteresting\n",
- pDevDesc->idVendor, pDevDesc->idProduct));
+ Log((DEVICE_NAME ":No matching filters, device %#x:%#x uninteresting.\n", pDevDesc->idVendor, pDevDesc->idProduct));
return USB_FAILURE;
}
*ppszDrv = ddi_strdup(VBOXUSB_DRIVER_NAME, KM_SLEEP);
-#if 0
- LogRel((DEVICE_NAME ": Capturing %s %s %#x:%#x:%s Bus=%d Port=%d\n",
- pDevStrings->usb_mfg ? pDevStrings->usb_mfg : "<Unknown Manufacturer>",
- pDevStrings->usb_product ? pDevStrings->usb_product : "<Unnamed USB device>",
- pDevDesc->idVendor, pDevDesc->idProduct, pszDevicePath, Bus, Port));
-#else
- /* Until IPRT R0 logging is fixed. See @bugref{6657#c7} */
- cmn_err(CE_CONT, "Capturing %s %s 0x%x:0x%x:%s Bus=%d Port=%d\n",
- pDevStrings->usb_mfg ? pDevStrings->usb_mfg : "<Unknown Manufacturer>",
- pDevStrings->usb_product ? pDevStrings->usb_product : "<Unnamed USB device>",
- pDevDesc->idVendor, pDevDesc->idProduct, pszDevicePath, Bus, Port);
-#endif
+ LogRel((DEVICE_NAME ": Capturing %s %#x:%#x:%s\n", pDevStrings->usb_product ? pDevStrings->usb_product : "<Unnamed USB device>",
+ pDevDesc->idVendor, pDevDesc->idProduct, pszDevicePath));
return USB_SUCCESS;
}
gdiff -Nurb VirtualBox-5.1.6/src/VBox/Installer/solaris/vboxconfig.sh VirtualBox-5.1.6/src/VBox/Installer/solaris/vboxconfig.sh
--- VirtualBox-5.1.6/src/VBox/Installer/solaris/vboxconfig.sh 2016-09-12 16:18:39.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/Installer/solaris/vboxconfig.sh 2016-09-16 13:12:45.593727486 +0000
@@ -1,11 +1,11 @@
#!/bin/sh
-# $Id: vboxconfig.sh $
+# $Id: vboxconfig.sh 91874 2014-01-28 12:29:16Z ramshankar $
## @file
-# VirtualBox Configuration Script, Solaris host.
+# VirtualBox Configuration Script, Solaris (10, 11, 12, SXCE, illumos) host.
#
#
-# Copyright (C) 2009-2015 Oracle Corporation
+# Copyright (C) 2009-2013 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
@@ -46,8 +46,6 @@
BIN_SVCS=/usr/bin/svcs
BIN_ID=/usr/bin/id
BIN_PKILL=/usr/bin/pkill
-BIN_PGREP=/usr/bin/pgrep
-BIN_IPADM=/usr/sbin/ipadm
# "vboxdrv" is also used in sed lines here (change those as well if it ever changes)
MOD_VBOXDRV=vboxdrv
@@ -55,7 +53,7 @@
MOD_VBOXNET=vboxnet
DESC_VBOXNET="NetAdapter"
-MOD_VBOXNET_INST=8
+MOD_VBOXNET_INST=32
MOD_VBOXFLT=vboxflt
DESC_VBOXFLT="NetFilter (STREAMS)"
@@ -80,21 +78,21 @@
infoprint()
{
- if test "x$ISSILENT" != "x$SILENTOP"; then
+ if test "$ISSILENT" != "$SILENTOP"; then
echo 1>&2 "$1"
fi
}
subprint()
{
- if test "x$ISSILENT" != "x$SILENTOP"; then
+ if test "$ISSILENT" != "$SILENTOP"; then
echo 1>&2 " - $1"
fi
}
warnprint()
{
- if test "x$ISSILENT" != "x$SILENTOP"; then
+ if test "$ISSILENT" != "$SILENTOP"; then
echo 1>&2 " * Warning!! $1"
fi
}
@@ -205,14 +203,6 @@
if test ! -x "$BIN_PKILL"; then
BIN_PKILL=`find_bin_path "$BIN_PKILL"`
fi
-
- if test ! -x "$BIN_PGREP"; then
- BIN_PGREP=`find_bin_path "$BIN_PGREP"`
- fi
-
- if test ! -x "$BIN_IPADM"; then
- BIN_IPADM=`find_bin_path "$BIN_IPADM"`
- fi
}
# check_root()
@@ -228,27 +218,10 @@
fi
}
-# get_sysinfo_other()
-# cannot fail
-get_unofficial_sysinfo()
-{
- HOST_OS_MAJORVERSION="11"
- HOST_OS_MINORVERSION="151"
-}
-
-# get_sysinfo()
+# get_sysinfo
# cannot fail
get_sysinfo()
{
- # First check 'uname -v' and weed out the recognized, unofficial distros of Solaris
- STR_OSVER=`uname -v`
- case "$STR_OSVER" in
- omnios*|oi_*|illumos*)
- get_unofficial_sysinfo
- return 0
- ;;
- esac
-
BIN_PKG=`which pkg 2> /dev/null`
if test -x "$BIN_PKG"; then
PKGFMRI=`$BIN_PKG $BASEDIR_PKGOPT contents -H -t set -a name=pkg.fmri -o pkg.fmri pkg:/system/kernel 2> /dev/null`
@@ -266,17 +239,19 @@
# The format is "pkg://solaris/system/kernel@0.5.11,5.11-0.161:20110315T070332Z"
# or "pkg://solaris/system/kernel@5.12,5.11-5.12.0.0.0.4.1:20120908T030246Z"
# or "pkg://solaris/system/kernel@0.5.11,5.11-0.175.0.0.0.1.0:20111012T032837Z"
- # or "pkg://solaris/system/kernel@5.12-5.12.0.0.0.9.1.3.0:20121012T032837Z" [1]
- # [1]: The sed below doesn't handle this. It's instead parsed below in the PSARC/2012/240 case.
- STR_KERN_MAJOR=`echo "$PKGFMRI" | sed 's/^.*\@//;s/\,.*//'`
+ # OI 151a8 "pkg://openindiana.org/system/kernel@0.5.11,5.11-0.151.1.8:20130721T133142Z"
+ # OI Hipster'15 "pkg://openindiana.org/system/kernel@0.5.11-2015.0.1.15135:20150621T130732Z"
+ # OmniOS Bloody "pkg://omnios/system/kernel@0.5.11,5.11-0.151015:20150519T142340Z"
+ # or "pkg://solaris/system/kernel@5.12-5.12.0.0.0.9.1.3.0:20121012T032837Z"
+ STR_KERN_MAJOR=`echo "$PKGFMRI" | sed 's/^.*\@//;s/\,.*//;s/\-.*//'`
if test ! -z "$STR_KERN_MAJOR"; then
# The format is "0.5.11" or "5.12"
# Let us just hardcode these for now, instead of trying to do things more generically. It's not
# worth trying to bring more order to chaos as it's clear that the version numbering is subject to breakage
# as it has been seen in the past.
- if test "x$STR_KERN_MAJOR" = "x5.12"; then
+ if test "$STR_KERN_MAJOR" = "5.12"; then
HOST_OS_MAJORVERSION="12"
- elif test "x$STR_KERN_MAJOR" = "x0.5.11" || test "x$STR_KERN_MAJOR" = "x5.11"; then
+ elif test "$STR_KERN_MAJOR" = "0.5.11" || test "$STR_KERN_MAJOR" = "5.11"; then
HOST_OS_MAJORVERSION="11"
else
# This could be the PSARC/2012/240 naming scheme for S12.
@@ -287,7 +262,7 @@
# the build number.
BRANCH_VERSION=$STR_KERN_MAJOR
HOST_OS_MAJORVERSION=`echo "$BRANCH_VERSION" | cut -f2 -d'-' | cut -f1,2 -d'.'`
- if test "x$HOST_OS_MAJORVERSION" = "x5.12"; then
+ if test "$HOST_OS_MAJORVERSION" = "5.12"; then
HOST_OS_MAJORVERSION="12"
HOST_OS_MINORVERSION=`echo "$BRANCH_VERSION" | cut -f2 -d'-' | cut -f6 -d'.'`
return 0
@@ -308,6 +283,16 @@
HOST_OS_MINORVERSION=`echo "$STR_KERN_MINOR" | cut -f2 -d'-' | cut -f6 -d'.'`
elif test "$HOST_OS_MAJORVERSION" -eq 11; then
HOST_OS_MINORVERSION=`echo "$STR_KERN_MINOR" | cut -f2 -d'-' | cut -f2 -d'.'`
+ case "`uname -v`" in
+ Generic_*) ;; # Sun/Oracle Solaris GA release
+ snv_*) # OpenSolaris
+ HOST_OS_MINORVERSION="`uname -v | sed 's/^snv_//'`" || \
+ HOST_OS_MINORVERSION=0 ;;
+ oi*|omnios*|illumos*) # More distros welcome
+ infoprint "Detected an opensource Solaris descendant, assuming snv_151 compatibility"
+ HOST_OS_MINORVERSION=151
+ ;;
+ esac
else
errorprint "Solaris kernel major version $HOST_OS_MAJORVERSION not supported."
exit 1
@@ -326,17 +311,33 @@
fi
else
HOST_OS_MAJORVERSION=`uname -r`
- if test -z "$HOST_OS_MAJORVERSION" || test "x$HOST_OS_MAJORVERSION" != "x5.10"; then
+ if test -z "$HOST_OS_MAJORVERSION" || test "$HOST_OS_MAJORVERSION" != "5.10"; then
+ case "`uname -v`" in
+ snv*) if grep "Solaris Express Community Edition snv_" $PKG_INSTALL_ROOT/etc/release 2>/dev/null; then
+ infoprint "WARNING: Solaris SXCE detected... you really should upgrade!"
+ infoprint " Assuming that Solaris 10 methods are applicable."
+ HOST_OS_MAJORVERSION=SXCE
+ fi ;;
+ esac
+ if test "$HOST_OS_MAJORVERSION" != "SXCE"; then
# S11 without 'pkg'?? Something's wrong... bail.
- errorprint "Solaris $HOST_OS_MAJORVERSION detected without executable $BIN_PKG !? I are confused."
+ errorprint "Solaris $HOST_OS_MAJORVERSION detected without executable $BIN_PKG !? I am confused."
exit 1
fi
+ HOST_OS_MAJORVERSION="11"
+ HOST_OS_MINORVERSION="`uname -v | sed 's/^snv_//'`" || \
+ HOST_OS_MINORVERSION=0
+ else
HOST_OS_MAJORVERSION="10"
+ fi
+
if test "$REMOTEINST" -eq 0; then
+ if test "$HOST_OS_MAJORVERSION" != 11 ; then
# Use uname to verify it's S10.
# Major version is S10, Minor version is no longer relevant (or used), use uname -v so it gets something
# like "Generic_blah" for purely cosmetic purposes
HOST_OS_MINORVERSION=`uname -v`
+ fi
else
# Remote installs from S10 local.
BIN_PKGCHK=`which pkgchk 2> /dev/null`
@@ -347,11 +348,13 @@
fi
REMOTE_S10=`$BIN_PKGCHK -l -p /kernel/amd64/genunix $BASEDIR_PKGOPT 2> /dev/null | grep SUNWckr | tr -d ' \t'`
- if test ! -z "$REMOTE_S10" && test "x$REMOTE_S10" = "xSUNWckr"; then
+ if test ! -z "$REMOTE_S10" && test "$REMOTE_S10" = "SUNWckr"; then
+ if test "$HOST_OS_MAJORVERSION" != 11 ; then
HOST_OS_MAJORVERSION="10"
HOST_OS_MINORVERSION=""
+ fi
else
- errorprint "Remote target $PKG_INSTALL_ROOT is not Solaris 10."
+ errorprint "Remote target $PKG_INSTALL_ROOT is not Solaris 10 nor SXCE."
errorprint "Will not attempt to install to an unidentified remote target."
exit 1
fi
@@ -364,7 +367,7 @@
check_zone()
{
currentzone=`zonename`
- if test "x$currentzone" != "xglobal"; then
+ if test "$currentzone" != "global"; then
errorprint "This script must be run from the global zone."
exit 1
fi
@@ -375,7 +378,7 @@
check_isa()
{
currentisa=`uname -i`
- if test "x$currentisa" = "xi86xpv"; then
+ if test "$currentisa" = "i86xpv"; then
errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!"
exit 1
fi
@@ -386,7 +389,7 @@
check_module_arch()
{
cputype=`isainfo -k`
- if test "x$cputype" != "xamd64" && test "x$cputype" != "xi386"; then
+ if test "$cputype" != "amd64" && test "$cputype" != "i386"; then
errorprint "VirtualBox works only on i386/amd64 hosts, not $cputype"
exit 1
fi
@@ -458,27 +461,28 @@
modperm="$5"
if test -n "$modperm"; then
- if test "x$nullop" = "x$NULLOP"; then
+ if test "$nullop" = "$NULLOP"; then
$BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname >/dev/null 2>&1
else
$BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname
fi
else
- if test "x$nullop" = "x$NULLOP"; then
+ if test "$nullop" = "$NULLOP"; then
$BIN_ADDDRV $BASEDIR_OPT $modname >/dev/null 2>&1
else
$BIN_ADDDRV $BASEDIR_OPT $modname
fi
fi
- if test "$?" -ne 0; then
+ if test $? -ne 0; then
subprint "Adding: $moddesc module ...FAILED!"
- if test "x$fatal" = "x$FATALOP"; then
+ if test "$fatal" = "$FATALOP"; then
exit 1
fi
return 1
- fi
+ elif test "$REMOTEINST" -eq 1 && test "$?" -eq 0; then
subprint "Added: $moddesc driver"
+ fi
return 0
}
@@ -498,18 +502,18 @@
module_added $modname
if test "$?" -eq 0; then
UPDATEBOOTARCHIVE=1
- if test "x$ISIPS" != "x$IPSOP"; then
+ if test "$ISIPS" != "$IPSOP"; then
$BIN_REMDRV $BASEDIR_OPT $modname
else
$BIN_REMDRV $BASEDIR_OPT $modname >/dev/null 2>&1
fi
# for remote installs, don't bother with return values of rem_drv
- if test "$?" -eq 0 || test "$REMOTEINST" -eq 1; then
- subprint "Removed: $moddesc driver"
+ if test $? -eq 0; then
+ subprint "Removed: $moddesc module"
return 0
else
subprint "Removing: $moddesc ...FAILED!"
- if test "x$fatal" = "x$FATALOP"; then
+ if test "$fatal" = "$FATALOP"; then
exit 1
fi
return 1
@@ -538,14 +542,14 @@
modid=`$BIN_MODINFO | grep "$modname " | cut -f 1 -d ' ' `
if test -n "$modid"; then
$BIN_MODUNLOAD -i $modid
- if test "$?" -eq 0; then
+ if test $? -eq 0; then
subprint "Unloaded: $moddesc module"
else
#
# Hack for vboxdrv. Delayed removing when VMM thread-context hooks are used.
# Our automated tests are probably too quick... Fix properly later.
#
- result="$?"
+ result=$?
if test "$retry" -eq 1; then
cmax=15
cslept=0
@@ -558,13 +562,13 @@
break
fi
$BIN_MODUNLOAD -i $modid
- result="$?"
+ result=$?
done
fi
if test "$result" -ne 0; then
subprint "Unloading: $moddesc module ...FAILED!"
- if test "x$fatal" = "x$FATALOP"; then
+ if test "$fatal" = "$FATALOP"; then
exit 1
fi
else
@@ -595,11 +599,12 @@
moddesc=$2
fatal=$3
$BIN_MODLOAD -p $modname
- if test "$?" -eq 0; then
+ if test $? -eq 0; then
+ subprint "Loaded: $moddesc module"
return 0
else
- subprint "Loading: $moddesc module ...FAILED!"
- if test "x$fatal" = "x$FATALOP"; then
+ subprint "Loading: $moddesc ...FAILED!"
+ if test "$fatal" = "$FATALOP"; then
exit 1
fi
return 1
@@ -633,7 +638,7 @@
install_drivers()
{
if test -f "$DIR_CONF/vboxdrv.conf"; then
- if test -n "_HARDENED_"; then
+ if test -n ""; then
add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0600 root sys','vboxdrvu 0666 root sys'"
else
add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0666 root sys','vboxdrvu 0666 root sys'"
@@ -658,7 +663,7 @@
# Create the device link for non-remote installs (not really relevant any more)
if test "$REMOTEINST" -eq 0; then
/usr/sbin/devfsadm -i "$MOD_VBOXDRV"
- if test "$?" -ne 0 || test ! -h "/dev/vboxdrv" || test ! -h "/dev/vboxdrvu" ; then
+ if test $? -ne 0 || test ! -h "/dev/vboxdrv" || test ! -h "/dev/vboxdrvu" ; then
errorprint "Failed to create device link for $MOD_VBOXDRV."
exit 1
fi
@@ -686,9 +691,7 @@
load_vboxbow
else
# If host is S10 or S11 (< snv_159) or vboxbow isn't shipped, then load vboxflt
- if test "$HOST_OS_MAJORVERSION" -eq 10 \
- || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -lt 159) \
- || test ! -f "$DIR_CONF/vboxbow.conf"; then
+ if test "$HOST_OS_MAJORVERSION" -eq 10 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -lt 159) || test ! -f "$DIR_CONF/vboxbow.conf"; then
load_vboxflt
else
# For S11 snv_159+ load vboxbow
@@ -697,22 +700,23 @@
fi
# Load VBoxUSBMon, VBoxUSB
- try_vboxusb="no"
- if test -f "$DIR_CONF/vboxusbmon.conf"; then
+ try_vboxusb=no
if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxusb"; then
subprint "Detected: Force-load file $PKG_INSTALL_ROOT/etc/vboxinst_vboxusb."
- try_vboxusb="yes"
+ try_vboxusb=yes
else
+ if test -f "$DIR_CONF/vboxusbmon.conf" && test "$HOST_OS_MAJORVERSION" != "10"; then
# For VirtualBox 3.1 the new USB code requires Nevada > 123 i.e. S12+ or S11 b124+
- if test "$HOST_OS_MAJORVERSION" -gt 11 \
- || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -gt 123); then
- try_vboxusb="yes"
+ if test "$HOST_OS_MAJORVERSION" -gt 11 || \
+ (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -gt 123); then
+ try_vboxusb=yes
else
warnprint "Solaris 11 build 124 or higher required for USB support. Skipped installing USB support."
fi
fi
fi
- if test "x$try_vboxusb" = "xyes"; then
+
+ if test "$try_vboxusb" = yes ; then
# Add a group "vboxuser" (8-character limit) for USB access.
# All users which need host USB-passthrough support will have to be added to this group.
groupadd vboxuser >/dev/null 2>&1
@@ -730,7 +734,7 @@
# Create the device link for non-remote installs
if test "$REMOTEINST" -eq 0; then
/usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
- if test "$?" -ne 0; then
+ if test $? -ne 0; then
errorprint "Failed to create device link for $MOD_VBOXUSBMON."
exit 1
fi
@@ -873,9 +877,9 @@
exit 1
fi
- procname="$1"
- $BIN_PGREP "$procname" > /dev/null 2>&1
- if test "$?" -eq 0; then
+ procname=$1
+ procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
+ if test ! -z "$procpid" && test "$procpid" -ge 0; then
return 1
fi
return 0
@@ -891,15 +895,16 @@
exit 1
fi
- procname="$1"
- is_process_running "$procname"
- if test "$?" -eq 1; then
+ # @todo use is_process_running()
+ procname=$1
+ procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
+ if test ! -z "$procpid" && test "$procpid" -ge 0; then
$BIN_PKILL "$procname"
sleep 2
- is_process_running "$procname"
- if test "$?" -eq 1; then
+ procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
+ if test ! -z "$procpid" && test "$procpid" -ge 0; then
subprint "Terminating: $procname ...FAILED!"
- if test "x$fatal" = "x$FATALOP"; then
+ if test "$fatal" = "$FATALOP"; then
exit 1
fi
else
@@ -925,7 +930,7 @@
success=0
$BIN_SVCS "$3" >/dev/null 2>&1
- while test "$?" -ne 0;
+ while test $? -ne 0;
do
sleep 1
cslept=`expr $cslept + 1`
@@ -938,10 +943,10 @@
if test "$success" -eq 0; then
$BIN_SVCADM enable -s "$3"
if test "$?" -eq 0; then
- subprint "Enabled: $1"
+ subprint "Loaded: $1"
return 0
else
- warnprint "Enabling $1 ...FAILED."
+ warnprint "Loading $1 ...FAILED."
warnprint "Refer $4 for details."
fi
else
@@ -966,136 +971,40 @@
# Don't delete the manifest, this is handled by the manifest class action
# $BIN_SVCCFG delete "$3"
if test "$?" -eq 0; then
- subprint "Disabled: $1"
+ subprint "Unloaded: $1"
else
- subprint "Disabling: $1 ...ERROR(S)."
+ subprint "Unloading: $1 ...ERROR(S)."
fi
fi
}
-# plumb vboxnet0 instance
-# failure: non fatal
-plumb_net()
+# cleanup_install([fatal])
+# failure: depends on [fatal]
+cleanup_install()
{
- # S11 175a renames vboxnet0 as 'netX', undo this and rename it back (S12+ or S11 b175+)
- if test "$HOST_OS_MAJORVERSION" -gt 11 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -gt 174); then
- vanityname=`dladm show-phys -po link,device | grep vboxnet0 | cut -f1 -d':'`
- if test "$?" -eq 0 && test ! -z "$vanityname" && test "x$vanityname" != "xvboxnet0"; then
- dladm rename-link "$vanityname" vboxnet0
- if test "$?" -ne 0; then
- errorprint "Failed to rename vanity interface ($vanityname) to vboxnet0"
- fi
- fi
- fi
-
- # use ipadm for Solaris 12 and newer
- if test "$HOST_OS_MAJORVERSION" -ge 12; then
- $BIN_IPADM create-ip vboxnet0
- if test "$?" -eq 0; then
- $BIN_IPADM create-addr -T static -a local="192.168.56.1/24" "vboxnet0/v4addr"
- if test "$?" -eq 0; then
- subprint "Configured: NetAdapter 'vboxnet0'"
- else
- warnprint "Failed to create local address for vboxnet0!"
- fi
- else
- warnprint "Failed to create IP instance for vboxnet0!"
- fi
- else
- $BIN_IFCONFIG vboxnet0 plumb
- $BIN_IFCONFIG vboxnet0 up
- if test "$?" -eq 0; then
- $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
-
- # /etc/netmasks is a symlink, older installers replaced this with
- # a copy of the actual file, repair that behaviour here.
- recreatelink=0
- if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
- nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
- else
- nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
- recreatelink=1
- fi
-
- # add the netmask to stay persistent across host reboots
- nmaskbackupfile=$nmaskfile.vbox
- if test -f $nmaskfile; then
- sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
-
- if test "$recreatelink" -eq 1; then
- # Check after removing our settings if /etc/netmasks is identifcal to /etc/inet/netmasks
- anydiff=`diff $nmaskbackupfile "$PKG_INSTALL_ROOT/etc/inet/netmasks"`
- if test ! -z "$anydiff"; then
- # User may have some custom settings in /etc/netmasks, don't overwrite /etc/netmasks!
- recreatelink=2
- fi
- fi
-
- echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
- inst=0
- networkn=56
- while test "$inst" -ne 1; do
- echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
- inst=`expr $inst + 1`
- networkn=`expr $networkn + 1`
- done
- echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
- mv -f $nmaskbackupfile $nmaskfile
+ fatal=$1
- # Recreate /etc/netmasks as a link if necessary
- if test "$recreatelink" -eq 1; then
- cp -f "$PKG_INSTALL_ROOT/etc/netmasks" "$PKG_INSTALL_ROOT/etc/inet/netmasks"
- ln -sf ./inet/netmasks "$PKG_INSTALL_ROOT/etc/netmasks"
- elif test "$recreatelink" -eq 2; then
- warnprint "/etc/netmasks is a symlink (to /etc/inet/netmasks) that older"
- warnprint "VirtualBox installers incorrectly overwrote. Now the contents"
- warnprint "of /etc/netmasks and /etc/inet/netmasks differ, therefore "
- warnprint "VirtualBox will not attempt to overwrite /etc/netmasks as a"
- warnprint "symlink to /etc/inet/netmasks. Please resolve this manually"
- warnprint "by updating /etc/inet/netmasks and creating /etc/netmasks as a"
- warnprint "symlink to /etc/inet/netmasks"
- fi
- fi
- else
- # Should this be fatal?
- warnprint "Failed to bring up vboxnet0!"
- fi
+ # No-Op for remote installs
+ if test "$REMOTEINST" -eq 1; then
+ return 0
fi
-}
+ # stop the services
+ stop_service "Web service" "virtualbox/webservice" "svc:/application/virtualbox/webservice:default"
+ stop_service "Balloon control service" "virtualbox/balloonctrl" "svc:/application/virtualbox/balloonctrl:default"
+ stop_service "Autostart service" "virtualbox/autostart" "svc:/application/virtualbox/autostart:default"
+ stop_service "Zone access service" "virtualbox/zoneaccess" "svc:/application/virtualbox/zoneaccess:default"
-# unplumb all vboxnet instances
-# failure: fatal
-unplumb_net()
-{
- inst=0
- # use ipadm for Solaris 12 and newer
- if test "$HOST_OS_MAJORVERSION" -ge 12; then
- while test "$inst" -ne $MOD_VBOXNET_INST; do
- vboxnetup=`$BIN_IPADM show-addr -p -o addrobj vboxnet$inst >/dev/null 2>&1`
- if test "$?" -eq 0; then
- $BIN_IPADM delete-addr vboxnet$inst/v4addr
- $BIN_IPADM delete-ip vboxnet$inst
- if test "$?" -ne 0; then
- errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be removed (probably in use)."
- if test "x$fatal" = "x$FATALOP"; then
- exit 1
- fi
- fi
- fi
-
- inst=`expr $inst + 1`
- done
- else
+ # unplumb all vboxnet instances for non-remote installs
inst=0
- while test "$inst" -ne $MOD_VBOXNET_INST; do
+ while test $inst -ne $MOD_VBOXNET_INST; do
vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
if test "$?" -eq 0; then
$BIN_IFCONFIG vboxnet$inst unplumb
if test "$?" -ne 0; then
errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
- if test "x$fatal" = "x$FATALOP"; then
+ if test "$fatal" = "$FATALOP"; then
exit 1
fi
fi
@@ -1107,7 +1016,7 @@
$BIN_IFCONFIG vboxnet$inst inet6 unplumb
if test "$?" -ne 0; then
errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
- if test "x$fatal" = "x$FATALOP"; then
+ if test "$fatal" = "$FATALOP"; then
exit 1
fi
fi
@@ -1115,36 +1024,6 @@
inst=`expr $inst + 1`
done
- fi
-}
-
-
-# cleanup_install([fatal])
-# failure: depends on [fatal]
-cleanup_install()
-{
- fatal=$1
-
- # No-Op for remote installs
- if test "$REMOTEINST" -eq 1; then
- return 0
- fi
-
- # stop the services
- stop_service "Web service" "virtualbox/webservice" "svc:/application/virtualbox/webservice:default"
- stop_service "Balloon control service" "virtualbox/balloonctrl" "svc:/application/virtualbox/balloonctrl:default"
- stop_service "Autostart service" "virtualbox/autostart" "svc:/application/virtualbox/autostart:default"
- stop_service "Zone access service" "virtualbox/zoneaccess" "svc:/application/virtualbox/zoneaccess:default"
-
- # DEBUG x4600b: verify that the ZoneAccess process is really gone
- is_process_running "VBoxZoneAccess"
- if test "$?" -eq 1; then
- warnprint "VBoxZoneAccess is alive despite its service being dead. Killing..."
- stop_process "VBoxZoneAccess"
- fi
-
- # unplumb all vboxnet instances for non-remote installs
- unplumb_net
# Stop our other daemons, non-fatal
stop_process "VBoxNetDHCP"
@@ -1189,20 +1068,6 @@
postinstall()
{
infoprint "Detected Solaris $HOST_OS_MAJORVERSION Version $HOST_OS_MINORVERSION"
-
- # Install the S10 legacy library links.
- # We do this early so that when we invoke services or other VirtualBox processes, the dependent libraries are resolved.
- if test -d "/opt/VirtualBox/legacy/"; then
- if test "$HOST_OS_MAJORVERSION" -eq 10; then
- for lib in `ls -1 /opt/VirtualBox/legacy/`; do
- /usr/sbin/installf -c none $PKGINST /opt/VirtualBox/$lib=legacy/$lib s
- done
- for lib in `ls -1 /opt/VirtualBox/amd64/legacy/`; do
- /usr/sbin/installf -c none $PKGINST /opt/VirtualBox/amd64/$lib=legacy/$lib s
- done
- fi
- fi
-
infoprint "Loading VirtualBox kernel modules..."
install_drivers
@@ -1217,7 +1082,7 @@
# add all vboxnet instances as static to nwam
inst=0
networkn=56
- while test "$inst" -ne 1; do
+ while test $inst -ne 1; do
echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
inst=`expr $inst + 1`
networkn=`expr $networkn + 1`
@@ -1227,7 +1092,75 @@
# plumb and configure vboxnet0 for non-remote installs
if test "$REMOTEINST" -eq 0; then
- plumb_net
+ # S11 175a renames vboxnet0 as 'netX', undo this and rename it back (S12+ or S11 b175+)
+ if test "$HOST_OS_MAJORVERSION" -gt 11 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -gt 174); then
+ vanityname=`dladm show-phys -po link,device | grep vboxnet0 | cut -f1 -d':'`
+ if test $? -eq 0 && test ! -z "$vanityname" && test "$vanityname" != "vboxnet0"; then
+ dladm rename-link "$vanityname" vboxnet0
+ if test $? -ne 0; then
+ errorprint "Failed to rename vanity interface ($vanityname) to vboxnet0"
+ fi
+ fi
+ fi
+
+ $BIN_IFCONFIG vboxnet0 plumb
+ $BIN_IFCONFIG vboxnet0 up
+ if test "$?" -eq 0; then
+ $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
+
+ # /etc/netmasks is a symlink, older installers replaced this with
+ # a copy of the actual file, repair that behaviour here.
+ recreatelink=0
+ if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
+ nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
+ else
+ nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
+ recreatelink=1
+ fi
+
+ # add the netmask to stay persistent across host reboots
+ nmaskbackupfile=$nmaskfile.vbox
+ if test -f $nmaskfile; then
+ sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
+
+ if test $recreatelink -eq 1; then
+ # Check after removing our settings if /etc/netmasks is identifcal to /etc/inet/netmasks
+ anydiff=`diff $nmaskbackupfile "$PKG_INSTALL_ROOT/etc/inet/netmasks"`
+ if test ! -z "$anydiff"; then
+ # User may have some custom settings in /etc/netmasks, don't overwrite /etc/netmasks!
+ recreatelink=2
+ fi
+ fi
+
+ echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
+ inst=0
+ networkn=56
+ while test $inst -ne 1; do
+ echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
+ inst=`expr $inst + 1`
+ networkn=`expr $networkn + 1`
+ done
+ echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
+ mv -f $nmaskbackupfile $nmaskfile
+
+ # Recreate /etc/netmasks as a link if necessary
+ if test $recreatelink -eq 1; then
+ cp -f "$PKG_INSTALL_ROOT/etc/netmasks" "$PKG_INSTALL_ROOT/etc/inet/netmasks"
+ ln -sf ./inet/netmasks "$PKG_INSTALL_ROOT/etc/netmasks"
+ elif test $recreatelink -eq 2; then
+ warnprint "/etc/netmasks is a symlink (to /etc/inet/netmasks) that older"
+ warnprint "VirtualBox installers incorrectly overwrote. Now the contents"
+ warnprint "of /etc/netmasks and /etc/inet/netmasks differ, therefore "
+ warnprint "VirtualBox will not attempt to overwrite /etc/netmasks as a"
+ warnprint "symlink to /etc/inet/netmasks. Please resolve this manually"
+ warnprint "by updating /etc/inet/netmasks and creating /etc/netmasks as a"
+ warnprint "symlink to /etc/inet/netmasks"
+ fi
+ fi
+ else
+ # Should this be fatal?
+ warnprint "Failed to bring up vboxnet0!!"
+ fi
fi
fi
@@ -1286,17 +1219,12 @@
if test "$?" -eq 0; then
INSTALLEDIT=0
fi
- PYTHONBIN=`which python2.7 2>/dev/null`
- install_python_bindings "$PYTHONBIN" "Python 2.7"
- if test "$?" -eq 0; then
- INSTALLEDIT=0
- fi
# remove files installed by Python build
rm -rf $DIR_VBOXBASE/sdk/installer/build
if test "$INSTALLEDIT" -ne 0; then
- warnprint "No suitable Python version found. Required Python 2.4, 2.5, 2.6 or 2.7"
+ warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
warnprint "Skipped installing the Python bindings."
fi
else
gdiff -Nurb VirtualBox-5.1.6/kBuild/env.sh VirtualBox-5.1.6/kBuild/env.sh
--- VirtualBox-5.1.6/kBuild/env.sh 2011-10-01 19:49:54.000000000 +0000
+++ VirtualBox-5.1.6/kBuild/env.sh 2016-09-18 15:58:30.800398219 +0000
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# $Id: env.sh 2546 2011-10-01 19:49:54Z bird $
## @file
# Environment setup script.
@@ -29,6 +29,9 @@
#
# Check if we're in eval mode or not.
#
+export PATH=/usr/gnu/bin:/usr/lib/qt/4.8/bin:/usr/bin:/sbin:/usr/sbin:$PATH
+export LD_OPTIONS="-L/lib/amd64 -R/lib/amd64 -L/usr/lib/amd64 -R/usr/lib/amd64 -L/usr/lib/qt/4.8/lib/amd64 -R/usr/lib/qt/4.8/lib/amd64"
+
ERR_REDIR=1
DBG_REDIR=1
EVAL_OPT=
gdiff -Nurb VirtualBox-5.1.6/src/VBox/Additions/solaris/Makefile.kmk VirtualBox-5.1.6/src/VBox/Additions/solaris/Makefile.kmk
--- VirtualBox-5.1.6/src/VBox/Additions/solaris/Makefile.kmk 2016-09-12 16:11:48.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/Additions/solaris/Makefile.kmk 2016-09-18 10:44:24.768170175 +0000
@@ -331,7 +331,7 @@
$(QUIET)$(INSTALL) -m 0644 $(PATH_ROOT)/src/VBox/Additions/solaris/Mouse/vboxmslnk.xml $(SOLARIS_ADD_SERVICESINST_DIR)/vboxmslnk.xml
$(QUIET)$(SOLARIS_ADDINST_OUT_DIR)/makepackage.sh $(SOLARIS_ADDINST_OUT_DIR) $(PKGFILENAME) $(VBOX_SVN_REV) $(VBOX_SOL_PKG_DEV)
$(QUIET)$(INSTALL) -m 0644 $(SOLARIS_ADDINST_OUT_DIR)/$(PKGFILENAME) $(PATH_STAGE_BIN)/additions/$(PKGFILENAME)
- $(QUIET)$(RM) -f $(SOLARIS_ADDINST_OUT_DIR)/$(PKGFILENAME)
+ #####$(QUIET)$(RM) -f $(SOLARIS_ADDINST_OUT_DIR)/$(PKGFILENAME)
gdiff -Nurb VirtualBox-5.1.6/src/VBox/Installer/solaris/Makefile.kmk VirtualBox-5.1.6/src/VBox/Installer/solaris/Makefile.kmk
--- VirtualBox-5.1.6/src/VBox/Installer/solaris/Makefile.kmk 2016-09-12 16:18:39.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/Installer/solaris/Makefile.kmk 2016-09-18 10:12:06.757261807 +0000
@@ -719,7 +719,7 @@
$(KBUILD_TARGET_ARCH) \
$(VBOX_SVN_REV)
$(MV) -- "$(VBOX_PATH_SI_SCRATCH_PKG)/$(PKG_FILENAME).pkg" "$@"
- $(RM) -Rf -- "$(VBOX_PATH_SI_SCRATCH_PKG)/"
+##### $(RM) -Rf -- "$(VBOX_PATH_SI_SCRATCH_PKG)/"
#
@@ -767,8 +767,14 @@
$(VBOX_SI_DEP_ON_MAKEFILE) \
$(foreach var, $(SOLARIS_FILE_LIST_DBGINFO_VARS), $(foreach file, $($(var)), $($(var).SRC)/$(file)))
$(call MSG_L1,Preparing $@)
- $(RM) -Rf -- "$(VBOX_PATH_SI_SCRATCH_DBG)/"
- $(RM) -f -- "$@"
+##### $(RM) -Rf -- "$(VBOX_PATH_SI_SCRATCH_DBG)/"
+##### $(RM) -f -- "$@"
+ rm -Rf $(VBOX_PATH_SOL_INST_SRC)/../../../../../prototype/i386
+ ln -s $(VBOX_PATH_SOL_INST_SRC)/../../../../../amd64/out/solaris.amd64/release/obj/Installer-solaris/pkg $(VBOX_PATH_SOL_INST_SRC)/../../../../../prototype/i386
+ rm -Rf $(VBOX_PATH_SOL_INST_SRC)/../../../../../prototype/i386/AdditionsInstaller
+ ln -s $(VBOX_PATH_SOL_INST_SRC)/../../../../../amd64/out/solaris.amd64/release/obj/AdditionsInstaller $(VBOX_PATH_SOL_INST_SRC)/../../../../../prototype/i386
+ cp $(VBOX_PATH_SOL_INST_SRC)/../../../../../../boot_logo.bmp $(VBOX_PATH_SOL_INST_SRC)/../../../../../amd64/src/VBox/Devices/Graphics/BIOS/ose_logo.bmp
+ cp $(VBOX_PATH_SOL_INST_SRC)/../../../../../../boot_logo.bmp $(VBOX_PATH_SOL_INST_SRC)/../../../../../amd64/src/VBox/Devices/EFI/Firmware/VBoxPkg/Logo/boot_logo.bmp
$(MKDIR) -p -m 0755 \
$(VBOX_PATH_SI_SCRATCH_DBG)/ \
$(sort $(foreach var, $(SOLARIS_FILE_LIST_DBGINFO_VARS), $($(var).DBGDST)/ $(if-expr "$($(var).SUBDIRS)" == "yes" \
@@ -780,5 +786,5 @@
-cvjRhf "$@" -C "$(VBOX_PATH_SI_SCRATCH_DBG)/.." "./$(notdir $(VBOX_PATH_SI_SCRATCH_DBG))/"
$(QUIET)$(CHMOD) 0644 $@
$(call MSG_L1,Packaging $@ is completed.)
- $(RM) -Rf "$(VBOX_PATH_SI_SCRATCH_DBG)/"
+##### $(RM) -Rf "$(VBOX_PATH_SI_SCRATCH_DBG)/"
gdiff -Nurb VirtualBox-5.1.6/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.cpp VirtualBox-5.1.6/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.cpp
--- VirtualBox-5.1.6/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.cpp 2016-08-16 19:59:59.000000000 +0000
+++ VirtualBox-5.1.6/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.cpp 2016-09-16 17:36:45.704977784 +0000
@@ -1178,7 +1178,7 @@
AssertPtrReturn(pLogViewer, 0);
{
/* Configure Log-Viewer: */
-#if defined(RT_OS_SOLARIS)
+#if defined(RT_OS_ORACLESOLARIS)
/* Use system fixed-width font on Solaris hosts as the Courier family fonts don't render well. */
QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
#else
Regards,
%martin
>Четверг, 22 сентября 2016, 8:02 UTC от Carl Brewer <carl at bl.echidna.id.au>:
>
>
>G'day,
>
>I'm playing around with Martin's Virtualbox port, on OI Hipster most
>recent, and the box has no head, so .. vncserver!
>
>root at dumper:~/VBox# uname -a
>SunOS dumper 5.11 illumos-380fd67 i86pc i386 i86pc
>
>Trying to run vncserver :
>
>root at dumper:~/VBox# vncserver
>
>WARNING: The first attempt to start Xvnc failed, possibly because the font
>catalog is not properly configured. Attempting to determine an appropriate
>font path for this system and restart Xvnc using that font path ...
>Could not start Xvnc.
>
>
>Xvnc TigerVNC 1.1.0
>Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
>See http://www.tigervnc.org for information on TigerVNC.
>Underlying X server release 11407000, The X.Org Foundation
>
>Initializing built-in extension Generic Event Extension
>Initializing built-in extension SHAPE
>Initializing built-in extension MIT-SHM
>Initializing built-in extension XInputExtension
>Initializing built-in extension XTEST
>Initializing built-in extension BIG-REQUESTS
>Initializing built-in extension SYNC
>Initializing built-in extension XKEYBOARD
>Initializing built-in extension XC-MISC
>Initializing built-in extension SECURITY
>Initializing built-in extension XINERAMA
>Initializing built-in extension XFIXES
>Initializing built-in extension RENDER
>Initializing built-in extension RANDR
>Initializing built-in extension COMPOSITE
>Initializing built-in extension DAMAGE
>Initializing built-in extension MIT-SCREEN-SAVER
>Initializing built-in extension DOUBLE-BUFFER
>Initializing built-in extension RECORD
>Initializing built-in extension DPMS
>Initializing built-in extension VNC
>Initializing built-in extension X-Resource
>Initializing built-in extension SolarisIA
>Initializing built-in extension SUN_TSOL
>Initializing built-in extension XVideo
>Initializing built-in extension XVideo-MotionCompensation
>
>Thu Sep 22 17:57:06 2016
> vncext: VNC extension running!
> vncext: Listening for VNC connections on all interface(s), port 5901
> vncext: created VNC server for screen 0
>XKB: Failed to compile keymap
>Keyboard initialization failed. This could be a missing or incorrect
>setup of xkeyboard-config.
>(EE)
>Fatal server error:
>(EE) Failed to activate core devices.(EE)
>
>Xvnc TigerVNC 1.1.0
>Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
>See http://www.tigervnc.org for information on TigerVNC.
>Underlying X server release 11407000, The X.Org Foundation
>
>Initializing built-in extension Generic Event Extension
>Initializing built-in extension SHAPE
>Initializing built-in extension MIT-SHM
>Initializing built-in extension XInputExtension
>Initializing built-in extension XTEST
>Initializing built-in extension BIG-REQUESTS
>Initializing built-in extension SYNC
>Initializing built-in extension XKEYBOARD
>Initializing built-in extension XC-MISC
>Initializing built-in extension SECURITY
>Initializing built-in extension XINERAMA
>Initializing built-in extension XFIXES
>Initializing built-in extension RENDER
>Initializing built-in extension RANDR
>Initializing built-in extension COMPOSITE
>Initializing built-in extension DAMAGE
>Initializing built-in extension MIT-SCREEN-SAVER
>Initializing built-in extension DOUBLE-BUFFER
>Initializing built-in extension RECORD
>Initializing built-in extension DPMS
>Initializing built-in extension VNC
>Initializing built-in extension X-Resource
>Initializing built-in extension SolarisIA
>Initializing built-in extension SUN_TSOL
>Initializing built-in extension XVideo
>Initializing built-in extension XVideo-MotionCompensation
>
>Thu Sep 22 17:57:09 2016
> vncext: VNC extension running!
> vncext: Listening for VNC connections on all interface(s), port 5901
> vncext: created VNC server for screen 0
>XKB: Failed to compile keymap
>Keyboard initialization failed. This could be a missing or incorrect
>setup of xkeyboard-config.
>(EE)
>Fatal server error:
>(EE) Failed to activate core devices.(EE)
>
>
>
>so, I've got something missing - I've been googling around and trying
>to find out what might be missing, xkeyboard-config seems to be it? As
>best I can tell I have all the x11 pkgs installed :
>
>pkg list | grep -i x11 | more
>benchmark/x11perf 1.5.4-2015.0.2.0 i--
>x11/bdftopcf 1.0.5-2015.0.1.0 i--
>x11/colormap-utilities 7.5-2013.0.0.0 i--
>x11/compatibility/links-xorg 0.5.11-2013.0.0.0 i--
>x11/data/workspace-patterns 0.5.11-2013.0.0.0 i--
>x11/data/xbitmaps 1.1.0-2013.0.0.0 i--
>x11/demo 7.5-2015.0.1.0 i--
>x11/diagnostic/x11-info-clients 7.5-2013.0.0.0 i--
>x11/font-util 1.3.1-2015.0.1.0 i--
>x11/font-utilities 7.5-2015.0.1.0 i--
>x11/header/bigreqsproto 1.1.2-2015.0.0.0 i--
>x11/header/compositeproto 0.4.2-2015.0.0.0 i--
>x11/header/damageproto 1.2.1-2015.0.0.0 i--
>x11/header/dmxproto 2.3.1-2015.0.0.0 i--
>x11/header/dri2proto 2.8-2015.0.0.0 i--
>x11/header/evieext 1.1.1-2015.0.0.0 i--
>x11/header/fixesproto 5.0-2015.0.0.0 i--
>x11/header/fontcacheproto 0.1.2-2015.0.0.0 i--
>x11/header/fontsproto 2.1.3-2015.0.1.0 i--
>x11/header/glproto 1.4.17-2015.0.0.0 i--
>x11/header/inputproto 2.3.1-2015.0.0.0 i--
>x11/header/kbproto 1.0.6-2015.0.0.0 i--
>x11/header/printproto 1.0.5-2015.0.0.0 i--
>x11/header/randrproto 1.4.0-2015.0.0.0 i--
>x11/header/recordproto 1.14.2-2015.0.0.0 i--
>x11/header/renderproto 0.11.1-2015.0.0.0 i--
>x11/header/resourceproto 1.2.0-2015.0.0.0 i--
>x11/header/scrnsaverproto 1.2.2-2015.0.0.0 i--
>x11/header/sun-ext-protos 0.1-2015.0.0.0 i--
>x11/header/videoproto 2.3.2-2015.0.0.0 i--
>x11/header/x11-protocols 7.5-2015.0.0.0 i--
>x11/header/xcb-protocols 1.11-2015.0.0.0 i--
>x11/header/xcmiscproto 1.2.2-2015.0.0.0 i--
>x11/header/xextproto 7.3.0-2015.0.0.0 i--
>x11/header/xf86bigfontproto 1.2.0-2015.0.0.0 i--
>x11/header/xf86dgaproto 2.1-2015.0.0.0 i--
>x11/header/xf86driproto 2.1.1-2015.0.0.0 i--
>x11/header/xf86miscproto 0.9.3-2015.0.0.0 i--
>x11/header/xf86vidmodeproto 2.3.1-2015.0.0.0 i--
>x11/header/xineramaproto 1.2.1-2015.0.0.0 i--
>x11/header/xproto 7.0.28-2015.0.1.0 i--
>x11/header/xproxymanagementprotocol 1.0.3-2015.0.0.0 i--
>x11/ico 1.0.4-2015.0.1.0 i--
>x11/installalias 0.5.11-2015.0.1.0 i--
>x11/keyboard/xkb-utilities 7.5-2013.0.0.0 i--
>x11/library/dps 7.5-2013.0.0.0 i--
>x11/library/libdga 0.5.11-2013.0.0.0 i--
>x11/library/libfontenc 1.0.5-2013.0.0.0 i--
>x11/library/libfs 1.0.2-2013.0.0.0 i--
>x11/library/libice 1.0.9-2015.0.1.0 i--
>x11/library/libowconfig 0.5.11-2013.0.0.0 i--
>x11/library/libsm 1.0.3-2013.0.0.0 i--
>x11/library/libx11 1.6.3-2015.0.1.0 i--
>x11/library/libxau 1.0.6-2013.0.0.0 i--
>x11/library/libxcb
>
>x11/library/libxcomposite 0.4.2-2013.0.0.0 i--
>x11/library/libxcursor 1.1.10-2013.0.0.0 i--
>x11/library/libxdamage 1.1.3-2013.0.0.0 i--
>x11/library/libxdmcp 1.0.3-2015.0.0.0 i--
>x11/library/libxevie 1.0.2-2013.0.0.0 i--
>x11/library/libxext 1.3.3-2015.0.1.0 i--
>x11/library/libxfixes 5.0.1-2015.0.2.0 i--
>x11/library/libxfont 1.4.9-2015.0.2.2 i--
>x11/library/libxft 2.3.2-2015.0.1.0 i--
>x11/library/libxi 1.7.6-2015.0.2.0 i--
>x11/library/libxinerama 1.1-2013.0.0.0 i--
>x11/library/libxkbfile 1.0.6-2013.0.0.0 i--
>x11/library/libxmu 1.1.2-2015.0.2.0 i--
>x11/library/libxmuu 1.1.2-2015.0.2.0 i--
>x11/library/libxp 1.0.0-2013.0.0.0 i--
>x11/library/libxpm 3.5.8-2013.0.0.0 i--
>x11/library/libxrandr 1.3.0-2013.0.0.0 i--
>x11/library/libxrender 0.9.6-2013.0.0.0 i--
>x11/library/libxres 1.0.4-2013.0.0.0 i--
>x11/library/libxscrnsaver 1.2.0-2013.0.0.0 i--
>x11/library/libxtst 1.1.0-2013.0.0.0 i--
>x11/library/libxv 1.0.5-2013.0.0.0 i--
>x11/library/libxvmc 1.0.6-2013.0.0.0 i--
>x11/library/libxxf86misc 1.0.2-2013.0.0.0 i--
>x11/library/libxxf86vm 1.1.0-2013.0.0.0 i--
>x11/library/toolkit/libxaw4 0.5.11-2013.0.0.0 i--
>x11/library/toolkit/libxaw5 0.5.11-2013.0.0.0 i--
>x11/library/toolkit/libxaw7 1.0.7-2013.0.0.0 i--
>x11/library/toolkit/libxt 1.0.8-2013.0.0.0 i--
>x11/library/xtrans 1.3.5-2015.0.1.0 i--
>x11/mkfontdir 1.0.7-2015.0.1.0 i--
>x11/mkfontscale 1.1.2-2015.0.1.0 i--
>x11/network/rstart 1.0.3-2013.0.0.0 i--
>x11/server/xserver-common 1.14.7-2015.0.1.0 i--
>x11/server/xvnc 1.1.0-2015.0.2.1 i--
>x11/session/mkcookie 0.5.11-2015.0.1.0 i--
>x11/session/sessreg 1.0.6-2013.0.0.0 i--
>x11/session/smproxy 1.0.3-2013.0.0.0 i--
>x11/session/winsysck 0.5.11-2013.0.0.0 i--
>x11/session/xauth 1.0.7-2015.0.1.0 i--
>x11/session/xinit 1.2.1-2013.0.0.0 i--
>x11/trusted/libxtsol 0.5.11-2015.0.1.0 i--
>x11/x11-server-utilities 7.5-2013.0.0.0 i--
>x11/x11-window-dump 1.0.3-2013.0.0.0 i--
>x11/xcalc 1.0.3-2013.0.0.0 i--
>x11/xeyes 1.1.1-2015.0.1.0 i--
>x11/xfd 1.1.2-2015.0.1.0 i--
>x11/xfs 1.1.4-2015.0.1.0 i--
>x11/xfs/xfs-utilities 7.5-2013.0.0.0 i--
>x11/xgc 1.0.5-2015.0.1.0 i--
>x11/xkill 1.0.2-2013.0.0.0 i--
>x11/xlock 0.5.11-2013.0.0.0 i--
>x11/xlogo 1.0.4-2015.0.1.0 i--
>x11/xmag 1.0.3-2013.0.0.0 i--
>x11/xvidtune 1.0.2-2013.0.0.0 i--
>
>something's either not installed OR not started, but what?
>
>Can anyone here beat me with a cluestick? My Solaris/OI foo is very rusty!
>
>Thank you,
>
>Carl
>
>
>
>
>
>
>_______________________________________________
>openindiana-discuss mailing list
>openindiana-discuss at openindiana.org
>https://openindiana.org/mailman/listinfo/openindiana-discuss
More information about the openindiana-discuss
mailing list